Snapshot aea001abfc1b38fec3a821bcd5174cc77dc75787 from master branch of git://git.jetbrains.org/idea/community.git
Change-Id: Icdea2a2bd7ad43b4d05967b1f0479db3bda1c93c
diff --git a/.gitignore b/.gitignore
index 5c411af..1589896 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,5 +3,5 @@
.idea/workspace.xml
/out
.DS_Store
-bin/build.log
-bin/build-log.xml
+/test-system
+/test-config
diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml
index 3bb1d82..0b13401 100644
--- a/.idea/codeStyleSettings.xml
+++ b/.idea/codeStyleSettings.xml
@@ -251,6 +251,10 @@
<option name="FOR_BRACE_FORCE" value="1" />
<option name="PARENT_SETTINGS_INSTALLED" value="true" />
</codeStyleSettings>
+ <codeStyleSettings language="Python">
+ <option name="KEEP_LINE_BREAKS" value="false" />
+ <option name="PARENT_SETTINGS_INSTALLED" value="true" />
+ </codeStyleSettings>
<codeStyleSettings language="SQL">
<option name="PARENT_SETTINGS_INSTALLED" value="true" />
</codeStyleSettings>
diff --git a/.idea/copyright/aosp.xml b/.idea/copyright/aosp.xml
deleted file mode 100644
index 077aec6..0000000
--- a/.idea/copyright/aosp.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<component name="CopyrightManager">
- <copyright>
- <option name="notice" value="Copyright (C) &#36;today.year The Android Open Source Project 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." />
- <option name="keyword" value="Copyright" />
- <option name="allowReplaceKeyword" value="" />
- <option name="myName" value="aosp" />
- <option name="myLocal" value="true" />
- </copyright>
-</component>
\ No newline at end of file
diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml
index c0df0b2..b84d8ef 100644
--- a/.idea/copyright/profiles_settings.xml
+++ b/.idea/copyright/profiles_settings.xml
@@ -1,8 +1,6 @@
<component name="CopyrightManager">
<settings default="apache 2 license">
- <module2copyright>
- <element module="aosp-code" copyright="aosp" />
- </module2copyright>
+ <module2copyright />
<LanguageOptions name="__TEMPLATE__">
<option name="addBlankAfter" value="false" />
</LanguageOptions>
diff --git a/.idea/dictionaries/adt.xml b/.idea/dictionaries/adt.xml
deleted file mode 100644
index e25bf25..0000000
--- a/.idea/dictionaries/adt.xml
+++ /dev/null
@@ -1,321 +0,0 @@
-<component name="ProjectDictionaryState">
- <dictionary name="adt">
- <words>
- <w>&amp</w>
- <w>aapt</w>
- <w>aarrggbb</w>
- <w>accessors</w>
- <w>actionbar</w>
- <w>adb's</w>
- <w>adbhost</w>
- <w>addon</w>
- <w>addons</w>
- <w>addr</w>
- <w>aidl</w>
- <w>aload</w>
- <w>androiddebugkey</w>
- <w>anim</w>
- <w>aosp</w>
- <w>apkbuilder</w>
- <w>apos</w>
- <w>appname</w>
- <w>areturn</w>
- <w>argb</w>
- <w>argv</w>
- <w>armeabi</w>
- <w>ast's</w>
- <w>async</w>
- <w>attrs</w>
- <w>autofocus</w>
- <w>automator</w>
- <w>avd's</w>
- <w>avdname</w>
- <w>backfill</w>
- <w>basename</w>
- <w>basenames</w>
- <w>bicubic</w>
- <w>bilinear</w>
- <w>bindir</w>
- <w>bipush</w>
- <w>bitcodelib</w>
- <w>bitmask</w>
- <w>blockquote</w>
- <w>bluetooth</w>
- <w>booleans</w>
- <w>bootloader</w>
- <w>borderless</w>
- <w>bytecode</w>
- <w>calloc</w>
- <w>charsets</w>
- <w>checkable</w>
- <w>chksum</w>
- <w>classfile</w>
- <w>classname</w>
- <w>classpathentry</w>
- <w>clinit</w>
- <w>clipart</w>
- <w>closeables</w>
- <w>codenames</w>
- <w>combineaccessrules</w>
- <w>compat</w>
- <w>configurables</w>
- <w>conv</w>
- <w>crlf</w>
- <w>crypto</w>
- <w>cygpath</w>
- <w>cygwin</w>
- <w>dalvik</w>
- <w>ddmlib</w>
- <w>ddms</w>
- <w>debuggable</w>
- <w>densityless</w>
- <w>designtime</w>
- <w>dest</w>
- <w>dexdump</w>
- <w>digester</w>
- <w>dimen</w>
- <w>dirname</w>
- <w>disp</w>
- <w>donottranslate</w>
- <w>dpad</w>
- <w>drawables</w>
- <w>dropdown</w>
- <w>dumpsys</w>
- <w>eabi</w>
- <w>easymock</w>
- <w>emdash</w>
- <w>endian</w>
- <w>enqueued</w>
- <w>errno</w>
- <w>executables</w>
- <w>expectedly</w>
- <w>filenames</w>
- <w>filepath</w>
- <w>fixme</w>
- <w>fqcn</w>
- <w>framebuffer</w>
- <w>frameworkdir</w>
- <w>froyo</w>
- <w>fwvga</w>
- <w>gbdserver</w>
- <w>gdbserver</w>
- <w>genkey</w>
- <w>getenv</w>
- <w>getfield</w>
- <w>getprop</w>
- <w>getstatic</w>
- <w>globbing</w>
- <w>goto</w>
- <w>gradle</w>
- <w>guide's</w>
- <w>guillemets</w>
- <w>hardcode</w>
- <w>hardcoding</w>
- <w>hashcode</w>
- <w>hdpi</w>
- <w>holo</w>
- <w>horiz</w>
- <w>httpclient</w>
- <w>hvga</w>
- <w>iaload</w>
- <w>iastore</w>
- <w>iconst</w>
- <w>inflater</w>
- <w>infos</w>
- <w>inlined</w>
- <w>innerclass</w>
- <w>inputfile</w>
- <w>insn</w>
- <w>instantiatable</w>
- <w>instrumentations</w>
- <w>intelli</w>
- <w>interpolator</w>
- <w>ints</w>
- <w>invokestatic</w>
- <w>invokevirtual</w>
- <w>ipsum</w>
- <w>ireturn</w>
- <w>iterable</w>
- <w>jarfile</w>
- <w>jarlist</w>
- <w>jarpath</w>
- <w>javabuilder</w>
- <w>javanature</w>
- <w>jdwp</w>
- <w>jpeg</w>
- <w>junit</w>
- <w>keepclasseswithmembernames</w>
- <w>keepclasseswithmembers</w>
- <w>keygen</w>
- <w>keypass</w>
- <w>keysexposed</w>
- <w>keyshidden</w>
- <w>keyssoft</w>
- <w>keystore</w>
- <w>keytool</w>
- <w>kxml</w>
- <w>landroid</w>
- <w>layoublib</w>
- <w>layoutlib</w>
- <w>layoutlibs</w>
- <w>layoutopt</w>
- <w>layoutrules</w>
- <w>ldltr</w>
- <w>ldpi</w>
- <w>ldrtl</w>
- <w>levenshtein</w>
- <w>lexing</w>
- <w>libc</w>
- <w>licensable</w>
- <w>licensor</w>
- <w>linenumber</w>
- <w>ljava</w>
- <w>lombok</w>
- <w>lookups</w>
- <w>lookupswitch</w>
- <w>looper</w>
- <w>lorem</w>
- <w>lpackage</w>
- <w>makefile</w>
- <w>malloc</w>
- <w>manifestmerger</w>
- <w>manifmerger</w>
- <w>mdpi</w>
- <w>memalign</w>
- <w>minsdk</w>
- <w>mipmap</w>
- <w>mkdirs</w>
- <w>monospace</w>
- <w>moreunit</w>
- <w>multimap</w>
- <w>multipart</w>
- <w>multitouch</w>
- <w>nano</w>
- <w>nativelib</w>
- <w>navexposed</w>
- <w>navhidden</w>
- <w>ninepatch</w>
- <w>nodpi</w>
- <w>nokeys</w>
- <w>nonav</w>
- <w>notlong</w>
- <w>notnight</w>
- <w>notouch</w>
- <w>nullable</w>
- <w>nulling</w>
- <w>nullness</w>
- <w>objectweb</w>
- <w>opcode</w>
- <w>opcodes</w>
- <w>pathname</w>
- <w>picasa</w>
- <w>plugin's</w>
- <w>png's</w>
- <w>prebuilts</w>
- <w>prefs</w>
- <w>preload</w>
- <w>prepending</w>
- <w>printf</w>
- <w>println</w>
- <w>proc</w>
- <w>prog</w>
- <w>progdir</w>
- <w>programmatically</w>
- <w>proguard</w>
- <w>prolog</w>
- <w>qemu</w>
- <w>quickfix</w>
- <w>quickstart</w>
- <w>qvga</w>
- <w>rasterize</w>
- <w>rasterizer</w>
- <w>realloc</w>
- <w>recurse</w>
- <w>reflow</w>
- <w>reformats</w>
- <w>reimplement</w>
- <w>renderscript</w>
- <w>reparse</w>
- <w>resampling</w>
- <w>resizability</w>
- <w>resized</w>
- <w>rrggbb</w>
- <w>sccs</w>
- <w>screenshot</w>
- <w>scroller</w>
- <w>scrollview</w>
- <w>sdcard</w>
- <w>sdk's</w>
- <w>sdkbin</w>
- <w>sdklib</w>
- <w>sdkman</w>
- <w>sdks</w>
- <w>serialnumber</w>
- <w>severities</w>
- <w>sparsearray</w>
- <w>sqrt</w>
- <w>stacktrace</w>
- <w>stderr</w>
- <w>stdout</w>
- <w>stopship</w>
- <w>storepass</w>
- <w>storetype</w>
- <w>styleable</w>
- <w>subclassed</w>
- <w>subclassing</w>
- <w>subfolder</w>
- <w>submenu</w>
- <w>superset</w>
- <w>sysdir</w>
- <w>sysimg</w>
- <w>targetsdk</w>
- <w>testcase</w>
- <w>testroot</w>
- <w>testsuite</w>
- <w>tmpdir</w>
- <w>traceview</w>
- <w>tuple</w>
- <w>tvdpi</w>
- <w>uiautomator</w>
- <w>uname</w>
- <w>unarchive</w>
- <w>unary</w>
- <w>uncapitalized</w>
- <w>uncompressing</w>
- <w>unescape</w>
- <w>unescaping</w>
- <w>unformatted</w>
- <w>unlocalized</w>
- <w>unmanages</w>
- <w>unregister</w>
- <w>unregisters</w>
- <w>userdata</w>
- <w>versioncode</w>
- <w>vert</w>
- <w>viewport</w>
- <w>vmsig</w>
- <w>wakelock</w>
- <w>wakelocks</w>
- <w>wakeup</w>
- <w>webkit</w>
- <w>wikipedia</w>
- <w>workdir</w>
- <w>wqvga</w>
- <w>writeable</w>
- <w>wvga</w>
- <w>xdpi</w>
- <w>xerces</w>
- <w>xfermode</w>
- <w>xhdpi</w>
- <w>xhigh</w>
- <w>xlarge</w>
- <w>xliff</w>
- <w>xmlns</w>
- <w>xxhdpi</w>
- <w>xxhigh</w>
- <w>ydpi</w>
- <w>yyyy</w>
- <w>zipalign</w>
- </words>
- </dictionary>
-</component>
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/idea_default.xml b/.idea/inspectionProfiles/idea_default.xml
index f622821..b357b21 100644
--- a/.idea/inspectionProfiles/idea_default.xml
+++ b/.idea/inspectionProfiles/idea_default.xml
@@ -50,7 +50,7 @@
<inspection_tool class="ConstantConditionalExpressionJS" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="ConstantConditions" enabled="true" level="WARNING" enabled_by_default="true">
<scope name="runtime.classes" level="WARNING" enabled="false">
- <option name="SUGGEST_NULLABLE_ANNOTATIONS" value="true" />
+ <option name="SUGGEST_NULLABLE_ANNOTATIONS" value="false" />
<option name="DONT_REPORT_TRUE_ASSERT_STATEMENTS" value="false" />
</scope>
<option name="SUGGEST_NULLABLE_ANNOTATIONS" value="true" />
@@ -317,10 +317,6 @@
<inspection_tool class="MethodNamesDifferOnlyByCase" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="MethodOverloadsParentMethod" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="MethodOverridesStaticMethod" enabled="true" level="WARNING" enabled_by_default="true" />
- <inspection_tool class="MissingOverrideAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
- <option name="ignoreObjectMethods" value="true" />
- <option name="ignoreAnonymousClassMethods" value="false" />
- </inspection_tool>
<inspection_tool class="MisspelledCompareTo" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="MisspelledEquals" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="MisspelledHashcode" enabled="true" level="WARNING" enabled_by_default="true" />
@@ -371,8 +367,11 @@
<inspection_tool class="PyChainedComparisonsInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="PyComparisonWithNoneInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="PyCompatibilityInspection" enabled="false" level="ERROR" enabled_by_default="false">
- <option name="fromVersion" value="2.4" />
- <option name="toVersion" value="3.1" />
+ <option name="ourVersions">
+ <value>
+ <list size="0" />
+ </value>
+ </option>
</inspection_tool>
<inspection_tool class="PyDecoratorInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="PyDefaultArgumentInspection" enabled="false" level="WARNING" enabled_by_default="false" />
diff --git a/.idea/inspectionProfiles/idea_default_no_spellchecker.xml b/.idea/inspectionProfiles/idea_default_no_spellchecker.xml
index 20deb1d..1048466 100644
--- a/.idea/inspectionProfiles/idea_default_no_spellchecker.xml
+++ b/.idea/inspectionProfiles/idea_default_no_spellchecker.xml
@@ -722,7 +722,6 @@
<inspection_tool class="StrutsTilesInspection" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="StrutsValidatorFormInspection" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="StrutsValidatorInspection" enabled="false" level="ERROR" enabled_by_default="false" />
- <inspection_tool class="SuperClassHasFrequentlyUsedInheritors" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="SwitchStatementWithConfusingDeclaration" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="SynchronizeOnThis" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="SystemOutErr" enabled="true" level="WARNING" enabled_by_default="true">
@@ -813,6 +812,7 @@
<inspection_tool class="VtlTypesInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="W3CssValidation" enabled="false" level="WARNING" enabled_by_default="false">
<option name="myCssVersion" value="css3" />
+ <option name="myIgnoreVendorSpecificProperties" value="false" />
</inspection_tool>
<inspection_tool class="WSReferenceInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="WaitNotInLoop" enabled="true" level="WARNING" enabled_by_default="true" />
diff --git a/.idea/libraries/asm_tools.xml b/.idea/libraries/asm_tools.xml
deleted file mode 100644
index 6009e9f..0000000
--- a/.idea/libraries/asm_tools.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<component name="libraryTable">
- <library name="asm-tools">
- <CLASSES>
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/asm-tools/asm-4.0.jar!/" />
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/asm-tools/asm-analysis-4.0.jar!/" />
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/asm-tools/asm-tree-4.0.jar!/" />
- </CLASSES>
- <JAVADOC />
- <SOURCES>
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/asm-tools/src-4.0.zip!/" />
- </SOURCES>
- </library>
-</component>
\ No newline at end of file
diff --git a/.idea/libraries/bouncy_castle.xml b/.idea/libraries/bouncy_castle.xml
deleted file mode 100644
index 70ec93b..0000000
--- a/.idea/libraries/bouncy_castle.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<component name="libraryTable">
- <library name="bouncy-castle">
- <CLASSES>
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/m2/repository/org/bouncycastle/bcpkix-jdk15on/1.48/bcpkix-jdk15on-1.48.jar!/" />
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/m2/repository/org/bouncycastle/bcprov-jdk15on/1.48/bcprov-jdk15on-1.48.jar!/" />
- </CLASSES>
- <JAVADOC />
- <SOURCES>
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/m2/repository/org/bouncycastle/bcpkix-jdk15on/1.48/bcpkix-jdk15on-1.48-sources.jar!/" />
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/m2/repository/org/bouncycastle/bcprov-jdk15on/1.48/bcprov-jdk15on-1.48-sources.jar!/" />
- </SOURCES>
- </library>
-</component>
\ No newline at end of file
diff --git a/.idea/libraries/commons_compress.xml b/.idea/libraries/commons_compress.xml
deleted file mode 100644
index be33df8..0000000
--- a/.idea/libraries/commons_compress.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<component name="libraryTable">
- <library name="commons-compress">
- <CLASSES>
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/commons-compress/commons-compress-1.0.jar!/" />
- </CLASSES>
- <JAVADOC />
- <SOURCES />
- </library>
-</component>
\ No newline at end of file
diff --git a/.idea/libraries/easymock_tools.xml b/.idea/libraries/easymock_tools.xml
deleted file mode 100644
index d01b884..0000000
--- a/.idea/libraries/easymock_tools.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<component name="libraryTable">
- <library name="easymock-tools">
- <CLASSES>
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/easymock-tools/easymock-3.1.jar!/" />
- </CLASSES>
- <JAVADOC>
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/easymock-tools/easymock-3.1-javadoc.jar!/" />
- </JAVADOC>
- <SOURCES>
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/easymock-tools/easymock-3.1-sources.jar!/" />
- </SOURCES>
- </library>
-</component>
\ No newline at end of file
diff --git a/.idea/libraries/freemarker_2_3_19.xml b/.idea/libraries/freemarker_2_3_19.xml
deleted file mode 100644
index 8015e9e..0000000
--- a/.idea/libraries/freemarker_2_3_19.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<component name="libraryTable">
- <library name="freemarker-2.3.19">
- <CLASSES>
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/freemarker/freemarker-2.3.19.jar!/" />
- </CLASSES>
- <JAVADOC />
- <SOURCES>
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/freemarker/src.zip!/" />
- </SOURCES>
- </library>
-</component>
\ No newline at end of file
diff --git a/.idea/libraries/guava_tools.xml b/.idea/libraries/guava_tools.xml
deleted file mode 100644
index 4e67511..0000000
--- a/.idea/libraries/guava_tools.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<component name="libraryTable">
- <library name="guava-tools">
- <CLASSES>
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/guava-tools/guava-13.0.1.jar!/" />
- </CLASSES>
- <JAVADOC />
- <SOURCES>
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/guava-tools/src.zip!/" />
- </SOURCES>
- </library>
-</component>
\ No newline at end of file
diff --git a/.idea/libraries/http_client.xml b/.idea/libraries/http_client.xml
deleted file mode 100644
index 9f81f11..0000000
--- a/.idea/libraries/http_client.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<component name="libraryTable">
- <library name="http-client">
- <CLASSES>
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/http-client/commons-codec-1.4.jar!/" />
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/http-client/commons-logging-1.1.1.jar!/" />
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/http-client/httpclient-4.1.1.jar!/" />
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/http-client/httpcore-4.1.jar!/" />
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/http-client/httpmime-4.1.1.jar!/" />
- </CLASSES>
- <JAVADOC />
- <SOURCES>
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/http-client/src/commons-codec-1.4-src.zip!/commons-codec-1.4-src/src/java" />
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/http-client/src/commons-logging-1.1.1-src.zip!/commons-logging-1.1.1-src/src/java" />
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/http-client/src/httpcomponents-client-4.1.1-src.zip!/httpcomponents-client-4.1.1/httpclient/src/main/java" />
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/http-client/src/httpcomponents-client-4.1.1-src.zip!/httpcomponents-client-4.1.1/httpclient-cache/src/main/java" />
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/http-client/src/httpcomponents-client-4.1.1-src.zip!/httpcomponents-client-4.1.1/httpmime/src/main/java" />
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/http-client/src/httpcomponents-client-4.1.1-src.zip!/httpcomponents-client-4.1.1/httpclient-benchmark/src/main/java" />
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/http-client/src/httpcomponents-client-4.1.1-src.zip!/httpcomponents-client-4.1.1/httpclient-contrib/src/main/java" />
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/http-client/src/httpcomponents-core-4.1-src.zip!/httpcomponents-core-4.1/httpcore-contrib/src/main/java" />
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/http-client/src/httpcomponents-core-4.1-src.zip!/httpcomponents-core-4.1/httpcore-nio/src/main/java" />
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/http-client/src/httpcomponents-core-4.1-src.zip!/httpcomponents-core-4.1/httpcore-benchmark/src/main/java" />
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/http-client/src/httpcomponents-core-4.1-src.zip!/httpcomponents-core-4.1/httpcore/src/main/java" />
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/http-client/src/httpcomponents-core-4.1-src.zip!/httpcomponents-core-4.1/httpcore-ab/src/main/java" />
- </SOURCES>
- </library>
-</component>
\ No newline at end of file
diff --git a/.idea/libraries/junit3_tools.xml b/.idea/libraries/junit3_tools.xml
deleted file mode 100644
index b3dd3f3..0000000
--- a/.idea/libraries/junit3_tools.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<component name="libraryTable">
- <library name="junit3-tools">
- <CLASSES>
- <root url="jar://$APPLICATION_HOME_DIR$/lib/junit.jar!/" />
- </CLASSES>
- <JAVADOC />
- <SOURCES />
- </library>
-</component>
\ No newline at end of file
diff --git a/.idea/libraries/kxml2.xml b/.idea/libraries/kxml2.xml
deleted file mode 100644
index 688c238..0000000
--- a/.idea/libraries/kxml2.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<component name="libraryTable">
- <library name="kxml2">
- <CLASSES>
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/kxml2-tools/kxml2-2.3.0.jar!/" />
- </CLASSES>
- <JAVADOC>
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/kxml2-tools/kxml2-src-2.3.0.zip!/www/kxml2/javadoc" />
- </JAVADOC>
- <SOURCES>
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/kxml2-tools/kxml2-src-2.3.0.zip!/src" />
- </SOURCES>
- </library>
-</component>
\ No newline at end of file
diff --git a/.idea/libraries/lombok_ast.xml b/.idea/libraries/lombok_ast.xml
deleted file mode 100644
index 250dbb9..0000000
--- a/.idea/libraries/lombok_ast.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<component name="libraryTable">
- <library name="lombok-ast">
- <CLASSES>
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/lombok-ast/lombok-ast-0.2.1.jar!/" />
- </CLASSES>
- <JAVADOC />
- <SOURCES>
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/lombok-ast/lombok-ast-0.2.1-src.zip!/src/template" />
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/lombok-ast/lombok-ast-0.2.1-src.zip!/src/ecjTransformer" />
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/lombok-ast/lombok-ast-0.2.1-src.zip!/src/javacTransformer" />
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/lombok-ast/lombok-ast-0.2.1-src.zip!/src/printer" />
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/lombok-ast/lombok-ast-0.2.1-src.zip!/src/main" />
- <root url="jar://$PROJECT_DIR$/../../prebuilts/tools/common/lombok-ast/lombok-ast-0.2.1-src.zip!/build/lombok.ast_generatedSource" />
- </SOURCES>
- </library>
-</component>
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 60db4ae..804f4a7 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -4,7 +4,10 @@
<entry_points version="2.0" />
</component>
<component name="FrameworkDetectionExcludesConfiguration">
- <type id="android" />
+ <file type="android" url="file://$PROJECT_DIR$/plugins/android/testData/AndroidManifest.xml" />
+ <file type="android" url="file://$PROJECT_DIR$/plugins/android/testData/lint/global/buttonsOrder/AndroidManifest.xml" />
+ <file type="android" url="file://$PROJECT_DIR$/plugins/android/testData/lint/global/manifestOrder/AndroidManifest.xml" />
+ <file type="android" url="file://$PROJECT_DIR$/plugins/android/testData/resNavigation/AndroidManifest.xml" />
</component>
<component name="IdProvider" IDEtalkID="88DB5D232B345F18EEFB2825E88EC093" />
<component name="JavadocGenerationManager">
@@ -24,30 +27,6 @@
<option name="LOCALE" />
<option name="OPEN_IN_BROWSER" value="true" />
</component>
- <component name="NullableNotNullManager">
- <option name="myDefaultNullable" value="org.jetbrains.annotations.Nullable" />
- <option name="myDefaultNotNull" value="org.jetbrains.annotations.NotNull" />
- <option name="myNullables">
- <value>
- <list size="4">
- <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
- <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
- <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
- <item index="3" class="java.lang.String" itemvalue="com.android.annotations.Nullable" />
- </list>
- </value>
- </option>
- <option name="myNotNulls">
- <value>
- <list size="4">
- <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
- <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
- <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
- <item index="3" class="java.lang.String" itemvalue="com.android.annotations.NonNull" />
- </list>
- </value>
- </option>
- </component>
<component name="ProjectDetails">
<option name="projectName" value="idea-community" />
</component>
diff --git a/.idea/modules.xml b/.idea/modules.xml
old mode 100755
new mode 100644
index fdae697..c9b64c7
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -11,28 +11,19 @@
<module fileurl="file://$PROJECT_DIR$/plugins/IntelliLang/IntelliLang-xml.iml" filepath="$PROJECT_DIR$/plugins/IntelliLang/IntelliLang-xml.iml" group="plugins/IntelliLang" />
<module fileurl="file://$PROJECT_DIR$/plugins/IntentionPowerPak/IntentionPowerPackPlugin.iml" filepath="$PROJECT_DIR$/plugins/IntentionPowerPak/IntentionPowerPackPlugin.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/RegExpSupport/RegExpSupport.iml" filepath="$PROJECT_DIR$/RegExpSupport/RegExpSupport.iml" group="platform" />
- <module fileurl="file://$PROJECT_DIR$/../adt/idea/adt-branding/adt-branding.iml" filepath="$PROJECT_DIR$/../adt/idea/adt-branding/adt-branding.iml" group="plugins/Android" />
<module fileurl="file://$PROJECT_DIR$/platform/analysis-api/analysis-api.iml" filepath="$PROJECT_DIR$/platform/analysis-api/analysis-api.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/platform/analysis-impl/analysis-impl.iml" filepath="$PROJECT_DIR$/platform/analysis-impl/analysis-impl.iml" group="platform" />
- <module fileurl="file://$PROJECT_DIR$/../adt/idea/android/android.iml" filepath="$PROJECT_DIR$/../adt/idea/android/android.iml" group="plugins/Android" />
- <module fileurl="file://$PROJECT_DIR$/../adt/idea/android/common/android-common.iml" filepath="$PROJECT_DIR$/../adt/idea/android/common/android-common.iml" group="plugins/Android" />
- <module fileurl="file://$PROJECT_DIR$/../adt/idea/android-designer/android-designer.iml" filepath="$PROJECT_DIR$/../adt/idea/android-designer/android-designer.iml" group="plugins/Android" />
- <module fileurl="file://$PROJECT_DIR$/../adt/idea/android-gradle-jps/android-gradle-jps.iml" filepath="$PROJECT_DIR$/../adt/idea/android-gradle-jps/android-gradle-jps.iml" group="plugins/Android" />
- <module fileurl="file://$PROJECT_DIR$/../adt/idea/android/jps-plugin/android-jps-plugin.iml" filepath="$PROJECT_DIR$/../adt/idea/android/jps-plugin/android-jps-plugin.iml" group="plugins/Android" />
- <module fileurl="file://$PROJECT_DIR$/../adt/idea/android/rt/android-rt.iml" filepath="$PROJECT_DIR$/../adt/idea/android/rt/android-rt.iml" group="plugins/Android" />
<module fileurl="file://$PROJECT_DIR$/platform/annotations/annotations.iml" filepath="$PROJECT_DIR$/platform/annotations/annotations.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/plugins/ant/ant.iml" filepath="$PROJECT_DIR$/plugins/ant/ant.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/plugins/ant/jps-plugin/ant-jps-plugin.iml" filepath="$PROJECT_DIR$/plugins/ant/jps-plugin/ant-jps-plugin.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/jps/antLayout/antlayout.iml" filepath="$PROJECT_DIR$/jps/antLayout/antlayout.iml" group="jps" />
<module fileurl="file://$PROJECT_DIR$/plugins/google-app-engine/runtime/appEngine-runtime.iml" filepath="$PROJECT_DIR$/plugins/google-app-engine/runtime/appEngine-runtime.iml" group="plugins/GAE" />
- <module fileurl="file://$PROJECT_DIR$/../base/asset-studio/assetstudio.iml" filepath="$PROJECT_DIR$/../base/asset-studio/assetstudio.iml" group="plugins/Android/android-sdk" />
<module fileurl="file://$PROJECT_DIR$/plugins/svn4idea/bindSvn/bindSvn.iml" filepath="$PROJECT_DIR$/plugins/svn4idea/bindSvn/bindSvn.iml" group="plugins/VCS" />
<module fileurl="file://$PROJECT_DIR$/platform/boot/boot.iml" filepath="$PROJECT_DIR$/platform/boot/boot.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/platform/bootstrap/bootstrap.iml" filepath="$PROJECT_DIR$/platform/bootstrap/bootstrap.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/build/build.iml" filepath="$PROJECT_DIR$/build/build.iml" />
<module fileurl="file://$PROJECT_DIR$/colorSchemes/colorSchemes.iml" filepath="$PROJECT_DIR$/colorSchemes/colorSchemes.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/plugins/commander/commander.iml" filepath="$PROJECT_DIR$/plugins/commander/commander.iml" group="plugins" />
- <module fileurl="file://$PROJECT_DIR$/../base/common/common.iml" filepath="$PROJECT_DIR$/../base/common/common.iml" group="plugins/Android/android-sdk" />
<module fileurl="file://$PROJECT_DIR$/plugins/eclipse/common-eclipse-util/common-eclipse-util.iml" filepath="$PROJECT_DIR$/plugins/eclipse/common-eclipse-util/common-eclipse-util.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/plugins/javaFX/common-javaFX-plugin/common-javaFX-plugin.iml" filepath="$PROJECT_DIR$/plugins/javaFX/common-javaFX-plugin/common-javaFX-plugin.iml" group="plugins/JavaFX" />
<module fileurl="file://$PROJECT_DIR$/community-main.iml" filepath="$PROJECT_DIR$/community-main.iml" />
@@ -47,7 +38,6 @@
<module fileurl="file://$PROJECT_DIR$/build/cucumber-test-runner/cucumber-test-runner.iml" filepath="$PROJECT_DIR$/build/cucumber-test-runner/cucumber-test-runner.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/plugins/cvs/cvs-core/cvs-core.iml" filepath="$PROJECT_DIR$/plugins/cvs/cvs-core/cvs-core.iml" group="plugins/VCS/cvs" />
<module fileurl="file://$PROJECT_DIR$/plugins/cvs/cvs-plugin/cvs-plugin.iml" filepath="$PROJECT_DIR$/plugins/cvs/cvs-plugin/cvs-plugin.iml" group="plugins/VCS/cvs" />
- <module fileurl="file://$PROJECT_DIR$/../base/ddmlib/ddmlib.iml" filepath="$PROJECT_DIR$/../base/ddmlib/ddmlib.iml" group="plugins/Android/android-sdk" />
<module fileurl="file://$PROJECT_DIR$/java/debugger/impl/debugger-impl.iml" filepath="$PROJECT_DIR$/java/debugger/impl/debugger-impl.iml" group="java" />
<module fileurl="file://$PROJECT_DIR$/java/debugger/openapi/debugger-openapi.iml" filepath="$PROJECT_DIR$/java/debugger/openapi/debugger-openapi.iml" group="java" />
<module fileurl="file://$PROJECT_DIR$/plugins/devkit/devkit.iml" filepath="$PROJECT_DIR$/plugins/devkit/devkit.iml" group="plugins" />
@@ -55,9 +45,7 @@
<module fileurl="file://$PROJECT_DIR$/xml/dom-impl/dom-impl.iml" filepath="$PROJECT_DIR$/xml/dom-impl/dom-impl.iml" group="xml" />
<module fileurl="file://$PROJECT_DIR$/xml/dom-openapi/dom-openapi.iml" filepath="$PROJECT_DIR$/xml/dom-openapi/dom-openapi.iml" group="xml" />
<module fileurl="file://$PROJECT_DIR$/xml/dom-tests/dom-tests.iml" filepath="$PROJECT_DIR$/xml/dom-tests/dom-tests.iml" group="xml" />
- <module fileurl="file://$PROJECT_DIR$/../base/draw9patch/draw9patch.iml" filepath="$PROJECT_DIR$/../base/draw9patch/draw9patch.iml" group="plugins/Android/android-sdk" />
<module fileurl="file://$PROJECT_DIR$/platform/dvcs/dvcs.iml" filepath="$PROJECT_DIR$/platform/dvcs/dvcs.iml" group="platform" />
- <module fileurl="file://$PROJECT_DIR$/../base/device_validator/dvlib/dvlib.iml" filepath="$PROJECT_DIR$/../base/device_validator/dvlib/dvlib.iml" group="plugins/Android/android-sdk" />
<module fileurl="file://$PROJECT_DIR$/plugins/eclipse/eclipse.iml" filepath="$PROJECT_DIR$/plugins/eclipse/eclipse.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/plugins/eclipse/jps-plugin/eclipse-jps-plugin.iml" filepath="$PROJECT_DIR$/plugins/eclipse/jps-plugin/eclipse-jps-plugin.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/java/execution/impl/execution-impl.iml" filepath="$PROJECT_DIR$/java/execution/impl/execution-impl.iml" group="java" />
@@ -114,13 +102,8 @@
<module fileurl="file://$PROJECT_DIR$/plugins/junit_rt/junit_rt.iml" filepath="$PROJECT_DIR$/plugins/junit_rt/junit_rt.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/platform/lang-api/lang-api.iml" filepath="$PROJECT_DIR$/platform/lang-api/lang-api.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/platform/lang-impl/lang-impl.iml" filepath="$PROJECT_DIR$/platform/lang-impl/lang-impl.iml" group="platform" />
- <module fileurl="file://$PROJECT_DIR$/../base/layoutlib-api/layoutlib-api.iml" filepath="$PROJECT_DIR$/../base/layoutlib-api/layoutlib-api.iml" group="plugins/Android/android-sdk" />
- <module fileurl="file://$PROJECT_DIR$/../base/lint/libs/lint-api/lint-api.iml" filepath="$PROJECT_DIR$/../base/lint/libs/lint-api/lint-api.iml" group="plugins/Android/android-sdk/lint" />
- <module fileurl="file://$PROJECT_DIR$/../base/lint/libs/lint-checks/lint-checks.iml" filepath="$PROJECT_DIR$/../base/lint/libs/lint-checks/lint-checks.iml" group="plugins/Android/android-sdk/lint" />
- <module fileurl="file://$PROJECT_DIR$/../base/lint/cli/lint-cli.iml" filepath="$PROJECT_DIR$/../base/lint/cli/lint-cli.iml" group="plugins/Android/android-sdk/lint" />
<module fileurl="file://$PROJECT_DIR$/platform/lvcs-api/lvcs-api.iml" filepath="$PROJECT_DIR$/platform/lvcs-api/lvcs-api.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/platform/lvcs-impl/lvcs-impl.iml" filepath="$PROJECT_DIR$/platform/lvcs-impl/lvcs-impl.iml" group="platform" />
- <module fileurl="file://$PROJECT_DIR$/../base/manifest-merger/manifest-merger.iml" filepath="$PROJECT_DIR$/../base/manifest-merger/manifest-merger.iml" group="plugins/Android/android-sdk" />
<module fileurl="file://$PROJECT_DIR$/plugins/maven/maven.iml" filepath="$PROJECT_DIR$/plugins/maven/maven.iml" group="plugins/maven" />
<module fileurl="file://$PROJECT_DIR$/plugins/maven/artifact-resolver-m2/maven-artifact-resolver-m2.iml" filepath="$PROJECT_DIR$/plugins/maven/artifact-resolver-m2/maven-artifact-resolver-m2.iml" group="plugins/maven" />
<module fileurl="file://$PROJECT_DIR$/plugins/maven/artifact-resolver-m3/maven-artifact-resolver-m3.iml" filepath="$PROJECT_DIR$/plugins/maven/artifact-resolver-m3/maven-artifact-resolver-m3.iml" group="plugins/maven" />
@@ -128,7 +111,6 @@
<module fileurl="file://$PROJECT_DIR$/plugins/maven/maven-server-api/maven-server-api.iml" filepath="$PROJECT_DIR$/plugins/maven/maven-server-api/maven-server-api.iml" group="plugins/maven" />
<module fileurl="file://$PROJECT_DIR$/plugins/maven/maven2-server-impl/maven2-server-impl.iml" filepath="$PROJECT_DIR$/plugins/maven/maven2-server-impl/maven2-server-impl.iml" group="plugins/maven" />
<module fileurl="file://$PROJECT_DIR$/plugins/maven/maven3-server-impl/maven3-server-impl.iml" filepath="$PROJECT_DIR$/plugins/maven/maven3-server-impl/maven3-server-impl.iml" group="plugins/maven" />
- <module fileurl="file://$PROJECT_DIR$/../base/ninepatch/ninepatch.iml" filepath="$PROJECT_DIR$/../base/ninepatch/ninepatch.iml" group="plugins/Android/android-sdk" />
<module fileurl="file://$PROJECT_DIR$/java/openapi/openapi.iml" filepath="$PROJECT_DIR$/java/openapi/openapi.iml" group="java" />
<module fileurl="file://$PROJECT_DIR$/platform/platform-api/platform-api.iml" filepath="$PROJECT_DIR$/platform/platform-api/platform-api.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/platform/platform-impl/platform-impl.iml" filepath="$PROJECT_DIR$/platform/platform-impl/platform-impl.iml" group="platform" />
@@ -139,11 +121,11 @@
<module fileurl="file://$PROJECT_DIR$/platform/projectModel-api/projectModel-api.iml" filepath="$PROJECT_DIR$/platform/projectModel-api/projectModel-api.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/platform/projectModel-impl/projectModel-impl.iml" filepath="$PROJECT_DIR$/platform/projectModel-impl/projectModel-impl.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/plugins/properties/properties.iml" filepath="$PROJECT_DIR$/plugins/properties/properties.iml" group="plugins" />
+ <module fileurl="file://$PROJECT_DIR$/platform/remote-servers/api/remote-servers-api.iml" filepath="$PROJECT_DIR$/platform/remote-servers/api/remote-servers-api.iml" group="platform" />
+ <module fileurl="file://$PROJECT_DIR$/platform/remote-servers/impl/remote-servers-impl.iml" filepath="$PROJECT_DIR$/platform/remote-servers/impl/remote-servers-impl.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/xml/relaxng/relaxng.iml" filepath="$PROJECT_DIR$/xml/relaxng/relaxng.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/resources/resources.iml" filepath="$PROJECT_DIR$/resources/resources.iml" />
<module fileurl="file://$PROJECT_DIR$/resources-en/resources-en.iml" filepath="$PROJECT_DIR$/resources-en/resources-en.iml" />
- <module fileurl="file://$PROJECT_DIR$/../base/sdk-common/sdk-common.iml" filepath="$PROJECT_DIR$/../base/sdk-common/sdk-common.iml" group="plugins/Android/android-sdk" />
- <module fileurl="file://$PROJECT_DIR$/../base/sdklib/sdklib.iml" filepath="$PROJECT_DIR$/../base/sdklib/sdklib.iml" group="plugins/Android/android-sdk" />
<module fileurl="file://$PROJECT_DIR$/platform/smRunner/smRunner.iml" filepath="$PROJECT_DIR$/platform/smRunner/smRunner.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/plugins/cvs/smartcvs-src/smartcvs-src.iml" filepath="$PROJECT_DIR$/plugins/cvs/smartcvs-src/smartcvs-src.iml" group="plugins/VCS/cvs" />
<module fileurl="file://$PROJECT_DIR$/spellchecker/spellchecker.iml" filepath="$PROJECT_DIR$/spellchecker/spellchecker.iml" group="plugins" />
@@ -161,7 +143,6 @@
<module fileurl="file://$PROJECT_DIR$/plugins/testng/testng.iml" filepath="$PROJECT_DIR$/plugins/testng/testng.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/plugins/testng_rt/testng_rt.iml" filepath="$PROJECT_DIR$/plugins/testng_rt/testng_rt.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/platform/testFramework/bootstrap/tests_bootstrap.iml" filepath="$PROJECT_DIR$/platform/testFramework/bootstrap/tests_bootstrap.iml" group="platform" />
- <module fileurl="file://$PROJECT_DIR$/../base/testutils/testutils.iml" filepath="$PROJECT_DIR$/../base/testutils/testutils.iml" group="plugins/Android/android-sdk" />
<module fileurl="file://$PROJECT_DIR$/plugins/ui-designer/ui-designer.iml" filepath="$PROJECT_DIR$/plugins/ui-designer/ui-designer.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/plugins/ui-designer-core/ui-designer-core.iml" filepath="$PROJECT_DIR$/plugins/ui-designer-core/ui-designer-core.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/plugins/ui-designer/jps-plugin/ui-designer-jps-plugin.iml" filepath="$PROJECT_DIR$/plugins/ui-designer/jps-plugin/ui-designer-jps-plugin.iml" group="plugins" />
diff --git a/.idea/runConfigurations/AndroidStudio.xml b/.idea/runConfigurations/AndroidStudio.xml
deleted file mode 100644
index 6f1a448..0000000
--- a/.idea/runConfigurations/AndroidStudio.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<component name="ProjectRunConfigurationManager">
- <configuration default="false" name="AndroidStudio" type="Application" factoryName="Application">
- <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
- <option name="MAIN_CLASS_NAME" value="com.intellij.idea.Main" />
- <option name="VM_PARAMETERS" value="-ea -Xbootclasspath/p:../out/classes/production/boot -Xms384m -Xmx768m -Didea.is.internal=true -XX:MaxPermSize=384m -Dapple.awt.graphics.UseQuartz=true -Didea.platform.prefix=AndroidStudio -Dsun.awt.disablegrab=true" />
- <option name="PROGRAM_PARAMETERS" value="" />
- <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/bin" />
- <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
- <option name="ALTERNATIVE_JRE_PATH" value="" />
- <option name="ENABLE_SWING_INSPECTOR" value="false" />
- <option name="ENV_VARIABLES" />
- <option name="PASS_PARENT_ENVS" value="true" />
- <module name="community-main" />
- <envs />
- <RunnerSettings RunnerId="Debug">
- <option name="DEBUG_PORT" value="" />
- <option name="TRANSPORT" value="0" />
- <option name="LOCAL" value="true" />
- </RunnerSettings>
- <RunnerSettings RunnerId="Run" />
- <ConfigurationWrapper RunnerId="Debug" />
- <ConfigurationWrapper RunnerId="Run" />
- <method />
- </configuration>
-</component>
\ No newline at end of file
diff --git a/.idea/scopes/androidplugin.xml b/.idea/scopes/androidplugin.xml
deleted file mode 100644
index dcc1341..0000000
--- a/.idea/scopes/androidplugin.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-<component name="DependencyValidationManager">
- <scope name="androidplugin" pattern="file[group:Android]:*//*&&!file[group:android-sdk]:*//*" />
-</component>
\ No newline at end of file
diff --git a/.idea/scopes/aosp_code.xml b/.idea/scopes/aosp_code.xml
deleted file mode 100644
index abf77af..0000000
--- a/.idea/scopes/aosp_code.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-<component name="DependencyValidationManager">
- <scope name="aosp-code" pattern="test[group:android-sdk]:*..*||src[group:android-sdk]:*..*" />
-</component>
\ No newline at end of file
diff --git a/.idea/scopes/obsoleteplugin.xml b/.idea/scopes/obsoleteplugin.xml
deleted file mode 100644
index 0537436..0000000
--- a/.idea/scopes/obsoleteplugin.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-<component name="DependencyValidationManager">
- <scope name="obsoleteplugin" pattern="file[community-main]:plugins/android//*||file[community-main]:plugins/android-designer//*" />
-</component>
\ No newline at end of file
diff --git a/.idea/scopes/platform.xml b/.idea/scopes/platform.xml
deleted file mode 100644
index a0bafd1..0000000
--- a/.idea/scopes/platform.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-<component name="DependencyValidationManager">
- <scope name="platform" pattern="src:*..*&&!src[group:Android]:*..*" />
-</component>
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index d1499b1..275077f 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -2,8 +2,6 @@
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
- <mapping directory="$PROJECT_DIR$/../adt/idea" vcs="Git" />
- <mapping directory="$PROJECT_DIR$/../base" vcs="Git" />
</component>
</project>
diff --git a/bin/linux/fsnotifier b/bin/linux/fsnotifier
index 85973cc..37430c7 100755
--- a/bin/linux/fsnotifier
+++ b/bin/linux/fsnotifier
Binary files differ
diff --git a/bin/linux/fsnotifier64 b/bin/linux/fsnotifier64
index e4b3e56..1bd8179 100755
--- a/bin/linux/fsnotifier64
+++ b/bin/linux/fsnotifier64
Binary files differ
diff --git a/bin/scripts/unix/idea.sh b/bin/scripts/unix/idea.sh
index 1de77a1..42aec04 100755
--- a/bin/scripts/unix/idea.sh
+++ b/bin/scripts/unix/idea.sh
@@ -92,9 +92,9 @@
VERSION_LOG=`"$MKTEMP" -t java.version.log.XXXXXX`
"$JDK/bin/java" -version 2> "$VERSION_LOG"
-"$GREP" 'OpenJDK' "$VERSION_LOG"
+"$GREP" 'OpenJDK' "$VERSION_LOG" > /dev/null
OPEN_JDK=$?
-"$GREP" "64-Bit|x86_64" "$VERSION_LOG"
+"$GREP" "64-Bit|x86_64" "$VERSION_LOG" > /dev/null
BITS=$?
"$RM" -f "$VERSION_LOG"
if [ $OPEN_JDK -eq 0 ]; then
@@ -159,7 +159,7 @@
OS_NAME=`echo $OS_TYPE | "$TR" '[:upper:]' '[:lower:]'`
AGENT_LIB="yjpagent-$OS_NAME$BITS"
if [ -r "$IDE_BIN_HOME/lib$AGENT_LIB.so" ]; then
- AGENT="-agentlib:$AGENT_LIB=disablej2ee,disablealloc,sessionname=@@system_selector@@"
+ AGENT="-agentlib:$AGENT_LIB=disablej2ee,disablealloc,delay=10000,sessionname=@@system_selector@@"
fi
fi
diff --git a/bin/scripts/win/idea.bat b/bin/scripts/win/idea.bat
index ad995b2..4375802 100644
--- a/bin/scripts/win/idea.bat
+++ b/bin/scripts/win/idea.bat
@@ -41,7 +41,8 @@
:: ---------------------------------------------------------------------
:: Collect JVM options and properties.
:: ---------------------------------------------------------------------
-SET VM_OPTIONS_FILE=%IDE_BIN_DIR%\@@vm_options@@.vmoptions
+SET VM_OPTIONS_FILE=%@@product_uc@@_VM_OPTIONS%
+IF "%VM_OPTIONS_FILE%" == "" SET VM_OPTIONS_FILE=%IDE_BIN_DIR%\@@vm_options@@.vmoptions
SET ACC=
FOR /F "usebackq delims=" %%i IN ("%VM_OPTIONS_FILE%") DO CALL "%IDE_BIN_DIR%\append.bat" "%%i"
IF EXIST "%VM_OPTIONS_FILE%" SET ACC=%ACC% -Djb.vmOptionsFile="%VM_OPTIONS_FILE%"
diff --git a/bin/win/IdeaWin32.dll b/bin/win/IdeaWin32.dll
old mode 100755
new mode 100644
Binary files differ
diff --git a/bin/win/IdeaWin64.dll b/bin/win/IdeaWin64.dll
old mode 100755
new mode 100644
Binary files differ
diff --git a/bin/win/breakgen.dll b/bin/win/breakgen.dll
old mode 100755
new mode 100644
Binary files differ
diff --git a/bin/win/breakgen64.dll b/bin/win/breakgen64.dll
old mode 100755
new mode 100644
Binary files differ
diff --git a/bin/win/focuskiller.dll b/bin/win/focuskiller.dll
old mode 100755
new mode 100644
Binary files differ
diff --git a/bin/win/focuskiller64.dll b/bin/win/focuskiller64.dll
old mode 100755
new mode 100644
Binary files differ
diff --git a/bin/win/fsnotifier.exe b/bin/win/fsnotifier.exe
old mode 100755
new mode 100644
Binary files differ
diff --git a/bin/win/restarter.exe b/bin/win/restarter.exe
old mode 100755
new mode 100644
Binary files differ
diff --git a/bin/win/runnerw.exe b/bin/win/runnerw.exe
old mode 100755
new mode 100644
Binary files differ
diff --git a/bin/win/vistalauncher.exe b/bin/win/vistalauncher.exe
old mode 100755
new mode 100644
Binary files differ
diff --git a/build/conf/ideaCE.properties b/build/conf/ideaCE.properties
index 81afaed..8c86bf3 100644
--- a/build/conf/ideaCE.properties
+++ b/build/conf/ideaCE.properties
@@ -1,11 +1,13 @@
#---------------------------------------------------------------------
-# IDE copies library jars to prevent their locking. If copying is not desirable, specify "true"
+# IDEA can copy library .jar files to prevent their locking.
+# By default this behavior is enabled on Windows and disabled on other platforms.
+# Uncomment this property to override.
#---------------------------------------------------------------------
-idea.jars.nocopy=false
+# idea.jars.nocopy=false
#---------------------------------------------------------------------
-# The VM option value to be used start the JVM in debug mode.
+# The VM option value to be used to start a JVM in debug mode.
# Some JREs define it in a different way (-XXdebug in Oracle VM)
#---------------------------------------------------------------------
idea.xdebug.key=-Xdebug
diff --git a/build/conf/mac/Contents/Info.plist b/build/conf/mac/Contents/Info.plist
index b57f202..0603a25 100644
--- a/build/conf/mac/Contents/Info.plist
+++ b/build/conf/mac/Contents/Info.plist
@@ -39,7 +39,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleGetInfoString</key>
- <string>@@bundle_name@@ @@version@@, build @@build@@. Copyright @@company_name@@, (c) @@min_year@@-@@max_year@@</string>
+ <string>@@bundle_name@@ @@version@@, build @@build@@. Copyright JetBrains s.r.o., (c) 2000-@@year@@</string>
<key>CFBundleShortVersionString</key>
<string>@@version@@</string>
<key>CFBundleVersion</key>
diff --git a/build/scripts/common_tests.gant b/build/scripts/common_tests.gant
index 466446b..b067618 100644
--- a/build/scripts/common_tests.gant
+++ b/build/scripts/common_tests.gant
@@ -27,7 +27,7 @@
}
loadProject()
- projectBuilder.useInProcessJavac = true
+ projectBuilder.useInProcessJavac = false
projectBuilder.targetFolder = out
projectBuilder.cleanOutput()
projectBuilder.buildAll()
diff --git a/build/scripts/layouts.gant b/build/scripts/layouts.gant
index 7e8e064..4ac31f9 100644
--- a/build/scripts/layouts.gant
+++ b/build/scripts/layouts.gant
@@ -56,6 +56,7 @@
"testFramework-java",
"debugger-openapi",
"compiler-openapi",
+ "remote-servers-api",
"dom-openapi",
"execution-openapi",
"jsp-openapi",
@@ -64,6 +65,7 @@
//noinspection GroovyAssignabilityCheck
List<String> implementationModules = [platformImplementationModules,
"compiler-impl",
+ "remote-servers-impl",
"debugger-impl",
"dom-impl",
"execution-impl",
@@ -78,6 +80,9 @@
"platform-main",
"testFramework",
"tests_bootstrap",
+ "InspectionGadgetsAnalysis",
+ "InspectionGadgetsPlugin",
+ "IntentionPowerPackPlugin",
].flatten()
ant.patternset(id: "resources.included") {
@@ -246,12 +251,6 @@
module("ant-jps-plugin")
}
}
- layoutPlugin("InspectionGadgets", "InspectionGadgetsPlugin") {
- jar("InspectionGadgetsAnalysis.jar") {
- module("InspectionGadgetsAnalysis")
- }
- }
- layoutPlugin("IntentionPowerPack", "IntentionPowerPackPlugin")
layoutPlugin("ToString", "generate-tostring", "toString")
layoutPlugin("uiDesigner", "ui-designer", "uiDesigner") {
dir("jps") {
@@ -695,6 +694,7 @@
include(name: "optimizedFileManager.jar")
include(name: "log4j.jar")
include(name: "jgoodies-forms.jar")
+ include(name: "ecj*.jar")
}
dir("test") {
jar("jps-build-test.jar") {
@@ -767,6 +767,7 @@
module("InspectionGadgetsAnalysis")
module("xml-psi-api")
module("xml-psi-impl")
+ module("resources") // IdeaPlugin.xml
}
jar("annotations.jar") {
diff --git a/build/scripts/libLicenses.gant b/build/scripts/libLicenses.gant
index e387e58..3f86792 100644
--- a/build/scripts/libLicenses.gant
+++ b/build/scripts/libLicenses.gant
@@ -166,6 +166,7 @@
libraryLicense(name: "Apache Commons Discovery", libraryName: "commons-discovery-0.4.jar", version: "0.4", license: "Apache 2.0", url: "http://jakarta.apache.org/commons/discovery/", licenseUrl: "http://commons.apache.org/license.html")
libraryLicense(name: "Apache Commons HTTPClient", libraryName: "http-client-3.1", version: "3.1 (with patch by JetBrains)", license: "Apache 2.0", url: "http://hc.apache.org/httpclient-3.x")
libraryLicense(name: "HttpComponents HttpClient", libraryName: "http-client", version: "4.1.1", license: "Apache 2.0", url: "http://hc.apache.org/httpcomponents-client-ga/index.html")
+libraryLicense(name: "HttpComponents HttpClient", libraryName: "httpclient-4.2.5", version: "4.2.5", license: "Apache 2.0", url: "http://hc.apache.org/httpcomponents-client-ga/index.html")
libraryLicense(name: "Apache Commons Net", libraryName: "commons-net", version: "3.1", license: "Apache 2.0", url: "http://commons.apache.org/net/")
libraryLicense(name: "Apache Commons Logging", libraryName: "commons-logging", version: "1.1.1", license: "Apache 2.0", url: "http://commons.apache.org/logging/")
libraryLicense(name: "Apache Lucene", libraryName: "lucene-core-2.4.1.jar", version: "2.4.1", license: "Apache 2.0", url: "http://lucene.apache.org/java")
diff --git a/build/scripts/utils.gant b/build/scripts/utils.gant
index 7a5798b..8df9913 100644
--- a/build/scripts/utils.gant
+++ b/build/scripts/utils.gant
@@ -52,18 +52,18 @@
return "true" == p("component.version.eap")
})
-binding.setVariable("mem32", "-server -Xms128m -Xmx512m -XX:MaxPermSize=250m -XX:ReservedCodeCacheSize=64m -XX:+UseCodeCacheFlushing -XX:+UseConcMarkSweepGC -XX:SoftRefLRUPolicyMSPerMB=50")
-binding.setVariable("mem64", "-Xms128m -Xmx750m -XX:MaxPermSize=350m -XX:ReservedCodeCacheSize=96m -XX:+UseCodeCacheFlushing -XX:+UseConcMarkSweepGC -XX:SoftRefLRUPolicyMSPerMB=50")
-binding.setVariable("common_vmoptions", "-ea -Dsun.io.useCanonCaches=false -Djava.net.preferIPv4Stack=true")
+binding.setVariable("mem32", "-server -Xms128m -Xmx512m -XX:MaxPermSize=250m -XX:ReservedCodeCacheSize=64m")
+binding.setVariable("mem64", "-Xms128m -Xmx750m -XX:MaxPermSize=350m -XX:ReservedCodeCacheSize=96m")
+binding.setVariable("common_vmoptions", "-ea -Dsun.io.useCanonCaches=false -Djava.net.preferIPv4Stack=true " +
+ "-XX:+UseCodeCacheFlushing -XX:+UseConcMarkSweepGC -XX:SoftRefLRUPolicyMSPerMB=50")
binding.setVariable("vmOptions", { "$common_vmoptions ${isEap() ? '-XX:+HeapDumpOnOutOfMemoryError' : ''}".trim() })
binding.setVariable("vmOptions32", { "$mem32 ${vmOptions()}".trim() })
binding.setVariable("vmOptions64", { "$mem64 ${vmOptions()}".trim() })
binding.setVariable("yjpOptions", { String systemSelector, String platformSuffix = "" ->
- "-agentlib:yjpagent$platformSuffix=disablej2ee,disablealloc,disabletracing,onlylocal,builtinprobes=none,disableexceptiontelemetry,sessionname=$systemSelector".trim()
+ "-agentlib:yjpagent$platformSuffix=disablej2ee,disablealloc,disabletracing,onlylocal,builtinprobes=none,disableexceptiontelemetry,delay=10000,sessionname=$systemSelector".trim()
})
-
binding.setVariable("vmOptions32yjp", { String systemSelector ->
"${vmOptions32()} ${yjpOptions(systemSelector)}".trim()
})
@@ -478,8 +478,8 @@
})
binding.setVariable("unixVMOptions", { String target, String name ->
- ant.echo(file: "$target/bin/${name}.vmoptions", message: vmOptions32().replace(' ', '\n'))
- ant.echo(file: "$target/bin/${name}64.vmoptions", message: vmOptions64().replace(' ', '\n'))
+ ant.echo(file: "$target/bin/${name}.vmoptions", message: "${vmOptions32()} -Dawt.useSystemAAFontSettings=lcd".trim().replace(' ', '\n'))
+ ant.echo(file: "$target/bin/${name}64.vmoptions", message: "${vmOptions64()} -Dawt.useSystemAAFontSettings=lcd".trim().replace(' ', '\n'))
ant.fixcrlf(srcdir: "$target/bin", includes: "*.vmoptions", eol: "unix")
})
@@ -732,7 +732,8 @@
}
}
-binding.setVariable("buildWinLauncher", { String ch, String inputPath, String outputPath, String appInfo, String launcherProperties, String pathsSelector, List resourcePaths ->
+binding.setVariable("buildWinLauncher", { String ch, String inputPath, String outputPath, String appInfo,
+ String launcherProperties, String pathsSelector, List resourcePaths ->
projectBuilder.stage("winLauncher")
File launcherPropertiesTempFile = null;
diff --git a/colorSchemes/src/colorSchemes/Darcula.xml b/colorSchemes/src/colorSchemes/Darcula.xml
index a387bd0..9749f7e 100644
--- a/colorSchemes/src/colorSchemes/Darcula.xml
+++ b/colorSchemes/src/colorSchemes/Darcula.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<scheme name="Darcula" version="1" parent_scheme="Default">
<option name="LINE_SPACING" value="1.0" />
- <option name="EDITOR_FONT_SIZE" value="12" />
- <option name="EDITOR_FONT_NAME" value="Menlo" />
+ <option name="EDITOR_FONT_SIZE" value="12" linux="14"/>
+ <option name="EDITOR_FONT_NAME" value="Menlo" linux="Source Code Pro"/>
<colors>
<option name="ADDED_LINES_COLOR" value="295622" />
<option name="ANNOTATIONS_COLOR" value="8b999f" />
@@ -134,6 +134,12 @@
<option name="EFFECT_TYPE" value="1" />
</value>
</option>
+ <option name="COFFEESCRIPT.PARAMETER">
+ <value>
+ <option name="EFFECT_COLOR" value="a9b7c6" />
+ <option name="EFFECT_TYPE" value="1" />
+ </value>
+ </option>
<option name="COFFEESCRIPT.JAVASCRIPT_CONTENT">
<value>
<option name="FOREGROUND" value="a9b7c6" />
@@ -287,7 +293,7 @@
</option>
<option name="CUSTOM_STRING_ATTRIBUTES">
<value>
- <option name="FOREGROUND" value="a5c25c" />
+ <option name="FOREGROUND" value="6A8759" />
</value>
</option>
<option name="CUSTOM_VALID_STRING_ESCAPE_ATTRIBUTES">
@@ -364,7 +370,7 @@
</option>
<option name="DEFAULT_INVALID_STRING_ESCAPE">
<value>
- <option name="FOREGROUND" value="a5c25c" />
+ <option name="FOREGROUND" value="6A8759" />
<option name="EFFECT_COLOR" value="ff0000" />
<option name="EFFECT_TYPE" value="2" />
</value>
@@ -415,7 +421,7 @@
</option>
<option name="DEFAULT_STRING">
<value>
- <option name="FOREGROUND" value="a5c25c" />
+ <option name="FOREGROUND" value="6A8759" />
</value>
</option>
<option name="DEFAULT_VALID_STRING_ESCAPE">
@@ -548,7 +554,7 @@
</option>
<option name="GString">
<value>
- <option name="FOREGROUND" value="a5c25c" />
+ <option name="FOREGROUND" value="6A8759" />
</value>
</option>
<option name="Groovy method declaration">
@@ -743,7 +749,7 @@
</option>
<option name="JAVA_INVALID_STRING_ESCAPE">
<value>
- <option name="FOREGROUND" value="a5c25c" />
+ <option name="FOREGROUND" value="6A8759" />
<option name="EFFECT_COLOR" value="ff0000" />
<option name="EFFECT_TYPE" value="2" />
</value>
@@ -770,7 +776,7 @@
</option>
<option name="JAVA_STRING">
<value>
- <option name="FOREGROUND" value="a5c25c" />
+ <option name="FOREGROUND" value="6A8759" />
</value>
</option>
<option name="JAVA_VALID_STRING_ESCAPE">
@@ -992,7 +998,7 @@
</option>
<option name="OC.STRING">
<value>
- <option name="FOREGROUND" value="a5c25c" />
+ <option name="FOREGROUND" value="6A8759" />
</value>
</option>
<option name="OC.STRUCT_FIELD">
@@ -1014,7 +1020,7 @@
</option>
<option name="PHP_EXEC_COMMAND_ID">
<value>
- <option name="FOREGROUND" value="a5c25c" />
+ <option name="FOREGROUND" value="6A8759" />
<option name="BACKGROUND" value="5e6465" />
</value>
</option>
@@ -1042,7 +1048,7 @@
</option>
<option name="PROPERTIES.VALUE">
<value>
- <option name="FOREGROUND" value="a5c25c" />
+ <option name="FOREGROUND" value="6A8759" />
</value>
</option>
<option name="PROTOCOL_REFERENCE">
@@ -1386,7 +1392,7 @@
</option>
<option name="SLIM_STRING_INTERPOLATED">
<value>
- <option name="FOREGROUND" value="a5c25c" />
+ <option name="FOREGROUND" value="6A8759" />
<option name="FONT_TYPE" value="1" />
</value>
</option>
@@ -1456,7 +1462,7 @@
</option>
<option name="String">
<value>
- <option name="FOREGROUND" value="a5c25c" />
+ <option name="FOREGROUND" value="6A8759" />
</value>
</option>
<option name="TAPESTRY_COMPONENT_PARAMATER">
@@ -1504,7 +1510,7 @@
</option>
<option name="TYPE_PARAMETER_NAME_ATTRIBUTES">
<value>
- <option name="FOREGROUND" value="247877" />
+ <option name="FOREGROUND" value="507874" />
</value>
</option>
<option name="TYPO">
@@ -1515,7 +1521,7 @@
</option>
<option name="Type parameter">
<value>
- <option name="FOREGROUND" value="247877" />
+ <option name="FOREGROUND" value="507874" />
</value>
</option>
<option name="UNMATCHED_BRACE_ATTRIBUTES">
@@ -1559,7 +1565,7 @@
</option>
<option name="VELOCITY_STRING">
<value>
- <option name="FOREGROUND" value="a5c25c" />
+ <option name="FOREGROUND" value="6A8759" />
<option name="FONT_TYPE" value="1" />
</value>
</option>
@@ -1644,7 +1650,7 @@
</option>
<option name="XPATH.STRING">
<value>
- <option name="FOREGROUND" value="a5c25c" />
+ <option name="FOREGROUND" value="6A8759" />
<option name="FONT_TYPE" value="1" />
</value>
</option>
diff --git a/colorSchemes/src/colorSchemes/all_hallows_eve.xml b/colorSchemes/src/colorSchemes/all_hallows_eve.xml
index f6b4212..9483cad 100644
--- a/colorSchemes/src/colorSchemes/all_hallows_eve.xml
+++ b/colorSchemes/src/colorSchemes/all_hallows_eve.xml
@@ -136,6 +136,11 @@
<option name="FOREGROUND" value="FFFFFF" />
</value>
</option>
+ <option name="COFFEESCRIPT.PARAMETER">
+ <value>
+ <option name="FONT_TYPE" value="2" />
+ </value>
+ </option>
<option name="COFFEESCRIPT.HEREDOC_CONTENT">
<value>
<option name="FOREGROUND" value="66CC33" />
diff --git a/colorSchemes/src/colorSchemes/cobalt.xml b/colorSchemes/src/colorSchemes/cobalt.xml
index 753c6e4..8f3cb46 100644
--- a/colorSchemes/src/colorSchemes/cobalt.xml
+++ b/colorSchemes/src/colorSchemes/cobalt.xml
@@ -138,6 +138,11 @@
<option name="FOREGROUND" value="CCCCCC" />
</value>
</option>
+ <option name="COFFEESCRIPT.PARAMETER">
+ <value>
+ <option name="FOREGROUND" value="CCCCCC" />
+ </value>
+ </option>
<option name="COFFEESCRIPT.HEREDOC_CONTENT">
<value>
<option name="FOREGROUND" value="3AD900" />
diff --git a/colorSchemes/src/colorSchemes/github.xml b/colorSchemes/src/colorSchemes/github.xml
index a2979fc..7e0e50c 100644
--- a/colorSchemes/src/colorSchemes/github.xml
+++ b/colorSchemes/src/colorSchemes/github.xml
@@ -116,6 +116,11 @@
<option name="FOREGROUND" value="108888" />
</value>
</option>
+ <option name="COFFEESCRIPT.PARAMETER">
+ <value>
+ <option name="FONT_TYPE" value="2" />
+ </value>
+ </option>
<option name="COFFEESCRIPT.HEREDOC_CONTENT">
<value>
<option name="FOREGROUND" value="DD1144" />
diff --git a/colorSchemes/src/colorSchemes/monokai.xml b/colorSchemes/src/colorSchemes/monokai.xml
index 362f11f..472c99d 100644
--- a/colorSchemes/src/colorSchemes/monokai.xml
+++ b/colorSchemes/src/colorSchemes/monokai.xml
@@ -130,6 +130,12 @@
<option name="FOREGROUND" value="E6DB74" />
</value>
</option>
+ <option name="COFFEESCRIPT.PARAMETER">
+ <value>
+ <option name="FOREGROUND" value="FD971F" />
+ <option name="FONT_TYPE" value="2" />
+ </value>
+ </option>
<option name="COFFEESCRIPT.JAVASCRIPT_ID">
<value>
<option name="FOREGROUND" value="E6DB74" />
diff --git a/colorSchemes/src/colorSchemes/rails_casts.xml b/colorSchemes/src/colorSchemes/rails_casts.xml
index 8bcc529..1770d47 100644
--- a/colorSchemes/src/colorSchemes/rails_casts.xml
+++ b/colorSchemes/src/colorSchemes/rails_casts.xml
@@ -113,6 +113,12 @@
<option name="FOREGROUND" value="D0D0FF" />
</value>
</option>
+ <option name="COFFEESCRIPT.PARAMETER">
+ <value>
+ <option name="EFFECT_TYPE" value="1" />
+ <option name="EFFECT_COLOR" value="E6E1DC" />
+ </value>
+ </option>
<option name="COFFEESCRIPT.HEREDOC_CONTENT">
<value>
<option name="FOREGROUND" value="A5C261" />
diff --git a/colorSchemes/src/colorSchemes/twilight.xml b/colorSchemes/src/colorSchemes/twilight.xml
index ddca675..d30254e 100644
--- a/colorSchemes/src/colorSchemes/twilight.xml
+++ b/colorSchemes/src/colorSchemes/twilight.xml
@@ -111,6 +111,11 @@
<option name="FOREGROUND" value="7587A6" />
</value>
</option>
+ <option name="COFFEESCRIPT.PARAMETER">
+ <value>
+ <option name="FOREGROUND" value="7587A6" />
+ </value>
+ </option>
<option name="COFFEESCRIPT.HEREDOC_CONTENT">
<value>
<option name="FOREGROUND" value="8F9D6A" />
diff --git a/colorSchemes/src/colorSchemes/vibrant_ink.xml b/colorSchemes/src/colorSchemes/vibrant_ink.xml
index 54b4b64..1b0c677 100644
--- a/colorSchemes/src/colorSchemes/vibrant_ink.xml
+++ b/colorSchemes/src/colorSchemes/vibrant_ink.xml
@@ -142,6 +142,11 @@
<option name="FOREGROUND" value="66ff00" />
</value>
</option>
+ <option name="COFFEESCRIPT.PARAMETER">
+ <value>
+ <option name="FONT_TYPE" value="2" />
+ </value>
+ </option>
<option name="COFFEESCRIPT.HEREDOC_ID">
<value>
<option name="FOREGROUND" value="66ff00" />
diff --git a/community-main.iml b/community-main.iml
index 2613b26..eb59ed1 100644
--- a/community-main.iml
+++ b/community-main.iml
@@ -87,10 +87,9 @@
<orderEntry type="module" module-name="github" />
<orderEntry type="module" module-name="hg4idea" />
<orderEntry type="module" module-name="android" />
- <orderEntry type="module" module-name="android-designer" />
- <orderEntry type="module" module-name="adt-branding" />
<orderEntry type="module" module-name="relaxng" />
<orderEntry type="module" module-name="gradle" />
+ <orderEntry type="module" module-name="remote-servers-impl" />
<orderEntry type="module" module-name="xml-tests" scope="TEST" />
<orderEntry type="module" module-name="dom-tests" />
<orderEntry type="module" module-name="devkit-jps-plugin" scope="TEST" />
diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java
index be2b1d2..f384d72 100644
--- a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java
+++ b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java
@@ -27,12 +27,17 @@
import com.intellij.compiler.make.CacheUtils;
import com.intellij.compiler.make.ChangedConstantsDependencyProcessor;
import com.intellij.compiler.make.DependencyCache;
+import com.intellij.compiler.options.CompilerConfigurable;
import com.intellij.compiler.progress.CompilerTask;
import com.intellij.compiler.server.BuildManager;
import com.intellij.compiler.server.CustomBuilderMessageHandler;
import com.intellij.compiler.server.DefaultMessageHandler;
import com.intellij.diagnostic.IdeErrorsDialog;
import com.intellij.diagnostic.PluginException;
+import com.intellij.notification.Notification;
+import com.intellij.notification.NotificationListener;
+import com.intellij.notification.NotificationType;
+import com.intellij.notification.Notifications;
import com.intellij.openapi.application.*;
import com.intellij.openapi.compiler.*;
import com.intellij.openapi.compiler.Compiler;
@@ -48,6 +53,7 @@
import com.intellij.openapi.module.LanguageLevelUtil;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
+import com.intellij.openapi.options.ShowSettingsUtil;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
@@ -102,6 +108,7 @@
import org.jetbrains.jps.api.RequestFuture;
import javax.swing.*;
+import javax.swing.event.HyperlinkEvent;
import java.io.*;
import java.util.*;
import java.util.concurrent.TimeUnit;
@@ -639,14 +646,14 @@
final String contentName =
forceCompile ? CompilerBundle.message("compiler.content.name.compile") : CompilerBundle.message("compiler.content.name.make");
- final CompilerTask compileTask = new CompilerTask(myProject, contentName, ApplicationManager.getApplication().isUnitTestMode(), true, true,
- isCompilationStartedAutomatically(scope));
+ final boolean isUnitTestMode = ApplicationManager.getApplication().isUnitTestMode();
+ final CompilerTask compileTask = new CompilerTask(myProject, contentName, isUnitTestMode, true, true, isCompilationStartedAutomatically(scope));
StatusBar.Info.set("", myProject, "Compiler");
if (useExtProcessBuild) {
// ensure the project model seen by build process is up-to-date
myProject.save();
- if (!ApplicationManager.getApplication().isUnitTestMode()) {
+ if (!isUnitTestMode) {
ApplicationManager.getApplication().saveSettings();
}
}
@@ -743,6 +750,12 @@
if (message != null) {
compileContext.addMessage(message);
}
+ else {
+ if (!isUnitTestMode) {
+ notifyDeprecatedImplementation();
+ }
+ }
+
TranslatingCompilerFilesMonitor.getInstance().ensureInitializationCompleted(myProject, compileContext.getProgressIndicator());
doCompile(compileContext, isRebuild, forceCompile, callback, checkCachesVersion);
}
@@ -770,6 +783,25 @@
});
}
+ private void notifyDeprecatedImplementation() {
+ final NotificationListener hyperlinkHandler = new NotificationListener.Adapter() {
+ @Override
+ protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) {
+ notification.expire();
+ if (!myProject.isDisposed()) {
+ ShowSettingsUtil.getInstance().editConfigurable(myProject, new CompilerConfigurable(myProject));
+ }
+ }
+ };
+ final Notification notification = new Notification(
+ "Compile", "Deprecated make implementation",
+ "Old implementation of \"Make\" feature is enabled for this project.<br>It has been deprecated and will be removed soon.<br>Please enable newer 'external build' feature in <a href=\"#\">Settings | Compiler</a>.",
+ NotificationType.WARNING,
+ hyperlinkHandler
+ );
+ Notifications.Bus.notify(notification, myProject);
+ }
+
@Nullable @TestOnly
public static ExitStatus getExternalBuildExitStatus(CompileContext context) {
return context.getUserData(COMPILE_SERVER_BUILD_STATUS);
diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/ProblemsViewImpl.java b/java/compiler/impl/src/com/intellij/compiler/impl/ProblemsViewImpl.java
index 320898a..e625dc1 100644
--- a/java/compiler/impl/src/com/intellij/compiler/impl/ProblemsViewImpl.java
+++ b/java/compiler/impl/src/com/intellij/compiler/impl/ProblemsViewImpl.java
@@ -70,7 +70,7 @@
if (project.isDisposed()) {
return;
}
- final ToolWindow tw = wm.registerToolWindow(PROBLEMS_TOOLWINDOW_ID, false, ToolWindowAnchor.BOTTOM, project);
+ final ToolWindow tw = wm.registerToolWindow(PROBLEMS_TOOLWINDOW_ID, false, ToolWindowAnchor.BOTTOM, project, true);
tw.setIcon(AllIcons.Toolwindows.Problems);
final Content content = ContentFactory.SERVICE.getInstance().createContent(myPanel, "", false);
// todo: setup content?
diff --git a/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java b/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java
index a9ad726..b0a4969 100644
--- a/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java
+++ b/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java
@@ -69,11 +69,13 @@
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.openapi.vfs.newvfs.BulkFileListener;
import com.intellij.openapi.vfs.newvfs.events.VFileEvent;
+import com.intellij.openapi.vfs.newvfs.impl.FileNameCache;
import com.intellij.util.Alarm;
import com.intellij.util.Function;
import com.intellij.util.SmartList;
import com.intellij.util.concurrency.Semaphore;
import com.intellij.util.concurrency.SequentialTaskExecutor;
+import com.intellij.util.containers.IntArrayList;
import com.intellij.util.io.storage.HeavyProcessLatch;
import com.intellij.util.messages.MessageBusConnection;
import com.intellij.util.net.NetUtils;
@@ -391,12 +393,20 @@
synchronized (myProjectDataMap) {
ProjectData data = myProjectDataMap.get(projectPath);
if (data != null && !data.myNeedRescan) {
- return new ArrayList<String>(data.myChanged);
+ return convertToStringPaths(data.myChanged);
}
return null;
}
}
+ private static List<String> convertToStringPaths(final Collection<InternedPath> interned) {
+ final ArrayList<String> list = new ArrayList<String>(interned.size());
+ for (InternedPath path : interned) {
+ list.add(path.getValue());
+ }
+ return list;
+ }
+
@Nullable
private static String getProjectPath(final Project project) {
final String url = project.getPresentableUrl();
@@ -419,7 +429,7 @@
}
private void runAutoMake() {
- final List<RequestFuture> futures = new ArrayList<RequestFuture>();
+ final List<RequestFuture> futures = new SmartList<RequestFuture>();
for (final Project project : getActiveProjects()) {
if (!canStartAutoMake(project)) {
continue;
@@ -472,7 +482,7 @@
}
public Collection<RequestFuture> cancelAutoMakeTasks(Project project) {
- final Collection<RequestFuture> futures = new ArrayList<RequestFuture>();
+ final Collection<RequestFuture> futures = new SmartList<RequestFuture>();
synchronized (myAutomakeFutures) {
for (Map.Entry<RequestFuture, Project> entry : myAutomakeFutures.entrySet()) {
if (entry.getValue().equals(project)) {
@@ -490,11 +500,38 @@
final Project project, final boolean isRebuild, final boolean isMake,
final boolean onlyCheckUpToDate, final List<TargetTypeBuildScope> scopes,
final Collection<String> paths,
- final Map<String, String> userData, final DefaultMessageHandler handler) {
+ final Map<String, String> userData, final DefaultMessageHandler messageHandler) {
final String projectPath = getProjectPath(project);
final UUID sessionId = UUID.randomUUID();
+ final boolean isAutomake = messageHandler instanceof AutoMakeMessageHandler;
+ final BuilderMessageHandler handler = new MessageHandlerWrapper(messageHandler) {
+ @Override
+ public void buildStarted(UUID sessionId) {
+ super.buildStarted(sessionId);
+ try {
+ ApplicationManager.getApplication().getMessageBus().syncPublisher(BuildManagerListener.TOPIC).buildStarted(project, sessionId, isAutomake);
+ }
+ catch (Throwable e) {
+ LOG.error(e);
+ }
+ }
+ @Override
+ public void sessionTerminated(UUID sessionId) {
+ try {
+ super.sessionTerminated(sessionId);
+ }
+ finally {
+ try {
+ ApplicationManager.getApplication().getMessageBus().syncPublisher(BuildManagerListener.TOPIC).buildFinished(project, sessionId, isAutomake);
+ }
+ catch (Throwable e) {
+ LOG.error(e);
+ }
+ }
+ }
+ };
// ensure server is listening
if (myListenPort < 0) {
try {
@@ -548,9 +585,9 @@
LOG.info("Scheduling build for " +
projectPath +
"; CHANGED: " +
- new HashSet<String>(data.myChanged) +
+ new HashSet<String>(convertToStringPaths(data.myChanged)) +
"; DELETED: " +
- new HashSet<String>(data.myDeleted));
+ new HashSet<String>(convertToStringPaths(data.myDeleted)));
}
currentFSChanges = data.getAndResetRescanFlag() ? null : data.createNextEvent();
projectTaskQueue = data.taskQueue;
@@ -568,7 +605,7 @@
userData, globals, currentFSChanges);
}
- myMessageDispatcher.registerBuildMessageHandler(sessionId, new BuilderMessageHandlerWrapper(handler) {
+ myMessageDispatcher.registerBuildMessageHandler(sessionId, new MessageHandlerWrapper(handler) {
@Override
public void sessionTerminated(UUID sessionId) {
try {
@@ -815,8 +852,8 @@
cmdLine.addParameter("-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=" + debugPort);
}
- if (Registry.is("compiler.process.use.memory.temp.cache")) {
- cmdLine.addParameter("-D"+ GlobalOptions.USE_MEMORY_TEMP_CACHE_OPTION);
+ if (!Registry.is("compiler.process.use.memory.temp.cache")) {
+ cmdLine.addParameter("-D"+ GlobalOptions.USE_MEMORY_TEMP_CACHE_OPTION + "=false");
}
if (Registry.is("compiler.process.use.external.javac")) {
cmdLine.addParameter("-D"+ GlobalOptions.USE_EXTERNAL_JAVAC_OPTION);
@@ -851,7 +888,7 @@
cp.addAll(myClasspathManager.getBuildProcessPluginsClasspath(project));
if (isProfilingMode) {
cp.add(new File(workDirectory, "yjp-controller-api-redist.jar").getPath());
- cmdLine.addParameter("-agentlib:yjpagent=disablej2ee,disablealloc,sessionname=ExternalBuild");
+ cmdLine.addParameter("-agentlib:yjpagent=disablej2ee,disablealloc,delay=10000,sessionname=ExternalBuild");
}
cmdLine.addParameter("-classpath");
@@ -971,34 +1008,6 @@
return builder.toString();
}
- private static class BuilderMessageHandlerWrapper implements BuilderMessageHandler {
- private final DefaultMessageHandler myHandler;
-
- public BuilderMessageHandlerWrapper(DefaultMessageHandler handler) {
- myHandler = handler;
- }
-
- @Override
- public void buildStarted(UUID sessionId) {
- myHandler.buildStarted(sessionId);
- }
-
- @Override
- public void handleBuildMessage(Channel channel, UUID sessionId, CmdlineRemoteProto.Message.BuilderMessage msg) {
- myHandler.handleBuildMessage(channel, sessionId, msg);
- }
-
- @Override
- public void handleFailure(UUID sessionId, CmdlineRemoteProto.Message.Failure failure) {
- myHandler.handleFailure(sessionId, failure);
- }
-
- @Override
- public void sessionTerminated(UUID sessionId) {
- myHandler.sessionTerminated(sessionId);
- }
- }
-
private static abstract class BuildManagerPeriodicTask implements Runnable {
private final Alarm myAlarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD);
private final AtomicBoolean myInProgress = new AtomicBoolean(false);
@@ -1107,8 +1116,8 @@
private static class ProjectData {
final SequentialTaskExecutor taskQueue;
- private final Set<String> myChanged = new THashSet<String>(FileUtil.PATH_HASHING_STRATEGY);
- private final Set<String> myDeleted = new THashSet<String>(FileUtil.PATH_HASHING_STRATEGY);
+ private final Set<InternedPath> myChanged = new THashSet<InternedPath>();
+ private final Set<InternedPath> myDeleted = new THashSet<InternedPath>();
private long myNextEventOrdinal = 0L;
private boolean myNeedRescan = true;
@@ -1118,15 +1127,21 @@
public void addChanged(Collection<String> paths) {
if (!myNeedRescan) {
- myDeleted.removeAll(paths);
- myChanged.addAll(paths);
+ for (String path : paths) {
+ final InternedPath _path = InternedPath.create(path);
+ myDeleted.remove(_path);
+ myChanged.add(_path);
+ }
}
}
public void addDeleted(Collection<String> paths) {
if (!myNeedRescan) {
- myChanged.removeAll(paths);
- myDeleted.addAll(paths);
+ for (String path : paths) {
+ final InternedPath _path = InternedPath.create(path);
+ myChanged.remove(_path);
+ myDeleted.add(_path);
+ }
}
}
@@ -1134,10 +1149,17 @@
final CmdlineRemoteProto.Message.ControllerMessage.FSEvent.Builder builder =
CmdlineRemoteProto.Message.ControllerMessage.FSEvent.newBuilder();
builder.setOrdinal(++myNextEventOrdinal);
- builder.addAllChangedPaths(myChanged);
+
+ for (InternedPath path : myChanged) {
+ builder.addChangedPaths(path.getValue());
+ }
myChanged.clear();
- builder.addAllDeletedPaths(myDeleted);
+
+ for (InternedPath path : myDeleted) {
+ builder.addDeletedPaths(path.getValue());
+ }
myDeleted.clear();
+
return builder.build();
}
@@ -1155,4 +1177,84 @@
}
}
+ private static abstract class InternedPath {
+ protected final int[] myPath;
+
+ /**
+ * @param path assuming system-independent path with forward slashes
+ */
+ protected InternedPath(String path) {
+ final IntArrayList list = new IntArrayList();
+ final StringTokenizer tokenizer = new StringTokenizer(path, "/", false);
+ while(tokenizer.hasMoreTokens()) {
+ final String element = tokenizer.nextToken();
+ list.add(FileNameCache.storeName(element));
+ }
+ myPath = list.toArray();
+ }
+
+ public abstract String getValue();
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ InternedPath path = (InternedPath)o;
+
+ if (!Arrays.equals(myPath, path.myPath)) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return Arrays.hashCode(myPath);
+ }
+
+ public static InternedPath create(String path) {
+ return path.startsWith("/")? new XInternedPath(path) : new WinInternedPath(path);
+ }
+ }
+
+ private static class WinInternedPath extends InternedPath {
+ private WinInternedPath(String path) {
+ super(path);
+ }
+
+ public String getValue() {
+ if (myPath.length == 1) {
+ final String name = FileNameCache.getVFileName(myPath[0]);
+ // handle case of windows drive letter
+ return name.length() == 2 && name.endsWith(":")? name + "/" : name;
+ }
+
+ final StringBuilder buf = new StringBuilder();
+ for (int element : myPath) {
+ if (buf.length() > 0) {
+ buf.append("/");
+ }
+ buf.append(FileNameCache.getVFileName(element));
+ }
+ return buf.toString();
+ }
+ }
+
+ private static class XInternedPath extends InternedPath {
+ private XInternedPath(String path) {
+ super(path);
+ }
+
+ public String getValue() {
+ if (myPath.length > 0) {
+ final StringBuilder buf = new StringBuilder();
+ for (int element : myPath) {
+ buf.append("/").append(FileNameCache.getVFileName(element));
+ }
+ return buf.toString();
+ }
+ return "/";
+ }
+ }
+
}
diff --git a/java/compiler/impl/src/com/intellij/compiler/server/BuildManagerListener.java b/java/compiler/impl/src/com/intellij/compiler/server/BuildManagerListener.java
new file mode 100644
index 0000000..292e6bd
--- /dev/null
+++ b/java/compiler/impl/src/com/intellij/compiler/server/BuildManagerListener.java
@@ -0,0 +1,18 @@
+package com.intellij.compiler.server;
+
+import com.intellij.openapi.project.Project;
+import com.intellij.util.messages.Topic;
+
+import java.util.UUID;
+
+/**
+ * @author Eugene Zhuravlev
+ * Date: 7/3/13
+ */
+public interface BuildManagerListener {
+ Topic<BuildManagerListener> TOPIC = Topic.create("Build Manager", BuildManagerListener.class);
+
+ void buildStarted(Project project, UUID sessionId, boolean isAutomake);
+
+ void buildFinished(Project project, UUID sessionId, boolean isAutomake);
+}
diff --git a/java/compiler/impl/src/com/intellij/compiler/server/MessageHandlerWrapper.java b/java/compiler/impl/src/com/intellij/compiler/server/MessageHandlerWrapper.java
new file mode 100644
index 0000000..a90ff9b
--- /dev/null
+++ b/java/compiler/impl/src/com/intellij/compiler/server/MessageHandlerWrapper.java
@@ -0,0 +1,38 @@
+package com.intellij.compiler.server;
+
+import org.jboss.netty.channel.Channel;
+import org.jetbrains.jps.api.CmdlineRemoteProto;
+
+import java.util.UUID;
+
+/**
+* @author Eugene Zhuravlev
+* Date: 7/3/13
+*/
+class MessageHandlerWrapper implements BuilderMessageHandler {
+ private final BuilderMessageHandler myHandler;
+
+ public MessageHandlerWrapper(BuilderMessageHandler handler) {
+ myHandler = handler;
+ }
+
+ @Override
+ public void buildStarted(UUID sessionId) {
+ myHandler.buildStarted(sessionId);
+ }
+
+ @Override
+ public void handleBuildMessage(Channel channel, UUID sessionId, CmdlineRemoteProto.Message.BuilderMessage msg) {
+ myHandler.handleBuildMessage(channel, sessionId, msg);
+ }
+
+ @Override
+ public void handleFailure(UUID sessionId, CmdlineRemoteProto.Message.Failure failure) {
+ myHandler.handleFailure(sessionId, failure);
+ }
+
+ @Override
+ public void sessionTerminated(UUID sessionId) {
+ myHandler.sessionTerminated(sessionId);
+ }
+}
diff --git a/java/compiler/instrumentation-util/src/com/intellij/compiler/instrumentation/InstrumentationClassFinder.java b/java/compiler/instrumentation-util/src/com/intellij/compiler/instrumentation/InstrumentationClassFinder.java
index 77a13ad..3716f4d 100644
--- a/java/compiler/instrumentation-util/src/com/intellij/compiler/instrumentation/InstrumentationClassFinder.java
+++ b/java/compiler/instrumentation-util/src/com/intellij/compiler/instrumentation/InstrumentationClassFinder.java
@@ -101,7 +101,7 @@
return aClass;
}
- final InputStream is = aClass == null? getClassBytesAsStream(internalName) : null;
+ final InputStream is = aClass == null? getClassBytesStream(internalName) : null;
if (is == null) {
if (aClass == null) {
@@ -132,6 +132,23 @@
public InputStream getClassBytesAsStream(String className) throws IOException {
final String internalName = className.replace('.', '/'); // normalize
+ final PseudoClass aClass = myLoaded.get(internalName);
+ if (aClass == PseudoClass.NULL_OBJ) {
+ return null;
+ }
+ InputStream bytes = null;
+ try {
+ bytes = getClassBytesStream(internalName);
+ }
+ finally {
+ if (aClass == null && bytes == null) {
+ myLoaded.put(internalName, PseudoClass.NULL_OBJ);
+ }
+ }
+ return bytes;
+ }
+
+ private InputStream getClassBytesStream(String internalName) throws IOException {
InputStream is = null;
// first look into platformCp
final String resourceName = internalName + CLASS_RESOURCE_EXTENSION;
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/LineBreakpoint.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/LineBreakpoint.java
index 76f1b79..9ca1bd1 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/LineBreakpoint.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/LineBreakpoint.java
@@ -36,6 +36,7 @@
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.markup.RangeHighlighter;
import com.intellij.openapi.fileEditor.FileDocumentManager;
+import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ProjectFileIndex;
import com.intellij.openapi.roots.ProjectRootManager;
@@ -44,12 +45,16 @@
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
+import com.intellij.psi.impl.java.stubs.index.JavaFullClassNameIndex;
import com.intellij.psi.jsp.JspFile;
+import com.intellij.psi.search.EverythingGlobalScope;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.ui.classFilter.ClassFilter;
+import com.intellij.util.Function;
import com.intellij.util.Processor;
import com.intellij.util.StringBuilderSpinAllocator;
+import com.intellij.util.containers.ContainerUtil;
import com.intellij.xdebugger.XDebuggerUtil;
import com.sun.jdi.*;
import com.sun.jdi.event.LocatableEvent;
@@ -203,6 +208,37 @@
return true;
}
}
+ if (LOG.isDebugEnabled()) {
+ final GlobalSearchScope scope = debugProcess.getSearchScope();
+ final boolean contains = scope.contains(breakpointFile);
+ final Project project = getProject();
+ final List<VirtualFile> files = ContainerUtil.map(
+ JavaFullClassNameIndex.getInstance().get(className.hashCode(), project, scope), new Function<PsiClass, VirtualFile>() {
+ @Override
+ public VirtualFile fun(PsiClass aClass) {
+ return aClass.getContainingFile().getVirtualFile();
+ }
+ });
+ final List<VirtualFile> allFiles = ContainerUtil.map(
+ JavaFullClassNameIndex.getInstance().get(className.hashCode(), project, new EverythingGlobalScope(project)), new Function<PsiClass, VirtualFile>() {
+ @Override
+ public VirtualFile fun(PsiClass aClass) {
+ return aClass.getContainingFile().getVirtualFile();
+ }
+ });
+ final VirtualFile contentRoot = fileIndex.getContentRootForFile(breakpointFile);
+ final Module module = fileIndex.getModuleForFile(breakpointFile);
+
+ LOG.debug("Did not find '" +
+ className + "' in " + scope +
+ "; contains=" + contains +
+ "; contentRoot=" + contentRoot +
+ "; module = " + module +
+ "; all files in index are: " + files+
+ "; all possible files are: " + allFiles
+ );
+ }
+
return false;
}
}
@@ -218,7 +254,7 @@
public Collection<VirtualFile> compute() {
final PsiClass[] classes = JavaPsiFacade.getInstance(myProject).findClasses(topLevelClassName, scope);
if (LOG.isDebugEnabled()) {
- LOG.debug("Found "+ classes.length + " classes " + topLevelClassName + " in scope");
+ LOG.debug("Found "+ classes.length + " classes " + topLevelClassName + " in scope "+scope);
}
if (classes.length == 0) {
return null;
@@ -241,12 +277,14 @@
LOG.debug(msg.toString());
}
- if (psiFile != null) {
- final VirtualFile vFile = psiFile.getVirtualFile();
- if (vFile != null && fileIndex.isInSourceContent(vFile)) {
- list.add(vFile);
- }
+ if (psiFile == null) {
+ return null;
}
+ final VirtualFile vFile = psiFile.getVirtualFile();
+ if (vFile == null || !fileIndex.isInSourceContent(vFile)) {
+ return null; // this will switch off the check if at least one class is from libraries
+ }
+ list.add(vFile);
}
return list;
}
diff --git a/java/debugger/openapi/src/com/intellij/debugger/engine/DebuggerUtils.java b/java/debugger/openapi/src/com/intellij/debugger/engine/DebuggerUtils.java
index 1dc0610..9fcc7d7 100644
--- a/java/debugger/openapi/src/com/intellij/debugger/engine/DebuggerUtils.java
+++ b/java/debugger/openapi/src/com/intellij/debugger/engine/DebuggerUtils.java
@@ -130,7 +130,7 @@
}
}
- public static final int MAX_DISPLAY_LABEL_LENGTH = 1024/*kb*/ *1024 /*bytes*/ / 2; // 1 Mb string
+ public static final int MAX_DISPLAY_LABEL_LENGTH = 1024 * 5;
public static String convertToPresentationString(String str) {
if (str.length() > MAX_DISPLAY_LABEL_LENGTH) {
diff --git a/java/execution/openapi/src/com/intellij/execution/configurations/PatchedRunnableState.java b/java/execution/openapi/src/com/intellij/execution/configurations/PatchedRunnableState.java
index 05d11b7..e09a206 100644
--- a/java/execution/openapi/src/com/intellij/execution/configurations/PatchedRunnableState.java
+++ b/java/execution/openapi/src/com/intellij/execution/configurations/PatchedRunnableState.java
@@ -15,6 +15,6 @@
*/
package com.intellij.execution.configurations;
-public interface PatchedRunnableState extends RunnableState{
+public interface PatchedRunnableState extends RunProfileState {
RunnerSettings getPatcher();
}
\ No newline at end of file
diff --git a/java/idea-ui/src/com/intellij/ide/actions/ImportModuleAction.java b/java/idea-ui/src/com/intellij/ide/actions/ImportModuleAction.java
index d588951..bd92290 100644
--- a/java/idea-ui/src/com/intellij/ide/actions/ImportModuleAction.java
+++ b/java/idea-ui/src/com/intellij/ide/actions/ImportModuleAction.java
@@ -35,6 +35,7 @@
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.projectImport.ProjectImportProvider;
import com.intellij.util.containers.ContainerUtil;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
@@ -106,6 +107,15 @@
String description = getFileChooserDescription(project);
descriptor.setDescription(description);
+ return selectFileAndCreateWizard(project, dialogParent, descriptor, providers);
+ }
+
+ @Nullable
+ public static AddModuleWizard selectFileAndCreateWizard(final Project project,
+ @Nullable Component dialogParent,
+ @NotNull FileChooserDescriptor descriptor,
+ ProjectImportProvider[] providers)
+ {
FileChooserDialog chooser = FileChooserFactory.getInstance().createFileChooser(descriptor, project, dialogParent);
VirtualFile toSelect = null;
String lastLocation = PropertiesComponent.getInstance().getValue(LAST_IMPORTED_LOCATION);
@@ -151,7 +161,7 @@
}
public static AddModuleWizard createImportWizard(final Project project,
- Component dialogParent,
+ @Nullable Component dialogParent,
final VirtualFile file,
ProjectImportProvider... providers) {
List<ProjectImportProvider> available = ContainerUtil.filter(providers, new Condition<ProjectImportProvider>() {
diff --git a/java/idea-ui/src/com/intellij/ide/actions/ShowStructureSettingsAction.java b/java/idea-ui/src/com/intellij/ide/actions/ShowStructureSettingsAction.java
index 81e4729..777105f 100644
--- a/java/idea-ui/src/com/intellij/ide/actions/ShowStructureSettingsAction.java
+++ b/java/idea-ui/src/com/intellij/ide/actions/ShowStructureSettingsAction.java
@@ -15,20 +15,15 @@
*/
package com.intellij.ide.actions;
-import com.intellij.facet.Facet;
-import com.intellij.facet.FacetManager;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
-import com.intellij.openapi.module.Module;
-import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.options.ShowSettingsUtil;
import com.intellij.openapi.options.newEditor.OptionsEditorDialog;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable;
-import com.intellij.openapi.ui.Messages;
public class ShowStructureSettingsAction extends AnAction implements DumbAware {
public void actionPerformed(AnActionEvent e) {
@@ -37,37 +32,6 @@
project = ProjectManager.getInstance().getDefaultProject();
}
- // TEMPORARY HACK! DO NOT MERGE INTO INTELLIJ. This just works around a lot
- // of confusion caused by the fact that the structure dialog lets you edit
- // project state which is ignored by gradle, so temporarily disable this
- // dialog for Android-Gradle-based projects.
- if (isGradleProject(project)) {
- showDisabledProjectStructureDialogMessage();
- }
-
ShowSettingsUtil.getInstance().editConfigurable(project, OptionsEditorDialog.DIMENSION_KEY, ProjectStructureConfigurable.getInstance(project));
}
-
- public static void showDisabledProjectStructureDialogMessage() {
- Messages.showWarningDialog(
- "We will provide a UI to configure project settings later. " +
- "Until then, please manually edit your build.gradle file to " +
- "configure source folders, libraries and dependencies.\n\n" +
- "NOTE THAT EDITS MADE IN THE FOLLOWING DIALOG DO NOT AFFECT THE GRADLE BUILD.\n" +
- "The dialog can be used for temporary adjustments to SDKs etc.",
- "Project Structure");
- }
-
- public static boolean isGradleProject(Project project) {
- ModuleManager moduleManager = ModuleManager.getInstance(project);
- for (Module module : moduleManager.getModules()) {
- FacetManager facetManager = FacetManager.getInstance(module);
- for (Facet facet : facetManager.getAllFacets()) {
- if ("android-gradle".equals(facet.getType().getStringId())) {
- return true;
- }
- }
- }
- return false;
- }
}
\ No newline at end of file
diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddModuleWizard.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddModuleWizard.java
index 167b861..2cb74deb 100644
--- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddModuleWizard.java
+++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddModuleWizard.java
@@ -89,7 +89,7 @@
}
/** Import mode */
- public AddModuleWizard(Project project, String filePath, ProjectImportProvider... importProviders) {
+ public AddModuleWizard(@Nullable Project project, String filePath, ProjectImportProvider... importProviders) {
super(getImportWizardTitle(project, importProviders), project);
myCurrentProject = project;
myImportProviders = importProviders;
diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SelectTemplateStep.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SelectTemplateStep.java
index cfdcf81..13b4fcd 100644
--- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SelectTemplateStep.java
+++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SelectTemplateStep.java
@@ -156,7 +156,16 @@
@Override
public String getHelpId() {
- return myWizardContext.isCreatingNewProject() ? "New_Project_Main_Settings" : "Add_Module_Main_Settings";
+ String helpId = myWizardContext.isCreatingNewProject() ? "New_Project_Main_Settings" : "Add_Module_Main_Settings";
+ ProjectTemplate projectTemplate = getSelectedTemplate();
+ if (projectTemplate instanceof WebProjectTemplate) {
+ WebProjectTemplate webProjectTemplate = (WebProjectTemplate) projectTemplate;
+ String subHelpId = webProjectTemplate.getHelpId();
+ if (subHelpId != null) {
+ helpId = helpId + ":" + subHelpId;
+ }
+ }
+ return helpId;
}
private static NamePathComponent initNamePathComponent(WizardContext context) {
diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/IdeaProjectSettingsService.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/IdeaProjectSettingsService.java
index 612399a..e654eab 100644
--- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/IdeaProjectSettingsService.java
+++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/IdeaProjectSettingsService.java
@@ -16,7 +16,6 @@
package com.intellij.openapi.roots.ui.configuration;
import com.intellij.compiler.actions.ArtifactAwareProjectSettingsService;
-import com.intellij.ide.actions.ShowStructureSettingsAction;
import com.intellij.ide.projectView.impl.ModuleGroup;
import com.intellij.ide.util.projectWizard.JdkChooserPanel;
import com.intellij.openapi.module.Module;
@@ -66,7 +65,6 @@
@Override
public void openLibrary(@NotNull final Library library) {
- warnIfGradleProject();
final ProjectStructureConfigurable config = ProjectStructureConfigurable.getInstance(myProject);
ShowSettingsUtil.getInstance().editConfigurable(myProject, config, new Runnable() {
@Override
@@ -83,7 +81,6 @@
@Override
public void openModuleSettings(final Module module) {
- warnIfGradleProject();
ModulesConfigurator.showDialog(myProject, module.getName(), null);
}
@@ -94,7 +91,6 @@
@Override
public void openModuleLibrarySettings(final Module module) {
- warnIfGradleProject();
ModulesConfigurator.showDialog(myProject, module.getName(), ClasspathEditor.NAME);
}
@@ -105,7 +101,6 @@
@Override
public void openContentEntriesSettings(final Module module) {
- warnIfGradleProject();
ModulesConfigurator.showDialog(myProject, module.getName(), ContentEntriesEditor.NAME);
}
@@ -116,7 +111,6 @@
@Override
public void openModuleDependenciesSettings(@NotNull final Module module, @Nullable final OrderEntry orderEntry) {
- warnIfGradleProject();
ShowSettingsUtil.getInstance().editConfigurable(myProject, ProjectStructureConfigurable.getInstance(myProject), new Runnable() {
@Override
public void run() {
@@ -132,7 +126,6 @@
@Override
public void openLibraryOrSdkSettings(@NotNull final OrderEntry orderEntry) {
- warnIfGradleProject();
final ProjectStructureConfigurable config = ProjectStructureConfigurable.getInstance(myProject);
ShowSettingsUtil.getInstance().editConfigurable(myProject, config, new Runnable() {
@Override
@@ -173,14 +166,6 @@
@Override
public void openArtifactSettings(@Nullable Artifact artifact) {
- warnIfGradleProject();
ModulesConfigurator.showArtifactSettings(myProject, artifact);
}
-
- // TEMPORARY HACK!! REMOVE ME ASAP!
- private void warnIfGradleProject() {
- if (ShowStructureSettingsAction.isGradleProject(myProject)) {
- ShowStructureSettingsAction.showDisabledProjectStructureDialogMessage();
- }
- }
}
diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectJdksConfigurable.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectJdksConfigurable.java
index 356eddb..d78731b 100644
--- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectJdksConfigurable.java
+++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectJdksConfigurable.java
@@ -172,7 +172,7 @@
}
});
actions.add(new MyActionGroupWrapper(group));
- actions.add(new MyDeleteAction(forAll(Conditions.alwaysTrue())));
+ actions.add(new MyDeleteAction(Conditions.<Object[]>alwaysTrue()));
return actions;
}
diff --git a/java/idea-ui/src/com/intellij/platform/templates/LocalArchivedTemplate.java b/java/idea-ui/src/com/intellij/platform/templates/LocalArchivedTemplate.java
index 1b9f3c2..f671335 100644
--- a/java/idea-ui/src/com/intellij/platform/templates/LocalArchivedTemplate.java
+++ b/java/idea-ui/src/com/intellij/platform/templates/LocalArchivedTemplate.java
@@ -19,6 +19,7 @@
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleType;
import com.intellij.openapi.module.ModuleTypeManager;
+import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.util.JDOMUtil;
@@ -43,8 +44,8 @@
*/
public class LocalArchivedTemplate extends ArchivedProjectTemplate {
- public static final String DESCRIPTION_PATH = ".idea/description.html";
- static final String IDEA_INPUT_FIELDS_XML = ".idea/project-template.xml";
+ public static final String DESCRIPTION_PATH = Project.DIRECTORY_STORE_FOLDER + "/description.html";
+ static final String IDEA_INPUT_FIELDS_XML = Project.DIRECTORY_STORE_FOLDER + "/project-template.xml";
private final URL myArchivePath;
private final ModuleType myModuleType;
diff --git a/java/idea-ui/src/com/intellij/platform/templates/SaveProjectAsTemplateAction.java b/java/idea-ui/src/com/intellij/platform/templates/SaveProjectAsTemplateAction.java
index e6cb2a3..54c0b7c 100644
--- a/java/idea-ui/src/com/intellij/platform/templates/SaveProjectAsTemplateAction.java
+++ b/java/idea-ui/src/com/intellij/platform/templates/SaveProjectAsTemplateAction.java
@@ -162,7 +162,7 @@
if (relativePath == null) {
throw new RuntimeException("Can't find relative path for " + virtualFile);
}
- final boolean system = ".idea".equals(virtualFile.getParent().getName());
+ final boolean system = Project.DIRECTORY_STORE_FOLDER.equals(virtualFile.getParent().getName());
if (system) {
if (!fileName.equals("description.html") &&
!fileName.equals(PROJECT_TEMPLATE_XML) &&
diff --git a/java/idea-ui/src/com/intellij/platform/templates/SystemFileProcessor.java b/java/idea-ui/src/com/intellij/platform/templates/SystemFileProcessor.java
index f57c954..29f21b4 100644
--- a/java/idea-ui/src/com/intellij/platform/templates/SystemFileProcessor.java
+++ b/java/idea-ui/src/com/intellij/platform/templates/SystemFileProcessor.java
@@ -53,7 +53,7 @@
@Override
protected String encodeFileText(String content, VirtualFile file, Project project) throws IOException {
final String fileName = file.getName();
- if (file.getParent().getName().equals(".idea") && fileName.equals("workspace.xml")) {
+ if (file.getParent().getName().equals(Project.DIRECTORY_STORE_FOLDER) && fileName.equals("workspace.xml")) {
List<Object> componentList = new ArrayList<Object>();
for (String componentName : COMPONENT_NAMES) {
diff --git a/java/idea-ui/src/com/intellij/platform/templates/TemplateModuleBuilder.java b/java/idea-ui/src/com/intellij/platform/templates/TemplateModuleBuilder.java
index 61bf78f..4b0727a 100644
--- a/java/idea-ui/src/com/intellij/platform/templates/TemplateModuleBuilder.java
+++ b/java/idea-ui/src/com/intellij/platform/templates/TemplateModuleBuilder.java
@@ -205,7 +205,7 @@
@Nullable
@Override
public String fun(String path) {
- if (moduleMode && path.contains(".idea")) return null;
+ if (moduleMode && path.contains(Project.DIRECTORY_STORE_FOLDER)) return null;
if (basePackage != null) {
return path.replace(getPathFragment(basePackage.getDefaultValue()), getPathFragment(basePackage.getValue()));
}
@@ -218,7 +218,7 @@
FileType fileType = FileTypeManager.getInstance().getFileTypeByExtension(FileUtilRt.getExtension(file.getName()));
return fileType.isBinary() ? content : processTemplates(projectName, new String(content), file);
}
- });
+ }, true);
String iml = ContainerUtil.find(dir.list(), new Condition<String>() {
@Override
public boolean value(String s) {
diff --git a/java/idea-ui/src/com/intellij/projectImport/ProjectFormatPanel.java b/java/idea-ui/src/com/intellij/projectImport/ProjectFormatPanel.java
index e367ce7..9b7795d 100644
--- a/java/idea-ui/src/com/intellij/projectImport/ProjectFormatPanel.java
+++ b/java/idea-ui/src/com/intellij/projectImport/ProjectFormatPanel.java
@@ -23,13 +23,14 @@
import com.intellij.ide.util.PropertiesComponent;
import com.intellij.ide.util.projectWizard.WizardContext;
import com.intellij.openapi.components.StorageScheme;
+import com.intellij.openapi.project.Project;
import javax.swing.*;
public class ProjectFormatPanel {
private static final String STORAGE_FORMAT_PROPERTY = "default.storage.format";
- public static final String DIR_BASED = ".idea (directory based)";
+ public static final String DIR_BASED = Project.DIRECTORY_STORE_FOLDER + " (directory based)";
private static final String FILE_BASED = ".ipr (file based)";
private JComboBox myStorageFormatCombo;
diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RemoveUnusedVariableUtil.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RemoveUnusedVariableUtil.java
index 4515cc8..dd32cd0 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RemoveUnusedVariableUtil.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RemoveUnusedVariableUtil.java
@@ -18,6 +18,7 @@
import com.intellij.psi.*;
import com.intellij.psi.util.InheritanceUtil;
import com.intellij.psi.util.PropertyUtil;
+import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
import com.intellij.util.IncorrectOperationException;
import gnu.trove.THashSet;
diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/ExplicitTypeCanBeDiamondInspection.java b/java/java-analysis-impl/src/com/intellij/codeInspection/ExplicitTypeCanBeDiamondInspection.java
index e4c583d..08bb341 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInspection/ExplicitTypeCanBeDiamondInspection.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/ExplicitTypeCanBeDiamondInspection.java
@@ -19,8 +19,10 @@
import com.intellij.codeInsight.intention.HighPriorityAction;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.TextRange;
import com.intellij.psi.*;
import com.intellij.psi.impl.PsiDiamondTypeUtil;
+import com.intellij.psi.impl.source.tree.ChildRole;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
@@ -67,8 +69,11 @@
LOG.assertTrue(classReference != null);
final PsiReferenceParameterList parameterList = classReference.getParameterList();
LOG.assertTrue(parameterList != null);
- holder.registerProblem(parameterList, "Explicit type argument #ref #loc can be replaced with <>",
- ProblemHighlightType.LIKE_UNUSED_SYMBOL, new ReplaceWithDiamondFix());
+ final PsiElement firstChild = parameterList.getFirstChild();
+ final PsiElement lastChild = parameterList.getLastChild();
+ final TextRange range = new TextRange(firstChild != null && firstChild.getNode().getElementType() == JavaTokenType.LT ? 1 : 0,
+ parameterList.getTextLength() - (lastChild != null && lastChild.getNode().getElementType() == JavaTokenType.GT ? 1 : 0));
+ holder.registerProblem(parameterList, "Explicit type argument #ref #loc can be replaced with <>", ProblemHighlightType.LIKE_UNUSED_SYMBOL, range, new ReplaceWithDiamondFix());
}
}
};
diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java
index 369f6ec..2dd724f 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java
@@ -29,6 +29,7 @@
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.containers.Stack;
import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
@@ -38,6 +39,7 @@
class ControlFlowAnalyzer extends JavaElementVisitor {
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.dataFlow.ControlFlowAnalyzer");
private static final int NOT_FOUND = -10;
+ private boolean myIgnoreAssertions;
private static class CannotAnalyzeException extends RuntimeException { }
@@ -54,9 +56,8 @@
myFactory = valueFactory;
}
- public ControlFlow buildControlFlow(PsiElement codeFragment) {
- if (codeFragment == null) return null;
-
+ public ControlFlow buildControlFlow(@NotNull PsiElement codeFragment, boolean ignoreAssertions) {
+ myIgnoreAssertions = ignoreAssertions;
PsiManager manager = codeFragment.getManager();
GlobalSearchScope scope = codeFragment.getResolveScope();
myRuntimeException = myFactory.getNotNullFactory().create(PsiType.getJavaLangRuntimeException(manager, scope));
@@ -203,6 +204,10 @@
}
@Override public void visitAssertStatement(PsiAssertStatement statement) {
+ if (myIgnoreAssertions) {
+ return;
+ }
+
startElement(statement);
final PsiExpression condition = statement.getAssertCondition();
final PsiExpression description = statement.getAssertDescription();
@@ -654,7 +659,6 @@
PsiType type = cd.getLubType();
if (type instanceof PsiClassType && ExceptionUtil.isUncheckedExceptionOrSuperclass((PsiClassType)type)) {
addConditionalRuntimeThrow(cd, true);
- break;
}
}
}
@@ -1595,15 +1599,16 @@
return null;
}
- PsiVariable var = resolveToVariable(refExpr);
+ PsiElement target = refExpr.resolve();
+ PsiVariable var = getAccessedVariable(target);
if (var == null) {
return null;
}
- boolean isCall = expression instanceof PsiMethodCallExpression;
+ PsiMethod accessMethod = target instanceof PsiMethod ? (PsiMethod)target : null;
PsiExpression qualifier = refExpr.getQualifierExpression();
if (qualifier == null) {
- DfaVariableValue result = myFactory.getVarFactory().createVariableValue(var, refExpr.getType(), false, null, isCall);
+ DfaVariableValue result = myFactory.getVarFactory().createVariableValue(var, refExpr.getType(), false, null, accessMethod);
if (var instanceof PsiField) {
myFields.add(result);
}
@@ -1613,15 +1618,14 @@
if (DfaPsiUtil.isFinalField(var) || DfaPsiUtil.isPlainMutableField(var)) {
DfaVariableValue qualifierValue = createChainedVariableValue(qualifier);
if (qualifierValue != null) {
- return myFactory.getVarFactory().createVariableValue(var, refExpr.getType(), false, qualifierValue, isCall || qualifierValue.isViaMethods());
+ return myFactory.getVarFactory().createVariableValue(var, refExpr.getType(), false, qualifierValue, accessMethod);
}
}
return null;
}
@Nullable
- private static PsiVariable resolveToVariable(PsiReferenceExpression refExpr) {
- PsiElement target = refExpr.resolve();
+ private static PsiVariable getAccessedVariable(final PsiElement target) {
if (target instanceof PsiVariable) {
return (PsiVariable)target;
}
diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspectionBase.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspectionBase.java
index 391fa1b..a5028fc 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspectionBase.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspectionBase.java
@@ -35,6 +35,7 @@
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Pair;
+import com.intellij.openapi.util.WriteExternalException;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
@@ -42,6 +43,7 @@
import com.intellij.util.ArrayUtil;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.SmartList;
+import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -54,6 +56,7 @@
@NonNls private static final String SHORT_NAME = "ConstantConditions";
public boolean SUGGEST_NULLABLE_ANNOTATIONS = false;
public boolean DONT_REPORT_TRUE_ASSERT_STATEMENTS = false;
+ public boolean IGNORE_ASSERT_STATEMENTS = false;
@Override
public JComponent createOptionsPanel() {
@@ -61,6 +64,15 @@
}
@Override
+ public void writeSettings(@NotNull Element node) throws WriteExternalException {
+ node.addContent(new Element("option").setAttribute("name", "SUGGEST_NULLABLE_ANNOTATIONS").setAttribute("value", String.valueOf(SUGGEST_NULLABLE_ANNOTATIONS)));
+ node.addContent(new Element("option").setAttribute("name", "DONT_REPORT_TRUE_ASSERT_STATEMENTS").setAttribute("value", String.valueOf(DONT_REPORT_TRUE_ASSERT_STATEMENTS)));
+ if (IGNORE_ASSERT_STATEMENTS) {
+ node.addContent(new Element("option").setAttribute("name", "IGNORE_ASSERT_STATEMENTS").setAttribute("value", "true"));
+ }
+ }
+
+ @Override
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
return new JavaElementVisitor() {
@@ -85,7 +97,7 @@
if (scope == null) return;
final StandardDataFlowRunner dfaRunner = new StandardDataFlowRunner(SUGGEST_NULLABLE_ANNOTATIONS);
final StandardInstructionVisitor visitor = new DataFlowInstructionVisitor(dfaRunner);
- final RunnerResult rc = dfaRunner.analyzeMethod(scope, visitor);
+ final RunnerResult rc = dfaRunner.analyzeMethod(scope, visitor, IGNORE_ASSERT_STATEMENTS);
if (rc == RunnerResult.OK) {
if (dfaRunner.problemsDetected(visitor)) {
createDescription(dfaRunner, holder, visitor);
diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DataFlowRunner.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DataFlowRunner.java
index 4e30cdd..a01901c 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DataFlowRunner.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DataFlowRunner.java
@@ -91,11 +91,15 @@
}
public final RunnerResult analyzeMethod(@NotNull PsiElement psiBlock, InstructionVisitor visitor) {
+ return analyzeMethod(psiBlock, visitor, false);
+ }
+
+ public final RunnerResult analyzeMethod(@NotNull PsiElement psiBlock, InstructionVisitor visitor, boolean ignoreAssertions) {
try {
final Collection<DfaMemoryState> initialStates = createInitialStates(psiBlock, visitor);
if (initialStates == null) return RunnerResult.NOT_APPLICABLE;
- final ControlFlow flow = createControlFlowAnalyzer().buildControlFlow(psiBlock);
+ final ControlFlow flow = createControlFlowAnalyzer().buildControlFlow(psiBlock, ignoreAssertions);
if (flow == null) return RunnerResult.NOT_APPLICABLE;
int endOffset = flow.getInstructionCount();
diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/value/DfaValueFactory.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/value/DfaValueFactory.java
index dcc4a3f..1ea146e 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/value/DfaValueFactory.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/value/DfaValueFactory.java
@@ -136,7 +136,7 @@
}
if (!variable.hasModifierProperty(PsiModifier.VOLATILE) && isEffectivelyUnqualified(referenceExpression)) {
- return getVarFactory().createVariableValue(variable, referenceExpression.getType(), false, null, false);
+ return getVarFactory().createVariableValue(variable, referenceExpression.getType(), false, null, null);
}
return null;
diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/value/DfaVariableValue.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/value/DfaVariableValue.java
index 39541bf..695c0e6 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/value/DfaVariableValue.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/value/DfaVariableValue.java
@@ -49,15 +49,15 @@
}
public DfaVariableValue createVariableValue(PsiVariable myVariable, boolean isNegated) {
- return createVariableValue(myVariable, myVariable.getType(), isNegated, null, false);
+ return createVariableValue(myVariable, myVariable.getType(), isNegated, null, null);
}
@NotNull
public DfaVariableValue createVariableValue(PsiVariable myVariable,
- @Nullable PsiType varType, boolean isNegated, @Nullable DfaVariableValue qualifier, boolean viaMethods) {
+ @Nullable PsiType varType, boolean isNegated, @Nullable DfaVariableValue qualifier, @Nullable PsiMethod accessMethod) {
mySharedInstance.myVariable = myVariable;
mySharedInstance.myIsNegated = isNegated;
mySharedInstance.myQualifier = qualifier;
- mySharedInstance.myViaMethods = viaMethods;
+ mySharedInstance.myAccessMethod = accessMethod;
String id = mySharedInstance.toString();
ArrayList<DfaVariableValue> conditions = myStringToObject.get(id);
@@ -71,7 +71,7 @@
}
}
- DfaVariableValue result = new DfaVariableValue(myVariable, varType, isNegated, myFactory, qualifier, viaMethods);
+ DfaVariableValue result = new DfaVariableValue(myVariable, varType, isNegated, myFactory, qualifier, accessMethod);
if (qualifier != null) {
myQualifiersToChainedVariables.putValue(qualifier, result);
}
@@ -92,18 +92,18 @@
private PsiVariable myVariable;
private PsiType myVarType;
+ private PsiMethod myAccessMethod;
@Nullable private DfaVariableValue myQualifier;
private boolean myIsNegated;
- private boolean myViaMethods;
private Nullness myInherentNullability;
- private DfaVariableValue(PsiVariable variable, PsiType varType, boolean isNegated, DfaValueFactory factory, @Nullable DfaVariableValue qualifier, boolean viaMethods) {
+ private DfaVariableValue(PsiVariable variable, PsiType varType, boolean isNegated, DfaValueFactory factory, @Nullable DfaVariableValue qualifier, PsiMethod accessMethod) {
super(factory);
myVariable = variable;
myIsNegated = isNegated;
myQualifier = qualifier;
- myViaMethods = viaMethods;
myVarType = varType;
+ myAccessMethod = accessMethod;
}
private DfaVariableValue(DfaValueFactory factory) {
@@ -128,7 +128,7 @@
@Override
public DfaVariableValue createNegated() {
- return myFactory.getVarFactory().createVariableValue(myVariable, myVarType, !myIsNegated, myQualifier, myViaMethods);
+ return myFactory.getVarFactory().createVariableValue(myVariable, myVarType, !myIsNegated, myQualifier, myAccessMethod);
}
@SuppressWarnings({"HardCodedStringLiteral"})
@@ -140,7 +140,7 @@
private boolean hardEquals(DfaVariableValue aVar) {
return aVar.myVariable == myVariable &&
aVar.myIsNegated == myIsNegated &&
- aVar.myViaMethods == myViaMethods &&
+ aVar.myAccessMethod == myAccessMethod &&
(myQualifier == null ? aVar.myQualifier == null : myQualifier.hardEquals(aVar.myQualifier));
}
@@ -150,7 +150,7 @@
}
public boolean isViaMethods() {
- return myViaMethods;
+ return myAccessMethod != null || myQualifier != null && myQualifier.isViaMethods();
}
public Nullness getInherentNullability() {
@@ -158,19 +158,32 @@
return myInherentNullability;
}
+ return myInherentNullability = calcInherentNullability();
+ }
+
+ private Nullness calcInherentNullability() {
+ PsiMethod accessMethod = myAccessMethod;
+ Nullness nullability = DfaPsiUtil.getElementNullability(getVariableType(), accessMethod);
+ if (nullability != Nullness.UNKNOWN) {
+ return nullability;
+ }
+
PsiVariable var = getPsiVariable();
- Nullness nullability = DfaPsiUtil.getElementNullability(getVariableType(), var);
- if (nullability == Nullness.UNKNOWN && var != null) {
+ nullability = DfaPsiUtil.getElementNullability(getVariableType(), var);
+ if (nullability != Nullness.UNKNOWN) {
+ return nullability;
+ }
+
+ if (var != null) {
if (DfaPsiUtil.isNullableInitialized(var, true)) {
- nullability = Nullness.NULLABLE;
- } else if (DfaPsiUtil.isNullableInitialized(var, false)) {
- nullability = Nullness.NOT_NULL;
+ return Nullness.NULLABLE;
+ }
+ if (DfaPsiUtil.isNullableInitialized(var, false)) {
+ return Nullness.NOT_NULL;
}
}
- myInherentNullability = nullability;
-
- return nullability;
+ return Nullness.UNKNOWN;
}
public boolean isLocalVariable() {
diff --git a/java/java-impl/src/com/intellij/application/options/CodeStyleGenerationConfigurable.java b/java/java-impl/src/com/intellij/application/options/CodeStyleGenerationConfigurable.java
index 44ccf49..aebfb44 100644
--- a/java/java-impl/src/com/intellij/application/options/CodeStyleGenerationConfigurable.java
+++ b/java/java-impl/src/com/intellij/application/options/CodeStyleGenerationConfigurable.java
@@ -18,8 +18,10 @@
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
import com.intellij.openapi.application.ApplicationBundle;
import com.intellij.openapi.options.Configurable;
+import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
+import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.ui.ToolbarDecorator;
@@ -230,18 +232,18 @@
reset(mySettings);
}
- public void apply(CodeStyleSettings settings) {
+ public void apply(CodeStyleSettings settings) throws ConfigurationException {
settings.PREFER_LONGER_NAMES = myCbPreferLongerNames.isSelected();
- settings.FIELD_NAME_PREFIX = myFieldPrefixField.getText().trim();
- settings.STATIC_FIELD_NAME_PREFIX = myStaticFieldPrefixField.getText().trim();
- settings.PARAMETER_NAME_PREFIX = myParameterPrefixField.getText().trim();
- settings.LOCAL_VARIABLE_NAME_PREFIX = myLocalVariablePrefixField.getText().trim();
+ settings.FIELD_NAME_PREFIX = setPrefixSuffix(myFieldPrefixField.getText(), true);
+ settings.STATIC_FIELD_NAME_PREFIX = setPrefixSuffix(myStaticFieldPrefixField.getText(), true);
+ settings.PARAMETER_NAME_PREFIX = setPrefixSuffix(myParameterPrefixField.getText(), true);
+ settings.LOCAL_VARIABLE_NAME_PREFIX = setPrefixSuffix(myLocalVariablePrefixField.getText(), true);
- settings.FIELD_NAME_SUFFIX = myFieldSuffixField.getText().trim();
- settings.STATIC_FIELD_NAME_SUFFIX = myStaticFieldSuffixField.getText().trim();
- settings.PARAMETER_NAME_SUFFIX = myParameterSuffixField.getText().trim();
- settings.LOCAL_VARIABLE_NAME_SUFFIX = myLocalVariableSuffixField.getText().trim();
+ settings.FIELD_NAME_SUFFIX = setPrefixSuffix(myFieldSuffixField.getText(), false);
+ settings.STATIC_FIELD_NAME_SUFFIX = setPrefixSuffix(myStaticFieldSuffixField.getText(), false);
+ settings.PARAMETER_NAME_SUFFIX = setPrefixSuffix(myParameterSuffixField.getText(), false);
+ settings.LOCAL_VARIABLE_NAME_SUFFIX = setPrefixSuffix(myLocalVariableSuffixField.getText(), false);
settings.LINE_COMMENT_AT_FIRST_COLUMN = myCbLineCommentAtFirstColumn.isSelected();
settings.BLOCK_COMMENT_AT_FIRST_COLUMN = myCbBlockCommentAtFirstColumn.isSelected();
@@ -260,7 +262,16 @@
}
}
- public void apply() {
+ private static String setPrefixSuffix(String text, boolean prefix) throws ConfigurationException {
+ text = text.trim();
+ if (text.isEmpty()) return text;
+ if (!StringUtil.isJavaIdentifier(text)) {
+ throw new ConfigurationException("Not a valid java identifier part in " + (prefix ? "prefix" : "suffix") + " \'" + text + "\'");
+ }
+ return text;
+ }
+
+ public void apply() throws ConfigurationException {
apply(mySettings);
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/ExpectedTypeInfo.java b/java/java-impl/src/com/intellij/codeInsight/ExpectedTypeInfo.java
index 650a6b0..7fe0abc 100644
--- a/java/java-impl/src/com/intellij/codeInsight/ExpectedTypeInfo.java
+++ b/java/java-impl/src/com/intellij/codeInsight/ExpectedTypeInfo.java
@@ -44,9 +44,5 @@
ExpectedTypeInfo[] intersect(ExpectedTypeInfo info);
- boolean isArrayTypeInfo();
-
TailType getTailType();
-
- boolean isInsertExplicitTypeParams();
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/ExpectedTypeInfoImpl.java b/java/java-impl/src/com/intellij/codeInsight/ExpectedTypeInfoImpl.java
index 0751887..619b647 100644
--- a/java/java-impl/src/com/intellij/codeInsight/ExpectedTypeInfoImpl.java
+++ b/java/java-impl/src/com/intellij/codeInsight/ExpectedTypeInfoImpl.java
@@ -28,13 +28,6 @@
private final PsiType type;
private final PsiType defaultType;
- private boolean myInsertExplicitTypeParams;
-
- int getDimCount() {
- return dimCount;
- }
-
- private final int dimCount;
@Override
public int getKind() {
@@ -59,29 +52,11 @@
private PsiMethod myCalledMethod;
- public ExpectedTypeInfoImpl(@NotNull PsiType type, int kind, int dimCount, @NotNull PsiType defaultType, @NotNull TailType myTailType) {
+ public ExpectedTypeInfoImpl(@NotNull PsiType type, int kind, @NotNull PsiType defaultType, @NotNull TailType myTailType) {
this.type = type;
this.kind = kind;
this.myTailType = myTailType;
- this.dimCount = dimCount;
-
- if (type == defaultType && type instanceof PsiClassType) {
- final PsiClassType psiClassType = (PsiClassType)type;
- final PsiClass psiClass = psiClassType.resolve();
- if (psiClass != null && CommonClassNames.JAVA_LANG_CLASS.equals(psiClass.getQualifiedName())) {
- final PsiType[] parameters = psiClassType.getParameters();
- PsiTypeParameter[] typeParameters = psiClass.getTypeParameters();
- if (parameters.length == 1 && parameters[0] instanceof PsiWildcardType && typeParameters.length == 1) {
- final PsiType bound = ((PsiWildcardType)parameters[0]).getExtendsBound();
- if (bound instanceof PsiClassType) {
- defaultType = JavaPsiFacade.getInstance(psiClass.getProject()).getElementFactory()
- .createType(psiClass, PsiSubstitutor.EMPTY.put(typeParameters[0], bound));
- }
- }
- }
- }
-
this.defaultType = defaultType;
PsiUtil.ensureValidType(type);
@@ -100,30 +75,13 @@
@Override
@NotNull
public PsiType getType () {
- PsiType t = type;
- int dims = dimCount;
-
- while (dims-- > 0) t = t.createArrayType();
- return t;
+ return type;
}
@Override
@NotNull
public PsiType getDefaultType () {
- PsiType t = defaultType;
- int dims = dimCount;
-
- while (dims-- > 0) t = t.createArrayType();
- return t;
- }
-
- @Override
- public boolean isInsertExplicitTypeParams() {
- return myInsertExplicitTypeParams;
- }
-
- public void setInsertExplicitTypeParams(final boolean insertExplicitTypeParams) {
- this.myInsertExplicitTypeParams = insertExplicitTypeParams;
+ return defaultType;
}
public boolean equals(final Object o) {
@@ -132,20 +90,18 @@
final ExpectedTypeInfoImpl that = (ExpectedTypeInfoImpl)o;
- if (dimCount != that.dimCount) return false;
if (kind != that.kind) return false;
- if (defaultType != null ? !defaultType.equals(that.defaultType) : that.defaultType != null) return false;
+ if (!defaultType.equals(that.defaultType)) return false;
if (myTailType != null ? !myTailType.equals(that.myTailType) : that.myTailType != null) return false;
- if (type != null ? !type.equals(that.type) : that.type != null) return false;
+ if (!type.equals(that.type)) return false;
return true;
}
public int hashCode() {
int result;
- result = (type != null ? type.hashCode() : 0);
- result = 31 * result + (defaultType != null ? defaultType.hashCode() : 0);
- result = 31 * result + dimCount;
+ result = (type.hashCode());
+ result = 31 * result + (defaultType.hashCode());
result = 31 * result + kind;
result = 31 * result + (myTailType != null ? myTailType.hashCode() : 0);
return result;
@@ -158,17 +114,15 @@
@SuppressWarnings({"HardCodedStringLiteral"})
public String toString() {
- return "ExpectedTypeInfo[type='" + type + "' kind='" + kind + "' dims='" + dimCount+ "']";
+ return "ExpectedTypeInfo[type='" + type + "' kind='" + kind + "']";
}
@Override
public ExpectedTypeInfo[] intersect(ExpectedTypeInfo info) {
ExpectedTypeInfoImpl info1 = (ExpectedTypeInfoImpl)info;
- LOG.assertTrue(!(type instanceof PsiArrayType) && !(info1.type instanceof PsiArrayType));
if (kind == TYPE_STRICTLY) {
if (info1.kind == TYPE_STRICTLY) {
- if (dimCount != info1.dimCount) return ExpectedTypeInfo.EMPTY_ARRAY;
if (info1.type.equals(type)) return new ExpectedTypeInfoImpl[] {this};
}
else {
@@ -177,12 +131,10 @@
}
else if (kind == TYPE_OR_SUBTYPE) {
if (info1.kind == TYPE_STRICTLY) {
- if (dimCount != info1.dimCount) return ExpectedTypeInfo.EMPTY_ARRAY;
if (type.isAssignableFrom(info1.type)) return new ExpectedTypeInfoImpl[] {info1};
}
else if (info1.kind == TYPE_OR_SUBTYPE) {
- PsiType type = dimCount == info1.dimCount ? this.type : getType();
- PsiType otherType = dimCount == info1.dimCount ? info1.type : info1.getType();
+ PsiType otherType = info1.type;
if (type.isAssignableFrom(otherType)) return new ExpectedTypeInfoImpl[] {info1};
else if (otherType.isAssignableFrom(type)) return new ExpectedTypeInfoImpl[] {this};
}
@@ -192,17 +144,14 @@
}
else if (kind == TYPE_OR_SUPERTYPE) {
if (info1.kind == TYPE_STRICTLY) {
- if (dimCount != info1.dimCount) return ExpectedTypeInfo.EMPTY_ARRAY;
if (info1.type.isAssignableFrom(type)) return new ExpectedTypeInfoImpl[] {info1};
}
else if (info1.kind == TYPE_OR_SUBTYPE) {
- PsiType type = dimCount == info1.dimCount ? this.type : getType();
- PsiType otherType = dimCount == info1.dimCount ? info1.type : info1.getType();
+ PsiType otherType = info1.type;
if (otherType.isAssignableFrom(type)) return new ExpectedTypeInfoImpl[] {this};
}
else if (info1.kind == TYPE_OR_SUPERTYPE) {
- PsiType type = dimCount == info1.dimCount ? this.type : getType();
- PsiType otherType = dimCount == info1.dimCount ? info1.type : info1.getType();
+ PsiType otherType = info1.type;
if (type.isAssignableFrom(otherType)) return new ExpectedTypeInfoImpl[] {this};
else if (otherType.isAssignableFrom(type)) return new ExpectedTypeInfoImpl[] {info1};
}
@@ -216,10 +165,4 @@
return ExpectedTypeInfo.EMPTY_ARRAY;
}
-
- @Override
- public boolean isArrayTypeInfo () {
- return dimCount > 0;
- }
-
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/ExpectedTypesProvider.java b/java/java-impl/src/com/intellij/codeInsight/ExpectedTypesProvider.java
index ebc4714..6a3d3f6 100644
--- a/java/java-impl/src/com/intellij/codeInsight/ExpectedTypesProvider.java
+++ b/java/java-impl/src/com/intellij/codeInsight/ExpectedTypesProvider.java
@@ -52,7 +52,7 @@
* @author ven
*/
public class ExpectedTypesProvider {
- private static final ExpectedTypeInfo VOID_EXPECTED = new ExpectedTypeInfoImpl(PsiType.VOID, ExpectedTypeInfo.TYPE_OR_SUBTYPE, 0, PsiType.VOID,
+ private static final ExpectedTypeInfo VOID_EXPECTED = new ExpectedTypeInfoImpl(PsiType.VOID, ExpectedTypeInfo.TYPE_OR_SUBTYPE, PsiType.VOID,
TailType.SEMICOLON);
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.ExpectedTypesProvider");
@@ -91,13 +91,7 @@
@NotNull
private static ExpectedTypeInfoImpl createInfoImpl(@NotNull PsiType type, int kind, PsiType defaultType, @NotNull TailType tailType) {
- int dims = 0;
- while (type instanceof PsiArrayType && defaultType instanceof PsiArrayType) {
- type = ((PsiArrayType) type).getComponentType();
- defaultType = ((PsiArrayType) defaultType).getComponentType();
- dims++;
- }
- return new ExpectedTypeInfoImpl(type, kind, dims, defaultType, tailType);
+ return new ExpectedTypeInfoImpl(type, kind, defaultType, tailType);
}
@NotNull
@@ -139,7 +133,7 @@
for (ExpectedTypeInfo info : infos) {
ExpectedTypeInfoImpl infoImpl = (ExpectedTypeInfoImpl)info;
- if (infoImpl.getDefaultType() instanceof PsiClassType && infoImpl.getDimCount() == 0) {
+ if (infoImpl.getDefaultType() instanceof PsiClassType) {
JavaResolveResult result = ((PsiClassType)infoImpl.getDefaultType()).resolveGenerics();
PsiClass aClass = (PsiClass)result.getElement();
if (aClass instanceof PsiAnonymousClass) {
@@ -155,10 +149,10 @@
}
if (infoImpl.kind == ExpectedTypeInfo.TYPE_OR_SUPERTYPE) {
- processAllSuperTypes(infoImpl.getType(), infoImpl.getDimCount(), visitor, project, set);
+ processAllSuperTypes(infoImpl.getType(), visitor, project, set);
}
else if (infoImpl.getKind() == ExpectedTypeInfo.TYPE_OR_SUBTYPE) {
- if (infoImpl.getType() instanceof PsiPrimitiveType && infoImpl.getDimCount() == 0) {
+ if (infoImpl.getType() instanceof PsiPrimitiveType) {
processPrimitiveTypeAndSubtypes((PsiPrimitiveType)infoImpl.getType(), visitor, set);
}
//else too expensive to search
@@ -183,7 +177,7 @@
}
}
- public static void processAllSuperTypes(@NotNull PsiType type, int dimCount, @NotNull PsiTypeVisitor<PsiType> visitor, @NotNull Project project, @NotNull Set<PsiType> set) {
+ public static void processAllSuperTypes(@NotNull PsiType type, @NotNull PsiTypeVisitor<PsiType> visitor, @NotNull Project project, @NotNull Set<PsiType> set) {
if (type instanceof PsiPrimitiveType) {
if (type.equals(PsiType.BOOLEAN) || type.equals(PsiType.VOID) || type.equals(PsiType.NULL)) return;
@@ -205,12 +199,8 @@
if (type instanceof PsiClassType) {
PsiType[] superTypes = type.getSuperTypes();
for (PsiType superType : superTypes) {
- PsiType wrappedType = superType;
- for (int j = 0; j < dimCount; j++) {
- wrappedType = wrappedType.createArrayType();
- }
- processType(wrappedType, visitor, set);
- processAllSuperTypes(superType, dimCount, visitor, project, set);
+ processType(superType, visitor, set);
+ processAllSuperTypes(superType, visitor, project, set);
}
}
}
@@ -864,7 +854,6 @@
ExpectedTypeInfo[] types = getExpectedTypes(expr, myForCompletion);
for (ExpectedTypeInfo info : types) {
ExpectedTypeInfoImpl infoImpl = (ExpectedTypeInfoImpl)info;
- infoImpl.setInsertExplicitTypeParams(true);
infoImpl.myTailType = TailType.COND_EXPR_COLON;
}
myResult = types;
@@ -874,9 +863,6 @@
LOG.error(Arrays.asList(expr.getChildren()) + "; " + myExpr);
}
myResult = getExpectedTypes(expr, myForCompletion);
- for (ExpectedTypeInfo info : myResult) {
- ((ExpectedTypeInfoImpl)info).setInsertExplicitTypeParams(true);
- }
}
}
@@ -1038,7 +1024,6 @@
PsiType defaultType = getDefaultType(method, substitutor, parameterType, argument, args, index);
ExpectedTypeInfoImpl info = createInfoImpl(parameterType, ExpectedTypeInfo.TYPE_OR_SUBTYPE, defaultType, tailType);
- info.setInsertExplicitTypeParams(true);
info.setCalledMethod(method);
NullableComputable<String> propertyName = getPropertyName(parameter);
info.expectedName = propertyName;
@@ -1048,7 +1033,6 @@
//Then we may still want to call with array argument
final PsiArrayType arrayType = parameterType.createArrayType();
ExpectedTypeInfoImpl info1 = createInfoImpl(arrayType, ExpectedTypeInfo.TYPE_OR_SUBTYPE, arrayType, tailType);
- info1.setInsertExplicitTypeParams(true);
info1.setCalledMethod(method);
info1.expectedName = propertyName;
array.add(info1);
diff --git a/java/java-impl/src/com/intellij/codeInsight/TargetElementUtil.java b/java/java-impl/src/com/intellij/codeInsight/TargetElementUtil.java
index 7ed0085..f9efd10 100644
--- a/java/java-impl/src/com/intellij/codeInsight/TargetElementUtil.java
+++ b/java/java-impl/src/com/intellij/codeInsight/TargetElementUtil.java
@@ -21,6 +21,7 @@
import com.intellij.openapi.util.Computable;
import com.intellij.psi.*;
import com.intellij.psi.search.searches.ClassInheritorsSearch;
+import com.intellij.psi.util.InheritanceUtil;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
import com.intellij.psi.xml.XmlAttribute;
@@ -299,7 +300,7 @@
return super.acceptImplementationForReference(reference, element);
}
- private static class PsiElementFindProcessor<T extends PsiElement> implements Processor<T> {
+ private static class PsiElementFindProcessor<T extends PsiClass> implements Processor<T> {
private final T myElement;
public PsiElementFindProcessor(T t) {
@@ -308,6 +309,7 @@
@Override
public boolean process(T t) {
+ if (InheritanceUtil.isInheritorOrSelf(t, myElement, true)) return false;
return !myElement.getManager().areElementsEquivalent(myElement, t);
}
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionData.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionData.java
index ba8486b..a9167f2 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionData.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionData.java
@@ -21,6 +21,7 @@
import com.intellij.codeInsight.completion.util.ParenthesesInsertHandler;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupItem;
+import com.intellij.codeInsight.lookup.PsiTypeLookupItem;
import com.intellij.codeInsight.lookup.TailTypeDecorator;
import com.intellij.patterns.ElementPattern;
import com.intellij.patterns.PsiJavaElementPattern;
@@ -612,6 +613,17 @@
return;
}
+ boolean afterNew = psiElement().afterLeaf(
+ psiElement().withText(PsiKeyword.NEW).andNot(psiElement().afterLeaf(PsiKeyword.THROW, "."))).accepts(position);
+ if (afterNew) {
+ PsiElementFactory factory = JavaPsiFacade.getElementFactory(position.getProject());
+ for (String primitiveType : PRIMITIVE_TYPES) {
+ result.addElement(PsiTypeLookupItem.createLookupItem(factory.createTypeFromText(primitiveType + "[]", null), null));
+ }
+ result.addElement(PsiTypeLookupItem.createLookupItem(factory.createTypeFromText("void[]", null), null));
+ return;
+ }
+
boolean inCast = psiElement()
.afterLeaf(psiElement().withText("(").withParent(psiElement(PsiParenthesizedExpression.class, PsiTypeCastExpression.class)))
.accepts(position);
@@ -619,8 +631,6 @@
boolean typeFragment = position.getContainingFile() instanceof PsiTypeCodeFragment && PsiTreeUtil.prevVisibleLeaf(position) == null;
boolean declaration = DECLARATION_START.accepts(position);
boolean expressionPosition = isExpressionPosition(position);
- boolean afterNew = psiElement().afterLeaf(
- psiElement().withText(PsiKeyword.NEW).andNot(psiElement().afterLeaf(PsiKeyword.THROW, "."))).accepts(position);
boolean inGenerics = PsiTreeUtil.getParentOfType(position, PsiReferenceParameterList.class) != null;
if (START_FOR.accepts(position) ||
isInsideParameterList(position) ||
@@ -629,7 +639,6 @@
inCast ||
declaration ||
typeFragment ||
- afterNew ||
expressionPosition ||
isStatementPosition(position)) {
for (String primitiveType : PRIMITIVE_TYPES) {
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java
index ee6de05..1de9f59 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java
@@ -34,6 +34,7 @@
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
import com.intellij.psi.util.TypeConversionUtil;
+import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;
@@ -260,7 +261,17 @@
public PreferDefaultTypeWeigher(ExpectedTypeInfo[] expectedTypes, CompletionParameters parameters) {
super("defaultType");
- myExpectedTypes = expectedTypes;
+ myExpectedTypes = expectedTypes == null ? null : ContainerUtil.map2Array(expectedTypes, ExpectedTypeInfo.class, new Function<ExpectedTypeInfo, ExpectedTypeInfo>() {
+ @Override
+ public ExpectedTypeInfo fun(ExpectedTypeInfo info) {
+ PsiType type = removeClassWildcard(info.getType());
+ PsiType defaultType = removeClassWildcard(info.getDefaultType());
+ if (type == info.getType() && defaultType == info.getDefaultType()) {
+ return info;
+ }
+ return new ExpectedTypeInfoImpl(type, info.getKind(), defaultType, info.getTailType());
+ }
+ });
myParameters = parameters;
final Pair<PsiClass,Integer> pair = TypeArgumentCompletionProvider.getTypeParameterInfo(parameters.getPosition());
@@ -293,7 +304,7 @@
}
for (final ExpectedTypeInfo expectedInfo : myExpectedTypes) {
- final PsiType defaultType = expectedInfo.getDefaultType();
+ final PsiType defaultType = expectedInfo.getDefaultType();
final PsiType expectedType = expectedInfo.getType();
if (!expectedType.isValid()) {
return MyResult.normal;
@@ -316,6 +327,16 @@
return MyResult.normal;
}
+ private static PsiType removeClassWildcard(PsiType type) {
+ if (type instanceof PsiClassType) {
+ final PsiClass psiClass = ((PsiClassType)type).resolve();
+ if (psiClass != null && CommonClassNames.JAVA_LANG_CLASS.equals(psiClass.getQualifiedName())) {
+ return GenericsUtil.eliminateWildcards(type);
+ }
+ }
+ return type;
+ }
+
private enum MyResult {
expectedNoSelect,
exactlyDefault,
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaDocCompletionContributor.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaDocCompletionContributor.java
index 75dc090..9e18f7b 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaDocCompletionContributor.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaDocCompletionContributor.java
@@ -29,6 +29,7 @@
import com.intellij.openapi.editor.ScrollType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Condition;
+import com.intellij.openapi.util.text.StringUtil;
import com.intellij.patterns.PsiJavaPatterns;
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
import com.intellij.psi.*;
@@ -38,10 +39,13 @@
import com.intellij.psi.filters.TrueFilter;
import com.intellij.psi.impl.JavaConstantExpressionEvaluator;
import com.intellij.psi.javadoc.*;
+import com.intellij.psi.util.InheritanceUtil;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.TypeConversionUtil;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.ProcessingContext;
+import com.intellij.util.Processor;
+import com.intellij.util.SystemProperties;
import com.intellij.util.text.CharArrayUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -120,18 +124,19 @@
@Override
protected void addCompletions(@NotNull final CompletionParameters parameters, final ProcessingContext context, @NotNull final CompletionResultSet result) {
- List<String> ret = new ArrayList<String>();
+ final List<String> ret = new ArrayList<String>();
final PsiElement position = parameters.getPosition();
final PsiDocComment comment = PsiTreeUtil.getParentOfType(position, PsiDocComment.class);
+ assert comment != null;
final PsiElement parent = comment.getContext();
final boolean isInline = position.getContext() instanceof PsiInlineDocTag;
- final JavadocManager manager = JavadocManager.SERVICE.getInstance(position.getProject());
- final JavadocTagInfo[] infos = manager.getTagInfos(parent);
- for (JavadocTagInfo info : infos) {
- if (info.getName().equals(SuppressionUtil.SUPPRESS_INSPECTIONS_TAG_NAME)) continue;
- if (isInline != (info.isInline())) continue;
- ret.add(info.getName());
+ for (JavadocTagInfo info : JavadocManager.SERVICE.getInstance(position.getProject()).getTagInfos(parent)) {
+ String tagName = info.getName();
+ if (tagName.equals(SuppressionUtil.SUPPRESS_INSPECTIONS_TAG_NAME)) continue;
+ if (isInline != info.isInline()) continue;
+ ret.add(tagName);
+ addSpecialTags(ret, comment, tagName);
}
InspectionProfile inspectionProfile =
@@ -149,11 +154,43 @@
result.addElement(TailTypeDecorator.withTail(LookupElementBuilder.create(s), TailType.INSERT_SPACE));
}
}
+ result.stopHere(); // no word completions at this point
}
- @SuppressWarnings({"HardCodedStringLiteral"})
- public String toString() {
- return "javadoc-tag-chooser";
+ private static void addSpecialTags(final List<String> result, PsiDocComment comment, String tagName) {
+ if ("author".equals(tagName)) {
+ result.add(tagName + " " + SystemProperties.getUserName());
+ return;
+ }
+
+ if ("param".equals(tagName)) {
+ PsiMethod psiMethod = PsiTreeUtil.getParentOfType(comment, PsiMethod.class);
+ if (psiMethod != null) {
+ PsiDocTag[] tags = comment.getTags();
+ for (PsiParameter param : psiMethod.getParameterList().getParameters()) {
+ if (!JavaDocLocalInspection.isFound(tags, param)) {
+ result.add(tagName + " " + param.getName());
+ }
+ }
+ }
+ return;
+ }
+
+ if ("see".equals(tagName)) {
+ PsiMember member = PsiTreeUtil.getParentOfType(comment, PsiMember.class);
+ if (member instanceof PsiClass) {
+ InheritanceUtil.processSupers((PsiClass)member, false, new Processor<PsiClass>() {
+ @Override
+ public boolean process(PsiClass psiClass) {
+ String name = psiClass.getQualifiedName();
+ if (StringUtil.isNotEmpty(name) && !CommonClassNames.JAVA_LANG_OBJECT.equals(name)) {
+ result.add("see " + name);
+ }
+ return true;
+ }
+ });
+ }
+ }
}
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaSmartCompletionContributor.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaSmartCompletionContributor.java
index ac70993..5e7af80 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaSmartCompletionContributor.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaSmartCompletionContributor.java
@@ -378,11 +378,11 @@
final PsiClassType classType = factory
.createTypeByFQClassName(CommonClassNames.JAVA_LANG_RUNTIME_EXCEPTION, position.getResolveScope());
final List<ExpectedTypeInfo> result = new SmartList<ExpectedTypeInfo>();
- result.add(new ExpectedTypeInfoImpl(classType, ExpectedTypeInfo.TYPE_OR_SUBTYPE, 0, classType, TailType.SEMICOLON));
+ result.add(new ExpectedTypeInfoImpl(classType, ExpectedTypeInfo.TYPE_OR_SUBTYPE, classType, TailType.SEMICOLON));
final PsiMethod method = PsiTreeUtil.getContextOfType(position, PsiMethod.class, true);
if (method != null) {
for (final PsiClassType type : method.getThrowsList().getReferencedTypes()) {
- result.add(new ExpectedTypeInfoImpl(type, ExpectedTypeInfo.TYPE_OR_SUBTYPE, 0, type, TailType.SEMICOLON));
+ result.add(new ExpectedTypeInfoImpl(type, ExpectedTypeInfo.TYPE_OR_SUBTYPE, type, TailType.SEMICOLON));
}
}
return result.toArray(new ExpectedTypeInfo[result.size()]);
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/JavaAwareInspectionProfileCoverter.java b/java/java-impl/src/com/intellij/codeInsight/daemon/JavaAwareInspectionProfileCoverter.java
index e79fdbe..5caad61 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/JavaAwareInspectionProfileCoverter.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/JavaAwareInspectionProfileCoverter.java
@@ -20,9 +20,8 @@
*/
package com.intellij.codeInsight.daemon;
-import com.intellij.codeInspection.InspectionProfileEntry;
import com.intellij.codeInspection.ModifiableModel;
-import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
+import com.intellij.codeInspection.ex.InspectionToolWrapper;
import com.intellij.codeInspection.javaDoc.JavaDocLocalInspection;
import com.intellij.profile.codeInspection.InspectionProfileManager;
import org.jdom.Element;
@@ -53,8 +52,8 @@
super.fillErrorLevels(profile);
//javadoc attributes
- final InspectionProfileEntry inspectionTool = profile.getInspectionTool(JavaDocLocalInspection.SHORT_NAME, null);
- JavaDocLocalInspection inspection = (JavaDocLocalInspection)((LocalInspectionToolWrapper)inspectionTool).getTool();
+ final InspectionToolWrapper toolWrapper = profile.getInspectionTool(JavaDocLocalInspection.SHORT_NAME, null);
+ JavaDocLocalInspection inspection = (JavaDocLocalInspection)toolWrapper.getTool();
inspection.myAdditionalJavadocTags = myAdditionalJavadocTags;
}
}
\ No newline at end of file
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/PostHighlightingPass.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/PostHighlightingPass.java
index a36521f..43a7037 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/PostHighlightingPass.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/PostHighlightingPass.java
@@ -139,7 +139,7 @@
VirtualFile virtualFile = viewProvider.getVirtualFile();
myInLibrary = fileIndex.isInLibraryClasses(virtualFile) || fileIndex.isInLibrarySource(virtualFile);
- myRefCountHolder = RefCountHolder.endUsing(myFile);
+ myRefCountHolder = RefCountHolder.endUsing(myFile, progress);
if (myRefCountHolder == null || !myRefCountHolder.retrieveUnusedReferencesInfo(progress, new Runnable() {
@Override
public void run() {
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/RecursiveCallLineMarkerProvider.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/RecursiveCallLineMarkerProvider.java
index 0fd2685..892eec1 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/RecursiveCallLineMarkerProvider.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/RecursiveCallLineMarkerProvider.java
@@ -63,7 +63,7 @@
public static boolean isRecursiveMethodCall(@NotNull PsiMethodCallExpression methodCall) {
final PsiMethod method = PsiTreeUtil.getParentOfType(methodCall, PsiMethod.class);
- if (method == null) {
+ if (method == null || !method.getName().equals(methodCall.getMethodExpression().getReferenceName())) {
return false;
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/RefCountHolder.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/RefCountHolder.java
index 6fd6ba5..175c133 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/RefCountHolder.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/RefCountHolder.java
@@ -18,7 +18,6 @@
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.util.Key;
-import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.UserDataHolderEx;
import com.intellij.psi.*;
@@ -34,11 +33,7 @@
import org.jetbrains.annotations.Nullable;
import java.lang.ref.SoftReference;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicInteger;
+import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
public class RefCountHolder {
@@ -55,34 +50,35 @@
private volatile ProgressIndicator analyzedUnder;
private static class HolderReference extends SoftReference<RefCountHolder> {
- @SuppressWarnings("UnusedDeclaration")
- private volatile RefCountHolder myHardRef; // to prevent gc
- // number of live references to RefCountHolder. Once it reaches zero, hard ref is cleared
- // the counter is used instead of a flag because multiple passes can be running simultaneously (one actual and several canceled winding down)
- // and there is a chance they overlap the usage of RCH
- private final AtomicInteger myRefCount = new AtomicInteger();
+ // Map holding hard references to RefCountHolder for each highlighting pass (identified by its progress indicator)
+ // there can be multiple passes running simultaneously (one actual and several passes just canceled and winding down but still alive)
+ // so there is a chance they overlap the usage of RCH
+ // As soon as everybody finished using RCH, map become empty and the RefCountHolder is eligible for gc
+ private final Map<ProgressIndicator, RefCountHolder> map = new ConcurrentHashMap<ProgressIndicator, RefCountHolder>();
public HolderReference(@NotNull RefCountHolder holder) {
super(holder);
- myHardRef = holder;
}
- private void changeLivenessBy(int delta) {
- if (myRefCount.addAndGet(delta) == 0) {
- myHardRef = null;
- }
- else if (myHardRef == null) {
- myHardRef = get();
- }
+ private void acquire(@NotNull ProgressIndicator indicator) {
+ RefCountHolder holder = get();
+ assert holder != null: "no way";
+ map.put(indicator, holder);
+ holder = get();
+ assert holder != null: "can't be!";
+ }
+
+ private RefCountHolder release(@NotNull ProgressIndicator indicator) {
+ return map.remove(indicator);
}
}
private static final Key<HolderReference> REF_COUNT_HOLDER_IN_FILE_KEY = Key.create("REF_COUNT_HOLDER_IN_FILE_KEY");
- @NotNull
- private static Pair<RefCountHolder, HolderReference> getInstance(@NotNull PsiFile file, boolean create) {
+
+ private static RefCountHolder getInstance(@NotNull PsiFile file, @NotNull ProgressIndicator indicator, boolean acquire) {
HolderReference ref = file.getUserData(REF_COUNT_HOLDER_IN_FILE_KEY);
RefCountHolder holder = ref == null ? null : ref.get();
- if (holder == null && create) {
+ if (holder == null && acquire) {
holder = new RefCountHolder(file);
HolderReference newRef = new HolderReference(holder);
while (true) {
@@ -99,31 +95,30 @@
}
}
}
- return Pair.create(holder, ref);
+ if (ref != null) {
+ if (acquire) {
+ ref.acquire(indicator);
+ }
+ else {
+ ref.release(indicator);
+ }
+ }
+ return holder;
}
@NotNull
- public static RefCountHolder startUsing(@NotNull PsiFile file) {
- Pair<RefCountHolder, HolderReference> pair = getInstance(file, true);
- HolderReference reference = pair.second;
- reference.changeLivenessBy(1); // make sure RefCountHolder won't be gced during highlighting
- log("startUsing: " + pair.first.myState+" for "+file);
- return pair.first;
+ public static RefCountHolder startUsing(@NotNull PsiFile file, @NotNull ProgressIndicator indicator) {
+ return getInstance(file, indicator, true);
}
@Nullable("might be gced")
- public static RefCountHolder endUsing(@NotNull PsiFile file) {
- Pair<RefCountHolder, HolderReference> pair = getInstance(file, false);
- HolderReference reference = pair.second;
- reference.changeLivenessBy(-1); // no longer needed, can be cleared
- RefCountHolder holder = pair.first;
- log("endUsing: " + (holder == null ? null : holder.myState)+" for "+file);
- return holder;
+ public static RefCountHolder endUsing(@NotNull PsiFile file, @NotNull ProgressIndicator indicator) {
+ return getInstance(file, indicator, false);
}
private RefCountHolder(@NotNull PsiFile file) {
myFile = file;
- log("c: created: " + myState.get()+" for "+file);
+ log("c: created: ", myState.get(), " for ", file);
}
private void clear() {
@@ -284,10 +279,10 @@
ProgressIndicator old = myState.get();
if (old != VIRGIN && old != READY) return false;
if (!myState.compareAndSet(old, indicator)) {
- log("a: failed to change " + old + "->" + indicator);
+ log("a: failed to change ", old, "->", indicator);
return false;
}
- log("a: changed " + old + "->" + indicator);
+ log("a: changed ", old, "->", indicator);
analyzedUnder = null;
boolean completed = false;
try {
@@ -308,22 +303,22 @@
ProgressIndicator resultState = completed ? READY : VIRGIN;
boolean set = myState.compareAndSet(indicator, resultState);
assert set : myState.get();
- log("a: changed after analyze" + indicator + "->" + resultState);
+ log("a: changed after analyze", indicator, "->", resultState);
}
return true;
}
- private static void log(@NonNls String s) {
- //System.err.println("RFC: "+s);
+ private static void log(@NonNls Object... s) {
+ //System.err.println("RFC: "+ Arrays.asList(s));
}
public boolean retrieveUnusedReferencesInfo(@NotNull ProgressIndicator indicator, @NotNull Runnable analyze) {
ProgressIndicator old = myState.get();
if (!myState.compareAndSet(READY, indicator)) {
- log("r: failed to change " + old + "->" + indicator);
+ log("r: failed to change ", old, "->", indicator);
return false;
}
- log("r: changed " + old + "->" + indicator);
+ log("r: changed ", old, "->", indicator);
try {
if (analyzedUnder != indicator) {
return false;
@@ -333,7 +328,7 @@
finally {
boolean set = myState.compareAndSet(indicator, READY);
assert set : myState.get();
- log("r: changed back " + indicator + "->" + READY);
+ log("r: changed back ", indicator, "->", READY);
}
return true;
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java
index 1d74a2f..48e10ee 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java
@@ -40,6 +40,7 @@
import com.intellij.util.containers.HashSet;
import gnu.trove.THashMap;
import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
@@ -384,8 +385,10 @@
}
@Nullable
- public static HighlightInfo checkElementInTypeParameterExtendsList(PsiReferenceList referenceList, JavaResolveResult resolveResult, PsiElement element) {
- PsiClass aClass = (PsiClass)referenceList.getParent();
+ public static HighlightInfo checkElementInTypeParameterExtendsList(@NotNull PsiReferenceList referenceList,
+ @NotNull PsiClass aClass,
+ @NotNull JavaResolveResult resolveResult,
+ @NotNull PsiElement element) {
final PsiJavaCodeReferenceElement[] referenceElements = referenceList.getReferenceElements();
PsiClass extendFrom = (PsiClass)resolveResult.getElement();
if (extendFrom == null) return null;
@@ -462,7 +465,7 @@
return null;
}
- public static HighlightInfo checkOverrideEquivalentMethods(final PsiClass aClass) {
+ public static HighlightInfo checkOverrideEquivalentMethods(@NotNull PsiClass aClass) {
final Collection<HierarchicalMethodSignature> signaturesWithSupers = aClass.getVisibleSignatures();
PsiManager manager = aClass.getManager();
Map<MethodSignature, MethodSignatureBackedByPsiMethod> sameErasureMethods =
@@ -520,10 +523,10 @@
}
@Nullable
- private static HighlightInfo checkSameErasureNotSubSignatureInner(final HierarchicalMethodSignature signature,
- final PsiManager manager,
- final PsiClass aClass,
- final Map<MethodSignature, MethodSignatureBackedByPsiMethod> sameErasureMethods) {
+ private static HighlightInfo checkSameErasureNotSubSignatureInner(@NotNull HierarchicalMethodSignature signature,
+ @NotNull PsiManager manager,
+ @NotNull PsiClass aClass,
+ @NotNull Map<MethodSignature, MethodSignatureBackedByPsiMethod> sameErasureMethods) {
PsiMethod method = signature.getMethod();
JavaPsiFacade facade = JavaPsiFacade.getInstance(manager.getProject());
if (!facade.getResolveHelper().isAccessible(method, aClass, null)) return null;
@@ -549,10 +552,11 @@
if (superSignature.isRaw() && !signature.isRaw()) {
final PsiType[] parameterTypes = signature.getParameterTypes();
- PsiType[] types = superSignature.getParameterTypes();
- for (int i = 0; i < types.length; i++) {
- if (!Comparing.equal(parameterTypes[i], TypeConversionUtil.erasure(types[i]))) {
- return getSameErasureMessage(false, method, superSignature.getMethod(), HighlightNamesUtil.getClassDeclarationTextRange(aClass));
+ PsiType[] erasedTypes = superSignature.getErasedParameterTypes();
+ for (int i = 0; i < erasedTypes.length; i++) {
+ if (!Comparing.equal(parameterTypes[i], erasedTypes[i])) {
+ return getSameErasureMessage(false, method, superSignature.getMethod(),
+ HighlightNamesUtil.getClassDeclarationTextRange(aClass));
}
}
}
@@ -601,10 +605,10 @@
!(checkEqualsSuper && Arrays.equals(superSignature.getParameterTypes(), signatureToCheck.getParameterTypes())) &&
!atLeast17) {
int idx = 0;
- final PsiType[] parameterTypes = signatureToCheck.getParameterTypes();
- boolean erasure = parameterTypes.length > 0;
+ final PsiType[] erasedTypes = signatureToCheck.getErasedParameterTypes();
+ boolean erasure = erasedTypes.length > 0;
for (PsiType type : superSignature.getParameterTypes()) {
- erasure &= Comparing.equal(type, TypeConversionUtil.erasure(parameterTypes[idx]));
+ erasure &= Comparing.equal(type, erasedTypes[idx]);
idx++;
}
@@ -624,9 +628,9 @@
}
}
- private static HighlightInfo getSameErasureMessage(final boolean sameClass, final PsiMethod method, final PsiMethod superMethod,
+ private static HighlightInfo getSameErasureMessage(final boolean sameClass, @NotNull PsiMethod method, @NotNull PsiMethod superMethod,
TextRange textRange) {
- @NonNls final String key = sameClass ? "generics.methods.have.same.erasure" :
+ @NonNls final String key = sameClass ? "generics.methods.have.same.erasure" :
method.hasModifierProperty(PsiModifier.STATIC) ?
"generics.methods.have.same.erasure.hide" :
"generics.methods.have.same.erasure.override";
@@ -1275,7 +1279,7 @@
if (resolve instanceof PsiClass) {
final PsiClass containingClass = ((PsiClass)resolve).getContainingClass();
if (containingClass != null) {
- if (psiClass.isInheritor(containingClass, true) ||
+ if (psiClass.isInheritor(containingClass, true) ||
unqualifiedNestedClassReferenceAccessedViaContainingClassInheritance(containingClass, ((PsiClass)resolve).getExtendsList()) ||
unqualifiedNestedClassReferenceAccessedViaContainingClassInheritance(containingClass, ((PsiClass)resolve).getImplementsList())) {
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).descriptionAndTooltip(((PsiClass)resolve).getName() + " is not accessible in current context").range(ref).create();
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java
index 4f6f099..ae32b61 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java
@@ -55,10 +55,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
+import java.util.*;
public class HighlightClassUtil {
private static final QuickFixFactory QUICK_FIX_FACTORY = QuickFixFactory.getInstance();
@@ -94,19 +91,32 @@
static HighlightInfo checkClassWithAbstractMethods(PsiClass aClass, PsiElement implementsFixElement, TextRange range) {
PsiMethod abstractMethod = ClassUtil.getAnyAbstractMethod(aClass);
- if (abstractMethod == null || abstractMethod.getContainingClass() == null) {
+ if (abstractMethod == null) {
return null;
}
+
+ final PsiClass superClass = abstractMethod.getContainingClass();
+ if (superClass == null) {
+ return null;
+ }
+
String baseClassName = HighlightUtil.formatClass(aClass, false);
String methodName = JavaHighlightUtil.formatMethod(abstractMethod);
String message = JavaErrorMessages.message(aClass instanceof PsiEnumConstantInitializer || implementsFixElement instanceof PsiEnumConstant ? "enum.constant.should.implement.method" : "class.must.be.abstract",
baseClassName,
methodName,
- HighlightUtil.formatClass(abstractMethod.getContainingClass(), false));
+ HighlightUtil.formatClass(superClass, false));
HighlightInfo errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range).descriptionAndTooltip(message).create();
- if (ClassUtil.getAnyMethodToImplement(aClass) != null) {
- QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createImplementMethodsFix(implementsFixElement));
+ final PsiMethod anyMethodToImplement = ClassUtil.getAnyMethodToImplement(aClass);
+ if (anyMethodToImplement != null) {
+ if (!anyMethodToImplement.hasModifierProperty(PsiModifier.PACKAGE_LOCAL) ||
+ JavaPsiFacade.getInstance(aClass.getProject()).arePackagesTheSame(aClass, superClass)) {
+ QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createImplementMethodsFix(implementsFixElement));
+ } else {
+ QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createModifierListFix(anyMethodToImplement, PsiModifier.PROTECTED, true, true));
+ QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createModifierListFix(anyMethodToImplement, PsiModifier.PUBLIC, true, true));
+ }
}
if (!(aClass instanceof PsiAnonymousClass)
&& HighlightUtil.getIncompatibleModifier(PsiModifier.ABSTRACT, aClass.getModifierList()) == null) {
@@ -985,7 +995,7 @@
if (classReference == null) return;
final PsiClass psiClass = (PsiClass)classReference.resolve();
if (psiClass == null) return;
- final MemberChooser<PsiMethodMember> chooser = chooseMethodsToImplement(editor, startElement, psiClass);
+ final MemberChooser<PsiMethodMember> chooser = chooseMethodsToImplement(editor, startElement, psiClass, false);
if (chooser == null) return;
final List<PsiMethodMember> selectedElements = chooser.getSelectedElements();
@@ -999,12 +1009,17 @@
newExpression = (PsiNewExpression)startElement.replace(newExpression);
final PsiClass psiClass = newExpression.getAnonymousClass();
if (psiClass == null) return;
- PsiClassType baseClassType = ((PsiAnonymousClass)psiClass).getBaseClassType();
- PsiClass resolve = baseClassType.resolve();
- if (resolve == null) return;
- PsiSubstitutor superClassSubstitutor = TypeConversionUtil.getSuperClassSubstitutor(resolve, psiClass, PsiSubstitutor.EMPTY);
+ Map<PsiClass, PsiSubstitutor> subst = new HashMap<PsiClass, PsiSubstitutor>();
for (PsiMethodMember selectedElement : selectedElements) {
- selectedElement.setSubstitutor(superClassSubstitutor);
+ final PsiClass baseClass = selectedElement.getElement().getContainingClass();
+ if (baseClass != null) {
+ PsiSubstitutor substitutor = subst.get(baseClass);
+ if (substitutor == null) {
+ substitutor = TypeConversionUtil.getSuperClassSubstitutor(baseClass, psiClass, PsiSubstitutor.EMPTY);
+ subst.put(baseClass, substitutor);
+ }
+ selectedElement.setSubstitutor(substitutor);
+ }
}
OverrideImplementUtil.overrideOrImplementMethodsInRightPlace(editor, psiClass, selectedElements, chooser.isCopyJavadoc(),
chooser.isInsertOverrideAnnotation());
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java
index 80f4b17..2d1a4db 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java
@@ -35,6 +35,7 @@
import com.intellij.psi.util.*;
import com.intellij.refactoring.util.RefactoringChangeUtil;
import com.intellij.ui.ColorUtil;
+import com.intellij.util.containers.MostlySingularMultiMap;
import com.intellij.util.ui.UIUtil;
import com.intellij.xml.util.XmlStringUtil;
import org.intellij.lang.annotations.Language;
@@ -833,18 +834,15 @@
}
@Nullable
- static HighlightInfo checkDuplicateMethod(PsiClass aClass, PsiMethod method) {
+ static HighlightInfo checkDuplicateMethod(PsiClass aClass,
+ @NotNull PsiMethod method,
+ @NotNull MostlySingularMultiMap<MethodSignature, PsiMethod> duplicateMethods) {
if (aClass == null || method instanceof ExternallyDefinedPsiElement) return null;
MethodSignature methodSignature = method.getSignature(PsiSubstitutor.EMPTY);
- int methodCount = 0;
- final PsiMethod[] methodsByName = aClass.findMethodsByName(method.getName(), false);
- for (PsiMethod other : methodsByName) {
- if (other instanceof ExternallyDefinedPsiElement) continue;
- if (other == method ||
- other.isConstructor() == method.isConstructor() && other.getSignature(PsiSubstitutor.EMPTY).equals(methodSignature)) {
- methodCount++;
- if (methodCount > 1) break;
- }
+ int methodCount = 1;
+ List<PsiMethod> methods = (List<PsiMethod>)duplicateMethods.get(methodSignature);
+ if (methods.size() > 1) {
+ methodCount++;
}
if (methodCount == 1 && aClass.isEnum() &&
@@ -874,6 +872,7 @@
if (hasNoBody) {
if (isExtension) {
description = JavaErrorMessages.message("extension.method.should.have.a.body");
+ additionalFixes.add(new AddMethodBodyFix(method));
}
else if (isInterface && isStatic) {
description = "Static methods in interfaces should have a body";
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java
index 94508df..e7b3d6b 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java
@@ -2516,7 +2516,7 @@
PsiClass aClass = (PsiClass)resolved;
if (refGrandParent instanceof PsiClass) {
if (refGrandParent instanceof PsiTypeParameter) {
- highlightInfo = GenericsHighlightUtil.checkElementInTypeParameterExtendsList(referenceList, resolveResult, ref);
+ highlightInfo = GenericsHighlightUtil.checkElementInTypeParameterExtendsList(referenceList, (PsiClass)refGrandParent, resolveResult, ref);
}
else {
highlightInfo = HighlightClassUtil.checkExtendsClassAndImplementsInterface(referenceList, resolveResult, ref);
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java
index 1c0e2ec..c705951 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java
@@ -39,11 +39,9 @@
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
import com.intellij.psi.javadoc.PsiDocComment;
import com.intellij.psi.javadoc.PsiDocTagValue;
-import com.intellij.psi.util.MethodSignatureBackedByPsiMethod;
-import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.psi.util.PsiUtil;
-import com.intellij.psi.util.TypeConversionUtil;
+import com.intellij.psi.util.*;
import com.intellij.psi.xml.XmlAttributeValue;
+import com.intellij.util.containers.MostlySingularMultiMap;
import gnu.trove.THashMap;
import gnu.trove.TObjectIntHashMap;
import org.jetbrains.annotations.NotNull;
@@ -82,11 +80,27 @@
}
}
};
+ private final Map<PsiClass, MostlySingularMultiMap<MethodSignature, PsiMethod>> myDuplicateMethods = new THashMap<PsiClass, MostlySingularMultiMap<MethodSignature, PsiMethod>>();
public HighlightVisitorImpl(@NotNull PsiResolveHelper resolveHelper) {
myResolveHelper = resolveHelper;
}
+ @NotNull
+ private MostlySingularMultiMap<MethodSignature, PsiMethod> getDuplicateMethods(PsiClass aClass) {
+ MostlySingularMultiMap<MethodSignature, PsiMethod> signatures = myDuplicateMethods.get(aClass);
+ if (signatures == null) {
+ signatures = new MostlySingularMultiMap<MethodSignature, PsiMethod>();
+ for (PsiMethod method : aClass.getMethods()) {
+ MethodSignature signature = method.getSignature(PsiSubstitutor.EMPTY);
+ signatures.add(signature, method);
+ }
+
+ myDuplicateMethods.put(aClass, signatures);
+ }
+ return signatures;
+ }
+
@Override
@NotNull
public HighlightVisitorImpl clone() {
@@ -130,12 +144,13 @@
Project project = file.getProject();
DaemonCodeAnalyzer daemonCodeAnalyzer = DaemonCodeAnalyzer.getInstance(project);
FileStatusMap fileStatusMap = ((DaemonCodeAnalyzerImpl)daemonCodeAnalyzer).getFileStatusMap();
- RefCountHolder refCountHolder = RefCountHolder.startUsing(file);
+ ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
+ if (indicator == null) throw new IllegalStateException("Must be run under progress");
+ RefCountHolder refCountHolder = RefCountHolder.startUsing(file, indicator);
myRefCountHolder = refCountHolder;
Document document = PsiDocumentManager.getInstance(project).getDocument(file);
TextRange dirtyScope = document == null ? file.getTextRange() : fileStatusMap.getFileDirtyScope(document, Pass.UPDATE_ALL);
- ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
- success = indicator != null && refCountHolder.analyze(file, dirtyScope, action, indicator);
+ success = refCountHolder.analyze(file, dirtyScope, action, indicator);
}
else {
myRefCountHolder = null;
@@ -152,6 +167,7 @@
myRefCountHolder = null;
myFile = null;
myHolder = null;
+ myDuplicateMethods.clear();
}
return success;
@@ -775,7 +791,7 @@
}
PsiClass aClass = method.getContainingClass();
if (!myHolder.hasErrorResults()) myHolder.add(HighlightMethodUtil.checkMethodMustHaveBody(method, aClass));
- if (!myHolder.hasErrorResults()) myHolder.add(HighlightMethodUtil.checkDuplicateMethod(aClass, method));
+ if (!myHolder.hasErrorResults()) myHolder.add(HighlightMethodUtil.checkDuplicateMethod(aClass, method, getDuplicateMethods(aClass)));
if (!myHolder.hasErrorResults()) myHolder.add(HighlightMethodUtil.checkConstructorCallsBaseClassConstructor(method, myRefCountHolder, myResolveHelper));
if (!myHolder.hasErrorResults()) myHolder.add(HighlightMethodUtil.checkStaticMethodOverride(method));
}
@@ -932,7 +948,10 @@
if (!myHolder.hasErrorResults()) myHolder.add(GenericsHighlightUtil.checkCannotPassInner(ref));
if (resolved != null && parent instanceof PsiReferenceList) {
- if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkElementInReferenceList(ref, (PsiReferenceList)parent, result));
+ if (!myHolder.hasErrorResults()) {
+ PsiReferenceList referenceList = (PsiReferenceList)parent;
+ myHolder.add(HighlightUtil.checkElementInReferenceList(ref, referenceList, result));
+ }
}
if (parent instanceof PsiAnonymousClass && ref.equals(((PsiAnonymousClass)parent).getBaseClassReference())) {
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeArgumentsConditionalFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeArgumentsConditionalFix.java
index 4457e5d..0057749 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeArgumentsConditionalFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeArgumentsConditionalFix.java
@@ -102,8 +102,8 @@
return true;
}
- public static void register(HighlightInfo highlightInfo, PsiExpression expression, PsiType lType) {
- if (expression instanceof PsiConditionalExpression) {
+ public static void register(HighlightInfo highlightInfo, PsiExpression expression, @NotNull PsiType lType) {
+ if (lType != PsiType.NULL && expression instanceof PsiConditionalExpression) {
final PsiExpression thenExpression = ((PsiConditionalExpression)expression).getThenExpression();
final PsiExpression elseExpression = ((PsiConditionalExpression)expression).getElseExpression();
if (thenExpression != null && elseExpression != null) {
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageUtils.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageUtils.java
index ad63c63..667143b 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageUtils.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageUtils.java
@@ -134,7 +134,7 @@
JVMElementFactory factory = JVMElementFactories.getFactory(aClass.getLanguage(), aClass.getProject());
- LOG.assertTrue(!aClass.isInterface(), "Interface bodies should be already set up");
+ LOG.assertTrue(!aClass.isInterface() || method.hasModifierProperty(PsiModifier.DEFAULT), "Interface bodies should be already set up");
FileType fileType = FileTypeManager.getInstance().getFileTypeByExtension(template.getExtension());
Properties properties = new Properties();
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateLocalFromUsageFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateLocalFromUsageFix.java
index 24ba71d..919c6b4 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateLocalFromUsageFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateLocalFromUsageFix.java
@@ -54,8 +54,11 @@
if (!super.isAvailableImpl(offset)) return false;
if(myReferenceExpression.isQualified()) return false;
PsiElement scope = PsiTreeUtil.getParentOfType(myReferenceExpression, PsiModifierListOwner.class);
+ if (scope instanceof PsiAnonymousClass) {
+ scope = PsiTreeUtil.getParentOfType(scope, PsiModifierListOwner.class, true);
+ }
return scope instanceof PsiMethod || scope instanceof PsiClassInitializer ||
- scope instanceof PsiLocalVariable || scope instanceof PsiAnonymousClass;
+ scope instanceof PsiLocalVariable;
}
@Override
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImplementMethodsFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImplementMethodsFix.java
index f9c9b7b..5e63273 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImplementMethodsFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImplementMethodsFix.java
@@ -28,16 +28,13 @@
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
-import com.intellij.psi.PsiClass;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiEnumConstant;
-import com.intellij.psi.PsiFile;
+import com.intellij.psi.*;
import com.intellij.psi.infos.CandidateInfo;
+import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import java.util.Collections;
-import java.util.List;
+import java.util.*;
public class ImplementMethodsFix extends LocalQuickFixAndIntentionActionOnPsiElement {
public ImplementMethodsFix(PsiElement aClass) {
@@ -75,7 +72,7 @@
if (editor == null || !FileModificationService.getInstance().prepareFileForWrite(myPsiElement.getContainingFile())) return;
if (myPsiElement instanceof PsiEnumConstant) {
- final MemberChooser<PsiMethodMember> chooser = chooseMethodsToImplement(editor, startElement, ((PsiEnumConstant)myPsiElement).getContainingClass());
+ final MemberChooser<PsiMethodMember> chooser = chooseMethodsToImplement(editor, startElement, ((PsiEnumConstant)myPsiElement).getContainingClass(), true);
if (chooser == null) return;
final List<PsiMethodMember> selectedElements = chooser.getSelectedElements();
@@ -103,10 +100,14 @@
@Nullable
- protected static MemberChooser<PsiMethodMember> chooseMethodsToImplement(Editor editor, PsiElement startElement, PsiClass aClass) {
+ protected static MemberChooser<PsiMethodMember> chooseMethodsToImplement(Editor editor,
+ PsiElement startElement,
+ PsiClass aClass,
+ boolean implemented) {
FeatureUsageTracker.getInstance().triggerFeatureUsed(ProductivityFeatureNames.CODEASSISTS_OVERRIDE_IMPLEMENT);
+ final Collection<CandidateInfo> overrideImplement = OverrideImplementExploreUtil.getMapToOverrideImplement(aClass, true, implemented).values();
return OverrideImplementUtil
- .showOverrideImplementChooser(editor, startElement, true, OverrideImplementExploreUtil.getMethodsToOverrideImplement(aClass, true), Collections.<CandidateInfo>emptyList());
+ .showOverrideImplementChooser(editor, startElement, true, overrideImplement, ContainerUtil.<CandidateInfo>newArrayList());
}
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFix.java
index a2bebf6..2e23f7e 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFix.java
@@ -107,6 +107,7 @@
return super.getRequiredMemberName(reference);
}
+ @NotNull
@Override
protected List<PsiClass> filterByContext(@NotNull List<PsiClass> candidates, @NotNull PsiJavaCodeReferenceElement ref) {
PsiElement typeElement = ref.getParent();
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFixBase.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFixBase.java
index e34ad18..bfb7c45 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFixBase.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFixBase.java
@@ -184,6 +184,7 @@
return null;
}
+ @NotNull
protected List<PsiClass> filterByContext(@NotNull List<PsiClass> candidates, @NotNull T ref) {
return candidates;
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ModifierFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ModifierFix.java
index 6ac2e5d..0d71068 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ModifierFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ModifierFix.java
@@ -141,6 +141,7 @@
final PsiModifierList myModifierList = (PsiModifierList)startElement;
final PsiVariable variable = myVariable == null ? null : myVariable.getElement();
if (!FileModificationService.getInstance().preparePsiElementForWrite(myModifierList)) return;
+ if (variable != null && !FileModificationService.getInstance().preparePsiElementForWrite(variable)) return;
final List<PsiModifierList> modifierLists = new ArrayList<PsiModifierList>();
final PsiFile containingFile = myModifierList.getContainingFile();
final PsiModifierList modifierList;
@@ -180,8 +181,6 @@
}));
}
- if (!FileModificationService.getInstance().prepareFileForWrite(containingFile)) return;
-
if (!modifierLists.isEmpty()) {
if (Messages.showYesNoDialog(project,
QuickFixBundle.message("change.inheritors.visibility.warning.text"),
diff --git a/java/java-impl/src/com/intellij/codeInsight/editorActions/CopyPasteReferenceProcessor.java b/java/java-impl/src/com/intellij/codeInsight/editorActions/CopyPasteReferenceProcessor.java
index e08b1a9..7f906c1 100644
--- a/java/java-impl/src/com/intellij/codeInsight/editorActions/CopyPasteReferenceProcessor.java
+++ b/java/java-impl/src/com/intellij/codeInsight/editorActions/CopyPasteReferenceProcessor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -51,7 +51,7 @@
return null;
}
- final ArrayList<ReferenceTransferableData.ReferenceData> array = new ArrayList<ReferenceTransferableData.ReferenceData>();
+ final ArrayList<ReferenceData> array = new ArrayList<ReferenceData>();
for (int j = 0; j < startOffsets.length; j++) {
final int startOffset = startOffsets[j];
for (final PsiElement element : CollectHighlightsUtil.getElementsInRange(file, startOffset, endOffsets[j])) {
@@ -63,10 +63,10 @@
return null;
}
- return new ReferenceTransferableData(array.toArray(new ReferenceTransferableData.ReferenceData[array.size()]));
+ return new ReferenceTransferableData(array.toArray(new ReferenceData[array.size()]));
}
- protected abstract void addReferenceData(PsiFile file, int startOffset, PsiElement element, ArrayList<ReferenceTransferableData.ReferenceData> to);
+ protected abstract void addReferenceData(PsiFile file, int startOffset, PsiElement element, ArrayList<ReferenceData> to);
@Override
@Nullable
@@ -74,7 +74,7 @@
ReferenceTransferableData referenceData = null;
if (CodeInsightSettings.getInstance().ADD_IMPORTS_ON_PASTE != CodeInsightSettings.NO) {
try {
- final DataFlavor flavor = ReferenceTransferableData.ReferenceData.getDataFlavor();
+ final DataFlavor flavor = ReferenceData.getDataFlavor();
if (flavor != null) {
referenceData = (ReferenceTransferableData)content.getTransferData(flavor);
}
@@ -109,7 +109,7 @@
}
PsiDocumentManager.getInstance(project).commitAllDocuments();
- final ReferenceTransferableData.ReferenceData[] referenceData = value.getData();
+ final ReferenceData[] referenceData = value.getData();
final TRef[] refs = findReferencesToRestore(file, bounds, referenceData);
if (CodeInsightSettings.getInstance().ADD_IMPORTS_ON_PASTE == CodeInsightSettings.ASK) {
askReferencesToRestore(project, refs, referenceData);
@@ -124,12 +124,12 @@
}
protected static void addReferenceData(final PsiElement element,
- final ArrayList<ReferenceTransferableData.ReferenceData> array,
+ final ArrayList<ReferenceData> array,
final int startOffset,
final String qClassName, @Nullable final String staticMemberName) {
final TextRange range = element.getTextRange();
array.add(
- new ReferenceTransferableData.ReferenceData(
+ new ReferenceData(
range.getStartOffset() - startOffset,
range.getEndOffset() - startOffset,
qClassName, staticMemberName));
@@ -137,13 +137,13 @@
protected abstract TRef[] findReferencesToRestore(PsiFile file,
RangeMarker bounds,
- ReferenceTransferableData.ReferenceData[] referenceData);
+ ReferenceData[] referenceData);
- protected abstract void restoreReferences(ReferenceTransferableData.ReferenceData[] referenceData,
+ protected abstract void restoreReferences(ReferenceData[] referenceData,
TRef[] refs);
private static void askReferencesToRestore(Project project, PsiElement[] refs,
- ReferenceTransferableData.ReferenceData[] referenceData) {
+ ReferenceData[] referenceData) {
PsiManager manager = PsiManager.getInstance(project);
ArrayList<Object> array = new ArrayList<Object>();
@@ -152,7 +152,7 @@
PsiElement ref = refs[i];
if (ref != null) {
LOG.assertTrue(ref.isValid());
- ReferenceTransferableData.ReferenceData data = referenceData[i];
+ ReferenceData data = referenceData[i];
PsiClass refClass = JavaPsiFacade.getInstance(manager.getProject()).findClass(data.qClassName, ref.getResolveScope());
if (refClass == null) continue;
diff --git a/java/java-impl/src/com/intellij/codeInsight/editorActions/JavaCopyPasteReferenceProcessor.java b/java/java-impl/src/com/intellij/codeInsight/editorActions/JavaCopyPasteReferenceProcessor.java
index 85ea365..51edddd 100644
--- a/java/java-impl/src/com/intellij/codeInsight/editorActions/JavaCopyPasteReferenceProcessor.java
+++ b/java/java-impl/src/com/intellij/codeInsight/editorActions/JavaCopyPasteReferenceProcessor.java
@@ -30,7 +30,7 @@
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.editorActions.JavaCopyPasteReferenceProcessor");
@Override
- protected void addReferenceData(PsiFile file, int startOffset, PsiElement element, ArrayList<ReferenceTransferableData.ReferenceData> to) {
+ protected void addReferenceData(PsiFile file, int startOffset, PsiElement element, ArrayList<ReferenceData> to) {
if (element instanceof PsiJavaCodeReferenceElement) {
if (!((PsiJavaCodeReferenceElement)element).isQualified()) {
final JavaResolveResult resolveResult = ((PsiJavaCodeReferenceElement)element).advancedResolve(false);
@@ -61,13 +61,13 @@
@Override
protected PsiJavaCodeReferenceElement[] findReferencesToRestore(PsiFile file,
RangeMarker bounds,
- ReferenceTransferableData.ReferenceData[] referenceData) {
+ ReferenceData[] referenceData) {
PsiManager manager = file.getManager();
final JavaPsiFacade facade = JavaPsiFacade.getInstance(manager.getProject());
PsiResolveHelper helper = facade.getResolveHelper();
PsiJavaCodeReferenceElement[] refs = new PsiJavaCodeReferenceElement[referenceData.length];
for (int i = 0; i < referenceData.length; i++) {
- ReferenceTransferableData.ReferenceData data = referenceData[i];
+ ReferenceData data = referenceData[i];
PsiClass refClass = facade.findClass(data.qClassName, file.getResolveScope());
if (refClass == null) continue;
@@ -105,14 +105,14 @@
}
@Override
- protected void restoreReferences(ReferenceTransferableData.ReferenceData[] referenceData,
+ protected void restoreReferences(ReferenceData[] referenceData,
PsiJavaCodeReferenceElement[] refs) {
for (int i = 0; i < refs.length; i++) {
PsiJavaCodeReferenceElement reference = refs[i];
if (reference == null || !reference.isValid()) continue;
try {
PsiManager manager = reference.getManager();
- ReferenceTransferableData.ReferenceData refData = referenceData[i];
+ ReferenceData refData = referenceData[i];
PsiClass refClass = JavaPsiFacade.getInstance(manager.getProject()).findClass(refData.qClassName, reference.getResolveScope());
if (refClass != null) {
if (refData.staticMemberName == null) {
diff --git a/java/java-impl/src/com/intellij/codeInsight/editorActions/ReferenceData.java b/java/java-impl/src/com/intellij/codeInsight/editorActions/ReferenceData.java
new file mode 100644
index 0000000..8cc6f8d
--- /dev/null
+++ b/java/java-impl/src/com/intellij/codeInsight/editorActions/ReferenceData.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2000-2013 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.codeInsight.editorActions;
+
+import org.jetbrains.annotations.NonNls;
+
+import java.awt.datatransfer.DataFlavor;
+import java.io.Serializable;
+
+/**
+* @author Denis Fokin
+*/
+public class ReferenceData implements Cloneable, Serializable {
+ public static @NonNls DataFlavor ourFlavor;
+
+ public int startOffset;
+ public int endOffset;
+ public final String qClassName;
+ public final String staticMemberName;
+
+ public ReferenceData(int startOffset, int endOffset, String qClassName, String staticMemberDescriptor) {
+ this.startOffset = startOffset;
+ this.endOffset = endOffset;
+ this.qClassName = qClassName;
+ this.staticMemberName = staticMemberDescriptor;
+ }
+
+ @Override
+ public Object clone() {
+ try{
+ return super.clone();
+ }
+ catch(CloneNotSupportedException e){
+ throw new RuntimeException();
+ }
+ }
+
+ public static DataFlavor getDataFlavor() {
+ if (ourFlavor != null) {
+ return ourFlavor;
+ }
+ try {
+ ourFlavor = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType + ";class=" + ReferenceData.class.getName(), "ReferenceData");
+ }
+ catch (NoClassDefFoundError e) {
+ return null;
+ }
+ catch (IllegalArgumentException e) {
+ return null;
+ }
+ return ourFlavor;
+ }
+}
diff --git a/java/java-impl/src/com/intellij/codeInsight/editorActions/ReferenceTransferableData.java b/java/java-impl/src/com/intellij/codeInsight/editorActions/ReferenceTransferableData.java
index 8b2e56e..76c3754 100644
--- a/java/java-impl/src/com/intellij/codeInsight/editorActions/ReferenceTransferableData.java
+++ b/java/java-impl/src/com/intellij/codeInsight/editorActions/ReferenceTransferableData.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -15,8 +15,6 @@
*/
package com.intellij.codeInsight.editorActions;
-import org.jetbrains.annotations.NonNls;
-
import java.awt.datatransfer.DataFlavor;
import java.io.Serializable;
@@ -70,46 +68,4 @@
public ReferenceData[] getData() {
return myReferenceDatas;
}
-
- public static class ReferenceData implements Cloneable, Serializable {
- public static @NonNls DataFlavor ourFlavor;
-
- public int startOffset;
- public int endOffset;
- public final String qClassName;
- public final String staticMemberName;
-
- public ReferenceData(int startOffset, int endOffset, String qClassName, String staticMemberDescriptor) {
- this.startOffset = startOffset;
- this.endOffset = endOffset;
- this.qClassName = qClassName;
- this.staticMemberName = staticMemberDescriptor;
- }
-
- @Override
- public Object clone() {
- try{
- return super.clone();
- }
- catch(CloneNotSupportedException e){
- throw new RuntimeException();
- }
- }
-
- public static DataFlavor getDataFlavor() {
- if (ourFlavor != null) {
- return ourFlavor;
- }
- try {
- ourFlavor = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType + ";class=" + ReferenceData.class.getName(), "ReferenceData");
- }
- catch (NoClassDefFoundError e) {
- return null;
- }
- catch (IllegalArgumentException e) {
- return null;
- }
- return ourFlavor;
- }
- }
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/GenerateGetterHandler.java b/java/java-impl/src/com/intellij/codeInsight/generation/GenerateGetterHandler.java
index d7aca70..1306e20 100644
--- a/java/java-impl/src/com/intellij/codeInsight/generation/GenerateGetterHandler.java
+++ b/java/java-impl/src/com/intellij/codeInsight/generation/GenerateGetterHandler.java
@@ -37,7 +37,7 @@
protected GenerationInfo[] generateMemberPrototypes(PsiClass aClass, ClassMember original) throws IncorrectOperationException {
if (original instanceof PropertyClassMember) {
final PropertyClassMember propertyClassMember = (PropertyClassMember)original;
- final GenerationInfo[] getters = propertyClassMember.generateGetters();
+ final GenerationInfo[] getters = propertyClassMember.generateGetters(aClass);
if (getters != null) {
return getters;
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/GenerateMembersUtil.java b/java/java-impl/src/com/intellij/codeInsight/generation/GenerateMembersUtil.java
index 5a8eea4..a58dfe3 100644
--- a/java/java-impl/src/com/intellij/codeInsight/generation/GenerateMembersUtil.java
+++ b/java/java-impl/src/com/intellij/codeInsight/generation/GenerateMembersUtil.java
@@ -15,6 +15,7 @@
*/
package com.intellij.codeInsight.generation;
+import com.intellij.codeInsight.ExceptionUtil;
import com.intellij.codeInsight.daemon.impl.quickfix.CreateFromUsageUtils;
import com.intellij.lang.ASTNode;
import com.intellij.openapi.diagnostic.Logger;
@@ -22,6 +23,7 @@
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.RangeMarker;
import com.intellij.openapi.editor.ScrollType;
+import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.text.StringUtil;
@@ -30,6 +32,7 @@
import com.intellij.psi.impl.light.LightTypeElement;
import com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl;
import com.intellij.psi.javadoc.PsiDocComment;
+import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
import com.intellij.psi.util.TypeConversionUtil;
@@ -42,10 +45,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
public class GenerateMembersUtil {
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.generation.GenerateMembersUtil");
@@ -266,7 +266,17 @@
substituteTypeParameters(factory, target, sourceMethod.getTypeParameterList(), resultMethod.getTypeParameterList(), substitutor, sourceMethod);
substituteReturnType(PsiManager.getInstance(project), resultMethod, sourceMethod.getReturnType(), collisionResolvedSubstitutor);
substituteParameters(factory, codeStyleManager, sourceMethod.getParameterList(), resultMethod.getParameterList(), collisionResolvedSubstitutor, target);
- substituteThrows(factory, sourceMethod.getThrowsList(), resultMethod.getThrowsList(), collisionResolvedSubstitutor, sourceMethod);
+ final List<PsiClassType> thrownTypes = ExceptionUtil.collectSubstituted(collisionResolvedSubstitutor, sourceMethod.getThrowsList().getReferencedTypes());
+ if (target instanceof PsiClass) {
+ final PsiClass[] supers = ((PsiClass)target).getSupers();
+ for (PsiClass aSuper : supers) {
+ final PsiMethod psiMethod = aSuper.findMethodBySignature(sourceMethod, true);
+ if (psiMethod != null && psiMethod != sourceMethod) {
+ ExceptionUtil.retainExceptions(thrownTypes, ExceptionUtil.collectSubstituted(TypeConversionUtil.getSuperClassSubstitutor(aSuper, (PsiClass)target, PsiSubstitutor.EMPTY), psiMethod.getThrowsList().getReferencedTypes()));
+ }
+ }
+ }
+ substituteThrows(factory, resultMethod.getThrowsList(), collisionResolvedSubstitutor, sourceMethod, thrownTypes);
return resultMethod;
}
catch (IncorrectOperationException e) {
@@ -400,11 +410,11 @@
}
private static void substituteThrows(@NotNull JVMElementFactory factory,
- @NotNull PsiReferenceList sourceThrowsList,
@NotNull PsiReferenceList targetThrowsList,
- @NotNull PsiSubstitutor substitutor,
- @NotNull PsiMethod sourceMethod) {
- for (PsiClassType thrownType : sourceThrowsList.getReferencedTypes()) {
+ @NotNull PsiSubstitutor substitutor,
+ @NotNull PsiMethod sourceMethod,
+ List<PsiClassType> thrownTypes) {
+ for (PsiClassType thrownType : thrownTypes) {
targetThrowsList.add(factory.createReferenceElementByType((PsiClassType)substituteType(substitutor, thrownType, sourceMethod)));
}
}
@@ -504,7 +514,7 @@
PsiModifierList targetModifierList = targetParam.getModifierList();
if (sourceModifierList != null && targetModifierList != null) {
if (sourceParam.getLanguage() == targetParam.getLanguage()) {
- targetModifierList.replace(sourceModifierList);
+ targetModifierList = (PsiModifierList)targetModifierList.replace(sourceModifierList);
}
else {
JVMElementFactory factory = JVMElementFactories.requireFactory(targetParam.getLanguage(), targetParam.getProject());
@@ -515,6 +525,30 @@
targetModifierList.setModifierProperty(m, sourceParam.hasModifierProperty(m));
}
}
+ processAnnotations(sourceModifierList.getProject(), targetModifierList, targetModifierList.getResolveScope());
+ }
+ }
+
+ private static void processAnnotations(Project project, PsiModifierList modifierList, GlobalSearchScope moduleScope) {
+ final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
+ final Set<String> toRemove = new HashSet<String>();
+ for (PsiAnnotation annotation : modifierList.getAnnotations()) {
+ final String qualifiedName = annotation.getQualifiedName();
+ if (qualifiedName != null) {
+ for (OverrideImplementsAnnotationsHandler handler : Extensions.getExtensions(OverrideImplementsAnnotationsHandler.EP_NAME)) {
+ final String[] annotations2Remove = handler.annotationsToRemove(project, qualifiedName);
+ Collections.addAll(toRemove, annotations2Remove);
+ if (moduleScope != null && psiFacade.findClass(qualifiedName, moduleScope) == null) {
+ toRemove.add(qualifiedName);
+ }
+ }
+ }
+ }
+ for (String fqn : toRemove) {
+ final PsiAnnotation psiAnnotation = modifierList.findAnnotation(fqn);
+ if (psiAnnotation != null) {
+ psiAnnotation.delete();
+ }
}
}
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/GenerateSetterHandler.java b/java/java-impl/src/com/intellij/codeInsight/generation/GenerateSetterHandler.java
index e33f1b8..76a2251 100644
--- a/java/java-impl/src/com/intellij/codeInsight/generation/GenerateSetterHandler.java
+++ b/java/java-impl/src/com/intellij/codeInsight/generation/GenerateSetterHandler.java
@@ -29,7 +29,7 @@
protected GenerationInfo[] generateMemberPrototypes(PsiClass aClass, ClassMember original) throws IncorrectOperationException {
if (original instanceof PropertyClassMember) {
final PropertyClassMember propertyClassMember = (PropertyClassMember)original;
- final GenerationInfo[] getters = propertyClassMember.generateSetters();
+ final GenerationInfo[] getters = propertyClassMember.generateSetters(aClass);
if (getters != null) {
return getters;
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/GetterSetterPrototypeProvider.java b/java/java-impl/src/com/intellij/codeInsight/generation/GetterSetterPrototypeProvider.java
index 727bd81..5214457 100644
--- a/java/java-impl/src/com/intellij/codeInsight/generation/GetterSetterPrototypeProvider.java
+++ b/java/java-impl/src/com/intellij/codeInsight/generation/GetterSetterPrototypeProvider.java
@@ -17,6 +17,7 @@
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.extensions.Extensions;
+import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiField;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.PsiModifier;
@@ -31,6 +32,17 @@
public abstract boolean canGeneratePrototypeFor(PsiField field);
public abstract PsiMethod[] generateGetters(PsiField field);
public abstract PsiMethod[] generateSetters(PsiField field);
+ public PsiMethod[] findGetters(PsiClass psiClass, String propertyName) {
+ return null;
+ }
+
+ public String suggestGetterName(String propertyName) {
+ return null;
+ }
+
+ public boolean isSimpleGetter(PsiMethod method, String oldPropertyName) {
+ return false;
+ }
public abstract boolean isReadOnly(PsiField field);
@@ -51,4 +63,27 @@
}
return field.hasModifierProperty(PsiModifier.FINAL);
}
+
+ public static PsiMethod[] findGetters(PsiClass aClass, String propertyName, boolean isStatic) {
+ if (!isStatic) {
+ for (GetterSetterPrototypeProvider provider : Extensions.getExtensions(EP_NAME)) {
+ final PsiMethod[] getterSetter = provider.findGetters(aClass, propertyName);
+ if (getterSetter != null) return getterSetter;
+ }
+ }
+ final PsiMethod propertyGetterSetter = PropertyUtil.findPropertyGetter(aClass, propertyName, isStatic, false);
+ if (propertyGetterSetter != null) {
+ return new PsiMethod[] {propertyGetterSetter};
+ }
+ return null;
+ }
+
+ public static String suggestNewGetterName(String oldPropertyName, String newPropertyName, PsiMethod method) {
+ for (GetterSetterPrototypeProvider provider : Extensions.getExtensions(EP_NAME)) {
+ if (provider.isSimpleGetter(method, oldPropertyName)) {
+ return provider.suggestGetterName(newPropertyName);
+ }
+ }
+ return null;
+ }
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/OverrideImplementUtil.java b/java/java-impl/src/com/intellij/codeInsight/generation/OverrideImplementUtil.java
index 68c3684..53630f6 100644
--- a/java/java-impl/src/com/intellij/codeInsight/generation/OverrideImplementUtil.java
+++ b/java/java-impl/src/com/intellij/codeInsight/generation/OverrideImplementUtil.java
@@ -435,17 +435,6 @@
Collection<CandidateInfo> secondary = toImplement || aClass.isInterface() ?
ContainerUtil.<CandidateInfo>newArrayList() : getMethodsToOverrideImplement(aClass, true);
- if (toImplement && PsiUtil.isLanguageLevel8OrHigher(aClass)) {
- for (Iterator<CandidateInfo> iterator = candidates.iterator(); iterator.hasNext(); ) {
- CandidateInfo candidate = iterator.next();
- PsiElement element = candidate.getElement();
- if (element instanceof PsiMethod && ((PsiMethod)element).hasModifierProperty(PsiModifier.DEFAULT)) {
- iterator.remove();
- secondary.add(candidate);
- }
- }
- }
-
final MemberChooser<PsiMethodMember> chooser = showOverrideImplementChooser(editor, aClass, toImplement, candidates, secondary);
if (chooser == null) return;
@@ -461,6 +450,9 @@
}.execute();
}
+ /**
+ * @param candidates, secondary should allow modifications
+ */
@Nullable
public static MemberChooser<PsiMethodMember> showOverrideImplementChooser(Editor editor,
final PsiElement aClass,
@@ -468,6 +460,17 @@
final Collection<CandidateInfo> candidates,
Collection<CandidateInfo> secondary) {
+ if (toImplement && PsiUtil.isLanguageLevel8OrHigher(aClass)) {
+ for (Iterator<CandidateInfo> iterator = candidates.iterator(); iterator.hasNext(); ) {
+ CandidateInfo candidate = iterator.next();
+ PsiElement element = candidate.getElement();
+ if (element instanceof PsiMethod && ((PsiMethod)element).hasModifierProperty(PsiModifier.DEFAULT)) {
+ iterator.remove();
+ secondary.add(candidate);
+ }
+ }
+ }
+
final JavaOverrideImplementMemberChooser chooser =
JavaOverrideImplementMemberChooser.create(aClass, toImplement, candidates, secondary);
if (chooser == null) {
@@ -612,7 +615,7 @@
finally {
PsiFile psiFile = psiClass.getContainingFile();
- Editor editor = fileEditorManager.openTextEditor(new OpenFileDescriptor(psiFile.getProject(), psiFile.getVirtualFile()), false);
+ Editor editor = fileEditorManager.openTextEditor(new OpenFileDescriptor(psiFile.getProject(), psiFile.getVirtualFile()), true);
if (editor != null && !results.isEmpty()) {
results.get(0).positionCaret(editor, true);
editor.getScrollingModel().scrollToCaret(ScrollType.CENTER);
diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/PropertyClassMember.java b/java/java-impl/src/com/intellij/codeInsight/generation/PropertyClassMember.java
index 006e5e5..7c5378f 100644
--- a/java/java-impl/src/com/intellij/codeInsight/generation/PropertyClassMember.java
+++ b/java/java-impl/src/com/intellij/codeInsight/generation/PropertyClassMember.java
@@ -15,6 +15,7 @@
*/
package com.intellij.codeInsight.generation;
+import com.intellij.psi.PsiClass;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.Nullable;
@@ -25,13 +26,15 @@
public interface PropertyClassMember extends EncapsulatableClassMember {
/**
* @return PsiElement or TemplateGenerationInfo
+ * @param aClass
*/
@Nullable
- GenerationInfo[] generateGetters() throws IncorrectOperationException;
+ GenerationInfo[] generateGetters(PsiClass aClass) throws IncorrectOperationException;
/**
* @return PsiElement or TemplateGenerationInfo
+ * @param aClass
*/
@Nullable
- GenerationInfo[] generateSetters() throws IncorrectOperationException;
+ GenerationInfo[] generateSetters(PsiClass aClass) throws IncorrectOperationException;
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/PsiFieldMember.java b/java/java-impl/src/com/intellij/codeInsight/generation/PsiFieldMember.java
index a4817c5..a14108b 100644
--- a/java/java-impl/src/com/intellij/codeInsight/generation/PsiFieldMember.java
+++ b/java/java-impl/src/com/intellij/codeInsight/generation/PsiFieldMember.java
@@ -42,38 +42,37 @@
@Nullable
@Override
public GenerationInfo generateGetter() throws IncorrectOperationException {
- final GenerationInfo[] infos = generateGetters();
+ final GenerationInfo[] infos = generateGetters(getElement().getContainingClass());
return infos != null && infos.length > 0 ? infos[0] : null;
}
@Nullable
@Override
- public GenerationInfo[] generateGetters() throws IncorrectOperationException {
- final PsiField field = getElement();
- return createGenerateInfos(field, GetterSetterPrototypeProvider.generateGetterSetters(field, true));
+ public GenerationInfo[] generateGetters(PsiClass aClass) throws IncorrectOperationException {
+ return createGenerateInfos(aClass, GetterSetterPrototypeProvider.generateGetterSetters(getElement(), true));
}
@Nullable
@Override
public GenerationInfo generateSetter() throws IncorrectOperationException {
- final GenerationInfo[] infos = generateSetters();
+ final GenerationInfo[] infos = generateSetters(getElement().getContainingClass());
return infos != null && infos.length > 0 ? infos[0] : null;
}
@Override
@Nullable
- public GenerationInfo[] generateSetters() {
+ public GenerationInfo[] generateSetters(PsiClass aClass) {
final PsiField field = getElement();
if (GetterSetterPrototypeProvider.isReadOnlyProperty(field)) {
return null;
}
- return createGenerateInfos(field, GetterSetterPrototypeProvider.generateGetterSetters(field, false));
+ return createGenerateInfos(aClass, GetterSetterPrototypeProvider.generateGetterSetters(field, false));
}
- private static GenerationInfo[] createGenerateInfos(PsiField field, PsiMethod[] prototypes) {
+ private static GenerationInfo[] createGenerateInfos(PsiClass aClass, PsiMethod[] prototypes) {
final List<GenerationInfo> methods = new ArrayList<GenerationInfo>();
for (PsiMethod prototype : prototypes) {
- final PsiMethod method = createMethodIfNotExists(field, prototype);
+ final PsiMethod method = createMethodIfNotExists(aClass, prototype);
if (method != null) {
methods.add(new PsiGenerationInfo(method));
}
@@ -82,8 +81,7 @@
}
@Nullable
- private static PsiMethod createMethodIfNotExists(final PsiField field, final PsiMethod template) {
- final PsiClass aClass = field.getContainingClass();
+ private static PsiMethod createMethodIfNotExists(PsiClass aClass, final PsiMethod template) {
PsiMethod existing = aClass.findMethodBySignature(template, false);
if (existing == null) {
if (template != null) {
diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/actions/GenerateCreateUIAction.java b/java/java-impl/src/com/intellij/codeInsight/generation/actions/GenerateCreateUIAction.java
index dee80a6..16ec3cc 100644
--- a/java/java-impl/src/com/intellij/codeInsight/generation/actions/GenerateCreateUIAction.java
+++ b/java/java-impl/src/com/intellij/codeInsight/generation/actions/GenerateCreateUIAction.java
@@ -17,6 +17,7 @@
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTypesUtil;
+import com.intellij.util.containers.HashSet;
/**
* @author Konstantin Bulenkov
@@ -27,12 +28,12 @@
}
@Override
- protected boolean isValidForClass(PsiClass targetClass) {
+ public boolean isValidForClass(PsiClass targetClass) {
final PsiModifierList list = targetClass.getModifierList();
return list != null
&& !list.hasModifierProperty(PsiModifier.ABSTRACT)
&& !hasCreateUIMethod(targetClass)
- && isComponentUI(targetClass);
+ && isComponentUI(targetClass, new HashSet<PsiClass>());
}
private static boolean hasCreateUIMethod(PsiClass aClass) {
@@ -49,8 +50,9 @@
return false;
}
- private static boolean isComponentUI(PsiClass aClass) {
+ private static boolean isComponentUI(PsiClass aClass, HashSet<PsiClass> classes) {
while (aClass != null) {
+ if (!classes.add(aClass)) return false;
if ("javax.swing.plaf.ComponentUI".equals(aClass.getQualifiedName())) {
return true;
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithTryFinallySurrounder.java b/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithTryFinallySurrounder.java
index c9a13f6..e757dde 100644
--- a/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithTryFinallySurrounder.java
+++ b/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithTryFinallySurrounder.java
@@ -16,6 +16,7 @@
package com.intellij.codeInsight.generation.surroundWith;
import com.intellij.codeInsight.CodeInsightBundle;
+import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.EditorModificationUtil;
@@ -28,6 +29,8 @@
import org.jetbrains.annotations.NonNls;
class JavaWithTryFinallySurrounder extends JavaStatementsSurrounder{
+ private static final Logger LOG = Logger.getInstance("#" + JavaWithTryFinallySurrounder.class.getName());
+
@Override
public String getTemplateDescription() {
return CodeInsightBundle.message("surround.with.try.finally.template");
@@ -67,7 +70,9 @@
final Document document = editor.getDocument();
PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(document);
editor.getSelectionModel().removeSelection();
- final PsiStatement firstTryStmt = tryBlock.getStatements()[0];
+ final PsiStatement[] tryBlockStatements = tryBlock.getStatements();
+ LOG.assertTrue(tryBlockStatements.length > 0, tryBlock.getText());
+ final PsiStatement firstTryStmt = tryBlockStatements[0];
final int indent = firstTryStmt.getTextOffset() - document.getLineStartOffset(document.getLineNumber(firstTryStmt.getTextOffset()));
EditorModificationUtil.insertStringAtCaret(editor, StringUtil.repeat(" ", indent), false, true);
return new TextRange(editor.getCaretModel().getOffset(), editor.getCaretModel().getOffset());
diff --git a/java/java-impl/src/com/intellij/codeInsight/highlighting/HighlightSuppressedWarningsHandler.java b/java/java-impl/src/com/intellij/codeInsight/highlighting/HighlightSuppressedWarningsHandler.java
index 2e92545..9d6fe88 100644
--- a/java/java-impl/src/com/intellij/codeInsight/highlighting/HighlightSuppressedWarningsHandler.java
+++ b/java/java-impl/src/com/intellij/codeInsight/highlighting/HighlightSuppressedWarningsHandler.java
@@ -25,11 +25,7 @@
import com.intellij.codeInsight.daemon.impl.LocalInspectionsPass;
import com.intellij.codeInspection.InspectionManager;
import com.intellij.codeInspection.InspectionProfile;
-import com.intellij.codeInspection.InspectionProfileEntry;
-import com.intellij.codeInspection.ex.GlobalInspectionContextImpl;
-import com.intellij.codeInspection.ex.InspectionManagerEx;
-import com.intellij.codeInspection.ex.InspectionProfileImpl;
-import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
+import com.intellij.codeInspection.ex.*;
import com.intellij.codeInspection.reference.RefManagerImpl;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
@@ -122,20 +118,20 @@
if (!(value instanceof String)) {
continue;
}
- final InspectionProfileEntry toolById = ((InspectionProfileImpl)inspectionProfile).getToolById((String)value, target);
- if (!(toolById instanceof LocalInspectionToolWrapper)) {
+ InspectionToolWrapper toolWrapperById = ((InspectionProfileImpl)inspectionProfile).getToolById((String)value, target);
+ if (!(toolWrapperById instanceof LocalInspectionToolWrapper)) {
continue;
}
- final LocalInspectionToolWrapper tool = ((LocalInspectionToolWrapper)toolById).createCopy();
+ final LocalInspectionToolWrapper toolWrapper = ((LocalInspectionToolWrapper)toolWrapperById).createCopy();
final InspectionManagerEx managerEx = (InspectionManagerEx)InspectionManager.getInstance(project);
final GlobalInspectionContextImpl context = managerEx.createNewGlobalContext(false);
- tool.initialize(context);
+ toolWrapper.initialize(context);
((RefManagerImpl)context.getRefManager()).inspectionReadActionStarted();
ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
Runnable inspect = new Runnable() {
@Override
public void run() {
- pass.doInspectInBatch(managerEx, Collections.<LocalInspectionToolWrapper>singletonList(tool));
+ pass.doInspectInBatch(managerEx, Collections.<LocalInspectionToolWrapper>singletonList(toolWrapper));
}
};
if (indicator == null) {
diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/ConcatenationToMessageFormatAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/ConcatenationToMessageFormatAction.java
index 544440f..9bc47e3 100644
--- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/ConcatenationToMessageFormatAction.java
+++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/ConcatenationToMessageFormatAction.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -25,7 +25,6 @@
import com.intellij.psi.*;
import com.intellij.psi.codeStyle.CodeStyleManager;
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
-import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.util.PsiConcatenationUtil;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
@@ -60,7 +59,7 @@
if (concatenation == null) return;
StringBuilder formatString = new StringBuilder();
List<PsiExpression> args = new ArrayList<PsiExpression>();
- buildMessageFormatString(concatenation, formatString, args);
+ PsiConcatenationUtil.buildFormatString(concatenation, formatString, args, false);
final PsiElementFactory factory = JavaPsiFacade.getElementFactory(project);
PsiMethodCallExpression call = (PsiMethodCallExpression)
@@ -87,47 +86,6 @@
concatenation.replace(call);
}
- public static void buildMessageFormatString(PsiExpression expression,
- StringBuilder formatString,
- List<PsiExpression> args)
- throws IncorrectOperationException {
- PsiConcatenationUtil.buildFormatString(expression, formatString, args, false);
-
- }
-
- private static void appendArgument(List<PsiExpression> args, PsiExpression argument, StringBuilder formatString) throws IncorrectOperationException {
- formatString.append("{").append(args.size()).append("}");
- args.add(getBoxedArgument(argument));
- }
-
- private static PsiExpression getBoxedArgument(PsiExpression arg) throws IncorrectOperationException {
- arg = PsiUtil.deparenthesizeExpression(arg);
- assert arg != null;
- if (PsiUtil.isLanguageLevel5OrHigher(arg)) {
- return arg;
- }
- final PsiType type = arg.getType();
- if (!(type instanceof PsiPrimitiveType) || type.equals(PsiType.NULL)) {
- return arg;
- }
- final PsiPrimitiveType primitiveType = (PsiPrimitiveType)type;
- final String boxedQName = primitiveType.getBoxedTypeName();
- if (boxedQName == null) {
- return arg;
- }
- final GlobalSearchScope resolveScope = arg.getResolveScope();
- final PsiElementFactory factory = JavaPsiFacade.getElementFactory(arg.getProject());
- final PsiJavaCodeReferenceElement ref = factory.createReferenceElementByFQClassName(boxedQName, resolveScope);
- final PsiNewExpression newExpr = (PsiNewExpression)factory.createExpressionFromText("new A(b)", null);
- final PsiElement classRef = newExpr.getClassReference();
- assert classRef != null;
- classRef.replace(ref);
- final PsiExpressionList argumentList = newExpr.getArgumentList();
- assert argumentList != null;
- argumentList.getExpressions()[0].replace(arg);
- return newExpr;
- }
-
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
if (PsiUtil.getLanguageLevel(file).compareTo(LanguageLevel.JDK_1_4) < 0) return false;
diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/SplitDeclarationAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/SplitDeclarationAction.java
index 51089f5..7b69611 100644
--- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/SplitDeclarationAction.java
+++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/SplitDeclarationAction.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -18,6 +18,7 @@
import com.intellij.codeInsight.CodeInsightBundle;
import com.intellij.codeInsight.FileModificationService;
import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction;
+import com.intellij.lang.java.JavaLanguage;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
@@ -42,6 +43,7 @@
if (element instanceof PsiCompiledElement) return false;
if (!element.getManager().isInProject(element)) return false;
+ if (!element.getLanguage().isKindOf(JavaLanguage.INSTANCE)) return false;
final PsiElement context = PsiTreeUtil.getParentOfType(element, PsiDeclarationStatement.class, PsiClass.class);
if (context instanceof PsiDeclarationStatement) {
diff --git a/java/java-impl/src/com/intellij/codeInsight/javadoc/JavaDocExternalFilter.java b/java/java-impl/src/com/intellij/codeInsight/javadoc/JavaDocExternalFilter.java
index 1713f6b..cac3b57 100644
--- a/java/java-impl/src/com/intellij/codeInsight/javadoc/JavaDocExternalFilter.java
+++ b/java/java-impl/src/com/intellij/codeInsight/javadoc/JavaDocExternalFilter.java
@@ -59,7 +59,7 @@
protected static @NonNls final Pattern ourAnchorsuffix = Pattern.compile("#(.*)$");
protected static @NonNls final Pattern ourHTMLFilesuffix = Pattern.compile("/([^/]*[.][hH][tT][mM][lL]?)$");
private static @NonNls final Pattern ourHREFselector = Pattern.compile("<A.*?HREF=\"([^>\"]*)\"", Pattern.CASE_INSENSITIVE|Pattern.DOTALL);
- private static @NonNls final Pattern ourMethodHeading = Pattern.compile("<H3>(.+?)</H3>", Pattern.CASE_INSENSITIVE|Pattern.DOTALL);
+ private static @NonNls final Pattern ourMethodHeading = Pattern.compile("<H[34]>(.+?)</H[34]>", Pattern.CASE_INSENSITIVE|Pattern.DOTALL);
protected static @NonNls final String DOC_ELEMENT_PROTOCOL = "doc_element://";
@NonNls protected static final String H2 = "</H2>";
@NonNls protected static final String HTML_CLOSE = "</HTML>";
diff --git a/java/java-impl/src/com/intellij/codeInsight/lookup/VariableLookupItem.java b/java/java-impl/src/com/intellij/codeInsight/lookup/VariableLookupItem.java
index 9fa4834..db14eca 100644
--- a/java/java-impl/src/com/intellij/codeInsight/lookup/VariableLookupItem.java
+++ b/java/java-impl/src/com/intellij/codeInsight/lookup/VariableLookupItem.java
@@ -169,8 +169,9 @@
PsiClass containingClass = field.getContainingClass();
if (containingClass != null && containingClass.getName() != null) {
- context.getDocument().insertString(context.getStartOffset(), ".");
+ OffsetKey oldStart = context.trackOffset(context.getStartOffset(), true);
JavaCompletionUtil.insertClassReference(containingClass, file, context.getStartOffset());
+ context.getDocument().insertString(context.getOffsetMap().getOffset(oldStart), ".");
PsiDocumentManager.getInstance(context.getProject()).commitDocument(context.getDocument());
}
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/macro/MacroUtil.java b/java/java-impl/src/com/intellij/codeInsight/template/macro/MacroUtil.java
index 059c047..6010a7a 100644
--- a/java/java-impl/src/com/intellij/codeInsight/template/macro/MacroUtil.java
+++ b/java/java-impl/src/com/intellij/codeInsight/template/macro/MacroUtil.java
@@ -27,11 +27,13 @@
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
import com.intellij.util.IncorrectOperationException;
+import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
public class MacroUtil {
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.template.macro.MacroUtil");
@@ -158,11 +160,15 @@
return new PsiVariable[0];
}
+ final Set<String> usedNames = ContainerUtil.newHashSet();
final List<PsiVariable> list = new ArrayList<PsiVariable>();
VariablesProcessor varproc = new VariablesProcessor(prefix, true, list) {
@Override
public boolean execute(@NotNull PsiElement pe, ResolveState state) {
if (pe instanceof PsiVariable) {
+ if (!usedNames.add(((PsiVariable)pe).getName())) {
+ return false;
+ }
//exclude variables that are initialized in 'place'
final PsiExpression initializer = ((PsiVariable)pe).getInitializer();
if (initializer != null && PsiTreeUtil.isAncestor(initializer, place, false)) return true;
diff --git a/java/java-impl/src/com/intellij/codeInspection/RedundantSuppressInspection.java b/java/java-impl/src/com/intellij/codeInspection/RedundantSuppressInspection.java
index f65d580..354af57 100644
--- a/java/java-impl/src/com/intellij/codeInspection/RedundantSuppressInspection.java
+++ b/java/java-impl/src/com/intellij/codeInspection/RedundantSuppressInspection.java
@@ -19,10 +19,8 @@
import com.intellij.codeInsight.daemon.GroupNames;
import com.intellij.codeInsight.daemon.impl.RemoveSuppressWarningAction;
import com.intellij.codeInspection.ex.*;
-import com.intellij.codeInspection.reference.RefClass;
-import com.intellij.codeInspection.reference.RefElement;
-import com.intellij.codeInspection.reference.RefJavaVisitor;
-import com.intellij.codeInspection.reference.RefManagerImpl;
+import com.intellij.codeInspection.reference.*;
+import com.intellij.codeInspection.ui.InspectionToolPresentation;
import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
@@ -116,7 +114,7 @@
return checkElement(psiClass, manager, project);
}
- public CommonProblemDescriptor[] checkElement(@NotNull final PsiElement psiElement, @NotNull InspectionManager manager, @NotNull Project project) {
+ public CommonProblemDescriptor[] checkElement(@NotNull final PsiElement psiElement, @NotNull final InspectionManager manager, @NotNull Project project) {
final Map<PsiElement, Collection<String>> suppressedScopes = new THashMap<PsiElement, Collection<String>>();
psiElement.accept(new JavaRecursiveElementWalkingVisitor() {
@Override public void visitModifierList(PsiModifierList list) {
@@ -141,7 +139,7 @@
private void checkElement(final PsiElement owner) {
String idsString = SuppressManager.getInstance().getSuppressedInspectionIdsIn(owner);
- if (idsString != null && idsString.length() != 0) {
+ if (idsString != null && !idsString.isEmpty()) {
List<String> ids = StringUtil.split(idsString, ",");
if (IGNORE_ALL && (ids.contains(SuppressionUtil.ALL) || ids.contains(SuppressionUtil.ALL.toLowerCase()))) return;
Collection<String> suppressed = suppressedScopes.get(owner);
@@ -162,27 +160,29 @@
if (suppressedScopes.values().isEmpty()) return null;
// have to visit all file from scratch since inspections can be written in any perversive way including checkFile() overriding
- Collection<InspectionTool> suppressedTools = new THashSet<InspectionTool>();
- InspectionTool[] tools = getInspectionTools(psiElement, manager);
+ Collection<InspectionToolWrapper> suppressedTools = new THashSet<InspectionToolWrapper>();
+ InspectionToolWrapper[] toolWrappers = getInspectionTools(psiElement, manager);
for (Collection<String> ids : suppressedScopes.values()) {
for (Iterator<String> iterator = ids.iterator(); iterator.hasNext(); ) {
final String shortName = iterator.next().trim();
- for (InspectionTool tool : tools) {
- if (tool instanceof LocalInspectionToolWrapper && ((LocalInspectionToolWrapper)tool).getTool().getID().equals(shortName)) {
- if (!((LocalInspectionToolWrapper)tool).isUnfair()) {
- suppressedTools.add(tool);
- } else {
+ for (InspectionToolWrapper toolWrapper : toolWrappers) {
+ if (toolWrapper instanceof LocalInspectionToolWrapper && ((LocalInspectionToolWrapper)toolWrapper).getTool().getID().equals(shortName)) {
+ if (((LocalInspectionToolWrapper)toolWrapper).isUnfair()) {
iterator.remove();
break;
}
+ else {
+ suppressedTools.add(toolWrapper);
+ }
}
- else if (tool.getShortName().equals(shortName)) {
+ else if (toolWrapper.getShortName().equals(shortName)) {
//ignore global unused as it won't be checked anyway
- if (!(tool instanceof LocalInspectionToolWrapper) && !(tool instanceof GlobalInspectionToolWrapper)) {
+ if (toolWrapper instanceof LocalInspectionToolWrapper || toolWrapper instanceof GlobalInspectionToolWrapper) {
+ suppressedTools.add(toolWrapper);
+ }
+ else {
iterator.remove();
break;
- } else {
- suppressedTools.add(tool);
}
}
}
@@ -190,31 +190,44 @@
}
final AnalysisScope scope = new AnalysisScope(psiElement.getContainingFile());
- final InspectionManagerEx inspectionManagerEx = ((InspectionManagerEx)InspectionManager.getInstance(project));
- GlobalInspectionContextImpl globalContext = inspectionManagerEx.createNewGlobalContext(false);
+ final InspectionManagerEx inspectionManagerEx = (InspectionManagerEx)InspectionManager.getInstance(project);
+ final GlobalInspectionContextImpl globalContext = inspectionManagerEx.createNewGlobalContext(false);
globalContext.setCurrentScope(scope);
- final RefManagerImpl refManager = ((RefManagerImpl)globalContext.getRefManager());
+ final RefManagerImpl refManager = (RefManagerImpl)globalContext.getRefManager();
refManager.inspectionReadActionStarted();
final List<ProblemDescriptor> result;
try {
result = new ArrayList<ProblemDescriptor>();
- for (InspectionTool tool : suppressedTools) {
- String toolId = tool instanceof LocalInspectionToolWrapper ? ((LocalInspectionToolWrapper)tool).getTool().getID() : tool.getShortName();
- tool.initialize(globalContext);
+ for (InspectionToolWrapper toolWrapper : suppressedTools) {
+ String toolId = toolWrapper instanceof LocalInspectionToolWrapper ? ((LocalInspectionToolWrapper)toolWrapper).getTool().getID() : toolWrapper.getShortName();
+ toolWrapper.initialize(globalContext);
Collection<CommonProblemDescriptor> descriptors;
- if (tool instanceof LocalInspectionToolWrapper) {
- LocalInspectionToolWrapper local = (LocalInspectionToolWrapper)tool;
+ final InspectionToolPresentation presentation = globalContext.getPresentation(toolWrapper);
+ if (toolWrapper instanceof LocalInspectionToolWrapper) {
+ LocalInspectionToolWrapper local = (LocalInspectionToolWrapper)toolWrapper;
if (local.isUnfair()) continue; //cant't work with passes other than LocalInspectionPass
- local.processFile(psiElement.getContainingFile(), false, manager);
- descriptors = local.getProblemDescriptors();
+ List<ProblemDescriptor> results = local.getTool().processFile(psiElement.getContainingFile(), manager);
+ InspectionToolPresentation toolPresentation = globalContext.getPresentation(local);
+ LocalDescriptorsUtil.addProblemDescriptors(results, toolPresentation, false, globalContext, local.getTool());
+ descriptors = presentation.getProblemDescriptors();
}
- else if (tool instanceof GlobalInspectionToolWrapper) {
- GlobalInspectionToolWrapper global = (GlobalInspectionToolWrapper)tool;
- if (global.getTool().isGraphNeeded()) {
+ else if (toolWrapper instanceof GlobalInspectionToolWrapper) {
+ final GlobalInspectionToolWrapper global = (GlobalInspectionToolWrapper)toolWrapper;
+ GlobalInspectionTool globalTool = global.getTool();
+ if (globalTool.isGraphNeeded()) {
refManager.findAllDeclarations();
}
- global.processFile(scope, manager, globalContext, false);
- descriptors = global.getProblemDescriptors();
+ final InspectionToolPresentation toolPresentation = globalContext.getPresentation(global);
+ globalContext.getRefManager().iterate(new RefVisitor() {
+ @Override public void visitElement(@NotNull RefEntity refEntity) {
+ CommonProblemDescriptor[]
+ descriptors1 = global.getTool().checkElement(refEntity, scope, manager, globalContext, toolPresentation);
+ if (descriptors1 != null) {
+ toolPresentation.addProblemElement(refEntity, false, descriptors1);
+ }
+ }
+ });
+ descriptors = presentation.getProblemDescriptors();
}
else {
continue;
@@ -283,9 +296,8 @@
return result.toArray(new ProblemDescriptor[result.size()]);
}
- protected InspectionTool[] getInspectionTools(PsiElement psiElement, InspectionManager manager) {
- final ModifiableModel
- model = InspectionProjectProfileManager.getInstance(manager.getProject()).getInspectionProfile().getModifiableModel();
+ protected InspectionToolWrapper[] getInspectionTools(PsiElement psiElement, @NotNull InspectionManager manager) {
+ ModifiableModel model = InspectionProjectProfileManager.getInstance(manager.getProject()).getInspectionProfile().getModifiableModel();
InspectionProfileWrapper profile = new InspectionProfileWrapper((InspectionProfile)model);
profile.init(manager.getProject());
diff --git a/java/java-impl/src/com/intellij/codeInspection/canBeFinal/CanBeFinalInspection.java b/java/java-impl/src/com/intellij/codeInspection/canBeFinal/CanBeFinalInspection.java
index 35a997f..105bee1 100644
--- a/java/java-impl/src/com/intellij/codeInspection/canBeFinal/CanBeFinalInspection.java
+++ b/java/java-impl/src/com/intellij/codeInspection/canBeFinal/CanBeFinalInspection.java
@@ -177,7 +177,8 @@
}
@Override
- protected boolean queryExternalUsagesRequests(@NotNull final RefManager manager, @NotNull final GlobalJavaInspectionContext globalContext,
+ protected boolean queryExternalUsagesRequests(@NotNull final RefManager manager,
+ @NotNull final GlobalJavaInspectionContext globalContext,
@NotNull final ProblemDescriptionsProcessor problemsProcessor) {
for (RefElement entryPoint : globalContext.getEntryPointsManager(manager).getEntryPoints()) {
problemsProcessor.ignoreElement(entryPoint);
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspection.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspection.java
index 348d3df..c22571a 100644
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspection.java
+++ b/java/java-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspection.java
@@ -46,6 +46,7 @@
}
private class OptionsPanel extends JPanel {
+ private final JCheckBox myIgnoreAssertions;
private final JCheckBox mySuggestNullables;
private final JCheckBox myDontReportTrueAsserts;
@@ -77,6 +78,15 @@
DONT_REPORT_TRUE_ASSERT_STATEMENTS = myDontReportTrueAsserts.isSelected();
}
});
+
+ myIgnoreAssertions = new JCheckBox("Ignore assert statements");
+ myIgnoreAssertions.setSelected(IGNORE_ASSERT_STATEMENTS);
+ myIgnoreAssertions.getModel().addChangeListener(new ChangeListener() {
+ @Override
+ public void stateChanged(ChangeEvent e) {
+ IGNORE_ASSERT_STATEMENTS = myIgnoreAssertions.isSelected();
+ }
+ });
gc.insets = new Insets(0, 0, 0, 0);
gc.gridy = 0;
@@ -121,6 +131,9 @@
gc.insets.left = 0;
gc.gridy++;
add(myDontReportTrueAsserts, gc);
+
+ gc.gridy++;
+ add(myIgnoreAssertions, gc);
}
}
diff --git a/java/java-impl/src/com/intellij/codeInspection/deadCode/DeadHTMLComposer.java b/java/java-impl/src/com/intellij/codeInspection/deadCode/DeadHTMLComposer.java
index 9b5cb30..88f5618 100644
--- a/java/java-impl/src/com/intellij/codeInspection/deadCode/DeadHTMLComposer.java
+++ b/java/java-impl/src/com/intellij/codeInspection/deadCode/DeadHTMLComposer.java
@@ -28,8 +28,8 @@
import com.intellij.codeInspection.InspectionsBundle;
import com.intellij.codeInspection.ex.DescriptorComposer;
import com.intellij.codeInspection.ex.HTMLComposerImpl;
-import com.intellij.codeInspection.ex.InspectionTool;
import com.intellij.codeInspection.reference.*;
+import com.intellij.codeInspection.ui.InspectionToolPresentation;
import com.intellij.codeInspection.ui.InspectionTreeNode;
import com.intellij.codeInspection.ui.RefElementNode;
import org.jetbrains.annotations.NonNls;
@@ -41,11 +41,11 @@
import java.util.Set;
public class DeadHTMLComposer extends HTMLComposerImpl {
- private final InspectionTool myTool;
+ private final InspectionToolPresentation myToolPresentation;
private final HTMLJavaHTMLComposer myComposer;
- public DeadHTMLComposer(@NotNull InspectionTool tool) {
- myTool = tool;
+ public DeadHTMLComposer(@NotNull InspectionToolPresentation presentation) {
+ myToolPresentation = presentation;
myComposer = getExtension(HTMLJavaHTMLComposer.COMPOSER);
}
@@ -64,7 +64,7 @@
//noinspection HardCodedStringLiteral
buf.append("<br><br>");
- appendResolution(buf, refElement, DescriptorComposer.quickFixTexts(refElement, myTool));
+ appendResolution(buf, refElement, DescriptorComposer.quickFixTexts(refElement, myToolPresentation));
refElement.accept(new RefJavaVisitor() {
@Override public void visitClass(@NotNull RefClass aClass) {
appendClassInstantiations(buf, aClass);
@@ -339,7 +339,7 @@
}
private void appendCallesList(RefElement element, StringBuffer buf, Set<RefElement> mentionedElements, boolean appendCallees){
- final Set<RefElement> possibleChildren = getPossibleChildren(new RefElementNode(element, myTool), element);
+ final Set<RefElement> possibleChildren = getPossibleChildren(new RefElementNode(element, myToolPresentation), element);
if (!possibleChildren.isEmpty()) {
if (appendCallees){
appendHeading(buf, InspectionsBundle.message("inspection.export.results.callees"));
diff --git a/java/java-impl/src/com/intellij/codeInspection/deadCode/DummyEntryPointsPresentation.java b/java/java-impl/src/com/intellij/codeInspection/deadCode/DummyEntryPointsPresentation.java
new file mode 100644
index 0000000..531c88c
--- /dev/null
+++ b/java/java-impl/src/com/intellij/codeInspection/deadCode/DummyEntryPointsPresentation.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2000-2013 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.codeInspection.deadCode;
+
+import com.intellij.codeInspection.InspectionsBundle;
+import com.intellij.codeInspection.ex.*;
+import com.intellij.codeInspection.reference.RefElement;
+import com.intellij.codeInspection.reference.RefEntity;
+import com.intellij.codeInspection.ui.InspectionNode;
+import com.intellij.codeInspection.ui.InspectionTreeNode;
+import com.intellij.codeInspection.util.RefFilter;
+import org.jetbrains.annotations.NotNull;
+
+public class DummyEntryPointsPresentation extends UnusedDeclarationPresentation {
+ private static final RefEntryPointFilter myFilter = new RefEntryPointFilter();
+ private QuickFixAction[] myQuickFixActions;
+
+ public DummyEntryPointsPresentation(UnusedDeclarationInspection inspection, @NotNull InspectionToolWrapper toolWrapper) {
+ super(toolWrapper);
+ }
+
+ @Override
+ public RefFilter getFilter() {
+ return myFilter;
+ }
+
+ @Override
+ public QuickFixAction[] getQuickFixes(@NotNull final RefEntity[] refElements) {
+ if (myQuickFixActions == null) {
+ myQuickFixActions = new QuickFixAction[]{new MoveEntriesToSuspicious(getToolWrapper())};
+ }
+ return myQuickFixActions;
+ }
+
+ private class MoveEntriesToSuspicious extends QuickFixAction {
+ private MoveEntriesToSuspicious(@NotNull InspectionToolWrapper toolWrapper) {
+ super(InspectionsBundle.message("inspection.dead.code.remove.from.entry.point.quickfix"), null, null, toolWrapper);
+ }
+
+ @Override
+ protected boolean applyFix(RefEntity[] refElements) {
+ final EntryPointsManager entryPointsManager =
+ getContext().getExtension(GlobalJavaInspectionContextImpl.CONTEXT).getEntryPointsManager(getContext().getRefManager());
+ for (RefEntity refElement : refElements) {
+ if (refElement instanceof RefElement) {
+ entryPointsManager.removeEntryPoint((RefElement)refElement);
+ }
+ }
+
+ return true;
+ }
+ }
+
+ @NotNull
+ @Override
+ public InspectionNode createToolNode(@NotNull GlobalInspectionContextImpl context, @NotNull InspectionNode node,
+ @NotNull InspectionRVContentProvider provider,
+ @NotNull InspectionTreeNode parentNode,
+ boolean showStructure) {
+ return node;
+ }
+
+ @Override
+ @NotNull
+ public HTMLComposerImpl getComposer() {
+ return new DeadHTMLComposer(this);
+ }
+}
diff --git a/java/java-impl/src/com/intellij/codeInspection/deadCode/DummyEntryPointsTool.java b/java/java-impl/src/com/intellij/codeInspection/deadCode/DummyEntryPointsTool.java
index 1b8ef74..524f333 100644
--- a/java/java-impl/src/com/intellij/codeInspection/deadCode/DummyEntryPointsTool.java
+++ b/java/java-impl/src/com/intellij/codeInspection/deadCode/DummyEntryPointsTool.java
@@ -19,39 +19,31 @@
import com.intellij.codeInspection.GlobalInspectionContext;
import com.intellij.codeInspection.InspectionManager;
import com.intellij.codeInspection.InspectionsBundle;
-import com.intellij.codeInspection.ex.*;
-import com.intellij.codeInspection.reference.RefElement;
-import com.intellij.codeInspection.reference.RefEntity;
-import com.intellij.codeInspection.util.RefFilter;
-import org.jdom.Element;
+import com.intellij.codeInspection.ProblemDescriptionsProcessor;
+import com.intellij.codeInspection.ex.InspectionPresentationProvider;
+import com.intellij.codeInspection.ex.InspectionToolWrapper;
+import com.intellij.codeInspection.ex.JobDescriptor;
+import com.intellij.codeInspection.ui.InspectionToolPresentation;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
/**
* @author max
*/
-public class DummyEntryPointsTool extends FilteringInspectionTool {
- private static final RefEntryPointFilter myFilter = new RefEntryPointFilter();
- private QuickFixAction[] myQuickFixActions;
-
- public DummyEntryPointsTool(@NotNull UnusedDeclarationInspection owner) {
- initialize(owner.getContext());
+public class DummyEntryPointsTool extends UnusedDeclarationInspection implements InspectionPresentationProvider {
+ public DummyEntryPointsTool() {
}
@Override
- public RefFilter getFilter() {
- return myFilter;
+ public void runInspection(@NotNull AnalysisScope scope,
+ @NotNull InspectionManager manager,
+ @NotNull GlobalInspectionContext globalContext,
+ @NotNull ProblemDescriptionsProcessor problemDescriptionsProcessor) {
}
+ @Nullable
@Override
- public void runInspection(@NotNull AnalysisScope scope, @NotNull final InspectionManager manager) {}
-
- @Override
- public void exportResults(@NotNull Element parentNode, @NotNull RefEntity refEntity) {
- }
-
- @Override
- @NotNull
- public JobDescriptor[] getJobDescriptors(@NotNull GlobalInspectionContext globalInspectionContext) {
+ public JobDescriptor[] getAdditionalJobs() {
return JobDescriptor.EMPTY_ARRAY;
}
@@ -73,34 +65,9 @@
return "";
}
- @Override
@NotNull
- public HTMLComposerImpl getComposer() {
- return new DeadHTMLComposer(this);
- }
-
@Override
- public QuickFixAction[] getQuickFixes(@NotNull final RefEntity[] refElements) {
- if (myQuickFixActions == null) {
- myQuickFixActions = new QuickFixAction[]{new MoveEntriesToSuspicious()};
- }
- return myQuickFixActions;
- }
-
- private class MoveEntriesToSuspicious extends QuickFixAction {
- private MoveEntriesToSuspicious() {
- super(InspectionsBundle.message("inspection.dead.code.remove.from.entry.point.quickfix"), null, null, DummyEntryPointsTool.this);
- }
-
- @Override
- protected boolean applyFix(RefElement[] refElements) {
- final EntryPointsManager entryPointsManager =
- getContext().getExtension(GlobalJavaInspectionContextImpl.CONTEXT).getEntryPointsManager(getContext().getRefManager());
- for (RefElement refElement : refElements) {
- entryPointsManager.removeEntryPoint(refElement);
- }
-
- return true;
- }
+ public InspectionToolPresentation createPresentation(@NotNull InspectionToolWrapper toolWrapper) {
+ return new DummyEntryPointsPresentation(this, toolWrapper);
}
}
diff --git a/java/java-impl/src/com/intellij/codeInspection/deadCode/RefUnreachableFilter.java b/java/java-impl/src/com/intellij/codeInspection/deadCode/RefUnreachableFilter.java
index 5984cf1..b00d749 100644
--- a/java/java-impl/src/com/intellij/codeInspection/deadCode/RefUnreachableFilter.java
+++ b/java/java-impl/src/com/intellij/codeInspection/deadCode/RefUnreachableFilter.java
@@ -24,17 +24,19 @@
*/
package com.intellij.codeInspection.deadCode;
-import com.intellij.codeInspection.ex.InspectionTool;
+import com.intellij.codeInspection.ex.GlobalInspectionContextImpl;
import com.intellij.codeInspection.reference.*;
import com.intellij.codeInspection.util.RefFilter;
import org.jetbrains.annotations.NotNull;
public class RefUnreachableFilter extends RefFilter {
@NotNull
- protected InspectionTool myTool;
+ protected UnusedDeclarationInspection myTool;
+ @NotNull protected final GlobalInspectionContextImpl myContext;
- public RefUnreachableFilter(@NotNull InspectionTool tool) {
+ public RefUnreachableFilter(@NotNull UnusedDeclarationInspection tool, @NotNull GlobalInspectionContextImpl context) {
myTool = tool;
+ myContext = context;
}
@Override
@@ -42,7 +44,7 @@
if (refElement instanceof RefParameter) return 0;
if (refElement.isSyntheticJSP()) return 0;
if (!(refElement instanceof RefMethod || refElement instanceof RefClass || refElement instanceof RefField)) return 0;
- if (!myTool.getContext().isToCheckMember(refElement, myTool)) return 0;
+ if (!myContext.isToCheckMember(refElement, myTool)) return 0;
return ((RefElementImpl)refElement).isSuspicious() ? 1 : 0;
}
}
diff --git a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnreferencedFilter.java b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnreferencedFilter.java
index 32dc522..923e577 100644
--- a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnreferencedFilter.java
+++ b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnreferencedFilter.java
@@ -24,13 +24,13 @@
*/
package com.intellij.codeInspection.deadCode;
-import com.intellij.codeInspection.ex.InspectionTool;
+import com.intellij.codeInspection.ex.GlobalInspectionContextImpl;
import com.intellij.codeInspection.reference.*;
import org.jetbrains.annotations.NotNull;
public class UnreferencedFilter extends RefUnreachableFilter {
- public UnreferencedFilter(@NotNull InspectionTool tool) {
- super(tool);
+ public UnreferencedFilter(@NotNull UnusedDeclarationInspection tool, @NotNull GlobalInspectionContextImpl context) {
+ super(tool, context);
}
@Override
@@ -39,7 +39,7 @@
if (refElement.isEntry() || !((RefElementImpl)refElement).isSuspicious() || refElement.isSyntheticJSP()) return 0;
if (!(refElement instanceof RefMethod || refElement instanceof RefClass || refElement instanceof RefField)) return 0;
- if (!myTool.getContext().isToCheckMember(refElement, myTool)) return 0;
+ if (!myContext.isToCheckMember(refElement, myTool)) return 0;
if (refElement instanceof RefField) {
RefField refField = (RefField) refElement;
diff --git a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java
index fa341a0..7799cc2 100644
--- a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java
+++ b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java
@@ -31,27 +31,17 @@
import com.intellij.codeInsight.daemon.GroupNames;
import com.intellij.codeInsight.daemon.ImplicitUsageProvider;
import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtilBase;
-import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.codeInspection.*;
import com.intellij.codeInspection.ex.*;
import com.intellij.codeInspection.reference.*;
-import com.intellij.codeInspection.ui.EntryPointsNode;
-import com.intellij.codeInspection.ui.InspectionNode;
-import com.intellij.codeInspection.ui.InspectionTreeNode;
+import com.intellij.codeInspection.ui.InspectionToolPresentation;
import com.intellij.codeInspection.util.RefFilter;
-import com.intellij.icons.AllIcons;
-import com.intellij.lang.annotation.HighlightSeverity;
-import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.editor.Document;
-import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.extensions.ExtensionPoint;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.InvalidDataException;
-import com.intellij.openapi.util.SystemInfo;
-import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.psi.*;
import com.intellij.psi.impl.PsiClassImplUtil;
@@ -59,15 +49,9 @@
import com.intellij.psi.search.PsiNonJavaFileReferenceProcessor;
import com.intellij.psi.search.PsiSearchHelper;
import com.intellij.psi.util.PsiMethodUtil;
-import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.psi.util.PsiUtilCore;
-import com.intellij.refactoring.safeDelete.SafeDeleteHandler;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.ui.SeparatorFactory;
-import com.intellij.util.IncorrectOperationException;
import com.intellij.util.containers.HashMap;
-import com.intellij.util.text.CharArrayUtil;
-import com.intellij.util.text.DateFormatUtil;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -77,40 +61,27 @@
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import java.awt.event.InputEvent;
-import java.awt.event.KeyEvent;
import java.util.*;
import java.util.List;
-public class UnusedDeclarationInspection extends FilteringInspectionTool {
+public class UnusedDeclarationInspection extends GlobalInspectionTool implements InspectionPresentationProvider {
public boolean ADD_MAINS_TO_ENTRIES = true;
public boolean ADD_APPLET_TO_ENTRIES = true;
public boolean ADD_SERVLET_TO_ENTRIES = true;
public boolean ADD_NONJAVA_TO_ENTRIES = true;
- private HashSet<RefElement> myProcessedSuspicious = null;
+ private Set<RefElement> myProcessedSuspicious = null;
private int myPhase;
- private final QuickFixAction[] myQuickFixActions;
public static final String DISPLAY_NAME = InspectionsBundle.message("inspection.dead.code.display.name");
- private WeakUnreferencedFilter myFilter;
- private DeadHTMLComposer myComposer;
@NonNls public static final String SHORT_NAME = "UnusedDeclaration";
@NonNls private static final String ALTERNATIVE_ID = "unused";
- private static final String COMMENT_OUT_QUICK_FIX = InspectionsBundle.message("inspection.dead.code.comment.quickfix");
- private static final String DELETE_QUICK_FIX = InspectionsBundle.message("inspection.dead.code.safe.delete.quickfix");
-
- @NonNls private static final String DELETE = "delete";
- @NonNls private static final String COMMENT = "comment";
- @NonNls private static final String [] HINTS = {COMMENT, DELETE};
-
public final EntryPoint[] myExtensions;
private static final Logger LOG = Logger.getInstance("#" + UnusedDeclarationInspection.class.getName());
+ private GlobalInspectionContextImpl myContext;
public UnusedDeclarationInspection() {
-
- myQuickFixActions = new QuickFixAction[]{new PermanentDeleteAction(), new CommentOutBin(), new MoveToEntries()};
ExtensionPoint<EntryPoint> point = Extensions.getRootArea().getExtensionPoint(ExtensionPoints.DEAD_CODE_TOOL);
final EntryPoint[] deadCodeAddins = new EntryPoint[point.getExtensions().length];
EntryPoint[] extensions = point.getExtensions();
@@ -132,10 +103,8 @@
myExtensions = deadCodeAddins;
}
- @Override
- public void initialize(@NotNull final GlobalInspectionContextImpl context) {
- super.initialize(context);
- ((EntryPointsManagerImpl)getEntryPointsManager()).setAddNonJavaEntries(ADD_NONJAVA_TO_ENTRIES);
+ private GlobalInspectionContextImpl getContext() {
+ return myContext;
}
private class OptionsPanel extends JPanel {
@@ -368,9 +337,13 @@
}
@Override
- public void runInspection(@NotNull final AnalysisScope scope, @NotNull final InspectionManager manager) {
- getRefManager().iterate(new RefJavaVisitor() {
- @Override public void visitElement(@NotNull final RefEntity refEntity) {
+ public void runInspection(@NotNull final AnalysisScope scope,
+ @NotNull InspectionManager manager,
+ @NotNull final GlobalInspectionContext globalContext,
+ @NotNull ProblemDescriptionsProcessor problemDescriptionsProcessor) {
+ globalContext.getRefManager().iterate(new RefJavaVisitor() {
+ @Override
+ public void visitElement(@NotNull final RefEntity refEntity) {
if (refEntity instanceof RefJavaElement) {
final RefElementImpl refElement = (RefElementImpl)refEntity;
if (!refElement.isSuspicious()) return;
@@ -379,7 +352,7 @@
if (file == null) return;
final boolean isSuppressed = refElement.isSuppressed(getShortName(), ALTERNATIVE_ID);
- if (!getContext().isToCheckFile(file, UnusedDeclarationInspection.this) || isSuppressed) {
+ if (!((GlobalInspectionContextImpl)globalContext).isToCheckFile(file, UnusedDeclarationInspection.this) || isSuppressed) {
if (isSuppressed || !scope.contains(file)) {
getEntryPointsManager().addEntryPoint(refElement, false);
}
@@ -387,13 +360,15 @@
}
refElement.accept(new RefJavaVisitor() {
- @Override public void visitMethod(@NotNull RefMethod method) {
+ @Override
+ public void visitMethod(@NotNull RefMethod method) {
if (isAddMainsEnabled() && method.isAppMain()) {
getEntryPointsManager().addEntryPoint(method, false);
}
}
- @Override public void visitClass(@NotNull RefClass aClass) {
+ @Override
+ public void visitClass(@NotNull RefClass aClass) {
if (isAddAppletEnabled() && aClass.isApplet() ||
isAddServletEnabled() && aClass.isServlet()) {
getEntryPointsManager().addEntryPoint(aClass, false);
@@ -406,19 +381,21 @@
if (isAddNonJavaUsedEnabled()) {
checkForReachables();
+ final StrictUnreferencedFilter strictUnreferencedFilter = new StrictUnreferencedFilter(this,
+ (GlobalInspectionContextImpl)globalContext);
ProgressManager.getInstance().runProcess(new Runnable() {
@Override
public void run() {
- final RefFilter filter = new StrictUnreferencedFilter(UnusedDeclarationInspection.this);
- final PsiSearchHelper helper = PsiSearchHelper.SERVICE.getInstance(getRefManager().getProject());
- getRefManager().iterate(new RefJavaVisitor() {
- @Override public void visitElement(@NotNull final RefEntity refEntity) {
- if (refEntity instanceof RefClass && filter.accepts((RefClass)refEntity)) {
+ final PsiSearchHelper helper = PsiSearchHelper.SERVICE.getInstance(globalContext.getRefManager().getProject());
+ globalContext.getRefManager().iterate(new RefJavaVisitor() {
+ @Override
+ public void visitElement(@NotNull final RefEntity refEntity) {
+ if (refEntity instanceof RefClass && strictUnreferencedFilter.accepts((RefClass)refEntity)) {
findExternalClassReferences((RefClass)refEntity);
}
else if (refEntity instanceof RefMethod) {
RefMethod refMethod = (RefMethod)refEntity;
- if (refMethod.isConstructor() && filter.accepts(refMethod)) {
+ if (refMethod.isConstructor() && strictUnreferencedFilter.accepts(refMethod)) {
findExternalClassReferences(refMethod.getOwnerClass());
}
}
@@ -436,7 +413,7 @@
return false;
}
},
- GlobalSearchScope.projectScope(getContext().getProject()));
+ GlobalSearchScope.projectScope(globalContext.getProject()));
}
}
});
@@ -514,9 +491,10 @@
return false;
}
+
private static class StrictUnreferencedFilter extends UnreferencedFilter {
- private StrictUnreferencedFilter(@NotNull InspectionTool tool) {
- super(tool);
+ private StrictUnreferencedFilter(@NotNull UnusedDeclarationInspection tool, @NotNull GlobalInspectionContextImpl context) {
+ super(tool, context);
}
@Override
@@ -527,34 +505,25 @@
}
}
- private static class WeakUnreferencedFilter extends UnreferencedFilter {
- private WeakUnreferencedFilter(@NotNull InspectionTool tool) {
- super(tool);
- }
-
- @Override
- public int getElementProblemCount(final RefJavaElement refElement) {
- final int problemCount = super.getElementProblemCount(refElement);
- if (problemCount > - 1) return problemCount;
- if (!((RefElementImpl)refElement).hasSuspiciousCallers() || ((RefJavaElementImpl)refElement).isSuspiciousRecursive()) return 1;
- return 0;
- }
- }
-
@Override
- public boolean queryExternalUsagesRequests(@NotNull final InspectionManager manager) {
+ public boolean queryExternalUsagesRequests(@NotNull InspectionManager manager,
+ @NotNull GlobalInspectionContext globalContext,
+ @NotNull ProblemDescriptionsProcessor problemDescriptionsProcessor) {
checkForReachables();
- final RefFilter filter = myPhase == 1 ? new StrictUnreferencedFilter(this) : new RefUnreachableFilter(this);
+ final RefFilter filter = myPhase == 1 ? new StrictUnreferencedFilter(this, (GlobalInspectionContextImpl)globalContext) :
+ new RefUnreachableFilter(this, (GlobalInspectionContextImpl)globalContext);
final boolean[] requestAdded = {false};
- getRefManager().iterate(new RefJavaVisitor() {
- @Override public void visitElement(@NotNull RefEntity refEntity) {
+ globalContext.getRefManager().iterate(new RefJavaVisitor() {
+ @Override
+ public void visitElement(@NotNull RefEntity refEntity) {
if (!(refEntity instanceof RefJavaElement)) return;
if (refEntity instanceof RefClass && ((RefClass)refEntity).isAnonymous()) return;
- RefJavaElement refElement= (RefJavaElement)refEntity;
+ RefJavaElement refElement = (RefJavaElement)refEntity;
if (filter.accepts(refElement) && !myProcessedSuspicious.contains(refElement)) {
refEntity.accept(new RefJavaVisitor() {
- @Override public void visitField(@NotNull final RefField refField) {
+ @Override
+ public void visitField(@NotNull final RefField refField) {
myProcessedSuspicious.add(refField);
PsiField psiField = refField.getElement();
if (isSerializationImplicitlyUsedField(psiField)) {
@@ -572,7 +541,8 @@
}
}
- @Override public void visitMethod(@NotNull final RefMethod refMethod) {
+ @Override
+ public void visitMethod(@NotNull final RefMethod refMethod) {
myProcessedSuspicious.add(refMethod);
if (refMethod instanceof RefImplicitConstructor) {
visitClass(refMethod.getOwnerClass());
@@ -593,7 +563,8 @@
}
}
- @Override public void visitClass(@NotNull final RefClass refClass) {
+ @Override
+ public void visitClass(@NotNull final RefClass refClass) {
myProcessedSuspicious.add(refClass);
if (!refClass.isAnonymous()) {
getJavaContext().enqueueDerivedClassesProcessor(refClass, new GlobalJavaInspectionContext.DerivedClassesProcessor() {
@@ -654,295 +625,24 @@
}
}
- public GlobalJavaInspectionContext getJavaContext() {
+ private GlobalJavaInspectionContext getJavaContext() {
return getContext().getExtension(GlobalJavaInspectionContext.CONTEXT);
}
- @Override
- public RefFilter getFilter() {
- if (myFilter == null) {
- myFilter = new WeakUnreferencedFilter(this);
- }
- return myFilter;
- }
-
- @Override
- @NotNull
- public HTMLComposerImpl getComposer() {
- if (myComposer == null) {
- myComposer = new DeadHTMLComposer(this);
- }
- return myComposer;
- }
-
- @Override
- public void exportResults(@NotNull final Element parentNode, @NotNull RefEntity refEntity) {
- if (!(refEntity instanceof RefJavaElement)) return;
- final WeakUnreferencedFilter filter = new WeakUnreferencedFilter(this);
- if (!getIgnoredRefElements().contains(refEntity) && filter.accepts((RefJavaElement)refEntity)) {
- if (refEntity instanceof RefImplicitConstructor) refEntity = ((RefImplicitConstructor)refEntity).getOwnerClass();
- Element element = refEntity.getRefManager().export(refEntity, parentNode, -1);
- if (element == null) return;
- @NonNls Element problemClassElement = new Element(InspectionsBundle.message("inspection.export.results.problem.element.tag"));
-
- final RefElement refElement = (RefElement)refEntity;
- final HighlightSeverity severity = getCurrentSeverity(refElement);
- final String attributeKey =
- getTextAttributeKey(refElement.getRefManager().getProject(), severity, ProblemHighlightType.LIKE_UNUSED_SYMBOL);
- problemClassElement.setAttribute("severity", severity.myName);
- problemClassElement.setAttribute("attribute_key", attributeKey);
-
- problemClassElement.addContent(InspectionsBundle.message("inspection.export.results.dead.code"));
- element.addContent(problemClassElement);
-
- @NonNls Element hintsElement = new Element("hints");
-
- for (String hint : HINTS) {
- @NonNls Element hintElement = new Element("hint");
- hintElement.setAttribute("value", hint);
- hintsElement.addContent(hintElement);
- }
- element.addContent(hintsElement);
-
-
- Element descriptionElement = new Element(InspectionsBundle.message("inspection.export.results.description.tag"));
- StringBuffer buf = new StringBuffer();
- DeadHTMLComposer.appendProblemSynopsis((RefElement)refEntity, buf);
- descriptionElement.addContent(buf.toString());
- element.addContent(descriptionElement);
- }
- }
-
- @Override
- public QuickFixAction[] getQuickFixes(@NotNull final RefEntity[] refElements) {
- return myQuickFixActions;
- }
-
- @NotNull
- @Override
- public JobDescriptor[] getJobDescriptors(@NotNull GlobalInspectionContext context) {
- return new JobDescriptor[]{context.getStdJobDescriptors().BUILD_GRAPH,
- context.getStdJobDescriptors().FIND_EXTERNAL_USAGES};
- }
-
- private static void commentOutDead(PsiElement psiElement) {
- PsiFile psiFile = psiElement.getContainingFile();
-
- if (psiFile != null) {
- Document doc = PsiDocumentManager.getInstance(psiElement.getProject()).getDocument(psiFile);
- if (doc != null) {
- TextRange textRange = psiElement.getTextRange();
- String date = DateFormatUtil.formatDateTime(new Date());
-
- int startOffset = textRange.getStartOffset();
- CharSequence chars = doc.getCharsSequence();
- while (CharArrayUtil.regionMatches(chars, startOffset, InspectionsBundle.message("inspection.dead.code.comment"))) {
- int line = doc.getLineNumber(startOffset) + 1;
- if (line < doc.getLineCount()) {
- startOffset = doc.getLineStartOffset(line);
- startOffset = CharArrayUtil.shiftForward(chars, startOffset, " \t");
- }
- }
-
- int endOffset = textRange.getEndOffset();
-
- int line1 = doc.getLineNumber(startOffset);
- int line2 = doc.getLineNumber(endOffset - 1);
-
- if (line1 == line2) {
- doc.insertString(startOffset, InspectionsBundle.message("inspection.dead.code.date.comment", date));
- }
- else {
- for (int i = line1; i <= line2; i++) {
- doc.insertString(doc.getLineStartOffset(i), "//");
- }
-
- doc.insertString(doc.getLineStartOffset(Math.min(line2 + 1, doc.getLineCount() - 1)),
- InspectionsBundle.message("inspection.dead.code.stop.comment", date));
- doc.insertString(doc.getLineStartOffset(line1), InspectionsBundle.message("inspection.dead.code.start.comment", date));
- }
- }
- }
- }
-
- @Override
@Nullable
- public IntentionAction findQuickFixes(final CommonProblemDescriptor descriptor, final String hint) {
- if (descriptor instanceof ProblemDescriptor) {
- if (DELETE.equals(hint)) {
- return new PermanentDeleteFix(((ProblemDescriptor)descriptor).getPsiElement());
- }
- if (COMMENT.equals(hint)) {
- return new CommentOutFix(((ProblemDescriptor)descriptor).getPsiElement());
- }
- }
- return null;
+ @Override
+ public JobDescriptor[] getAdditionalJobs() {
+ return new JobDescriptor[]{getContext().getStdJobDescriptors().BUILD_GRAPH, getContext().getStdJobDescriptors().FIND_EXTERNAL_USAGES};
}
- private class PermanentDeleteAction extends QuickFixAction {
- private PermanentDeleteAction() {
- super(DELETE_QUICK_FIX, AllIcons.Actions.Cancel, KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), UnusedDeclarationInspection.this);
- }
- @Override
- protected boolean applyFix(final RefElement[] refElements) {
- if (!super.applyFix(refElements)) return false;
- final ArrayList<PsiElement> psiElements = new ArrayList<PsiElement>();
- for (RefElement refElement : refElements) {
- PsiElement psiElement = refElement.getElement();
- if (psiElement == null) continue;
- if (getFilter().getElementProblemCount((RefJavaElement)refElement) == 0) continue;
- psiElements.add(psiElement);
- }
-
- ApplicationManager.getApplication().invokeLater(new Runnable() {
- @Override
- public void run() {
- final Project project = getContext().getProject();
- SafeDeleteHandler.invoke(project, PsiUtilCore.toPsiElementArray(psiElements), false, new Runnable() {
- @Override
- public void run() {
- removeElements(refElements, project, UnusedDeclarationInspection.this);
- }
- });
- }
- });
-
- return false; //refresh after safe delete dialog is closed
- }
- }
-
- private static class PermanentDeleteFix implements IntentionAction {
- private final PsiElement myElement;
-
- private PermanentDeleteFix(final PsiElement element) {
- myElement = element;
- }
-
- @Override
- @NotNull
- public String getText() {
- return DELETE_QUICK_FIX;
- }
-
- @Override
- @NotNull
- public String getFamilyName() {
- return getText();
- }
-
- @Override
- public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
- return true;
- }
-
- @Override
- public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
- if (myElement != null && myElement.isValid()) {
- ApplicationManager.getApplication().invokeLater(new Runnable() {
- @Override
- public void run() {
- SafeDeleteHandler
- .invoke(myElement.getProject(), new PsiElement[]{PsiTreeUtil.getParentOfType(myElement, PsiModifierListOwner.class)}, false);
- }
- });
- }
- }
-
- @Override
- public boolean startInWriteAction() {
- return true;
- }
- }
-
- private class CommentOutBin extends QuickFixAction {
- private CommentOutBin() {
- super(COMMENT_OUT_QUICK_FIX, null, KeyStroke.getKeyStroke(KeyEvent.VK_SLASH, SystemInfo.isMac ? InputEvent.META_MASK : InputEvent.CTRL_MASK),
- UnusedDeclarationInspection.this);
- }
-
- @Override
- protected boolean applyFix(RefElement[] refElements) {
- if (!super.applyFix(refElements)) return false;
- ArrayList<RefElement> deletedRefs = new ArrayList<RefElement>(1);
- for (RefElement refElement : refElements) {
- PsiElement psiElement = refElement.getElement();
- if (psiElement == null) continue;
- if (getFilter().getElementProblemCount((RefJavaElement)refElement) == 0) continue;
- commentOutDead(psiElement);
- refElement.getRefManager().removeRefElement(refElement, deletedRefs);
- }
-
- EntryPointsManager entryPointsManager = getEntryPointsManager();
- for (RefElement refElement : deletedRefs) {
- entryPointsManager.removeEntryPoint(refElement);
- }
-
- return true;
- }
- }
-
- private static class CommentOutFix implements IntentionAction {
- private final PsiElement myElement;
-
- private CommentOutFix(final PsiElement element) {
- myElement = element;
- }
-
- @Override
- @NotNull
- public String getText() {
- return COMMENT_OUT_QUICK_FIX;
- }
-
- @Override
- @NotNull
- public String getFamilyName() {
- return getText();
- }
-
- @Override
- public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
- return true;
- }
-
- @Override
- public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
- if (myElement != null && myElement.isValid()) {
- commentOutDead(PsiTreeUtil.getParentOfType(myElement, PsiModifierListOwner.class));
- }
- }
-
- @Override
- public boolean startInWriteAction() {
- return true;
- }
- }
-
- private class MoveToEntries extends QuickFixAction {
- private MoveToEntries() {
- super(InspectionsBundle.message("inspection.dead.code.entry.point.quickfix"), null, KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, 0), UnusedDeclarationInspection.this);
- }
-
- @Override
- protected boolean applyFix(RefElement[] refElements) {
- final EntryPointsManager entryPointsManager = getEntryPointsManager();
- for (RefElement refElement : refElements) {
- entryPointsManager.addEntryPoint(refElement, true);
- }
-
- return true;
- }
-
-
- }
-
- private void checkForReachables() {
+ void checkForReachables() {
CodeScanner codeScanner = new CodeScanner();
// Cleanup previous reachability information.
- getRefManager().iterate(new RefJavaVisitor() {
- @Override public void visitElement(@NotNull RefEntity refEntity) {
+ getContext().getRefManager().iterate(new RefJavaVisitor() {
+ @Override
+ public void visitElement(@NotNull RefEntity refEntity) {
if (refEntity instanceof RefJavaElement) {
final RefJavaElementImpl refElement = (RefJavaElementImpl)refEntity;
if (!getContext().isToCheckMember(refElement, UnusedDeclarationInspection.this)) return;
@@ -1094,17 +794,27 @@
}
}
+
+ @NotNull
@Override
- public void updateContent() {
- checkForReachables();
- super.updateContent();
+ public InspectionToolPresentation createPresentation(@NotNull InspectionToolWrapper toolWrapper) {
+ return new UnusedDeclarationPresentation(toolWrapper);
}
@Override
- public InspectionNode createToolNode(@NotNull final InspectionRVContentProvider provider, final InspectionTreeNode parentNode, final boolean showStructure) {
- final InspectionNode toolNode = super.createToolNode(provider, parentNode, showStructure);
- final EntryPointsNode entryPointsNode = new EntryPointsNode(this);
- provider.appendToolNodeContent(entryPointsNode, toolNode, showStructure);
- return entryPointsNode;
+ public void initialize(@NotNull GlobalInspectionContext context) {
+ super.initialize(context);
+ myContext = (GlobalInspectionContextImpl)context;
+ }
+
+ @Override
+ public void cleanup() {
+ super.cleanup();
+ myContext = null;
+ }
+
+ @Override
+ public boolean isGraphNeeded() {
+ return true;
}
}
diff --git a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationPresentation.java b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationPresentation.java
new file mode 100644
index 0000000..29f0578
--- /dev/null
+++ b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationPresentation.java
@@ -0,0 +1,523 @@
+/*
+ * Copyright 2000-2013 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.codeInspection.deadCode;
+
+import com.intellij.codeInsight.intention.IntentionAction;
+import com.intellij.codeInspection.*;
+import com.intellij.codeInspection.ex.*;
+import com.intellij.codeInspection.reference.*;
+import com.intellij.codeInspection.ui.*;
+import com.intellij.codeInspection.util.RefFilter;
+import com.intellij.icons.AllIcons;
+import com.intellij.lang.annotation.HighlightSeverity;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.editor.Document;
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Comparing;
+import com.intellij.openapi.util.SystemInfo;
+import com.intellij.openapi.util.TextRange;
+import com.intellij.openapi.vcs.FileStatus;
+import com.intellij.psi.PsiDocumentManager;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiFile;
+import com.intellij.psi.PsiModifierListOwner;
+import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.psi.util.PsiUtilCore;
+import com.intellij.refactoring.safeDelete.SafeDeleteHandler;
+import com.intellij.util.IncorrectOperationException;
+import com.intellij.util.containers.HashMap;
+import com.intellij.util.containers.HashSet;
+import com.intellij.util.text.CharArrayUtil;
+import com.intellij.util.text.DateFormatUtil;
+import org.jdom.Element;
+import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+import java.util.*;
+
+public class UnusedDeclarationPresentation extends DefaultInspectionToolPresentation {
+ private Map<String, Set<RefEntity>> myPackageContents = new HashMap<String, Set<RefEntity>>();
+
+ private Map<String, Set<RefEntity>> myOldPackageContents = null;
+
+ private final Set<RefEntity> myIgnoreElements = new HashSet<RefEntity>();
+ private WeakUnreferencedFilter myFilter;
+ private DeadHTMLComposer myComposer;
+ @NonNls private static final String DELETE = "delete";
+ @NonNls private static final String COMMENT = "comment";
+ @NonNls private static final String [] HINTS = {COMMENT, DELETE};
+
+ public UnusedDeclarationPresentation(@NotNull InspectionToolWrapper toolWrapper) {
+ super(toolWrapper);
+ myQuickFixActions = createQuickFixes(toolWrapper);
+ }
+
+ public RefFilter getFilter() {
+ if (myFilter == null) {
+ myFilter = new WeakUnreferencedFilter(getTool(), getContext());
+ }
+ return myFilter;
+ }
+ private static class WeakUnreferencedFilter extends UnreferencedFilter {
+ private WeakUnreferencedFilter(@NotNull UnusedDeclarationInspection tool, @NotNull GlobalInspectionContextImpl context) {
+ super(tool, context);
+ }
+
+ @Override
+ public int getElementProblemCount(final RefJavaElement refElement) {
+ final int problemCount = super.getElementProblemCount(refElement);
+ if (problemCount > - 1) return problemCount;
+ if (!((RefElementImpl)refElement).hasSuspiciousCallers() || ((RefJavaElementImpl)refElement).isSuspiciousRecursive()) return 1;
+ return 0;
+ }
+ }
+
+ @NotNull
+ UnusedDeclarationInspection getTool() {
+ return (UnusedDeclarationInspection)getToolWrapper().getTool();
+ }
+
+
+ @Override
+ @NotNull
+ public HTMLComposerImpl getComposer() {
+ if (myComposer == null) {
+ myComposer = new DeadHTMLComposer(this);
+ }
+ return myComposer;
+ }
+
+ @Override
+ public void exportResults(@NotNull final Element parentNode, @NotNull RefEntity refEntity) {
+ if (!(refEntity instanceof RefJavaElement)) return;
+ final RefFilter filter = getFilter();
+ if (!getIgnoredRefElements().contains(refEntity) && filter.accepts((RefJavaElement)refEntity)) {
+ refEntity = getRefManager().getRefinedElement(refEntity);
+ Element element = refEntity.getRefManager().export(refEntity, parentNode, -1);
+ if (element == null) return;
+ @NonNls Element problemClassElement = new Element(InspectionsBundle.message("inspection.export.results.problem.element.tag"));
+
+ final RefElement refElement = (RefElement)refEntity;
+ final HighlightSeverity severity = getSeverity(refElement, getContext(), getToolWrapper());
+ final String attributeKey =
+ getTextAttributeKey(refElement.getRefManager().getProject(), severity, ProblemHighlightType.LIKE_UNUSED_SYMBOL);
+ problemClassElement.setAttribute("severity", severity.myName);
+ problemClassElement.setAttribute("attribute_key", attributeKey);
+
+ problemClassElement.addContent(InspectionsBundle.message("inspection.export.results.dead.code"));
+ element.addContent(problemClassElement);
+
+ @NonNls Element hintsElement = new Element("hints");
+
+ for (String hint : HINTS) {
+ @NonNls Element hintElement = new Element("hint");
+ hintElement.setAttribute("value", hint);
+ hintsElement.addContent(hintElement);
+ }
+ element.addContent(hintsElement);
+
+
+ Element descriptionElement = new Element(InspectionsBundle.message("inspection.export.results.description.tag"));
+ StringBuffer buf = new StringBuffer();
+ DeadHTMLComposer.appendProblemSynopsis((RefElement)refEntity, buf);
+ descriptionElement.addContent(buf.toString());
+ element.addContent(descriptionElement);
+ }
+ }
+
+ @Override
+ public QuickFixAction[] getQuickFixes(@NotNull final RefEntity[] refElements) {
+ return myQuickFixActions;
+ }
+
+ final QuickFixAction[] myQuickFixActions;
+
+ @NotNull
+ private QuickFixAction[] createQuickFixes(@NotNull InspectionToolWrapper toolWrapper) {
+ return new QuickFixAction[]{new PermanentDeleteAction(toolWrapper), new CommentOutBin(toolWrapper), new MoveToEntries(toolWrapper)};
+ }
+ private static final String DELETE_QUICK_FIX = InspectionsBundle.message("inspection.dead.code.safe.delete.quickfix");
+
+ class PermanentDeleteAction extends QuickFixAction {
+ PermanentDeleteAction(@NotNull InspectionToolWrapper toolWrapper) {
+ super(DELETE_QUICK_FIX, AllIcons.Actions.Cancel, KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), toolWrapper);
+ }
+
+ @Override
+ protected boolean applyFix(final RefEntity[] refElements) {
+ if (!super.applyFix(refElements)) return false;
+ final ArrayList<PsiElement> psiElements = new ArrayList<PsiElement>();
+ for (RefEntity refElement : refElements) {
+ PsiElement psiElement = refElement instanceof RefElement ? ((RefElement)refElement).getElement() : null;
+ if (psiElement == null) continue;
+ if (getFilter().getElementProblemCount((RefJavaElement)refElement) == 0) continue;
+ psiElements.add(psiElement);
+ }
+
+ ApplicationManager.getApplication().invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ final Project project = getContext().getProject();
+ SafeDeleteHandler.invoke(project, PsiUtilCore.toPsiElementArray(psiElements), false, new Runnable() {
+ @Override
+ public void run() {
+ removeElements(refElements, project, myToolWrapper);
+ }
+ });
+ }
+ });
+
+ return false; //refresh after safe delete dialog is closed
+ }
+ }
+
+ private EntryPointsManager getEntryPointsManager() {
+ return getContext().getExtension(GlobalJavaInspectionContext.CONTEXT).getEntryPointsManager(getContext().getRefManager());
+ }
+
+ class MoveToEntries extends QuickFixAction {
+ MoveToEntries(@NotNull InspectionToolWrapper toolWrapper) {
+ super(InspectionsBundle.message("inspection.dead.code.entry.point.quickfix"), null, KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, 0), toolWrapper);
+ }
+
+ @Override
+ protected boolean applyFix(RefEntity[] refElements) {
+ final EntryPointsManager entryPointsManager = getEntryPointsManager();
+ for (RefEntity refElement : refElements) {
+ if (refElement instanceof RefElement) {
+ entryPointsManager.addEntryPoint((RefElement)refElement, true);
+ }
+ }
+
+ return true;
+ }
+ }
+
+ class CommentOutBin extends QuickFixAction {
+ CommentOutBin(@NotNull InspectionToolWrapper toolWrapper) {
+ super(COMMENT_OUT_QUICK_FIX, null, KeyStroke.getKeyStroke(KeyEvent.VK_SLASH, SystemInfo.isMac ? InputEvent.META_MASK : InputEvent.CTRL_MASK),
+ toolWrapper);
+ }
+
+ @Override
+ protected boolean applyFix(RefEntity[] refElements) {
+ if (!super.applyFix(refElements)) return false;
+ ArrayList<RefElement> deletedRefs = new ArrayList<RefElement>(1);
+ for (RefEntity refElement : refElements) {
+ PsiElement psiElement = refElement instanceof RefElement ? ((RefElement)refElement).getElement() : null;
+ if (psiElement == null) continue;
+ if (getFilter().getElementProblemCount((RefJavaElement)refElement) == 0) continue;
+ commentOutDead(psiElement);
+ refElement.getRefManager().removeRefElement((RefElement)refElement, deletedRefs);
+ }
+
+ EntryPointsManager entryPointsManager = getEntryPointsManager();
+ for (RefElement refElement : deletedRefs) {
+ entryPointsManager.removeEntryPoint(refElement);
+ }
+
+ return true;
+ }
+ }
+
+ private static final String COMMENT_OUT_QUICK_FIX = InspectionsBundle.message("inspection.dead.code.comment.quickfix");
+ private static class CommentOutFix implements IntentionAction {
+ private final PsiElement myElement;
+
+ private CommentOutFix(final PsiElement element) {
+ myElement = element;
+ }
+
+ @Override
+ @NotNull
+ public String getText() {
+ return COMMENT_OUT_QUICK_FIX;
+ }
+
+ @Override
+ @NotNull
+ public String getFamilyName() {
+ return getText();
+ }
+
+ @Override
+ public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
+ return true;
+ }
+
+ @Override
+ public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
+ if (myElement != null && myElement.isValid()) {
+ commentOutDead(PsiTreeUtil.getParentOfType(myElement, PsiModifierListOwner.class));
+ }
+ }
+
+ @Override
+ public boolean startInWriteAction() {
+ return true;
+ }
+ }
+ private static void commentOutDead(PsiElement psiElement) {
+ PsiFile psiFile = psiElement.getContainingFile();
+
+ if (psiFile != null) {
+ Document doc = PsiDocumentManager.getInstance(psiElement.getProject()).getDocument(psiFile);
+ if (doc != null) {
+ TextRange textRange = psiElement.getTextRange();
+ String date = DateFormatUtil.formatDateTime(new Date());
+
+ int startOffset = textRange.getStartOffset();
+ CharSequence chars = doc.getCharsSequence();
+ while (CharArrayUtil.regionMatches(chars, startOffset, InspectionsBundle.message("inspection.dead.code.comment"))) {
+ int line = doc.getLineNumber(startOffset) + 1;
+ if (line < doc.getLineCount()) {
+ startOffset = doc.getLineStartOffset(line);
+ startOffset = CharArrayUtil.shiftForward(chars, startOffset, " \t");
+ }
+ }
+
+ int endOffset = textRange.getEndOffset();
+
+ int line1 = doc.getLineNumber(startOffset);
+ int line2 = doc.getLineNumber(endOffset - 1);
+
+ if (line1 == line2) {
+ doc.insertString(startOffset, InspectionsBundle.message("inspection.dead.code.date.comment", date));
+ }
+ else {
+ for (int i = line1; i <= line2; i++) {
+ doc.insertString(doc.getLineStartOffset(i), "//");
+ }
+
+ doc.insertString(doc.getLineStartOffset(Math.min(line2 + 1, doc.getLineCount() - 1)),
+ InspectionsBundle.message("inspection.dead.code.stop.comment", date));
+ doc.insertString(doc.getLineStartOffset(line1), InspectionsBundle.message("inspection.dead.code.start.comment", date));
+ }
+ }
+ }
+ }
+
+ @NotNull
+ @Override
+ public InspectionNode createToolNode(@NotNull GlobalInspectionContextImpl context,
+ @NotNull InspectionNode node,
+ @NotNull InspectionRVContentProvider provider,
+ @NotNull InspectionTreeNode parentNode,
+ boolean showStructure) {
+ final EntryPointsNode entryPointsNode = new EntryPointsNode(context);
+ InspectionToolWrapper dummyToolWrapper = entryPointsNode.getToolWrapper();
+ InspectionToolPresentation presentation = context.getPresentation(dummyToolWrapper);
+ presentation.updateContent();
+ provider.appendToolNodeContent(context, entryPointsNode, node, showStructure);
+ return entryPointsNode;
+ }
+
+ @Override
+ public void initialize(@NotNull GlobalInspectionContextImpl context) {
+ super.initialize(context);
+ ((EntryPointsManagerImpl)getEntryPointsManager()).setAddNonJavaEntries(getTool().ADD_NONJAVA_TO_ENTRIES);
+ }
+
+ @Override
+ public void updateContent() {
+ getTool().checkForReachables();
+ myPackageContents = new HashMap<String, Set<RefEntity>>();
+ getContext().getRefManager().iterate(new RefJavaVisitor() {
+ @Override public void visitElement(@NotNull RefEntity refEntity) {
+ if (!(refEntity instanceof RefJavaElement)) return;//dead code doesn't work with refModule | refPackage
+ RefJavaElement refElement = (RefJavaElement)refEntity;
+ if (!(getContext().getUIOptions().FILTER_RESOLVED_ITEMS && getIgnoredRefElements().contains(refElement)) && refElement.isValid() && getFilter().accepts(refElement)) {
+ String packageName = RefJavaUtil.getInstance().getPackageName(refEntity);
+ Set<RefEntity> content = myPackageContents.get(packageName);
+ if (content == null) {
+ content = new HashSet<RefEntity>();
+ myPackageContents.put(packageName, content);
+ }
+ content.add(refEntity);
+ }
+ }
+ });
+ }
+
+ @Override
+ public boolean hasReportedProblems() {
+ final GlobalInspectionContextImpl context = getContext();
+ if (context != null && context.getUIOptions().SHOW_ONLY_DIFF){
+ return containsOnlyDiff(myPackageContents) ||
+ myOldPackageContents != null && containsOnlyDiff(myOldPackageContents);
+ }
+ if (!myPackageContents.isEmpty()) return true;
+ return isOldProblemsIncluded() && !myOldPackageContents.isEmpty();
+ }
+
+ private boolean containsOnlyDiff(@NotNull Map<String, Set<RefEntity>> packageContents) {
+ for (String packageName : packageContents.keySet()) {
+ final Set<RefEntity> refElements = packageContents.get(packageName);
+ if (refElements != null){
+ for (RefEntity refElement : refElements) {
+ if (getElementStatus(refElement) != FileStatus.NOT_CHANGED){
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public Map<String, Set<RefEntity>> getContent() {
+ return myPackageContents;
+ }
+
+ @Override
+ public Map<String, Set<RefEntity>> getOldContent() {
+ return myOldPackageContents;
+ }
+
+ @Override
+ public void ignoreCurrentElement(RefEntity refEntity) {
+ if (refEntity == null) return;
+ myIgnoreElements.add(refEntity);
+ }
+
+ @Override
+ public void amnesty(RefEntity refEntity) {
+ myIgnoreElements.remove(refEntity);
+ }
+
+ @Override
+ public void cleanup() {
+ super.cleanup();
+ myOldPackageContents = null;
+ myPackageContents.clear();
+ myIgnoreElements.clear();
+ }
+
+
+ @Override
+ public void finalCleanup() {
+ super.finalCleanup();
+ myOldPackageContents = null;
+ }
+
+ @Override
+ public boolean isGraphNeeded() {
+ return true;
+ }
+
+ @Override
+ public boolean isElementIgnored(final RefEntity element) {
+ for (RefEntity entity : myIgnoreElements) {
+ if (Comparing.equal(entity, element)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ @NotNull
+ @Override
+ public FileStatus getElementStatus(final RefEntity element) {
+ final GlobalInspectionContextImpl context = getContext();
+ if (context != null && context.getUIOptions().SHOW_DIFF_WITH_PREVIOUS_RUN){
+ if (myOldPackageContents != null){
+ final boolean old = RefUtil.contains(element, collectRefElements(myOldPackageContents));
+ final boolean current = RefUtil.contains(element, collectRefElements(myPackageContents));
+ return calcStatus(old, current);
+ }
+ return FileStatus.ADDED;
+ }
+ return FileStatus.NOT_CHANGED;
+ }
+
+ @Override
+ @NotNull
+ public Collection<RefEntity> getIgnoredRefElements() {
+ return myIgnoreElements;
+ }
+
+ private static Set<RefEntity> collectRefElements(Map<String, Set<RefEntity>> packageContents) {
+ Set<RefEntity> allAvailable = new HashSet<RefEntity>();
+ for (Set<RefEntity> elements : packageContents.values()) {
+ allAvailable.addAll(elements);
+ }
+ return allAvailable;
+ }
+
+ @Override
+ @Nullable
+ public IntentionAction findQuickFixes(@NotNull final CommonProblemDescriptor descriptor, final String hint) {
+ if (descriptor instanceof ProblemDescriptor) {
+ if (DELETE.equals(hint)) {
+ return new PermanentDeleteFix(((ProblemDescriptor)descriptor).getPsiElement());
+ }
+ if (COMMENT.equals(hint)) {
+ return new CommentOutFix(((ProblemDescriptor)descriptor).getPsiElement());
+ }
+ }
+ return null;
+ }
+
+
+ private static class PermanentDeleteFix implements IntentionAction {
+ private final PsiElement myElement;
+
+ private PermanentDeleteFix(final PsiElement element) {
+ myElement = element;
+ }
+
+ @Override
+ @NotNull
+ public String getText() {
+ return DELETE_QUICK_FIX;
+ }
+
+ @Override
+ @NotNull
+ public String getFamilyName() {
+ return getText();
+ }
+
+ @Override
+ public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
+ return true;
+ }
+
+ @Override
+ public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
+ if (myElement != null && myElement.isValid()) {
+ ApplicationManager.getApplication().invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ SafeDeleteHandler
+ .invoke(myElement.getProject(), new PsiElement[]{PsiTreeUtil.getParentOfType(myElement, PsiModifierListOwner.class)}, false);
+ }
+ });
+ }
+ }
+
+ @Override
+ public boolean startInWriteAction() {
+ return true;
+ }
+ }
+}
diff --git a/java/java-impl/src/com/intellij/codeInspection/emptyMethod/EmptyMethodInspection.java b/java/java-impl/src/com/intellij/codeInspection/emptyMethod/EmptyMethodInspection.java
index 4792728..a2a95d7 100644
--- a/java/java-impl/src/com/intellij/codeInspection/emptyMethod/EmptyMethodInspection.java
+++ b/java/java-impl/src/com/intellij/codeInspection/emptyMethod/EmptyMethodInspection.java
@@ -202,7 +202,8 @@
}
@Override
- protected boolean queryExternalUsagesRequests(@NotNull final RefManager manager, @NotNull final GlobalJavaInspectionContext context,
+ protected boolean queryExternalUsagesRequests(@NotNull final RefManager manager,
+ @NotNull final GlobalJavaInspectionContext context,
@NotNull final ProblemDescriptionsProcessor descriptionsProcessor) {
manager.iterate(new RefJavaVisitor() {
@Override public void visitElement(@NotNull RefEntity refEntity) {
diff --git a/java/java-impl/src/com/intellij/codeInspection/ex/FilteringInspectionTool.java b/java/java-impl/src/com/intellij/codeInspection/ex/FilteringInspectionTool.java
deleted file mode 100644
index 71a49a4..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/ex/FilteringInspectionTool.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Copyright 2000-2009 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.codeInspection.ex;
-
-import com.intellij.codeInsight.daemon.HighlightDisplayKey;
-import com.intellij.codeInspection.SuppressIntentionAction;
-import com.intellij.codeInspection.SuppressManager;
-import com.intellij.codeInspection.reference.RefEntity;
-import com.intellij.codeInspection.reference.RefJavaElement;
-import com.intellij.codeInspection.reference.RefJavaUtil;
-import com.intellij.codeInspection.reference.RefJavaVisitor;
-import com.intellij.codeInspection.util.RefFilter;
-import com.intellij.openapi.util.Comparing;
-import com.intellij.openapi.vcs.FileStatus;
-import com.intellij.util.containers.HashMap;
-import com.intellij.util.containers.HashSet;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author max
- */
-public abstract class FilteringInspectionTool extends InspectionTool {
- public abstract RefFilter getFilter();
- private Map<String, Set<RefEntity>> myPackageContents = new HashMap<String, Set<RefEntity>>();
-
- private Map<String, Set<RefEntity>> myOldPackageContents = null;
-
- private final Set<RefEntity> myIgnoreElements = new HashSet<RefEntity>();
-
- @Override
- public void updateContent() {
- myPackageContents = new HashMap<String, Set<RefEntity>>();
- getContext().getRefManager().iterate(new RefJavaVisitor() {
- @Override public void visitElement(@NotNull RefEntity refEntity) {
- if (!(refEntity instanceof RefJavaElement)) return;//dead code doesn't work with refModule | refPackage
- RefJavaElement refElement = (RefJavaElement)refEntity;
- if (!(getContext().getUIOptions().FILTER_RESOLVED_ITEMS && myIgnoreElements.contains(refElement)) && refElement.isValid() && getFilter().accepts(refElement)) {
- String packageName = RefJavaUtil.getInstance().getPackageName(refEntity);
- Set<RefEntity> content = myPackageContents.get(packageName);
- if (content == null) {
- content = new HashSet<RefEntity>();
- myPackageContents.put(packageName, content);
- }
- content.add(refEntity);
- }
- }
- });
- }
-
- @Override
- public boolean hasReportedProblems() {
- final GlobalInspectionContextImpl context = getContext();
- if (context != null && context.getUIOptions().SHOW_ONLY_DIFF){
- return containsOnlyDiff(myPackageContents) ||
- myOldPackageContents != null && containsOnlyDiff(myOldPackageContents);
- }
- if (!myPackageContents.isEmpty()) return true;
- return isOldProblemsIncluded() && !myOldPackageContents.isEmpty();
- }
-
- private boolean containsOnlyDiff(@NotNull Map<String, Set<RefEntity>> packageContents) {
- for (String packageName : packageContents.keySet()) {
- final Set<RefEntity> refElements = packageContents.get(packageName);
- if (refElements != null){
- for (RefEntity refElement : refElements) {
- if (getElementStatus(refElement) != FileStatus.NOT_CHANGED){
- return true;
- }
- }
- }
- }
- return false;
- }
-
- @Override
- public Map<String, Set<RefEntity>> getContent() {
- return myPackageContents;
- }
-
- @Override
- public Map<String, Set<RefEntity>> getOldContent() {
- return myOldPackageContents;
- }
-
- @Override
- public void ignoreCurrentElement(RefEntity refEntity) {
- if (refEntity == null) return;
- myIgnoreElements.add(refEntity);
- }
-
- @Override
- public void amnesty(RefEntity refEntity) {
- myIgnoreElements.remove(refEntity);
- }
-
- @Override
- public void cleanup() {
- super.cleanup();
- myOldPackageContents = null;
- myPackageContents.clear();
- myIgnoreElements.clear();
- }
-
-
- @Override
- public void finalCleanup() {
- super.finalCleanup();
- myOldPackageContents = null;
- }
-
- @Override
- public boolean isGraphNeeded() {
- return true;
- }
-
- @Override
- public boolean isElementIgnored(final RefEntity element) {
- for (RefEntity entity : myIgnoreElements) {
- if (Comparing.equal(entity, element)) {
- return true;
- }
- }
- return false;
- }
-
-
- @NotNull
- @Override
- public FileStatus getElementStatus(final RefEntity element) {
- final GlobalInspectionContextImpl context = getContext();
- if (context != null && context.getUIOptions().SHOW_DIFF_WITH_PREVIOUS_RUN){
- if (myOldPackageContents != null){
- final boolean old = contains(element, collectRefElements(myOldPackageContents));
- final boolean current = contains(element, collectRefElements(myPackageContents));
- return calcStatus(old, current);
- }
- return FileStatus.ADDED;
- }
- return FileStatus.NOT_CHANGED;
- }
-
- @NotNull
- @Override
- public Collection<RefEntity> getIgnoredRefElements() {
- return myIgnoreElements;
- }
-
- private static Set<RefEntity> collectRefElements(Map<String, Set<RefEntity>> packageContents) {
- Set<RefEntity> allAvailable = new HashSet<RefEntity>();
- for (Set<RefEntity> elements : packageContents.values()) {
- allAvailable.addAll(elements);
- }
- return allAvailable;
- }
-
- @Override
- @Nullable
- public SuppressIntentionAction[] getSuppressActions() {
- return SuppressManager.getInstance().createSuppressActions(HighlightDisplayKey.find(getShortName()));
- }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/ex/GlobalJavaInspectionContextImpl.java b/java/java-impl/src/com/intellij/codeInspection/ex/GlobalJavaInspectionContextImpl.java
index 86ff16c..cd70665 100644
--- a/java/java-impl/src/com/intellij/codeInspection/ex/GlobalJavaInspectionContextImpl.java
+++ b/java/java-impl/src/com/intellij/codeInspection/ex/GlobalJavaInspectionContextImpl.java
@@ -25,6 +25,7 @@
import com.intellij.codeInspection.*;
import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection;
import com.intellij.codeInspection.reference.*;
+import com.intellij.codeInspection.ui.InspectionToolPresentation;
import com.intellij.lang.StdLanguages;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
@@ -68,8 +69,8 @@
public void enqueueClassUsagesProcessor(RefClass refClass, UsagesProcessor p) {
if (myClassUsagesRequests == null) myClassUsagesRequests = new THashMap<SmartPsiElementPointer, List<UsagesProcessor>>();
enqueueRequestImpl(refClass, myClassUsagesRequests, p);
- }
+ }
@Override
public void enqueueDerivedClassesProcessor(RefClass refClass, DerivedClassesProcessor p) {
if (myDerivedClassesRequests == null) myDerivedClassesRequests = new THashMap<SmartPsiElementPointer, List<DerivedClassesProcessor>>();
@@ -101,7 +102,7 @@
}
@SuppressWarnings({"UseOfSystemOutOrSystemErr"})
- public static boolean isInspectionsEnabled(final boolean online, Project project) {
+ public static boolean isInspectionsEnabled(final boolean online, @NotNull Project project) {
final Module[] modules = ModuleManager.getInstance(project).getModules();
if (online) {
if (modules.length == 0) {
@@ -413,12 +414,14 @@
}
@Override
- public void performPreRunActivities(final List<Tools> globalTools, final List<Tools> localTools,
- final GlobalInspectionContext context) {
+ public void performPreRunActivities(@NotNull final List<Tools> globalTools,
+ @NotNull final List<Tools> localTools,
+ @NotNull final GlobalInspectionContext context) {
getEntryPointsManager(context.getRefManager()).resolveEntryPoints(context.getRefManager());
+ // UnusedDeclarationInspection should run first
for (int i = 0; i < globalTools.size(); i++) {
- InspectionProfileEntry tool = globalTools.get(i).getTool();
- if (UnusedDeclarationInspection.SHORT_NAME.equals(tool.getShortName())) {
+ InspectionToolWrapper toolWrapper = globalTools.get(i).getTool();
+ if (UnusedDeclarationInspection.SHORT_NAME.equals(toolWrapper.getShortName())) {
Collections.swap(globalTools, i, 0);
break;
}
@@ -428,17 +431,22 @@
@Override
- public void performPostRunActivities(List<InspectionProfileEntry> needRepeatSearchRequest, final GlobalInspectionContext context) {
+ public void performPostRunActivities(@NotNull List<InspectionToolWrapper> needRepeatSearchRequest, @NotNull final GlobalInspectionContext context) {
JobDescriptor progress = context.getStdJobDescriptors().FIND_EXTERNAL_USAGES;
progress.setTotalAmount(getRequestCount());
do {
processSearchRequests(context);
- InspectionProfileEntry[] requestors = needRepeatSearchRequest.toArray(new InspectionProfileEntry[needRepeatSearchRequest.size()]);
- for (InspectionProfileEntry requestor : requestors) {
- if (requestor instanceof InspectionTool &&
- !((InspectionTool)requestor).queryExternalUsagesRequests(InspectionManager.getInstance(context.getProject()))) {
- needRepeatSearchRequest.remove(requestor);
+ InspectionToolWrapper[] requestors = needRepeatSearchRequest.toArray(new InspectionToolWrapper[needRepeatSearchRequest.size()]);
+ InspectionManager inspectionManager = InspectionManager.getInstance(context.getProject());
+ for (InspectionToolWrapper toolWrapper : requestors) {
+ boolean result = false;
+ if (toolWrapper instanceof GlobalInspectionToolWrapper) {
+ InspectionToolPresentation presentation = ((GlobalInspectionContextImpl)context).getPresentation(toolWrapper);
+ result = ((GlobalInspectionToolWrapper)toolWrapper).getTool().queryExternalUsagesRequests(inspectionManager, context, presentation);
+ }
+ if (!result) {
+ needRepeatSearchRequest.remove(toolWrapper);
}
}
int oldSearchRequestCount = progress.getTotalAmount();
diff --git a/java/java-impl/src/com/intellij/codeInspection/ex/JavaInspectionExtensionsFactory.java b/java/java-impl/src/com/intellij/codeInspection/ex/JavaInspectionExtensionsFactory.java
index 21cf2f8..d5f607e 100644
--- a/java/java-impl/src/com/intellij/codeInspection/ex/JavaInspectionExtensionsFactory.java
+++ b/java/java-impl/src/com/intellij/codeInspection/ex/JavaInspectionExtensionsFactory.java
@@ -31,6 +31,7 @@
import com.intellij.codeInspection.reference.RefManagerImpl;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class JavaInspectionExtensionsFactory extends InspectionExtensionsFactory {
@@ -62,7 +63,7 @@
}
@Override
- public boolean isProjectConfiguredToRunInspections(final Project project, final boolean online) {
+ public boolean isProjectConfiguredToRunInspections(@NotNull final Project project, final boolean online) {
return GlobalJavaInspectionContextImpl.isInspectionsEnabled(online, project);
}
}
\ No newline at end of file
diff --git a/java/java-impl/src/com/intellij/codeInspection/reference/RefImplicitConstructorImpl.java b/java/java-impl/src/com/intellij/codeInspection/reference/RefImplicitConstructorImpl.java
index 5d9bd6c..7dd9282 100644
--- a/java/java-impl/src/com/intellij/codeInspection/reference/RefImplicitConstructorImpl.java
+++ b/java/java-impl/src/com/intellij/codeInspection/reference/RefImplicitConstructorImpl.java
@@ -92,6 +92,6 @@
@Override
public RefClass getOwnerClass() {
- return myOwnerClass == null ? super.getOwnerClass() : myOwnerClass;
+ return myOwnerClass;
}
}
diff --git a/java/java-impl/src/com/intellij/codeInspection/reference/RefJavaManagerImpl.java b/java/java-impl/src/com/intellij/codeInspection/reference/RefJavaManagerImpl.java
index bf78af2..8ebd6ab 100644
--- a/java/java-impl/src/com/intellij/codeInspection/reference/RefJavaManagerImpl.java
+++ b/java/java-impl/src/com/intellij/codeInspection/reference/RefJavaManagerImpl.java
@@ -110,7 +110,7 @@
@Override
protected Ref<UnusedDeclarationInspection> compute(PsiFile file, RefManagerImpl refManager) {
Tools tools = ((GlobalInspectionContextImpl)refManager.getContext()).getTools().get(UnusedDeclarationInspection.SHORT_NAME);
- InspectionToolWrapper toolWrapper = tools != null ? (InspectionToolWrapper)tools.getEnabledTool(file) : null;
+ InspectionToolWrapper toolWrapper = tools == null ? null : tools.getEnabledTool(file);
InspectionProfileEntry tool = toolWrapper == null ? null : toolWrapper.getTool();
return Ref.create(tool instanceof UnusedDeclarationInspection ? (UnusedDeclarationInspection)tool : null);
}
@@ -283,8 +283,9 @@
return null;
}
+ @NotNull
@Override
- public RefEntity getRefinedElement(final RefEntity ref) {
+ public RefEntity getRefinedElement(@NotNull final RefEntity ref) {
if (ref instanceof RefImplicitConstructor) {
return ((RefImplicitConstructor)ref).getOwnerClass();
}
@@ -312,7 +313,7 @@
}
@Override
- public void export(final RefEntity refEntity, final Element element) {
+ public void export(@NotNull final RefEntity refEntity, @NotNull final Element element) {
if (refEntity instanceof RefElement) {
final SmartPsiElementPointer pointer = ((RefElement)refEntity).getPointer();
if (pointer != null) {
diff --git a/java/java-impl/src/com/intellij/codeInspection/ui/EntryPointsNode.java b/java/java-impl/src/com/intellij/codeInspection/ui/EntryPointsNode.java
index 5106360..7363d43 100644
--- a/java/java-impl/src/com/intellij/codeInspection/ui/EntryPointsNode.java
+++ b/java/java-impl/src/com/intellij/codeInspection/ui/EntryPointsNode.java
@@ -16,7 +16,9 @@
package com.intellij.codeInspection.ui;
import com.intellij.codeInspection.deadCode.DummyEntryPointsTool;
-import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection;
+import com.intellij.codeInspection.ex.GlobalInspectionContextImpl;
+import com.intellij.codeInspection.ex.GlobalInspectionToolWrapper;
+import com.intellij.codeInspection.ex.InspectionToolWrapper;
import com.intellij.icons.AllIcons;
import org.jetbrains.annotations.NotNull;
@@ -26,9 +28,14 @@
* @author max
*/
public class EntryPointsNode extends InspectionNode {
- public EntryPointsNode(@NotNull UnusedDeclarationInspection tool) {
- super(new DummyEntryPointsTool(tool));
- getTool().updateContent();
+ public EntryPointsNode(@NotNull GlobalInspectionContextImpl context) {
+ super(createDummyWrapper(context));
+ }
+
+ private static InspectionToolWrapper createDummyWrapper(@NotNull GlobalInspectionContextImpl context) {
+ InspectionToolWrapper toolWrapper = new GlobalInspectionToolWrapper(new DummyEntryPointsTool());
+ toolWrapper.initialize(context);
+ return toolWrapper;
}
@Override
diff --git a/java/java-impl/src/com/intellij/codeInspection/util/XMLExportUtl.java b/java/java-impl/src/com/intellij/codeInspection/util/XMLExportUtl.java
deleted file mode 100644
index 6854148..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/util/XMLExportUtl.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Copyright 2000-2009 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.
- */
-
-/*
- * Created by IntelliJ IDEA.
- * User: max
- * Date: May 23, 2002
- * Time: 2:36:58 PM
- * To change template for new class use
- * Code Style | Class Templates options (Tools | IDE Options).
- */
-package com.intellij.codeInspection.util;
-
-import com.intellij.codeInspection.InspectionsBundle;
-import com.intellij.codeInspection.reference.*;
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.editor.Document;
-import com.intellij.openapi.util.TextRange;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.psi.*;
-import com.intellij.psi.javadoc.PsiDocComment;
-import com.intellij.psi.javadoc.PsiDocTag;
-import com.intellij.psi.util.PsiFormatUtil;
-import org.jdom.Element;
-
-@SuppressWarnings({"HardCodedStringLiteral"})
-@Deprecated
-public class XMLExportUtl {
- private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.util.XMLExportUtl");
-
- private XMLExportUtl() {
- }
-
- public static Element createElement(RefEntity refEntity, Element parentNode, int actualLine, final TextRange range) {
- refEntity = refEntity.getRefManager().getRefinedElement(refEntity);
-
- Element problem = new Element("problem");
-
- if (refEntity instanceof RefElement) {
- final RefElement refElement = (RefElement)refEntity;
- PsiElement psiElement = refElement.getElement();
- PsiFile psiFile = psiElement.getContainingFile();
-
- Element fileElement = new Element("file");
- Element lineElement = new Element("line");
- final VirtualFile virtualFile = psiFile.getVirtualFile();
- LOG.assertTrue(virtualFile != null);
- fileElement.addContent(virtualFile.getUrl());
-
- if (actualLine == -1) {
- final Document document = PsiDocumentManager.getInstance(refElement.getRefManager().getProject()).getDocument(psiFile);
- LOG.assertTrue(document != null);
- lineElement.addContent(String.valueOf(document.getLineNumber(psiElement.getTextOffset()) + 1));
- }
- else {
- lineElement.addContent(String.valueOf(actualLine));
- }
-
- problem.addContent(fileElement);
- problem.addContent(lineElement);
- appendModule(problem, refElement.getModule());
- }
- else if (refEntity instanceof RefModule) {
- final RefModule refModule = (RefModule)refEntity;
- final VirtualFile moduleFile = refModule.getModule().getModuleFile();
- final Element fileElement = new Element("file");
- fileElement.addContent(moduleFile != null? moduleFile.getUrl() : refEntity.getName());
- problem.addContent(fileElement);
- appendModule(problem, refModule);
- appendFakePackage(problem);
- } else if (refEntity instanceof RefPackage) {
- Element packageElement = new Element("package");
- packageElement.addContent(refEntity.getName());
- problem.addContent(packageElement);
- }
-
- new SmartRefElementPointerImpl(refEntity, true).writeExternal(problem);
-
- if (refEntity instanceof RefMethod) {
- RefMethod refMethod = (RefMethod)refEntity;
- appendMethod(refMethod, problem);
- }
- else if (refEntity instanceof RefField) {
- RefField refField = (RefField)refEntity;
- appendField(refField, problem);
- }
- else if (refEntity instanceof RefClass) {
- RefClass refClass = (RefClass)refEntity;
- appendClass(refClass, problem);
- } else if (refEntity instanceof RefFile) {
- appendFakePackage(problem);
- }
- parentNode.addContent(problem);
-
- return problem;
- }
-
- private static void appendModule(final Element problem, final RefModule refModule) {
- if (refModule != null) {
- Element moduleElement = new Element("module");
- moduleElement.addContent(refModule.getName());
- problem.addContent(moduleElement);
- }
- }
-
- private static void appendFakePackage(final Element problem) {
- final Element fakePackage = new Element("package");
- fakePackage.addContent(InspectionsBundle.message("inspection.export.results.default"));
- problem.addContent(fakePackage);
- }
-
- private static void appendClass(RefClass refClass, Element parentNode) {
- PsiClass psiClass = refClass.getElement();
- PsiDocComment psiDocComment = psiClass.getDocComment();
-
- PsiFile psiFile = psiClass.getContainingFile();
-
- if (psiFile instanceof PsiJavaFile) {
- String packageName = ((PsiJavaFile)psiFile).getPackageName();
- Element packageElement = new Element("package");
- packageElement.addContent(packageName.length() > 0 ? packageName : InspectionsBundle.message("inspection.export.results.default"));
- parentNode.addContent(packageElement);
- }
-
- Element classElement = new Element("class");
- if (psiDocComment != null) {
- PsiDocTag[] tags = psiDocComment.getTags();
- for (PsiDocTag tag : tags) {
- if ("author".equals(tag.getName()) && tag.getValueElement() != null) {
- classElement.setAttribute("author", tag.getValueElement().getText());
- }
- }
- }
-
- String name = PsiFormatUtil.formatClass(psiClass, PsiFormatUtil.SHOW_NAME);
- Element nameElement = new Element("name");
- nameElement.addContent(name);
- classElement.addContent(nameElement);
-
- Element displayName = new Element("display_name");
- displayName.addContent(refClass.getQualifiedName());
- classElement.addContent(displayName);
-
- parentNode.addContent(classElement);
-
- RefClass topClass = RefJavaUtil.getInstance().getTopLevelClass(refClass);
- if (topClass != refClass) {
- appendClass(topClass, classElement);
- }
- }
-
- private static void appendMethod(final RefMethod refMethod, Element parentNode) {
- Element methodElement = new Element(refMethod.isConstructor() ? "constructor" : "method");
-
- PsiMethod psiMethod = (PsiMethod)refMethod.getElement();
- String name = PsiFormatUtil.formatMethod(psiMethod, PsiSubstitutor.EMPTY, PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_FQ_NAME |
- PsiFormatUtil.SHOW_TYPE | PsiFormatUtil.SHOW_PARAMETERS,
- PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_TYPE);
-
- Element shortNameElement = new Element("name");
- shortNameElement.addContent(name);
- methodElement.addContent(shortNameElement);
-
- Element displayName = new Element("name");
- displayName.addContent(refMethod.getQualifiedName());
- methodElement.addContent(displayName);
-
- appendClass(RefJavaUtil.getInstance().getTopLevelClass(refMethod), methodElement);
-
- parentNode.addContent(methodElement);
- }
-
- private static void appendField(final RefField refField, Element parentNode) {
- Element fieldElement = new Element("field");
- PsiField psiField = refField.getElement();
- String name = PsiFormatUtil.formatVariable(psiField, PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_TYPE, PsiSubstitutor.EMPTY);
-
- Element shortNameElement = new Element("name");
- shortNameElement.addContent(name);
- fieldElement.addContent(shortNameElement);
-
- Element displayName = new Element("display_name");
- displayName.addContent(refField.getQualifiedName());
- fieldElement.addContent(displayName);
-
- appendClass(RefJavaUtil.getInstance().getTopLevelClass(refField), fieldElement);
-
- parentNode.addContent(fieldElement);
- }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/varScopeCanBeNarrowed/BaseConvertToLocalQuickFix.java b/java/java-impl/src/com/intellij/codeInspection/varScopeCanBeNarrowed/BaseConvertToLocalQuickFix.java
index 6dd3558..1862d7e 100644
--- a/java/java-impl/src/com/intellij/codeInspection/varScopeCanBeNarrowed/BaseConvertToLocalQuickFix.java
+++ b/java/java-impl/src/com/intellij/codeInspection/varScopeCanBeNarrowed/BaseConvertToLocalQuickFix.java
@@ -46,7 +46,7 @@
* @author Danila Ponomarenko
*/
public abstract class BaseConvertToLocalQuickFix<V extends PsiVariable> implements LocalQuickFix {
- private static final Logger LOG = Logger.getInstance(BaseConvertToLocalQuickFix.class);
+ protected static final Logger LOG = Logger.getInstance(BaseConvertToLocalQuickFix.class);
@Override
@NotNull
@@ -89,10 +89,14 @@
}
@Nullable
- private PsiElement moveDeclaration(@NotNull Project project, @NotNull V variable) {
+ protected PsiElement moveDeclaration(@NotNull Project project, @NotNull V variable) {
final Collection<PsiReference> references = ReferencesSearch.search(variable).findAll();
if (references.isEmpty()) return null;
+ return moveDeclaration(project, variable, references, true);
+ }
+
+ protected PsiElement moveDeclaration(Project project, V variable, final Collection<PsiReference> references, boolean delete) {
final PsiCodeBlock anchorBlock = findAnchorBlock(references);
if (anchorBlock == null) return null; //was assert, but need to fix the case when obsolete inspection highlighting is left
if (!CodeInsightUtil.preparePsiElementsForWrite(anchorBlock)) return null;
@@ -113,6 +117,7 @@
anchorAssignmentExpression.getRExpression(),
variable,
refsSet,
+ delete,
new NotNullFunction<PsiDeclarationStatement, PsiElement>() {
@NotNull
@Override
@@ -132,6 +137,7 @@
variable.getInitializer(),
variable,
references,
+ delete,
new NotNullFunction<PsiDeclarationStatement, PsiElement>() {
@NotNull
@Override
@@ -147,7 +153,7 @@
@Nullable final PsiExpression initializer,
@NotNull final V variable,
@NotNull final Collection<PsiReference> references,
- @NotNull final NotNullFunction<PsiDeclarationStatement, PsiElement> action) {
+ final boolean delete, @NotNull final NotNullFunction<PsiDeclarationStatement, PsiElement> action) {
final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project);
return ApplicationManager.getApplication().runWriteAction(
@@ -155,9 +161,11 @@
@Override
public PsiElement compute() {
final PsiElement newDeclaration = moveDeclaration(elementFactory, localName, variable, initializer, action, references);
- beforeDelete(project, variable, newDeclaration);
- variable.normalizeDeclaration();
- variable.delete();
+ if (delete) {
+ beforeDelete(project, variable, newDeclaration);
+ variable.normalizeDeclaration();
+ variable.delete();
+ }
return newDeclaration;
}
}
diff --git a/java/java-impl/src/com/intellij/codeInspection/varScopeCanBeNarrowed/FieldCanBeLocalInspection.java b/java/java-impl/src/com/intellij/codeInspection/varScopeCanBeNarrowed/FieldCanBeLocalInspection.java
index 8eb5198..c82e779 100644
--- a/java/java-impl/src/com/intellij/codeInspection/varScopeCanBeNarrowed/FieldCanBeLocalInspection.java
+++ b/java/java-impl/src/com/intellij/codeInspection/varScopeCanBeNarrowed/FieldCanBeLocalInspection.java
@@ -25,6 +25,7 @@
import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel;
import com.intellij.codeInspection.util.SpecialAnnotationsUtil;
import com.intellij.lang.java.JavaCommenter;
+import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Comparing;
@@ -36,6 +37,7 @@
import com.intellij.psi.codeStyle.VariableKind;
import com.intellij.psi.controlFlow.*;
import com.intellij.psi.javadoc.PsiDocComment;
+import com.intellij.psi.search.searches.ReferencesSearch;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
import com.intellij.refactoring.util.RefactoringUtil;
@@ -47,10 +49,8 @@
import javax.swing.*;
import java.awt.*;
-import java.util.Collection;
-import java.util.LinkedHashSet;
+import java.util.*;
import java.util.List;
-import java.util.Set;
/**
* @author ven
@@ -271,6 +271,63 @@
private static class ConvertFieldToLocalQuickFix extends BaseConvertToLocalQuickFix<PsiField> {
+ @Nullable
+ @Override
+ protected PsiElement moveDeclaration(@NotNull final Project project, @NotNull final PsiField variable) {
+ final Map<PsiCodeBlock, Collection<PsiReference>> refs = new HashMap<PsiCodeBlock, Collection<PsiReference>>();
+ groupByCodeBlocks(ReferencesSearch.search(variable).findAll(), refs);
+ PsiElement element = null;
+ for (Collection<PsiReference> psiReferences : refs.values()) {
+ element = super.moveDeclaration(project, variable, psiReferences, false);
+ }
+ if (element != null) {
+ final PsiElement finalElement = element;
+ Runnable runnable = new Runnable() {
+ public void run() {
+ beforeDelete(project, variable, finalElement);
+ variable.normalizeDeclaration();
+ variable.delete();
+ }
+ };
+ ApplicationManager.getApplication().runWriteAction(runnable);
+ }
+ return element;
+ }
+
+ private static void groupByCodeBlocks(final Collection<PsiReference> allReferences, Map<PsiCodeBlock, Collection<PsiReference>> refs) {
+ for (PsiReference psiReference : allReferences) {
+ final PsiElement element = psiReference.getElement();
+ final PsiCodeBlock block = PsiTreeUtil.getParentOfType(element, PsiCodeBlock.class);
+ LOG.assertTrue(block != null);
+ Collection<PsiReference> references = refs.get(block);
+ if (references == null) {
+ references = new ArrayList<PsiReference>();
+ if (findExistentBlock(refs, psiReference, block, references)) continue;
+ refs.put(block, references);
+ }
+ references.add(psiReference);
+ }
+ }
+
+ private static boolean findExistentBlock(Map<PsiCodeBlock, Collection<PsiReference>> refs,
+ PsiReference psiReference,
+ PsiCodeBlock block,
+ Collection<PsiReference> references) {
+ for (Iterator<PsiCodeBlock> iterator = refs.keySet().iterator(); iterator.hasNext(); ) {
+ PsiCodeBlock codeBlock = iterator.next();
+ if (PsiTreeUtil.isAncestor(codeBlock, block, false)) {
+ refs.get(codeBlock).add(psiReference);
+ return true;
+ }
+ else if (PsiTreeUtil.isAncestor(block, codeBlock, false)) {
+ references.addAll(refs.get(codeBlock));
+ iterator.remove();
+ break;
+ }
+ }
+ return false;
+ }
+
@Override
@Nullable
protected PsiField getVariable(@NotNull ProblemDescriptor descriptor) {
diff --git a/java/java-impl/src/com/intellij/codeInspection/varScopeCanBeNarrowed/ParameterCanBeLocalInspection.java b/java/java-impl/src/com/intellij/codeInspection/varScopeCanBeNarrowed/ParameterCanBeLocalInspection.java
index 66980e9..a0fb322 100644
--- a/java/java-impl/src/com/intellij/codeInspection/varScopeCanBeNarrowed/ParameterCanBeLocalInspection.java
+++ b/java/java-impl/src/com/intellij/codeInspection/varScopeCanBeNarrowed/ParameterCanBeLocalInspection.java
@@ -153,11 +153,12 @@
@Override
protected PsiElement applyChanges(@NotNull final Project project,
- @NotNull final String localName,
- @Nullable final PsiExpression initializer,
- @NotNull final PsiParameter parameter,
- @NotNull final Collection<PsiReference> references,
- @NotNull final NotNullFunction<PsiDeclarationStatement, PsiElement> action) {
+ @NotNull final String localName,
+ @Nullable final PsiExpression initializer,
+ @NotNull final PsiParameter parameter,
+ @NotNull final Collection<PsiReference> references,
+ boolean delete,
+ @NotNull final NotNullFunction<PsiDeclarationStatement, PsiElement> action) {
final PsiElement scope = parameter.getDeclarationScope();
if (scope instanceof PsiMethod) {
final PsiMethod method = (PsiMethod)scope;
diff --git a/java/java-impl/src/com/intellij/codeInspection/visibility/VisibilityExtension.java b/java/java-impl/src/com/intellij/codeInspection/visibility/VisibilityExtension.java
index 4036509..ab0a63e 100644
--- a/java/java-impl/src/com/intellij/codeInspection/visibility/VisibilityExtension.java
+++ b/java/java-impl/src/com/intellij/codeInspection/visibility/VisibilityExtension.java
@@ -17,7 +17,8 @@
import com.intellij.codeInspection.ProblemDescriptionsProcessor;
import com.intellij.codeInspection.reference.RefManager;
+import org.jetbrains.annotations.NotNull;
public interface VisibilityExtension {
- void fillIgnoreList(RefManager refManager, ProblemDescriptionsProcessor processor);
+ void fillIgnoreList(@NotNull RefManager refManager, @NotNull ProblemDescriptionsProcessor processor);
}
\ No newline at end of file
diff --git a/java/java-impl/src/com/intellij/codeInspection/visibility/VisibilityInspection.java b/java/java-impl/src/com/intellij/codeInspection/visibility/VisibilityInspection.java
index 112c379..88ff09b 100644
--- a/java/java-impl/src/com/intellij/codeInspection/visibility/VisibilityInspection.java
+++ b/java/java-impl/src/com/intellij/codeInspection/visibility/VisibilityInspection.java
@@ -403,7 +403,8 @@
@Override
- protected boolean queryExternalUsagesRequests(@NotNull final RefManager manager, @NotNull final GlobalJavaInspectionContext globalContext,
+ protected boolean queryExternalUsagesRequests(@NotNull final RefManager manager,
+ @NotNull final GlobalJavaInspectionContext globalContext,
@NotNull final ProblemDescriptionsProcessor processor) {
final EntryPointsManager entryPointsManager = globalContext.getEntryPointsManager(manager);
for (RefElement entryPoint : entryPointsManager.getEntryPoints()) {
diff --git a/java/java-impl/src/com/intellij/ide/hierarchy/call/CallHierarchyNodeDescriptor.java b/java/java-impl/src/com/intellij/ide/hierarchy/call/CallHierarchyNodeDescriptor.java
index c5847af..866e2ce 100644
--- a/java/java-impl/src/com/intellij/ide/hierarchy/call/CallHierarchyNodeDescriptor.java
+++ b/java/java-impl/src/com/intellij/ide/hierarchy/call/CallHierarchyNodeDescriptor.java
@@ -40,6 +40,7 @@
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtilBase;
import com.intellij.ui.LayeredIcon;
+import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
@@ -51,12 +52,11 @@
private final List<PsiReference> myReferences = new ArrayList<PsiReference>();
private final boolean myNavigateToReference;
- public CallHierarchyNodeDescriptor(
- final Project project,
- final HierarchyNodeDescriptor parentDescriptor,
- final PsiElement element,
- final boolean isBase,
- final boolean navigateToReference){
+ public CallHierarchyNodeDescriptor(@NotNull Project project,
+ final HierarchyNodeDescriptor parentDescriptor,
+ @NotNull PsiElement element,
+ final boolean isBase,
+ final boolean navigateToReference) {
super(project, parentDescriptor, element, isBase);
myNavigateToReference = navigateToReference;
}
diff --git a/java/java-impl/src/com/intellij/ide/hierarchy/call/CallerMethodsTreeStructure.java b/java/java-impl/src/com/intellij/ide/hierarchy/call/CallerMethodsTreeStructure.java
index 16ed3e9..b8770ed 100644
--- a/java/java-impl/src/com/intellij/ide/hierarchy/call/CallerMethodsTreeStructure.java
+++ b/java/java-impl/src/com/intellij/ide/hierarchy/call/CallerMethodsTreeStructure.java
@@ -27,6 +27,7 @@
import com.intellij.util.Processor;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.HashMap;
+import org.jetbrains.annotations.NotNull;
import java.util.HashSet;
import java.util.Map;
@@ -38,7 +39,7 @@
/**
* Should be called in read action
*/
- public CallerMethodsTreeStructure(final Project project, final PsiMethod method, final String scopeType) {
+ public CallerMethodsTreeStructure(@NotNull Project project, @NotNull PsiMethod method, final String scopeType) {
super(project, new CallHierarchyNodeDescriptor(project, null, method, true, false));
myScopeType = scopeType;
}
diff --git a/java/java-impl/src/com/intellij/ide/highlighter/JavaClsStructureViewBuilderProvider.java b/java/java-impl/src/com/intellij/ide/highlighter/JavaClsStructureViewBuilderProvider.java
index 3d4f103..7361877 100644
--- a/java/java-impl/src/com/intellij/ide/highlighter/JavaClsStructureViewBuilderProvider.java
+++ b/java/java-impl/src/com/intellij/ide/highlighter/JavaClsStructureViewBuilderProvider.java
@@ -27,6 +27,7 @@
import com.intellij.lang.Language;
import com.intellij.lang.LanguageStructureViewBuilder;
import com.intellij.lang.PsiStructureViewFactory;
+import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.fileTypes.ContentBasedFileSubstitutor;
import com.intellij.openapi.fileTypes.FileType;
@@ -39,6 +40,7 @@
import org.jetbrains.annotations.Nullable;
public class JavaClsStructureViewBuilderProvider implements StructureViewBuilderProvider {
+ @Override
@Nullable
public StructureViewBuilder getStructureViewBuilder(@NotNull final FileType fileType, @NotNull final VirtualFile file, @NotNull final Project project) {
@@ -58,9 +60,10 @@
final PsiJavaFile javaFile = (PsiJavaFile)psiFile;
if (javaFile == null) return null;
return new TreeBasedStructureViewBuilder() {
+ @Override
@NotNull
- public StructureViewModel createStructureViewModel() {
- return new JavaFileTreeModel(javaFile);
+ public StructureViewModel createStructureViewModel(@Nullable Editor editor) {
+ return new JavaFileTreeModel(javaFile, editor);
}
};
}
diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaFileTreeModel.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaFileTreeModel.java
index d9c25eb..962bf5f 100644
--- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaFileTreeModel.java
+++ b/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaFileTreeModel.java
@@ -23,9 +23,11 @@
import com.intellij.ide.util.treeView.smartTree.Grouper;
import com.intellij.ide.util.treeView.smartTree.NodeProvider;
import com.intellij.ide.util.treeView.smartTree.Sorter;
+import com.intellij.openapi.editor.Editor;
import com.intellij.psi.*;
import com.intellij.ui.PlaceHolder;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
import java.util.Collection;
@@ -36,11 +38,12 @@
private final PsiClassOwner myFile;
private String myPlace;
- public JavaFileTreeModel(@NotNull PsiClassOwner file) {
- super(file);
+ public JavaFileTreeModel(@NotNull PsiClassOwner file, @Nullable Editor editor) {
+ super(editor, file);
myFile = file;
}
+ @Override
@NotNull
public Filter[] getFilters() {
return new Filter[]{new FieldsFilter(),
@@ -53,20 +56,24 @@
return NODE_PROVIDERS;
}
+ @Override
@NotNull
public Grouper[] getGroupers() {
return new Grouper[]{new SuperTypesGrouper(), new PropertiesGrouper()};
}
+ @Override
@NotNull
public StructureViewTreeElement getRoot() {
return new JavaFileTreeElement(myFile);
}
+ @Override
public boolean shouldEnterElement(final Object element) {
return element instanceof PsiClass;
}
+ @Override
@NotNull
public Sorter[] getSorters() {
return new Sorter[] {
@@ -76,15 +83,18 @@
Sorter.ALPHA_SORTER};
}
+ @Override
protected PsiFile getPsiFile() {
return myFile;
}
+ @Override
public boolean isAlwaysShowsPlus(StructureViewTreeElement element) {
Object value = element.getValue();
return value instanceof PsiClass || value instanceof PsiFile;
}
+ @Override
public boolean isAlwaysLeaf(StructureViewTreeElement element) {
Object value = element.getValue();
return value instanceof PsiMethod || value instanceof PsiField;
@@ -113,6 +123,7 @@
return false;
}
+ @Override
@NotNull
protected Class[] getSuitableClasses() {
return new Class[]{PsiClass.class, PsiMethod.class, PsiField.class, PsiJavaFile.class};
diff --git a/java/java-impl/src/com/intellij/ide/util/gotoByName/DefaultSymbolNavigationContributor.java b/java/java-impl/src/com/intellij/ide/util/gotoByName/DefaultSymbolNavigationContributor.java
index e42aff9..402e7f5 100644
--- a/java/java-impl/src/com/intellij/ide/util/gotoByName/DefaultSymbolNavigationContributor.java
+++ b/java/java-impl/src/com/intellij/ide/util/gotoByName/DefaultSymbolNavigationContributor.java
@@ -19,18 +19,20 @@
import com.intellij.navigation.ChooseByNameContributor;
import com.intellij.navigation.NavigationItem;
import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
+import com.intellij.psi.impl.PsiSuperMethodImplUtil;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.PsiShortNamesCache;
import com.intellij.psi.util.PsiUtil;
import com.intellij.util.ArrayUtil;
-import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.HashSet;
import org.jetbrains.annotations.NotNull;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
public class DefaultSymbolNavigationContributor implements ChooseByNameContributor {
private static final Logger LOG = Logger.getInstance("#com.intellij.ide.util.gotoByName.DefaultSymbolNavigationContributor");
@@ -52,45 +54,41 @@
GlobalSearchScope scope = includeNonProjectItems ? GlobalSearchScope.allScope(project) : GlobalSearchScope.projectScope(project);
PsiShortNamesCache cache = PsiShortNamesCache.getInstance(project);
- PsiMethod[] methods = cache.getMethodsByName(name, scope);
- methods = filterInheritedMethods(methods);
- PsiField[] fields = cache.getFieldsByName(name, scope);
- PsiClass[] classes = cache.getClassesByName(name, scope);
-
List<PsiMember> result = new ArrayList<PsiMember>();
- ContainerUtil.addAll(result, methods);
- ContainerUtil.addAll(result, fields);
- ContainerUtil.addAll(result, classes);
- filterOutNonOpenable(result);
+ for (PsiMethod method : cache.getMethodsByName(name, scope)) {
+ if (!method.isConstructor() && isOpenable(method) && !hasSuperMethod(method)) {
+ result.add(method);
+ }
+ }
+ for (PsiField field : cache.getFieldsByName(name, scope)) {
+ if (isOpenable(field)) {
+ result.add(field);
+ }
+ }
+ for (PsiClass aClass : cache.getClassesByName(name, scope)) {
+ if (isOpenable(aClass)) {
+ result.add(aClass);
+ }
+ }
PsiMember[] array = result.toArray(new PsiMember[result.size()]);
Arrays.sort(array, MyComparator.INSTANCE);
return array;
}
- private static void filterOutNonOpenable(List<PsiMember> members) {
- ListIterator<PsiMember> it = members.listIterator();
- while (it.hasNext()) {
- PsiMember member = it.next();
- if (isNonOpenable(member)) {
- it.remove();
+ private static boolean isOpenable(PsiMember member) {
+ return member.getContainingFile().getVirtualFile() != null;
+ }
+
+ private static boolean hasSuperMethod(PsiMethod method) {
+ PsiClass containingClass = method.getContainingClass();
+ if (containingClass == null) return false;
+
+ for (PsiMethod candidate : containingClass.findMethodsByName(method.getName(), true)) {
+ if (candidate.getContainingClass() != containingClass && PsiSuperMethodImplUtil.isSuperMethodSmart(method, candidate)) {
+ return true;
}
}
- }
-
- private static boolean isNonOpenable(PsiMember member) {
- return member.getContainingFile().getVirtualFile() == null;
- }
-
- private static PsiMethod[] filterInheritedMethods(PsiMethod[] methods) {
- ArrayList<PsiMethod> list = new ArrayList<PsiMethod>(methods.length);
- for (PsiMethod method : methods) {
- ProgressManager.checkCanceled();
- if (method.isConstructor()) continue;
- PsiMethod[] supers = method.findSuperMethods();
- if (supers.length > 0) continue;
- list.add(method);
- }
- return list.toArray(new PsiMethod[list.size()]);
+ return false;
}
private static class MyComparator implements Comparator<PsiModifierListOwner>{
diff --git a/java/java-impl/src/com/intellij/lang/java/JavaStructureViewBuilderFactory.java b/java/java-impl/src/com/intellij/lang/java/JavaStructureViewBuilderFactory.java
index a353cff..e8d4eba 100644
--- a/java/java-impl/src/com/intellij/lang/java/JavaStructureViewBuilderFactory.java
+++ b/java/java-impl/src/com/intellij/lang/java/JavaStructureViewBuilderFactory.java
@@ -24,6 +24,7 @@
import com.intellij.ide.structureView.TreeBasedStructureViewBuilder;
import com.intellij.ide.structureView.impl.java.JavaFileTreeModel;
import com.intellij.lang.PsiStructureViewFactory;
+import com.intellij.openapi.editor.Editor;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiJavaFile;
import org.jetbrains.annotations.NotNull;
@@ -37,8 +38,8 @@
return new TreeBasedStructureViewBuilder() {
@Override
@NotNull
- public StructureViewModel createStructureViewModel() {
- return new JavaFileTreeModel((PsiJavaFile)psiFile);
+ public StructureViewModel createStructureViewModel(@Nullable Editor editor) {
+ return new JavaFileTreeModel((PsiJavaFile)psiFile, editor);
}
@Override
diff --git a/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java b/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java
index e81e167..1376f44 100644
--- a/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java
+++ b/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java
@@ -296,7 +296,12 @@
}
else if (myRole1 == ChildRole.FIELD) {
int lines = Math.max(getLinesAroundField(), getLinesAroundMethod()) + 1;
- myResult = Spacing.createSpacing(0, mySettings.SPACE_BEFORE_CLASS_LBRACE ? 1 : 0, 0, true, mySettings.KEEP_BLANK_LINES_BEFORE_RBRACE,
+ // IJ has been keeping initialization block which starts at the same line as a field for a while.
+ // However, it's not convenient for a situation when particular code is created via PSI - it's easier to not bothering
+ // with whitespace elements when inserting, say, new initialization blocks. That's why we don't enforce new line
+ // only during explicit reformatting ('Reformat' action).
+ int minLineFeeds = FormatterUtil.isFormatterCalledExplicitly() ? 0 : 1;
+ myResult = Spacing.createSpacing(0, mySettings.SPACE_BEFORE_CLASS_LBRACE ? 1 : 0, 1, true, mySettings.KEEP_BLANK_LINES_BEFORE_RBRACE,
lines);
}
else if (myRole1 == ChildRole.CLASS) {
diff --git a/java/java-impl/src/com/intellij/psi/impl/PackagePrefixElementFinder.java b/java/java-impl/src/com/intellij/psi/impl/PackagePrefixElementFinder.java
index 7f58413..0f2df2d 100644
--- a/java/java-impl/src/com/intellij/psi/impl/PackagePrefixElementFinder.java
+++ b/java/java-impl/src/com/intellij/psi/impl/PackagePrefixElementFinder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -68,7 +68,7 @@
final String qualifiedName = psiPackage.getQualifiedName();
for (final String prefix : myPackagePrefixIndex.getAllPackagePrefixes(scope)) {
- if (StringUtil.isEmpty(qualifiedName) || StringUtil.startsWithConcatenationOf(prefix, qualifiedName, ".")) {
+ if (StringUtil.isEmpty(qualifiedName) || StringUtil.startsWithConcatenation(prefix, qualifiedName, ".")) {
final int i = prefix.indexOf('.', qualifiedName.length() + 1);
String childName = i >= 0 ? prefix.substring(0, i) : prefix;
if (!packagesMap.containsKey(childName)) {
@@ -83,7 +83,7 @@
public boolean packagePrefixExists(String packageQName) {
for (final String prefix : myPackagePrefixIndex.getAllPackagePrefixes(null)) {
- if (StringUtil.startsWithConcatenationOf(prefix, packageQName, ".") || prefix.equals(packageQName)) {
+ if (StringUtil.startsWithConcatenation(prefix, packageQName, ".") || prefix.equals(packageQName)) {
return true;
}
}
diff --git a/java/java-impl/src/com/intellij/psi/impl/smartPointers/AnchorElementInfoFactory.java b/java/java-impl/src/com/intellij/psi/impl/smartPointers/AnchorElementInfoFactory.java
index a80ffad..57f919f 100644
--- a/java/java-impl/src/com/intellij/psi/impl/smartPointers/AnchorElementInfoFactory.java
+++ b/java/java-impl/src/com/intellij/psi/impl/smartPointers/AnchorElementInfoFactory.java
@@ -20,6 +20,7 @@
import com.intellij.psi.impl.source.PsiFileWithStubSupport;
import com.intellij.psi.stubs.IStubElementType;
import com.intellij.psi.stubs.StubTree;
+import com.intellij.psi.util.PsiUtilCore;
import com.intellij.psi.xml.XmlTag;
import com.intellij.xml.util.XmlTagUtil;
import org.jetbrains.annotations.NotNull;
@@ -55,7 +56,7 @@
@Nullable
static PsiElement getAnchor(PsiElement element) {
- LOG.assertTrue(element.isValid());
+ PsiUtilCore.ensureValid(element);
PsiElement anchor = null;
if (element instanceof PsiClass) {
if (element instanceof PsiAnonymousClass) {
diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ImportHelper.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ImportHelper.java
index 1571656..39a8cdc 100644
--- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ImportHelper.java
+++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ImportHelper.java
@@ -124,7 +124,7 @@
}
public static void collectOnDemandImports(List<Pair<String, Boolean>> resultList,
- final Set<String> classesOrPackagesToImportOnDemand,
+ final Set<String> classesOrPackagesToImportOnDemand,
final CodeStyleSettings settings) {
TObjectIntHashMap<String> packageToCountMap = new TObjectIntHashMap<String>();
TObjectIntHashMap<String> classToCountMap = new TObjectIntHashMap<String>();
@@ -132,7 +132,7 @@
String name = pair.getFirst();
Boolean isStatic = pair.getSecond();
String packageOrClassName = getPackageOrClassName(name);
- if (packageOrClassName.length() == 0) continue;
+ if (packageOrClassName.isEmpty()) continue;
if (isStatic) {
int count = classToCountMap.get(packageOrClassName);
classToCountMap.put(packageOrClassName, count + 1);
@@ -209,12 +209,12 @@
String name = pair.getFirst();
Boolean isStatic = pair.getSecond();
String prefix = getPackageOrClassName(name);
- if (prefix.length() == 0) continue;
+ if (prefix.isEmpty()) continue;
final boolean isImplicitlyImported = implicitlyImportedPackages.contains(prefix);
if (!onDemandImports.contains(prefix) && !isImplicitlyImported) continue;
String shortName = PsiNameHelper.getShortClassName(name);
- String thisPackageClass = thisPackageName.length() > 0 ? thisPackageName + "." + shortName : shortName;
+ String thisPackageClass = !thisPackageName.isEmpty() ? thisPackageName + "." + shortName : shortName;
if (JavaPsiFacade.getInstance(manager.getProject()).findClass(thisPackageClass, resolveScope) != null) {
namesToUseSingle.add(name);
continue;
@@ -303,7 +303,7 @@
conflicts.addAll(inter);
}
}
- if (!conflicts.isEmpty()) {
+ if (!conflicts.isEmpty() && !(file instanceof PsiCompiledElement)) {
file.accept(new JavaRecursiveElementVisitor() {
@Override
public void visitReferenceElement(PsiJavaCodeReferenceElement reference) {
@@ -382,7 +382,7 @@
}
boolean useOnDemand = true;
- if (packageName.length() == 0){
+ if (packageName.isEmpty()){
useOnDemand = false;
}
@@ -640,7 +640,7 @@
int limitCount = isStaticImportNeeded ? settings.NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND :
settings.CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND;
if (classCount >= limitCount) return true;
- if (packageName.length() == 0) return false;
+ if (packageName.isEmpty()) return false;
PackageEntryTable table = settings.PACKAGES_TO_USE_IMPORT_ON_DEMAND;
return table != null && table.contains(packageName);
}
@@ -839,21 +839,23 @@
final boolean[] hasResolveProblem = {false};
// do not visit imports
for (PsiClass aClass : file.getClasses()) {
- aClass.accept(new JavaRecursiveElementWalkingVisitor() {
- @Override
- public void visitReferenceElement(PsiJavaCodeReferenceElement reference) {
- String name = reference.getReferenceName();
- Pair<String, Boolean> pair = unresolvedNames.get(name);
- if (reference.multiResolve(false).length == 0) {
- hasResolveProblem[0] = true;
- if (pair != null) {
- namesToImport.add(pair);
- unresolvedNames.remove(name);
+ if (!(aClass instanceof PsiCompiledElement)) {
+ aClass.accept(new JavaRecursiveElementWalkingVisitor() {
+ @Override
+ public void visitReferenceElement(PsiJavaCodeReferenceElement reference) {
+ String name = reference.getReferenceName();
+ Pair<String, Boolean> pair = unresolvedNames.get(name);
+ if (reference.multiResolve(false).length == 0) {
+ hasResolveProblem[0] = true;
+ if (pair != null) {
+ namesToImport.add(pair);
+ unresolvedNames.remove(name);
+ }
}
+ super.visitReferenceElement(reference);
}
- super.visitReferenceElement(reference);
- }
- });
+ });
+ }
}
if (hasResolveProblem[0]) {
namesToImport.addAll(unresolvedOnDemand);
@@ -872,7 +874,7 @@
public static boolean hasPackage(@NotNull String className, @NotNull String packageName){
if (!className.startsWith(packageName)) return false;
if (className.length() == packageName.length()) return false;
- if (packageName.length() > 0 && className.charAt(packageName.length()) != '.') return false;
+ if (!packageName.isEmpty() && className.charAt(packageName.length()) != '.') return false;
return className.indexOf('.', packageName.length() + 1) < 0;
}
diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDClassComment.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDClassComment.java
index ad0e0d5..354e853 100644
--- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDClassComment.java
+++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDClassComment.java
@@ -15,9 +15,11 @@
*/
package com.intellij.psi.impl.source.codeStyle.javadoc;
-import org.jetbrains.annotations.NonNls;
+import com.intellij.util.containers.ContainerUtilRt;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
-import java.util.ArrayList;
+import java.util.List;
/**
* Class comment
@@ -25,51 +27,45 @@
* @author Dmitry Skavish
*/
public class JDClassComment extends JDParamListOwnerComment {
- public JDClassComment(CommentFormatter formatter) {
+ private List<String> myAuthorsList;
+ private String myVersion;
+
+ public JDClassComment(@NotNull CommentFormatter formatter) {
super(formatter);
}
- private ArrayList authorsList;
- private String version;
-
@Override
- protected void generateSpecial(String prefix, @NonNls StringBuffer sb) {
+ protected void generateSpecial(@NotNull String prefix, @NotNull StringBuilder sb) {
super.generateSpecial(prefix, sb);
- if (!isNull(authorsList)) {
- for (Object aAuthorsList : authorsList) {
- String s = (String)aAuthorsList;
+ if (!isNull(myAuthorsList)) {
+ JDTag tag = JDTag.AUTHOR;
+ for (String author : myAuthorsList) {
sb.append(prefix);
- sb.append("@author ");
- sb.append(myFormatter.getParser().splitIntoCLines(s, prefix + " ", false));
+ sb.append(tag.getWithEndWhitespace());
+ sb.append(myFormatter.getParser().formatJDTagDescription(author, tag.getDescriptionPrefix(prefix)));
}
}
- if (!isNull(version)) {
+ if (!isNull(myVersion)) {
sb.append(prefix);
- sb.append("@version ");
- sb.append(myFormatter.getParser().splitIntoCLines(version, prefix + " ", false));
+ JDTag tag = JDTag.VERSION;
+ sb.append(tag.getWithEndWhitespace());
+ sb.append(myFormatter.getParser().formatJDTagDescription(myVersion, tag.getDescriptionPrefix(prefix)));
}
}
- public void addAuthor(String author) {
- if (authorsList == null) {
- authorsList = new ArrayList();
+ public void addAuthor(@NotNull String author) {
+ if (myAuthorsList == null) {
+ myAuthorsList = ContainerUtilRt.newArrayList();
}
- authorsList.add(author);
+ myAuthorsList.add(author);
}
- public ArrayList getAuthorsList() {
- return authorsList;
- }
-
- public void setAuthorsList(ArrayList authorsList) {
- this.authorsList = authorsList;
- }
-
+ @Nullable
public String getVersion() {
- return version;
+ return myVersion;
}
- public void setVersion(String version) {
- this.version = version;
+ public void setVersion(@NotNull String version) {
+ this.myVersion = version;
}
}
\ No newline at end of file
diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDComment.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDComment.java
index cedc964..28dc6a3 100644
--- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDComment.java
+++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDComment.java
@@ -15,9 +15,11 @@
*/
package com.intellij.psi.impl.source.codeStyle.javadoc;
-import org.jetbrains.annotations.NonNls;
+import com.intellij.util.containers.ContainerUtilRt;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
-import java.util.ArrayList;
+import java.util.List;
/**
* @author max
@@ -27,43 +29,42 @@
* @author Dmitry Skavish
*/
public class JDComment {
- protected CommentFormatter myFormatter;
+ protected final CommentFormatter myFormatter;
- String description;
- protected ArrayList unknownList;
- protected ArrayList seeAlsoList;
- protected String since;
- String deprecated;
+ private String myDescription;
+ private List<String> myUnknownList;
+ private List<String> mySeeAlsoList;
+ private String mySince;
+ private String myDeprecated;
- //protected LinkedHashMap xdocTagMap = new LinkedHashMap();
-
- public JDComment(CommentFormatter formatter) {
+ public JDComment(@NotNull CommentFormatter formatter) {
myFormatter = formatter;
}
- protected static boolean isNull(String s) {
+ protected static boolean isNull(@Nullable String s) {
return s == null || s.trim().length() == 0;
}
- protected static boolean isNull(ArrayList l) {
+ protected static boolean isNull(@Nullable List<?> l) {
return l == null || l.size() == 0;
}
- public String generate(String indent) {
+ @Nullable
+ public String generate(@NotNull String indent) {
final String prefix;
+
if (myFormatter.getSettings().JD_LEADING_ASTERISKS_ARE_ENABLED) {
prefix = indent + " * ";
} else {
prefix = indent;
}
- @NonNls StringBuffer sb = new StringBuffer();
-// sb.append("/**\n");
-
+ StringBuilder sb = new StringBuilder();
int start = sb.length();
- if (!isNull(description)) {
- sb.append(myFormatter.getParser().splitIntoCLines(description, prefix));
+ if (!isNull(myDescription)) {
+ sb.append(prefix);
+ sb.append(myFormatter.getParser().formatJDTagDescription(myDescription, prefix));
if (myFormatter.getSettings().JD_ADD_BLANK_AFTER_DESCRIPTION) {
sb.append(prefix);
@@ -73,48 +74,40 @@
generateSpecial(prefix, sb);
- if (!isNull(unknownList) && myFormatter.getSettings().JD_KEEP_INVALID_TAGS) {
- for (Object aUnknownList : unknownList) {
- String s = (String)aUnknownList;
- sb.append(myFormatter.getParser().splitIntoCLines(s, prefix));
- }
- }
-
- /*
- if( xdocTagMap.size() > 0 ) {
- Iterator it = xdocTagMap.values().iterator();
- while( it.hasNext() ) {
- ArrayList list = (ArrayList) it.next();
- for( int i = 0; i<list.size(); i++ ) {
- XDTag tag = (XDTag) list.get(i);
- tag.append(sb, prefix);
- if( myFormatter.getSettings().add_blank_after_xdoclet_tag ) {
- sb.append(prefix);
- sb.append('\n');
- }
- }
- }
- }*/
-
- if (!isNull(seeAlsoList)) {
- for (Object aSeeAlsoList : seeAlsoList) {
- String s = (String)aSeeAlsoList;
+ if (!isNull(myUnknownList) && myFormatter.getSettings().JD_KEEP_INVALID_TAGS) {
+ for (String aUnknownList : myUnknownList) {
sb.append(prefix);
- sb.append("@see ");
- sb.append(myFormatter.getParser().splitIntoCLines(s, prefix + " ", false));
+ sb.append(myFormatter.getParser().formatJDTagDescription(aUnknownList, prefix));
}
}
- if (!isNull(since)) {
- sb.append(prefix);
- sb.append("@since ");
- sb.append(myFormatter.getParser().splitIntoCLines(since, prefix + " ", false));
+ if (!isNull(mySeeAlsoList)) {
+ JDTag tag = JDTag.SEE;
+ for (String aSeeAlsoList : mySeeAlsoList) {
+ sb.append(prefix);
+ sb.append(tag.getWithEndWhitespace());
+ StringBuilder tagDescription = myFormatter.getParser()
+ .formatJDTagDescription(aSeeAlsoList, prefix, true, tag.getDescriptionPrefix(prefix).length());
+ sb.append(tagDescription);
+ }
}
- if (deprecated != null) {
+ if (!isNull(mySince)) {
+ JDTag tag = JDTag.SINCE;
sb.append(prefix);
- sb.append("@deprecated ");
- sb.append(myFormatter.getParser().splitIntoCLines(deprecated, prefix + " ", false));
+ sb.append(tag.getWithEndWhitespace());
+ StringBuilder tagDescription = myFormatter.getParser()
+ .formatJDTagDescription(mySince, prefix, true, tag.getDescriptionPrefix(prefix).length());
+ sb.append(tagDescription);
+ }
+
+ if (myDeprecated != null) {
+ JDTag tag = JDTag.DEPRECATED;
+ sb.append(prefix);
+ sb.append(tag.getWithEndWhitespace());
+ StringBuilder tagDescription = myFormatter.getParser()
+ .formatJDTagDescription(myDeprecated, prefix, true, tag.getDescriptionPrefix(prefix).length());
+ sb.append(tagDescription);
}
if (sb.length() == start) return null;
@@ -139,77 +132,37 @@
return sb.toString();
}
- protected void generateSpecial(String prefix, StringBuffer sb) {
+ protected void generateSpecial(@NotNull String prefix, @NotNull StringBuilder sb) {
}
- public void addSeeAlso(String seeAlso) {
- if (seeAlsoList == null) {
- seeAlsoList = new ArrayList();
+ public void addSeeAlso(@NotNull String seeAlso) {
+ if (mySeeAlsoList == null) {
+ mySeeAlsoList = ContainerUtilRt.newArrayList();
}
- seeAlsoList.add(seeAlso);
+ mySeeAlsoList.add(seeAlso);
}
- public void addUnknownTag(String unknownTag) {
- if (unknownList == null) {
- unknownList = new ArrayList();
+ public void addUnknownTag(@NotNull String unknownTag) {
+ if (myUnknownList == null) {
+ myUnknownList = ContainerUtilRt.newArrayList();
}
- unknownList.add(unknownTag);
- }
-/*
- public void addXDocTag( XDTag tag ) {
- getXdocTagList(tag.getNamespaceDesc()).add(tag);
- }
-
- public ArrayList getXdocTagList( String nsName ) {
- ArrayList list = (ArrayList) xdocTagMap.get(nsName);
- if( list == null ) {
- list = new ArrayList();
- xdocTagMap.put(nsName, list);
- }
- return list;
- }
-
- public ArrayList getXdocTagList( XDNamespaceDesc desc ) {
- return getXdocTagList(desc.getName());
- }
-*/
- public ArrayList getSeeAlsoList() {
- return seeAlsoList;
+ myUnknownList.add(unknownTag);
}
- public void setUnknownList(ArrayList unknownList) {
- this.unknownList = unknownList;
+ public void setSince(@Nullable String since) {
+ this.mySince = since;
}
- public void setSeeAlsoList(ArrayList seeAlsoList) {
- this.seeAlsoList = seeAlsoList;
+ public void setDeprecated(@Nullable String deprecated) {
+ this.myDeprecated = deprecated;
}
- public ArrayList getUnknownList() {
- return unknownList;
- }
-
- public String getSince() {
- return since;
- }
-
- public void setSince(String since) {
- this.since = since;
- }
-
- public String getDeprecated() {
- return deprecated;
- }
-
- public void setDeprecated(String deprecated) {
- this.deprecated = deprecated;
- }
-
+ @Nullable
public String getDescription() {
- return description;
+ return myDescription;
}
- public void setDescription(String description) {
- this.description = description;
+ public void setDescription(@Nullable String description) {
+ this.myDescription = description;
}
}
diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDMethodComment.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDMethodComment.java
index 6fd664b..0059b2f 100644
--- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDMethodComment.java
+++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDMethodComment.java
@@ -15,9 +15,11 @@
*/
package com.intellij.psi.impl.source.codeStyle.javadoc;
-import org.jetbrains.annotations.NonNls;
+import com.intellij.util.containers.ContainerUtilRt;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
-import java.util.ArrayList;
+import java.util.List;
/**
* Method comment
@@ -25,26 +27,23 @@
* @author Dmitry Skavish
*/
public class JDMethodComment extends JDParamListOwnerComment {
- public JDMethodComment(CommentFormatter formatter) {
+ private String myReturnTag;
+ private List<NameDesc> myThrowsList;
+
+ public JDMethodComment(@NotNull CommentFormatter formatter) {
super(formatter);
}
- private String returnTag;
- private ArrayList<NameDesc> throwsList;
-
- private static final @NonNls String THROWS_TAG = "@throws ";
- private static final @NonNls String EXCEPTION_TAG = "@exception ";
-
@Override
- protected void generateSpecial(String prefix, @NonNls StringBuffer sb) {
-
+ protected void generateSpecial(@NotNull String prefix, @NotNull StringBuilder sb) {
super.generateSpecial(prefix, sb);
- if (returnTag != null) {
- if (returnTag.trim().length() != 0 || myFormatter.getSettings().JD_KEEP_EMPTY_RETURN) {
+ if (myReturnTag != null) {
+ if (myFormatter.getSettings().JD_KEEP_EMPTY_RETURN || myReturnTag.trim().length() != 0) {
+ JDTag tag = JDTag.RETURN;
sb.append(prefix);
- sb.append("@return ");
- sb.append(myFormatter.getParser().splitIntoCLines(returnTag, prefix + " ", false));
+ sb.append(tag.getWithEndWhitespace());
+ sb.append(myFormatter.getParser().formatJDTagDescription(myReturnTag, prefix, true, tag.getDescriptionPrefix(prefix).length()));
if (myFormatter.getSettings().JD_ADD_BLANK_AFTER_RETURN) {
sb.append(prefix);
sb.append('\n');
@@ -52,48 +51,24 @@
}
}
- if (throwsList != null) {
- String tag = myFormatter.getSettings().JD_USE_THROWS_NOT_EXCEPTION ? THROWS_TAG : EXCEPTION_TAG;
- generateList(prefix, sb, throwsList, tag,
+ if (myThrowsList != null) {
+ JDTag tag = myFormatter.getSettings().JD_USE_THROWS_NOT_EXCEPTION ? JDTag.THROWS : JDTag.EXCEPTION;
+ generateList(prefix, sb, myThrowsList, tag.getWithEndWhitespace(),
myFormatter.getSettings().JD_ALIGN_EXCEPTION_COMMENTS,
- myFormatter.getSettings().JD_MIN_EXCEPTION_NAME_LENGTH,
- myFormatter.getSettings().JD_MAX_EXCEPTION_NAME_LENGTH,
myFormatter.getSettings().JD_KEEP_EMPTY_EXCEPTION,
myFormatter.getSettings().JD_PARAM_DESCRIPTION_ON_NEW_LINE
);
}
}
- public String getReturnTag() {
- return returnTag;
+ public void setReturnTag(@NotNull String returnTag) {
+ this.myReturnTag = returnTag;
}
- public void setReturnTag(String returnTag) {
- this.returnTag = returnTag;
- }
-
- public void removeThrow(NameDesc nd) {
- if (throwsList == null) return;
- throwsList.remove(nd);
- }
-
- public ArrayList<NameDesc> getThrowsList() {
- return throwsList;
- }
-
- public void addThrow(String className, String description) {
- if (throwsList == null) {
- throwsList = new ArrayList<NameDesc>();
+ public void addThrow(@NotNull String className, @Nullable String description) {
+ if (myThrowsList == null) {
+ myThrowsList = ContainerUtilRt.newArrayList();
}
- throwsList.add(new NameDesc(className, description));
+ myThrowsList.add(new NameDesc(className, description));
}
-
- public NameDesc getThrow(String name) {
- return getNameDesc(name, throwsList);
- }
-
- public void setThrowsList(ArrayList<NameDesc> throwsList) {
- this.throwsList = throwsList;
- }
-
}
diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDParamListOwnerComment.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDParamListOwnerComment.java
index 64af287..c004bc9 100644
--- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDParamListOwnerComment.java
+++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDParamListOwnerComment.java
@@ -22,28 +22,28 @@
import com.intellij.formatting.IndentInfo;
import com.intellij.ide.highlighter.JavaFileType;
+import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
-import org.jetbrains.annotations.NonNls;
+import com.intellij.util.containers.ContainerUtilRt;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
-import java.util.ArrayList;
+import java.util.List;
-public class JDParamListOwnerComment extends JDComment{
- protected ArrayList<NameDesc> parmsList;
- private static final @NonNls String PARAM_TAG = "@param ";
+public class JDParamListOwnerComment extends JDComment {
+ protected List<NameDesc> myParamsList;
- public JDParamListOwnerComment(CommentFormatter formatter) {
+ public JDParamListOwnerComment(@NotNull CommentFormatter formatter) {
super(formatter);
}
@Override
- protected void generateSpecial(String prefix, StringBuffer sb) {
- if (parmsList != null) {
+ protected void generateSpecial(@NotNull String prefix, @NotNull StringBuilder sb) {
+ if (myParamsList != null) {
int before = sb.length();
- generateList(prefix, sb, parmsList, PARAM_TAG,
+ generateList(prefix, sb, myParamsList, JDTag.PARAM.getWithEndWhitespace(),
myFormatter.getSettings().JD_ALIGN_PARAM_COMMENTS,
- myFormatter.getSettings().JD_MIN_PARM_NAME_LENGTH,
- myFormatter.getSettings().JD_MAX_PARM_NAME_LENGTH,
myFormatter.getSettings().JD_KEEP_EMPTY_PARAMETER,
myFormatter.getSettings().JD_PARAM_DESCRIPTION_ON_NEW_LINE
);
@@ -56,35 +56,25 @@
}
}
- public NameDesc getParameter(String name) {
- return getNameDesc(name, parmsList);
+ @Nullable
+ public NameDesc getParameter(@Nullable String name) {
+ return getNameDesc(name, myParamsList);
}
- public void removeParameter(NameDesc nd) {
- if (parmsList == null) return;
- parmsList.remove(nd);
- }
-
- public ArrayList<NameDesc> getParmsList() {
- return parmsList;
- }
-
- public void addParameter(String name, String description) {
- if (parmsList == null) {
- parmsList = new ArrayList<NameDesc>();
+ public void addParameter(@NotNull String name, @Nullable String description) {
+ if (myParamsList == null) {
+ myParamsList = ContainerUtilRt.newArrayList();
}
- parmsList.add(new NameDesc(name, description));
+ myParamsList.add(new NameDesc(name, description));
}
- public void setParmsList(ArrayList<NameDesc> parmsList) {
- this.parmsList = parmsList;
- }
-
- static NameDesc getNameDesc(String name, ArrayList<NameDesc> list) {
+ @Nullable
+ private static NameDesc getNameDesc(@Nullable String name, @Nullable List<NameDesc> list) {
if (list == null) return null;
- for (Object aList : list) {
- NameDesc parameter = (NameDesc)aList;
- if (parameter.name.equals(name)) return parameter;
+ for (NameDesc aList : list) {
+ if (aList.name.equals(name)) {
+ return aList;
+ }
}
return null;
}
@@ -93,59 +83,56 @@
* Generates parameters or exceptions
*
*/
- protected void generateList(String prefix, StringBuffer sb, ArrayList<NameDesc> list, String tag, boolean align_comments,
- int min_name_length, int max_name_length, boolean generate_empty_tags, boolean wrapDescription)
+ protected void generateList(@NotNull String prefix,
+ @NotNull StringBuilder sb,
+ @NotNull List<NameDesc> list,
+ @NotNull String tag,
+ boolean align_comments,
+ boolean generate_empty_tags,
+ boolean wrapDescription)
{
CodeStyleSettings settings = myFormatter.getSettings();
CommonCodeStyleSettings.IndentOptions indentOptions = settings.getIndentOptions(JavaFileType.INSTANCE);
String continuationIndent = new IndentInfo(0, indentOptions.CONTINUATION_INDENT_SIZE, 0).generateNewWhiteSpace(indentOptions);
+
int max = 0;
- if (align_comments && ! wrapDescription) {
- for (Object aList : list) {
- NameDesc nd = (NameDesc)aList;
- int l = nd.name.length();
+
+ if (align_comments && !wrapDescription) {
+ for (NameDesc nd: list) {
+ int currentLength = nd.name.length();
if (isNull(nd.desc) && !generate_empty_tags) continue;
- if (l > max && l <= max_name_length) max = l;
+ //finding longest parameter length
+ if (currentLength > max) {
+ max = currentLength;
+ }
}
}
- max = Math.max(max, min_name_length);
-
- // create filler
- StringBuffer fill = new StringBuffer(prefix.length() + tag.length() + max + 1);
+ StringBuilder fill = new StringBuilder(prefix.length() + tag.length() + max + 1);
fill.append(prefix);
- int k = max + 1 + tag.length();
- for (int i = 0; i < k; i++) fill.append(' ');
+ StringUtil.repeatSymbol(fill, ' ', max + 1 + tag.length());
String wrapParametersPrefix = prefix + continuationIndent;
-
- for (Object aList1 : list) {
- NameDesc nd = (NameDesc)aList1;
+ for (NameDesc nd : list) {
if (isNull(nd.desc) && !generate_empty_tags) continue;
if (wrapDescription && !isNull(nd.desc)) {
sb.append(prefix).append(tag).append(nd.name).append("\n");
- sb.append(myFormatter.getParser().splitIntoCLines(nd.desc, wrapParametersPrefix));
+ sb.append(wrapParametersPrefix);
+ sb.append(myFormatter.getParser().formatJDTagDescription(nd.desc, wrapParametersPrefix));
}
else if (align_comments) {
sb.append(prefix);
sb.append(tag);
sb.append(nd.name);
-
- if (nd.name.length() > max_name_length) {
- sb.append('\n');
- sb.append(myFormatter.getParser().splitIntoCLines(nd.desc, fill, true));
- }
- else {
- int len = max - nd.name.length() + 1;
- for (int j = 0; j < len; j++) {
- sb.append(' ');
- }
- sb.append(myFormatter.getParser().splitIntoCLines(nd.desc, fill, false));
- }
+ int spacesNumber = max + 1 - nd.name.length();
+ StringUtil.repeatSymbol(sb, ' ', Math.max(0, spacesNumber));
+ sb.append(myFormatter.getParser().formatJDTagDescription(nd.desc, fill));
}
else {
- sb.append(myFormatter.getParser().splitIntoCLines(tag + nd.name + " " + nd.desc, prefix, true));
+ sb.append(prefix);
+ String description = (nd.desc == null) ? "" : nd.desc;
+ sb.append(myFormatter.getParser().formatJDTagDescription(tag + nd.name + " " + description, prefix));
}
}
}
-}
\ No newline at end of file
+}
diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDParser.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDParser.java
index 1f7d047..859e848 100644
--- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDParser.java
+++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDParser.java
@@ -16,8 +16,9 @@
package com.intellij.psi.impl.source.codeStyle.javadoc;
import com.intellij.openapi.util.Pair;
+import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.codeStyle.CodeStyleSettings;
-import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
@@ -26,27 +27,31 @@
/**
* Javadoc parser
- *
+ *
* @author Dmitry Skavish
*/
public class JDParser {
-
+
private static final String PRE_TAG_START = "<pre>";
private static final String PRE_TAG_END = "</pre>";
-
+ private static final String P_END_TAG = "</p>";
+ private static final String P_START_TAG = "<p>";
+ private static final String SELF_CLOSED_P_TAG = "<p/>";
+
private final CodeStyleSettings mySettings;
- public JDParser(CodeStyleSettings settings) {
+ public JDParser(@NotNull CodeStyleSettings settings) {
mySettings = settings;
}
private static final char lineSeparator = '\n';
- public JDComment parse(String text, JDComment c) {
+ @NotNull
+ public JDComment parse(@Nullable String text, @NotNull JDComment c) {
if (text == null) return c;
- ArrayList<Boolean> markers = new ArrayList<Boolean>();
- ArrayList<String> l = toArray(text, "\n", markers);
+ List<Boolean> markers = new ArrayList<Boolean>();
+ List<String> l = toArray(text, "\n", markers);
if (l == null) return c;
int size = l.size();
if (size == 0) return c;
@@ -73,7 +78,7 @@
l.set(i, line);
}
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
String tag = null;
for (int i = 0; i <= size; i++) {
String line = i == size ? null : l.get(i);
@@ -126,42 +131,22 @@
}
/**
- * Breaks the specified string by lineseparator into array of strings
- *
- * @param s the specified string
- * @return array of strings (lines)
- */
- public ArrayList<String> toArrayByNL(String s) {
- return toArray(s, "\n", null);
- }
-
- /**
- * Breaks the specified string by comma into array of strings
- *
- * @param s the specified string
- * @return list of strings
- */
- public ArrayList<String> toArrayByComma(String s) {
- return toArray(s, ",", null);
- }
-
- /**
* Breaks the specified string by the specified separators into array of strings
- *
+ *
* @param s the specified string
* @param separators the specified separators
* @param markers if this parameter is not null then it will be filled with Boolean values:
- * true if the correspoding line in returned list is inside <pre> tag,
+ * true if the corresponding line in returned list is inside <pre> tag,
* false if it is outside
* @return array of strings (lines)
*/
- @SuppressWarnings({"HardCodedStringLiteral"})
- private ArrayList<String> toArray(String s, String separators, ArrayList<Boolean> markers) {
+ @Nullable
+ private List<String> toArray(@Nullable String s, @NotNull String separators, @Nullable List<Boolean> markers) {
if (s == null) return null;
s = s.trim();
if (s.length() == 0) return null;
boolean p2nl = markers != null && mySettings.JD_P_AT_EMPTY_LINES;
- ArrayList<String> list = new ArrayList<String>();
+ List<String> list = new ArrayList<String>();
StringTokenizer st = new StringTokenizer(s, separators, true);
boolean first = true;
int preCount = 0;
@@ -170,7 +155,7 @@
String token = st.nextToken();
curPos += token.length();
- if (separators.indexOf(token) >= 0) {
+ if (separators.contains(token)) {
if (!first) {
list.add("");
if (markers != null) markers.add(Boolean.valueOf(preCount > 0));
@@ -180,7 +165,7 @@
else {
first = true;
if (p2nl) {
- if (isParaTag(token) && s.indexOf("</p>", curPos) < 0) {
+ if (isParaTag(token) && s.indexOf(P_END_TAG, curPos) < 0) {
list.add("");
markers.add(Boolean.valueOf(preCount > 0));
continue;
@@ -191,9 +176,9 @@
list.add(token);
if (markers != null) {
- if (token.indexOf("<pre>") >= 0) preCount++;
+ if (token.contains(PRE_TAG_START)) preCount++;
markers.add(Boolean.valueOf(preCount > 0));
- if (token.indexOf("</pre>") >= 0) preCount--;
+ if (token.contains(PRE_TAG_END)) preCount--;
}
}
@@ -201,56 +186,30 @@
return list;
}
- @SuppressWarnings({"HardCodedStringLiteral"})
- private boolean isParaTag(final String token) {
+ private static boolean isParaTag(@NotNull final String token) {
String withoutWS = removeWhiteSpacesFrom(token).toLowerCase();
- return withoutWS.equals("<p/>") || withoutWS.equals("<p>");
+ return withoutWS.equals(SELF_CLOSED_P_TAG) || withoutWS.equals(P_START_TAG);
}
- private String removeWhiteSpacesFrom(final String token) {
- final StringBuffer result = new StringBuffer();
+ @NotNull
+ private static String removeWhiteSpacesFrom(@NotNull final String token) {
+ final StringBuilder result = new StringBuilder();
for (char c : token.toCharArray()) {
if (c != ' ') result.append(c);
}
return result.toString();
}
- public static String toLines(ArrayList l) {
- if (l == null || l.size() == 0) return null;
- StringBuffer sb = new StringBuffer();
- for (Object aL : l) {
- String s = (String)aL;
- if (sb.length() > 0) {
- sb.append(lineSeparator);
- }
- sb.append(s);
- }
- return sb.toString();
- }
-
- public static String toCommaSeparated(ArrayList<String> l) {
- if (l == null || l.size() == 0) return null;
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < l.size(); i++) {
- String s = l.get(i);
- if (i != 0) {
- sb.append(", ");
- }
- sb.append(s);
- }
- return sb.toString();
- }
-
/**
- * Processes all lines (char sequences separated by line feed symbol) from the given string slitting them if necessary
- * ensuring that every returned line contains less symbols than the given width.
- *
+ * Processes all lines (char sequences separated by line feed symbol) from the given string slitting them if necessary
+ * ensuring that every returned line contains less symbols than the given width.
+ *
* @param s the specified string
* @param width width of the wrapped text
* @return array of strings (lines)
*/
@Nullable
- private List<String> toArrayWrapping(String s, int width) {
+ private List<String> toArrayWrapping(@Nullable String s, int width) {
List<String> list = new ArrayList<String>();
List<Pair<String, Boolean>> pairs = splitToParagraphs(s);
if (pairs == null) {
@@ -305,7 +264,7 @@
/**
* Processes given string and produces on its basis set of pairs like <code>'(string; flag)'</code> where <code>'string'</code>
* is interested line and <code>'flag'</code> indicates if it is wrapped to {@code <pre>} tag.
- *
+ *
* @param s string to process
* @return processing result
*/
@@ -313,15 +272,16 @@
private List<Pair<String, Boolean>> splitToParagraphs(@Nullable String s) {
if (s == null) return null;
s = s.trim();
- if (s == null /* just to make inspection happy*/ || s.isEmpty()) return null;
+ if (s.isEmpty()) return null;
List<Pair<String, Boolean>> result = new ArrayList<Pair<String, Boolean>>();
-
+
StringBuilder sb = new StringBuilder();
- ArrayList<Boolean> markers = new ArrayList<Boolean>();
- ArrayList<String> list = toArray(s, "\n", markers);
+ List<Boolean> markers = new ArrayList<Boolean>();
+ List<String> list = toArray(s, "\n", markers);
Boolean[] marks = markers.toArray(new Boolean[markers.size()]);
markers.clear();
+ assert list != null;
for (int i = 0; i < list.size(); i++) {
String s1 = list.get(i);
if (marks[i].booleanValue()) {
@@ -353,27 +313,17 @@
}
return result;
}
-
- static abstract class TagParser {
+
+ abstract static class TagParser {
abstract boolean parse(String tag, String line, JDComment c);
}
- private static final @NonNls String SEE_TAG = "see";
- private static final @NonNls String SINCE_TAG = "since";
- private static final @NonNls String VERSION_TAG = "version";
- private static final @NonNls String DEPRECATED_TAG = "deprecated";
- private static final @NonNls String RETURN_TAG = "return";
- private static final @NonNls String PARAM_TAG = "param";
- private static final @NonNls String THROWS_TAG = "throws";
- private static final @NonNls String EXCEPTION_TAG = "exception";
- private static final @NonNls String AUTHOR_TAG = "author";
-
private static final TagParser[] tagParsers = {
new TagParser() {
@Override
boolean parse(String tag, String line, JDComment c) {
- boolean isMyTag = SEE_TAG.equals(tag);
+ boolean isMyTag = JDTag.SEE.tagEqual(tag);
if (isMyTag) {
c.addSeeAlso(line);
}
@@ -383,7 +333,7 @@
new TagParser() {
@Override
boolean parse(String tag, String line, JDComment c) {
- boolean isMyTag = SINCE_TAG.equals(tag);
+ boolean isMyTag = JDTag.SINCE.tagEqual(tag);
if (isMyTag) {
c.setSince(line);
}
@@ -393,7 +343,7 @@
new TagParser() {
@Override
boolean parse(String tag, String line, JDComment c) {
- boolean isMyTag = c instanceof JDClassComment && VERSION_TAG.equals(tag);
+ boolean isMyTag = c instanceof JDClassComment && JDTag.VERSION.tagEqual(tag);
if (isMyTag) {
((JDClassComment)c).setVersion(line);
}
@@ -403,7 +353,7 @@
new TagParser() {
@Override
boolean parse(String tag, String line, JDComment c) {
- boolean isMyTag = DEPRECATED_TAG.equals(tag);
+ boolean isMyTag = JDTag.DEPRECATED.tagEqual(tag);
if (isMyTag) {
c.setDeprecated(line);
}
@@ -413,7 +363,7 @@
new TagParser() {
@Override
boolean parse(String tag, String line, JDComment c) {
- boolean isMyTag = c instanceof JDMethodComment && RETURN_TAG.equals(tag);
+ boolean isMyTag = c instanceof JDMethodComment && JDTag.RETURN.tagEqual(tag);
if (isMyTag) {
JDMethodComment mc = (JDMethodComment)c;
mc.setReturnTag(line);
@@ -424,7 +374,7 @@
new TagParser() {
@Override
boolean parse(String tag, String line, JDComment c) {
- boolean isMyTag = c instanceof JDParamListOwnerComment && PARAM_TAG.equals(tag);
+ boolean isMyTag = c instanceof JDParamListOwnerComment && JDTag.PARAM.tagEqual(tag);
if (isMyTag) {
JDParamListOwnerComment mc = (JDParamListOwnerComment)c;
int idx;
@@ -447,7 +397,7 @@
new TagParser() {
@Override
boolean parse(String tag, String line, JDComment c) {
- boolean isMyTag = c instanceof JDMethodComment && (THROWS_TAG.equals(tag) || EXCEPTION_TAG.equals(tag));
+ boolean isMyTag = c instanceof JDMethodComment && (JDTag.THROWS.tagEqual(tag) || JDTag.EXCEPTION.tagEqual(tag));
if (isMyTag) {
JDMethodComment mc = (JDMethodComment)c;
int idx;
@@ -470,7 +420,7 @@
new TagParser() {
@Override
boolean parse(String tag, String line, JDComment c) {
- boolean isMyTag = c instanceof JDClassComment && AUTHOR_TAG.equals(tag);
+ boolean isMyTag = c instanceof JDClassComment && JDTag.AUTHOR.tagEqual(tag);
if (isMyTag) {
JDClassComment cl = (JDClassComment)c;
cl.addAuthor(line.trim());
@@ -478,33 +428,72 @@
return isMyTag;
}
},
-/* new TagParser() {
- boolean parse( String tag, String line, JDComment c ) {
- XDTag xdtag = XDTag.parse(tag, line);
- if( xdtag != null ) {
- c.addXDocTag(xdtag);
- }
- return xdtag != null;
- }
- },*/
};
- protected StringBuffer splitIntoCLines(String s, String prefix) {
- return splitIntoCLines(s, prefix, true);
+ /**
+ * @see JDParser#formatJDTagDescription(String, CharSequence, boolean, int)
+ */
+ @NotNull
+ protected StringBuilder formatJDTagDescription(@Nullable String s, @NotNull CharSequence prefix) {
+ return formatJDTagDescription(s, prefix, false, 0);
}
- protected StringBuffer splitIntoCLines(String s, String prefix, boolean add_prefix_to_first_line) {
- return splitIntoCLines(s, new StringBuffer(prefix), add_prefix_to_first_line);
+ private static boolean lineHasUnclosedPreTag(@NotNull String line) {
+ return StringUtil.getOccurrenceCount(line, PRE_TAG_START) > StringUtil.getOccurrenceCount(line, PRE_TAG_END);
}
- protected StringBuffer splitIntoCLines(String s, StringBuffer prefix, boolean add_prefix_to_first_line) {
- @NonNls StringBuffer sb = new StringBuffer();
- if (add_prefix_to_first_line) {
- sb.append(prefix);
+ /**
+ * Returns formatted JavaDoc tag description, according to selected configuration
+ * @param str JavaDoc tag description
+ * @param prefix JavaDoc prefix(like " * ") which will be appended to every new line
+ * @param firstLineShorter flag if first line should be shorter (has another prefix length than other lines)
+ * @param firstLinePrefixLength first line prefix length
+ * @return formatted JavaDoc tag description
+ */
+ @NotNull
+ protected StringBuilder formatJDTagDescription(@Nullable String str,
+ @NotNull CharSequence prefix,
+ boolean firstLineShorter,
+ int firstLinePrefixLength)
+ {
+ StringBuilder sb = new StringBuilder();
+ List<String> list;
+
+ //If wrap comments selected, comments should be wrapped by the right margin
+ if (mySettings.WRAP_COMMENTS) {
+ list = toArrayWrapping(str, mySettings.RIGHT_MARGIN - prefix.length());
+
+ if (firstLineShorter
+ && list != null && !list.isEmpty()
+ && list.get(0).length() > mySettings.RIGHT_MARGIN - firstLinePrefixLength)
+ {
+ list = new ArrayList<String>();
+ //want the first line to be shorter, according to it's prefix
+ String firstLine = toArrayWrapping(str, mySettings.RIGHT_MARGIN - firstLinePrefixLength).get(0);
+ //so now first line is exactly same width we need
+ list.add(firstLine);
+ str = str.substring(firstLine.length());
+ //actually there is one more problem - when first line has unclosed <pre> tag, substring should be processed if it's inside <pre>
+ boolean unclosedPreTag = lineHasUnclosedPreTag(firstLine);
+ if (unclosedPreTag) {
+ str = PRE_TAG_START + str.replaceAll("^\\s+", "");
+ }
+
+ //getting all another lines according to their prefix
+ List<String> subList = toArrayWrapping(str, mySettings.RIGHT_MARGIN - prefix.length());
+
+ //removing pre tag
+ if (unclosedPreTag) {
+ String firstLineTagRemoved = subList.get(0).substring(PRE_TAG_START.length());
+ subList.set(0, firstLineTagRemoved);
+ }
+ list.addAll(subList);
+ }
}
- List<String> list = mySettings.WRAP_COMMENTS
- ? toArrayWrapping(s, mySettings.RIGHT_MARGIN - prefix.length())
- : toArray(s, "\n", new ArrayList<Boolean>());
+ else {
+ list = toArray(str, "\n", new ArrayList<Boolean>());
+ }
+
if (list == null) {
sb.append('\n');
}
@@ -515,11 +504,11 @@
if (line.length() == 0 && !mySettings.JD_KEEP_EMPTY_LINES) continue;
if (i != 0) sb.append(prefix);
if (line.length() == 0 && mySettings.JD_P_AT_EMPTY_LINES && !insidePreTag) {
- sb.append("<p/>");
+ sb.append(SELF_CLOSED_P_TAG);
}
else {
sb.append(line);
-
+
// We want to track if we're inside <pre>...</pre> in order to not generate <p/> there.
if (PRE_TAG_START.equals(line)) {
insidePreTag = true;
diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDTag.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDTag.java
new file mode 100644
index 0000000..1b35145
--- /dev/null
+++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDTag.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2000-2013 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.psi.impl.source.codeStyle.javadoc;
+
+import com.intellij.openapi.util.text.StringUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * User: Lepenkin Y.
+ * Date: 7/1/13
+ * Time: 4:15 PM
+ */
+public enum JDTag {
+ SEE("see"),
+ AUTHOR("author"),
+ VERSION("version"),
+ THROWS("throws"),
+ EXCEPTION("exception"),
+ RETURN("return"),
+ PARAM("param"),
+ SINCE("since"),
+ DEPRECATED("deprecated");
+
+
+ @NotNull private final String myTag;
+
+ JDTag(@NotNull String tag) {
+ this.myTag = tag;
+ }
+
+ @NotNull
+ public String getDescriptionPrefix(@NotNull String prefix) {
+ return prefix + StringUtil.repeatSymbol(' ', getWithEndWhitespace().length());
+ }
+
+ @NotNull
+ public String getWithEndWhitespace() {
+ return "@" + myTag + " ";
+ }
+
+ public boolean tagEqual(@Nullable String tag) {
+ return myTag.equals(tag);
+ }
+}
diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/NameDesc.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/NameDesc.java
index d7de91b..6e8ee10 100644
--- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/NameDesc.java
+++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/NameDesc.java
@@ -15,29 +15,25 @@
*/
package com.intellij.psi.impl.source.codeStyle.javadoc;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
/**
*
* @author Dmitry Skavish
*/
public class NameDesc {
+ @NotNull public final String name;
+ @Nullable public final String desc;
- public String name;
- public String desc;
- private String type;
-
- public NameDesc(String name, String desc) {
+ public NameDesc(@NotNull String name, @Nullable String desc) {
this.name = name;
this.desc = desc;
}
- public NameDesc(String name, String desc, String type) {
- this.name = name;
- this.desc = desc;
- this.type = type;
- }
-
+ @NotNull
+ @Override
public String toString() {
- if (type == null) return name;
- return name + ": " + type;
+ return name;
}
}
diff --git a/java/java-impl/src/com/intellij/refactoring/OptimizeImportsRefactoringHelper.java b/java/java-impl/src/com/intellij/refactoring/OptimizeImportsRefactoringHelper.java
index 5f6072a..cd8613d 100644
--- a/java/java-impl/src/com/intellij/refactoring/OptimizeImportsRefactoringHelper.java
+++ b/java/java-impl/src/com/intellij/refactoring/OptimizeImportsRefactoringHelper.java
@@ -39,12 +39,9 @@
Set<PsiJavaFile> javaFiles = new HashSet<PsiJavaFile>();
for (UsageInfo usage : usages) {
if (usage.isNonCodeUsage) continue;
- final PsiElement element = usage.getElement();
- if (element != null) {
- final PsiFile file = element.getContainingFile();
- if (file instanceof PsiJavaFile) {
- javaFiles.add((PsiJavaFile)file);
- }
+ final PsiFile file = usage.getFile();
+ if (file instanceof PsiJavaFile) {
+ javaFiles.add((PsiJavaFile)file);
}
}
return javaFiles;
diff --git a/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureDetector.java b/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureDetector.java
index 6faaf8e..eba4ae9 100644
--- a/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureDetector.java
+++ b/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureDetector.java
@@ -111,8 +111,9 @@
public String extractSignature(PsiElement element, @NotNull ChangeInfo initialChangeInfo) {
final PsiMethod method = PsiTreeUtil.getParentOfType(element, PsiMethod.class, false);
if (method != null && isInsideMethodSignature(element, method) && method == initialChangeInfo.getMethod()) {
- final TextRange signatureRange = getSignatureRange(method);
- return element.getContainingFile().getText().substring(signatureRange.getStartOffset(), signatureRange.getEndOffset());
+ final PsiCodeBlock body = method.getBody();
+ final TextRange signatureRange = new TextRange(0, body != null ? body.getStartOffsetInParent() : method.getTextLength());
+ return signatureRange.substring(method.getText());
} else if (element instanceof PsiIdentifier && element.getParent() instanceof PsiNamedElement) {
return element.getText();
}
diff --git a/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureDialog.java b/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureDialog.java
index 647cd09..d46fa20 100644
--- a/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureDialog.java
+++ b/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureDialog.java
@@ -30,7 +30,6 @@
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.ValidationInfo;
-import com.intellij.openapi.ui.VerticalFlowLayout;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.Ref;
@@ -50,13 +49,13 @@
import com.intellij.refactoring.util.RefactoringMessageUtil;
import com.intellij.refactoring.util.RefactoringUtil;
import com.intellij.ui.*;
-import com.intellij.ui.components.JBLabel;
import com.intellij.ui.table.JBTable;
import com.intellij.ui.table.TableView;
import com.intellij.ui.treeStructure.Tree;
import com.intellij.util.*;
import com.intellij.util.ui.DialogUtil;
import com.intellij.util.ui.UIUtil;
+import com.intellij.util.ui.table.JBListTable;
import com.intellij.util.ui.table.JBTableRow;
import com.intellij.util.ui.table.JBTableRowEditor;
import org.jetbrains.annotations.NotNull;
@@ -228,7 +227,6 @@
@Override
protected JComponent getRowPresentation(ParameterTableModelItemBase<ParameterInfoImpl> item, boolean selected, final boolean focused) {
- final JPanel panel = new JPanel(new BorderLayout());
final String typeText = item.typeCodeFragment.getText();
final String separator = StringUtil.repeatSymbol(' ', getTypesMaxLength() - typeText.length() + 1);
String text = typeText + separator + item.parameter.getName();
@@ -246,28 +244,7 @@
if (!StringUtil.isEmpty(tail)) {
text += " //" + tail;
}
- final EditorTextField field = new EditorTextField(" " + text, getProject(), getFileType()) {
- @Override
- protected boolean shouldHaveBorder() {
- return false;
- }
- };
-
- Font font = EditorColorsManager.getInstance().getGlobalScheme().getFont(EditorFontType.PLAIN);
- font = new Font(font.getFontName(), font.getStyle(), 12);
- field.setFont(font);
-
- if (selected && focused) {
- panel.setBackground(UIUtil.getTableSelectionBackground());
- field.setAsRendererWithSelection(UIUtil.getTableSelectionBackground(), UIUtil.getTableSelectionForeground());
- } else {
- panel.setBackground(UIUtil.getTableBackground());
- if (selected && !focused) {
- panel.setBorder(new DottedBorder(UIUtil.getTableForeground()));
- }
- }
- panel.add(field, BorderLayout.WEST);
- return panel;
+ return JBListTable.createEditorTextFieldPresentation(getProject(), getFileType(), " " + text, selected, focused);
}
private int getTypesMaxLength() {
@@ -311,43 +288,20 @@
private EditorTextField myDefaultValueEditor;
private JCheckBox myAnyVar;
- class MyDocumentListener extends DocumentAdapter {
- private int myColumn;
-
- private MyDocumentListener(int column) {
- myColumn = column;
- }
-
- @Override
- public void documentChanged(DocumentEvent e) {
- fireDocumentChanged(e, myColumn);
- }
- }
-
@Override
public void prepareEditor(JTable table, int row) {
setLayout(new BorderLayout());
- final JPanel typePanel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, 4, 2, true, false));
final Document document = PsiDocumentManager.getInstance(getProject()).getDocument(item.typeCodeFragment);
myTypeEditor = new EditorTextField(document, getProject(), getFileType());
myTypeEditor.addDocumentListener(mySignatureUpdater);
- final JBLabel typeLabel = new JBLabel("Type:", UIUtil.ComponentStyle.SMALL);
- IJSwingUtilities.adjustComponentsOnMac(typeLabel, myTypeEditor);
- typePanel.add(typeLabel);
- typePanel.add(myTypeEditor);
myTypeEditor.setPreferredWidth(t.getWidth() / 2);
- myTypeEditor.addDocumentListener(new MyDocumentListener(0));
- add(typePanel, BorderLayout.WEST);
+ myTypeEditor.addDocumentListener(new RowEditorChangeListener(0));
+ add(createLabeledPanel("Type:", myTypeEditor), BorderLayout.WEST);
- final JPanel namePanel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, 4, 2, true, false));
myNameEditor = new EditorTextField(item.parameter.getName(), getProject(), getFileType());
myNameEditor.addDocumentListener(mySignatureUpdater);
- myNameEditor.addDocumentListener(new MyDocumentListener(1));
- final JBLabel nameLabel = new JBLabel("Name:", UIUtil.ComponentStyle.SMALL);
- IJSwingUtilities.adjustComponentsOnMac(nameLabel, myNameEditor);
- namePanel.add(nameLabel);
- namePanel.add(myNameEditor);
- add(namePanel, BorderLayout.CENTER);
+ myNameEditor.addDocumentListener(new RowEditorChangeListener(1));
+ add(createLabeledPanel("Name:", myNameEditor), BorderLayout.CENTER);
new TextFieldCompletionProvider() {
@Override
@@ -377,17 +331,12 @@
if (!item.isEllipsisType() && item.parameter.getOldIndex() == -1) {
final JPanel additionalPanel = new JPanel(new BorderLayout());
- final JPanel defaultValuePanel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, 4, 2, true, false));
final Document doc = PsiDocumentManager.getInstance(getProject()).getDocument(item.defaultValueCodeFragment);
myDefaultValueEditor = new EditorTextField(doc, getProject(), getFileType());
((PsiExpressionCodeFragment)item.defaultValueCodeFragment).setExpectedType(getRowType(item));
- final JBLabel defaultValueLabel = new JBLabel("Default value:", UIUtil.ComponentStyle.SMALL);
- IJSwingUtilities.adjustComponentsOnMac(defaultValueLabel, myDefaultValueEditor);
- defaultValuePanel.add(defaultValueLabel);
- defaultValuePanel.add(myDefaultValueEditor);
myDefaultValueEditor.setPreferredWidth(t.getWidth() / 2);
- myDefaultValueEditor.addDocumentListener(new MyDocumentListener(2));
- additionalPanel.add(defaultValuePanel, BorderLayout.WEST);
+ myDefaultValueEditor.addDocumentListener(new RowEditorChangeListener(2));
+ additionalPanel.add(createLabeledPanel("Default value:", myDefaultValueEditor), BorderLayout.WEST);
if (!isGenerateDelegate()) {
myAnyVar = new JCheckBox("&Use Any Var");
diff --git a/java/java-impl/src/com/intellij/refactoring/convertToInstanceMethod/ConvertToInstanceMethodProcessor.java b/java/java-impl/src/com/intellij/refactoring/convertToInstanceMethod/ConvertToInstanceMethodProcessor.java
index 34c4308..c3a8d72 100644
--- a/java/java-impl/src/com/intellij/refactoring/convertToInstanceMethod/ConvertToInstanceMethodProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/convertToInstanceMethod/ConvertToInstanceMethodProcessor.java
@@ -187,7 +187,7 @@
myTypeParameterReplacements = buildTypeParameterReplacements();
List<PsiClass> inheritors = new ArrayList<PsiClass>();
- RefactoringUtil.sortDepthFirstRightLeftOrder(usages);
+ CommonRefactoringUtil.sortDepthFirstRightLeftOrder(usages);
// Process usages
for (final UsageInfo usage : usages) {
diff --git a/java/java-impl/src/com/intellij/refactoring/copy/CopyClassesHandler.java b/java/java-impl/src/com/intellij/refactoring/copy/CopyClassesHandler.java
index a081ff2..b6e3be4 100644
--- a/java/java-impl/src/com/intellij/refactoring/copy/CopyClassesHandler.java
+++ b/java/java-impl/src/com/intellij/refactoring/copy/CopyClassesHandler.java
@@ -37,6 +37,7 @@
import com.intellij.refactoring.RefactoringBundle;
import com.intellij.refactoring.move.moveClassesOrPackages.MoveDirectoryWithClassesProcessor;
import com.intellij.util.ArrayUtil;
+import com.intellij.util.ArrayUtilRt;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -183,14 +184,16 @@
String className = null;
boolean openInEditor = true;
if (copyOneClass(classes)) {
- final String commonPath = ArrayUtil.find(elements, classes.values().iterator().next()) == -1 ? normalizeRelativeMap(relativePathsMap) : null;
+ final String commonPath =
+ ArrayUtilRt.find(elements, classes.values().iterator().next()) == -1 ? normalizeRelativeMap(relativePathsMap) : null;
CopyClassDialog dialog = new CopyClassDialog(classes.values().iterator().next()[0], defaultTargetDirectory, project, false){
@Override
protected String getQualifiedName() {
- if (commonPath != null && !commonPath.isEmpty()) {
- return StringUtil.getQualifiedName(super.getQualifiedName(), commonPath.replaceAll("/", "."));
+ final String qualifiedName = super.getQualifiedName();
+ if (commonPath != null && !commonPath.isEmpty() && !qualifiedName.endsWith(commonPath)) {
+ return StringUtil.getQualifiedName(qualifiedName, commonPath.replaceAll("/", "."));
}
- return super.getQualifiedName();
+ return qualifiedName;
}
};
dialog.setTitle(RefactoringBundle.message("copy.handler.copy.class"));
diff --git a/java/java-impl/src/com/intellij/refactoring/encapsulateFields/EncapsulateFieldsProcessor.java b/java/java-impl/src/com/intellij/refactoring/encapsulateFields/EncapsulateFieldsProcessor.java
index 180e28d..fc87374 100644
--- a/java/java-impl/src/com/intellij/refactoring/encapsulateFields/EncapsulateFieldsProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/encapsulateFields/EncapsulateFieldsProcessor.java
@@ -299,7 +299,7 @@
for (List<MyUsageInfo> usageInfos : usagesInFiles.values()) {
//this is to avoid elements to become invalid as a result of processUsage
final MyUsageInfo[] infos = usageInfos.toArray(new MyUsageInfo[usageInfos.size()]);
- RefactoringUtil.sortDepthFirstRightLeftOrder(infos);
+ CommonRefactoringUtil.sortDepthFirstRightLeftOrder(infos);
for (MyUsageInfo info : infos) {
processUsage(info);
diff --git a/java/java-impl/src/com/intellij/refactoring/inline/InlineLocalHandler.java b/java/java-impl/src/com/intellij/refactoring/inline/InlineLocalHandler.java
index 3171175..41aa79b 100644
--- a/java/java-impl/src/com/intellij/refactoring/inline/InlineLocalHandler.java
+++ b/java/java-impl/src/com/intellij/refactoring/inline/InlineLocalHandler.java
@@ -42,10 +42,8 @@
import com.intellij.refactoring.util.CommonRefactoringUtil;
import com.intellij.refactoring.util.InlineUtil;
import com.intellij.refactoring.util.RefactoringMessageDialog;
-import com.intellij.util.ArrayUtil;
-import com.intellij.util.IncorrectOperationException;
-import com.intellij.util.Processor;
-import com.intellij.util.Query;
+import com.intellij.util.*;
+import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -195,7 +193,7 @@
}
}
- final PsiElement writeAccess = checkRefsInAugmentedAssignmentOrUnaryModified(refsToInline);
+ final PsiElement writeAccess = checkRefsInAugmentedAssignmentOrUnaryModified(refsToInline, defToInline);
if (writeAccess != null) {
HighlightManager.getInstance(project).addOccurrenceHighlights(editor, new PsiElement[]{writeAccess}, writeAttributes, true, null);
String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("variable.is.accessed.for.writing", localName));
@@ -234,10 +232,11 @@
final Runnable runnable = new Runnable() {
public void run() {
try{
- PsiExpression[] exprs = new PsiExpression[refsToInline.length];
+ SmartPsiElementPointer<PsiExpression>[] exprs = new SmartPsiElementPointer[refsToInline.length];
+ final SmartPointerManager pointerManager = SmartPointerManager.getInstance(project);
for(int idx = 0; idx < refsToInline.length; idx++){
PsiJavaCodeReferenceElement refElement = (PsiJavaCodeReferenceElement)refsToInline[idx];
- exprs[idx] = InlineUtil.inlineVariable(local, defToInline, refElement);
+ exprs[idx] = pointerManager.createSmartPsiElementPointer(InlineUtil.inlineVariable(local, defToInline, refElement));
}
if (!isInliningVariableInitializer(defToInline)) {
@@ -251,12 +250,17 @@
}
if (editor != null && !ApplicationManager.getApplication().isUnitTestMode()) {
- highlightManager.addOccurrenceHighlights(editor, exprs, attributes, true, null);
+ highlightManager.addOccurrenceHighlights(editor, ContainerUtil.convert(exprs, new PsiExpression[refsToInline.length], new Function<SmartPsiElementPointer<PsiExpression>, PsiExpression>() {
+ @Override
+ public PsiExpression fun(SmartPsiElementPointer<PsiExpression> pointer) {
+ return pointer.getElement();
+ }
+ }), attributes, true, null);
WindowManager.getInstance().getStatusBar(project).setInfo(RefactoringBundle.message("press.escape.to.remove.the.highlighting"));
}
- for (final PsiExpression expr : exprs) {
- InlineUtil.tryToInlineArrayCreationForVarargs(expr);
+ for (final SmartPsiElementPointer<PsiExpression> expr : exprs) {
+ InlineUtil.tryToInlineArrayCreationForVarargs(expr.getElement());
}
}
catch (IncorrectOperationException e){
@@ -273,12 +277,13 @@
}
@Nullable
- public static PsiElement checkRefsInAugmentedAssignmentOrUnaryModified(final PsiElement[] refsToInline) {
+ public static PsiElement checkRefsInAugmentedAssignmentOrUnaryModified(final PsiElement[] refsToInline, PsiElement defToInline) {
for (PsiElement element : refsToInline) {
PsiElement parent = element.getParent();
if (parent instanceof PsiArrayAccessExpression) {
if (((PsiArrayAccessExpression)parent).getIndexExpression() == element) continue;
+ if (defToInline instanceof PsiExpression && !(defToInline instanceof PsiNewExpression)) continue;
element = parent;
parent = parent.getParent();
}
diff --git a/java/java-impl/src/com/intellij/refactoring/inline/InlineMethodProcessor.java b/java/java-impl/src/com/intellij/refactoring/inline/InlineMethodProcessor.java
index 1659cac..a82994d 100644
--- a/java/java-impl/src/com/intellij/refactoring/inline/InlineMethodProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/inline/InlineMethodProcessor.java
@@ -404,7 +404,7 @@
}
}
else {
- RefactoringUtil.sortDepthFirstRightLeftOrder(usages);
+ CommonRefactoringUtil.sortDepthFirstRightLeftOrder(usages);
if (myMethod.isConstructor()) {
for (UsageInfo usage : usages) {
PsiElement element = usage.getElement();
diff --git a/java/java-impl/src/com/intellij/refactoring/inline/InlineParameterHandler.java b/java/java-impl/src/com/intellij/refactoring/inline/InlineParameterHandler.java
index e22f0b8..58d4d1e 100644
--- a/java/java-impl/src/com/intellij/refactoring/inline/InlineParameterHandler.java
+++ b/java/java-impl/src/com/intellij/refactoring/inline/InlineParameterHandler.java
@@ -125,7 +125,7 @@
if (rExpr != null) {
final PsiElement[] refs = DefUseUtil.getRefs(codeBlock, psiParameter, refExpr);
- if (InlineLocalHandler.checkRefsInAugmentedAssignmentOrUnaryModified(refs) == null) {
+ if (InlineLocalHandler.checkRefsInAugmentedAssignmentOrUnaryModified(refs, def) == null) {
new WriteCommandAction(project) {
@Override
protected void run(Result result) throws Throwable {
diff --git a/java/java-impl/src/com/intellij/refactoring/inlineSuperClass/InlineSuperClassRefactoringProcessor.java b/java/java-impl/src/com/intellij/refactoring/inlineSuperClass/InlineSuperClassRefactoringProcessor.java
index 818b8c3..ab340a5 100644
--- a/java/java-impl/src/com/intellij/refactoring/inlineSuperClass/InlineSuperClassRefactoringProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/inlineSuperClass/InlineSuperClassRefactoringProcessor.java
@@ -32,10 +32,7 @@
import com.intellij.refactoring.inlineSuperClass.usageInfo.*;
import com.intellij.refactoring.memberPushDown.PushDownConflicts;
import com.intellij.refactoring.memberPushDown.PushDownProcessor;
-import com.intellij.refactoring.util.DocCommentPolicy;
-import com.intellij.refactoring.util.FixableUsageInfo;
-import com.intellij.refactoring.util.FixableUsagesRefactoringProcessor;
-import com.intellij.refactoring.util.RefactoringUtil;
+import com.intellij.refactoring.util.*;
import com.intellij.refactoring.util.classMembers.MemberInfo;
import com.intellij.refactoring.util.classMembers.MemberInfoStorage;
import com.intellij.usageView.UsageInfo;
@@ -290,7 +287,7 @@
} else {
super.performRefactoring(pushDownUsages);
}
- RefactoringUtil.sortDepthFirstRightLeftOrder(usages);
+ CommonRefactoringUtil.sortDepthFirstRightLeftOrder(usages);
for (UsageInfo usageInfo : usages) {
if (!(usageInfo instanceof ReplaceExtendsListUsageInfo || usageInfo instanceof RemoveImportUsageInfo)) {
try {
diff --git a/java/java-impl/src/com/intellij/refactoring/introduceParameter/IntroduceParameterProcessor.java b/java/java-impl/src/com/intellij/refactoring/introduceParameter/IntroduceParameterProcessor.java
index 8f0f5fb..ba3ba8a 100644
--- a/java/java-impl/src/com/intellij/refactoring/introduceParameter/IntroduceParameterProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/introduceParameter/IntroduceParameterProcessor.java
@@ -382,7 +382,7 @@
}
ChangeContextUtil.clearContextInfo(myParameterInitializer);
- // Replacing expression occurences
+ // Replacing expression occurrences
for (UsageInfo usage : usages) {
if (usage instanceof ChangedMethodCallInfo) {
PsiElement element = usage.getElement();
diff --git a/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java b/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java
index 740c2cc..9d64136 100644
--- a/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java
+++ b/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java
@@ -134,12 +134,18 @@
}
else {
int selection;
- PsiExpression expression = expressions.get(0);
- if (expression instanceof PsiReferenceExpression && ((PsiReferenceExpression)expression).resolve() instanceof PsiLocalVariable) {
- selection = 1;
- }
- else {
- selection = -1;
+ if (statementsInRange.length == 1 &&
+ statementsInRange[0] instanceof PsiExpressionStatement &&
+ PsiUtilCore.hasErrorElementChild(statementsInRange[0])) {
+ selection = expressions.indexOf(((PsiExpressionStatement)statementsInRange[0]).getExpression());
+ } else {
+ PsiExpression expression = expressions.get(0);
+ if (expression instanceof PsiReferenceExpression && ((PsiReferenceExpression)expression).resolve() instanceof PsiLocalVariable) {
+ selection = 1;
+ }
+ else {
+ selection = -1;
+ }
}
IntroduceTargetChooser.showChooser(editor, expressions,
new Pass<PsiExpression>(){
diff --git a/java/java-impl/src/com/intellij/refactoring/introduceVariable/JavaVariableInplaceIntroducer.java b/java/java-impl/src/com/intellij/refactoring/introduceVariable/JavaVariableInplaceIntroducer.java
index eb5938c..c3562db 100644
--- a/java/java-impl/src/com/intellij/refactoring/introduceVariable/JavaVariableInplaceIntroducer.java
+++ b/java/java-impl/src/com/intellij/refactoring/introduceVariable/JavaVariableInplaceIntroducer.java
@@ -20,6 +20,7 @@
import com.intellij.openapi.actionSystem.Shortcut;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.WriteCommandAction;
+import com.intellij.openapi.command.impl.StartMarkAction;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.RangeMarker;
@@ -29,9 +30,11 @@
import com.intellij.openapi.keymap.KeymapUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Comparing;
+import com.intellij.openapi.vfs.ReadonlyStatusHandler;
import com.intellij.psi.*;
import com.intellij.psi.codeStyle.CodeStyleManager;
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
+import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
import com.intellij.psi.scope.processor.VariablesProcessor;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.TypeConversionUtil;
@@ -105,6 +108,11 @@
}
@Override
+ protected StartMarkAction startRename() throws StartMarkAction.AlreadyStartedException {
+ return StartMarkAction.start(myEditor, myProject, getCommandName());
+ }
+
+ @Override
protected void beforeTemplateStart() {
super.beforeTemplateStart();
final ResolveSnapshotProvider resolveSnapshotProvider = VariableInplaceRenamer.INSTANCE.forLanguage(myScope.getLanguage());
@@ -169,6 +177,7 @@
myEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
}
if (myExpressionText != null) {
+ if (!ReadonlyStatusHandler.ensureDocumentWritable(myProject, InjectedLanguageUtil.getTopLevelEditor(myEditor).getDocument())) return;
ApplicationManager.getApplication().runWriteAction(new Runnable() {
public void run() {
final PsiDeclarationStatement element = myPointer.getElement();
diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveJavaFileHandler.java b/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveJavaFileHandler.java
index 530660b..de994d9 100644
--- a/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveJavaFileHandler.java
+++ b/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveJavaFileHandler.java
@@ -94,7 +94,8 @@
final PsiPackage aPackage = JavaDirectoryService.getInstance().getPackage(containingDirectory);
if (aPackage != null) {
final String qualifiedName = aPackage.getQualifiedName();
- final PsiPackageStatement packageStatement = qualifiedName.length() > 0
+ final PsiNameHelper helper = JavaPsiFacade.getInstance(file.getProject()).getNameHelper();
+ final PsiPackageStatement packageStatement = !StringUtil.isEmptyOrSpaces(qualifiedName) && helper.isQualifiedName(qualifiedName)
? JavaPsiFacade.getElementFactory(file.getProject()).createPackageStatement(qualifiedName)
: null;
if (file instanceof PsiJavaFile) {
diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerImpl.java b/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerImpl.java
index fe37b7d..c33cc48 100644
--- a/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerImpl.java
+++ b/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerImpl.java
@@ -34,14 +34,16 @@
public static final String REFACTORING_NAME = RefactoringBundle.message("move.inner.to.upper.level.title");
- public static void doMove(final Project project, PsiElement[] elements, final MoveCallback moveCallback) {
+ public static void doMove(final Project project, PsiElement[] elements, final MoveCallback moveCallback, @Nullable PsiElement targetContainer) {
if (elements.length != 1) return;
final PsiClass aClass = (PsiClass) elements[0];
boolean condition = aClass.getContainingClass() != null;
LOG.assertTrue(condition);
if (!CommonRefactoringUtil.checkReadOnlyStatus(project, aClass)) return;
- final PsiElement targetContainer = getTargetContainer(aClass, true);
+ if (targetContainer == null) {
+ targetContainer = getTargetContainer(aClass, true);
+ }
if (targetContainer == null) return;
final MoveInnerDialog dialog = new MoveInnerDialog(
diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerProcessor.java b/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerProcessor.java
index 35ca3e2..ddff1f0 100644
--- a/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerProcessor.java
@@ -164,7 +164,7 @@
if (myParameterNameOuterClass != null) {
// pass outer as a parameter
field = factory.createField(myFieldNameOuterClass, factory.createType(myOuterClass));
- field = (PsiField)myInnerClass.add(field);
+ field = addOuterField(field);
myInnerClass = field.getContainingClass();
addFieldInitializationToConstructors(myInnerClass, field, myParameterNameOuterClass);
}
@@ -296,6 +296,19 @@
}
}
+ private PsiField addOuterField(PsiField field) {
+ final PsiMember[] members = PsiTreeUtil.getChildrenOfType(myInnerClass, PsiMember.class);
+ if (members != null) {
+ for (PsiMember member : members) {
+ if (!member.hasModifierProperty(PsiModifier.STATIC)) {
+ return (PsiField)myInnerClass.addBefore(field, member);
+ }
+ }
+ }
+
+ return (PsiField)myInnerClass.add(field);
+ }
+
protected void performPsiSpoilingRefactoring() {
if (myNonCodeUsages != null) {
RenameUtil.renameNonCodeUsages(myProject, myNonCodeUsages);
diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerToUpperHandler.java b/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerToUpperHandler.java
index f807e89..706fc79 100644
--- a/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerToUpperHandler.java
+++ b/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerToUpperHandler.java
@@ -17,6 +17,7 @@
import com.intellij.featureStatistics.FeatureUsageTracker;
import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiClass;
@@ -35,9 +36,7 @@
public boolean canMove(final PsiElement[] elements, @Nullable final PsiElement targetContainer) {
if (elements.length != 1) return false;
PsiElement element = elements [0];
- return isNonStaticInnerClass(element) &&
- (targetContainer == null || targetContainer.equals(MoveInnerImpl.getTargetContainer((PsiClass)elements[0], false)));
-
+ return isNonStaticInnerClass(element);
}
private static boolean isNonStaticInnerClass(final PsiElement element) {
@@ -46,7 +45,7 @@
}
public void doMove(final Project project, final PsiElement[] elements, final PsiElement targetContainer, final MoveCallback callback) {
- MoveInnerImpl.doMove(project, elements, callback);
+ MoveInnerImpl.doMove(project, elements, callback, targetContainer);
}
public boolean tryToMove(final PsiElement element, final Project project, final DataContext dataContext, final PsiReference reference,
@@ -60,7 +59,7 @@
RefactoringBundle.message("move.title"), null);
return true;
}
- MoveInnerImpl.doMove(project, new PsiElement[]{aClass}, null);
+ MoveInnerImpl.doMove(project, new PsiElement[]{aClass}, null, LangDataKeys.TARGET_PSI_ELEMENT.getData(dataContext));
return true;
}
return false;
diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerToUpperOrMembersHandler.java b/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerToUpperOrMembersHandler.java
index 823ee22..2ad1d53 100644
--- a/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerToUpperOrMembersHandler.java
+++ b/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerToUpperOrMembersHandler.java
@@ -17,6 +17,7 @@
import com.intellij.featureStatistics.FeatureUsageTracker;
import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
@@ -39,8 +40,7 @@
public boolean canMove(final PsiElement[] elements, @Nullable final PsiElement targetContainer) {
if (elements.length != 1) return false;
PsiElement element = elements [0];
- return isStaticInnerClass(element) &&
- (targetContainer == null || targetContainer.equals(MoveInnerImpl.getTargetContainer((PsiClass)elements[0], false)));
+ return isStaticInnerClass(element);
}
private static boolean isStaticInnerClass(final PsiElement element) {
@@ -64,13 +64,14 @@
final Editor editor) {
if (isStaticInnerClass(element) && !JavaMoveClassesOrPackagesHandler.isReferenceInAnonymousClass(reference)) {
FeatureUsageTracker.getInstance().triggerFeatureUsed("refactoring.move.moveInner");
+ final PsiElement targetContainer = LangDataKeys.TARGET_PSI_ELEMENT.getData(dataContext);
PsiClass aClass = (PsiClass) element;
SelectInnerOrMembersRefactoringDialog dialog = new SelectInnerOrMembersRefactoringDialog(aClass, project);
dialog.show();
if (dialog.isOK()) {
final MoveHandlerDelegate moveHandlerDelegate = dialog.getRefactoringHandler();
if (moveHandlerDelegate != null) {
- moveHandlerDelegate.doMove(project, new PsiElement[] { aClass }, null, null);
+ moveHandlerDelegate.doMove(project, new PsiElement[] { aClass }, targetContainer, null);
}
}
return true;
diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveJavaMemberHandler.java b/java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveJavaMemberHandler.java
index ea39904..4dda4d7 100644
--- a/java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveJavaMemberHandler.java
+++ b/java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveJavaMemberHandler.java
@@ -193,7 +193,7 @@
}
}
else { // no qualifier
- if (usage.qualifierClass != null && PsiTreeUtil.getParentOfType(refExpr, PsiSwitchLabelStatement.class) == null) {
+ if (usage.qualifierClass != null && (!usage.qualifierClass.isEnum() || PsiTreeUtil.getParentOfType(refExpr, PsiSwitchLabelStatement.class) == null)) {
changeQualifier(refExpr, usage.qualifierClass, usage.member);
}
}
diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveMembersProcessor.java b/java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveMembersProcessor.java
index 3f4f59a..cc594a3 100644
--- a/java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveMembersProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveMembersProcessor.java
@@ -116,7 +116,7 @@
PsiElement ref = psiReference.getElement();
final MoveMemberHandler handler = MoveMemberHandler.EP_NAME.forLanguage(ref.getLanguage());
MoveMembersUsageInfo usage = null;
- if (handler != null) {
+ if (handler != null && myTargetClass != null) {
usage = handler.getUsage(member, psiReference, myMembersToMove, myTargetClass);
}
if (usage != null) {
diff --git a/java/java-impl/src/com/intellij/refactoring/rename/RenameJavaVariableProcessor.java b/java/java-impl/src/com/intellij/refactoring/rename/RenameJavaVariableProcessor.java
index 7e485dc..8c2f688 100644
--- a/java/java-impl/src/com/intellij/refactoring/rename/RenameJavaVariableProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/rename/RenameJavaVariableProcessor.java
@@ -15,6 +15,7 @@
*/
package com.intellij.refactoring.rename;
+import com.intellij.codeInsight.generation.GetterSetterPrototypeProvider;
import com.intellij.lang.StdLanguages;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
@@ -43,10 +44,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
public class RenameJavaVariableProcessor extends RenameJavaMemberProcessor {
private static final Logger LOG = Logger.getInstance("#com.intellij.refactoring.rename.RenameJavaVariableProcessor");
@@ -150,7 +148,9 @@
String newPropertyName = manager.variableNameToPropertyName(newName, VariableKind.FIELD);
boolean isStatic = field.hasModifierProperty(PsiModifier.STATIC);
- PsiMethod getter = PropertyUtil.findPropertyGetter(aClass, propertyName, isStatic, false);
+
+ PsiMethod[] getters = GetterSetterPrototypeProvider.findGetters(aClass, propertyName, isStatic);
+
PsiMethod setter = PropertyUtil.findPropertySetter(aClass, propertyName, isStatic, false);
boolean shouldRenameSetterParameter = false;
@@ -161,22 +161,31 @@
shouldRenameSetterParameter = parameterName.equals(setterParameter.getName());
}
- String newGetterName = "";
-
- if (getter != null) {
- String getterId = getter.getName();
- newGetterName = PropertyUtil.suggestGetterName(newPropertyName, field.getType(), getterId);
- if (newGetterName.equals(getterId)) {
- getter = null;
- newGetterName = null;
- } else {
- for (PsiMethod method : getter.findDeepestSuperMethods()) {
- if (method instanceof PsiCompiledElement) {
- getter = null;
- break;
- }
+ if (getters != null) {
+ List<PsiMethod> validGetters = new ArrayList<PsiMethod>();
+ for (PsiMethod getter : getters) {
+ String newGetterName = GetterSetterPrototypeProvider.suggestNewGetterName(propertyName, newPropertyName, getter);
+ String getterId = null;
+ if (newGetterName == null) {
+ getterId = getter.getName();
+ newGetterName = PropertyUtil.suggestGetterName(newPropertyName, field.getType(), getterId);
}
+ if (newGetterName.equals(getterId)) {
+ continue;
+ }
+ else {
+ boolean valid = true;
+ for (PsiMethod method : getter.findDeepestSuperMethods()) {
+ if (method instanceof PsiCompiledElement) {
+ valid = false;
+ break;
+ }
+ }
+ if (!valid) continue;
+ }
+ validGetters.add(getter);
}
+ getters = validGetters.isEmpty() ? null : validGetters.toArray(new PsiMethod[validGetters.size()]);
}
String newSetterName = "";
@@ -201,14 +210,20 @@
}
}
- if ((getter != null || setter != null) && askToRenameAccesors(getter, setter, newName, project)) {
- getter = null;
+ if ((getters != null || setter != null) && askToRenameAccesors(getters != null ? getters[0] : null, setter, newName, project)) {
+ getters = null;
setter = null;
shouldRenameSetterParameter = false;
}
- if (getter != null) {
- addOverriddenAndImplemented(getter, newGetterName, allRenames);
+ if (getters != null) {
+ for (PsiMethod getter : getters) {
+ String newGetterName = GetterSetterPrototypeProvider.suggestNewGetterName(propertyName, newPropertyName, getter);
+ if (newGetterName == null) {
+ newGetterName = PropertyUtil.suggestGetterName(newPropertyName, field.getType(), getter.getName());
+ }
+ addOverriddenAndImplemented(getter, newGetterName, allRenames);
+ }
}
if (setter != null) {
diff --git a/java/java-impl/src/com/intellij/refactoring/safeDelete/JavaSafeDeleteProcessor.java b/java/java-impl/src/com/intellij/refactoring/safeDelete/JavaSafeDeleteProcessor.java
index 7f8ae6d..ac7a6d9 100644
--- a/java/java-impl/src/com/intellij/refactoring/safeDelete/JavaSafeDeleteProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/safeDelete/JavaSafeDeleteProcessor.java
@@ -16,6 +16,7 @@
package com.intellij.refactoring.safeDelete;
import com.intellij.codeInsight.daemon.impl.quickfix.RemoveUnusedVariableUtil;
+import com.intellij.codeInsight.generation.GetterSetterPrototypeProvider;
import com.intellij.find.findUsages.PsiElement2UsageTargetAdapter;
import com.intellij.ide.util.SuperMethodWarningUtil;
import com.intellij.openapi.application.ApplicationManager;
@@ -187,21 +188,30 @@
PsiClass aClass = field.getContainingClass();
if (aClass != null) {
boolean isStatic = field.hasModifierProperty(PsiModifier.STATIC);
- PsiMethod getter = PropertyUtil.findPropertyGetter(aClass, propertyName, isStatic, false);
- if (allElementsToDelete.contains(getter) || getter != null && !getter.isPhysical()) getter = null;
+ PsiMethod[] getters = GetterSetterPrototypeProvider.findGetters(aClass, propertyName, isStatic);
+ if (getters != null) {
+ final List<PsiMethod> validGetters = new ArrayList<PsiMethod>(1);
+ for (PsiMethod getter : getters) {
+ if (!allElementsToDelete.contains(getter) && (getter != null && getter.isPhysical())) {
+ validGetters.add(getter);
+ }
+ }
+ getters = validGetters.isEmpty() ? null : validGetters.toArray(new PsiMethod[validGetters.size()]);
+ }
+
PsiMethod setter = PropertyUtil.findPropertySetter(aClass, propertyName, isStatic, false);
if (allElementsToDelete.contains(setter) || setter != null && !setter.isPhysical()) setter = null;
- if (askUser && (getter != null || setter != null)) {
+ if (askUser && (getters != null || setter != null)) {
final String message =
- RefactoringMessageUtil.getGetterSetterMessage(field.getName(), RefactoringBundle.message("delete.title"), getter, setter);
- if (Messages.showYesNoDialog(project, message, RefactoringBundle.message("safe.delete.title"), Messages.getQuestionIcon()) != 0) {
- getter = null;
+ RefactoringMessageUtil.getGetterSetterMessage(field.getName(), RefactoringBundle.message("delete.title"), getters != null ? getters[0] : null, setter);
+ if (!ApplicationManager.getApplication().isUnitTestMode() && Messages.showYesNoDialog(project, message, RefactoringBundle.message("safe.delete.title"), Messages.getQuestionIcon()) != 0) {
+ getters = null;
setter = null;
}
}
List<PsiElement> elements = new ArrayList<PsiElement>();
if (setter != null) elements.add(setter);
- if (getter != null) elements.add(getter);
+ if (getters != null) Collections.addAll(elements, getters);
return elements;
}
}
diff --git a/java/java-impl/src/com/intellij/refactoring/turnRefsToSuper/TurnRefsToSuperProcessorBase.java b/java/java-impl/src/com/intellij/refactoring/turnRefsToSuper/TurnRefsToSuperProcessorBase.java
index 45b0b1a..53c1b70 100644
--- a/java/java-impl/src/com/intellij/refactoring/turnRefsToSuper/TurnRefsToSuperProcessorBase.java
+++ b/java/java-impl/src/com/intellij/refactoring/turnRefsToSuper/TurnRefsToSuperProcessorBase.java
@@ -451,7 +451,6 @@
else if (declScope instanceof PsiForeachStatement) {
final PsiExpression iteratedValue = ((PsiForeachStatement)declScope).getIteratedValue();
addLink(type, iteratedValue);
- addLink(iteratedValue, type);
}
else if (declScope instanceof PsiMethod) {
final PsiMethod method = (PsiMethod)declScope;
diff --git a/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationLabeler.java b/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationLabeler.java
index b0c8fea..1060495 100644
--- a/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationLabeler.java
+++ b/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationLabeler.java
@@ -96,13 +96,12 @@
final PsiElement element = p.getFirst().retrieve();
LOG.assertTrue(element != null);
final PsiType type = ((PsiExpression)element).getType();
- report[j++] = "Cannot convert type of expression <b>" +
- StringUtil.escapeXml(element.getText()) +
- "</b>" +
- " from <b>" +
- StringUtil.escapeXml(type.getCanonicalText()) +
- "</b> to <b>" + StringUtil.escapeXml(p.getSecond().getCanonicalText()) +
- "</b><br>";
+ report[j++] = "Cannot convert type of expression <b>" + StringUtil.escapeXml(element.getText()) + "</b>" +
+ (type != null
+ ? " from <b>" + StringUtil.escapeXml(type.getCanonicalText()) + "</b>" +
+ " to <b>" + StringUtil.escapeXml(p.getSecond().getCanonicalText()) + "</b>"
+ : "")
+ + "<br>";
}
return report;
@@ -539,7 +538,6 @@
}
void markFailedConversion(final Pair<PsiType, PsiType> typePair, final PsiExpression expression) {
- LOG.assertTrue(expression.getType() != null);
LOG.assertTrue(typePair.getSecond() != null);
myFailedConversions.add(new Pair<PsiAnchor, PsiType>(PsiAnchor.create(expression), typePair.getSecond()));
}
diff --git a/java/java-impl/src/com/intellij/refactoring/util/FixableUsagesRefactoringProcessor.java b/java/java-impl/src/com/intellij/refactoring/util/FixableUsagesRefactoringProcessor.java
index 2c5fc9f..4ad49a9 100644
--- a/java/java-impl/src/com/intellij/refactoring/util/FixableUsagesRefactoringProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/util/FixableUsagesRefactoringProcessor.java
@@ -38,7 +38,7 @@
}
protected void performRefactoring(UsageInfo[] usageInfos) {
- RefactoringUtil.sortDepthFirstRightLeftOrder(usageInfos);
+ CommonRefactoringUtil.sortDepthFirstRightLeftOrder(usageInfos);
for (UsageInfo usageInfo : usageInfos) {
if (usageInfo instanceof FixableUsageInfo) {
try {
diff --git a/java/java-impl/src/com/intellij/refactoring/util/RefactoringUtil.java b/java/java-impl/src/com/intellij/refactoring/util/RefactoringUtil.java
index 80a4a91..ca905b0 100644
--- a/java/java-impl/src/com/intellij/refactoring/util/RefactoringUtil.java
+++ b/java/java-impl/src/com/intellij/refactoring/util/RefactoringUtil.java
@@ -172,22 +172,6 @@
}
}
- //order of usages accross different files is irrelevant
- public static void sortDepthFirstRightLeftOrder(final UsageInfo[] usages) {
- Arrays.sort(usages, new Comparator<UsageInfo>() {
- public int compare(final UsageInfo usage1, final UsageInfo usage2) {
- final PsiElement element1 = usage1.getElement();
- final PsiElement element2 = usage2.getElement();
- if (element1 == null) {
- if (element2 == null) return 0;
- return 1;
- }
- if (element2 == null) return -1;
- return element2.getTextRange().getStartOffset() - element1.getTextRange().getStartOffset();
- }
- });
- }
-
@Nullable
public static String suggestNewOverriderName(String oldOverriderName, String oldBaseName, String newBaseName) {
if (oldOverriderName.equals(oldBaseName)) {
diff --git a/java/java-indexing-api/src/com/intellij/psi/search/PsiShortNamesCache.java b/java/java-indexing-api/src/com/intellij/psi/search/PsiShortNamesCache.java
index b85bd97..38465bd 100644
--- a/java/java-indexing-api/src/com/intellij/psi/search/PsiShortNamesCache.java
+++ b/java/java-indexing-api/src/com/intellij/psi/search/PsiShortNamesCache.java
@@ -21,6 +21,7 @@
import com.intellij.psi.*;
import com.intellij.util.ArrayUtil;
import com.intellij.util.Processor;
+import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.HashSet;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -84,6 +85,10 @@
@NotNull
public abstract String[] getAllClassNames();
+ public boolean processAllClassNames(Processor<String> processor) {
+ return ContainerUtil.process(getAllClassNames(), processor);
+ }
+
/**
* Adds the names of all classes in the project and (optionally) libraries
* to the specified set.
diff --git a/java/java-indexing-impl/src/com/intellij/psi/impl/CompositeShortNamesCache.java b/java/java-indexing-impl/src/com/intellij/psi/impl/CompositeShortNamesCache.java
index 269006b..52d5801 100644
--- a/java/java-indexing-impl/src/com/intellij/psi/impl/CompositeShortNamesCache.java
+++ b/java/java-indexing-impl/src/com/intellij/psi/impl/CompositeShortNamesCache.java
@@ -23,6 +23,7 @@
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.PsiShortNamesCache;
import com.intellij.util.ArrayUtil;
+import com.intellij.util.CommonProcessors;
import com.intellij.util.Processor;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.HashSet;
@@ -94,6 +95,17 @@
}
@Override
+ public boolean processAllClassNames(Processor<String> processor) {
+ CommonProcessors.UniqueProcessor<String> uniqueProcessor = new CommonProcessors.UniqueProcessor<String>(processor);
+ for (PsiShortNamesCache cache : myCaches) {
+ if (!cache.processAllClassNames(uniqueProcessor)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
public void getAllClassNames(@NotNull HashSet<String> dest) {
for (PsiShortNamesCache cache : myCaches) {
cache.getAllClassNames(dest);
diff --git a/java/java-indexing-impl/src/com/intellij/psi/impl/PsiShortNamesCacheImpl.java b/java/java-indexing-impl/src/com/intellij/psi/impl/PsiShortNamesCacheImpl.java
index 215c9eb..b17c4b1 100644
--- a/java/java-indexing-impl/src/com/intellij/psi/impl/PsiShortNamesCacheImpl.java
+++ b/java/java-indexing-impl/src/com/intellij/psi/impl/PsiShortNamesCacheImpl.java
@@ -101,13 +101,17 @@
@Override
@NotNull
public String[] getAllClassNames() {
- final Collection<String> names = JavaShortClassNameIndex.getInstance().getAllKeys(myManager.getProject());
- return ArrayUtil.toStringArray(names);
+ return ArrayUtil.toStringArray(JavaShortClassNameIndex.getInstance().getAllKeys(myManager.getProject()));
}
@Override
public void getAllClassNames(@NotNull HashSet<String> set) {
- set.addAll(JavaShortClassNameIndex.getInstance().getAllKeys(myManager.getProject()));
+ processAllClassNames(new CommonProcessors.CollectProcessor<String>(set));
+ }
+
+ @Override
+ public boolean processAllClassNames(Processor<String> processor) {
+ return JavaShortClassNameIndex.getInstance().processAllKeys(myManager.getProject(), processor);
}
@Override
@@ -147,13 +151,12 @@
@Override
@NotNull
public String[] getAllMethodNames() {
- final Collection<String> names = JavaMethodNameIndex.getInstance().getAllKeys(myManager.getProject());
- return ArrayUtil.toStringArray(names);
+ return ArrayUtil.toStringArray(JavaMethodNameIndex.getInstance().getAllKeys(myManager.getProject()));
}
@Override
public void getAllMethodNames(@NotNull HashSet<String> set) {
- set.addAll(JavaMethodNameIndex.getInstance().getAllKeys(myManager.getProject()));
+ JavaMethodNameIndex.getInstance().processAllKeys(myManager.getProject(), new CommonProcessors.CollectProcessor<String>(set));
}
@Override
@@ -186,13 +189,12 @@
@Override
@NotNull
public String[] getAllFieldNames() {
- final Collection<String> names = JavaFieldNameIndex.getInstance().getAllKeys(myManager.getProject());
- return ArrayUtil.toStringArray(names);
+ return ArrayUtil.toStringArray(JavaFieldNameIndex.getInstance().getAllKeys(myManager.getProject()));
}
@Override
public void getAllFieldNames(@NotNull HashSet<String> set) {
- set.addAll(JavaFieldNameIndex.getInstance().getAllKeys(myManager.getProject()));
+ JavaFieldNameIndex.getInstance().processAllKeys(myManager.getProject(), new CommonProcessors.CollectProcessor<String>(set));
}
private <T extends PsiMember> List<T> filterMembers(Collection<T> members, final GlobalSearchScope scope) {
diff --git a/java/java-indexing-impl/src/com/intellij/psi/impl/java/stubs/index/JavaAnonymousClassBaseRefOccurenceIndex.java b/java/java-indexing-impl/src/com/intellij/psi/impl/java/stubs/index/JavaAnonymousClassBaseRefOccurenceIndex.java
index 2521522..b2d61c4 100644
--- a/java/java-indexing-impl/src/com/intellij/psi/impl/java/stubs/index/JavaAnonymousClassBaseRefOccurenceIndex.java
+++ b/java/java-indexing-impl/src/com/intellij/psi/impl/java/stubs/index/JavaAnonymousClassBaseRefOccurenceIndex.java
@@ -24,6 +24,7 @@
import com.intellij.psi.impl.search.JavaSourceFilterScope;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.stubs.StringStubIndexExtension;
+import com.intellij.psi.stubs.StubIndex;
import com.intellij.psi.stubs.StubIndexKey;
import org.jetbrains.annotations.NotNull;
@@ -45,6 +46,6 @@
@Override
public Collection<PsiAnonymousClass> get(final String s, final Project project, @NotNull final GlobalSearchScope scope) {
- return super.get(s, project, new JavaSourceFilterScope(scope));
+ return StubIndex.getInstance().safeGet(getKey(), s, project, new JavaSourceFilterScope(scope), PsiAnonymousClass.class);
}
}
\ No newline at end of file
diff --git a/java/java-indexing-impl/src/com/intellij/psi/impl/java/stubs/index/JavaFieldNameIndex.java b/java/java-indexing-impl/src/com/intellij/psi/impl/java/stubs/index/JavaFieldNameIndex.java
index 54eb0ed..e00f2bf 100644
--- a/java/java-indexing-impl/src/com/intellij/psi/impl/java/stubs/index/JavaFieldNameIndex.java
+++ b/java/java-indexing-impl/src/com/intellij/psi/impl/java/stubs/index/JavaFieldNameIndex.java
@@ -24,6 +24,7 @@
import com.intellij.psi.impl.search.JavaSourceFilterScope;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.stubs.StringStubIndexExtension;
+import com.intellij.psi.stubs.StubIndex;
import com.intellij.psi.stubs.StubIndexKey;
import org.jetbrains.annotations.NotNull;
@@ -44,6 +45,6 @@
@Override
public Collection<PsiField> get(final String s, final Project project, @NotNull final GlobalSearchScope scope) {
- return super.get(s, project, new JavaSourceFilterScope(scope));
+ return StubIndex.getInstance().safeGet(getKey(), s, project, new JavaSourceFilterScope(scope), PsiField.class);
}
}
\ No newline at end of file
diff --git a/java/java-indexing-impl/src/com/intellij/psi/impl/java/stubs/index/JavaMethodNameIndex.java b/java/java-indexing-impl/src/com/intellij/psi/impl/java/stubs/index/JavaMethodNameIndex.java
index a92856f..51d28ad 100644
--- a/java/java-indexing-impl/src/com/intellij/psi/impl/java/stubs/index/JavaMethodNameIndex.java
+++ b/java/java-indexing-impl/src/com/intellij/psi/impl/java/stubs/index/JavaMethodNameIndex.java
@@ -24,6 +24,7 @@
import com.intellij.psi.impl.search.JavaSourceFilterScope;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.stubs.StringStubIndexExtension;
+import com.intellij.psi.stubs.StubIndex;
import com.intellij.psi.stubs.StubIndexKey;
import org.jetbrains.annotations.NotNull;
@@ -44,6 +45,6 @@
@Override
public Collection<PsiMethod> get(final String s, final Project project, @NotNull final GlobalSearchScope scope) {
- return super.get(s, project, new JavaSourceFilterScope(scope));
+ return StubIndex.getInstance().safeGet(getKey(), s, project, new JavaSourceFilterScope(scope), PsiMethod.class);
}
}
\ No newline at end of file
diff --git a/java/java-indexing-impl/src/com/intellij/psi/impl/java/stubs/index/JavaSuperClassNameOccurenceIndex.java b/java/java-indexing-impl/src/com/intellij/psi/impl/java/stubs/index/JavaSuperClassNameOccurenceIndex.java
index a70b7ea..e1e8819 100644
--- a/java/java-indexing-impl/src/com/intellij/psi/impl/java/stubs/index/JavaSuperClassNameOccurenceIndex.java
+++ b/java/java-indexing-impl/src/com/intellij/psi/impl/java/stubs/index/JavaSuperClassNameOccurenceIndex.java
@@ -24,6 +24,7 @@
import com.intellij.psi.impl.search.JavaSourceFilterScope;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.stubs.StringStubIndexExtension;
+import com.intellij.psi.stubs.StubIndex;
import com.intellij.psi.stubs.StubIndexKey;
import org.jetbrains.annotations.NotNull;
@@ -45,7 +46,7 @@
@Override
public Collection<PsiReferenceList> get(final String s, final Project project, @NotNull final GlobalSearchScope scope) {
- return super.get(s, project, new JavaSourceFilterScope(scope));
+ return StubIndex.getInstance().safeGet(getKey(), s, project, new JavaSourceFilterScope(scope), PsiReferenceList.class);
}
@Override
diff --git a/java/java-indexing-impl/src/com/intellij/psi/impl/search/AllClassesSearchExecutor.java b/java/java-indexing-impl/src/com/intellij/psi/impl/search/AllClassesSearchExecutor.java
index bae6155..b2e0d84 100644
--- a/java/java-indexing-impl/src/com/intellij/psi/impl/search/AllClassesSearchExecutor.java
+++ b/java/java-indexing-impl/src/com/intellij/psi/impl/search/AllClassesSearchExecutor.java
@@ -22,10 +22,11 @@
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressIndicatorProvider;
+import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Computable;
-import com.intellij.psi.JavaRecursiveElementWalkingVisitor;
-import com.intellij.psi.PsiClass;
-import com.intellij.psi.PsiElement;
+import com.intellij.openapi.util.Key;
+import com.intellij.openapi.util.Pair;
+import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.LocalSearchScope;
import com.intellij.psi.search.PsiShortNamesCache;
@@ -33,14 +34,17 @@
import com.intellij.psi.search.searches.AllClassesSearch;
import com.intellij.util.Processor;
import com.intellij.util.QueryExecutor;
+import com.intellij.util.TimedReference;
import org.jetbrains.annotations.NotNull;
+import java.lang.ref.SoftReference;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public class AllClassesSearchExecutor implements QueryExecutor<PsiClass, AllClassesSearch.SearchParameters> {
+ private static final Key<TimedReference<SoftReference<Pair<String[], Long>>>> ALL_CLASS_NAMES_CACHE = Key.create("ALL_CLASS_NAMES_CACHE");
@Override
public boolean execute(@NotNull final AllClassesSearch.SearchParameters queryParameters, @NotNull final Processor<PsiClass> consumer) {
SearchScope scope = queryParameters.getScope();
@@ -55,17 +59,30 @@
}
return true;
}
-
- private static boolean processAllClassesInGlobalScope(final GlobalSearchScope scope, final Processor<PsiClass> processor, AllClassesSearch.SearchParameters parameters) {
- final PsiShortNamesCache cache = PsiShortNamesCache.getInstance(parameters.getProject());
-
- final String[] names = ApplicationManager.getApplication().runReadAction(new Computable<String[]>() {
+
+ private static String[] getAllClassNames(final Project project) {
+ return ApplicationManager.getApplication().runReadAction(new Computable<String[]>() {
@Override
public String[] compute() {
- return cache.getAllClassNames();
+ final long modCount = PsiManager.getInstance(project).getModificationTracker().getJavaStructureModificationCount();
+ TimedReference<SoftReference<Pair<String[], Long>>> ref1 = project.getUserData(ALL_CLASS_NAMES_CACHE);
+ SoftReference<Pair<String[], Long>> ref2 = ref1 == null ? null : ref1.get();
+ Pair<String[], Long> pair = ref2 == null ? null : ref2.get();
+ if (pair != null && pair.second.equals(modCount)) {
+ return pair.first;
+ }
+
+ String[] names = PsiShortNamesCache.getInstance(project).getAllClassNames();
+ ref1 = new TimedReference<SoftReference<Pair<String[], Long>>>(null);
+ ref1.set(new SoftReference<Pair<String[], Long>>(Pair.create(names, modCount)));
+ project.putUserData(ALL_CLASS_NAMES_CACHE, ref1);
+ return names;
}
});
+ }
+ private static boolean processAllClassesInGlobalScope(final GlobalSearchScope scope, final Processor<PsiClass> processor, final AllClassesSearch.SearchParameters parameters) {
+ String[] names = getAllClassNames(parameters.getProject());
final ProgressIndicator indicator = ProgressIndicatorProvider.getGlobalProgressIndicator();
if (indicator != null) {
indicator.checkCanceled();
@@ -93,6 +110,7 @@
}
});
+ final PsiShortNamesCache cache = PsiShortNamesCache.getInstance(parameters.getProject());
for (final String name : sorted) {
ProgressIndicatorProvider.checkCanceled();
final PsiClass[] classes = ApplicationManager.getApplication().runReadAction(new Computable<PsiClass[]>() {
@@ -111,11 +129,10 @@
return true;
}
- private static boolean processScopeRootForAllClasses(PsiElement scopeRoot, final Processor<PsiClass> processor) {
- if (scopeRoot == null) return true;
- final boolean[] stopped = new boolean[]{false};
+ private static boolean processScopeRootForAllClasses(@NotNull PsiElement scopeRoot, final Processor<PsiClass> processor) {
+ final boolean[] stopped = {false};
- scopeRoot.accept(new JavaRecursiveElementWalkingVisitor() {
+ JavaElementVisitor visitor = scopeRoot instanceof PsiCompiledElement ? new JavaRecursiveElementVisitor() {
@Override
public void visitElement(PsiElement element) {
if (!stopped[0]) {
@@ -123,11 +140,26 @@
}
}
- @Override public void visitClass(PsiClass aClass) {
+ @Override
+ public void visitClass(PsiClass aClass) {
stopped[0] = !processor.process(aClass);
super.visitClass(aClass);
}
- });
+ } : new JavaRecursiveElementWalkingVisitor() {
+ @Override
+ public void visitElement(PsiElement element) {
+ if (!stopped[0]) {
+ super.visitElement(element);
+ }
+ }
+
+ @Override
+ public void visitClass(PsiClass aClass) {
+ stopped[0] = !processor.process(aClass);
+ super.visitClass(aClass);
+ }
+ };
+ scopeRoot.accept(visitor);
return !stopped[0];
}
diff --git a/java/java-psi-api/src/com/intellij/psi/GenericsUtil.java b/java/java-psi-api/src/com/intellij/psi/GenericsUtil.java
index 7c25697..481f809 100644
--- a/java/java-psi-api/src/com/intellij/psi/GenericsUtil.java
+++ b/java/java-psi-api/src/com/intellij/psi/GenericsUtil.java
@@ -23,7 +23,7 @@
import com.intellij.psi.util.InheritanceUtil;
import com.intellij.psi.util.PsiUtil;
import com.intellij.psi.util.TypeConversionUtil;
-import com.intellij.util.containers.*;
+import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.HashMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -39,7 +39,8 @@
private GenericsUtil() {}
- public static PsiType getGreatestLowerBound(PsiType type1, PsiType type2) {
+ public static PsiType getGreatestLowerBound(@Nullable PsiType type1, @Nullable PsiType type2) {
+ if (type1 == null || type2 == null) return null;
return PsiIntersectionType.createIntersection(type1, type2);
}
@@ -185,18 +186,21 @@
public static PsiClass[] getLeastUpperClasses(PsiClass aClass, PsiClass bClass) {
if (InheritanceUtil.isInheritorOrSelf(aClass, bClass, true)) return new PsiClass[]{bClass};
Set<PsiClass> supers = new LinkedHashSet<PsiClass>();
- getLeastUpperClassesInner(aClass, bClass, supers);
+ Set<PsiClass> visited = new HashSet<PsiClass>();
+ getLeastUpperClassesInner(aClass, bClass, supers, visited);
return supers.toArray(new PsiClass[supers.size()]);
}
- private static void getLeastUpperClassesInner(PsiClass aClass, PsiClass bClass, Set<PsiClass> supers) {
+ private static void getLeastUpperClassesInner(PsiClass aClass, PsiClass bClass, Set<PsiClass> supers, Set<PsiClass> visited) {
if (bClass.isInheritor(aClass, true)) {
addSuper(supers, aClass);
}
else {
final PsiClass[] aSupers = aClass.getSupers();
for (PsiClass aSuper : aSupers) {
- getLeastUpperClassesInner(aSuper, bClass, supers);
+ if (visited.add(aSuper)) {
+ getLeastUpperClassesInner(aSuper, bClass, supers, visited);
+ }
}
}
}
diff --git a/java/java-psi-api/src/com/intellij/psi/PsiCapturedWildcardType.java b/java/java-psi-api/src/com/intellij/psi/PsiCapturedWildcardType.java
index 6fe40d8..5f51304 100644
--- a/java/java-psi-api/src/com/intellij/psi/PsiCapturedWildcardType.java
+++ b/java/java-psi-api/src/com/intellij/psi/PsiCapturedWildcardType.java
@@ -22,8 +22,8 @@
* @author ven
*/
public class PsiCapturedWildcardType extends PsiType {
- private final PsiWildcardType myExistential;
- private final PsiElement myContext;
+ @NotNull private final PsiWildcardType myExistential;
+ @NotNull private final PsiElement myContext;
public boolean equals(final Object o) {
if (!(o instanceof PsiCapturedWildcardType)) return false;
@@ -36,13 +36,14 @@
return myExistential.hashCode() + 31 * myContext.hashCode();
}
- private PsiCapturedWildcardType(PsiWildcardType existential, final PsiElement context) {
+ private PsiCapturedWildcardType(@NotNull PsiWildcardType existential, @NotNull PsiElement context) {
super(PsiAnnotation.EMPTY_ARRAY);//todo
myExistential = existential;
myContext = context;
}
- public static PsiCapturedWildcardType create(PsiWildcardType existential, final PsiElement context) {
+ @NotNull
+ public static PsiCapturedWildcardType create(@NotNull PsiWildcardType existential, @NotNull PsiElement context) {
return new PsiCapturedWildcardType(existential, context);
}
@@ -104,10 +105,12 @@
}
}
+ @NotNull
public PsiWildcardType getWildcard() {
return myExistential;
}
+ @NotNull
public PsiElement getContext() {
return myContext;
}
diff --git a/java/java-psi-api/src/com/intellij/psi/util/MethodSignatureBackedByPsiMethod.java b/java/java-psi-api/src/com/intellij/psi/util/MethodSignatureBackedByPsiMethod.java
index 37fd4a4..4b2b4da 100644
--- a/java/java-psi-api/src/com/intellij/psi/util/MethodSignatureBackedByPsiMethod.java
+++ b/java/java-psi-api/src/com/intellij/psi/util/MethodSignatureBackedByPsiMethod.java
@@ -24,6 +24,7 @@
private final PsiMethod myMethod;
private final boolean myIsRaw;
+ private final String myName;
protected MethodSignatureBackedByPsiMethod(@NotNull PsiMethod method,
@NotNull PsiSubstitutor substitutor,
@@ -32,16 +33,14 @@
@NotNull PsiTypeParameter[] methodTypeParameters) {
super(substitutor, parameterTypes, methodTypeParameters);
myIsRaw = isRaw;
- if (!method.isValid()) {
- LOG.error("Invalid method: "+method, new PsiInvalidElementAccessException(method));
- }
myMethod = method;
+ myName = method.getName();
}
@NotNull
@Override
public String getName() {
- return myMethod.getName();
+ return myName;
}
@Override
@@ -84,7 +83,6 @@
PsiType[] parameterTypes = new PsiType[parameters.length];
for (int i = 0; i < parameterTypes.length; i++) {
PsiType type = parameters[i].getType();
- assert type.isValid();
parameterTypes[i] = isRaw ? TypeConversionUtil.erasure(substitutor.substitute(type)) : type;
}
diff --git a/java/java-psi-api/src/com/intellij/psi/util/MethodSignatureBase.java b/java/java-psi-api/src/com/intellij/psi/util/MethodSignatureBase.java
index 2dd259d..fe2bbae 100644
--- a/java/java-psi-api/src/com/intellij/psi/util/MethodSignatureBase.java
+++ b/java/java-psi-api/src/com/intellij/psi/util/MethodSignatureBase.java
@@ -25,6 +25,7 @@
private final PsiSubstitutor mySubstitutor;
private final PsiType[] myParameterTypes;
+ private volatile PsiType[] myErasedParameterTypes;
protected final PsiTypeParameter[] myTypeParameters;
protected MethodSignatureBase(@NotNull PsiSubstitutor substitutor, @NotNull PsiType[] parameterTypes, @NotNull PsiTypeParameter[] typeParameters) {
@@ -33,16 +34,23 @@
myParameterTypes = parameterTypes.length == 0 ? PsiType.EMPTY_ARRAY : new PsiType[parameterTypes.length];
for (int i = 0; i < parameterTypes.length; i++) {
PsiType type = parameterTypes[i];
- assert type == null || type.isValid();
+ if (type != null) {
+ PsiUtil.ensureValidType(type);
+ }
if (type instanceof PsiEllipsisType) type = ((PsiEllipsisType) type).toArrayType();
myParameterTypes[i] = substitutor.substitute(type);
}
myTypeParameters = typeParameters;
}
- protected MethodSignatureBase(@NotNull PsiSubstitutor substitutor, PsiParameterList parameterList, @Nullable PsiTypeParameterList typeParameterList) {
+ protected MethodSignatureBase(@NotNull PsiSubstitutor substitutor,
+ @Nullable PsiParameterList parameterList,
+ @Nullable PsiTypeParameterList typeParameterList) {
mySubstitutor = substitutor;
- if (parameterList != null) {
+ if (parameterList == null) {
+ myParameterTypes = PsiType.EMPTY_ARRAY;
+ }
+ else {
final PsiParameter[] parameters = parameterList.getParameters();
myParameterTypes = parameters.length == 0 ? PsiType.EMPTY_ARRAY : new PsiType[parameters.length];
for (int i = 0; i < parameters.length; i++) {
@@ -51,9 +59,6 @@
myParameterTypes[i] = substitutor.substitute(type);
}
}
- else {
- myParameterTypes = PsiType.EMPTY_ARRAY;
- }
myTypeParameters = typeParameterList == null ? PsiTypeParameter.EMPTY_ARRAY : typeParameterList.getTypeParameters();
}
@@ -70,6 +75,14 @@
return myTypeParameters;
}
+ public PsiType[] getErasedParameterTypes() {
+ PsiType[] result = myErasedParameterTypes;
+ if (result == null) {
+ myErasedParameterTypes = result = MethodSignatureUtil.calcErasedParameterTypes(this);
+ }
+ return result;
+ }
+
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof MethodSignature)) return false;
@@ -80,9 +93,13 @@
public int hashCode() {
int result = getName().hashCode();
-
- final PsiType[] parameterTypes = getParameterTypes();
- result += 37 * parameterTypes.length;
+ final PsiType[] parameterTypes = getErasedParameterTypes();
+ result = 31 * result + parameterTypes.length;
+ for (int i = 0, length = Math.min(3, parameterTypes.length); i < length; i++) {
+ PsiType type = parameterTypes[i];
+ if (type == null) continue;
+ result = 31 * result + type.hashCode();
+ }
return result;
}
diff --git a/java/java-psi-api/src/com/intellij/psi/util/MethodSignatureUtil.java b/java/java-psi-api/src/com/intellij/psi/util/MethodSignatureUtil.java
index f97ff17..8692a22 100644
--- a/java/java-psi-api/src/com/intellij/psi/util/MethodSignatureUtil.java
+++ b/java/java-psi-api/src/com/intellij/psi/util/MethodSignatureUtil.java
@@ -23,6 +23,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -48,38 +49,37 @@
new TObjectHashingStrategy<MethodSignature>() {
@Override
public int computeHashCode(final MethodSignature signature) {
- int result = signature.isConstructor() ? 0 : signature.getName().hashCode();
-
- PsiType[] parameterTypes = signature.getParameterTypes();
- result += 37 * parameterTypes.length;
- PsiType firstParamType = parameterTypes.length == 0 ? null : parameterTypes[0];
- if (firstParamType != null) {
- firstParamType = TypeConversionUtil.erasure(firstParamType, signature.getSubstitutor());
- assert firstParamType != null : parameterTypes[0];
- result = 31*result + firstParamType.hashCode();
- }
- return result;
+ return signature.hashCode();
}
@Override
public boolean equals(MethodSignature method1, MethodSignature method2) {
- if (method1.isConstructor() != method2.isConstructor()) return false;
- if (!method1.isConstructor() && !method1.getName().equals(method2.getName())) return false;
- final PsiType[] parameterTypes1 = method1.getParameterTypes();
- final PsiType[] parameterTypes2 = method2.getParameterTypes();
- if (parameterTypes1.length != parameterTypes2.length) return false;
-
- final PsiSubstitutor substitutor1 = method1.getSubstitutor();
- final PsiSubstitutor substitutor2 = method2.getSubstitutor();
- for (int i = 0; i < parameterTypes1.length; i++) {
- final PsiType type1 = TypeConversionUtil.erasure(substitutor1.substitute(parameterTypes1[i]), substitutor1);
- final PsiType type2 = TypeConversionUtil.erasure(substitutor2.substitute(parameterTypes2[i]), substitutor2);
- if (!Comparing.equal(type1, type2)) return false;
- }
- return true;
+ return areSignaturesEqualLightweight(method1, method2) && areErasedParametersEqual(method1, method2);
}
};
+ private static boolean areErasedParametersEqual(@NotNull MethodSignature method1, @NotNull MethodSignature method2) {
+ PsiType[] erased1 = method1 instanceof MethodSignatureBase
+ ? ((MethodSignatureBase)method1).getErasedParameterTypes() : calcErasedParameterTypes(method1);
+ PsiType[] erased2 = method2 instanceof MethodSignatureBase
+ ? ((MethodSignatureBase)method2).getErasedParameterTypes() : calcErasedParameterTypes(method2);
+ return Arrays.equals(erased1, erased2);
+ }
+
+ @NotNull
+ public static PsiType[] calcErasedParameterTypes(@NotNull MethodSignature signature) {
+ PsiType[] parameterTypes = signature.getParameterTypes();
+ if (parameterTypes.length == 0) return PsiType.EMPTY_ARRAY;
+
+ PsiSubstitutor substitutor = signature.getSubstitutor();
+ PsiType[] erasedTypes = new PsiType[parameterTypes.length];
+ for (int i = 0; i < parameterTypes.length; i++) {
+ erasedTypes[i] = TypeConversionUtil.erasure(substitutor.substitute(parameterTypes[i]), substitutor);
+ }
+ return erasedTypes;
+ }
+
+ @NotNull
public static MethodSignature createMethodSignature(@NonNls @NotNull String name,
@Nullable PsiParameterList parameterTypes,
@Nullable PsiTypeParameterList typeParameterList,
@@ -87,6 +87,7 @@
return createMethodSignature(name, parameterTypes, typeParameterList, substitutor, false);
}
+ @NotNull
public static MethodSignature createMethodSignature(@NonNls @NotNull String name,
@Nullable PsiParameterList parameterTypes,
@Nullable PsiTypeParameterList typeParameterList,
@@ -95,6 +96,7 @@
return new MethodSignatureHandMade(name, parameterTypes, typeParameterList, substitutor, isConstructor);
}
+ @NotNull
public static MethodSignature createMethodSignature(@NonNls @NotNull String name,
@NotNull PsiType[] parameterTypes,
@NotNull PsiTypeParameter[] typeParameterList,
@@ -102,6 +104,7 @@
return createMethodSignature(name, parameterTypes, typeParameterList, substitutor, false);
}
+ @NotNull
public static MethodSignature createMethodSignature(@NonNls @NotNull String name,
@NotNull PsiType[] parameterTypes,
@NotNull PsiTypeParameter[] typeParameterList,
@@ -110,22 +113,22 @@
return new MethodSignatureHandMade(name, parameterTypes, typeParameterList, substitutor, isConstructor);
}
- public static boolean areSignaturesEqual(PsiMethod method1, PsiMethod method2) {
+ public static boolean areSignaturesEqual(@NotNull PsiMethod method1, @NotNull PsiMethod method2) {
return method1.getSignature(PsiSubstitutor.EMPTY).equals(method2.getSignature(PsiSubstitutor.EMPTY));
}
- public static boolean areSignaturesEqual(MethodSignature method1, MethodSignature method2) {
+ public static boolean areSignaturesEqual(@NotNull MethodSignature method1, @NotNull MethodSignature method2) {
if (method2 == method1) return true;
if (!areSignaturesEqualLightweight(method1, method2)) return false;
- PsiSubstitutor unifyingSubstitutor = getSuperMethodSignatureSubstitutor(method1, method2);
- return checkSignaturesEqualInner(method1, method2, unifyingSubstitutor);
+ return checkSignaturesEqualInner(method1, method2, getSuperMethodSignatureSubstitutor(method1, method2))
+ || checkSignaturesEqualInner(method2, method1, getSuperMethodSignatureSubstitutor(method2, method1));
}
- private static boolean checkSignaturesEqualInner(final MethodSignature subSignature,
- final MethodSignature superSignature,
+ private static boolean checkSignaturesEqualInner(@NotNull MethodSignature subSignature,
+ @NotNull MethodSignature superSignature,
final PsiSubstitutor unifyingSubstitutor) {
if (unifyingSubstitutor == null) return false;
- if (!METHOD_PARAMETERS_ERASURE_EQUALITY.equals(subSignature, superSignature)) return false;
+ if (!areErasedParametersEqual(subSignature, superSignature)) return false;
final PsiType[] subParameterTypes = subSignature.getParameterTypes();
final PsiType[] superParameterTypes = superSignature.getParameterTypes();
@@ -140,12 +143,12 @@
return true;
}
- public static boolean areSignaturesEqualLightweight(final MethodSignature sig1, final MethodSignature sig2) {
+ public static boolean areSignaturesEqualLightweight(@NotNull MethodSignature sig1, @NotNull MethodSignature sig2) {
final boolean isConstructor1 = sig1.isConstructor();
final boolean isConstructor2 = sig2.isConstructor();
if (isConstructor1 != isConstructor2) return false;
- if (!isConstructor1 && !isConstructor2 || !(sig1 instanceof HierarchicalMethodSignature || sig2 instanceof HierarchicalMethodSignature)) {
+ if (!isConstructor1 || !(sig1 instanceof HierarchicalMethodSignature || sig2 instanceof HierarchicalMethodSignature)) {
final String name1 = sig1.getName();
final String name2 = sig2.getName();
if (!name1.equals(name2)) return false;
@@ -166,7 +169,7 @@
return true;
}
- public static boolean isSuperMethod(final PsiMethod superMethodCandidate, final PsiMethod derivedMethod) {
+ public static boolean isSuperMethod(@NotNull PsiMethod superMethodCandidate, @NotNull PsiMethod derivedMethod) {
PsiClass superClassCandidate = superMethodCandidate.getContainingClass();
PsiClass derivedClass = derivedMethod.getContainingClass();
if (derivedClass == null || superClassCandidate == null) return false;
@@ -181,16 +184,16 @@
@Nullable
public static PsiMethod findMethodInSuperClassBySignatureInDerived(@NotNull final PsiClass aClass,
@NotNull final PsiClass superClass,
- final MethodSignature signature,
+ @NotNull MethodSignature signature,
final boolean checkDeep) {
PsiSubstitutor superSubstitutor = TypeConversionUtil.getSuperClassSubstitutor(superClass, aClass, PsiSubstitutor.EMPTY);
return doFindMethodInSuperClassBySignatureInDerived(superClass, superSubstitutor, signature, checkDeep);
}
@Nullable
- private static PsiMethod doFindMethodInSuperClassBySignatureInDerived(final PsiClass superClass,
- final PsiSubstitutor superSubstitutor,
- final MethodSignature signature,
+ private static PsiMethod doFindMethodInSuperClassBySignatureInDerived(@NotNull PsiClass superClass,
+ @NotNull PsiSubstitutor superSubstitutor,
+ @NotNull MethodSignature signature,
final boolean checkDeep) {
final String name = signature.getName();
final PsiMethod[] methods = superClass.findMethodsByName(name, false);
@@ -212,12 +215,12 @@
}
@Nullable
- public static PsiMethod findMethodBySignature(final PsiClass aClass, final PsiMethod pattenMethod, boolean checkBases) {
+ public static PsiMethod findMethodBySignature(@NotNull PsiClass aClass, @NotNull PsiMethod pattenMethod, boolean checkBases) {
return findMethodBySignature(aClass, pattenMethod.getSignature(PsiSubstitutor.EMPTY), checkBases);
}
@Nullable
- public static PsiMethod findMethodBySignature(final PsiClass aClass, final MethodSignature methodSignature, boolean checkBases) {
+ public static PsiMethod findMethodBySignature(@NotNull PsiClass aClass, @NotNull MethodSignature methodSignature, boolean checkBases) {
String name = methodSignature.isConstructor() ? aClass.getName() : methodSignature.getName();
List<Pair<PsiMethod, PsiSubstitutor>> pairs = aClass.findMethodsAndTheirSubstitutorsByName(name, checkBases);
for (Pair<PsiMethod, PsiSubstitutor> pair : pairs) {
@@ -230,7 +233,7 @@
}
@Nullable
- public static PsiMethod findMethodBySuperSignature(final PsiClass aClass, final MethodSignature methodSignature, final boolean checkBases) {
+ public static PsiMethod findMethodBySuperSignature(@NotNull PsiClass aClass, @NotNull MethodSignature methodSignature, final boolean checkBases) {
String name = methodSignature.isConstructor() ? aClass.getName() : methodSignature.getName();
List<Pair<PsiMethod, PsiSubstitutor>> pairs = aClass.findMethodsAndTheirSubstitutorsByName(name, checkBases);
for (Pair<PsiMethod, PsiSubstitutor> pair : pairs) {
@@ -243,7 +246,7 @@
}
@Nullable
- public static PsiMethod findMethodBySuperMethod(final PsiClass aClass, final PsiMethod method, final boolean checkBases) {
+ public static PsiMethod findMethodBySuperMethod(@NotNull PsiClass aClass, @NotNull PsiMethod method, final boolean checkBases) {
List<Pair<PsiMethod, PsiSubstitutor>> pairs = aClass.findMethodsAndTheirSubstitutorsByName(method.getName(), checkBases);
for (Pair<PsiMethod, PsiSubstitutor> pair : pairs) {
PsiMethod candidate = pair.first;
@@ -260,22 +263,23 @@
return null;
}
- public static boolean hasOverloads(PsiMethod method) {
+ public static boolean hasOverloads(@NotNull PsiMethod method) {
return getOverloads(method).length > 1;
}
- public static PsiMethod[] getOverloads(PsiMethod method) {
+ @NotNull
+ public static PsiMethod[] getOverloads(@NotNull PsiMethod method) {
PsiClass aClass = method.getContainingClass();
if (aClass == null) return new PsiMethod[]{method};
return aClass.findMethodsByName(method.getName(), false);
}
- public static boolean areParametersErasureEqual(PsiMethod method1, PsiMethod method2) {
+ public static boolean areParametersErasureEqual(@NotNull PsiMethod method1, @NotNull PsiMethod method2) {
if (method1.getParameterList().getParametersCount() != method2.getParameterList().getParametersCount()) return false;
return areSignaturesErasureEqual(method1.getSignature(PsiSubstitutor.EMPTY), method2.getSignature(PsiSubstitutor.EMPTY));
}
- public static boolean areSignaturesErasureEqual(MethodSignature signature1, MethodSignature signature2) {
+ public static boolean areSignaturesErasureEqual(@NotNull MethodSignature signature1, @NotNull MethodSignature signature2) {
return METHOD_PARAMETERS_ERASURE_EQUALITY.equals(signature1, signature2);
}
@@ -285,7 +289,7 @@
* @return null if signatures do not match
*/
@Nullable
- public static PsiSubstitutor getSuperMethodSignatureSubstitutor(MethodSignature methodSignature, MethodSignature superMethodSignature) {
+ public static PsiSubstitutor getSuperMethodSignatureSubstitutor(@NotNull MethodSignature methodSignature, @NotNull MethodSignature superMethodSignature) {
PsiSubstitutor result = getSuperMethodSignatureSubstitutorImpl(methodSignature, superMethodSignature);
if (result == null) return null;
@@ -315,7 +319,7 @@
}
@Nullable
- private static PsiSubstitutor getSuperMethodSignatureSubstitutorImpl(MethodSignature methodSignature, MethodSignature superSignature) {
+ private static PsiSubstitutor getSuperMethodSignatureSubstitutorImpl(@NotNull MethodSignature methodSignature, @NotNull MethodSignature superSignature) {
// normalize generic method declarations: correlate type parameters
// todo: correlate type params by name?
PsiTypeParameter[] methodTypeParameters = methodSignature.getTypeParameters();
@@ -334,7 +338,8 @@
return result;
}
- public static PsiSubstitutor combineSubstitutors(PsiSubstitutor substitutor1, PsiSubstitutor substitutor2) {
+ @NotNull
+ public static PsiSubstitutor combineSubstitutors(@NotNull PsiSubstitutor substitutor1, @NotNull PsiSubstitutor substitutor2) {
if (substitutor1 == PsiSubstitutor.EMPTY) return substitutor2;
Set<PsiTypeParameter> parameters1 = substitutor1.getSubstitutionMap().keySet();
final PsiTypeParameter[] typeParameters = parameters1.toArray(new PsiTypeParameter[parameters1.size()]);
@@ -355,7 +360,7 @@
}
@NotNull
- public static PsiMethod[] convertMethodSignaturesToMethods(List<? extends MethodSignatureBackedByPsiMethod> sameNameMethodList) {
+ public static PsiMethod[] convertMethodSignaturesToMethods(@NotNull List<? extends MethodSignatureBackedByPsiMethod> sameNameMethodList) {
final PsiMethod[] methods = new PsiMethod[sameNameMethodList.size()];
for (int i = 0; i < sameNameMethodList.size(); i++) {
methods[i] = sameNameMethodList.get(i).getMethod();
@@ -363,7 +368,7 @@
return methods;
}
- public static boolean isSubsignature(MethodSignature superSignature, MethodSignature subSignature) {
+ public static boolean isSubsignature(@NotNull MethodSignature superSignature, @NotNull MethodSignature subSignature) {
if (subSignature == superSignature) return true;
if (!areSignaturesEqualLightweight(superSignature, subSignature)) return false;
PsiSubstitutor unifyingSubstitutor = getSuperMethodSignatureSubstitutor(subSignature, superSignature);
diff --git a/java/java-psi-api/src/com/intellij/psi/util/RedundantCastUtil.java b/java/java-psi-api/src/com/intellij/psi/util/RedundantCastUtil.java
index 2852584..faa1e50 100644
--- a/java/java-psi-api/src/com/intellij/psi/util/RedundantCastUtil.java
+++ b/java/java-psi-api/src/com/intellij/psi/util/RedundantCastUtil.java
@@ -251,8 +251,8 @@
final JavaResolveResult newResult = newCall.getMethodExpression().advancedResolve(false);
if (!newResult.isValidResult()) return;
final PsiMethod newTargetMethod = (PsiMethod)newResult.getElement();
- final PsiType newReturnType = newResult.getSubstitutor().substitute(newTargetMethod.getReturnType());
- final PsiType oldReturnType = resolveResult.getSubstitutor().substitute(targetMethod.getReturnType());
+ final PsiType newReturnType = newCall.getType();
+ final PsiType oldReturnType = methodCall.getType();
if (Comparing.equal(newReturnType, oldReturnType)) {
if (newTargetMethod.equals(targetMethod) ||
(newTargetMethod.getSignature(newResult.getSubstitutor()).equals(targetMethod.getSignature(resolveResult.getSubstitutor())) &&
diff --git a/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java b/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java
index 9cce64d..2675e39 100644
--- a/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java
+++ b/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java
@@ -445,8 +445,6 @@
/**
* @param tokenType JavaTokenType enumeration
- * @param lOperand
- * @param rOperand
* @param strict true if operator result type should be convertible to the left operand
* @return true if lOperand operator rOperand expression is syntactically correct
*/
@@ -480,16 +478,14 @@
}
else {
if (isPrimitiveAndNotNull(ltype)) {
- if (rtype instanceof PsiClassType && ((PsiClassType)rtype).getLanguageLevel().isAtLeast(LanguageLevel.JDK_1_7)) {
- return areTypesConvertible(ltype, rtype);
- }
- return false;
+ return rtype instanceof PsiClassType &&
+ ((PsiClassType)rtype).getLanguageLevel().isAtLeast(LanguageLevel.JDK_1_7) &&
+ areTypesConvertible(ltype, rtype);
}
if (isPrimitiveAndNotNull(rtype)) {
- if (ltype instanceof PsiClassType && ((PsiClassType)ltype).getLanguageLevel().isAtLeast(LanguageLevel.JDK_1_7)) {
- return areTypesConvertible(rtype, ltype);
- }
- return false;
+ return ltype instanceof PsiClassType &&
+ ((PsiClassType)ltype).getLanguageLevel().isAtLeast(LanguageLevel.JDK_1_7) &&
+ areTypesConvertible(rtype, ltype);
}
isApplicable = areTypesConvertible(ltype, rtype) || areTypesConvertible(rtype, ltype);
}
@@ -693,10 +689,7 @@
final PsiType lType = lLambdaExpression.getFunctionalInterfaceType();
return Comparing.equal(rType, lType);
}
- if (left instanceof PsiArrayType) {
- return false;
- }
- return LambdaUtil.isAcceptable(rLambdaExpression, left, false);
+ return !(left instanceof PsiArrayType) && LambdaUtil.isAcceptable(rLambdaExpression, left, false);
}
if (left instanceof PsiIntersectionType) {
@@ -745,9 +738,7 @@
if (lCompType instanceof PsiPrimitiveType) {
return lCompType.equals(rCompType);
}
- else {
- return !(rCompType instanceof PsiPrimitiveType) && isAssignable(lCompType, rCompType, allowUncheckedConversion);
- }
+ return !(rCompType instanceof PsiPrimitiveType) && isAssignable(lCompType, rCompType, allowUncheckedConversion);
}
if (left instanceof PsiDisjunctionType) {
@@ -828,12 +819,10 @@
if (left instanceof PsiPrimitiveType && !PsiType.NULL.equals(left)) {
return right instanceof PsiClassType && isAssignable(left, right);
}
- else {
- return left instanceof PsiClassType
- && right instanceof PsiPrimitiveType
- && !PsiType.NULL.equals(right)
- && isAssignable(left, right);
- }
+ return left instanceof PsiClassType
+ && right instanceof PsiPrimitiveType
+ && !PsiType.NULL.equals(right)
+ && isAssignable(left, right);
}
private static final Key<CachedValue<Set<String>>> POSSIBLE_BOXED_HOLDER_TYPES = Key.create("Types that may be possibly assigned from primitive ones");
@@ -932,7 +921,7 @@
}
private static final RecursionGuard ourGuard = RecursionManager.createGuard("isAssignable");
-
+
public static boolean typesAgree(PsiType typeLeft, PsiType typeRight, final boolean allowUncheckedConversion) {
if (typeLeft instanceof PsiWildcardType) {
final PsiWildcardType leftWildcard = (PsiWildcardType)typeLeft;
@@ -985,7 +974,7 @@
}
}
- private static Boolean containsWildcards(PsiType leftBound) {
+ private static boolean containsWildcards(@NotNull PsiType leftBound) {
final WildcardDetector wildcardDetector = new WildcardDetector();
if (leftBound instanceof PsiIntersectionType) {
for (PsiType conjunctType :((PsiIntersectionType)leftBound).getConjuncts()) {
@@ -993,7 +982,7 @@
}
return true;
}
-
+
return leftBound.accept(wildcardDetector);
}
@@ -1020,9 +1009,6 @@
* <code>superClass</code> must be a super class/interface of <code>derivedClass</code> (as in
* <code>InheritanceUtil.isInheritor(derivedClass, superClass, true)</code>
*
- * @param superClass
- * @param derivedClass
- * @param derivedSubstitutor
* @return substitutor (never returns <code>null</code>)
* @see InheritanceUtil#isInheritor(PsiClass, PsiClass, boolean)
*/
@@ -1228,7 +1214,7 @@
return typeParameterErasure(typeParameter, PsiSubstitutor.EMPTY);
}
- private static PsiType typeParameterErasure(@NotNull PsiTypeParameter typeParameter, final PsiSubstitutor beforeSubstitutor) {
+ private static PsiType typeParameterErasure(@NotNull PsiTypeParameter typeParameter, @NotNull PsiSubstitutor beforeSubstitutor) {
final PsiClassType[] extendsList = typeParameter.getExtendsList().getReferencedTypes();
if (extendsList.length > 0) {
final PsiClass psiClass = extendsList[0].resolve();
@@ -1274,7 +1260,7 @@
return erasure(type, PsiSubstitutor.EMPTY);
}
- public static PsiType erasure(@Nullable final PsiType type, final PsiSubstitutor beforeSubstitutor) {
+ public static PsiType erasure(@Nullable final PsiType type, @NotNull final PsiSubstitutor beforeSubstitutor) {
if (type == null) return null;
return type.accept(new PsiTypeVisitor<PsiType>() {
@Override
@@ -1283,9 +1269,7 @@
if (aClass instanceof PsiTypeParameter) {
return typeParameterErasure((PsiTypeParameter)aClass, beforeSubstitutor);
}
- else {
- return classType.rawType();
- }
+ return classType.rawType();
}
@Override
diff --git a/java/java-psi-impl/src/com/intellij/codeInsight/BaseExternalAnnotationsManager.java b/java/java-psi-impl/src/com/intellij/codeInsight/BaseExternalAnnotationsManager.java
index 269114b..8d75564 100644
--- a/java/java-psi-impl/src/com/intellij/codeInsight/BaseExternalAnnotationsManager.java
+++ b/java/java-psi-impl/src/com/intellij/codeInsight/BaseExternalAnnotationsManager.java
@@ -302,7 +302,7 @@
Set<PsiFile> possibleAnnotationsXmls = new THashSet<PsiFile>();
for (VirtualFile root : getExternalAnnotationsRoots(virtualFile)) {
- final VirtualFile ext = root.findFileByRelativePath(packageName.replace(".", "/") + "/" + ANNOTATIONS_XML);
+ final VirtualFile ext = root.findFileByRelativePath(packageName.replace('.', '/') + "/" + ANNOTATIONS_XML);
if (ext == null) continue;
final PsiFile psiFile = myPsiManager.findFile(ext);
if (psiFile == null) continue;
diff --git a/java/java-psi-impl/src/com/intellij/codeInsight/ExceptionUtil.java b/java/java-psi-impl/src/com/intellij/codeInsight/ExceptionUtil.java
index 1aa0ac2..4b245a0 100644
--- a/java/java-psi-impl/src/com/intellij/codeInsight/ExceptionUtil.java
+++ b/java/java-psi-impl/src/com/intellij/codeInsight/ExceptionUtil.java
@@ -20,10 +20,11 @@
import com.intellij.psi.*;
import com.intellij.psi.controlFlow.*;
import com.intellij.psi.impl.PsiImplUtil;
-import com.intellij.psi.util.InheritanceUtil;
-import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.psi.util.PsiUtil;
-import com.intellij.psi.util.TypeConversionUtil;
+import com.intellij.psi.infos.CandidateInfo;
+import com.intellij.psi.scope.MethodProcessorSetupFailedException;
+import com.intellij.psi.scope.processor.MethodResolverProcessor;
+import com.intellij.psi.scope.util.PsiScopesUtil;
+import com.intellij.psi.util.*;
import com.intellij.util.NullableFunction;
import com.intellij.util.SmartList;
import com.intellij.util.containers.ContainerUtil;
@@ -62,7 +63,7 @@
}
@NotNull
- private static List<PsiClassType> filterOutUncheckedExceptions(List<PsiClassType> exceptions) {
+ private static List<PsiClassType> filterOutUncheckedExceptions(@NotNull List<PsiClassType> exceptions) {
List<PsiClassType> array = ContainerUtil.newArrayList();
for (PsiClassType exception : exceptions) {
if (!isUncheckedException(exception)) array.add(exception);
@@ -95,9 +96,13 @@
final PsiExpression expr = ((PsiThrowStatement)element).getException();
if (expr == null) return Collections.emptyList();
final List<PsiType> types = getPreciseThrowTypes(expr);
- final List<PsiClassType> classTypes = ContainerUtil.mapNotNull(types, new NullableFunction<PsiType, PsiClassType>() {
- @Override public PsiClassType fun(PsiType type) { return type instanceof PsiClassType ? (PsiClassType)type : null; }
- });
+ List<PsiClassType> classTypes =
+ new ArrayList<PsiClassType>(ContainerUtil.mapNotNull(types, new NullableFunction<PsiType, PsiClassType>() {
+ @Override
+ public PsiClassType fun(PsiType type) {
+ return type instanceof PsiClassType ? (PsiClassType)type : null;
+ }
+ }));
addExceptions(classTypes, getThrownExceptions(expr));
return classTypes;
}
@@ -115,7 +120,8 @@
return getThrownExceptions(element.getChildren());
}
- private static List<PsiClassType> getTryExceptions(PsiTryStatement tryStatement) {
+ @NotNull
+ private static List<PsiClassType> getTryExceptions(@NotNull PsiTryStatement tryStatement) {
List<PsiClassType> array = ContainerUtil.newArrayList();
PsiResourceList resourceList = tryStatement.getResourceList();
@@ -169,7 +175,7 @@
}
@NotNull
- private static List<PsiClassType> getExceptionsByMethodAndChildren(PsiElement element, JavaResolveResult resolveResult) {
+ private static List<PsiClassType> getExceptionsByMethodAndChildren(@NotNull PsiElement element, @NotNull JavaResolveResult resolveResult) {
List<PsiClassType> result = ContainerUtil.newArrayList();
PsiMethod method = (PsiMethod)resolveResult.getElement();
@@ -197,13 +203,13 @@
return result;
}
- private static void addExceptions(List<PsiClassType> array, Collection<PsiClassType> exceptions) {
+ private static void addExceptions(@NotNull List<PsiClassType> array, @NotNull Collection<PsiClassType> exceptions) {
for (PsiClassType exception : exceptions) {
addException(array, exception);
}
}
- private static void addException(List<PsiClassType> array, PsiClassType exception) {
+ private static void addException(@NotNull List<PsiClassType> array, @Nullable PsiClassType exception) {
if (exception == null) return ;
for (int i = array.size()-1; i>=0; i--) {
PsiClassType exception1 = array.get(i);
@@ -311,7 +317,8 @@
return foundExceptions;
}
- private static Collection<PsiClassType> getUnhandledExceptions(PsiMethodReferenceExpression methodReferenceExpression,
+ @NotNull
+ private static Collection<PsiClassType> getUnhandledExceptions(@NotNull PsiMethodReferenceExpression methodReferenceExpression,
PsiElement topElement) {
final JavaResolveResult resolveResult = methodReferenceExpression.advancedResolve(false);
final PsiElement resolve = resolveResult.getElement();
@@ -321,7 +328,7 @@
return Collections.emptyList();
}
- private static boolean firstStatementIsConstructorCall(PsiCodeBlock constructorBody) {
+ private static boolean firstStatementIsConstructorCall(@NotNull PsiCodeBlock constructorBody) {
final PsiStatement[] statements = constructorBody.getStatements();
if (statements.length == 0) return false;
if (!(statements[0] instanceof PsiExpressionStatement)) return false;
@@ -333,29 +340,29 @@
}
@NotNull
- public static List<PsiClassType> getUnhandledExceptions(PsiElement[] elements) {
+ public static List<PsiClassType> getUnhandledExceptions(@NotNull PsiElement[] elements) {
final List<PsiClassType> array = ContainerUtil.newArrayList();
final PsiElementVisitor visitor = new JavaRecursiveElementWalkingVisitor() {
@Override
- public void visitCallExpression(PsiCallExpression expression) {
+ public void visitCallExpression(@NotNull PsiCallExpression expression) {
addExceptions(array, getUnhandledExceptions(expression, null));
visitElement(expression);
}
@Override
- public void visitThrowStatement(PsiThrowStatement statement) {
+ public void visitThrowStatement(@NotNull PsiThrowStatement statement) {
addExceptions(array, getUnhandledExceptions(statement, null));
visitElement(statement);
}
@Override
- public void visitMethodReferenceExpression(PsiMethodReferenceExpression expression) {
+ public void visitMethodReferenceExpression(@NotNull PsiMethodReferenceExpression expression) {
addExceptions(array, getUnhandledExceptions(expression, null));
visitElement(expression);
}
@Override
- public void visitResourceVariable(PsiResourceVariable resourceVariable) {
+ public void visitResourceVariable(@NotNull PsiResourceVariable resourceVariable) {
addExceptions(array, getUnhandledCloserExceptions(resourceVariable, null));
visitElement(resourceVariable);
}
@@ -386,12 +393,12 @@
}
@NotNull
- public static List<PsiClassType> getUnhandledExceptions(final PsiCallExpression methodCall, @Nullable final PsiElement topElement) {
+ public static List<PsiClassType> getUnhandledExceptions(@NotNull final PsiCallExpression methodCall, @Nullable final PsiElement topElement) {
return getUnhandledExceptions(methodCall, topElement, true);
}
@NotNull
- public static List<PsiClassType> getUnhandledExceptions(final PsiCallExpression methodCall,
+ public static List<PsiClassType> getUnhandledExceptions(@NotNull final PsiCallExpression methodCall,
@Nullable final PsiElement topElement,
boolean includeSelfCalls) {
final JavaResolveResult result = methodCall.resolveMethodGenerics();
@@ -400,29 +407,86 @@
return Collections.emptyList();
}
- final PsiSubstitutor substitutor = ApplicationManager.getApplication().runReadAction(new Computable<PsiSubstitutor>() {
- @Override
- public PsiSubstitutor compute() {
- return result.getSubstitutor();
+ final PsiSubstitutor substitutor = result.getSubstitutor();
+ if (method != null && !isArrayClone(method, methodCall) && methodCall instanceof PsiMethodCallExpression) {
+ final PsiClassType[] thrownExceptions = method.getThrowsList().getReferencedTypes();
+ if (thrownExceptions.length > 0) {
+ final MethodResolverProcessor processor = new MethodResolverProcessor((PsiMethodCallExpression)methodCall);
+ try {
+ PsiScopesUtil.setupAndRunProcessor(processor, methodCall, false);
+ final List<CandidateInfo> results = processor.getResults();
+ if (results.size() > 1) {
+ final List<PsiClassType> ex = collectSubstituted(substitutor, thrownExceptions);
+ for (CandidateInfo info : results) {
+ final PsiElement element = info.getElement();
+ if (element instanceof PsiMethod && MethodSignatureUtil.areSignaturesEqual(method, (PsiMethod)element)) {
+ final PsiClassType[] exceptions = ((PsiMethod)element).getThrowsList().getReferencedTypes();
+ if (exceptions.length == 0) {
+ return getUnhandledExceptions(methodCall, topElement, PsiSubstitutor.EMPTY, PsiClassType.EMPTY_ARRAY);
+ }
+ retainExceptions(ex, collectSubstituted(info.getSubstitutor(), exceptions));
+ }
+ }
+ return getUnhandledExceptions(methodCall, topElement, PsiSubstitutor.EMPTY, ex.toArray(new PsiClassType[ex.size()]));
+ }
+ }
+ catch (MethodProcessorSetupFailedException ignore) {
+ return Collections.emptyList();
+ }
}
- });
+ }
+
return getUnhandledExceptions(method, methodCall, topElement, substitutor);
}
+ public static void retainExceptions(List<PsiClassType> ex, List<PsiClassType> thrownEx) {
+ final List<PsiClassType> replacement = new ArrayList<PsiClassType>();
+ for (Iterator<PsiClassType> iterator = ex.iterator(); iterator.hasNext(); ) {
+ PsiClassType classType = iterator.next();
+ boolean found = false;
+ for (PsiClassType psiClassType : thrownEx) {
+ if (psiClassType.isAssignableFrom(classType)) {
+ found = true;
+ break;
+ } else if (classType.isAssignableFrom(psiClassType)) {
+ replacement.add(psiClassType);
+ iterator.remove();
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ iterator.remove();
+ }
+ }
+ ex.addAll(replacement);
+ }
+
+ public static List<PsiClassType> collectSubstituted(PsiSubstitutor substitutor, PsiClassType[] thrownExceptions) {
+ final List<PsiClassType> ex = new ArrayList<PsiClassType>();
+ for (PsiClassType thrownException : thrownExceptions) {
+ final PsiType psiType = substitutor.substitute(thrownException);
+ if (psiType instanceof PsiClassType) {
+ ex.add((PsiClassType)psiType);
+ }
+ }
+ return ex;
+ }
+
@NotNull
- public static List<PsiClassType> getCloserExceptions(final PsiResourceVariable resource) {
+ public static List<PsiClassType> getCloserExceptions(@NotNull final PsiResourceVariable resource) {
final PsiMethod method = PsiUtil.getResourceCloserMethod(resource);
return method != null ? getExceptionsByMethod(method, PsiSubstitutor.EMPTY) : Collections.<PsiClassType>emptyList();
}
@NotNull
- public static List<PsiClassType> getUnhandledCloserExceptions(final PsiResourceVariable resource, @Nullable final PsiElement topElement) {
+ public static List<PsiClassType> getUnhandledCloserExceptions(@NotNull final PsiResourceVariable resource, @Nullable final PsiElement topElement) {
final PsiMethod method = PsiUtil.getResourceCloserMethod(resource);
return method != null ? getUnhandledExceptions(method, resource, topElement, PsiSubstitutor.EMPTY) : Collections.<PsiClassType>emptyList();
}
@NotNull
- public static List<PsiClassType> getUnhandledExceptions(PsiThrowStatement throwStatement, @Nullable PsiElement topElement) {
+ public static List<PsiClassType> getUnhandledExceptions(@NotNull PsiThrowStatement throwStatement, @Nullable PsiElement topElement) {
List<PsiClassType> unhandled = new SmartList<PsiClassType>();
for (PsiType type : getPreciseThrowTypes(throwStatement.getException())) {
List<PsiType> types = type instanceof PsiDisjunctionType ? ((PsiDisjunctionType)type).getDisjunctions() : Collections.singletonList(type);
@@ -458,14 +522,21 @@
}
@NotNull
- private static List<PsiClassType> getUnhandledExceptions(PsiMethod method,
+ private static List<PsiClassType> getUnhandledExceptions(@Nullable PsiMethod method,
PsiElement element,
PsiElement topElement,
- PsiSubstitutor substitutor) {
+ @NotNull PsiSubstitutor substitutor) {
if (method == null || isArrayClone(method, element)) {
return Collections.emptyList();
}
final PsiClassType[] referencedTypes = method.getThrowsList().getReferencedTypes();
+ return getUnhandledExceptions(element, topElement, substitutor, referencedTypes);
+ }
+
+ private static List<PsiClassType> getUnhandledExceptions(PsiElement element,
+ PsiElement topElement,
+ PsiSubstitutor substitutor,
+ PsiClassType[] referencedTypes) {
if (referencedTypes.length > 0) {
List<PsiClassType> result = ContainerUtil.newArrayList();
@@ -487,7 +558,7 @@
return Collections.emptyList();
}
- private static boolean isArrayClone(PsiMethod method, PsiElement element) {
+ private static boolean isArrayClone(@NotNull PsiMethod method, PsiElement element) {
if (!method.getName().equals(CLONE_METHOD_NAME)) return false;
PsiClass containingClass = method.getContainingClass();
if (containingClass == null || !CommonClassNames.JAVA_LANG_OBJECT.equals(containingClass.getQualifiedName())) {
@@ -519,11 +590,11 @@
CommonClassNames.JAVA_LANG_EXCEPTION.equals(canonicalText);
}
- public static boolean isHandled(PsiClassType exceptionType, PsiElement throwPlace) {
+ public static boolean isHandled(@NotNull PsiClassType exceptionType, @NotNull PsiElement throwPlace) {
return isHandled(throwPlace, exceptionType, throwPlace.getContainingFile());
}
- private static boolean isHandled(PsiElement element, PsiClassType exceptionType, PsiElement topElement) {
+ private static boolean isHandled(@Nullable PsiElement element, @NotNull PsiClassType exceptionType, PsiElement topElement) {
if (element == null || element.getParent() == topElement || element.getParent() == null) return false;
final PsiElement parent = element.getParent();
@@ -590,7 +661,7 @@
return isHandled(parent, exceptionType, topElement);
}
- private static boolean isDeclaredBySAMMethod(PsiClassType exceptionType, PsiType interfaceType) {
+ private static boolean isDeclaredBySAMMethod(@NotNull PsiClassType exceptionType, @Nullable PsiType interfaceType) {
if (interfaceType != null) {
final PsiMethod interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(interfaceType);
if (interfaceMethod != null) {
@@ -600,7 +671,7 @@
return true;
}
- private static boolean areAllConstructorsThrow(final PsiClass aClass, PsiClassType exceptionType) {
+ private static boolean areAllConstructorsThrow(@Nullable final PsiClass aClass, @NotNull PsiClassType exceptionType) {
if (aClass == null) return false;
final PsiMethod[] constructors = aClass.getConstructors();
boolean thrown = constructors.length != 0;
@@ -613,7 +684,7 @@
return thrown;
}
- private static boolean isCaught(PsiTryStatement tryStatement, PsiClassType exceptionType) {
+ private static boolean isCaught(@NotNull PsiTryStatement tryStatement, @NotNull PsiClassType exceptionType) {
// if finally block completes abruptly, exception gets lost
PsiCodeBlock finallyBlock = tryStatement.getFinallyBlock();
if (finallyBlock != null && blockCompletesAbruptly(finallyBlock)) return true;
@@ -627,7 +698,7 @@
return false;
}
- private static boolean blockCompletesAbruptly(final PsiCodeBlock finallyBlock) {
+ private static boolean blockCompletesAbruptly(@NotNull final PsiCodeBlock finallyBlock) {
try {
ControlFlow flow = ControlFlowFactory.getInstance(finallyBlock.getProject()).getControlFlow(finallyBlock, LocalsOrMyInstanceFieldsControlFlowPolicy.getInstance(), false);
int completionReasons = ControlFlowUtil.getCompletionReasons(flow, 0, flow.getSize());
@@ -639,19 +710,19 @@
return false;
}
- private static boolean isHandledByMethodThrowsClause(PsiMethod method, PsiClassType exceptionType) {
+ private static boolean isHandledByMethodThrowsClause(@NotNull PsiMethod method, @NotNull PsiClassType exceptionType) {
final PsiClassType[] referencedTypes = method.getThrowsList().getReferencedTypes();
return isHandledBy(exceptionType, referencedTypes);
}
- public static boolean isHandledBy(PsiClassType exceptionType, @NotNull PsiClassType[] referencedTypes) {
+ public static boolean isHandledBy(@NotNull PsiClassType exceptionType, @NotNull PsiClassType[] referencedTypes) {
for (PsiClassType classType : referencedTypes) {
if (classType.isAssignableFrom(exceptionType)) return true;
}
return false;
}
- public static void sortExceptionsByHierarchy(List<PsiClassType> exceptions) {
+ public static void sortExceptionsByHierarchy(@NotNull List<PsiClassType> exceptions) {
if (exceptions.size() <= 1) return;
sortExceptionsByHierarchy(exceptions.subList(1, exceptions.size()));
for (int i=0; i<exceptions.size()-1;i++) {
diff --git a/java/java-psi-impl/src/com/intellij/codeInsight/generation/OverrideImplementExploreUtil.java b/java/java-psi-impl/src/com/intellij/codeInsight/generation/OverrideImplementExploreUtil.java
index a29a0c5..6c273b2 100644
--- a/java/java-psi-impl/src/com/intellij/codeInsight/generation/OverrideImplementExploreUtil.java
+++ b/java/java-psi-impl/src/com/intellij/codeInsight/generation/OverrideImplementExploreUtil.java
@@ -30,12 +30,17 @@
@NotNull
public static Collection<MethodSignature> getMethodSignaturesToOverride(@NotNull PsiClass aClass) {
- if (aClass.isInterface()) return Collections.emptySet();
+ if (aClass.isAnnotationType()) return Collections.emptySet();
return getMapToOverrideImplement(aClass, false).keySet();
}
@NotNull
- private static Map<MethodSignature, CandidateInfo> getMapToOverrideImplement(PsiClass aClass, boolean toImplement) {
+ public static Map<MethodSignature, CandidateInfo> getMapToOverrideImplement(PsiClass aClass, boolean toImplement) {
+ return getMapToOverrideImplement(aClass, toImplement, true);
+ }
+
+ @NotNull
+ public static Map<MethodSignature, CandidateInfo> getMapToOverrideImplement(PsiClass aClass, boolean toImplement, boolean skipImplemented) {
Map<MethodSignature, PsiMethod> abstracts = new LinkedHashMap<MethodSignature,PsiMethod>();
Map<MethodSignature, PsiMethod> finals = new LinkedHashMap<MethodSignature,PsiMethod>();
Map<MethodSignature, PsiMethod> concretes = new LinkedHashMap<MethodSignature,PsiMethod>();
@@ -55,7 +60,7 @@
continue;
}
// filter already implemented
- if (MethodSignatureUtil.findMethodBySignature(aClass, signature, false) != null) {
+ if (skipImplemented && MethodSignatureUtil.findMethodBySignature(aClass, signature, false) != null) {
continue;
}
diff --git a/java/java-psi-impl/src/com/intellij/lang/java/parser/ExpressionParser.java b/java/java-psi-impl/src/com/intellij/lang/java/parser/ExpressionParser.java
index 34dd67d..25da019 100644
--- a/java/java-psi-impl/src/com/intellij/lang/java/parser/ExpressionParser.java
+++ b/java/java-psi-impl/src/com/intellij/lang/java/parser/ExpressionParser.java
@@ -393,6 +393,7 @@
else if (dotTokenType == JavaTokenType.SUPER_KEYWORD) {
dotPos.drop();
final PsiBuilder.Marker refExpr = expr.precede();
+ builder.mark().done(JavaElementType.REFERENCE_PARAMETER_LIST);
builder.advanceLexer();
refExpr.done(JavaElementType.REFERENCE_EXPRESSION);
expr = refExpr;
diff --git a/java/java-psi-impl/src/com/intellij/psi/PsiDiamondTypeImpl.java b/java/java-psi-impl/src/com/intellij/psi/PsiDiamondTypeImpl.java
index b14a37d..8844055 100644
--- a/java/java-psi-impl/src/com/intellij/psi/PsiDiamondTypeImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/PsiDiamondTypeImpl.java
@@ -287,7 +287,7 @@
}
public static boolean haveConstructorsGenericsParameters(@NotNull final PsiClass psiClass) {
- for (PsiMethod method : psiClass.getConstructors()) {
+ for (final PsiMethod method : psiClass.getConstructors()) {
for (PsiParameter parameter : method.getParameterList().getParameters()) {
final PsiType type = parameter.getType();
final Boolean accept = type.accept(new PsiTypeVisitor<Boolean>() {
@@ -304,7 +304,8 @@
if (typaParamFound != null && typaParamFound) return true;
}
}
- return PsiUtil.resolveClassInType(classType) instanceof PsiTypeParameter;
+ final PsiClass aClass = PsiUtil.resolveClassInType(classType);
+ return aClass instanceof PsiTypeParameter && ((PsiTypeParameter)aClass).getOwner() == method;
}
@Override
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/InheritanceImplUtil.java b/java/java-psi-impl/src/com/intellij/psi/impl/InheritanceImplUtil.java
index 28fc636..247477e 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/InheritanceImplUtil.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/InheritanceImplUtil.java
@@ -20,20 +20,43 @@
import com.intellij.openapi.util.Comparing;
import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
+import com.intellij.psi.util.CachedValueProvider;
+import com.intellij.psi.util.CachedValuesManager;
import com.intellij.psi.util.InheritanceUtil;
+import com.intellij.util.containers.ConcurrentHashMap;
import com.intellij.util.containers.HashSet;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import java.util.Map;
import java.util.Set;
public class InheritanceImplUtil {
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.InheritanceImplUtil");
- public static boolean isInheritor(@NotNull PsiClass candidateClass, @NotNull PsiClass baseClass, final boolean checkDeep) {
- return !(baseClass instanceof PsiAnonymousClass) && isInheritor(candidateClass, baseClass, checkDeep, null);
+ public static boolean isInheritor(@NotNull final PsiClass candidateClass, @NotNull PsiClass baseClass, final boolean checkDeep) {
+ if (baseClass instanceof PsiAnonymousClass) return false;
+ if (!checkDeep) return isInheritor(candidateClass, baseClass, false, null);
+
+ if (CommonClassNames.JAVA_LANG_OBJECT.equals(baseClass.getQualifiedName())) return true;
+ Map<PsiClass, Boolean> map = CachedValuesManager.getManager(candidateClass.getProject()).
+ getCachedValue(candidateClass, new CachedValueProvider<Map<PsiClass, Boolean>>() {
+ @Nullable
+ @Override
+ public Result<Map<PsiClass, Boolean>> compute() {
+ final Map<PsiClass, Boolean> map = new ConcurrentHashMap<PsiClass, Boolean>();
+ return Result.create(map, candidateClass);
+ }
+ });
+
+ Boolean computed = map.get(baseClass);
+ if (computed == null) {
+ computed = isInheritor(candidateClass, baseClass, true, null);
+ map.put(baseClass, computed);
+ }
+ return computed;
}
private static boolean isInheritor(@NotNull PsiClass candidateClass, @NotNull PsiClass baseClass, boolean checkDeep, Set<PsiClass> checkedClasses) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/JavaPsiFacadeImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/JavaPsiFacadeImpl.java
index f80a099..2bde13a 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/JavaPsiFacadeImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/JavaPsiFacadeImpl.java
@@ -182,7 +182,7 @@
if (cache == null) {
myPackageCache = new SoftReference<ConcurrentMap<String, PsiPackage>>(cache = new ConcurrentHashMap<String, PsiPackage>());
}
-
+
PsiPackage aPackage = cache.get(qualifiedName);
if (aPackage != null) {
return aPackage;
@@ -352,9 +352,9 @@
ContainerUtil.quickSort(list, new Comparator<PsiClass>() {
@Override
public int compare(PsiClass o1, PsiClass o2) {
- VirtualFile file2 = PsiUtilCore.getVirtualFile(o2);
VirtualFile file1 = PsiUtilCore.getVirtualFile(o1);
- return scope.compare(file2, file1);
+ VirtualFile file2 = PsiUtilCore.getVirtualFile(o2);
+ return file1 == null ? file2 == null ? 0 : -1 : file2 == null ? 1 : scope.compare(file2, file1);
}
});
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java
index 71dff8a..a0f3e9a 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java
@@ -570,8 +570,8 @@
if (!processor.execute(candidateMethod, state.put(PsiSubstitutor.KEY, finalSubstitutor))) {
resolved = true;
}
- if (resolved) return false;
}
+ if (resolved) return false;
if (visited != null) {
for (Pair<PsiMember, PsiSubstitutor> aList : list) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiElementFactoryImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiElementFactoryImpl.java
index 120b725..9ac1dd2 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiElementFactoryImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiElementFactoryImpl.java
@@ -36,6 +36,7 @@
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.util.PsiUtil;
import com.intellij.util.IncorrectOperationException;
+import com.intellij.util.containers.ConcurrentHashMap;
import com.intellij.util.containers.HashMap;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -46,9 +47,17 @@
public class PsiElementFactoryImpl extends PsiJavaParserFacadeImpl implements PsiElementFactory {
private PsiClass myArrayClass;
private PsiClass myArrayClass15;
+ private final ConcurrentHashMap<GlobalSearchScope, PsiClassType> myCachedObjectType = new ConcurrentHashMap<GlobalSearchScope, PsiClassType>();
- public PsiElementFactoryImpl(final PsiManager manager) {
+
+ public PsiElementFactoryImpl(final PsiManagerEx manager) {
super(manager);
+ manager.registerRunnableToRunOnChange(new Runnable() {
+ @Override
+ public void run() {
+ myCachedObjectType.clear();
+ }
+ });
}
@NotNull
@@ -56,14 +65,14 @@
public PsiClass getArrayClass(@NotNull final LanguageLevel languageLevel) {
if (!languageLevel.isAtLeast(LanguageLevel.JDK_1_5)) {
if (myArrayClass == null) {
- final String body = "public class __Array__{\n public final int length;\n public Object clone() {}\n}";
+ @NonNls final String body = "public class __Array__{\n public final int length;\n public Object clone() {}\n}";
myArrayClass = createClassFromText(body, null).getInnerClasses()[0];
}
return myArrayClass;
}
else {
if (myArrayClass15 == null) {
- final String body = "public class __Array__<T>{\n public final int length;\n public T[] clone() {}\n}";
+ @NonNls final String body = "public class __Array__<T>{\n public final int length;\n public T[] clone() {}\n}";
myArrayClass15 = createClassFromText(body, null).getInnerClasses()[0];
}
return myArrayClass15;
@@ -171,7 +180,7 @@
@NotNull
@Override
public PsiTypeParameter createTypeParameter(String name, PsiClassType[] superTypes) {
- StringBuilder builder = new StringBuilder();
+ @NonNls StringBuilder builder = new StringBuilder();
builder.append("public <").append(name);
if (superTypes.length > 1) {
builder.append(" extends ");
@@ -199,7 +208,7 @@
throw new IncorrectOperationException("Cannot create field with type \"null\".");
}
- final String text = "class _Dummy_ { private " + type.getCanonicalText() + " " + name + "; }";
+ @NonNls final String text = "class _Dummy_ { private " + type.getCanonicalText() + " " + name + "; }";
final PsiJavaFile aFile = createDummyJavaFile(text);
final PsiClass[] classes = aFile.getClasses();
if (classes.length < 1) {
@@ -385,6 +394,18 @@
@NotNull
@Override
public PsiClassType createTypeByFQClassName(@NotNull final String qName, @NotNull final GlobalSearchScope resolveScope) {
+ if (CommonClassNames.JAVA_LANG_OBJECT.equals(qName)) {
+ PsiClassType cachedObjectType = myCachedObjectType.get(resolveScope);
+ if (cachedObjectType != null) {
+ return cachedObjectType;
+ }
+ PsiClass aClass = JavaPsiFacade.getInstance(myManager.getProject()).findClass(CommonClassNames.JAVA_LANG_OBJECT, resolveScope);
+ if (aClass != null) {
+ cachedObjectType = new PsiImmediateClassType(aClass, PsiSubstitutor.EMPTY);
+ cachedObjectType = myCachedObjectType.cacheOrGet(resolveScope, cachedObjectType);
+ return cachedObjectType;
+ }
+ }
return new PsiClassReferenceType(createReferenceElementByFQClassName(qName, resolveScope), null);
}
@@ -455,7 +476,7 @@
@NotNull
@Override
public PsiParameterList createParameterList(@NotNull final String[] names, @NotNull final PsiType[] types) throws IncorrectOperationException {
- final StringBuilder builder = new StringBuilder();
+ @NonNls StringBuilder builder = new StringBuilder();
builder.append("void method(");
for (int i = 0; i < names.length; i++) {
if (i > 0) builder.append(", ");
@@ -468,7 +489,7 @@
@NotNull
@Override
public PsiReferenceList createReferenceList(@NotNull final PsiJavaCodeReferenceElement[] references) throws IncorrectOperationException {
- final StringBuilder builder = new StringBuilder();
+ @NonNls final StringBuilder builder = new StringBuilder();
builder.append("void method()");
if (references.length > 0){
builder.append(" throws ");
@@ -579,7 +600,7 @@
throw new IncorrectOperationException("Cannot create variable with type \"null\".");
}
- final String text = "X " + name + (initializer != null ? " = x" : "") + ";";
+ @NonNls final String text = "X " + name + (initializer != null ? " = x" : "") + ";";
final PsiDeclarationStatement statement = (PsiDeclarationStatement)createStatementFromText(text, null);
final PsiVariable variable = (PsiVariable)statement.getDeclaredElements()[0];
@@ -596,7 +617,7 @@
@NotNull
@Override
public PsiDocTag createParamTag(@NotNull final String parameterName, @NonNls final String description) throws IncorrectOperationException {
- final StringBuilder builder = new StringBuilder();
+ @NonNls final StringBuilder builder = new StringBuilder();
builder.append(" * @param ");
builder.append(parameterName);
builder.append(" ");
@@ -718,7 +739,7 @@
throw new IncorrectOperationException("Unexpected type:" + exceptionType);
}
- final String text = "catch (" + exceptionType.getCanonicalText() + " " + exceptionName + ") {}";
+ @NonNls final String text = "catch (" + exceptionType.getCanonicalText() + " " + exceptionName + ") {}";
final DummyHolder holder = DummyHolderFactory.createHolder(myManager, new JavaDummyElement(text, CATCH_SECTION, level(context)), context);
final PsiElement element = SourceTreeToPsiMap.treeElementToPsi(holder.getTreeElement().getFirstChildNode());
if (!(element instanceof PsiCatchSection)) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiImplUtil.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiImplUtil.java
index d0f0548..13040f2 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiImplUtil.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiImplUtil.java
@@ -504,7 +504,7 @@
return normalized;
}
- private static PsiType doNormalizeWildcardByPosition(final PsiType type, final PsiExpression expression, final PsiExpression toplevel) {
+ private static PsiType doNormalizeWildcardByPosition(final PsiType type, @NotNull PsiExpression expression, final PsiExpression toplevel) {
if (type instanceof PsiCapturedWildcardType) {
return doNormalizeWildcardByPosition(((PsiCapturedWildcardType)type).getWildcard(), expression, toplevel);
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiJavaParserFacadeImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiJavaParserFacadeImpl.java
index 15492b3..717d123 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiJavaParserFacadeImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiJavaParserFacadeImpl.java
@@ -37,6 +37,7 @@
import com.intellij.psi.util.PsiUtil;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.containers.HashMap;
+import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -255,7 +256,7 @@
public PsiType createTypeFromText(@NotNull final String text, @Nullable final PsiElement context) throws IncorrectOperationException {
return createTypeInner(text, context, false);
}
-
+
@NotNull
@Override
public PsiTypeElement createTypeElementFromText(@NotNull final String text, @Nullable final PsiElement context) throws IncorrectOperationException {
@@ -327,7 +328,7 @@
return (PsiExpression)element;
}
- protected PsiJavaFile createDummyJavaFile(final String text) {
+ protected PsiJavaFile createDummyJavaFile(@NonNls final String text) {
final FileType type = JavaFileType.INSTANCE;
return (PsiJavaFile)PsiFileFactory.getInstance(myManager.getProject()).createFileFromText(DUMMY_FILE_NAME, type, text);
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiSubstitutorImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiSubstitutorImpl.java
index c7cd48a..61e71bb 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiSubstitutorImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiSubstitutorImpl.java
@@ -130,10 +130,8 @@
// First bound
return substitute(extendsTypes[0]);
}
- else {
- // Object
- return PsiType.getJavaLangObject(typeParameter.getManager(), typeParameter.getResolveScope());
- }
+ // Object
+ return PsiType.getJavaLangObject(typeParameter.getManager(), typeParameter.getResolveScope());
}
private abstract static class SubstitutionVisitorBase extends PsiTypeVisitorEx<PsiType> {
@@ -291,7 +289,7 @@
return null;
}
PsiClassType result = JavaPsiFacade.getElementFactory(aClass.getProject()).createType(aClass, createSubstitutor(hashMap), classType.getLanguageLevel());
- assert result.isValid();
+ PsiUtil.ensureValidType(result);
return result;
}
@@ -357,8 +355,8 @@
if (substitutedBoundType != null && !(substitutedBoundType instanceof PsiWildcardType) && !substitutedBoundType.equalsToText(
CommonClassNames.JAVA_LANG_OBJECT)) {
if (originalBound == null ||
- (!TypeConversionUtil.erasure(substitutedBoundType).isAssignableFrom(TypeConversionUtil.erasure(originalBound)) &&
- !TypeConversionUtil.erasure(substitutedBoundType).isAssignableFrom(originalBound))) { //erasure is essential to avoid infinite recursion
+ !TypeConversionUtil.erasure(substitutedBoundType).isAssignableFrom(TypeConversionUtil.erasure(originalBound)) &&
+ !TypeConversionUtil.erasure(substitutedBoundType).isAssignableFrom(originalBound)) { //erasure is essential to avoid infinite recursion
if (wildcardType.isExtends()) {
final PsiType glb = GenericsUtil.getGreatestLowerBound(wildcardType.getBound(), substitutedBoundType);
if (glb != null) {
@@ -375,52 +373,45 @@
}
if (captureContext != null) {
- LOG.assertTrue(substituted instanceof PsiWildcardType);
substituted = oldSubstituted instanceof PsiCapturedWildcardType && substituted == ((PsiCapturedWildcardType)oldSubstituted).getWildcard()
? oldSubstituted : PsiCapturedWildcardType.create((PsiWildcardType)substituted, captureContext);
}
return substituted;
}
- private PsiType correctExternalSubstitution(PsiType substituted, final PsiType original) {
- if (original == null) return null;
-
- if (substituted == null) {
- return original.accept(new PsiTypeVisitor<PsiType>() {
- @Override
- public PsiType visitArrayType(PsiArrayType arrayType) {
- return new PsiArrayType(arrayType.getComponentType().accept(this));
- }
-
- @Override
- public PsiType visitEllipsisType(PsiEllipsisType ellipsisType) {
- return new PsiEllipsisType(ellipsisType.getComponentType().accept(this));
- }
-
- @Override
- public PsiType visitClassType(PsiClassType classType) {
- PsiClass aClass = classType.resolve();
- if (aClass != null) {
- if (aClass instanceof PsiTypeParameter) {
- return rawTypeForTypeParameter((PsiTypeParameter)aClass);
- }
- else {
- return JavaPsiFacade.getInstance(aClass.getProject()).getElementFactory().createType(aClass);
- }
- }
- else {
- return classType;
- }
- }
-
- @Override
- public PsiType visitType(PsiType type) {
- LOG.error(type.getInternalCanonicalText());
- return null;
- }
- });
+ private PsiType correctExternalSubstitution(PsiType substituted, @NotNull PsiType original) {
+ if (substituted != null) {
+ return substituted;
}
- return substituted;
+ return original.accept(new PsiTypeVisitor<PsiType>() {
+ @Override
+ public PsiType visitArrayType(PsiArrayType arrayType) {
+ return new PsiArrayType(arrayType.getComponentType().accept(this));
+ }
+
+ @Override
+ public PsiType visitEllipsisType(PsiEllipsisType ellipsisType) {
+ return new PsiEllipsisType(ellipsisType.getComponentType().accept(this));
+ }
+
+ @Override
+ public PsiType visitClassType(PsiClassType classType) {
+ PsiClass aClass = classType.resolve();
+ if (aClass == null) {
+ return classType;
+ }
+ if (aClass instanceof PsiTypeParameter) {
+ return rawTypeForTypeParameter((PsiTypeParameter)aClass);
+ }
+ return JavaPsiFacade.getInstance(aClass.getProject()).getElementFactory().createType(aClass);
+ }
+
+ @Override
+ public PsiType visitType(PsiType type) {
+ LOG.error(type.getInternalCanonicalText());
+ return null;
+ }
+ });
}
@Override
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiSuperMethodImplUtil.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiSuperMethodImplUtil.java
index f31d87c..f32b42d 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiSuperMethodImplUtil.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiSuperMethodImplUtil.java
@@ -328,16 +328,24 @@
return map.values();
}
- @NotNull public static HierarchicalMethodSignature getHierarchicalMethodSignature(PsiMethod method) {
- PsiClass aClass = method.getContainingClass();
- HierarchicalMethodSignature result = null;
- if (aClass != null) {
- result = getSignaturesMap(aClass).get(method.getSignature(PsiSubstitutor.EMPTY));
- }
- if (result == null) {
- result = new HierarchicalMethodSignatureImpl((MethodSignatureBackedByPsiMethod)method.getSignature(PsiSubstitutor.EMPTY));
- }
- return result;
+ @NotNull
+ public static HierarchicalMethodSignature getHierarchicalMethodSignature(final PsiMethod method) {
+ return CachedValuesManager.getManager(method.getProject())
+ .getCachedValue(method, new CachedValueProvider<HierarchicalMethodSignature>() {
+ @Nullable
+ @Override
+ public Result<HierarchicalMethodSignature> compute() {
+ PsiClass aClass = method.getContainingClass();
+ HierarchicalMethodSignature result = null;
+ if (aClass != null) {
+ result = getSignaturesMap(aClass).get(method.getSignature(PsiSubstitutor.EMPTY));
+ }
+ if (result == null) {
+ result = new HierarchicalMethodSignatureImpl((MethodSignatureBackedByPsiMethod)method.getSignature(PsiSubstitutor.EMPTY));
+ }
+ return Result.create(result, PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT);
+ }
+ });
}
private static Map<MethodSignature, HierarchicalMethodSignature> getSignaturesMap(final PsiClass aClass) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsAnnotationParameterListImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsAnnotationParameterListImpl.java
index bb76064..0100ccc 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsAnnotationParameterListImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsAnnotationParameterListImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -15,6 +15,7 @@
*/
package com.intellij.psi.impl.compiled;
+import com.intellij.openapi.diagnostic.Logger;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.SourceTreeToPsiMap;
import com.intellij.psi.impl.source.tree.TreeElement;
@@ -33,7 +34,11 @@
for (int i = 0; i < myAttributes.length; i++) {
String name = psiAttributes[i].getName();
PsiAnnotationMemberValue value = psiAttributes[i].getValue();
- assert value != null : "name=" + name + " value" + value;
+ if (value == null) {
+ String anno = parent instanceof ClsAnnotationImpl ? ((ClsAnnotationImpl)parent).getStub().getText() : parent.getText();
+ Logger.getInstance(getClass()).error("name=" + name + " anno=[" + anno + "]");
+ value = new ClsLiteralExpressionImpl(this, "null", PsiType.NULL, null);
+ }
myAttributes[i] = new ClsNameValuePairImpl(this, name, value);
}
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsClassImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsClassImpl.java
index 8f0e58d..e73ac2a 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsClassImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsClassImpl.java
@@ -129,12 +129,18 @@
@Override
@NotNull
public PsiClass[] getSupers() {
+ if (CommonClassNames.JAVA_LANG_OBJECT.equals(getQualifiedName())) {
+ return PsiClass.EMPTY_ARRAY;
+ }
return PsiClassImplUtil.getSupers(this);
}
@Override
@NotNull
public PsiClassType[] getSuperTypes() {
+ if (CommonClassNames.JAVA_LANG_OBJECT.equals(getQualifiedName())) {
+ return PsiClassType.EMPTY_ARRAY;
+ }
return PsiClassImplUtil.getSuperTypes(this);
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/light/LightClassReference.java b/java/java-psi-impl/src/com/intellij/psi/impl/light/LightClassReference.java
index 10ae244..e47d896 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/light/LightClassReference.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/light/LightClassReference.java
@@ -31,7 +31,7 @@
private final PsiElement myContext;
private final GlobalSearchScope myResolveScope;
private final PsiClass myRefClass;
- private PsiSubstitutor mySubstitutor;
+ private final PsiSubstitutor mySubstitutor;
private LightReferenceParameterList myParameterList;
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiClassReferenceType.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiClassReferenceType.java
index 348f6ba..72cd0de 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiClassReferenceType.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiClassReferenceType.java
@@ -15,7 +15,6 @@
*/
package com.intellij.psi.impl.source;
-import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Comparing;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.*;
@@ -32,8 +31,7 @@
* @author max
*/
public class PsiClassReferenceType extends PsiClassType {
- private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.PsiClassReferenceType");
-
+ @NotNull
private final PsiJavaCodeReferenceElement myReference;
public PsiClassReferenceType(@NotNull PsiJavaCodeReferenceElement reference, LanguageLevel langLevel) {
@@ -173,10 +171,11 @@
return myReference.getTypeParameters();
}
+ @NotNull
public PsiClassType createImmediateCopy() {
ClassResolveResult resolveResult = resolveGenerics();
PsiClass element = resolveResult.getElement();
- return element != null ? new PsiImmediateClassType(element, resolveResult.getSubstitutor()) : this;
+ return element == null ? this : new PsiImmediateClassType(element, resolveResult.getSubstitutor());
}
@Override
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiJavaFileBaseImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiJavaFileBaseImpl.java
index e71bf63..47a1b8e 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiJavaFileBaseImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiJavaFileBaseImpl.java
@@ -142,7 +142,9 @@
StubElement<?> stub = getStub();
if (stub != null) {
PsiImportList[] nodes = stub.getChildrenByType(JavaStubElementTypes.IMPORT_LIST, PsiImportList.ARRAY_FACTORY);
- assert nodes.length == 1 : stub + "; " + stub.getChildrenStubs();
+ if (nodes.length != 1) {
+ reportStubAstMismatch(stub + "; " + stub.getChildrenStubs(), getStubTree(), PsiDocumentManager.getInstance(getProject()).getCachedDocument(this));
+ }
return nodes[0];
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiParameterImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiParameterImpl.java
index ec4cec3..bafbd37 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiParameterImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiParameterImpl.java
@@ -159,7 +159,13 @@
@Override
public PsiTypeElement getTypeElement() {
- return PsiTreeUtil.getChildOfType(this, PsiTypeElement.class);
+ for (PsiElement child = getFirstChild(); child != null; child = child.getNextSibling()) {
+ if (child instanceof PsiTypeElement) {
+ //noinspection unchecked
+ return (PsiTypeElement)child;
+ }
+ }
+ return null;
}
@Override
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/InferenceGraphNode.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/InferenceGraphNode.java
new file mode 100644
index 0000000..221f482
--- /dev/null
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/InferenceGraphNode.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2000-2013 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.psi.impl.source.resolve;
+
+import com.intellij.psi.PsiTypeParameter;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Stack;
+
+/**
+ * User: anna
+ * Date: 7/4/13
+ */
+public class InferenceGraphNode<T> {
+ private final T myValue;
+ private final List<InferenceGraphNode<T>> myDependencies = new ArrayList<InferenceGraphNode<T>>();
+
+ private int index = -1;
+ private int lowlink;
+
+ public InferenceGraphNode(T value) {
+ myValue = value;
+ }
+
+ public T getValue() {
+ return myValue;
+ }
+
+ public List<InferenceGraphNode<T>> getDependencies() {
+ return myDependencies;
+ }
+
+ public void addDependency(InferenceGraphNode<T> node) {
+ myDependencies.add(node);
+ }
+
+ public static <T> List<List<InferenceGraphNode<T>>> tarjan(Collection<InferenceGraphNode<T>> nodes) {
+ final ArrayList<List<InferenceGraphNode<T>>> result = new ArrayList<List<InferenceGraphNode<T>>>();
+ final Stack<InferenceGraphNode<T>> currentStack = new Stack<InferenceGraphNode<T>>();
+ int index = 0;
+ for (InferenceGraphNode<T> node : nodes) {
+ if (node.index == -1) {
+ index += strongConnect(node, index, currentStack, result);
+ }
+ }
+ return result;
+ }
+
+ private static <T> int strongConnect(InferenceGraphNode<T> currentNode,
+ int index,
+ Stack<InferenceGraphNode<T>> currentStack,
+ ArrayList<List<InferenceGraphNode<T>>> result) {
+ currentNode.index = index;
+ currentNode.lowlink = index;
+ index++;
+
+ currentStack.push(currentNode);
+
+ for (InferenceGraphNode<T> dependantNode : currentNode.getDependencies()) {
+ if (dependantNode.index == -1) {
+ strongConnect(dependantNode, index, currentStack, result);
+ currentNode.lowlink = Math.min(currentNode.lowlink, dependantNode.lowlink);
+ }
+ else if (currentStack.contains(dependantNode)) {
+ currentNode.lowlink = Math.min(currentNode.lowlink, dependantNode.index);
+ }
+ }
+
+ if (currentNode.lowlink == currentNode.index) {
+ final ArrayList<InferenceGraphNode<T>> arrayList = new ArrayList<InferenceGraphNode<T>>();
+ InferenceGraphNode<T> cyclicNode;
+ do {
+ cyclicNode = currentStack.pop();
+ arrayList.add(cyclicNode);
+ }
+ while (cyclicNode != currentNode);
+ result.add(arrayList);
+ }
+ return index;
+ }
+}
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/JavaResolveCache.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/JavaResolveCache.java
index d17355f..7389517 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/JavaResolveCache.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/JavaResolveCache.java
@@ -32,7 +32,6 @@
import com.intellij.psi.impl.source.PsiImmediateClassType;
import com.intellij.psi.util.TypeConversionUtil;
import com.intellij.reference.SoftReference;
-import com.intellij.util.ConcurrencyUtil;
import com.intellij.util.Function;
import com.intellij.util.containers.ConcurrentWeakHashMap;
import com.intellij.util.messages.MessageBus;
@@ -96,10 +95,8 @@
}
if (type == null) type = TypeConversionUtil.NULL_TYPE;
Reference<PsiType> ref = new SoftReference<PsiType>(type);
- Reference<PsiType> storedRef = ConcurrencyUtil.cacheOrGet(myCalculatedTypes, expr, ref);
+ myCalculatedTypes.put(expr, ref);
- PsiType stored = ref == storedRef ? type : storedRef.get();
- type = stored == null ? type : stored;
if (type instanceof PsiClassReferenceType) {
// convert reference-based class type to the PsiImmediateClassType, since the reference may become invalid
PsiClassType.ClassResolveResult result = ((PsiClassReferenceType)type).resolveGenerics();
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java
index 60be7ad..6dd5439 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java
@@ -361,6 +361,7 @@
@SuppressWarnings("unchecked")
Pair<PsiType, ConstraintType>[] constraints = new Pair[typeParameters.length];
PsiFile file = parent.getContainingFile();
+ LOG.assertTrue(file != null, parent);
final PsiManager manager = file.getManager();
final LanguageLevel languageLevel = PsiUtil.getLanguageLevel(file);
for (int i = 0; i < typeParameters.length; i++) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiReferenceExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiReferenceExpressionImpl.java
index 550da84..4b2dc0b 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiReferenceExpressionImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiReferenceExpressionImpl.java
@@ -46,15 +46,14 @@
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
import com.intellij.psi.util.TypeConversionUtil;
-import com.intellij.util.CharTable;
-import com.intellij.util.Function;
-import com.intellij.util.IncorrectOperationException;
-import com.intellij.util.NullableFunction;
+import com.intellij.util.*;
+import com.intellij.util.containers.Stack;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.Set;
@@ -185,6 +184,14 @@
private static final class OurGenericsResolver implements ResolveCache.PolyVariantResolver<PsiJavaReference> {
private static final OurGenericsResolver INSTANCE = new OurGenericsResolver();
+ @SuppressWarnings("SSBasedInspection")
+ private static final ThreadLocal<Stack<Object>> ourQualifiers = new ThreadLocal<Stack<Object>>() {
+ @Override
+ protected Stack<Object> initialValue() {
+ return new Stack<Object>();
+ }
+ };
+
@Override
@NotNull
public JavaResolveResult[] resolve(@NotNull PsiJavaReference ref, boolean incompleteCode) {
@@ -192,29 +199,43 @@
CompositeElement treeParent = expression.getTreeParent();
IElementType parentType = treeParent == null ? null : treeParent.getElementType();
PsiFile file = expression.getContainingFile();
- resolveAllQualifiers(expression, file);
- JavaResolveResult[] result = expression.resolve(parentType, file);
- if (result.length == 0 && incompleteCode && parentType != JavaElementType.REFERENCE_EXPRESSION) {
- result = expression.resolve(JavaElementType.REFERENCE_EXPRESSION, file);
+ List<ResolveResult[]> qualifierResults = resolveAllQualifiers(expression, file);
+ ourQualifiers.get().push(qualifierResults);
+ try {
+ JavaResolveResult[] result = expression.resolve(parentType, file);
+
+ if (result.length == 0 && incompleteCode && parentType != JavaElementType.REFERENCE_EXPRESSION) {
+ result = expression.resolve(JavaElementType.REFERENCE_EXPRESSION, file);
+ }
+
+ JavaResolveUtil.substituteResults(expression, result);
+
+ return result;
}
-
- JavaResolveUtil.substituteResults(expression, result);
-
- return result;
+ finally {
+ ourQualifiers.get().pop();
+ }
}
- private static void resolveAllQualifiers(@NotNull PsiReferenceExpressionImpl expression, final PsiFile containingFile) {
+ private static List<ResolveResult[]> resolveAllQualifiers(@NotNull PsiReferenceExpressionImpl expression, final PsiFile containingFile) {
// to avoid SOE, resolve all qualifiers starting from the innermost
PsiElement qualifier = expression.getQualifier();
- if (qualifier == null) return;
+ if (qualifier == null) return Collections.emptyList();
+
+ final List<ResolveResult[]> qualifierResults = new SmartList<ResolveResult[]>();
final ResolveCache resolveCache = ResolveCache.getInstance(containingFile.getProject());
qualifier.accept(new JavaRecursiveElementWalkingVisitor() {
@Override
public void visitReferenceExpression(PsiReferenceExpression expression) {
- if (!(expression instanceof PsiReferenceExpressionImpl) || resolveCache.isCached(expression, true, false, true)) {
+ if (!(expression instanceof PsiReferenceExpressionImpl)) {
return;
}
+ ResolveResult[] cachedResults = resolveCache.getCachedResults(expression, true, false, true);
+ if (cachedResults == null) {
+ return;
+ }
+ qualifierResults.add(cachedResults);
visitElement(expression);
}
@@ -222,9 +243,10 @@
protected void elementFinished(PsiElement element) {
if (!(element instanceof PsiReferenceExpressionImpl)) return;
PsiReferenceExpressionImpl expression = (PsiReferenceExpressionImpl)element;
- resolveCache.resolveWithCaching(expression, INSTANCE, false, false, containingFile);
+ qualifierResults.add(resolveCache.resolveWithCaching(expression, INSTANCE, false, false, containingFile));
}
});
+ return qualifierResults;
}
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiResourceListImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiResourceListImpl.java
index fcc7d7e..3f0878c 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiResourceListImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiResourceListImpl.java
@@ -68,6 +68,7 @@
public void deleteChildInternal(@NotNull final ASTNode child) {
if (child.getPsi() instanceof PsiResourceVariable && getResourceVariablesCount() == 1) {
getTreeParent().deleteChildInternal(this);
+ return;
}
super.deleteChildInternal(child);
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiTryStatementImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiTryStatementImpl.java
index 3eefe91..5af4858 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiTryStatementImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiTryStatementImpl.java
@@ -181,6 +181,26 @@
return true;
}
+ @Override
+ public void deleteChildInternal(@NotNull ASTNode child) {
+ if (child.getPsi() instanceof PsiResourceList && getCatchBlocks().length == 0 && getFinallyBlock() == null) {
+ final PsiCodeBlock tryBlock = getTryBlock();
+ if (tryBlock != null) {
+ final PsiCodeBlock block = (PsiCodeBlock)replace(tryBlock);
+ final PsiJavaToken lBrace = block.getLBrace();
+ final PsiJavaToken rBrace = block.getRBrace();
+ if (lBrace != null) {
+ lBrace.delete();
+ }
+ if (rBrace != null) {
+ rBrace.delete();
+ }
+ return;
+ }
+ }
+ super.deleteChildInternal(child);
+ }
+
public String toString() {
return "PsiTryStatement";
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java b/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java
index f4b8aea..f74d883 100644
--- a/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java
+++ b/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java
@@ -28,15 +28,14 @@
import com.intellij.psi.scope.PsiConflictResolver;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.util.*;
+import com.intellij.util.containers.HashSet;
+import gnu.trove.THashMap;
import gnu.trove.THashSet;
import gnu.trove.TIntArrayList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
/**
* Created by IntelliJ IDEA.
@@ -102,6 +101,7 @@
}
private void checkLambdaApplicable(List<CandidateInfo> conflicts) {
+ if (!PsiUtil.isLanguageLevel8OrHigher(myArgumentsList)) return;
for (int i = 0; i < myActualParameterTypes.length; i++) {
PsiType parameterType = myActualParameterTypes[i];
if (parameterType instanceof PsiLambdaExpressionType) {
@@ -190,7 +190,17 @@
private void checkSameSignatures(final List<CandidateInfo> conflicts) {
// candidates should go in order of class hierarchy traversal
// in order for this to work
- Map<MethodSignature, CandidateInfo> signatures = new HashMap<MethodSignature, CandidateInfo>();
+ Map<MethodSignature, CandidateInfo> signatures = new THashMap<MethodSignature, CandidateInfo>(conflicts.size());
+ Set<PsiMethod> superMethods = new HashSet<PsiMethod>();
+ for (CandidateInfo conflict : conflicts) {
+ final PsiMethod method = ((MethodCandidateInfo)conflict).getElement();
+ for (HierarchicalMethodSignature methodSignature : method.getHierarchicalMethodSignature().getSuperSignatures()) {
+ final PsiMethod superMethod = methodSignature.getMethod();
+ if (!CommonClassNames.JAVA_LANG_OBJECT.equals(superMethod.getContainingClass().getQualifiedName())) {
+ superMethods.add(superMethod);
+ }
+ }
+ }
nextConflict:
for (int i=0; i<conflicts.size();i++) {
ProgressManager.checkCanceled();
@@ -198,16 +208,10 @@
PsiMethod method = (PsiMethod)info.getElement();
assert method != null;
- if (!method.hasModifierProperty(PsiModifier.STATIC)) {
- for (int k=i-1; k>=0; k--) {
- ProgressManager.checkCanceled();
- PsiMethod existingMethod = (PsiMethod)conflicts.get(k).getElement();
- if (PsiSuperMethodImplUtil.isSuperMethodSmart(existingMethod, method)) {
- conflicts.remove(i);
- i--;
- continue nextConflict;
- }
- }
+ if (!method.hasModifierProperty(PsiModifier.STATIC) && superMethods.contains(method)) {
+ conflicts.remove(i);
+ i--;
+ continue;
}
PsiClass class1 = method.getContainingClass();
diff --git a/java/java-psi-impl/src/com/intellij/refactoring/util/duplicates/DuplicatesFinder.java b/java/java-psi-impl/src/com/intellij/refactoring/util/duplicates/DuplicatesFinder.java
index d44b9d8..7540384 100644
--- a/java/java-psi-impl/src/com/intellij/refactoring/util/duplicates/DuplicatesFinder.java
+++ b/java/java-psi-impl/src/com/intellij/refactoring/util/duplicates/DuplicatesFinder.java
@@ -394,6 +394,12 @@
match.registerReturnValue(new ContinueReturnValue());
} else if (pattern instanceof PsiBreakStatement) {
match.registerReturnValue(new BreakReturnValue());
+ }else if (pattern instanceof PsiMethodCallExpression) {
+ final PsiMethod patternMethod = ((PsiMethodCallExpression)pattern).resolveMethod();
+ final PsiMethod candidateMethod = ((PsiMethodCallExpression)candidate).resolveMethod();
+ if (patternMethod != null && candidateMethod != null) {
+ if (!MethodSignatureUtil.areSignaturesEqual(patternMethod, candidateMethod)) return false;
+ }
} else if (pattern instanceof PsiReferenceExpression) {
final PsiReferenceExpression patternRefExpr = (PsiReferenceExpression)pattern;
final PsiReferenceExpression candidateRefExpr = (PsiReferenceExpression)candidate;
diff --git a/java/java-tests/testData/codeInsight/completion/smartType/CastWithGenerics-out.java b/java/java-tests/testData/codeInsight/completion/smartType/CastWithGenerics-out.java
index 9e5e012..39f34e4 100644
--- a/java/java-tests/testData/codeInsight/completion/smartType/CastWithGenerics-out.java
+++ b/java/java-tests/testData/codeInsight/completion/smartType/CastWithGenerics-out.java
@@ -1,9 +1,9 @@
public class Aaaaaaa {
- void foo(Class<? extends Object> c) {}
+ void foo(Class<? extends Aaaaaaa> c) {}
void bar() {
- foo((Class<Object>) <caret>Class.forName("sdd"));
+ foo((Class<? extends Aaaaaaa>) <caret>Class.forName("sdd"));
}
}
diff --git a/java/java-tests/testData/codeInsight/completion/smartType/CastWithGenerics.java b/java/java-tests/testData/codeInsight/completion/smartType/CastWithGenerics.java
index 8e3735a..fa75169 100644
--- a/java/java-tests/testData/codeInsight/completion/smartType/CastWithGenerics.java
+++ b/java/java-tests/testData/codeInsight/completion/smartType/CastWithGenerics.java
@@ -1,6 +1,6 @@
public class Aaaaaaa {
- void foo(Class<? extends Object> c) {}
+ void foo(Class<? extends Aaaaaaa> c) {}
void bar() {
foo((<caret>Class.forName("sdd"));
diff --git a/java/java-tests/testData/codeInsight/completion/smartType/DiamondNotCollapsed-out.java b/java/java-tests/testData/codeInsight/completion/smartType/DiamondNotCollapsed-out.java
index b0e0ac5..7ac0b4f 100644
--- a/java/java-tests/testData/codeInsight/completion/smartType/DiamondNotCollapsed-out.java
+++ b/java/java-tests/testData/codeInsight/completion/smartType/DiamondNotCollapsed-out.java
@@ -1,6 +1,6 @@
class MyClass {
public void foo() {
- MyDD<String> d = new MyDD<String>(<caret>);
+ MyDD<String> d = new MyDD<>(<caret>);
}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/NoUnhandledExceptionsMultipleInheritance.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/NoUnhandledExceptionsMultipleInheritance.java
new file mode 100644
index 0000000..327bc82
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/NoUnhandledExceptionsMultipleInheritance.java
@@ -0,0 +1,77 @@
+import java.io.*;
+
+interface ThrowsCloneNotSupportedException {
+ void f() throws CloneNotSupportedException;
+}
+
+interface ThrowsIOException {
+ void f() throws IOException;
+}
+
+abstract class ThrowsNothing implements ThrowsCloneNotSupportedException, ThrowsIOException {
+ private void foo() {
+ f();
+ }
+}
+
+class Main {
+ public static void main(String[] args) {
+ ThrowsNothing throwsNothing = null;
+ throwsNothing.f();
+ }
+}
+
+
+interface A {
+ void close() throws Exception;
+}
+
+interface B {
+ void close() throws IOException;
+}
+
+abstract class AB implements A, B {}
+abstract class BA implements B, A {}
+
+class ABUsage {
+ void foo(AB ab) {
+ try {
+ ab.close();
+ }
+ catch (IOException ignored) {}
+ }
+
+ void foo(BA ba) {
+ try {
+ ba.close();
+ }
+ catch (IOException ignored) {}
+ }
+}
+
+interface C {
+ void close();
+}
+
+interface D {
+ void close() throws IOException;
+}
+
+abstract class CD implements C, D {}
+abstract class DC implements D, C {}
+
+class CDUsage {
+ void foo(CD cd) {
+ try {
+ cd.close();
+ }
+ catch (<error descr="Exception 'java.io.IOException' is never thrown in the corresponding try block">IOException ignored</error>) {}
+ }
+
+ void foo(DC dc) {
+ try {
+ dc.close();
+ }
+ catch (<error descr="Exception 'java.io.IOException' is never thrown in the corresponding try block">IOException ignored</error>) {}
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA109875.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA109875.java
new file mode 100644
index 0000000..a70b094
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA109875.java
@@ -0,0 +1,13 @@
+import java.util.Collections;
+import java.util.Set;
+
+public class Test<Y> {
+
+ public static <K> Test<K> doTest(K k){
+ return null;
+ }
+
+ public static void main(String[] args) {
+ Test.<Set<String>>doTest<error descr="'doTest(java.util.Set<java.lang.String>)' in 'Test' cannot be applied to '(java.util.Set<java.lang.Object>)'">(Collections.emptySet())</error>;
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA67672.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA67672.java
index 939ce3f..db8282f 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA67672.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA67672.java
@@ -3,5 +3,5 @@
interface A
{
- <<error descr="'addAll(Collection<? extends E>)' in 'java.util.Collection' clashes with 'addAll(Collection<? extends E>)' in 'java.util.List'; both methods have same erasure, yet neither overrides the other"></error>T extends List<?> & Collection<? extends Cloneable>> void foo(T x);
+ <<error descr="'add(E)' in 'java.util.List' clashes with 'add(E)' in 'java.util.Collection'; both methods have same erasure, yet neither overrides the other"></error>T extends List<?> & Collection<? extends Cloneable>> void foo(T x);
}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/MethodSignatureEquality.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/MethodSignatureEquality.java
index e41b471..cabf948 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/MethodSignatureEquality.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/MethodSignatureEquality.java
@@ -70,7 +70,7 @@
abstract class F<T extends Throwable> {
<error descr="'foo(F<?>)' is already defined in 'Test.F'">abstract void foo(F<?> y)</error>;
- abstract void foo(F<? extends Throwable> y);
+ <error descr="'foo(F<? extends Throwable>)' is already defined in 'Test.F'">abstract void foo(F<? extends Throwable> y)</error>;
}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/SOEInLeastUpperClass.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/SOEInLeastUpperClass.java
new file mode 100644
index 0000000..70ad266
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/SOEInLeastUpperClass.java
@@ -0,0 +1,12 @@
+<error descr="Cyclic inheritance involving 'A'">interface A extends A</error> {}
+interface B {}
+
+<error descr="Cyclic inheritance involving 'A'">class T implements A, B</error>{
+ <T1> T1 foo(A a, B b) {
+ return null;
+ }
+
+ void bar (boolean a, A a1, B b1){
+ <error descr="Incompatible types. Found: 'java.lang.Object', required: 'T'">T t = a ? a1 : b1;</error>
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addMethodBody/afterDefaultMethod.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addMethodBody/afterDefaultMethod.java
new file mode 100644
index 0000000..d11590f
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addMethodBody/afterDefaultMethod.java
@@ -0,0 +1,7 @@
+// "Add Method Body" "true"
+interface a {
+ default String f() {
+ <selection>return null;</selection>
+ }
+}
+
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addMethodBody/beforeDefaultMethod.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addMethodBody/beforeDefaultMethod.java
new file mode 100644
index 0000000..65bd47a
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addMethodBody/beforeDefaultMethod.java
@@ -0,0 +1,5 @@
+// "Add Method Body" "true"
+interface a {
+ default <caret>String f();
+}
+
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/convert2Local/afterMultipleMethods.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/convert2Local/afterMultipleMethods.java
new file mode 100644
index 0000000..d5d911a
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/convert2Local/afterMultipleMethods.java
@@ -0,0 +1,13 @@
+// "Convert to local" "true"
+class Test {
+
+ int getFoo1() {
+ int myFoo = 1;
+ return myFoo;
+ }
+
+ int getFoo2() {
+ int myFoo = 2;
+ return myFoo;
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/convert2Local/beforeMultipleMethods.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/convert2Local/beforeMultipleMethods.java
new file mode 100644
index 0000000..f4afcf9
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/convert2Local/beforeMultipleMethods.java
@@ -0,0 +1,14 @@
+// "Convert to local" "true"
+class Test {
+ private int my<caret>Foo;
+
+ int getFoo1() {
+ myFoo = 1;
+ return myFoo;
+ }
+
+ int getFoo2() {
+ myFoo = 2;
+ return myFoo;
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createLocalFromUsage/afterAnonymous.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createLocalFromUsage/afterAnonymous.java
new file mode 100644
index 0000000..8de7067
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createLocalFromUsage/afterAnonymous.java
@@ -0,0 +1,7 @@
+// "Create Local Variable 'zeit'" "true"
+public class A {
+ {
+ Object zeit;
+ Runnable r = new Runnable(zeit) {};
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createLocalFromUsage/afterWildcard.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createLocalFromUsage/afterWildcard.java
new file mode 100644
index 0000000..2d533da
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createLocalFromUsage/afterWildcard.java
@@ -0,0 +1,8 @@
+// "Create Local Variable 'a'" "true"
+public class A {
+ void foo() {
+ Class<?>[] a = get();
+ }
+
+ Class<?>[] get() {return null;}
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createLocalFromUsage/beforeAnonymous.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createLocalFromUsage/beforeAnonymous.java
new file mode 100644
index 0000000..1062727
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createLocalFromUsage/beforeAnonymous.java
@@ -0,0 +1,6 @@
+// "Create Local Variable 'zeit'" "true"
+public class A {
+ {
+ Runnable r = new Runnable(ze<caret>it) {};
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createLocalFromUsage/beforeAnonymousInField.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createLocalFromUsage/beforeAnonymousInField.java
new file mode 100644
index 0000000..47da144
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createLocalFromUsage/beforeAnonymousInField.java
@@ -0,0 +1,4 @@
+// "Create Local Variable 'zeit'" "false"
+public class A {
+ Runnable r = new Runnable(ze<caret>it) {};
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createLocalFromUsage/beforeWildcard.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createLocalFromUsage/beforeWildcard.java
new file mode 100644
index 0000000..d04bee5
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createLocalFromUsage/beforeWildcard.java
@@ -0,0 +1,8 @@
+// "Create Local Variable 'a'" "true"
+public class A {
+ void foo() {
+ <caret>a = get();
+ }
+
+ Class<?>[] get() {return null;}
+}
diff --git a/java/java-tests/testData/codeInsight/generate/generateCreateUI/beforeSOE.java b/java/java-tests/testData/codeInsight/generate/generateCreateUI/beforeSOE.java
new file mode 100644
index 0000000..24218d5
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/generate/generateCreateUI/beforeSOE.java
@@ -0,0 +1,3 @@
+class A extends A {
+ <caret>
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/overrideImplement/afterMultipleInheritedThrows.java b/java/java-tests/testData/codeInsight/overrideImplement/afterMultipleInheritedThrows.java
new file mode 100644
index 0000000..688387c
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/overrideImplement/afterMultipleInheritedThrows.java
@@ -0,0 +1,17 @@
+import java.io.*;
+interface A {
+ void close() throws Exception;
+}
+
+interface B {
+ void close() throws IOException;
+}
+
+interface C<T extends Exception> {
+ void close() throws T;
+}
+
+interface AB extends A, C, B {
+ @Override
+ void close() throws IOException;
+}
diff --git a/java/java-tests/testData/codeInsight/overrideImplement/afterOverrideInInterface.java b/java/java-tests/testData/codeInsight/overrideImplement/afterOverrideInInterface.java
new file mode 100644
index 0000000..d314284
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/overrideImplement/afterOverrideInInterface.java
@@ -0,0 +1,8 @@
+interface A {
+ void foo();
+}
+
+interface B extends A {
+ @Override
+ void foo();
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/overrideImplement/afterSkipUnknownAnnotations.java b/java/java-tests/testData/codeInsight/overrideImplement/afterSkipUnknownAnnotations.java
new file mode 100644
index 0000000..004a0c0
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/overrideImplement/afterSkipUnknownAnnotations.java
@@ -0,0 +1,9 @@
+interface A {
+ void f(@Unknown1 @Unknown2 String s, @Unknown3 s3);
+}
+class B implements A {
+ @Override
+ public void f(String s) {
+
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/overrideImplement/beforeMultipleInheritedThrows.java b/java/java-tests/testData/codeInsight/overrideImplement/beforeMultipleInheritedThrows.java
new file mode 100644
index 0000000..8b66b89
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/overrideImplement/beforeMultipleInheritedThrows.java
@@ -0,0 +1,16 @@
+import java.io.*;
+interface A {
+ void close() throws Exception;
+}
+
+interface B {
+ void close() throws IOException;
+}
+
+interface C<T extends Exception> {
+ void close() throws T;
+}
+
+interface AB extends A, C, B {
+ <caret>
+}
diff --git a/java/java-tests/testData/codeInsight/overrideImplement/beforeOverrideInInterface.java b/java/java-tests/testData/codeInsight/overrideImplement/beforeOverrideInInterface.java
new file mode 100644
index 0000000..dde843d
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/overrideImplement/beforeOverrideInInterface.java
@@ -0,0 +1,7 @@
+interface A {
+ void foo();
+}
+
+interface B extends A {
+ <caret>
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/overrideImplement/beforeSkipUnknownAnnotations.java b/java/java-tests/testData/codeInsight/overrideImplement/beforeSkipUnknownAnnotations.java
new file mode 100644
index 0000000..870a74e
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/overrideImplement/beforeSkipUnknownAnnotations.java
@@ -0,0 +1,6 @@
+interface A {
+ void f(@Unknown1 @Unknown2 String s, @Unknown3 s3);
+}
+class B implements A {
+ <caret>
+}
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/CatchThrowable.java b/java/java-tests/testData/inspection/dataFlow/fixture/CatchThrowable.java
new file mode 100644
index 0000000..b055937
--- /dev/null
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/CatchThrowable.java
@@ -0,0 +1,26 @@
+public class BrokenAlignment {
+
+ public static void main(String[] args) {
+
+ Throwable error = null;
+ try {
+ doSomething();
+ } catch (AssertionError e) {
+ // rethrow error
+ throw e;
+ } catch (Throwable e) {
+ // remember error
+ error = e;
+ }
+
+ if (error != null) { // <<--- inspection warning
+ // handle error ...
+ }
+
+ }
+
+ public static void doSomething() {
+ throw new RuntimeException("dummy");
+ }
+
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/HonorGetterAnnotation.java b/java/java-tests/testData/inspection/dataFlow/fixture/HonorGetterAnnotation.java
new file mode 100644
index 0000000..fa72072
--- /dev/null
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/HonorGetterAnnotation.java
@@ -0,0 +1,19 @@
+import org.jetbrains.annotations.Nullable;
+
+public class Goo {
+ Permission permission;
+
+ {
+ Object category = permission.getCategory();
+ System.out.println(<warning descr="Method invocation 'category.hashCode()' may produce 'java.lang.NullPointerException'">category.hashCode()</warning>);
+ }
+}
+
+class Permission {
+ Object category;
+
+
+ @Nullable Object getCategory() {
+ return category;
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/IgnoreAssertions.java b/java/java-tests/testData/inspection/dataFlow/fixture/IgnoreAssertions.java
new file mode 100644
index 0000000..5fa6f05
--- /dev/null
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/IgnoreAssertions.java
@@ -0,0 +1,10 @@
+class Foo {
+ Object getObjectFromElsewhere() { return null; }
+ void foo() {
+ Object object = getObjectFromElsewhere();
+ assert (object != null);
+ if (object != null) {
+ return;
+ }
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/redundantCast/generics/GetClassProcessing/expected.xml b/java/java-tests/testData/inspection/redundantCast/generics/GetClassProcessing/expected.xml
new file mode 100644
index 0000000..4704d91
--- /dev/null
+++ b/java/java-tests/testData/inspection/redundantCast/generics/GetClassProcessing/expected.xml
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<problems/>
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/redundantCast/generics/GetClassProcessing/src/Test.java b/java/java-tests/testData/inspection/redundantCast/generics/GetClassProcessing/src/Test.java
new file mode 100644
index 0000000..0fa9d05
--- /dev/null
+++ b/java/java-tests/testData/inspection/redundantCast/generics/GetClassProcessing/src/Test.java
@@ -0,0 +1,10 @@
+class B { }
+class A extends B { }
+
+class C {
+ void m(Class<? extends A> c) {}
+
+ void x(B b) {
+ m(((A)b).getClass());
+ }
+}
diff --git a/java/java-tests/testData/psi/parser-full/expressionParsing/QualifiedSuperMethodCall.txt b/java/java-tests/testData/psi/parser-full/expressionParsing/QualifiedSuperMethodCall.txt
index 02cb11f..0905da3 100644
--- a/java/java-tests/testData/psi/parser-full/expressionParsing/QualifiedSuperMethodCall.txt
+++ b/java/java-tests/testData/psi/parser-full/expressionParsing/QualifiedSuperMethodCall.txt
@@ -58,6 +58,8 @@
PsiJavaToken:LPARENTH('(')
PsiJavaToken:RPARENTH(')')
PsiJavaToken:DOT('.')
+ PsiReferenceParameterList
+ <empty list>
PsiKeyword:super('super')
PsiExpressionList
PsiJavaToken:LPARENTH('(')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/QualifiedSuperMethodCall0.txt b/java/java-tests/testData/psi/parser-partial/expressions/QualifiedSuperMethodCall0.txt
index 6b22700..452d64a 100644
--- a/java/java-tests/testData/psi/parser-partial/expressions/QualifiedSuperMethodCall0.txt
+++ b/java/java-tests/testData/psi/parser-partial/expressions/QualifiedSuperMethodCall0.txt
@@ -14,6 +14,8 @@
PsiJavaToken:LPARENTH('(')
PsiJavaToken:RPARENTH(')')
PsiJavaToken:DOT('.')
+ PsiReferenceParameterList
+ <empty list>
PsiKeyword:super('super')
PsiExpressionList
PsiJavaToken:LPARENTH('(')
diff --git a/java/java-tests/testData/refactoring/extractMethod/OverloadedMethods.java b/java/java-tests/testData/refactoring/extractMethod/OverloadedMethods.java
new file mode 100644
index 0000000..a951ea0
--- /dev/null
+++ b/java/java-tests/testData/refactoring/extractMethod/OverloadedMethods.java
@@ -0,0 +1,21 @@
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+
+public class Test {
+ public void myTest(List list, String s1, String s2) {
+ }
+
+ public void myTest(Collection list, String s1, String s2) {
+ }
+
+ public void usage() {
+ List list = new ArrayList();
+ String aa = "AA";
+ String bb = "bb";
+ myTest(list, aa, bb);
+ Collection col = new ArrayList();
+ <selection>myTest(col, aa, bb);</selection>
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/extractMethod/OverloadedMethods_after.java b/java/java-tests/testData/refactoring/extractMethod/OverloadedMethods_after.java
new file mode 100644
index 0000000..dd8e4c5
--- /dev/null
+++ b/java/java-tests/testData/refactoring/extractMethod/OverloadedMethods_after.java
@@ -0,0 +1,25 @@
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+
+public class Test {
+ public void myTest(List list, String s1, String s2) {
+ }
+
+ public void myTest(Collection list, String s1, String s2) {
+ }
+
+ public void usage() {
+ List list = new ArrayList();
+ String aa = "AA";
+ String bb = "bb";
+ myTest(list, aa, bb);
+ Collection col = new ArrayList();
+ newMethod(aa, bb, col);
+ }
+
+ private void newMethod(String aa, String bb, Collection col) {
+ myTest(col, aa, bb);
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/extractSuperClass/emptyForeach/after/Test.java b/java/java-tests/testData/refactoring/extractSuperClass/emptyForeach/after/Test.java
new file mode 100644
index 0000000..7442184
--- /dev/null
+++ b/java/java-tests/testData/refactoring/extractSuperClass/emptyForeach/after/Test.java
@@ -0,0 +1,3 @@
+public class Test {
+ public void m() {}
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/extractSuperClass/emptyForeach/after/TestSubclass.java b/java/java-tests/testData/refactoring/extractSuperClass/emptyForeach/after/TestSubclass.java
new file mode 100644
index 0000000..840eeb4
--- /dev/null
+++ b/java/java-tests/testData/refactoring/extractSuperClass/emptyForeach/after/TestSubclass.java
@@ -0,0 +1,18 @@
+import java.util.List;
+
+class TestSubclass extends Test {
+}
+
+
+class Base {
+ public void main(List<Test> tests) {
+ for (Test test : tests) {}
+ }
+}
+
+class Inheritor extends Base {
+ @Override
+ public void main(List<Test> tests) {
+ super.main(tests);
+ }
+}
diff --git a/java/java-tests/testData/refactoring/extractSuperClass/emptyForeach/before/Test.java b/java/java-tests/testData/refactoring/extractSuperClass/emptyForeach/before/Test.java
new file mode 100644
index 0000000..a490e06
--- /dev/null
+++ b/java/java-tests/testData/refactoring/extractSuperClass/emptyForeach/before/Test.java
@@ -0,0 +1,19 @@
+import java.util.List;
+
+class Test {
+ public void m() {}
+}
+
+
+class Base {
+ public void main(List<Test> tests) {
+ for (Test test : tests) {}
+ }
+}
+
+class Inheritor extends Base {
+ @Override
+ public void main(List<Test> tests) {
+ super.main(tests);
+ }
+}
diff --git a/java/java-tests/testData/refactoring/inlineLocal/ArrayMethodCallInitialized.java b/java/java-tests/testData/refactoring/inlineLocal/ArrayMethodCallInitialized.java
new file mode 100644
index 0000000..aa7c17c
--- /dev/null
+++ b/java/java-tests/testData/refactoring/inlineLocal/ArrayMethodCallInitialized.java
@@ -0,0 +1,11 @@
+public class A {
+
+ public void testInlineRefactoring() {
+ int[] array = ar();
+ arr<caret>ay[1] = 22;
+ }
+
+ private int[] ar() {
+ return new int[0];
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/inlineLocal/ArrayMethodCallInitialized.java.after b/java/java-tests/testData/refactoring/inlineLocal/ArrayMethodCallInitialized.java.after
new file mode 100644
index 0000000..72d6b9f
--- /dev/null
+++ b/java/java-tests/testData/refactoring/inlineLocal/ArrayMethodCallInitialized.java.after
@@ -0,0 +1,10 @@
+public class A {
+
+ public void testInlineRefactoring() {
+ ar()[1] = 22;
+ }
+
+ private int[] ar() {
+ return new int[0];
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/inlineLocal/ResourceVariable.java b/java/java-tests/testData/refactoring/inlineLocal/ResourceVariable.java
new file mode 100644
index 0000000..db06692
--- /dev/null
+++ b/java/java-tests/testData/refactoring/inlineLocal/ResourceVariable.java
@@ -0,0 +1,9 @@
+class Test {
+ void m() throws Exception {
+ try (AutoCloseable inl<caret>ineMe = null) {
+ try (AutoCloseable r2 = inlineMe) {
+ System.out.println(inlineMe + ", " + r2);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/inlineLocal/ResourceVariable.java.after b/java/java-tests/testData/refactoring/inlineLocal/ResourceVariable.java.after
new file mode 100644
index 0000000..0ec3906
--- /dev/null
+++ b/java/java-tests/testData/refactoring/inlineLocal/ResourceVariable.java.after
@@ -0,0 +1,7 @@
+class Test {
+ void m() throws Exception {
+ try (AutoCloseable r2 = null) {
+ System.out.println(null + ", " + r2);
+ }
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/moveInner/scr30106/after/p/B.java b/java/java-tests/testData/refactoring/moveInner/scr30106/after/p/B.java
index 6fa9162..32301db 100644
--- a/java/java-tests/testData/refactoring/moveInner/scr30106/after/p/B.java
+++ b/java/java-tests/testData/refactoring/moveInner/scr30106/after/p/B.java
@@ -1,12 +1,12 @@
package p;
public class B extends X {
+ private A outer;
+
{
method();
}
- private A outer;
-
public B(A outer) {
this.outer = outer;
}
diff --git a/java/java-tests/testData/refactoring/moveMembers/stringConstantFromCaseStatement/after/A.java b/java/java-tests/testData/refactoring/moveMembers/stringConstantFromCaseStatement/after/A.java
new file mode 100644
index 0000000..c77f0cd
--- /dev/null
+++ b/java/java-tests/testData/refactoring/moveMembers/stringConstantFromCaseStatement/after/A.java
@@ -0,0 +1,3 @@
+public class A {
+ public static final String ONE = "";
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/moveMembers/stringConstantFromCaseStatement/after/B.java b/java/java-tests/testData/refactoring/moveMembers/stringConstantFromCaseStatement/after/B.java
new file mode 100644
index 0000000..6ad6775
--- /dev/null
+++ b/java/java-tests/testData/refactoring/moveMembers/stringConstantFromCaseStatement/after/B.java
@@ -0,0 +1,8 @@
+public class B {
+ void foo(String s) {
+ switch (i) {
+ case A.ONE :
+ break;
+ }
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/moveMembers/stringConstantFromCaseStatement/before/A.java b/java/java-tests/testData/refactoring/moveMembers/stringConstantFromCaseStatement/before/A.java
new file mode 100644
index 0000000..61ff2ab
--- /dev/null
+++ b/java/java-tests/testData/refactoring/moveMembers/stringConstantFromCaseStatement/before/A.java
@@ -0,0 +1,2 @@
+public class A {
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/moveMembers/stringConstantFromCaseStatement/before/B.java b/java/java-tests/testData/refactoring/moveMembers/stringConstantFromCaseStatement/before/B.java
new file mode 100644
index 0000000..5ae2fae
--- /dev/null
+++ b/java/java-tests/testData/refactoring/moveMembers/stringConstantFromCaseStatement/before/B.java
@@ -0,0 +1,9 @@
+public class B {
+ public static final String ONE = "";
+ void foo(String s) {
+ switch (i) {
+ case ONE :
+ break;
+ }
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/safeDelete/LastResourceVariableWithFinallyBlock.java b/java/java-tests/testData/refactoring/safeDelete/LastResourceVariableWithFinallyBlock.java
new file mode 100644
index 0000000..cbd6447
--- /dev/null
+++ b/java/java-tests/testData/refactoring/safeDelete/LastResourceVariableWithFinallyBlock.java
@@ -0,0 +1,6 @@
+class ARM {
+ void f() {
+ try (AutoCloseable <caret>r = null) {
+ } finally {}
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/safeDelete/LastResourceVariableWithFinallyBlock_after.java b/java/java-tests/testData/refactoring/safeDelete/LastResourceVariableWithFinallyBlock_after.java
new file mode 100644
index 0000000..04c6ee5
--- /dev/null
+++ b/java/java-tests/testData/refactoring/safeDelete/LastResourceVariableWithFinallyBlock_after.java
@@ -0,0 +1,6 @@
+class ARM {
+ void f() {
+ try {
+ } finally {}
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/safeDelete/LastResourceVariable_after.java b/java/java-tests/testData/refactoring/safeDelete/LastResourceVariable_after.java
index 299e83c..3b50367 100644
--- a/java/java-tests/testData/refactoring/safeDelete/LastResourceVariable_after.java
+++ b/java/java-tests/testData/refactoring/safeDelete/LastResourceVariable_after.java
@@ -1,6 +1,4 @@
class ARM {
void f() {
- try {
- }
}
}
\ No newline at end of file
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/GenerateCreateUITest.java b/java/java-tests/testSrc/com/intellij/codeInsight/GenerateCreateUITest.java
new file mode 100644
index 0000000..683a22a
--- /dev/null
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/GenerateCreateUITest.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2000-2013 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.codeInsight;
+
+import com.intellij.codeInsight.generation.actions.GenerateCreateUIAction;
+import com.intellij.psi.PsiClass;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.testFramework.LightCodeInsightTestCase;
+
+/**
+ * @author anna
+ */
+public class GenerateCreateUITest extends LightCodeInsightTestCase {
+ public void testSOE() throws Exception {
+ configureByFile("/codeInsight/generate/generateCreateUI/beforeSOE.java");
+ final PsiClass targetClass = PsiTreeUtil.getParentOfType(getFile().findElementAt(getEditor().getCaretModel().getOffset()), PsiClass.class);
+ assertNotNull(targetClass);
+ assertFalse(new GenerateCreateUIAction().isValidForClass(targetClass));
+ }
+
+}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/OverrideImplementTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/OverrideImplementTest.java
index 95de823..670b101 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/OverrideImplementTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/OverrideImplementTest.java
@@ -70,6 +70,11 @@
public void testImplementExtensionMethods() { doTest8(false, true); }
public void testOverrideExtensionMethods() { doTest8(false, false); }
public void testDoNotImplementExtensionMethods() { doTest8(false, true); }
+ public void testSkipUnknownAnnotations() { doTest8(false, true); }
+
+
+ public void testOverrideInInterface() { doTest8(false, false); }
+ public void testMultipleInheritedThrows() {doTest8(false, false);}
public void testLongFinalParameterList() {
CodeStyleSettings codeStyleSettings = CodeStyleSettingsManager.getSettings(getProject()).clone();
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy
index a55697a..4524ed7 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy
@@ -21,6 +21,7 @@
import com.intellij.codeInsight.lookup.Lookup
import com.intellij.codeInsight.lookup.LookupElementPresentation
import com.intellij.codeInsight.lookup.LookupManager
+import com.intellij.codeInsight.lookup.PsiTypeLookupItem
import com.intellij.codeInsight.lookup.impl.LookupImpl
import com.intellij.codeInsight.template.impl.TemplateManagerImpl
import com.intellij.ide.DataManager
@@ -740,7 +741,7 @@
myFixture.checkResult(" class Foo { { int iteraaa; iteraaa<caret> } } ")
assert !lookup
}
-
+
public void testChoosingItemDuringCopyCommit() {
registerContributor(LongReplacementOffsetContributor)
@@ -1023,8 +1024,7 @@
myFixture.addClass("package xxxxx; public class SYSTEM_EXCEPTION {}")
myFixture.configureByText "a.java", "import xxxxx.*; class Foo { S<caret> }"
type 'Ystem'
- assert 'java.lang.System' == ((JavaPsiClassReferenceElement) myFixture.lookupElements[0]).qualifiedName
- assert 'xxxxx.SYSTEM_EXCEPTION' == ((JavaPsiClassReferenceElement) myFixture.lookupElements[1]).qualifiedName
+ myFixture.assertPreferredCompletionItems 1, 'System', 'SYSTEM_EXCEPTION'
}
public void testSamePrefixIgnoreCase2() {
@@ -1032,9 +1032,7 @@
myFixture.addClass("package xxxxx; public class SYstem {}")
myFixture.configureByText "a.java", "import xxxxx.*; class Foo { S<caret> }"
type 'Ystem'
- assert 'xxxxx.SYstem' == ((JavaPsiClassReferenceElement) myFixture.lookupElements[0]).qualifiedName
- assert 'java.lang.System' == ((JavaPsiClassReferenceElement) myFixture.lookupElements[1]).qualifiedName
- assert 'xxxxx.SYSTEM_EXCEPTION' == ((JavaPsiClassReferenceElement) myFixture.lookupElements[2]).qualifiedName
+ myFixture.assertPreferredCompletionItems 0, 'SYstem', 'System', 'SYSTEM_EXCEPTION'
}
private FileEditor openEditorForUndo() {
@@ -1331,7 +1329,10 @@
}
}
'''
- type 'int['
+ type 'int'
+ myFixture.assertPreferredCompletionItems 0, 'int', 'Integer'
+ assert ((PsiTypeLookupItem) myFixture.lookupElements[0]).bracketsCount == 1
+ type '['
myFixture.checkResult '''
class Foo {
void foo() {
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavadocCompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavadocCompletionTest.groovy
similarity index 78%
rename from java/java-tests/testSrc/com/intellij/codeInsight/completion/JavadocCompletionTest.java
rename to java/java-tests/testSrc/com/intellij/codeInsight/completion/JavadocCompletionTest.groovy
index 3c17cc8..6c5c239 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavadocCompletionTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavadocCompletionTest.groovy
@@ -1,26 +1,21 @@
-package com.intellij.codeInsight.completion;
-
-import com.intellij.JavaTestUtil;
-import com.intellij.codeInsight.CodeInsightSettings;
-import com.intellij.codeInsight.lookup.LookupElement;
-import com.intellij.codeInspection.javaDoc.JavaDocLocalInspection;
-import com.intellij.lang.StdLanguages;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiReference;
-import com.intellij.psi.PsiReferenceBase;
-import com.intellij.psi.PsiReferenceProvider;
-import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
-import com.intellij.psi.impl.source.resolve.reference.PsiReferenceRegistrarImpl;
-import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry;
-import com.intellij.psi.javadoc.PsiDocTag;
-import com.intellij.util.ObjectUtils;
-import com.intellij.util.ProcessingContext;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.Arrays;
-import java.util.List;
-
-
+package com.intellij.codeInsight.completion
+import com.intellij.JavaTestUtil
+import com.intellij.codeInsight.CodeInsightSettings
+import com.intellij.codeInsight.lookup.LookupElement
+import com.intellij.codeInspection.javaDoc.JavaDocLocalInspection
+import com.intellij.lang.StdLanguages
+import com.intellij.psi.PsiElement
+import com.intellij.psi.PsiReference
+import com.intellij.psi.PsiReferenceBase
+import com.intellij.psi.PsiReferenceProvider
+import com.intellij.psi.codeStyle.CodeStyleSettingsManager
+import com.intellij.psi.impl.source.resolve.reference.PsiReferenceRegistrarImpl
+import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry
+import com.intellij.psi.javadoc.PsiDocTag
+import com.intellij.util.ObjectUtils
+import com.intellij.util.ProcessingContext
+import com.intellij.util.SystemProperties
+import org.jetbrains.annotations.NotNull
/**
* @author mike
*/
@@ -39,7 +34,7 @@
public void testNamesInClass() throws Exception {
configureByFile("ClassTagName.java");
- assertStringItems("author", "deprecated", "param", "see", "serial", "since", "version");
+ assertStringItems("author", 'author ' + SystemProperties.getUserName(), "deprecated", "param", "see", "serial", "since", "version");
}
public void testNamesInField() throws Exception {
@@ -54,7 +49,7 @@
public void testNamesInMethod1() throws Exception {
configureByFile("MethodTagName1.java");
- assertStringItems("see", "serialData", "since", "class", "throws");
+ assertStringItems("see", "serialData", "since", "throws");
}
public void testParamValueCompletion() throws Exception {
@@ -204,6 +199,39 @@
checkResultByFile(getTestName(false) + "_after.java");
}
+ public void "test suggest param names"() {
+ myFixture.configureByText "a.java", '''
+class Foo {
+ /**
+ * @par<caret>
+ */
+ void foo(int intParam, Object param2) {
+ }
+}
+'''
+ myFixture.completeBasic()
+ myFixture.assertPreferredCompletionItems 0, 'param', 'param intParam', 'param param2'
+ myFixture.type('\n intParam\n@para')
+ myFixture.completeBasic()
+ myFixture.assertPreferredCompletionItems 0, 'param', 'param param2'
+ }
+
+ public void "test see super class"() {
+ myFixture.addClass("package foo; public interface Foo {}")
+ myFixture.addClass("package bar; public class Bar {} ")
+ myFixture.configureByText "a.java", '''
+import foo.*;
+import bar.*;
+
+/**
+ * @se<caret>
+ */
+class Impl extends Bar implements Foo {}
+'''
+ myFixture.completeBasic()
+ myFixture.assertPreferredCompletionItems 0, 'see', 'see bar.Bar', 'see foo.Foo'
+ }
+
public void testCustomReferenceProvider() throws Exception {
PsiReferenceRegistrarImpl registrar =
(PsiReferenceRegistrarImpl) ReferenceProvidersRegistry.getInstance().getRegistrar(StdLanguages.JAVA);
@@ -211,7 +239,7 @@
@Override
@NotNull
public PsiReference[] getReferencesByElement(@NotNull final PsiElement element, @NotNull final ProcessingContext context) {
- return new PsiReference[]{new PsiReferenceBase<PsiElement>(element) {
+ def ref = new PsiReferenceBase<PsiElement>(element) {
@Override
public PsiElement resolve() {
@@ -221,9 +249,10 @@
@Override
@NotNull
public Object[] getVariants() {
- return new Object[]{"1", "2", "3"};
+ return ["1", "2", "3"]
}
- }};
+ }
+ return [ref]
}
};
try {
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy
index 7c2bc5b..8a1bfe6 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy
@@ -60,7 +60,7 @@
final LookupImpl lookup = invokeCompletion(getTestName(false) + ".html");
assertPreferredItems(0, "p", "param", "pre");
incUseCount(lookup, 2);
- assertPreferredItems(0, "p", "pre", "param");
+ assertPreferredItems(1, "p", "pre", "param");
}
public void testUppercaseMatters2() throws Throwable {
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java
index fca0924..ec241b5 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java
@@ -237,6 +237,7 @@
public void testIDEA22005() throws Exception { doTest5(false);}
public void testIDEA57259() throws Exception { doTest5(false);}
public void testIDEA107957() throws Exception { doTest6(false);}
+ public void testIDEA109875() throws Exception { doTest6(false);}
public void testIDEA106964() throws Exception { doTest5(false);}
public void testIDEA107782() throws Exception { doTest5(false);}
public void testInheritedWithDifferentArgsInTypeParams() throws Exception { doTest5(false);}
@@ -287,6 +288,7 @@
public void testIDEA104100() {doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);}
public void testIDEA104160() {doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);}
+ public void testSOEInLeastUpperClass() {doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);}
public void testJavaUtilCollections_NoVerify() throws Exception {
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingPerformanceTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingPerformanceTest.java
index a331e33..a0d0ffc 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingPerformanceTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingPerformanceTest.java
@@ -91,6 +91,10 @@
private List<HighlightInfo> doTest(final int maxMillis) throws Exception {
configureByFile(getFilePath(""));
+ return startTest(maxMillis);
+ }
+
+ private List<HighlightInfo> startTest(int maxMillis) {
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
getFile().getText(); //to load text
CodeInsightTestFixtureImpl.ensureIndexesUpToDate(getProject());
@@ -124,4 +128,20 @@
fail("Actual: " + errors.size());
}
}
+
+ public void testDuplicateMethods() throws Exception {
+ StringBuilder text = new StringBuilder("class X {\n");
+ int N = 1000;
+ for (int i=0;i<N;i++) {
+ text.append("public void visit(C" + i + " param) {}\n");
+ }
+ for (int i=0;i<N;i++) {
+ text.append("class C" + i + " {}\n");
+ }
+ text.append("}");
+ configureFromFileText("x.java", text.toString());
+
+ List<HighlightInfo> infos = startTest(Math.max(1000, 10000 - JobSchedulerImpl.CORES_COUNT * 1000));
+ assertEmpty(infos);
+ }
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingTest.java
index 9cffb6d..c72853a 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingTest.java
@@ -119,6 +119,7 @@
public void testFieldDoubleInitialization() { doTest(false, false); }
public void testAssignToFinal() { doTest(false, false); }
public void testUnhandledExceptionsInSuperclass() { doTest(false, false); }
+ public void testNoUnhandledExceptionsMultipleInheritance() { doTest(false, false); }
public void testAssignmentCompatible () { doTest(false, false); }
public void testMustBeBoolean() { doTest(false, false); }
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/TarjanTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/TarjanTest.java
new file mode 100644
index 0000000..1abbe2d
--- /dev/null
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/TarjanTest.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2000-2013 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.codeInsight.daemon.lambda;
+
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.psi.impl.source.resolve.InferenceGraphNode;
+import com.intellij.util.Function;
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * User: anna
+ * Date: 7/4/13
+ */
+public class TarjanTest extends TestCase {
+
+ //testdata from https://github.com/bwesterb/py-tarjan/
+ public void testResultGraph() throws Exception {
+ //{1:[2],2:[1,5],3:[4],4:[3,5],5:[6],6:[7],7:[8],8:[6,9],9:[]}
+ InferenceGraphNode<Integer>[] nodes = new InferenceGraphNode[9];
+ for (int i = 0; i < nodes.length; i++) {
+ nodes[i] = new InferenceGraphNode<Integer>(i + 1);
+ }
+
+ nodes[0].getDependencies().add(nodes[1]);
+
+ nodes[1].getDependencies().add(nodes[0]);
+ nodes[1].getDependencies().add(nodes[4]);
+
+ nodes[2].getDependencies().add(nodes[3]);
+
+ nodes[3].getDependencies().add(nodes[2]);
+ nodes[3].getDependencies().add(nodes[4]);
+
+ nodes[4].getDependencies().add(nodes[5]);
+
+ nodes[5].getDependencies().add(nodes[6]);
+
+ nodes[6].getDependencies().add(nodes[7]);
+
+ nodes[7].getDependencies().add(nodes[5]);
+ nodes[7].getDependencies().add(nodes[8]);
+
+ final List<List<InferenceGraphNode<Integer>>> tarjan = InferenceGraphNode.tarjan(Arrays.asList(nodes));
+ final String messages = StringUtil.join(tarjan, new Function<List<InferenceGraphNode<Integer>>, String>() {
+ @Override
+ public String fun(List<InferenceGraphNode<Integer>> nodes) {
+ return StringUtil.join(nodes, new Function<InferenceGraphNode<Integer>, String>() {
+ @Override
+ public String fun(InferenceGraphNode<Integer> node) {
+ return String.valueOf(node.getValue());
+ }
+ }, ",");
+ }
+ }, "\n");
+
+ Assert.assertEquals("9\n" +
+ "8,7,6\n" +
+ "5\n" +
+ "2,1\n" +
+ "4,3", messages);
+ }
+}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ConvertFieldToLocalTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ConvertFieldToLocalTest.java
new file mode 100644
index 0000000..d74b67f
--- /dev/null
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/ConvertFieldToLocalTest.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2000-2013 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.codeInsight.daemon.quickFix;
+
+import com.intellij.codeInspection.LocalInspectionTool;
+import com.intellij.codeInspection.varScopeCanBeNarrowed.FieldCanBeLocalInspection;
+import org.jetbrains.annotations.NotNull;
+
+
+public class ConvertFieldToLocalTest extends LightQuickFixTestCase {
+ @NotNull
+ @Override
+ protected LocalInspectionTool[] configureLocalInspectionTools() {
+ final FieldCanBeLocalInspection inspection = new FieldCanBeLocalInspection();
+ inspection.IGNORE_FIELDS_USED_IN_MULTIPLE_METHODS = false;
+ return new LocalInspectionTool[] { inspection };
+ }
+
+ public void test() throws Exception { doAllTests(); }
+
+ @Override
+ protected String getBasePath() {
+ return "/codeInsight/daemonCodeAnalyzer/quickFix/convert2Local";
+ }
+
+}
\ No newline at end of file
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RemoveRedundantUncheckedSuppressionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RemoveRedundantUncheckedSuppressionTest.java
index f341e1d..4afe459 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RemoveRedundantUncheckedSuppressionTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RemoveRedundantUncheckedSuppressionTest.java
@@ -16,7 +16,7 @@
package com.intellij.codeInsight.daemon.quickFix;
import com.intellij.codeInspection.*;
-import com.intellij.codeInspection.ex.InspectionTool;
+import com.intellij.codeInspection.ex.InspectionToolWrapper;
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
import com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection;
import com.intellij.psi.*;
@@ -32,8 +32,8 @@
final UncheckedWarningLocalInspection warningLocalInspection = new UncheckedWarningLocalInspection();
final RedundantSuppressInspection inspection = new RedundantSuppressInspection(){
@Override
- protected InspectionTool[] getInspectionTools(PsiElement psiElement, InspectionManager manager) {
- return new InspectionTool[]{
+ protected InspectionToolWrapper[] getInspectionTools(PsiElement psiElement, @NotNull InspectionManager manager) {
+ return new InspectionToolWrapper[]{
new LocalInspectionToolWrapper(varargsInspection),
new LocalInspectionToolWrapper(warningLocalInspection)
};
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Suppress15InspectionsTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Suppress15InspectionsTest.java
index 13ebabf..2ab3462 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Suppress15InspectionsTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Suppress15InspectionsTest.java
@@ -1,4 +1,3 @@
-
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
@@ -19,7 +18,6 @@
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.codeInspection.accessStaticViaInstance.AccessStaticViaInstance;
import com.intellij.codeInspection.deprecation.DeprecationInspection;
-import com.intellij.codeInspection.ex.GlobalInspectionToolWrapper;
import com.intellij.codeInspection.javaDoc.JavaDocReferenceInspection;
import com.intellij.codeInspection.sillyAssignment.SillyAssignmentInspection;
import com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection;
@@ -33,7 +31,7 @@
@Override
protected void setUp() throws Exception {
super.setUp();
- enableInspectionTool(new GlobalInspectionToolWrapper(new UnusedParametersInspection()));
+ enableInspectionTool(new UnusedParametersInspection());
}
@NotNull
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy
index d3a7466..3ab71c0 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy
@@ -605,4 +605,15 @@
assert myFixture.editor.document.text.contains('List<Map.Entry<String, Integer>> result;')
}
+ public void "test name shadowing"() {
+ myFixture.configureByText "a.java", """class LiveTemplateVarSuggestion {
+ private Object value;
+ public void setValue(Object value, Object value1){
+ inn<caret>
+ }
+}"""
+ myFixture.type('\t')
+ assert myFixture.lookupElementStrings == ['value', 'value1']
+ }
+
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/ConcatenationToMessageFormatActionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/ConcatenationToMessageFormatActionTest.java
index 412104c..11f426a 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/ConcatenationToMessageFormatActionTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/ConcatenationToMessageFormatActionTest.java
@@ -3,36 +3,37 @@
*/
package com.intellij.codeInspection;
-import com.intellij.codeInsight.intention.impl.ConcatenationToMessageFormatAction;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiExpression;
+import com.intellij.psi.util.PsiConcatenationUtil;
import com.intellij.testFramework.LightIdeaTestCase;
import java.util.ArrayList;
public class ConcatenationToMessageFormatActionTest extends LightIdeaTestCase {
+
+ public void doTest(String expressionText, String messageFormatText, String... foundExpressionTexts) {
+ final PsiExpression expression = JavaPsiFacade.getElementFactory(getProject()).createExpressionFromText(expressionText, null);
+ final StringBuilder result = new StringBuilder();
+ final ArrayList<PsiExpression> args = new ArrayList<PsiExpression>();
+ PsiConcatenationUtil.buildFormatString(expression, result, args, false);
+ assertEquals(messageFormatText, result.toString());
+ assertEquals(foundExpressionTexts.length, args.size());
+ for (int i = 0; i < foundExpressionTexts.length; i++) {
+ final String foundExpressionText = foundExpressionTexts[i];
+ assertEquals(foundExpressionText, args.get(i).getText());
+ }
+ }
public void test1() throws Exception{
- final String text = "\"aaa 'bbb' '\" + ((java.lang.String)ccc) + \"'\"";
- final PsiExpression expression = JavaPsiFacade.getInstance(getProject()).getElementFactory().createExpressionFromText(
- text, null
- );
- final StringBuilder result = new StringBuilder();
- ConcatenationToMessageFormatAction.buildMessageFormatString(expression,
- result,
- new ArrayList<PsiExpression>());
- assertEquals("aaa ''bbb'' ''{0}''", result.toString());
+ doTest("\"aaa 'bbb' '\" + ((java.lang.String)ccc) + \"'\"", "aaa ''bbb'' ''{0}''", "ccc");
}
public void test2() throws Exception {
- final String text = "1 + 2 + 3 + \"{}'\" + '\\n' + ((java.lang.String)ccc)";
- final PsiExpression expression = JavaPsiFacade.getElementFactory(getProject()).createExpressionFromText(text, null);
- final StringBuilder result = new StringBuilder();
- final ArrayList<PsiExpression> args = new ArrayList<PsiExpression>();
- ConcatenationToMessageFormatAction.buildMessageFormatString(expression, result, args);
- assertEquals("{0}'{'}''\\n{1}", result.toString());
- assertEquals(2, args.size());
- assertEquals("1 + 2 + 3", args.get(0).getText());
- assertEquals("ccc", args.get(1).getText());
+ doTest("1 + 2 + 3 + \"{}'\" + '\\n' + ((java.lang.String)ccc)", "{0}'{}'''\\n{1}", "1 + 2 + 3", "ccc");
+ }
+
+ public void test3() throws Exception {
+ doTest("\"Test{A = \" + 1 + \", B = \" + 2 + \", C = \" + 3 + \"}\"", "Test'{'A = {0}, B = {1}, C = {2}'}'", "1", "2", "3");
}
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java
index fc5824c..c156581 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java
@@ -99,6 +99,7 @@
public void testReturningNullFromVoidMethod() throws Throwable { doTest(); }
public void testCatchRuntimeException() throws Throwable { doTest(); }
+ public void testCatchThrowable() throws Throwable { doTest(); }
public void testNotNullCatchParameter() { doTest(); }
public void testAssertFailInCatch() throws Throwable {
@@ -170,6 +171,8 @@
public void testEqualsHasNoSideEffects() { doTest(); }
+ public void testHonorGetterAnnotation() { doTest(); }
+
public void testIsNullCheck() throws Exception {
ConditionCheckManager.getInstance(myModule.getProject()).getIsNullCheckMethods().add(
buildConditionChecker("Value", "isNull", ConditionChecker.Type.IS_NULL_METHOD,
@@ -228,4 +231,11 @@
assert psiMethod != null;
return new ConditionChecker.FromPsiBuilder(psiMethod, psiMethod.getParameterList().getParameters()[0], type).build();
}
+
+ public void testIgnoreAssertions() {
+ final DataFlowInspection inspection = new DataFlowInspection();
+ inspection.IGNORE_ASSERT_STATEMENTS = true;
+ myFixture.enableInspections(inspection);
+ myFixture.testHighlighting(true, false, true, getTestName(false) + ".java");
+ }
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/GlobalInspectionContextTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/GlobalInspectionContextTest.java
index 872ae12..2cdf8a2 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/GlobalInspectionContextTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/GlobalInspectionContextTest.java
@@ -20,7 +20,9 @@
import com.intellij.codeInsight.CodeInsightTestCase;
import com.intellij.codeInspection.actions.RunInspectionIntention;
import com.intellij.codeInspection.ex.*;
+import com.intellij.codeInspection.ui.InspectionToolPresentation;
import com.intellij.codeInspection.visibility.VisibilityInspection;
+import com.intellij.psi.PsiFile;
import java.util.ArrayList;
import java.util.Arrays;
@@ -34,32 +36,36 @@
public void testProblemDuplication() throws Exception {
String shortName = new VisibilityInspection().getShortName();
InspectionProfileImpl profile = new InspectionProfileImpl("Foo");
- profile.disableAllTools();
- profile.enableTool(shortName);
+ profile.disableAllTools(getProject());
+ profile.enableTool(shortName, getProject());
GlobalInspectionContextImpl context = ((InspectionManagerEx)InspectionManager.getInstance(getProject())).createNewGlobalContext(false);
context.setExternalProfile(profile);
configureByFile("Foo.java");
AnalysisScope scope = new AnalysisScope(getFile());
- context.doInspections(scope, InspectionManager.getInstance(getProject()));
+ context.doInspections(scope);
Tools tools = context.getTools().get(shortName);
- GlobalInspectionToolWrapper tool = (GlobalInspectionToolWrapper)tools.getTool();
- assertEquals(1, tool.getProblemDescriptors().size());
+ GlobalInspectionToolWrapper toolWrapper = (GlobalInspectionToolWrapper)tools.getTool();
+ InspectionToolPresentation presentation = context.getPresentation(toolWrapper);
+ assertEquals(1, presentation.getProblemDescriptors().size());
- context.doInspections(scope, InspectionManager.getInstance(getProject()));
+ context.doInspections(scope);
tools = context.getTools().get(shortName);
- tool = (GlobalInspectionToolWrapper)tools.getTool();
- assertEquals(1, tool.getProblemDescriptors().size());
+ toolWrapper = (GlobalInspectionToolWrapper)tools.getTool();
+ presentation = context.getPresentation(toolWrapper);
+ assertEquals(1, presentation.getProblemDescriptors().size());
}
public void testRunInspectionContext() throws Exception {
InspectionProfile profile = new InspectionProfileImpl("foo");
- InspectionProfileEntry[] tools = profile.getInspectionTools(null);
- for (InspectionProfileEntry tool : tools) {
- if (!tool.isEnabledByDefault()) {
- GlobalInspectionContextImpl context = RunInspectionIntention.createContext(tool, (InspectionManagerEx)InspectionManager.getInstance(myProject), null);
+ InspectionToolWrapper[] tools = profile.getInspectionTools(null);
+ PsiFile file = createDummyFile("xx.txt", "xxx");
+ for (InspectionToolWrapper toolWrapper : tools) {
+ if (!toolWrapper.isEnabledByDefault()) {
+ InspectionManagerEx instance = (InspectionManagerEx)InspectionManager.getInstance(myProject);
+ GlobalInspectionContextImpl context = RunInspectionIntention.createContext(toolWrapper, instance, file);
context.initializeTools(new ArrayList<Tools>(), new ArrayList<Tools>(), new ArrayList<Tools>());
assertEquals(1, context.getTools().size());
return;
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/InspectionProfileTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/InspectionProfileTest.java
index b6f20b9..ed2db87 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/InspectionProfileTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/InspectionProfileTest.java
@@ -186,11 +186,10 @@
}
public void testLockProfile() throws Exception {
-
final List<InspectionToolWrapper> list = new ArrayList<InspectionToolWrapper>();
list.add(createTool("foo", true));
- InspectionToolRegistrar registrar = new InspectionToolRegistrar(null) {
+ InspectionToolRegistrar registrar = new InspectionToolRegistrar() {
@NotNull
@Override
public List<InspectionToolWrapper> createTools() {
@@ -200,10 +199,10 @@
InspectionProfileImpl profile = createProfile(registrar);
- List<ScopeToolState> tools = profile.getAllTools();
+ List<ScopeToolState> tools = profile.getAllTools(getProject());
assertEquals(1, tools.size());
assertTrue(profile.isToolEnabled(HighlightDisplayKey.find("foo")));
- assertTrue(profile.getToolDefaultState("foo").isEnabled());
+ assertTrue(profile.getToolDefaultState("foo", getProject()).isEnabled());
InspectionProfileImpl model = (InspectionProfileImpl)profile.getModifiableModel();
model.lockProfile(true);
@@ -226,15 +225,15 @@
profile = createProfile(registrar);
profile.readExternal(element);
- tools = profile.getAllTools();
+ tools = profile.getAllTools(getProject());
assertEquals(3, tools.size());
assertTrue(profile.isProfileLocked());
assertFalse(profile.isToolEnabled(HighlightDisplayKey.find("bar")));
assertFalse(profile.isToolEnabled(HighlightDisplayKey.find("disabled")));
- assertTrue(profile.getToolDefaultState("bar").isEnabled());
- assertFalse(profile.getToolDefaultState("disabled").isEnabled());
+ assertTrue(profile.getToolDefaultState("bar", getProject()).isEnabled());
+ assertFalse(profile.getToolDefaultState("disabled", getProject()).isEnabled());
assertEquals("<profile version=\"1.0\" is_locked=\"true\">\n" +
" <option name=\"myName\" value=\"Foo\" />\n" +
@@ -262,8 +261,8 @@
public void testGlobalInspectionContext() throws Exception {
InspectionProfileImpl profile = new InspectionProfileImpl("Foo");
- profile.disableAllTools();
- profile.enableTool(new UnusedDeclarationInspection().getShortName());
+ profile.disableAllTools(getProject());
+ profile.enableTool(new UnusedDeclarationInspection().getShortName(), getProject());
GlobalInspectionContextImpl context = ((InspectionManagerEx)InspectionManager.getInstance(getProject())).createNewGlobalContext(false);
context.setExternalProfile(profile);
@@ -285,7 +284,7 @@
model = foo.getModifiableModel();
assertEquals(0, countInitializedTools(model));
- List<ScopeToolState> tools = ((InspectionProfileImpl)model).getAllTools();
+ List<ScopeToolState> tools = ((InspectionProfileImpl)model).getAllTools(getProject());
for (ScopeToolState tool : tools) {
if (!tool.isEnabled()) {
tool.setEnabled(true);
@@ -299,23 +298,23 @@
InspectionProfileImpl profile = new InspectionProfileImpl("profile");
profile.setBaseProfile(InspectionProfileImpl.getDefaultProfile());
assertEquals(0, countInitializedTools(profile));
- InspectionProfileEntry[] tools = profile.getInspectionTools(null);
- assertTrue(tools.length > 0);
- InspectionProfileEntry tool = profile.getInspectionTool(new DataFlowInspection().getShortName());
- assertNotNull(tool);
- String id = tool.getShortName();
+ InspectionToolWrapper[] toolWrappers = profile.getInspectionTools(null);
+ assertTrue(toolWrappers.length > 0);
+ InspectionToolWrapper toolWrapper = profile.getInspectionTool(new DataFlowInspection().getShortName(), getProject());
+ assertNotNull(toolWrapper);
+ String id = toolWrapper.getShortName();
System.out.println(id);
if (profile.isToolEnabled(HighlightDisplayKey.findById(id))) {
- profile.disableTool(id);
+ profile.disableTool(id, getProject());
}
else {
- profile.enableTool(id);
+ profile.enableTool(id, getProject());
}
assertEquals(0, countInitializedTools(profile));
profile.writeExternal(new Element("profile"));
- List<InspectionProfileEntry> initializedTools = getInitializedTools(profile);
+ List<InspectionToolWrapper> initializedTools = getInitializedTools(profile);
if (initializedTools.size() != 1) {
- for (InspectionProfileEntry initializedTool : initializedTools) {
+ for (InspectionToolWrapper initializedTool : initializedTools) {
System.out.println(initializedTool.getShortName());
}
fail();
@@ -340,14 +339,14 @@
return getInitializedTools(foo).size();
}
- public static List<InspectionProfileEntry> getInitializedTools(Profile foo) {
- List<InspectionProfileEntry> initialized = new ArrayList<InspectionProfileEntry>();
- List<ScopeToolState> tools = ((InspectionProfileImpl)foo).getAllTools();
+ @NotNull
+ public static List<InspectionToolWrapper> getInitializedTools(@NotNull Profile foo) {
+ List<InspectionToolWrapper> initialized = new ArrayList<InspectionToolWrapper>();
+ List<ScopeToolState> tools = ((InspectionProfileImpl)foo).getAllTools(getProject());
for (ScopeToolState tool : tools) {
- InspectionProfileEntry entry = tool.getTool();
- assertTrue(entry instanceof InspectionToolWrapper);
- if (entry.isInitialized()) {
- initialized.add(entry);
+ InspectionToolWrapper toolWrapper = tool.getTool();
+ if (toolWrapper.isInitialized()) {
+ initialized.add(toolWrapper);
}
}
return initialized;
@@ -360,11 +359,11 @@
foo.groupDisplayName = s;
foo.level = "ERROR";
foo.enabledByDefault = enabled;
- foo.implementationClass = "com.intellij.codeInspection.InspectionProfileTest$TestTool";
+ foo.implementationClass = TestTool.class.getName();
return new LocalInspectionToolWrapper(foo);
}
- @SuppressWarnings({"UnusedDeclaration", "InspectionDescriptionNotFoundInspection"})
+ @SuppressWarnings("InspectionDescriptionNotFoundInspection")
public static class TestTool extends LocalInspectionTool {
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast15Test.java b/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast15Test.java
index 15a238a..a20b8d0 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast15Test.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast15Test.java
@@ -46,6 +46,7 @@
public void testIDEA22899() throws Exception { doTest();}
public void testRawCast1() throws Exception { doTest();}
public void testInferenceFromCast() throws Exception { doTest();}
+ public void testGetClassProcessing() throws Exception { doTest();}
public void testTypeParameterAccessChecksJava7() throws Exception {
((JavaVersionServiceImpl)JavaVersionService.getInstance()).setTestVersion(JavaSdkVersion.JDK_1_7, getTestRootDisposable());
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/RedundantSuppressTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/RedundantSuppressTest.java
index 9be168c..1d00526 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/RedundantSuppressTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/RedundantSuppressTest.java
@@ -5,22 +5,23 @@
import com.intellij.codeInspection.i18n.I18nInspection;
import com.intellij.psi.PsiElement;
import com.intellij.testFramework.InspectionTestCase;
+import org.jetbrains.annotations.NotNull;
public class RedundantSuppressTest extends InspectionTestCase {
private GlobalInspectionToolWrapper myWrapper;
- private InspectionTool[] myInspectionTools;
+ private InspectionToolWrapper[] myInspectionToolWrappers;
@Override
protected void setUp() throws Exception {
super.setUp();
InspectionToolRegistrar.getInstance().ensureInitialized();
- myInspectionTools = new InspectionTool[]{new LocalInspectionToolWrapper(new I18nInspection()),
+ myInspectionToolWrappers = new InspectionToolWrapper[]{new LocalInspectionToolWrapper(new I18nInspection()),
new GlobalInspectionToolWrapper(new EmptyMethodInspection())};
myWrapper = new GlobalInspectionToolWrapper(new RedundantSuppressInspection() {
@Override
- protected InspectionTool[] getInspectionTools(PsiElement psiElement, InspectionManager manager) {
- return myInspectionTools;
+ protected InspectionToolWrapper[] getInspectionTools(PsiElement psiElement, @NotNull InspectionManager manager) {
+ return myInspectionToolWrappers;
}
});
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/SingleInspectionProfilePanelTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/SingleInspectionProfilePanelTest.java
index ab3a853..255358b 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/SingleInspectionProfilePanelTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/SingleInspectionProfilePanelTest.java
@@ -103,7 +103,7 @@
}
private JavaDocLocalInspection getInspection(InspectionProfileImpl profile) {
- LocalInspectionToolWrapper original = (LocalInspectionToolWrapper)profile.getInspectionTool(myInspection.getShortName());
+ LocalInspectionToolWrapper original = (LocalInspectionToolWrapper)profile.getInspectionTool(myInspection.getShortName(), getProject());
assert original != null;
return (JavaDocLocalInspection)original.getTool();
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/UnusedDeclarationTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/UnusedDeclarationTest.java
index a9a1e4e..10604a1 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/UnusedDeclarationTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/UnusedDeclarationTest.java
@@ -18,6 +18,7 @@
import com.intellij.JavaTestUtil;
import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection;
import com.intellij.codeInspection.ex.EntryPointsManagerImpl;
+import com.intellij.codeInspection.ex.GlobalInspectionToolWrapper;
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.testFramework.InspectionTestCase;
@@ -40,7 +41,7 @@
}
private void doTest() {
- doTest("deadCode/" + getTestName(true), myTool);
+ doTest("deadCode/" + getTestName(true), new GlobalInspectionToolWrapper(myTool));
}
public void testSCR6067() {
@@ -151,7 +152,7 @@
public void testJunitAbstractClassWithoutInheritor() {
doTest();
}
-
+
public void testJunitEntryPointCustomRunWith() {
doTest();
}
diff --git a/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java b/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java
index 36fcc43..65092f2 100644
--- a/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java
+++ b/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java
@@ -210,7 +210,7 @@
List<UsageInfo> usages = findUsages(findModel);
assertEquals(2, usages.size());
- if (!(usages.get(0).getElement().getContainingFile() instanceof PsiJavaFile)) {
+ if (!(usages.get(0).getFile() instanceof PsiJavaFile)) {
Collections.swap(usages, 0, 1);
}
PsiElement element = usages.get(0).getElement();
diff --git a/java/java-tests/testSrc/com/intellij/navigation/ChooseByNameTest.groovy b/java/java-tests/testSrc/com/intellij/navigation/ChooseByNameTest.groovy
new file mode 100644
index 0000000..0e82ee3
--- /dev/null
+++ b/java/java-tests/testSrc/com/intellij/navigation/ChooseByNameTest.groovy
@@ -0,0 +1,185 @@
+package com.intellij.navigation
+import com.intellij.ide.util.gotoByName.ChooseByNameBase
+import com.intellij.ide.util.gotoByName.ChooseByNameModel
+import com.intellij.ide.util.gotoByName.ChooseByNamePopup
+import com.intellij.ide.util.gotoByName.GotoClassModel2
+import com.intellij.ide.util.gotoByName.GotoFileModel
+import com.intellij.ide.util.gotoByName.GotoSymbolModel2
+import com.intellij.openapi.Disposable
+import com.intellij.openapi.application.ModalityState
+import com.intellij.openapi.util.Disposer
+import com.intellij.psi.PsiElement
+import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
+import com.intellij.util.Consumer
+import com.intellij.util.concurrency.Semaphore
+/**
+ * @author peter
+ */
+class ChooseByNameTest extends LightCodeInsightFixtureTestCase {
+ ChooseByNamePopup myPopup
+
+ @Override
+ protected void tearDown() throws Exception {
+ myPopup = null
+ super.tearDown()
+ }
+
+ public void "test goto class order by matching degree"() {
+ def startMatch = myFixture.addClass("class UiUtil {}")
+ def wordSkipMatch = myFixture.addClass("class UiAbstractUtil {}")
+ def camelMatch = myFixture.addClass("class UberInstructionUxTopicInterface {}")
+ def middleMatch = myFixture.addClass("class BaseUiUtil {}")
+ def elements = getPopupElements(new GotoClassModel2(project), "uiuti")
+ assert elements == [startMatch, wordSkipMatch, camelMatch, ChooseByNameBase.NON_PREFIX_SEPARATOR, middleMatch]
+ }
+
+ public void "test annotation syntax"() {
+ def match = myFixture.addClass("@interface Anno1 {}")
+ myFixture.addClass("class Anno2 {}")
+ def elements = getPopupElements(new GotoClassModel2(project), "@Anno")
+ assert elements == [match]
+ }
+
+ public void "test no result for empty patterns"() {
+ myFixture.addClass("@interface Anno1 {}")
+ myFixture.addClass("class Anno2 {}")
+
+ def popup = createPopup(new GotoClassModel2(project))
+ assert getPopupElements(popup, "") == []
+ popup.close(false)
+
+ popup = createPopup(new GotoClassModel2(project))
+ assert getPopupElements(popup, "@") == []
+ popup.close(false)
+
+ popup = createPopup(new GotoFileModel(project))
+ assert getPopupElements(popup, "foo/") == []
+ popup.close(false)
+ }
+
+ public void "test filter overridden methods from goto symbol"() {
+ def intf = myFixture.addClass("""
+class Intf {
+ void xxx1() {}
+ void xxx2() {}
+}""")
+ def impl = myFixture.addClass("""
+class Impl extends Intf {
+ void xxx1() {}
+ void xxx3() {}
+}
+""")
+
+ def elements = getPopupElements(new GotoSymbolModel2(project), "xxx")
+
+ assert intf.findMethodsByName('xxx1', false)[0] in elements
+ assert intf.findMethodsByName('xxx2', false)[0] in elements
+
+ assert impl.findMethodsByName('xxx3', false)[0] in elements
+ assert !(impl.findMethodsByName('xxx1', false)[0] in elements)
+ }
+
+ public void "test disprefer underscore"() {
+ def intf = myFixture.addClass("""
+class Intf {
+ void _xxx1() {}
+ void xxx2() {}
+}""")
+
+ def elements = getPopupElements(new GotoSymbolModel2(project), "xxx")
+ assert elements == [intf.findMethodsByName('xxx2', false), ChooseByNameBase.NON_PREFIX_SEPARATOR, intf.findMethodsByName('_xxx1', false)]
+ }
+
+ public void "test prefer exact extension matches"() {
+ def m = myFixture.addFileToProject("relaunch.m", "")
+ def mod = myFixture.addFileToProject("reference.mod", "")
+ def elements = getPopupElements(new GotoFileModel(project), "re*.m")
+ assert elements == [m, mod]
+ }
+
+ public void "test prefer better path matches"() {
+ def fooIndex = myFixture.addFileToProject("foo/index.html", "foo")
+ def fooBarIndex = myFixture.addFileToProject("foo/bar/index.html", "foo bar")
+ def barFooIndex = myFixture.addFileToProject("bar/foo/index.html", "bar foo")
+ def elements = getPopupElements(new GotoFileModel(project), "foo/index")
+ assert elements == [fooIndex, barFooIndex, fooBarIndex]
+ }
+
+ public void "test sort same-named items by path"() {
+ def files = (30..10).collect { i -> myFixture.addFileToProject("foo$i/index.html", "foo$i") }.reverse()
+ def elements = getPopupElements(new GotoFileModel(project), "index")
+ assert elements == files
+ }
+
+ public void "test middle matching for directories"() {
+ def fooIndex = myFixture.addFileToProject("foo/index.html", "foo")
+ def ooIndex = myFixture.addFileToProject("oo/index.html", "oo")
+ def fooBarIndex = myFixture.addFileToProject("foo/bar/index.html", "foo bar")
+ def elements = getPopupElements(new GotoFileModel(project), "oo/index")
+ assert elements == [ooIndex, fooIndex, fooBarIndex]
+ }
+
+ public void "test prefer files from current directory"() {
+ def fooIndex = myFixture.addFileToProject("foo/index.html", "foo")
+ def barIndex = myFixture.addFileToProject("bar/index.html", "bar")
+ def fooContext = myFixture.addFileToProject("foo/context.html", "")
+ def barContext = myFixture.addFileToProject("bar/context.html", "")
+
+ def popup = createPopup(new GotoFileModel(project), fooContext)
+ assert getPopupElements(popup, "index") == [fooIndex, barIndex]
+ popup.close(false)
+
+ popup = createPopup(new GotoFileModel(project), barContext)
+ assert getPopupElements(popup, "index") == [barIndex, fooIndex]
+
+ }
+
+ public void "test find method by qualified name"() {
+ def method = myFixture.addClass("package foo.bar; class Goo { void zzzZzz() {} }").methods[0]
+ assert getPopupElements(new GotoSymbolModel2(project), 'zzzZzz') == [method]
+ assert getPopupElements(new GotoSymbolModel2(project), 'goo.zzzZzz') == [method]
+ assert getPopupElements(new GotoSymbolModel2(project), 'foo.bar.goo.zzzZzz') == [method]
+ assert getPopupElements(new GotoSymbolModel2(project), 'foo.zzzZzz') == [method]
+ assert getPopupElements(new GotoSymbolModel2(project), 'bar.zzzZzz') == [method]
+ assert getPopupElements(new GotoSymbolModel2(project), 'bar.goo.zzzZzz') == [method]
+ }
+
+ private List<Object> getPopupElements(ChooseByNameModel model, String text) {
+ return getPopupElements(createPopup(model), text)
+ }
+
+ private static ArrayList<String> getPopupElements(ChooseByNamePopup popup, String text) {
+ List<Object> elements = ['empty']
+ def semaphore = new Semaphore()
+ semaphore.down()
+ popup.scheduleCalcElements(text, false, false, ModalityState.NON_MODAL, { set ->
+ elements = set as List
+ semaphore.up()
+ } as Consumer<Set<?>>)
+ if (!semaphore.waitFor(1000)) {
+ printThreadDump()
+ fail()
+ }
+ return elements
+ }
+
+ private ChooseByNamePopup createPopup(ChooseByNameModel model, PsiElement context = null) {
+ if (myPopup) {
+ myPopup.close(false)
+ }
+
+ def popup = myPopup = ChooseByNamePopup.createPopup(project, model, (PsiElement)context, "")
+ Disposer.register(testRootDisposable, { popup.close(false) } as Disposable)
+ popup
+ }
+
+ @Override
+ protected boolean runInDispatchThread() {
+ return false
+ }
+
+ @Override
+ protected void invokeTestRunnable(Runnable runnable) throws Exception {
+ runnable.run()
+ }
+}
diff --git a/java/java-tests/testSrc/com/intellij/navigation/GotoImplementationHandlerTest.java b/java/java-tests/testSrc/com/intellij/navigation/GotoImplementationHandlerTest.java
index 161859e..bf9f09f 100644
--- a/java/java-tests/testSrc/com/intellij/navigation/GotoImplementationHandlerTest.java
+++ b/java/java-tests/testSrc/com/intellij/navigation/GotoImplementationHandlerTest.java
@@ -121,4 +121,32 @@
assertNotNull(aClass);
assertEquals(aClass.getName(), "X");
}
+
+ public void testImplicitInheritance() throws Throwable {
+ PsiFile file = myFixture.addFileToProject("Foo.java", "interface PackContainer {\n" +
+ " void foo();\n" +
+ "}\n" +
+ "interface PsiPackage extends PackContainer {}\n" +
+ "class PsiPackageBase implements PackContainer {\n" +
+ " public void foo() {}\n" +
+ "}\n" +
+ "class PsiPackageImpl extends PsiPackageBase implements PsiPackage {}\n" +
+ "\n" +
+ "class Foo {\n" +
+ " class Bar {\n" +
+ " void bar(PsiPackage i) {\n" +
+ " i.fo<caret>o();\n" +
+ " }\n" +
+ " }\n" +
+ "}");
+ myFixture.configureFromExistingVirtualFile(file.getVirtualFile());
+
+ final PsiElement[] impls = new GotoImplementationHandler().getSourceAndTargetElements(myFixture.getEditor(), file).targets;
+ assertEquals(1, impls.length);
+ final PsiElement meth = impls[0];
+ assertTrue(meth instanceof PsiMethod);
+ final PsiClass aClass = ((PsiMethod)meth).getContainingClass();
+ assertNotNull(aClass);
+ assertEquals(aClass.getName(), "PsiPackageBase");
+ }
}
\ No newline at end of file
diff --git a/java/java-tests/testSrc/com/intellij/projectView/FileStructureDialogTest.java b/java/java-tests/testSrc/com/intellij/projectView/FileStructureDialogTest.java
index eab9203..f460748 100644
--- a/java/java-tests/testSrc/com/intellij/projectView/FileStructureDialogTest.java
+++ b/java/java-tests/testSrc/com/intellij/projectView/FileStructureDialogTest.java
@@ -43,7 +43,7 @@
final StructureViewBuilder structureViewBuilder =
StructureViewBuilder.PROVIDER.getStructureViewBuilder(virtualFile.getFileType(), virtualFile, myProject);
assertNotNull(structureViewBuilder);
- final StructureViewModel structureViewModel = ((TreeBasedStructureViewBuilder)structureViewBuilder).createStructureViewModel();
+ final StructureViewModel structureViewModel = ((TreeBasedStructureViewBuilder)structureViewBuilder).createStructureViewModel(null);
final EditorFactory factory = EditorFactory.getInstance();
assertNotNull(factory);
diff --git a/java/java-tests/testSrc/com/intellij/projectView/ProjectViewUpdatingTest.java b/java/java-tests/testSrc/com/intellij/projectView/ProjectViewUpdatingTest.java
new file mode 100644
index 0000000..c23078e
--- /dev/null
+++ b/java/java-tests/testSrc/com/intellij/projectView/ProjectViewUpdatingTest.java
@@ -0,0 +1,464 @@
+/*
+ * Copyright (c) 2004 JetBrains s.r.o. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * -Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * -Redistribution in binary form must reproduct the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of JetBrains or IntelliJ IDEA
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
+ * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+ * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. JETBRAINS AND ITS LICENSORS SHALL NOT
+ * BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE AS A RESULT
+ * OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE SOFTWARE OR ITS
+ * DERIVATIVES. IN NO EVENT WILL JETBRAINS OR ITS LICENSORS BE LIABLE FOR ANY LOST
+ * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
+ * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
+ * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE, EVEN
+ * IF JETBRAINS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ */
+package com.intellij.projectView;
+
+import com.intellij.ide.projectView.PresentationData;
+import com.intellij.ide.projectView.TreeStructureProvider;
+import com.intellij.ide.projectView.ViewSettings;
+import com.intellij.ide.projectView.impl.AbstractProjectViewPSIPane;
+import com.intellij.ide.projectView.impl.ClassesTreeStructureProvider;
+import com.intellij.ide.util.treeView.AbstractTreeNode;
+import com.intellij.ide.util.treeView.NodeDescriptor;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.command.CommandProcessor;
+import com.intellij.openapi.editor.Document;
+import com.intellij.openapi.fileEditor.FileDocumentManager;
+import com.intellij.openapi.project.Project;
+import com.intellij.psi.*;
+import com.intellij.refactoring.rename.RenameProcessor;
+import com.intellij.testFramework.PlatformTestUtil;
+import com.intellij.uiDesigner.projectView.FormMergerTreeStructureProvider;
+import com.intellij.util.IncorrectOperationException;
+import com.intellij.util.ui.tree.TreeUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+import java.awt.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.List;
+
+@SuppressWarnings({"HardCodedStringLiteral"})
+public class ProjectViewUpdatingTest extends BaseProjectViewTestCase {
+ public void testStandardProviders() throws Exception{
+ PsiFile element = JavaDirectoryService.getInstance().getClasses(getPackageDirectory())[0].getContainingFile();
+ final AbstractProjectViewPSIPane pane = myStructure.createPane();
+ getProjectTreeStructure().setProviders();
+ pane.select(element, element.getContainingFile().getVirtualFile(), true);
+ PlatformTestUtil.assertTreeEqual(pane.getTree(), "-Project\n" +
+ " -PsiDirectory: standardProviders\n" +
+ " -PsiDirectory: src\n" +
+ " -PsiDirectory: com\n" +
+ " -PsiDirectory: package1\n" +
+ " Class1.java\n" +
+ " Class2.java\n" +
+ " Class4.java\n" +
+ " Form1.form\n" +
+ " Form1.java\n" +
+ " Form2.form\n" +
+ getRootFiles() +
+ " +External Libraries\n"
+ );
+ final PsiClass[] classes = JavaDirectoryService.getInstance()
+ .getPackage(getContentDirectory().findSubdirectory("src").findSubdirectory("com").findSubdirectory("package1")).getClasses();
+ sortClassesByName(classes);
+ ApplicationManager.getApplication().runWriteAction(new Runnable() {
+ public void run() {
+ classes[0].delete();
+ }
+ });
+
+
+ PlatformTestUtil.waitForAlarm(600);
+
+ PlatformTestUtil.assertTreeEqual(pane.getTree(), "-Project\n" +
+ " -PsiDirectory: standardProviders\n" +
+ " -PsiDirectory: src\n" +
+ " -PsiDirectory: com\n" +
+ " -PsiDirectory: package1\n" +
+ " Class2.java\n" +
+ " Class4.java\n" +
+ " Form1.form\n" +
+ " Form1.java\n" +
+ " Form2.form\n" +
+ getRootFiles() +
+ " +External Libraries\n");
+
+ }
+
+ public void testUpdateProjectView() throws Exception {
+ getProjectTreeStructure().setProviders(new ClassesTreeStructureProvider(myProject), new FormMergerTreeStructureProvider(myProject));
+
+ final AbstractProjectViewPSIPane pane = myStructure.createPane();
+ final JTree tree = pane.getTree();
+ PlatformTestUtil.assertTreeEqual(tree, "-Project\n" +
+ " +PsiDirectory: updateProjectView\n" +
+ getRootFiles() +
+ " +External Libraries\n");
+
+ final PsiJavaFile classFile = (PsiJavaFile)getContentDirectory().findSubdirectory("src").findSubdirectory("com").findSubdirectory("package1").findFile("Form1.java");
+ final PsiClass aClass = classFile.getClasses()[0];
+ final PsiFile containingFile = aClass.getContainingFile();
+ pane.select(aClass, containingFile.getVirtualFile(), true);
+ PlatformTestUtil.assertTreeEqual(pane.getTree(), "-Project\n" +
+ " -PsiDirectory: updateProjectView\n" +
+ " -PsiDirectory: src\n" +
+ " -PsiDirectory: com\n" +
+ " -PsiDirectory: package1\n" +
+ " Class1\n" +
+ " +Class2.java\n" +
+ " Class4.java\n" +
+ " Form2.form\n" +
+ " -Form:Form1\n" +
+ " [Form1]\n" +
+ " Form1.form\n" +
+ getRootFiles() +
+ " +External Libraries\n", true);
+
+ CommandProcessor.getInstance().executeCommand(myProject, new Runnable() {
+ @Override
+ public void run() {
+ new RenameProcessor(myProject, aClass, "Form1_renamed", false, false).run();
+ }
+ }, null, null);
+
+ PlatformTestUtil.waitForAlarm(600);
+ PlatformTestUtil.assertTreeEqual(tree, "-Project\n" +
+ " -PsiDirectory: updateProjectView\n" +
+ " -PsiDirectory: src\n" +
+ " -PsiDirectory: com\n" +
+ " -PsiDirectory: package1\n" +
+ " Class1\n" +
+ " +Class2.java\n" +
+ " Class4.java\n" +
+ " Form2.form\n" +
+ " -Form:Form1_renamed\n" +
+ " Form1.form\n" +
+ " [Form1_renamed]\n" +
+ getRootFiles() +
+ " +External Libraries\n", true);
+
+ TreeUtil.collapseAll(pane.getTree(), -1);
+ PlatformTestUtil.assertTreeEqual(tree, "-Project\n" +
+ " +PsiDirectory: updateProjectView\n" +
+ getRootFiles() +
+ " +External Libraries\n");
+
+ final PsiClass aClass2 = JavaDirectoryService.getInstance()
+ .createClass(getContentDirectory().findSubdirectory("src").findSubdirectory("com").findSubdirectory("package1"), "Class6");
+ PlatformTestUtil.waitForAlarm(600);
+ final PsiFile containingFile2 = aClass2.getContainingFile();
+ pane.select(aClass2, containingFile2.getVirtualFile(), true);
+ PlatformTestUtil.assertTreeEqual(pane.getTree(), "-Project\n" +
+ " -PsiDirectory: updateProjectView\n" +
+ " -PsiDirectory: src\n" +
+ " -PsiDirectory: com\n" +
+ " -PsiDirectory: package1\n" +
+ " Class1\n" +
+ " +Class2.java\n" +
+ " Class4.java\n" +
+ " [Class6]\n" +
+ " Form2.form\n" +
+ " +Form:Form1_renamed\n" +
+ getRootFiles() +
+ " +External Libraries\n", true);
+ }
+
+ public void testShowClassMembers() throws Exception{
+
+ getProjectTreeStructure().setProviders(new ClassesTreeStructureProvider(myProject), new FormMergerTreeStructureProvider(myProject));
+
+ final AbstractProjectViewPSIPane pane = myStructure.createPane();
+ final JTree tree = pane.getTree();
+ PlatformTestUtil.assertTreeEqual(tree, "-Project\n" +
+ " +PsiDirectory: showClassMembers\n" +
+ getRootFiles() +
+ " +External Libraries\n");
+
+ myStructure.setShowMembers(true);
+
+ PsiJavaFile classFile = (PsiJavaFile)getContentDirectory().findSubdirectory("src").findSubdirectory("com").findSubdirectory("package1").findFile("Class1.java");
+ PsiClass aClass = classFile.getClasses()[0];
+ PsiFile containingFile = aClass.getContainingFile();
+ pane.select(aClass, containingFile.getVirtualFile(), true);
+ PlatformTestUtil.assertTreeEqual(pane.getTree(), "-Project\n" +
+ " -PsiDirectory: showClassMembers\n" +
+ " -PsiDirectory: src\n" +
+ " -PsiDirectory: com\n" +
+ " -PsiDirectory: package1\n" +
+ " -[Class1]\n" +
+ " +InnerClass\n" +
+ " getValue():int\n" +
+ " myField1:boolean\n" +
+ " myField2:boolean\n" +
+ " +Class2\n" +
+ getRootFiles() +
+ " +External Libraries\n", true);
+
+
+ final Document document = FileDocumentManager.getInstance().getDocument(containingFile.getVirtualFile());
+ final int caretPosition = document.getText().indexOf("public class InnerClass") - 1;
+
+ ApplicationManager.getApplication().runWriteAction(new Runnable() {
+ public void run() {
+ CommandProcessor.getInstance().executeCommand(myProject,
+ new Runnable() {
+ @Override
+ public void run() {
+ document.insertString(caretPosition, "\n");
+ }
+ },
+ "typing",
+ null);
+ }
+ });
+
+
+ PsiDocumentManager.getInstance(myProject).commitDocument(document);
+ PlatformTestUtil.waitForAlarm(600);
+
+ PlatformTestUtil.assertTreeEqual(pane.getTree(), "-Project\n" +
+ " -PsiDirectory: showClassMembers\n" +
+ " -PsiDirectory: src\n" +
+ " -PsiDirectory: com\n" +
+ " -PsiDirectory: package1\n" +
+ " -[Class1]\n" +
+ " +InnerClass\n" +
+ " getValue():int\n" +
+ " myField1:boolean\n" +
+ " myField2:boolean\n" +
+ " +Class2\n" +
+ getRootFiles() +
+ " +External Libraries\n", true);
+
+ classFile = (PsiJavaFile)getContentDirectory().findSubdirectory("src").findSubdirectory("com").findSubdirectory("package1").findFile("Class1.java");
+ aClass = classFile.getClasses()[0];
+ final PsiField lastField = aClass.getFields()[1];
+ pane.select(lastField, containingFile.getVirtualFile(), true);
+
+ PlatformTestUtil.assertTreeEqual(pane.getTree(), "-Project\n" +
+ " -PsiDirectory: showClassMembers\n" +
+ " -PsiDirectory: src\n" +
+ " -PsiDirectory: com\n" +
+ " -PsiDirectory: package1\n" +
+ " -Class1\n" +
+ " +InnerClass\n" +
+ " getValue():int\n" +
+ " myField1:boolean\n" +
+ " [myField2:boolean]\n" +
+ " +Class2\n" +
+ getRootFiles() +
+ " +External Libraries\n", true);
+
+ CommandProcessor.getInstance().executeCommand(myProject, new Runnable() {
+ @Override
+ public void run() {
+ ApplicationManager.getApplication().runWriteAction(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ assertEquals("myField2", lastField.getName());
+ lastField.setName("_firstField");
+ }
+ catch (IncorrectOperationException e) {
+ fail(e.getMessage());
+ }
+ }
+ });
+ }
+ }, null, null);
+
+ PlatformTestUtil.waitForAlarm(600);
+
+ PlatformTestUtil.assertTreeEqual(pane.getTree(), "-Project\n" +
+ " -PsiDirectory: showClassMembers\n" +
+ " -PsiDirectory: src\n" +
+ " -PsiDirectory: com\n" +
+ " -PsiDirectory: package1\n" +
+ " -Class1\n" +
+ " +InnerClass\n" +
+ " getValue():int\n" +
+ " [_firstField:boolean]\n" +
+ " myField1:boolean\n" +
+ " +Class2\n" +
+ getRootFiles() +
+ " +External Libraries\n", true);
+ }
+
+ public void testAnnoyingScrolling() throws Exception{
+
+ getProjectTreeStructure().setProviders(new ClassesTreeStructureProvider(myProject));
+
+ final AbstractProjectViewPSIPane pane = myStructure.createPane();
+ final JTree tree = pane.getTree();
+
+ myStructure.setShowMembers(true);
+
+ PsiJavaFile classFile = (PsiJavaFile)getContentDirectory().findSubdirectory("src").findSubdirectory("com").findSubdirectory("package1").findFile("Class1.java");
+ PsiClass aClass = classFile.getClasses()[0];
+ PsiFile containingFile = aClass.getContainingFile();
+ PsiDirectory directory = containingFile.getContainingDirectory();
+ pane.select(aClass, containingFile.getVirtualFile(), true);
+ Point viewPosition = ((JViewport)tree.getParent()).getViewPosition();
+ for (int i=0;i<100;i++) {
+ JavaDirectoryService.getInstance().createClass(directory, "A" + i);
+ }
+ PlatformTestUtil.waitForAlarm(600);
+ Point viewPositionAfter = ((JViewport)tree.getParent()).getViewPosition();
+ assertEquals(viewPosition, viewPositionAfter);
+
+ }
+
+ class NodeWrapper extends AbstractTreeNode<Object> {
+ String myName;
+ List<NodeWrapper> myChildren = new ArrayList<NodeWrapper>();
+
+ public NodeWrapper(final Project project, final String value) {
+ super(project, new Object());
+ myName = value;
+ }
+
+ @Override
+ @NotNull
+ public Collection<? extends AbstractTreeNode> getChildren() {
+ return myChildren;
+ }
+
+ @Override
+ protected void update(final PresentationData presentation) {
+ presentation.setPresentableText(myName);
+ }
+
+ public void addChild(final NodeWrapper nodeWrapper) {
+ myChildren.add(nodeWrapper);
+ }
+
+ public void setName(final String s) {
+ myName = s;
+ }
+ }
+
+ public void testUpdatingAfterRename() throws Exception{
+
+ final NodeWrapper rootWrapper = new NodeWrapper(myProject, "1");
+
+ final NodeWrapper wr11 = new NodeWrapper(myProject, "1.1");
+ final NodeWrapper wr12 = new NodeWrapper(myProject, "1.2");
+ final NodeWrapper wr13 = new NodeWrapper(myProject, "1.3");
+ final NodeWrapper wr111 = new NodeWrapper(myProject, "1.1.1");
+ final NodeWrapper wr112 = new NodeWrapper(myProject, "1.1.2");
+ final NodeWrapper wr113 = new NodeWrapper(myProject, "1.1.3");
+ final NodeWrapper wr121 = new NodeWrapper(myProject, "1.2.1");
+ final NodeWrapper wr122 = new NodeWrapper(myProject, "1.2.2");
+ final NodeWrapper wr123 = new NodeWrapper(myProject, "1.2.3");
+ final NodeWrapper wr131 = new NodeWrapper(myProject, "1.3.1");
+ final NodeWrapper wr132 = new NodeWrapper(myProject, "1.3.2");
+ final NodeWrapper wr133 = new NodeWrapper(myProject, "1.3.3");
+
+ rootWrapper.addChild(wr11);
+ rootWrapper.addChild(wr12);
+ rootWrapper.addChild(wr13);
+
+ wr11.addChild(wr111);
+ wr11.addChild(wr112);
+ wr11.addChild(wr113);
+
+ wr12.addChild(wr121);
+ wr12.addChild(wr122);
+ wr12.addChild(wr123);
+
+ wr13.addChild(wr131);
+ wr13.addChild(wr132);
+ wr13.addChild(wr133);
+
+
+ getProjectTreeStructure().setProviders(createWrapProvider(rootWrapper));
+
+ final AbstractProjectViewPSIPane pane = myStructure.createPane();
+
+ final JTree tree = pane.getTree();
+
+ pane.getTreeBuilder().setNodeDescriptorComparator(new Comparator<NodeDescriptor>() {
+ @Override
+ public int compare(final NodeDescriptor o1, final NodeDescriptor o2) {
+ if (o1 instanceof NodeWrapper && o2 instanceof NodeWrapper) {
+ return ((NodeWrapper)o1).getName().compareTo(((NodeWrapper)o2).getName());
+ }
+ else {
+ return 0;
+ }
+ }
+ });
+
+ tree.expandRow(2);
+ TreeUtil.selectPath(tree, tree.getPathForRow(4));
+
+ PlatformTestUtil.assertTreeEqual(tree, "-Project\n" +
+ " -1\n" +
+ " +1.1\n" +
+ " -1.2\n" +
+ " 1.2.1\n" +
+ " [1.2.2]\n" +
+ " 1.2.3\n" +
+ " +1.3\n", true);
+
+ wr12.setName("01.2");
+ wr122.setName("01.2.2");
+
+ pane.getTreeBuilder().updateFromRoot();
+
+ PlatformTestUtil.assertTreeEqual(tree, "-Project\n" +
+ " -1\n" +
+ " -01.2\n" +
+ " [01.2.2]\n" +
+ " 1.2.1\n" +
+ " 1.2.3\n" +
+ " +1.1\n" +
+ " +1.3\n", true);
+
+
+ }
+
+ private TreeStructureProvider createWrapProvider(final NodeWrapper rootWrapper) {
+ return new TreeStructureProvider() {
+ @Override
+ public Collection<AbstractTreeNode> modify(AbstractTreeNode parent, Collection<AbstractTreeNode> children, ViewSettings settings) {
+
+ if (parent instanceof NodeWrapper) {
+ return children;
+ }
+ List<AbstractTreeNode> result = new ArrayList<AbstractTreeNode>();
+ result.add(rootWrapper);
+ return result;
+ }
+
+ @Override
+ @Nullable
+ public Object getData(Collection<AbstractTreeNode> selected, String dataName) {
+ return null;
+ }
+ };
+ }
+
+}
diff --git a/java/java-tests/testSrc/com/intellij/psi/MiscPsiTest.java b/java/java-tests/testSrc/com/intellij/psi/MiscPsiTest.java
new file mode 100644
index 0000000..e972b4f
--- /dev/null
+++ b/java/java-tests/testSrc/com/intellij/psi/MiscPsiTest.java
@@ -0,0 +1,245 @@
+package com.intellij.psi;
+
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.editor.Document;
+import com.intellij.openapi.fileEditor.FileDocumentManager;
+import com.intellij.openapi.roots.LanguageLevelProjectExtension;
+import com.intellij.openapi.vfs.VfsUtil;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.pom.java.LanguageLevel;
+import com.intellij.psi.impl.source.tree.LazyParseableElement;
+import com.intellij.testFramework.PlatformTestCase;
+import com.intellij.testFramework.PsiTestCase;
+import com.intellij.testFramework.PsiTestUtil;
+
+@PlatformTestCase.WrapInCommand
+public class MiscPsiTest extends PsiTestCase{
+ private VirtualFile myRoot;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ myRoot = PsiTestUtil.createTestProjectStructure(myProject, myModule, myFilesToDelete);
+ }
+
+ public void testCopyTextFile() throws Exception{
+ VirtualFile vFile = myRoot.createChildData(null, "Test.txt");
+ final String text = "1234567890";
+ vFile.setBinaryContent(text.getBytes());
+
+ VirtualFile vDir = myRoot.createChildDirectory(null, "dir");
+
+ PsiDocumentManager.getInstance(myProject).commitAllDocuments();
+ PsiFile file = myPsiManager.findFile(vFile);
+ assertTrue(file instanceof PsiPlainTextFile);
+ PsiDirectory dir = myPsiManager.findDirectory(vDir);
+ PsiFile fileCopy = (PsiFile)file.copy();
+ fileCopy = (PsiFile) fileCopy.setName("NewTest.txt");
+ PsiFile newFile = (PsiFile)dir.add(fileCopy);
+ assertTrue(newFile instanceof PsiPlainTextFile);
+
+ assertEquals(text, new String(newFile.getVirtualFile().contentsToByteArray()));
+ assertEquals(newFile.getVirtualFile().getModificationStamp(), newFile.getViewProvider().getModificationStamp());
+ Document document = PsiDocumentManager.getInstance(myProject).getDocument(newFile);
+ assertEquals(newFile.getVirtualFile().getModificationStamp(), document.getModificationStamp());
+ }
+
+ public void testCopyBinaryFile() throws Exception{
+ VirtualFile vFile = myRoot.createChildData(null, "Test.xxx");
+ final byte[] bytes = new byte[]{12,34,56,78,90,45,83,0x22,(byte)0xff, (byte)0xff, (byte)0xff, (byte)0xee};
+ vFile.setBinaryContent(bytes);
+
+ VirtualFile vDir = myRoot.createChildDirectory(null, "dir");
+
+ PsiDocumentManager.getInstance(myProject).commitAllDocuments();
+ PsiFile file = myPsiManager.findFile(vFile);
+ assertTrue(file instanceof PsiBinaryFile);
+ PsiDirectory dir = myPsiManager.findDirectory(vDir);
+ PsiFile fileCopy = (PsiFile)file.copy();
+ fileCopy = (PsiFile) fileCopy.setName("NewTest.xxx");
+ PsiFile newFile = (PsiFile)dir.add(fileCopy);
+ assertTrue(newFile instanceof PsiBinaryFile);
+
+ assertOrderedEquals(newFile.getVirtualFile().contentsToByteArray(), bytes);
+ }
+
+ public void testCopyBinaryToTextFile() throws Exception{
+ VirtualFile vFile = myRoot.createChildData(null, "Test.xxx");
+ String text = "1234567890";
+ vFile.setBinaryContent(text.getBytes());
+
+ VirtualFile vDir = myRoot.createChildDirectory(null, "dir");
+
+ PsiDocumentManager.getInstance(myProject).commitAllDocuments();
+ PsiFile file = myPsiManager.findFile(vFile);
+ PsiDirectory dir = myPsiManager.findDirectory(vDir);
+ PsiFile fileCopy = (PsiFile)file.copy();
+ fileCopy = (PsiFile) fileCopy.setName("NewTest.txt");
+ PsiFile newFile = (PsiFile)dir.add(fileCopy);
+ assertTrue(newFile instanceof PsiPlainTextFile);
+
+ assertEquals(text, VfsUtil.loadText(newFile.getVirtualFile()));
+ assertEquals(newFile.getVirtualFile().getModificationStamp(), newFile.getViewProvider().getModificationStamp());
+ assertFalse(FileDocumentManager.getInstance().isFileModified(newFile.getVirtualFile()));
+ }
+
+ public void testSCR4212() throws Exception{
+ VirtualFile vFile = myRoot.createChildData(null, "Test.java");
+ String text = "class A{{ return(Object)new String(); }}";
+ VfsUtil.saveText(vFile, text);
+
+ PsiDocumentManager.getInstance(myProject).commitAllDocuments();
+ PsiJavaFile file = (PsiJavaFile)myPsiManager.findFile(vFile);
+ PsiClass aClass = file.getClasses()[0];
+ PsiClassInitializer initializer = aClass.getInitializers()[0];
+ PsiStatement statement = initializer.getBody().getStatements()[0];
+ PsiTypeCastExpression typeCast = (PsiTypeCastExpression)((PsiReturnStatement)statement).getReturnValue();
+ typeCast.replace(typeCast.getOperand());
+
+ String textAfter = file.getText();
+ String expectedText = "class A{{ return new String(); }}";
+ assertEquals(expectedText, textAfter);
+ }
+
+ public void testDeleteFieldInMultipleDeclarations() throws Exception {
+ final PsiClass aClass = getJavaFacade().getElementFactory().createClassFromText("public int i, j;", null);
+
+ final PsiField aField = aClass.getFields()[0];
+ ApplicationManager.getApplication().runWriteAction(new Runnable() {
+ public void run() {
+ aField.delete();
+ }
+ });
+
+ assertEquals("public int j;", aClass.getFields()[0].getText());
+ }
+
+ public void testSCR5929() throws Exception {
+ VirtualFile vFileA = myRoot.createChildData(null, "A.java");
+ String text = "class A{ /** @see a.B */ }";
+ VfsUtil.saveText(vFileA, text);
+
+ VirtualFile dir = myRoot.createChildDirectory(null, "a");
+ VirtualFile vFileB = dir.createChildData(null, "B.java");
+ text = "class B{}";
+ VfsUtil.saveText(vFileB, text);
+
+ PsiDocumentManager.getInstance(myProject).commitAllDocuments();
+ PsiFile fileA = myPsiManager.findFile(vFileA);
+ PsiJavaFile fileACopy = (PsiJavaFile)fileA.copy();
+ PsiClass aClass = fileACopy.getClasses()[0];
+ aClass.setName("A2");
+ fileA.getContainingDirectory().add(fileACopy);
+ }
+
+ public void testCopyClass() throws Exception {
+ VirtualFile vFile = myRoot.createChildData(null, "A.java");
+ String text = "package aaa; class A{}";
+ VfsUtil.saveText(vFile, text);
+
+ PsiDocumentManager.getInstance(myProject).commitAllDocuments();
+ PsiFile file = myPsiManager.findFile(vFile);
+ PsiJavaFile fileACopy = (PsiJavaFile)file.copy();
+ PsiClass aClass = fileACopy.getClasses()[0];
+ aClass.setName("ANew");
+ PsiFile newFile = (PsiFile)file.getContainingDirectory().add(fileACopy);
+ Document document = PsiDocumentManager.getInstance(myProject).getDocument(newFile);
+ FileDocumentManager.getInstance().saveDocument(document);
+ assertEquals(newFile.getVirtualFile().getModificationStamp(), newFile.getViewProvider().getModificationStamp());
+ assertFalse(FileDocumentManager.getInstance().isFileModified(newFile.getVirtualFile()));
+ }
+
+ public void testSCR15954() throws Exception {
+ PsiJavaFile file = (PsiJavaFile)createFile("A.java", "class A{\nA(){}\n}");
+
+ PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(myProject);
+ Document document = psiDocumentManager.getDocument(file);
+ document.insertString(document.getTextLength(), " "); // insert a trailing space to strip
+ psiDocumentManager.commitAllDocuments();
+
+ PsiClass aClass = file.getClasses()[0];
+ aClass.setName("B");
+ }
+
+ public void testDeleteAnnotationAttribute() throws Exception {
+ final PsiAnnotation annotation = getJavaFacade().getElementFactory().createAnnotationFromText("@A(b,c)", null);
+ final PsiNameValuePair secondAttribute = annotation.getParameterList().getAttributes()[1];
+ ApplicationManager.getApplication().runWriteAction(new Runnable() {
+ public void run() {
+ secondAttribute.delete();
+ }
+ });
+
+ assertEquals("@A(b )", annotation.getText());
+ }
+
+ public void testDeleteAnnotationArrayInitializerElement() throws Exception {
+ final PsiAnnotation annotation = getJavaFacade().getElementFactory().createAnnotationFromText("@A({b,c})", null);
+ final PsiNameValuePair firstAttribute = annotation.getParameterList().getAttributes()[0];
+ assertTrue(firstAttribute.getValue() instanceof PsiArrayInitializerMemberValue);
+ final PsiAnnotationMemberValue firstInitializer = ((PsiArrayInitializerMemberValue)firstAttribute.getValue()).getInitializers()[0];
+ ApplicationManager.getApplication().runWriteAction(new Runnable() {
+ public void run() {
+ firstInitializer.delete();
+ }
+ });
+
+ assertEquals("@A({ c})", annotation.getText());
+ }
+
+ public void testJavaLangObjectSuperMethod() throws Exception {
+ final PsiClass aClass =
+ getJavaFacade().getElementFactory().createClassFromText("public String toString() {return null;}", null);
+ final PsiMethod method = aClass.getMethods()[0];
+ final PsiMethod[] superMethods = method.findSuperMethods();
+ assertEquals(1, superMethods.length);
+ assertEquals(CommonClassNames.JAVA_LANG_OBJECT, superMethods[0].getContainingClass().getQualifiedName());
+ }
+
+ public void testImportOnDemand() throws Exception {
+ final PsiJavaFile file = (PsiJavaFile)PsiFileFactory.getInstance(getProject()).createFileFromText("D.java",
+ "import java.util.Map.Entry");
+ PsiImportStatement importStatement = file.getImportList().getImportStatements()[0];
+ assertTrue(!importStatement.isOnDemand());
+ }
+
+ public void testDocCommentPrecededByLineComment() throws Exception {
+ final PsiJavaFile file = (PsiJavaFile)PsiFileFactory.getInstance(getProject()).createFileFromText("D.java",
+ "////////////////////////////////////////\n" +
+ "/** */\n" +
+ "/////////////////////////////////////////////////\n" +
+ "class Usage {\n" +
+ "}");
+ final PsiClass psiClass = file.getClasses()[0];
+ assertNotNull(psiClass.getDocComment());
+ }
+
+ public void testTopLevelEnumIsNotStatic() throws Exception {
+ final JavaPsiFacade facade = getJavaFacade();
+ final LanguageLevel prevLanguageLevel = LanguageLevelProjectExtension.getInstance(facade.getProject()).getLanguageLevel();
+ LanguageLevelProjectExtension.getInstance(facade.getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
+ final PsiClass aClass;
+ try {
+ aClass = JavaPsiFacade.getInstance(getProject()).getElementFactory().createEnum("E");
+ }
+ finally {
+ LanguageLevelProjectExtension.getInstance(facade.getProject()).setLanguageLevel(prevLanguageLevel);
+ }
+ assertTrue(aClass.isEnum());
+ assertFalse(aClass.hasModifierProperty(PsiModifier.STATIC));
+ }
+
+ public void testDoNotExpandNestedChameleons() throws Exception {
+ PsiJavaFile file = (PsiJavaFile)createFile("a.java", "class A {{{}}}");
+ file.getNode();
+
+ PsiCodeBlock initializer = file.getClasses()[0].getInitializers()[0].getBody();
+ assertFalse(assertInstanceOf(initializer.getNode(), LazyParseableElement.class).isParsed());
+
+ PsiCodeBlock nestedBlock = ((PsiBlockStatement)initializer.getStatements()[0]).getCodeBlock();
+ assertTrue(assertInstanceOf(initializer.getNode(), LazyParseableElement.class).isParsed());
+ assertFalse(assertInstanceOf(nestedBlock.getNode(), LazyParseableElement.class).isParsed());
+ }
+
+}
diff --git a/java/java-tests/testSrc/com/intellij/psi/PsiConcurrencyStressTest.java b/java/java-tests/testSrc/com/intellij/psi/PsiConcurrencyStressTest.java
index c1d20b4..a9c2b5f 100644
--- a/java/java-tests/testSrc/com/intellij/psi/PsiConcurrencyStressTest.java
+++ b/java/java-tests/testSrc/com/intellij/psi/PsiConcurrencyStressTest.java
@@ -19,6 +19,7 @@
*/
package com.intellij.psi;
+import com.intellij.codeInsight.daemon.impl.DaemonProgressIndicator;
import com.intellij.codeInsight.daemon.impl.HighlightInfoFilter;
import com.intellij.codeInsight.daemon.impl.analysis.HighlightInfoHolder;
import com.intellij.codeInsight.daemon.impl.analysis.HighlightVisitorImpl;
@@ -27,6 +28,7 @@
import com.intellij.openapi.application.ex.PathManagerEx;
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.editor.Document;
+import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.search.GlobalSearchScope;
@@ -60,7 +62,7 @@
PsiTestUtil.createTestProjectStructure(myProject, myModule, root, myFilesToDelete);
}
- private PsiJavaFile myFile;
+ private volatile PsiJavaFile myFile;
private volatile boolean writeActionInProgress;
public void testStress() throws Exception {
int numOfThreads = 10;
@@ -85,13 +87,18 @@
public void run() {
for (int i = 0; i < readIterations; i++) {
if (myPsiManager == null) return;
- ApplicationManager.getApplication().runReadAction(new Runnable() {
+ ProgressManager.getInstance().runProcess(new Runnable() {
@Override
public void run() {
- assertFalse(writeActionInProgress);
- readStep(random);
+ ApplicationManager.getApplication().runReadAction(new Runnable() {
+ @Override
+ public void run() {
+ assertFalse(writeActionInProgress);
+ readStep(random);
+ }
+ });
}
- });
+ }, new DaemonProgressIndicator());
}
reads.countDown();
@@ -130,7 +137,7 @@
assertTrue(psiClass.isValid());
return psiClass;
}
-
+
private synchronized void writeStep(final Random random) throws IncorrectOperationException {
switch (random.nextInt(2)) {
case 0 :
@@ -177,7 +184,7 @@
final HighlightInfoHolder infoHolder = new HighlightInfoHolder(myFile, HighlightInfoFilter.EMPTY_ARRAY);
final HighlightVisitorImpl visitor = new HighlightVisitorImpl(PsiResolveHelper.SERVICE.getInstance(getProject()));
- visitor.analyze(myFile, false, infoHolder, new Runnable() {
+ visitor.analyze(myFile, true, infoHolder, new Runnable() {
@Override
public void run() {
visitor.visit(element);
diff --git a/java/java-tests/testSrc/com/intellij/psi/StubAstSwitchTest.groovy b/java/java-tests/testSrc/com/intellij/psi/StubAstSwitchTest.groovy
index b9a5732..da446c7 100644
--- a/java/java-tests/testSrc/com/intellij/psi/StubAstSwitchTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/psi/StubAstSwitchTest.groovy
@@ -14,15 +14,16 @@
* limitations under the License.
*/
package com.intellij.psi
-
import com.intellij.openapi.application.ApplicationManager
+import com.intellij.openapi.fileEditor.FileDocumentManager
+import com.intellij.openapi.vfs.VfsUtil
import com.intellij.psi.impl.source.PsiFileImpl
+import com.intellij.psi.search.GlobalSearchScope
import com.intellij.psi.util.PsiTreeUtil
-import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
import com.intellij.reference.SoftReference
+import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
import java.util.concurrent.CountDownLatch
-
/**
* @author peter
*/
@@ -79,4 +80,21 @@
}
latch.await()
}
+
+ public void "test external modification of a stubbed file with smart pointer switches the file to AST"() {
+ PsiFile file = myFixture.addFileToProject("A.java", "class A {}")
+ def oldClass = JavaPsiFacade.getInstance(project).findClass("A", GlobalSearchScope.allScope(project))
+ def pointer = SmartPointerManager.getInstance(project).createSmartPsiElementPointer(oldClass)
+
+ def document = FileDocumentManager.instance.getCachedDocument(file.virtualFile)
+ assert document
+ assert file == PsiDocumentManager.getInstance(project).getCachedPsiFile(document)
+ assert document == PsiDocumentManager.getInstance(project).getCachedDocument(file)
+
+ assert ((PsiFileImpl)file).stub
+
+ ApplicationManager.application.runWriteAction { VfsUtil.saveText(file.virtualFile, "import java.util.*; class A {}; class B {}") }
+ assert pointer.element == oldClass
+ assert ((PsiFileImpl)file).treeElement
+ }
}
diff --git a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterIndentationTest.java b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterIndentationTest.java
index b61689b..be33547 100644
--- a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterIndentationTest.java
+++ b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterIndentationTest.java
@@ -40,7 +40,7 @@
// Checking that closing curly brace of initialization block that is not the first block on a line is correctly indented.
doTextTest("class Class {\n" + " private Type field; {\n" + " }\n" + "}",
- "class Class {\n" + " private Type field; {\n" + " }\n" + "}");
+ "class Class {\n" + " private Type field;\n\n {\n" + " }\n" + "}");
doTextTest(
"class T {\n" +
" private final DecimalFormat fmt = new DecimalFormat(); {\n" +
@@ -49,7 +49,7 @@
" }\n" +
"}",
"class T {\n" +
- " private final DecimalFormat fmt = new DecimalFormat(); {\n" +
+ " private final DecimalFormat fmt = new DecimalFormat();\n\n {\n" +
" fmt.setGroupingUsed(false);\n" +
" fmt.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.US));\n" +
" }\n" +
diff --git a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavadocFormatterTest.java b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavadocFormatterTest.java
index d01f0f6..28e4de5 100644
--- a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavadocFormatterTest.java
+++ b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavadocFormatterTest.java
@@ -122,7 +122,31 @@
"}"
);
}
-
+
+ public void testParameterDescriptionNotOnNewLine() throws Exception {
+ // IDEA-107383
+ getSettings().getRootSettings().ENABLE_JAVADOC_FORMATTING = true;
+ getSettings().getRootSettings().JD_ALIGN_PARAM_COMMENTS = true;
+
+ doClassTest(
+ "/**\n" +
+ " @param protocolId protocol id\n" +
+ " @param connectedUserIdHandlerFromServer user id\n" +
+ " @return\n" +
+
+ " */\n" +
+ "public void register(int protocolId, int connectedUserIdHandlerFromServer) {\n" +
+ "}",
+
+ "/**\n" +
+ " * @param protocolId protocol id\n" +
+ " * @param connectedUserIdHandlerFromServer user id\n" +
+ " * @return\n" +
+ " */\n" +
+ "public void register(int protocolId, int connectedUserIdHandlerFromServer) {\n" +
+ "}");
+ }
+
public void testWrappedParameterDescription() throws Exception {
// Inspired by IDEA-13072
getSettings().getRootSettings().ENABLE_JAVADOC_FORMATTING = true;
@@ -155,4 +179,177 @@
"}"
);
}
+
+ public void testExceptionAlignmentCorrect() {
+ getCurrentCodeStyleSettings().ENABLE_JAVADOC_FORMATTING = true;
+ getCurrentCodeStyleSettings().JD_ALIGN_EXCEPTION_COMMENTS = true;
+
+ String before =
+ "public class Controller {\n" +
+ "\n" +
+ " /**\n" +
+ " * @throws NoSearchServersConfiguredException If no search engine servers are configured.\n" +
+ " * @throws SearchServerUnavailableException If the search engine server is not accessible.\n" +
+ " * @throws InvalidSearchServerResponseException If the search engine server response was invalid.\n" +
+ " * @throws NotificationEncodingException If the request could not be encoded to UTF-8.\n" +
+ " * @throws NotificationUnavailableException If the notification server is not available or sent back an invalid response code.\n" +
+ " */\n" +
+ " public int superDangerousMethod() {\n" +
+ " return 68;\n" +
+ " }\n" +
+ "}";
+
+ String after =
+ "public class Controller {\n" +
+ "\n" +
+ " /**\n" +
+ " * @throws NoSearchServersConfiguredException If no search engine servers are configured.\n" +
+ " * @throws SearchServerUnavailableException If the search engine server is not accessible.\n" +
+ " * @throws InvalidSearchServerResponseException If the search engine server response was invalid.\n" +
+ " * @throws NotificationEncodingException If the request could not be encoded to UTF-8.\n" +
+ " * @throws NotificationUnavailableException If the notification server is not available or sent back an invalid response code.\n" +
+ " */\n" +
+ " public int superDangerousMethod() {\n" +
+ " return 68;\n" +
+ " }\n" +
+ "}";
+
+ doTextTest(before, after);
+ }
+
+ public void testReturnTagAlignment() throws Exception {
+ getSettings().getRootSettings().ENABLE_JAVADOC_FORMATTING = true;
+ getSettings().getRootSettings().RIGHT_MARGIN = 80;
+ getSettings().getRootSettings().JD_LEADING_ASTERISKS_ARE_ENABLED = true;
+ getSettings().getRootSettings().WRAP_COMMENTS = true;
+ getSettings().getRootSettings().getCommonSettings(JavaLanguage.INSTANCE).WRAP_LONG_LINES = true;
+
+ String before = " /**\n" +
+ " * @return this is a return value documentation with a very long description that is longer than the right margin. It is more than 200 characters long, not including the comment indent and the asterisk characters, which should be greater than any sane right margin.\n" +
+ " */\n" +
+ " public int method(int parameter) {\n" +
+ " return 0;\n" +
+ " }\n";
+
+ String after = "/**\n" +
+ " * @return this is a return value documentation with a very long description\n" +
+ " * that is longer than the right margin. It is more than 200 characters\n" +
+ " * long, not including the comment indent and the asterisk characters, which\n" +
+ " * should be greater than any sane right margin.\n" +
+ " */\n" +
+ "public int method(int parameter) {\n" +
+ " return 0;\n" +
+ "}\n";
+
+ doClassTest(before, after);
+ }
+
+
+ public void testReturnTagAlignmentWithPreTagOnFirstLine() throws Exception {
+ getSettings().getRootSettings().ENABLE_JAVADOC_FORMATTING = true;
+ getSettings().getRootSettings().RIGHT_MARGIN = 80;
+ getSettings().getRootSettings().JD_LEADING_ASTERISKS_ARE_ENABLED = true;
+ getSettings().getRootSettings().WRAP_COMMENTS = true;
+ getSettings().getRootSettings().getCommonSettings(JavaLanguage.INSTANCE).WRAP_LONG_LINES = true;
+
+ String before = " /**\n" +
+ " * @return <pre>this is a return value documentation with a very long description\n" +
+ " * that is longer than the right margin.</pre>\n" +
+ " */\n" +
+ " public int method(int parameter) {\n" +
+ " return 0;\n" +
+ " }";
+
+ String after = "/**\n" +
+ " * @return <pre>this is a return value documentation with a very long\n" +
+ " * description\n" +
+ " * that is longer than the right margin.</pre>\n" +
+ " */\n" +
+ "public int method(int parameter) {\n" +
+ " return 0;\n" +
+ "}";
+
+ doClassTest(before, after);
+ }
+
+ public void testSeeTagAlignment() throws Exception {
+ getSettings().getRootSettings().ENABLE_JAVADOC_FORMATTING = true;
+ getSettings().getRootSettings().RIGHT_MARGIN = 80;
+ getSettings().getRootSettings().JD_LEADING_ASTERISKS_ARE_ENABLED = true;
+ getSettings().getRootSettings().WRAP_COMMENTS = true;
+ getSettings().getRootSettings().getCommonSettings(JavaLanguage.INSTANCE).WRAP_LONG_LINES = true;
+
+ String before = " /**\n" +
+ " * @see this is an additional documentation with a very long description that is longer than the right margin. It is more than 200 characters long, not including the comment indent and the asterisk characters which should be greater than any sane right margin\n" +
+ " */\n" +
+ " public int method(int parameter) {\n" +
+ " return 0;\n" +
+ " }";
+
+ String after = "/**\n" +
+ " * @see this is an additional documentation with a very long description\n" +
+ " * that is longer than the right margin. It is more than 200 characters\n" +
+ " * long, not including the comment indent and the asterisk characters which\n" +
+ " * should be greater than any sane right margin\n" +
+ " */\n" +
+ "public int method(int parameter) {\n" +
+ " return 0;\n" +
+ "}";
+
+ doClassTest(before, after);
+ }
+
+ public void testDummySinceTagAlignment() throws Exception {
+ getSettings().getRootSettings().ENABLE_JAVADOC_FORMATTING = true;
+ getSettings().getRootSettings().RIGHT_MARGIN = 80;
+ getSettings().getRootSettings().JD_LEADING_ASTERISKS_ARE_ENABLED = true;
+ getSettings().getRootSettings().WRAP_COMMENTS = true;
+ getSettings().getRootSettings().getCommonSettings(JavaLanguage.INSTANCE).WRAP_LONG_LINES = true;
+
+ String before = " /**\n" +
+ " * @since this is an additional documentation with a very long description that is longer than the right margin. It is more than 200 characters long, not including the comment indent and the asterisk characters which should be greater than any sane right margin\n" +
+ " */\n" +
+ " public int method(int parameter) {\n" +
+ " return 0;\n" +
+ " }";
+
+ String after = "/**\n" +
+ " * @since this is an additional documentation with a very long description\n" +
+ " * that is longer than the right margin. It is more than 200 characters\n" +
+ " * long, not including the comment indent and the asterisk characters which\n" +
+ " * should be greater than any sane right margin\n" +
+ " */\n" +
+ "public int method(int parameter) {\n" +
+ " return 0;\n" +
+ "}";
+
+ doClassTest(before, after);
+ }
+
+ public void testDummyDeprecatedTagAlignment() throws Exception {
+ getSettings().getRootSettings().ENABLE_JAVADOC_FORMATTING = true;
+ getSettings().getRootSettings().RIGHT_MARGIN = 80;
+ getSettings().getRootSettings().JD_LEADING_ASTERISKS_ARE_ENABLED = true;
+ getSettings().getRootSettings().WRAP_COMMENTS = true;
+ getSettings().getRootSettings().getCommonSettings(JavaLanguage.INSTANCE).WRAP_LONG_LINES = true;
+
+ String before = " /**\n" +
+ " * @deprecated this is an additional documentation with a very long description that is longer than the right margin. It is more than 200 characters long, not including the comment indent and the asterisk characters which should be greater than any sane right margin\n" +
+ " */\n" +
+ " public int method(int parameter) {\n" +
+ " return 0;\n" +
+ " }";
+
+ String after = "/**\n" +
+ " * @deprecated this is an additional documentation with a very long\n" +
+ " * description that is longer than the right margin. It is more than 200\n" +
+ " * characters long, not including the comment indent and the asterisk\n" +
+ " * characters which should be greater than any sane right margin\n" +
+ " */\n" +
+ "public int method(int parameter) {\n" +
+ " return 0;\n" +
+ "}";
+
+ doClassTest(before, after);
+ }
}
diff --git a/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodTest.java b/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodTest.java
index 3639cbd..88537b7 100644
--- a/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodTest.java
+++ b/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodTest.java
@@ -583,6 +583,10 @@
doDuplicatesTest();
}
+ public void testOverloadedMethods() throws Exception {
+ doDuplicatesTest();
+ }
+
public void testTargetAnonymous() throws Exception {
doTest();
}
diff --git a/java/java-tests/testSrc/com/intellij/refactoring/ExtractSuperClassTest.java b/java/java-tests/testSrc/com/intellij/refactoring/ExtractSuperClassTest.java
index 4775463..732ead7 100644
--- a/java/java-tests/testSrc/com/intellij/refactoring/ExtractSuperClassTest.java
+++ b/java/java-tests/testSrc/com/intellij/refactoring/ExtractSuperClassTest.java
@@ -56,6 +56,11 @@
doTest("Test", "TestSubclass", new RefactoringTestUtil.MemberDescriptor("m", PsiMethod.class));
}
+
+ public void testEmptyForeach() throws Exception {
+ doTest("Test", "TestSubclass", new RefactoringTestUtil.MemberDescriptor("m", PsiMethod.class));
+ }
+
public void testConflictUsingPrivateMethod() throws Exception {
doTest("Test", "TestSubclass",
new String[] {"Method <b><code>Test.foo()</code></b> is private and will not be accessible from method <b><code>x()</code></b>."},
diff --git a/java/java-tests/testSrc/com/intellij/refactoring/MoveMembersTest.java b/java/java-tests/testSrc/com/intellij/refactoring/MoveMembersTest.java
index 596944b..ca97d36 100644
--- a/java/java-tests/testSrc/com/intellij/refactoring/MoveMembersTest.java
+++ b/java/java-tests/testSrc/com/intellij/refactoring/MoveMembersTest.java
@@ -107,6 +107,10 @@
doTest("B", "A", 0);
}
+ public void testStringConstantFromCaseStatement() throws Exception {
+ doTest("B", "A", 0);
+ }
+
public void testDependantFields() throws Exception {
doTest("B", "A", 0);
}
diff --git a/java/java-tests/testSrc/com/intellij/refactoring/SafeDeleteTest.java b/java/java-tests/testSrc/com/intellij/refactoring/SafeDeleteTest.java
index 0cf3fc3..83dbbef 100644
--- a/java/java-tests/testSrc/com/intellij/refactoring/SafeDeleteTest.java
+++ b/java/java-tests/testSrc/com/intellij/refactoring/SafeDeleteTest.java
@@ -149,6 +149,11 @@
doSingleFileTest();
}
+ public void testLastResourceVariableWithFinallyBlock() throws Exception {
+ LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_7);
+ doSingleFileTest();
+ }
+
public void testLastTypeParam() throws Exception {
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_7);
doSingleFileTest();
diff --git a/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineLocalTest.java b/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineLocalTest.java
index 709db99..6d66a43 100644
--- a/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineLocalTest.java
+++ b/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineLocalTest.java
@@ -140,6 +140,10 @@
"Variable 'arr' is accessed for writing.");
}
+ public void testArrayMethodCallInitialized() throws Exception {
+ doTest(true);
+ }
+
public void testArrayIndex() throws Exception {
doTest(true);
}
@@ -205,6 +209,10 @@
doTest(true);
}
+ public void testResourceVariable() throws Exception {
+ doTest(false);
+ }
+
public void testEnclosingThisExpression() throws Exception {
doTest(true);
}
diff --git a/java/openapi/src/com/intellij/psi/search/scope/packageSet/PatternPackageSet.java b/java/openapi/src/com/intellij/psi/search/scope/packageSet/PatternPackageSet.java
index ebefeef..7950e60 100644
--- a/java/openapi/src/com/intellij/psi/search/scope/packageSet/PatternPackageSet.java
+++ b/java/openapi/src/com/intellij/psi/search/scope/packageSet/PatternPackageSet.java
@@ -79,7 +79,7 @@
@Override
public boolean contains(VirtualFile file, @NotNull Project project, @Nullable NamedScopesHolder holder) {
ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
- return matchesScope(file, holder.getProject(), fileIndex) && (myPattern == null || myPattern.matcher(getPackageName(file, fileIndex)).matches());
+ return matchesScope(file, project, fileIndex) && (myPattern == null || myPattern.matcher(getPackageName(file, fileIndex)).matches());
}
private boolean matchesScope(VirtualFile file, Project project, ProjectFileIndex fileIndex) {
diff --git a/java/openapi/src/com/intellij/psi/util/PsiConcatenationUtil.java b/java/openapi/src/com/intellij/psi/util/PsiConcatenationUtil.java
index 9b60456..08e3443 100644
--- a/java/openapi/src/com/intellij/psi/util/PsiConcatenationUtil.java
+++ b/java/openapi/src/com/intellij/psi/util/PsiConcatenationUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -26,65 +26,61 @@
* User: cdr
*/
public class PsiConcatenationUtil {
- public static void buildFormatString(
- PsiExpression expression, StringBuilder formatString,
- List<PsiExpression> formatParameters, boolean printfFormat) {
- if (expression instanceof PsiLiteralExpression) {
- final PsiLiteralExpression literalExpression =
- (PsiLiteralExpression) expression;
- final String text = String.valueOf(literalExpression.getValue());
- final String formatText;
- if (printfFormat) {
- formatText = StringUtil.escapeStringCharacters(text)
- .replace("%", "%%").replace("\\'", "'");
+
+ public static void buildFormatString(PsiExpression expression, StringBuilder formatString,
+ List<PsiExpression> formatParameters, boolean printfFormat) {
+ if (expression instanceof PsiLiteralExpression) {
+ final PsiLiteralExpression literalExpression = (PsiLiteralExpression) expression;
+ final String text = String.valueOf(literalExpression.getValue());
+ final String formatText;
+ if (printfFormat) {
+ formatText = StringUtil.escapeStringCharacters(text).replace("%", "%%").replace("\\'", "'");
+ }
+ else {
+ formatText = StringUtil.escapeStringCharacters(text).replace("'", "''").replaceAll("((\\{|})+)", "'$1'");
+ }
+ formatString.append(formatText);
+ } else if (expression instanceof PsiPolyadicExpression) {
+ final PsiType type = expression.getType();
+ if (type != null && type.equalsToText("java.lang.String")) {
+ final PsiPolyadicExpression binaryExpression = (PsiPolyadicExpression) expression;
+ PsiExpression[] operands = binaryExpression.getOperands();
+ PsiType left = operands[0].getType();
+ boolean stringStarted = left != null && left.equalsToText("java.lang.String");
+ if (stringStarted) {
+ buildFormatString(operands[0], formatString, formatParameters, printfFormat);
}
- else {
- formatText = StringUtil.escapeStringCharacters(text)
- .replace("'", "''").replace("{", "'{").replace("}", "'}");
- }
- formatString.append(formatText);
- } else if (expression instanceof PsiPolyadicExpression) {
- final PsiType type = expression.getType();
- if (type != null && type.equalsToText("java.lang.String")) {
- final PsiPolyadicExpression binaryExpression =
- (PsiPolyadicExpression) expression;
- PsiExpression[] operands = binaryExpression.getOperands();
- PsiType left = operands[0].getType();
- boolean stringStarted = left != null && left.equalsToText("java.lang.String");
- if (stringStarted) {
- buildFormatString(operands[0], formatString, formatParameters, printfFormat);
+ for (int i = 1; i < operands.length; i++) {
+ PsiExpression op = operands[i];
+ PsiType optype = op.getType();
+ PsiType r = TypeConversionUtil.calcTypeForBinaryExpression(left, optype, binaryExpression.getOperationTokenType(), true);
+ if (r != null && r.equalsToText("java.lang.String") && !stringStarted) {
+ stringStarted = true;
+ PsiElement element = binaryExpression.getTokenBeforeOperand(op);
+ if (element.getPrevSibling() instanceof PsiWhiteSpace) element = element.getPrevSibling();
+ String text = binaryExpression.getText().substring(0, element.getStartOffsetInParent());
+ PsiExpression subExpression = JavaPsiFacade.getInstance(binaryExpression.getProject()).getElementFactory()
+ .createExpressionFromText(text, binaryExpression);
+ addFormatParameter(subExpression, formatString, formatParameters, printfFormat);
+ }
+ if (stringStarted) {
+ if (optype != null && (optype.equalsToText("java.lang.String") || optype == PsiType.CHAR)) {
+ buildFormatString(op, formatString, formatParameters, printfFormat);
}
- for (int i = 1; i < operands.length; i++) {
- PsiExpression op = operands[i];
- PsiType optype = op.getType();
- PsiType r = TypeConversionUtil.calcTypeForBinaryExpression(left, optype, binaryExpression.getOperationTokenType(), true);
- if (r != null && r.equalsToText("java.lang.String") && !stringStarted) {
- stringStarted = true;
- PsiElement element = binaryExpression.getTokenBeforeOperand(op);
- if (element.getPrevSibling() instanceof PsiWhiteSpace) element = element.getPrevSibling();
- String text = binaryExpression.getText().substring(0, element.getStartOffsetInParent());
- PsiExpression subExpression = JavaPsiFacade.getInstance(binaryExpression.getProject()).getElementFactory()
- .createExpressionFromText(text, binaryExpression);
- addFormatParameter(subExpression, formatString, formatParameters, printfFormat);
- }
- if (stringStarted) {
- if (optype != null && (optype.equalsToText("java.lang.String") || optype == PsiType.CHAR)) {
- buildFormatString(op, formatString, formatParameters, printfFormat);
- }
- else {
- addFormatParameter(op, formatString, formatParameters, printfFormat);
- }
- }
- left = r;
+ else {
+ addFormatParameter(op, formatString, formatParameters, printfFormat);
}
}
- else {
- addFormatParameter(expression, formatString, formatParameters, printfFormat);
- }
+ left = r;
+ }
}
else {
addFormatParameter(expression, formatString, formatParameters, printfFormat);
}
+ }
+ else {
+ addFormatParameter(expression, formatString, formatParameters, printfFormat);
+ }
}
private static void addFormatParameter(PsiExpression expression,
@@ -92,13 +88,13 @@
List<PsiExpression> formatParameters, boolean printfFormat) {
final PsiType type = expression.getType();
if (!printfFormat) {
- formatString.append("{" + formatParameters.size() + "}");
+ formatString.append("{").append(formatParameters.size()).append("}");
}
else if (type != null &&
- (type.equalsToText("long") ||
- type.equalsToText("int") ||
- type.equalsToText("java.lang.Long") ||
- type.equalsToText("java.lang.Integer"))) {
+ (type.equalsToText("long") ||
+ type.equalsToText("int") ||
+ type.equalsToText("java.lang.Long") ||
+ type.equalsToText("java.lang.Integer"))) {
formatString.append("%d");
}
else {
diff --git a/java/testFramework/src/com/intellij/codeInsight/daemon/DaemonAnalyzerTestCase.java b/java/testFramework/src/com/intellij/codeInsight/daemon/DaemonAnalyzerTestCase.java
index 6d40070..ccaa2cb 100644
--- a/java/testFramework/src/com/intellij/codeInsight/daemon/DaemonAnalyzerTestCase.java
+++ b/java/testFramework/src/com/intellij/codeInsight/daemon/DaemonAnalyzerTestCase.java
@@ -119,16 +119,17 @@
@Override
@NotNull
- public InspectionTool[] getInspectionTools(PsiElement element) {
+ public InspectionToolWrapper[] getInspectionTools(PsiElement element) {
Collection<InspectionToolWrapper> values = myAvailableTools.values();
- return values.toArray(new InspectionTool[values.size()]);
+ return values.toArray(new InspectionToolWrapper[values.size()]);
}
+ @NotNull
@Override
- public List<ToolsImpl> getAllEnabledInspectionTools(Project project) {
- List<ToolsImpl> result = new ArrayList<ToolsImpl>();
- for (InspectionProfileEntry entry : getInspectionTools(null)) {
- result.add(new ToolsImpl(entry, entry.getDefaultLevel(), true));
+ public List<Tools> getAllEnabledInspectionTools(Project project) {
+ List<Tools> result = new ArrayList<Tools>();
+ for (InspectionToolWrapper toolWrapper : getInspectionTools(null)) {
+ result.add(new ToolsImpl(toolWrapper, toolWrapper.getDefaultLevel(), true));
}
return result;
}
@@ -140,12 +141,12 @@
@Override
public HighlightDisplayLevel getErrorLevel(@NotNull HighlightDisplayKey key, PsiElement element) {
- final InspectionProfileEntry localInspectionTool = myAvailableTools.get(key.toString());
+ final InspectionToolWrapper localInspectionTool = myAvailableTools.get(key.toString());
return localInspectionTool != null ? localInspectionTool.getDefaultLevel() : HighlightDisplayLevel.WARNING;
}
@Override
- public InspectionTool getInspectionTool(@NotNull String shortName, @NotNull PsiElement element) {
+ public InspectionToolWrapper getInspectionTool(@NotNull String shortName, @NotNull PsiElement element) {
return myAvailableTools.get(shortName);
}
};
@@ -192,14 +193,9 @@
//((VirtualFilePointerManagerImpl)VirtualFilePointerManager.getInstance()).assertPointersDisposed();
}
- protected void enableInspectionTool(InspectionProfileEntry tool){
- InspectionToolWrapper wrapper = InspectionToolRegistrar.wrapTool(tool);
- final String shortName = wrapper.getShortName();
- final HighlightDisplayKey key = HighlightDisplayKey.find(shortName);
- if (key == null) {
- HighlightDisplayKey.register(shortName, wrapper.getDisplayName(), ((LocalInspectionToolWrapper)wrapper).getID());
- }
- myAvailableTools.put(shortName, wrapper);
+ protected void enableInspectionTool(@NotNull InspectionProfileEntry tool) {
+ InspectionToolWrapper toolWrapper = InspectionToolRegistrar.wrapTool(tool);
+ LightPlatformTestCase.enableInspectionTool(myAvailableTools, toolWrapper);
}
protected void enableInspectionToolsFromProvider(InspectionToolProvider toolProvider){
diff --git a/java/testFramework/src/com/intellij/debugger/DebuggerTestCase.java b/java/testFramework/src/com/intellij/debugger/DebuggerTestCase.java
new file mode 100644
index 0000000..e1f9857
--- /dev/null
+++ b/java/testFramework/src/com/intellij/debugger/DebuggerTestCase.java
@@ -0,0 +1,531 @@
+/*
+ * Copyright 2000-2013 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.debugger;
+
+import com.intellij.debugger.engine.DebugProcessImpl;
+import com.intellij.debugger.engine.RemoteStateState;
+import com.intellij.debugger.engine.SuspendContextImpl;
+import com.intellij.debugger.engine.evaluation.EvaluateException;
+import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
+import com.intellij.debugger.engine.events.DebuggerCommandImpl;
+import com.intellij.debugger.impl.*;
+import com.intellij.debugger.jdi.StackFrameProxyImpl;
+import com.intellij.debugger.settings.DebuggerSettings;
+import com.intellij.debugger.settings.NodeRendererSettings;
+import com.intellij.debugger.ui.breakpoints.BreakpointManager;
+import com.intellij.execution.ExecutionException;
+import com.intellij.execution.ExecutionResult;
+import com.intellij.execution.Executor;
+import com.intellij.execution.configurations.*;
+import com.intellij.execution.executors.DefaultDebugExecutor;
+import com.intellij.execution.process.ProcessAdapter;
+import com.intellij.execution.process.ProcessEvent;
+import com.intellij.execution.process.ProcessOutputTypes;
+import com.intellij.execution.runners.ExecutionEnvironment;
+import com.intellij.execution.runners.ProgramRunner;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ModalityState;
+import com.intellij.openapi.editor.Document;
+import com.intellij.openapi.module.Module;
+import com.intellij.openapi.options.SettingsEditor;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.*;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.psi.JavaPsiFacade;
+import com.intellij.psi.PsiClass;
+import com.intellij.psi.PsiDocumentManager;
+import com.intellij.psi.search.GlobalSearchScope;
+import com.intellij.util.ui.UIUtil;
+import org.jdom.Element;
+import org.jetbrains.annotations.NotNull;
+
+import javax.swing.*;
+import java.lang.reflect.InvocationTargetException;
+import java.util.StringTokenizer;
+
+public abstract class DebuggerTestCase extends ExecutionWithDebuggerToolsTestCase {
+ protected DebuggerSession myDebuggerSession;
+ private StringBuffer myConsoleBuffer;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @Override
+ protected void initApplication() throws Exception {
+ super.initApplication();
+ setTestJDK();
+ DebuggerSettings.getInstance().DEBUGGER_TRANSPORT = DebuggerSettings.SOCKET_TRANSPORT;
+ DebuggerSettings.getInstance().SKIP_CONSTRUCTORS = false;
+ DebuggerSettings.getInstance().SKIP_GETTERS = false;
+ NodeRendererSettings.getInstance().getClassRenderer().SHOW_DECLARED_TYPE = true;
+ }
+
+ @Override
+ protected void runTest() throws Throwable {
+ super.runTest();
+ if(getDebugProcess() != null) {
+ getDebugProcess().getExecutionResult().getProcessHandler().startNotify();
+ waitProcess(getDebugProcess().getExecutionResult().getProcessHandler());
+ waitForCompleted();
+ disposeSession(myDebuggerSession);
+ assertNull(DebuggerManagerEx.getInstanceEx(myProject).getDebugProcess(getDebugProcess().getExecutionResult().getProcessHandler()));
+ myDebuggerSession = null;
+ }
+ if(myConsoleBuffer != null) {
+ //println("", b);
+ //println("Console output:", b);
+ //println(myConsoleBuffer.toString(), b);
+ }
+ checkTestOutput();
+ }
+
+ protected void checkTestOutput() throws Exception {
+ getChecker().checkValid(getTestProjectJdk());
+ }
+
+ protected void disposeSession(final DebuggerSession debuggerSession) throws InterruptedException, InvocationTargetException {
+ UIUtil.invokeAndWaitIfNeeded(new Runnable() {
+ @Override
+ public void run() {
+ debuggerSession.dispose();
+ }
+ });
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ myConsoleBuffer = null;
+ }
+
+ protected void createLocalProcess(String className) throws ExecutionException, InterruptedException, InvocationTargetException {
+ LOG.assertTrue(myDebugProcess == null);
+ myDebuggerSession = createLocalProcess(DebuggerSettings.SOCKET_TRANSPORT, createJavaParameters(className));
+ myDebugProcess = myDebuggerSession.getProcess();
+ }
+
+ protected DebuggerSession createLocalSession(final JavaParameters javaParameters, final String sessionName) throws ExecutionException, InterruptedException {
+ createBreakpoints(javaParameters.getMainClass());
+ DebuggerSettings.getInstance().DEBUGGER_TRANSPORT = DebuggerSettings.SOCKET_TRANSPORT;
+
+ GenericDebuggerRunnerSettings debuggerRunnerSettings = new GenericDebuggerRunnerSettings();
+ debuggerRunnerSettings.LOCAL = true;
+
+ final RemoteConnection debugParameters = DebuggerManagerImpl.createDebugParameters(javaParameters, debuggerRunnerSettings, false);
+
+ RunnerSettings<JDOMExternalizable> runnerSettings = new RunnerSettings<JDOMExternalizable>(debuggerRunnerSettings, null);
+
+ final JavaCommandLineState javaCommandLineState = new JavaCommandLineState(new ExecutionEnvironment(new MockConfiguration(), myProject,
+ runnerSettings, null, null)){
+ @Override
+ protected JavaParameters createJavaParameters() {
+ return javaParameters;
+ }
+
+ @Override
+ protected GeneralCommandLine createCommandLine() throws ExecutionException {
+ return CommandLineBuilder.createFromJavaParameters(getJavaParameters());
+ }
+ };
+
+ final GenericDebuggerRunner runner = new GenericDebuggerRunner();
+
+ ApplicationManager.getApplication().invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ myDebuggerSession = DebuggerManagerEx.getInstanceEx(myProject).attachVirtualMachine(new DefaultDebugExecutor(),
+ runner, new MockConfiguration(), javaCommandLineState, debugParameters, false);
+ }
+ catch (ExecutionException e) {
+ LOG.error(e);
+ }
+ }
+ }, ModalityState.defaultModalityState());
+ myDebugProcess = myDebuggerSession.getProcess();
+
+ //myConsoleBuffer = new StringBuffer();
+
+ myDebugProcess.addProcessListener(new ProcessAdapter() {
+ @Override
+ public void onTextAvailable(ProcessEvent event, Key outputType) {
+ //myConsoleBuffer.append(event.getText());
+ print(event.getText(), outputType);
+ }
+ });
+
+ assertNotNull(myDebuggerSession);
+ assertNotNull(myDebugProcess);
+
+ return myDebuggerSession;
+ }
+
+
+ protected DebuggerSession createLocalProcess(int transport, final JavaParameters javaParameters) throws ExecutionException, InterruptedException, InvocationTargetException {
+ createBreakpoints(javaParameters.getMainClass());
+ final DebuggerSession[] debuggerSession = new DebuggerSession[]{null};
+
+ DebuggerSettings.getInstance().DEBUGGER_TRANSPORT = transport;
+
+ GenericDebuggerRunnerSettings debuggerRunnerSettings = new GenericDebuggerRunnerSettings();
+ debuggerRunnerSettings.LOCAL = true;
+ debuggerRunnerSettings.DEBUG_PORT = "3456";
+
+ RunnerSettings<JDOMExternalizable> runnerSettings = new RunnerSettings<JDOMExternalizable>(debuggerRunnerSettings, null);
+
+ final JavaCommandLineState javaCommandLineState = new JavaCommandLineState(new ExecutionEnvironment(new MockConfiguration(), myProject,
+ runnerSettings, null, null)) {
+ @Override
+ protected JavaParameters createJavaParameters() {
+ return javaParameters;
+ }
+
+ @Override
+ protected GeneralCommandLine createCommandLine() throws ExecutionException {
+ return CommandLineBuilder.createFromJavaParameters(getJavaParameters());
+ }
+ };
+
+ final RemoteConnection debugParameters =
+ DebuggerManagerImpl.createDebugParameters(javaCommandLineState.getJavaParameters(), debuggerRunnerSettings, true);
+
+ UIUtil.invokeAndWaitIfNeeded(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ debuggerSession[0] = attachVirtualMachine(javaCommandLineState, debugParameters, false);
+ }
+ catch (ExecutionException e) {
+ fail(e.getMessage());
+ }
+ }
+ });
+
+ final ExecutionResult executionResult = debuggerSession[0].getProcess().getExecutionResult();
+ debuggerSession[0].getProcess().addProcessListener(new ProcessAdapter() {
+ @Override
+ public void onTextAvailable(ProcessEvent event, Key outputType) {
+ print(event.getText(), outputType);
+ }
+ });
+
+ DebugProcessImpl process =
+ (DebugProcessImpl)DebuggerManagerEx.getInstanceEx(myProject).getDebugProcess(executionResult.getProcessHandler());
+ assertNotNull(process);
+ return debuggerSession[0];
+ }
+
+
+ protected DebuggerSession createRemoteProcess(final int transport, final boolean serverMode, JavaParameters javaParameters)
+ throws ExecutionException, InterruptedException, InvocationTargetException {
+ boolean useSockets = transport == DebuggerSettings.SOCKET_TRANSPORT;
+
+ RemoteConnection remoteConnection = new RemoteConnection(
+ useSockets,
+ "127.0.0.1",
+ "3456",
+ serverMode);
+
+ String launchCommandLine = remoteConnection.getLaunchCommandLine();
+
+ launchCommandLine = StringUtil.replace(launchCommandLine, RemoteConnection.ONTHROW, "");
+ launchCommandLine = StringUtil.replace(launchCommandLine, RemoteConnection.ONUNCAUGHT, "");
+
+ launchCommandLine = StringUtil.replace(launchCommandLine, "suspend=n", "suspend=y");
+
+ println(launchCommandLine, ProcessOutputTypes.SYSTEM);
+
+ JavaParameters parameters = javaParameters;
+
+ for(StringTokenizer tokenizer = new StringTokenizer(launchCommandLine);tokenizer.hasMoreTokens();) {
+ String token = tokenizer.nextToken();
+ parameters.getVMParametersList().add(token);
+ }
+
+ GeneralCommandLine commandLine = CommandLineBuilder.createFromJavaParameters(parameters);
+
+
+ DebuggerSession debuggerSession;
+
+ if(serverMode) {
+ debuggerSession = attachVM(remoteConnection, false);
+ commandLine.createProcess();
+ } else {
+ commandLine.createProcess();
+ debuggerSession = attachVM(remoteConnection, true);
+ }
+
+ ExecutionResult executionResult = debuggerSession.getProcess().getExecutionResult();
+ DebugProcessImpl process = (DebugProcessImpl)DebuggerManagerEx.getInstanceEx(myProject)
+ .getDebugProcess(executionResult.getProcessHandler());
+
+ assertNotNull(process);
+ return debuggerSession;
+ }
+
+ protected DebuggerSession attachVM(final RemoteConnection remoteConnection, final boolean pollConnection)
+ throws InvocationTargetException, InterruptedException {
+ final RunnerSettings<JDOMExternalizable> runnerSettings = new RunnerSettings<JDOMExternalizable>(null, null);
+ final RemoteState remoteState = new RemoteStateState(myProject, remoteConnection, runnerSettings, null);
+
+ final DebuggerSession[] debuggerSession = new DebuggerSession[1];
+ UIUtil.invokeAndWaitIfNeeded(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ debuggerSession[0] = attachVirtualMachine(remoteState, remoteConnection, pollConnection);
+ }
+ catch (ExecutionException e) {
+ fail(e.getMessage());
+ }
+ }
+ });
+ debuggerSession[0].getProcess().getExecutionResult().getProcessHandler().addProcessListener(new ProcessAdapter() {
+ @Override
+ public void onTextAvailable(ProcessEvent event, Key outputType) {
+ print(event.getText(), outputType);
+ }
+ });
+ return debuggerSession[0];
+ }
+
+ protected void createBreakpoints(final String className) {
+ final PsiClass psiClass = ApplicationManager.getApplication().runReadAction(new Computable<PsiClass>() {
+ @Override
+ public PsiClass compute() {
+ return JavaPsiFacade.getInstance(myProject).findClass(className, GlobalSearchScope.allScope(myProject));
+ }
+ });
+
+ createBreakpoints(psiClass.getContainingFile());
+
+ }
+
+ protected EvaluationContextImpl createEvaluationContext(final SuspendContextImpl suspendContext) {
+ try {
+ return new EvaluationContextImpl(
+ suspendContext,
+ suspendContext.getFrameProxy(),
+ suspendContext.getFrameProxy().thisObject());
+ }
+ catch (EvaluateException e) {
+ error(e);
+ return null;
+ }
+ }
+
+ protected void waitForCompleted() {
+ final SynchronizationBasedSemaphore s = new SynchronizationBasedSemaphore();
+ s.down();
+
+ final InvokeThread.WorkerThreadRequest request = getDebugProcess().getManagerThread().getCurrentRequest();
+ final Thread thread = new Thread("Joining "+request) {
+ @Override
+ public void run() {
+ try {
+ request.join();
+ }
+ catch (Exception e) {
+ }
+ }
+ };
+ thread.start();
+ if(request.isDone()) {
+ thread.interrupt();
+ }
+ waitFor(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ thread.join();
+ }
+ catch (InterruptedException e) {
+ }
+ }
+ });
+
+ invokeRatherLater(new DebuggerCommandImpl() {
+ @Override
+ protected void action() throws Exception {
+ LOG.assertTrue(false);
+ }
+
+ @Override
+ protected void commandCancelled() {
+ //We wait for invokeRatherLater's
+ invokeRatherLater(new DebuggerCommandImpl() {
+ @Override
+ protected void action() throws Exception {
+ LOG.assertTrue(false);
+ }
+
+ @Override
+ protected void commandCancelled() {
+ s.up();
+ }
+ });
+ }
+ });
+
+ waitFor(new Runnable() {
+ @Override
+ public void run() {
+ s.waitFor();
+ }
+ });
+ }
+
+ public DebuggerContextImpl createDebuggerContext(final SuspendContextImpl suspendContext, StackFrameProxyImpl stackFrame) {
+ final DebuggerSession[] session = new DebuggerSession[1];
+
+ UIUtil.invokeAndWaitIfNeeded(new Runnable() {
+ @Override
+ public void run() {
+ session[0] = DebuggerManagerEx.getInstanceEx(myProject).getSession(suspendContext.getDebugProcess());
+ }
+ });
+
+ DebuggerContextImpl debuggerContext = DebuggerContextImpl.createDebuggerContext(
+ session[0],
+ suspendContext,
+ stackFrame != null ? stackFrame.threadProxy() : null,
+ stackFrame);
+ debuggerContext.initCaches();
+ return debuggerContext;
+ }
+
+ public DebuggerContextImpl createDebuggerContext(final SuspendContextImpl suspendContext) {
+ return createDebuggerContext(suspendContext, suspendContext.getFrameProxy());
+ }
+
+ protected void createBreakpointInHelloWorld() {
+ DebuggerInvocationUtil.invokeAndWait(myProject, new Runnable() {
+ @Override
+ public void run() {
+ BreakpointManager breakpointManager = DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager();
+ PsiClass psiClass = JavaPsiFacade.getInstance(myProject).findClass("HelloWorld", GlobalSearchScope.allScope(myProject));
+ Document document = PsiDocumentManager.getInstance(myProject).getDocument(psiClass.getContainingFile());
+ breakpointManager.addLineBreakpoint(document, 3);
+ }
+ }, ApplicationManager.getApplication().getDefaultModalityState());
+ }
+
+ protected void createHelloWorldProcessWithBreakpoint() throws ExecutionException, InterruptedException, InvocationTargetException {
+ createLocalProcess("HelloWorld");
+
+ createBreakpointInHelloWorld();
+ }
+
+ @Override
+ protected DebugProcessImpl getDebugProcess() {
+ return myDebuggerSession != null ? myDebuggerSession.getProcess() : null;
+ }
+
+ public DebuggerSession getDebuggerSession() {
+ return myDebuggerSession;
+ }
+
+ protected DebuggerSession attachVirtualMachine(RunProfileState state, RemoteConnection remoteConnection, boolean pollConnection) throws ExecutionException {
+ return DebuggerManagerEx.getInstanceEx(myProject).attachVirtualMachine(new DefaultDebugExecutor(), new GenericDebuggerRunner(), new MockConfiguration(), state, remoteConnection, pollConnection);
+ }
+
+ private static class MockConfiguration implements ModuleRunConfiguration {
+ @Override
+ @NotNull
+ public Module[] getModules() {
+ return Module.EMPTY_ARRAY; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public Icon getIcon() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public ConfigurationFactory getFactory() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void setName(final String name) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public SettingsEditor<? extends RunConfiguration> getConfigurationEditor() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public Project getProject() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ @NotNull
+ public ConfigurationType getType() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public JDOMExternalizable createRunnerSettings(final ConfigurationInfoProvider provider) {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public SettingsEditor<JDOMExternalizable> getRunnerSettingsEditor(final ProgramRunner runner) {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public RunConfiguration clone() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public int getUniqueID() {
+ return 0;
+ }
+
+ @Override
+ public RunProfileState getState(@NotNull final Executor executor, @NotNull final ExecutionEnvironment env) throws ExecutionException {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public String getName() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void checkConfiguration() throws RuntimeConfigurationException {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void readExternal(final Element element) throws InvalidDataException {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void writeExternal(final Element element) throws WriteExternalException {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+ }
+
+}
diff --git a/java/testFramework/src/com/intellij/debugger/ExecutionWithDebuggerToolsTestCase.java b/java/testFramework/src/com/intellij/debugger/ExecutionWithDebuggerToolsTestCase.java
new file mode 100644
index 0000000..bccbfe5
--- /dev/null
+++ b/java/testFramework/src/com/intellij/debugger/ExecutionWithDebuggerToolsTestCase.java
@@ -0,0 +1,428 @@
+/*
+ * Copyright 2000-2013 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.debugger;
+
+import com.intellij.debugger.engine.*;
+import com.intellij.debugger.engine.evaluation.CodeFragmentKind;
+import com.intellij.debugger.engine.evaluation.EvaluateException;
+import com.intellij.debugger.engine.evaluation.TextWithImportsImpl;
+import com.intellij.debugger.engine.events.DebuggerCommandImpl;
+import com.intellij.debugger.engine.events.SuspendContextCommandImpl;
+import com.intellij.debugger.impl.DebuggerManagerImpl;
+import com.intellij.debugger.impl.PositionUtil;
+import com.intellij.debugger.impl.PrioritizedTask;
+import com.intellij.debugger.impl.SynchronizationBasedSemaphore;
+import com.intellij.debugger.jdi.StackFrameProxyImpl;
+import com.intellij.debugger.settings.DebuggerSettings;
+import com.intellij.debugger.ui.breakpoints.Breakpoint;
+import com.intellij.debugger.ui.breakpoints.BreakpointManager;
+import com.intellij.execution.ExecutionException;
+import com.intellij.execution.ExecutionTestCase;
+import com.intellij.execution.configurations.RemoteConnection;
+import com.intellij.execution.configurations.RunProfileState;
+import com.intellij.execution.process.ProcessOutputTypes;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ModalityState;
+import com.intellij.openapi.editor.Document;
+import com.intellij.openapi.projectRoots.ProjectJdkTable;
+import com.intellij.openapi.projectRoots.Sdk;
+import com.intellij.openapi.projectRoots.impl.JavaAwareProjectJdkTableImpl;
+import com.intellij.openapi.projectRoots.impl.ProjectJdkImpl;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.psi.PsiDocumentManager;
+import com.intellij.psi.PsiFile;
+import com.intellij.ui.classFilter.ClassFilter;
+import com.intellij.util.IJSwingUtilities;
+import com.intellij.util.ui.UIUtil;
+import com.sun.jdi.Method;
+import com.sun.jdi.ThreadReference;
+
+import javax.swing.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+public abstract class ExecutionWithDebuggerToolsTestCase extends ExecutionTestCase {
+ private DebugProcessListener myPauseScriptListener = null;
+ private final List<SuspendContextRunnable> myScriptRunnables = new ArrayList<SuspendContextRunnable>();
+ private final SynchronizationBasedSemaphore myScriptRunnablesSema = new SynchronizationBasedSemaphore();
+ protected static final int RATHER_LATER_INVOKES_N = 10;
+ public DebugProcessImpl myDebugProcess = null;
+
+
+ private class InvokeRatherLaterRequest {
+ private final DebuggerCommandImpl myDebuggerCommand;
+ private final DebugProcessImpl myDebugProcess;
+ int invokesN = 0;
+
+ public InvokeRatherLaterRequest(DebuggerCommandImpl debuggerCommand, DebugProcessImpl debugProcess) {
+ myDebuggerCommand = debuggerCommand;
+ myDebugProcess = debugProcess;
+ }
+ }
+
+ public List<InvokeRatherLaterRequest> myRatherLaterRequests = new ArrayList<InvokeRatherLaterRequest>();
+
+ protected DebugProcessImpl getDebugProcess() {
+ return myDebugProcess;
+ }
+
+ protected String readValue(String comment, String valueName) {
+ int valueStart = comment.indexOf(valueName);
+ if (valueStart == -1) return null;
+
+ int valueEnd = comment.indexOf(')', valueStart);
+ return comment.substring(valueStart + valueName.length() + 1, valueEnd);
+ }
+
+ protected void resume(SuspendContextImpl context) {
+ DebugProcessImpl debugProcess = context.getDebugProcess();
+ debugProcess.getManagerThread().schedule(debugProcess.createResumeCommand(context, PrioritizedTask.Priority.LOW));
+ }
+
+ protected void waitBreakpoints() {
+ myScriptRunnablesSema.down();
+ waitFor(new Runnable() {
+ @Override
+ public void run() {
+ myScriptRunnablesSema.waitFor();
+ }
+ });
+ }
+
+ protected void onBreakpoint(SuspendContextRunnable runnable) {
+ if (myPauseScriptListener == null) {
+ final DebugProcessImpl debugProcess = getDebugProcess();
+
+ assertTrue("Debug process was not started", debugProcess != null);
+
+ myPauseScriptListener = new DelayedEventsProcessListener(
+ new DebugProcessAdapterImpl() {
+ @Override
+ public void paused(SuspendContextImpl suspendContext) {
+ try {
+ if (myScriptRunnables.isEmpty()) {
+ print("resuming ", ProcessOutputTypes.SYSTEM);
+ printContext(suspendContext);
+ resume(suspendContext);
+ return;
+ }
+ SuspendContextRunnable suspendContextRunnable = myScriptRunnables.remove(0);
+ suspendContextRunnable.run(suspendContext);
+ }
+ catch (Exception e) {
+ error(e);
+ }
+
+ if (myScriptRunnables.isEmpty()) {
+ myScriptRunnablesSema.up();
+ }
+ }
+
+ //executed in manager thread
+ @Override
+ public void resumed(SuspendContextImpl suspendContext) {
+ final SuspendContextImpl pausedContext = debugProcess.getSuspendManager().getPausedContext();
+ if (pausedContext != null) {
+ debugProcess.getManagerThread().schedule(new SuspendContextCommandImpl(pausedContext) {
+ @Override
+ public void contextAction() throws Exception {
+ paused(pausedContext);
+ }
+ });
+ }
+ }
+ }
+ );
+ debugProcess.addDebugProcessListener(myPauseScriptListener);
+ }
+ myScriptRunnables.add(runnable);
+ }
+
+ protected void printFrameProxy(StackFrameProxyImpl frameProxy) throws EvaluateException {
+ int frameIndex = frameProxy.getFrameIndex();
+ Method method = frameProxy.location().method();
+
+ println("frameProxy(" + frameIndex + ") = " + method, ProcessOutputTypes.SYSTEM);
+ }
+
+ protected void printContext(final StackFrameContext context) {
+ ApplicationManager.getApplication().runReadAction(new Runnable() {
+ @Override
+ public void run() {
+ if (context.getFrameProxy() != null) {
+ SourcePosition sourcePosition = PositionUtil.getSourcePosition(context);
+ println(sourcePosition.getFile().getVirtualFile().getName() + ":" + sourcePosition.getLine(), ProcessOutputTypes.SYSTEM);
+ }
+ else {
+ println("Context thread is null", ProcessOutputTypes.SYSTEM);
+ }
+ }
+ });
+ }
+
+ protected void invokeRatherLater(SuspendContextImpl context, final Runnable runnable) {
+ invokeRatherLater(new SuspendContextCommandImpl(context) {
+ @Override
+ public void contextAction() throws Exception {
+ DebuggerInvocationUtil.invokeLater(myProject, runnable);
+ }
+ });
+ }
+
+ protected void pumpSwingThread() {
+ LOG.assertTrue(SwingUtilities.isEventDispatchThread());
+
+ final InvokeRatherLaterRequest request = myRatherLaterRequests.get(0);
+ request.invokesN++;
+
+ if (request.invokesN == RATHER_LATER_INVOKES_N) {
+ myRatherLaterRequests.remove(0);
+ if (!myRatherLaterRequests.isEmpty()) pumpSwingThread();
+ }
+
+ if (request.myDebuggerCommand instanceof SuspendContextCommandImpl) {
+ request.myDebugProcess.getManagerThread().schedule(new SuspendContextCommandImpl(
+ ((SuspendContextCommandImpl)request.myDebuggerCommand).getSuspendContext()) {
+ @Override
+ public void contextAction() throws Exception {
+ pumpDebuggerThread(request);
+ }
+
+ @Override
+ protected void commandCancelled() {
+ pumpDebuggerThread(request);
+ }
+ });
+ }
+ else {
+ request.myDebugProcess.getManagerThread().schedule(new DebuggerCommandImpl() {
+ @Override
+ protected void action() throws Exception {
+ pumpDebuggerThread(request);
+ }
+
+ @Override
+ protected void commandCancelled() {
+ pumpDebuggerThread(request);
+ }
+ });
+ }
+ }
+
+ private void pumpDebuggerThread(final InvokeRatherLaterRequest request) {
+ if (request.invokesN == RATHER_LATER_INVOKES_N) {
+ request.myDebugProcess.getManagerThread().schedule(request.myDebuggerCommand);
+ }
+ else {
+ if (!SwingUtilities.isEventDispatchThread()) {
+ UIUtil.invokeAndWaitIfNeeded(new Runnable() {
+ @Override
+ public void run() {
+ pumpSwingThread();
+ }
+ });
+ }
+ else {
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ pumpSwingThread();
+ }
+ });
+ }
+ }
+ }
+
+ protected void invokeRatherLater(final DebuggerCommandImpl command) {
+ IJSwingUtilities.invoke(new Runnable() {
+ @Override
+ public void run() {
+ InvokeRatherLaterRequest request = new InvokeRatherLaterRequest(command, getDebugProcess());
+ myRatherLaterRequests.add(request);
+
+ if (myRatherLaterRequests.size() == 1) pumpSwingThread();
+ }
+ });
+ }
+
+
+ protected void error(Throwable th) {
+ fail(StringUtil.getThrowableText(th));
+ }
+
+ public void createBreakpoints(final PsiFile file) {
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ BreakpointManager breakpointManager = DebuggerManagerImpl.getInstanceEx(myProject).getBreakpointManager();
+ Document document = PsiDocumentManager.getInstance(myProject).getDocument(file);
+ int offset = -1;
+ for (; ;) {
+ offset = document.getText().indexOf("Breakpoint!", offset + 1);
+ if (offset == -1) break;
+
+ int commentLine = document.getLineNumber(offset);
+
+ String comment = document.getText().substring(document.getLineStartOffset(commentLine), document.getLineEndOffset(commentLine));
+
+ Breakpoint breakpoint;
+
+ if (comment.indexOf("Method") != -1) {
+ breakpoint = breakpointManager.addMethodBreakpoint(document, commentLine + 1);
+ println("MethodBreakpoint created at " + file.getVirtualFile().getName() + ":" + (commentLine + 2), ProcessOutputTypes.SYSTEM);
+ }
+ else if (comment.indexOf("Field") != -1) {
+ breakpoint = breakpointManager.addFieldBreakpoint(document, commentLine + 1, readValue(comment, "Field"));
+ println("FieldBreakpoint created at " + file.getVirtualFile().getName() + ":" + (commentLine + 2), ProcessOutputTypes.SYSTEM);
+ }
+ else if (comment.indexOf("Exception") != -1) {
+ breakpoint = breakpointManager.addExceptionBreakpoint(readValue(comment, "Exception"), "");
+ println("ExceptionBreakpoint created at " + file.getVirtualFile().getName() + ":" + (commentLine + 2), ProcessOutputTypes.SYSTEM);
+ }
+ else {
+ breakpoint = breakpointManager.addLineBreakpoint(document, commentLine + 1);
+ println("LineBreakpoint created at " + file.getVirtualFile().getName() + ":" + (commentLine + 2), ProcessOutputTypes.SYSTEM);
+ }
+
+ String suspendPolicy = readValue(comment, "suspendPolicy");
+ if (suspendPolicy != null) {
+ breakpoint.SUSPEND = !DebuggerSettings.SUSPEND_NONE.equals(suspendPolicy);
+ breakpoint.SUSPEND_POLICY = suspendPolicy;
+ println("SUSPEND_POLICY = " + suspendPolicy, ProcessOutputTypes.SYSTEM);
+ }
+ String condition = readValue(comment, "Condition");
+ if (condition != null) {
+ breakpoint.CONDITION_ENABLED = true;
+ breakpoint.setCondition(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, condition));
+ println("Condition = " + condition, ProcessOutputTypes.SYSTEM);
+ }
+ String passCount = readValue(comment, "Pass count");
+ if (passCount != null) {
+ breakpoint.COUNT_FILTER_ENABLED = true;
+ breakpoint.COUNT_FILTER = Integer.parseInt(passCount);
+ println("Pass count = " + passCount, ProcessOutputTypes.SYSTEM);
+ }
+
+ String classFilters = readValue(comment, "Class filters");
+ if (classFilters != null) {
+ breakpoint.CLASS_FILTERS_ENABLED = true;
+ StringTokenizer tokenizer = new StringTokenizer(classFilters, " ,");
+ ArrayList<ClassFilter> lst = new ArrayList<ClassFilter>();
+
+ while (tokenizer.hasMoreTokens()) {
+ ClassFilter filter = new ClassFilter();
+ filter.setEnabled(true);
+ filter.setPattern(tokenizer.nextToken());
+ lst.add(filter);
+ }
+
+ breakpoint.setClassFilters(lst.toArray(new ClassFilter[lst.size()]));
+ println("Class filters = " + classFilters, ProcessOutputTypes.SYSTEM);
+ }
+ }
+ }
+ };
+ if (!SwingUtilities.isEventDispatchThread()) {
+ DebuggerInvocationUtil.invokeAndWait(myProject, runnable, ModalityState.defaultModalityState());
+ }
+ else {
+ runnable.run();
+ }
+ }
+
+ private Sdk getTestJdk() {
+ try {
+ ProjectJdkImpl jdk = (ProjectJdkImpl)JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk().clone();
+ jdk.setName("JDK");
+ return jdk;
+ }
+ catch (CloneNotSupportedException e) {
+ LOG.error(e);
+ return null;
+ }
+ }
+
+ protected void setTestJDK() {
+ ApplicationManager.getApplication().runWriteAction(new Runnable() {
+ @Override
+ public void run() {
+ Sdk jdk = ProjectJdkTable.getInstance().findJdk("JDK");
+ if (jdk != null) {
+ ProjectJdkTable.getInstance().removeJdk(jdk);
+ }
+
+ ProjectJdkTable.getInstance().addJdk(getTestJdk());
+ }
+ });
+ }
+
+ private class DelayedEventsProcessListener implements DebugProcessListener {
+ private final DebugProcessAdapterImpl myTarget;
+
+ public DelayedEventsProcessListener(DebugProcessAdapterImpl target) {
+ myTarget = target;
+ }
+
+ @Override
+ public void threadStarted(DebugProcess proc, ThreadReference thread) {
+ }
+
+ @Override
+ public void threadStopped(DebugProcess proc, ThreadReference thread) {
+ }
+
+ @Override
+ public void paused(final SuspendContext suspendContext) {
+ pauseExecution();
+ myTarget.paused(suspendContext);
+ }
+
+ @Override
+ public void resumed(final SuspendContext suspendContext) {
+ pauseExecution();
+ myTarget.resumed(suspendContext);
+ }
+
+ @Override
+ public void processDetached(final DebugProcess process, final boolean closedByUser) {
+ myTarget.processDetached(process, closedByUser);
+ }
+
+ @Override
+ public void processAttached(final DebugProcess process) {
+ myTarget.processAttached(process);
+ }
+
+ @Override
+ public void connectorIsReady() {
+ myTarget.connectorIsReady();
+ }
+
+ @Override
+ public void attachException(final RunProfileState state, final ExecutionException exception, final RemoteConnection remoteConnection) {
+ myTarget.attachException(state, exception, remoteConnection);
+ }
+
+ private void pauseExecution() {
+ try {
+ Thread.sleep(10);
+ }
+ catch (InterruptedException ignored) {
+ }
+ }
+ }
+}
diff --git a/java/testFramework/src/com/intellij/debugger/impl/DescriptorTestCase.java b/java/testFramework/src/com/intellij/debugger/impl/DescriptorTestCase.java
new file mode 100644
index 0000000..0d6624d
--- /dev/null
+++ b/java/testFramework/src/com/intellij/debugger/impl/DescriptorTestCase.java
@@ -0,0 +1,216 @@
+/*
+ * Copyright 2000-2013 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.debugger.impl;
+
+import com.intellij.debugger.DebuggerTestCase;
+import com.intellij.debugger.engine.DebugProcessImpl;
+import com.intellij.debugger.engine.SuspendContextImpl;
+import com.intellij.debugger.engine.evaluation.EvaluateException;
+import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
+import com.intellij.debugger.engine.events.SuspendContextCommandImpl;
+import com.intellij.debugger.engine.jdi.StackFrameProxy;
+import com.intellij.debugger.settings.NodeRendererSettings;
+import com.intellij.debugger.ui.impl.watch.DebuggerTree;
+import com.intellij.debugger.ui.impl.watch.LocalVariableDescriptorImpl;
+import com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl;
+import com.intellij.debugger.ui.tree.DebuggerTreeNode;
+import com.intellij.debugger.ui.tree.NodeDescriptor;
+import com.intellij.debugger.ui.tree.ValueDescriptor;
+import com.intellij.debugger.ui.tree.render.NodeRenderer;
+import com.intellij.execution.process.ProcessOutputTypes;
+import com.intellij.openapi.util.Pair;
+import com.sun.jdi.Value;
+
+import java.util.*;
+
+public abstract class DescriptorTestCase extends DebuggerTestCase {
+ private final List<Pair<NodeDescriptorImpl,List<String>>> myDescriptorLog = new ArrayList<Pair<NodeDescriptorImpl, List<String>>>();
+
+ public DescriptorTestCase() {
+ super();
+ }
+
+ protected NodeRenderer getToStringRenderer() {
+ return NodeRendererSettings.getInstance().getToStringRenderer();
+ }
+
+ protected NodeRenderer getMapRenderer() {
+ return getAlternateCollectionRenderer("Map");
+ }
+
+ private NodeRenderer getAlternateCollectionRenderer(final String name) {
+ final NodeRenderer[] renderers = NodeRendererSettings.getInstance().getAlternateCollectionRenderers();
+ for (int idx = 0; idx < renderers.length; idx++) {
+ NodeRenderer renderer = renderers[idx];
+ if (name.equals(renderer.getName())) {
+ return renderer;
+ }
+ }
+ return null;
+ }
+
+ protected NodeRenderer getMapEntryRenderer() {
+ return getAlternateCollectionRenderer("Map.Entry");
+ }
+
+ protected NodeRenderer getHexRenderer() {
+ return NodeRendererSettings.getInstance().getHexRenderer();
+ }
+
+ protected NodeRenderer getCollectionRenderer() {
+ return getAlternateCollectionRenderer("Collection");
+ }
+
+ @Override
+ protected void resume(final SuspendContextImpl suspendContext) {
+ final DebugProcessImpl localProcess = suspendContext.getDebugProcess();
+ invokeRatherLater(new SuspendContextCommandImpl(suspendContext) {
+ @Override
+ public void contextAction() throws Exception {
+ flushDescriptors();
+ localProcess.getManagerThread().schedule(localProcess.createResumeCommand(suspendContext, Priority.LOW));
+ }
+ });
+ }
+
+ protected void logDescriptor(final NodeDescriptorImpl descriptor, String text) {
+ Pair<NodeDescriptorImpl, List<String>> descriptorText = findDescriptorLog(descriptor);
+
+ if(descriptorText == null) {
+ ArrayList<String> allText = new ArrayList<String>();
+ allText.add(text);
+ descriptorText = new Pair<NodeDescriptorImpl, List<String>>(descriptor, allText);
+ myDescriptorLog.add(descriptorText);
+ }
+ else {
+ List<String> allText = descriptorText.getSecond();
+ if(!allText.get(allText.size() - 1).equals(text)) {
+ allText.add(text);
+ }
+ }
+ }
+
+ private Pair<NodeDescriptorImpl, List<String>> findDescriptorLog(final NodeDescriptorImpl descriptor) {
+ Pair<NodeDescriptorImpl, List<String>> descriptorText = null;
+ for (Iterator<Pair<NodeDescriptorImpl, List<String>>> iterator = myDescriptorLog.iterator(); iterator.hasNext();) {
+ Pair<NodeDescriptorImpl, List<String>> pair = iterator.next();
+ if(pair.getFirst() == descriptor) {
+ descriptorText = pair;
+ break;
+ }
+ }
+ return descriptorText;
+ }
+
+ protected void flushDescriptor(final NodeDescriptorImpl descriptor) {
+ Pair<NodeDescriptorImpl, List<String>> descriptorLog = findDescriptorLog(descriptor);
+ if(descriptorLog != null) {
+ printDescriptorLog(descriptorLog);
+ myDescriptorLog.remove(descriptorLog);
+ }
+ }
+
+ protected void flushDescriptors() {
+ for (Iterator<Pair<NodeDescriptorImpl, List<String>>> iterator = myDescriptorLog.iterator(); iterator.hasNext();) {
+ printDescriptorLog(iterator.next());
+ }
+ myDescriptorLog.clear();
+ }
+
+ private void printDescriptorLog(Pair<NodeDescriptorImpl, List<String>> pair) {
+ for (Iterator<String> it = pair.getSecond().iterator(); it.hasNext();) {
+ String text = it.next();
+ print(text, ProcessOutputTypes.SYSTEM);
+ }
+ }
+
+ protected void disableRenderer(NodeRenderer renderer) {
+ renderer.setEnabled(false);
+ }
+
+ protected void enableRenderer(NodeRenderer renderer) {
+ renderer.setEnabled(true);
+ }
+
+ protected LocalVariableDescriptorImpl localVar(DebuggerTree frameTree,
+ EvaluationContextImpl evaluationContext,
+ String name) {
+ try {
+ StackFrameProxy frameProxy = evaluationContext.getFrameProxy();
+ LocalVariableDescriptorImpl local = frameTree.getNodeFactory().getLocalVariableDescriptor(null, frameProxy.visibleVariableByName(name));
+ local.setContext(evaluationContext);
+ return local;
+ } catch (EvaluateException e) {
+ error(e);
+ return null;
+ }
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ flushDescriptors();
+ super.tearDown();
+ }
+
+ protected void expandAll(final DebuggerTree tree, final Runnable runnable) {
+ doExpandAll(tree, runnable, new HashSet<Value>(), null);
+ }
+
+ protected static interface NodeFilter {
+ boolean shouldExpand(DebuggerTreeNode node);
+ }
+
+ protected void expandAll(final DebuggerTree tree, final Runnable runnable, NodeFilter filter) {
+ doExpandAll(tree, runnable, new HashSet<Value>(), filter);
+ }
+
+ private void doExpandAll(final DebuggerTree tree, final Runnable runnable, final Set<Value> alreadyExpanded, final NodeFilter filter) {
+ invokeRatherLater(tree.getDebuggerContext().getSuspendContext(), new Runnable() {
+ @Override
+ public void run() {
+ boolean anyCollapsed = false;
+ for(int i = 0; i < tree.getRowCount(); i++) {
+ final DebuggerTreeNode treeNode = (DebuggerTreeNode)tree.getPathForRow(i).getLastPathComponent();
+ if(tree.isCollapsed(i) && !treeNode.isLeaf()) {
+ final NodeDescriptor nodeDescriptor = treeNode.getDescriptor();
+ boolean shouldExpand = filter == null? true : filter.shouldExpand(treeNode);
+ if (shouldExpand) {
+ // additional checks to prevent infinite expand
+ if (nodeDescriptor instanceof ValueDescriptor) {
+ final Value value = ((ValueDescriptor)nodeDescriptor).getValue();
+ shouldExpand = !alreadyExpanded.contains(value);
+ if (shouldExpand) {
+ alreadyExpanded.add(value);
+ }
+ }
+ }
+ if (shouldExpand) {
+ anyCollapsed = true;
+ tree.expandRow(i);
+ }
+ }
+ }
+
+ if (anyCollapsed) {
+ doExpandAll(tree, runnable, alreadyExpanded, filter);
+ }
+ else {
+ runnable.run();
+ }
+ }
+ });
+ }
+}
diff --git a/java/testFramework/src/com/intellij/debugger/impl/OutputChecker.java b/java/testFramework/src/com/intellij/debugger/impl/OutputChecker.java
new file mode 100644
index 0000000..9c48ade
--- /dev/null
+++ b/java/testFramework/src/com/intellij/debugger/impl/OutputChecker.java
@@ -0,0 +1,281 @@
+/*
+ * Copyright 2000-2013 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.debugger.impl;
+
+import com.intellij.execution.process.ProcessOutputTypes;
+import com.intellij.idea.IdeaLogger;
+import com.intellij.openapi.application.Application;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.PathManager;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.projectRoots.Sdk;
+import com.intellij.openapi.projectRoots.ex.JavaSdkUtil;
+import com.intellij.openapi.projectRoots.impl.JavaAwareProjectJdkTableImpl;
+import com.intellij.openapi.util.Computable;
+import com.intellij.openapi.util.Key;
+import com.intellij.openapi.util.SystemInfo;
+import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.util.containers.HashMap;
+import junit.framework.Assert;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.net.InetAddress;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class OutputChecker {
+ private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.impl.OutputChecker");
+
+ protected final String myAppPath;
+
+ public static final Key[] OUTPUT_ORDER = new Key[] {
+ ProcessOutputTypes.SYSTEM, ProcessOutputTypes.STDOUT, ProcessOutputTypes.STDERR
+ };
+ private Map<Key, StringBuffer> myBuffers;
+ protected String myTestName;
+
+
+ //ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
+ private static final Pattern JDI_BUG_OUTPUT_PATTERN_1 =
+ Pattern.compile("ERROR\\:\\s+JDWP\\s+Unable\\s+to\\s+get\\s+JNI\\s+1\\.2\\s+environment,\\s+jvm-\\>GetEnv\\(\\)\\s+return\\s+code\\s+=\\s+-2\n");
+ //JDWP exit error AGENT_ERROR_NO_JNI_ENV(183): [../../../src/share/back/util.c:820]
+ private static final Pattern JDI_BUG_OUTPUT_PATTERN_2 =
+ Pattern.compile("JDWP\\s+exit\\s+error\\s+AGENT_ERROR_NO_JNI_ENV.*\\]\n");
+
+ public OutputChecker(String appPath) {
+ myAppPath = appPath;
+ }
+
+ public void init(String testName) {
+ IdeaLogger.ourErrorsOccurred = null;
+
+ testName = Character.toLowerCase(testName.charAt(0)) + testName.substring(1);
+ myTestName = testName;
+ synchronized (this) {
+ myBuffers = new HashMap<Key, StringBuffer>();
+ }
+ }
+
+ public void print(String s, Key outputType) {
+ synchronized (this) {
+ if (myBuffers != null) {
+ StringBuffer buffer = myBuffers.get(outputType);
+ if (buffer == null) {
+ myBuffers.put(outputType, buffer = new StringBuffer());
+ }
+ buffer.append(s);
+ }
+ }
+ }
+
+ public void println(String s, Key outputType) {
+ print(s + "\n", outputType);
+ }
+
+ public void checkValid(Sdk jdk) throws Exception {
+ checkValid(jdk, false);
+ }
+
+ public void checkValid(Sdk jdk, boolean sortClassPath) throws Exception {
+ if (IdeaLogger.ourErrorsOccurred != null) {
+ throw IdeaLogger.ourErrorsOccurred;
+ }
+
+ String actual = preprocessBuffer(jdk, buildOutputString(), sortClassPath);
+
+ File outs = new File(myAppPath + File.separator + "outs");
+ assert outs.exists() || outs.mkdirs() : outs;
+
+ File outFile = new File(outs, myTestName + ".out");
+ if (!outFile.exists()) {
+ if (SystemInfo.isWindows) {
+ final File winOut = new File(outs, myTestName + ".win.out");
+ if (winOut.exists()) {
+ outFile = winOut;
+ }
+ }
+ else if (SystemInfo.isUnix) {
+ final File unixOut = new File(outs, myTestName + ".unx.out");
+ if (unixOut.exists()) {
+ outFile = unixOut;
+ }
+ }
+ }
+
+ if (!outFile.exists()) {
+ FileOutputStream fos = new FileOutputStream(outFile, false);
+ try {
+ fos.write(actual.getBytes());
+ }
+ finally {
+ fos.close();
+ }
+ LOG.error("Test file created " + outFile.getPath() + "\n" + "**************** Don't forget to put it into VCS! *******************");
+ }
+ else {
+ String originalText = FileUtil.loadFile(outFile);
+ String expected = originalText;
+
+ expected = StringUtil.replace(expected, "\r\n", "\n");
+ expected = StringUtil.replace(expected, "\r", "\n");
+
+ if (!expected.equals(actual)) {
+ System.out.println("expected:");
+ System.out.println(originalText);
+ System.out.println("actual:");
+ System.out.println(actual);
+
+ Assert.assertEquals(originalText, actual);
+ }
+ }
+ }
+
+ private synchronized String buildOutputString() {
+ final StringBuilder result = new StringBuilder();
+ for (Key key : OUTPUT_ORDER) {
+ final StringBuffer buffer = myBuffers.get(key);
+ if (buffer != null) {
+ result.append(buffer.toString());
+ }
+ }
+ return result.toString();
+ }
+
+ private String preprocessBuffer(final Sdk testJdk, final String buffer, final boolean sortClassPath) throws Exception {
+ Application application = ApplicationManager.getApplication();
+
+ if (application == null) return buffer;
+
+ final Exception[] ex = new Exception[]{null};
+
+ String actual = application.runReadAction(new Computable<String>() {
+ @Override
+ public String compute() {
+ try {
+ String internalJdkHome = JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk().getHomeDirectory().getPath();
+ //System.out.println("internalJdkHome = " + internalJdkHome);
+
+ String result = buffer;
+ //System.out.println("Original Output = " + result);
+ final boolean shouldIgnoreCase = !SystemInfo.isFileSystemCaseSensitive;
+
+ result = StringUtil.replace(result, "\r\n", "\n");
+ result = StringUtil.replace(result, "\r", "\n");
+ result = StringUtil.replace(result, testJdk.getHomePath(), "!TEST_JDK!", shouldIgnoreCase);
+ result = StringUtil.replace(result, myAppPath, "!APP_PATH!", shouldIgnoreCase);
+ result = StringUtil.replace(result, myAppPath.replace(File.separatorChar, '/'), "!APP_PATH!", shouldIgnoreCase);
+ result = StringUtil.replace(result, JavaSdkUtil.getIdeaRtJarPath(), "!RT_JAR!", shouldIgnoreCase);
+ result = StringUtil.replace(result, JavaSdkUtil.getJunit4JarPath(), "!JUNIT4_JAR!", shouldIgnoreCase);
+ result = StringUtil.replace(result, InetAddress.getLocalHost().getCanonicalHostName(), "!HOST_NAME!", shouldIgnoreCase);
+ result = StringUtil.replace(result, InetAddress.getLocalHost().getHostName(), "!HOST_NAME!", shouldIgnoreCase);
+ result = StringUtil.replace(result, "127.0.0.1", "!HOST_NAME!", shouldIgnoreCase);
+ result = StringUtil.replace(result, JavaSdkUtil.getIdeaRtJarPath().replace('/', File.separatorChar), "!RT_JAR!", shouldIgnoreCase);
+ result = StringUtil.replace(result, internalJdkHome.replace('/', File.separatorChar), "!JDK_HOME!", shouldIgnoreCase);
+ result = StringUtil.replace(result, internalJdkHome, "!JDK_HOME!", shouldIgnoreCase);
+ result = StringUtil.replace(result, PathManager.getHomePath(), "!IDEA_HOME!", shouldIgnoreCase);
+ result = StringUtil.replace(result, "Process finished with exit code 255", "Process finished with exit code -1");
+
+ result = replaceAdditionalInOutput(result);
+
+// result = result.replaceAll(" +\n", "\n");
+ result = result.replaceAll("!HOST_NAME!:\\d*", "!HOST_NAME!:!HOST_PORT!");
+ result = result.replaceAll("at \\'.*?\\'", "at '!HOST_NAME!:PORT_NAME!'");
+ result = result.replaceAll("address: \\'.*?\\'", "address: '!HOST_NAME!:PORT_NAME!'");
+ result = result.replaceAll("file.*AppletPage.*\\.html", "file:/!APPLET_HTML!");
+ result = result.replaceAll("\"(!JDK_HOME!.*?)\"", "$1");
+ result = result.replaceAll("\"(!APP_PATH!.*?)\"", "$1");
+
+ result = result.replaceAll("-Didea.launcher.port=\\d*", "-Didea.launcher.port=!IDEA_LAUNCHER_PORT!");
+ result = result.replaceAll("-Dfile.encoding=[\\w\\d-]*", "-Dfile.encoding=!FILE_ENCODING!");
+ result = result.replaceAll("\\((.*)\\:\\d+\\)", "($1:!LINE_NUMBER!)");
+
+ int commandLineStart = result.indexOf("!JDK_HOME!");
+ while (commandLineStart != -1) {
+ final StringBuilder builder = new StringBuilder(result);
+ int i = commandLineStart + 1;
+ while (i < builder.length()) {
+ char c = builder.charAt(i);
+ if (c == '\n') break;
+ else if (c == File.separatorChar) builder.setCharAt(i, '\\');
+ i++;
+ }
+ result = builder.toString();
+ commandLineStart = result.indexOf("!JDK_HOME!", commandLineStart + 1);
+ }
+
+ result = stripQuotesAroundClasspath(result);
+
+ final Matcher matcher = Pattern.compile("-classpath\\s+(\\S+)\\s+").matcher(result);
+ while (matcher.find()) {
+ final String classPath = matcher.group(1);
+ final String[] classPathElements = classPath.split(File.pathSeparator);
+ if (sortClassPath) {
+ Arrays.sort(classPathElements);
+ }
+ final String sortedPath = StringUtil.join(classPathElements, ";");
+ result = StringUtil.replace(result, classPath, sortedPath);
+ }
+
+ result = JDI_BUG_OUTPUT_PATTERN_1.matcher(result).replaceAll("");
+ result = JDI_BUG_OUTPUT_PATTERN_2.matcher(result).replaceAll("");
+
+ return result;
+ }
+ catch (Exception exception) {
+ ex[0] = exception;
+ return null;
+ }
+ }
+ });
+
+
+ if (ex[0] != null) throw ex[0];
+
+ return actual;
+ }
+
+ protected String replaceAdditionalInOutput(String str) {
+ return str;
+ }
+
+ //do not depend on spaces in jdk path
+ private static String stripQuotesAroundClasspath(String result) {
+ final String clsp = "-classpath ";
+ int clspIdx = 0;
+ while (true) {
+ clspIdx = result.indexOf(clsp, clspIdx);
+ if (clspIdx <= -1) {
+ break;
+ }
+
+ final int spaceIdx = result.indexOf(" ", clspIdx + clsp.length());
+ if (spaceIdx > -1) {
+ result = result.substring(0, clspIdx) +
+ clsp +
+ StringUtil.stripQuotesAroundValue(result.substring(clspIdx + clsp.length(), spaceIdx)) +
+ result.substring(spaceIdx);
+ clspIdx += clsp.length();
+ } else {
+ break;
+ }
+ }
+ return result;
+ }
+}
diff --git a/java/testFramework/src/com/intellij/debugger/impl/SynchronizationBasedSemaphore.java b/java/testFramework/src/com/intellij/debugger/impl/SynchronizationBasedSemaphore.java
new file mode 100644
index 0000000..8c57cd3
--- /dev/null
+++ b/java/testFramework/src/com/intellij/debugger/impl/SynchronizationBasedSemaphore.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2000-2013 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.debugger.impl;
+
+import com.intellij.openapi.diagnostic.Logger;
+
+/**
+ * @author Eugene Zhuravlev
+ * Date: Nov 17, 2009
+ */
+public class SynchronizationBasedSemaphore {
+ private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.impl.Semaphore");
+ private int mySemaphore = 0;
+
+ public synchronized void down() {
+ mySemaphore++;
+ if (mySemaphore == 0) {
+ notifyAll();
+ }
+ }
+
+ public synchronized void up() {
+ mySemaphore--;
+ if (mySemaphore == 0) {
+ notifyAll();
+ }
+ }
+
+ public synchronized void waitFor() {
+ try {
+ while (mySemaphore > 0) {
+ wait();
+ }
+ }
+ catch (InterruptedException e) {
+ LOG.debug(e);
+ throw new RuntimeException(e);
+ }
+ }
+
+ public synchronized boolean waitFor(final long timeout) {
+ try {
+ if (mySemaphore == 0) return true;
+ final long startTime = System.currentTimeMillis();
+ long waitTime = timeout;
+ while (mySemaphore > 0) {
+ wait(waitTime);
+ final long elapsed = System.currentTimeMillis() - startTime;
+ if (elapsed < timeout) {
+ waitTime = timeout - elapsed;
+ }
+ else {
+ break;
+ }
+ }
+ return mySemaphore == 0;
+ }
+ catch (InterruptedException e) {
+ LOG.debug(e);
+ throw new RuntimeException(e);
+ }
+ }
+
+}
diff --git a/java/testFramework/src/com/intellij/execution/ExecutionTestCase.java b/java/testFramework/src/com/intellij/execution/ExecutionTestCase.java
new file mode 100644
index 0000000..075c681
--- /dev/null
+++ b/java/testFramework/src/com/intellij/execution/ExecutionTestCase.java
@@ -0,0 +1,284 @@
+/*
+ * Copyright 2000-2013 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.execution;
+
+import com.intellij.debugger.impl.OutputChecker;
+import com.intellij.execution.configurations.JavaParameters;
+import com.intellij.execution.process.ProcessHandler;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.PathManager;
+import com.intellij.openapi.projectRoots.impl.JavaAwareProjectJdkTableImpl;
+import com.intellij.openapi.roots.ModuleRootManager;
+import com.intellij.openapi.util.Key;
+import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.openapi.vfs.LocalFileSystem;
+import com.intellij.openapi.vfs.VfsUtilCore;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.testFramework.IdeaTestCase;
+import com.intellij.testFramework.PsiTestUtil;
+import com.intellij.util.Alarm;
+import com.intellij.util.ArrayUtil;
+import com.intellij.util.ui.UIUtil;
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+import org.jetbrains.annotations.NonNls;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.util.ArrayList;
+import java.util.List;
+
+public abstract class ExecutionTestCase extends IdeaTestCase {
+ private OutputChecker myChecker;
+
+ private int myTimeout;
+
+ private static AssertionFailedError ourAssertion;
+ private static final String CLASSES = "classes";
+ private static final String SRC = "src";
+
+ public ExecutionTestCase() {
+ setTimeout(300000); //30 seconds
+ }
+
+ public void setTimeout(int timeout) {
+ myTimeout = timeout;
+ }
+
+ protected abstract OutputChecker initOutputChecker();
+
+ protected abstract String getTestAppPath();
+
+ @Override
+ protected void setUp() throws Exception {
+ ourAssertion = null;
+ ensureCompiledAppExists();
+ myChecker = initOutputChecker();
+ UIUtil.invokeAndWaitIfNeeded(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ ExecutionTestCase.super.setUp();
+ }
+ catch (Throwable e) {
+ e.printStackTrace();
+ assertTrue(false);
+ }
+ }
+ });
+ }
+
+ @Override
+ protected void setUpModule() {
+ super.setUpModule();
+ ApplicationManager.getApplication().runWriteAction(new Runnable() {
+ @Override
+ public void run() {
+ final String modulePath = getTestAppPath();
+ final String srcPath = modulePath + File.separator + "src";
+ VirtualFile moduleDir = LocalFileSystem.getInstance().findFileByPath(modulePath.replace(File.separatorChar, '/'));
+ VirtualFile srcDir = LocalFileSystem.getInstance().findFileByPath(srcPath.replace(File.separatorChar, '/'));
+
+ final ModuleRootManager rootManager = ModuleRootManager.getInstance(myModule);
+ PsiTestUtil.removeAllRoots(myModule, rootManager.getSdk());
+ PsiTestUtil.addContentRoot(myModule, moduleDir);
+ PsiTestUtil.addSourceRoot(myModule, srcDir);
+ PsiTestUtil.setCompilerOutputPath(myModule, VfsUtilCore.pathToUrl(FileUtil.toSystemIndependentName(getAppClassesPath())), false);
+ }
+ });
+ }
+
+ public void println(@NonNls String s, Key outputType) {
+ myChecker.println(s, outputType);
+ }
+
+ public void print(String s, Key outputType) {
+ myChecker.print(s, outputType);
+ }
+
+ @Override
+ protected void runBareRunnable(Runnable runnable) throws Throwable {
+ runnable.run();
+ }
+
+ @Override
+ protected void runTest() throws Throwable {
+ myChecker.init(getTestName(true));
+ super.runTest();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ UIUtil.invokeAndWaitIfNeeded(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ ExecutionTestCase.super.tearDown();
+ }
+ catch (Exception e) {
+ LOG.error(e);
+ }
+ }
+ });
+ if (ourAssertion != null) {
+ throw ourAssertion;
+ }
+ //myChecker.checkValid(getTestProjectJdk());
+ //probably some thread is destroyed right now because of log exception
+ //wait a little bit
+ synchronized (this) {
+ wait(300);
+ }
+ }
+
+ protected JavaParameters createJavaParameters(String mainClass) {
+ JavaParameters parameters = new JavaParameters();
+ parameters.getClassPath().add(getAppClassesPath());
+ parameters.setMainClass(mainClass);
+ parameters.setJdk(JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk());
+ return parameters;
+ }
+
+ protected OutputChecker getChecker() {
+ return myChecker;
+ }
+
+ protected String getAppDataPath() {
+ return getTestAppPath() + File.separator + "data";
+ }
+
+ protected String getAppOptionsPath() {
+ return getTestAppPath() + File.separator + "config" + File.separator + "options";
+ }
+
+ protected String getAppClassesPath() {
+ return getTestAppPath() + File.separator + "classes";
+ }
+
+ public void waitProcess(final ProcessHandler processHandler) {
+ Alarm alarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD, getTestRootDisposable());
+
+ final boolean[] isRunning = {true};
+ alarm.addRequest(new Runnable() {
+ @Override
+ public void run() {
+ boolean b;
+ synchronized (isRunning) {
+ b = isRunning[0];
+ }
+ if (b) {
+ processHandler.destroyProcess();
+ LOG.error("process was running over " + myTimeout / 1000 + " seconds. Interrupted. ");
+ }
+ }
+ }, myTimeout);
+ processHandler.waitFor();
+ synchronized (isRunning) {
+ isRunning[0] = false;
+ }
+ alarm.dispose();
+ }
+
+ public void waitFor(Runnable r) {
+ Alarm alarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD, getTestRootDisposable());
+ final Thread thread = Thread.currentThread();
+
+ final boolean[] isRunning = {true};
+ alarm.addRequest(new Runnable() {
+ @Override
+ public void run() {
+ boolean b;
+ synchronized (isRunning) {
+ b = isRunning[0];
+ }
+ if (b) {
+ thread.interrupt();
+ LOG.error("test was running over " + myTimeout / 1000 + " seconds. Interrupted. ");
+ }
+ }
+ }, myTimeout);
+ r.run();
+ synchronized (isRunning) {
+ isRunning[0] = false;
+ }
+ Thread.interrupted();
+ }
+
+// public static void fail(String message) {
+// ourAssertion = new AssertionFailedError(message);
+// }
+//
+// static public void assertTrue(String message, boolean condition) {
+// if (!condition)
+// fail(message);
+// }
+//
+// static public void assertTrue(boolean condition) {
+// assertTrue(null, condition);
+// }
+
+ private static final int CURRENT_VERSION = 6;
+ private static final String VERSION_FILE_NAME = "version-" + CURRENT_VERSION;
+ protected void ensureCompiledAppExists() throws Exception {
+ final String appPath = getTestAppPath();
+ final File classesDir = new File(appPath, CLASSES);
+ final File versionFile = new File(classesDir, VERSION_FILE_NAME);
+ if (!classesDir.exists() || !versionFile.exists() || !hasCompiledClasses(classesDir)) {
+ FileUtil.delete(classesDir);
+ classesDir.mkdirs();
+ if (compileTinyApp(appPath) != 0) {
+ throw new Exception("Failed to compile debugger test application.\nIt must be compiled in order to run debugger tests.\n" + appPath);
+ }
+ versionFile.createNewFile();
+ }
+ }
+
+ private int compileTinyApp(String appPath) {
+ final List<String> args = new ArrayList<String>();
+ args.add("-g");
+ args.add("-d");
+ args.add(new File(appPath, CLASSES).getPath());
+
+ final Class<TestCase> testCaseClass = TestCase.class;
+ final String junitLibRoot = PathManager.getResourceRoot(testCaseClass, "/" + testCaseClass.getName().replace('.', '/') + ".class");
+ if (junitLibRoot != null) {
+ args.add("-cp");
+ args.add(junitLibRoot);
+ }
+
+ final File[] files = new File(appPath, SRC).listFiles(new FilenameFilter() {
+ @Override
+ public boolean accept(File dir, String name) {
+ return name.endsWith(".java");
+ }
+ });
+ if (files == null) return 0; // Nothing to compile
+
+ for (File file : files) {
+ args.add(file.getPath());
+ }
+ return com.sun.tools.javac.Main.compile(ArrayUtil.toStringArray(args));
+ }
+
+ private boolean hasCompiledClasses(final File classesDir) {
+ for (File file : classesDir.listFiles()) {
+ if (file.isFile() && file.getName().endsWith(".class")) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/java/testFramework/src/com/intellij/testFramework/InspectionTestCase.java b/java/testFramework/src/com/intellij/testFramework/InspectionTestCase.java
index a93ea6b..bfeac04 100644
--- a/java/testFramework/src/com/intellij/testFramework/InspectionTestCase.java
+++ b/java/testFramework/src/com/intellij/testFramework/InspectionTestCase.java
@@ -76,11 +76,11 @@
doTest(folderName, new GlobalInspectionToolWrapper(tool), "java 1.4", checkRange, runDeadCodeFirst);
}
- public void doTest(@NonNls String folderName, InspectionTool tool) {
+ public void doTest(@NonNls String folderName, InspectionToolWrapper tool) {
doTest(folderName, tool, "java 1.4");
}
- public void doTest(@NonNls String folderName, InspectionTool tool, final boolean checkRange) {
+ public void doTest(@NonNls String folderName, InspectionToolWrapper tool, final boolean checkRange) {
doTest(folderName, tool, "java 1.4", checkRange);
}
@@ -88,35 +88,35 @@
doTest(folderName, new LocalInspectionToolWrapper(tool), jdkName);
}
- public void doTest(@NonNls String folderName, InspectionTool tool, @NonNls final String jdkName) {
+ public void doTest(@NonNls String folderName, InspectionToolWrapper tool, @NonNls final String jdkName) {
doTest(folderName, tool, jdkName, false);
}
- public void doTest(@NonNls String folderName, InspectionTool tool, @NonNls final String jdkName, boolean checkRange) {
+ public void doTest(@NonNls String folderName, InspectionToolWrapper tool, @NonNls final String jdkName, boolean checkRange) {
doTest(folderName, tool, jdkName, checkRange, false);
}
public void doTest(@NonNls String folderName,
- InspectionTool tool,
+ InspectionToolWrapper toolWrapper,
@NonNls final String jdkName,
boolean checkRange,
boolean runDeadCodeFirst,
- InspectionTool... additional) {
+ InspectionToolWrapper... additional) {
final String testDir = getTestDataPath() + "/" + folderName;
- runTool(testDir, jdkName, runDeadCodeFirst, tool, additional);
+ runTool(testDir, jdkName, runDeadCodeFirst, toolWrapper, additional);
- InspectionTestUtil.compareToolResults(tool, checkRange, testDir);
+ InspectionTestUtil.compareToolResults(toolWrapper, checkRange, testDir);
}
- protected void runTool(@NonNls final String testDir, @NonNls final String jdkName, final InspectionTool tool) {
+ protected void runTool(@NonNls final String testDir, @NonNls final String jdkName, final InspectionToolWrapper tool) {
runTool(testDir, jdkName, false, tool);
}
protected void runTool(final String testDir,
final String jdkName,
boolean runDeadCodeFirst,
- final InspectionTool tool,
- InspectionTool... additional) {
+ @NotNull InspectionToolWrapper toolWrapper,
+ @NotNull InspectionToolWrapper... additional) {
final VirtualFile[] sourceDir = new VirtualFile[1];
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
@@ -132,14 +132,15 @@
AnalysisScope scope = createAnalysisScope(sourceDir[0].getParent());
InspectionManagerEx inspectionManager = (InspectionManagerEx)InspectionManager.getInstance(getProject());
- InspectionTool[] tools = runDeadCodeFirst ? new InspectionTool[]{new UnusedDeclarationInspection(), tool} : new InspectionTool[]{tool};
- tools = ArrayUtil.mergeArrays(tools, additional);
+ InspectionToolWrapper[] toolWrappers = runDeadCodeFirst ? new InspectionToolWrapper []{new GlobalInspectionToolWrapper(new UnusedDeclarationInspection()), toolWrapper} : new InspectionToolWrapper []{toolWrapper};
+ toolWrappers = ArrayUtil.mergeArrays(toolWrappers, additional);
final GlobalInspectionContextImpl globalContext =
- CodeInsightTestFixtureImpl.createGlobalContextForTool(scope, getProject(), inspectionManager, tools);
+ CodeInsightTestFixtureImpl.createGlobalContextForTool(scope, getProject(), inspectionManager, toolWrappers);
- InspectionTestUtil.runTool(tool, scope, globalContext, inspectionManager);
+ InspectionTestUtil.runTool(toolWrapper, scope, globalContext, inspectionManager);
}
+ @NotNull
protected AnalysisScope createAnalysisScope(VirtualFile sourceDir) {
PsiManager psiManager = PsiManager.getInstance(myProject);
return new AnalysisScope(psiManager.findDirectory(sourceDir));
diff --git a/java/testFramework/testFramework-java.iml b/java/testFramework/testFramework-java.iml
index 9d48d3d..ed67da5 100644
--- a/java/testFramework/testFramework-java.iml
+++ b/java/testFramework/testFramework-java.iml
@@ -22,6 +22,8 @@
<orderEntry type="module" module-name="relaxng" exported="" scope="TEST" />
<orderEntry type="module" module-name="idea-ui" exported="" />
<orderEntry type="module" module-name="external-system-impl" exported="" scope="TEST" />
+ <orderEntry type="module" module-name="debugger-impl" exported="" />
+ <orderEntry type="module" module-name="execution-openapi" exported="" />
</component>
<component name="copyright">
<Base>
diff --git a/jps/jps-builders/proto/javac_remote_proto.proto b/jps/jps-builders/proto/javac_remote_proto.proto
index c9991c0..63d4d2e 100644
--- a/jps/jps-builders/proto/javac_remote_proto.proto
+++ b/jps/jps-builders/proto/javac_remote_proto.proto
@@ -50,6 +50,7 @@
CLASS_DATA = 3;
BUILD_COMPLETED = 4;
REQUEST_ACK = 5;
+ SRC_FILE_LOADED = 6;
}
message CompileMessage {
diff --git a/jps/jps-builders/src/org/jetbrains/jps/builders/artifacts/ArtifactBuildTaskProvider.java b/jps/jps-builders/src/org/jetbrains/jps/builders/artifacts/ArtifactBuildTaskProvider.java
index 0569e19..17cfe2f 100644
--- a/jps/jps-builders/src/org/jetbrains/jps/builders/artifacts/ArtifactBuildTaskProvider.java
+++ b/jps/jps-builders/src/org/jetbrains/jps/builders/artifacts/ArtifactBuildTaskProvider.java
@@ -26,7 +26,7 @@
*/
public abstract class ArtifactBuildTaskProvider {
public enum ArtifactBuildPhase {
- PRE_PROCESSING, POST_PROCESSING
+ PRE_PROCESSING, FINISHING_BUILD, POST_PROCESSING
}
@NotNull
diff --git a/jps/jps-builders/src/org/jetbrains/jps/builders/impl/BuildRootDescriptorImpl.java b/jps/jps-builders/src/org/jetbrains/jps/builders/impl/BuildRootDescriptorImpl.java
index 84a12e5..bb59350 100644
--- a/jps/jps-builders/src/org/jetbrains/jps/builders/impl/BuildRootDescriptorImpl.java
+++ b/jps/jps-builders/src/org/jetbrains/jps/builders/impl/BuildRootDescriptorImpl.java
@@ -27,9 +27,7 @@
private final boolean myCanUseFileCache;
public BuildRootDescriptorImpl(BuildTarget target, File root) {
- myTarget = target;
- myRoot = root;
- myCanUseFileCache = super.canUseFileCache();
+ this(target, root, false);
}
public BuildRootDescriptorImpl(BuildTarget target, File root, boolean canUseFileCache) {
diff --git a/jps/jps-builders/src/org/jetbrains/jps/builders/impl/storage/BuildTargetStorages.java b/jps/jps-builders/src/org/jetbrains/jps/builders/impl/storage/BuildTargetStorages.java
index 4e64ce6..e94bee3 100644
--- a/jps/jps-builders/src/org/jetbrains/jps/builders/impl/storage/BuildTargetStorages.java
+++ b/jps/jps-builders/src/org/jetbrains/jps/builders/impl/storage/BuildTargetStorages.java
@@ -15,6 +15,8 @@
*/
package org.jetbrains.jps.builders.impl.storage;
+import com.intellij.openapi.util.AtomicNotNullLazyValue;
+import com.intellij.openapi.util.NotNullLazyValue;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.builders.BuildTarget;
import org.jetbrains.jps.builders.storage.BuildDataPaths;
@@ -23,8 +25,9 @@
import org.jetbrains.jps.incremental.storage.StorageOwner;
import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.Iterator;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
/**
* @author nik
@@ -32,7 +35,8 @@
public class BuildTargetStorages extends CompositeStorageOwner {
private final BuildTarget<?> myTarget;
private final BuildDataPaths myPaths;
- private Map<StorageProvider<?>, StorageOwner> myStorages = new HashMap<StorageProvider<?>, StorageOwner>();
+ private final ConcurrentMap<StorageProvider<?>, AtomicNotNullLazyValue<? extends StorageOwner>> myStorages
+ = new ConcurrentHashMap<StorageProvider<?>, AtomicNotNullLazyValue<? extends StorageOwner>>(16, 0.75f, 1);
public BuildTargetStorages(BuildTarget<?> target, BuildDataPaths paths) {
myTarget = target;
@@ -40,18 +44,62 @@
}
@NotNull
- public <S extends StorageOwner> S getOrCreateStorage(@NotNull StorageProvider<S> provider) throws IOException {
- //noinspection unchecked
- S storage = (S)myStorages.get(provider);
- if (storage == null) {
- storage = provider.createStorage(myPaths.getTargetDataRoot(myTarget));
- myStorages.put(provider, storage);
+ public <S extends StorageOwner> S getOrCreateStorage(@NotNull final StorageProvider<S> provider) throws IOException {
+ NotNullLazyValue<? extends StorageOwner> lazyValue = myStorages.get(provider);
+ if (lazyValue == null) {
+ AtomicNotNullLazyValue<S> newValue = new AtomicNotNullLazyValue<S>() {
+ @NotNull
+ @Override
+ protected S compute() {
+ try {
+ return provider.createStorage(myPaths.getTargetDataRoot(myTarget));
+ }
+ catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ };
+ lazyValue = myStorages.putIfAbsent(provider, newValue);
+ if (lazyValue == null) {
+ lazyValue = newValue; // just initialized
+ }
}
- return (S)storage;
+ //noinspection unchecked
+ try {
+ return (S)lazyValue.getValue();
+ }
+ catch (RuntimeException e) {
+ final Throwable cause = e.getCause();
+ if (cause instanceof IOException) {
+ throw (IOException)cause;
+ }
+ throw e;
+ }
}
@Override
protected Iterable<? extends StorageOwner> getChildStorages() {
- return myStorages.values();
+ return new Iterable<StorageOwner>() {
+ @Override
+ public Iterator<StorageOwner> iterator() {
+ final Iterator<AtomicNotNullLazyValue<? extends StorageOwner>> iterator = myStorages.values().iterator();
+ return new Iterator<StorageOwner>() {
+ @Override
+ public boolean hasNext() {
+ return iterator.hasNext();
+ }
+
+ @Override
+ public StorageOwner next() {
+ return iterator.next().getValue();
+ }
+
+ @Override
+ public void remove() {
+ iterator.remove();
+ }
+ };
+ }
+ };
}
}
diff --git a/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildRunner.java b/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildRunner.java
index 7fe98f3..7061fc6 100644
--- a/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildRunner.java
+++ b/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildRunner.java
@@ -55,7 +55,7 @@
public class BuildRunner {
private static final Logger LOG = Logger.getInstance("#org.jetbrains.jps.cmdline.BuildRunner");
public static final boolean PARALLEL_BUILD_ENABLED = Boolean.parseBoolean(System.getProperty(GlobalOptions.COMPILE_PARALLEL_OPTION, "false"));
- private static final boolean STORE_TEMP_CACHES_IN_MEMORY = PARALLEL_BUILD_ENABLED || System.getProperty(GlobalOptions.USE_MEMORY_TEMP_CACHE_OPTION) != null;
+ private static final boolean STORE_TEMP_CACHES_IN_MEMORY = PARALLEL_BUILD_ENABLED || Boolean.valueOf(System.getProperty(GlobalOptions.USE_MEMORY_TEMP_CACHE_OPTION, "true"));
private final JpsModelLoader myModelLoader;
private final List<String> myFilePaths;
private final Map<String, String> myBuilderParams;
@@ -121,7 +121,7 @@
for (int attempt = 0; attempt < 2; attempt++) {
final boolean forceClean = myForceCleanCaches && myFilePaths.isEmpty();
final CompileScope compileScope = createCompilationScope(pd, scopes, myFilePaths, forceClean, includeDependenciesToScope);
- final IncProjectBuilder builder = new IncProjectBuilder(pd, BuilderRegistry.getInstance(), myBuilderParams, cs, constantSearch);
+ final IncProjectBuilder builder = new IncProjectBuilder(pd, BuilderRegistry.getInstance(), myBuilderParams, cs, constantSearch, Utils.IS_TEST_MODE);
builder.addMessageHandler(msgHandler);
try {
switch (buildType) {
diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/FSCache.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/FSCache.java
index 75b5a99..689d2fe 100644
--- a/jps/jps-builders/src/org/jetbrains/jps/incremental/FSCache.java
+++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/FSCache.java
@@ -19,6 +19,7 @@
import org.jetbrains.annotations.Nullable;
import java.io.File;
+import java.util.Collections;
import java.util.Map;
/**
@@ -37,24 +38,20 @@
private static final File[] NULL_VALUE = new File[0];
private static final File[] EMPTY_FILE_ARRAY = new File[0];
- private final Map<File, File[]> myMap = new THashMap<File, File[]>();
+ private final Map<File, File[]> myMap = Collections.synchronizedMap(new THashMap<File, File[]>());
@Nullable
public File[] getChildren(File file) {
- synchronized (myMap) {
- final File[] children = myMap.get(file);
- if (children != null) {
- return children == NULL_VALUE? null : children;
- }
- final File[] files = file.listFiles();
- myMap.put(file, files == null? NULL_VALUE : (files.length == 0? EMPTY_FILE_ARRAY : files));
- return files;
+ final File[] children = myMap.get(file);
+ if (children != null) {
+ return children == NULL_VALUE? null : children;
}
+ final File[] files = file.listFiles();
+ myMap.put(file, files == null? NULL_VALUE : (files.length == 0? EMPTY_FILE_ARRAY : files));
+ return files;
}
public void clear() {
- synchronized (myMap) {
- myMap.clear();
- }
+ myMap.clear();
}
}
diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/IncProjectBuilder.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/IncProjectBuilder.java
index b9bf4e5..718dc8c 100644
--- a/jps/jps-builders/src/org/jetbrains/jps/incremental/IncProjectBuilder.java
+++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/IncProjectBuilder.java
@@ -81,7 +81,7 @@
private static final String CLASSPATH_INDEX_FINE_NAME = "classpath.index";
private static final boolean GENERATE_CLASSPATH_INDEX = Boolean.parseBoolean(System.getProperty(GlobalOptions.GENERATE_CLASSPATH_INDEX_OPTION, "false"));
private static final GlobalContextKey<Set<BuildTarget<?>>> TARGET_WITH_CLEARED_OUTPUT = GlobalContextKey.create("_targets_with_cleared_output_");
- private static final int MAX_BUILDER_THREADS;
+ public static final int MAX_BUILDER_THREADS;
static {
int maxThreads = 6;
try {
@@ -105,6 +105,7 @@
}
}
};
+ private final boolean myIsTestMode;
private volatile float myTargetsProcessed = 0.0f;
private final float myTotalTargetsWork;
@@ -112,7 +113,7 @@
private final List<Future> myAsyncTasks = Collections.synchronizedList(new ArrayList<Future>());
public IncProjectBuilder(ProjectDescriptor pd, BuilderRegistry builderRegistry, Map<String, String> builderParams, CanceledStatus cs,
- @Nullable Callbacks.ConstantAffectionResolver constantSearch) {
+ @Nullable Callbacks.ConstantAffectionResolver constantSearch, final boolean isTestMode) {
myProjectDescriptor = pd;
myBuilderRegistry = builderRegistry;
myBuilderParams = builderParams;
@@ -120,6 +121,7 @@
myConstantSearch = constantSearch;
myTotalTargetsWork = pd.getBuildTargetIndex().getAllTargets().size();
myTotalModuleLevelBuilderCount = builderRegistry.getModuleLevelBuilderCount();
+ myIsTestMode = isTestMode;
}
public void addMessageHandler(MessageHandler handler) {
@@ -936,15 +938,10 @@
final ProjectBuilderLogger logger = context.getLoggingManager().getProjectBuilderLogger();
// actually delete outputs associated with removed paths
final Collection<String> pathsForIteration;
- if (Utils.IS_TEST_MODE) {
+ if (myIsTestMode) {
// ensure predictable order in test logs
pathsForIteration = new ArrayList<String>(deletedPaths);
- Collections.sort((List<String>)pathsForIteration, new Comparator<String>() {
- @Override
- public int compare(String o1, String o2) {
- return o1.compareTo(o2);
- }
- });
+ Collections.sort((List<String>)pathsForIteration);
}
else {
pathsForIteration = deletedPaths;
@@ -1060,6 +1057,10 @@
BUILDER_CATEGORY_LOOP:
for (BuilderCategory category : BuilderCategory.values()) {
final List<ModuleLevelBuilder> builders = myBuilderRegistry.getBuilders(category);
+ if (category == BuilderCategory.CLASS_POST_PROCESSOR) {
+ // ensure changes from instrumenters are visible to class post-processors
+ saveInstrumentedClasses(outputConsumer);
+ }
if (builders.isEmpty()) {
continue;
}
@@ -1117,11 +1118,7 @@
while (nextPassRequired);
}
finally {
- for (CompiledClass compiledClass : outputConsumer.getCompiledClasses().values()) {
- if (compiledClass.isDirty()) {
- compiledClass.save();
- }
- }
+ saveInstrumentedClasses(outputConsumer);
outputConsumer.fireFileGeneratedEvents();
outputConsumer.clear();
for (BuilderCategory category : BuilderCategory.values()) {
@@ -1134,6 +1131,14 @@
return doneSomething;
}
+ private static void saveInstrumentedClasses(ChunkBuildOutputConsumerImpl outputConsumer) throws IOException {
+ for (CompiledClass compiledClass : outputConsumer.getCompiledClasses().values()) {
+ if (compiledClass.isDirty()) {
+ compiledClass.save();
+ }
+ }
+ }
+
private static void onChunkBuildComplete(CompileContext context, @NotNull BuildTargetChunk chunk) throws IOException {
final ProjectDescriptor pd = context.getProjectDescriptor();
final BuildFSState fsState = pd.fsState;
diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/ModuleBuildTarget.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/ModuleBuildTarget.java
index 0763f17..a16810e 100644
--- a/jps/jps-builders/src/org/jetbrains/jps/incremental/ModuleBuildTarget.java
+++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/ModuleBuildTarget.java
@@ -139,13 +139,17 @@
roots_loop:
for (JpsTypedModuleSourceRoot<JpsSimpleElement<JavaSourceRootProperties>> sourceRoot : myModule.getSourceRoots(type)) {
+ if (JpsPathUtil.isUnder(moduleExcludes, sourceRoot.getFile())) {
+ continue;
+ }
for (ExcludedJavaSourceRootProvider provider : excludedRootProviders) {
- if (provider.isExcludedFromCompilation(myModule, sourceRoot) || JpsPathUtil.isUnder(moduleExcludes, sourceRoot.getFile())) {
+ if (provider.isExcludedFromCompilation(myModule, sourceRoot)) {
continue roots_loop;
}
}
final String packagePrefix = sourceRoot.getProperties().getData().getPackagePrefix();
- roots.add(new JavaSourceRootDescriptor(sourceRoot.getFile(), this, false, false, packagePrefix, computeRootExcludes(sourceRoot.getFile(), index)));
+ roots.add(new JavaSourceRootDescriptor(sourceRoot.getFile(), this, false, false, packagePrefix,
+ computeRootExcludes(sourceRoot.getFile(), index)));
}
return roots;
}
diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/artifacts/IncArtifactBuilder.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/artifacts/IncArtifactBuilder.java
index e4350bd..a83164e 100644
--- a/jps/jps-builders/src/org/jetbrains/jps/incremental/artifacts/IncArtifactBuilder.java
+++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/artifacts/IncArtifactBuilder.java
@@ -173,6 +173,7 @@
JarsBuilder builder = new JarsBuilder(changedJars, context, outputConsumer, outSrcMapping);
builder.buildJars();
+ runArtifactTasks(context, artifact, ArtifactBuildTaskProvider.ArtifactBuildPhase.FINISHING_BUILD);
runArtifactTasks(context, artifact, ArtifactBuildTaskProvider.ArtifactBuildPhase.POST_PROCESSING);
}
catch (IOException e) {
diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java
index d3a654a..776c3a8 100644
--- a/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java
+++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java
@@ -50,15 +50,14 @@
import org.jetbrains.jps.javac.*;
import org.jetbrains.jps.model.JpsDummyElement;
import org.jetbrains.jps.model.JpsProject;
-import org.jetbrains.jps.model.JpsSimpleElement;
-import org.jetbrains.jps.model.java.*;
+import org.jetbrains.jps.model.java.JpsJavaExtensionService;
+import org.jetbrains.jps.model.java.JpsJavaSdkType;
+import org.jetbrains.jps.model.java.LanguageLevel;
import org.jetbrains.jps.model.java.compiler.*;
import org.jetbrains.jps.model.library.sdk.JpsSdk;
import org.jetbrains.jps.model.module.JpsModule;
import org.jetbrains.jps.model.module.JpsModuleType;
-import org.jetbrains.jps.model.module.JpsTypedModuleSourceRoot;
import org.jetbrains.jps.service.JpsServiceManager;
-import org.jetbrains.jps.util.JpsPathUtil;
import javax.tools.*;
import java.io.*;
@@ -233,7 +232,6 @@
final Collection<File> platformCp = ProjectPaths.getPlatformCompilationClasspath(chunk, false/*context.isProjectRebuild()*/);
// begin compilation round
- final DiagnosticSink diagnosticSink = new DiagnosticSink(context);
final Mappings delta = pd.dataManager.getMappings().createDelta();
final Callbacks.Backend mappingsCallback = delta.getCallback();
final OutputFilesSink outputSink = new OutputFilesSink(context, outputConsumer, mappingsCallback, chunk.getName());
@@ -248,14 +246,14 @@
exitCode = ExitCode.OK;
final Set<File> srcPath = new HashSet<File>();
- collectSourceRoots(chunk, srcPath, chunk.containsTests()? JavaSourceRootType.TEST_SOURCE : JavaSourceRootType.SOURCE);
final BuildRootIndex index = pd.getBuildRootIndex();
for (ModuleBuildTarget target : chunk.getTargets()) {
for (JavaSourceRootDescriptor rd : index.getTempTargetRoots(target, context)) {
srcPath.add(rd.root);
}
}
-
+ final DiagnosticSink diagnosticSink = new DiagnosticSink(context);
+
final String chunkName = chunk.getName();
context.processMessage(new ProgressMessage("Parsing java... [" + chunkName + "]"));
@@ -276,7 +274,17 @@
LOG.debug(" " + file.getAbsolutePath());
}
}
- compiledOk = compileJava(context, chunk, files, classpath, platformCp, srcPath, diagnosticSink, outputSink);
+ try {
+ compiledOk = compileJava(context, chunk, files, classpath, platformCp, srcPath, diagnosticSink, outputSink);
+ }
+ finally {
+ // heuristic: incorrect paths data recovery, so that the next make should not contain non-existing sources in 'recompile' list
+ for (File file : diagnosticSink.getFilesWithErrors()) {
+ if (!file.exists()) {
+ FSOperations.markDeleted(context, file);
+ }
+ }
+ }
}
context.checkCanceled();
@@ -303,14 +311,6 @@
return exitCode;
}
- private static void collectSourceRoots(ModuleChunk chunk, Set<File> srcPath, final JavaSourceRootType rootType) {
- for (JpsModule module : chunk.getModules()) {
- for (JpsTypedModuleSourceRoot<JpsSimpleElement<JavaSourceRootProperties>> root : module.getSourceRoots(rootType)) {
- srcPath.add(JpsPathUtil.urlToFile(root.getUrl()));
- }
- }
- }
-
private boolean compileJava(
final CompileContext context,
ModuleChunk chunk,
@@ -780,15 +780,20 @@
return map;
}
- private class DiagnosticSink implements DiagnosticOutputConsumer {
+ private static class DiagnosticSink implements DiagnosticOutputConsumer {
private final CompileContext myContext;
private volatile int myErrorCount = 0;
private volatile int myWarningCount = 0;
+ private final Set<File> myFilesWithErrors = new HashSet<File>();
public DiagnosticSink(CompileContext context) {
myContext = context;
}
+ @Override
+ public void javaFileLoaded(File file) {
+ }
+
public void registerImports(final String className, final Collection<String> imports, final Collection<String> staticImports) {
//submitAsyncTask(myContext, new Runnable() {
// public void run() {
@@ -819,7 +824,7 @@
}
}
- private BuildMessage.Kind getKindByMessageText(String line) {
+ private static BuildMessage.Kind getKindByMessageText(String line) {
final String lowercasedLine = line.toLowerCase(Locale.US);
if (lowercasedLine.contains("error") || lowercasedLine.contains("requires target release")) {
return BuildMessage.Kind.ERROR;
@@ -853,15 +858,23 @@
catch (Exception e) {
LOG.info(e);
}
- final String srcPath = sourceFile != null ? FileUtil.toSystemIndependentName(sourceFile.getPath()) : null;
+ final String srcPath;
+ if (sourceFile != null) {
+ myFilesWithErrors.add(sourceFile);
+ srcPath = FileUtil.toSystemIndependentName(sourceFile.getPath());
+ }
+ else {
+ srcPath = null;
+ }
String message = diagnostic.getMessage(Locale.US);
if (Utils.IS_TEST_MODE) {
LOG.info(message);
}
- myContext.processMessage(
- new CompilerMessage(BUILDER_NAME, kind, message, srcPath, diagnostic.getStartPosition(),
- diagnostic.getEndPosition(), diagnostic.getPosition(), diagnostic.getLineNumber(),
- diagnostic.getColumnNumber()));
+ myContext.processMessage(new CompilerMessage(
+ BUILDER_NAME, kind, message, srcPath, diagnostic.getStartPosition(),
+ diagnostic.getEndPosition(), diagnostic.getPosition(), diagnostic.getLineNumber(),
+ diagnostic.getColumnNumber()
+ ));
}
public int getErrorCount() {
@@ -871,6 +884,10 @@
public int getWarningCount() {
return myWarningCount;
}
+
+ public Collection<File> getFilesWithErrors() {
+ return myFilesWithErrors;
+ }
}
private class ClassProcessingConsumer implements OutputFileConsumer {
diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/messages/BuildMessage.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/messages/BuildMessage.java
index 3fad1fb..7e84cc8 100644
--- a/jps/jps-builders/src/org/jetbrains/jps/incremental/messages/BuildMessage.java
+++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/messages/BuildMessage.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -20,7 +20,7 @@
* Date: 9/29/11
*/
public abstract class BuildMessage {
- public static enum Kind {
+ public enum Kind {
ERROR, WARNING, INFO, PROGRESS
}
diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/storage/BuildDataManager.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/storage/BuildDataManager.java
index 522c66a..3c9ac5b 100644
--- a/jps/jps-builders/src/org/jetbrains/jps/incremental/storage/BuildDataManager.java
+++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/storage/BuildDataManager.java
@@ -16,6 +16,7 @@
package org.jetbrains.jps.incremental.storage;
import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.util.AtomicNotNullLazyValue;
import com.intellij.openapi.util.io.FileUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -26,11 +27,14 @@
import org.jetbrains.jps.builders.storage.BuildDataPaths;
import org.jetbrains.jps.builders.storage.SourceToOutputMapping;
import org.jetbrains.jps.builders.storage.StorageProvider;
+import org.jetbrains.jps.cmdline.BuildRunner;
+import org.jetbrains.jps.incremental.IncProjectBuilder;
import java.io.*;
import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.Iterator;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
/**
* @author Eugene Zhuravlev
@@ -41,23 +45,81 @@
private static final Logger LOG = Logger.getInstance("#org.jetbrains.jps.incremental.storage.BuildDataManager");
private static final String SRC_TO_FORM_STORAGE = "src-form";
private static final String MAPPINGS_STORAGE = "mappings";
+ private static final int CONCURRENCY_LEVEL = BuildRunner.PARALLEL_BUILD_ENABLED? IncProjectBuilder.MAX_BUILDER_THREADS : 1;
- private final Object mySourceToOutputLock = new Object();
- private final Map<BuildTarget<?>, SourceToOutputMappingImpl> mySourceToOutputs = new HashMap<BuildTarget<?>, SourceToOutputMappingImpl>();
- private final Object myTargetStoragesLock = new Object();
- private final Map<BuildTarget<?>, BuildTargetStorages> myTargetStorages = new HashMap<BuildTarget<?>, BuildTargetStorages>();
- private StorageOwner myTargetStoragesOwner = new CompositeStorageOwner() {
- @Override
- protected Iterable<? extends StorageOwner> getChildStorages() {
- return myTargetStorages.values();
- }
- };
+ private final ConcurrentMap<BuildTarget<?>, AtomicNotNullLazyValue<SourceToOutputMappingImpl>> mySourceToOutputs =
+ new ConcurrentHashMap<BuildTarget<?>, AtomicNotNullLazyValue<SourceToOutputMappingImpl>>(16, 0.75f, CONCURRENCY_LEVEL);
+ private final ConcurrentMap<BuildTarget<?>, AtomicNotNullLazyValue<BuildTargetStorages>> myTargetStorages =
+ new ConcurrentHashMap<BuildTarget<?>, AtomicNotNullLazyValue<BuildTargetStorages>>(16, 0.75f, CONCURRENCY_LEVEL);
private final OneToManyPathsMapping mySrcToFormMap;
private final Mappings myMappings;
private final BuildDataPaths myDataPaths;
private final BuildTargetsState myTargetsState;
private final File myVersionFile;
+ private StorageOwner myTargetStoragesOwner = new CompositeStorageOwner() {
+ @Override
+ protected Iterable<? extends StorageOwner> getChildStorages() {
+ return new Iterable<StorageOwner>() {
+ @Override
+ public Iterator<StorageOwner> iterator() {
+ final Iterator<AtomicNotNullLazyValue<BuildTargetStorages>> iterator = myTargetStorages.values().iterator();
+ return new Iterator<StorageOwner>() {
+ @Override
+ public boolean hasNext() {
+ return iterator.hasNext();
+ }
+
+ @Override
+ public StorageOwner next() {
+ return iterator.next().getValue();
+ }
+
+ @Override
+ public void remove() {
+ iterator.remove();
+ }
+ };
+ }
+ };
+ }
+ };
+
+
+ private interface LazyValueFactory<K, V> {
+ AtomicNotNullLazyValue<V> create(K key);
+ }
+
+ private LazyValueFactory<BuildTarget<?>,SourceToOutputMappingImpl> SOURCE_OUTPUT_MAPPING_VALUE_FACTORY = new LazyValueFactory<BuildTarget<?>, SourceToOutputMappingImpl>() {
+ @Override
+ public AtomicNotNullLazyValue<SourceToOutputMappingImpl> create(final BuildTarget<?> key) {
+ return new AtomicNotNullLazyValue<SourceToOutputMappingImpl>() {
+ @NotNull
+ @Override
+ protected SourceToOutputMappingImpl compute() {
+ try {
+ return new SourceToOutputMappingImpl(new File(getSourceToOutputMapRoot(key), "data"));
+ }
+ catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ };
+ }
+ };
+
+ private LazyValueFactory<BuildTarget<?>,BuildTargetStorages> TARGET_STORAGES_VALUE_FACTORY = new LazyValueFactory<BuildTarget<?>, BuildTargetStorages>() {
+ @Override
+ public AtomicNotNullLazyValue<BuildTargetStorages> create(final BuildTarget<?> target) {
+ return new AtomicNotNullLazyValue<BuildTargetStorages>() {
+ @NotNull
+ @Override
+ protected BuildTargetStorages compute() {
+ return new BuildTargetStorages(target, myDataPaths);
+ }
+ };
+ }
+ };
public BuildDataManager(final BuildDataPaths dataPaths, BuildTargetsState targetsState, final boolean useMemoryTempCaches) throws IOException {
myDataPaths = dataPaths;
@@ -68,31 +130,13 @@
}
public SourceToOutputMapping getSourceToOutputMap(final BuildTarget<?> target) throws IOException {
- SourceToOutputMappingImpl mapping;
- synchronized (mySourceToOutputLock) {
- mapping = mySourceToOutputs.get(target);
- if (mapping == null) {
- mapping = new SourceToOutputMappingImpl(new File(getSourceToOutputMapRoot(target), "data"));
- mySourceToOutputs.put(target, mapping);
- }
- }
- return mapping;
- }
-
- private File getSourceToOutputMapRoot(BuildTarget<?> target) {
- return new File(myDataPaths.getTargetDataRoot(target), "src-out");
+ return fetchValue(mySourceToOutputs, target, SOURCE_OUTPUT_MAPPING_VALUE_FACTORY);
}
@NotNull
public <S extends StorageOwner> S getStorage(@NotNull BuildTarget<?> target, @NotNull StorageProvider<S> provider) throws IOException {
- synchronized (myTargetStoragesLock) {
- BuildTargetStorages storages = myTargetStorages.get(target);
- if (storages == null) {
- storages = new BuildTargetStorages(target, myDataPaths);
- myTargetStorages.put(target, storages);
- }
- return storages.getOrCreateStorage(provider);
- }
+ final BuildTargetStorages storages = fetchValue(myTargetStorages, target, TARGET_STORAGES_VALUE_FACTORY);
+ return storages.getOrCreateStorage(provider);
}
public OneToManyPathsMapping getSourceToFormMap() {
@@ -105,11 +149,9 @@
public void cleanTargetStorages(BuildTarget<?> target) throws IOException {
try {
- synchronized (myTargetStoragesLock) {
- BuildTargetStorages storages = myTargetStorages.remove(target);
- if (storages != null) {
- storages.close();
- }
+ AtomicNotNullLazyValue<BuildTargetStorages> storages = myTargetStorages.remove(target);
+ if (storages != null) {
+ storages.getValue().close();
}
}
finally {
@@ -128,16 +170,12 @@
public void clean() throws IOException {
try {
- synchronized (myTargetStoragesLock) {
- myTargetStoragesOwner.close();
- myTargetStorages.clear();
- }
+ myTargetStoragesOwner.close();
+ myTargetStorages.clear();
}
finally {
try {
- synchronized (mySourceToOutputLock) {
- closeSourceToOutputStorages();
- }
+ closeSourceToOutputStorages();
}
finally {
try {
@@ -161,13 +199,9 @@
}
public void flush(boolean memoryCachesOnly) {
- synchronized (myTargetStoragesLock) {
- myTargetStoragesOwner.flush(memoryCachesOnly);
- }
- synchronized (mySourceToOutputLock) {
- for (SourceToOutputMappingImpl mapping : mySourceToOutputs.values()) {
- mapping.flush(memoryCachesOnly);
- }
+ myTargetStoragesOwner.flush(memoryCachesOnly);
+ for (AtomicNotNullLazyValue<SourceToOutputMappingImpl> mapping : mySourceToOutputs.values()) {
+ mapping.getValue().flush(memoryCachesOnly);
}
mySrcToFormMap.flush(memoryCachesOnly);
final Mappings mappings = myMappings;
@@ -181,20 +215,16 @@
public void close() throws IOException {
try {
myTargetsState.save();
- synchronized (myTargetStoragesLock) {
- try {
- myTargetStoragesOwner.close();
- }
- finally {
- myTargetStorages.clear();
- }
+ try {
+ myTargetStoragesOwner.close();
+ }
+ finally {
+ myTargetStorages.clear();
}
}
finally {
try {
- synchronized (mySourceToOutputLock) {
- closeSourceToOutputStorages();
- }
+ closeSourceToOutputStorages();
}
finally {
try {
@@ -220,13 +250,11 @@
}
public void closeSourceToOutputStorages(Collection<BuildTargetChunk> chunks) throws IOException {
- synchronized (mySourceToOutputLock) {
- for (BuildTargetChunk chunk : chunks) {
- for (BuildTarget<?> target : chunk.getTargets()) {
- final SourceToOutputMappingImpl mapping = mySourceToOutputs.remove(target);
- if (mapping != null) {
- mapping.close();
- }
+ for (BuildTargetChunk chunk : chunks) {
+ for (BuildTarget<?> target : chunk.getTargets()) {
+ final AtomicNotNullLazyValue<SourceToOutputMappingImpl> mapping = mySourceToOutputs.remove(target);
+ if (mapping != null) {
+ mapping.getValue().close();
}
}
}
@@ -235,12 +263,12 @@
private void closeSourceToOutputStorages() throws IOException {
IOException ex = null;
try {
- for (SourceToOutputMappingImpl mapping : mySourceToOutputs.values()) {
+ for (AtomicNotNullLazyValue<SourceToOutputMappingImpl> mapping : mySourceToOutputs.values()) {
try {
- mapping.close();
+ mapping.getValue().close();
}
catch (IOException e) {
- if (e != null) {
+ if (ex == null) {
ex = e;
}
}
@@ -254,6 +282,31 @@
}
}
+ private static <K, V> V fetchValue(ConcurrentMap<K, AtomicNotNullLazyValue<V>> container, K key, final LazyValueFactory<K, V> valueFactory) throws IOException {
+ AtomicNotNullLazyValue<V> lazy = container.get(key);
+ if (lazy == null) {
+ final AtomicNotNullLazyValue<V> newValue = valueFactory.create(key);
+ lazy = container.putIfAbsent(key, newValue);
+ if (lazy == null) {
+ lazy = newValue; // just initialized
+ }
+ }
+ try {
+ return lazy.getValue();
+ }
+ catch (RuntimeException e) {
+ final Throwable cause = e.getCause();
+ if (cause instanceof IOException) {
+ throw (IOException)cause;
+ }
+ throw e;
+ }
+ }
+
+ private File getSourceToOutputMapRoot(BuildTarget<?> target) {
+ return new File(myDataPaths.getTargetDataRoot(target), "src-out");
+ }
+
private File getSourceToFormsRoot() {
return new File(myDataPaths.getDataStorageRoot(), SRC_TO_FORM_STORAGE);
}
diff --git a/jps/jps-builders/src/org/jetbrains/jps/javac/DiagnosticOutputConsumer.java b/jps/jps-builders/src/org/jetbrains/jps/javac/DiagnosticOutputConsumer.java
index ee42692..b24a832 100644
--- a/jps/jps-builders/src/org/jetbrains/jps/javac/DiagnosticOutputConsumer.java
+++ b/jps/jps-builders/src/org/jetbrains/jps/javac/DiagnosticOutputConsumer.java
@@ -16,6 +16,7 @@
package org.jetbrains.jps.javac;
import javax.tools.*;
+import java.io.File;
import java.util.Collection;
/**
@@ -25,4 +26,5 @@
public interface DiagnosticOutputConsumer extends DiagnosticListener<JavaFileObject> {
void outputLineAvailable(String line);
void registerImports(String className, Collection<String> imports, Collection<String> staticImports);
+ void javaFileLoaded(File file);
}
diff --git a/jps/jps-builders/src/org/jetbrains/jps/javac/JavacFileManager.java b/jps/jps-builders/src/org/jetbrains/jps/javac/JavacFileManager.java
index 03b9d41..ede1a77 100644
--- a/jps/jps-builders/src/org/jetbrains/jps/javac/JavacFileManager.java
+++ b/jps/jps-builders/src/org/jetbrains/jps/javac/JavacFileManager.java
@@ -61,6 +61,14 @@
myOutputsMap = outputDirToSrcRoots;
}
+ @Override
+ public String inferBinaryName(Location location, JavaFileObject file) {
+ return super.inferBinaryName(
+ location,
+ file instanceof TransformableJavaFileObject? ((TransformableJavaFileObject)file).getOriginal() : file
+ );
+ }
+
public void setLocation(Location location, Iterable<? extends File> path) throws IOException{
getStdManager().setLocation(location, path);
}
diff --git a/jps/jps-builders/src/org/jetbrains/jps/javac/JavacMain.java b/jps/jps-builders/src/org/jetbrains/jps/javac/JavacMain.java
index 33e0475..fdf99ef 100644
--- a/jps/jps-builders/src/org/jetbrains/jps/javac/JavacMain.java
+++ b/jps/jps-builders/src/org/jetbrains/jps/javac/JavacMain.java
@@ -16,6 +16,7 @@
package org.jetbrains.jps.javac;
import com.intellij.openapi.util.SystemInfo;
+import com.intellij.util.SmartList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.api.CanceledStatus;
import org.jetbrains.jps.builders.java.JavaSourceTransformer;
@@ -50,7 +51,7 @@
Collection<File> platformClasspath,
Collection<File> sourcePath,
Map<File, Set<File>> outputDirToRoots,
- final DiagnosticOutputConsumer outConsumer,
+ final DiagnosticOutputConsumer diagnosticConsumer,
final OutputFileConsumer outputSink,
CanceledStatus canceledStatus, boolean useEclipseCompiler) {
JavaCompiler compiler = null;
@@ -60,7 +61,7 @@
break;
}
if (compiler == null) {
- outConsumer.report(new PlainMessageDiagnostic(Diagnostic.Kind.ERROR, "Eclipse Batch Compiler was not found in classpath"));
+ diagnosticConsumer.report(new PlainMessageDiagnostic(Diagnostic.Kind.ERROR, "Eclipse Batch Compiler was not found in classpath"));
return false;
}
}
@@ -69,7 +70,7 @@
if (compiler == null) {
compiler = ToolProvider.getSystemJavaCompiler();
if (compiler == null) {
- outConsumer.report(new PlainMessageDiagnostic(Diagnostic.Kind.ERROR, "System Java Compiler was not found in classpath"));
+ diagnosticConsumer.report(new PlainMessageDiagnostic(Diagnostic.Kind.ERROR, "System Java Compiler was not found in classpath"));
return false;
}
nowUsingJavac = true;
@@ -84,7 +85,7 @@
final List<JavaSourceTransformer> transformers = getSourceTransformers();
- final JavacFileManager fileManager = new JavacFileManager(new ContextImpl(compiler, outConsumer, outputSink, canceledStatus, nowUsingJavac), transformers);
+ final JavacFileManager fileManager = new JavacFileManager(new ContextImpl(compiler, diagnosticConsumer, outputSink, canceledStatus, nowUsingJavac), transformers);
fileManager.handleOption("-bootclasspath", Collections.singleton("").iterator()); // this will clear cached stuff
fileManager.handleOption("-extdirs", Collections.singleton("").iterator()); // this will clear cached stuff
@@ -136,7 +137,7 @@
final LineOutputWriter out = new LineOutputWriter() {
protected void lineAvailable(String line) {
if (nowUsingJavac) {
- outConsumer.outputLineAvailable(line);
+ diagnosticConsumer.outputLineAvailable(line);
}
else {
// todo: filter too verbose eclipse output?
@@ -154,7 +155,7 @@
}
final JavaCompiler.CompilationTask task = compiler.getTask(
- out, fileManager, outConsumer, _options, null, fileManager.getJavaFileObjectsFromFiles(sources)
+ out, fileManager, diagnosticConsumer, _options, null, fileManager.getJavaFileObjectsFromFiles(sources)
);
//if (!IS_VM_6_VERSION) { //todo!
@@ -166,10 +167,10 @@
return task.call();
}
catch(IllegalArgumentException e) {
- outConsumer.report(new PlainMessageDiagnostic(Diagnostic.Kind.ERROR, e.getMessage()));
+ diagnosticConsumer.report(new PlainMessageDiagnostic(Diagnostic.Kind.ERROR, e.getMessage()));
}
catch (CompilationCanceledException ignored) {
- outConsumer.report(new PlainMessageDiagnostic(Diagnostic.Kind.OTHER, "Compilation was canceled"));
+ diagnosticConsumer.report(new PlainMessageDiagnostic(Diagnostic.Kind.OTHER, "Compilation was canceled"));
}
finally {
fileManager.close();
@@ -183,7 +184,7 @@
private static List<JavaSourceTransformer> getSourceTransformers() {
final Class<JavaSourceTransformer> transformerClass = JavaSourceTransformer.class;
final ServiceLoader<JavaSourceTransformer> loader = ServiceLoader.load(transformerClass, transformerClass.getClassLoader());
- final List<JavaSourceTransformer> transformers = new ArrayList<JavaSourceTransformer>();
+ final List<JavaSourceTransformer> transformers = new SmartList<JavaSourceTransformer>();
for (JavaSourceTransformer t : loader) {
transformers.add(t);
}
@@ -211,7 +212,6 @@
private static Collection<String> prepareOptions(final Collection<String> options, boolean usingJavac) {
final List<String> result = new ArrayList<String>();
if (usingJavac) {
- result.add("-Xprefer:source");
result.add("-implicit:class"); // the option supported by javac only
}
else { // is Eclipse
diff --git a/jps/jps-builders/src/org/jetbrains/jps/javac/JavacProtoUtil.java b/jps/jps-builders/src/org/jetbrains/jps/javac/JavacProtoUtil.java
index 23d0756..7feb5b8 100644
--- a/jps/jps-builders/src/org/jetbrains/jps/javac/JavacProtoUtil.java
+++ b/jps/jps-builders/src/org/jetbrains/jps/javac/JavacProtoUtil.java
@@ -101,6 +101,17 @@
return builder.build();
}
+ public static JavacRemoteProto.Message.Response createSourceFileLoadedResponse(File srcFile) {
+
+ final JavacRemoteProto.Message.Response.OutputObject outObjMsg = JavacRemoteProto.Message.Response.OutputObject.newBuilder()
+ .setKind(convertKind(JavaFileObject.Kind.SOURCE)).setFilePath(FileUtil.toSystemIndependentName(srcFile.getPath())).build();
+
+ final JavacRemoteProto.Message.Response.Builder builder = JavacRemoteProto.Message.Response.newBuilder();
+ builder.setResponseType(JavacRemoteProto.Message.Response.Type.SRC_FILE_LOADED).setOutputObject(outObjMsg);
+
+ return builder.build();
+ }
+
public static JavacRemoteProto.Message.Response createClassDataResponse(String className, Collection<String> imports, Collection<String> staticImports) {
final JavacRemoteProto.Message.Response.ClassData.Builder msgBuilder = JavacRemoteProto.Message.Response.ClassData.newBuilder();
msgBuilder.setClassName(className);
diff --git a/jps/jps-builders/src/org/jetbrains/jps/javac/JavacRemoteProto.java b/jps/jps-builders/src/org/jetbrains/jps/javac/JavacRemoteProto.java
index 87317f2..e16704d 100644
--- a/jps/jps-builders/src/org/jetbrains/jps/javac/JavacRemoteProto.java
+++ b/jps/jps-builders/src/org/jetbrains/jps/javac/JavacRemoteProto.java
@@ -3694,6 +3694,10 @@
* <code>REQUEST_ACK = 5;</code>
*/
REQUEST_ACK(4, 5),
+ /**
+ * <code>SRC_FILE_LOADED = 6;</code>
+ */
+ SRC_FILE_LOADED(5, 6),
;
/**
@@ -3716,6 +3720,10 @@
* <code>REQUEST_ACK = 5;</code>
*/
public static final int REQUEST_ACK_VALUE = 5;
+ /**
+ * <code>SRC_FILE_LOADED = 6;</code>
+ */
+ public static final int SRC_FILE_LOADED_VALUE = 6;
public final int getNumber() { return value; }
@@ -3727,6 +3735,7 @@
case 3: return CLASS_DATA;
case 4: return BUILD_COMPLETED;
case 5: return REQUEST_ACK;
+ case 6: return SRC_FILE_LOADED;
default: return null;
}
}
diff --git a/jps/jps-builders/src/org/jetbrains/jps/javac/JavacServer.java b/jps/jps-builders/src/org/jetbrains/jps/javac/JavacServer.java
index 359e151..76a6fe9 100644
--- a/jps/jps-builders/src/org/jetbrains/jps/javac/JavacServer.java
+++ b/jps/jps-builders/src/org/jetbrains/jps/javac/JavacServer.java
@@ -127,6 +127,11 @@
Map<File, Set<File>> outs,
final CanceledStatus canceledStatus) {
final DiagnosticOutputConsumer diagnostic = new DiagnosticOutputConsumer() {
+ @Override
+ public void javaFileLoaded(File file) {
+ Channels.write(ctx.getChannel(), JavacProtoUtil.toMessage(sessionId, JavacProtoUtil.createSourceFileLoadedResponse(file)));
+ }
+
public void outputLineAvailable(String line) {
Channels.write(ctx.getChannel(), JavacProtoUtil.toMessage(sessionId, JavacProtoUtil.createStdOutputResponse(line)));
}
diff --git a/jps/jps-builders/src/org/jetbrains/jps/javac/JavacServerResponseHandler.java b/jps/jps-builders/src/org/jetbrains/jps/javac/JavacServerResponseHandler.java
index a9d2173..6f06bca 100644
--- a/jps/jps-builders/src/org/jetbrains/jps/javac/JavacServerResponseHandler.java
+++ b/jps/jps-builders/src/org/jetbrains/jps/javac/JavacServerResponseHandler.java
@@ -99,6 +99,13 @@
myOutputSink.save(fileObject);
return false;
}
+
+ if (responseType == JavacRemoteProto.Message.Response.Type.SRC_FILE_LOADED) {
+ final JavacRemoteProto.Message.Response.OutputObject outputObject = response.getOutputObject();
+ final File file = new File(outputObject.getFilePath());
+ myDiagnosticSink.javaFileLoaded(file);
+ return false;
+ }
if (responseType == JavacRemoteProto.Message.Response.Type.CLASS_DATA) {
final JavacRemoteProto.Message.Response.ClassData data = response.getClassData();
diff --git a/jps/jps-builders/src/org/jetbrains/jps/javac/TransformableJavaFileObject.java b/jps/jps-builders/src/org/jetbrains/jps/javac/TransformableJavaFileObject.java
index 673b6e3..e44aa5f 100644
--- a/jps/jps-builders/src/org/jetbrains/jps/javac/TransformableJavaFileObject.java
+++ b/jps/jps-builders/src/org/jetbrains/jps/javac/TransformableJavaFileObject.java
@@ -38,6 +38,10 @@
myTransformers = transformers;
}
+ public JavaFileObject getOriginal() {
+ return myOriginal;
+ }
+
@Override
public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
// todo: cache transformed content?
@@ -108,4 +112,10 @@
public boolean delete() {
return myOriginal.delete();
}
+
+ @Override
+ public final String toString() {
+ // must implement like this because toString() is called inside com.sun.tools.javac.jvm.ClassWriter instead of getName()
+ return getName();
+ }
}
diff --git a/jps/jps-builders/testSrc/org/jetbrains/ether/MarkDirtyTest.java b/jps/jps-builders/testSrc/org/jetbrains/ether/MarkDirtyTest.java
index 6e605db..4fe9694 100644
--- a/jps/jps-builders/testSrc/org/jetbrains/ether/MarkDirtyTest.java
+++ b/jps/jps-builders/testSrc/org/jetbrains/ether/MarkDirtyTest.java
@@ -54,6 +54,6 @@
}
public void testRecompileTwinDependencies() {
- doTest().assertSuccessful();
+ doTest().assertFailed();
}
}
diff --git a/jps/jps-builders/testSrc/org/jetbrains/jps/builders/BuildResult.java b/jps/jps-builders/testSrc/org/jetbrains/jps/builders/BuildResult.java
index 0df6ded..1dc08ba 100644
--- a/jps/jps-builders/testSrc/org/jetbrains/jps/builders/BuildResult.java
+++ b/jps/jps-builders/testSrc/org/jetbrains/jps/builders/BuildResult.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -24,7 +24,6 @@
import org.jetbrains.jps.incremental.messages.DoneSomethingNotification;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
/**
@@ -78,12 +77,9 @@
}
@NotNull
- public List<BuildMessage> getErrorMessages() {
- return Collections.unmodifiableList(myErrorMessages);
- }
-
- @NotNull
- public List<BuildMessage> getWarnMessages() {
- return myWarnMessages;
+ public List<BuildMessage> getMessages(@NotNull BuildMessage.Kind kind) {
+ if (kind == BuildMessage.Kind.ERROR) return myErrorMessages;
+ else if (kind == BuildMessage.Kind.WARNING) return myWarnMessages;
+ else return myInfoMessages;
}
}
diff --git a/jps/jps-builders/testSrc/org/jetbrains/jps/builders/CompileScopeTestBuilder.java b/jps/jps-builders/testSrc/org/jetbrains/jps/builders/CompileScopeTestBuilder.java
index 0d1c0af..73f1e3e 100644
--- a/jps/jps-builders/testSrc/org/jetbrains/jps/builders/CompileScopeTestBuilder.java
+++ b/jps/jps-builders/testSrc/org/jetbrains/jps/builders/CompileScopeTestBuilder.java
@@ -26,10 +26,7 @@
import org.jetbrains.jps.model.module.JpsModule;
import java.io.File;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
+import java.util.*;
/**
* @author nik
@@ -76,6 +73,11 @@
return this;
}
+ public CompileScopeTestBuilder targetTypes(BuildTargetType<?>... targets) {
+ myTargetTypes.addAll(Arrays.asList(targets));
+ return this;
+ }
+
public CompileScope build() {
Collection<BuildTargetType<?>> typesToForceBuild = myForceBuild ? myTargetTypes : Collections.<BuildTargetType<?>>emptyList();
return new CompileScopeImpl(myTargetTypes, typesToForceBuild, myTargets, Collections.<BuildTarget<?>,Set<File>>emptyMap());
diff --git a/jps/jps-builders/testSrc/org/jetbrains/jps/builders/JpsBuildTestCase.java b/jps/jps-builders/testSrc/org/jetbrains/jps/builders/JpsBuildTestCase.java
index 5e353c9..6241b04 100644
--- a/jps/jps-builders/testSrc/org/jetbrains/jps/builders/JpsBuildTestCase.java
+++ b/jps/jps-builders/testSrc/org/jetbrains/jps/builders/JpsBuildTestCase.java
@@ -290,7 +290,7 @@
}
protected BuildResult doBuild(final ProjectDescriptor descriptor, CompileScopeTestBuilder scopeBuilder) {
- IncProjectBuilder builder = new IncProjectBuilder(descriptor, BuilderRegistry.getInstance(), myBuildParams, CanceledStatus.NULL, null);
+ IncProjectBuilder builder = new IncProjectBuilder(descriptor, BuilderRegistry.getInstance(), myBuildParams, CanceledStatus.NULL, null, true);
BuildResult result = new BuildResult();
builder.addMessageHandler(result);
try {
diff --git a/jps/model-serialization/src/com/intellij/openapi/components/PathMacroMap.java b/jps/model-serialization/src/com/intellij/openapi/components/PathMacroMap.java
index c0484d6..05dc780 100644
--- a/jps/model-serialization/src/com/intellij/openapi/components/PathMacroMap.java
+++ b/jps/model-serialization/src/com/intellij/openapi/components/PathMacroMap.java
@@ -22,6 +22,7 @@
import org.jdom.Comment;
import org.jdom.Element;
import org.jdom.Text;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
@@ -36,11 +37,11 @@
public abstract String substitute(String text, boolean caseSensitive);
- public final void substitute(Element e, boolean caseSensitive) {
+ public final void substitute(@NotNull Element e, boolean caseSensitive) {
substitute(e, caseSensitive, false);
}
- public final void substitute(Element e, boolean caseSensitive, final boolean recursively,
+ public final void substitute(@NotNull Element e, boolean caseSensitive, final boolean recursively,
@Nullable PathMacroFilter filter) {
List content = e.getContent();
//noinspection ForLoopReplaceableByForEach
@@ -77,7 +78,7 @@
}
}
- public final void substitute(Element e, boolean caseSensitive, final boolean recursively) {
+ public final void substitute(@NotNull Element e, boolean caseSensitive, final boolean recursively) {
substitute(e, caseSensitive, recursively, null);
}
diff --git a/lib/jdom.jar b/lib/jdom.jar
index 2173e13..09d8845 100644
--- a/lib/jdom.jar
+++ b/lib/jdom.jar
Binary files differ
diff --git a/lib/src/jdom.zip b/lib/src/jdom.zip
index 412f7d0..73cef55 100644
--- a/lib/src/jdom.zip
+++ b/lib/src/jdom.zip
Binary files differ
diff --git a/native/fsNotifier/linux/inotify.c b/native/fsNotifier/linux/inotify.c
index 444a5bf..77536dc 100644
--- a/native/fsNotifier/linux/inotify.c
+++ b/native/fsNotifier/linux/inotify.c
@@ -305,14 +305,17 @@
struct stat st;
if (stat(root, &st) != 0) {
- if (errno == EACCES) {
- return ERR_IGNORE;
- }
- else if (errno == ENOENT) {
+ if (errno == ENOENT) {
return ERR_MISSING;
}
- userlog(LOG_ERR, "stat(%s): %s", root, strerror(errno));
- return ERR_ABORT;
+ else if (errno == EACCES || errno == ELOOP || errno == ENAMETOOLONG || errno == ENOTDIR) {
+ userlog(LOG_INFO, "stat(%s): %s", root, strerror(errno));
+ return ERR_CONTINUE;
+ }
+ else {
+ userlog(LOG_ERR, "stat(%s): %s", root, strerror(errno));
+ return ERR_ABORT;
+ }
}
if (S_ISREG(st.st_mode)) {
diff --git a/native/fsNotifier/linux/main.c b/native/fsNotifier/linux/main.c
index de87fad..3cd65e2 100644
--- a/native/fsNotifier/linux/main.c
+++ b/native/fsNotifier/linux/main.c
@@ -36,7 +36,7 @@
#define LOG_ENV_ERROR "error"
#define LOG_ENV_OFF "off"
-#define VERSION "20130415.2136"
+#define VERSION "20130617.1935"
#define VERSION_MSG "fsnotifier " VERSION "\n"
#define USAGE_MSG \
@@ -73,8 +73,8 @@
static void init_log();
static void run_self_test();
-static void main_loop();
-static bool read_input();
+static bool main_loop();
+static int read_input();
static bool update_roots(array* new_roots);
static void unregister_roots();
static bool register_roots(array* new_roots, array* unwatchable, array* mounts);
@@ -116,12 +116,15 @@
setvbuf(stdin, NULL, _IONBF, 0);
+ int rv = 0;
roots = array_create(20);
- if (init_inotify() && roots != NULL) {
+ if (roots != NULL && init_inotify()) {
set_inotify_callback(&inotify_callback);
if (!self_test) {
- main_loop();
+ if (!main_loop()) {
+ rv = 3;
+ }
}
else {
run_self_test();
@@ -131,14 +134,15 @@
}
else {
output("GIVEUP\n");
+ rv = 2;
}
close_inotify();
array_delete(roots);
- userlog(LOG_INFO, "finished");
+ userlog(LOG_INFO, "finished (%d)", rv);
closelog();
- return 0;
+ return rv;
}
@@ -216,7 +220,7 @@
}
-static void main_loop() {
+static bool main_loop() {
int input_fd = fileno(stdin), inotify_fd = get_inotify_fd();
int nfds = (inotify_fd > input_fd ? inotify_fd : input_fd) + 1;
fd_set rfds;
@@ -233,14 +237,16 @@
if (select(nfds, &rfds, NULL, NULL, &timeout) < 0) {
if (errno != EINTR) {
userlog(LOG_ERR, "select: %s", strerror(errno));
- break;
+ return false;
}
}
else if (FD_ISSET(input_fd, &rfds)) {
- if (!read_input()) break;
+ int result = read_input();
+ if (result == 0) return true;
+ else if (result != ERR_CONTINUE) return false;
}
else if (FD_ISSET(inotify_fd, &rfds)) {
- if (!process_inotify_input()) break;
+ if (!process_inotify_input()) return false;
}
else {
check_missing_roots();
@@ -249,24 +255,24 @@
}
-static bool read_input() {
+static int read_input() {
char* line = read_line(stdin);
userlog(LOG_DEBUG, "input: %s", (line ? line : "<null>"));
if (line == NULL || strcmp(line, "EXIT") == 0) {
userlog(LOG_INFO, "exiting: %s", line);
- return false;
+ return 0;
}
if (strcmp(line, "ROOTS") == 0) {
array* new_roots = array_create(20);
- CHECK_NULL(new_roots, false);
+ CHECK_NULL(new_roots, ERR_ABORT);
while (1) {
line = read_line(stdin);
userlog(LOG_DEBUG, "input: %s", (line ? line : "<null>"));
if (line == NULL || strlen(line) == 0) {
- return false;
+ return 0;
}
else if (strcmp(line, "#") == 0) {
break;
@@ -274,15 +280,15 @@
else {
int l = strlen(line);
if (l > 1 && line[l-1] == '/') line[l-1] = '\0';
- CHECK_NULL(array_push(new_roots, strdup(line)), false);
+ CHECK_NULL(array_push(new_roots, strdup(line)), ERR_ABORT);
}
}
- return update_roots(new_roots);
+ return update_roots(new_roots) ? ERR_CONTINUE : ERR_ABORT;
}
- userlog(LOG_INFO, "unrecognised command: %s", line);
- return true;
+ userlog(LOG_WARNING, "unrecognised command: %s", line);
+ return ERR_CONTINUE;
}
diff --git a/platform/analysis-api/src/com/intellij/codeHighlighting/HighlightDisplayLevel.java b/platform/analysis-api/src/com/intellij/codeHighlighting/HighlightDisplayLevel.java
index 34133f6..f8cd9d7 100644
--- a/platform/analysis-api/src/com/intellij/codeHighlighting/HighlightDisplayLevel.java
+++ b/platform/analysis-api/src/com/intellij/codeHighlighting/HighlightDisplayLevel.java
@@ -18,6 +18,7 @@
import com.intellij.lang.annotation.HighlightSeverity;
import com.intellij.openapi.editor.colors.CodeInsightColors;
import com.intellij.openapi.editor.colors.TextAttributesKey;
+import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.util.Comparing;
@@ -111,7 +112,9 @@
private static Icon createIconByMask(@NotNull TextAttributesKey key) {
Icon icon = createIconByMaskFromExtensions(key);
if (icon != null) return icon;
- return createIconByMask(key.getDefaultAttributes().getErrorStripeColor());
+ TextAttributes defaultAttributes = key.getDefaultAttributes();
+ if (defaultAttributes == null) defaultAttributes = TextAttributes.ERASE_MARKER;
+ return createIconByMask(defaultAttributes.getErrorStripeColor());
}
public interface IconCreator {
diff --git a/platform/analysis-api/src/com/intellij/codeInspection/GlobalInspectionTool.java b/platform/analysis-api/src/com/intellij/codeInspection/GlobalInspectionTool.java
index 807eca1..5e72c93 100644
--- a/platform/analysis-api/src/com/intellij/codeInspection/GlobalInspectionTool.java
+++ b/platform/analysis-api/src/com/intellij/codeInspection/GlobalInspectionTool.java
@@ -197,4 +197,7 @@
public boolean worksInBatchModeOnly() {
return true;
}
+
+ public void initialize(@NotNull GlobalInspectionContext context) {
+ }
}
diff --git a/platform/analysis-api/src/com/intellij/codeInspection/InspectionManager.java b/platform/analysis-api/src/com/intellij/codeInspection/InspectionManager.java
index 2d5b03b..406dc3c 100644
--- a/platform/analysis-api/src/com/intellij/codeInspection/InspectionManager.java
+++ b/platform/analysis-api/src/com/intellij/codeInspection/InspectionManager.java
@@ -16,7 +16,9 @@
package com.intellij.codeInspection;
import com.intellij.openapi.components.ServiceManager;
+import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NonNls;
@@ -28,6 +30,7 @@
*/
public abstract class InspectionManager {
@NonNls public static final String INSPECTION_GROUP_ID = "Inspections"; // for use in notifications
+ public static final ExtensionPointName<Condition<PsiElement>> CANT_BE_STATIC_EXTENSION = ExtensionPointName.create("com.intellij.cantBeStatic");
public static InspectionManager getInstance(Project project) {
return ServiceManager.getService(project, InspectionManager.class);
diff --git a/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfile.java b/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfile.java
index 9ae0333..f46a5cd 100644
--- a/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfile.java
+++ b/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfile.java
@@ -18,6 +18,8 @@
import com.intellij.codeHighlighting.HighlightDisplayLevel;
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
+import com.intellij.codeInspection.ex.InspectionToolWrapper;
+import com.intellij.codeInspection.ex.Tools;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import com.intellij.profile.Profile;
@@ -26,6 +28,8 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import java.util.List;
+
/**
* User: anna
* Date: Dec 7, 2004
@@ -37,10 +41,10 @@
/**
* If you need to modify tool's settings, please use {@link #modifyToolSettings}
*/
- InspectionProfileEntry getInspectionTool(@NotNull String shortName, @NotNull PsiElement element);
+ InspectionToolWrapper getInspectionTool(@NotNull String shortName, @NotNull PsiElement element);
@Nullable
- InspectionProfileEntry getInspectionTool(@NotNull String shortName);
+ InspectionToolWrapper getInspectionTool(@NotNull String shortName, Project project);
/** Returns (unwrapped) inspection */
InspectionProfileEntry getUnwrappedTool(@NotNull String shortName, @NotNull PsiElement element);
@@ -61,16 +65,16 @@
* @since 12.1
*/
<T extends InspectionProfileEntry>
- void modifyToolSettings(Key<T> shortNameKey, @NotNull PsiElement psiElement, Consumer<T> toolConsumer);
+ void modifyToolSettings(@NotNull Key<T> shortNameKey, @NotNull PsiElement psiElement, @NotNull Consumer<T> toolConsumer);
/**
* @param element context element
* @return all (both enabled and disabled) tools
*/
@NotNull
- InspectionProfileEntry[] getInspectionTools(@Nullable PsiElement element);
+ InspectionToolWrapper[] getInspectionTools(@Nullable PsiElement element);
- void cleanup(Project project);
+ void cleanup(@NotNull Project project);
/**
* @see #modifyProfile(com.intellij.util.Consumer)
@@ -82,7 +86,7 @@
boolean isToolEnabled(HighlightDisplayKey key);
- boolean isExecutable();
+ boolean isExecutable(Project project);
boolean isEditable();
@@ -90,4 +94,7 @@
String getDisplayName();
void scopesChanged();
+
+ @NotNull
+ List<Tools> getAllEnabledInspectionTools(Project project);
}
diff --git a/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfileEntry.java b/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfileEntry.java
index d0664f0..da8b135 100644
--- a/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfileEntry.java
+++ b/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfileEntry.java
@@ -56,6 +56,10 @@
private static final Object BLACK_LIST_LOCK = new Object();
private Boolean myUseNewSerializer = null;
+ public void cleanup() {
+
+ }
+
interface DefaultNameProvider {
@Nullable String getDefaultShortName();
@Nullable String getDefaultDisplayName();
@@ -239,6 +243,7 @@
}
}
+ @NotNull
public static Collection<String> getBlackList() {
synchronized (BLACK_LIST_LOCK) {
if (ourBlackList == null) {
@@ -266,7 +271,7 @@
* @param project to be associated with this entry
* @deprecated this won't work for inspections configured via {@link com.intellij.codeInspection.InspectionEP}
*/
- public void projectOpened(Project project) {
+ public void projectOpened(@NotNull Project project) {
}
/**
@@ -275,7 +280,7 @@
* @param project to be disassociated from this entry
* @deprecated this won't work for inspections configured via {@link com.intellij.codeInspection.InspectionEP}
*/
- public void projectClosed(Project project) {
+ public void projectClosed(@NotNull Project project) {
}
/**
@@ -300,6 +305,7 @@
return ResourceUtil.getResource(getDescriptionContextClass(), "/inspectionDescriptions", fileName);
}
+ @NotNull
protected Class<? extends InspectionProfileEntry> getDescriptionContextClass() {
return getClass();
}
diff --git a/platform/analysis-api/src/com/intellij/codeInspection/LocalInspectionTool.java b/platform/analysis-api/src/com/intellij/codeInspection/LocalInspectionTool.java
index ef85342..db7d8c4 100644
--- a/platform/analysis-api/src/com/intellij/codeInspection/LocalInspectionTool.java
+++ b/platform/analysis-api/src/com/intellij/codeInspection/LocalInspectionTool.java
@@ -16,16 +16,15 @@
package com.intellij.codeInspection;
import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiElementVisitor;
-import com.intellij.psi.PsiFile;
-import com.intellij.psi.PsiNamedElement;
+import com.intellij.psi.*;
import org.intellij.lang.annotations.Language;
import org.intellij.lang.annotations.Pattern;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import java.util.List;
+
/**
* @author max
*/
@@ -172,4 +171,29 @@
@Deprecated()
public void inspectionFinished(@NotNull LocalInspectionToolSession session) {}
+ @NotNull
+ public List<ProblemDescriptor> processFile(@NotNull PsiFile file,
+ @NotNull InspectionManager manager) {
+ final ProblemsHolder holder = new ProblemsHolder(manager, file, false);
+ LocalInspectionToolSession session = new LocalInspectionToolSession(file, 0, file.getTextLength());
+ final PsiElementVisitor customVisitor = buildVisitor(holder, false, session);
+ LOG.assertTrue(!(customVisitor instanceof PsiRecursiveElementVisitor),
+ "The visitor returned from LocalInspectionTool.buildVisitor() must not be recursive");
+
+ inspectionStarted(session, false);
+
+ file.accept(new PsiRecursiveElementWalkingVisitor() {
+ @Override
+ public void visitElement(PsiElement element) {
+ element.accept(customVisitor);
+ super.visitElement(element);
+ }
+ });
+
+ inspectionFinished(session, holder);
+
+ return holder.getResults();
+ }
+
+
}
diff --git a/platform/analysis-api/src/com/intellij/codeInspection/ModifiableModel.java b/platform/analysis-api/src/com/intellij/codeInspection/ModifiableModel.java
index 4cb8997..bdaf567 100644
--- a/platform/analysis-api/src/com/intellij/codeInspection/ModifiableModel.java
+++ b/platform/analysis-api/src/com/intellij/codeInspection/ModifiableModel.java
@@ -18,6 +18,8 @@
import com.intellij.codeHighlighting.HighlightDisplayLevel;
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
+import com.intellij.codeInspection.ex.InspectionToolWrapper;
+import com.intellij.openapi.project.Project;
import com.intellij.profile.Profile;
import com.intellij.psi.PsiElement;
import com.intellij.psi.search.scope.packageSet.NamedScope;
@@ -39,11 +41,11 @@
void setBaseProfile(InspectionProfile profile);
- void enableTool(String inspectionTool, NamedScope namedScope);
+ void enableTool(String inspectionTool, NamedScope namedScope, Project project);
- void disableTool(String inspectionTool, NamedScope namedScope);
+ void disableTool(String inspectionTool, NamedScope namedScope, @NotNull Project project);
- void setErrorLevel(HighlightDisplayKey key, @NotNull HighlightDisplayLevel level);
+ void setErrorLevel(HighlightDisplayKey key, @NotNull HighlightDisplayLevel level, Project project);
HighlightDisplayLevel getErrorLevel(HighlightDisplayKey inspectionToolKey, PsiElement element);
@@ -57,24 +59,21 @@
void setModified(final boolean toolsSettingsChanged);
- @Deprecated
- boolean isProperSetting(HighlightDisplayKey key);
+ boolean isProperSetting(@NotNull String toolId);
- boolean isProperSetting(String toolId);
+ void resetToBase(Project project);
- void resetToBase();
-
- void resetToEmpty();
+ void resetToEmpty(Project project);
/**
* @return {@link com.intellij.codeInspection.ex.InspectionToolWrapper}
* @see #getUnwrappedTool(String, com.intellij.psi.PsiElement)
*/
- InspectionProfileEntry getInspectionTool(String shortName, PsiElement element);
+ InspectionToolWrapper getInspectionTool(String shortName, PsiElement element);
InspectionProfileEntry getUnwrappedTool(@NotNull String shortName, @NotNull PsiElement element);
- InspectionProfileEntry[] getInspectionTools(PsiElement element);
+ InspectionToolWrapper[] getInspectionTools(PsiElement element);
void copyFrom(InspectionProfile profile);
@@ -86,7 +85,7 @@
void lockProfile(boolean isLocked);
- void disableTool(String toolId, PsiElement element);
+ void disableTool(@NotNull String toolId, @NotNull PsiElement element);
- void disableTool(String inspectionTool);
+ void disableTool(String inspectionTool, Project project);
}
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionToolWrapper.java b/platform/analysis-api/src/com/intellij/codeInspection/ex/InspectionToolWrapper.java
similarity index 69%
rename from platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionToolWrapper.java
rename to platform/analysis-api/src/com/intellij/codeInspection/ex/InspectionToolWrapper.java
index 36443ce..0b98381 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionToolWrapper.java
+++ b/platform/analysis-api/src/com/intellij/codeInspection/ex/InspectionToolWrapper.java
@@ -16,28 +16,30 @@
package com.intellij.codeInspection.ex;
import com.intellij.codeHighlighting.HighlightDisplayLevel;
-import com.intellij.codeInspection.*;
+import com.intellij.codeInspection.GlobalInspectionContext;
+import com.intellij.codeInspection.InspectionEP;
+import com.intellij.codeInspection.InspectionProfileEntry;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.InvalidDataException;
-import com.intellij.openapi.util.WriteExternalException;
-import com.intellij.util.Function;
-import com.intellij.util.containers.ContainerUtil;
-import org.jdom.Element;
+import com.intellij.util.ResourceUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import javax.swing.*;
+import java.io.IOException;
import java.net.URL;
/**
* @author Dmitry Avdeev
* Date: 9/28/11
*/
-public abstract class InspectionToolWrapper<T extends InspectionProfileEntry, E extends InspectionEP> extends DescriptorProviderInspection {
+public abstract class InspectionToolWrapper<T extends InspectionProfileEntry, E extends InspectionEP> {
+ private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.ex.InspectionToolWrapper");
+
protected T myTool;
protected final E myEP;
+ private GlobalInspectionContext myContext;
protected InspectionToolWrapper(@NotNull E ep) {
this(null, ep);
@@ -58,7 +60,17 @@
myEP = other.myEP;
// we need to create a copy for buffering
//noinspection unchecked
- myTool = other.myTool == null ? null : (T)InspectionToolRegistrar.instantiateTool(other.myTool.getClass());
+ myTool = other.myTool == null ? null : (T)InspectionToolsRegistrarCore.instantiateTool(other.myTool.getClass());
+ }
+
+ public void initialize(@NotNull GlobalInspectionContext context) {
+ myContext = context;
+ projectOpened(context.getProject());
+ }
+
+ @NotNull
+ public GlobalInspectionContext getContext() {
+ return myContext;
}
@NotNull
@@ -76,7 +88,6 @@
return myTool;
}
- @Override
public boolean isInitialized() {
return myTool != null;
}
@@ -91,13 +102,11 @@
}
@NotNull
- @Override
public String getShortName() {
return myEP != null ? myEP.getShortName() : getTool().getShortName();
}
@NotNull
- @Override
public String getDisplayName() {
if (myEP == null) {
return getTool().getDisplayName();
@@ -109,7 +118,6 @@
}
@NotNull
- @Override
public String getGroupDisplayName() {
if (myEP == null) {
return getTool().getGroupDisplayName();
@@ -120,19 +128,16 @@
}
}
- @Override
public boolean isEnabledByDefault() {
return myEP == null ? getTool().isEnabledByDefault() : myEP.enabledByDefault;
}
@NotNull
- @Override
public HighlightDisplayLevel getDefaultLevel() {
return myEP == null ? getTool().getDefaultLevel() : myEP.getDefaultLevel();
}
@NotNull
- @Override
public String[] getGroupPath() {
if (myEP == null) {
return getTool().getGroupPath();
@@ -143,74 +148,65 @@
}
}
- @Override
- public void readSettings(@NotNull Element element) throws InvalidDataException {
- getTool().readSettings(element);
- }
-
- @Override
- public void writeSettings(@NotNull Element element) throws WriteExternalException {
- getTool().writeSettings(element);
- }
-
- @Override
- public JComponent createOptionsPanel() {
- return getTool().createOptionsPanel();
- }
-
- @Override
- public void projectOpened(Project project) {
+ public void projectOpened(@NotNull Project project) {
if (myEP == null) {
getTool().projectOpened(project);
}
}
- @Override
- public void projectClosed(Project project) {
+ public void projectClosed(@NotNull Project project) {
if (myEP == null) {
getTool().projectClosed(project);
}
}
- @Override
public String getStaticDescription() {
return myEP == null || myEP.hasStaticDescription ? getTool().getStaticDescription() : null;
}
- @Override
+ public String loadDescription() {
+ final String description = getStaticDescription();
+ if (description != null) return description;
+ try {
+ URL descriptionUrl = getDescriptionUrl();
+ if (descriptionUrl == null) return null;
+ return ResourceUtil.loadText(descriptionUrl);
+ }
+ catch (IOException ignored) { }
+
+ return getTool().loadDescription();
+ }
+
protected URL getDescriptionUrl() {
Application app = ApplicationManager.getApplication();
if (myEP == null || app.isUnitTestMode() || app.isHeadlessEnvironment()) {
- return super.getDescriptionUrl();
+ return superGetDescriptionUrl();
}
String fileName = getDescriptionFileName();
return myEP.getLoaderForClass().getResource("/inspectionDescriptions/" + fileName);
}
- @Override
- public SuppressIntentionAction[] getSuppressActions() {
- T tool = getTool();
- if (tool instanceof CustomSuppressableInspectionTool) {
- return ((CustomSuppressableInspectionTool)tool).getSuppressActions(null);
- }
- if (tool instanceof BatchSuppressableTool) {
- LocalQuickFix[] actions = ((BatchSuppressableTool)tool).getBatchSuppressActions(null);
- return ContainerUtil.map2Array(actions, SuppressIntentionAction.class, new Function<LocalQuickFix, SuppressIntentionAction>() {
- @Override
- public SuppressIntentionAction fun(final LocalQuickFix fix) {
- return InspectionManagerEx.convertBatchToSuppressIntentionAction((SuppressQuickFix)fix);
- }
- });
- }
- return super.getSuppressActions();
+ @Nullable
+ protected URL superGetDescriptionUrl() {
+ final String fileName = getDescriptionFileName();
+ return ResourceUtil.getResource(getDescriptionContextClass(), "/inspectionDescriptions", fileName);
}
- @Override
+ @NotNull
+ public String getDescriptionFileName() {
+ return getShortName() + ".html";
+ }
+
+ @NotNull
+ public final String getFolderName() {
+ return getShortName();
+ }
+
+ @NotNull
public Class<? extends InspectionProfileEntry> getDescriptionContextClass() {
return getTool().getClass();
}
- @Override
public String getMainToolId() {
return getTool().getMainToolId();
}
@@ -223,4 +219,15 @@
public String toString() {
return getShortName();
}
+
+ public void cleanup() {
+ myContext = null;
+ T tool = myTool;
+ if (tool != null) {
+ tool.cleanup();
+ }
+ }
+
+ @NotNull
+ public abstract JobDescriptor[] getJobDescriptors(@NotNull GlobalInspectionContext context);
}
diff --git a/platform/analysis-api/src/com/intellij/codeInspection/ex/InspectionToolsRegistrarCore.java b/platform/analysis-api/src/com/intellij/codeInspection/ex/InspectionToolsRegistrarCore.java
new file mode 100644
index 0000000..7d2ffb7
--- /dev/null
+++ b/platform/analysis-api/src/com/intellij/codeInspection/ex/InspectionToolsRegistrarCore.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2000-2013 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.codeInspection.ex;
+
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.util.ArrayUtil;
+import org.jetbrains.annotations.NotNull;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+public class InspectionToolsRegistrarCore {
+ private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.ex.InspectionToolsRegistrarCore");
+ static Object instantiateTool(@NotNull Class<?> toolClass) {
+ try {
+ Constructor<?> constructor = toolClass.getDeclaredConstructor(ArrayUtil.EMPTY_CLASS_ARRAY);
+ constructor.setAccessible(true);
+ return constructor.newInstance(ArrayUtil.EMPTY_OBJECT_ARRAY);
+ }
+ catch (SecurityException e) {
+ LOG.error(e);
+ }
+ catch (NoSuchMethodException e) {
+ LOG.error(e);
+ }
+ catch (InstantiationException e) {
+ LOG.error(e);
+ }
+ catch (IllegalAccessException e) {
+ LOG.error(e);
+ }
+ catch (IllegalArgumentException e) {
+ LOG.error(e);
+ }
+ catch (InvocationTargetException e) {
+ LOG.error(e);
+ }
+
+ return null;
+ }
+}
diff --git a/platform/analysis-api/src/com/intellij/codeInspection/ex/ScopeToolState.java b/platform/analysis-api/src/com/intellij/codeInspection/ex/ScopeToolState.java
index 6498af5..e82cbe6 100644
--- a/platform/analysis-api/src/com/intellij/codeInspection/ex/ScopeToolState.java
+++ b/platform/analysis-api/src/com/intellij/codeInspection/ex/ScopeToolState.java
@@ -21,7 +21,6 @@
package com.intellij.codeInspection.ex;
import com.intellij.codeHighlighting.HighlightDisplayLevel;
-import com.intellij.codeInspection.InspectionProfileEntry;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.JDOMUtil;
@@ -39,21 +38,21 @@
private NamedScope myScope;
@NotNull
private final String myScopeName;
- private InspectionProfileEntry myTool;
+ private InspectionToolWrapper myToolWrapper;
private boolean myEnabled;
private HighlightDisplayLevel myLevel;
private JComponent myAdditionalConfigPanel;
private static final Logger LOG = Logger.getInstance("#" + ScopeToolState.class.getName());
- public ScopeToolState(@NotNull NamedScope scope, @NotNull InspectionProfileEntry tool, boolean enabled, @NotNull HighlightDisplayLevel level) {
- this(scope.getName(), tool, enabled, level);
+ public ScopeToolState(@NotNull NamedScope scope, @NotNull InspectionToolWrapper toolWrapper, boolean enabled, @NotNull HighlightDisplayLevel level) {
+ this(scope.getName(), toolWrapper, enabled, level);
myScope = scope;
}
- public ScopeToolState(@NotNull String scopeName, @NotNull InspectionProfileEntry tool, boolean enabled, @NotNull HighlightDisplayLevel level) {
+ public ScopeToolState(@NotNull String scopeName, @NotNull InspectionToolWrapper toolWrapper, boolean enabled, @NotNull HighlightDisplayLevel level) {
myScopeName = scopeName;
- myTool = tool;
+ myToolWrapper = toolWrapper;
myEnabled = enabled;
myLevel = level;
}
@@ -74,8 +73,8 @@
}
@NotNull
- public InspectionProfileEntry getTool() {
- return myTool;
+ public InspectionToolWrapper getTool() {
+ return myToolWrapper;
}
public boolean isEnabled() {
@@ -95,40 +94,37 @@
myLevel = level;
}
- @Nullable
+ @NotNull
public JComponent getAdditionalConfigPanel() {
- if (myAdditionalConfigPanel == null){
- myAdditionalConfigPanel = myTool.createOptionsPanel();
+ if (myAdditionalConfigPanel == null) {
+ myAdditionalConfigPanel = myToolWrapper.getTool().createOptionsPanel();
if (myAdditionalConfigPanel == null){
myAdditionalConfigPanel = new JPanel();
}
- return myAdditionalConfigPanel;
}
return myAdditionalConfigPanel;
}
-
-
public void resetConfigPanel(){
myAdditionalConfigPanel = null;
}
- public void setTool(@NotNull InspectionProfileEntry tool) {
- myTool = tool;
+ public void setTool(@NotNull InspectionToolWrapper tool) {
+ myToolWrapper = tool;
}
- public boolean equalTo(ScopeToolState state2) {
+ public boolean equalTo(@NotNull ScopeToolState state2) {
if (isEnabled() != state2.isEnabled()) return false;
if (getLevel() != state2.getLevel()) return false;
- InspectionProfileEntry tool = getTool();
- InspectionProfileEntry tool2 = state2.getTool();
- if (!tool.isInitialized() && !tool2.isInitialized()) return true;
+ InspectionToolWrapper toolWrapper = getTool();
+ InspectionToolWrapper toolWrapper2 = state2.getTool();
+ if (!toolWrapper.isInitialized() && !toolWrapper2.isInitialized()) return true;
try {
@NonNls String tempRoot = "root";
Element oldToolSettings = new Element(tempRoot);
- tool.writeSettings(oldToolSettings);
+ toolWrapper.getTool().writeSettings(oldToolSettings);
Element newToolSettings = new Element(tempRoot);
- tool2.writeSettings(newToolSettings);
+ toolWrapper2.getTool().writeSettings(newToolSettings);
return JDOMUtil.areElementsEqual(oldToolSettings, newToolSettings);
}
catch (WriteExternalException e) {
diff --git a/platform/analysis-api/src/com/intellij/codeInspection/ex/Tools.java b/platform/analysis-api/src/com/intellij/codeInspection/ex/Tools.java
index af05b3e..8f91945 100644
--- a/platform/analysis-api/src/com/intellij/codeInspection/ex/Tools.java
+++ b/platform/analysis-api/src/com/intellij/codeInspection/ex/Tools.java
@@ -20,7 +20,6 @@
*/
package com.intellij.codeInspection.ex;
-import com.intellij.codeInspection.InspectionProfileEntry;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -28,13 +27,14 @@
import java.util.List;
public interface Tools {
- InspectionProfileEntry getInspectionTool(PsiElement element);
+ @NotNull
+ InspectionToolWrapper getInspectionTool(PsiElement element);
@NotNull
String getShortName();
@NotNull
- InspectionProfileEntry getTool();
+ InspectionToolWrapper getTool();
@NotNull
List<ScopeToolState> getTools();
@@ -47,5 +47,5 @@
boolean isEnabled(@Nullable PsiElement element);
@Nullable
- InspectionProfileEntry getEnabledTool(@Nullable PsiElement element);
+ InspectionToolWrapper getEnabledTool(@Nullable PsiElement element);
}
\ No newline at end of file
diff --git a/platform/analysis-api/src/com/intellij/codeInspection/lang/GlobalInspectionContextExtension.java b/platform/analysis-api/src/com/intellij/codeInspection/lang/GlobalInspectionContextExtension.java
index 3dd66c0..f42507f 100644
--- a/platform/analysis-api/src/com/intellij/codeInspection/lang/GlobalInspectionContextExtension.java
+++ b/platform/analysis-api/src/com/intellij/codeInspection/lang/GlobalInspectionContextExtension.java
@@ -21,7 +21,7 @@
package com.intellij.codeInspection.lang;
import com.intellij.codeInspection.GlobalInspectionContext;
-import com.intellij.codeInspection.InspectionProfileEntry;
+import com.intellij.codeInspection.ex.InspectionToolWrapper;
import com.intellij.codeInspection.ex.Tools;
import com.intellij.openapi.util.Key;
import org.jetbrains.annotations.NotNull;
@@ -35,8 +35,7 @@
void performPreRunActivities(@NotNull List<Tools> globalTools,
@NotNull List<Tools> localTools,
@NotNull GlobalInspectionContext context);
- //InspectionToolWrapper
- void performPostRunActivities(@NotNull List<InspectionProfileEntry> inspections, @NotNull GlobalInspectionContext context);
+ void performPostRunActivities(@NotNull List<InspectionToolWrapper> inspections, @NotNull GlobalInspectionContext context);
void cleanup();
}
diff --git a/platform/analysis-api/src/com/intellij/codeInspection/lang/InspectionExtensionsFactory.java b/platform/analysis-api/src/com/intellij/codeInspection/lang/InspectionExtensionsFactory.java
index a8e7b79..fc7f9c3 100644
--- a/platform/analysis-api/src/com/intellij/codeInspection/lang/InspectionExtensionsFactory.java
+++ b/platform/analysis-api/src/com/intellij/codeInspection/lang/InspectionExtensionsFactory.java
@@ -25,6 +25,7 @@
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public abstract class InspectionExtensionsFactory {
@@ -42,6 +43,6 @@
@Nullable
public abstract String getSuppressedInspectionIdsIn(PsiElement element);
- public abstract boolean isProjectConfiguredToRunInspections(Project project, boolean online);
+ public abstract boolean isProjectConfiguredToRunInspections(@NotNull Project project, boolean online);
}
diff --git a/platform/analysis-api/src/com/intellij/codeInspection/lang/RefManagerExtension.java b/platform/analysis-api/src/com/intellij/codeInspection/lang/RefManagerExtension.java
index f129b53..12691a0 100644
--- a/platform/analysis-api/src/com/intellij/codeInspection/lang/RefManagerExtension.java
+++ b/platform/analysis-api/src/com/intellij/codeInspection/lang/RefManagerExtension.java
@@ -52,7 +52,8 @@
@Nullable
String getType(RefEntity entity);
- RefEntity getRefinedElement(final RefEntity ref);
+ @NotNull
+ RefEntity getRefinedElement(@NotNull RefEntity ref);
void visitElement(final PsiElement element);
@@ -61,7 +62,7 @@
boolean belongsToScope(final PsiElement psiElement);
- void export(final RefEntity refEntity, final Element element);
+ void export(@NotNull RefEntity refEntity, @NotNull Element element);
void onEntityInitialized(RefElement refEntity, PsiElement psiElement);
}
diff --git a/platform/analysis-api/src/com/intellij/codeInspection/reference/RefEntity.java b/platform/analysis-api/src/com/intellij/codeInspection/reference/RefEntity.java
index 0b3923a..3c7d660 100644
--- a/platform/analysis-api/src/com/intellij/codeInspection/reference/RefEntity.java
+++ b/platform/analysis-api/src/com/intellij/codeInspection/reference/RefEntity.java
@@ -30,6 +30,8 @@
* @see RefManager
*/
public interface RefEntity extends UserDataHolder {
+ RefEntity[] EMPTY_ELEMENTS_ARRAY = new RefEntity[0];
+
/**
* Returns the name of the node.
*
diff --git a/platform/analysis-api/src/com/intellij/codeInspection/reference/RefManager.java b/platform/analysis-api/src/com/intellij/codeInspection/reference/RefManager.java
index fd3fc5f..6f0a3c2 100644
--- a/platform/analysis-api/src/com/intellij/codeInspection/reference/RefManager.java
+++ b/platform/analysis-api/src/com/intellij/codeInspection/reference/RefManager.java
@@ -103,9 +103,10 @@
@Nullable
public abstract String getType(final RefEntity ref);
- public abstract RefEntity getRefinedElement(final RefEntity ref);
+ @NotNull
+ public abstract RefEntity getRefinedElement(@NotNull RefEntity ref);
- public abstract Element export(RefEntity entity, Element element, final int actualLine);
+ public abstract Element export(@NotNull RefEntity entity, @NotNull Element element, final int actualLine);
@Nullable
public abstract String getGroupName(final RefElement entity);
@@ -114,7 +115,7 @@
public abstract String getQualifiedName(RefEntity refEntity);
- public abstract void removeRefElement(RefElement refElement, List<RefElement> deletedRefs);
+ public abstract void removeRefElement(@NotNull RefElement refElement, @NotNull List<RefElement> deletedRefs);
@NotNull
public abstract PsiManager getPsiManager();
diff --git a/platform/analysis-api/src/com/intellij/codeInspection/reference/RefUtil.java b/platform/analysis-api/src/com/intellij/codeInspection/reference/RefUtil.java
index a2ac4aa..1790f70 100644
--- a/platform/analysis-api/src/com/intellij/codeInspection/reference/RefUtil.java
+++ b/platform/analysis-api/src/com/intellij/codeInspection/reference/RefUtil.java
@@ -17,7 +17,11 @@
import com.intellij.codeInsight.daemon.ImplicitUsageProvider;
import com.intellij.openapi.extensions.Extensions;
+import com.intellij.openapi.util.Comparing;
import com.intellij.psi.PsiElement;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Collection;
/**
* Application component which provides utility methods for working with the reference
@@ -36,4 +40,13 @@
}
return false;
}
+
+ public static boolean contains(RefEntity element, @NotNull Collection<RefEntity> entities){
+ for (RefEntity refEntity : entities) {
+ if (Comparing.equal(refEntity, element)) {
+ return true;
+ }
+ }
+ return false;
+ }
}
diff --git a/platform/analysis-api/src/com/intellij/lang/annotation/ProblemGroup.java b/platform/analysis-api/src/com/intellij/lang/annotation/ProblemGroup.java
index d778e7f..585d087 100644
--- a/platform/analysis-api/src/com/intellij/lang/annotation/ProblemGroup.java
+++ b/platform/analysis-api/src/com/intellij/lang/annotation/ProblemGroup.java
@@ -15,10 +15,13 @@
*/
package com.intellij.lang.annotation;
+import org.jetbrains.annotations.Nullable;
+
/**
* Unique object, which is the same for all of the problems of some group.
* It is used to split some inspection to several fake inspections
*/
public interface ProblemGroup {
+ @Nullable
String getProblemName();
}
diff --git a/platform/analysis-api/src/com/intellij/profile/DefaultProjectProfileManager.java b/platform/analysis-api/src/com/intellij/profile/DefaultProjectProfileManager.java
index 1ccdade..4e116fc 100644
--- a/platform/analysis-api/src/com/intellij/profile/DefaultProjectProfileManager.java
+++ b/platform/analysis-api/src/com/intellij/profile/DefaultProjectProfileManager.java
@@ -49,6 +49,7 @@
private static final String VERSION = "1.0";
+ @NotNull
protected final Project myProject;
/** This field is used for serialization. Do not rename it or make access weaker */
@@ -63,12 +64,12 @@
private final List<ProfileChangeAdapter> myProfilesListener = ContainerUtil.createLockFreeCopyOnWriteList();
@NonNls private static final String PROJECT_DEFAULT_PROFILE_NAME = "Project Default";
- public DefaultProjectProfileManager(final Project project, final ApplicationProfileManager applicationProfileManager,
- final DependencyValidationManager holder) {
+ public DefaultProjectProfileManager(@NotNull final Project project,
+ @NotNull ApplicationProfileManager applicationProfileManager,
+ @NotNull DependencyValidationManager holder) {
myProject = project;
myHolder = holder;
myApplicationProfileManager = applicationProfileManager;
- LOG.assertTrue(myApplicationProfileManager != null);
}
@NotNull
@@ -127,8 +128,8 @@
public synchronized void writeExternal(Element element) throws WriteExternalException {
final List<String> sortedProfiles = new ArrayList<String>(myProfiles.keySet());
- Element profiles = null;
Collections.sort(sortedProfiles);
+ Element profiles = null;
for (String profile : sortedProfiles) {
final Profile projectProfile = myProfiles.get(profile);
if (projectProfile != null) {
@@ -227,7 +228,7 @@
return profile;
}
- public void addProfilesListener(final ProfileChangeAdapter profilesListener, Disposable parent) {
+ public void addProfilesListener(@NotNull final ProfileChangeAdapter profilesListener, @NotNull Disposable parent) {
myProfilesListener.add(profilesListener);
Disposer.register(parent, new Disposable() {
@Override
@@ -237,7 +238,7 @@
});
}
- public void removeProfilesListener(ProfileChangeAdapter profilesListener) {
+ public void removeProfilesListener(@NotNull ProfileChangeAdapter profilesListener) {
myProfilesListener.remove(profilesListener);
}
@@ -299,4 +300,14 @@
}
}
+ protected void fireProfilesInitialized() {
+ for (ProfileChangeAdapter profileChangeAdapter : myProfilesListener) {
+ profileChangeAdapter.profilesInitialized();
+ }
+ }
+ protected void fireProfilesShutdown() {
+ for (ProfileChangeAdapter profileChangeAdapter : myProfilesListener) {
+ profileChangeAdapter.profilesShutdown();
+ }
+ }
}
diff --git a/platform/analysis-api/src/com/intellij/profile/Profile.java b/platform/analysis-api/src/com/intellij/profile/Profile.java
index 0b16551..ad4c4bc 100644
--- a/platform/analysis-api/src/com/intellij/profile/Profile.java
+++ b/platform/analysis-api/src/com/intellij/profile/Profile.java
@@ -31,6 +31,8 @@
boolean isLocal();
void setName(@NotNull String name);
+ @NotNull
+ String getName();
void setProfileManager(@NotNull ProfileManager profileManager);
@NotNull
diff --git a/platform/analysis-api/src/com/intellij/profile/ProfileChangeAdapter.java b/platform/analysis-api/src/com/intellij/profile/ProfileChangeAdapter.java
index 540ef02..7e77e3d 100644
--- a/platform/analysis-api/src/com/intellij/profile/ProfileChangeAdapter.java
+++ b/platform/analysis-api/src/com/intellij/profile/ProfileChangeAdapter.java
@@ -15,11 +15,15 @@
*/
package com.intellij.profile;
+import org.jetbrains.annotations.NotNull;
+
/**
* User: anna
* Date: 20-Nov-2005
*/
public abstract class ProfileChangeAdapter {
public void profileChanged(Profile profile){}
- public void profileActivated(Profile oldProfile, Profile profile){}
+ public void profileActivated(@NotNull Profile oldProfile, Profile profile){}
+ public void profilesInitialized() {}
+ public void profilesShutdown(){}
}
diff --git a/platform/analysis-api/src/com/intellij/psi/search/scope/packageSet/FilePatternPackageSet.java b/platform/analysis-api/src/com/intellij/psi/search/scope/packageSet/FilePatternPackageSet.java
index b2d0d5b..89aee72 100644
--- a/platform/analysis-api/src/com/intellij/psi/search/scope/packageSet/FilePatternPackageSet.java
+++ b/platform/analysis-api/src/com/intellij/psi/search/scope/packageSet/FilePatternPackageSet.java
@@ -75,7 +75,7 @@
@Override
public boolean contains(VirtualFile file, @NotNull Project project, @Nullable NamedScopesHolder holder) {
ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
- return file != null && fileMatcher(file, fileIndex, holder.getProjectBaseDir()) &&
+ return file != null && fileMatcher(file, fileIndex, holder != null ? holder.getProjectBaseDir() : project.getBaseDir()) &&
matchesModule(myModuleGroupPattern, myModulePattern, file, fileIndex);
}
diff --git a/platform/analysis-api/src/com/intellij/psi/search/scope/packageSet/NamedScopesHolder.java b/platform/analysis-api/src/com/intellij/psi/search/scope/packageSet/NamedScopesHolder.java
index 887cb71..58e66d9 100644
--- a/platform/analysis-api/src/com/intellij/psi/search/scope/packageSet/NamedScopesHolder.java
+++ b/platform/analysis-api/src/com/intellij/psi/search/scope/packageSet/NamedScopesHolder.java
@@ -112,6 +112,7 @@
return null;
}
+ @NotNull
public static NamedScopesHolder[] getAllNamedScopeHolders(@NotNull Project project) {
NamedScopesHolder[] holders = new NamedScopesHolder[2];
holders [0] = NamedScopeManager.getInstance(project);
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/InspectionProfileConvertor.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/InspectionProfileConvertor.java
similarity index 86%
rename from platform/lang-impl/src/com/intellij/codeInsight/daemon/InspectionProfileConvertor.java
rename to platform/analysis-impl/src/com/intellij/codeInsight/daemon/InspectionProfileConvertor.java
index 8406428..e683b79 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/InspectionProfileConvertor.java
+++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/InspectionProfileConvertor.java
@@ -18,19 +18,19 @@
import com.intellij.codeHighlighting.HighlightDisplayLevel;
import com.intellij.codeInspection.InspectionProfile;
-import com.intellij.codeInspection.InspectionProfileEntry;
import com.intellij.codeInspection.ModifiableModel;
-import com.intellij.codeInspection.ex.InspectionProfileImpl;
+import com.intellij.codeInspection.ex.InspectionToolWrapper;
import com.intellij.lang.annotation.HighlightSeverity;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.JDOMUtil;
import com.intellij.profile.codeInspection.InspectionProfileManager;
-import com.intellij.profile.codeInspection.InspectionProfileManagerImpl;
+import com.intellij.profile.codeInspection.SeverityProvider;
import com.intellij.util.SystemProperties;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
@@ -68,7 +68,7 @@
renameOldDefaultsProfile();
}
- private boolean retrieveOldSettings(Element element) {
+ private boolean retrieveOldSettings(@NotNull Element element) {
boolean hasOldSettings = false;
for (final Object obj : element.getChildren(OPTION_TAG)) {
Element option = (Element)obj;
@@ -87,7 +87,7 @@
Element e = (Element)o;
String key = e.getName();
String levelName = e.getAttributeValue(LEVEL_ATT);
- HighlightSeverity severity = ((InspectionProfileManagerImpl)myManager).getSeverityRegistrar().getSeverity(levelName);
+ HighlightSeverity severity = ((SeverityProvider)myManager).getSeverityRegistrar().getSeverity(levelName);
HighlightDisplayLevel level = severity == null ? null : HighlightDisplayLevel.find(severity);
if (level == null) continue;
myDisplayLevelMap.put(key, level);
@@ -97,9 +97,8 @@
return false;
}
- public void storeEditorHighlightingProfile(Element element) {
+ public void storeEditorHighlightingProfile(@NotNull Element element, @NotNull InspectionProfile editorProfile) {
if (retrieveOldSettings(element)) {
- final InspectionProfileImpl editorProfile = new InspectionProfileImpl(OLD_HIGHTLIGHTING_SETTINGS_PROFILE);
final ModifiableModel editorProfileModel = editorProfile.getModifiableModel();
@@ -116,9 +115,9 @@
public static Element convertToNewFormat(Element profileFile, InspectionProfile profile) throws IOException, JDOMException {
Element rootElement = new Element(INSPECTIONS_TAG);
rootElement.setAttribute(NAME_ATT, profile.getName());
- final InspectionProfileEntry[] tools = profile.getInspectionTools(null);
+ final InspectionToolWrapper[] tools = profile.getInspectionTools(null);
for (final Object o : profileFile.getChildren(INSP_TOOL_TAG)) {
- Element toolElement = (Element)((Element)o).clone();
+ Element toolElement = ((Element)o).clone();
String toolClassName = toolElement.getAttributeValue(CLASS_ATT);
final String shortName = convertToShortName(toolClassName, tools);
if (shortName == null) {
@@ -162,8 +161,8 @@
}
protected void fillErrorLevels(final ModifiableModel profile) {
- InspectionProfileEntry[] tools = profile.getInspectionTools(null);
- LOG.assertTrue(tools != null, "Profile was not correctly init");
+ InspectionToolWrapper[] toolWrappers = profile.getInspectionTools(null);
+ LOG.assertTrue(toolWrappers != null, "Profile was not correctly init");
//fill error levels
for (final String shortName : myDisplayLevelMap.keySet()) {
//key <-> short name
@@ -175,21 +174,21 @@
//set up tools for default profile
if (level != HighlightDisplayLevel.DO_NOT_SHOW) {
- profile.enableTool(shortName, null);
+ profile.enableTool(shortName, null, null);
}
if (level == null || level == HighlightDisplayLevel.DO_NOT_SHOW) {
level = HighlightDisplayLevel.WARNING;
}
- profile.setErrorLevel(key, level);
+ profile.setErrorLevel(key, level, null);
}
}
@Nullable
- private static String convertToShortName(String displayName, InspectionProfileEntry[] tools) {
+ private static String convertToShortName(String displayName, InspectionToolWrapper[] tools) {
if (displayName == null) return null;
- for (InspectionProfileEntry tool : tools) {
+ for (InspectionToolWrapper tool : tools) {
if (displayName.equals(tool.getDisplayName())) {
return tool.getShortName();
}
diff --git a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/Validator.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/Validator.java
index caa471a..a5b2ddd 100644
--- a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/Validator.java
+++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/Validator.java
@@ -17,6 +17,7 @@
package com.intellij.codeInsight.daemon;
import com.intellij.psi.PsiElement;
+import org.intellij.lang.annotations.MagicConstant;
import org.jetbrains.annotations.NotNull;
/**
@@ -32,10 +33,13 @@
WARNING, ERROR, INFO
}
- void addMessage(PsiElement context, String message, int type);
- void addMessage(PsiElement context, String message, ErrorType type);
+ /**
+ * @deprecated Use {@link #addMessage(PsiElement, String, ErrorType)} instead
+ */
+ void addMessage(PsiElement context, String message, @MagicConstant(intValues = {INFO, WARNING, ERROR}) int type);
+ void addMessage(PsiElement context, String message, @NotNull ErrorType type);
}
-
+
void validate(@NotNull T context,@NotNull ValidationHost host);
}
diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/ProblemDescriptorBase.java b/platform/analysis-impl/src/com/intellij/codeInspection/ProblemDescriptorBase.java
index cffbf55..a7286d5 100644
--- a/platform/analysis-impl/src/com/intellij/codeInspection/ProblemDescriptorBase.java
+++ b/platform/analysis-impl/src/com/intellij/codeInspection/ProblemDescriptorBase.java
@@ -126,7 +126,10 @@
TextRange textRange = getTextRange();
if (textRange == null) return -1;
textRange = manager.injectedToHost(psiElement, textRange);
- myLineNumber = document.getLineNumber(textRange.getStartOffset()) + 1;
+ final int startOffset = textRange.getStartOffset();
+ final int textLength = document.getTextLength();
+ LOG.assertTrue(startOffset <= textLength, getDescriptionTemplate() + " at " + startOffset + ", " + textLength);
+ myLineNumber = document.getLineNumber(startOffset) + 1;
}
return myLineNumber;
}
diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/ex/GlobalInspectionToolWrapper.java b/platform/analysis-impl/src/com/intellij/codeInspection/ex/GlobalInspectionToolWrapper.java
new file mode 100644
index 0000000..5fb8e94
--- /dev/null
+++ b/platform/analysis-impl/src/com/intellij/codeInspection/ex/GlobalInspectionToolWrapper.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2000-2013 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.codeInspection.ex;
+
+import com.intellij.codeInspection.GlobalInspectionContext;
+import com.intellij.codeInspection.GlobalInspectionTool;
+import com.intellij.codeInspection.InspectionEP;
+import com.intellij.codeInspection.reference.RefGraphAnnotator;
+import com.intellij.codeInspection.reference.RefManagerImpl;
+import com.intellij.util.ArrayUtil;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * User: anna
+ * Date: 28-Dec-2005
+ */
+public class GlobalInspectionToolWrapper extends InspectionToolWrapper<GlobalInspectionTool, InspectionEP> {
+ public GlobalInspectionToolWrapper(@NotNull GlobalInspectionTool globalInspectionTool) {
+ super(globalInspectionTool);
+ }
+
+ public GlobalInspectionToolWrapper(@NotNull InspectionEP ep) {
+ super(ep);
+ }
+
+ private GlobalInspectionToolWrapper(@NotNull GlobalInspectionToolWrapper other) {
+ super(other);
+ }
+
+ @NotNull
+ @Override
+ public GlobalInspectionToolWrapper createCopy() {
+ return new GlobalInspectionToolWrapper(this);
+ }
+
+ @Override
+ public void initialize(@NotNull GlobalInspectionContext context) {
+ super.initialize(context);
+ RefManagerImpl refManager = (RefManagerImpl)context.getRefManager();
+ final RefGraphAnnotator annotator = getTool().getAnnotator(refManager);
+ if (annotator != null) {
+ refManager.registerGraphAnnotator(annotator);
+ }
+ getTool().initialize(context);
+ }
+
+ @Override
+ @NotNull
+ public JobDescriptor[] getJobDescriptors(@NotNull GlobalInspectionContext context) {
+ final JobDescriptor[] additionalJobs = getTool().getAdditionalJobs();
+ if (additionalJobs == null) {
+ return getTool().isGraphNeeded() ? context.getStdJobDescriptors().BUILD_GRAPH_ONLY : JobDescriptor.EMPTY_ARRAY;
+ }
+ else {
+ return getTool().isGraphNeeded() ? ArrayUtil.append(additionalJobs, context.getStdJobDescriptors().BUILD_GRAPH) : additionalJobs;
+ }
+ }
+
+ public boolean worksInBatchModeOnly() {
+ return getTool().worksInBatchModeOnly();
+ }
+}
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java b/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java
similarity index 69%
rename from platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java
rename to platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java
index 7dd25d8..deae74c 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java
+++ b/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java
@@ -19,17 +19,18 @@
import com.intellij.codeHighlighting.HighlightDisplayLevel;
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
import com.intellij.codeInsight.daemon.InspectionProfileConvertor;
-import com.intellij.codeInspection.*;
+import com.intellij.codeInspection.InspectionEP;
+import com.intellij.codeInspection.InspectionProfile;
+import com.intellij.codeInspection.InspectionProfileEntry;
+import com.intellij.codeInspection.ModifiableModel;
import com.intellij.ide.plugins.IdeaPluginDescriptorImpl;
import com.intellij.lang.annotation.HighlightSeverity;
import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.options.ExternalInfo;
import com.intellij.openapi.options.ExternalizableScheme;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.*;
import com.intellij.profile.DefaultProjectProfileManager;
import com.intellij.profile.ProfileEx;
@@ -58,13 +59,6 @@
public class InspectionProfileImpl extends ProfileEx implements ModifiableModel, InspectionProfile, ExternalizableScheme {
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.ex.InspectionProfileImpl");
@NonNls private static final String VALID_VERSION = "1.0";
- private static final Function<InspectionProfileEntry,InspectionToolWrapper> WRAPPER_FUNCTION =
- new Function<InspectionProfileEntry, InspectionToolWrapper>() {
- @Override
- public InspectionToolWrapper fun(@NotNull InspectionProfileEntry tool) {
- return InspectionToolRegistrar.wrapTool(tool);
- }
- };
private Map<String, ToolsImpl> myTools = new THashMap<String, ToolsImpl>();
@@ -80,7 +74,6 @@
@NonNls private static final String CLASS_TAG = "class";
@NonNls private static final String PROFILE_NAME_TAG = "profile_name";
@NonNls private static final String ROOT_ELEMENT_TAG = "inspections";
- @NonNls static final String SCOPE = "scope";
private String myEnabledTool = null;
@NonNls private static final String USED_LEVELS = "used_levels";
@@ -88,7 +81,6 @@
final InspectionToolRegistrar myRegistrar;
@NonNls private static final String IS_LOCKED = "is_locked";
private final ExternalInfo myExternalInfo = new ExternalInfo();
- static final String NAME = "name";
public static boolean INIT_INSPECTIONS = false;
@Override
@@ -132,24 +124,27 @@
}
@NotNull
- public static InspectionProfileImpl createSimple(@NotNull String name, @NotNull final InspectionProfileEntry... tools) {
- InspectionProfileImpl profile = new InspectionProfileImpl(name, new InspectionToolRegistrar(null) {
+ public static InspectionProfileImpl createSimple(@NotNull String name,
+ @NotNull Project project,
+ @NotNull final InspectionToolWrapper... toolWrappers) {
+ InspectionToolRegistrar registrar = new InspectionToolRegistrar() {
@NotNull
@Override
public List<InspectionToolWrapper> createTools() {
- return ContainerUtil.map(tools, WRAPPER_FUNCTION);
+ return Arrays.asList(toolWrappers);
}
- }, InspectionProfileManager.getInstance());
+ };
+ InspectionProfileImpl profile = new InspectionProfileImpl(name, registrar, InspectionProfileManager.getInstance());
boolean init = INIT_INSPECTIONS;
try {
INIT_INSPECTIONS = true;
- profile.initialize(null);
+ profile.initialize(project);
}
finally {
INIT_INSPECTIONS = init;
}
- for (InspectionProfileEntry tool : tools) {
- profile.enableTool(tool.getShortName());
+ for (InspectionToolWrapper toolWrapper : toolWrappers) {
+ profile.enableTool(toolWrapper.getShortName(), project);
}
return profile;
}
@@ -178,50 +173,47 @@
}
private static boolean toolSettingsAreEqual(String toolName, @NotNull InspectionProfileImpl profile1, @NotNull InspectionProfileImpl profile2) {
- final ToolsImpl toolList1 = profile1.myTools.get(toolName);
- final ToolsImpl toolList2 = profile2.myTools.get(toolName);
+ final Tools toolList1 = profile1.myTools.get(toolName);
+ final Tools toolList2 = profile2.myTools.get(toolName);
return Comparing.equal(toolList1, toolList2);
}
@Override
- public boolean isProperSetting(@NotNull HighlightDisplayKey key) {
- return isProperSetting(key.toString());
- }
-
- @Override
- public boolean isProperSetting(String toolId) {
+ public boolean isProperSetting(@NotNull String toolId) {
if (myBaseProfile != null) {
- final ToolsImpl tools = myBaseProfile.getTools(toolId);
- final ToolsImpl currentTools = myTools.get(toolId);
+ final Tools tools = myBaseProfile.getTools(toolId, null);
+ final Tools currentTools = myTools.get(toolId);
return !Comparing.equal(tools, currentTools);
}
return false;
}
@Override
- public void resetToBase() {
- initInspectionTools(null);
+ public void resetToBase(Project project) {
+ initInspectionTools(project);
- copyToolsConfigurations(myBaseProfile, null);
+ copyToolsConfigurations(myBaseProfile, project);
myDisplayLevelMap = null;
}
@Override
- public void resetToEmpty() {
- final InspectionProfileEntry[] profileEntries = getInspectionTools(null);
- for (InspectionProfileEntry entry : profileEntries) {
- disableTool(entry.getShortName());
+ public void resetToEmpty(Project project) {
+ initInspectionTools(project);
+ final InspectionToolWrapper[] profileEntries = getInspectionTools(null);
+ for (InspectionToolWrapper toolWrapper : profileEntries) {
+ disableTool(toolWrapper.getShortName(), project);
}
}
@Override
public HighlightDisplayLevel getErrorLevel(@NotNull HighlightDisplayKey inspectionToolKey, PsiElement element) {
- final ToolsImpl tools = getTools(inspectionToolKey.toString());
+ Project project = element == null ? null : element.getProject();
+ final ToolsImpl tools = getTools(inspectionToolKey.toString(), project);
HighlightDisplayLevel level = tools != null ? tools.getLevel(element) : HighlightDisplayLevel.WARNING;
if (!((SeverityProvider)getProfileManager()).getOwnSeverityRegistrar().isSeverityValid(level.getSeverity().toString())) {
level = HighlightDisplayLevel.WARNING;
- setErrorLevel(inspectionToolKey, level);
+ setErrorLevel(inspectionToolKey, level, project);
}
return level;
}
@@ -258,7 +250,7 @@
for (final Object o : element.getChildren(INSPECTION_TOOL_TAG)) {
// make clone to avoid retaining memory via o.parent pointers
- Element toolElement = (Element)((Element)o).clone();
+ Element toolElement = ((Element)o).clone();
IdeaPluginDescriptorImpl.internJDOMElement(toolElement);
String toolClassName = toolElement.getAttributeValue(CLASS_TAG);
@@ -271,7 +263,7 @@
public Set<HighlightSeverity> getUsedSeverities() {
LOG.assertTrue(myInitialized);
final Set<HighlightSeverity> result = new HashSet<HighlightSeverity>();
- for (ToolsImpl tools : myTools.values()) {
+ for (Tools tools : myTools.values()) {
for (ScopeToolState state : tools.getTools()) {
result.add(state.getLevel().getSeverity());
}
@@ -289,7 +281,7 @@
synchronized (myExternalInfo) {
if (!myInitialized) {
for (Element el : myDeinstalledInspectionsSettings.values()) {
- element.addContent((Element)el.clone());
+ element.addContent(el.clone());
}
return;
}
@@ -315,22 +307,23 @@
element.addContent(inspectionElement);
}
else {
- element.addContent((Element)toolElement.clone());
+ element.addContent(toolElement.clone());
}
}
}
}
- public void collectDependentInspections(@NotNull InspectionProfileEntry profileEntry, @NotNull Set<InspectionProfileEntry> dependentEntries) {
- String mainToolId = profileEntry.getMainToolId();
+ public void collectDependentInspections(@NotNull InspectionToolWrapper toolWrapper,
+ @NotNull Set<InspectionToolWrapper> dependentEntries,
+ Project project) {
+ String mainToolId = toolWrapper.getMainToolId();
if (mainToolId != null) {
- InspectionProfileEntry dependentEntry = getInspectionTool(mainToolId);
+ InspectionToolWrapper dependentEntryWrapper = getInspectionTool(mainToolId, project);
- if (dependentEntry != null) {
- if (!dependentEntries.contains(dependentEntry)) {
- dependentEntries.add(dependentEntry);
- collectDependentInspections(dependentEntry, dependentEntries);
+ if (dependentEntryWrapper != null) {
+ if (!dependentEntries.add(dependentEntryWrapper)) {
+ collectDependentInspections(dependentEntryWrapper, dependentEntries, project);
}
}
else {
@@ -341,16 +334,16 @@
@Override
@Nullable
- public InspectionProfileEntry getInspectionTool(@NotNull String shortName, @NotNull PsiElement element) {
- final Tools toolList = getTools(shortName);
- return toolList != null ? toolList.getInspectionTool(element) : null;
+ public InspectionToolWrapper getInspectionTool(@NotNull String shortName, @NotNull PsiElement element) {
+ final Tools toolList = getTools(shortName, element.getProject());
+ return toolList == null ? null : toolList.getInspectionTool(element);
}
@Nullable
@Override
public InspectionProfileEntry getUnwrappedTool(@NotNull String shortName, @NotNull PsiElement element) {
- InspectionProfileEntry tool = getInspectionTool(shortName, element);
- return tool instanceof InspectionToolWrapper ? ((InspectionToolWrapper)tool).getTool() : tool;
+ InspectionToolWrapper tool = getInspectionTool(shortName, element);
+ return tool == null ? null : tool.getTool();
}
@Override
@@ -387,15 +380,15 @@
@Override
@Nullable
- public InspectionProfileEntry getInspectionTool(@NotNull String shortName) {
- final ToolsImpl tools = getTools(shortName);
+ public InspectionToolWrapper getInspectionTool(@NotNull String shortName, Project project) {
+ final ToolsImpl tools = getTools(shortName, project);
return tools != null? tools.getTool() : null;
}
- public InspectionProfileEntry getToolById(@NotNull String id, @NotNull PsiElement element) {
+ public InspectionToolWrapper getToolById(@NotNull String id, @NotNull PsiElement element) {
initInspectionTools(element.getProject());
for (Tools toolList : myTools.values()) {
- final InspectionProfileEntry tool = toolList.getInspectionTool(element);
+ final InspectionToolWrapper tool = toolList.getInspectionTool(element);
String toolId =
tool instanceof LocalInspectionToolWrapper ? ((LocalInspectionToolWrapper)tool).getID() : tool.getShortName();
if (id.equals(toolId)) return tool;
@@ -421,7 +414,7 @@
@Override
public void scopesChanged() {
- for (ScopeToolState toolState : getAllTools()) {
+ for (ScopeToolState toolState : getAllTools(null)) {
toolState.scopesChanged();
}
InspectionProfileManager.getInstance().fireProfileChanged(this);
@@ -432,21 +425,6 @@
myEnabledTool = displayName;
}
- public void load(@NotNull Element element) {
- try {
- readExternal(element);
- }
- catch (Exception e) {
- ApplicationManager.getApplication().invokeLater(new Runnable() {
- @Override
- public void run() {
- Messages.showErrorDialog(InspectionsBundle.message("inspection.error.loading.message", 0, getName()),
- InspectionsBundle.message("inspection.errors.occurred.dialog.title"));
- }
- }, ModalityState.NON_MODAL);
- }
- }
-
@Override
public boolean isProfileLocked() {
return myLockedProfile;
@@ -459,18 +437,20 @@
@Override
@NotNull
- public InspectionProfileEntry[] getInspectionTools(@Nullable PsiElement element) {
- initInspectionTools(element != null ? element.getProject() : null);
- List<InspectionTool> result = new ArrayList<InspectionTool>();
+ public InspectionToolWrapper[] getInspectionTools(@Nullable PsiElement element) {
+ initInspectionTools(element == null ? null : element.getProject());
+ List<InspectionToolWrapper> result = new ArrayList<InspectionToolWrapper>();
for (Tools toolList : myTools.values()) {
- result.add((InspectionTool)toolList.getInspectionTool(element));
+ result.add(toolList.getInspectionTool(element));
}
- return result.toArray(new InspectionTool[result.size()]);
+ return result.toArray(new InspectionToolWrapper[result.size()]);
}
- public List<ToolsImpl> getAllEnabledInspectionTools(Project project) {
+ @Override
+ @NotNull
+ public List<Tools> getAllEnabledInspectionTools(Project project) {
initInspectionTools(project);
- final ArrayList<ToolsImpl> result = new ArrayList<ToolsImpl>();
+ List<Tools> result = new ArrayList<Tools>();
for (final ToolsImpl toolList : myTools.values()) {
if (toolList.isEnabled()) {
result.add(toolList);
@@ -480,21 +460,21 @@
}
@Override
- public void disableTool(String toolId, PsiElement element) {
- getTools(toolId).disableTool(element);
+ public void disableTool(@NotNull String toolId, @NotNull PsiElement element) {
+ getTools(toolId, element.getProject()).disableTool(element);
}
- public void disableToolByDefault(String toolId) {
- getToolDefaultState(toolId).setEnabled(false);
+ public void disableToolByDefault(String toolId, Project project) {
+ getToolDefaultState(toolId, project).setEnabled(false);
}
@NotNull
- public ScopeToolState getToolDefaultState(String toolId) {
- return getTools(toolId).getDefaultState();
+ public ScopeToolState getToolDefaultState(String toolId, Project project) {
+ return getTools(toolId, project).getDefaultState();
}
- public void enableToolByDefault(String toolId) {
- getToolDefaultState(toolId).setEnabled(true);
+ public void enableToolByDefault(String toolId, Project project) {
+ getToolDefaultState(toolId, project).setEnabled(true);
}
public boolean wasInitialized() {
@@ -517,25 +497,25 @@
final List<InspectionToolWrapper> tools;
try {
- tools = createTools();
+ tools = createTools(project);
}
catch (ProcessCanceledException e) {
return false;
}
- for (InspectionToolWrapper tool : tools) {
- final String shortName = tool.getShortName();
+ for (InspectionToolWrapper toolWrapper : tools) {
+ final String shortName = toolWrapper.getShortName();
HighlightDisplayKey key = HighlightDisplayKey.find(shortName);
if (key == null) {
- final InspectionEP extension = tool.getExtension();
- Computable<String> computable = extension == null ? new Computable.PredefinedValueComputable<String>(tool.getDisplayName()) : new Computable<String>() {
+ final InspectionEP extension = toolWrapper.getExtension();
+ Computable<String> computable = extension == null ? new Computable.PredefinedValueComputable<String>(toolWrapper.getDisplayName()) : new Computable<String>() {
@Override
public String compute() {
return extension.getDisplayName();
}
};
- if (tool instanceof LocalInspectionToolWrapper) {
- key = HighlightDisplayKey.register(shortName, computable, ((LocalInspectionToolWrapper)tool).getID(),
- ((LocalInspectionToolWrapper)tool).getAlternativeID());
+ if (toolWrapper instanceof LocalInspectionToolWrapper) {
+ key = HighlightDisplayKey.register(shortName, computable, ((LocalInspectionToolWrapper)toolWrapper).getID(),
+ ((LocalInspectionToolWrapper)toolWrapper).getAlternativeID());
}
else {
key = HighlightDisplayKey.register(shortName, computable);
@@ -543,19 +523,19 @@
}
LOG.assertTrue(key != null, shortName + " ; number of initialized tools: " + myTools.size());
- HighlightDisplayLevel level = myBaseProfile != null ? myBaseProfile.getErrorLevel(key) : tool.getDefaultLevel();
- boolean enabled = myBaseProfile != null ? myBaseProfile.isToolEnabled(key) : tool.isEnabledByDefault();
- final ToolsImpl toolsList = new ToolsImpl(tool, level, !myLockedProfile && enabled, enabled);
- final Element element = myDeinstalledInspectionsSettings.remove(tool.getShortName());
+ HighlightDisplayLevel level = myBaseProfile != null ? myBaseProfile.getErrorLevel(key, project) : toolWrapper.getDefaultLevel();
+ boolean enabled = myBaseProfile != null ? myBaseProfile.isToolEnabled(key) : toolWrapper.isEnabledByDefault();
+ final ToolsImpl toolsList = new ToolsImpl(toolWrapper, level, !myLockedProfile && enabled, enabled);
+ final Element element = myDeinstalledInspectionsSettings.remove(toolWrapper.getShortName());
if (element != null) {
try {
toolsList.readExternal(element, this);
}
catch (InvalidDataException e) {
- LOG.error("Can't read settings for " + tool, e);
+ LOG.error("Can't read settings for " + toolWrapper, e);
}
}
- myTools.put(tool.getShortName(), toolsList);
+ myTools.put(toolWrapper.getShortName(), toolsList);
}
if (mySource != null) {
copyToolsConfigurations(mySource, project);
@@ -564,21 +544,21 @@
}
@NotNull
- private List<InspectionToolWrapper> createTools() {
+ private List<InspectionToolWrapper> createTools(Project project) {
if (mySource != null) {
- return ContainerUtil.map(mySource.getAllTools(), new Function<ScopeToolState, InspectionToolWrapper>() {
+ return ContainerUtil.map(mySource.getAllTools(project), new Function<ScopeToolState, InspectionToolWrapper>() {
@NotNull
@Override
public InspectionToolWrapper fun(@NotNull ScopeToolState state) {
- return (InspectionToolWrapper)state.getTool();
+ return state.getTool();
}
});
}
return myRegistrar.createTools();
}
- private HighlightDisplayLevel getErrorLevel(@NotNull HighlightDisplayKey key) {
- final ToolsImpl tools = getTools(key.toString());
+ private HighlightDisplayLevel getErrorLevel(@NotNull HighlightDisplayKey key, Project project) {
+ final ToolsImpl tools = getTools(key.toString(), project);
LOG.assertTrue(tools != null, "profile name: " + myName + " base profile: " + (myBaseProfile != null ? myBaseProfile.getName() : "-") + " key: " + key);
return tools.getLevel();
}
@@ -603,18 +583,19 @@
for (ToolsImpl toolList : profile.myTools.values()) {
final ToolsImpl tools = myTools.get(toolList.getShortName());
final ScopeToolState defaultState = toolList.getDefaultState();
- tools.setDefaultState(copyToolSettings((InspectionToolWrapper)defaultState.getTool()), defaultState.isEnabled(), defaultState.getLevel());
+ tools.setDefaultState(copyToolSettings(defaultState.getTool()), defaultState.isEnabled(), defaultState.getLevel());
tools.removeAllScopes();
tools.setEnabled(toolList.isEnabled());
final List<ScopeToolState> nonDefaultToolStates = toolList.getNonDefaultTools();
if (nonDefaultToolStates != null) {
for (ScopeToolState state : nonDefaultToolStates) {
- final InspectionTool inspectionTool = copyToolSettings((InspectionToolWrapper)state.getTool());
- final NamedScope scope = project != null ? state.getScope(project) : ScopeToolStateUtil.getScope(state);
+ final InspectionToolWrapper toolWrapper = copyToolSettings(state.getTool());
+ final NamedScope scope = state.getScope(project);
if (scope != null) {
- tools.addTool(scope, inspectionTool, state.isEnabled(), state.getLevel());
- } else {
- tools.addTool(state.getScopeName(), inspectionTool, state.isEnabled(), state.getLevel());
+ tools.addTool(scope, toolWrapper, state.isEnabled(), state.getLevel());
+ }
+ else {
+ tools.addTool(state.getScopeName(), toolWrapper, state.isEnabled(), state.getLevel());
}
}
}
@@ -629,32 +610,32 @@
}
@NotNull
- private static InspectionTool copyToolSettings(@NotNull InspectionToolWrapper tool)
+ private static InspectionToolWrapper copyToolSettings(@NotNull InspectionToolWrapper toolWrapper)
throws WriteExternalException, InvalidDataException {
- final InspectionTool inspectionTool = tool.createCopy();
- if (tool.isInitialized()) {
+ final InspectionToolWrapper inspectionTool = toolWrapper.createCopy();
+ if (toolWrapper.isInitialized()) {
@NonNls String tempRoot = "config";
Element config = new Element(tempRoot);
- tool.writeSettings(config);
- inspectionTool.readSettings(config);
+ toolWrapper.getTool().writeSettings(config);
+ inspectionTool.getTool().readSettings(config);
}
return inspectionTool;
}
@Override
- public void cleanup(Project project) {
+ public void cleanup(@NotNull Project project) {
for (final ToolsImpl toolList : myTools.values()) {
if (toolList.isEnabled()) {
- for (InspectionProfileEntry tool : toolList.getAllTools()) {
- tool.projectClosed(project);
- ((InspectionTool)tool).cleanup();
+ for (InspectionToolWrapper toolWrapper : toolList.getAllTools()) {
+ toolWrapper.projectClosed(project);
+ toolWrapper.cleanup();
}
}
}
}
- public void enableTool(String inspectionTool) {
- final ToolsImpl tools = getTools(inspectionTool);
+ public void enableTool(@NotNull String inspectionTool, Project project) {
+ final ToolsImpl tools = getTools(inspectionTool, project);
tools.setEnabled(true);
if (tools.getNonDefaultTools() == null) {
tools.getDefaultState().setEnabled(true);
@@ -662,19 +643,19 @@
}
@Override
- public void enableTool(String inspectionTool, NamedScope namedScope) {
- getTools(inspectionTool).enableTool(namedScope);
+ public void enableTool(String inspectionTool, NamedScope namedScope, Project project) {
+ getTools(inspectionTool, project).enableTool(namedScope, project);
}
@Override
- public void disableTool(String inspectionTool, NamedScope namedScope) {
- getTools(inspectionTool).disableTool(namedScope);
+ public void disableTool(String inspectionTool, NamedScope namedScope, @NotNull Project project) {
+ getTools(inspectionTool, project).disableTool(namedScope, project);
}
@Override
- public void disableTool(String inspectionTool) {
- final ToolsImpl tools = getTools(inspectionTool);
+ public void disableTool(String inspectionTool, Project project) {
+ final ToolsImpl tools = getTools(inspectionTool, project);
tools.setEnabled(false);
if (tools.getNonDefaultTools() == null) {
tools.getDefaultState().setEnabled(false);
@@ -682,8 +663,8 @@
}
@Override
- public void setErrorLevel(@NotNull HighlightDisplayKey key, HighlightDisplayLevel level) {
- getTools(key.toString()).setLevel(level);
+ public void setErrorLevel(@NotNull HighlightDisplayKey key, @NotNull HighlightDisplayLevel level, Project project) {
+ getTools(key.toString(), project).setLevel(level);
}
@Override
@@ -691,19 +672,19 @@
if (key == null) {
return false;
}
- final Tools toolState = getTools(key.toString());
+ final Tools toolState = getTools(key.toString(), element == null ? null : element.getProject());
return toolState != null && toolState.isEnabled(element);
}
@Override
public boolean isToolEnabled(HighlightDisplayKey key) {
- return isToolEnabled(key, (PsiElement)null);
+ return isToolEnabled(key, null);
}
@Override
- public boolean isExecutable() {
- initInspectionTools(null);
- for (ToolsImpl tools : myTools.values()) {
+ public boolean isExecutable(Project project) {
+ initInspectionTools(project);
+ for (Tools tools : myTools.values()) {
if (tools.isEnabled()) return true;
}
return false;
@@ -719,7 +700,7 @@
}
private void commit(@NotNull InspectionProfileImpl inspectionProfile) {
- myName = inspectionProfile.myName;
+ setName(inspectionProfile.getName());
myLocal = inspectionProfile.myLocal;
myLockedProfile = inspectionProfile.myLockedProfile;
myDisplayLevelMap = inspectionProfile.myDisplayLevelMap;
@@ -755,8 +736,9 @@
}
- public void convert(@NotNull Element element) {
- initInspectionTools(null);
+ @Override
+ public void convert(@NotNull Element element, @NotNull Project project) {
+ initInspectionTools(project);
final Element scopes = element.getChild(DefaultProjectProfileManager.SCOPES);
if (scopes == null) {
return;
@@ -770,12 +752,12 @@
if (inspectionProfile != null) {
final NamedScope scope = getProfileManager().getScopesManager().getScope(scopeElement.getAttributeValue(NAME));
if (scope != null) {
- for (InspectionProfileEntry entry : inspectionProfile.getInspectionTools(null)) {
- final HighlightDisplayKey key = HighlightDisplayKey.find(entry.getShortName());
+ for (InspectionToolWrapper toolWrapper : inspectionProfile.getInspectionTools(null)) {
+ final HighlightDisplayKey key = HighlightDisplayKey.find(toolWrapper.getShortName());
try {
- getTools(entry.getShortName())
- .addTool(scope, copyToolSettings((InspectionToolWrapper)entry), inspectionProfile.isToolEnabled(key),
- inspectionProfile.getErrorLevel(key, (NamedScope)null));
+ InspectionToolWrapper toolWrapperCopy = copyToolSettings(toolWrapper);
+ HighlightDisplayLevel errorLevel = inspectionProfile.getErrorLevel(key, null, project);
+ getTools(toolWrapper.getShortName(), project).addTool(scope, toolWrapperCopy, inspectionProfile.isToolEnabled(key), errorLevel);
}
catch (Exception e) {
LOG.error(e);
@@ -816,8 +798,8 @@
}
@NotNull
- public List<ScopeToolState> getAllTools() {
- initInspectionTools(null);
+ public List<ScopeToolState> getAllTools(Project project) {
+ initInspectionTools(project);
final List<ScopeToolState> result = new ArrayList<ScopeToolState>();
for (Tools tools : myTools.values()) {
result.addAll(tools.getTools());
@@ -826,8 +808,8 @@
}
@NotNull
- public List<ScopeToolState> getDefaultStates() {
- initInspectionTools(null);
+ public List<ScopeToolState> getDefaultStates(Project project) {
+ initInspectionTools(project);
final List<ScopeToolState> result = new ArrayList<ScopeToolState>();
for (Tools tools : myTools.values()) {
result.add(tools.getDefaultState());
@@ -836,33 +818,29 @@
}
@NotNull
- public List<ScopeToolState> getNonDefaultTools(String shortName) {
+ public List<ScopeToolState> getNonDefaultTools(String shortName, Project project) {
final List<ScopeToolState> result = new ArrayList<ScopeToolState>();
- final List<ScopeToolState> nonDefaultTools = getTools(shortName).getNonDefaultTools();
+ final List<ScopeToolState> nonDefaultTools = getTools(shortName, project).getNonDefaultTools();
if (nonDefaultTools != null) {
result.addAll(nonDefaultTools);
}
return result;
}
- public boolean isToolEnabled(@NotNull HighlightDisplayKey key, NamedScope namedScope) {
- return getTools(key.toString()).isEnabled(namedScope);
+ public boolean isToolEnabled(@NotNull HighlightDisplayKey key, NamedScope namedScope, Project project) {
+ return getTools(key.toString(), project).isEnabled(namedScope,project);
}
- public void removeScope(String toolId, int scopeIdx) {
- getTools(toolId).removeScope(scopeIdx);
+ public void removeScope(String toolId, int scopeIdx, Project project) {
+ getTools(toolId, project).removeScope(scopeIdx);
}
- public void removeAllScopes(String toolId) {
- getTools(toolId).removeAllScopes();
+ public void removeAllScopes(String toolId, Project project) {
+ getTools(toolId, project).removeAllScopes();
}
- public void setScope(String toolId, int idx, NamedScope namedScope) {
- getTools(toolId).setScope(idx, namedScope);
- }
-
- public void moveScope(String toolId, int idx, int dir) {
- getTools(toolId).moveScope(idx, dir);
+ public void moveScope(String toolId, int idx, int dir, Project project) {
+ getTools(toolId, project).moveScope(idx, dir);
}
/**
@@ -881,34 +859,38 @@
return myDisplayLevelMap;
}
- public HighlightDisplayLevel getErrorLevel(@NotNull HighlightDisplayKey key, NamedScope scope) {
- final ToolsImpl tools = getTools(key.toString());
- return tools != null ? tools.getLevel(scope) : HighlightDisplayLevel.WARNING;
+ @NotNull
+ public HighlightDisplayLevel getErrorLevel(@NotNull HighlightDisplayKey key, NamedScope scope, Project project) {
+ final ToolsImpl tools = getTools(key.toString(), project);
+ return tools != null ? tools.getLevel(scope, project) : HighlightDisplayLevel.WARNING;
}
- public ScopeToolState addScope(@NotNull InspectionProfileEntry tool, NamedScope scope, HighlightDisplayLevel level, boolean enabled) {
- return getTools(tool.getShortName()).prependTool(scope, tool, enabled, level);
+ public ScopeToolState addScope(@NotNull InspectionToolWrapper toolWrapper,
+ NamedScope scope,
+ @NotNull HighlightDisplayLevel level,
+ boolean enabled,
+ Project project) {
+ return getTools(toolWrapper.getShortName(), project).prependTool(scope, toolWrapper, enabled, level);
}
-
- public void setErrorLevel(@NotNull HighlightDisplayKey key, HighlightDisplayLevel level, int scopeIdx) {
- getTools(key.toString()).setLevel(level, scopeIdx);
+ public void setErrorLevel(@NotNull HighlightDisplayKey key, @NotNull HighlightDisplayLevel level, int scopeIdx, Project project) {
+ getTools(key.toString(), project).setLevel(level, scopeIdx, project);
}
- private ToolsImpl getTools(String toolId) {
- initInspectionTools(null);
+ private ToolsImpl getTools(String toolId, Project project) {
+ initInspectionTools(project);
return myTools.get(toolId);
}
- public void enableAllTools() {
- for (InspectionProfileEntry entry : getInspectionTools(null)) {
- enableTool(entry.getShortName());
+ public void enableAllTools(Project project) {
+ for (InspectionToolWrapper entry : getInspectionTools(null)) {
+ enableTool(entry.getShortName(), project);
}
}
- public void disableAllTools() {
- for (InspectionProfileEntry entry : getInspectionTools(null)) {
- disableTool(entry.getShortName());
+ public void disableAllTools(Project project) {
+ for (InspectionToolWrapper entry : getInspectionTools(null)) {
+ disableTool(entry.getShortName(), project);
}
}
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionProfileWrapper.java b/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileWrapper.java
similarity index 60%
rename from platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionProfileWrapper.java
rename to platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileWrapper.java
index ecb2d14..6bf6c14 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionProfileWrapper.java
+++ b/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileWrapper.java
@@ -18,6 +18,7 @@
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
import com.intellij.codeInspection.InspectionProfile;
+import com.intellij.codeInspection.InspectionProfileEntry;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
@@ -26,7 +27,6 @@
import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;
-import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@@ -40,42 +40,31 @@
/**
* Key that is assumed to hold strategy that customizes {@link InspectionProfileWrapper} object to use.
* <p/>
- * I.e. given strategy (if any) receives {@link InspectionProfileWrapper} object that is going to be used so far and returns
+ * I.e. given strategy (if any) receives {@link InspectionProfileWrapper} object that is going to be used so far and returns
* {@link InspectionProfileWrapper} object that should be used later.
*/
public static final Key<Function<InspectionProfileWrapper, InspectionProfileWrapper>> CUSTOMIZATION_KEY
= Key.create("Inspection Profile Wrapper Customization");
- private final InspectionProfileImpl myProfile;
+ protected final InspectionProfile myProfile;
- public InspectionProfileWrapper(final InspectionProfile profile) {
- myProfile = (InspectionProfileImpl)profile;
+ public InspectionProfileWrapper(@NotNull InspectionProfile profile) {
+ myProfile = profile;
}
- public InspectionTool[] getInspectionTools(PsiElement element){
- return (InspectionTool[])myProfile.getInspectionTools(element);
- }
-
- public List<LocalInspectionToolWrapper> getHighlightingLocalInspectionTools(PsiElement element) {
- List<LocalInspectionToolWrapper> enabled = new ArrayList<LocalInspectionToolWrapper>();
- final InspectionTool[] tools = getInspectionTools(element);
- checkInspectionsDuplicates(tools);
- for (InspectionTool tool : tools) {
- if (tool instanceof LocalInspectionToolWrapper && myProfile.isToolEnabled(HighlightDisplayKey.find(tool.getShortName()), element)) {
- enabled.add((LocalInspectionToolWrapper)tool);
- }
- }
- return enabled;
+ @NotNull
+ public InspectionToolWrapper[] getInspectionTools(PsiElement element){
+ return myProfile.getInspectionTools(element);
}
// check whether some inspection got registered twice by accident. 've bit once.
private static boolean alreadyChecked;
- private static void checkInspectionsDuplicates(@NotNull InspectionTool[] tools) {
+ public static void checkInspectionsDuplicates(@NotNull InspectionToolWrapper[] toolWrappers) {
if (alreadyChecked) return;
alreadyChecked = true;
- Set<InspectionTool> uniqTools = new THashSet<InspectionTool>(tools.length);
- for (InspectionTool tool : tools) {
- if (!uniqTools.add(tool)) {
- LOG.error("Inspection " + tool.getDisplayName() + " (" + tool.getClass() + ") already registered");
+ Set<InspectionProfileEntry> uniqTools = new THashSet<InspectionProfileEntry>(toolWrappers.length);
+ for (InspectionToolWrapper toolWrapper : toolWrappers) {
+ if (!uniqTools.add(toolWrapper.getTool())) {
+ LOG.error("Inspection " + toolWrapper.getDisplayName() + " (" + toolWrapper.getTool().getClass() + ") already registered");
}
}
}
@@ -92,12 +81,12 @@
return myProfile.isToolEnabled(key);
}
- public InspectionTool getInspectionTool(final String shortName, PsiElement element) {
- return (InspectionTool)myProfile.getInspectionTool(shortName, element);
+ public InspectionToolWrapper getInspectionTool(final String shortName, PsiElement element) {
+ return myProfile.getInspectionTool(shortName, element);
}
- public void init(final Project project) {
- final List<ToolsImpl> profileEntries = myProfile.getAllEnabledInspectionTools(project);
+ public void init(@NotNull Project project) {
+ final List<Tools> profileEntries = myProfile.getAllEnabledInspectionTools(project);
for (Tools profileEntry : profileEntries) {
for (ScopeToolState toolState : profileEntry.getTools()) {
toolState.getTool().projectOpened(project);
@@ -105,10 +94,11 @@
}
}
- public void cleanup(final Project project){
+ public void cleanup(@NotNull Project project){
myProfile.cleanup(project);
}
+ @NotNull
public InspectionProfile getInspectionProfile() {
return myProfile;
}
diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionToolRegistrar.java b/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionToolRegistrar.java
new file mode 100644
index 0000000..c1223d7
--- /dev/null
+++ b/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionToolRegistrar.java
@@ -0,0 +1,188 @@
+/*
+ * Copyright 2000-2013 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.codeInspection.ex;
+
+import com.intellij.codeInspection.*;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.components.ServiceManager;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.extensions.Extensions;
+import com.intellij.openapi.progress.ProgressManager;
+import com.intellij.openapi.util.Factory;
+import com.intellij.util.containers.ContainerUtil;
+import gnu.trove.THashSet;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.TestOnly;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * @author max
+ */
+public class InspectionToolRegistrar {
+ private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.ex.InspectionToolRegistrar");
+
+ private final List<Factory<InspectionToolWrapper>> myInspectionToolFactories = new ArrayList<Factory<InspectionToolWrapper>>();
+
+ private final AtomicBoolean myInspectionComponentsLoaded = new AtomicBoolean(false);
+
+ public void ensureInitialized() {
+ if (!myInspectionComponentsLoaded.getAndSet(true)) {
+ Set<InspectionToolProvider> providers = new THashSet<InspectionToolProvider>();
+ ContainerUtil.addAll(providers, ApplicationManager.getApplication().getComponents(InspectionToolProvider.class));
+ ContainerUtil.addAll(providers, Extensions.getExtensions(InspectionToolProvider.EXTENSION_POINT_NAME));
+ registerTools(providers.toArray(new InspectionToolProvider[providers.size()]));
+ for (final LocalInspectionEP ep : Extensions.getExtensions(LocalInspectionEP.LOCAL_INSPECTION)) {
+ myInspectionToolFactories.add(new Factory<InspectionToolWrapper>() {
+ @Override
+ public InspectionToolWrapper create() {
+ return new LocalInspectionToolWrapper(ep);
+ }
+ });
+ }
+ for (final InspectionEP ep : Extensions.getExtensions(InspectionEP.GLOBAL_INSPECTION)) {
+ myInspectionToolFactories.add(new Factory<InspectionToolWrapper>() {
+ @Override
+ public InspectionToolWrapper create() {
+ return new GlobalInspectionToolWrapper(ep);
+ }
+ });
+ }
+ for (InspectionToolsFactory factory : Extensions.getExtensions(InspectionToolsFactory.EXTENSION_POINT_NAME)) {
+ for (final InspectionProfileEntry profileEntry : factory.createTools()) {
+ myInspectionToolFactories.add(new Factory<InspectionToolWrapper>() {
+ @Override
+ public InspectionToolWrapper create() {
+ return wrapTool(profileEntry);
+ }
+ });
+ }
+ }
+ }
+ }
+
+ @NotNull
+ public static InspectionToolWrapper wrapTool(@NotNull InspectionProfileEntry profileEntry) {
+ if (profileEntry instanceof LocalInspectionTool) {
+ return new LocalInspectionToolWrapper((LocalInspectionTool)profileEntry);
+ }
+ if (profileEntry instanceof GlobalInspectionTool) {
+ return new GlobalInspectionToolWrapper((GlobalInspectionTool)profileEntry);
+ }
+ throw new RuntimeException("unknown inspection class: " + profileEntry + "; "+profileEntry.getClass());
+ }
+
+ public void registerTools(@NotNull InspectionToolProvider[] providers) {
+ for (InspectionToolProvider provider : providers) {
+ Class[] classes = provider.getInspectionClasses();
+ for (Class aClass : classes) {
+ registerInspectionTool(aClass);
+ }
+ }
+ }
+
+ @NotNull
+ private Factory<InspectionToolWrapper> registerInspectionTool(@NotNull final Class aClass) {
+ if (LocalInspectionTool.class.isAssignableFrom(aClass)) {
+ return registerLocalInspection(aClass, true);
+ }
+ if (GlobalInspectionTool.class.isAssignableFrom(aClass)) {
+ return registerGlobalInspection(aClass, true);
+ }
+ throw new RuntimeException("unknown inspection class: " + aClass);
+ }
+
+ public static InspectionToolRegistrar getInstance() {
+ return ServiceManager.getService(InspectionToolRegistrar.class);
+ }
+
+ /**
+ * make sure that it is not too late
+ */
+ @NotNull
+ public Factory<InspectionToolWrapper> registerInspectionToolFactory(@NotNull Factory<InspectionToolWrapper> factory, boolean store) {
+ if (store) {
+ myInspectionToolFactories.add(factory);
+ }
+ return factory;
+ }
+
+ @NotNull
+ private Factory<InspectionToolWrapper> registerLocalInspection(final Class toolClass, boolean store) {
+ return registerInspectionToolFactory(new Factory<InspectionToolWrapper>() {
+ @Override
+ public InspectionToolWrapper create() {
+ return new LocalInspectionToolWrapper((LocalInspectionTool)InspectionToolsRegistrarCore.instantiateTool(toolClass));
+ }
+ }, store);
+ }
+
+ @NotNull
+ private Factory<InspectionToolWrapper> registerGlobalInspection(@NotNull final Class aClass, boolean store) {
+ return registerInspectionToolFactory(new Factory<InspectionToolWrapper>() {
+ @Override
+ public InspectionToolWrapper create() {
+ return new GlobalInspectionToolWrapper((GlobalInspectionTool) InspectionToolsRegistrarCore.instantiateTool(aClass));
+ }
+ }, store);
+ }
+
+ @NotNull
+ @TestOnly
+ public List<InspectionToolWrapper> createTools() {
+ ensureInitialized();
+
+ final List<InspectionToolWrapper> tools = ContainerUtil.newArrayListWithCapacity(myInspectionToolFactories.size());
+ final Set<Factory<InspectionToolWrapper>> broken = ContainerUtil.newHashSet();
+ for (final Factory<InspectionToolWrapper> factory : myInspectionToolFactories) {
+ ProgressManager.checkCanceled();
+ final InspectionToolWrapper toolWrapper = factory.create();
+ if (toolWrapper != null && checkTool(toolWrapper) == null) {
+ tools.add(toolWrapper);
+ }
+ else {
+ broken.add(factory);
+ }
+ }
+ myInspectionToolFactories.removeAll(broken);
+
+ return tools;
+ }
+
+ private static String checkTool(@NotNull final InspectionToolWrapper toolWrapper) {
+ if (!(toolWrapper instanceof LocalInspectionToolWrapper)) {
+ return null;
+ }
+ String message = null;
+ try {
+ final String id = ((LocalInspectionToolWrapper)toolWrapper).getID();
+ if (id == null || !LocalInspectionTool.isValidID(id)) {
+ message = InspectionsBundle.message("inspection.disabled.wrong.id", toolWrapper.getShortName(), id, LocalInspectionTool.VALID_ID_PATTERN);
+ }
+ }
+ catch (Throwable t) {
+ message = InspectionsBundle.message("inspection.disabled.error", toolWrapper.getShortName(), t.getMessage());
+ }
+ if (message != null) {
+ LOG.error(message);
+ }
+ return message;
+ }
+}
diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/ex/LocalInspectionToolWrapper.java b/platform/analysis-impl/src/com/intellij/codeInspection/ex/LocalInspectionToolWrapper.java
new file mode 100644
index 0000000..2f18996
--- /dev/null
+++ b/platform/analysis-impl/src/com/intellij/codeInspection/ex/LocalInspectionToolWrapper.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2000-2013 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.codeInspection.ex;
+
+import com.intellij.codeInspection.*;
+import com.intellij.openapi.extensions.Extensions;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.NotNullLazyValue;
+import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
+import com.intellij.psi.PsiElement;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.TestOnly;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author max
+ */
+public class LocalInspectionToolWrapper extends InspectionToolWrapper<LocalInspectionTool, LocalInspectionEP> {
+ /** This should be used in tests primarily */
+ @TestOnly
+ public LocalInspectionToolWrapper(@NotNull LocalInspectionTool tool) {
+ super(tool, ourEPMap.getValue().get(tool.getShortName()));
+ }
+
+ public LocalInspectionToolWrapper(@NotNull LocalInspectionEP ep) {
+ super(ep);
+ }
+
+ private LocalInspectionToolWrapper(@NotNull LocalInspectionToolWrapper other) {
+ super(other);
+ }
+
+ @NotNull
+ @Override
+ public LocalInspectionToolWrapper createCopy() {
+ return new LocalInspectionToolWrapper(this);
+ }
+
+ @Override
+ @NotNull
+ public JobDescriptor[] getJobDescriptors(@NotNull GlobalInspectionContext context) {
+ return context.getStdJobDescriptors().LOCAL_ANALYSIS_ARRAY;
+ }
+
+
+ public boolean isUnfair() {
+ return myEP == null ? getTool() instanceof UnfairLocalInspectionTool : myEP.unfair;
+ }
+
+ public String getID() {
+ return myEP == null ? getTool().getID() : myEP.id == null ? myEP.getShortName() : myEP.id;
+ }
+
+ @Nullable
+ public String getAlternativeID() {
+ return myEP == null ? getTool().getAlternativeID() : myEP.alternativeId;
+ }
+
+ public boolean runForWholeFile() {
+ return myEP == null ? getTool().runForWholeFile() : myEP.runForWholeFile;
+ }
+
+ private static final NotNullLazyValue<Map<String, LocalInspectionEP>> ourEPMap = new NotNullLazyValue<Map<String, LocalInspectionEP>>() {
+ @NotNull
+ @Override
+ protected Map<String, LocalInspectionEP> compute() {
+ HashMap<String, LocalInspectionEP> map = new HashMap<String, LocalInspectionEP>();
+ for (LocalInspectionEP ep : Extensions.getExtensions(LocalInspectionEP.LOCAL_INSPECTION)) {
+ map.put(ep.getShortName(), ep);
+ }
+ return map;
+ }
+ };
+
+ public static InspectionToolWrapper findTool2RunInBatch(@NotNull Project project, @Nullable PsiElement element, @NotNull String name) {
+ final InspectionProfile inspectionProfile = InspectionProjectProfileManager.getInstance(project).getInspectionProfile();
+ final InspectionToolWrapper toolWrapper = element == null
+ ? inspectionProfile.getInspectionTool(name, project)
+ : inspectionProfile.getInspectionTool(name, element);
+ if (toolWrapper instanceof LocalInspectionToolWrapper && ((LocalInspectionToolWrapper)toolWrapper).isUnfair()) {
+ final LocalInspectionTool inspectionTool = ((LocalInspectionToolWrapper)toolWrapper).getTool();
+ if (inspectionTool instanceof PairedUnfairLocalInspectionTool) {
+ final String oppositeShortName = ((PairedUnfairLocalInspectionTool)inspectionTool).getInspectionForBatchShortName();
+ if (oppositeShortName != null) {
+ return element == null
+ ? inspectionProfile.getInspectionTool(oppositeShortName, project)
+ : inspectionProfile.getInspectionTool(oppositeShortName, element);
+ }
+ }
+ return null;
+ }
+ return toolWrapper;
+ }
+}
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/PairedUnfairLocalInspectionTool.java b/platform/analysis-impl/src/com/intellij/codeInspection/ex/PairedUnfairLocalInspectionTool.java
similarity index 100%
rename from platform/lang-impl/src/com/intellij/codeInspection/ex/PairedUnfairLocalInspectionTool.java
rename to platform/analysis-impl/src/com/intellij/codeInspection/ex/PairedUnfairLocalInspectionTool.java
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/ToolsImpl.java b/platform/analysis-impl/src/com/intellij/codeInspection/ex/ToolsImpl.java
similarity index 74%
rename from platform/lang-impl/src/com/intellij/codeInspection/ex/ToolsImpl.java
rename to platform/analysis-impl/src/com/intellij/codeInspection/ex/ToolsImpl.java
index fccb5e2..a017575 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/ex/ToolsImpl.java
+++ b/platform/analysis-impl/src/com/intellij/codeInspection/ex/ToolsImpl.java
@@ -22,12 +22,13 @@
import com.intellij.codeHighlighting.HighlightDisplayLevel;
import com.intellij.codeInsight.daemon.impl.SeverityRegistrar;
-import com.intellij.codeInspection.InspectionProfileEntry;
+import com.intellij.codeInspection.InspectionProfile;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.packageDependencies.DependencyValidationManager;
+import com.intellij.profile.ProfileEx;
import com.intellij.profile.ProfileManager;
import com.intellij.profile.codeInspection.SeverityProvider;
import com.intellij.psi.PsiElement;
@@ -56,40 +57,41 @@
private List<ScopeToolState> myTools;
private boolean myEnabled;
- public ToolsImpl(@NotNull InspectionProfileEntry tool, HighlightDisplayLevel level, boolean enabled, boolean enabledByDefault) {
- myShortName = tool.getShortName();
+ public ToolsImpl(@NotNull InspectionToolWrapper toolWrapper, @NotNull HighlightDisplayLevel level, boolean enabled, boolean enabledByDefault) {
+ myShortName = toolWrapper.getShortName();
myEnabled = enabled;
- myDefaultState = new ScopeToolState(CustomScopesProviderEx.getAllScope(), tool, enabledByDefault, level);
+ myDefaultState = new ScopeToolState(CustomScopesProviderEx.getAllScope(), toolWrapper, enabledByDefault, level);
}
@TestOnly
- public ToolsImpl(@NotNull InspectionProfileEntry tool, HighlightDisplayLevel level, boolean enabled) {
- this(tool, level, enabled, enabled);
+ public ToolsImpl(@NotNull InspectionToolWrapper toolWrapper, @NotNull HighlightDisplayLevel level, boolean enabled) {
+ this(toolWrapper, level, enabled, enabled);
}
@NotNull
- public ScopeToolState addTool(@NotNull NamedScope scope, @NotNull InspectionProfileEntry tool, boolean enabled, HighlightDisplayLevel level) {
- return insertTool(scope, tool, enabled, level, myTools != null ? myTools.size() : 0);
+ public ScopeToolState addTool(@NotNull NamedScope scope, @NotNull InspectionToolWrapper toolWrapper, boolean enabled, @NotNull HighlightDisplayLevel level) {
+ return insertTool(scope, toolWrapper, enabled, level, myTools != null ? myTools.size() : 0);
}
@NotNull
- public ScopeToolState prependTool(@NotNull NamedScope scope, @NotNull InspectionProfileEntry tool, boolean enabled, HighlightDisplayLevel level) {
- return insertTool(scope, tool, enabled, level, 0);
+ public ScopeToolState prependTool(@NotNull NamedScope scope, @NotNull InspectionToolWrapper toolWrapper, boolean enabled, @NotNull HighlightDisplayLevel level) {
+ return insertTool(scope, toolWrapper, enabled, level, 0);
}
@NotNull
- private ScopeToolState insertTool(@NotNull NamedScope scope, @NotNull InspectionProfileEntry tool, boolean enabled, HighlightDisplayLevel level, int idx) {
+ private ScopeToolState insertTool(@NotNull NamedScope scope, @NotNull InspectionToolWrapper toolWrapper, boolean enabled, @NotNull HighlightDisplayLevel level, int idx) {
if (myTools == null) {
myTools = new ArrayList<ScopeToolState>();
setEnabled(true);
}
- final ScopeToolState scopeToolState = new ScopeToolState(scope, tool, enabled, level);
+ final ScopeToolState scopeToolState = new ScopeToolState(scope, toolWrapper, enabled, level);
myTools.add(idx, scopeToolState);
return scopeToolState;
}
+ @NotNull
@Override
- public InspectionProfileEntry getInspectionTool(PsiElement element) {
+ public InspectionToolWrapper getInspectionTool(PsiElement element) {
if (myTools != null) {
final Project project = element != null ? element.getProject() : null;
for (ScopeToolState state : myTools) {
@@ -126,10 +128,11 @@
}
@NotNull
- public List<InspectionProfileEntry> getAllTools() {
- final List<InspectionProfileEntry> result = new ArrayList<InspectionProfileEntry>();
+ public List<InspectionToolWrapper> getAllTools() {
+ List<InspectionToolWrapper> result = new ArrayList<InspectionToolWrapper>();
for (ScopeToolState state : getTools()) {
- result.add(state.getTool());
+ InspectionToolWrapper toolWrapper = state.getTool();
+ result.add(toolWrapper);
}
return result;
}
@@ -141,18 +144,19 @@
scopeElement.setAttribute("name", state.getScopeName());
scopeElement.setAttribute(LEVEL_ATTRIBUTE, state.getLevel().toString());
scopeElement.setAttribute(ENABLED_ATTRIBUTE, Boolean.toString(state.isEnabled()));
- InspectionProfileEntry InspectionProfileEntry = state.getTool();
- InspectionProfileEntry.writeSettings(scopeElement);
+ InspectionToolWrapper toolWrapper = state.getTool();
+ toolWrapper.getTool().writeSettings(scopeElement);
inspectionElement.addContent(scopeElement);
}
}
inspectionElement.setAttribute(ENABLED_ATTRIBUTE, Boolean.toString(isEnabled()));
inspectionElement.setAttribute(LEVEL_ATTRIBUTE, getLevel().toString());
inspectionElement.setAttribute(ENABLED_BY_DEFAULT_ATTRIBUTE, Boolean.toString(myDefaultState.isEnabled()));
- myDefaultState.getTool().writeSettings(inspectionElement);
+ InspectionToolWrapper toolWrapper = myDefaultState.getTool();
+ toolWrapper.getTool().writeSettings(inspectionElement);
}
- void readExternal(@NotNull Element toolElement, @NotNull InspectionProfileImpl profile) throws InvalidDataException {
+ void readExternal(@NotNull Element toolElement, @NotNull InspectionProfile profile) throws InvalidDataException {
final String levelName = toolElement.getAttributeValue(LEVEL_ATTRIBUTE);
final ProfileManager profileManager = profile.getProfileManager();
final SeverityRegistrar registrar = ((SeverityProvider)profileManager).getOwnSeverityRegistrar();
@@ -167,12 +171,12 @@
final String enabledTool = toolElement.getAttributeValue(ENABLED_BY_DEFAULT_ATTRIBUTE);
myDefaultState.setEnabled(enabledTool != null ? Boolean.parseBoolean(enabledTool) : isEnabled);
- final InspectionToolWrapper tool = (InspectionToolWrapper)myDefaultState.getTool();
+ final InspectionToolWrapper toolWrapper = myDefaultState.getTool();
- final List scopeElements = toolElement.getChildren(InspectionProfileImpl.SCOPE);
+ final List scopeElements = toolElement.getChildren(ProfileEx.SCOPE);
for (Object sO : scopeElements) {
final Element scopeElement = (Element)sO;
- final String scopeName = scopeElement.getAttributeValue(InspectionProfileImpl.NAME);
+ final String scopeName = scopeElement.getAttributeValue(ProfileEx.NAME);
if (scopeName == null) {
continue;
}
@@ -183,10 +187,10 @@
}
final String errorLevel = scopeElement.getAttributeValue(LEVEL_ATTRIBUTE);
final String enabledInScope = scopeElement.getAttributeValue(ENABLED_ATTRIBUTE);
- final InspectionProfileEntry copyTool = tool.createCopy();
+ final InspectionToolWrapper copyToolWrapper = toolWrapper.createCopy();
// check if unknown children exists
- if (scopeElement.getAttributes().size() > 3 || scopeElement.getChildren().size() > 0) {
- copyTool.readSettings(scopeElement);
+ if (scopeElement.getAttributes().size() > 3 || !scopeElement.getChildren().isEmpty()) {
+ copyToolWrapper.getTool().readSettings(scopeElement);
}
HighlightDisplayLevel scopeLevel = errorLevel != null ?
HighlightDisplayLevel.find(registrar.getSeverity(errorLevel)) : null;
@@ -194,32 +198,32 @@
scopeLevel = level;
}
if (namedScope != null) {
- addTool(namedScope, copyTool, enabledInScope != null && Boolean.parseBoolean(enabledInScope), scopeLevel);
+ addTool(namedScope, copyToolWrapper, enabledInScope != null && Boolean.parseBoolean(enabledInScope), scopeLevel);
}
else {
- addTool(scopeName, copyTool, enabledInScope != null && Boolean.parseBoolean(enabledInScope), scopeLevel);
+ addTool(scopeName, copyToolWrapper, enabledInScope != null && Boolean.parseBoolean(enabledInScope), scopeLevel);
}
}
// check if unknown children exists
if (toolElement.getAttributes().size() > 4 || toolElement.getChildren().size() > scopeElements.size()) {
- tool.readSettings(toolElement);
+ toolWrapper.getTool().readSettings(toolElement);
}
}
- public ScopeToolState addTool(@NotNull String scopeName, @NotNull InspectionProfileEntry tool, boolean enabled, HighlightDisplayLevel level) {
+ public ScopeToolState addTool(@NotNull String scopeName, @NotNull InspectionToolWrapper toolWrapper, boolean enabled, @NotNull HighlightDisplayLevel level) {
if (myTools == null) {
myTools = new ArrayList<ScopeToolState>();
setEnabled(true);
}
- final ScopeToolState scopeToolState = new ScopeToolState(scopeName, tool, enabled, level);
+ final ScopeToolState scopeToolState = new ScopeToolState(scopeName, toolWrapper, enabled, level);
myTools.add(scopeToolState);
return scopeToolState;
}
@NotNull
@Override
- public InspectionProfileEntry getTool() {
+ public InspectionToolWrapper getTool() {
if (myTools == null) return myDefaultState.getTool();
return myTools.iterator().next().getTool();
}
@@ -256,9 +260,9 @@
public void setScope(int idx, NamedScope namedScope) {
if (myTools != null && myTools.size() > idx && idx >= 0) {
final ScopeToolState scopeToolState = myTools.get(idx);
- final InspectionProfileEntry tool = scopeToolState.getTool();
+ InspectionToolWrapper toolWrapper = scopeToolState.getTool();
myTools.remove(idx);
- myTools.add(idx, new ScopeToolState(namedScope, tool, scopeToolState.isEnabled(), scopeToolState.getLevel()));
+ myTools.add(idx, new ScopeToolState(namedScope, toolWrapper, scopeToolState.isEnabled(), scopeToolState.getLevel()));
}
}
@@ -270,11 +274,11 @@
}
}
- public boolean isEnabled(NamedScope namedScope) {
+ public boolean isEnabled(NamedScope namedScope, Project project) {
if (!myEnabled) return false;
if (namedScope != null && myTools != null) {
for (ScopeToolState state : myTools) {
- if (Comparing.equal(namedScope, ScopeToolStateUtil.getScope(state))) return state.isEnabled();
+ if (Comparing.equal(namedScope, state.getScope(project))) return state.isEnabled();
}
}
return myDefaultState.isEnabled();
@@ -326,10 +330,10 @@
@Override
@Nullable
- public InspectionTool getEnabledTool(PsiElement element) {
+ public InspectionToolWrapper getEnabledTool(PsiElement element) {
if (!myEnabled) return null;
if (myTools == null || element == null) {
- return myDefaultState.isEnabled() ? (InspectionTool)myDefaultState.getTool() : null;
+ return myDefaultState.isEnabled() ? myDefaultState.getTool() : null;
}
final Project project = element.getProject();
final DependencyValidationManager manager = DependencyValidationManager.getInstance(project);
@@ -338,21 +342,21 @@
if (scope != null) {
final PackageSet set = scope.getValue();
if (set != null && set.contains(element.getContainingFile(), manager)) {
- return state.isEnabled() ? (InspectionTool)state.getTool() : null;
+ return state.isEnabled() ? state.getTool() : null;
}
}
}
- return myDefaultState.isEnabled() ? (InspectionTool)myDefaultState.getTool() : null;
+ return myDefaultState.isEnabled() ? myDefaultState.getTool() : null;
}
public void setEnabled(boolean enabled) {
myEnabled = enabled;
}
- public void enableTool(NamedScope namedScope) {
+ public void enableTool(NamedScope namedScope, Project project) {
if (myTools != null) {
for (ScopeToolState state : myTools) {
- if (Comparing.equal(ScopeToolStateUtil.getScope(state), namedScope)) {
+ if (Comparing.equal(state.getScope(project), namedScope)) {
state.setEnabled(true);
}
}
@@ -360,10 +364,10 @@
setEnabled(true);
}
- public void disableTool(NamedScope namedScope) {
+ public void disableTool(NamedScope namedScope, Project project) {
if (myTools != null) {
for (ScopeToolState state : myTools) {
- if (Comparing.equal(ScopeToolStateUtil.getScope(state), namedScope)) {
+ if (Comparing.equal(state.getScope(project), namedScope)) {
state.setEnabled(false);
}
}
@@ -371,12 +375,7 @@
}
- public void disableTool(PsiElement element) {
- if (element == null){
- myDefaultState.setEnabled(false);
- setEnabled(false);
- return;
- }
+ public void disableTool(@NotNull PsiElement element) {
final Project project = element.getProject();
final DependencyValidationManager validationManager = DependencyValidationManager.getInstance(project);
if (myTools != null) {
@@ -391,16 +390,18 @@
}
}
myDefaultState.setEnabled(false);
- } else {
+ }
+ else {
myDefaultState.setEnabled(false);
setEnabled(false);
}
}
- public HighlightDisplayLevel getLevel(final NamedScope scope) {
+ @NotNull
+ public HighlightDisplayLevel getLevel(final NamedScope scope, Project project) {
if (myTools != null && scope != null){
for (ScopeToolState state : myTools) {
- if (Comparing.equal(ScopeToolStateUtil.getScope(state), scope)) {
+ if (Comparing.equal(state.getScope(project), scope)) {
return state.getLevel();
}
}
@@ -424,28 +425,31 @@
}
- public void setLevel(HighlightDisplayLevel level, int idx) {
+ public void setLevel(@NotNull HighlightDisplayLevel level, int idx, Project project) {
if (myTools != null && myTools.size() > idx && idx >= 0) {
final ScopeToolState scopeToolState = myTools.get(idx);
myTools.remove(idx);
- final NamedScope scope = ScopeToolStateUtil.getScope(scopeToolState);
+ final NamedScope scope = scopeToolState.getScope(project);
+ InspectionToolWrapper toolWrapper = scopeToolState.getTool();
if (scope != null) {
- myTools.add(idx, new ScopeToolState(scope, scopeToolState.getTool(), scopeToolState.isEnabled(), level));
- } else {
- myTools.add(idx, new ScopeToolState(scopeToolState.getScopeName(), scopeToolState.getTool(), scopeToolState.isEnabled(), level));
+ myTools.add(idx, new ScopeToolState(scope, toolWrapper, scopeToolState.isEnabled(), level));
}
- } else if (idx == - 1) {
+ else {
+ myTools.add(idx, new ScopeToolState(scopeToolState.getScopeName(), toolWrapper, scopeToolState.isEnabled(), level));
+ }
+ }
+ else if (idx == -1) {
myDefaultState.setLevel(level);
}
}
- public void setDefaultState(InspectionProfileEntry inspectionTool, boolean enabled, HighlightDisplayLevel level) {
- myDefaultState.setTool(inspectionTool);
+ public void setDefaultState(@NotNull InspectionToolWrapper toolWrapper, boolean enabled, @NotNull HighlightDisplayLevel level) {
+ myDefaultState.setTool(toolWrapper);
myDefaultState.setLevel(level);
myDefaultState.setEnabled(enabled);
}
- public void setLevel(HighlightDisplayLevel level) {
+ public void setLevel(@NotNull HighlightDisplayLevel level) {
myDefaultState.setLevel(level);
}
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/inspection-black-list.txt b/platform/analysis-impl/src/com/intellij/codeInspection/inspection-black-list.txt
similarity index 100%
rename from platform/lang-impl/src/com/intellij/codeInspection/inspection-black-list.txt
rename to platform/analysis-impl/src/com/intellij/codeInspection/inspection-black-list.txt
diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/reference/RefManagerImpl.java b/platform/analysis-impl/src/com/intellij/codeInspection/reference/RefManagerImpl.java
index 0c92b22..5f596b3 100644
--- a/platform/analysis-impl/src/com/intellij/codeInspection/reference/RefManagerImpl.java
+++ b/platform/analysis-impl/src/com/intellij/codeInspection/reference/RefManagerImpl.java
@@ -205,8 +205,9 @@
return null;
}
+ @NotNull
@Override
- public RefEntity getRefinedElement(RefEntity ref) {
+ public RefEntity getRefinedElement(@NotNull RefEntity ref) {
for (RefManagerExtension extension : myExtensions.values()) {
ref = extension.getRefinedElement(ref);
}
@@ -214,7 +215,7 @@
}
@Override
- public Element export(RefEntity refEntity, final Element element, final int actualLine) {
+ public Element export(@NotNull RefEntity refEntity, @NotNull final Element element, final int actualLine) {
refEntity = getRefinedElement(refEntity);
Element problem = new Element("problem");
@@ -349,7 +350,7 @@
return myPsiManager;
}
- public void removeReference(RefElement refElem) {
+ public void removeReference(@NotNull RefElement refElem) {
myLock.writeLock().lock();
try {
final Map<PsiAnchor, RefElement> refTable = getRefTable();
@@ -600,7 +601,7 @@
}
@Override
- public void removeRefElement(RefElement refElement, List<RefElement> deletedRefs) {
+ public void removeRefElement(@NotNull RefElement refElement, @NotNull List<RefElement> deletedRefs) {
List<RefEntity> children = refElement.getChildren();
if (children != null) {
RefElement[] refElements = children.toArray(new RefElement[children.size()]);
diff --git a/platform/lang-impl/src/com/intellij/packageDependencies/DependencyValidationManagerImpl.java b/platform/analysis-impl/src/com/intellij/packageDependencies/DependencyValidationManagerImpl.java
similarity index 92%
rename from platform/lang-impl/src/com/intellij/packageDependencies/DependencyValidationManagerImpl.java
rename to platform/analysis-impl/src/com/intellij/packageDependencies/DependencyValidationManagerImpl.java
index 4352a88..8e1baba 100644
--- a/platform/lang-impl/src/com/intellij/packageDependencies/DependencyValidationManagerImpl.java
+++ b/platform/analysis-impl/src/com/intellij/packageDependencies/DependencyValidationManagerImpl.java
@@ -69,10 +69,8 @@
public List<NamedScope> getPredefinedScopes() {
final List<NamedScope> predefinedScopes = new ArrayList<NamedScope>();
final CustomScopesProvider[] scopesProviders = myProject.getExtensions(CustomScopesProvider.CUSTOM_SCOPES_PROVIDER);
- if (scopesProviders != null) {
- for (CustomScopesProvider scopesProvider : scopesProviders) {
- predefinedScopes.addAll(scopesProvider.getCustomScopes());
- }
+ for (CustomScopesProvider scopesProvider : scopesProviders) {
+ predefinedScopes.addAll(scopesProvider.getCustomScopes());
}
return predefinedScopes;
}
@@ -80,14 +78,12 @@
@Override
public NamedScope getPredefinedScope(String name) {
final CustomScopesProvider[] scopesProviders = myProject.getExtensions(CustomScopesProvider.CUSTOM_SCOPES_PROVIDER);
- if (scopesProviders != null) {
- for (CustomScopesProvider scopesProvider : scopesProviders) {
- final NamedScope scope = scopesProvider instanceof CustomScopesProviderEx
- ? ((CustomScopesProviderEx)scopesProvider).getCustomScope(name)
- : CustomScopesProviderEx.findPredefinedScope(name, scopesProvider.getCustomScopes());
- if (scope != null) {
- return scope;
- }
+ for (CustomScopesProvider scopesProvider : scopesProviders) {
+ final NamedScope scope = scopesProvider instanceof CustomScopesProviderEx
+ ? ((CustomScopesProviderEx)scopesProvider).getCustomScope(name)
+ : CustomScopesProviderEx.findPredefinedScope(name, scopesProvider.getCustomScopes());
+ if (scope != null) {
+ return scope;
}
}
return null;
@@ -120,10 +116,9 @@
return result.toArray(new DependencyRule[result.size()]);
}
- @Override
- public
@NotNull
- DependencyRule[] getApplicableRules(PsiFile file) {
+ @Override
+ public DependencyRule[] getApplicableRules(PsiFile file) {
ArrayList<DependencyRule> result = new ArrayList<DependencyRule>();
for (DependencyRule dependencyRule : myRules) {
if (dependencyRule.isApplicable(file)) {
@@ -315,7 +310,7 @@
result.add(new Pair<Element, String>(element, name));
}
}
- if (e.getChildren().size() > 0) {
+ if (!e.getChildren().isEmpty()) {
result.add(new Pair<Element, String>(e, generator.generateUniqueName("scope_settings") + ".xml"));
}
return result;
@@ -335,7 +330,7 @@
target.addContent(state);
}
for (Object attr : element.getAttributes()) {
- target.setAttribute((Attribute)((Attribute)attr).clone());
+ target.setAttribute(((Attribute)attr).clone());
}
}
}
diff --git a/platform/analysis-api/src/com/intellij/profile/ProfileEx.java b/platform/analysis-impl/src/com/intellij/profile/ProfileEx.java
similarity index 87%
rename from platform/analysis-api/src/com/intellij/profile/ProfileEx.java
rename to platform/analysis-impl/src/com/intellij/profile/ProfileEx.java
index dccf136..1baa154 100644
--- a/platform/analysis-api/src/com/intellij/profile/ProfileEx.java
+++ b/platform/analysis-impl/src/com/intellij/profile/ProfileEx.java
@@ -16,6 +16,7 @@
package com.intellij.profile;
import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.DefaultJDOMExternalizer;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
@@ -27,21 +28,22 @@
* User: anna
* Date: 01-Dec-2005
*/
-public class ProfileEx implements Profile {
+public abstract class ProfileEx implements Profile {
+ // public for JDOMExternalizable
+ @NotNull
public String myName;
private static final Logger LOG = Logger.getInstance("com.intellij.profile.ProfileEx");
public boolean myLocal = true;
protected ProfileManager myProfileManager;
+ @NonNls public static final String SCOPE = "scope";
+ public static final String NAME = "name";
public ProfileEx(@NotNull String name) {
- myName = name;
- }
-
- public ProfileEx(@NotNull String name, final Element element) {
- this(name);
+ setName(name);
}
@Override
+ @NotNull
public String getName() {
return myName;
}
@@ -72,7 +74,7 @@
}
@Override
- public void setName(String name) {
+ public void setName(@NotNull String name) {
myName = name;
}
@@ -119,4 +121,6 @@
}
return 0;
}
+
+ public void convert(@NotNull Element element, @NotNull Project project) {}
}
diff --git a/platform/analysis-impl/src/com/intellij/profile/codeInspection/InspectionProfileLoadUtil.java b/platform/analysis-impl/src/com/intellij/profile/codeInspection/InspectionProfileLoadUtil.java
new file mode 100644
index 0000000..2d35985
--- /dev/null
+++ b/platform/analysis-impl/src/com/intellij/profile/codeInspection/InspectionProfileLoadUtil.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2000-2013 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.profile.codeInspection;
+
+import com.intellij.codeInspection.ex.InspectionProfileImpl;
+import com.intellij.codeInspection.ex.InspectionToolRegistrar;
+import com.intellij.openapi.util.InvalidDataException;
+import com.intellij.openapi.util.JDOMUtil;
+import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.profile.Profile;
+import com.intellij.profile.ProfileManager;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.JDOMException;
+import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.io.File;
+import java.io.IOException;
+
+public class InspectionProfileLoadUtil {
+ @NonNls private static final String PROFILE_NAME_TAG = "profile_name";
+ @NonNls public static final String PROFILE_TAG = "profile";
+
+ private static String getProfileName(@NotNull File file, @NotNull Document document) {
+ String name = getRootElementAttribute(PROFILE_NAME_TAG, document);
+ if (name != null) return name;
+ return FileUtil.getNameWithoutExtension(file);
+ }
+
+ private static String getRootElementAttribute(@NotNull Document document, @NonNls String name) {
+ Element root = document.getRootElement();
+ return root.getAttributeValue(name);
+ }
+
+ @Nullable
+ private static String getRootElementAttribute(@NonNls String name, final Document doc) {
+ return getRootElementAttribute(doc, name);
+ }
+
+ @NotNull
+ static String getProfileName(@NotNull Document document) {
+ String name = getRootElementAttribute(document, PROFILE_NAME_TAG);
+ if (name != null) return name;
+ return "unnamed";
+ }
+
+ @NotNull
+ public static Profile load(@NotNull File file,
+ @NotNull InspectionToolRegistrar registrar,
+ @NotNull ProfileManager profileManager) throws JDOMException, IOException, InvalidDataException {
+ Document document = JDOMUtil.loadDocument(file);
+ InspectionProfileImpl profile = new InspectionProfileImpl(getProfileName(file, document), registrar, profileManager);
+ Element rootElement = document.getRootElement();
+ final Element profileElement = rootElement.getChild(PROFILE_TAG);
+ if (profileElement != null) {
+ rootElement = profileElement;
+ }
+ profile.readExternal(rootElement);
+ return profile;
+ }
+}
diff --git a/platform/analysis-impl/src/com/intellij/profile/codeInspection/InspectionProfileManager.java b/platform/analysis-impl/src/com/intellij/profile/codeInspection/InspectionProfileManager.java
index e68f80b..dce1d0a 100644
--- a/platform/analysis-impl/src/com/intellij/profile/codeInspection/InspectionProfileManager.java
+++ b/platform/analysis-impl/src/com/intellij/profile/codeInspection/InspectionProfileManager.java
@@ -32,7 +32,6 @@
import java.io.File;
import java.io.IOException;
-import java.util.Collection;
import java.util.List;
/**
@@ -53,10 +52,6 @@
public InspectionProfileManager() {
}
- @Override
- @NotNull
- public abstract Collection<Profile> getProfiles();
-
protected abstract void initProfiles();
public abstract Profile loadProfile(@NotNull String path) throws IOException, JDOMException;
@@ -68,13 +63,6 @@
}
@Override
- public abstract void updateProfile(@NotNull Profile profile);
-
-
- @Override
- public abstract Profile createProfile();
-
- @Override
public void addProfileChangeListener(@NotNull final ProfileChangeAdapter listener) {
myProfileChangeAdapters.add(listener);
}
@@ -103,16 +91,6 @@
}
}
- @Override
- public abstract Profile getProfile(@NotNull final String name, boolean returnRootProfileIfNamedIsAbsent);
-
- @Override
- @NotNull
- public abstract Profile getRootProfile();
-
- @Override
- public abstract void deleteProfile(final String profile);
-
@Nullable
public static File getProfileDirectory() {
String directoryPath = PathManager.getConfigPath() + File.separator + INSPECTION_DIR;
@@ -126,10 +104,6 @@
}
@Override
- @NotNull
- public abstract String[] getAvailableProfileNames();
-
- @Override
public Profile getProfile(@NotNull final String name) {
return getProfile(name, true);
}
diff --git a/platform/analysis-impl/src/com/intellij/profile/codeInspection/InspectionProjectProfileManager.java b/platform/analysis-impl/src/com/intellij/profile/codeInspection/InspectionProjectProfileManager.java
index 7299cbc..3eff813 100644
--- a/platform/analysis-impl/src/com/intellij/profile/codeInspection/InspectionProjectProfileManager.java
+++ b/platform/analysis-impl/src/com/intellij/profile/codeInspection/InspectionProjectProfileManager.java
@@ -34,7 +34,9 @@
* Date: 30-Nov-2005
*/
public abstract class InspectionProjectProfileManager extends DefaultProjectProfileManager implements ProjectComponent, PersistentStateComponent<Element> {
- public InspectionProjectProfileManager(final Project project, InspectionProfileManager inspectionProfileManager, DependencyValidationManager holder) {
+ public InspectionProjectProfileManager(@NotNull Project project,
+ @NotNull InspectionProfileManager inspectionProfileManager,
+ @NotNull DependencyValidationManager holder) {
super(project, inspectionProfileManager, holder);
}
diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProjectProfileManagerImpl.java b/platform/analysis-impl/src/com/intellij/profile/codeInspection/InspectionProjectProfileManagerImpl.java
similarity index 77%
rename from platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProjectProfileManagerImpl.java
rename to platform/analysis-impl/src/com/intellij/profile/codeInspection/InspectionProjectProfileManagerImpl.java
index bd144ad..34fff87 100644
--- a/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProjectProfileManagerImpl.java
+++ b/platform/analysis-impl/src/com/intellij/profile/codeInspection/InspectionProjectProfileManagerImpl.java
@@ -15,11 +15,8 @@
*/
package com.intellij.profile.codeInspection;
-import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
import com.intellij.codeInsight.daemon.impl.SeverityRegistrar;
-import com.intellij.codeInsight.daemon.impl.analysis.HighlightingSettingsPerFile;
import com.intellij.codeInspection.InspectionProfile;
-import com.intellij.codeInspection.ex.InspectionProfileImpl;
import com.intellij.codeInspection.ex.InspectionProfileWrapper;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.Application;
@@ -31,16 +28,13 @@
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
-import com.intellij.openapi.wm.WindowManager;
-import com.intellij.openapi.wm.ex.StatusBarEx;
-import com.intellij.openapi.wm.impl.status.TogglePopupHintsPanel;
import com.intellij.packageDependencies.DependencyValidationManager;
import com.intellij.profile.Profile;
+import com.intellij.profile.ProfileEx;
import com.intellij.psi.search.scope.packageSet.NamedScopeManager;
import com.intellij.psi.search.scope.packageSet.NamedScopesHolder;
import com.intellij.util.ui.UIUtil;
import org.jdom.Element;
-import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.util.HashSet;
@@ -65,13 +59,12 @@
private final Map<String, InspectionProfileWrapper> myName2Profile = new ConcurrentHashMap<String, InspectionProfileWrapper>();
private final SeverityRegistrar mySeverityRegistrar;
private final NamedScopeManager myLocalScopesHolder;
- private TogglePopupHintsPanel myTogglePopupHintsPanel;
private NamedScopesHolder.ScopeListener myScopeListener;
- public InspectionProjectProfileManagerImpl(final Project project,
- InspectionProfileManager inspectionProfileManager,
- DependencyValidationManager holder,
- NamedScopeManager localScopesHolder) {
+ public InspectionProjectProfileManagerImpl(@NotNull Project project,
+ @NotNull InspectionProfileManager inspectionProfileManager,
+ @NotNull DependencyValidationManager holder,
+ @NotNull NamedScopeManager localScopesHolder) {
super(project, inspectionProfileManager, holder);
myLocalScopesHolder = localScopesHolder;
mySeverityRegistrar = new SeverityRegistrar();
@@ -82,11 +75,6 @@
}
@Override
- public String getProfileName() {
- return getInspectionProfile().getName();
- }
-
- @Override
public Element getState() {
try {
final Element e = new Element("settings");
@@ -144,26 +132,10 @@
}
@Override
- @NotNull
- @NonNls
- public String getComponentName() {
- return "InspectionProjectProfileManager";
- }
-
- @Override
- public void initComponent() {
- }
-
- @Override
- public void disposeComponent() {
- }
-
- @Override
public void projectOpened() {
- StatusBarEx statusBar = (StatusBarEx)WindowManager.getInstance().getStatusBar(myProject);
- myTogglePopupHintsPanel = new TogglePopupHintsPanel(myProject);
- statusBar.addWidget(myTogglePopupHintsPanel, myProject);
- StartupManager.getInstance(myProject).registerPostStartupActivity(new DumbAwareRunnable() {
+ StartupManager startupManager = StartupManager.getInstance(myProject);
+ if (startupManager == null) return; // upsource
+ startupManager.registerPostStartupActivity(new DumbAwareRunnable() {
@Override
public void run() {
final Set<Profile> profiles = new HashSet<Profile>();
@@ -177,19 +149,14 @@
for (Profile profile : profiles) {
initProfileWrapper(profile);
}
- //restart daemon when profiles are ready
- ApplicationManager.getApplication().invokeLater(new Runnable() {
- @Override
- public void run() {
- DaemonCodeAnalyzer.getInstance(myProject).restart();
- }
- }, myProject.getDisposed());
+ fireProfilesInitialized();
}
};
if (app.isUnitTestMode() || app.isHeadlessEnvironment()) {
initInspectionProfilesRunnable.run();
UIUtil.dispatchAllInvocationEvents(); //do not restart daemon in the middle of the test
- } else {
+ }
+ else {
app.executeOnPooledThread(initInspectionProfilesRunnable);
}
myScopeListener = new NamedScopesHolder.ScopeListener() {
@@ -205,8 +172,8 @@
Disposer.register(myProject, new Disposable() {
@Override
public void dispose() {
- myHolder.removeScopeListener(myScopeListener);
- myLocalScopesHolder.removeScopeListener(myScopeListener);
+ myHolder.removeScopeListener(myScopeListener);
+ myLocalScopesHolder.removeScopeListener(myScopeListener);
}
});
}
@@ -222,7 +189,6 @@
@Override
public void projectClosed() {
-
final Application app = ApplicationManager.getApplication();
Runnable cleanupInspectionProfilesRunnable = new Runnable() {
@Override
@@ -230,6 +196,7 @@
for (InspectionProfileWrapper wrapper : myName2Profile.values()) {
wrapper.cleanup(myProject);
}
+ fireProfilesShutdown();
}
};
if (app.isUnitTestMode() || app.isHeadlessEnvironment()) {
@@ -238,7 +205,6 @@
else {
app.executeOnPooledThread(cleanupInspectionProfilesRunnable);
}
- HighlightingSettingsPerFile.getInstance(myProject).cleanProfileSettings();
}
@NotNull
@@ -265,10 +231,6 @@
mySeverityRegistrar.writeExternal(element);
}
- public void updateStatusBar() {
- if (myTogglePopupHintsPanel != null) myTogglePopupHintsPanel.updateStatus();
- }
-
@Override
public Profile getProfile(@NotNull final String name) {
return getProfile(name, true);
@@ -278,7 +240,7 @@
public void convert(Element element) throws InvalidDataException {
super.convert(element);
if (PROJECT_PROFILE != null) {
- ((InspectionProfileImpl)getProjectProfileImpl()).convert(element);
+ ((ProfileEx)getProjectProfileImpl()).convert(element, getProject());
}
}
}
diff --git a/platform/bootstrap/src/com/intellij/idea/Main.java b/platform/bootstrap/src/com/intellij/idea/Main.java
index e26c181..685808b 100644
--- a/platform/bootstrap/src/com/intellij/idea/Main.java
+++ b/platform/bootstrap/src/com/intellij/idea/Main.java
@@ -170,7 +170,7 @@
public static void showMessage(String title, String message, boolean error) {
if (isCommandLine()) {
PrintStream stream = error ? System.err : System.out;
- stream.println(title + ": " + message);
+ stream.println("\n" + title + ": " + message);
}
else {
try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); }
diff --git a/platform/core-api/src/com/intellij/lexer/FlexAdapter.java b/platform/core-api/src/com/intellij/lexer/FlexAdapter.java
index af805fb..cd9ccaf 100644
--- a/platform/core-api/src/com/intellij/lexer/FlexAdapter.java
+++ b/platform/core-api/src/com/intellij/lexer/FlexAdapter.java
@@ -86,7 +86,7 @@
return myEnd;
}
- private void locateToken() {
+ protected void locateToken() {
if (myTokenType != null) return;
try {
myState = myFlex.yystate();
diff --git a/platform/lang-api/src/com/intellij/lexer/LayeredLexer.java b/platform/core-api/src/com/intellij/lexer/LayeredLexer.java
similarity index 100%
rename from platform/lang-api/src/com/intellij/lexer/LayeredLexer.java
rename to platform/core-api/src/com/intellij/lexer/LayeredLexer.java
diff --git a/platform/lang-api/src/com/intellij/navigation/PsiElementNavigationItem.java b/platform/core-api/src/com/intellij/navigation/PsiElementNavigationItem.java
similarity index 100%
rename from platform/lang-api/src/com/intellij/navigation/PsiElementNavigationItem.java
rename to platform/core-api/src/com/intellij/navigation/PsiElementNavigationItem.java
diff --git a/platform/core-api/src/com/intellij/openapi/application/Application.java b/platform/core-api/src/com/intellij/openapi/application/Application.java
index 6a4d2fa..bbf39c9 100644
--- a/platform/core-api/src/com/intellij/openapi/application/Application.java
+++ b/platform/core-api/src/com/intellij/openapi/application/Application.java
@@ -331,6 +331,7 @@
* @param action to be executed
* @return future result
*/
+ @NotNull
Future<?> executeOnPooledThread(@NotNull Runnable action);
/**
@@ -338,6 +339,7 @@
* @param action to be executed
* @return future result
*/
+ @NotNull
<T> Future<T> executeOnPooledThread(@NotNull Callable<T> action);
/**
@@ -355,7 +357,7 @@
/**
* Exits and restarts IDEA. If the current platform is not restart capable, only exits.
- *
+ *
* @since 8.1
*/
void restart();
@@ -370,11 +372,13 @@
/**
* Returns lock used for read operations, should be closed in finally block
*/
+ @NotNull
AccessToken acquireReadActionLock();
/**
* Returns lock used for write operations, should be closed in finally block
*/
+ @NotNull
AccessToken acquireWriteActionLock(@Nullable Class marker);
boolean isInternal();
diff --git a/platform/core-api/src/com/intellij/openapi/components/ComponentManager.java b/platform/core-api/src/com/intellij/openapi/components/ComponentManager.java
index 1d7778f..32514a3 100644
--- a/platform/core-api/src/com/intellij/openapi/components/ComponentManager.java
+++ b/platform/core-api/src/com/intellij/openapi/components/ComponentManager.java
@@ -40,7 +40,7 @@
* @return component with given name or null if there is no such component
* @see com.intellij.openapi.components.NamedComponent#getComponentName()
*/
- BaseComponent getComponent(String name);
+ BaseComponent getComponent(@NotNull String name);
/**
* Gets the component by its interface class.
@@ -48,7 +48,7 @@
* @param interfaceClass the interface class of the component
* @return component that matches interface class or null if there is no such component
*/
- <T> T getComponent(Class<T> interfaceClass);
+ <T> T getComponent(@NotNull Class<T> interfaceClass);
/**
* Gets the component by its interface class but returns a specified default implementation
@@ -58,7 +58,7 @@
* @param defaultImplementationIfAbsent the default implementation
* @return component that matches interface class or default if there is no such component
*/
- <T> T getComponent(Class<T> interfaceClass, T defaultImplementationIfAbsent);
+ <T> T getComponent(@NotNull Class<T> interfaceClass, T defaultImplementationIfAbsent);
/**
* Checks whether there is a component with the specified interface class.
@@ -72,21 +72,22 @@
/**
* Gets all components whose implementation class is derived from <code>baseClass</code>.
*
- * @param baseClass
* @return array of components
* @deprecated use extension points instead
*/
@NotNull
- <T> T[] getComponents(Class<T> baseClass);
+ <T> T[] getComponents(@NotNull Class<T> baseClass);
@NotNull
PicoContainer getPicoContainer();
+ @NotNull
MessageBus getMessageBus();
boolean isDisposed();
- <T> T[] getExtensions(ExtensionPointName<T> extensionPointName);
+ @NotNull
+ <T> T[] getExtensions(@NotNull ExtensionPointName<T> extensionPointName);
/**
* @return condition for this component being disposed.
diff --git a/platform/core-api/src/com/intellij/openapi/project/Project.java b/platform/core-api/src/com/intellij/openapi/project/Project.java
index 84f4b9c..8c1e0fb 100644
--- a/platform/core-api/src/com/intellij/openapi/project/Project.java
+++ b/platform/core-api/src/com/intellij/openapi/project/Project.java
@@ -26,7 +26,7 @@
* Project interface class.
*/
public interface Project extends ComponentManager, AreaInstance {
- @NonNls String DIRECTORY_STORE_FOLDER = ".idea";
+ @NonNls String DIRECTORY_STORE_FOLDER = ProjectCoreUtil.DIRECTORY_BASED_PROJECT_DIR;
/**
* Returns a name ot the project. For a directory-based project it's an arbitrary string specified by user at project creation
diff --git a/platform/core-api/src/com/intellij/openapi/vfs/InvalidVirtualFileAccessException.java b/platform/core-api/src/com/intellij/openapi/vfs/InvalidVirtualFileAccessException.java
index c9b1be7..e8feca5 100644
--- a/platform/core-api/src/com/intellij/openapi/vfs/InvalidVirtualFileAccessException.java
+++ b/platform/core-api/src/com/intellij/openapi/vfs/InvalidVirtualFileAccessException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -20,6 +20,25 @@
*/
public class InvalidVirtualFileAccessException extends RuntimeException {
public InvalidVirtualFileAccessException(final VirtualFile file) {
- super("Accessing invalid virtual file: " + file.getUrl());
+ super(composeMessage(file));
+ }
+
+ private static String composeMessage(VirtualFile file) {
+ String url = file.getUrl();
+ String message = "Accessing invalid virtual file: " + url;
+
+ try {
+ VirtualFile found = VirtualFileManager.getInstance().findFileByUrl(url);
+ message += "; original:" + hashCode(file) + "; found:" + hashCode(found);
+ }
+ catch (Throwable t) {
+ message += "; lookup failed: " + t.getMessage();
+ }
+
+ return message;
+ }
+
+ private static int hashCode(Object o) {
+ return o != null ? o.hashCode() : 0;
}
}
\ No newline at end of file
diff --git a/platform/core-api/src/com/intellij/openapi/vfs/VFileProperty.java b/platform/core-api/src/com/intellij/openapi/vfs/VFileProperty.java
new file mode 100644
index 0000000..a7ffb4a
--- /dev/null
+++ b/platform/core-api/src/com/intellij/openapi/vfs/VFileProperty.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2000-2013 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.vfs;
+
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Locale;
+
+public enum VFileProperty {
+ HIDDEN, SPECIAL, SYMLINK;
+
+ @NotNull
+ public String getName() {
+ return toString().toLowerCase(Locale.ENGLISH);
+ }
+}
diff --git a/platform/core-api/src/com/intellij/openapi/vfs/VfsUtilCore.java b/platform/core-api/src/com/intellij/openapi/vfs/VfsUtilCore.java
index 20d6498..26d29d4 100644
--- a/platform/core-api/src/com/intellij/openapi/vfs/VfsUtilCore.java
+++ b/platform/core-api/src/com/intellij/openapi/vfs/VfsUtilCore.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -280,7 +280,7 @@
* Returns {@code true} if given virtual file represents broken symbolic link (which points to non-existent file).
*/
public static boolean isBrokenLink(@NotNull VirtualFile file) {
- return file.isSymLink() && file.getCanonicalPath() == null;
+ return file.is(VFileProperty.SYMLINK) && file.getCanonicalPath() == null;
}
/**
@@ -389,7 +389,7 @@
String protocol = url.getProtocol();
String path = url.getPath();
if (protocol.equals(StandardFileSystems.JAR_PROTOCOL)) {
- if (StringUtil.startsWithConcatenationOf(path, StandardFileSystems.FILE_PROTOCOL, PROTOCOL_DELIMITER)) {
+ if (StringUtil.startsWithConcatenation(path, StandardFileSystems.FILE_PROTOCOL, PROTOCOL_DELIMITER)) {
try {
URL subURL = new URL(path);
path = subURL.getPath();
diff --git a/platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java b/platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java
index 23886f4..ddb1e62 100644
--- a/platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java
+++ b/platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java
@@ -48,6 +48,42 @@
public static final Key<Object> REQUESTOR_MARKER = Key.create("REQUESTOR_MARKER");
public static final VirtualFile[] EMPTY_ARRAY = new VirtualFile[0];
+ /**
+ * Used as a property name in the {@link VirtualFilePropertyEvent} fired when the name of a
+ * {@link VirtualFile} changes.
+ *
+ * @see VirtualFileListener#propertyChanged
+ * @see VirtualFilePropertyEvent#getPropertyName
+ */
+ @NonNls public static final String PROP_NAME = "name";
+
+ /**
+ * Used as a property name in the {@link VirtualFilePropertyEvent} fired when the encoding of a
+ * {@link VirtualFile} changes.
+ *
+ * @see VirtualFileListener#propertyChanged
+ * @see VirtualFilePropertyEvent#getPropertyName
+ */
+ @NonNls public static final String PROP_ENCODING = "encoding";
+
+ /**
+ * Used as a property name in the {@link VirtualFilePropertyEvent} fired when the write permission of a
+ * {@link VirtualFile} changes.
+ *
+ * @see VirtualFileListener#propertyChanged
+ * @see VirtualFilePropertyEvent#getPropertyName
+ */
+ @NonNls public static final String PROP_WRITABLE = "writable";
+
+ /**
+ * Used as a property name in the {@link VirtualFilePropertyEvent} fired when a visibility of a
+ * {@link VirtualFile} changes.
+ *
+ * @see VirtualFileListener#propertyChanged
+ * @see VirtualFilePropertyEvent#getPropertyName
+ */
+ @NonNls public static final String PROP_HIDDEN = VFileProperty.HIDDEN.getName();
+
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vfs.VirtualFile");
private static final Key<byte[]> BOM_KEY = Key.create("BOM");
private static final Key<Charset> CHARSET_KEY = Key.create("CHARSET");
@@ -111,47 +147,6 @@
}
/**
- * Used as a property name in the {@link VirtualFilePropertyEvent} fired when the name of a
- * {@link VirtualFile} changes.
- *
- * @see VirtualFileListener#propertyChanged
- * @see VirtualFilePropertyEvent#getPropertyName
- */
- @NonNls public static final String PROP_NAME = "name";
-
- /**
- * Used as a property name in the {@link VirtualFilePropertyEvent} fired when the encoding of a
- * {@link VirtualFile} changes.
- *
- * @see VirtualFileListener#propertyChanged
- * @see VirtualFilePropertyEvent#getPropertyName
- */
- @NonNls public static final String PROP_ENCODING = "encoding";
-
- /**
- * Used as a property name in the {@link VirtualFilePropertyEvent} fired when the write permission of a
- * {@link VirtualFile} changes.
- *
- * @see VirtualFileListener#propertyChanged
- * @see VirtualFilePropertyEvent#getPropertyName
- */
- @NonNls public static final String PROP_WRITABLE = "writable";
-
- /**
- * Used as a property name in the {@link VirtualFilePropertyEvent} fired when a visibility of a
- * {@link VirtualFile} changes.
- *
- * @see VirtualFileListener#propertyChanged
- * @see VirtualFilePropertyEvent#getPropertyName
- */
- @NonNls public static final String PROP_HIDDEN = "hidden";
-
- /**
- * Used as a property name in the {@link #is(String)}.
- */
- @NonNls public static final String PROP_SPECIAL = "special";
-
- /**
* Gets the extension of this file. If file name contains '.' extension is the substring from the last '.'
* to the end of the name, otherwise extension is null.
*
@@ -211,6 +206,10 @@
*/
public abstract boolean isWritable();
+ public void setWritable(boolean writable) throws IOException {
+ throw new IOException("Not supported");
+ }
+
/**
* Checks whether this file is a directory.
*
@@ -218,30 +217,25 @@
*/
public abstract boolean isDirectory();
- /**
- * Checks whether this file is a symbolic link.
- *
- * @return <code>true</code> if this file is a symbolic link, <code>false</code> otherwise
- * @since 11.0
- */
+ /** @deprecated use {@link #is(VFileProperty)} (to remove in IDEA 14) */
+ @SuppressWarnings("UnusedDeclaration")
public boolean isSymLink() {
- return false;
+ return is(VFileProperty.SYMLINK);
}
- /** @deprecated use {@link #is(String)} (to remove in IDEA 14) */
+ /** @deprecated use {@link #is(VFileProperty)} (to remove in IDEA 14) */
@SuppressWarnings("UnusedDeclaration")
public boolean isSpecialFile() {
- return is(PROP_SPECIAL);
+ return is(VFileProperty.SPECIAL);
}
/**
* Checks whether this file has a specific property.
- * Examples of such properties are {@link #PROP_HIDDEN} or {@link #PROP_SPECIAL}.
*
* @return <code>true</code> if the file has a specific property, <code>false</code> otherwise
* @since 13.0
*/
- public boolean is(String property) {
+ public boolean is(@NotNull VFileProperty property) {
return false;
}
@@ -358,7 +352,7 @@
child = this;
}
else if (name.equals("..")) {
- if (isSymLink()) {
+ if (is(VFileProperty.SYMLINK)) {
final VirtualFile canonicalFile = getCanonicalFile();
child = canonicalFile != null ? canonicalFile.getParent() : null;
}
diff --git a/platform/core-api/src/com/intellij/openapi/vfs/VirtualFileVisitor.java b/platform/core-api/src/com/intellij/openapi/vfs/VirtualFileVisitor.java
index 5a8fae9..aa2af4f 100644
--- a/platform/core-api/src/com/intellij/openapi/vfs/VirtualFileVisitor.java
+++ b/platform/core-api/src/com/intellij/openapi/vfs/VirtualFileVisitor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -168,7 +168,7 @@
}
final boolean allowVisitChildren(@NotNull VirtualFile file) {
- return !file.isSymLink() || myFollowSymLinks && !VfsUtilCore.isInvalidLink(file);
+ return !file.is(VFileProperty.SYMLINK) || myFollowSymLinks && !VfsUtilCore.isInvalidLink(file);
}
final boolean depthLimitReached() {
diff --git a/platform/lang-api/src/com/intellij/psi/IdentitySmartPointer.java b/platform/core-api/src/com/intellij/psi/IdentitySmartPointer.java
similarity index 100%
rename from platform/lang-api/src/com/intellij/psi/IdentitySmartPointer.java
rename to platform/core-api/src/com/intellij/psi/IdentitySmartPointer.java
diff --git a/platform/core-api/src/com/intellij/psi/PsiLanguageInjectionHost.java b/platform/core-api/src/com/intellij/psi/PsiLanguageInjectionHost.java
index 3d84036..c1e015e 100644
--- a/platform/core-api/src/com/intellij/psi/PsiLanguageInjectionHost.java
+++ b/platform/core-api/src/com/intellij/psi/PsiLanguageInjectionHost.java
@@ -20,6 +20,7 @@
import com.intellij.openapi.util.TextRange;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import com.intellij.lang.injection.*;
import java.util.List;
@@ -29,7 +30,7 @@
* but is used by IDEA for highlighting, completion and other code insight actions.
* In order to do the injection, you have to
* <ul>
- * <li>Implement {@link com.intellij.psi.LanguageInjector} to describe exact place where injection should occur.</li>
+ * <li>Implement {@link com.intellij.psi.LanguageInjector} to describe exact place where injection should occur.</li>
* <li>Register injection in {@link com.intellij.psi.LanguageInjector#EXTENSION_POINT_NAME} extension point.</li>
* </ul>
* Currently, language can be injected into string literals, XML tag contents and XML attributes.
@@ -40,7 +41,7 @@
boolean isValidHost();
PsiLanguageInjectionHost updateText(@NotNull String text);
-
+
@NotNull
LiteralTextEscaper<? extends PsiLanguageInjectionHost> createLiteralTextEscaper();
diff --git a/platform/core-api/src/com/intellij/psi/search/LocalSearchScope.java b/platform/core-api/src/com/intellij/psi/search/LocalSearchScope.java
index e1474d8..fa5f638 100644
--- a/platform/core-api/src/com/intellij/psi/search/LocalSearchScope.java
+++ b/platform/core-api/src/com/intellij/psi/search/LocalSearchScope.java
@@ -23,7 +23,6 @@
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtilCore;
-import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -35,6 +34,7 @@
public class LocalSearchScope extends SearchScope {
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.search.LocalSearchScope");
+ @NotNull
private final PsiElement[] myScope;
private final boolean myIgnoreInjectedPsi;
@@ -67,8 +67,10 @@
LOG.assertTrue(element != null, "null element");
LOG.assertTrue(element.getContainingFile() != null, element.getClass().getName());
if (element instanceof PsiFile) {
- List<PsiFile> files = ((PsiFile)element).getViewProvider().getAllFiles();
- ContainerUtil.addAll(localScope, files);
+ for (PsiFile file : ((PsiFile)element).getViewProvider().getAllFiles()) {
+ if (file == null) throw new IllegalArgumentException("file "+element+" returned null in its getAllFiles()");
+ localScope.add(file);
+ }
}
else if (element.getTextRange() != null){
localScope.add(element);
@@ -86,6 +88,7 @@
return myDisplayName == null ? super.getDisplayName() : myDisplayName;
}
+ @NotNull
public PsiElement[] getScope() {
return myScope;
}
diff --git a/platform/core-api/src/com/intellij/psi/tree/IElementType.java b/platform/core-api/src/com/intellij/psi/tree/IElementType.java
index 0219e58..b64d761 100644
--- a/platform/core-api/src/com/intellij/psi/tree/IElementType.java
+++ b/platform/core-api/src/com/intellij/psi/tree/IElementType.java
@@ -23,6 +23,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
* Interface for token types returned from lexical analysis and for types
@@ -53,8 +54,15 @@
public static final short MAX_INDEXED_TYPES = 15000;
private static short ourCounter = FIRST_TOKEN_INDEX;
- private static final List<IElementType> ourRegistry = new ArrayList<IElementType>(700);
+ private static IElementType[] ourRegistry = new IElementType[700];
+ private static final ReentrantReadWriteLock.ReadLock ourRegistryReadLock;
+ private static final ReentrantReadWriteLock.WriteLock ourRegistryWriteLock;
+ static {
+ ReentrantReadWriteLock ourLock = new ReentrantReadWriteLock();
+ ourRegistryReadLock = ourLock.readLock();
+ ourRegistryWriteLock = ourLock.writeLock();
+ }
private final short myIndex;
@NotNull private final String myDebugName;
@NotNull private final Language myLanguage;
@@ -74,10 +82,20 @@
myLanguage = language == null ? Language.ANY : language;
if (register) {
//noinspection AssignmentToStaticFieldFromInstanceMethod
- myIndex = ourCounter++;
- LOG.assertTrue(ourCounter < MAX_INDEXED_TYPES, "Too many element types registered. Out of (short) range.");
- synchronized (ourRegistry) {
- ourRegistry.add(this);
+ ourRegistryWriteLock.lock();
+ try {
+ myIndex = ourCounter++;
+ LOG.assertTrue(myIndex < MAX_INDEXED_TYPES, "Too many element types registered. Out of (short) range.");
+ final int registryIndex = myIndex - FIRST_TOKEN_INDEX;
+
+ if (ourRegistry.length == registryIndex) {
+ IElementType[] newRegistry = new IElementType[ourRegistry.length << 1];
+ System.arraycopy(ourRegistry, 0, newRegistry, 0, ourRegistry.length);
+ ourRegistry = newRegistry;
+ }
+ ourRegistry[registryIndex] = this; // overflow
+ } finally {
+ ourRegistryWriteLock.unlock();
}
}
else {
@@ -142,10 +160,13 @@
* @throws IndexOutOfBoundsException if the index is out of registered elements' range.
*/
public static IElementType find(short idx) {
- synchronized (ourRegistry) {
- if (idx == 0) return ourRegistry.get(0); // We've changed FIRST_TOKEN_INDEX from 0 to 1. This is just for old plugins to avoid crashes.
- if (idx >= ourRegistry.size() + FIRST_TOKEN_INDEX) return null;
- return ourRegistry.get(idx - FIRST_TOKEN_INDEX);
+ ourRegistryReadLock.lock();
+ try {
+ if (idx == 0) return ourRegistry[0]; // We've changed FIRST_TOKEN_INDEX from 0 to 1. This is just for old plugins to avoid crashes.
+ if (idx >= ourCounter) return null;
+ return ourRegistry[idx - FIRST_TOKEN_INDEX];
+ } finally {
+ ourRegistryReadLock.unlock();
}
}
@@ -171,8 +192,12 @@
@NotNull
public static IElementType[] enumerate(@NotNull Predicate p) {
IElementType[] copy;
- synchronized (ourRegistry) {
- copy = ourRegistry.toArray(new IElementType[ourRegistry.size()]);
+ ourRegistryReadLock.lock();
+ try {
+ copy = new IElementType[ourCounter - FIRST_TOKEN_INDEX];
+ System.arraycopy(ourRegistry, 0, copy, 0, ourCounter - FIRST_TOKEN_INDEX);
+ } finally {
+ ourRegistryReadLock.unlock();
}
List<IElementType> matches = new ArrayList<IElementType>();
diff --git a/platform/core-api/src/com/intellij/util/IconUtil.java b/platform/core-api/src/com/intellij/util/IconUtil.java
index ff9c5a8..0327435 100644
--- a/platform/core-api/src/com/intellij/util/IconUtil.java
+++ b/platform/core-api/src/com/intellij/util/IconUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -25,6 +25,7 @@
import com.intellij.openapi.util.Iconable;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.SystemInfo;
+import com.intellij.openapi.vfs.VFileProperty;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.WritingAccessProvider;
import com.intellij.ui.IconDeferrer;
@@ -142,7 +143,7 @@
(!file.isWritable() || !WritingAccessProvider.isPotentiallyWritable(file, project))) {
icon = new LayeredIcon(icon, PlatformIcons.LOCKED_ICON);
}
- if (file.isSymLink()) {
+ if (file.is(VFileProperty.SYMLINK)) {
icon = new LayeredIcon(icon, PlatformIcons.SYMLINK_ICON);
}
@@ -284,7 +285,7 @@
}
/**
- * Result icons look like original but have equal (maximum) size
+ * Result icons look like original but have equal (maximum) size
*/
@NotNull
public static Icon[] getEqualSizedIcons(@NotNull Icon... icons) {
diff --git a/platform/core-impl/src/com/intellij/ide/plugins/IdeaPluginDescriptorImpl.java b/platform/core-impl/src/com/intellij/ide/plugins/IdeaPluginDescriptorImpl.java
index e1d2b77..7d09201 100644
--- a/platform/core-impl/src/com/intellij/ide/plugins/IdeaPluginDescriptorImpl.java
+++ b/platform/core-impl/src/com/intellij/ide/plugins/IdeaPluginDescriptorImpl.java
@@ -115,7 +115,9 @@
@NotNull
public static String intern(@NotNull String s) {
- return ourInterner.intern(s);
+ synchronized (ourInterner) {
+ return ourInterner.intern(s);
+ }
}
public static void internJDOMElement(@NotNull Element rootElement) {
diff --git a/platform/core-impl/src/com/intellij/ide/plugins/PluginManagerCore.java b/platform/core-impl/src/com/intellij/ide/plugins/PluginManagerCore.java
index bb67286..9ffddbc 100644
--- a/platform/core-impl/src/com/intellij/ide/plugins/PluginManagerCore.java
+++ b/platform/core-impl/src/com/intellij/ide/plugins/PluginManagerCore.java
@@ -27,10 +27,7 @@
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.extensions.LogProvider;
import com.intellij.openapi.extensions.PluginId;
-import com.intellij.openapi.util.BuildNumber;
-import com.intellij.openapi.util.Comparing;
-import com.intellij.openapi.util.Condition;
-import com.intellij.openapi.util.JDOMUtil;
+import com.intellij.openapi.util.*;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.ArrayUtil;
@@ -93,27 +90,19 @@
public static void loadDisabledPlugins(final String configPath, final Collection<String> disabledPlugins) {
final File file = new File(configPath, DISABLED_PLUGINS_FILENAME);
if (file.isFile()) {
- BufferedReader reader = null;
try {
- reader = new BufferedReader(new FileReader(file));
- String id;
- while ((id = reader.readLine()) != null) {
- disabledPlugins.add(id.trim());
- }
- }
- catch (IOException e) {
- //do nothing
- }
- finally {
+ BufferedReader reader = new BufferedReader(new FileReader(file));
try {
- if (reader != null) {
- reader.close();
+ String id;
+ while ((id = reader.readLine()) != null) {
+ disabledPlugins.add(id.trim());
}
}
- catch (IOException e) {
- //do nothing
+ finally {
+ reader.close();
}
}
+ catch (IOException ignored) { }
}
}
@@ -137,18 +126,15 @@
if (!plugins.isFile()) {
FileUtil.ensureCanCreateFile(plugins);
}
- PrintWriter printWriter = null;
+ PrintWriter printWriter = new PrintWriter(new BufferedWriter(new FileWriter(plugins, append)));
try {
- printWriter = new PrintWriter(new BufferedWriter(new FileWriter(plugins, append)));
for (String id : ids) {
printWriter.println(id);
}
printWriter.flush();
}
finally {
- if (printWriter != null) {
- printWriter.close();
- }
+ printWriter.close();
}
}
@@ -233,7 +219,7 @@
Map<PluginId, IdeaPluginDescriptor> map,
final boolean checkModuleDependencies) {
for (PluginId id: descriptor.getDependentPluginIds()) {
- if (ArrayUtil.contains(id, descriptor.getOptionalDependentPluginIds())) {
+ if (ArrayUtil.contains(id, (Object[])descriptor.getOptionalDependentPluginIds())) {
continue;
}
if (!checkModuleDependencies && isModuleDependency(id)) {
@@ -412,19 +398,16 @@
return 0;
}
- @SuppressWarnings({"EmptyCatchBlock"})
static Collection<URL> getClassLoaderUrls() {
final ClassLoader classLoader = PluginManagerCore.class.getClassLoader();
final Class<? extends ClassLoader> aClass = classLoader.getClass();
try {
- return (List<URL>)aClass.getMethod("getUrls").invoke(classLoader);
+ @SuppressWarnings("unchecked") List<URL> urls = (List<URL>)aClass.getMethod("getUrls").invoke(classLoader);
+ return urls;
}
- catch (IllegalAccessException e) {
- }
- catch (InvocationTargetException e) {
- }
- catch (NoSuchMethodException e) {
- }
+ catch (IllegalAccessException ignored) { }
+ catch (InvocationTargetException ignored) { }
+ catch (NoSuchMethodException ignored) { }
if (classLoader instanceof URLClassLoader) {
return Arrays.asList(((URLClassLoader)classLoader).getURLs());
@@ -448,10 +431,10 @@
}
}
- static <T extends IdeaPluginDescriptor> void addModulesAsDependents(final Map<PluginId, T> map) {
+ private static void addModulesAsDependents(Map<PluginId, ? super IdeaPluginDescriptorImpl> map) {
for (String module : ourAvailableModules) {
// fake plugin descriptors to satisfy dependencies
- map.put(PluginId.getId(module), (T) new IdeaPluginDescriptorImpl());
+ map.put(PluginId.getId(module), new IdeaPluginDescriptorImpl());
}
}
@@ -648,7 +631,7 @@
if (optionalDescriptor == null && !FileUtil.isJarOrZip(file)) {
for (URL url : getClassLoaderUrls()) {
if ("file".equals(url.getProtocol())) {
- optionalDescriptor = loadDescriptor(new File(URLDecoder.decode(url.getFile())), optionalDescriptorName);
+ optionalDescriptor = loadDescriptor(new File(decodeUrl(url.getFile())), optionalDescriptorName);
if (optionalDescriptor != null) {
break;
}
@@ -795,51 +778,46 @@
return null;
}
- @SuppressWarnings({"UseOfSystemOutOrSystemErr", "CallToPrintStackTrace"})
- static void loadDescriptorsFromClassPath(final List<IdeaPluginDescriptorImpl> result, @Nullable StartupProgress progress) {
- try {
- final Collection<URL> urls = getClassLoaderUrls();
- final String platformPrefix = System.getProperty(PlatformUtilsCore.PLATFORM_PREFIX_KEY);
- int i = 0;
- for (URL url : urls) {
- i++;
- final String protocol = url.getProtocol();
- if ("file".equals(protocol)) {
- final File file = new File(URLDecoder.decode(url.getFile()));
- //final String canonicalPath = file.getCanonicalPath();
- //if (!canonicalPath.startsWith(homePath) || canonicalPath.endsWith(".jar")) continue;
- //if (!canonicalPath.startsWith(homePath)) continue;
+ static void loadDescriptorsFromClassPath(@NotNull List<IdeaPluginDescriptorImpl> result, @Nullable StartupProgress progress) {
+ Collection<URL> urls = getClassLoaderUrls();
+ String platformPrefix = System.getProperty(PlatformUtilsCore.PLATFORM_PREFIX_KEY);
+ int i = 0;
+ for (URL url : urls) {
+ i++;
+ if ("file".equals(url.getProtocol())) {
+ File file = new File(decodeUrl(url.getFile()));
- IdeaPluginDescriptorImpl platformPluginDescriptor = null;
- if (platformPrefix != null) {
- platformPluginDescriptor = loadDescriptor(file, platformPrefix + "Plugin.xml");
- if (platformPluginDescriptor != null && !result.contains(platformPluginDescriptor)) {
- platformPluginDescriptor.setUseCoreClassLoader(true);
- result.add(platformPluginDescriptor);
- }
+ IdeaPluginDescriptorImpl platformPluginDescriptor = null;
+ if (platformPrefix != null) {
+ platformPluginDescriptor = loadDescriptor(file, platformPrefix + "Plugin.xml");
+ if (platformPluginDescriptor != null && !result.contains(platformPluginDescriptor)) {
+ platformPluginDescriptor.setUseCoreClassLoader(true);
+ result.add(platformPluginDescriptor);
}
+ }
- IdeaPluginDescriptorImpl pluginDescriptor = loadDescriptor(file, PLUGIN_XML);
- if (platformPrefix != null && pluginDescriptor != null && pluginDescriptor.getName().equals(SPECIAL_IDEA_PLUGIN)) {
- continue;
+ IdeaPluginDescriptorImpl pluginDescriptor = loadDescriptor(file, PLUGIN_XML);
+ if (platformPrefix != null && pluginDescriptor != null && pluginDescriptor.getName().equals(SPECIAL_IDEA_PLUGIN)) {
+ continue;
+ }
+ if (pluginDescriptor != null && !result.contains(pluginDescriptor)) {
+ if (platformPluginDescriptor != null) {
+ // if we found a regular plugin.xml in the same .jar/root as a platform-prefixed descriptor, use the core loader for it too
+ pluginDescriptor.setUseCoreClassLoader(true);
}
- if (pluginDescriptor != null && !result.contains(pluginDescriptor)) {
- if (platformPluginDescriptor != null) {
- // if we found a regular plugin.xml in the same .jar/root as a platform-prefixed descriptor, use the core loader for it too
- pluginDescriptor.setUseCoreClassLoader(true);
- }
- result.add(pluginDescriptor);
- if (progress != null) {
- progress.showProgress("Plugin loaded: " + pluginDescriptor.getName(), PLUGINS_PROGRESS_MAX_VALUE * ((float)i / urls.size()));
- }
+ result.add(pluginDescriptor);
+ if (progress != null) {
+ progress.showProgress("Plugin loaded: " + pluginDescriptor.getName(), PLUGINS_PROGRESS_MAX_VALUE * ((float)i / urls.size()));
}
}
}
}
- catch (Exception e) {
- System.err.println("Error loading plugins from classpath:");
- e.printStackTrace();
- }
+ }
+
+ @SuppressWarnings("deprecation")
+ private static String decodeUrl(String file) {
+ String quotePluses = StringUtil.replace(file, "+", "%2B");
+ return URLDecoder.decode(quotePluses);
}
static void loadDescriptorsFromProperty(final List<IdeaPluginDescriptorImpl> result) {
diff --git a/platform/core-impl/src/com/intellij/mock/MockApplication.java b/platform/core-impl/src/com/intellij/mock/MockApplication.java
index b5a8eb1..6ae8944 100644
--- a/platform/core-impl/src/com/intellij/mock/MockApplication.java
+++ b/platform/core-impl/src/com/intellij/mock/MockApplication.java
@@ -85,11 +85,13 @@
return true;
}
+ @NotNull
@Override
public Future<?> executeOnPooledThread(@NotNull Runnable action) {
return ExecutorServiceHolder.ourThreadExecutorsService.submit(action);
}
+ @NotNull
@Override
public <T> Future<T> executeOnPooledThread(@NotNull Callable<T> action) {
return ExecutorServiceHolder.ourThreadExecutorsService.submit(action);
@@ -139,11 +141,13 @@
return computation.compute();
}
+ @NotNull
@Override
public AccessToken acquireReadActionLock() {
return AccessToken.EMPTY_ACCESS_TOKEN;
}
+ @NotNull
@Override
public AccessToken acquireWriteActionLock(@Nullable Class marker) {
return AccessToken.EMPTY_ACCESS_TOKEN;
@@ -250,10 +254,10 @@
@Override
public void saveSettings() {
}
-
+
private static class ExecutorServiceHolder {
private static final ExecutorService ourThreadExecutorsService = createServiceImpl();
-
+
private static ThreadPoolExecutor createServiceImpl() {
return new ThreadPoolExecutor(10, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), new ThreadFactory() {
@NotNull
diff --git a/platform/core-impl/src/com/intellij/mock/MockComponentManager.java b/platform/core-impl/src/com/intellij/mock/MockComponentManager.java
index f2261cc..6950a31 100644
--- a/platform/core-impl/src/com/intellij/mock/MockComponentManager.java
+++ b/platform/core-impl/src/com/intellij/mock/MockComponentManager.java
@@ -63,7 +63,7 @@
}
@Override
- public BaseComponent getComponent(String name) {
+ public BaseComponent getComponent(@NotNull String name) {
return null;
}
@@ -85,13 +85,13 @@
}
@Override
- public <T> T getComponent(Class<T> interfaceClass) {
+ public <T> T getComponent(@NotNull Class<T> interfaceClass) {
final Object o = myPicoContainer.getComponentInstance(interfaceClass);
return (T)(o != null ? o : myComponents.get(interfaceClass));
}
@Override
- public <T> T getComponent(Class<T> interfaceClass, T defaultImplementation) {
+ public <T> T getComponent(@NotNull Class<T> interfaceClass, T defaultImplementation) {
return getComponent(interfaceClass);
}
@@ -102,7 +102,7 @@
@Override
@NotNull
- public <T> T[] getComponents(Class<T> baseClass) {
+ public <T> T[] getComponents(@NotNull Class<T> baseClass) {
final List<?> list = myPicoContainer.getComponentInstancesOfType(baseClass);
return list.toArray((T[])Array.newInstance(baseClass, 0));
}
@@ -113,6 +113,7 @@
return myPicoContainer;
}
+ @NotNull
@Override
public MessageBus getMessageBus() {
return myMessageBus;
@@ -127,8 +128,9 @@
public void dispose() {
}
+ @NotNull
@Override
- public <T> T[] getExtensions(final ExtensionPointName<T> extensionPointName) {
+ public <T> T[] getExtensions(@NotNull final ExtensionPointName<T> extensionPointName) {
throw new UnsupportedOperationException("getExtensions()");
}
diff --git a/platform/core-impl/src/com/intellij/mock/MockProject.java b/platform/core-impl/src/com/intellij/mock/MockProject.java
index c5d8c8f..c1418a0 100644
--- a/platform/core-impl/src/com/intellij/mock/MockProject.java
+++ b/platform/core-impl/src/com/intellij/mock/MockProject.java
@@ -136,8 +136,9 @@
public void save() {
}
+ @NotNull
@Override
- public <T> T[] getExtensions(final ExtensionPointName<T> extensionPointName) {
+ public <T> T[] getExtensions(@NotNull final ExtensionPointName<T> extensionPointName) {
return Extensions.getArea(this).getExtensionPoint(extensionPointName).getExtensions();
}
diff --git a/platform/core-impl/src/com/intellij/openapi/components/ComponentSerializationUtil.java b/platform/core-impl/src/com/intellij/openapi/components/ComponentSerializationUtil.java
new file mode 100644
index 0000000..edf85e0
--- /dev/null
+++ b/platform/core-impl/src/com/intellij/openapi/components/ComponentSerializationUtil.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2000-2013 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.components;
+
+import com.intellij.util.ReflectionUtil;
+
+import java.lang.reflect.TypeVariable;
+
+/**
+ * @author nik
+ */
+public class ComponentSerializationUtil {
+ public static Class getStateClass(final Class<? extends PersistentStateComponent> aClass) {
+ TypeVariable<Class<PersistentStateComponent>> variable = PersistentStateComponent.class.getTypeParameters()[0];
+ return ReflectionUtil.getRawType(ReflectionUtil.resolveVariableInHierarchy(variable, aClass));
+ }
+}
diff --git a/platform/core-impl/src/com/intellij/openapi/components/impl/ComponentManagerImpl.java b/platform/core-impl/src/com/intellij/openapi/components/impl/ComponentManagerImpl.java
index a33f221..855c352 100644
--- a/platform/core-impl/src/com/intellij/openapi/components/impl/ComponentManagerImpl.java
+++ b/platform/core-impl/src/com/intellij/openapi/components/impl/ComponentManagerImpl.java
@@ -90,6 +90,7 @@
initComponents();
}
+ @NotNull
@Override
public MessageBus getMessageBus() {
assert !myDisposeCompleted && !myDisposed : "Already disposed";
@@ -185,13 +186,13 @@
}
@Override
- public <T> T getComponent(Class<T> interfaceClass) {
+ public <T> T getComponent(@NotNull Class<T> interfaceClass) {
assert !myDisposeCompleted : "Already disposed: "+this;
return getComponent(interfaceClass, null);
}
@Override
- public <T> T getComponent(Class<T> interfaceClass, T defaultImplementation) {
+ public <T> T getComponent(@NotNull Class<T> interfaceClass, T defaultImplementation) {
final T fromContainer = getComponentFromContainer(interfaceClass);
if (fromContainer != null) return fromContainer;
if (defaultImplementation != null) return defaultImplementation;
@@ -255,7 +256,7 @@
@Override
@SuppressWarnings({"unchecked"})
@NotNull
- public synchronized <T> T[] getComponents(Class<T> baseClass) {
+ public synchronized <T> T[] getComponents(@NotNull Class<T> baseClass) {
return myComponentsRegistry.getComponentsByType(baseClass);
}
@@ -280,7 +281,7 @@
}
@Override
- public synchronized BaseComponent getComponent(String name) {
+ public synchronized BaseComponent getComponent(@NotNull String name) {
return myComponentsRegistry.getComponentByName(name);
}
diff --git a/platform/core-impl/src/com/intellij/openapi/fileEditor/impl/LoadTextUtil.java b/platform/core-impl/src/com/intellij/openapi/fileEditor/impl/LoadTextUtil.java
index 314d86b..ed515aa 100644
--- a/platform/core-impl/src/com/intellij/openapi/fileEditor/impl/LoadTextUtil.java
+++ b/platform/core-impl/src/com/intellij/openapi/fileEditor/impl/LoadTextUtil.java
@@ -98,7 +98,14 @@
detectedLineSeparator = "\n";
}
- CharSequence result = buffer.length() == dst ? buffer : buffer.subSequence(0, dst);
+ CharSequence result;
+ if (buffer.length() == dst) {
+ result = buffer;
+ }
+ else {
+ // in Mac JDK CharBuffer.subSequence() signature differs from Oracle
+ result = buffer.subSequence(0, dst);
+ }
return Pair.create(result, detectedLineSeparator);
}
@@ -217,12 +224,9 @@
* <p/>
* Normally you should not use this method.
*
- * @param project
- * @param virtualFile
* @param requestor any object to control who called this method. Note that
* it is considered to be an external change if <code>requestor</code> is <code>null</code>.
* See {@link com.intellij.openapi.vfs.VirtualFileEvent#getRequestor}
- * @param text
* @param newModificationStamp new modification stamp or -1 if no special value should be set @return <code>Writer</code>
* @throws java.io.IOException if an I/O error occurs
* @see VirtualFile#getModificationStamp()
@@ -286,8 +290,6 @@
try {
if (existing == null) return Pair.create(specified, toBytes(text, specified));
if (specified == null || specified.equals(existing)) return Pair.create(specified, toBytes(text, existing));
- if (existing == null) return Pair.create(specified, toBytes(text, specified));
- if (specified == null || specified.equals(existing)) return Pair.create(specified, toBytes(text, existing));
byte[] out = isSupported(specified, text);
if (out != null) return Pair.create(specified, out); //if explicitly specified encoding is safe, return it
diff --git a/platform/core-impl/src/com/intellij/openapi/progress/util/TooManyUsagesStatus.java b/platform/core-impl/src/com/intellij/openapi/progress/util/TooManyUsagesStatus.java
index edaed93..9aa1efb 100644
--- a/platform/core-impl/src/com/intellij/openapi/progress/util/TooManyUsagesStatus.java
+++ b/platform/core-impl/src/com/intellij/openapi/progress/util/TooManyUsagesStatus.java
@@ -87,7 +87,6 @@
@Override
public void pauseProcessingIfTooManyUsages() {
- int i = 0;
}
}
}
diff --git a/platform/core-impl/src/com/intellij/pom/core/impl/PomModelImpl.java b/platform/core-impl/src/com/intellij/pom/core/impl/PomModelImpl.java
index b3e62f1..9b00977 100644
--- a/platform/core-impl/src/com/intellij/pom/core/impl/PomModelImpl.java
+++ b/platform/core-impl/src/com/intellij/pom/core/impl/PomModelImpl.java
@@ -17,29 +17,36 @@
import com.intellij.lang.ASTNode;
import com.intellij.openapi.Disposable;
+import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
+import com.intellij.openapi.progress.EmptyProgressIndicator;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressIndicatorProvider;
-import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Pair;
+import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.UserDataHolderBase;
+import com.intellij.openapi.util.text.StringUtil;
import com.intellij.pom.PomModel;
import com.intellij.pom.PomModelAspect;
import com.intellij.pom.PomTransaction;
import com.intellij.pom.event.PomModelEvent;
import com.intellij.pom.event.PomModelListener;
+import com.intellij.pom.impl.PomTransactionBase;
+import com.intellij.pom.tree.TreeAspect;
+import com.intellij.pom.tree.TreeAspectEvent;
import com.intellij.psi.*;
-import com.intellij.psi.impl.PsiDocumentManagerBase;
-import com.intellij.psi.impl.PsiManagerImpl;
-import com.intellij.psi.impl.PsiToDocumentSynchronizer;
+import com.intellij.psi.codeStyle.CodeStyleManager;
+import com.intellij.psi.impl.*;
import com.intellij.psi.impl.source.PsiFileImpl;
import com.intellij.psi.impl.source.text.BlockSupportImpl;
+import com.intellij.psi.impl.source.text.DiffLog;
import com.intellij.psi.impl.source.tree.FileElement;
import com.intellij.psi.impl.source.tree.TreeElement;
import com.intellij.psi.impl.source.tree.TreeUtil;
+import com.intellij.psi.text.BlockSupport;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.containers.ContainerUtil;
@@ -223,9 +230,67 @@
BlockSupportImpl.sendAfterChildrenChangedEvent((PsiManagerImpl)PsiManager.getInstance(myProject), (PsiFileImpl)containingFileByTree, oldLength, true);
}
}
+ if (containingFileByTree != null) {
+ boolean isFromCommit = ApplicationManager.getApplication().isDispatchThread() &&
+ ApplicationManager.getApplication().hasWriteAction(CommitToPsiFileAction.class);
+ if (!isFromCommit && !synchronizer.isIgnorePsiEvents()) {
+ reparseParallelTrees(containingFileByTree);
+ }
+ }
if (progressIndicator != null) progressIndicator.finishNonCancelableSection();
}
+
+ private void reparseParallelTrees(PsiFile changedFile) {
+ List<PsiFile> allFiles = changedFile.getViewProvider().getAllFiles();
+ if (allFiles.size() <= 1) {
+ return;
+ }
+
+ String newText = changedFile.getNode().getText();
+ for (final PsiFile file : allFiles) {
+ if (file != changedFile) {
+ FileElement fileElement = ((PsiFileImpl)file).getTreeElement();
+ if (fileElement != null) {
+ String oldText = fileElement.getText();
+ try {
+ reparseFile(file, newText, oldText);
+ }
+ finally {
+ TextBlock.get(file).clear();
+ }
+ }
+ }
+ }
+ }
+
+ private void reparseFile(final PsiFile file, String newText, String oldText) {
+ if (oldText.equals(newText)) return;
+
+ PsiToDocumentSynchronizer synchronizer =((PsiDocumentManagerBase)PsiDocumentManager.getInstance(myProject)).getSynchronizer();
+ int changeStart = StringUtil.commonPrefixLength(oldText, newText);
+ int changeEnd = oldText.length() - StringUtil.commonSuffixLength(oldText, newText);
+ TextRange changedPsiRange = DocumentCommitProcessor.getChangedPsiRange(file, changeStart, changeEnd, newText.length());
+ final DiffLog log = BlockSupport.getInstance(myProject).reparseRange(file, changedPsiRange, newText, new EmptyProgressIndicator());
+ synchronizer.setIgnorePsiEvents(true);
+ try {
+ CodeStyleManager.getInstance(file.getProject()).performActionWithFormatterDisabled(new Runnable() {
+ @Override
+ public void run() {
+ runTransaction(new PomTransactionBase(file, getModelAspect(TreeAspect.class)) {
+ @Nullable
+ @Override
+ public PomModelEvent runInner() throws IncorrectOperationException {
+ return new TreeAspectEvent(PomModelImpl.this, log.performActualPsiChange(file));
+ }
+ });
+ }
+ });
+ }
+ finally {
+ synchronizer.setIgnorePsiEvents(false);
+ }
+ }
private void startTransaction(final PomTransaction transaction) {
final ProgressIndicator progressIndicator = ProgressIndicatorProvider.getGlobalProgressIndicator();
diff --git a/platform/core-impl/src/com/intellij/pom/tree/events/impl/TreeChangeImpl.java b/platform/core-impl/src/com/intellij/pom/tree/events/impl/TreeChangeImpl.java
index c3ac3b0..e76757a 100644
--- a/platform/core-impl/src/com/intellij/pom/tree/events/impl/TreeChangeImpl.java
+++ b/platform/core-impl/src/com/intellij/pom/tree/events/impl/TreeChangeImpl.java
@@ -154,9 +154,17 @@
}
finally {
if (optimizedIndex != haveNotCalculated && index != optimizedIndex) {
- ChangeInfo changeInfo = myChanges.get(child);
ASTNode prev = child.getTreePrev();
- LOG.error("Failed to calculate optimized index for add change at offset:"+changeInfo + "," + prev + "," + myChanges.get(prev));
+ Pair<ASTNode, Integer> pair = mySortedChanges.get(index);
+ ChangeInfo prevChange = myChanges.get(prev);
+ ChangeInfo prevChange2 = myChanges.get(pair.getFirst());
+ LOG.error("Failed to calculate optimized index for add change at offset: prev node:"+prev + ", prev change:" + prevChange +
+ ",prev change length:" + (prevChange != null ? prevChange.getOldLength() : null) + ", prev text length:" + prev.getTextLength() +
+ ",prev offset:" + mySortedChanges.get(mySortedChanges.size() - 1).getSecond() + ", node:" + child + ", nodeOffset:" +
+ nodeOffset + ", optimizedIndex:"+optimizedIndex + ", real index:" + index + ", same node:" + (pair.getFirst() == child) +
+ ", at place:"+ pair.getSecond() + ", node:" +pair.getFirst() + ", change:"+prevChange2 + ", prevChange oldLength:" +
+ (prevChange2 != null ? prevChange2.getOldLength():null) + ", prevchange length2:" + pair.getFirst().getTextLength() + "," +
+ toString());
ourEnableAddChangeAtOffsetOptimization = false;
}
}
diff --git a/platform/core-impl/src/com/intellij/psi/SingleRootFileViewProvider.java b/platform/core-impl/src/com/intellij/psi/SingleRootFileViewProvider.java
index d8e58ae..0de8e74 100644
--- a/platform/core-impl/src/com/intellij/psi/SingleRootFileViewProvider.java
+++ b/platform/core-impl/src/com/intellij/psi/SingleRootFileViewProvider.java
@@ -30,11 +30,11 @@
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.FileIndexFacade;
-import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.UserDataHolderBase;
import com.intellij.openapi.vfs.NonPhysicalFileSystem;
import com.intellij.openapi.vfs.PersistentFSConstants;
+import com.intellij.openapi.vfs.VFileProperty;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.impl.PsiManagerEx;
import com.intellij.psi.impl.PsiManagerImpl;
@@ -47,6 +47,8 @@
import com.intellij.testFramework.LightVirtualFile;
import com.intellij.util.LocalTimeCounter;
import com.intellij.util.ReflectionCache;
+import com.intellij.util.SmartList;
+import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -146,7 +148,7 @@
@Override
@NotNull
public List<PsiFile> getAllFiles() {
- return Collections.singletonList(getPsi(getBaseLanguage()));
+ return ContainerUtil.createMaybeSingletonList(getPsi(getBaseLanguage()));
}
@Nullable
@@ -181,10 +183,10 @@
setContent(cachedDocument == null ? new VirtualFileContent() : new DocumentContent());
}
- public void beforeDocumentChanged() {
- final PsiFile psiFile = getCachedPsi(getBaseLanguage());
- if (psiFile instanceof PsiFileImpl && ((PsiFileImpl)psiFile).isContentsLoaded() && getContent() instanceof DocumentContent) {
- setContent(new PsiFileContent((PsiFileImpl)psiFile, getModificationStamp()));
+ public void beforeDocumentChanged(@Nullable PsiFile psiCause) {
+ PsiFile psiFile = psiCause != null ? psiCause : getPsi(getBaseLanguage());
+ if (psiFile instanceof PsiFileImpl) {
+ setContent(new PsiFileContent((PsiFileImpl)psiFile, psiCause == null ? getModificationStamp() : LocalTimeCounter.currentTime()));
}
}
@@ -267,7 +269,7 @@
@Nullable
protected PsiFile createFile(@NotNull Project project, @NotNull VirtualFile file, @NotNull FileType fileType) {
- if (fileType.isBinary() || file.is(VirtualFile.PROP_SPECIAL)) {
+ if (fileType.isBinary() || file.is(VFileProperty.SPECIAL)) {
return new PsiBinaryFileImpl((PsiManagerImpl)getManager(), this);
}
if (!isTooLargeForIntelligence(file)) {
@@ -504,9 +506,20 @@
public long getModificationStamp() {
return getVirtualFile().getModificationStamp();
}
+
+ @Override
+ public String toString() {
+ return "VirtualFileContent{size=" + getVirtualFile().getLength() + "}";
+ }
}
private class DocumentContent implements Content {
+ @Override
+ public String toString() {
+ final Document document = getDocument();
+ return "DocumentContent{size=" + (document == null ? null : document.getTextLength()) + "}";
+ }
+
@NotNull
@Override
public CharSequence getText() {
@@ -525,36 +538,33 @@
private class PsiFileContent implements Content {
private final PsiFileImpl myFile;
- private CharSequence myContent = null;
+ private volatile String myContent = null;
private final long myModificationStamp;
+ @SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
+ private final List<FileElement> myFileElementHardRefs = new SmartList<FileElement>();
+
private PsiFileContent(final PsiFileImpl file, final long modificationStamp) {
myFile = file;
myModificationStamp = modificationStamp;
+ for (PsiFile aFile : getAllFiles()) {
+ if (aFile instanceof PsiFileImpl) {
+ myFileElementHardRefs.add(((PsiFileImpl)aFile).calcTreeElement());
+ }
+ }
}
@Override
public CharSequence getText() {
- if (!myFile.isContentsLoaded()) {
- unsetPsiContent();
- return getContents();
+ if (myContent == null) {
+ ApplicationManager.getApplication().assertReadAccessAllowed();
+ myContent = myFile.calcTreeElement().getText();
}
- if (myContent != null) return myContent;
- return myContent = ApplicationManager.getApplication().runReadAction(new Computable<CharSequence>() {
- @Override
- @NotNull
- public CharSequence compute() {
- return myFile.calcTreeElement().getText();
- }
- });
+ return myContent;
}
@Override
public long getModificationStamp() {
- if (!myFile.isContentsLoaded()) {
- unsetPsiContent();
- return SingleRootFileViewProvider.this.getModificationStamp();
- }
return myModificationStamp;
}
}
diff --git a/platform/core-impl/src/com/intellij/psi/impl/AbstractModificationTracker.java b/platform/core-impl/src/com/intellij/psi/impl/AbstractModificationTracker.java
index e8e5cc3..dd4200a 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/AbstractModificationTracker.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/AbstractModificationTracker.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
diff --git a/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitProcessor.java b/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitProcessor.java
index d9f201f..d731883 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitProcessor.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitProcessor.java
@@ -23,6 +23,7 @@
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Comparing;
+import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.pom.PomManager;
@@ -35,7 +36,6 @@
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiLock;
import com.intellij.psi.codeStyle.CodeStyleManager;
-import com.intellij.psi.impl.smartPointers.SmartPointerManagerImpl;
import com.intellij.psi.impl.source.PsiFileImpl;
import com.intellij.psi.impl.source.text.DiffLog;
import com.intellij.psi.impl.source.tree.FileElement;
@@ -52,7 +52,7 @@
public abstract class DocumentCommitProcessor {
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.DocumentCommitThread");
- public abstract void commitSynchronously(@NotNull Document document, @NotNull Project project, PsiFile excludeFile);
+ public abstract void commitSynchronously(@NotNull Document document, @NotNull Project project);
public abstract void commitAsynchronously(@NotNull final Project project, @NotNull final Document document, @NonNls @NotNull Object reason);
protected static class CommitTask {
@@ -105,10 +105,8 @@
@Nullable("returns runnable to execute under write action in AWT to finish the commit")
public Processor<Document> doCommit(@NotNull final CommitTask task,
@NotNull final PsiFile file,
- final boolean synchronously,
- @NotNull PsiDocumentManager documentManager) {
+ final boolean synchronously) {
Document document = task.document;
- ((PsiDocumentManagerBase)documentManager).clearTreeHardRef(document);
final TextBlock textBlock = TextBlock.get(file);
if (textBlock.isEmpty()) return null;
final long startDocModificationTimeStamp = document.getModificationStamp();
@@ -123,20 +121,8 @@
final String oldPsiText = ApplicationManager.getApplication().isInternal() && ApplicationManager.getApplication().isUnitTestMode()
? myTreeElementBeingReparsedSoItWontBeCollected.getText()
: null;
- int startOffset;
- int endOffset;
- int lengthShift;
- if (file.getViewProvider().supportsIncrementalReparse(file.getLanguage())) {
- startOffset = textBlock.getStartOffset();
- int psiEndOffset = textBlock.getPsiEndOffset();
- endOffset = psiEndOffset;
- lengthShift = textBlock.getTextEndOffset() - psiEndOffset;
- }
- else {
- startOffset = 0;
- endOffset = document.getTextLength();
- lengthShift = document.getTextLength() - myTreeElementBeingReparsedSoItWontBeCollected.getTextLength();
- }
+ final TextRange changedPsiRange =
+ getChangedPsiRange(file, textBlock.getStartOffset(), textBlock.getPsiEndOffset(), document.getTextLength());
if (!assertBeforeCommit(document, file, textBlock, chars, oldPsiText, myTreeElementBeingReparsedSoItWontBeCollected)) {
return new Processor<Document>() {
@Override
@@ -151,7 +137,7 @@
};
}
BlockSupport blockSupport = BlockSupport.getInstance(file.getProject());
- final DiffLog diffLog = blockSupport.reparseRange(file, startOffset, endOffset, lengthShift, chars, task.indicator);
+ final DiffLog diffLog = blockSupport.reparseRange(file, changedPsiRange, chars, task.indicator);
return new Processor<Document>() {
@Override
@@ -163,17 +149,12 @@
}
try {
- textBlock.performAtomically(new Runnable() {
+ CodeStyleManager.getInstance(file.getProject()).performActionWithFormatterDisabled(new Runnable() {
@Override
public void run() {
- CodeStyleManager.getInstance(file.getProject()).performActionWithFormatterDisabled(new Runnable() {
- @Override
- public void run() {
- synchronized (PsiLock.LOCK) {
- doActualPsiChange(file, diffLog);
- }
- }
- });
+ synchronized (PsiLock.LOCK) {
+ doActualPsiChange(file, diffLog);
+ }
}
});
@@ -181,7 +162,6 @@
}
finally {
textBlock.clear();
- SmartPointerManagerImpl.synchronizePointers(file);
}
return true;
@@ -189,6 +169,13 @@
};
}
+ public static TextRange getChangedPsiRange(PsiFile file, int changeStart, int changeEnd, int newTextLength) {
+ if (file.getViewProvider().supportsIncrementalReparse(file.getLanguage())) {
+ return new TextRange(changeStart, changeEnd);
+ }
+ return new TextRange(0, newTextLength);
+ }
+
public static void doActualPsiChange(@NotNull final PsiFile file, @NotNull final DiffLog diffLog) {
file.getViewProvider().beforeContentsSynchronized();
@@ -279,7 +266,7 @@
file.putUserData(BlockSupport.DO_NOT_REPARSE_INCREMENTALLY, Boolean.TRUE);
try {
BlockSupport blockSupport = BlockSupport.getInstance(file.getProject());
- final DiffLog diffLog = blockSupport.reparseRange(file, 0, documentText.length(), 0, documentText, createProgressIndicator());
+ final DiffLog diffLog = blockSupport.reparseRange(file, new TextRange(0, documentText.length()), documentText, createProgressIndicator());
CodeStyleManager.getInstance(file.getProject()).performActionWithFormatterDisabled(new Runnable() {
@Override
public void run() {
diff --git a/platform/core-impl/src/com/intellij/psi/impl/PsiDocumentManagerBase.java b/platform/core-impl/src/com/intellij/psi/impl/PsiDocumentManagerBase.java
index b951cbf..24ecf9b 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/PsiDocumentManagerBase.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/PsiDocumentManagerBase.java
@@ -17,7 +17,6 @@
package com.intellij.psi.impl;
import com.intellij.injected.editor.DocumentWindow;
-import com.intellij.lang.ASTNode;
import com.intellij.lang.injection.InjectedLanguageManager;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
@@ -263,7 +262,7 @@
public void commitDocument(@NotNull final Document doc) {
final Document document = doc instanceof DocumentWindow ? ((DocumentWindow)doc).getDelegate() : doc;
if (!isCommitted(document)) {
- doCommit(document, null);
+ doCommit(document);
}
}
@@ -346,17 +345,17 @@
}
}
- protected void doCommit(@NotNull final Document document, final PsiFile excludeFile) {
+ private void doCommit(@NotNull final Document document) {
assert !myIsCommitInProgress : "Do not call commitDocument() from inside PSI change listener";
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
// otherwise there are many clients calling commitAllDocs() on PSI childrenChanged()
- if (getSynchronizer().isDocumentAffectedByTransactions(document) && excludeFile == null) return;
+ if (getSynchronizer().isDocumentAffectedByTransactions(document)) return;
myIsCommitInProgress = true;
try {
- myDocumentCommitProcessor.commitSynchronously(document, myProject, excludeFile);
+ myDocumentCommitProcessor.commitSynchronously(document, myProject);
}
finally {
myIsCommitInProgress = false;
@@ -366,9 +365,6 @@
});
}
- public void commitOtherFilesAssociatedWithDocument(final Document document, final PsiFile psiFile) {
- }
-
@Override
public <T> T commitAndRunReadAction(@NotNull final Computable<T> computation) {
final Ref<T> ref = Ref.create(null);
@@ -558,12 +554,6 @@
return !myIsCommitInProgress && !myUncommittedDocuments.isEmpty();
}
- private final Key<ASTNode> TEMP_TREE_IN_DOCUMENT_KEY = Key.create("TEMP_TREE_IN_DOCUMENT_KEY");
-
- void clearTreeHardRef(@NotNull Document document) {
- document.putUserData(TEMP_TREE_IN_DOCUMENT_KEY, null);
- }
-
@Override
public void beforeDocumentChange(DocumentEvent event) {
final Document document = event.getDocument();
@@ -576,39 +566,23 @@
if (virtualFile.getFileType().isBinary()) return;
final List<PsiFile> files = viewProvider.getAllFiles();
- boolean hasLockedBlocks = false;
+ PsiFile psiCause = null;
for (PsiFile file : files) {
- if (file == null) continue;
+ mySmartPointerManager.fastenBelts(file, event.getOffset(), null);
- if (file.isPhysical() && mySmartPointerManager != null) { // mock tests
- mySmartPointerManager.fastenBelts(file, event.getOffset(), null);
- }
-
- final TextBlock textBlock = TextBlock.get(file);
- if (textBlock.isLocked()) {
- hasLockedBlocks = true;
- continue;
- }
-
- if (file instanceof PsiFileImpl) {
- myIsCommitInProgress = true;
- try {
- PsiFileImpl psiFile = (PsiFileImpl)file;
- // tree should be initialized and be kept until commit
- document.putUserData(TEMP_TREE_IN_DOCUMENT_KEY, psiFile.calcTreeElement());
- }
- finally {
- myIsCommitInProgress = false;
- }
+ if (TextBlock.get(file).isLocked()) {
+ psiCause = file;
}
}
- if (!hasLockedBlocks)
+ if (psiCause == null) {
beforeDocumentChangeOnUnlockedDocument(viewProvider);
+ }
+
+ ((SingleRootFileViewProvider)viewProvider).beforeDocumentChanged(psiCause);
}
protected void beforeDocumentChangeOnUnlockedDocument(@NotNull final FileViewProvider viewProvider) {
- ((SingleRootFileViewProvider)viewProvider).beforeDocumentChanged();
}
@Override
@@ -620,14 +594,15 @@
ApplicationManager.getApplication().assertWriteAccessAllowed();
final List<PsiFile> files = viewProvider.getAllFiles();
- boolean commitNecessary = false;
+ boolean commitNecessary = true;
for (PsiFile file : files) {
- if (file == null || file instanceof PsiFileImpl && ((PsiFileImpl)file).getTreeElement() == null) continue;
- if (mySmartPointerManager != null) { // mock tests
- mySmartPointerManager.unfastenBelts(file, event.getOffset());
- }
+ mySmartPointerManager.unfastenBelts(file, event.getOffset());
+
final TextBlock textBlock = TextBlock.get(file);
- if (textBlock.isLocked()) continue;
+ if (textBlock.isLocked()) {
+ commitNecessary = false;
+ continue;
+ }
textBlock.documentChanged(event);
assert file instanceof PsiFileImpl || "mock.file".equals(file.getName()) && ApplicationManager.getApplication().isUnitTestMode() :
@@ -638,8 +613,6 @@
files +
"; viewProvider=" +
viewProvider;
-
- commitNecessary = true;
}
boolean forceCommit = ApplicationManager.getApplication().hasWriteAction(ExternalChangeAction.class) &&
diff --git a/platform/core-impl/src/com/intellij/psi/impl/PsiManagerImpl.java b/platform/core-impl/src/com/intellij/psi/impl/PsiManagerImpl.java
index ce823bd..107f052 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/PsiManagerImpl.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/PsiManagerImpl.java
@@ -118,7 +118,6 @@
@Override
public boolean isInProject(@NotNull PsiElement element) {
PsiFile file = element.getContainingFile();
- if (file == null && !element.isPhysical()) return element.getProject() == myProject;
if (file != null && file.isPhysical() && file.getViewProvider().getVirtualFile() instanceof LightVirtualFile) return true;
if (element instanceof PsiDirectoryContainer) {
diff --git a/platform/core-impl/src/com/intellij/psi/impl/PsiModificationTrackerImpl.java b/platform/core-impl/src/com/intellij/psi/impl/PsiModificationTrackerImpl.java
index d3c6b41..5fefd4f 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/PsiModificationTrackerImpl.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/PsiModificationTrackerImpl.java
@@ -60,10 +60,12 @@
public void incCounter() {
myModificationCount.getAndIncrement();
myJavaStructureModificationCount.getAndIncrement();
- incOutOfCodeBlockModificationCounter();
+ myOutOfCodeBlockModificationCount.getAndIncrement();
+ myPublisher.modificationCountChanged();
}
public void incOutOfCodeBlockModificationCounter() {
+ myModificationCount.getAndIncrement();
myOutOfCodeBlockModificationCount.getAndIncrement();
myPublisher.modificationCountChanged();
}
@@ -72,7 +74,7 @@
public void treeChanged(@NotNull PsiTreeChangeEventImpl event) {
myModificationCount.getAndIncrement();
if (event.getParent() instanceof PsiDirectory) {
- incOutOfCodeBlockModificationCounter();
+ myOutOfCodeBlockModificationCount.getAndIncrement();
}
myPublisher.modificationCountChanged();
diff --git a/platform/core-impl/src/com/intellij/psi/impl/PsiToDocumentSynchronizer.java b/platform/core-impl/src/com/intellij/psi/impl/PsiToDocumentSynchronizer.java
index ec7e52d..0d7e1dd 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/PsiToDocumentSynchronizer.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/PsiToDocumentSynchronizer.java
@@ -17,7 +17,6 @@
package com.intellij.psi.impl;
import com.intellij.injected.editor.DocumentWindow;
-import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
@@ -92,8 +91,6 @@
}
});
- myPsiDocumentManager.commitOtherFilesAssociatedWithDocument(document, psiFile);
-
final boolean insideTransaction = myTransactionsMap.containsKey(document);
if (!insideTransaction) {
document.setModificationStamp(psiFile.getViewProvider().getModificationStamp());
@@ -101,6 +98,8 @@
PsiDocumentManagerBase.checkConsistency(psiFile, document);
}
}
+
+ psiFile.getViewProvider().contentsSynchronized();
}
@Override
@@ -149,9 +148,17 @@
});
}
- private static boolean toProcessPsiEvent() {
- Application application = ApplicationManager.getApplication();
- return !application.hasWriteAction(IgnorePsiEventsMarker.class);
+ private boolean myIgnorePsiEvents;
+ public void setIgnorePsiEvents(boolean ignorePsiEvents) {
+ myIgnorePsiEvents = ignorePsiEvents;
+ }
+
+ public boolean isIgnorePsiEvents() {
+ return myIgnorePsiEvents;
+ }
+
+ private boolean toProcessPsiEvent() {
+ return !myIgnorePsiEvents && !ApplicationManager.getApplication().hasWriteAction(IgnorePsiEventsMarker.class);
}
public void replaceString(Document document, int startOffset, int endOffset, String s) {
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/PsiTreeChangePreprocessorBase.java b/platform/core-impl/src/com/intellij/psi/impl/PsiTreeChangePreprocessorBase.java
similarity index 100%
rename from platform/lang-impl/src/com/intellij/psi/impl/PsiTreeChangePreprocessorBase.java
rename to platform/core-impl/src/com/intellij/psi/impl/PsiTreeChangePreprocessorBase.java
diff --git a/platform/core-impl/src/com/intellij/psi/impl/TextBlock.java b/platform/core-impl/src/com/intellij/psi/impl/TextBlock.java
index e62cd63..65cf98f 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/TextBlock.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/TextBlock.java
@@ -92,17 +92,13 @@
}
public void performAtomically(@NotNull Runnable runnable) {
- boolean wasLocked = isLocked();
- if (!wasLocked) {
- lock();
- }
+ assert !isLocked();
+ lock();
try {
runnable.run();
}
finally {
- if (!wasLocked) {
- unlock();
- }
+ unlock();
}
}
diff --git a/platform/core-impl/src/com/intellij/psi/impl/file/PsiPackageBase.java b/platform/core-impl/src/com/intellij/psi/impl/file/PsiPackageBase.java
index 3b406fb..57d40a8 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/file/PsiPackageBase.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/file/PsiPackageBase.java
@@ -103,7 +103,7 @@
}
if (myQualifiedName.isEmpty()) return null;
int index = myQualifiedName.lastIndexOf('.');
- if (index < 0) {
+ if (index <= 0) {
return myQualifiedName;
}
else {
diff --git a/platform/core-impl/src/com/intellij/psi/impl/smartPointers/ClsElementInfo.java b/platform/core-impl/src/com/intellij/psi/impl/smartPointers/ClsElementInfo.java
index 91d15d3..296b2ac 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/smartPointers/ClsElementInfo.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/smartPointers/ClsElementInfo.java
@@ -50,11 +50,6 @@
public void unfastenBelt(int offset) {
}
- // commit
- @Override
- public void documentAndPsiInSync() {
- }
-
@Override
public PsiElement restoreElement() {
return myStubIndexReference.retrieve();
diff --git a/platform/core-impl/src/com/intellij/psi/impl/smartPointers/FileElementInfo.java b/platform/core-impl/src/com/intellij/psi/impl/smartPointers/FileElementInfo.java
index a4356e3..9650b4e 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/smartPointers/FileElementInfo.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/smartPointers/FileElementInfo.java
@@ -54,10 +54,6 @@
}
@Override
- public void documentAndPsiInSync() {
- }
-
- @Override
public void fastenBelt(int offset, RangeMarker[] cachedRangeMarker) {
}
diff --git a/platform/core-impl/src/com/intellij/psi/impl/smartPointers/HardElementInfo.java b/platform/core-impl/src/com/intellij/psi/impl/smartPointers/HardElementInfo.java
index f769351..99634f9 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/smartPointers/HardElementInfo.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/smartPointers/HardElementInfo.java
@@ -43,10 +43,6 @@
}
@Override
- public void documentAndPsiInSync() {
- }
-
- @Override
public void fastenBelt(int offset, RangeMarker[] cachedRangeMarker) {
}
diff --git a/platform/core-impl/src/com/intellij/psi/impl/smartPointers/SelfElementInfo.java b/platform/core-impl/src/com/intellij/psi/impl/smartPointers/SelfElementInfo.java
index c3fa384..e5d313d 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/smartPointers/SelfElementInfo.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/smartPointers/SelfElementInfo.java
@@ -161,11 +161,6 @@
myRangeMarker = null; // clear hard ref to avoid leak, hold soft ref for not recreating marker later
}
- // commit
- @Override
- public void documentAndPsiInSync() {
- }
-
@Override
public PsiElement restoreElement() {
if (!mySyncMarkerIsValid) return null;
diff --git a/platform/core-impl/src/com/intellij/psi/impl/smartPointers/SmartPointerElementInfo.java b/platform/core-impl/src/com/intellij/psi/impl/smartPointers/SmartPointerElementInfo.java
index 4a8b5ec..502096e 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/smartPointers/SmartPointerElementInfo.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/smartPointers/SmartPointerElementInfo.java
@@ -29,7 +29,6 @@
@Nullable
Document getDocumentToSynchronize();
- void documentAndPsiInSync();
void fastenBelt(int offset, RangeMarker[] cachedRangeMarkers);
void unfastenBelt(int offset);
diff --git a/platform/core-impl/src/com/intellij/psi/impl/smartPointers/SmartPointerEx.java b/platform/core-impl/src/com/intellij/psi/impl/smartPointers/SmartPointerEx.java
index afed7d9..acce06a 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/smartPointers/SmartPointerEx.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/smartPointers/SmartPointerEx.java
@@ -22,7 +22,6 @@
public interface SmartPointerEx<E extends PsiElement> extends SmartPsiElementPointer<E> {
void fastenBelt(int offset, @Nullable RangeMarker[] cachedRangeMarkers);
- void documentAndPsiInSync();
void unfastenBelt(int offset);
diff --git a/platform/core-impl/src/com/intellij/psi/impl/smartPointers/SmartPointerManagerImpl.java b/platform/core-impl/src/com/intellij/psi/impl/smartPointers/SmartPointerManagerImpl.java
index be7edcf..eaa4872 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/smartPointers/SmartPointerManagerImpl.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/smartPointers/SmartPointerManagerImpl.java
@@ -17,11 +17,9 @@
package com.intellij.psi.impl.smartPointers;
import com.intellij.injected.editor.DocumentWindow;
-import com.intellij.lang.Language;
import com.intellij.lang.injection.InjectedLanguageManager;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.RangeMarker;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
@@ -37,7 +35,6 @@
import java.lang.ref.Reference;
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");
@@ -108,36 +105,6 @@
}
}
- public static void synchronizePointers(@NotNull PsiFile file) {
- final Set<Language> languages = file.getViewProvider().getLanguages();
- for (Language language : languages) {
- final PsiFile f = file.getViewProvider().getPsi(language);
- synchronized (f) {
- _synchronizePointers(f);
- }
- }
- }
-
- private static void _synchronizePointers(@NotNull PsiFile file) {
- List<SmartPointerEx> pointers = getPointers(file);
- if (pointers == null) return;
-
- //noinspection ForLoopReplaceableByForEach
- for (int i = 0; i < pointers.size(); i++) {
- SmartPointerEx pointer = pointers.get(i);
- if (pointer != null) {
- pointer.documentAndPsiInSync();
- }
- }
-
- final PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(file.getProject());
- for (Document document : InjectedLanguageManager.getInstance(file.getProject()).getCachedInjectedDocuments(file)) {
- PsiFile injectedfile = psiDocumentManager.getPsiFile(document);
- if (injectedfile == null) continue;
- _synchronizePointers(injectedfile);
- }
- }
-
private static final Key<Reference<SmartPsiElementPointer>> CACHED_SMART_POINTER_KEY = Key.create("CACHED_SMART_POINTER_KEY");
@Override
@NotNull
diff --git a/platform/core-impl/src/com/intellij/psi/impl/smartPointers/SmartPsiElementPointerImpl.java b/platform/core-impl/src/com/intellij/psi/impl/smartPointers/SmartPsiElementPointerImpl.java
index 1f28bca..566f60e 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/smartPointers/SmartPsiElementPointerImpl.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/smartPointers/SmartPsiElementPointerImpl.java
@@ -53,25 +53,10 @@
cacheElement(element);
myElementClass = elementClass;
myElementInfo = elementInfo;
- // Assert document committed.
- //todo
- //if (containingFile != null) {
- // final PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(project);
- // if (psiDocumentManager instanceof PsiDocumentManagerImpl) {
- // Document doc = psiDocumentManager.getCachedDocument(containingFile);
- // if (doc != null) {
- // //[ven] this is a really NASTY hack; when no smart pointer is kept on UsageInfo then remove this conditional
- // if (!(element instanceof PsiFile)) {
- // LOG.assertTrue(!psiDocumentManager.isUncommited(doc) || ((PsiDocumentManagerImpl)psiDocumentManager).isCommittingDocument(doc));
- // }
- // }
- // }
- //}
}
public boolean equals(Object obj) {
- if (!(obj instanceof SmartPsiElementPointer)) return false;
- return pointsToTheSameElementAs(this, (SmartPsiElementPointer)obj);
+ return obj instanceof SmartPsiElementPointer && pointsToTheSameElementAs(this, (SmartPsiElementPointer)obj);
}
public int hashCode() {
@@ -191,11 +176,6 @@
}
@Override
- public void documentAndPsiInSync() {
- myElementInfo.documentAndPsiInSync();
- }
-
- @Override
public void unfastenBelt(int offset) {
myElementInfo.unfastenBelt(offset);
}
diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/IdentityCharTable.java b/platform/core-impl/src/com/intellij/psi/impl/source/IdentityCharTable.java
index 2d05ee1..29c5a0f 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/source/IdentityCharTable.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/source/IdentityCharTable.java
@@ -37,7 +37,7 @@
@NotNull
@Override
public CharSequence intern(@NotNull CharSequence baseText, int startOffset, int endOffset) {
- if (endOffset - startOffset == baseText.length()) return baseText.toString();
+ if (startOffset == 0 && endOffset == baseText.length()) return baseText;
return baseText.subSequence(startOffset, endOffset);
}
}
diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/PsiFileImpl.java b/platform/core-impl/src/com/intellij/psi/impl/source/PsiFileImpl.java
index f17a438..2a38d15 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/source/PsiFileImpl.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/source/PsiFileImpl.java
@@ -59,6 +59,7 @@
import com.intellij.util.PatchedWeakReference;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.text.CharArrayUtil;
+import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -213,10 +214,6 @@
myStub = null;
myTreeElementPointer = createTreeElementPointer(treeElement);
- if (document != null && isPhysical()) {
- TextBlock.get(this).clear();
- }
-
if (LOG.isDebugEnabled() && viewProvider.isPhysical()) {
LOG.debug("Loaded text for file " + viewProvider.getVirtualFile().getPresentableUrl());
}
@@ -306,13 +303,23 @@
return result;
}
- private void reportStubAstMismatch(String message, StubTree stubTree, Document cachedDocument) {
+ protected void reportStubAstMismatch(String message, StubTree stubTree, Document cachedDocument) {
rebuildStub();
+ clearStub();
+ scheduleDropCachesWithInvalidStubPsi();
+
String msg = message;
msg += "\n file=" + this;
- msg += "\n name=" + getName();
+ msg += ", modStamp=" + getModificationStamp();
msg += "\n stub debugInfo=" + stubTree.getDebugInfo();
msg += "\n document before=" + cachedDocument;
+
+ ObjectStubTree latestIndexedStub = StubTreeLoader.getInstance().readFromVFile(getProject(), getVirtualFile());
+ msg += "\nlatestIndexedStub=" + latestIndexedStub;
+ if (latestIndexedStub != null) {
+ msg += "\n same size=" + (stubTree.getPlainList().size() == latestIndexedStub.getPlainList().size());
+ msg += "\n debugInfo=" + latestIndexedStub.getDebugInfo();
+ }
FileViewProvider viewProvider = getViewProvider();
msg += "\n viewProvider=" + viewProvider;
@@ -326,10 +333,25 @@
if (document != null) {
msg += "\n doc saved: " + !FileDocumentManager.getInstance().isDocumentUnsaved(document);
msg += "; doc stamp: " + document.getModificationStamp();
+ msg += "; doc size: " + document.getTextLength();
msg += "; committed: " + PsiDocumentManager.getInstance(getProject()).isCommitted(document);
}
- throw new AssertionError(msg);
+ throw new AssertionError(msg + "\n------------\n");
+ }
+
+ private void scheduleDropCachesWithInvalidStubPsi() {
+ UIUtil.invokeLaterIfNeeded(new Runnable() {
+ @Override
+ public void run() {
+ ApplicationManager.getApplication().runWriteAction(new Runnable() {
+ @Override
+ public void run() {
+ ((PsiModificationTrackerImpl)getManager().getModificationTracker()).incCounter();
+ }
+ });
+ }
+ });
}
protected FileElement createFileElement(final CharSequence docText) {
@@ -354,6 +376,7 @@
}
public void unloadContent() {
+ ApplicationManager.getApplication().assertWriteAccessAllowed();
LOG.assertTrue(getTreeElement() != null);
clearCaches();
myViewProvider.beforeContentsSynchronized();
@@ -366,7 +389,6 @@
private void clearStub() {
StubTree stubHolder = myStub == null ? null : myStub.get();
if (stubHolder != null) {
- ApplicationManager.getApplication().assertWriteAccessAllowed();
((StubBase<?>)stubHolder.getRoot()).setPsi(null);
}
myStub = null;
@@ -676,6 +698,7 @@
ObjectStubTree tree = StubTreeLoader.getInstance().readOrBuild(getProject(), vFile, this);
if (!(tree instanceof StubTree)) return null;
StubTree stubHolder = (StubTree)tree;
+ tree.setDebugInfo(tree.getDebugInfo() + "\n loaded at " + vFile.getTimeStamp() + "; mod stamp" + getModificationStamp() + "; viewProvider=" + getViewProvider());
synchronized (PsiLock.LOCK) {
if (getTreeElement() != null) return null;
diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/resolve/ResolveCache.java b/platform/core-impl/src/com/intellij/psi/impl/source/resolve/ResolveCache.java
index d49e98f..844d9bf 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/source/resolve/ResolveCache.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/source/resolve/ResolveCache.java
@@ -26,7 +26,6 @@
import com.intellij.psi.impl.AnyPsiChangeListener;
import com.intellij.psi.impl.PsiManagerImpl;
import com.intellij.reference.SoftReference;
-import com.intellij.util.ConcurrencyUtil;
import com.intellij.util.containers.ConcurrentWeakHashMap;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.messages.MessageBus;
@@ -133,10 +132,11 @@
return result == null ? ResolveResult.EMPTY_ARRAY : result;
}
- public <T extends PsiPolyVariantReference> boolean isCached(@NotNull T ref, boolean physical, boolean incompleteCode, boolean isPoly) {
+ @Nullable
+ public <T extends PsiPolyVariantReference> ResolveResult[] getCachedResults(@NotNull T ref, boolean physical, boolean incompleteCode, boolean isPoly) {
Map<T, Getter<ResolveResult[]>> map = getMap(physical, incompleteCode, isPoly);
Getter<ResolveResult[]> reference = map.get(ref);
- return reference != null && reference.get() != null;
+ return reference == null ? null : reference.get();
}
public PsiElement resolveWithCaching(@NotNull PsiReference ref,
@@ -188,6 +188,6 @@
else {
cached = new SoftGetter<TResult>(result);
}
- ConcurrencyUtil.cacheOrGet(map, ref, cached);
+ map.put(ref, cached);
}
}
diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/text/BlockSupportImpl.java b/platform/core-impl/src/com/intellij/psi/impl/source/text/BlockSupportImpl.java
index c4df612..9519314 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/source/text/BlockSupportImpl.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/source/text/BlockSupportImpl.java
@@ -75,35 +75,25 @@
@Override
@NotNull
public DiffLog reparseRange(@NotNull final PsiFile file,
- final int startOffset,
- final int endOffset,
- final int lengthShift,
+ TextRange changedPsiRange,
@NotNull final CharSequence newFileText,
@NotNull final ProgressIndicator indicator) {
- return reparseRangeInternal(file, startOffset > 0 ? startOffset - 1 : 0, endOffset, lengthShift, newFileText, indicator);
- }
-
- @NotNull
- private static DiffLog reparseRangeInternal(@NotNull PsiFile file,
- int startOffset,
- int endOffset,
- int lengthShift,
- @NotNull CharSequence newFileText,
- @NotNull ProgressIndicator indicator) {
final PsiFileImpl fileImpl = (PsiFileImpl)file;
Project project = fileImpl.getProject();
final FileElement treeFileElement = fileImpl.getTreeElement();
final CharTable charTable = treeFileElement.getCharTable();
- final int textLength = treeFileElement.getTextLength() + lengthShift;
+
+ final int textLength = newFileText.length();
+ int lengthShift = textLength - treeFileElement.getTextLength();
if (treeFileElement.getElementType() instanceof ITemplateDataElementType || isTooDeep(file)) {
// unable to perform incremental reparse for template data in JSP, or in exceptionally deep trees
return makeFullParse(treeFileElement, newFileText, textLength, fileImpl, indicator);
}
- final ASTNode leafAtStart = treeFileElement.findLeafElementAt(startOffset);
- final ASTNode leafAtEnd = treeFileElement.findLeafElementAt(endOffset);
+ final ASTNode leafAtStart = treeFileElement.findLeafElementAt(Math.max(0, changedPsiRange.getStartOffset() - 1));
+ final ASTNode leafAtEnd = treeFileElement.findLeafElementAt(changedPsiRange.getEndOffset());
ASTNode node = leafAtStart != null && leafAtEnd != null ? TreeUtil.findCommonParent(leafAtStart, leafAtEnd) : treeFileElement;
Language baseLanguage = file.getViewProvider().getBaseLanguage();
diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/tree/CompositeElement.java b/platform/core-impl/src/com/intellij/psi/impl/source/tree/CompositeElement.java
index 5f205f3..580c3b4 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/source/tree/CompositeElement.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/source/tree/CompositeElement.java
@@ -40,7 +40,6 @@
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.TokenSet;
import com.intellij.util.ArrayFactory;
-import com.intellij.util.text.CharArrayCharSequence;
import com.intellij.util.text.StringFactory;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -856,7 +855,9 @@
// creates PSI and stores to the 'myWrapper', if not created already
void createAllChildrenPsiIfNecessary() {
synchronized (PsiLock.LOCK) { // guard for race condition with getPsi()
- acceptTree(CREATE_CHILDREN_PSI);
+ for(TreeElement child = getFirstChildNode(); child != null; child = child.getTreeNext()) {
+ child.acceptTree(CREATE_CHILDREN_PSI);
+ }
}
}
private static final RecursiveTreeElementWalkingVisitor CREATE_CHILDREN_PSI = new RecursiveTreeElementWalkingVisitor(false) {
@@ -867,12 +868,10 @@
@Override
public void visitComposite(CompositeElement composite) {
ProgressIndicatorProvider.checkCanceled(); // we can safely interrupt creating children PSI any moment
- if (composite.myWrapper != null) {
- // someone else 've managed to create the PSI in the meantime. Abandon our attempts to cache everything.
- stopWalking();
- return;
+ if (composite.myWrapper == null) {
+ composite.createAndStorePsi();
}
- composite.createAndStorePsi();
+
super.visitComposite(composite);
}
};
diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/tree/LazyParseableElement.java b/platform/core-impl/src/com/intellij/psi/impl/source/tree/LazyParseableElement.java
index d1edc6f..15b605c 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/source/tree/LazyParseableElement.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/source/tree/LazyParseableElement.java
@@ -179,21 +179,11 @@
if (parsedNode == null) return;
super.rawAddChildrenWithoutNotifications((TreeElement)parsedNode);
-
- //if (getNotCachedLength() != text.length()) {
- // if (ApplicationManager.getApplication().isInternal()) {
- // LOG.error("Inconsistent reparse: type=" + getElementType() + "; text=" + text + "; treeText=" + getText());
- // } else {
- // LOG.error("Inconsistent reparse: type=" + getElementType());
- // }
- //}
-
- if (!(parsedNode instanceof CompositeElement)) return;
}
// create PSI all at once, to reduce contention of PsiLock in CompositeElement.getPsi()
// create PSI outside the 'lock' since this method grabs PSI_LOCK and deadlock is possible when someone else locks in the other order.
- ((CompositeElement)parsedNode).createAllChildrenPsiIfNecessary();
+ createAllChildrenPsiIfNecessary();
}
@Override
diff --git a/platform/core-impl/src/com/intellij/psi/text/BlockSupport.java b/platform/core-impl/src/com/intellij/psi/text/BlockSupport.java
index 55a7b00..6cbacf0 100644
--- a/platform/core-impl/src/com/intellij/psi/text/BlockSupport.java
+++ b/platform/core-impl/src/com/intellij/psi/text/BlockSupport.java
@@ -21,6 +21,7 @@
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
+import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.UserDataHolder;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.psi.PsiFile;
@@ -38,9 +39,7 @@
@NotNull
public abstract DiffLog reparseRange(@NotNull PsiFile file,
- int startOffset,
- int endOffset,
- int lengthShift,
+ TextRange changedPsiRange,
@NotNull CharSequence newText,
@NotNull ProgressIndicator progressIndicator) throws IncorrectOperationException;
diff --git a/platform/dvcs/src/com/intellij/dvcs/DvcsUtil.java b/platform/dvcs/src/com/intellij/dvcs/DvcsUtil.java
index c872f04..27a353c 100644
--- a/platform/dvcs/src/com/intellij/dvcs/DvcsUtil.java
+++ b/platform/dvcs/src/com/intellij/dvcs/DvcsUtil.java
@@ -88,4 +88,13 @@
}
}, ", ");
}
+
+ public static boolean anyRepositoryIsFresh(Collection<? extends Repository> repositories) {
+ for (Repository repository : repositories) {
+ if (repository.isFresh()) {
+ return true;
+ }
+ }
+ return false;
+ }
}
diff --git a/platform/dvcs/src/com/intellij/dvcs/repo/AbstractRepositoryManager.java b/platform/dvcs/src/com/intellij/dvcs/repo/AbstractRepositoryManager.java
new file mode 100644
index 0000000..8652595
--- /dev/null
+++ b/platform/dvcs/src/com/intellij/dvcs/repo/AbstractRepositoryManager.java
@@ -0,0 +1,209 @@
+package com.intellij.dvcs.repo;
+
+import com.intellij.openapi.Disposable;
+import com.intellij.openapi.components.AbstractProjectComponent;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Disposer;
+import com.intellij.openapi.vcs.*;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.util.ArrayUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+/**
+ * @author Nadya Zabrodina
+ */
+public abstract class AbstractRepositoryManager<T extends Repository> extends AbstractProjectComponent
+ implements Disposable, RepositoryManager<T>, VcsListener {
+
+ private static final Logger LOG = Logger.getInstance(RepositoryManager.class);
+
+ @NotNull private final ProjectLevelVcsManager myVcsManager;
+ @NotNull private final AbstractVcs myVcs;
+ @NotNull private final String myRootDirName;
+
+ @NotNull protected final Map<VirtualFile, T> myRepositories = new HashMap<VirtualFile, T>();
+
+ @NotNull protected final ReentrantReadWriteLock REPO_LOCK = new ReentrantReadWriteLock();
+
+ protected AbstractRepositoryManager(@NotNull Project project,
+ @NotNull ProjectLevelVcsManager vcsManager, @NotNull AbstractVcs vcs, @NotNull String rootDirName) {
+ super(project);
+ myVcsManager = vcsManager;
+ myVcs = vcs;
+ myRootDirName = rootDirName;
+ }
+
+ @Override
+ public void initComponent() {
+ Disposer.register(myProject, this);
+ myProject.getMessageBus().connect().subscribe(ProjectLevelVcsManager.VCS_CONFIGURATION_CHANGED, this);
+ }
+
+ @Override
+ public void dispose() {
+ try {
+ REPO_LOCK.writeLock().lock();
+ myRepositories.clear();
+ }
+ finally {
+ REPO_LOCK.writeLock().unlock();
+ }
+ }
+
+ @Override
+ public void directoryMappingChanged() {
+ updateRepositoriesCollection();
+ }
+
+ @Override
+ @Nullable
+ public T getRepositoryForRoot(@Nullable VirtualFile root) {
+ if (root == null) {
+ return null;
+ }
+ try {
+ REPO_LOCK.readLock().lock();
+ return myRepositories.get(root);
+ }
+ finally {
+ REPO_LOCK.readLock().unlock();
+ }
+ }
+
+ @Override
+ @Nullable
+ public T getRepositoryForFile(@NotNull VirtualFile file) {
+ final VcsRoot vcsRoot = myVcsManager.getVcsRootObjectFor(file);
+ return getRepositoryForVcsRoot(vcsRoot, file.getPath());
+ }
+
+ @Override
+ public T getRepositoryForFile(@NotNull FilePath file) {
+ final VcsRoot vcsRoot = myVcsManager.getVcsRootObjectFor(file);
+ return getRepositoryForVcsRoot(vcsRoot, file.getPath());
+ }
+
+ @Nullable
+ private T getRepositoryForVcsRoot(@Nullable VcsRoot vcsRoot, @NotNull String filePath) {
+ if (vcsRoot == null) {
+ return null;
+ }
+ final AbstractVcs vcs = vcsRoot.getVcs();
+ if (!myVcs.equals(vcs)) {
+ if (vcs != null) {
+ LOG.debug(String.format("getRepositoryForFile returned non-(%s) root for file %s", myVcs.getDisplayName(), filePath));
+ }
+ return null;
+ }
+ return getRepositoryForRoot(vcsRoot.getPath());
+ }
+
+ @Override
+ @NotNull
+ public List<T> getRepositories() {
+ try {
+ REPO_LOCK.readLock().lock();
+ return RepositoryUtil.sortRepositories(myRepositories.values());
+ }
+ finally {
+ REPO_LOCK.readLock().unlock();
+ }
+ }
+
+ @Override
+ public boolean moreThanOneRoot() {
+ return myRepositories.size() > 1;
+ }
+
+ @Override
+ public void updateRepository(@Nullable VirtualFile root) {
+ T repo = getRepositoryForRoot(root);
+ if (repo != null) {
+ repo.update();
+ }
+ }
+
+ @Override
+ public void updateAllRepositories() {
+ Map<VirtualFile, T> repositories;
+ try {
+ REPO_LOCK.readLock().lock();
+ repositories = new HashMap<VirtualFile, T>(myRepositories);
+ }
+ finally {
+ REPO_LOCK.readLock().unlock();
+ }
+
+ for (VirtualFile root : repositories.keySet()) {
+ updateRepository(root);
+ }
+ }
+
+ // note: we are not calling this method during the project startup - it is called anyway by f.e the GitRootTracker
+ private void updateRepositoriesCollection() {
+ Map<VirtualFile, T> repositories;
+ try {
+ REPO_LOCK.readLock().lock();
+ repositories = new HashMap<VirtualFile, T>(myRepositories);
+ }
+ finally {
+ REPO_LOCK.readLock().unlock();
+ }
+
+ final VirtualFile[] roots = myVcsManager.getRootsUnderVcs(myVcs);
+ // remove repositories that are not in the roots anymore
+ for (Iterator<Map.Entry<VirtualFile, T>> iterator = repositories.entrySet().iterator(); iterator.hasNext(); ) {
+ if (!ArrayUtil.contains(iterator.next().getValue().getRoot(), roots)) {
+ iterator.remove();
+ }
+ }
+ // add Repositories for all roots that don't have correspondent appropriate Git or Hg Repositories yet.
+ for (VirtualFile root : roots) {
+ if (!repositories.containsKey(root)) {
+ if (isRootValid(root)) {
+ try {
+ T repository = createRepository(root);
+ repositories.put(root, repository);
+ }
+ catch (RepoStateException e) {
+ LOG.error("Couldn't initialize Repository in " + root.getPresentableUrl(), e);
+ }
+ }
+ else {
+ LOG.info("Invalid vcs root: " + root);
+ }
+ }
+ }
+
+ REPO_LOCK.writeLock().lock();
+ try {
+ myRepositories.clear();
+ myRepositories.putAll(repositories);
+ }
+ finally {
+ REPO_LOCK.writeLock().unlock();
+ }
+ }
+
+ private boolean isRootValid(@NotNull VirtualFile root) {
+ VirtualFile vcsDir = root.findChild(myRootDirName);
+ return vcsDir != null && vcsDir.exists();
+ }
+
+ @NotNull
+ protected abstract T createRepository(@NotNull VirtualFile root);
+
+ @Override
+ @NotNull
+ public String toString() {
+ return "RepositoryManager{myRepositories: " + myRepositories + '}';
+ }
+}
diff --git a/platform/dvcs/src/com/intellij/dvcs/repo/Repository.java b/platform/dvcs/src/com/intellij/dvcs/repo/Repository.java
index c47f5fb..3650b99 100644
--- a/platform/dvcs/src/com/intellij/dvcs/repo/Repository.java
+++ b/platform/dvcs/src/com/intellij/dvcs/repo/Repository.java
@@ -93,7 +93,6 @@
@NotNull
Project getProject();
-
@NotNull
State getState();
@@ -104,16 +103,19 @@
@Nullable
String getCurrentRevision();
-
/**
* @return true if current repository is "fresh", i.e. if no commits have been made yet.
*/
boolean isFresh();
/**
- * Synchronously updates the Vcs Repository by reading information from .git/config and .git/refs/...
+ * Synchronously updates the Repository by reading information about it from disk (e.g. for Git: from .git/config and .git/refs/...)
*/
void update();
+ /**
+ * Returns a detailed String representation suitable for logging purposes.
+ */
+ @NotNull
String toLogString();
}
diff --git a/platform/dvcs/src/com/intellij/dvcs/repo/RepositoryManager.java b/platform/dvcs/src/com/intellij/dvcs/repo/RepositoryManager.java
new file mode 100644
index 0000000..9f0a5e2
--- /dev/null
+++ b/platform/dvcs/src/com/intellij/dvcs/repo/RepositoryManager.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2000-2011 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.dvcs.repo;
+
+import com.intellij.openapi.vcs.FilePath;
+import com.intellij.openapi.vfs.VirtualFile;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.List;
+
+/**
+ * RepositoryManager initializes and stores {@link Repository repositories} for Git or Hgroots defined in the project.
+ *
+ * @author Kirill Likhodedov
+ */
+public interface RepositoryManager<T extends Repository> {
+
+ /**
+ * Returns the {@link Repository} which tracks the Git or Hg repository located in the given directory,
+ * or {@code null} if the given file is not a vcs root known to this {@link com.intellij.openapi.project.Project}.
+ */
+ @Nullable
+ T getRepositoryForRoot(@Nullable VirtualFile root);
+
+ /**
+ * Returns the {@link Repository} which the given file belongs to, or {@code null} if the file is not under any Git or Hg repository.
+ */
+ @Nullable
+ T getRepositoryForFile(@NotNull VirtualFile file);
+
+ /**
+ * Returns the {@link Repository} which the given file belongs to, or {@code null} if the file is not under any Git ot Hg repository.
+ */
+ @Nullable
+ T getRepositoryForFile(@NotNull FilePath file);
+
+ /**
+ * @return all repositories tracked by the manager.
+ */
+ @NotNull
+ List<T> getRepositories();
+
+ boolean moreThanOneRoot();
+
+ /**
+ * Synchronously updates the specified information about repository under the given root.
+ *
+ * @param root root directory of the vcs repository.
+ */
+ void updateRepository(VirtualFile root);
+
+ void updateAllRepositories();
+}
diff --git a/platform/dvcs/src/com/intellij/dvcs/repo/RepositoryUtil.java b/platform/dvcs/src/com/intellij/dvcs/repo/RepositoryUtil.java
index 1de63ab..21b8988 100644
--- a/platform/dvcs/src/com/intellij/dvcs/repo/RepositoryUtil.java
+++ b/platform/dvcs/src/com/intellij/dvcs/repo/RepositoryUtil.java
@@ -27,7 +27,7 @@
import java.io.File;
import java.io.IOException;
-import java.util.Collection;
+import java.util.*;
import java.util.concurrent.Callable;
/**
@@ -118,4 +118,15 @@
myRepository.update();
}
}
+
+ public static <T extends Repository> List<T> sortRepositories(@NotNull Collection<T> repositories) {
+ List<T> repos = new ArrayList<T>(repositories);
+ Collections.sort(repos, new Comparator<Repository>() {
+ @Override
+ public int compare(Repository o1, Repository o2) {
+ return o1.getPresentableUrl().compareTo(o2.getPresentableUrl());
+ }
+ });
+ return repos;
+ }
}
diff --git a/platform/dvcs/src/com/intellij/dvcs/ui/NewBranchAction.java b/platform/dvcs/src/com/intellij/dvcs/ui/NewBranchAction.java
index 19f1470..29481e2 100644
--- a/platform/dvcs/src/com/intellij/dvcs/ui/NewBranchAction.java
+++ b/platform/dvcs/src/com/intellij/dvcs/ui/NewBranchAction.java
@@ -15,6 +15,7 @@
*/
package com.intellij.dvcs.ui;
+import com.intellij.dvcs.DvcsUtil;
import com.intellij.dvcs.repo.Repository;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.DumbAwareAction;
@@ -40,7 +41,7 @@
@Override
public void update(AnActionEvent e) {
- if (anyRepositoryIsFresh()) {
+ if (DvcsUtil.anyRepositoryIsFresh(myRepositories)) {
e.getPresentation().setEnabled(false);
e.getPresentation().setDescription("Checkout of a new branch is not possible before the first commit.");
}
@@ -48,13 +49,4 @@
@Override
public abstract void actionPerformed(AnActionEvent e);
-
- private boolean anyRepositoryIsFresh() {
- for (Repository repository : myRepositories) {
- if (repository.isFresh()) {
- return true;
- }
- }
- return false;
- }
}
diff --git a/platform/dvcs/src/com/intellij/dvcs/ui/RootAction.java b/platform/dvcs/src/com/intellij/dvcs/ui/RootAction.java
index a2a2f49..151c706 100644
--- a/platform/dvcs/src/com/intellij/dvcs/ui/RootAction.java
+++ b/platform/dvcs/src/com/intellij/dvcs/ui/RootAction.java
@@ -30,9 +30,9 @@
public class RootAction<T extends Repository> extends ActionGroup {
@NotNull protected final T myRepository;
- @NotNull private ActionGroup myGroup;
- @NotNull private String myBranchText;
- @NotNull private String myBranchOrRev;
+ @NotNull private final ActionGroup myGroup;
+ @NotNull private final String myBranchText;
+ @NotNull private final String myBranchOrRev;
/**
diff --git a/platform/dvcs/testFramework/com/intellij/dvcs/test/MockProject.java b/platform/dvcs/testFramework/com/intellij/dvcs/test/MockProject.java
index 8ec17c4..7a54623 100644
--- a/platform/dvcs/testFramework/com/intellij/dvcs/test/MockProject.java
+++ b/platform/dvcs/testFramework/com/intellij/dvcs/test/MockProject.java
@@ -26,7 +26,7 @@
import org.jetbrains.annotations.NotNull;
/**
- *
+ *
* @author Kirill Likhodedov
*/
public class MockProject implements Project {
@@ -106,17 +106,17 @@
}
@Override
- public BaseComponent getComponent(String name) {
+ public BaseComponent getComponent(@NotNull String name) {
throw new UnsupportedOperationException();
}
@Override
- public <T> T getComponent(Class<T> interfaceClass) {
+ public <T> T getComponent(@NotNull Class<T> interfaceClass) {
throw new UnsupportedOperationException();
}
@Override
- public <T> T getComponent(Class<T> interfaceClass, T defaultImplementationIfAbsent) {
+ public <T> T getComponent(@NotNull Class<T> interfaceClass, T defaultImplementationIfAbsent) {
throw new UnsupportedOperationException();
}
@@ -127,7 +127,7 @@
@NotNull
@Override
- public <T> T[] getComponents(Class<T> baseClass) {
+ public <T> T[] getComponents(@NotNull Class<T> baseClass) {
throw new UnsupportedOperationException();
}
@@ -137,9 +137,10 @@
throw new UnsupportedOperationException();
}
+ @NotNull
@Override
public MessageBus getMessageBus() {
- return null;
+ throw new UnsupportedOperationException();
}
@Override
@@ -147,8 +148,9 @@
return false;
}
+ @NotNull
@Override
- public <T> T[] getExtensions(ExtensionPointName<T> extensionPointName) {
+ public <T> T[] getExtensions(@NotNull ExtensionPointName<T> extensionPointName) {
throw new UnsupportedOperationException();
}
diff --git a/platform/dvcs/testFramework/com/intellij/dvcs/test/MockVcsHelper.java b/platform/dvcs/testFramework/com/intellij/dvcs/test/MockVcsHelper.java
index 25b2b12..98884e6 100644
--- a/platform/dvcs/testFramework/com/intellij/dvcs/test/MockVcsHelper.java
+++ b/platform/dvcs/testFramework/com/intellij/dvcs/test/MockVcsHelper.java
@@ -45,8 +45,8 @@
* @author Kirill Likhodedov
*/
public class MockVcsHelper extends AbstractVcsHelper {
- private boolean myCommitDialogShown;
- private boolean myMergeDialogShown;
+ private volatile boolean myCommitDialogShown;
+ private volatile boolean myMergeDialogShown;
private CommitHandler myCommitHandler;
private MergeHandler myMergeHandler;
diff --git a/platform/extensions/src/com/intellij/openapi/extensions/impl/ExtensionPointImpl.java b/platform/extensions/src/com/intellij/openapi/extensions/impl/ExtensionPointImpl.java
index 685e08d..7cf52a4 100644
--- a/platform/extensions/src/com/intellij/openapi/extensions/impl/ExtensionPointImpl.java
+++ b/platform/extensions/src/com/intellij/openapi/extensions/impl/ExtensionPointImpl.java
@@ -143,13 +143,6 @@
private void internalRegisterExtension(@NotNull T extension, @NotNull ExtensionComponentAdapter adapter, int index, boolean runNotifications) {
if (myExtensions.contains(extension)) {
-
- // DO NOT MERGE:
- // Temporarily hidden in Studio; not sure why this is triggered but we don't want everyone
- // using 0.1.6 to get this error and report it since (a) we know about it (b.android.com/56793)
- // and (b) the IDE can recover
- if (true) { return; }
-
myLogger.error("Extension was already added: " + extension);
return;
}
@@ -243,11 +236,16 @@
myLoadedAdapters.clear();
ExtensionComponentAdapter[] adapters = allAdapters.toArray(new ExtensionComponentAdapter[myExtensionAdapters.size()]);
LoadingOrder.sort(adapters);
+ final List<T> extensions = new ArrayList<T>(adapters.length);
for (ExtensionComponentAdapter adapter : adapters) {
@SuppressWarnings("unchecked") T extension = (T)adapter.getExtension();
assertClass(extension.getClass());
+ extensions.add(extension);
+ }
- internalRegisterExtension(extension, adapter, myExtensions.size(), ArrayUtilRt.find(loadedAdapters, adapter) == -1);
+ for (int i = 0; i < extensions.size(); i++) {
+ T extension = extensions.get(i);
+ internalRegisterExtension(extension, adapters[i], myExtensions.size(), ArrayUtilRt.find(loadedAdapters, adapters[i]) == -1);
}
myExtensionAdapters.clear();
}
diff --git a/platform/external-system-api/resources/i18n/ExternalSystemBundle.properties b/platform/external-system-api/resources/i18n/ExternalSystemBundle.properties
index acd0ee2..2d08b31 100644
--- a/platform/external-system-api/resources/i18n/ExternalSystemBundle.properties
+++ b/platform/external-system-api/resources/i18n/ExternalSystemBundle.properties
@@ -1,5 +1,7 @@
# Import.
import.title=Import {0} Projects
+module.type.title={0} Module
+module.type.description={0} modules are used for developing <b>JVM-based</b> applications with dependencies managed by <b>{0}</b>
orphan.modules.text=<html>The modules below are not backed by {0} anymore.<br/>Check those to be removed from the ide project too:
# Settings.
diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/ExternalSystemManager.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/ExternalSystemManager.java
index df67190..dd50bc8 100644
--- a/platform/external-system-api/src/com/intellij/openapi/externalSystem/ExternalSystemManager.java
+++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/ExternalSystemManager.java
@@ -30,7 +30,7 @@
public interface ExternalSystemManager<
ProjectSettings extends ExternalProjectSettings,
SettingsListener extends ExternalSystemSettingsListener<ProjectSettings>,
- Settings extends AbstractExternalSystemSettings<ProjectSettings, SettingsListener>,
+ Settings extends AbstractExternalSystemSettings<Settings, ProjectSettings, SettingsListener>,
LocalSettings extends AbstractExternalSystemLocalSettings,
ExecutionSettings extends ExternalSystemExecutionSettings>
extends ParametersEnhancer
diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/settings/AbstractExternalSystemLocalSettings.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/settings/AbstractExternalSystemLocalSettings.java
index eecd554..f2cea2f 100644
--- a/platform/external-system-api/src/com/intellij/openapi/externalSystem/settings/AbstractExternalSystemLocalSettings.java
+++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/settings/AbstractExternalSystemLocalSettings.java
@@ -15,6 +15,7 @@
*/
package com.intellij.openapi.externalSystem.settings;
+import com.intellij.openapi.externalSystem.ExternalSystemManager;
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
import com.intellij.openapi.externalSystem.model.execution.ExternalTaskExecutionInfo;
import com.intellij.openapi.externalSystem.model.execution.ExternalTaskPojo;
@@ -46,20 +47,22 @@
= !SystemProperties.getBooleanProperty("external.system.forget.expand.nodes.state", false);
private final AtomicReference<Map<String/*tree path*/, Boolean/*expanded*/>> myExpandStates
- =
+ =
new AtomicReference<Map<String, Boolean>>(new HashMap<String, Boolean>());
- private final AtomicReference<List<ExternalTaskExecutionInfo>> myRecentTasks =
+ private final AtomicReference<List<ExternalTaskExecutionInfo>> myRecentTasks =
new AtomicReference<List<ExternalTaskExecutionInfo>>(
ContainerUtilRt.<ExternalTaskExecutionInfo>newArrayList()
);
- private final AtomicReference<Map<ExternalProjectPojo, Collection<ExternalProjectPojo>>> myAvailableProjects =
+ private final AtomicReference<Map<ExternalProjectPojo, Collection<ExternalProjectPojo>>> myAvailableProjects =
new AtomicReference<Map<ExternalProjectPojo, Collection<ExternalProjectPojo>>>(
ContainerUtilRt.<ExternalProjectPojo, Collection<ExternalProjectPojo>>newHashMap()
);
- private final AtomicReference<Map<String, Collection<ExternalTaskPojo>>> myAvailableTasks =
+ private final AtomicReference<Map<String/* external project config path */, Collection<ExternalTaskPojo>>> myAvailableTasks =
new AtomicReference<Map<String, Collection<ExternalTaskPojo>>>(
ContainerUtilRt.<String, Collection<ExternalTaskPojo>>newHashMap()
);
+ private final AtomicReference<Map<String/* external project config path */, Long>> myExternalConfigModificationStamps =
+ new AtomicReference<Map<String, Long>>(ContainerUtilRt.<String, Long>newHashMap());
@NotNull private final ProjectSystemId myExternalSystemId;
@NotNull private final Project myProject;
@@ -71,7 +74,7 @@
/**
* Asks current settings to drop all information related to external project which root config is located at the given path.
- *
+ *
* @param linkedProjectPathsToForget target root external project's path
*/
public void forgetExternalProject(@NotNull Set<String> linkedProjectPathsToForget) {
@@ -101,6 +104,11 @@
it.remove();
}
}
+
+ Map<String, Long> modificationStamps = myExternalConfigModificationStamps.get();
+ for (String path : linkedProjectPathsToForget) {
+ modificationStamps.remove(path);
+ }
}
@SuppressWarnings("UnusedDeclaration")
@@ -135,7 +143,18 @@
public void setRecentTasks(@NotNull List<ExternalTaskExecutionInfo> tasks) {
myRecentTasks.set(tasks);
}
+
+ @NotNull
+ public Map<String, Long> getExternalConfigModificationStamps() {
+ return myExternalConfigModificationStamps.get();
+ }
+ @SuppressWarnings("UnusedDeclaration")
+ public void setExternalConfigModificationStamps(@NotNull Map<String, Long> modificationStamps) {
+ // Required for IJ serialization.
+ myExternalConfigModificationStamps.set(modificationStamps);
+ }
+
public void fillState(@NotNull State state) {
if (PRESERVE_EXPAND_STATE) {
state.tasksExpandState = myExpandStates.get();
@@ -146,17 +165,44 @@
state.recentTasks = myRecentTasks.get();
state.availableProjects = myAvailableProjects.get();
state.availableTasks = myAvailableTasks.get();
+ state.modificationStamps = myExternalConfigModificationStamps.get();
}
public void loadState(@NotNull State state) {
setIfNotNull(myExpandStates, state.tasksExpandState);
setIfNotNull(myAvailableProjects, state.availableProjects);
setIfNotNull(myAvailableTasks, state.availableTasks);
+ setIfNotNull(myExternalConfigModificationStamps, state.modificationStamps);
if (state.recentTasks != null) {
List<ExternalTaskExecutionInfo> recentTasks = myRecentTasks.get();
recentTasks.clear();
recentTasks.addAll(state.recentTasks);
}
+ pruneOutdatedEntries();
+ }
+
+ private void pruneOutdatedEntries() {
+ ExternalSystemManager<?,?,?,?,?> manager = ExternalSystemApiUtil.getManager(myExternalSystemId);
+ assert manager != null;
+ Set<String> toForget = ContainerUtilRt.newHashSet();
+ for (ExternalProjectPojo pojo : myAvailableProjects.get().keySet()) {
+ toForget.add(pojo.getPath());
+ }
+ for (String path : myAvailableTasks.get().keySet()) {
+ toForget.add(path);
+ }
+ for (ExternalTaskExecutionInfo taskInfo : myRecentTasks.get()) {
+ toForget.add(taskInfo.getSettings().getExternalProjectPath());
+ }
+
+ AbstractExternalSystemSettings<?, ?, ?> settings = manager.getSettingsProvider().fun(myProject);
+ for (ExternalProjectSettings projectSettings : settings.getLinkedProjectsSettings()) {
+ toForget.remove(projectSettings.getExternalProjectPath());
+ }
+
+ if (!toForget.isEmpty()) {
+ forgetExternalProject(toForget);
+ }
}
private static <K, V> void setIfNotNull(@NotNull AtomicReference<Map<K, V>> ref, @Nullable Map<K, V> candidate) {
@@ -172,5 +218,8 @@
public List<ExternalTaskExecutionInfo> recentTasks = ContainerUtilRt.newArrayList();
public Map<ExternalProjectPojo, Collection<ExternalProjectPojo>> availableProjects = ContainerUtilRt.newHashMap();
public Map<String/* project name */, Collection<ExternalTaskPojo>> availableTasks = ContainerUtilRt.newHashMap();
+
+ public Map<String/* linked project path */, Long/* last config modification stamp */> modificationStamps
+ = ContainerUtilRt.newHashMap();
}
}
diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/settings/AbstractExternalSystemSettings.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/settings/AbstractExternalSystemSettings.java
index d947a51..308750d 100644
--- a/platform/external-system-api/src/com/intellij/openapi/externalSystem/settings/AbstractExternalSystemSettings.java
+++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/settings/AbstractExternalSystemSettings.java
@@ -15,7 +15,9 @@
*/
package com.intellij.openapi.externalSystem.settings;
+import com.intellij.openapi.Disposable;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Disposer;
import com.intellij.util.containers.ContainerUtilRt;
import com.intellij.util.messages.Topic;
import org.jetbrains.annotations.NotNull;
@@ -32,28 +34,85 @@
* @author Denis Zhdanov
* @since 4/3/13 4:04 PM
*/
-public abstract class AbstractExternalSystemSettings<S extends ExternalProjectSettings, L extends ExternalSystemSettingsListener<S>> {
-
- @NotNull private final Topic<L> myChangesTopic;
- @NotNull private final Project myProject;
+public abstract class AbstractExternalSystemSettings<
+ SS extends AbstractExternalSystemSettings<SS, PS, L>,
+ PS extends ExternalProjectSettings,
+ L extends ExternalSystemSettingsListener<PS>>
+ implements Disposable
+{
- @NotNull private final Map<String/* project path */, S> myLinkedProjectsSettings = ContainerUtilRt.newHashMap();
+ @NotNull private final Topic<L> myChangesTopic;
+
+ private Project myProject;
+
+ @NotNull private final Map<String/* project path */, PS> myLinkedProjectsSettings = ContainerUtilRt.newHashMap();
+
+ @NotNull private final Map<String/* project path */, PS> myLinkedProjectsSettingsView
+ = Collections.unmodifiableMap(myLinkedProjectsSettings);
protected AbstractExternalSystemSettings(@NotNull Topic<L> topic, @NotNull Project project) {
myChangesTopic = topic;
myProject = project;
+ Disposer.register(project, this);
}
+
+ @Override
+ public void dispose() {
+ myProject = null;
+ }
+
+ @NotNull
+ public Project getProject() {
+ return myProject;
+ }
+
+ /**
+ * Every time particular external system setting is changed corresponding message is sent via ide
+ * <a href="http://confluence.jetbrains.com/display/IDEADEV/IntelliJ+IDEA+Messaging+infrastructure">messaging sub-system</a>.
+ * The problem is that every external system implementation defines it's own topic/listener pair. Listener interface is derived
+ * from the common {@link ExternalSystemSettingsListener} interface and is specific to external sub-system implementation.
+ * However, it's possible that a client wants to perform particular actions based only on {@link ExternalSystemSettingsListener}
+ * facilities. There is no way for such external system-agnostic client to create external system-specific listener
+ * implementation then.
+ * <p/>
+ * That's why this method allows to wrap given 'generic listener' into external system-specific one.
+ *
+ * @param listener target generic listener to wrap to external system-specific implementation
+ */
+ public abstract void subscribe(@NotNull ExternalSystemSettingsListener<PS> listener);
+
+ public void copyFrom(@NotNull SS settings) {
+ myLinkedProjectsSettings.clear();
+ for (PS projectSettings : settings.getLinkedProjectsSettings()) {
+ myLinkedProjectsSettings.put(projectSettings.getExternalProjectPath(), projectSettings);
+ }
+ copyExtraSettingsFrom(settings);
+ }
+
+ protected abstract void copyExtraSettingsFrom(@NotNull SS settings);
@SuppressWarnings("unchecked")
@NotNull
- public Collection<S> getLinkedProjectsSettings() {
- return myLinkedProjectsSettings.values();
+ public Collection<PS> getLinkedProjectsSettings() {
+ return myLinkedProjectsSettingsView.values();
}
@Nullable
- public S getLinkedProjectSettings(@NotNull String linkedProjectPath) {
+ public PS getLinkedProjectSettings(@NotNull String linkedProjectPath) {
return myLinkedProjectsSettings.get(linkedProjectPath);
}
+
+ public void linkProject(@NotNull PS settings) throws IllegalArgumentException {
+ PS existing = getLinkedProjectSettings(settings.getExternalProjectPath());
+ if (existing != null) {
+ throw new IllegalArgumentException(String.format(
+ "Can't link external project '%s'. Reason: it's already registered at the current ide project",
+ settings.getExternalProjectPath()
+ ));
+ }
+ myLinkedProjectsSettings.put(settings.getExternalProjectPath(), settings);
+ getPublisher().onProjectsLinked(Collections.singleton(settings));
+ }
/**
* Un-links given external project from the current ide project.
@@ -64,7 +123,7 @@
* <code>false</code> otherwise
*/
public boolean unlinkExternalProject(@NotNull String linkedProjectPath) {
- S removed = myLinkedProjectsSettings.remove(linkedProjectPath);
+ PS removed = myLinkedProjectsSettings.remove(linkedProjectPath);
if (removed == null) {
return false;
}
@@ -73,16 +132,16 @@
return true;
}
- public void setLinkedProjectsSettings(@NotNull Collection<S> settings) {
- List<S> added = ContainerUtilRt.newArrayList();
- Map<String, S> removed = ContainerUtilRt.newHashMap(myLinkedProjectsSettings);
+ public void setLinkedProjectsSettings(@NotNull Collection<PS> settings) {
+ List<PS> added = ContainerUtilRt.newArrayList();
+ Map<String, PS> removed = ContainerUtilRt.newHashMap(myLinkedProjectsSettings);
myLinkedProjectsSettings.clear();
- for (S current : settings) {
+ for (PS current : settings) {
myLinkedProjectsSettings.put(current.getExternalProjectPath(), current);
}
- for (S current : settings) {
- S old = removed.remove(current.getExternalProjectPath());
+ for (PS current : settings) {
+ PS old = removed.remove(current.getExternalProjectPath());
if (old == null) {
added.add(current);
}
@@ -108,7 +167,7 @@
* @param old old settings state
* @param current current settings state
*/
- protected abstract void checkSettings(@NotNull S old, @NotNull S current);
+ protected abstract void checkSettings(@NotNull PS old, @NotNull PS current);
@NotNull
public Topic<L> getChangesTopic() {
@@ -120,17 +179,17 @@
return myProject.getMessageBus().syncPublisher(myChangesTopic);
}
- protected void fillState(@NotNull State<S> state) {
+ protected void fillState(@NotNull State<PS> state) {
state.setLinkedExternalProjectsSettings(ContainerUtilRt.newTreeSet(myLinkedProjectsSettings.values()));
}
@SuppressWarnings("unchecked")
- protected void loadState(@NotNull State<S> state) {
- Set<S> settings = state.getLinkedExternalProjectsSettings();
+ protected void loadState(@NotNull State<PS> state) {
+ Set<PS> settings = state.getLinkedExternalProjectsSettings();
if (settings != null) {
myLinkedProjectsSettings.clear();
- for (S s : settings) {
- myLinkedProjectsSettings.put(s.getExternalProjectPath(), s);
+ for (PS projectSettings : settings) {
+ myLinkedProjectsSettings.put(projectSettings.getExternalProjectPath(), projectSettings);
}
}
}
diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/settings/DelegatingExternalSystemSettingsListener.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/settings/DelegatingExternalSystemSettingsListener.java
new file mode 100644
index 0000000..6afb850
--- /dev/null
+++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/settings/DelegatingExternalSystemSettingsListener.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2000-2013 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.externalSystem.settings;
+
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Collection;
+import java.util.Set;
+
+/**
+ * @author Denis Zhdanov
+ * @since 6/24/13 6:23 PM
+ */
+public class DelegatingExternalSystemSettingsListener<S extends ExternalProjectSettings> implements ExternalSystemSettingsListener<S> {
+
+ @NotNull private final ExternalSystemSettingsListener<S> myDelegate;
+
+ public DelegatingExternalSystemSettingsListener(@NotNull ExternalSystemSettingsListener<S> delegate) {
+ myDelegate = delegate;
+ }
+
+ @Override
+ public void onProjectsLinked(@NotNull Collection<S> settings) {
+ myDelegate.onProjectsLinked(settings);
+ }
+
+ @Override
+ public void onProjectsUnlinked(@NotNull Set<String> linkedProjectPaths) {
+ myDelegate.onProjectsUnlinked(linkedProjectPaths);
+ }
+
+ @Override
+ public void onUseAutoImportChange(boolean currentValue, @NotNull String linkedProjectPath) {
+ myDelegate.onUseAutoImportChange(currentValue, linkedProjectPath);
+ }
+
+ @Override
+ public void onBulkChangeStart() {
+ myDelegate.onBulkChangeStart();
+ }
+
+ @Override
+ public void onBulkChangeEnd() {
+ myDelegate.onBulkChangeEnd();
+ }
+}
diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemApiUtil.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemApiUtil.java
index fd35403..3d97120 100644
--- a/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemApiUtil.java
+++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemApiUtil.java
@@ -184,7 +184,7 @@
*/
@NotNull
public static String toCanonicalPath(@NotNull String path) {
- return PathUtil.getCanonicalPath(new File(path).getAbsolutePath());
+ return PathUtil.getCanonicalPath(normalizePath(new File(path).getAbsolutePath()));
}
@NotNull
@@ -215,6 +215,7 @@
@NotNull
public static <K, V> Map<DataNode<K>, List<DataNode<V>>> groupBy(@NotNull Collection<DataNode<V>> nodes, @NotNull final Key<K> key) {
return groupBy(nodes, new Function<DataNode<V>, DataNode<K>>() {
+ @Nullable
@Override
public DataNode<K> fun(DataNode<V> node) {
return node.getDataNode(key);
@@ -355,7 +356,10 @@
if (!pathToUse.startsWith("/")) {
pathToUse = '/' + pathToUse;
}
- classPath.add(PathManager.getResourceRoot(contextClass, pathToUse));
+ String root = PathManager.getResourceRoot(contextClass, pathToUse);
+ if (root != null) {
+ classPath.add(root);
+ }
}
@SuppressWarnings("ConstantConditions")
diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemConstants.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemConstants.java
index f3a606d..80795f4 100644
--- a/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemConstants.java
+++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemConstants.java
@@ -24,18 +24,17 @@
*/
public class ExternalSystemConstants {
- @NonNls @NotNull public static final String NEWLY_IMPORTED_PROJECT = "external.system.newly.imported";
@NonNls @NotNull public static final String EXTERNAL_SYSTEM_ID_KEY = "external.system.id";
@NonNls @NotNull public static final String LINKED_PROJECT_PATH_KEY = "external.linked.project.path";
@NonNls @NotNull public static final String TOOL_WINDOW_TOOLBAR_ACTIONS_GROUP_ID = "ExternalSystem.ToolWindow.Toolbar";
@NonNls @NotNull public static final String TREE_ACTIONS_GROUP_ID = "ExternalSystem.Tree.Context";
- @NonNls @NotNull public static final String TOOL_WINDOW_PLACE = "ExternalSystem.ToolWindow";
- @NonNls @NotNull public static final String TREE_PLACE = "ExternalSystem.Tree";
+ @NonNls @NotNull public static final String TOOL_WINDOW_PLACE = "ExternalSystem.ToolWindow";
+ @NonNls @NotNull public static final String TREE_CONTEXT_MENU_PLACE = "ExternalSystem.Tree.Context.Menu";
@NotNull public static final String DEBUG_RUNNER_ID = "ExternalSystemTaskDebugRunner";
- @NotNull public static final String RUNNER_ID = "ExternalSystemTaskRunner";
+ @NotNull public static final String RUNNER_ID = "ExternalSystemTaskRunner";
public static final boolean VERBOSE_PROCESSING = SystemProperties.getBooleanProperty("external.system.verbose.processing", false);
public static final int RECENT_TASKS_NUMBER = SystemProperties.getIntProperty("external.system.recent.tasks.number", 7);
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/action/AttachExternalProjectAction.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/action/AttachExternalProjectAction.java
index 8a94464..dcd4479 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/action/AttachExternalProjectAction.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/action/AttachExternalProjectAction.java
@@ -17,17 +17,20 @@
import com.intellij.icons.AllIcons;
import com.intellij.ide.actions.ImportModuleAction;
+import com.intellij.ide.util.newProjectWizard.AddModuleWizard;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.externalSystem.ExternalSystemManager;
import com.intellij.openapi.externalSystem.model.ExternalSystemDataKeys;
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
+import com.intellij.openapi.externalSystem.service.project.wizard.AbstractExternalProjectImportProvider;
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
import com.intellij.openapi.externalSystem.util.ExternalSystemBundle;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.SystemInfoRt;
+import com.intellij.projectImport.ProjectImportProvider;
/**
* @author Denis Zhdanov
@@ -61,7 +64,26 @@
if (project == null) {
return;
}
+
+ ProjectImportProvider[] projectImportProviders = new ProjectImportProvider[1];
+ for (ProjectImportProvider provider : ProjectImportProvider.PROJECT_IMPORT_PROVIDER.getExtensions()) {
+ if (provider instanceof AbstractExternalProjectImportProvider
+ && externalSystemId.equals(((AbstractExternalProjectImportProvider)provider).getExternalSystemId()))
+ {
+ projectImportProviders[0] = provider;
+ break;
+ }
+ }
+ if (projectImportProviders[0] == null) {
+ return;
+ }
- ImportModuleAction.doImport(project);
+ AddModuleWizard wizard = ImportModuleAction.selectFileAndCreateWizard(project,
+ null,
+ manager.getExternalProjectDescriptor(),
+ projectImportProviders);
+ if (wizard != null && (wizard.getStepCount() <= 0 || wizard.showAndGet())) {
+ ImportModuleAction.createFromWizard(project, wizard);
+ }
}
}
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/action/DetachExternalProjectAction.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/action/DetachExternalProjectAction.java
index abfa7ef..6c96875 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/action/DetachExternalProjectAction.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/action/DetachExternalProjectAction.java
@@ -15,12 +15,12 @@
*/
package com.intellij.openapi.externalSystem.action;
+import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.components.ServiceManager;
-import com.intellij.openapi.externalSystem.ExternalSystemManager;
import com.intellij.openapi.externalSystem.model.ExternalSystemDataKeys;
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
import com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo;
@@ -30,15 +30,18 @@
import com.intellij.openapi.externalSystem.settings.AbstractExternalSystemLocalSettings;
import com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings;
import com.intellij.openapi.externalSystem.settings.ExternalProjectSettings;
-import com.intellij.openapi.externalSystem.util.*;
+import com.intellij.openapi.externalSystem.settings.ExternalSystemSettingsManager;
+import com.intellij.openapi.externalSystem.util.ExternalSystemBundle;
+import com.intellij.openapi.externalSystem.util.ExternalSystemConstants;
+import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.SystemInfoRt;
import com.intellij.util.containers.ContainerUtilRt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import javax.swing.*;
import java.util.Collections;
import java.util.List;
@@ -51,15 +54,19 @@
public DetachExternalProjectAction() {
getTemplatePresentation().setText(ExternalSystemBundle.message("action.detach.external.project.text"));
getTemplatePresentation().setDescription(ExternalSystemBundle.message("action.detach.external.project.description"));
+ getTemplatePresentation().setIcon(SystemInfoRt.isMac ? AllIcons.ToolbarDecorator.Mac.Remove : AllIcons.ToolbarDecorator.Remove);
}
@Override
public void update(AnActionEvent e) {
MyInfo info = getProcessingInfo(e.getDataContext());
- if (info.icon != null) {
- e.getPresentation().setIcon(info.icon);
+ String place = e.getPlace();
+ if (ExternalSystemConstants.TOOL_WINDOW_PLACE.equals(place)) {
+ e.getPresentation().setEnabled(info.externalProject != null);
}
- e.getPresentation().setVisible(info.externalProject != null);
+ else if (ExternalSystemConstants.TREE_CONTEXT_MENU_PLACE.equals(place)) {
+ e.getPresentation().setVisible(info.externalProject != null);
+ }
}
@Override
@@ -121,44 +128,39 @@
return MyInfo.EMPTY;
}
- ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(externalSystemId);
- assert manager != null;
- AbstractExternalSystemSettings<?, ?> settings = manager.getSettingsProvider().fun(ideProject);
+ ExternalSystemSettingsManager settingsManager = ServiceManager.getService(ExternalSystemSettingsManager.class);
+ AbstractExternalSystemSettings<?, ?, ?> settings = settingsManager.getSettings(ideProject, externalSystemId);
ExternalProjectSettings externalProjectSettings = settings.getLinkedProjectSettings(externalProject.getPath());
- AbstractExternalSystemLocalSettings localSettings = manager.getLocalSettingsProvider().fun(ideProject);
- Icon icon = ExternalSystemUiUtil.getUiAware(externalSystemId).getProjectIcon();
+ AbstractExternalSystemLocalSettings localSettings = settingsManager.getLocalSettings(ideProject, externalSystemId);
+
return new MyInfo(externalProjectSettings == null ? null : settings,
localSettings == null ? null : localSettings,
externalProjectSettings == null ? null : externalProject,
ideProject,
- externalSystemId,
- icon);
+ externalSystemId);
}
private static class MyInfo {
- public static final MyInfo EMPTY = new MyInfo(null, null, null, null, null, null);
+ public static final MyInfo EMPTY = new MyInfo(null, null, null, null, null);
- @Nullable public final AbstractExternalSystemSettings<?, ?> settings;
+ @Nullable public final AbstractExternalSystemSettings<?, ?, ?> settings;
@Nullable public final AbstractExternalSystemLocalSettings localSettings;
@Nullable public final ExternalProjectPojo externalProject;
@Nullable public final Project ideProject;
@Nullable public final ProjectSystemId externalSystemId;
- @Nullable public final Icon icon;
- MyInfo(@Nullable AbstractExternalSystemSettings<?, ?> settings,
+ MyInfo(@Nullable AbstractExternalSystemSettings<?, ?, ?> settings,
@Nullable AbstractExternalSystemLocalSettings localSettings,
@Nullable ExternalProjectPojo externalProject,
@Nullable Project ideProject,
- @Nullable ProjectSystemId externalSystemId,
- @Nullable Icon icon)
+ @Nullable ProjectSystemId externalSystemId)
{
this.settings = settings;
this.localSettings = localSettings;
this.externalProject = externalProject;
this.ideProject = ideProject;
this.externalSystemId = externalSystemId;
- this.icon = icon;
}
}
}
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/action/RefreshAllExternalProjectsAction.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/action/RefreshAllExternalProjectsAction.java
index 9d88d5f..57c4cf7 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/action/RefreshAllExternalProjectsAction.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/action/RefreshAllExternalProjectsAction.java
@@ -60,6 +60,6 @@
// We save all documents because there is a possible case that there is an external system config file changed inside the ide.
FileDocumentManager.getInstance().saveAllDocuments();
- ExternalSystemUtil.refreshProjects(project, externalSystemId);
+ ExternalSystemUtil.refreshProjects(project, externalSystemId, true);
}
}
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/model/ExternalSystemDataKeys.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/model/ExternalSystemDataKeys.java
index cb485c3..c2f885f 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/model/ExternalSystemDataKeys.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/model/ExternalSystemDataKeys.java
@@ -21,6 +21,7 @@
import com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo;
import com.intellij.openapi.externalSystem.service.task.ui.ExternalSystemRecentTasksList;
import com.intellij.openapi.externalSystem.service.task.ui.ExternalSystemTasksTreeModel;
+import com.intellij.openapi.util.Key;
import org.jetbrains.annotations.NotNull;
/**
@@ -38,6 +39,8 @@
@NotNull public static final DataKey<ExternalSystemRecentTasksList> RECENT_TASKS_LIST
= DataKey.create("external.system.recent.tasks.list");
+ @NotNull public static final Key<Boolean> NEWLY_IMPORTED_PROJECT = new Key<Boolean>("external.system.newly.imported");
+
private ExternalSystemDataKeys() {
}
}
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/model/settings/LocationSettingType.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/model/settings/LocationSettingType.java
index 32ef4e7..c067932 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/model/settings/LocationSettingType.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/model/settings/LocationSettingType.java
@@ -7,6 +7,7 @@
import javax.swing.*;
import java.awt.*;
+import java.util.Arrays;
/**
* Enumerates possible types of 'gradle home' location setting.
@@ -17,7 +18,7 @@
public enum LocationSettingType {
/** User hasn't defined gradle location but the IDE discovered it automatically. */
- DEDUCED("setting.type.location.deduced", "TextField.inactiveForeground"),
+ DEDUCED("setting.type.location.deduced", "TextField.inactiveForeground", "nimbusDisabledText"),
/** User hasn't defined gradle location and the IDE was unable to discover it automatically. */
UNKNOWN("setting.type.location.unknown"),
@@ -26,19 +27,28 @@
EXPLICIT_INCORRECT("setting.type.location.explicit.correct"),
EXPLICIT_CORRECT("setting.type.location.explicit.incorrect");
-
+
@NotNull private final String myDescriptionKey;
- @NotNull private final String myColorKey;
+ @NotNull private final Color myColor;
LocationSettingType(@NotNull String descriptionKey) {
this(descriptionKey, "TextField.foreground");
}
LocationSettingType(@NotNull @PropertyKey(resourceBundle = ExternalSystemBundle.PATH_TO_BUNDLE) String descriptionKey,
- @NotNull String colorKey)
+ @NotNull String ... colorKeys)
{
myDescriptionKey = descriptionKey;
- myColorKey = colorKey;
+ Color c = null;
+ for (String key : colorKeys) {
+ c = UIManager.getColor(key);
+ if (c != null) {
+ break;
+ }
+ }
+
+ assert c != null : "Can't find color for keys " + Arrays.toString(colorKeys);
+ myColor = c;
}
/**
@@ -50,6 +60,6 @@
@NotNull
public Color getColor() {
- return UIManager.getColor(myColorKey);
+ return myColor;
}
}
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ExternalSystemFacadeImpl.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ExternalSystemFacadeImpl.java
index 050dff9..d61abed 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ExternalSystemFacadeImpl.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ExternalSystemFacadeImpl.java
@@ -11,6 +11,9 @@
import com.intellij.util.containers.ContainerUtilRt;
import org.jetbrains.annotations.NotNull;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintStream;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
@@ -45,6 +48,7 @@
@NotNull private final RemoteExternalSystemProjectResolverImpl<S> myProjectResolver;
@NotNull private final RemoteExternalSystemTaskManagerImpl<S> myTaskManager;
+ private volatile boolean myStdOutputConfigured;
public ExternalSystemFacadeImpl(@NotNull Class<ExternalSystemProjectResolver<S>> projectResolverClass,
@NotNull Class<ExternalSystemTaskManager<S>> buildManagerClass)
@@ -131,7 +135,7 @@
* @throws ClassNotFoundException in case of incorrect assumptions about server class interface
* @throws RemoteException
*/
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({"unchecked", "IOResourceOpenedButNotSafelyClosed", "UseOfSystemOutOrSystemErr"})
private <I extends RemoteExternalSystemService<S>, C extends I> I getRemote(@NotNull Class<I> interfaceClass,
@NotNull final C impl)
throws ClassNotFoundException, IllegalAccessException, InstantiationException, RemoteException
@@ -140,6 +144,13 @@
if (cachedResult != null) {
return (I)cachedResult;
}
+
+ if (!myStdOutputConfigured) {
+ myStdOutputConfigured = true;
+ System.setOut(new LineAwarePrintStream(System.out));
+ System.setErr(new LineAwarePrintStream(System.err));
+ }
+
S settings = mySettings.get();
if (settings != null) {
impl.setNotificationListener(myNotificationListener.get());
@@ -308,4 +319,46 @@
}
}
}
+
+ @SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
+ private static class LineAwarePrintStream extends PrintStream {
+ private LineAwarePrintStream(@NotNull final PrintStream delegate) {
+ super(new OutputStream() {
+
+ @NotNull private final StringBuilder myBuffer = new StringBuilder();
+
+ @Override
+ public void write(int b) throws IOException {
+ char c = (char)b;
+ myBuffer.append(Character.toString(c));
+ if (c == '\n') {
+ doFlush();
+ }
+ }
+
+ @Override
+ public void write(byte[] b, int off, int len) throws IOException {
+ int start = off;
+ int maxOffset = off + len;
+ for (int i = off; i < maxOffset; i++) {
+ if (b[i] == '\n') {
+ myBuffer.append(new String(b, start, i - start + 1));
+ doFlush();
+ start = i + 1;
+ }
+ }
+
+ if (start < maxOffset) {
+ myBuffer.append(new String(b, start, maxOffset - start));
+ }
+ }
+
+ private void doFlush() {
+ delegate.print(myBuffer.toString());
+ delegate.flush();
+ myBuffer.setLength(0);
+ }
+ });
+ }
+ }
}
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ExternalSystemStartupActivity.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ExternalSystemStartupActivity.java
index 859b6bd..d3f63f3 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ExternalSystemStartupActivity.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ExternalSystemStartupActivity.java
@@ -16,14 +16,14 @@
package com.intellij.openapi.externalSystem.service;
import com.intellij.openapi.externalSystem.ExternalSystemManager;
+import com.intellij.openapi.externalSystem.model.ExternalSystemDataKeys;
import com.intellij.openapi.externalSystem.service.project.autoimport.ExternalSystemAutoImporter;
import com.intellij.openapi.externalSystem.service.ui.ExternalToolWindowManager;
-import com.intellij.openapi.externalSystem.util.ExternalSystemConstants;
+import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.startup.StartupActivity;
import com.intellij.openapi.startup.StartupManager;
-import com.intellij.util.SystemProperties;
/**
* @author Denis Zhdanov
@@ -37,12 +37,14 @@
@SuppressWarnings("unchecked")
@Override
public void run() {
- if (SystemProperties.getBooleanProperty(ExternalSystemConstants.NEWLY_IMPORTED_PROJECT, false)) {
- System.setProperty(ExternalSystemConstants.NEWLY_IMPORTED_PROJECT, Boolean.toString(false));
+ for (ExternalSystemManager<?, ?, ?, ?, ?> manager : ExternalSystemApiUtil.getAllManagers()) {
+ if (manager instanceof StartupActivity) {
+ ((StartupActivity)manager).runActivity(project);
+ }
}
- else {
+ if (project.getUserData(ExternalSystemDataKeys.NEWLY_IMPORTED_PROJECT) != Boolean.TRUE) {
for (ExternalSystemManager manager : ExternalSystemManager.EP_NAME.getExtensions()) {
- ExternalSystemUtil.refreshProjects(project, manager.getSystemId());
+ ExternalSystemUtil.refreshProjects(project, manager.getSystemId(), false);
}
}
ExternalSystemAutoImporter.letTheMagicBegin(project);
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/AbstractExternalSystemTaskConfigurationType.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/AbstractExternalSystemTaskConfigurationType.java
index 9b57fd7..5f050bb 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/AbstractExternalSystemTaskConfigurationType.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/AbstractExternalSystemTaskConfigurationType.java
@@ -71,6 +71,7 @@
return myFactories[0];
}
+ @SuppressWarnings("MethodMayBeStatic")
@NotNull
protected ExternalSystemRunConfiguration doCreateConfiguration(@NotNull ProjectSystemId externalSystemId,
@NotNull Project project,
@@ -124,7 +125,7 @@
{
ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(externalSystemId);
assert manager != null;
- AbstractExternalSystemSettings<?,?> s = manager.getSettingsProvider().fun(project);
+ AbstractExternalSystemSettings<?, ?,?> s = manager.getSettingsProvider().fun(project);
Map<String/* project dir path */, String/* project file path */> rootProjectPaths = ContainerUtilRt.newHashMap();
for (ExternalProjectSettings projectSettings : s.getLinkedProjectsSettings()) {
String path = projectSettings.getExternalProjectPath();
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/ExternalSystemRunConfiguration.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/ExternalSystemRunConfiguration.java
index 6248fb6..c4700d0 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/ExternalSystemRunConfiguration.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/ExternalSystemRunConfiguration.java
@@ -131,7 +131,7 @@
public void checkConfiguration() throws RuntimeConfigurationException {
}
- public static class MyRunnableState implements RunnableState {
+ public static class MyRunnableState implements RunProfileState {
@NotNull private final ExternalSystemTaskExecutionSettings mySettings;
@NotNull private final Project myProject;
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/internal/AbstractExternalSystemTask.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/internal/AbstractExternalSystemTask.java
index 806db99..e736723 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/internal/AbstractExternalSystemTask.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/internal/AbstractExternalSystemTask.java
@@ -31,7 +31,7 @@
new AtomicReference<ExternalSystemTaskState>(ExternalSystemTaskState.NOT_STARTED);
private final AtomicReference<Throwable> myError = new AtomicReference<Throwable>();
- @NotNull transient private final Project myIdeProject;
+ @NotNull private final transient Project myIdeProject;
@NotNull private final ExternalSystemTaskId myId;
@NotNull private final ProjectSystemId myExternalSystemId;
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/ExternalSystemIdeNotificationManager.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/ExternalSystemIdeNotificationManager.java
index 1adf63a..d23c8c3 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/ExternalSystemIdeNotificationManager.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/notification/ExternalSystemIdeNotificationManager.java
@@ -15,6 +15,7 @@
import com.intellij.openapi.options.ShowSettingsUtil;
import com.intellij.openapi.project.Project;
import com.intellij.ui.EditorNotifications;
+import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -41,7 +42,10 @@
@NotNull String externalProjectName,
@NotNull ProjectSystemId externalSystemId)
{
- ExternalSystemManager<?,?,?,?,?> manager = ExternalSystemApiUtil.getManager(externalSystemId);
+ if (project.isDisposed() || !project.isOpen()) {
+ return;
+ }
+ ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(externalSystemId);
if (!(manager instanceof ExternalSystemConfigurableAware)) {
return;
}
@@ -62,26 +66,32 @@
});
}
- public void showNotification(@NotNull String title,
- @NotNull String message,
- @NotNull NotificationType type,
- @NotNull Project project,
- @NotNull ProjectSystemId externalSystemId,
- @Nullable NotificationListener listener)
+ public void showNotification(@NotNull final String title,
+ @NotNull final String message,
+ @NotNull final NotificationType type,
+ @NotNull final Project project,
+ @NotNull final ProjectSystemId externalSystemId,
+ @Nullable final NotificationListener listener)
{
- NotificationGroup group = ExternalSystemUtil.getToolWindowElement(NotificationGroup.class,
- project,
- ExternalSystemDataKeys.NOTIFICATION_GROUP,
- externalSystemId);
- if (group == null) {
- return;
- }
+ UIUtil.invokeLaterIfNeeded(new Runnable() {
+ @Override
+ public void run() {
+ NotificationGroup group = ExternalSystemUtil.getToolWindowElement(NotificationGroup.class,
+ project,
+ ExternalSystemDataKeys.NOTIFICATION_GROUP,
+ externalSystemId);
+ if (group == null) {
+ return;
+ }
- Notification notification = group.createNotification(title, message, type, listener);
- applyNotification(notification, project);
+ Notification notification = group.createNotification(title, message, type, listener);
+ applyNotification(notification, project);
+ }
+ });
+
}
- private void applyNotification(@NotNull Notification notification, @NotNull Project project) {
+ private void applyNotification(@NotNull final Notification notification, @NotNull final Project project) {
final Notification oldNotification = myNotification.get();
if (oldNotification != null && myNotification.compareAndSet(oldNotification, null)) {
oldNotification.expire();
@@ -91,6 +101,8 @@
return;
}
- notification.notify(project);
+ if (!project.isDisposed() && project.isOpen()) {
+ notification.notify(project);
+ }
}
}
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/autoimport/ExternalSystemAutoImporter.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/autoimport/ExternalSystemAutoImporter.java
index 79b581f..8527c63 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/autoimport/ExternalSystemAutoImporter.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/autoimport/ExternalSystemAutoImporter.java
@@ -34,6 +34,7 @@
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.roots.ex.ProjectRootManagerEx;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
@@ -78,14 +79,24 @@
@NotNull private final Runnable myDocumentsSaveRequest = new Runnable() {
@Override
public void run() {
- saveDocumentsIfNecessary();
+ saveDocumentsIfNecessary();
}
};
@NotNull private final ExternalProjectRefreshCallback myRefreshCallback = new ExternalProjectRefreshCallback() {
@Override
- public void onSuccess(@Nullable DataNode<ProjectData> externalProject) {
+ public void onSuccess(@Nullable final DataNode<ProjectData> externalProject) {
if (externalProject != null) {
- myProjectDataManager.importData(externalProject.getKey(), Collections.singleton(externalProject), myProject, false);
+ ExternalSystemApiUtil.executeProjectChangeAction(new Runnable() {
+ @Override
+ public void run() {
+ ProjectRootManagerEx.getInstanceEx(myProject).mergeRootsChangesDuring(new Runnable() {
+ @Override
+ public void run() {
+ myProjectDataManager.importData(externalProject.getKey(), Collections.singleton(externalProject), myProject, true);
+ }
+ });
+ }
+ });
}
}
@@ -114,7 +125,7 @@
List<MyEntry> autoImportAware = ContainerUtilRt.newArrayList();
Collection<ExternalSystemManager<?, ?, ?, ?, ?>> managers = ExternalSystemApiUtil.getAllManagers();
for (ExternalSystemManager<?, ?, ?, ?, ?> manager : managers) {
- AbstractExternalSystemSettings<?, ?> systemSettings = manager.getSettingsProvider().fun(project);
+ AbstractExternalSystemSettings<?, ?, ?> systemSettings = manager.getSettingsProvider().fun(project);
ExternalSystemAutoImportAware defaultImportAware = createDefault(systemSettings);
final ExternalSystemAutoImportAware aware;
if (manager instanceof ExternalSystemAutoImportAware) {
@@ -153,7 +164,7 @@
}
@NotNull
- private static ExternalSystemAutoImportAware createDefault(@NotNull final AbstractExternalSystemSettings<?, ?> systemSettings) {
+ private static ExternalSystemAutoImportAware createDefault(@NotNull final AbstractExternalSystemSettings<?, ?, ?> systemSettings) {
return new ExternalSystemAutoImportAware() {
@Nullable
@Override
@@ -327,13 +338,13 @@
}
private static class MyEntry {
-
- @NotNull public final ProjectSystemId externalSystemId;
- @NotNull public final AbstractExternalSystemSettings<?, ?> systemSettings;
- @NotNull public final ExternalSystemAutoImportAware aware;
+
+ @NotNull public final ProjectSystemId externalSystemId;
+ @NotNull public final AbstractExternalSystemSettings<?, ?, ?> systemSettings;
+ @NotNull public final ExternalSystemAutoImportAware aware;
MyEntry(@NotNull ProjectSystemId externalSystemId,
- @NotNull AbstractExternalSystemSettings<?, ?> systemSettings,
+ @NotNull AbstractExternalSystemSettings<?, ?, ?> systemSettings,
@NotNull ExternalSystemAutoImportAware aware)
{
this.externalSystemId = externalSystemId;
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/LibraryDataService.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/LibraryDataService.java
index 48777a1..5d7bbe1 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/LibraryDataService.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/LibraryDataService.java
@@ -27,6 +27,7 @@
import java.io.File;
import java.util.Collection;
+import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -181,12 +182,21 @@
}
public void syncPaths(@NotNull final LibraryData externalLibrary, @NotNull final Library ideLibrary, boolean synchronous) {
- final Set<String> toRemove = ContainerUtilRt.newHashSet();
- final Set<String> toAdd = ContainerUtilRt.newHashSet(externalLibrary.getPaths(LibraryPathType.BINARY));
- for (VirtualFile ideFile : ideLibrary.getFiles(OrderRootType.CLASSES)) {
- String idePath = ExternalSystemApiUtil.getLocalFileSystemPath(ideFile);
- if (!toAdd.remove(idePath)) {
- toRemove.add(idePath);
+ final Map<OrderRootType, Set<String>> toRemove = ContainerUtilRt.newHashMap();
+ final Map<OrderRootType, Set<String>> toAdd = ContainerUtilRt.newHashMap();
+ for (LibraryPathType pathType : LibraryPathType.values()) {
+ OrderRootType ideType = myLibraryPathTypeMapper.map(pathType);
+ HashSet<String> toAddPerType = ContainerUtilRt.newHashSet(externalLibrary.getPaths(pathType));
+ toAdd.put(ideType, toAddPerType);
+
+ HashSet<String> toRemovePerType = ContainerUtilRt.newHashSet();
+ toRemove.put(ideType, toRemovePerType);
+
+ for (VirtualFile ideFile : ideLibrary.getFiles(ideType)) {
+ String idePath = ExternalSystemApiUtil.getLocalFileSystemPath(ideFile);
+ if (!toAddPerType.remove(idePath)) {
+ toRemovePerType.add(ideFile.getUrl());
+ }
}
}
if (toRemove.isEmpty() && toAdd.isEmpty()) {
@@ -197,12 +207,17 @@
public void run() {
Library.ModifiableModel model = ideLibrary.getModifiableModel();
try {
- for (String path : toRemove) {
- model.removeRoot(path, OrderRootType.CLASSES);
+ for (Map.Entry<OrderRootType, Set<String>> entry : toRemove.entrySet()) {
+ for (String path : entry.getValue()) {
+ model.removeRoot(path, entry.getKey());
+ }
}
- Map<OrderRootType, Collection<File>> roots = ContainerUtilRt.newHashMap();
- roots.put(OrderRootType.CLASSES, ContainerUtil.map(toAdd, PATH_TO_FILE));
- registerPaths(roots, model, externalLibrary.getName());
+
+ for (Map.Entry<OrderRootType, Set<String>> entry : toAdd.entrySet()) {
+ Map<OrderRootType, Collection<File>> roots = ContainerUtilRt.newHashMap();
+ roots.put(entry.getKey(), ContainerUtil.map(entry.getValue(), PATH_TO_FILE));
+ registerPaths(roots, model, externalLibrary.getName());
+ }
}
finally {
model.commit();
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDataService.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDataService.java
index 94e61cd..bad7805 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDataService.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDataService.java
@@ -21,7 +21,6 @@
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.Alarm;
import com.intellij.util.containers.ContainerUtilRt;
-import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import java.io.File;
@@ -72,7 +71,7 @@
myAlarm.addRequest(new ImportModulesTask(project, toImport, synchronous), PROJECT_INITIALISATION_DELAY_MS);
return;
}
- Runnable task = new Runnable() {
+ ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new Runnable() {
@Override
public void run() {
final Collection<DataNode<ModuleData>> toCreate = filterExistingModules(toImport, project);
@@ -84,15 +83,9 @@
if (module != null) {
syncPaths(module, node.getData());
}
- }
+ }
}
- };
- if (synchronous) {
- UIUtil.invokeAndWaitIfNeeded(task);
- }
- else {
- UIUtil.invokeLaterIfNeeded(task);
- }
+ });
}
private void createModules(@NotNull final Collection<DataNode<ModuleData>> toCreate, @NotNull final Project project) {
@@ -187,27 +180,28 @@
}
private static void syncPaths(@NotNull Module module, @NotNull ModuleData data) {
- CompilerModuleExtension extension = CompilerModuleExtension.getInstance(module);
+ ModifiableRootModel modifiableModel = ModuleRootManager.getInstance(module).getModifiableModel();
+ CompilerModuleExtension extension = modifiableModel.getModuleExtension(CompilerModuleExtension.class);
if (extension == null) {
+ modifiableModel.dispose();
LOG.warn(String.format("Can't sync paths for module '%s'. Reason: no compiler extension is found for it", module.getName()));
return;
}
- CompilerModuleExtension model = (CompilerModuleExtension)extension.getModifiableModel(true);
try {
String compileOutputPath = data.getCompileOutputPath(ExternalSystemSourceType.SOURCE);
if (compileOutputPath != null) {
- model.setCompilerOutputPath(compileOutputPath);
+ extension.setCompilerOutputPath(compileOutputPath);
}
String testCompileOutputPath = data.getCompileOutputPath(ExternalSystemSourceType.TEST);
if (testCompileOutputPath != null) {
- model.setCompilerOutputPathForTests(testCompileOutputPath);
+ extension.setCompilerOutputPathForTests(testCompileOutputPath);
}
- model.inheritCompilerOutputPath(data.isInheritProjectCompileOutputPath());
+ extension.inheritCompilerOutputPath(data.isInheritProjectCompileOutputPath());
}
finally {
- model.commit();
+ modifiableModel.commit();
}
}
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractExternalModuleBuilder.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractExternalModuleBuilder.java
new file mode 100644
index 0000000..e592312
--- /dev/null
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractExternalModuleBuilder.java
@@ -0,0 +1,180 @@
+/*
+ * Copyright 2000-2013 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.externalSystem.service.project.wizard;
+
+import com.intellij.ide.fileTemplates.FileTemplate;
+import com.intellij.ide.fileTemplates.FileTemplateManager;
+import com.intellij.ide.util.projectWizard.ModuleBuilder;
+import com.intellij.ide.util.projectWizard.ModuleWizardStep;
+import com.intellij.ide.util.projectWizard.WizardContext;
+import com.intellij.openapi.components.ServiceManager;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.externalSystem.model.ProjectSystemId;
+import com.intellij.openapi.externalSystem.service.settings.AbstractExternalProjectSettingsControl;
+import com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings;
+import com.intellij.openapi.externalSystem.settings.ExternalProjectSettings;
+import com.intellij.openapi.externalSystem.settings.ExternalSystemSettingsManager;
+import com.intellij.openapi.externalSystem.util.ExternalSystemBundle;
+import com.intellij.openapi.externalSystem.util.ExternalSystemUiUtil;
+import com.intellij.openapi.options.ConfigurationException;
+import com.intellij.openapi.roots.ModifiableRootModel;
+import com.intellij.openapi.roots.ui.configuration.ModulesProvider;
+import com.intellij.openapi.util.io.FileUtilRt;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.openapi.vfs.LocalFileSystem;
+import com.intellij.openapi.vfs.VfsUtil;
+import com.intellij.openapi.vfs.VirtualFile;
+import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * @author Denis Zhdanov
+ * @since 6/26/13 10:39 AM
+ */
+public abstract class AbstractExternalModuleBuilder<S extends ExternalProjectSettings> extends ModuleBuilder {
+
+ private static final Logger LOG = Logger.getInstance("#" + AbstractExternalModuleBuilder.class.getName());
+
+ @NotNull private final ExternalSystemSettingsManager mySettingsManager;
+ @NotNull private final Icon myIcon;
+ @NotNull private final ProjectSystemId myExternalSystemId;
+
+ @Nullable private final AbstractExternalProjectSettingsControl<S> myExternalProjectSettingsControl;
+ @Nullable private final String myTemplateConfigName;
+
+ protected AbstractExternalModuleBuilder(@NotNull ProjectSystemId externalSystemId,
+ @Nullable AbstractExternalProjectSettingsControl<S> control,
+ @Nullable String templateConfigName)
+ {
+ this(ServiceManager.getService(ExternalSystemSettingsManager.class), externalSystemId, control, templateConfigName);
+ }
+
+ protected AbstractExternalModuleBuilder(@NotNull ExternalSystemSettingsManager manager,
+ @NotNull ProjectSystemId externalSystemId,
+ @Nullable AbstractExternalProjectSettingsControl<S> externalProjectSettingsControl,
+ @Nullable String templateConfigName)
+ {
+ mySettingsManager = manager;
+ myExternalSystemId = externalSystemId;
+ myTemplateConfigName = templateConfigName;
+ myExternalProjectSettingsControl = externalProjectSettingsControl;
+ Icon icon = ExternalSystemUiUtil.getUiAware(externalSystemId).getProjectIcon();
+ myIcon = icon == null ? super.getNodeIcon() : icon;
+ }
+
+ @Override
+ public String getBuilderId() {
+ return getClass().getName();
+ }
+
+ @Override
+ public String getPresentableName() {
+ return ExternalSystemBundle.message("module.type.title", myExternalSystemId.getReadableName());
+ }
+
+ @Override
+ public String getDescription() {
+ return ExternalSystemBundle.message("module.type.description", myExternalSystemId.getReadableName());
+ }
+
+ @Override
+ public Icon getNodeIcon() {
+ return myIcon;
+ }
+
+ @Override
+ public void setModuleFilePath(@NonNls String path) {
+ super.setModuleFilePath(path);
+ String contentPath = getContentEntryPath();
+ if (myExternalProjectSettingsControl != null && contentPath != null) {
+ myExternalProjectSettingsControl.getInitialSettings().setExternalProjectPath(contentPath);
+ myExternalProjectSettingsControl.reset();
+ }
+ }
+
+ @Override
+ public ModuleWizardStep[] createWizardSteps(WizardContext wizardContext, ModulesProvider modulesProvider) {
+ return myExternalProjectSettingsControl == null
+ ? ModuleWizardStep.EMPTY_ARRAY
+ : new ModuleWizardStep[]{new ExternalModuleSettingsStep<S>(myExternalProjectSettingsControl)};
+ }
+
+ @Override
+ public void setupRootModel(ModifiableRootModel model) throws ConfigurationException {
+ String contentPath = getContentEntryPath();
+ if (StringUtil.isEmpty(contentPath)) {
+ return;
+ }
+ assert contentPath != null;
+ File contentRootDir = new File(contentPath);
+ FileUtilRt.createDirectory(contentRootDir);
+ LocalFileSystem fileSystem = LocalFileSystem.getInstance();
+ VirtualFile vContentRootDir = fileSystem.refreshAndFindFileByIoFile(contentRootDir);
+ if (vContentRootDir == null) {
+ return;
+ }
+
+ model.addContentEntry(vContentRootDir);
+ model.inheritSdk();
+
+
+ VirtualFile configFile = getExternalProjectConfigFile(vContentRootDir);
+ if (configFile != null && myTemplateConfigName != null) {
+ FileTemplateManager manager = FileTemplateManager.getInstance();
+ FileTemplate template = manager.getInternalTemplate(myTemplateConfigName);
+ try {
+ VfsUtil.saveText(configFile, template.getText());
+ }
+ catch (IOException e) {
+ LOG.warn(String.format("Unexpected exception on applying template %s config", myExternalSystemId.getReadableName()), e);
+ throw new ConfigurationException(
+ e.getMessage(),
+ String.format("Can't apply %s template config text", myExternalSystemId.getReadableName())
+ );
+ }
+ }
+
+ AbstractExternalSystemSettings settings = mySettingsManager.getSettings(model.getProject(), myExternalSystemId);
+ S externalProjectSettings = createSettings();
+ if (myExternalProjectSettingsControl != null) {
+ String errorMessage = myExternalProjectSettingsControl.apply(externalProjectSettings);
+ myExternalProjectSettingsControl.disposeUIResources();
+ if (errorMessage != null) {
+ throw new ConfigurationException(errorMessage);
+ }
+ }
+ //noinspection unchecked
+ settings.linkProject(externalProjectSettings);
+ }
+
+ @NotNull
+ protected abstract S createSettings();
+
+ /**
+ * Asks external system-specific module builder to prepare external system config file if necessary.
+ *
+ * @param contentRootDir new module's content root dir
+ * @return external system config file created by the external system-specific implementation (if any);
+ * <code>null</code> as an indication that no external system config file has been created
+ */
+ @Nullable
+ protected abstract VirtualFile getExternalProjectConfigFile(@NotNull VirtualFile contentRootDir);
+}
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractExternalProjectImportBuilder.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractExternalProjectImportBuilder.java
index cf3d9ce..f4a88e5 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractExternalProjectImportBuilder.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractExternalProjectImportBuilder.java
@@ -1,8 +1,10 @@
package com.intellij.openapi.externalSystem.service.project.wizard;
import com.intellij.ide.util.projectWizard.WizardContext;
+import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.externalSystem.model.DataNode;
+import com.intellij.openapi.externalSystem.model.ExternalSystemDataKeys;
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
import com.intellij.openapi.externalSystem.model.project.ProjectData;
import com.intellij.openapi.externalSystem.service.internal.ExternalSystemResolveProjectTask;
@@ -14,7 +16,6 @@
import com.intellij.openapi.externalSystem.settings.ExternalSystemSettingsManager;
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
import com.intellij.openapi.externalSystem.util.ExternalSystemBundle;
-import com.intellij.openapi.externalSystem.util.ExternalSystemConstants;
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
import com.intellij.openapi.module.ModifiableModuleModel;
import com.intellij.openapi.module.Module;
@@ -31,6 +32,7 @@
import com.intellij.openapi.roots.ui.configuration.ModulesProvider;
import com.intellij.openapi.startup.StartupManager;
import com.intellij.openapi.util.Ref;
+import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.packaging.artifacts.ModifiableArtifactModel;
import com.intellij.projectImport.ProjectImportBuilder;
@@ -40,10 +42,7 @@
import org.jetbrains.annotations.Nullable;
import java.io.File;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
/**
* GoF builder for gradle-backed projects.
@@ -63,7 +62,7 @@
@NotNull private final C myControl;
@NotNull private final ProjectSystemId myExternalSystemId;
- private DataNode<ProjectData> myExternalProjectNode;
+ private DataNode<ProjectData> myExternalProjectNode;
public AbstractExternalProjectImportBuilder(@NotNull ExternalSystemSettingsManager settingsManager,
@NotNull ProjectDataManager projectDataManager,
@@ -115,7 +114,7 @@
ModulesProvider modulesProvider,
ModifiableArtifactModel artifactModel)
{
- System.setProperty(ExternalSystemConstants.NEWLY_IMPORTED_PROJECT, Boolean.TRUE.toString());
+ project.putUserData(ExternalSystemDataKeys.NEWLY_IMPORTED_PROJECT, Boolean.TRUE);
final DataNode<ProjectData> externalProjectNode = getExternalProjectNode();
if (externalProjectNode != null) {
beforeCommit(externalProjectNode, project);
@@ -125,11 +124,10 @@
@Override
public void run() {
AbstractExternalSystemSettings systemSettings = mySettingsManager.getSettings(project, myExternalSystemId);
- ExternalProjectSettings projectSettings = myControl.getProjectSettings().clone();
- final String linkedProjectPath = projectSettings.getExternalProjectPath();
- assert linkedProjectPath != null;
+ final ExternalProjectSettings projectSettings = getCurrentExternalProjectSettings();
Set<ExternalProjectSettings> projects = ContainerUtilRt.newHashSet(systemSettings.getLinkedProjectsSettings());
projects.add(projectSettings);
+ systemSettings.copyFrom(myControl.getSystemSettings());
systemSettings.setLinkedProjectsSettings(projects);
if (externalProjectNode != null) {
@@ -140,6 +138,7 @@
@Override
public void run() {
myProjectDataManager.importData(externalProjectNode.getKey(), Collections.singleton(externalProjectNode), project, true);
+ myExternalProjectNode = null;
}
});
}
@@ -154,7 +153,7 @@
@Override
public void run(@NotNull final ProgressIndicator indicator) {
ExternalSystemResolveProjectTask task
- = new ExternalSystemResolveProjectTask(myExternalSystemId, project, linkedProjectPath, true);
+ = new ExternalSystemResolveProjectTask(myExternalSystemId, project, projectSettings.getExternalProjectPath(), true);
task.execute(indicator);
DataNode<ProjectData> projectWithResolvedLibraries = task.getExternalProject();
if (projectWithResolvedLibraries == null) {
@@ -173,6 +172,16 @@
return Collections.emptyList();
}
+ @NotNull
+ private ExternalProjectSettings getCurrentExternalProjectSettings() {
+ ExternalProjectSettings result = myControl.getProjectSettings().clone();
+ File externalProjectConfigFile = getExternalProjectConfigToUse(new File(result.getExternalProjectPath()));
+ final String linkedProjectPath = FileUtil.toCanonicalPath(externalProjectConfigFile.getPath());
+ assert linkedProjectPath != null;
+ result.setExternalProjectPath(linkedProjectPath);
+ return result;
+ }
+
protected abstract void beforeCommit(@NotNull DataNode<ProjectData> dataNode, @NotNull Project project);
/**
@@ -245,15 +254,16 @@
* @param wizardContext current wizard context
* @throws ConfigurationException if gradle project is not defined and can't be constructed
*/
+ @SuppressWarnings("unchecked")
public void ensureProjectIsDefined(@NotNull WizardContext wizardContext) throws ConfigurationException {
- String externalSystemName = myExternalSystemId.getReadableName();
+ final String externalSystemName = myExternalSystemId.getReadableName();
File projectFile = getProjectFile();
if (projectFile == null) {
throw new ConfigurationException(ExternalSystemBundle.message("error.project.undefined"));
}
projectFile = getExternalProjectConfigToUse(projectFile);
final Ref<ConfigurationException> error = new Ref<ConfigurationException>();
- ExternalProjectRefreshCallback callback = new ExternalProjectRefreshCallback() {
+ final ExternalProjectRefreshCallback callback = new ExternalProjectRefreshCallback() {
@Override
public void onSuccess(@Nullable DataNode<ProjectData> externalProject) {
myExternalProjectNode = externalProject;
@@ -262,25 +272,39 @@
@Override
public void onFailure(@NotNull String errorMessage, @Nullable String errorDetails) {
if (!StringUtil.isEmpty(errorDetails)) {
+ assert errorDetails != null;
LOG.warn(errorDetails);
}
error.set(new ConfigurationException(ExternalSystemBundle.message("error.resolve.with.reason", errorMessage),
ExternalSystemBundle.message("error.resolve.generic")));
}
};
- try {
- final Project project = getProject(wizardContext);
- ExternalSystemUtil.refreshProject(
- project,
- myExternalSystemId,
- projectFile.getAbsolutePath(),
- callback,
- false,
- true
- );
- }
- catch (IllegalArgumentException e) {
- throw new ConfigurationException(e.getMessage(), ExternalSystemBundle.message("error.cannot.parse.project", externalSystemName));
+
+ final Project project = getProject(wizardContext);
+ final File finalProjectFile = projectFile;
+ final Ref<ConfigurationException> exRef = new Ref<ConfigurationException>();
+ executeAndRestoreDefaultProjectSettings(project, new Runnable() {
+ @Override
+ public void run() {
+ try {
+ ExternalSystemUtil.refreshProject(
+ project,
+ myExternalSystemId,
+ finalProjectFile.getAbsolutePath(),
+ callback,
+ false,
+ true
+ );
+ }
+ catch (IllegalArgumentException e) {
+ exRef.set(
+ new ConfigurationException(e.getMessage(), ExternalSystemBundle.message("error.cannot.parse.project", externalSystemName)));
+ }
+ }
+ });
+ ConfigurationException ex = exRef.get();
+ if (ex != null) {
+ throw ex;
}
if (myExternalProjectNode == null) {
ConfigurationException exception = error.get();
@@ -293,6 +317,34 @@
}
}
+ @SuppressWarnings("unchecked")
+ private void executeAndRestoreDefaultProjectSettings(@NotNull Project project, @NotNull Runnable task) {
+ if (!project.isDefault()) {
+ task.run();
+ return;
+ }
+
+ AbstractExternalSystemSettings systemSettings = mySettingsManager.getSettings(project, myExternalSystemId);
+ Object systemStateToRestore = null;
+ if (systemSettings instanceof PersistentStateComponent) {
+ systemStateToRestore = ((PersistentStateComponent)systemSettings).getState();
+ }
+ systemSettings.copyFrom(myControl.getSystemSettings());
+ Collection projectSettingsToRestore = systemSettings.getLinkedProjectsSettings();
+ systemSettings.setLinkedProjectsSettings(Collections.singleton(getCurrentExternalProjectSettings()));
+ try {
+ task.run();
+ }
+ finally {
+ if (systemStateToRestore != null) {
+ ((PersistentStateComponent)systemSettings).loadState(systemStateToRestore);
+ }
+ else {
+ systemSettings.setLinkedProjectsSettings(projectSettingsToRestore);
+ }
+ }
+ }
+
/**
* Allows to adjust external project config file to use on the basis of the given value.
* <p/>
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractExternalProjectImportProvider.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractExternalProjectImportProvider.java
index acc2774..d03ab25 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractExternalProjectImportProvider.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractExternalProjectImportProvider.java
@@ -2,9 +2,11 @@
import com.intellij.ide.util.projectWizard.ModuleWizardStep;
import com.intellij.ide.util.projectWizard.WizardContext;
+import com.intellij.openapi.externalSystem.model.ProjectSystemId;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.projectImport.ProjectImportBuilder;
import com.intellij.projectImport.ProjectImportProvider;
+import org.jetbrains.annotations.NotNull;
/**
* Provides 'import from external model' functionality.
@@ -13,9 +15,17 @@
* @since 7/29/11 3:45 PM
*/
public abstract class AbstractExternalProjectImportProvider extends ProjectImportProvider {
-
- public AbstractExternalProjectImportProvider(ProjectImportBuilder builder) {
+
+ @NotNull private final ProjectSystemId myExternalSystemId;
+
+ public AbstractExternalProjectImportProvider(ProjectImportBuilder builder, @NotNull ProjectSystemId externalSystemId) {
super(builder);
+ myExternalSystemId = externalSystemId;
+ }
+
+ @NotNull
+ public ProjectSystemId getExternalSystemId() {
+ return myExternalSystemId;
}
@Override
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/ExternalModuleSettingsStep.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/ExternalModuleSettingsStep.java
new file mode 100644
index 0000000..50020fd
--- /dev/null
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/ExternalModuleSettingsStep.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2000-2013 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.externalSystem.service.project.wizard;
+
+import com.intellij.ide.util.projectWizard.ModuleWizardStep;
+import com.intellij.openapi.externalSystem.settings.ExternalProjectSettings;
+import com.intellij.openapi.externalSystem.util.ExternalSystemSettingsControl;
+import com.intellij.openapi.externalSystem.util.ExternalSystemUiUtil;
+import com.intellij.openapi.externalSystem.util.PaintAwarePanel;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+
+/**
+ * @author Denis Zhdanov
+ * @since 6/26/13 1:38 PM
+ */
+public class ExternalModuleSettingsStep<S extends ExternalProjectSettings> extends ModuleWizardStep {
+
+ @NotNull private final ExternalSystemSettingsControl<S> myControl;
+
+ @Nullable private PaintAwarePanel myComponent;
+
+ public ExternalModuleSettingsStep(@NotNull ExternalSystemSettingsControl<S> control) {
+ myControl = control;
+ }
+
+ @Override
+ public JComponent getComponent() {
+ PaintAwarePanel result = myComponent;
+ if (result == null) {
+ result = new PaintAwarePanel();
+ myControl.fillUi(result, 0);
+ ExternalSystemUiUtil.fillBottom(result);
+ myComponent = result;
+ }
+
+ return result;
+ }
+
+ @Override
+ public void updateDataModel() {
+ }
+}
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractExternalProjectSettingsControl.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractExternalProjectSettingsControl.java
index 0103c69..acba6f3 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractExternalProjectSettingsControl.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractExternalProjectSettingsControl.java
@@ -44,7 +44,7 @@
}
@NotNull
- protected S getInitialSettings() {
+ public S getInitialSettings() {
return myInitialSettings;
}
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractExternalSystemConfigurable.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractExternalSystemConfigurable.java
index 90fed07..e1efe0a 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractExternalSystemConfigurable.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractExternalSystemConfigurable.java
@@ -62,7 +62,7 @@
public abstract class AbstractExternalSystemConfigurable<
ProjectSettings extends ExternalProjectSettings,
L extends ExternalSystemSettingsListener<ProjectSettings>,
- SystemSettings extends AbstractExternalSystemSettings<ProjectSettings, L>
+ SystemSettings extends AbstractExternalSystemSettings<SystemSettings, ProjectSettings, L>
> implements SearchableConfigurable, Configurable.NoScroll
{
@@ -186,9 +186,11 @@
@NotNull
protected abstract ExternalSystemSettingsControl<ProjectSettings> createProjectSettingsControl(@NotNull ProjectSettings settings);
+ @SuppressWarnings("MethodMayBeStatic")
@NotNull
protected String getProjectName(@NotNull String path) {
- return new File(path).getParentFile().getName();
+ File file = new File(path);
+ return file.isDirectory() ? file.getName() : file.getParentFile().getName();
}
private void prepareSystemSettings(@NotNull SystemSettings s) {
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractExternalSystemToolWindowCondition.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractExternalSystemToolWindowCondition.java
index 3096205..75dc8ae 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractExternalSystemToolWindowCondition.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractExternalSystemToolWindowCondition.java
@@ -16,13 +16,12 @@
package com.intellij.openapi.externalSystem.service.settings;
import com.intellij.openapi.externalSystem.ExternalSystemManager;
+import com.intellij.openapi.externalSystem.model.ExternalSystemDataKeys;
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
import com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings;
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
-import com.intellij.openapi.externalSystem.util.ExternalSystemConstants;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Condition;
-import com.intellij.util.SystemProperties;
import org.jetbrains.annotations.NotNull;
/**
@@ -39,14 +38,14 @@
@Override
public boolean value(Project project) {
- if (SystemProperties.getBooleanProperty(ExternalSystemConstants.NEWLY_IMPORTED_PROJECT, false)) {
+ if (project.getUserData(ExternalSystemDataKeys.NEWLY_IMPORTED_PROJECT) == Boolean.TRUE) {
return true;
}
ExternalSystemManager<?,?,?,?,?> manager = ExternalSystemApiUtil.getManager(myExternalSystemId);
if (manager == null) {
return false;
}
- AbstractExternalSystemSettings<?,?> settings = manager.getSettingsProvider().fun(project);
+ AbstractExternalSystemSettings<?, ?,?> settings = manager.getSettingsProvider().fun(project);
return settings != null && !settings.getLinkedProjectsSettings().isEmpty();
}
}
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractImportFromExternalSystemControl.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractImportFromExternalSystemControl.java
index 4978dba..cb915f4 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractImportFromExternalSystemControl.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractImportFromExternalSystemControl.java
@@ -44,7 +44,7 @@
public abstract class AbstractImportFromExternalSystemControl<
ProjectSettings extends ExternalProjectSettings,
L extends ExternalSystemSettingsListener<ProjectSettings>,
- SystemSettings extends AbstractExternalSystemSettings<ProjectSettings, L>>
+ SystemSettings extends AbstractExternalSystemSettings<SystemSettings, ProjectSettings, L>>
{
@NotNull private final SystemSettings mySystemSettings;
@NotNull private final ProjectSettings myProjectSettings;
@@ -166,6 +166,11 @@
}
@NotNull
+ public SystemSettings getSystemSettings() {
+ return mySystemSettings;
+ }
+
+ @NotNull
public ProjectSettings getProjectSettings() {
return myProjectSettings;
}
@@ -186,7 +191,7 @@
else if (myCurrentProject != null) {
ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(myExternalSystemId);
assert manager != null;
- AbstractExternalSystemSettings<?,?> settings = manager.getSettingsProvider().fun(myCurrentProject);
+ AbstractExternalSystemSettings<?, ?,?> settings = manager.getSettingsProvider().fun(myCurrentProject);
if (settings.getLinkedProjectSettings(linkedProjectPath) != null) {
throw new ConfigurationException(ExternalSystemBundle.message("error.project.already.registered"));
}
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/task/ui/ExternalSystemTasksPanel.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/task/ui/ExternalSystemTasksPanel.java
index 5e8ae40..a10b25d 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/task/ui/ExternalSystemTasksPanel.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/task/ui/ExternalSystemTasksPanel.java
@@ -85,7 +85,10 @@
myRecentTasksList = new ExternalSystemRecentTasksList(recentTasksModel, externalSystemId, project) {
@Override
protected void processMouseEvent(MouseEvent e) {
- mySelectedTaskProvider = myRecentTasksList;
+ if (e.getClickCount() > 0) {
+ mySelectedTaskProvider = myRecentTasksList;
+ myAllTasksTree.getSelectionModel().clearSelection();
+ }
super.processMouseEvent(e);
}
};
@@ -94,12 +97,15 @@
myAllTasksTree = new ExternalSystemTasksTree(myAllTasksModel, settings.getExpandStates()) {
@Override
protected void processMouseEvent(MouseEvent e) {
- mySelectedTaskProvider = myAllTasksTree;
+ if (e.getClickCount() > 0) {
+ mySelectedTaskProvider = myAllTasksTree;
+ myRecentTasksList.getSelectionModel().clearSelection();
+ }
super.processMouseEvent(e);
}
};
ExternalSystemUiUtil.apply(settings, myAllTasksModel);
- CustomizationUtil.installPopupHandler(myAllTasksTree, TREE_ACTIONS_GROUP_ID, TREE_PLACE);
+ CustomizationUtil.installPopupHandler(myAllTasksTree, TREE_ACTIONS_GROUP_ID, TREE_CONTEXT_MENU_PLACE);
ActionManager actionManager = ActionManager.getInstance();
ActionGroup group = (ActionGroup)actionManager.getAction(TOOL_WINDOW_TOOLBAR_ACTIONS_GROUP_ID);
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ui/ExternalToolWindowManager.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ui/ExternalToolWindowManager.java
index 5ccb967..80af1b8 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ui/ExternalToolWindowManager.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/ui/ExternalToolWindowManager.java
@@ -9,6 +9,7 @@
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowManager;
import com.intellij.openapi.wm.impl.ToolWindowImpl;
+import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -26,10 +27,11 @@
*/
public class ExternalToolWindowManager {
+ @SuppressWarnings("unchecked")
public static void handle(@NotNull final Project project) {
for (final ExternalSystemManager<?, ?, ?, ?, ?> manager : ExternalSystemApiUtil.getAllManagers()) {
final AbstractExternalSystemSettings settings = manager.getSettingsProvider().fun(project);
- project.getMessageBus().connect(project).subscribe(settings.getChangesTopic(), new ExternalSystemSettingsListenerAdapter() {
+ settings.subscribe(new ExternalSystemSettingsListenerAdapter() {
@Override
public void onProjectsLinked(@NotNull Collection linked) {
if (settings.getLinkedProjectsSettings().size() != 1) {
@@ -46,9 +48,14 @@
if (!settings.getLinkedProjectsSettings().isEmpty()) {
return;
}
- ToolWindow toolWindow = getToolWindow(project, manager.getSystemId());
+ final ToolWindow toolWindow = getToolWindow(project, manager.getSystemId());
if (toolWindow != null) {
- toolWindow.setAvailable(false, null);
+ UIUtil.invokeLaterIfNeeded(new Runnable() {
+ @Override
+ public void run() {
+ toolWindow.setAvailable(false, null);
+ }
+ });
}
}
});
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/settings/ExternalSystemSettingsManager.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/settings/ExternalSystemSettingsManager.java
index 61b1d08..c238fdb 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/settings/ExternalSystemSettingsManager.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/settings/ExternalSystemSettingsManager.java
@@ -54,7 +54,7 @@
@NotNull ProjectSystemId externalSystemId) throws IllegalArgumentException
{
Holder holder = myHolder.getValue();
- Function<Project, ? extends AbstractExternalSystemSettings<?, ?>> provider = holder.settingsProviders.get(externalSystemId);
+ Function<Project, ? extends AbstractExternalSystemSettings<?, ?, ?>> provider = holder.settingsProviders.get(externalSystemId);
if (provider == null) {
throw new IllegalArgumentException(String.format(
"Can't retrieve settings for external system with id '%s'. Reason: no such system is registered. Known systems: %s",
@@ -105,7 +105,7 @@
private static class Holder {
@NotNull
- public final ConcurrentMap<ProjectSystemId, Function<Project, ? extends AbstractExternalSystemSettings<?, ?>>> settingsProviders
+ public final ConcurrentMap<ProjectSystemId, Function<Project, ? extends AbstractExternalSystemSettings<?, ?, ?>>> settingsProviders
= ContainerUtil.newConcurrentMap();
@NotNull
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUtil.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUtil.java
index cb48408..cf33285 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUtil.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUtil.java
@@ -48,8 +48,11 @@
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.roots.ex.ProjectRootManagerEx;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.openapi.vfs.LocalFileSystem;
+import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowId;
import com.intellij.openapi.wm.ToolWindowManager;
@@ -160,28 +163,29 @@
*
* @param project target ide project
* @param externalSystemId target external system which projects should be refreshed
+ * @param force flag which defines if external project refresh should be performed if it's config is up-to-date
*/
- public static void refreshProjects(@NotNull final Project project, @NotNull final ProjectSystemId externalSystemId) {
+ public static void refreshProjects(@NotNull final Project project, @NotNull final ProjectSystemId externalSystemId, boolean force) {
ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(externalSystemId);
if (manager == null) {
return;
}
- AbstractExternalSystemSettings<?, ?> settings = manager.getSettingsProvider().fun(project);
+ AbstractExternalSystemSettings<?, ?, ?> settings = manager.getSettingsProvider().fun(project);
final Collection<? extends ExternalProjectSettings> projectsSettings = settings.getLinkedProjectsSettings();
if (projectsSettings.isEmpty()) {
return;
}
final ProjectDataManager projectDataManager = ServiceManager.getService(ProjectDataManager.class);
+ final int[] counter = new int[1];
ExternalProjectRefreshCallback callback = new ExternalProjectRefreshCallback() {
@NotNull
private final Set<String> myExternalModuleNames = ContainerUtilRt.newHashSet();
- private int myCounter = projectsSettings.size();
@Override
- public void onSuccess(@Nullable DataNode<ProjectData> externalProject) {
+ public void onSuccess(@Nullable final DataNode<ProjectData> externalProject) {
if (externalProject == null) {
return;
}
@@ -189,15 +193,25 @@
for (DataNode<ModuleData> node : moduleNodes) {
myExternalModuleNames.add(node.getData().getName());
}
- projectDataManager.importData(externalProject.getKey(), Collections.singleton(externalProject), project, false);
- if (--myCounter <= 0) {
+ ExternalSystemApiUtil.executeProjectChangeAction(true, new Runnable() {
+ @Override
+ public void run() {
+ ProjectRootManagerEx.getInstanceEx(project).mergeRootsChangesDuring(new Runnable() {
+ @Override
+ public void run() {
+ projectDataManager.importData(externalProject.getKey(), Collections.singleton(externalProject), project, true);
+ }
+ });
+ }
+ });
+ if (--counter[0] <= 0) {
processOrphanModules();
}
}
@Override
public void onFailure(@NotNull String errorMessage, @Nullable String errorDetails) {
- myCounter = Integer.MAX_VALUE; // Don't process orphan modules if there was an error on refresh.
+ counter[0] = Integer.MAX_VALUE; // Don't process orphan modules if there was an error on refresh.
}
private void processOrphanModules() {
@@ -211,15 +225,34 @@
orphanIdeModules.add(module);
}
}
-
+
if (!orphanIdeModules.isEmpty()) {
ruleOrphanModules(orphanIdeModules, project, externalSystemId);
}
}
};
+
+ Map<String, Long> modificationStamps = manager.getLocalSettingsProvider().fun(project).getExternalConfigModificationStamps();
+ Set<String> toRefresh = ContainerUtilRt.newHashSet();
for (ExternalProjectSettings setting : projectsSettings) {
- refreshProject(project, externalSystemId, setting.getExternalProjectPath(), callback, true, false);
+ Long oldModificationStamp = modificationStamps.get(setting.getExternalProjectPath());
+ long currentModificationStamp = getTimeStamp(setting.getExternalProjectPath());
+ if (force || currentModificationStamp < 0 || oldModificationStamp == null || oldModificationStamp < currentModificationStamp) {
+ toRefresh.add(setting.getExternalProjectPath());
+ }
}
+
+ if (!toRefresh.isEmpty()) {
+ counter[0] = toRefresh.size();
+ for (String path : toRefresh) {
+ refreshProject(project, externalSystemId, path, callback, true, false);
+ }
+ }
+ }
+
+ private static long getTimeStamp(@NotNull String path) {
+ VirtualFile vFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(path));
+ return vFile == null ? -1 : vFile.getTimeStamp();
}
/**
@@ -232,7 +265,7 @@
* </ol>
* </pre>
* This method handles that situation, i.e. it asks a user what should be done and acts accordingly.
- *
+ *
* @param orphanModules modules which correspond to the un-linked external project
* @param project current ide project
* @param externalSystemId id of the external system which project has been un-linked from ide project
@@ -326,7 +359,14 @@
final boolean resolveLibraries,
final boolean modal)
{
- final String projectName = new File(externalProjectPath).getParentFile().getName();
+ File projectFile = new File(externalProjectPath);
+ final String projectName;
+ if (projectFile.isFile()) {
+ projectName = projectFile.getParentFile().getName();
+ }
+ else {
+ projectName = projectFile.getName();
+ }
final TaskUnderProgress refreshProjectStructureTask = new TaskUnderProgress() {
@SuppressWarnings({"ThrowableResultOfMethodCallIgnored", "IOResourceOpenedButNotSafelyClosed"})
@Override
@@ -336,6 +376,12 @@
task.execute(indicator);
final Throwable error = task.getError();
if (error == null) {
+ long stamp = getTimeStamp(externalProjectPath);
+ if (stamp > 0) {
+ ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(externalSystemId);
+ assert manager != null;
+ manager.getLocalSettingsProvider().fun(project).getExternalConfigModificationStamps().put(externalProjectPath, stamp);
+ }
DataNode<ProjectData> externalProject = task.getExternalProject();
callback.onSuccess(externalProject);
return;
@@ -347,7 +393,7 @@
externalSystemId.getReadableName(), externalProjectPath, message
);
}
-
+
callback.onFailure(message, extractDetails(error));
ExternalSystemIdeNotificationManager notificationManager = ServiceManager.getService(ExternalSystemIdeNotificationManager.class);
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/PaintAwarePanel.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/PaintAwarePanel.java
index 1abf691..00393e3 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/PaintAwarePanel.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/PaintAwarePanel.java
@@ -16,14 +16,10 @@
package com.intellij.openapi.externalSystem.util;
import com.intellij.util.Consumer;
-import com.intellij.util.containers.ContainerUtilRt;
-import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
-import java.util.List;
-import java.util.Set;
/**
* @author Denis Zhdanov
@@ -33,11 +29,12 @@
@Nullable private Consumer<Graphics> myPaintCallback;
- public PaintAwarePanel(LayoutManager layout) {
- super(layout);
+ public PaintAwarePanel() {
+ this(new GridBagLayout());
}
- public PaintAwarePanel() {
+ public PaintAwarePanel(LayoutManager layout) {
+ super(layout);
}
@Override
diff --git a/platform/indexing-api/src/com/intellij/psi/stubs/AbstractStubIndex.java b/platform/indexing-api/src/com/intellij/psi/stubs/AbstractStubIndex.java
index da31e32..6e6ce92 100644
--- a/platform/indexing-api/src/com/intellij/psi/stubs/AbstractStubIndex.java
+++ b/platform/indexing-api/src/com/intellij/psi/stubs/AbstractStubIndex.java
@@ -18,6 +18,7 @@
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.psi.search.GlobalSearchScope;
+import com.intellij.util.Processor;
import java.util.Collection;
@@ -29,6 +30,10 @@
return StubIndex.getInstance().getAllKeys(getKey(), project);
}
+ public boolean processAllKeys(Project project, Processor<Key> processor) {
+ return StubIndex.getInstance().processAllKeys(getKey(), project, processor);
+ }
+
public Collection<Psi> get(Key key, final Project project, final GlobalSearchScope scope) {
return StubIndex.getInstance().get(getKey(), key, project, scope);
}
diff --git a/platform/indexing-api/src/com/intellij/psi/stubs/StubIndex.java b/platform/indexing-api/src/com/intellij/psi/stubs/StubIndex.java
index c3100e8..eee5e64 100644
--- a/platform/indexing-api/src/com/intellij/psi/stubs/StubIndex.java
+++ b/platform/indexing-api/src/com/intellij/psi/stubs/StubIndex.java
@@ -57,6 +57,8 @@
@NotNull
public abstract <Key> Collection<Key> getAllKeys(@NotNull StubIndexKey<Key, ?> indexKey, @NotNull Project project);
+ public abstract <K> boolean processAllKeys(@NotNull StubIndexKey<K, ?> indexKey, @NotNull Project project, Processor<K> processor);
+
public <Key, Psi extends PsiElement> Collection<Psi> safeGet(@NotNull StubIndexKey<Key, Psi> indexKey,
@NotNull Key key,
@NotNull final Project project,
diff --git a/platform/indexing-impl/src/com/intellij/ide/highlighter/custom/AbstractCustomLexer.java b/platform/indexing-impl/src/com/intellij/ide/highlighter/custom/AbstractCustomLexer.java
index f048510..92e75ad 100644
--- a/platform/indexing-impl/src/com/intellij/ide/highlighter/custom/AbstractCustomLexer.java
+++ b/platform/indexing-impl/src/com/intellij/ide/highlighter/custom/AbstractCustomLexer.java
@@ -33,8 +33,8 @@
protected int myStartOffset = 0;
protected int myEndOffset = 0;
private final TokenParser[] myTokenParsers;
- private TokenInfo myCurrentToken;
- private int myPosition;
+ protected TokenInfo myCurrentToken;
+ protected int myPosition;
public AbstractCustomLexer(List<TokenParser> tokenParsers) {
myTokenParsers = tokenParsers.toArray(new TokenParser[tokenParsers.size()]);
@@ -86,11 +86,15 @@
}
if (!tokenFound) {
- myCurrentToken.updateData(myPosition, myPosition + 1, CustomHighlighterTokenType.CHARACTER);
+ handleTokenNotFound();
}
myPosition = myCurrentToken.getEnd();
}
+ protected void handleTokenNotFound() {
+ myCurrentToken.updateData(myPosition, myPosition + 1, CustomHighlighterTokenType.CHARACTER);
+ }
+
public CharSequence getBufferSequence() {
return myBuffer;
}
diff --git a/platform/indexing-impl/src/com/intellij/psi/impl/search/CachesBasedRefSearcher.java b/platform/indexing-impl/src/com/intellij/psi/impl/search/CachesBasedRefSearcher.java
index a82dd40..b430c0d 100644
--- a/platform/indexing-impl/src/com/intellij/psi/impl/search/CachesBasedRefSearcher.java
+++ b/platform/indexing-impl/src/com/intellij/psi/impl/search/CachesBasedRefSearcher.java
@@ -3,10 +3,7 @@
import com.intellij.openapi.application.QueryExecutorBase;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiFile;
-import com.intellij.psi.PsiNamedElement;
-import com.intellij.psi.PsiReference;
+import com.intellij.psi.*;
import com.intellij.psi.meta.PsiMetaData;
import com.intellij.psi.meta.PsiMetaOwner;
import com.intellij.psi.search.SearchScope;
@@ -27,8 +24,8 @@
final PsiElement refElement = p.getElementToSearch();
String text = null;
- if (refElement instanceof PsiFile) {
- final VirtualFile vFile = ((PsiFile)refElement).getVirtualFile();
+ if (refElement instanceof PsiFileSystemItem) {
+ final VirtualFile vFile = ((PsiFileSystemItem)refElement).getVirtualFile();
if (vFile != null) {
text = vFile.getNameWithoutExtension();
}
diff --git a/platform/indexing-impl/src/com/intellij/psi/impl/search/PsiSearchHelperImpl.java b/platform/indexing-impl/src/com/intellij/psi/impl/search/PsiSearchHelperImpl.java
index 7852e7d..01a0207 100644
--- a/platform/indexing-impl/src/com/intellij/psi/impl/search/PsiSearchHelperImpl.java
+++ b/platform/indexing-impl/src/com/intellij/psi/impl/search/PsiSearchHelperImpl.java
@@ -269,7 +269,6 @@
break;
}
}
- myManager.dropResolveCaches();
}
catch (ProcessCanceledException e) {
canceled.set(true);
diff --git a/platform/lang-api/src/com/intellij/codeInsight/preview/ElementPreviewProvider.java b/platform/lang-api/src/com/intellij/codeInsight/preview/ElementPreviewProvider.java
new file mode 100644
index 0000000..94d98c1
--- /dev/null
+++ b/platform/lang-api/src/com/intellij/codeInsight/preview/ElementPreviewProvider.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2000-2013 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.codeInsight.preview;
+
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.extensions.ExtensionPointName;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiFile;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.awt.*;
+
+public interface ElementPreviewProvider {
+ ExtensionPointName<ElementPreviewProvider> EP_NAME = ExtensionPointName.create("com.intellij.elementPreviewProvider");
+
+ boolean isSupportedFile(@NotNull PsiFile psiFile);
+
+ void show(@NotNull PsiElement element, @NotNull Editor editor, @NotNull Point point);
+
+ void hide(@Nullable("if disposed") PsiElement element, @NotNull Editor editor);
+}
\ No newline at end of file
diff --git a/platform/lang-api/src/com/intellij/codeInsight/preview/PreviewHintProvider.java b/platform/lang-api/src/com/intellij/codeInsight/preview/PreviewHintProvider.java
index 9fbaf90..9af51d8 100644
--- a/platform/lang-api/src/com/intellij/codeInsight/preview/PreviewHintProvider.java
+++ b/platform/lang-api/src/com/intellij/codeInsight/preview/PreviewHintProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.intellij.codeInsight.preview;
import com.intellij.openapi.extensions.ExtensionPointName;
diff --git a/platform/lang-api/src/com/intellij/codeInspection/IntentionWrapper.java b/platform/lang-api/src/com/intellij/codeInspection/IntentionWrapper.java
index 1c268c3..7453e51 100644
--- a/platform/lang-api/src/com/intellij/codeInspection/IntentionWrapper.java
+++ b/platform/lang-api/src/com/intellij/codeInspection/IntentionWrapper.java
@@ -32,7 +32,7 @@
* Date: 4/20/11
* Time: 9:27 PM
*/
-public class IntentionWrapper implements LocalQuickFix, IntentionAction {
+public class IntentionWrapper implements LocalQuickFix, IntentionAction, ActionClassHolder {
private final IntentionAction myAction;
private final PsiFile myFile;
@@ -74,6 +74,7 @@
return myAction.startInWriteAction();
}
+ @NotNull
public IntentionAction getAction() {
return myAction;
}
@@ -87,5 +88,11 @@
myAction.invoke(project, editor instanceof TextEditor ? ((TextEditor) editor).getEditor() : null, myFile);
}
}
+
+ @NotNull
+ @Override
+ public Class getActionClass() {
+ return getAction().getClass();
+ }
}
diff --git a/platform/lang-api/src/com/intellij/codeInspection/ex/ScopeToolStateUtil.java b/platform/lang-api/src/com/intellij/codeInspection/ex/ScopeToolStateUtil.java
deleted file mode 100644
index 099ed1d..0000000
--- a/platform/lang-api/src/com/intellij/codeInspection/ex/ScopeToolStateUtil.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2000-2013 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.codeInspection.ex;
-
-import com.intellij.ide.DataManager;
-import com.intellij.openapi.actionSystem.PlatformDataKeys;
-import com.intellij.openapi.project.Project;
-import com.intellij.psi.search.scope.packageSet.NamedScope;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-public class ScopeToolStateUtil {
- @Nullable
- public static NamedScope getScope(@NotNull ScopeToolState toolState) {
- Project project = PlatformDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext());
- return toolState.getScope(project);
- }
-}
diff --git a/platform/lang-api/src/com/intellij/execution/Executor.java b/platform/lang-api/src/com/intellij/execution/Executor.java
index 0da71ca..e803e85 100644
--- a/platform/lang-api/src/com/intellij/execution/Executor.java
+++ b/platform/lang-api/src/com/intellij/execution/Executor.java
@@ -24,23 +24,54 @@
import javax.swing.*;
/**
+ * Describes a specific way of executing any possible run configuration. The three default executors provided by the IntelliJ Platform
+ * by default are Run, Debug and (in IntelliJ IDEA Ultimate and certain platform-based IDEs) Run with Coverage. Each executor gets its
+ * own toolbar button, which starts the selected run configuration using this executor, and its own context menu item for starting
+ * a configuration using this executor.
+ *
* @author spleaner
*/
public abstract class Executor {
public static final ExtensionPointName<Executor> EXECUTOR_EXTENSION_NAME = ExtensionPointName.create("com.intellij.executor");
+ /**
+ * Returns the ID of the toolwindow in which the run tabs created by this executor will be displayed.
+ *
+ * @return the ID of the toolwindow (usually {@link com.intellij.openapi.wm.ToolWindowId#RUN} or
+ * {@link com.intellij.openapi.wm.ToolWindowId#DEBUG}).
+ */
public abstract String getToolWindowId();
public abstract Icon getToolWindowIcon();
+ /**
+ * Returns the 16x16 icon for the toolbar button corresponding to the executor.
+ *
+ * @return the icon.
+ */
@NotNull
public abstract Icon getIcon();
+
+ /**
+ * Returns the 16x16 icon for the disabled toolbar button corresponding to the executor.
+ *
+ * @return the icon for the disabled button.
+ */
public abstract Icon getDisabledIcon();
+ /**
+ * Returns the action description (text displayed in the status bar) for the toolbar button corresponding to the executor.
+ *
+ * @return the executor action description.
+ */
public abstract String getDescription();
@NotNull
public abstract String getActionName();
+ /**
+ * Returns the unique ID of the executor.
+ * @return the ID of the executor.
+ */
@NotNull
@NonNls
public abstract String getId();
diff --git a/platform/lang-api/src/com/intellij/execution/configurations/CommandLineState.java b/platform/lang-api/src/com/intellij/execution/configurations/CommandLineState.java
index 6d9eda5..664a17b 100644
--- a/platform/lang-api/src/com/intellij/execution/configurations/CommandLineState.java
+++ b/platform/lang-api/src/com/intellij/execution/configurations/CommandLineState.java
@@ -33,7 +33,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-public abstract class CommandLineState implements RunnableState {
+public abstract class CommandLineState implements RunProfileState {
private static final Logger LOG = Logger.getInstance("#com.intellij.execution.configurations.CommandLineState");
private TextConsoleBuilder myConsoleBuilder;
diff --git a/platform/lang-api/src/com/intellij/execution/configurations/ConfigurationFactory.java b/platform/lang-api/src/com/intellij/execution/configurations/ConfigurationFactory.java
index cc62714..33828da 100644
--- a/platform/lang-api/src/com/intellij/execution/configurations/ConfigurationFactory.java
+++ b/platform/lang-api/src/com/intellij/execution/configurations/ConfigurationFactory.java
@@ -25,6 +25,9 @@
import javax.swing.*;
/**
+ * Factory for run configuration instances.
+ *
+ * @see com.intellij.execution.configurations.ConfigurationType#getConfigurationFactories()
* @author dyoma
*/
public abstract class ConfigurationFactory {
@@ -36,18 +39,36 @@
myType = type;
}
+ /**
+ * Creates a new run configuration with the specified name by cloning the specified template.
+ *
+ * @param name the name for the new run configuration.
+ * @param template the template from which the run configuration is copied
+ * @return the new run configuration.
+ */
public RunConfiguration createConfiguration(String name, RunConfiguration template) {
RunConfiguration newConfiguration = template.clone();
newConfiguration.setName(name);
return newConfiguration;
}
+ /**
+ * Creates a new template run configuration within the context of the specified project.
+ *
+ * @param project the project in which the run configuration will be used
+ * @return the run configuration instance.
+ */
public abstract RunConfiguration createTemplateConfiguration(Project project);
public RunConfiguration createTemplateConfiguration(Project project, RunManager runManager) {
return createTemplateConfiguration(project);
}
+ /**
+ * Returns the name of the run configuration variant created by this factory.
+ *
+ * @return the name of the run configuration variant created by this factory
+ */
public String getName() {
return myType.getDisplayName();
}
diff --git a/platform/lang-api/src/com/intellij/execution/configurations/ConfigurationType.java b/platform/lang-api/src/com/intellij/execution/configurations/ConfigurationType.java
index 731a741..f373869 100644
--- a/platform/lang-api/src/com/intellij/execution/configurations/ConfigurationType.java
+++ b/platform/lang-api/src/com/intellij/execution/configurations/ConfigurationType.java
@@ -21,15 +21,51 @@
import javax.swing.*;
+/**
+ * The type of a run configuration.
+ *
+ * @see ConfigurationTypeBase
+ */
public interface ConfigurationType {
ExtensionPointName<ConfigurationType> CONFIGURATION_TYPE_EP = ExtensionPointName.create("com.intellij.configurationType");
+ /**
+ * Returns the display name of the configuration type. This is used, for example, to represent the configuration type in the run
+ * configurations tree, and also as the name of the action used to create the configuration.
+ *
+ * @return the display name of the configuration type.
+ */
String getDisplayName();
+
+ /**
+ * Returns the description of the configuration type. You may return the same text as the display name of the configuration type.
+ *
+ * @return the description of the configuration type.
+ */
String getConfigurationTypeDescription();
+
+ /**
+ * Returns the 16x16 icon used to represent the configuration type.
+ *
+ * @return the icon
+ */
Icon getIcon();
+ /**
+ * Returns the ID of the configuration type. The ID is used to store run configuration settings in a project or workspace file and
+ * must not change between plugin versions.
+ *
+ * @return the configuration type ID.
+ */
@NonNls @NotNull
String getId();
+ /**
+ * Returns the configuration factories used by this configuration type. Normally each configuration type provides just a single factory.
+ * You can return multiple factories if your configurations can be created in multiple variants (for example, local and remote for an
+ * application server).
+ *
+ * @return the run configuration factories.
+ */
ConfigurationFactory[] getConfigurationFactories();
}
\ No newline at end of file
diff --git a/platform/lang-api/src/com/intellij/execution/configurations/ConfigurationTypeBase.java b/platform/lang-api/src/com/intellij/execution/configurations/ConfigurationTypeBase.java
index e47eb78..b6ab467 100644
--- a/platform/lang-api/src/com/intellij/execution/configurations/ConfigurationTypeBase.java
+++ b/platform/lang-api/src/com/intellij/execution/configurations/ConfigurationTypeBase.java
@@ -16,12 +16,10 @@
package com.intellij.execution.configurations;
+import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
/**
* @author yole
@@ -44,10 +42,7 @@
}
protected void addFactory(ConfigurationFactory factory) {
- List<ConfigurationFactory> newFactories = new ArrayList<ConfigurationFactory>(myFactories.length + 1);
- Collections.addAll(newFactories, myFactories);
- newFactories.add(factory);
- myFactories = newFactories.toArray(new ConfigurationFactory[newFactories.size()]);
+ myFactories = ArrayUtil.append(myFactories, factory);
}
@Override
diff --git a/platform/lang-api/src/com/intellij/execution/configurations/RunProfile.java b/platform/lang-api/src/com/intellij/execution/configurations/RunProfile.java
index 43c2252..e4a5ccb 100644
--- a/platform/lang-api/src/com/intellij/execution/configurations/RunProfile.java
+++ b/platform/lang-api/src/com/intellij/execution/configurations/RunProfile.java
@@ -15,26 +15,53 @@
*/
package com.intellij.execution.configurations;
-import com.intellij.execution.Executor;
import com.intellij.execution.ExecutionException;
+import com.intellij.execution.Executor;
import com.intellij.execution.runners.ExecutionEnvironment;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
+/**
+ * Base interface for run configurations.
+ *
+ * @see RunConfiguration
+ * @see ConfigurationFactory#createTemplateConfiguration(com.intellij.openapi.project.Project)
+ */
public interface RunProfile {
/**
- * todo - javadoc
+ * Prepares for executing a specific instance of the run configuration.
+ *
+ * @param executor the execution mode selected by the user (run, debug, profile etc.)
+ * @param env the environment object containing additional settings for executing the configuration.
+ * @return the RunProfileState describing the process which is about to be started, or null if it's impossible to start the process.
*/
@Nullable
- RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException ;
+ RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException;
+ /**
+ * Returns the name of the run configuration.
+ *
+ * @return the name of the run configuration.
+ */
String getName();
+ /**
+ * Returns the icon for the run configuration.
+ *
+ * @return the icon for the run configuration.
+ */
@Nullable
Icon getIcon();
+ /**
+ * Checks whether the run configuration settings are valid.
+ *
+ * @throws RuntimeConfigurationException if the configuration settings contain a non-fatal problem which the user should be warned about
+ * but the execution should still be allowed
+ * @throws RuntimeConfigurationError if the configuration settings contain a fatal problem which makes it impossible to execute the run
+ * configuration.
+ */
void checkConfiguration() throws RuntimeConfigurationException;
-
-}
+}
\ No newline at end of file
diff --git a/platform/lang-api/src/com/intellij/execution/configurations/RunnableState.java b/platform/lang-api/src/com/intellij/execution/configurations/RunnableState.java
index ecfc2ed..064de9c 100644
--- a/platform/lang-api/src/com/intellij/execution/configurations/RunnableState.java
+++ b/platform/lang-api/src/com/intellij/execution/configurations/RunnableState.java
@@ -15,5 +15,8 @@
*/
package com.intellij.execution.configurations;
+/**
+ * @deprecated this interface doesn't have any purpose, please don't use it
+ */
public interface RunnableState extends RunProfileState {
}
diff --git a/platform/lang-api/src/com/intellij/execution/ui/RunnerLayoutUi.java b/platform/lang-api/src/com/intellij/execution/ui/RunnerLayoutUi.java
index 68131d6..baa19b4 100644
--- a/platform/lang-api/src/com/intellij/execution/ui/RunnerLayoutUi.java
+++ b/platform/lang-api/src/com/intellij/execution/ui/RunnerLayoutUi.java
@@ -32,7 +32,7 @@
import javax.swing.*;
-public interface RunnerLayoutUi {
+public interface RunnerLayoutUi {
@NotNull
LayoutStateDefaults getDefaults();
diff --git a/platform/lang-api/src/com/intellij/ide/structureView/StructureViewModelBase.java b/platform/lang-api/src/com/intellij/ide/structureView/StructureViewModelBase.java
index 00d9f51..f38ef15 100644
--- a/platform/lang-api/src/com/intellij/ide/structureView/StructureViewModelBase.java
+++ b/platform/lang-api/src/com/intellij/ide/structureView/StructureViewModelBase.java
@@ -17,8 +17,10 @@
package com.intellij.ide.structureView;
import com.intellij.ide.util.treeView.smartTree.Sorter;
+import com.intellij.openapi.editor.Editor;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
/**
* @author yole
@@ -28,8 +30,15 @@
private Sorter[] mySorters = Sorter.EMPTY_ARRAY;
private Class[] mySuitableClasses = null;
+ public StructureViewModelBase(@NotNull PsiFile psiFile, @Nullable Editor editor, @NotNull StructureViewTreeElement root) {
+ super(editor, psiFile);
+
+ myRoot = root;
+ }
+
public StructureViewModelBase(@NotNull PsiFile psiFile, @NotNull StructureViewTreeElement root) {
super(psiFile);
+
myRoot = root;
}
diff --git a/platform/lang-api/src/com/intellij/ide/structureView/TextEditorBasedStructureViewModel.java b/platform/lang-api/src/com/intellij/ide/structureView/TextEditorBasedStructureViewModel.java
index 067f1be..a6a17be 100644
--- a/platform/lang-api/src/com/intellij/ide/structureView/TextEditorBasedStructureViewModel.java
+++ b/platform/lang-api/src/com/intellij/ide/structureView/TextEditorBasedStructureViewModel.java
@@ -38,7 +38,7 @@
/**
* The standard {@link StructureViewModel} implementation which is linked to a text editor.
*
- * @see com.intellij.ide.structureView.TreeBasedStructureViewBuilder#createStructureViewModel()
+ * @see com.intellij.ide.structureView.TreeBasedStructureViewBuilder#createStructureViewModel(Editor editor)
*/
public abstract class TextEditorBasedStructureViewModel implements StructureViewModel, ProvidingTreeModel {
@@ -66,7 +66,7 @@
this(editor, null);
}
- private TextEditorBasedStructureViewModel(Editor editor, PsiFile file) {
+ protected TextEditorBasedStructureViewModel(Editor editor, PsiFile file) {
myEditor = editor;
myPsiFile = file;
diff --git a/platform/lang-api/src/com/intellij/ide/structureView/TreeBasedStructureViewBuilder.java b/platform/lang-api/src/com/intellij/ide/structureView/TreeBasedStructureViewBuilder.java
index 95796f0..ec30047 100644
--- a/platform/lang-api/src/com/intellij/ide/structureView/TreeBasedStructureViewBuilder.java
+++ b/platform/lang-api/src/com/intellij/ide/structureView/TreeBasedStructureViewBuilder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -16,11 +16,13 @@
package com.intellij.ide.structureView;
import com.intellij.openapi.Disposable;
+import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.fileEditor.FileEditor;
+import com.intellij.openapi.fileEditor.TextEditor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import org.jetbrains.annotations.NotNull;
-
+import org.jetbrains.annotations.Nullable;
/**
* Default implementation of the {@link StructureViewBuilder} interface which uses the
@@ -31,21 +33,35 @@
* @see TextEditorBasedStructureViewModel
* @see com.intellij.lang.LanguageStructureViewBuilder#getStructureViewBuilder(com.intellij.psi.PsiFile)
*/
-public abstract class TreeBasedStructureViewBuilder implements StructureViewBuilder {
+public abstract class
+ TreeBasedStructureViewBuilder implements StructureViewBuilder {
+ /**
+ * @deprecated Use createStructureViewModel(Editor editor)
+ */
+ @NotNull
+ @Deprecated
+ public StructureViewModel createStructureViewModel() {
+ throw new AbstractMethodError();
+ }
+
/**
* Returns the structure view model defining the data displayed in the structure view
* for a specific file.
*
+ * todo This method must be abstract, but due to compatibility reasons we wait IDEA 13 release
+ *
* @return the structure view model instance.
* @see TextEditorBasedStructureViewModel
*/
@NotNull
- public abstract StructureViewModel createStructureViewModel();
+ public StructureViewModel createStructureViewModel(@Nullable Editor editor) {
+ return createStructureViewModel();
+ }
@Override
@NotNull
public StructureView createStructureView(FileEditor fileEditor, Project project) {
- final StructureViewModel model = createStructureViewModel();
+ final StructureViewModel model = createStructureViewModel(fileEditor instanceof TextEditor ? ((TextEditor)fileEditor).getEditor() : null);
StructureView view = StructureViewFactory.getInstance(project).createStructureView(fileEditor, model, project, isRootNodeShown());
Disposer.register(view, new Disposable() {
@Override
@@ -57,10 +73,10 @@
}
/**
- * Override returning <code>false</code> if root node created by {@link #createStructureViewModel()} shall not be visible
+ * Override returning <code>false</code> if root node created by {@link #createStructureViewModel(Editor editor)} shall not be visible
* @return <code>false</code> if root node shall not be visible in structure tree.
*/
public boolean isRootNodeShown() {
return true;
}
-}
+}
\ No newline at end of file
diff --git a/platform/lang-api/src/com/intellij/ide/util/EditSourceUtil.java b/platform/lang-api/src/com/intellij/ide/util/EditSourceUtil.java
index 2db2236..70ce9f0 100644
--- a/platform/lang-api/src/com/intellij/ide/util/EditSourceUtil.java
+++ b/platform/lang-api/src/com/intellij/ide/util/EditSourceUtil.java
@@ -13,13 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.intellij.ide.util;
import com.intellij.navigation.NavigationItem;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.util.UserDataHolder;
+import com.intellij.openapi.vfs.VFileProperty;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.pom.Navigatable;
@@ -54,13 +54,13 @@
return desc;
}
- public static boolean canNavigate (PsiElement element) {
+ public static boolean canNavigate(PsiElement element) {
if (element == null || !element.isValid()) {
return false;
}
VirtualFile file = PsiUtilCore.getVirtualFile(element.getNavigationElement());
- return file != null && file.isValid() && !file.is(VirtualFile.PROP_SPECIAL) && !VfsUtilCore.isBrokenLink(file);
+ return file != null && file.isValid() && !file.is(VFileProperty.SPECIAL) && !VfsUtilCore.isBrokenLink(file);
}
public static void navigate(NavigationItem item, boolean requestFocus, boolean useCurrentWindow) {
diff --git a/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java b/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java
index 5eb1340..678f672 100644
--- a/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java
+++ b/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java
@@ -431,15 +431,11 @@
* Align parameter comments to longest parameter name
*/
public boolean JD_ALIGN_PARAM_COMMENTS = true;
- public int JD_MIN_PARM_NAME_LENGTH = 0;
- public int JD_MAX_PARM_NAME_LENGTH = 30;
/**
* Align exception comments to longest exception name
*/
public boolean JD_ALIGN_EXCEPTION_COMMENTS = true;
- public int JD_MIN_EXCEPTION_NAME_LENGTH = 0;
- public int JD_MAX_EXCEPTION_NAME_LENGTH = 30;
public boolean JD_ADD_BLANK_AFTER_PARM_COMMENTS = false;
public boolean JD_ADD_BLANK_AFTER_RETURN = false;
diff --git a/platform/lang-api/src/com/intellij/psi/codeStyle/arrangement/match/StdArrangementEntryMatcher.java b/platform/lang-api/src/com/intellij/psi/codeStyle/arrangement/match/StdArrangementEntryMatcher.java
index fe0d9ff..f677122 100644
--- a/platform/lang-api/src/com/intellij/psi/codeStyle/arrangement/match/StdArrangementEntryMatcher.java
+++ b/platform/lang-api/src/com/intellij/psi/codeStyle/arrangement/match/StdArrangementEntryMatcher.java
@@ -137,7 +137,7 @@
ByNameArrangementEntryMatcher byName = myNamePattern == null ? null : new ByNameArrangementEntryMatcher(myNamePattern);
ByNamespaceArrangementEntryMatcher byNamespace = myNamespacePattern == null
? null : new ByNamespaceArrangementEntryMatcher(myNamespacePattern);
- int i = countNonNulls(byType, byModifiers, byName);
+ int i = countNonNulls(byType, byModifiers, byName, byNamespace);
if (i == 0 && myMatchers.isEmpty()) {
return ArrangementEntryMatcher.EMPTY;
}
diff --git a/platform/lang-api/src/com/intellij/psi/codeStyle/arrangement/match/StdArrangementMatchRule.java b/platform/lang-api/src/com/intellij/psi/codeStyle/arrangement/match/StdArrangementMatchRule.java
index 4b741c2..71969f8 100644
--- a/platform/lang-api/src/com/intellij/psi/codeStyle/arrangement/match/StdArrangementMatchRule.java
+++ b/platform/lang-api/src/com/intellij/psi/codeStyle/arrangement/match/StdArrangementMatchRule.java
@@ -54,6 +54,11 @@
public int compareTo(@NotNull StdArrangementMatchRule o) {
final Set<ArrangementSettingsToken> tokens = ArrangementUtil.extractTokens(getMatcher().getCondition()).keySet();
final Set<ArrangementSettingsToken> tokens1 = ArrangementUtil.extractTokens(o.getMatcher().getCondition()).keySet();
- return tokens1.containsAll(tokens) ? 1 : tokens.containsAll(tokens1) ? -1 : 0;
+ if (tokens1.containsAll(tokens)) {
+ return tokens.containsAll(tokens1) ? 0 : 1;
+ }
+ else {
+ return tokens.containsAll(tokens1) ? -1 : 0;
+ }
}
}
diff --git a/platform/lang-api/src/com/intellij/psi/util/PsiUtilBase.java b/platform/lang-api/src/com/intellij/psi/util/PsiUtilBase.java
index 609bac1..2f5e43c 100644
--- a/platform/lang-api/src/com/intellij/psi/util/PsiUtilBase.java
+++ b/platform/lang-api/src/com/intellij/psi/util/PsiUtilBase.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -34,6 +34,7 @@
import com.intellij.openapi.util.AsyncResult;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.vfs.LocalFileSystem;
+import com.intellij.openapi.vfs.VFileProperty;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileSystem;
import com.intellij.psi.*;
@@ -304,6 +305,6 @@
public static boolean isSymLink(@NotNull final PsiFileSystemItem element) {
final VirtualFile virtualFile = element.getVirtualFile();
- return virtualFile != null && virtualFile.isSymLink();
+ return virtualFile != null && virtualFile.is(VFileProperty.SYMLINK);
}
}
diff --git a/platform/lang-api/src/com/intellij/refactoring/listeners/RefactoringElementListener.java b/platform/lang-api/src/com/intellij/refactoring/listeners/RefactoringElementListener.java
index 4d44851..3f95ca3 100644
--- a/platform/lang-api/src/com/intellij/refactoring/listeners/RefactoringElementListener.java
+++ b/platform/lang-api/src/com/intellij/refactoring/listeners/RefactoringElementListener.java
@@ -21,6 +21,8 @@
/**
* {@linkplain RefactoringElementListenerProvider} receives a notification of what happened
* to element it have been observing during a refactoring.
+ * @see com.intellij.refactoring.listeners.RefactoringElementAdapter
+ * @see com.intellij.refactoring.listeners.UndoRefactoringElementAdapter
* @author dsl
*/
public interface RefactoringElementListener {
diff --git a/platform/lang-api/src/com/intellij/refactoring/listeners/UndoRefactoringElementAdapter.java b/platform/lang-api/src/com/intellij/refactoring/listeners/UndoRefactoringElementAdapter.java
new file mode 100644
index 0000000..dbd6054
--- /dev/null
+++ b/platform/lang-api/src/com/intellij/refactoring/listeners/UndoRefactoringElementAdapter.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2000-2013 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.refactoring.listeners;
+
+import com.intellij.psi.PsiElement;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+public abstract class UndoRefactoringElementAdapter implements RefactoringElementListener, UndoRefactoringElementListener {
+ @Override
+ public final void elementMoved(@NotNull PsiElement newElement) {
+ refactored(newElement, null);
+ }
+
+ @Override
+ public final void elementRenamed(@NotNull PsiElement newElement) {
+ refactored(newElement, null);
+ }
+
+ @Override
+ public final void undoElementMovedOrRenamed(@NotNull PsiElement newElement, @NotNull String oldQualifiedName) {
+ refactored(newElement, oldQualifiedName);
+ }
+
+ /**
+ * oldQualifiedName not-null on undoElementMovedOrRenamed, otherwise null
+ */
+ protected abstract void refactored(@NotNull PsiElement element, @Nullable String oldQualifiedName);
+}
\ No newline at end of file
diff --git a/platform/lang-api/src/com/intellij/refactoring/util/CommonRefactoringUtil.java b/platform/lang-api/src/com/intellij/refactoring/util/CommonRefactoringUtil.java
index fddef64..44db009 100644
--- a/platform/lang-api/src/com/intellij/refactoring/util/CommonRefactoringUtil.java
+++ b/platform/lang-api/src/com/intellij/refactoring/util/CommonRefactoringUtil.java
@@ -29,6 +29,7 @@
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.refactoring.RefactoringBundle;
+import com.intellij.usageView.UsageInfo;
import com.intellij.util.containers.ContainerUtil;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NonNls;
@@ -38,6 +39,7 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.Comparator;
/**
* @author ven
@@ -51,6 +53,22 @@
dialog.show();
}
+ //order of usages accross different files is irrelevant
+ public static void sortDepthFirstRightLeftOrder(final UsageInfo[] usages) {
+ Arrays.sort(usages, new Comparator<UsageInfo>() {
+ public int compare(final UsageInfo usage1, final UsageInfo usage2) {
+ final PsiElement element1 = usage1.getElement();
+ final PsiElement element2 = usage2.getElement();
+ if (element1 == null) {
+ if (element2 == null) return 0;
+ return 1;
+ }
+ if (element2 == null) return -1;
+ return element2.getTextRange().getStartOffset() - element1.getTextRange().getStartOffset();
+ }
+ });
+ }
+
/**
* Fatal refactoring problem during unit test run. Corresponds to message of modal dialog shown during user driven refactoring.
*/
diff --git a/platform/lang-api/src/com/intellij/usageView/UsageInfo.java b/platform/lang-api/src/com/intellij/usageView/UsageInfo.java
index 5aa56bb..11afd4b 100644
--- a/platform/lang-api/src/com/intellij/usageView/UsageInfo.java
+++ b/platform/lang-api/src/com/intellij/usageView/UsageInfo.java
@@ -45,7 +45,7 @@
TextRange elementRange = element.getTextRange();
if (elementRange == null) {
- LOG.error("text range null for " + element + "; " + element.getClass());
+ throw new IllegalArgumentException("text range null for " + element + "; " + element.getClass());
}
if (startOffset == -1 && endOffset == -1) {
// calculate natural element range
@@ -53,8 +53,12 @@
endOffset = elementRange.getEndOffset() - elementRange.getStartOffset();
}
- LOG.assertTrue(startOffset >= 0, "element " + element + "; startOffset " +startOffset);
- LOG.assertTrue(endOffset >= startOffset, "element " + element + "; diff " + (endOffset-startOffset));
+ if (startOffset < 0) {
+ throw new IllegalArgumentException("element " + element + "; startOffset " +startOffset);
+ }
+ if (startOffset > endOffset) {
+ throw new IllegalArgumentException("element " + element + "; diff " + (endOffset-startOffset));
+ }
if (startOffset != element.getTextOffset() - elementRange.getStartOffset() || endOffset != elementRange.getLength()) {
PsiFile file = element.getContainingFile();
diff --git a/platform/lang-impl/src/com/intellij/application/options/CodeStyleAbstractPanel.java b/platform/lang-impl/src/com/intellij/application/options/CodeStyleAbstractPanel.java
index 84e077c..f7c1fd4 100644
--- a/platform/lang-impl/src/com/intellij/application/options/CodeStyleAbstractPanel.java
+++ b/platform/lang-impl/src/com/intellij/application/options/CodeStyleAbstractPanel.java
@@ -32,6 +32,7 @@
import com.intellij.openapi.editor.highlighter.EditorHighlighter;
import com.intellij.openapi.editor.markup.*;
import com.intellij.openapi.fileTypes.FileType;
+import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectUtil;
import com.intellij.openapi.util.Disposer;
@@ -219,7 +220,11 @@
PsiFile psiFile = createFileFromText(project, myTextToReformat);
prepareForReformat(psiFile);
- apply(mySettings);
+ try {
+ apply(mySettings);
+ }
+ catch (ConfigurationException ignore) {
+ }
CodeStyleSettings clone = mySettings.clone();
clone.RIGHT_MARGIN = getAdjustedRightMargin();
CodeStyleSettingsManager.getInstance(project).setTemporarySettings(clone);
@@ -392,7 +397,7 @@
@Nullable
protected abstract String getPreviewText();
- public abstract void apply(CodeStyleSettings settings);
+ public abstract void apply(CodeStyleSettings settings) throws ConfigurationException;
public final void reset(final CodeStyleSettings settings) {
myShouldUpdatePreview = false;
diff --git a/platform/lang-impl/src/com/intellij/application/options/CodeStyleSchemesConfigurable.java b/platform/lang-impl/src/com/intellij/application/options/CodeStyleSchemesConfigurable.java
index 054c0dd..9f38c66 100644
--- a/platform/lang-impl/src/com/intellij/application/options/CodeStyleSchemesConfigurable.java
+++ b/platform/lang-impl/src/com/intellij/application/options/CodeStyleSchemesConfigurable.java
@@ -423,7 +423,7 @@
return ensurePanel().isModified();
}
- public void applyPanel() {
+ public void applyPanel() throws ConfigurationException {
ensurePanel().apply();
}
diff --git a/platform/lang-impl/src/com/intellij/application/options/TabbedLanguageCodeStylePanel.java b/platform/lang-impl/src/com/intellij/application/options/TabbedLanguageCodeStylePanel.java
index 2926e1f..01e7f76 100644
--- a/platform/lang-impl/src/com/intellij/application/options/TabbedLanguageCodeStylePanel.java
+++ b/platform/lang-impl/src/com/intellij/application/options/TabbedLanguageCodeStylePanel.java
@@ -231,7 +231,7 @@
}
@Override
- public void apply(CodeStyleSettings settings) {
+ public void apply(CodeStyleSettings settings) throws ConfigurationException {
ensureTabs();
for (CodeStyleAbstractPanel tab : myTabs) {
tab.apply(settings);
@@ -514,13 +514,8 @@
}
@Override
- public void apply(CodeStyleSettings settings) {
- try {
- myConfigurable.apply();
- }
- catch (ConfigurationException e) {
- // Ignore
- }
+ public void apply(CodeStyleSettings settings) throws ConfigurationException {
+ myConfigurable.apply();
}
@Override
diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/CodeStyleMainPanel.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/CodeStyleMainPanel.java
index ab7bc2e..4db811b 100644
--- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/CodeStyleMainPanel.java
+++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/CodeStyleMainPanel.java
@@ -21,6 +21,7 @@
import com.intellij.lang.Language;
import com.intellij.openapi.application.ApplicationBundle;
import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.ui.DetailsComponent;
import com.intellij.psi.codeStyle.CodeStyleScheme;
import com.intellij.psi.codeStyle.CodeStyleSchemes;
@@ -192,7 +193,7 @@
mySettingsPanels.clear();
}
- public void apply() {
+ public void apply() throws ConfigurationException {
final NewCodeStyleSettingsPanel[] panels = getPanels();
for (NewCodeStyleSettingsPanel panel : panels) {
if (panel.isModified()) panel.apply();
diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/MultilanguageCodeStyleAbstractPanel.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/MultilanguageCodeStyleAbstractPanel.java
index 6991041..88a23ee 100644
--- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/MultilanguageCodeStyleAbstractPanel.java
+++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/MultilanguageCodeStyleAbstractPanel.java
@@ -35,6 +35,7 @@
import com.intellij.psi.codeStyle.CodeStyleSettings;
import com.intellij.psi.codeStyle.CodeStyleSettingsCustomizable;
import com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider;
+import com.intellij.ui.AncestorListenerAdapter;
import com.intellij.ui.components.JBTabbedPane;
import com.intellij.util.Function;
import com.intellij.util.IncorrectOperationException;
@@ -46,7 +47,6 @@
import javax.swing.*;
import javax.swing.event.AncestorEvent;
-import javax.swing.event.AncestorListener;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
@@ -236,21 +236,11 @@
}
});
previewPanel.add(tabbedPane, BorderLayout.CENTER);
- previewPanel.addAncestorListener(new AncestorListener() {
+ previewPanel.addAncestorListener(new AncestorListenerAdapter() {
@Override
public void ancestorAdded(AncestorEvent event) {
selectCurrentLanguageTab();
}
-
- @Override
- public void ancestorRemoved(AncestorEvent event) {
- // Do nothing
- }
-
- @Override
- public void ancestorMoved(AncestorEvent event) {
- // Do nothing
- }
});
}
else {
diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/NewCodeStyleSettingsPanel.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/NewCodeStyleSettingsPanel.java
index 08ec6eb..3615b2c 100644
--- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/NewCodeStyleSettingsPanel.java
+++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/NewCodeStyleSettingsPanel.java
@@ -56,14 +56,9 @@
}
}
- public void apply() {
- try {
- if (myTab.isModified()) {
- myTab.apply();
- }
- }
- catch (ConfigurationException e) {
- LOG.error(e);
+ public void apply() throws ConfigurationException {
+ if (myTab.isModified()) {
+ myTab.apply();
}
}
diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/highlighting/HighlightsExtractor.java b/platform/lang-impl/src/com/intellij/application/options/colors/highlighting/HighlightsExtractor.java
index d80abf6..189578a 100644
--- a/platform/lang-impl/src/com/intellij/application/options/colors/highlighting/HighlightsExtractor.java
+++ b/platform/lang-impl/src/com/intellij/application/options/colors/highlighting/HighlightsExtractor.java
@@ -80,9 +80,13 @@
myIsOpeningTag = false;
openTag++;
}
+ if (!isValidTagFirstChar(text.charAt(openTag + 1))) {
+ myIndex = openTag + 1;
+ return "";
+ }
+
int closeTag = text.indexOf('>', openTag + 1);
- if (closeTag == -1) return null;
-
+ if (closeTag == -1) return null;
final String tagName = text.substring(openTag + 1, closeTag);
if (myIsOpeningTag) {
@@ -93,6 +97,10 @@
myIndex = Math.max(myStartOffset, myEndOffset + 1);
return tagName;
}
+
+ private static boolean isValidTagFirstChar(char c) {
+ return Character.isLetter(c) || c == '_';
+ }
public String cutDefinedTags(String text) {
if (myTags == null || myTags.isEmpty()) return text;
@@ -113,17 +121,22 @@
sb.append(text.substring(index, text.length()));
break;
}
-
- String tag;
- if (text.charAt(from + 1) == '/') {
- tag = text.substring(from + 2, to);
- } else {
- tag = text.substring(from + 1, to);
+ int tagNameStart = from + 1;
+ if (text.charAt(tagNameStart) == '/') {
+ tagNameStart ++;
}
- if (myTags.containsKey(tag)) {
- sb.append(text.substring(index, from));
- index = to + 1;
- continue;
+
+ if (isValidTagFirstChar(text.charAt(tagNameStart))) {
+ String tag;
+ tag = text.substring(tagNameStart, to);
+ if (myTags.containsKey(tag)) {
+ sb.append(text.substring(index, from));
+ index = to + 1;
+ continue;
+ }
+ }
+ else {
+ to = from;
}
sb.append(text.substring(index, to + 1));
index = to + 1;
diff --git a/platform/lang-impl/src/com/intellij/codeEditor/printing/BasePainter.java b/platform/lang-impl/src/com/intellij/codeEditor/printing/BasePainter.java
new file mode 100644
index 0000000..5c887dc
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/codeEditor/printing/BasePainter.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2000-2013 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.codeEditor.printing;
+
+import com.intellij.openapi.progress.ProgressIndicator;
+
+import java.awt.print.Printable;
+
+abstract class BasePainter implements Printable {
+ protected ProgressIndicator myProgress;
+
+ public void setProgress(ProgressIndicator progress) {
+ myProgress = progress;
+ }
+}
diff --git a/platform/lang-impl/src/com/intellij/codeEditor/printing/MultiFilePainter.java b/platform/lang-impl/src/com/intellij/codeEditor/printing/MultiFilePainter.java
index 5e7f089..5dd8790 100644
--- a/platform/lang-impl/src/com/intellij/codeEditor/printing/MultiFilePainter.java
+++ b/platform/lang-impl/src/com/intellij/codeEditor/printing/MultiFilePainter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -13,12 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.intellij.codeEditor.printing;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.progress.ProcessCanceledException;
-import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.util.Pair;
import com.intellij.psi.PsiFile;
@@ -28,44 +26,39 @@
import java.awt.print.PrinterException;
import java.util.List;
-class MultiFilePainter implements Printable{
+class MultiFilePainter extends BasePainter {
private final List<Pair<PsiFile, Editor>> myFilesList;
private int myFileIndex = 0;
private int myStartPageIndex = 0;
private Printable myTextPainter = null;
- private ProgressIndicator myProgress;
public MultiFilePainter(List<Pair<PsiFile, Editor>> filesList) {
myFilesList = filesList;
}
- public void setProgress(ProgressIndicator progress) {
- myProgress = progress;
- }
-
@Override
public int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException {
if (myProgress.isCanceled()) {
return Printable.NO_SUCH_PAGE;
}
- while(myFileIndex < myFilesList.size()) {
- if(myTextPainter == null) {
+ while (myFileIndex < myFilesList.size()) {
+ if (myTextPainter == null) {
Pair<PsiFile, Editor> pair = myFilesList.get(myFileIndex);
myTextPainter = PrintManager.initTextPainter(pair.first, pair.second);
}
if (myTextPainter != null) {
((TextPainter)myTextPainter).setProgress(myProgress);
+
int ret = 0;
try {
ret = myTextPainter.print(g, pageFormat, pageIndex - myStartPageIndex);
}
- catch (ProcessCanceledException ignored) {
- }
+ catch (ProcessCanceledException ignored) { }
if (myProgress.isCanceled()) {
return Printable.NO_SUCH_PAGE;
}
- if(ret == Printable.PAGE_EXISTS) {
+ if (ret == Printable.PAGE_EXISTS) {
return Printable.PAGE_EXISTS;
}
myTextPainter = null;
diff --git a/platform/lang-impl/src/com/intellij/codeEditor/printing/PrintManager.java b/platform/lang-impl/src/com/intellij/codeEditor/printing/PrintManager.java
index 7b2cfac..f678716 100644
--- a/platform/lang-impl/src/com/intellij/codeEditor/printing/PrintManager.java
+++ b/platform/lang-impl/src/com/intellij/codeEditor/printing/PrintManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -13,11 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.intellij.codeEditor.printing;
import com.intellij.CommonBundle;
import com.intellij.ide.highlighter.HighlighterFactory;
+import com.intellij.notification.Notification;
+import com.intellij.notification.NotificationType;
+import com.intellij.notification.Notifications;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
@@ -29,9 +31,9 @@
import com.intellij.openapi.fileTypes.FileTypes;
import com.intellij.openapi.progress.*;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Pair;
+import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
@@ -40,7 +42,6 @@
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
-import javax.swing.*;
import java.awt.print.*;
import java.util.List;
@@ -49,59 +50,62 @@
public static void executePrint(DataContext dataContext) {
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
+ if (project == null) return;
- final PrinterJob printerJob = PrinterJob.getPrinterJob();
-
- final PsiDirectory[] psiDirectory = new PsiDirectory[1];
+ PsiDirectory[] psiDirectory = new PsiDirectory[1];
PsiElement psiElement = LangDataKeys.PSI_ELEMENT.getData(dataContext);
- if(psiElement instanceof PsiDirectory) {
+ if (psiElement instanceof PsiDirectory) {
psiDirectory[0] = (PsiDirectory)psiElement;
}
- final PsiFile psiFile = LangDataKeys.PSI_FILE.getData(dataContext);
- final String[] shortFileName = new String[1];
- final String[] directoryName = new String[1];
- if(psiFile != null || psiDirectory[0] != null) {
- if(psiFile != null) {
- shortFileName[0] = psiFile.getVirtualFile().getName();
- if(psiDirectory[0] == null) {
+ PsiFile psiFile = LangDataKeys.PSI_FILE.getData(dataContext);
+ String[] shortFileName = new String[1];
+ String[] directoryName = new String[1];
+ if (psiFile != null || psiDirectory[0] != null) {
+ if (psiFile != null) {
+ shortFileName[0] = psiFile.getName();
+ if (psiDirectory[0] == null) {
psiDirectory[0] = psiFile.getContainingDirectory();
}
}
- if(psiDirectory[0] != null) {
+ if (psiDirectory[0] != null) {
directoryName[0] = psiDirectory[0].getVirtualFile().getPresentableUrl();
}
}
Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
String text = null;
- if(editor != null) {
- if(editor.getSelectionModel().hasSelection()) {
+ if (editor != null) {
+ if (editor.getSelectionModel().hasSelection()) {
text = CodeEditorBundle.message("print.selected.text.radio");
- } else {
+ }
+ else {
text = psiFile == null ? "Console text" : null;
}
}
+
PrintDialog printDialog = new PrintDialog(shortFileName[0], directoryName[0], text, project);
printDialog.reset();
printDialog.show();
- if(!printDialog.isOK()) {
+ if (!printDialog.isOK()) {
return;
}
printDialog.apply();
final PageFormat pageFormat = createPageFormat();
- PrintSettings printSettings = PrintSettings.getInstance();
- Printable painter;
+ final BasePainter painter;
- if(printSettings.getPrintScope() != PrintSettings.PRINT_DIRECTORY) {
+ PrintSettings printSettings = PrintSettings.getInstance();
+ if (printSettings.getPrintScope() != PrintSettings.PRINT_DIRECTORY) {
if (psiFile == null && editor == null) return;
TextPainter textPainter = psiFile != null ? initTextPainter(psiFile, editor) : initTextPainter((DocumentEx)editor.getDocument(), project);
if (textPainter == null) return;
- if(printSettings.getPrintScope() == PrintSettings.PRINT_SELECTED_TEXT && editor != null && editor.getSelectionModel().hasSelection()) {
+ if (printSettings.getPrintScope() == PrintSettings.PRINT_SELECTED_TEXT &&
+ editor != null &&
+ editor.getSelectionModel().hasSelection()) {
int firstLine = editor.getDocument().getLineNumber(editor.getSelectionModel().getSelectionStart());
- textPainter.setSegment(editor.getSelectionModel().getSelectionStart(), editor.getSelectionModel().getSelectionEnd(), firstLine+1);
+ textPainter.setSegment(editor.getSelectionModel().getSelectionStart(), editor.getSelectionModel().getSelectionEnd(), firstLine + 1);
}
painter = textPainter;
}
@@ -109,71 +113,58 @@
List<Pair<PsiFile, Editor>> filesList = ContainerUtil.newArrayList();
boolean isRecursive = printSettings.isIncludeSubdirectories();
addToPsiFileList(psiDirectory[0], filesList, isRecursive);
-
painter = new MultiFilePainter(filesList);
}
- final Printable painter0 = painter;
- Pageable document = new Pageable(){
+
+ Pageable document = new Pageable() {
@Override
public int getNumberOfPages() {
return Pageable.UNKNOWN_NUMBER_OF_PAGES;
}
@Override
- public PageFormat getPageFormat(int pageIndex)
- throws IndexOutOfBoundsException {
+ public PageFormat getPageFormat(int pageIndex) throws IndexOutOfBoundsException {
return pageFormat;
}
@Override
- public Printable getPrintable(int pageIndex)
- throws IndexOutOfBoundsException {
- return painter0;
+ public Printable getPrintable(int pageIndex) throws IndexOutOfBoundsException {
+ return painter;
}
};
-
+ final PrinterJob printerJob = PrinterJob.getPrinterJob();
try {
printerJob.setPageable(document);
printerJob.setPrintable(painter, pageFormat);
- if(!printerJob.printDialog()) {
+ if (!printerJob.printDialog()) {
return;
}
- } catch (Exception e) {
- // In case print dialog is not supported on some platform. Strange thing but there was a checking
- // for Windows only...
+ }
+ catch (Exception e) {
+ LOG.warn(e);
}
PsiDocumentManager.getInstance(project).commitAllDocuments();
- ProgressManager.getInstance().run(new Task.Backgroundable(project, CodeEditorBundle.message("print.progress"), true, PerformInBackgroundOption.ALWAYS_BACKGROUND) {
- @Override
- public void run(@NotNull ProgressIndicator indicator) {
- try {
- ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
- if (painter0 instanceof MultiFilePainter) {
- ((MultiFilePainter)painter0).setProgress(progress);
+ ProgressManager.getInstance()
+ .run(new Task.Backgroundable(project, CodeEditorBundle.message("print.progress"), true, PerformInBackgroundOption.ALWAYS_BACKGROUND) {
+ @Override
+ public void run(@NotNull ProgressIndicator indicator) {
+ try {
+ painter.setProgress(indicator);
+ printerJob.print();
}
- else {
- ((TextPainter)painter0).setProgress(progress);
+ catch (ProcessCanceledException e) {
+ LOG.info("Cancelled");
+ printerJob.cancel();
}
-
- printerJob.print();
+ catch (Exception e) {
+ Notifications.Bus.notify(new Notification("Print", CommonBundle.getErrorTitle(), e.getMessage(), NotificationType.ERROR));
+ LOG.warn(e);
+ }
}
- catch(final PrinterException e) {
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- Messages.showErrorDialog(project, e.getMessage(), CommonBundle.getErrorTitle());
- }
- });
- LOG.info(e);
- }
- catch(ProcessCanceledException e) {
- printerJob.cancel();
- }
- }
- });
+ });
}
private static void addToPsiFileList(PsiDirectory psiDirectory, List<Pair<PsiFile, Editor>> filesList, boolean isRecursive) {
@@ -190,27 +181,26 @@
}
}
-
private static PageFormat createPageFormat() {
PrintSettings printSettings = PrintSettings.getInstance();
PageFormat pageFormat = new PageFormat();
Paper paper = new Paper();
String paperSize = printSettings.PAPER_SIZE;
- double paperWidth = PageSizes.getWidth(paperSize)*72;
- double paperHeight = PageSizes.getHeight(paperSize)*72;
- double leftMargin = printSettings.LEFT_MARGIN*72;
- double rightMargin = printSettings.RIGHT_MARGIN*72;
- double topMargin = printSettings.TOP_MARGIN*72;
- double bottomMargin = printSettings.BOTTOM_MARGIN*72;
+ double paperWidth = PageSizes.getWidth(paperSize) * 72;
+ double paperHeight = PageSizes.getHeight(paperSize) * 72;
+ double leftMargin = printSettings.LEFT_MARGIN * 72;
+ double rightMargin = printSettings.RIGHT_MARGIN * 72;
+ double topMargin = printSettings.TOP_MARGIN * 72;
+ double bottomMargin = printSettings.BOTTOM_MARGIN * 72;
paper.setSize(paperWidth, paperHeight);
- if(printSettings.PORTRAIT_LAYOUT) {
+ if (printSettings.PORTRAIT_LAYOUT) {
pageFormat.setOrientation(PageFormat.PORTRAIT);
paperWidth -= leftMargin + rightMargin;
paperHeight -= topMargin + bottomMargin;
paper.setImageableArea(leftMargin, topMargin, paperWidth, paperHeight);
}
- else{
+ else {
pageFormat.setOrientation(PageFormat.LANDSCAPE);
paperWidth -= topMargin + bottomMargin;
paperHeight -= leftMargin + rightMargin;
@@ -220,7 +210,7 @@
return pageFormat;
}
- public static TextPainter initTextPainter(final PsiFile psiFile, final Editor editor) {
+ static TextPainter initTextPainter(final PsiFile psiFile, final Editor editor) {
return ApplicationManager.getApplication().runReadAction(new Computable<TextPainter>() {
@Override
public TextPainter compute() {
@@ -230,15 +220,16 @@
}
private static TextPainter doInitTextPainter(final PsiFile psiFile, final Editor editor) {
- final String fileName = psiFile.getVirtualFile().getPresentableUrl();
+ VirtualFile virtualFile = psiFile.getVirtualFile();
+ if (virtualFile == null) return null;
DocumentEx doc = (DocumentEx)PsiDocumentManager.getInstance(psiFile.getProject()).getDocument(psiFile);
if (doc == null) return null;
- EditorHighlighter highlighter = HighlighterFactory.createHighlighter(psiFile.getProject(), psiFile.getVirtualFile());
+ EditorHighlighter highlighter = HighlighterFactory.createHighlighter(psiFile.getProject(), virtualFile);
highlighter.setText(doc.getCharsSequence());
- return new TextPainter(doc, highlighter, fileName, psiFile, psiFile.getFileType(), editor);
+ return new TextPainter(doc, highlighter, virtualFile.getPresentableUrl(), psiFile, psiFile.getFileType(), editor);
}
- public static TextPainter initTextPainter(@NotNull final DocumentEx doc, final Project project) {
+ private static TextPainter initTextPainter(@NotNull final DocumentEx doc, final Project project) {
final TextPainter[] res = new TextPainter[1];
ApplicationManager.getApplication().runReadAction(
new Runnable() {
@@ -252,8 +243,8 @@
}
private static TextPainter doInitTextPainter(@NotNull final DocumentEx doc, Project project) {
- EditorHighlighter highlighter = HighlighterFactory.createHighlighter(project, "unknown");
- highlighter.setText(doc.getCharsSequence());
- return new TextPainter(doc, highlighter, "unknown", project, FileTypes.PLAIN_TEXT, null);
- }
+ EditorHighlighter highlighter = HighlighterFactory.createHighlighter(project, "unknown");
+ highlighter.setText(doc.getCharsSequence());
+ return new TextPainter(doc, highlighter, "unknown", project, FileTypes.PLAIN_TEXT, null);
+ }
}
diff --git a/platform/lang-impl/src/com/intellij/codeEditor/printing/TextPainter.java b/platform/lang-impl/src/com/intellij/codeEditor/printing/TextPainter.java
index 6d7274e..e46ea7b 100644
--- a/platform/lang-impl/src/com/intellij/codeEditor/printing/TextPainter.java
+++ b/platform/lang-impl/src/com/intellij/codeEditor/printing/TextPainter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.intellij.codeEditor.printing;
import com.intellij.codeInsight.daemon.LineMarkerInfo;
@@ -25,7 +24,6 @@
import com.intellij.openapi.editor.highlighter.HighlighterIterator;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.fileTypes.FileType;
-import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
@@ -48,12 +46,10 @@
import java.awt.print.PrinterException;
import java.util.List;
-public class TextPainter implements Printable {
+class TextPainter extends BasePainter {
private final DocumentEx myDocument;
-
private int myOffset = 0;
private int myLineNumber = 1;
-
private float myLineHeight = -1;
private float myDescent = -1;
private double myCharWidth = -1;
@@ -71,7 +67,7 @@
private int myCurrentMethodSeparator;
private final CodeStyleSettings myCodeStyleSettings;
private final FileType myFileType;
- private ProgressIndicator myProgress;
+
@NonNls private static final String DEFAULT_MEASURE_HEIGHT_TEXT = "A";
@NonNls private static final String DEFAULT_MEASURE_WIDTH_TEXT = "w";
@NonNls private static final String HEADER_TOKEN_PAGE = "PAGE";
@@ -80,8 +76,9 @@
public TextPainter(DocumentEx editorDocument,
EditorHighlighter highlighter,
String fileName,
- @NotNull final PsiFile psiFile,
- final FileType fileType, final Editor editor) {
+ @NotNull PsiFile psiFile,
+ FileType fileType,
+ Editor editor) {
this(editorDocument, highlighter, fileName, psiFile.getProject(), fileType,
FileSeparatorProvider.getInstance().getFileSeparators(psiFile, editorDocument, editor));
}
@@ -89,8 +86,9 @@
public TextPainter(DocumentEx editorDocument,
EditorHighlighter highlighter,
String fileName,
- final Project project,
- final FileType fileType, final List<LineMarkerInfo> separators) {
+ Project project,
+ FileType fileType,
+ List<LineMarkerInfo> separators) {
myCodeStyleSettings = CodeStyleSettingsManager.getSettings(project);
myDocument = editorDocument;
myPrintSettings = PrintSettings.getInstance();
@@ -101,8 +99,7 @@
myItalicFont = new Font(fontName, Font.ITALIC, fontSize);
myBoldItalicFont = new Font(fontName, Font.BOLD | Font.ITALIC, fontSize);
myHighlighter = highlighter;
- myHeaderFont = new Font(myPrintSettings.FOOTER_HEADER_FONT_NAME, Font.PLAIN,
- myPrintSettings.FOOTER_HEADER_FONT_SIZE);
+ myHeaderFont = new Font(myPrintSettings.FOOTER_HEADER_FONT_NAME, Font.PLAIN, myPrintSettings.FOOTER_HEADER_FONT_SIZE);
myFileName = fileName;
mySegmentEnd = myDocument.getTextLength();
myFileType = fileType;
@@ -110,10 +107,6 @@
myCurrentMethodSeparator = 0;
}
- public void setProgress(ProgressIndicator progress) {
- myProgress = progress;
- }
-
public void setSegment(int segmentStart, int segmentEnd, int firstLineNumber) {
myOffset = segmentStart;
mySegmentEnd = segmentEnd;
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/actions/LayoutCodeDialog.java b/platform/lang-impl/src/com/intellij/codeInsight/actions/LayoutCodeDialog.java
index ed467aa..dcbaded 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/actions/LayoutCodeDialog.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/actions/LayoutCodeDialog.java
@@ -111,8 +111,7 @@
!myRbSelectedText.isSelected() &&
!(myFile != null && LanguageImportStatements.INSTANCE.forFile(myFile).isEmpty() && myRbFile.isSelected())
);
- myCbArrangeEntries.setEnabled(myRbFile.isSelected()
- && myFile != null
+ myCbArrangeEntries.setEnabled(myFile != null
&& Rearranger.EXTENSION.forLanguage(myFile.getLanguage()) != null
);
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionLookupArranger.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionLookupArranger.java
index 1c96332..5185944 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionLookupArranger.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionLookupArranger.java
@@ -139,7 +139,7 @@
public void addElement(Lookup lookup, LookupElement element, LookupElementPresentation presentation) {
StatisticsWeigher.clearBaseStatisticsInfo(element);
- final String invariant = presentation.getItemText() + "###" + getTailTextOrSpace(presentation) + "###" + presentation.getTypeText();
+ final String invariant = presentation.getItemText() + "\0###" + getTailTextOrSpace(presentation) + "###" + presentation.getTypeText();
element.putUserData(PRESENTATION_INVARIANT, invariant);
CompletionSorterImpl sorter = obtainSorter(element);
@@ -332,9 +332,9 @@
return old;
}
- Object selectedValue = ((LookupImpl)lookup).getList().getSelectedValue();
+ Object selectedValue = lookup.getList().getSelectedValue();
if (selectedValue instanceof EmptyLookupItem && ((EmptyLookupItem)selectedValue).isLoading()) {
- int index = ((LookupImpl)lookup).getList().getSelectedIndex();
+ int index = lookup.getList().getSelectedIndex();
if (index >= 0 && index < items.size()) {
return index;
}
@@ -351,7 +351,7 @@
String selectedText = lookup.getEditor().getSelectionModel().getSelectedText();
for (int i = 0; i < items.size(); i++) {
LookupElement item = items.get(i);
- if (isPrefixItem(lookup, item, true) && !isLiveTemplate(item) ||
+ if (isAlphaSorted() && isPrefixItem(lookup, item, true) && !isLiveTemplate(item) ||
item.getLookupString().equals(selectedText)) {
return i;
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/impl/CamelHumpMatcher.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/impl/CamelHumpMatcher.java
index e885060..fe37cd1 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/completion/impl/CamelHumpMatcher.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/impl/CamelHumpMatcher.java
@@ -5,13 +5,13 @@
import com.intellij.codeInsight.completion.PrefixMatcher;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.openapi.Disposable;
-import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Disposer;
+import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.codeStyle.MinusculeMatcher;
import com.intellij.psi.codeStyle.NameUtil;
-import com.intellij.util.containers.ContainerUtil;
+import com.intellij.util.containers.FList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.TestOnly;
@@ -43,12 +43,24 @@
@Override
public boolean isStartMatch(LookupElement element) {
- return ContainerUtil.or(element.getAllLookupStrings(), new Condition<String>() {
- @Override
- public boolean value(String s) {
- return myCaseInsensitiveMatcher.isStartMatch(s);
+ for (String s : element.getAllLookupStrings()) {
+ FList<TextRange> ranges = myCaseInsensitiveMatcher.matchingFragments(s);
+ if (ranges == null) continue;
+ if (ranges.isEmpty() || isStartMatchModuloUnderscores(s, ranges.get(0).getStartOffset())) {
+ return true;
}
- });
+ }
+
+ return false;
+ }
+
+ private static boolean isStartMatchModuloUnderscores(@NotNull String name, int startIndex) {
+ for (int i = 0; i < startIndex; i++) {
+ if (name.charAt(i) != '_') {
+ return false;
+ }
+ }
+ return true;
}
@Override
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/DaemonCodeAnalyzerSettingsImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/DaemonCodeAnalyzerSettingsImpl.java
index 099cca5..4f7ecad 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/DaemonCodeAnalyzerSettingsImpl.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/DaemonCodeAnalyzerSettingsImpl.java
@@ -16,6 +16,7 @@
package com.intellij.codeInsight.daemon;
+import com.intellij.codeInspection.ex.InspectionProfileImpl;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.components.*;
import com.intellij.openapi.diagnostic.Logger;
@@ -110,13 +111,15 @@
}
}
- public void readExternal(Element element) throws InvalidDataException {
+ private void readExternal(Element element) throws InvalidDataException {
DefaultJDOMExternalizer.readExternal(this, element);
- myManager.getConverter().storeEditorHighlightingProfile(element);
+ myManager.getConverter().storeEditorHighlightingProfile(element,
+ new InspectionProfileImpl(
+ InspectionProfileConvertor.OLD_HIGHTLIGHTING_SETTINGS_PROFILE));
myManager.setRootProfile(element.getAttributeValue(PROFILE_ATT));
}
- public void writeExternal(Element element) throws WriteExternalException {
+ private void writeExternal(Element element) throws WriteExternalException {
DefaultJDOMExternalizer.writeExternal(this, element);
element.setAttribute(PROFILE_ATT, myManager.getRootProfile().getName());
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/IdeValidationHost.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/IdeValidationHost.java
index 5532c52..6d14422 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/IdeValidationHost.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/IdeValidationHost.java
@@ -17,10 +17,11 @@
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.psi.PsiElement;
+import org.jetbrains.annotations.NotNull;
/**
* @author yole
*/
public interface IdeValidationHost extends Validator.ValidationHost {
- void addMessageWithFixes(PsiElement context, String message, ErrorType type, IntentionAction... fixes);
+ void addMessageWithFixes(PsiElement context, String message, @NotNull ErrorType type, IntentionAction... fixes);
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java
index fd04257..6110bc4 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java
@@ -59,6 +59,9 @@
import com.intellij.openapi.vfs.VirtualFileAdapter;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.openapi.vfs.VirtualFilePropertyEvent;
+import com.intellij.openapi.wm.WindowManager;
+import com.intellij.openapi.wm.ex.StatusBarEx;
+import com.intellij.openapi.wm.impl.status.TogglePopupHintsPanel;
import com.intellij.packageDependencies.DependencyValidationManager;
import com.intellij.profile.Profile;
import com.intellij.profile.ProfileChangeAdapter;
@@ -504,9 +507,37 @@
}
@Override
- public void profileActivated(Profile oldProfile, Profile profile) {
+ public void profileActivated(@NotNull Profile oldProfile, Profile profile) {
stopDaemonAndRestartAllFiles();
}
+
+ @Override
+ public void profilesInitialized() {
+ inspectionProfilesInitialized();
+ }
+
+ @Override
+ public void profilesShutdown() {
+ }
+ }
+
+ private TogglePopupHintsPanel myTogglePopupHintsPanel;
+ private void inspectionProfilesInitialized() {
+ UIUtil.invokeLaterIfNeeded(new Runnable() {
+ @Override
+ public void run() {
+ if (myProject.isDisposed()) return;
+ StatusBarEx statusBar = (StatusBarEx)WindowManager.getInstance().getStatusBar(myProject);
+ myTogglePopupHintsPanel = new TogglePopupHintsPanel(myProject);
+ statusBar.addWidget(myTogglePopupHintsPanel, myProject);
+
+ stopDaemonAndRestartAllFiles();
+ }
+ });
+ }
+
+ public void updateStatusBar() {
+ if (myTogglePopupHintsPanel != null) myTogglePopupHintsPanel.updateStatus();
}
private class MyAnActionListener implements AnActionListener {
@@ -594,5 +625,4 @@
myDaemonEventPublisher.daemonCancelEventOccurred();
myDaemonCodeAnalyzer.restart();
}
-
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/GeneralHighlightingPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/GeneralHighlightingPass.java
index 61cafe4..226e49d 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/GeneralHighlightingPass.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/GeneralHighlightingPass.java
@@ -788,8 +788,10 @@
return visitorArray;
}
- static void cancelAndRestartDaemonLater(ProgressIndicator progress, final Project project, TextEditorHighlightingPass pass) throws ProcessCanceledException {
- PassExecutorService.log(progress, pass, "Cancel and restart");
+ static void cancelAndRestartDaemonLater(@NotNull ProgressIndicator progress,
+ @NotNull final Project project,
+ @NotNull TextEditorHighlightingPass passCalledFrom) throws ProcessCanceledException {
+ PassExecutorService.log(progress, passCalledFrom, "Cancel and restart");
progress.cancel();
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HectorComponent.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HectorComponent.java
index 1d3e2cc..2e6f6cf 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HectorComponent.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HectorComponent.java
@@ -36,7 +36,6 @@
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.profile.codeInspection.InspectionProjectProfileManagerImpl;
import com.intellij.profile.codeInspection.ui.ErrorsConfigurable;
import com.intellij.psi.FileViewProvider;
import com.intellij.psi.PsiElement;
@@ -272,7 +271,7 @@
}
}
forceDaemonRestart();
- InspectionProjectProfileManagerImpl.getInstanceImpl(myFile.getProject()).updateStatusBar();
+ DaemonListeners.getInstance(myFile.getProject()).updateStatusBar();
}
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java
index 4be279f..cf55516 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java
@@ -651,10 +651,14 @@
}
private static void appendFixes(@Nullable TextRange fixedRange, HighlightInfo info, List<Annotation.QuickFixInfo> fixes) {
+ if (info == null) return;
if (fixes != null) {
for (final Annotation.QuickFixInfo quickFixInfo : fixes) {
- QuickFixAction.registerQuickFixAction(info, fixedRange != null ? fixedRange : quickFixInfo.textRange, quickFixInfo.quickFix,
- quickFixInfo.key != null ? quickFixInfo.key : HighlightDisplayKey.find(DefaultHighlightVisitorBasedInspection.AnnotatorBasedInspection.ANNOTATOR_SHORT_NAME));
+ TextRange range = fixedRange != null ? fixedRange : quickFixInfo.textRange;
+ HighlightDisplayKey key = quickFixInfo.key != null
+ ? quickFixInfo.key
+ : HighlightDisplayKey.find(DefaultHighlightVisitorBasedInspection.AnnotatorBasedInspection.ANNOTATOR_SHORT_NAME);
+ QuickFixAction.registerQuickFixAction(info, range, quickFixInfo.quickFix, key);
}
}
}
@@ -762,7 +766,8 @@
List<IntentionAction> options = myOptions;
HighlightDisplayKey key = myKey;
if (myProblemGroup != null) {
- HighlightDisplayKey problemGroupKey = HighlightDisplayKey.findById(myProblemGroup.getProblemName());
+ String problemName = myProblemGroup.getProblemName();
+ HighlightDisplayKey problemGroupKey = problemName != null ? HighlightDisplayKey.findById(problemName) : null;
if (problemGroupKey != null) {
key = problemGroupKey;
}
@@ -772,46 +777,52 @@
}
List<IntentionAction> newOptions = IntentionManager.getInstance().getStandardIntentionOptions(key, element);
InspectionProfile profile = InspectionProjectProfileManager.getInstance(element.getProject()).getInspectionProfile();
- InspectionProfileEntry tool = profile.getInspectionTool(key.toString(), element);
- if (!(tool instanceof LocalInspectionToolWrapper)) {
+ InspectionToolWrapper toolWrapper = profile.getInspectionTool(key.toString(), element);
+ if (!(toolWrapper instanceof LocalInspectionToolWrapper)) {
HighlightDisplayKey idkey = HighlightDisplayKey.findById(key.toString());
if (idkey != null) {
- tool = profile.getInspectionTool(idkey.toString(), element);
+ toolWrapper = profile.getInspectionTool(idkey.toString(), element);
}
}
- InspectionProfileEntry wrappedTool = tool;
- if (tool instanceof LocalInspectionToolWrapper) {
- wrappedTool = ((LocalInspectionToolWrapper)tool).getTool();
- Class aClass = myAction.getClass();
- if (myAction instanceof QuickFixWrapper) {
- aClass = ((QuickFixWrapper)myAction).getFix().getClass();
- }
- newOptions.add(new CleanupInspectionIntention((LocalInspectionToolWrapper)tool, aClass));
- } else if (tool instanceof GlobalInspectionToolWrapper) {
- wrappedTool = ((GlobalInspectionToolWrapper)tool).getTool();
- if (wrappedTool instanceof GlobalSimpleInspectionTool && (myAction instanceof LocalQuickFix || myAction instanceof QuickFixWrapper)) {
+ if (toolWrapper != null) {
+ InspectionProfileEntry wrappedTool;
+ if (toolWrapper instanceof LocalInspectionToolWrapper) {
+ wrappedTool = ((LocalInspectionToolWrapper)toolWrapper).getTool();
Class aClass = myAction.getClass();
if (myAction instanceof QuickFixWrapper) {
aClass = ((QuickFixWrapper)myAction).getFix().getClass();
}
- newOptions.add(new CleanupInspectionIntention((GlobalInspectionToolWrapper)tool, aClass));
+ newOptions.add(new CleanupInspectionIntention(toolWrapper, aClass));
}
- }
-
- if (wrappedTool instanceof CustomSuppressableInspectionTool) {
- final IntentionAction[] suppressActions = ((CustomSuppressableInspectionTool)wrappedTool).getSuppressActions(element);
- if (suppressActions != null) {
- ContainerUtil.addAll(newOptions, suppressActions);
- }
- }
- if (wrappedTool instanceof BatchSuppressableTool) {
- final SuppressQuickFix[] suppressActions = ((BatchSuppressableTool)wrappedTool).getBatchSuppressActions(element);
- ContainerUtil.addAll(newOptions, ContainerUtil.map(suppressActions, new Function<SuppressQuickFix, IntentionAction>() {
- @Override
- public IntentionAction fun(SuppressQuickFix fix) {
- return InspectionManagerEx.convertBatchToSuppressIntentionAction(fix);
+ else if (toolWrapper instanceof GlobalInspectionToolWrapper) {
+ wrappedTool = ((GlobalInspectionToolWrapper)toolWrapper).getTool();
+ if (wrappedTool instanceof GlobalSimpleInspectionTool && (myAction instanceof LocalQuickFix || myAction instanceof QuickFixWrapper)) {
+ Class aClass = myAction.getClass();
+ if (myAction instanceof QuickFixWrapper) {
+ aClass = ((QuickFixWrapper)myAction).getFix().getClass();
+ }
+ newOptions.add(new CleanupInspectionIntention(toolWrapper, aClass));
}
- }));
+ }
+ else {
+ throw new AssertionError("unknown tool: " + toolWrapper+"; key: "+myKey);
+ }
+
+ if (wrappedTool instanceof CustomSuppressableInspectionTool) {
+ final IntentionAction[] suppressActions = ((CustomSuppressableInspectionTool)wrappedTool).getSuppressActions(element);
+ if (suppressActions != null) {
+ ContainerUtil.addAll(newOptions, suppressActions);
+ }
+ }
+ if (wrappedTool instanceof BatchSuppressableTool) {
+ final SuppressQuickFix[] suppressActions = ((BatchSuppressableTool)wrappedTool).getBatchSuppressActions(element);
+ ContainerUtil.addAll(newOptions, ContainerUtil.map(suppressActions, new Function<SuppressQuickFix, IntentionAction>() {
+ @Override
+ public IntentionAction fun(SuppressQuickFix fix) {
+ return InspectionManagerEx.convertBatchToSuppressIntentionAction(fix);
+ }
+ }));
+ }
}
if (myProblemGroup instanceof SuppressableProblemGroup) {
final IntentionAction[] suppressActions = ((SuppressableProblemGroup)myProblemGroup).getSuppressActions(element);
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java
index 1506d66..ea6d832 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java
@@ -24,6 +24,7 @@
import com.intellij.codeInsight.intention.EmptyIntentionAction;
import com.intellij.codeInspection.*;
import com.intellij.codeInspection.ex.*;
+import com.intellij.codeInspection.ui.InspectionToolPresentation;
import com.intellij.concurrency.JobLauncher;
import com.intellij.injected.editor.DocumentWindow;
import com.intellij.lang.Language;
@@ -159,11 +160,19 @@
for (InspectionResult inspectionResult : resultList) {
LocalInspectionToolWrapper toolWrapper = inspectionResult.tool;
for (ProblemDescriptor descriptor : inspectionResult.foundProblems) {
- toolWrapper.addProblemDescriptors(Collections.singletonList(descriptor), myIgnoreSuppressed);
+ addDescriptors(toolWrapper, descriptor);
}
}
}
+ private void addDescriptors(@NotNull LocalInspectionToolWrapper toolWrapper, @NotNull ProblemDescriptor descriptor) {
+ GlobalInspectionContextImpl context = (GlobalInspectionContextImpl)toolWrapper.getContext();
+ InspectionToolPresentation toolPresentation = context.getPresentation(toolWrapper);
+ LocalDescriptorsUtil.addProblemDescriptors(Collections.singletonList(descriptor), toolPresentation, myIgnoreSuppressed,
+ context,
+ toolWrapper.getTool());
+ }
+
private void addDescriptorsFromInjectedResults(@NotNull InspectionManagerEx iManager) {
InjectedLanguageManager ilManager = InjectedLanguageManager.getInstance(myProject);
PsiDocumentManager documentManager = PsiDocumentManager.getInstance(myProject);
@@ -174,12 +183,12 @@
DocumentWindow documentRange = (DocumentWindow)documentManager.getDocument(file);
List<InspectionResult> resultList = entry.getValue();
for (InspectionResult inspectionResult : resultList) {
- LocalInspectionToolWrapper tool = inspectionResult.tool;
+ LocalInspectionToolWrapper toolWrapper = inspectionResult.tool;
for (ProblemDescriptor descriptor : inspectionResult.foundProblems) {
PsiElement psiElement = descriptor.getPsiElement();
if (psiElement == null) continue;
- if (InspectionManagerEx.inspectionResultSuppressed(psiElement, tool.getTool())) continue;
+ if (InspectionManagerEx.inspectionResultSuppressed(psiElement, toolWrapper.getTool())) continue;
List<TextRange> editables = ilManager.intersectWithAllEditableFragments(file, ((ProblemDescriptorBase)descriptor).getTextRange());
for (TextRange editable : editables) {
TextRange hostRange = documentRange.injectedToHost(editable);
@@ -194,7 +203,7 @@
}
ProblemDescriptor patchedDescriptor = iManager.createProblemDescriptor(myFile, hostRange, descriptor.getDescriptionTemplate(),
descriptor.getHighlightType(), true, localFixes);
- tool.addProblemDescriptors(Collections.singletonList(patchedDescriptor), true);
+ addDescriptors(toolWrapper, patchedDescriptor);
}
}
}
@@ -711,16 +720,30 @@
return new ArrayList<PsiElement>(result);
}
+
+ @NotNull
+ private List<LocalInspectionToolWrapper> getHighlightingLocalInspectionTools(@NotNull InspectionProfileWrapper profile, PsiElement element) {
+ List<LocalInspectionToolWrapper> enabled = new ArrayList<LocalInspectionToolWrapper>();
+ final InspectionToolWrapper[] toolWrappers = profile.getInspectionTools(element);
+ InspectionProfileWrapper.checkInspectionsDuplicates(toolWrappers);
+ for (InspectionToolWrapper toolWrapper : toolWrappers) {
+ if (!profile.isToolEnabled(HighlightDisplayKey.find(toolWrapper.getShortName()), element)) continue;
+ LocalInspectionToolWrapper wrapper = null;
+ if (toolWrapper instanceof LocalInspectionToolWrapper) {
+ wrapper = (LocalInspectionToolWrapper)toolWrapper;
+ }
+ if (wrapper == null) continue;
+ if (myIgnoreSuppressed && InspectionManagerEx.inspectionResultSuppressed(myFile, wrapper.getTool())) {
+ continue;
+ }
+ enabled.add(wrapper);
+ }
+ return enabled;
+ }
+
@NotNull
List<LocalInspectionToolWrapper> getInspectionTools(@NotNull InspectionProfileWrapper profile) {
- final List<LocalInspectionToolWrapper> tools = profile.getHighlightingLocalInspectionTools(myFile);
- for (Iterator<LocalInspectionToolWrapper> iterator = tools.iterator(); iterator.hasNext(); ) {
- LocalInspectionToolWrapper tool = iterator.next();
- if (myIgnoreSuppressed && InspectionManagerEx.inspectionResultSuppressed(myFile, tool.getTool())) {
- iterator.remove();
- }
- }
- return tools;
+ return getHighlightingLocalInspectionTools(profile, myFile);
}
private void doInspectInjectedPsi(@NotNull PsiFile injectedPsi,
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ProgressableTextEditorHighlightingPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ProgressableTextEditorHighlightingPass.java
index dcb582d..669714c 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ProgressableTextEditorHighlightingPass.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ProgressableTextEditorHighlightingPass.java
@@ -110,7 +110,7 @@
private void repaintTrafficIcon() {
if (ApplicationManager.getApplication().isCommandLine()) return;
- if (repaintIconAlarm.getActiveRequestCount() == 0 || getProgressCount() >= getProgressLimit()) {
+ if (repaintIconAlarm.isEmpty() || getProgressCount() >= getProgressLimit()) {
repaintIconAlarm.addRequest(new Runnable() {
@Override
public void run() {
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightingSettingsPerFile.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightingSettingsPerFile.java
index 275b41b..f3cc7f3 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightingSettingsPerFile.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightingSettingsPerFile.java
@@ -18,9 +18,10 @@
import com.intellij.codeInspection.InspectionProfile;
import com.intellij.openapi.components.*;
-import com.intellij.openapi.components.StoragePathMacros;
import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.project.ProjectManager;
+import com.intellij.openapi.project.ProjectManagerAdapter;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.psi.PsiElement;
@@ -46,6 +47,15 @@
private final Map<VirtualFile, FileHighlightingSetting[]> myHighlightSettings = new HashMap<VirtualFile, FileHighlightingSetting[]>();
private final Map<PsiFile, InspectionProfile> myProfileSettings = new WeakHashMap<PsiFile, InspectionProfile>();
+ public HighlightingSettingsPerFile(Project project) {
+ project.getMessageBus().connect().subscribe(ProjectManager.TOPIC, new ProjectManagerAdapter() {
+ @Override
+ public void projectClosed(Project project) {
+ cleanProfileSettings();
+ }
+ });
+ }
+
public FileHighlightingSetting getHighlightingSettingForRoot(@NotNull PsiElement root){
final PsiFile containingFile = root.getContainingFile();
final VirtualFile virtualFile = containingFile.getVirtualFile();
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/documentation/QuickDocOnMouseOverManager.java b/platform/lang-impl/src/com/intellij/codeInsight/documentation/QuickDocOnMouseOverManager.java
index 8746ed7..7c23791 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/documentation/QuickDocOnMouseOverManager.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/documentation/QuickDocOnMouseOverManager.java
@@ -22,6 +22,7 @@
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.EditorFactory;
+import com.intellij.openapi.editor.VisualPosition;
import com.intellij.openapi.editor.event.*;
import com.intellij.openapi.editor.ex.EditorSettingsExternalizable;
import com.intellij.openapi.project.Project;
@@ -194,8 +195,14 @@
closeQuickDocIfPossible();
return;
}
+
+ VisualPosition visualPosition = editor.xyToVisualPosition(e.getMouseEvent().getPoint());
+ if (editor.getSoftWrapModel().isInsideOrBeforeSoftWrap(visualPosition)) {
+ closeQuickDocIfPossible();
+ return;
+ }
- int mouseOffset = editor.logicalPositionToOffset(editor.xyToLogicalPosition(e.getMouseEvent().getPoint()));
+ int mouseOffset = editor.logicalPositionToOffset(editor.visualToLogicalPosition(visualPosition));
PsiElement elementUnderMouse = psiFile.findElementAt(mouseOffset);
if (elementUnderMouse == null || elementUnderMouse instanceof PsiWhiteSpace) {
closeQuickDocIfPossible();
@@ -211,7 +218,7 @@
PsiElement activeElement = myActiveElements.get(editor);
if (targetElementUnderMouse.equals(activeElement)
- && (myAlarm.getActiveRequestCount() > 0 // Request to show documentation for the target component has been already queued.
+ && (!myAlarm.isEmpty() // Request to show documentation for the target component has been already queued.
|| hint != null)) // Documentation for the target component is being shown.
{
return;
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/AutoHardWrapHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/AutoHardWrapHandler.java
index 57b4ac4..d09e0bc 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/AutoHardWrapHandler.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/AutoHardWrapHandler.java
@@ -93,8 +93,10 @@
change.charTyped(editor, modificationStampBeforeTyping);
}
- // Return eagerly if we don't need to auto-wrap line on right margin exceeding.
- if (project == null || !editor.getSettings().isWrapWhenTypingReachesRightMargin(project)
+ // Return eagerly if we don't need to auto-wrap line, e.g. because of right margin exceeding.
+ if (/*editor.isOneLineMode()
+ || */project == null
+ || !editor.getSettings().isWrapWhenTypingReachesRightMargin(project)
|| (TemplateManager.getInstance(project) != null && TemplateManager.getInstance(project).getActiveTemplate(editor) != null))
{
return;
@@ -108,6 +110,10 @@
// Check if right margin is exceeded.
int margin = editor.getSettings().getRightMargin(project);
+ if (margin <= 0) {
+ return;
+ }
+
VisualPosition visEndLinePosition = editor.offsetToVisualPosition(endOffset);
if (margin > visEndLinePosition.column) {
if (change != null) {
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CopyPasteFoldingProcessor.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CopyPasteFoldingProcessor.java
index 86f670c..01f2649 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CopyPasteFoldingProcessor.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CopyPasteFoldingProcessor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -39,14 +39,14 @@
// might be slow
//CodeFoldingManager.getInstance(file.getManager().getProject()).updateFoldRegions(editor);
- final ArrayList<FoldingTransferableData.FoldingData> list = new ArrayList<FoldingTransferableData.FoldingData>();
+ final ArrayList<FoldingData> list = new ArrayList<FoldingData>();
final FoldRegion[] regions = editor.getFoldingModel().getAllFoldRegions();
for (final FoldRegion region : regions) {
if (!region.isValid()) continue;
for (int j = 0; j < startOffsets.length; j++) {
if (startOffsets[j] <= region.getStartOffset() && region.getEndOffset() <= endOffsets[j]) {
list.add(
- new FoldingTransferableData.FoldingData(
+ new FoldingData(
region.getStartOffset() - startOffsets[j],
region.getEndOffset() - startOffsets[j],
region.isExpanded()
@@ -56,7 +56,7 @@
}
}
- return new FoldingTransferableData(list.toArray(new FoldingTransferableData.FoldingData[list.size()]));
+ return new FoldingTransferableData(list.toArray(new FoldingData[list.size()]));
}
@Override
@@ -64,7 +64,7 @@
public FoldingTransferableData extractTransferableData(final Transferable content) {
FoldingTransferableData foldingData = null;
try {
- final DataFlavor flavor = FoldingTransferableData.FoldingData.getDataFlavor();
+ final DataFlavor flavor = FoldingData.getDataFlavor();
if (flavor != null) {
foldingData = (FoldingTransferableData)content.getTransferData(flavor);
}
@@ -95,7 +95,7 @@
Runnable operation = new Runnable() {
@Override
public void run() {
- for (FoldingTransferableData.FoldingData data : value.getData()) {
+ for (FoldingData data : value.getData()) {
FoldRegion region = foldingManager.findFoldRegion(editor, data.startOffset + bounds.getStartOffset(), data.endOffset + bounds.getStartOffset());
if (region != null) {
region.setExpanded(data.isExpanded);
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/FoldingData.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/FoldingData.java
new file mode 100644
index 0000000..93c1392
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/FoldingData.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2000-2013 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.codeInsight.editorActions;
+
+import org.jetbrains.annotations.NonNls;
+
+import java.awt.datatransfer.DataFlavor;
+import java.io.Serializable;
+
+/**
+* @author Denis Fokin
+*/
+public class FoldingData implements Cloneable, Serializable {
+ private static @NonNls DataFlavor ourFlavor;
+
+ public int startOffset;
+ public int endOffset;
+ public final boolean isExpanded;
+
+ public FoldingData(int startOffset, int endOffset, boolean expanded){
+ this.startOffset = startOffset;
+ this.endOffset = endOffset;
+ isExpanded = expanded;
+ }
+
+ @Override
+ public Object clone() {
+ try{
+ return super.clone();
+ }
+ catch(CloneNotSupportedException e){
+ throw new RuntimeException();
+ }
+ }
+
+ public static DataFlavor getDataFlavor() {
+ if (ourFlavor != null) {
+ return ourFlavor;
+ }
+ try {
+ ourFlavor = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType + ";class=" + FoldingData.class.getName(), "FoldingData");
+ }
+ catch (NoClassDefFoundError e) {
+ return null;
+ }
+ catch (IllegalArgumentException e) {
+ return null;
+ }
+ return ourFlavor;
+ }
+}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/FoldingTransferableData.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/FoldingTransferableData.java
index da97d1b..91115fb 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/FoldingTransferableData.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/FoldingTransferableData.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -16,8 +16,6 @@
package com.intellij.codeInsight.editorActions;
-import org.jetbrains.annotations.NonNls;
-
import java.awt.datatransfer.DataFlavor;
import java.io.Serializable;
@@ -68,44 +66,4 @@
public FoldingData[] getData() {
return myFoldingDatas;
}
-
- public static class FoldingData implements Cloneable, Serializable {
- private static @NonNls DataFlavor ourFlavor;
-
- public int startOffset;
- public int endOffset;
- public final boolean isExpanded;
-
- public FoldingData(int startOffset, int endOffset, boolean expanded){
- this.startOffset = startOffset;
- this.endOffset = endOffset;
- isExpanded = expanded;
- }
-
- @Override
- public Object clone() {
- try{
- return super.clone();
- }
- catch(CloneNotSupportedException e){
- throw new RuntimeException();
- }
- }
-
- public static DataFlavor getDataFlavor() {
- if (ourFlavor != null) {
- return ourFlavor;
- }
- try {
- ourFlavor = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType + ";class=" + FoldingData.class.getName(), "FoldingData");
- }
- catch (NoClassDefFoundError e) {
- return null;
- }
- catch (IllegalArgumentException e) {
- return null;
- }
- return ourFlavor;
- }
- }
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/TextBlockTransferable.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/TextBlockTransferable.java
index 46b1598..904ffe6 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/TextBlockTransferable.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/TextBlockTransferable.java
@@ -44,7 +44,7 @@
List<DataFlavor> dataFlavors = new ArrayList<DataFlavor>();
Collections.addAll(dataFlavors, DataFlavor.stringFlavor, DataFlavor.plainTextFlavor);
final DataFlavor flavor = RawText.getDataFlavor();
- if (flavor != null) {
+ if (myRawText != null && flavor != null) {
dataFlavors.add(flavor);
}
for(TextBlockTransferableData data: extraData) {
@@ -80,7 +80,7 @@
return data;
}
}
- if (Comparing.equal(RawText.getDataFlavor(), flavor)) {
+ if (myRawText != null && Comparing.equal(RawText.getDataFlavor(), flavor)) {
return myRawText;
}
else if (DataFlavor.stringFlavor.equals(flavor)) {
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/UnSelectWordHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/UnSelectWordHandler.java
index 1fc5e46..967a672 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/UnSelectWordHandler.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/UnSelectWordHandler.java
@@ -83,12 +83,19 @@
}
}
- while (element instanceof PsiWhiteSpace) {
- if (element.getNextSibling() == null) {
+ if (element instanceof PsiWhiteSpace) {
+ PsiElement nextSibling = element.getNextSibling();
+ if (nextSibling == null) {
element = element.getParent();
+ if (element == null || element instanceof PsiFile) {
+ return;
+ }
+ nextSibling = element.getNextSibling();
+ if (nextSibling == null) {
+ return;
+ }
}
-
- element = element.getNextSibling();
+ element = nextSibling;
cursorOffset = element.getTextRange().getStartOffset();
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hint/InspectionDescriptionLinkHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/hint/InspectionDescriptionLinkHandler.java
index 63cb09b..102c880 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/hint/InspectionDescriptionLinkHandler.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/hint/InspectionDescriptionLinkHandler.java
@@ -17,8 +17,8 @@
import com.intellij.codeInsight.highlighting.TooltipLinkHandler;
import com.intellij.codeInspection.InspectionProfile;
-import com.intellij.codeInspection.InspectionProfileEntry;
import com.intellij.codeInspection.InspectionsBundle;
+import com.intellij.codeInspection.ex.InspectionToolWrapper;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
@@ -30,7 +30,7 @@
/**
* Handles tooltip links in format <code>#inspection/inspection_short_name</code>.
* On a click or expend acton returns more detailed description for given inspection.
- *
+ *
* @author peter
*/
public class InspectionDescriptionLinkHandler extends TooltipLinkHandler {
@@ -50,10 +50,10 @@
}
final InspectionProfile profile = (InspectionProfile)InspectionProfileManager.getInstance().getRootProfile();
- final InspectionProfileEntry tool = profile.getInspectionTool(refSuffix, file);
- if (tool == null) return null;
+ final InspectionToolWrapper toolWrapper = profile.getInspectionTool(refSuffix, file);
+ if (toolWrapper == null) return null;
- String description = tool.loadDescription();
+ String description = toolWrapper.loadDescription();
if (description == null) {
LOG.warn("No description for inspection '" + refSuffix + "'");
description = InspectionsBundle.message("inspection.tool.description.under.construction.text");
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoComponent.java b/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoComponent.java
index 0d9fcd0..a686136 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoComponent.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoComponent.java
@@ -340,7 +340,7 @@
myLabel.setForeground(FOREGROUND_COLOR);
if (flagsMap.isEmpty()) {
- myLabel.setText(text);
+ myLabel.setText(XmlStringUtil.wrapInHtml(text));
}
else {
String labelText = buildLabelText(text, flagsMap);
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hint/ShowContainerInfoHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/hint/ShowContainerInfoHandler.java
index 9bffb23..b0e1e6c 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/hint/ShowContainerInfoHandler.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/hint/ShowContainerInfoHandler.java
@@ -58,7 +58,7 @@
StructureViewBuilder builder = LanguageStructureViewBuilder.INSTANCE.getStructureViewBuilder(file);
if (builder instanceof TreeBasedStructureViewBuilder) {
- StructureViewModel model = ((TreeBasedStructureViewBuilder) builder).createStructureViewModel();
+ StructureViewModel model = ((TreeBasedStructureViewBuilder) builder).createStructureViewModel(editor);
boolean goOneLevelUp = true;
try {
if (container == null) {
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionManagerImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionManagerImpl.java
index 7901634..46842af 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionManagerImpl.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionManagerImpl.java
@@ -237,6 +237,6 @@
}
public boolean hasActiveRequests() {
- return myInitActionsAlarm.getActiveRequestCount() > 0;
+ return !myInitActionsAlarm.isEmpty();
}
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/actions/ChooseItemAction.java b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/actions/ChooseItemAction.java
index 6f93833..7e92f1c 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/actions/ChooseItemAction.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/actions/ChooseItemAction.java
@@ -22,16 +22,14 @@
import com.intellij.codeInsight.lookup.Lookup;
import com.intellij.codeInsight.lookup.LookupManager;
import com.intellij.codeInsight.lookup.impl.LookupImpl;
-import com.intellij.codeInsight.template.impl.ListTemplatesHandler;
-import com.intellij.codeInsight.template.impl.SurroundWithTemplateHandler;
-import com.intellij.codeInsight.template.impl.TemplateImpl;
+import com.intellij.codeInsight.template.TemplateManager;
+import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
import com.intellij.codeInsight.template.impl.TemplateSettings;
import com.intellij.featureStatistics.FeatureUsageTracker;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
-import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
@@ -109,22 +107,8 @@
final Editor editor = lookup.getEditor();
PsiDocumentManager.getInstance(file.getProject()).commitDocument(editor.getDocument());
-
- final int end = editor.getCaretModel().getOffset();
- final int start = lookup.getLookupStart();
- final String prefix = !lookup.getItems().isEmpty() ? editor.getDocument().getText(TextRange.create(start, end)) : ListTemplatesHandler
- .getPrefix(editor.getDocument(), end);
-
- if (TemplateSettings.getInstance().getTemplates(prefix).isEmpty()) {
- return false;
- }
-
- for (TemplateImpl template : SurroundWithTemplateHandler.getApplicableTemplates(editor, file, false)) {
- if (prefix.equals(template.getKey()) && shortcutChar == TemplateSettings.getInstance().getShortcutChar(template)) {
- return true;
- }
- }
- return false;
+
+ return ((TemplateManagerImpl)TemplateManager.getInstance(file.getProject())).prepareTemplate(editor, shortcutChar, null) != null;
}
public static class Always extends ChooseItemAction {
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/navigation/CtrlMouseHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/navigation/CtrlMouseHandler.java
index d4c1a98..d2b99fd 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/CtrlMouseHandler.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/CtrlMouseHandler.java
@@ -99,8 +99,8 @@
import java.util.List;
public class CtrlMouseHandler extends AbstractProjectComponent {
-
private static final AbstractDocumentationTooltipAction[] ourTooltipActions = {new ShowQuickDocAtPinnedWindowFromTooltipAction()};
+ private final EditorColorsManager myEditorColorsManager;
private HighlightersSet myHighlighter;
@JdkConstants.InputEventMask private int myStoredModifiers = 0;
@@ -174,7 +174,7 @@
private final EditorMouseMotionListener myEditorMouseMotionListener = new EditorMouseMotionAdapter() {
@Override
public void mouseMoved(final EditorMouseEvent e) {
- if (e.isConsumed() || !myProject.isInitialized()) {
+ if (e.isConsumed() || !myProject.isInitialized() || myProject.isDisposed()) {
return;
}
MouseEvent mouseEvent = e.getMouseEvent();
@@ -188,12 +188,13 @@
Editor editor = e.getEditor();
if (editor.getProject() != null && editor.getProject() != myProject) return;
- PsiFile psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(editor.getDocument());
+ PsiDocumentManager documentManager = PsiDocumentManager.getInstance(myProject);
+ PsiFile psiFile = documentManager.getPsiFile(editor.getDocument());
Point point = new Point(mouseEvent.getPoint());
- if (PsiDocumentManager.getInstance(myProject).isCommitted(editor.getDocument())) {
+ if (documentManager.isCommitted(editor.getDocument())) {
// when document is committed, try to check injected stuff - it's fast
- editor = InjectedLanguageUtil
- .getEditorForInjectedLanguageNoCommit(editor, psiFile, editor.logicalPositionToOffset(editor.xyToLogicalPosition(point)));
+ int offset = editor.logicalPositionToOffset(editor.xyToLogicalPosition(point));
+ editor = InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(editor, psiFile, offset);
}
LogicalPosition pos = editor.xyToLogicalPosition(point);
@@ -221,11 +222,15 @@
@NotNull private final Alarm myDocAlarm;
- public CtrlMouseHandler(final Project project, StartupManager startupManager, EditorColorsManager colorsManager,
- FileEditorManager fileEditorManager, @NotNull DocumentationManager documentationManager,
+ public CtrlMouseHandler(final Project project,
+ StartupManager startupManager,
+ EditorColorsManager colorsManager,
+ FileEditorManager fileEditorManager,
+ @NotNull DocumentationManager documentationManager,
@NotNull final EditorFactory editorFactory)
{
super(project);
+ myEditorColorsManager = colorsManager;
startupManager.registerPostStartupActivity(new DumbAwareRunnable() {
@Override
public void run() {
@@ -265,7 +270,7 @@
return null;
}
JComponent hintComponent = hint.getComponent();
- if (hintComponent == null || !hintComponent.isShowing()) {
+ if (!hintComponent.isShowing()) {
return null;
}
return new Rectangle(hintComponent.getLocationOnScreen(), hintComponent.getSize());
@@ -847,7 +852,7 @@
Consumer<String> newTextConsumer = newTextConsumerRef.get();
QuickDocInfoPane quickDocPane = null;
if (docInfo.documentationAnchor != null) {
- quickDocPane = new QuickDocInfoPane(docInfo.documentationAnchor, info.myElementAtPointer, label, docInfo.text);
+ quickDocPane = new QuickDocInfoPane(docInfo.documentationAnchor, info.myElementAtPointer, label);
quickDocPaneRef.set(quickDocPane);
}
@@ -887,7 +892,7 @@
myFileEditorManager.addFileEditorManagerListener(myFileEditorManagerListener);
List<RangeHighlighter> highlighters = new ArrayList<RangeHighlighter>();
- TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.REFERENCE_HYPERLINK_COLOR);
+ TextAttributes attributes = myEditorColorsManager.getGlobalScheme().getAttributes(EditorColors.REFERENCE_HYPERLINK_COLOR);
for (TextRange range : info.getRanges()) {
final RangeHighlighter highlighter = editor.getMarkupModel().addRangeHighlighter(range.getStartOffset(), range.getEndOffset(),
HighlighterLayer.SELECTION + 1,
@@ -958,9 +963,7 @@
QuickDocInfoPane(@NotNull PsiElement documentationAnchor,
@NotNull PsiElement elementUnderMouse,
- @NotNull JComponent baseDocControl,
- @NotNull String text)
- {
+ @NotNull JComponent baseDocControl) {
myBaseDocControl = baseDocControl;
PresentationFactory presentationFactory = new PresentationFactory();
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/navigation/MethodUpDownUtil.java b/platform/lang-impl/src/com/intellij/codeInsight/navigation/MethodUpDownUtil.java
index dc89034..0d8f29e 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/MethodUpDownUtil.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/MethodUpDownUtil.java
@@ -63,7 +63,7 @@
StructureViewBuilder structureViewBuilder = LanguageStructureViewBuilder.INSTANCE.getStructureViewBuilder(element);
if (structureViewBuilder instanceof TreeBasedStructureViewBuilder) {
TreeBasedStructureViewBuilder builder = (TreeBasedStructureViewBuilder) structureViewBuilder;
- StructureViewModel model = builder.createStructureViewModel();
+ StructureViewModel model = builder.createStructureViewModel(null);
try {
addStructureViewElements(model.getRoot(), array, element);
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/preview/ElementPreviewHintProvider.java b/platform/lang-impl/src/com/intellij/codeInsight/preview/ElementPreviewHintProvider.java
new file mode 100644
index 0000000..96b28c6
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/codeInsight/preview/ElementPreviewHintProvider.java
@@ -0,0 +1,83 @@
+package com.intellij.codeInsight.preview;
+
+import com.intellij.codeInsight.hint.HintManager;
+import com.intellij.codeInsight.hint.HintManagerImpl;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.extensions.Extensions;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiFile;
+import com.intellij.ui.LightweightHint;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+import java.awt.*;
+
+import static com.intellij.codeInsight.hint.HintManagerImpl.getHintPosition;
+
+public class ElementPreviewHintProvider implements ElementPreviewProvider {
+ private static final Logger LOG = Logger.getInstance(ElementPreviewHintProvider.class);
+
+ private static final int HINT_HIDE_FLAGS = HintManager.HIDE_BY_ANY_KEY |
+ HintManager.HIDE_BY_OTHER_HINT |
+ HintManager.HIDE_BY_SCROLLING |
+ HintManager.HIDE_BY_TEXT_CHANGE |
+ HintManager.HIDE_IF_OUT_OF_EDITOR;
+ @Nullable
+ private LightweightHint hint;
+
+ @Override
+ public boolean isSupportedFile(@NotNull PsiFile psiFile) {
+ for (PreviewHintProvider hintProvider : Extensions.getExtensions(PreviewHintProvider.EP_NAME)) {
+ if (hintProvider.isSupportedFile(psiFile)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public void show(@NotNull PsiElement element, @NotNull Editor editor, @NotNull Point point) {
+ LightweightHint newHint = getHint(element);
+ hideCurrentHintIfAny();
+ if (newHint == null) {
+ return;
+ }
+
+ hint = newHint;
+ HintManagerImpl.getInstanceImpl().showEditorHint(newHint, editor,
+ getHintPosition(newHint, editor, editor.xyToLogicalPosition(point), HintManager.RIGHT_UNDER),
+ HINT_HIDE_FLAGS, 0, false);
+ }
+
+ private void hideCurrentHintIfAny() {
+ if (hint != null) {
+ hint.hide();
+ hint = null;
+ }
+ }
+
+ @Override
+ public void hide(@Nullable PsiElement element, @NotNull Editor editor) {
+ hideCurrentHintIfAny();
+ }
+
+ @Nullable
+ private static LightweightHint getHint(@NotNull PsiElement element) {
+ for (PreviewHintProvider hintProvider : Extensions.getExtensions(PreviewHintProvider.EP_NAME)) {
+ JComponent preview;
+ try {
+ preview = hintProvider.getPreviewComponent(element);
+ }
+ catch (Exception e) {
+ LOG.error(e);
+ continue;
+ }
+ if (preview != null) {
+ return new LightweightHint(preview);
+ }
+ }
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/preview/ImageOrColorPreviewManager.java b/platform/lang-impl/src/com/intellij/codeInsight/preview/ImageOrColorPreviewManager.java
index 53b2b82..7652bb4 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/preview/ImageOrColorPreviewManager.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/preview/ImageOrColorPreviewManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -16,181 +16,160 @@
package com.intellij.codeInsight.preview;
-import com.intellij.codeInsight.hint.HintManager;
-import com.intellij.codeInsight.hint.HintManagerImpl;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.editor.LogicalPosition;
+import com.intellij.openapi.editor.EditorFactory;
+import com.intellij.openapi.editor.event.EditorFactoryEvent;
+import com.intellij.openapi.editor.event.EditorFactoryListener;
import com.intellij.openapi.editor.event.EditorMouseEvent;
import com.intellij.openapi.editor.event.EditorMouseMotionListener;
import com.intellij.openapi.extensions.Extensions;
-import com.intellij.openapi.fileEditor.TextEditor;
import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Disposer;
+import com.intellij.openapi.util.Key;
import com.intellij.psi.PsiCompiledElement;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
-import com.intellij.ui.LightweightHint;
-import com.intellij.util.ui.update.MergingUpdateQueue;
-import com.intellij.util.ui.update.UiNotifyConnector;
-import com.intellij.util.ui.update.Update;
-import org.jetbrains.annotations.NonNls;
+import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
+import com.intellij.util.Alarm;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
-import java.awt.event.InputEvent;
+import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
+import java.lang.ref.WeakReference;
-import static com.intellij.codeInsight.hint.HintManagerImpl.getHintPosition;
+public class ImageOrColorPreviewManager implements Disposable, EditorMouseMotionListener {
+ private static final Logger LOG = Logger.getInstance(ImageOrColorPreviewManager.class);
-/**
- * @author spleaner
- */
-public class ImageOrColorPreviewManager implements Disposable, EditorMouseMotionListener, KeyListener {
- private static final Logger LOG = Logger.getInstance("#com.intellij.html.preview.ImageOrColorPreviewManager");
- private static final String QUEUE_NAME = "ImageOrColorPreview";
- private static final int HINT_HIDE_FLAGS = HintManager.HIDE_BY_ANY_KEY |
- HintManager.HIDE_BY_OTHER_HINT |
- HintManager.HIDE_BY_SCROLLING |
- HintManager.HIDE_BY_TEXT_CHANGE |
- HintManager.HIDE_IF_OUT_OF_EDITOR;
- @Nullable private MergingUpdateQueue myQueue;
- @Nullable private Editor myEditor;
- @Nullable private PsiFile myFile;
- @Nullable private LightweightHint myHint;
- @Nullable private PsiElement myElement;
+ private static final Key<KeyListener> EDITOR_LISTENER_ADDED = Key.create("previewManagerListenerAdded");
- public ImageOrColorPreviewManager(@NotNull final TextEditor editor, @NotNull Project project) {
- myEditor = editor.getEditor();
+ private final Alarm alarm = new Alarm();
- myEditor.addEditorMouseMotionListener(this);
- myEditor.getContentComponent().addKeyListener(this);
+ @Nullable
+ private WeakReference<PsiElement> elementRef;
- Document document = myEditor.getDocument();
- myFile = PsiDocumentManager.getInstance(project).getPsiFile(document);
+ public ImageOrColorPreviewManager(EditorFactory editorFactory) {
+ // we don't use multicaster because we don't want to serve all editors - only supported
+ editorFactory.addEditorFactoryListener(new EditorFactoryListener() {
+ @Override
+ public void editorCreated(@NotNull EditorFactoryEvent event) {
+ registerListeners(event.getEditor());
+ }
+ @Override
+ public void editorReleased(@NotNull EditorFactoryEvent event) {
+ Editor editor = event.getEditor();
+ if (editor.isOneLineMode()) {
+ return;
+ }
- final JComponent component = editor.getEditor().getComponent();
- myQueue = new MergingUpdateQueue(QUEUE_NAME, 100, component.isShowing(), component);
- Disposer.register(this, new UiNotifyConnector(editor.getComponent(), myQueue));
+ KeyListener keyListener = editor.getUserData(EDITOR_LISTENER_ADDED);
+ if (keyListener != null) {
+ editor.getContentComponent().removeKeyListener(keyListener);
+ editor.removeEditorMouseMotionListener(ImageOrColorPreviewManager.this);
+ }
+ }
+ }, this);
}
- @Override
- public void keyTyped(final KeyEvent e) {
- }
+ private void registerListeners(final Editor editor) {
+ if (editor.isOneLineMode()) {
+ return;
+ }
- @Override
- public void keyPressed(@NotNull final KeyEvent e) {
- if (e.getKeyCode() == KeyEvent.VK_SHIFT) {
- if (myEditor != null) {
- final PointerInfo pointerInfo = MouseInfo.getPointerInfo();
- if (pointerInfo != null) {
- final Point location = pointerInfo.getLocation();
- SwingUtilities.convertPointFromScreen(location, myEditor.getContentComponent());
+ Project project = editor.getProject();
+ if (project == null || project.isDisposed()) {
+ return;
+ }
- if (myQueue != null) {
- myQueue.cancelAllUpdates();
- myQueue.queue(new PreviewUpdate(this, location));
+ PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
+ if (psiFile == null || psiFile instanceof PsiCompiledElement || !isSupportedFile(psiFile)) {
+ return;
+ }
+
+ editor.addEditorMouseMotionListener(this);
+
+ KeyListener keyListener = new KeyAdapter() {
+ @Override
+ public void keyPressed(KeyEvent e) {
+ if (e.getKeyCode() == KeyEvent.VK_SHIFT && !editor.isOneLineMode()) {
+ PointerInfo pointerInfo = MouseInfo.getPointerInfo();
+ if (pointerInfo != null) {
+ Point location = pointerInfo.getLocation();
+ SwingUtilities.convertPointFromScreen(location, editor.getContentComponent());
+ alarm.cancelAllRequests();
+ alarm.addRequest(new PreviewRequest(location, editor), 100);
}
}
}
- }
+ };
+ editor.getContentComponent().addKeyListener(keyListener);
+
+ editor.putUserData(EDITOR_LISTENER_ADDED, keyListener);
}
- @Override
- public void keyReleased(final KeyEvent e) {
+ private static boolean isSupportedFile(PsiFile psiFile) {
+ for (ElementPreviewProvider provider : Extensions.getExtensions(ElementPreviewProvider.EP_NAME)) {
+ if (provider.isSupportedFile(psiFile)) {
+ return true;
+ }
+ }
+ return false;
}
@Nullable
- public Editor getEditor() {
- return myEditor;
- }
-
- @Nullable
- private PsiElement getPsiElementAt(@NotNull final Point point) {
- final LogicalPosition position = getLogicalPosition(point);
- if (myEditor != null && myFile != null && !(myFile instanceof PsiCompiledElement)) {
- return myFile.getViewProvider().findElementAt(myEditor.logicalPositionToOffset(position));
+ private static PsiElement getPsiElementAt(Point point, Editor editor) {
+ if (editor.isDisposed()) {
+ return null;
}
- return null;
- }
-
- @NotNull
- private LogicalPosition getLogicalPosition(@NotNull final Point point) {
- return myEditor != null ? myEditor.xyToLogicalPosition(point) : new LogicalPosition(0, 0);
- }
-
- private void setCurrentHint(@Nullable final LightweightHint hint, final PsiElement element) {
- if (hint != null) {
- myHint = hint;
- myElement = element;
+ Project project = editor.getProject();
+ if (project == null || project.isDisposed()) {
+ return null;
}
- }
- private void showHint(@NotNull final LightweightHint hint,
- @NotNull final PsiElement element,
- @NotNull Editor editor,
- @NotNull Point point) {
- if (element != myElement && element.isValid()) {
- hideCurrentHintIfAny();
- setCurrentHint(hint, element);
-
- HintManagerImpl.getInstanceImpl().showEditorHint(hint, editor,
- getHintPosition(hint, editor, getLogicalPosition(point), HintManager.RIGHT_UNDER),
- HINT_HIDE_FLAGS, 0, false);
+ PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
+ if (psiFile == null || psiFile instanceof PsiCompiledElement) {
+ return null;
}
- }
-
- private void hideCurrentHindIfOutOfElement(final PsiElement e) {
- if (myHint != null && e != myElement) {
- hideCurrentHintIfAny();
- }
- }
-
- private void hideCurrentHintIfAny() {
- if (myHint != null) {
- myHint.hide();
- myHint = null;
- myElement = null;
- }
+ return InjectedLanguageUtil.findElementAtNoCommit(psiFile, editor.logicalPositionToOffset(editor.xyToLogicalPosition(point)));
}
@Override
public void dispose() {
- if (myEditor != null) {
- myEditor.removeEditorMouseMotionListener(this);
- myEditor.getContentComponent().removeKeyListener(this);
- }
-
- if (myQueue != null) {
- myQueue.cancelAllUpdates();
- myQueue.hideNotify();
- }
-
- myQueue = null;
- myEditor = null;
- myFile = null;
- myHint = null;
+ alarm.cancelAllRequests();
+ elementRef = null;
}
@Override
- public void mouseMoved(@NotNull EditorMouseEvent e) {
- if (myQueue != null) {
- myQueue.cancelAllUpdates();
+ public void mouseMoved(@NotNull EditorMouseEvent event) {
+ Editor editor = event.getEditor();
+ if (editor.isOneLineMode()) {
+ return;
}
- if (myHint == null && e.getMouseEvent().getModifiers() == InputEvent.SHIFT_MASK) {
- myQueue.queue(new PreviewUpdate(this, e.getMouseEvent().getPoint()));
+
+ alarm.cancelAllRequests();
+ Point point = event.getMouseEvent().getPoint();
+ if (elementRef == null && event.getMouseEvent().isShiftDown()) {
+ alarm.addRequest(new PreviewRequest(point, editor), 100);
}
- else {
- hideCurrentHindIfOutOfElement(getPsiElementAt(e.getMouseEvent().getPoint()));
+ else if (elementRef != null && elementRef.get() != getPsiElementAt(point, editor)) {
+ PsiElement element = elementRef.get();
+ elementRef = null;
+ for (ElementPreviewProvider provider : Extensions.getExtensions(ElementPreviewProvider.EP_NAME)) {
+ try {
+ provider.hide(element, editor);
+ }
+ catch (Exception e) {
+ LOG.error(e);
+ }
+ }
}
}
@@ -199,62 +178,34 @@
// nothing
}
- @Nullable
- private static LightweightHint getHint(@NotNull PsiElement element) {
- for (PreviewHintProvider hintProvider : Extensions.getExtensions(PreviewHintProvider.EP_NAME)) {
- JComponent preview;
- try {
- preview = hintProvider.getPreviewComponent(element);
- }
- catch (Exception e) {
- LOG.error(e);
- continue;
- }
- if (preview != null) {
- return new LightweightHint(preview);
- }
- }
+ private final class PreviewRequest implements Runnable {
+ private final Point point;
+ private final Editor editor;
- return null;
- }
-
- private static final class PreviewUpdate extends Update {
- private final ImageOrColorPreviewManager myManager;
- @NotNull private final Point myPoint;
-
- public PreviewUpdate(@NonNls final ImageOrColorPreviewManager manager, @NotNull final Point point) {
- super(manager);
-
- myManager = manager;
- myPoint = point;
+ public PreviewRequest(Point point, Editor editor) {
+ this.point = point;
+ this.editor = editor;
}
@Override
public void run() {
- final PsiElement element = myManager.getPsiElementAt(myPoint);
- final Editor editor = myManager.getEditor();
- if (editor != null && element != null && element.isValid()) {
- if (PsiDocumentManager.getInstance(element.getProject()).isUncommited(editor.getDocument())) {
- return;
- }
+ PsiElement element = getPsiElementAt(point, editor);
+ if (element == null || !element.isValid() || (elementRef != null && elementRef.get() == element)) {
+ return;
+ }
+ if (PsiDocumentManager.getInstance(element.getProject()).isUncommited(editor.getDocument()) || DumbService.getInstance(element.getProject()).isDumb()) {
+ return;
+ }
- if (DumbService.getInstance(element.getProject()).isDumb()) {
- return;
+ elementRef = new WeakReference<PsiElement>(element);
+ for (ElementPreviewProvider provider : Extensions.getExtensions(ElementPreviewProvider.EP_NAME)) {
+ try {
+ provider.show(element, editor, point);
}
-
- final LightweightHint hint = getHint(element);
- if (hint != null) {
- myManager.showHint(hint, element, editor, myPoint);
- }
- else {
- myManager.hideCurrentHintIfAny();
+ catch (Exception e) {
+ LOG.error(e);
}
}
}
-
- @Override
- public boolean canEat(final Update update) {
- return true;
- }
}
-}
+}
\ No newline at end of file
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/preview/ImageOrColorPreviewProjectComponent.java b/platform/lang-impl/src/com/intellij/codeInsight/preview/ImageOrColorPreviewProjectComponent.java
deleted file mode 100644
index 69f5b25..0000000
--- a/platform/lang-impl/src/com/intellij/codeInsight/preview/ImageOrColorPreviewProjectComponent.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2000-2009 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.codeInsight.preview;
-
-import com.intellij.openapi.components.AbstractProjectComponent;
-import com.intellij.openapi.extensions.Extensions;
-import com.intellij.openapi.fileEditor.*;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Disposer;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.psi.FileViewProvider;
-import com.intellij.psi.PsiFile;
-import com.intellij.psi.PsiManager;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * @author spleaner
- */
-public class ImageOrColorPreviewProjectComponent extends AbstractProjectComponent {
-
- public ImageOrColorPreviewProjectComponent(final Project project) {
- super(project);
- }
-
- @Override
- public void projectOpened() {
- myProject.getMessageBus().connect(myProject).subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new MyFileEditorManagerListener());
- }
-
- @Override
- @NonNls
- @NotNull
- public String getComponentName() {
- return "ImageOrColorPreviewComponent";
- }
-
- private static class MyFileEditorManagerListener extends FileEditorManagerAdapter {
- @Override
- public void fileOpened(@NotNull final FileEditorManager source, @NotNull final VirtualFile file) {
- if (isSuitable(source.getProject(), file)) {
- final FileEditor[] fileEditors = source.getEditors(file);
- for (final FileEditor each : fileEditors) {
- if (each instanceof TextEditor) {
- Disposer.register(each, new ImageOrColorPreviewManager((TextEditor)each, source.getProject()));
- }
- }
- }
- }
-
- private static boolean isSuitable(final Project project, final VirtualFile file) {
- final FileViewProvider provider = PsiManager.getInstance(project).findViewProvider(file);
- if (provider == null) return false;
-
- for (final PsiFile psiFile : provider.getAllFiles()) {
- for(PreviewHintProvider hintProvider: Extensions.getExtensions(PreviewHintProvider.EP_NAME)) {
- if (hintProvider.isSupportedFile(psiFile)) {
- return true;
- }
- }
- }
-
- return false;
- }
- }
-
-
-}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/CustomTemplateCallback.java b/platform/lang-impl/src/com/intellij/codeInsight/template/CustomTemplateCallback.java
index 147d730..939573e 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/template/CustomTemplateCallback.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/template/CustomTemplateCallback.java
@@ -22,7 +22,6 @@
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.project.Project;
-import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
@@ -52,8 +51,6 @@
myProject = file.getProject();
myTemplateManager = TemplateManager.getInstance(myProject);
- PsiDocumentManager.getInstance(myProject).commitAllDocuments();
-
int offset = getOffset(wrapping, editor);
PsiElement element = InjectedLanguageUtil.findInjectedElementNoCommit(file, offset);
myFile = element != null ? element.getContainingFile() : file;
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateCompletionContributor.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateCompletionContributor.java
index 51b6c7f..bfe6d92 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateCompletionContributor.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateCompletionContributor.java
@@ -17,7 +17,10 @@
import com.intellij.codeInsight.completion.*;
import com.intellij.codeInsight.lookup.LookupElement;
+import com.intellij.codeInsight.template.CustomLiveTemplate;
+import com.intellij.codeInsight.template.CustomTemplateCallback;
import com.intellij.codeInsight.template.TemplateContextType;
+import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.registry.Registry;
@@ -42,31 +45,32 @@
@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
ProcessingContext context,
- @NotNull final CompletionResultSet result) {
+ @NotNull CompletionResultSet result) {
final PsiFile file = parameters.getPosition().getContainingFile();
final int offset = parameters.getOffset();
final List<TemplateImpl> templates = listApplicableTemplates(file, offset);
if (showAllTemplates()) {
final Ref<Boolean> templatesShown = Ref.create(false);
-
+
+ final CompletionResultSet finalResult = result;
result.runRemainingContributors(parameters, new Consumer<CompletionResult>() {
@Override
public void consume(CompletionResult completionResult) {
- result.passResult(completionResult);
- ensureTemplatesShown(templatesShown, templates, result);
+ finalResult.passResult(completionResult);
+ ensureTemplatesShown(templatesShown, templates, finalResult);
}
});
ensureTemplatesShown(templatesShown, templates, result);
-
return;
}
if (parameters.getInvocationCount() > 0) return; //only in autopopups for now
- final String prefix = result.getPrefixMatcher().getPrefix();
- final TemplateImpl template = findApplicableTemplate(file, offset, prefix);
+ String templatePrefix = findLiveTemplatePrefix(file, parameters.getLookup().getEditor(), result.getPrefixMatcher().getPrefix());
+ final TemplateImpl template = findApplicableTemplate(file, offset, templatePrefix);
if (template != null) {
+ result = result.withPrefixMatcher(template.getKey());
result.addElement(new LiveTemplateLookupElement(template, true));
}
for (final TemplateImpl possible : templates) {
@@ -104,15 +108,27 @@
}
@Nullable
- public static TemplateImpl findApplicableTemplate(PsiFile file, int offset, final String key) {
+ public static TemplateImpl findApplicableTemplate(final PsiFile file, int offset, @NotNull final String possiblePrefix) {
return ContainerUtil.find(listApplicableTemplates(file, offset), new Condition<TemplateImpl>() {
@Override
public boolean value(TemplateImpl template) {
- return key.equals(template.getKey());
+ return possiblePrefix.equals(template.getKey());
}
});
}
+ @NotNull
+ public static String findLiveTemplatePrefix(@NotNull PsiFile file, @NotNull Editor editor, @NotNull String defaultValue) {
+ final CustomTemplateCallback callback = new CustomTemplateCallback(editor, file, false);
+ for (CustomLiveTemplate customLiveTemplate : CustomLiveTemplate.EP_NAME.getExtensions()) {
+ final String customKey = customLiveTemplate.computeTemplateKey(callback);
+ if (customKey != null) {
+ return customKey;
+ }
+ }
+ return defaultValue;
+ }
+
public static class Skipper extends CompletionPreselectSkipper {
@Override
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateLookupElement.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateLookupElement.java
index c9b93d4..00e6c44 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateLookupElement.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateLookupElement.java
@@ -31,11 +31,17 @@
private final String myPrefix;
private final TemplateImpl myTemplate;
public final boolean sudden;
+ private final boolean myWorthShowingInAutoPopup;
public LiveTemplateLookupElement(TemplateImpl template, boolean sudden) {
+ this(template, sudden, false);
+ }
+
+ public LiveTemplateLookupElement(TemplateImpl template, boolean sudden, boolean worthShowingInAutoPopup) {
this.sudden = sudden;
myPrefix = template.getKey();
myTemplate = template;
+ myWorthShowingInAutoPopup = worthShowingInAutoPopup;
}
@NotNull
@Override
@@ -75,6 +81,6 @@
@Override
public boolean isWorthShowingInAutoPopup() {
- return false;
+ return myWorthShowingInAutoPopup;
}
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateManagerImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateManagerImpl.java
index 0703166..022d772 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateManagerImpl.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateManagerImpl.java
@@ -281,6 +281,7 @@
for (final CustomLiveTemplate customLiveTemplate : CustomLiveTemplate.EP_NAME.getExtensions()) {
if (shortcutChar == customLiveTemplate.getShortcut()) {
if (isApplicable(customLiveTemplate, editor, file)) {
+ PsiDocumentManager.getInstance(myProject).commitAllDocuments();
final CustomTemplateCallback callback = new CustomTemplateCallback(editor, file, false);
final String key = customLiveTemplate.computeTemplateKey(callback);
if (key != null) {
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/WrapWithCustomTemplateAction.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/WrapWithCustomTemplateAction.java
index 16354fd..917faa5 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/WrapWithCustomTemplateAction.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/WrapWithCustomTemplateAction.java
@@ -24,6 +24,7 @@
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.vfs.ReadonlyStatusHandler;
import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
import java.util.Set;
@@ -63,6 +64,7 @@
if (selection != null) {
selection = selection.trim();
+ PsiDocumentManager.getInstance(myFile.getProject()).commitAllDocuments();
myTemplate.wrap(selection, new CustomTemplateCallback(myEditor, myFile, true));
}
}
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/InspectionApplication.java b/platform/lang-impl/src/com/intellij/codeInspection/InspectionApplication.java
index fe4ef04..be97d7f 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/InspectionApplication.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/InspectionApplication.java
@@ -17,10 +17,7 @@
package com.intellij.codeInspection;
import com.intellij.analysis.AnalysisScope;
-import com.intellij.codeInspection.ex.GlobalInspectionContextImpl;
-import com.intellij.codeInspection.ex.InspectionManagerEx;
-import com.intellij.codeInspection.ex.InspectionProfileImpl;
-import com.intellij.codeInspection.ex.XSLTReportConverter;
+import com.intellij.codeInspection.ex.*;
import com.intellij.conversion.ConversionListener;
import com.intellij.conversion.ConversionService;
import com.intellij.ide.impl.PatchProjectUtil;
@@ -221,7 +218,7 @@
if (myErrorCodeRequired) System.exit(1);
return;
}
- inspectionContext.launchInspectionsOffline(scope, resultsDataPath, myRunGlobalToolsOnly, im, inspectionsResults);
+ inspectionContext.launchInspectionsOffline(scope, resultsDataPath, myRunGlobalToolsOnly, inspectionsResults);
logMessageLn(1, "\n" +
InspectionsBundle.message("inspection.capitalized.done") +
"\n");
@@ -438,16 +435,16 @@
}
private static void describeInspections(@NonNls String myOutputPath, final String name) throws IOException {
- final InspectionProfileEntry[] profileEntries = InspectionProfileImpl.getDefaultProfile().getInspectionTools(null);
- final Map<String, Set<InspectionProfileEntry>> map = new HashMap<String, Set<InspectionProfileEntry>>();
- for (InspectionProfileEntry entry : profileEntries) {
- final String groupName = entry.getGroupDisplayName();
- Set<InspectionProfileEntry> groupInspections = map.get(groupName);
+ final InspectionToolWrapper[] toolWrappers = InspectionProfileImpl.getDefaultProfile().getInspectionTools(null);
+ final Map<String, Set<InspectionToolWrapper>> map = new HashMap<String, Set<InspectionToolWrapper>>();
+ for (InspectionToolWrapper toolWrapper : toolWrappers) {
+ final String groupName = toolWrapper.getGroupDisplayName();
+ Set<InspectionToolWrapper> groupInspections = map.get(groupName);
if (groupInspections == null) {
- groupInspections = new HashSet<InspectionProfileEntry>();
+ groupInspections = new HashSet<InspectionToolWrapper>();
map.put(groupName, groupInspections);
}
- groupInspections.add(entry);
+ groupInspections.add(toolWrapper);
}
FileWriter fw = new FileWriter(myOutputPath);
@@ -460,17 +457,17 @@
for (String groupName : map.keySet()) {
xmlWriter.startNode("group");
xmlWriter.addAttribute("name", groupName);
- final Set<InspectionProfileEntry> entries = map.get(groupName);
- for (InspectionProfileEntry entry : entries) {
+ final Set<InspectionToolWrapper> entries = map.get(groupName);
+ for (InspectionToolWrapper toolWrapper : entries) {
xmlWriter.startNode("inspection");
- xmlWriter.addAttribute("shortName", entry.getShortName());
- xmlWriter.addAttribute("displayName", entry.getDisplayName());
- final String description = entry.loadDescription();
+ xmlWriter.addAttribute("shortName", toolWrapper.getShortName());
+ xmlWriter.addAttribute("displayName", toolWrapper.getDisplayName());
+ final String description = toolWrapper.loadDescription();
if (description != null) {
xmlWriter.setValue(description);
}
else {
- LOG.error(entry.getShortName() + " descriptionUrl==" + entry.getDescriptionUrl());
+ LOG.error(toolWrapper.getShortName() + " descriptionUrl==" + toolWrapper);
}
xmlWriter.endNode();
}
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/InspectionRunningUtil.java b/platform/lang-impl/src/com/intellij/codeInspection/InspectionRunningUtil.java
index b9b6564..65872c1 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/InspectionRunningUtil.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/InspectionRunningUtil.java
@@ -15,12 +15,17 @@
*/
package com.intellij.codeInspection;
+import com.intellij.analysis.AnalysisScope;
+import com.intellij.codeInsight.daemon.impl.DaemonProgressIndicator;
import com.intellij.codeInspection.ex.*;
+import com.intellij.codeInspection.reference.RefElement;
import com.intellij.codeInspection.reference.RefManagerImpl;
+import com.intellij.codeInspection.ui.InspectionToolPresentation;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -34,31 +39,41 @@
return runInspectionOnFile(file, new LocalInspectionToolWrapper(inspectionTool));
}
- public static List<CommonProblemDescriptor> runInspectionOnFile(@NotNull PsiFile file, @NotNull InspectionToolWrapper tool) {
+ @NotNull
+ public static List<CommonProblemDescriptor> runInspectionOnFile(@NotNull PsiFile file, @NotNull InspectionToolWrapper toolWrapper) {
final InspectionManagerEx managerEx = (InspectionManagerEx)InspectionManager.getInstance(file.getProject());
final GlobalInspectionContextImpl context = managerEx.createNewGlobalContext(false);
- tool.initialize(context);
- ((RefManagerImpl)context.getRefManager()).inspectionReadActionStarted();
+ toolWrapper.initialize(context);
+ RefManagerImpl refManager = (RefManagerImpl)context.getRefManager();
+ refManager.inspectionReadActionStarted();
try {
- if (tool instanceof LocalInspectionToolWrapper) {
- ((LocalInspectionToolWrapper)tool).processFile(file, true, managerEx, false);
- return new ArrayList<CommonProblemDescriptor>(tool.getProblemDescriptors());
+ if (toolWrapper instanceof LocalInspectionToolWrapper) {
+ LocalInspectionTool localTool = ((LocalInspectionToolWrapper)toolWrapper).getTool();
+ List<ProblemDescriptor> descriptors =
+ InspectionEngine.inspect(Collections.singletonList(localTool), file, managerEx, false, false, new DaemonProgressIndicator());
+ return new ArrayList<CommonProblemDescriptor>(descriptors);
}
- else if (tool instanceof GlobalInspectionToolWrapper) {
- final GlobalInspectionTool globalInspectionTool = ((GlobalInspectionToolWrapper)tool).getTool();
- if (globalInspectionTool instanceof GlobalSimpleInspectionTool) {
+ if (toolWrapper instanceof GlobalInspectionToolWrapper) {
+ final GlobalInspectionTool globalTool = ((GlobalInspectionToolWrapper)toolWrapper).getTool();
+ if (globalTool instanceof GlobalSimpleInspectionTool) {
+ GlobalSimpleInspectionTool simpleTool = (GlobalSimpleInspectionTool)globalTool;
ProblemsHolder problemsHolder = new ProblemsHolder(managerEx, file, false);
- ((GlobalSimpleInspectionTool)globalInspectionTool)
- .checkFile(file, managerEx, problemsHolder, context, tool);
- return new ArrayList<CommonProblemDescriptor>(tool.getProblemDescriptors());
+ InspectionToolPresentation presentation = context.getPresentation(toolWrapper);
+ simpleTool.checkFile(file, managerEx, problemsHolder, context, presentation);
+ return new ArrayList<CommonProblemDescriptor>(presentation.getProblemDescriptors());
+ }
+ RefElement fileRef = refManager.getReference(file);
+ CommonProblemDescriptor[] descriptors = globalTool.checkElement(fileRef, new AnalysisScope(file), managerEx, context);
+ if (descriptors != null) {
+ return Arrays.asList(descriptors);
}
}
return Collections.emptyList();
}
finally {
- ((RefManagerImpl)context.getRefManager()).inspectionReadActionFinished();
- tool.cleanup();
- context.cleanup(managerEx);
+ refManager.inspectionReadActionFinished();
+ toolWrapper.cleanup();
+ context.cleanup();
}
}
}
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/actions/CleanupInspectionIntention.java b/platform/lang-impl/src/com/intellij/codeInspection/actions/CleanupInspectionIntention.java
index f913ac4..7bbf6d9 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/actions/CleanupInspectionIntention.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/actions/CleanupInspectionIntention.java
@@ -45,18 +45,18 @@
* Date: 21-Feb-2006
*/
public class CleanupInspectionIntention implements IntentionAction, HighPriorityAction {
- private final InspectionToolWrapper myTool;
+ private final InspectionToolWrapper myToolWrapper;
private final Class myQuickfixClass;
- public CleanupInspectionIntention(@NotNull InspectionToolWrapper tool, Class quickFixClass) {
- myTool = tool;
+ public CleanupInspectionIntention(@NotNull InspectionToolWrapper toolWrapper, Class quickFixClass) {
+ myToolWrapper = toolWrapper;
myQuickfixClass = quickFixClass;
}
@Override
@NotNull
public String getText() {
- return InspectionsBundle.message("fix.all.inspection.problems.in.file", myTool.getDisplayName());
+ return InspectionsBundle.message("fix.all.inspection.problems.in.file", myToolWrapper.getDisplayName());
}
@Override
@@ -72,7 +72,7 @@
ProgressManager.getInstance().runProcess(new Computable<List<CommonProblemDescriptor>>() {
@Override
public List<CommonProblemDescriptor> compute() {
- return InspectionRunningUtil.runInspectionOnFile(file, myTool);
+ return InspectionRunningUtil.runInspectionOnFile(file, myToolWrapper);
}
}, new EmptyProgressIndicator());
@@ -111,8 +111,8 @@
@Override
public boolean isAvailable(@NotNull final Project project, final Editor editor, final PsiFile file) {
- return myQuickfixClass != null && myQuickfixClass != EmptyIntentionAction.class && !(myTool instanceof LocalInspectionToolWrapper &&
- ((LocalInspectionToolWrapper)myTool).isUnfair());
+ return myQuickfixClass != null && myQuickfixClass != EmptyIntentionAction.class && !(myToolWrapper instanceof LocalInspectionToolWrapper &&
+ ((LocalInspectionToolWrapper)myToolWrapper).isUnfair());
}
@Override
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/actions/CodeInspectionAction.java b/platform/lang-impl/src/com/intellij/codeInspection/actions/CodeInspectionAction.java
index 228eb1f..387c0af 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/actions/CodeInspectionAction.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/actions/CodeInspectionAction.java
@@ -58,11 +58,10 @@
try {
scope.setSearchInLibraries(false);
FileDocumentManager.getInstance().saveAllDocuments();
- final InspectionManagerEx inspectionManagerEx = (InspectionManagerEx)InspectionManager.getInstance(project);
final GlobalInspectionContextImpl inspectionContext = getGlobalInspectionContext(project);
inspectionContext.setExternalProfile(myExternalProfile);
inspectionContext.setCurrentScope(scope);
- inspectionContext.doInspections(scope, inspectionManagerEx);
+ inspectionContext.doInspections(scope);
}
finally {
myGlobalInspectionContext = null;
@@ -91,7 +90,7 @@
}
@Override
- protected JComponent getAdditionalActionSettings(final Project project, final BaseAnalysisActionDialog dialog) {
+ protected JComponent getAdditionalActionSettings(@NotNull final Project project, final BaseAnalysisActionDialog dialog) {
final AdditionalPanel panel = new AdditionalPanel();
final InspectionManagerEx manager = (InspectionManagerEx)InspectionManager.getInstance(project);
final JComboBox profiles = panel.myBrowseProfilesCombo.getComboBox();
@@ -121,7 +120,7 @@
else {
//if profile was disabled and cancel after apply was pressed
final InspectionProfile profile = (InspectionProfile)profiles.getSelectedItem();
- final boolean canExecute = profile != null && profile.isExecutable();
+ final boolean canExecute = profile != null && profile.isExecutable(project);
dialog.setOKActionEnabled(canExecute);
}
}
@@ -130,7 +129,7 @@
@Override
public void actionPerformed(ActionEvent e) {
myExternalProfile = (InspectionProfile)profiles.getSelectedItem();
- final boolean canExecute = myExternalProfile != null && myExternalProfile.isExecutable();
+ final boolean canExecute = myExternalProfile != null && myExternalProfile.isExecutable(project);
dialog.setOKActionEnabled(canExecute);
if (canExecute) {
manager.setProfile(myExternalProfile.getName());
@@ -138,7 +137,7 @@
}
});
final InspectionProfile profile = (InspectionProfile)profiles.getSelectedItem();
- dialog.setOKActionEnabled(profile != null && profile.isExecutable());
+ dialog.setOKActionEnabled(profile != null && profile.isExecutable(project));
return panel.myAdditionalPanel;
}
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/actions/CodeInspectionOnEditorAction.java b/platform/lang-impl/src/com/intellij/codeInspection/actions/CodeInspectionOnEditorAction.java
index 8c4499f..4649c0b 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/actions/CodeInspectionOnEditorAction.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/actions/CodeInspectionOnEditorAction.java
@@ -51,7 +51,7 @@
final InspectionProfile inspectionProfile =
InspectionProjectProfileManager.getInstance(project).getInspectionProfile();
inspectionContext.setExternalProfile(inspectionProfile);
- inspectionContext.doInspections(scope, inspectionManagerEx);
+ inspectionContext.doInspections(scope);
}
@Override
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/actions/GotoInspectionModel.java b/platform/lang-impl/src/com/intellij/codeInspection/actions/GotoInspectionModel.java
index c12e8d5..06d1e92 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/actions/GotoInspectionModel.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/actions/GotoInspectionModel.java
@@ -15,8 +15,8 @@
*/
package com.intellij.codeInspection.actions;
-import com.intellij.codeInspection.InspectionProfileEntry;
import com.intellij.codeInspection.ex.InspectionProfileImpl;
+import com.intellij.codeInspection.ex.InspectionToolWrapper;
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
import com.intellij.codeInspection.ex.ScopeToolState;
import com.intellij.ide.IdeBundle;
@@ -26,15 +26,18 @@
import com.intellij.util.ArrayUtil;
import javax.swing.*;
-import java.util.*;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
/**
* @author Konstantin Bulenkov
*/
public class GotoInspectionModel extends SimpleChooseByNameModel {
- private final Map<String, InspectionProfileEntry> myToolNames = new HashMap<String, InspectionProfileEntry>();
- private final Map<String, Set<InspectionProfileEntry>> myGroupNames = new HashMap<String, Set<InspectionProfileEntry>>();
- private final Map<String, InspectionProfileEntry> myToolShortNames = new HashMap<String, InspectionProfileEntry>();
+ private final Map<String, InspectionToolWrapper> myToolNames = new HashMap<String, InspectionToolWrapper>();
+ private final Map<String, Set<InspectionToolWrapper>> myGroupNames = new HashMap<String, Set<InspectionToolWrapper>>();
+ private final Map<String, InspectionToolWrapper> myToolShortNames = new HashMap<String, InspectionToolWrapper>();
private final String[] myNames;
private final ListCellRenderer myListCellRenderer = new InspectionListCellRenderer();
@@ -42,9 +45,9 @@
public GotoInspectionModel(Project project) {
super(project, IdeBundle.message("prompt.goto.inspection.enter.name"), "goto.inspection.help.id");
final InspectionProfileImpl rootProfile = (InspectionProfileImpl)InspectionProfileManager.getInstance().getRootProfile();
- for (ScopeToolState state : rootProfile.getAllTools()) {
- final InspectionProfileEntry tool = state.getTool();
- InspectionProfileEntry workingTool = tool;
+ for (ScopeToolState state : rootProfile.getAllTools(project)) {
+ InspectionToolWrapper tool = state.getTool();
+ InspectionToolWrapper workingTool = tool;
if (tool instanceof LocalInspectionToolWrapper) {
workingTool = LocalInspectionToolWrapper.findTool2RunInBatch(project, null, tool.getShortName());
if (workingTool == null) {
@@ -53,9 +56,9 @@
}
myToolNames.put(tool.getDisplayName(), workingTool);
final String groupName = tool.getGroupDisplayName();
- Set<InspectionProfileEntry> toolsInGroup = myGroupNames.get(groupName);
+ Set<InspectionToolWrapper> toolsInGroup = myGroupNames.get(groupName);
if (toolsInGroup == null) {
- toolsInGroup = new HashSet<InspectionProfileEntry>();
+ toolsInGroup = new HashSet<InspectionToolWrapper>();
myGroupNames.put(groupName, toolsInGroup);
}
toolsInGroup.add(workingTool);
@@ -80,8 +83,8 @@
@Override
public Object[] getElementsByName(final String id, final String pattern) {
- final Set<InspectionProfileEntry> result = new HashSet<InspectionProfileEntry>();
- InspectionProfileEntry e = myToolNames.get(id);
+ final Set<InspectionToolWrapper> result = new HashSet<InspectionToolWrapper>();
+ InspectionToolWrapper e = myToolNames.get(id);
if (e != null) {
result.add(e);
}
@@ -89,17 +92,17 @@
if (e != null) {
result.add(e);
}
- final Set<InspectionProfileEntry> entries = myGroupNames.get(id);
+ final Set<InspectionToolWrapper> entries = myGroupNames.get(id);
if (entries != null) {
result.addAll(entries);
}
- return result.toArray(new InspectionProfileEntry[result.size()]);
+ return result.toArray(new InspectionToolWrapper[result.size()]);
}
@Override
public String getElementName(final Object element) {
- if (element instanceof InspectionProfileEntry) {
- final InspectionProfileEntry entry = (InspectionProfileEntry)element;
+ if (element instanceof InspectionToolWrapper) {
+ InspectionToolWrapper entry = (InspectionToolWrapper)element;
return entry.getDisplayName() + " " + entry.getGroupDisplayName();
}
return null;
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/actions/InspectionListCellRenderer.java b/platform/lang-impl/src/com/intellij/codeInspection/actions/InspectionListCellRenderer.java
index f28b3c0..8608a2d 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/actions/InspectionListCellRenderer.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/actions/InspectionListCellRenderer.java
@@ -15,8 +15,7 @@
*/
package com.intellij.codeInspection.actions;
-import com.intellij.codeInspection.InspectionProfileEntry;
-import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
+import com.intellij.codeInspection.ex.InspectionToolWrapper;
import com.intellij.ide.util.gotoByName.ChooseByNameBase;
import com.intellij.lang.Language;
import com.intellij.openapi.fileTypes.LanguageFileType;
@@ -27,8 +26,8 @@
import com.intellij.ui.speedSearch.SpeedSearchUtil;
import com.intellij.util.text.Matcher;
import com.intellij.util.text.MatcherHolder;
-import com.intellij.util.ui.EmptyIcon;
import com.intellij.util.ui.UIUtil;
+import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
@@ -38,8 +37,6 @@
*/
@SuppressWarnings({"GtkPreferredJComboBoxRenderer"})
public class InspectionListCellRenderer extends DefaultListCellRenderer implements MatcherHolder {
- private static final Icon EMPTY_ICON = EmptyIcon.ICON_18;
-
private Matcher myMatcher;
private final SimpleTextAttributes SELECTED;
private final SimpleTextAttributes PLAIN;
@@ -67,19 +64,19 @@
panel.setForeground(fg);
SimpleTextAttributes attr = sel ? SELECTED : PLAIN;
- if (value instanceof InspectionProfileEntry) {
- final InspectionProfileEntry tool = (InspectionProfileEntry)value;
+ if (value instanceof InspectionToolWrapper) {
+ final InspectionToolWrapper toolWrapper = (InspectionToolWrapper)value;
final SimpleColoredComponent c = new SimpleColoredComponent();
- SpeedSearchUtil.appendColoredFragmentForMatcher(" " + tool.getDisplayName(), c, attr, myMatcher, bg, sel);
+ SpeedSearchUtil.appendColoredFragmentForMatcher(" " + toolWrapper.getDisplayName(), c, attr, myMatcher, bg, sel);
panel.add(c, BorderLayout.WEST);
final SimpleColoredComponent group = new SimpleColoredComponent();
- SpeedSearchUtil.appendColoredFragmentForMatcher(tool.getGroupDisplayName() + " ", group, attr, myMatcher, bg, sel);
+ SpeedSearchUtil.appendColoredFragmentForMatcher(toolWrapper.getGroupDisplayName() + " ", group, attr, myMatcher, bg, sel);
final JPanel right = new JPanel(new BorderLayout());
right.setBackground(bg);
right.setForeground(fg);
right.add(group, BorderLayout.CENTER);
- final JLabel icon = new JLabel(getIcon(tool));
+ final JLabel icon = new JLabel(getIcon(toolWrapper));
icon.setBackground(bg);
icon.setForeground(fg);
right.add(icon, BorderLayout.EAST);
@@ -94,15 +91,14 @@
return panel;
}
- private static Icon getIcon(InspectionProfileEntry tool) {
+ @NotNull
+ private static Icon getIcon(@NotNull InspectionToolWrapper tool) {
Icon icon = null;
- if (tool instanceof LocalInspectionToolWrapper) {
- final Language language = Language.findLanguageByID(((LocalInspectionToolWrapper)tool).getLanguage());
- if (language != null) {
- final LanguageFileType fileType = language.getAssociatedFileType();
- if (fileType != null) {
- icon = fileType.getIcon();
- }
+ final Language language = Language.findLanguageByID(tool.getLanguage());
+ if (language != null) {
+ final LanguageFileType fileType = language.getAssociatedFileType();
+ if (fileType != null) {
+ icon = fileType.getIcon();
}
}
if (icon == null) {
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/actions/RunInspectionAction.java b/platform/lang-impl/src/com/intellij/codeInspection/actions/RunInspectionAction.java
index bb27a62..8f65af5 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/actions/RunInspectionAction.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/actions/RunInspectionAction.java
@@ -20,9 +20,9 @@
import com.intellij.analysis.AnalysisUIOptions;
import com.intellij.analysis.BaseAnalysisActionDialog;
import com.intellij.codeInspection.InspectionManager;
-import com.intellij.codeInspection.InspectionProfileEntry;
import com.intellij.codeInspection.InspectionsBundle;
import com.intellij.codeInspection.ex.InspectionManagerEx;
+import com.intellij.codeInspection.ex.InspectionToolWrapper;
import com.intellij.featureStatistics.FeatureUsageTracker;
import com.intellij.ide.IdeBundle;
import com.intellij.ide.actions.GotoActionBase;
@@ -79,7 +79,7 @@
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
- runInspection(project, (InspectionProfileEntry)element, virtualFile, psiElement, psiFile);
+ runInspection(project, (InspectionToolWrapper)element, virtualFile, psiElement, psiFile);
}
});
}
@@ -87,16 +87,18 @@
}
private static void runInspection(@NotNull Project project,
- @NotNull InspectionProfileEntry profileEntry,
+ @NotNull InspectionToolWrapper toolWrapper,
@Nullable VirtualFile virtualFile,
- PsiElement psiElement, PsiFile psiFile) {
+ PsiElement psiElement,
+ PsiFile psiFile) {
final InspectionManagerEx managerEx = (InspectionManagerEx)InspectionManager.getInstance(project);
final Module module = virtualFile != null ? ModuleUtilCore.findModuleForFile(virtualFile, project) : null;
AnalysisScope analysisScope = null;
if (psiFile != null) {
analysisScope = new AnalysisScope(psiFile);
- } else {
+ }
+ else {
if (virtualFile != null && virtualFile.isDirectory()) {
final PsiDirectory psiDirectory = PsiManager.getInstance(project).findDirectory(virtualFile);
if (psiDirectory != null) {
@@ -114,7 +116,7 @@
final FileFilterPanel fileFilterPanel = new FileFilterPanel();
fileFilterPanel.init();
- final BaseAnalysisActionDialog dlg = new BaseAnalysisActionDialog(
+ final BaseAnalysisActionDialog dialog = new BaseAnalysisActionDialog(
AnalysisScopeBundle.message("specify.analysis.scope", InspectionsBundle.message("inspection.action.title")),
AnalysisScopeBundle.message("analysis.scope.title", InspectionsBundle.message("inspection.action.noun")),
project,
@@ -135,11 +137,11 @@
}
};
- AnalysisScope scope = analysisScope;
- dlg.show();
- if (!dlg.isOK()) return;
+ dialog.show();
+ if (!dialog.isOK()) return;
final AnalysisUIOptions uiOptions = AnalysisUIOptions.getInstance(project);
- scope = dlg.getScope(uiOptions, scope, project, module);
- RunInspectionIntention.rerunInspection(profileEntry, managerEx, scope, psiFile);
+ AnalysisScope scope = dialog.getScope(uiOptions, analysisScope, project, module);
+ PsiElement element = psiFile == null ? psiElement : psiFile;
+ RunInspectionIntention.rerunInspection(toolWrapper, managerEx, scope, element);
}
}
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/actions/RunInspectionIntention.java b/platform/lang-impl/src/com/intellij/codeInspection/actions/RunInspectionIntention.java
index 678d427..4555040 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/actions/RunInspectionIntention.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/actions/RunInspectionIntention.java
@@ -29,6 +29,8 @@
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.InvalidDataException;
+import com.intellij.openapi.util.WriteExternalException;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.profile.codeInspection.InspectionProfileManager;
import com.intellij.psi.PsiElement;
@@ -46,8 +48,8 @@
public class RunInspectionIntention implements IntentionAction, HighPriorityAction {
private final String myShortName;
- public RunInspectionIntention(final InspectionProfileEntry tool) {
- myShortName = tool.getShortName();
+ public RunInspectionIntention(@NotNull InspectionToolWrapper toolWrapper) {
+ myShortName = toolWrapper.getShortName();
}
public RunInspectionIntention(final HighlightDisplayKey key) {
@@ -93,31 +95,37 @@
rerunInspection(LocalInspectionToolWrapper.findTool2RunInBatch(project, file, myShortName), managerEx, analysisScope, file);
}
- public static void rerunInspection(final InspectionProfileEntry baseTool, final InspectionManagerEx managerEx, final AnalysisScope scope,
+ public static void rerunInspection(@NotNull InspectionToolWrapper toolWrapper,
+ @NotNull InspectionManagerEx managerEx,
+ @NotNull AnalysisScope scope,
PsiElement psiElement) {
- GlobalInspectionContextImpl inspectionContext = createContext(baseTool, managerEx, psiElement);
- inspectionContext.doInspections(scope, managerEx);
+ GlobalInspectionContextImpl inspectionContext = createContext(toolWrapper, managerEx, psiElement);
+ inspectionContext.doInspections(scope);
}
- public static GlobalInspectionContextImpl createContext(final InspectionProfileEntry baseTool, InspectionManagerEx managerEx, PsiElement psiElement) {
+ public static GlobalInspectionContextImpl createContext(@NotNull InspectionToolWrapper toolWrapper,
+ @NotNull InspectionManagerEx managerEx,
+ PsiElement psiElement) {
final InspectionProfileImpl rootProfile = (InspectionProfileImpl)InspectionProfileManager.getInstance().getRootProfile();
- LinkedHashSet<InspectionProfileEntry> allEntries = new LinkedHashSet<InspectionProfileEntry>();
- allEntries.add(baseTool);
- rootProfile.collectDependentInspections(baseTool, allEntries);
- InspectionProfileEntry[] toolsArray = allEntries.toArray(new InspectionProfileEntry[allEntries.size()]);
- final InspectionProfileImpl model = InspectionProfileImpl.createSimple(baseTool.getDisplayName(), toolsArray);
+ LinkedHashSet<InspectionToolWrapper> allWrappers = new LinkedHashSet<InspectionToolWrapper>();
+ allWrappers.add(toolWrapper);
+ rootProfile.collectDependentInspections(toolWrapper, allWrappers, managerEx.getProject());
+ InspectionToolWrapper[] toolWrappers = allWrappers.toArray(new InspectionToolWrapper[allWrappers.size()]);
+ final InspectionProfileImpl model = InspectionProfileImpl.createSimple(toolWrapper.getDisplayName(), managerEx.getProject(), toolWrappers);
try {
Element element = new Element("toCopy");
-
- for (InspectionProfileEntry tool : allEntries) {
- tool.writeSettings(element);
- model.getInspectionTool(tool.getShortName(), psiElement).readSettings(element);
+ for (InspectionToolWrapper wrapper : toolWrappers) {
+ wrapper.getTool().writeSettings(element);
+ InspectionToolWrapper tw = psiElement == null ? model.getInspectionTool(wrapper.getShortName(), managerEx.getProject())
+ : model.getInspectionTool(wrapper.getShortName(), psiElement);
+ tw.getTool().readSettings(element);
}
}
- catch (Exception e) {
- //skip
+ catch (WriteExternalException ignored) {
}
- model.setEditable(baseTool.getDisplayName());
+ catch (InvalidDataException ignored) {
+ }
+ model.setEditable(toolWrapper.getDisplayName());
final GlobalInspectionContextImpl inspectionContext = managerEx.createNewGlobalContext(false);
inspectionContext.setExternalProfile(model);
return inspectionContext;
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/actions/ViewOfflineResultsAction.java b/platform/lang-impl/src/com/intellij/codeInspection/actions/ViewOfflineResultsAction.java
index 28d41dc..82eb306 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/actions/ViewOfflineResultsAction.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/actions/ViewOfflineResultsAction.java
@@ -211,23 +211,24 @@
return showOfflineView(project, resMap, inspectionProfile, title);
}
- public static InspectionResultsView showOfflineView(final Project project,
- final Map<String, Map<String, Set<OfflineProblemDescriptor>>> resMap,
+ @NotNull
+ public static InspectionResultsView showOfflineView(@NotNull Project project,
+ @NotNull Map<String, Map<String, Set<OfflineProblemDescriptor>>> resMap,
final InspectionProfile inspectionProfile,
final String title) {
final AnalysisScope scope = new AnalysisScope(project);
final InspectionManagerEx managerEx = (InspectionManagerEx)InspectionManager.getInstance(project);
- final GlobalInspectionContextImpl inspectionContext = managerEx.createNewGlobalContext(false);
- inspectionContext.setExternalProfile(inspectionProfile);
- inspectionContext.setCurrentScope(scope);
- inspectionContext.initializeTools(new ArrayList<Tools>(), new ArrayList<Tools>(), new ArrayList<Tools>());
- final InspectionResultsView view = new InspectionResultsView(project, inspectionProfile, scope, inspectionContext,
+ final GlobalInspectionContextImpl context = managerEx.createNewGlobalContext(false);
+ context.setExternalProfile(inspectionProfile);
+ context.setCurrentScope(scope);
+ context.initializeTools(new ArrayList<Tools>(), new ArrayList<Tools>(), new ArrayList<Tools>());
+ final InspectionResultsView view = new InspectionResultsView(project, inspectionProfile, scope, context,
new OfflineInspectionRVContentProvider(resMap, project));
- ((RefManagerImpl)inspectionContext.getRefManager()).inspectionReadActionStarted();
+ ((RefManagerImpl)context.getRefManager()).inspectionReadActionStarted();
view.update();
TreeUtil.selectFirstNode(view.getTree());
- if (inspectionContext.getContentManager() != null) { //test
- inspectionContext.addView(view, title);
+ if (context.getContentManager() != null) { //test
+ context.addView(view, title);
}
return view;
}
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/CommonInspectionToolWrapper.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/CommonInspectionToolWrapper.java
deleted file mode 100644
index 7232012..0000000
--- a/platform/lang-impl/src/com/intellij/codeInspection/ex/CommonInspectionToolWrapper.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Copyright 2000-2012 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.codeInspection.ex;
-
-import com.intellij.analysis.AnalysisScope;
-import com.intellij.codeInsight.intention.IntentionAction;
-import com.intellij.codeInspection.*;
-import com.intellij.codeInspection.reference.RefElement;
-import com.intellij.codeInspection.reference.RefEntity;
-import com.intellij.codeInspection.reference.RefManager;
-import com.intellij.codeInspection.reference.RefModule;
-import com.intellij.codeInspection.ui.InspectionNode;
-import com.intellij.codeInspection.ui.InspectionTreeNode;
-import com.intellij.lang.annotation.HighlightSeverity;
-import com.intellij.openapi.vcs.FileStatus;
-import org.jdom.Element;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-
-public class CommonInspectionToolWrapper extends InspectionToolWrapper<InspectionTool, InspectionEP> {
- public CommonInspectionToolWrapper(@NotNull InspectionEP ep) {
- super(ep);
- }
-
- public CommonInspectionToolWrapper(@NotNull InspectionTool tool) {
- super(tool);
- }
-
- private CommonInspectionToolWrapper(@NotNull CommonInspectionToolWrapper other) {
- super(other);
- }
-
- @NotNull
- @Override
- public CommonInspectionToolWrapper createCopy() {
- return new CommonInspectionToolWrapper(this);
- }
-
- @Override
- public void runInspection(@NotNull AnalysisScope scope, @NotNull InspectionManager manager) {
- getTool().runInspection(scope, manager);
- }
-
- @NotNull
- @Override
- public RefManager getRefManager() {
- return getTool().getRefManager();
- }
-
- @Override
- public void initialize(@NotNull GlobalInspectionContextImpl context) {
- getTool().initialize(context);
- }
-
- @NotNull
- @Override
- public JobDescriptor[] getJobDescriptors(@NotNull GlobalInspectionContext globalInspectionContext) {
- return getTool().getJobDescriptors(globalInspectionContext);
- }
-
- @Override
- public boolean isGraphNeeded() {
- return getTool().isGraphNeeded();
- }
-
- @Override
- public void updateContent() {
- getTool().updateContent();
- }
-
- @Override
- public boolean hasReportedProblems() {
- return getTool().hasReportedProblems();
- }
-
- @Override
- public Map<String, Set<RefEntity>> getContent() {
- return getTool().getContent();
- }
-
- @NotNull
- @Override
- public GlobalInspectionContextImpl getContext() {
- return getTool().getContext();
- }
-
- @NotNull
- @Override
- public HTMLComposerImpl getComposer() {
- return getTool().getComposer();
- }
-
- @Override
- public void finalCleanup() {
- getTool().finalCleanup();
- }
-
- @Override
- public void cleanup() {
- getTool().cleanup();
- }
-
- @Nullable
- @Override
- public QuickFixAction[] getQuickFixes(@NotNull RefEntity[] refElements) {
- return getTool().getQuickFixes(refElements);
- }
-
- @NotNull
- @Override
- public InspectionNode createToolNode(@NotNull InspectionRVContentProvider provider,
- @NotNull InspectionTreeNode parentNode,
- boolean showStructure) {
- return getTool().createToolNode(provider, parentNode, showStructure);
- }
-
- @Override
- @SuppressWarnings({"UnusedDeclaration"})
- @Nullable
- public IntentionAction findQuickFixes(CommonProblemDescriptor descriptor, String hint) {
- return getTool().findQuickFixes(descriptor, hint);
- }
-
- @Override
- public HighlightSeverity getCurrentSeverity(@NotNull RefElement element) {
- return getTool().getCurrentSeverity(element);
- }
-
- @NotNull
- @Override
- public FileStatus getElementStatus(RefEntity element) {
- return getTool().getElementStatus(element);
- }
-
- @Override
- public boolean isElementIgnored(RefEntity element) {
- return getTool().isElementIgnored(element);
- }
-
- @Override
- @Nullable
- public Set<RefModule> getModuleProblems() {
- return getTool().getModuleProblems();
- }
-
- @Override
- public boolean isOldProblemsIncluded() {
- return getTool().isOldProblemsIncluded();
- }
-
- @Override
- @Nullable
- public Map<String, Set<RefEntity>> getOldContent() {
- return getTool().getOldContent();
- }
-
- @Override
- public boolean queryExternalUsagesRequests(@NotNull InspectionManager manager) {
- return getTool().queryExternalUsagesRequests(manager);
- }
-
- @Override
- public void exportResults(@NotNull Element parentNode, @NotNull RefEntity refEntity) {
- getTool().exportResults(parentNode, refEntity);
- }
-
- @Override
- public void exportResults(@NotNull Element parentNode) {
- getTool().exportResults(parentNode);
- }
-
- @Override
- public void amnesty(RefEntity refEntity) {
- getTool().amnesty(refEntity);
- }
-
- @Override
- public void ignoreCurrentElement(RefEntity refElement) {
- getTool().ignoreCurrentElement(refElement);
- }
-
- @NotNull
- @Override
- public Collection<RefEntity> getIgnoredRefElements() {
- return getTool().getIgnoredRefElements();
- }
-
- @Override
- @Nullable
- public SuppressIntentionAction[] getSuppressActions() {
- return getTool().getSuppressActions();
- }
-}
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/Descriptor.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/Descriptor.java
index dac36ac..c3d4e15 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/ex/Descriptor.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/Descriptor.java
@@ -20,6 +20,7 @@
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
import com.intellij.codeInspection.InspectionProfileEntry;
import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.psi.search.scope.packageSet.NamedScope;
import org.jdom.Element;
@@ -36,7 +37,7 @@
private final HighlightDisplayKey myKey;
private Element myConfig;
- private final InspectionProfileEntry myTool;
+ private final InspectionToolWrapper myToolWrapper;
private final HighlightDisplayLevel myLevel;
private boolean myEnabled = false;
private final NamedScope myScope;
@@ -44,18 +45,18 @@
private final ScopeToolState myState;
private final InspectionProfileImpl myInspectionProfile;
- public Descriptor(@NotNull ScopeToolState state, @NotNull InspectionProfileImpl inspectionProfile) {
+ public Descriptor(@NotNull ScopeToolState state, @NotNull InspectionProfileImpl inspectionProfile, @NotNull Project project) {
myState = state;
myInspectionProfile = inspectionProfile;
- final InspectionProfileEntry tool = state.getTool();
+ InspectionToolWrapper tool = state.getTool();
myText = tool.getDisplayName();
final String[] groupPath = tool.getGroupPath();
myGroup = groupPath.length == 0 ? new String[]{InspectionProfileEntry.GENERAL_GROUP_NAME} : groupPath;
myKey = HighlightDisplayKey.find(tool.getShortName());
- myLevel = inspectionProfile.getErrorLevel(myKey, ScopeToolStateUtil.getScope(state));
- myEnabled = inspectionProfile.isToolEnabled(myKey, ScopeToolStateUtil.getScope(state));
- myTool = tool;
- myScope = ScopeToolStateUtil.getScope(state);
+ myScope = state.getScope(project);
+ myLevel = inspectionProfile.getErrorLevel(myKey, myScope, project);
+ myEnabled = inspectionProfile.isToolEnabled(myKey, myScope, project);
+ myToolWrapper = tool;
}
public boolean equals(Object obj) {
@@ -98,28 +99,29 @@
return myConfig;
}
- public InspectionProfileEntry getTool() {
- return myTool;
+ @NotNull
+ public InspectionToolWrapper getToolWrapper() {
+ return myToolWrapper;
}
@Nullable
public String loadDescription() {
if (myConfig == null) {
- myConfig = createConfigElement(getTool());
+ InspectionToolWrapper toolWrapper = getToolWrapper();
+ myConfig = createConfigElement(toolWrapper);
}
- if (!(myTool instanceof InspectionTool)) return null;
- return myTool.loadDescription();
+ return myToolWrapper.loadDescription();
}
public InspectionProfileImpl getInspectionProfile() {
return myInspectionProfile;
}
- public static Element createConfigElement(InspectionProfileEntry tool) {
+ public static Element createConfigElement(InspectionToolWrapper toolWrapper) {
Element element = new Element("options");
try {
- tool.writeSettings(element);
+ toolWrapper.getTool().writeSettings(element);
}
catch (WriteExternalException e) {
LOG.error(e);
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/DescriptorComposer.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/DescriptorComposer.java
index 24db7c5..6269c06 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/ex/DescriptorComposer.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/DescriptorComposer.java
@@ -19,6 +19,7 @@
import com.intellij.codeInspection.*;
import com.intellij.codeInspection.reference.RefElement;
import com.intellij.codeInspection.reference.RefEntity;
+import com.intellij.codeInspection.ui.InspectionToolPresentation;
import com.intellij.injected.editor.VirtualFileWindow;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
@@ -38,9 +39,9 @@
*/
public class DescriptorComposer extends HTMLComposerImpl {
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.ex.DescriptorComposer");
- private final DescriptorProviderInspection myTool;
+ private final InspectionToolPresentation myTool;
- public DescriptorComposer(DescriptorProviderInspection tool) {
+ public DescriptorComposer(@NotNull InspectionToolPresentation tool) {
myTool = tool;
}
@@ -72,14 +73,13 @@
}
}
- public static String[] quickFixTexts(RefEntity where, InspectionTool tool){
- QuickFixAction[] quickFixes = tool.getQuickFixes(new RefEntity[] {where});
+ public static String[] quickFixTexts(RefEntity where, @NotNull InspectionToolPresentation toolPresentation){
+ QuickFixAction[] quickFixes = toolPresentation.getQuickFixes(new RefEntity[] {where});
if (quickFixes == null) {
return null;
}
List<String> texts = new ArrayList<String>();
- for (int i = 0; i < quickFixes.length; i++) {
- QuickFixAction quickFix = quickFixes[i];
+ for (QuickFixAction quickFix : quickFixes) {
final String text = quickFix.getText(where);
if (text == null) continue;
texts.add(text);
@@ -143,7 +143,7 @@
protected void composeDescription(@NotNull CommonProblemDescriptor description, int i, @NotNull StringBuffer buf, @NotNull RefEntity refElement) {
PsiElement expression = description instanceof ProblemDescriptor ? ((ProblemDescriptor)description).getPsiElement() : null;
- StringBuffer anchor = new StringBuffer();
+ StringBuilder anchor = new StringBuilder();
VirtualFile vFile = null;
if (expression != null) {
@@ -156,7 +156,8 @@
if (myExporter == null){
//noinspection HardCodedStringLiteral
anchor.append(new URL(vFile.getUrl() + "#descr:" + i));
- } else {
+ }
+ else {
anchor.append(myExporter.getURL(refElement));
}
}
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/DisableInspectionToolAction.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/DisableInspectionToolAction.java
index 5fecc27..bbb1784 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/ex/DisableInspectionToolAction.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/DisableInspectionToolAction.java
@@ -63,8 +63,8 @@
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
final InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(project);
InspectionProfile inspectionProfile = profileManager.getInspectionProfile();
- InspectionProfileEntry tool = inspectionProfile.getInspectionTool(myToolId);
- return tool == null || tool.getDefaultLevel() != HighlightDisplayLevel.NON_SWITCHABLE_ERROR;
+ InspectionToolWrapper toolWrapper = inspectionProfile.getInspectionTool(myToolId, project);
+ return toolWrapper == null || toolWrapper.getDefaultLevel() != HighlightDisplayLevel.NON_SWITCHABLE_ERROR;
}
@Override
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/EditInspectionToolsSettingsInSuppressedPlaceIntention.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/EditInspectionToolsSettingsInSuppressedPlaceIntention.java
index 4689492..70e452b 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/ex/EditInspectionToolsSettingsInSuppressedPlaceIntention.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/EditInspectionToolsSettingsInSuppressedPlaceIntention.java
@@ -17,7 +17,6 @@
package com.intellij.codeInspection.ex;
import com.intellij.codeInsight.intention.IntentionAction;
-import com.intellij.codeInspection.InspectionProfileEntry;
import com.intellij.codeInspection.InspectionsBundle;
import com.intellij.codeInspection.lang.InspectionExtensionsFactory;
import com.intellij.openapi.editor.Editor;
@@ -83,15 +82,15 @@
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
myId = getSuppressedId(editor, file);
if (myId != null) {
- InspectionProfileEntry tool = getTool(project, file);
- if (tool == null) return false;
- myDisplayName = tool.getDisplayName();
+ InspectionToolWrapper toolWrapper = getTool(project, file);
+ if (toolWrapper == null) return false;
+ myDisplayName = toolWrapper.getDisplayName();
}
return myId != null;
}
@Nullable
- private InspectionProfileEntry getTool(final Project project, final PsiFile file) {
+ private InspectionToolWrapper getTool(final Project project, final PsiFile file) {
final InspectionProjectProfileManager projectProfileManager = InspectionProjectProfileManager.getInstance(project);
final InspectionProfileImpl inspectionProfile = (InspectionProfileImpl)projectProfileManager.getInspectionProfile();
return inspectionProfile.getToolById(myId, file);
@@ -99,11 +98,11 @@
@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
- InspectionProfileEntry tool = getTool(project, file);
- if (tool == null) return;
+ InspectionToolWrapper toolWrapper = getTool(project, file);
+ if (toolWrapper == null) return;
final InspectionProjectProfileManager projectProfileManager = InspectionProjectProfileManager.getInstance(project);
final InspectionProfileImpl inspectionProfile = (InspectionProfileImpl)projectProfileManager.getInspectionProfile();
- EditInspectionToolsSettingsAction.editToolSettings(project, inspectionProfile, false, tool.getShortName());
+ EditInspectionToolsSettingsAction.editToolSettings(project, inspectionProfile, false, toolWrapper.getShortName());
}
@Override
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java
index f6cc6d3..badab00 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java
@@ -24,7 +24,9 @@
import com.intellij.codeInspection.lang.GlobalInspectionContextExtension;
import com.intellij.codeInspection.lang.InspectionExtensionsFactory;
import com.intellij.codeInspection.reference.*;
+import com.intellij.codeInspection.ui.DefaultInspectionToolPresentation;
import com.intellij.codeInspection.ui.InspectionResultsView;
+import com.intellij.codeInspection.ui.InspectionToolPresentation;
import com.intellij.concurrency.JobLauncher;
import com.intellij.lang.annotation.ProblemGroup;
import com.intellij.lang.injection.InjectedLanguageManager;
@@ -40,7 +42,7 @@
import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.IndexNotReadyException;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.project.ProjectUtil;
+import com.intellij.openapi.project.ProjectUtilCore;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.util.*;
import com.intellij.openapi.util.io.FileUtil;
@@ -79,14 +81,14 @@
public class GlobalInspectionContextImpl extends UserDataHolderBase implements GlobalInspectionContext {
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.ex.GlobalInspectionContextImpl");
- private static final TObjectHashingStrategy<ToolsImpl> TOOLS_HASHING_STRATEGY = new TObjectHashingStrategy<ToolsImpl>() {
+ private static final TObjectHashingStrategy<Tools> TOOLS_HASHING_STRATEGY = new TObjectHashingStrategy<Tools>() {
@Override
- public int computeHashCode(ToolsImpl object) {
+ public int computeHashCode(Tools object) {
return object.getShortName().hashCode();
}
@Override
- public boolean equals(ToolsImpl o1, ToolsImpl o2) {
+ public boolean equals(Tools o1, Tools o2) {
return o1.getShortName().equals(o2.getShortName());
}
};
@@ -102,22 +104,21 @@
private Content myContent = null;
- private ProgressIndicator myProgressIndicator;
private final StdJobDescriptors myStdJobDescriptors = new StdJobDescriptors();
+ private ProgressIndicator myProgressIndicator;
private InspectionProfile myExternalProfile = null;
private final Map<Key, GlobalInspectionContextExtension> myExtensions = new HashMap<Key, GlobalInspectionContextExtension>();
- private boolean RUN_GLOBAL_TOOLS_ONLY = false;
private final Map<String, Tools> myTools = new THashMap<String, Tools>();
private AnalysisUIOptions myUIOptions;
- @NonNls static final String LOCAL_TOOL_ATTRIBUTE = "is_local_tool";
+ @NonNls public static final String LOCAL_TOOL_ATTRIBUTE = "is_local_tool";
private boolean myUseProgressIndicatorInTests = false;
- public GlobalInspectionContextImpl(Project project, NotNullLazyValue<ContentManager> contentManager) {
+ public GlobalInspectionContextImpl(@NotNull Project project, @NotNull NotNullLazyValue<ContentManager> contentManager) {
myProject = project;
myUIOptions = AnalysisUIOptions.getInstance(myProject).copy();
@@ -149,13 +150,14 @@
if (myExternalProfile != null) return myExternalProfile;
InspectionManagerEx managerEx = (InspectionManagerEx)InspectionManager.getInstance(myProject);
final InspectionProjectProfileManager inspectionProfileManager = InspectionProjectProfileManager.getInstance(myProject);
- Profile profile = inspectionProfileManager.getProfile(managerEx.getCurrentProfile(), false);
+ String currentProfile = managerEx.getCurrentProfile();
+ Profile profile = inspectionProfileManager.getProfile(currentProfile, false);
if (profile == null) {
- profile = InspectionProfileManager.getInstance().getProfile(managerEx.getCurrentProfile());
+ profile = InspectionProfileManager.getInstance().getProfile(currentProfile);
if (profile != null) return (InspectionProfile)profile;
final String[] availableProfileNames = inspectionProfileManager.getAvailableProfileNames();
- if (availableProfileNames == null || availableProfileNames.length == 0) {
+ if (availableProfileNames.length == 0) {
//can't be
return null;
}
@@ -184,7 +186,7 @@
for (ScopeToolState state : tools.getTools()) {
final NamedScope namedScope = state.getScope(project);
if (namedScope == null || namedScope.getValue().contains(file, getCurrentProfile().getProfileManager().getScopesManager())) {
- return state.isEnabled() && ((InspectionToolWrapper)state.getTool()).getTool() == tool;
+ return state.isEnabled() && state.getTool().getTool() == tool;
}
}
}
@@ -204,7 +206,7 @@
}
- public synchronized void addView(InspectionResultsView view, String title) {
+ public synchronized void addView(@NotNull InspectionResultsView view, String title) {
if (myContent != null) return;
myContentManager.getValue().addContentManagerListener(new ContentManagerAdapter() {
@Override
@@ -230,14 +232,14 @@
ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.INSPECTION).activate(null);
}
- protected void addView(InspectionResultsView view) {
+ public void addView(@NotNull InspectionResultsView view) {
addView(view, view.getCurrentProfileName() == null
? InspectionsBundle.message("inspection.results.title")
: InspectionsBundle.message("inspection.results.for.profile.toolwindow.title", view.getCurrentProfileName()));
}
- private void cleanup() {
+ private void cleanupTools() {
myProgressIndicator = null;
for (GlobalInspectionContextExtension extension : myExtensions.values()) {
@@ -246,7 +248,8 @@
for (Tools tools : myTools.values()) {
for (ScopeToolState state : tools.getTools()) {
- ((InspectionTool)state.getTool()).cleanup();
+ InspectionToolWrapper toolWrapper = state.getTool();
+ toolWrapper.cleanup();
}
}
myTools.clear();
@@ -263,14 +266,14 @@
}
}
- public void setCurrentScope(AnalysisScope currentScope) {
+ public void setCurrentScope(@NotNull AnalysisScope currentScope) {
myCurrentScope = currentScope;
}
- public void doInspections(@NotNull final AnalysisScope scope, @NotNull final InspectionManager manager) {
+ public void doInspections(@NotNull final AnalysisScope scope) {
if (!InspectionManagerEx.canRunInspections(myProject, true)) return;
- cleanup();
+ cleanupTools();
if (myContent != null) {
getContentManager().removeContent(myContent, true);
}
@@ -279,7 +282,7 @@
@Override
public void run() {
myCurrentScope = scope;
- launchInspections(scope, manager);
+ launchInspections(scope);
}
};
@@ -309,20 +312,16 @@
public void launchInspectionsOffline(final AnalysisScope scope,
@Nullable final String outputPath,
final boolean runGlobalToolsOnly,
- final InspectionManager manager,
@NotNull final List<File> inspectionsResults) {
- cleanup();
-
+ cleanupTools();
myCurrentScope = scope;
- InspectionTool.setOutputPath(outputPath);
- final boolean oldToolsSettings = RUN_GLOBAL_TOOLS_ONLY;
- RUN_GLOBAL_TOOLS_ONLY = runGlobalToolsOnly;
+ DefaultInspectionToolPresentation.setOutputPath(outputPath);
try {
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
- performInspectionsWithProgress(scope, manager);
+ performInspectionsWithProgress(scope, runGlobalToolsOnly);
@NonNls final String ext = ".xml";
final Map<Element, Tools> globalTools = new HashMap<Element, Tools>();
for (Map.Entry<String,Tools> stringSetEntry : myTools.entrySet()) {
@@ -331,13 +330,14 @@
String toolName = stringSetEntry.getKey();
if (sameTools != null) {
for (ScopeToolState toolDescr : sameTools.getTools()) {
- final InspectionTool tool = (InspectionTool)toolDescr.getTool();
- if (tool instanceof LocalInspectionToolWrapper) {
+ InspectionToolWrapper toolWrapper = toolDescr.getTool();
+ if (toolWrapper instanceof LocalInspectionToolWrapper) {
hasProblems = new File(outputPath, toolName + ext).exists();
}
else {
- tool.updateContent();
- if (tool.hasReportedProblems()) {
+ InspectionToolPresentation presentation = getPresentation(toolWrapper);
+ presentation.updateContent();
+ if (presentation.hasReportedProblems()) {
final Element root = new Element(InspectionsBundle.message("inspection.problems"));
globalTools.put(root, sameTools);
LOG.assertTrue(!hasProblems, toolName);
@@ -365,7 +365,9 @@
final Tools tools = globalTools.get(element);
for (ScopeToolState state : tools.getTools()) {
try {
- ((InspectionTool)state.getTool()).exportResults(element, refEntity);
+ InspectionToolWrapper toolWrapper = state.getTool();
+ InspectionToolPresentation presentation = getPresentation(toolWrapper);
+ presentation.exportResults(element, refEntity);
}
catch (Exception e) {
LOG.error("Problem when exporting: " + refEntity.getExternalName(), e);
@@ -401,28 +403,24 @@
});
}
finally {
- InspectionTool.setOutputPath(null);
- RUN_GLOBAL_TOOLS_ONLY = oldToolsSettings;
+ DefaultInspectionToolPresentation.setOutputPath(null);
}
}
- public boolean isToCheckMember(@NotNull RefElement owner, InspectionProfileEntry tool) {
+ public boolean isToCheckMember(@NotNull RefElement owner, @NotNull InspectionProfileEntry tool) {
return isToCheckFile(((RefElementImpl)owner).getContainingFile(), tool) && !((RefElementImpl)owner).isSuppressed(tool.getShortName());
}
- public boolean isToCheckFile(PsiFile file, final InspectionProfileEntry tool) {
+ public boolean isToCheckFile(PsiFile file, @NotNull InspectionProfileEntry tool) {
final Tools tools = myTools.get(tool.getShortName());
if (tools != null && file != null) {
for (ScopeToolState state : tools.getTools()) {
final NamedScope namedScope = state.getScope(file.getProject());
if (namedScope == null || namedScope.getValue().contains(file, getCurrentProfile().getProfileManager().getScopesManager())) {
if (state.isEnabled()) {
- final InspectionProfileEntry entry = state.getTool();
- if (entry instanceof InspectionToolWrapper && ((InspectionToolWrapper)entry).getTool() == tool) return true;
- if (entry == tool) {
- return true;
- }
+ InspectionToolWrapper toolWrapper = state.getTool();
+ if (toolWrapper.getTool() == tool) return true;
}
return false;
}
@@ -431,12 +429,13 @@
return false;
}
- public void ignoreElement(final InspectionTool tool, final PsiElement element) {
+ public void ignoreElement(@NotNull InspectionProfileEntry tool, final PsiElement element) {
final RefElement refElement = getRefManager().getReference(element);
final Tools tools = myTools.get(tool.getShortName());
if (tools != null){
for (ScopeToolState state : tools.getTools()) {
- ignoreElementRecursively((InspectionTool)state.getTool(), refElement);
+ InspectionToolWrapper toolWrapper = state.getTool();
+ ignoreElementRecursively(toolWrapper, refElement);
}
}
}
@@ -445,13 +444,14 @@
return myView;
}
- private static void ignoreElementRecursively(final InspectionTool tool, final RefEntity refElement) {
+ private void ignoreElementRecursively(@NotNull InspectionToolWrapper toolWrapper, final RefEntity refElement) {
if (refElement != null) {
- tool.ignoreCurrentElement(refElement);
+ InspectionToolPresentation presentation = getPresentation(toolWrapper);
+ presentation.ignoreCurrentElement(refElement);
final List<RefEntity> children = refElement.getChildren();
if (children != null) {
for (RefEntity child : children) {
- ignoreElementRecursively(tool, child);
+ ignoreElementRecursively(toolWrapper, child);
}
}
}
@@ -469,7 +469,7 @@
return myUIOptions.getAutoScrollToSourceHandler().createToggleAction();
}
- private void launchInspections(final AnalysisScope scope, final InspectionManager manager) {
+ private void launchInspections(@NotNull final AnalysisScope scope) {
myUIOptions = AnalysisUIOptions.getInstance(myProject).copy();
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
@@ -479,33 +479,38 @@
new PerformAnalysisInBackgroundOption(myProject)) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
- performInspectionsWithProgress(scope, manager);
+ performInspectionsWithProgress(scope, false);
}
@Override
public void onSuccess() {
- UIUtil.invokeLaterIfNeeded(new Runnable() {
- @Override
- public void run() {
- LOG.info("Code inspection finished");
-
- if (myView != null) {
- if (!myView.update() && !getUIOptions().SHOW_ONLY_DIFF) {
- NotificationGroup.toolWindowGroup("Inspection Results", ToolWindowId.INSPECTION, true)
- .createNotification(InspectionsBundle.message("inspection.no.problems.message"), MessageType.INFO).notify(myProject);
- close(true);
- }
- else {
- addView(myView);
- }
- }
- }
- });
+ notifyInspectionsFinished();
}
});
}
- public void performInspectionsWithProgress(@NotNull final AnalysisScope scope, @NotNull final InspectionManager manager) {
+ private void notifyInspectionsFinished() {
+ if (ApplicationManager.getApplication().isUnitTestMode()) return;
+ UIUtil.invokeLaterIfNeeded(new Runnable() {
+ @Override
+ public void run() {
+ LOG.info("Code inspection finished");
+
+ if (myView != null) {
+ if (!myView.update() && !getUIOptions().SHOW_ONLY_DIFF) {
+ NotificationGroup.toolWindowGroup("Inspection Results", ToolWindowId.INSPECTION, true)
+ .createNotification(InspectionsBundle.message("inspection.no.problems.message"), MessageType.INFO).notify(myProject);
+ close(true);
+ }
+ else {
+ addView(myView);
+ }
+ }
+ }
+ });
+ }
+
+ private void performInspectionsWithProgress(@NotNull final AnalysisScope scope, final boolean runGlobalToolsOnly) {
final PsiManager psiManager = PsiManager.getInstance(myProject);
myProgressIndicator = getProgressIndicator();
//init manager in read action
@@ -520,16 +525,16 @@
((ProgressManagerImpl)ProgressManager.getInstance()).executeProcessUnderProgress(new Runnable() {
@Override
public void run() {
- runTools(scope, manager);
+ runTools(scope, runGlobalToolsOnly);
}
}, ProgressWrapper.wrap(myProgressIndicator));
}
catch (ProcessCanceledException e) {
- cleanup((InspectionManagerEx)manager);
+ cleanup();
throw e;
}
catch (IndexNotReadyException e) {
- cleanup((InspectionManagerEx)manager);
+ cleanup();
DumbService.getInstance(myProject).showDumbModeNotification("Usage search is not available until indices are ready");
throw new ProcessCanceledException();
}
@@ -552,23 +557,27 @@
myUseProgressIndicatorInTests = useProgressIndicatorInTests;
}
- private void runTools(@NotNull AnalysisScope scope, @NotNull final InspectionManager manager) {
- final List<Tools> globalTools = new ArrayList<Tools>();
+ private void runTools(@NotNull AnalysisScope scope, boolean runGlobalToolsOnly) {
+ final InspectionManagerEx inspectionManager = (InspectionManagerEx)InspectionManager.getInstance(myProject);
+ List<Tools> globalTools = new ArrayList<Tools>();
final List<Tools> localTools = new ArrayList<Tools>();
final List<Tools> globalSimpleTools = new ArrayList<Tools>();
initializeTools(globalTools, localTools, globalSimpleTools);
- final List<InspectionProfileEntry> needRepeatSearchRequest = new ArrayList<InspectionProfileEntry>();
+ final List<InspectionToolWrapper> needRepeatSearchRequest = new ArrayList<InspectionToolWrapper>();
((RefManagerImpl)getRefManager()).initializeAnnotators();
+
for (Tools tools : globalTools) {
for (ScopeToolState state : tools.getTools()) {
- final InspectionTool tool = (InspectionTool)state.getTool();
+ InspectionToolWrapper toolWrapper = state.getTool();
+ GlobalInspectionTool tool = (GlobalInspectionTool)toolWrapper.getTool();
+ InspectionToolPresentation toolPresentation = getPresentation(toolWrapper);
try {
if (tool.isGraphNeeded()) {
((RefManagerImpl)getRefManager()).findAllDeclarations();
}
- tool.runInspection(scope, manager);
- if (tool.queryExternalUsagesRequests(manager)) {
- needRepeatSearchRequest.add(tool);
+ tool.runInspection(scope, inspectionManager, this, toolPresentation);
+ if (tool.queryExternalUsagesRequests(inspectionManager, this, toolPresentation)) {
+ needRepeatSearchRequest.add(toolWrapper);
}
}
catch (ProcessCanceledException e) {
@@ -596,23 +605,24 @@
LOG.error(e);
}
}
- if (RUN_GLOBAL_TOOLS_ONLY) return;
+ if (runGlobalToolsOnly) return;
final PsiManager psiManager = PsiManager.getInstance(myProject);
final Set<VirtualFile> localScopeFiles = scope.toSearchScope() instanceof LocalSearchScope ? new THashSet<VirtualFile>() : null;
for (Tools tools : globalSimpleTools) {
GlobalInspectionToolWrapper toolWrapper = (GlobalInspectionToolWrapper)tools.getTool();
GlobalSimpleInspectionTool tool = (GlobalSimpleInspectionTool)toolWrapper.getTool();
- tool.inspectionStarted(manager, this, toolWrapper);
+ tool.inspectionStarted(inspectionManager, this, getPresentation(toolWrapper));
}
- final Map<String, DescriptorProviderInspection> map = getInspectionWrappersMap(localTools);
+ final Map<String, InspectionToolWrapper> map = getInspectionWrappersMap(localTools);
scope.accept(new PsiElementVisitor() {
@Override
public void visitFile(final PsiFile file) {
final VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile != null) {
- incrementJobDoneAmount(getStdJobDescriptors().LOCAL_ANALYSIS, ProjectUtil.calcRelativeToProjectPath(virtualFile, myProject));
+ incrementJobDoneAmount(getStdJobDescriptors().LOCAL_ANALYSIS, ProjectUtilCore.displayUrlRelativeToProject(virtualFile, virtualFile
+ .getPresentableUrl(), myProject, true, false));
if (SingleRootFileViewProvider.isTooLargeForIntelligence(virtualFile)) return;
if (localScopeFiles != null && !localScopeFiles.add(virtualFile)) return;
}
@@ -630,18 +640,19 @@
lTools.add(enabledTool);
}
}
- pass.doInspectInBatch((InspectionManagerEx)manager, lTools);
+ pass.doInspectInBatch(inspectionManager, lTools);
JobLauncher.getInstance().invokeConcurrentlyUnderProgress(globalSimpleTools, myProgressIndicator, false, new Processor<Tools>() {
@Override
public boolean process(Tools tools) {
GlobalInspectionToolWrapper toolWrapper = (GlobalInspectionToolWrapper)tools.getTool();
GlobalSimpleInspectionTool tool = (GlobalSimpleInspectionTool)toolWrapper.getTool();
- ProblemsHolder problemsHolder = new ProblemsHolder(manager, file, false);
- GlobalInspectionToolWrapper problemDescriptionProcessor = getProblemDescriptionProcessor(toolWrapper, map);
- tool.checkFile(file, manager, problemsHolder, GlobalInspectionContextImpl.this, problemDescriptionProcessor);
- LocalInspectionToolWrapper.addProblemDescriptors(problemsHolder.getResults(), false, GlobalInspectionContextImpl.this, null,
- CONVERT, toolWrapper);
+ ProblemsHolder problemsHolder = new ProblemsHolder(inspectionManager, file, false);
+ ProblemDescriptionsProcessor problemDescriptionProcessor = getProblemDescriptionProcessor(toolWrapper, map);
+ tool.checkFile(file, inspectionManager, problemsHolder, GlobalInspectionContextImpl.this, problemDescriptionProcessor);
+ InspectionToolPresentation toolPresentation = getPresentation(toolWrapper);
+ LocalDescriptorsUtil.addProblemDescriptors(problemsHolder.getResults(), false, GlobalInspectionContextImpl.this, null,
+ CONVERT, toolPresentation);
return true;
}
});
@@ -666,49 +677,58 @@
for (Tools tools : globalSimpleTools) {
GlobalInspectionToolWrapper toolWrapper = (GlobalInspectionToolWrapper)tools.getTool();
GlobalSimpleInspectionTool tool = (GlobalSimpleInspectionTool)toolWrapper.getTool();
- GlobalInspectionToolWrapper problemDescriptionProcessor = getProblemDescriptionProcessor(toolWrapper, map);
- tool.inspectionFinished(manager, this, problemDescriptionProcessor);
+ ProblemDescriptionsProcessor problemDescriptionProcessor = getProblemDescriptionProcessor(toolWrapper, map);
+ tool.inspectionFinished(inspectionManager, this, problemDescriptionProcessor);
}
}
- private static GlobalInspectionToolWrapper getProblemDescriptionProcessor(@NotNull final GlobalInspectionToolWrapper toolWrapper,
- final Map<String, DescriptorProviderInspection> wrappersMap) {
-
- return new GlobalInspectionToolWrapper(toolWrapper.getTool()) {
+ @NotNull
+ private ProblemDescriptionsProcessor getProblemDescriptionProcessor(@NotNull final GlobalInspectionToolWrapper toolWrapper,
+ @NotNull final Map<String, InspectionToolWrapper> wrappersMap) {
+ return new ProblemDescriptionsProcessor() {
+ @Nullable
@Override
- public void addProblemElement(RefEntity refEntity, @NotNull CommonProblemDescriptor... commonProblemDescriptors) {
+ public CommonProblemDescriptor[] getDescriptions(@NotNull RefEntity refEntity) {
+ return new CommonProblemDescriptor[0];
+ }
+
+ @Override
+ public void ignoreElement(@NotNull RefEntity refEntity) {
+
+ }
+
+ @Override
+ public void addProblemElement(@Nullable RefEntity refEntity, @NotNull CommonProblemDescriptor... commonProblemDescriptors) {
for (CommonProblemDescriptor problemDescriptor : commonProblemDescriptors) {
- if (problemDescriptor instanceof ProblemDescriptor) {
- ProblemGroup problemGroup = ((ProblemDescriptor)problemDescriptor).getProblemGroup();
+ if (!(problemDescriptor instanceof ProblemDescriptor)) {
+ continue;
+ }
+ ProblemGroup problemGroup = ((ProblemDescriptor)problemDescriptor).getProblemGroup();
- if (problemGroup != null) {
- DescriptorProviderInspection dummyWrapper = wrappersMap.get(problemGroup.getProblemName());
-
- if (dummyWrapper != null) { // Else it's switched off
- dummyWrapper.addProblemElement(refEntity, problemDescriptor);
- }
- }
- else {
- toolWrapper.addProblemElement(refEntity, problemDescriptor);
- }
+ InspectionToolWrapper targetWrapper = problemGroup == null ? toolWrapper : wrappersMap.get(problemGroup.getProblemName());
+ if (targetWrapper != null) { // Else it's switched off
+ InspectionToolPresentation toolPresentation = getPresentation(targetWrapper);
+ toolPresentation.addProblemElement(refEntity, problemDescriptor);
}
}
}
+
+ @Override
+ public RefEntity getElement(@NotNull CommonProblemDescriptor descriptor) {
+ return null;
+ }
};
}
@NotNull
- private static Map<String, DescriptorProviderInspection> getInspectionWrappersMap(List<Tools> tools) {
-
- Map<String, DescriptorProviderInspection> toolWrappers = new HashMap<String, DescriptorProviderInspection>(tools.size());
+ private static Map<String, InspectionToolWrapper> getInspectionWrappersMap(@NotNull List<Tools> tools) {
+ Map<String, InspectionToolWrapper> name2Inspection = new HashMap<String, InspectionToolWrapper>(tools.size());
for (Tools tool : tools) {
- InspectionProfileEntry profileEntry = tool.getTool();
- if (profileEntry instanceof DescriptorProviderInspection) {
- toolWrappers.put(profileEntry.getShortName(), (DescriptorProviderInspection)profileEntry);
- }
+ InspectionToolWrapper toolWrapper = tool.getTool();
+ name2Inspection.put(toolWrapper.getShortName(), toolWrapper);
}
- return toolWrappers;
+ return name2Inspection;
}
private static final TripleFunction<LocalInspectionTool,PsiElement,GlobalInspectionContext,RefElement> CONVERT =
@@ -732,15 +752,20 @@
@NotNull List<Tools> outLocalTools,
@NotNull List<Tools> outGlobalSimpleTools) {
myJobDescriptors = new ArrayList<JobDescriptor>();
- final List<ToolsImpl> usedTools = getUsedTools();
+ final List<Tools> usedTools = getUsedTools();
for (Tools currentTools : usedTools) {
final String shortName = currentTools.getShortName();
myTools.put(shortName, currentTools);
- final InspectionTool tool = (InspectionTool)currentTools.getTool();
- classifyTool(outGlobalTools, outLocalTools, outGlobalSimpleTools, currentTools, tool);
+ InspectionToolWrapper toolWrapper = currentTools.getTool();
+ classifyTool(outGlobalTools, outLocalTools, outGlobalSimpleTools, currentTools, toolWrapper);
for (ScopeToolState state : currentTools.getTools()) {
- ((InspectionTool)state.getTool()).initialize(this);
+ state.getTool().initialize(this);
+ }
+
+ JobDescriptor[] jobDescriptors = toolWrapper.getJobDescriptors(this);
+ for (JobDescriptor jobDescriptor : jobDescriptors) {
+ appendJobDescriptor(jobDescriptor);
}
}
for (GlobalInspectionContextExtension extension : myExtensions.values()) {
@@ -748,46 +773,48 @@
}
}
- protected List<ToolsImpl> getUsedTools() {
+ protected List<Tools> getUsedTools() {
InspectionProfileImpl profile = new InspectionProfileImpl((InspectionProfileImpl)getCurrentProfile());
- List<ToolsImpl> tools = profile.getAllEnabledInspectionTools(myProject);
- Set<InspectionProfileEntry> dependentTools = new LinkedHashSet<InspectionProfileEntry>();
- for (ToolsImpl tool : tools) {
- profile.collectDependentInspections(tool.getTool(), dependentTools);
+ List<Tools> tools = profile.getAllEnabledInspectionTools(myProject);
+ Set<InspectionToolWrapper> dependentTools = new LinkedHashSet<InspectionToolWrapper>();
+ for (Tools tool : tools) {
+ profile.collectDependentInspections(tool.getTool(), dependentTools, getProject());
}
- if (!dependentTools.isEmpty()) {
- THashSet<ToolsImpl> set = new THashSet<ToolsImpl>(tools, TOOLS_HASHING_STRATEGY);
- set.addAll(ContainerUtil.map(dependentTools, new Function<InspectionProfileEntry, ToolsImpl>() {
- @Override
- public ToolsImpl fun(InspectionProfileEntry entry) {
- return new ToolsImpl(entry, entry.getDefaultLevel(), true, true);
- }
- }));
- return new ArrayList<ToolsImpl>(set);
- }
- else {
+ if (dependentTools.isEmpty()) {
return tools;
}
+ Set<Tools> set = new THashSet<Tools>(tools, TOOLS_HASHING_STRATEGY);
+ set.addAll(ContainerUtil.map(dependentTools, new Function<InspectionToolWrapper, ToolsImpl>() {
+ @Override
+ public ToolsImpl fun(InspectionToolWrapper toolWrapper) {
+ return new ToolsImpl(toolWrapper, toolWrapper.getDefaultLevel(), true, true);
+ }
+ }));
+ return new ArrayList<Tools>(set);
}
- private void classifyTool(List<Tools> outGlobalTools,
- List<Tools> outLocalTools,
- List<Tools> outGlobalSimpleTools,
- Tools currentTools,
- InspectionTool tool) {
- if (tool instanceof LocalInspectionToolWrapper) {
+ private static void classifyTool(@NotNull List<Tools> outGlobalTools,
+ @NotNull List<Tools> outLocalTools,
+ @NotNull List<Tools> outGlobalSimpleTools,
+ @NotNull Tools currentTools,
+ @NotNull InspectionToolWrapper toolWrapper) {
+ if (toolWrapper instanceof LocalInspectionToolWrapper) {
outLocalTools.add(currentTools);
}
- else if (tool instanceof GlobalInspectionToolWrapper && ((GlobalInspectionToolWrapper)tool).getTool() instanceof GlobalSimpleInspectionTool) {
- outGlobalSimpleTools.add(currentTools);
+ else if (toolWrapper instanceof GlobalInspectionToolWrapper) {
+ if (toolWrapper.getTool() instanceof GlobalSimpleInspectionTool) {
+ outGlobalSimpleTools.add(currentTools);
+ }
+ else if (toolWrapper.getTool() instanceof GlobalInspectionTool) {
+ outGlobalTools.add(currentTools);
+ }
+ else {
+ throw new RuntimeException("unknown global tool " + toolWrapper);
+ }
}
else {
- outGlobalTools.add(currentTools);
- }
- JobDescriptor[] jobDescriptors = tool.getJobDescriptors(this);
- for (JobDescriptor jobDescriptor : jobDescriptors) {
- appendJobDescriptor(jobDescriptor);
+ throw new RuntimeException("unknown tool " + toolWrapper);
}
}
@@ -804,8 +831,7 @@
public void close(boolean noSuspisiousCodeFound) {
if (!noSuspisiousCodeFound && (myView == null || myView.isRerun())) return;
- final InspectionManagerEx managerEx = (InspectionManagerEx)InspectionManager.getInstance(myProject);
- cleanup(managerEx);
+ cleanup();
AnalysisUIOptions.getInstance(myProject).save(myUIOptions);
if (myContent != null) {
final ContentManager contentManager = getContentManager();
@@ -816,14 +842,15 @@
myView = null;
}
- public void cleanup(final InspectionManagerEx managerEx) {
- managerEx.closeRunningContext(this);
+ public void cleanup() {
+ ((InspectionManagerEx)InspectionManager.getInstance(getProject())).closeRunningContext(this);
for (Tools tools : myTools.values()) {
for (ScopeToolState state : tools.getTools()) {
- ((InspectionTool)state.getTool()).finalCleanup();
+ InspectionToolWrapper toolWrapper = state.getTool();
+ getPresentation(toolWrapper).finalCleanup();
}
}
- cleanup();
+ cleanupTools();
}
public void refreshViews() {
@@ -848,23 +875,40 @@
}
private float getTotalProgress() {
- float totalProgress = 0;
- int liveDescriptors = 0;
+ float totalDone = 0;
+ int totalTotal = 0;
for (JobDescriptor jobDescriptor : myJobDescriptors) {
- totalProgress += jobDescriptor.getProgress();
- liveDescriptors += jobDescriptor.getTotalAmount() == 0 ? 0 : 1;
+ totalDone += jobDescriptor.getDoneAmount();
+ totalTotal += jobDescriptor.getTotalAmount();
}
-
- return totalProgress / liveDescriptors;
+ return totalTotal == 0 ? 1 : totalDone / totalTotal;
}
public void setExternalProfile(InspectionProfile profile) {
myExternalProfile = profile;
}
- @NotNull
@Override
+ @NotNull
public StdJobDescriptors getStdJobDescriptors() {
return myStdJobDescriptors;
}
+
+ private final Map<InspectionToolWrapper, InspectionToolPresentation> myPresentationMap = new THashMap<InspectionToolWrapper, InspectionToolPresentation>();
+ @NotNull
+ public InspectionToolPresentation getPresentation(@NotNull InspectionToolWrapper toolWrapper) {
+ InspectionToolPresentation presentation = myPresentationMap.get(toolWrapper);
+ if (presentation == null) {
+ InspectionProfileEntry tool = toolWrapper.getTool();
+ if (tool instanceof InspectionPresentationProvider) {
+ presentation = ((InspectionPresentationProvider)tool).createPresentation(toolWrapper);
+ }
+ else {
+ presentation = new DefaultInspectionToolPresentation(toolWrapper);
+ }
+ presentation.initialize(this);
+ myPresentationMap.put(toolWrapper, presentation);
+ }
+ return presentation;
+ }
}
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionToolWrapper.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionToolWrapper.java
deleted file mode 100644
index 66aefd3..0000000
--- a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionToolWrapper.java
+++ /dev/null
@@ -1,154 +0,0 @@
-package com.intellij.codeInspection.ex;
-
-import com.intellij.analysis.AnalysisScope;
-import com.intellij.codeInsight.intention.IntentionAction;
-import com.intellij.codeInspection.*;
-import com.intellij.codeInspection.reference.RefEntity;
-import com.intellij.codeInspection.reference.RefGraphAnnotator;
-import com.intellij.codeInspection.reference.RefManagerImpl;
-import com.intellij.codeInspection.reference.RefVisitor;
-import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.project.Project;
-import com.intellij.psi.PsiFile;
-import com.intellij.util.ArrayUtil;
-import com.intellij.util.IncorrectOperationException;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * User: anna
- * Date: 28-Dec-2005
- */
-public class GlobalInspectionToolWrapper extends InspectionToolWrapper<GlobalInspectionTool, InspectionEP> {
-
- public GlobalInspectionToolWrapper(@NotNull GlobalInspectionTool globalInspectionTool) {
- super(globalInspectionTool);
- }
-
- public GlobalInspectionToolWrapper(InspectionEP ep) {
- super(ep);
- }
-
- private GlobalInspectionToolWrapper(GlobalInspectionToolWrapper other) {
- super(other);
- }
-
- @NotNull
- @Override
- public InspectionToolWrapper<GlobalInspectionTool, InspectionEP> createCopy() {
- return new GlobalInspectionToolWrapper(this);
- }
-
- @Override
- public void initialize(@NotNull GlobalInspectionContextImpl context) {
- super.initialize(context);
- final RefGraphAnnotator annotator = getTool().getAnnotator(getRefManager());
- if (annotator != null) {
- ((RefManagerImpl)getRefManager()).registerGraphAnnotator(annotator);
- }
- }
-
- @Override
- public void runInspection(@NotNull final AnalysisScope scope, @NotNull final InspectionManager manager) {
- getTool().runInspection(scope, manager, getContext(), this);
- }
-
- @Override
- public boolean queryExternalUsagesRequests(@NotNull final InspectionManager manager) {
- return getTool().queryExternalUsagesRequests(manager, getContext(), this);
- }
-
- @Override
- @NotNull
- public JobDescriptor[] getJobDescriptors(@NotNull GlobalInspectionContext context) {
- final JobDescriptor[] additionalJobs = getTool().getAdditionalJobs();
- if (additionalJobs == null) {
- return isGraphNeeded() ? context.getStdJobDescriptors().BUILD_GRAPH_ONLY : JobDescriptor.EMPTY_ARRAY;
- }
- else {
- return isGraphNeeded() ? ArrayUtil.append(additionalJobs, context.getStdJobDescriptors().BUILD_GRAPH) : additionalJobs;
- }
- }
-
- @Override
- public boolean isGraphNeeded() {
- return getTool().isGraphNeeded();
- }
-
- public void processFile(@NotNull final AnalysisScope analysisScope,
- @NotNull final InspectionManager manager,
- @NotNull final GlobalInspectionContext context,
- final boolean filterSuppressed) {
- context.getRefManager().iterate(new RefVisitor() {
- @Override public void visitElement(@NotNull RefEntity refEntity) {
- CommonProblemDescriptor[] descriptors = getTool()
- .checkElement(refEntity, analysisScope, manager, context, GlobalInspectionToolWrapper.this);
- if (descriptors != null) {
- addProblemElement(refEntity, filterSuppressed, descriptors);
- }
- }
- });
- }
-
- @NotNull
- @Override
- public HTMLComposerImpl getComposer() {
- return new DescriptorComposer(this) {
- @Override
- protected void composeAdditionalDescription(@NotNull final StringBuffer buf, @NotNull final RefEntity refEntity) {
- getTool().compose(buf, refEntity, this);
- }
- };
- }
-
- @Override
- @Nullable
- public IntentionAction findQuickFixes(final CommonProblemDescriptor problemDescriptor, final String hint) {
- final QuickFix fix = getTool().getQuickFix(hint);
- if (fix != null) {
- if (problemDescriptor instanceof ProblemDescriptor) {
- final ProblemDescriptor descriptor = new ProblemDescriptorImpl(((ProblemDescriptor)problemDescriptor).getStartElement(),
- ((ProblemDescriptor)problemDescriptor).getEndElement(),
- problemDescriptor.getDescriptionTemplate(),
- new LocalQuickFix[]{(LocalQuickFix)fix},
- ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false, null, false);
- return QuickFixWrapper.wrap(descriptor, 0);
- }
- else {
- return new IntentionAction() {
- @Override
- @NotNull
- public String getText() {
- return fix.getName();
- }
-
- @Override
- @NotNull
- public String getFamilyName() {
- return fix.getFamilyName();
- }
-
- @Override
- public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
- return true;
- }
-
- @Override
- public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
- fix.applyFix(project, problemDescriptor); //todo check type consistency
- }
-
- @Override
- public boolean startInWriteAction() {
- return true;
- }
- };
- }
- }
- return null;
- }
-
- public boolean worksInBatchModeOnly() {
- return getTool().worksInBatchModeOnly();
- }
-}
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionManagerEx.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionManagerEx.java
index d559e8f..ef777d2 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionManagerEx.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionManagerEx.java
@@ -27,6 +27,8 @@
import com.intellij.codeInspection.lang.InspectionExtensionsFactory;
import com.intellij.icons.AllIcons;
import com.intellij.ide.impl.ContentManagerWatcher;
+import com.intellij.ide.ui.search.SearchableOptionsRegistrar;
+import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.extensions.Extensions;
@@ -39,18 +41,24 @@
import com.intellij.openapi.wm.ToolWindowManager;
import com.intellij.profile.codeInspection.InspectionProfileManager;
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
+import com.intellij.profile.codeInspection.ui.InspectionToolsConfigurable;
import com.intellij.psi.PsiElement;
import com.intellij.ui.content.ContentFactory;
import com.intellij.ui.content.ContentManager;
import com.intellij.ui.content.TabbedPaneContentUI;
+import com.intellij.util.Function;
import com.intellij.util.IncorrectOperationException;
+import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.regex.Pattern;
public class InspectionManagerEx extends InspectionManagerBase {
private GlobalInspectionContextImpl myGlobalInspectionContext = null;
@@ -133,6 +141,23 @@
};
}
+ @Nullable
+ public static SuppressIntentionAction[] getSuppressActions(@NotNull InspectionProfileEntry tool) {
+ if (tool instanceof CustomSuppressableInspectionTool) {
+ return ((CustomSuppressableInspectionTool)tool).getSuppressActions(null);
+ }
+ if (tool instanceof BatchSuppressableTool) {
+ LocalQuickFix[] actions = ((BatchSuppressableTool)tool).getBatchSuppressActions(null);
+ return ContainerUtil.map2Array(actions, SuppressIntentionAction.class, new Function<LocalQuickFix, SuppressIntentionAction>() {
+ @Override
+ public SuppressIntentionAction fun(final LocalQuickFix fix) {
+ return convertBatchToSuppressIntentionAction((SuppressQuickFix)fix);
+ }
+ });
+ }
+ return null;
+ }
+
@NotNull
public ProblemDescriptor createProblemDescriptor(@NotNull final PsiElement psiElement,
@@ -196,7 +221,7 @@
isSuppressed(place, alternativeId);
}
- public static boolean canRunInspections(final Project project, final boolean online) {
+ public static boolean canRunInspections(@NotNull Project project, final boolean online) {
for (InspectionExtensionsFactory factory : Extensions.getExtensions(InspectionExtensionsFactory.EP_NAME)) {
if (!factory.isProjectConfiguredToRunInspections(project, online)) {
return false;
@@ -230,4 +255,41 @@
public NotNullLazyValue<ContentManager> getContentManager() {
return myContentManager;
}
+
+ private final AtomicBoolean myToolsAreInitialized = new AtomicBoolean(false);
+ private static final Pattern HTML_PATTERN = Pattern.compile("<[^<>]*>");
+ public void buildInspectionSearchIndexIfNecessary() {
+ if (!myToolsAreInitialized.getAndSet(true)) {
+ final SearchableOptionsRegistrar myOptionsRegistrar = SearchableOptionsRegistrar.getInstance();
+ final InspectionToolRegistrar toolRegistrar = InspectionToolRegistrar.getInstance();
+ final Application app = ApplicationManager.getApplication();
+ if (app.isUnitTestMode() || app.isHeadlessEnvironment()) return;
+
+ app.executeOnPooledThread(new Runnable(){
+ @Override
+ public void run() {
+ List<InspectionToolWrapper> tools = toolRegistrar.createTools();
+ for (InspectionToolWrapper toolWrapper : tools) {
+ processText(toolWrapper.getDisplayName().toLowerCase(), toolWrapper, myOptionsRegistrar);
+
+ final String description = toolWrapper.loadDescription();
+ if (description != null) {
+ @NonNls String descriptionText = HTML_PATTERN.matcher(description).replaceAll(" ");
+ processText(descriptionText, toolWrapper, myOptionsRegistrar);
+ }
+ }
+ }
+ });
+ }
+ }
+
+ private static void processText(@NotNull @NonNls String descriptionText,
+ @NotNull InspectionToolWrapper tool,
+ @NotNull SearchableOptionsRegistrar myOptionsRegistrar) {
+ if (ApplicationManager.getApplication().isDisposed()) return;
+ final Set<String> words = myOptionsRegistrar.getProcessedWordsWithoutStemming(descriptionText);
+ for (String word : words) {
+ myOptionsRegistrar.addOption(word, tool.getShortName(), tool.getDisplayName(), InspectionToolsConfigurable.ID, InspectionToolsConfigurable.DISPLAY_NAME);
+ }
+ }
}
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionPresentationProvider.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionPresentationProvider.java
new file mode 100644
index 0000000..7780470
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionPresentationProvider.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2000-2013 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.codeInspection.ex;
+
+import com.intellij.codeInspection.ui.InspectionToolPresentation;
+import org.jetbrains.annotations.NotNull;
+
+public interface InspectionPresentationProvider {
+ @NotNull
+ InspectionToolPresentation createPresentation(@NotNull InspectionToolWrapper toolWrapper);
+}
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionRVContentProvider.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionRVContentProvider.java
index 902ba50..d8eec59 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionRVContentProvider.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionRVContentProvider.java
@@ -52,7 +52,7 @@
UserObjectContainer<T> getOwner();
@NotNull
- RefElementNode createNode(@NotNull InspectionTool tool);
+ RefElementNode createNode(@NotNull InspectionToolPresentation presentation);
T getUserObject();
@@ -64,41 +64,47 @@
boolean supportStructure();
}
- public abstract boolean checkReportedProblems(@NotNull InspectionTool tool);
+ public abstract boolean checkReportedProblems(@NotNull GlobalInspectionContextImpl context, @NotNull InspectionToolWrapper toolWrapper);
@Nullable
- public abstract QuickFixAction[] getQuickFixes(@NotNull InspectionTool tool, @NotNull InspectionTree tree);
+ public abstract QuickFixAction[] getQuickFixes(@NotNull InspectionToolWrapper toolWrapper, @NotNull InspectionTree tree);
- public void appendToolNodeContent(@NotNull InspectionNode toolNode,
- final InspectionTreeNode parentNode,
+ public void appendToolNodeContent(@NotNull GlobalInspectionContextImpl context,
+ @NotNull InspectionNode toolNode,
+ @NotNull InspectionTreeNode parentNode,
final boolean showStructure) {
- final InspectionTool tool = toolNode.getTool();
- final Map<String, Set<RefEntity>> content = tool.getContent();
- appendToolNodeContent(toolNode, parentNode, showStructure, content != null ? content : new HashMap<String, Set<RefEntity>>(),
- tool instanceof DescriptorProviderInspection ? ((DescriptorProviderInspection)tool).getProblemElements() : null, null);
+ InspectionToolWrapper wrapper = toolNode.getToolWrapper();
+ InspectionToolPresentation presentation = context.getPresentation(wrapper);
+ Map<String, Set<RefEntity>> content = presentation.getContent();
+ Map<RefEntity, CommonProblemDescriptor[]> problems = presentation.getProblemElements();
+ Map<String, Set<RefEntity>> contents = content == null ? new HashMap<String, Set<RefEntity>>() : content;
+ appendToolNodeContent(context, toolNode, parentNode, showStructure, contents, problems, null);
}
- public abstract void appendToolNodeContent(final InspectionNode toolNode,
- final InspectionTreeNode parentNode,
+ public abstract void appendToolNodeContent(@NotNull GlobalInspectionContextImpl context,
+ @NotNull InspectionNode toolNode,
+ @NotNull InspectionTreeNode parentNode,
final boolean showStructure,
- final Map<String, Set<RefEntity>> contents,
- final Map<RefEntity, CommonProblemDescriptor[]> problems,
+ @NotNull Map<String, Set<RefEntity>> contents,
+ @NotNull Map<RefEntity, CommonProblemDescriptor[]> problems,
@Nullable final DefaultTreeModel model);
- protected abstract void appendDescriptor(final InspectionTool tool,
- final UserObjectContainer container,
- final InspectionPackageNode pNode,
+ protected abstract void appendDescriptor(@NotNull GlobalInspectionContextImpl context,
+ @NotNull InspectionToolWrapper toolWrapper,
+ @NotNull UserObjectContainer container,
+ @NotNull InspectionPackageNode pNode,
final boolean canPackageRepeat);
public boolean isContentLoaded() {
return true;
}
- protected <T> List<InspectionTreeNode> buildTree(final Map<String, Set<T>> packageContents,
+ protected <T> List<InspectionTreeNode> buildTree(@NotNull GlobalInspectionContextImpl context,
+ @NotNull Map<String, Set<T>> packageContents,
final boolean canPackageRepeat,
- final InspectionTool tool,
- final Function<T, UserObjectContainer<T>> computeContainer,
+ @NotNull InspectionToolWrapper toolWrapper,
+ @NotNull Function<T, UserObjectContainer<T>> computeContainer,
final boolean showStructure) {
final List<InspectionTreeNode> content = new ArrayList<InspectionTreeNode>();
final Map<String, Map<String, InspectionPackageNode>> module2PackageMap = new HashMap<String, Map<String, InspectionPackageNode>>();
@@ -119,7 +125,7 @@
pNode = new InspectionPackageNode(packageName);
packageNodes.put(packageName, pNode);
}
- appendDescriptor(tool, container, pNode, canPackageRepeat);
+ appendDescriptor(context, toolWrapper, container, pNode, canPackageRepeat);
}
}
if (supportStructure) {
@@ -211,15 +217,16 @@
return content;
}
+ @NotNull
protected static RefElementNode addNodeToParent(@NotNull UserObjectContainer container,
- @NotNull InspectionTool tool,
+ @NotNull InspectionToolPresentation presentation,
final InspectionTreeNode parentNode) {
- final RefElementNode nodeToBeAdded = container.createNode(tool);
+ final RefElementNode nodeToBeAdded = container.createNode(presentation);
final Ref<Boolean> firstLevel = new Ref<Boolean>(true);
RefElementNode prevNode = null;
final Ref<RefElementNode> result = new Ref<RefElementNode>();
while (true) {
- final RefElementNode currentNode = firstLevel.get() ? nodeToBeAdded : container.createNode(tool);
+ final RefElementNode currentNode = firstLevel.get() ? nodeToBeAdded : container.createNode(presentation);
final UserObjectContainer finalContainer = container;
final RefElementNode finalPrevNode = prevNode;
TreeUtil.traverseDepth(parentNode, new TreeUtil.Traverse() {
@@ -279,7 +286,7 @@
}
}
else if (current instanceof InspectionNode) {
- if (((InspectionNode)current).getTool().getShortName().compareTo(((InspectionNode)child).getTool().getShortName()) == 0) {
+ if (((InspectionNode)current).getToolWrapper().getShortName().compareTo(((InspectionNode)child).getToolWrapper().getShortName()) == 0) {
processDepth(model, child, current);
return;
}
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionRVContentProviderImpl.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionRVContentProviderImpl.java
index bc0948d..f9d3134 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionRVContentProviderImpl.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionRVContentProviderImpl.java
@@ -21,10 +21,7 @@
package com.intellij.codeInspection.ex;
import com.intellij.codeInspection.CommonProblemDescriptor;
-import com.intellij.codeInspection.reference.RefDirectory;
-import com.intellij.codeInspection.reference.RefElement;
-import com.intellij.codeInspection.reference.RefEntity;
-import com.intellij.codeInspection.reference.RefModule;
+import com.intellij.codeInspection.reference.*;
import com.intellij.codeInspection.ui.*;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Comparing;
@@ -40,41 +37,45 @@
import java.util.Set;
public class InspectionRVContentProviderImpl extends InspectionRVContentProvider {
-
public InspectionRVContentProviderImpl(final Project project) {
super(project);
}
@Override
- public boolean checkReportedProblems(@NotNull final InspectionTool tool) {
- tool.updateContent();
- return tool.hasReportedProblems();
+ public boolean checkReportedProblems(@NotNull GlobalInspectionContextImpl context,
+ @NotNull final InspectionToolWrapper toolWrapper) {
+ InspectionToolPresentation presentation = context.getPresentation(toolWrapper);
+ presentation.updateContent();
+ return presentation.hasReportedProblems();
}
@Override
@Nullable
- public QuickFixAction[] getQuickFixes(@NotNull final InspectionTool tool, @NotNull final InspectionTree tree) {
+ public QuickFixAction[] getQuickFixes(@NotNull final InspectionToolWrapper toolWrapper, @NotNull final InspectionTree tree) {
final RefEntity[] refEntities = tree.getSelectedElements();
- return refEntities.length == 0 ? null : tool.getQuickFixes(refEntities);
+ InspectionToolPresentation presentation = ((GlobalInspectionContextImpl)toolWrapper.getContext()).getPresentation(toolWrapper);
+ return refEntities.length == 0 ? null : presentation.getQuickFixes(refEntities);
}
@Override
- public void appendToolNodeContent(final InspectionNode toolNode,
- final InspectionTreeNode parentNode,
+ public void appendToolNodeContent(@NotNull GlobalInspectionContextImpl context,
+ @NotNull final InspectionNode toolNode,
+ @NotNull final InspectionTreeNode parentNode,
final boolean showStructure,
- final Map<String, Set<RefEntity>> contents,
- final Map<RefEntity, CommonProblemDescriptor[]> problems, DefaultTreeModel model) {
- final InspectionTool tool = toolNode.getTool();
+ @NotNull final Map<String, Set<RefEntity>> contents,
+ @NotNull final Map<RefEntity, CommonProblemDescriptor[]> problems,
+ DefaultTreeModel model) {
+ final InspectionToolWrapper toolWrapper = toolNode.getToolWrapper();
Function<RefEntity, UserObjectContainer<RefEntity>> computeContainer = new Function<RefEntity, UserObjectContainer<RefEntity>>() {
@Override
public UserObjectContainer<RefEntity> fun(final RefEntity refElement) {
- return new RefElementContainer(refElement, problems != null ? problems.get(refElement) : null);
+ return new RefElementContainer(refElement, problems.get(refElement));
}
};
-
- final Set<RefModule> moduleProblems = tool.getModuleProblems();
+ InspectionToolPresentation presentation = context.getPresentation(toolWrapper);
+ final Set<RefModule> moduleProblems = presentation.getModuleProblems();
if (moduleProblems != null && !moduleProblems.isEmpty()) {
Set<RefEntity> entities = contents.get("");
if (entities == null) {
@@ -83,16 +84,14 @@
}
entities.addAll(moduleProblems);
}
- List<InspectionTreeNode> list = buildTree(contents, false, tool, computeContainer, showStructure);
+ List<InspectionTreeNode> list = buildTree(context, contents, false, toolWrapper, computeContainer, showStructure);
for (InspectionTreeNode node : list) {
merge(model, node, toolNode, true);
}
- if (tool.isOldProblemsIncluded()) {
- final Map<RefEntity, CommonProblemDescriptor[]> oldProblems =
- tool instanceof DescriptorProviderInspection && !(tool instanceof CommonInspectionToolWrapper)? ((DescriptorProviderInspection)tool)
- .getOldProblemElements() : null;
+ if (presentation.isOldProblemsIncluded()) {
+ final Map<RefEntity, CommonProblemDescriptor[]> oldProblems = presentation.getOldProblemElements();
computeContainer = new Function<RefEntity, UserObjectContainer<RefEntity>>() {
@Override
public UserObjectContainer<RefEntity> fun(final RefEntity refElement) {
@@ -100,7 +99,7 @@
}
};
- list = buildTree(tool.getOldContent(), true, tool, computeContainer, showStructure);
+ list = buildTree(context, presentation.getOldContent(), true, toolWrapper, computeContainer, showStructure);
for (InspectionTreeNode node : list) {
merge(model, node, toolNode, true);
@@ -110,25 +109,24 @@
}
@Override
- protected void appendDescriptor(final InspectionTool tool,
- final UserObjectContainer container,
- final InspectionPackageNode pNode,
+ protected void appendDescriptor(@NotNull GlobalInspectionContextImpl context,
+ @NotNull final InspectionToolWrapper toolWrapper,
+ @NotNull final UserObjectContainer container,
+ @NotNull final InspectionPackageNode pNode,
final boolean canPackageRepeat) {
- final GlobalInspectionContextImpl context = tool.getContext();
final RefElementContainer refElementDescriptor = (RefElementContainer)container;
final RefEntity refElement = refElementDescriptor.getUserObject();
- if (context.getUIOptions().SHOW_ONLY_DIFF && tool.getElementStatus(refElement) == FileStatus.NOT_CHANGED) return;
- if (tool instanceof DescriptorProviderInspection && !(tool instanceof CommonInspectionToolWrapper)) {
- final DescriptorProviderInspection descriptorProviderInspection = (DescriptorProviderInspection)tool;
+ InspectionToolPresentation presentation = context.getPresentation(toolWrapper);
+ if (context.getUIOptions().SHOW_ONLY_DIFF && presentation.getElementStatus(refElement) == FileStatus.NOT_CHANGED) return;
+ if (toolWrapper instanceof LocalInspectionToolWrapper) {
final CommonProblemDescriptor[] problems = refElementDescriptor.getProblemDescriptors();
if (problems != null) {
- final RefElementNode elemNode = addNodeToParent(container, tool, pNode);
+ final RefElementNode elemNode = addNodeToParent(container, presentation, pNode);
for (CommonProblemDescriptor problem : problems) {
- if (context.getUIOptions().SHOW_ONLY_DIFF && descriptorProviderInspection.getProblemStatus(problem) == FileStatus.NOT_CHANGED) {
+ if (context.getUIOptions().SHOW_ONLY_DIFF && presentation.getProblemStatus(problem) == FileStatus.NOT_CHANGED) {
continue;
}
- elemNode.add(
- new ProblemDescriptionNode(refElement, problem, descriptorProviderInspection));
+ elemNode.add(new ProblemDescriptionNode(refElement, problem, toolWrapper));
if (problems.length == 1) {
elemNode.setProblem(problems[0]);
}
@@ -137,13 +135,13 @@
}
else {
if (canPackageRepeat) {
- final Set<RefEntity> currentElements = tool.getContent().get(pNode.getPackageName());
+ final Set<RefEntity> currentElements = presentation.getContent().get(pNode.getPackageName());
if (currentElements != null) {
final Set<RefEntity> currentEntities = new HashSet<RefEntity>(currentElements);
- if (InspectionTool.contains(refElement, currentEntities)) return;
+ if (RefUtil.contains(refElement, currentEntities)) return;
}
}
- addNodeToParent(container, tool, pNode);
+ addNodeToParent(container, presentation, pNode);
}
}
@@ -169,8 +167,8 @@
@NotNull
@Override
- public RefElementNode createNode(@NotNull InspectionTool tool) {
- return new RefElementNode(myElement, tool);
+ public RefElementNode createNode(@NotNull InspectionToolPresentation presentation) {
+ return new RefElementNode(myElement, presentation);
}
@Override
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionTool.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionTool.java
deleted file mode 100644
index 4b95f04..0000000
--- a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionTool.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * Copyright 2000-2009 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.
- */
-
-/*
- * Author: max
- * Date: Oct 9, 2001
- * Time: 8:50:56 PM
- */
-
-package com.intellij.codeInspection.ex;
-
-import com.intellij.analysis.AnalysisScope;
-import com.intellij.codeHighlighting.HighlightDisplayLevel;
-import com.intellij.codeInsight.daemon.HighlightDisplayKey;
-import com.intellij.codeInsight.daemon.impl.HighlightInfoType;
-import com.intellij.codeInsight.daemon.impl.SeverityUtil;
-import com.intellij.codeInsight.intention.IntentionAction;
-import com.intellij.codeInspection.*;
-import com.intellij.codeInspection.reference.*;
-import com.intellij.codeInspection.ui.InspectionNode;
-import com.intellij.codeInspection.ui.InspectionTreeNode;
-import com.intellij.lang.annotation.HighlightSeverity;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Comparing;
-import com.intellij.openapi.vcs.FileStatus;
-import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
-import com.intellij.psi.PsiElement;
-import org.jdom.Element;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-
-public abstract class InspectionTool extends InspectionProfileEntry {
- private GlobalInspectionContextImpl myContext;
- protected static String ourOutputPath;
- protected InspectionNode myToolNode;
-
- public void initialize(@NotNull GlobalInspectionContextImpl context) {
- myContext = context;
- projectOpened(context.getProject());
- }
-
- @NotNull
- public GlobalInspectionContextImpl getContext() {
- return myContext;
- }
-
- @NotNull
- public RefManager getRefManager() {
- return getContext().getRefManager();
- }
-
- public abstract void runInspection(@NotNull AnalysisScope scope, @NotNull InspectionManager manager);
-
- public void exportResults(@NotNull final Element parentNode) {
- getRefManager().iterate(new RefVisitor(){
- @Override
- public void visitElement(@NotNull RefEntity elem) {
- exportResults(parentNode, elem);
- }
- });
- }
-
- public abstract void exportResults(@NotNull Element parentNode, @NotNull RefEntity refEntity);
-
- public abstract boolean isGraphNeeded();
- @Nullable
- public QuickFixAction[] getQuickFixes(@NotNull RefEntity[] refElements) {
- return null;
- }
-
- @NotNull
- public abstract JobDescriptor[] getJobDescriptors(@NotNull GlobalInspectionContext globalInspectionContext);
-
- public boolean queryExternalUsagesRequests(@NotNull InspectionManager manager) {
- return false;
- }
-
- @Override
- public boolean isEnabledByDefault() {
- return getDefaultLevel() != HighlightDisplayLevel.DO_NOT_SHOW;
- }
-
- @Override
- @SuppressWarnings({"HardCodedStringLiteral"})
- @NotNull
- public final String getDescriptionFileName() {
- return getShortName() + ".html";
- }
-
- public final String getFolderName() {
- return getShortName();
- }
-
- public void cleanup() {
- if (myContext != null) {
- projectClosed(myContext.getProject());
- }
- myContext = null;
- }
-
- public void finalCleanup(){
- cleanup();
- }
-
- @NotNull
- public abstract HTMLComposerImpl getComposer();
-
- public abstract boolean hasReportedProblems();
-
- public abstract void updateContent();
-
- public abstract Map<String, Set<RefEntity>> getContent();
-
- @Nullable
- public abstract Map<String, Set<RefEntity>> getOldContent();
-
- public boolean isOldProblemsIncluded() {
- final GlobalInspectionContextImpl context = getContext();
- return context != null && context.getUIOptions().SHOW_DIFF_WITH_PREVIOUS_RUN && getOldContent() != null;
- }
-
- @Nullable
- public Set<RefModule> getModuleProblems(){
- return null;
- }
-
- public abstract void ignoreCurrentElement(RefEntity refElement);
-
- @NotNull
- public abstract Collection<RefEntity> getIgnoredRefElements();
-
- public abstract void amnesty(RefEntity refEntity);
-
- public abstract boolean isElementIgnored(final RefEntity element);
-
- @NotNull
- public abstract FileStatus getElementStatus(final RefEntity element);
-
- @NotNull
- protected static FileStatus calcStatus(boolean old, boolean current) {
- if (old) {
- if (!current) {
- return FileStatus.DELETED;
- }
- }
- else if (current) {
- return FileStatus.ADDED;
- }
- return FileStatus.NOT_CHANGED;
- }
-
- protected static boolean contains(RefEntity element, @NotNull Collection<RefEntity> entities){
- for (RefEntity refEntity : entities) {
- if (Comparing.equal(refEntity, element)) {
- return true;
- }
- }
- return false;
- }
-
- protected HighlightSeverity getCurrentSeverity(@NotNull RefElement element) {
- final PsiElement psiElement = element.getPointer().getContainingFile();
- if (psiElement != null) {
- if (myContext != null) {
- final Tools tools = myContext.getTools().get(getShortName());
- if (tools != null) {
- for (ScopeToolState state : tools.getTools()) {
- if (state.getTool() == this) {
- return myContext.getCurrentProfile().getErrorLevel(HighlightDisplayKey.find(getShortName()), psiElement).getSeverity();
- }
- }
- }
-
- final InspectionProfile profile = InspectionProjectProfileManager.getInstance(getContext().getProject()).getInspectionProfile();
- final HighlightDisplayLevel level = profile.getErrorLevel(HighlightDisplayKey.find(getShortName()), psiElement);
- return level.getSeverity();
- }
- }
- return null;
- }
-
- protected static String getTextAttributeKey(@NotNull Project project, @NotNull HighlightSeverity severity, @NotNull ProblemHighlightType highlightType) {
- if (highlightType == ProblemHighlightType.LIKE_DEPRECATED) {
- return HighlightInfoType.DEPRECATED.getAttributesKey().getExternalName();
- }
- if (highlightType == ProblemHighlightType.LIKE_UNKNOWN_SYMBOL && severity == HighlightSeverity.ERROR) {
- return HighlightInfoType.WRONG_REF.getAttributesKey().getExternalName();
- }
- if (highlightType == ProblemHighlightType.LIKE_UNUSED_SYMBOL) {
- return HighlightInfoType.UNUSED_SYMBOL.getAttributesKey().getExternalName();
- }
- return SeverityUtil.getSeverityRegistrar(project).getHighlightInfoTypeBySeverity(severity).getAttributesKey().getExternalName();
- }
-
- public static void setOutputPath(final String output) {
- ourOutputPath = output;
- }
-
- @SuppressWarnings({"UnusedDeclaration"})
- @Nullable
- public IntentionAction findQuickFixes(final CommonProblemDescriptor descriptor, final String hint) {
- return null;
- }
-
- public InspectionNode createToolNode(final InspectionRVContentProvider provider, final InspectionTreeNode parentNode, final boolean showStructure) {
- myToolNode = new InspectionNode(this);
- provider.appendToolNodeContent(myToolNode, parentNode, showStructure);
- return myToolNode;
- }
-
- @Nullable
- public SuppressIntentionAction[] getSuppressActions() {
- return null;
- }
-}
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionToolRegistrar.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionToolRegistrar.java
deleted file mode 100644
index 79bce51..0000000
--- a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionToolRegistrar.java
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- * Copyright 2000-2011 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.codeInspection.ex;
-
-import com.intellij.codeInspection.*;
-import com.intellij.ide.ui.search.SearchableOptionsRegistrar;
-import com.intellij.notification.Notification;
-import com.intellij.notification.NotificationType;
-import com.intellij.notification.Notifications;
-import com.intellij.openapi.application.Application;
-import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.components.ServiceManager;
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.extensions.ExtensionPointName;
-import com.intellij.openapi.extensions.Extensions;
-import com.intellij.openapi.progress.ProgressManager;
-import com.intellij.openapi.util.Factory;
-import com.intellij.profile.codeInspection.ui.InspectionToolsConfigurable;
-import com.intellij.util.ArrayUtil;
-import com.intellij.util.containers.ContainerUtil;
-import gnu.trove.THashSet;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.regex.Pattern;
-
-/**
- * @author max
- */
-public class InspectionToolRegistrar {
- private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.ex.InspectionToolRegistrar");
-
- private final List<Factory<InspectionToolWrapper>> myInspectionToolFactories = new ArrayList<Factory<InspectionToolWrapper>>();
-
- private final AtomicBoolean myToolsAreInitialized = new AtomicBoolean(false);
- private final AtomicBoolean myInspectionComponentsLoaded = new AtomicBoolean(false);
-
- private static final Pattern HTML_PATTERN = Pattern.compile("<[^<>]*>");
- public final SearchableOptionsRegistrar myOptionsRegistrar;
-
- private static final ExtensionPointName<InspectionEP> SPECIAL_TOOL = ExtensionPointName.create("com.intellij.specialTool");
-
-
- public InspectionToolRegistrar(SearchableOptionsRegistrar registrar) {
- myOptionsRegistrar = registrar;
- }
-
- public void ensureInitialized() {
- if (!myInspectionComponentsLoaded.getAndSet(true)) {
- Set<InspectionToolProvider> providers = new THashSet<InspectionToolProvider>();
- ContainerUtil.addAll(providers, ApplicationManager.getApplication().getComponents(InspectionToolProvider.class));
- ContainerUtil.addAll(providers, Extensions.getExtensions(InspectionToolProvider.EXTENSION_POINT_NAME));
- registerTools(providers.toArray(new InspectionToolProvider[providers.size()]));
- for (final LocalInspectionEP ep : Extensions.getExtensions(LocalInspectionEP.LOCAL_INSPECTION)) {
- myInspectionToolFactories.add(new Factory<InspectionToolWrapper>() {
- @Override
- public InspectionToolWrapper create() {
- return new LocalInspectionToolWrapper(ep);
- }
- });
- }
- for (final InspectionEP ep : Extensions.getExtensions(InspectionEP.GLOBAL_INSPECTION)) {
- myInspectionToolFactories.add(new Factory<InspectionToolWrapper>() {
- @Override
- public InspectionToolWrapper create() {
- return new GlobalInspectionToolWrapper(ep);
- }
- });
- }
- for (final InspectionEP ep : Extensions.getExtensions(SPECIAL_TOOL)) {
- myInspectionToolFactories.add(new Factory<InspectionToolWrapper>() {
- @Override
- public InspectionToolWrapper create() {
- return new CommonInspectionToolWrapper(ep);
- }
- });
- }
- for (InspectionToolsFactory factory : Extensions.getExtensions(InspectionToolsFactory.EXTENSION_POINT_NAME)) {
- for (final InspectionProfileEntry profileEntry : factory.createTools()) {
- myInspectionToolFactories.add(new Factory<InspectionToolWrapper>() {
- @Override
- public InspectionToolWrapper create() {
- return wrapTool(profileEntry);
- }
- });
- }
- }
- }
- }
-
- @NotNull
- public static InspectionToolWrapper wrapTool(@NotNull InspectionProfileEntry profileEntry) {
- if (profileEntry instanceof InspectionToolWrapper) {
- return (InspectionToolWrapper)profileEntry;
- }
- if (profileEntry instanceof LocalInspectionTool) {
- return new LocalInspectionToolWrapper((LocalInspectionTool)profileEntry);
- }
- if (profileEntry instanceof GlobalInspectionTool) {
- return new GlobalInspectionToolWrapper((GlobalInspectionTool)profileEntry);
- }
- return new CommonInspectionToolWrapper((InspectionTool)profileEntry);
- }
-
- public void registerTools(@NotNull InspectionToolProvider[] providers) {
- for (InspectionToolProvider provider : providers) {
- Class[] classes = provider.getInspectionClasses();
- for (Class aClass : classes) {
- registerInspectionTool(aClass, true);
- }
- }
- }
-
- @NotNull
- private Factory<InspectionToolWrapper> registerInspectionTool(@NotNull final Class aClass, boolean store) {
- if (LocalInspectionTool.class.isAssignableFrom(aClass)) {
- return registerLocalInspection(aClass, store);
- }
- if (GlobalInspectionTool.class.isAssignableFrom(aClass)) {
- return registerGlobalInspection(aClass, store);
- }
- ensureInitialized();
- return registerInspectionToolFactory(new Factory<InspectionToolWrapper>() {
- @Override
- public InspectionToolWrapper create() {
- return new CommonInspectionToolWrapper((InspectionTool)instantiateTool(aClass));
- }
- }, store);
- }
-
- public static InspectionToolRegistrar getInstance() {
- return ServiceManager.getService(InspectionToolRegistrar.class);
- }
-
- /**
- * make sure that it is not too late
- */
- @NotNull
- public Factory<InspectionToolWrapper> registerInspectionToolFactory(@NotNull Factory<InspectionToolWrapper> factory, boolean store) {
- if (store) {
- myInspectionToolFactories.add(factory);
- }
- return factory;
- }
-
- @NotNull
- private Factory<InspectionToolWrapper> registerLocalInspection(final Class toolClass, boolean store) {
- return registerInspectionToolFactory(new Factory<InspectionToolWrapper>() {
- @Override
- public InspectionToolWrapper create() {
- return new LocalInspectionToolWrapper((LocalInspectionTool)instantiateTool(toolClass));
- }
- }, store);
- }
-
- @NotNull
- private Factory<InspectionToolWrapper> registerGlobalInspection(@NotNull final Class aClass, boolean store) {
- return registerInspectionToolFactory(new Factory<InspectionToolWrapper>() {
- @Override
- public InspectionToolWrapper create() {
- return new GlobalInspectionToolWrapper((GlobalInspectionTool) instantiateTool(aClass));
- }
- }, store);
- }
-
- @NotNull
- public List<InspectionToolWrapper> createTools() {
- ensureInitialized();
-
- final List<InspectionToolWrapper> tools = ContainerUtil.newArrayListWithCapacity(myInspectionToolFactories.size());
- final Set<Factory<InspectionToolWrapper>> broken = ContainerUtil.newHashSet();
- for (final Factory<InspectionToolWrapper> factory : myInspectionToolFactories) {
- ProgressManager.checkCanceled();
- final InspectionToolWrapper toolWrapper = factory.create();
- if (toolWrapper != null && checkTool(toolWrapper)) {
- tools.add(toolWrapper);
- }
- else {
- broken.add(factory);
- }
- }
- myInspectionToolFactories.removeAll(broken);
-
- return tools;
- }
-
- static Object instantiateTool(@NotNull Class<?> toolClass) {
- try {
- Constructor<?> constructor = toolClass.getDeclaredConstructor(ArrayUtil.EMPTY_CLASS_ARRAY);
- constructor.setAccessible(true);
- return constructor.newInstance(ArrayUtil.EMPTY_OBJECT_ARRAY);
- }
- catch (SecurityException e) {
- LOG.error(e);
- }
- catch (NoSuchMethodException e) {
- LOG.error(e);
- }
- catch (InstantiationException e) {
- LOG.error(e);
- }
- catch (IllegalAccessException e) {
- LOG.error(e);
- }
- catch (IllegalArgumentException e) {
- LOG.error(e);
- }
- catch (InvocationTargetException e) {
- LOG.error(e);
- }
-
- return null;
- }
-
- public void buildInspectionSearchIndexIfNecessary() {
- if (!myToolsAreInitialized.getAndSet(true)) {
- final Application app = ApplicationManager.getApplication();
- if (app.isUnitTestMode() || app.isHeadlessEnvironment()) return;
-
- app.executeOnPooledThread(new Runnable(){
- @Override
- public void run() {
- List<InspectionToolWrapper> tools = createTools();
- for (InspectionToolWrapper tool : tools) {
- processText(tool.getDisplayName().toLowerCase(), tool);
-
- final String description = tool.loadDescription();
- if (description != null) {
- @NonNls String descriptionText = HTML_PATTERN.matcher(description).replaceAll(" ");
- processText(descriptionText, tool);
- }
- }
- }
- });
- }
- }
-
- private void processText(@NotNull @NonNls String descriptionText, @NotNull InspectionToolWrapper tool) {
- if (ApplicationManager.getApplication().isDisposed()) return;
- LOG.assertTrue(myOptionsRegistrar != null);
- final Set<String> words = myOptionsRegistrar.getProcessedWordsWithoutStemming(descriptionText);
- for (String word : words) {
- myOptionsRegistrar.addOption(word, tool.getShortName(), tool.getDisplayName(), InspectionToolsConfigurable.ID, InspectionToolsConfigurable.DISPLAY_NAME);
- }
- }
-
- private static boolean checkTool(@NotNull final InspectionToolWrapper toolWrapper) {
- if (toolWrapper instanceof LocalInspectionToolWrapper) {
- String message = null;
- try {
- final String id = ((LocalInspectionToolWrapper)toolWrapper).getID();
- if (id == null || !LocalInspectionTool.isValidID(id)) {
- message = InspectionsBundle.message("inspection.disabled.wrong.id", toolWrapper.getShortName(), id, LocalInspectionTool.VALID_ID_PATTERN);
- }
- }
- catch (Throwable t) {
- message = InspectionsBundle.message("inspection.disabled.error", toolWrapper.getShortName(), t.getMessage());
- }
- if (message != null) {
- showNotification(message);
- return false;
- }
- }
- return true;
- }
-
- private static void showNotification(@NotNull final String message) {
- ApplicationManager.getApplication().invokeLater(new Runnable() {
- @Override
- public void run() {
- Notifications.Bus.notify(new Notification(InspectionManager.INSPECTION_GROUP_ID, InspectionsBundle.message("inspection.disabled.title"),
- message, NotificationType.ERROR));
- }
- });
- }
-}
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/LocalDescriptorsUtil.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/LocalDescriptorsUtil.java
new file mode 100644
index 0000000..b803177
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/LocalDescriptorsUtil.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2000-2013 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.codeInspection.ex;
+
+import com.intellij.codeInspection.*;
+import com.intellij.codeInspection.reference.RefElement;
+import com.intellij.codeInspection.reference.RefManagerImpl;
+import com.intellij.codeInspection.ui.InspectionToolPresentation;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiNamedElement;
+import com.intellij.util.TripleFunction;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class LocalDescriptorsUtil {
+ private static final TripleFunction<LocalInspectionTool, PsiElement, GlobalInspectionContext,RefElement> CONVERT = new TripleFunction<LocalInspectionTool, PsiElement, GlobalInspectionContext,RefElement>() {
+ @Override
+ public RefElement fun(LocalInspectionTool tool, PsiElement element, GlobalInspectionContext context) {
+ final PsiNamedElement problemElement = tool.getProblemElement(element);
+
+ RefElement refElement = context.getRefManager().getReference(problemElement);
+ if (refElement == null && problemElement != null) { // no need to lose collected results
+ refElement = GlobalInspectionUtil.retrieveRefElement(element, context);
+ }
+ return refElement;
+ }
+ };
+
+ static void addProblemDescriptors(@NotNull List<ProblemDescriptor> descriptors,
+ boolean filterSuppressed,
+ @NotNull GlobalInspectionContext context,
+ @Nullable LocalInspectionTool tool,
+ @NotNull TripleFunction<LocalInspectionTool, PsiElement, GlobalInspectionContext, RefElement> getProblemElementFunction,
+ @NotNull InspectionToolPresentation dpi) {
+ if (descriptors.isEmpty()) return;
+
+ Map<RefElement, List<ProblemDescriptor>> problems = new HashMap<RefElement, List<ProblemDescriptor>>();
+ final RefManagerImpl refManager = (RefManagerImpl)context.getRefManager();
+ for (ProblemDescriptor descriptor : descriptors) {
+ final PsiElement element = descriptor.getPsiElement();
+ if (element == null) continue;
+ if (filterSuppressed) {
+ String alternativeId;
+ String id;
+ if (refManager.isDeclarationsFound() &&
+ (context.isSuppressed(element, id = tool.getID()) ||
+ (alternativeId = tool.getAlternativeID()) != null &&
+ !alternativeId.equals(id) &&
+ context.isSuppressed(element, alternativeId))) {
+ continue;
+ }
+ if (InspectionManagerEx.inspectionResultSuppressed(element, tool)) continue;
+ }
+
+
+ RefElement refElement = getProblemElementFunction.fun(tool, element, context);
+
+ List<ProblemDescriptor> elementProblems = problems.get(refElement);
+ if (elementProblems == null) {
+ elementProblems = new ArrayList<ProblemDescriptor>();
+ problems.put(refElement, elementProblems);
+ }
+ elementProblems.add(descriptor);
+ }
+
+ for (Map.Entry<RefElement, List<ProblemDescriptor>> entry : problems.entrySet()) {
+ final List<ProblemDescriptor> problemDescriptors = entry.getValue();
+ RefElement refElement = entry.getKey();
+ CommonProblemDescriptor[] descriptions = problemDescriptors.toArray(new CommonProblemDescriptor[problemDescriptors.size()]);
+ dpi.addProblemElement(refElement, filterSuppressed, descriptions);
+ }
+ }
+
+ public static void addProblemDescriptors(@NotNull List<ProblemDescriptor> descriptors,
+ @NotNull InspectionToolPresentation dpi,
+ boolean filterSuppressed,
+ @NotNull GlobalInspectionContext inspectionContext,
+ @NotNull LocalInspectionTool tool) {
+ addProblemDescriptors(descriptors, filterSuppressed, inspectionContext, tool, CONVERT, dpi);
+ }
+}
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/LocalInspectionToolWrapper.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/LocalInspectionToolWrapper.java
deleted file mode 100644
index 670ad29..0000000
--- a/platform/lang-impl/src/com/intellij/codeInspection/ex/LocalInspectionToolWrapper.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * Copyright 2000-2013 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.codeInspection.ex;
-
-import com.intellij.analysis.AnalysisScope;
-import com.intellij.codeHighlighting.HighlightDisplayLevel;
-import com.intellij.codeInspection.*;
-import com.intellij.codeInspection.reference.RefElement;
-import com.intellij.codeInspection.reference.RefEntity;
-import com.intellij.codeInspection.reference.RefManagerImpl;
-import com.intellij.codeInspection.ui.InspectionResultsView;
-import com.intellij.codeInspection.ui.InspectionTreeNode;
-import com.intellij.lang.annotation.HighlightSeverity;
-import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.extensions.Extensions;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.NotNullLazyValue;
-import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
-import com.intellij.psi.*;
-import com.intellij.util.TripleFunction;
-import com.intellij.util.containers.HashSet;
-import com.intellij.util.ui.UIUtil;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.jetbrains.annotations.TestOnly;
-
-import javax.swing.tree.DefaultTreeModel;
-import java.util.*;
-
-/**
- * @author max
- */
-public class LocalInspectionToolWrapper extends InspectionToolWrapper<LocalInspectionTool, LocalInspectionEP> {
- private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.ex.LocalInspectionToolWrapper");
-
- /** This should be used in tests primarily */
- @TestOnly
- public LocalInspectionToolWrapper(@NotNull LocalInspectionTool tool) {
- super(tool, ourEPMap.getValue().get(tool.getShortName()));
- }
-
- public LocalInspectionToolWrapper(@NotNull LocalInspectionEP ep) {
- super(ep);
- }
-
- @TestOnly
- public LocalInspectionToolWrapper(@Nullable LocalInspectionTool tool, @Nullable LocalInspectionEP ep) {
- super(tool, ep);
- }
-
- private LocalInspectionToolWrapper(@NotNull LocalInspectionToolWrapper other) {
- super(other);
- }
-
- @NotNull
- @Override
- public LocalInspectionToolWrapper createCopy() {
- return new LocalInspectionToolWrapper(this);
- }
-
- public void processFile(@NotNull PsiFile file, final boolean filterSuppressed, @NotNull InspectionManager manager) {
- processFile(file, filterSuppressed, manager, false);
- }
-
- public void processFile(@NotNull PsiFile file, final boolean filterSuppressed, @NotNull InspectionManager manager, final boolean isOnTheFly) {
- final ProblemsHolder holder = new ProblemsHolder(manager, file, isOnTheFly);
- LocalInspectionToolSession session = new LocalInspectionToolSession(file, 0, file.getTextLength());
- final PsiElementVisitor customVisitor = getTool().buildVisitor(holder, isOnTheFly, session);
- LOG.assertTrue(!(customVisitor instanceof PsiRecursiveElementVisitor), "The visitor returned from LocalInspectionTool.buildVisitor() must not be recursive");
-
- getTool().inspectionStarted(session, isOnTheFly);
-
- file.accept(new PsiRecursiveElementWalkingVisitor() {
- @Override public void visitElement(PsiElement element) {
- element.accept(customVisitor);
- super.visitElement(element);
- }
- });
-
- getTool().inspectionFinished(session, holder);
-
- addProblemDescriptors(holder.getResults(), filterSuppressed);
- }
-
- @Override
- @NotNull
- public JobDescriptor[] getJobDescriptors(@NotNull GlobalInspectionContext context) {
- return context.getStdJobDescriptors().LOCAL_ANALYSIS_ARRAY;
- }
-
- public void addProblemDescriptors(@NotNull List<ProblemDescriptor> descriptors, final boolean filterSuppressed) {
- final GlobalInspectionContextImpl context = getContext();
- if (context != null) { //can be already closed
- addProblemDescriptors(descriptors, filterSuppressed, context, getTool(), CONVERT, this);
- }
- }
- private static final TripleFunction<LocalInspectionTool, PsiElement, GlobalInspectionContext,RefElement> CONVERT = new TripleFunction<LocalInspectionTool, PsiElement, GlobalInspectionContext,RefElement>() {
- @Override
- public RefElement fun(LocalInspectionTool tool, PsiElement elt, GlobalInspectionContext context) {
- final PsiNamedElement problemElement = tool.getProblemElement(elt);
-
- RefElement refElement = context.getRefManager().getReference(problemElement);
- if (refElement == null && problemElement != null) { // no need to lose collected results
- refElement = GlobalInspectionUtil.retrieveRefElement(elt, context);
- }
- return refElement;
- }
- };
-
- @Override
- protected void addProblemElement(RefEntity refElement, boolean filterSuppressed, @NotNull CommonProblemDescriptor... descriptions) {
- final GlobalInspectionContextImpl context = getContext();
- if (context == null) return;
- super.addProblemElement(refElement, filterSuppressed, descriptions);
- final InspectionResultsView view = context.getView();
- if (view != null && refElement instanceof RefElement) {
- if (myToolNode == null) {
- final HighlightSeverity currentSeverity = getCurrentSeverity((RefElement)refElement);
- view.addTool(this, HighlightDisplayLevel.find(currentSeverity), context.getUIOptions().GROUP_BY_SEVERITY);
- } else if (myToolNode.isTooBigForOnlineRefresh()) {
- return;
- }
- final HashMap<RefEntity, CommonProblemDescriptor[]> problems = new HashMap<RefEntity, CommonProblemDescriptor[]>();
- problems.put(refElement, descriptions);
- final HashMap<String, Set<RefEntity>> contents = new HashMap<String, Set<RefEntity>>();
- final String groupName = refElement.getRefManager().getGroupName((RefElement)refElement);
- Set<RefEntity> content = contents.get(groupName);
- if (content == null) {
- content = new HashSet<RefEntity>();
- contents.put(groupName, content);
- }
- content.add(refElement);
-
- UIUtil.invokeLaterIfNeeded(new Runnable() {
- @Override
- public void run() {
- final GlobalInspectionContextImpl context = getContext();
- if (context != null) {
- view.getProvider().appendToolNodeContent(myToolNode,
- (InspectionTreeNode)myToolNode.getParent(), context.getUIOptions().SHOW_STRUCTURE,
- contents, problems, (DefaultTreeModel)view.getTree().getModel());
- context.addView(view);
- }
- }
- });
- }
- }
-
- public static void addProblemDescriptors(@NotNull List<ProblemDescriptor> descriptors,
- boolean filterSuppressed,
- @NotNull GlobalInspectionContextImpl context,
- @Nullable LocalInspectionTool tool,
- @NotNull TripleFunction<LocalInspectionTool, PsiElement, GlobalInspectionContext, RefElement> getProblemElementFunction,
- @NotNull DescriptorProviderInspection dpi) {
- if (descriptors.isEmpty()) return;
-
- Map<RefElement, List<ProblemDescriptor>> problems = new HashMap<RefElement, List<ProblemDescriptor>>();
- final RefManagerImpl refManager = (RefManagerImpl)context.getRefManager();
- for (ProblemDescriptor descriptor : descriptors) {
- final PsiElement elt = descriptor.getPsiElement();
- if (elt == null) continue;
- if (filterSuppressed) {
- String alternativeId;
- String id;
- if (refManager.isDeclarationsFound() &&
- (context.isSuppressed(elt, id = tool.getID()) ||
- (alternativeId = tool.getAlternativeID()) != null &&
- !alternativeId.equals(id) &&
- context.isSuppressed(elt, alternativeId))) {
- continue;
- }
- if (InspectionManagerEx.inspectionResultSuppressed(elt, tool)) continue;
- }
-
-
- RefElement refElement = getProblemElementFunction.fun(tool, elt, context);
-
- List<ProblemDescriptor> elementProblems = problems.get(refElement);
- if (elementProblems == null) {
- elementProblems = new ArrayList<ProblemDescriptor>();
- problems.put(refElement, elementProblems);
- }
- elementProblems.add(descriptor);
- }
-
- for (Map.Entry<RefElement, List<ProblemDescriptor>> entry : problems.entrySet()) {
- final List<ProblemDescriptor> problemDescriptors = entry.getValue();
- dpi.addProblemElement(entry.getKey(),
- filterSuppressed,
- problemDescriptors.toArray(new CommonProblemDescriptor[problemDescriptors.size()]));
- }
- }
-
- @Override
- public void runInspection(@NotNull AnalysisScope scope, @NotNull final InspectionManager manager) {
- LOG.assertTrue(ApplicationManager.getApplication().isUnitTestMode());
- scope.accept(new PsiRecursiveElementVisitor() {
- @Override public void visitFile(PsiFile file) {
- processFile(file, true, manager);
- }
- });
- }
-
- public boolean isUnfair() {
- return myEP == null ? getTool() instanceof UnfairLocalInspectionTool : myEP.unfair;
- }
-
- public String getID() {
- return myEP == null ? getTool().getID() : myEP.id == null ? myEP.getShortName() : myEP.id;
- }
-
- @Nullable
- public String getAlternativeID() {
- return myEP == null ? getTool().getAlternativeID() : myEP.alternativeId;
- }
-
- public boolean runForWholeFile() {
- return myEP == null ? getTool().runForWholeFile() : myEP.runForWholeFile;
- }
-
- private static final NotNullLazyValue<Map<String, LocalInspectionEP>> ourEPMap = new NotNullLazyValue<Map<String, LocalInspectionEP>>() {
- @NotNull
- @Override
- protected Map<String, LocalInspectionEP> compute() {
- HashMap<String, LocalInspectionEP> map = new HashMap<String, LocalInspectionEP>();
- for (LocalInspectionEP ep : Extensions.getExtensions(LocalInspectionEP.LOCAL_INSPECTION)) {
- map.put(ep.getShortName(), ep);
- }
- return map;
- }
- };
-
- public static InspectionProfileEntry findTool2RunInBatch(Project project, @Nullable PsiElement element, final String name) {
- final InspectionProfile inspectionProfile = InspectionProjectProfileManager.getInstance(project).getInspectionProfile();
- final InspectionProfileEntry tool = element != null ? inspectionProfile.getInspectionTool(name, element) : inspectionProfile.getInspectionTool(name);
- if (tool instanceof LocalInspectionToolWrapper && ((LocalInspectionToolWrapper)tool).isUnfair()) {
- final LocalInspectionTool inspectionTool = ((LocalInspectionToolWrapper)tool).getTool();
- if (inspectionTool instanceof PairedUnfairLocalInspectionTool) {
- final String oppositeShortName = ((PairedUnfairLocalInspectionTool)inspectionTool).getInspectionForBatchShortName();
- if (oppositeShortName != null) {
- return element != null ? inspectionProfile.getInspectionTool(oppositeShortName, element) : inspectionProfile.getInspectionTool(oppositeShortName);
- }
- }
- return null;
- }
- return tool;
- }
-}
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/LocalQuickFixWrapper.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/LocalQuickFixWrapper.java
index e3f43ca..22df0cd 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/ex/LocalQuickFixWrapper.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/LocalQuickFixWrapper.java
@@ -21,6 +21,7 @@
import com.intellij.codeInspection.reference.RefElement;
import com.intellij.codeInspection.reference.RefEntity;
import com.intellij.codeInspection.reference.RefManager;
+import com.intellij.codeInspection.ui.InspectionToolPresentation;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
@@ -30,6 +31,7 @@
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
+import java.util.List;
import java.util.Set;
/**
@@ -39,9 +41,8 @@
private final QuickFix myFix;
private String myText;
- public LocalQuickFixWrapper(@NotNull QuickFix fix, @NotNull DescriptorProviderInspection tool) {
- super(fix.getName(), tool);
- myTool = tool;
+ public LocalQuickFixWrapper(@NotNull QuickFix fix, @NotNull InspectionToolWrapper toolWrapper) {
+ super(fix.getName(), toolWrapper);
myFix = fix;
myText = myFix.getName();
}
@@ -73,11 +74,11 @@
}
@Nullable
- protected QuickFix getWorkingQuickFix(QuickFix[] fixes) {
+ protected QuickFix getWorkingQuickFix(@NotNull QuickFix[] fixes) {
for (QuickFix fix : fixes) {
if (!myFix.getClass().isInstance(fix)) continue;
if (myFix instanceof IntentionWrapper && fix instanceof IntentionWrapper &&
- !(((IntentionWrapper)myFix).getAction().getClass().isInstance(((IntentionWrapper)fix).getAction()))) {
+ !((IntentionWrapper)myFix).getAction().getClass().isInstance(((IntentionWrapper)fix).getAction())) {
continue;
}
return fix;
@@ -86,15 +87,17 @@
}
@Override
- protected boolean applyFix(RefElement[] refElements) {
+ protected boolean applyFix(RefEntity[] refElements) {
throw new UnsupportedOperationException("");
}
@Override
- protected void applyFix(final Project project, final CommonProblemDescriptor[] descriptors, final Set<PsiElement> ignoredElements) {
+ protected void applyFix(@NotNull final Project project,
+ @NotNull final CommonProblemDescriptor[] descriptors,
+ @NotNull final Set<PsiElement> ignoredElements) {
final PsiModificationTracker tracker = PsiManager.getInstance(project).getModificationTracker();
if (myFix instanceof BatchQuickFix) {
- final ArrayList<PsiElement> collectedElementsToIgnore = new ArrayList<PsiElement>();
+ final List<PsiElement> collectedElementsToIgnore = new ArrayList<PsiElement>();
final Runnable refreshViews = new Runnable() {
@Override
public void run() {
@@ -103,13 +106,13 @@
ignore(ignoredElements, descriptor, getWorkingQuickFix(descriptor.getFixes()));
}
- final RefManager refManager = myTool.getContext().getRefManager();
+ final RefManager refManager = myToolWrapper.getContext().getRefManager();
final RefElement[] refElements = new RefElement[collectedElementsToIgnore.size()];
for (int i = 0, collectedElementsToIgnoreSize = collectedElementsToIgnore.size(); i < collectedElementsToIgnoreSize; i++) {
refElements[i] = refManager.getReference(collectedElementsToIgnore.get(i));
}
- removeElements(refElements, project, myTool);
+ removeElements(refElements, project, myToolWrapper);
}
};
@@ -139,9 +142,11 @@
}
}
- private void ignore(Set<PsiElement> ignoredElements, CommonProblemDescriptor descriptor, QuickFix fix) {
+ private void ignore(@NotNull Set<PsiElement> ignoredElements, @NotNull CommonProblemDescriptor descriptor, @Nullable QuickFix fix) {
if (fix != null) {
- ((DescriptorProviderInspection)myTool).ignoreProblem(descriptor, fix);
+ InspectionToolPresentation presentation =
+ ((GlobalInspectionContextImpl)myToolWrapper.getContext()).getPresentation(myToolWrapper);
+ presentation.ignoreProblem(descriptor, fix);
}
if (descriptor instanceof ProblemDescriptor) {
ignoredElements.add(((ProblemDescriptor)descriptor).getPsiElement());
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/PlainTextFormatter.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/PlainTextFormatter.java
index d4eb145..fd8b295 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/ex/PlainTextFormatter.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/PlainTextFormatter.java
@@ -1,7 +1,6 @@
package com.intellij.codeInspection.ex;
import com.intellij.codeInspection.InspectionApplication;
-import com.intellij.codeInspection.InspectionProfileEntry;
import com.intellij.codeInspection.InspectionsReportConverter;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
@@ -93,13 +92,13 @@
continue;
}
- final InspectionProfileEntry tool = tools.get(fileNameWithoutExt).getTool();
+ InspectionToolWrapper toolWrapper = tools.get(fileNameWithoutExt).getTool();
// Tool name and group
- w.append(getToolPresentableName(tool)).append("\n");
+ w.append(getToolPresentableName(toolWrapper)).append("\n");
// Description is HTML based, need to be converted in plain text
- writeInspectionDescription(w, tool, transformer);
+ writeInspectionDescription(w, toolWrapper, transformer);
// separator before file list
w.append("\n");
@@ -114,7 +113,7 @@
final List problems = root.getChildren(PROBLEM_ELEMENT);
// let's count max file path & line_number length to align problem descriptions
- final int maxFileColonLineLength = getMaxFileColonLineNumLength(inspectionData, tool, problems);
+ final int maxFileColonLineLength = getMaxFileColonLineNumLength(inspectionData, toolWrapper, problems);
for (Object problem : problems) {
// Format:
@@ -124,7 +123,7 @@
final String filePath = getPath(fileElement);
// skip suppressed results
- if (resultsIgnored(inspectionData, tool)) {
+ if (resultsIgnored(inspectionData, toolWrapper)) {
continue;
}
@@ -165,7 +164,7 @@
}
private int getMaxFileColonLineNumLength(@NotNull final File inspectionResultData,
- @NotNull final InspectionProfileEntry tool,
+ @NotNull final InspectionToolWrapper toolWrapper,
@NotNull final List problems) {
int maxFileColonLineLength = 0;
for (Object problem : problems) {
@@ -174,7 +173,7 @@
final String filePath = getPath(fileElement);
// skip suppressed results
- if (resultsIgnored(inspectionResultData, tool)) {
+ if (resultsIgnored(inspectionResultData, toolWrapper)) {
continue;
}
@@ -188,7 +187,7 @@
}
private boolean resultsIgnored(@NotNull final File file,
- @NotNull final InspectionProfileEntry tool) {
+ @NotNull final InspectionToolWrapper toolWrapper) {
// TODO: check according to config
return false;
}
@@ -199,12 +198,12 @@
}
protected void writeInspectionDescription(@NotNull final Writer w,
- @NotNull final InspectionProfileEntry tool,
+ @NotNull final InspectionToolWrapper toolWrapper,
@NotNull final Transformer transformer)
throws IOException, ConversionException {
final StringWriter descrWriter = new StringWriter();
- String descr = tool.loadDescription();
+ String descr = toolWrapper.loadDescription();
if (descr == null) {
return;
}
@@ -217,7 +216,7 @@
}
catch (TransformerException e) {
// Not critical problem, just inspection error cannot be loaded
- warn("ERROR: Cannot load description for inspection: " + getToolPresentableName(tool) + ".\n Error message: " + e.getMessage());
+ warn("ERROR: Cannot load description for inspection: " + getToolPresentableName(toolWrapper) + ".\n Error message: " + e.getMessage());
return;
}
@@ -231,14 +230,14 @@
}
@NotNull
- protected String getToolPresentableName(@NotNull final InspectionProfileEntry tool) throws IOException {
+ protected String getToolPresentableName(@NotNull final InspectionToolWrapper toolWrapper) throws IOException {
final StringBuilder buff = new StringBuilder();
// inspection name
- buff.append(tool.getDisplayName()).append(" (");
+ buff.append(toolWrapper.getDisplayName()).append(" (");
// group name
- final String[] groupPath = tool.getGroupPath();
+ final String[] groupPath = toolWrapper.getGroupPath();
for (int i = 0, groupPathLength = groupPath.length; i < groupPathLength; i++) {
if (i != 0) {
buff.append(" | ");
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/QuickFixAction.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/QuickFixAction.java
index dd88d85..60b2ec2 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/ex/QuickFixAction.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/QuickFixAction.java
@@ -16,6 +16,7 @@
package com.intellij.codeInspection.ex;
+import com.intellij.codeInsight.FileModificationService;
import com.intellij.codeInspection.CommonProblemDescriptor;
import com.intellij.codeInspection.InspectionManager;
import com.intellij.codeInspection.ProblemDescriptor;
@@ -52,19 +53,19 @@
* @author max
*/
public class QuickFixAction extends AnAction {
- protected InspectionTool myTool;
+ protected final InspectionToolWrapper myToolWrapper;
public static InspectionResultsView getInvoker(AnActionEvent e) {
return InspectionResultsView.DATA_KEY.getData(e.getDataContext());
}
- protected QuickFixAction(String text, @NotNull InspectionTool tool) {
- this(text, AllIcons.Actions.CreateFromUsage, null, tool);
+ protected QuickFixAction(String text, @NotNull InspectionToolWrapper toolWrapper) {
+ this(text, AllIcons.Actions.CreateFromUsage, null, toolWrapper);
}
- protected QuickFixAction(String text, Icon icon, KeyStroke keyStroke, @NotNull InspectionTool tool) {
+ protected QuickFixAction(String text, Icon icon, KeyStroke keyStroke, @NotNull InspectionToolWrapper toolWrapper) {
super(text, null, icon);
- myTool = tool;
+ myToolWrapper = toolWrapper;
if (keyStroke != null) {
registerCustomShortcutSet(new CustomShortcutSet(keyStroke), null);
}
@@ -79,8 +80,8 @@
}
final InspectionTree tree = view.getTree();
- final InspectionTool tool = tree.getSelectedTool();
- if (!view.isSingleToolInSelection() || tool != myTool) {
+ final InspectionToolWrapper toolWrapper = tree.getSelectedToolWrapper();
+ if (!view.isSingleToolInSelection() || toolWrapper != myToolWrapper) {
e.getPresentation().setVisible(false);
e.getPresentation().setEnabled(false);
return;
@@ -117,9 +118,12 @@
}
- protected void applyFix(Project project, CommonProblemDescriptor[] descriptors, Set<PsiElement> ignoredElements) {}
- private void doApplyFix(final Project project,
- final CommonProblemDescriptor[] descriptors) {
+ protected void applyFix(@NotNull Project project,
+ @NotNull CommonProblemDescriptor[] descriptors,
+ @NotNull Set<PsiElement> ignoredElements) {
+ }
+
+ private void doApplyFix(@NotNull final Project project, @NotNull final CommonProblemDescriptor[] descriptors) {
final Set<VirtualFile> readOnlyFiles = new THashSet<VirtualFile>();
for (CommonProblemDescriptor descriptor : descriptors) {
final PsiElement psiElement = descriptor instanceof ProblemDescriptor ? ((ProblemDescriptor)descriptor).getPsiElement() : null;
@@ -128,12 +132,9 @@
}
}
- if (!readOnlyFiles.isEmpty()) {
- final ReadonlyStatusHandler.OperationStatus operationStatus = ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(VfsUtil.toVirtualFileArray(readOnlyFiles));
- if (operationStatus.hasReadonlyFiles()) return;
- }
+ if (!FileModificationService.getInstance().prepareVirtualFilesForWrite(project, readOnlyFiles)) return;
- final RefManagerImpl refManager = ((RefManagerImpl)myTool.getContext().getRefManager());
+ final RefManagerImpl refManager = (RefManagerImpl)myToolWrapper.getContext().getRefManager();
final boolean initial = refManager.isInProcess();
@@ -159,22 +160,22 @@
}
}, getTemplatePresentation().getText(), null);
- refreshViews(project, ignoredElements, myTool);
+ refreshViews(project, ignoredElements, myToolWrapper);
}
finally { //to make offline view lazy
if (initial) refManager.inspectionReadActionStarted();
}
}
- public void doApplyFix(final RefElement[] refElements, InspectionResultsView view) {
- final RefManagerImpl refManager = ((RefManagerImpl)myTool.getContext().getRefManager());
+ public void doApplyFix(@NotNull final RefEntity[] refElements, @NotNull InspectionResultsView view) {
+ final RefManagerImpl refManager = (RefManagerImpl)view.getGlobalInspectionContext().getRefManager();
final boolean initial = refManager.isInProcess();
refManager.inspectionReadActionFinished();
try {
- final boolean[] refreshNeeded = new boolean[]{false};
+ final boolean[] refreshNeeded = {false};
if (refElements.length > 0) {
final Project project = refElements[0].getRefManager().getProject();
CommandProcessor.getInstance().executeCommand(project, new Runnable() {
@@ -191,7 +192,7 @@
}, getTemplatePresentation().getText(), null);
}
if (refreshNeeded[0]) {
- refreshViews(view.getProject(), refElements, myTool);
+ refreshViews(view.getProject(), refElements, myToolWrapper);
}
}
finally { //to make offline view lazy
@@ -199,26 +200,26 @@
}
}
- public static void removeElements(final RefElement[] refElements, final Project project, final InspectionTool tool) {
- refreshViews(project, refElements, tool);
+ public static void removeElements(@NotNull RefEntity[] refElements, @NotNull Project project, @NotNull InspectionToolWrapper toolWrapper) {
+ refreshViews(project, refElements, toolWrapper);
final ArrayList<RefElement> deletedRefs = new ArrayList<RefElement>(1);
- for (RefElement refElement : refElements) {
- if (refElement == null) continue;
- refElement.getRefManager().removeRefElement(refElement, deletedRefs);
+ for (RefEntity refElement : refElements) {
+ if (!(refElement instanceof RefElement)) continue;
+ refElement.getRefManager().removeRefElement((RefElement)refElement, deletedRefs);
}
}
- private static Set<VirtualFile> getReadOnlyFiles(final RefElement[] refElements) {
+ private static Set<VirtualFile> getReadOnlyFiles(final RefEntity[] refElements) {
Set<VirtualFile> readOnlyFiles = new THashSet<VirtualFile>();
- for (RefElement refElement : refElements) {
- PsiElement psiElement = refElement.getElement();
+ for (RefEntity refElement : refElements) {
+ PsiElement psiElement = refElement instanceof RefElement ? ((RefElement)refElement).getElement() : null;
if (psiElement == null || psiElement.getContainingFile() == null) continue;
readOnlyFiles.add(psiElement.getContainingFile().getVirtualFile());
}
return readOnlyFiles;
}
- private static RefElement[] getSelectedElements(AnActionEvent e) {
+ private static RefEntity[] getSelectedElements(AnActionEvent e) {
final InspectionResultsView invoker = getInvoker(e);
if (invoker == null) return new RefElement[0];
List<RefEntity> selection = new ArrayList<RefEntity>(Arrays.asList(invoker.getTree().getSelectedElements()));
@@ -255,35 +256,36 @@
}
});
- return selection.toArray(new RefElement[selection.size()]);
+ return selection.toArray(new RefEntity[selection.size()]);
}
- private static void refreshViews(final Project project, final Set<PsiElement> selectedElements, final InspectionTool tool) {
+ private static void refreshViews(@NotNull Project project, @NotNull Set<PsiElement> selectedElements, @NotNull InspectionToolWrapper toolWrapper) {
InspectionManagerEx managerEx = (InspectionManagerEx)InspectionManager.getInstance(project);
final Set<GlobalInspectionContextImpl> runningContexts = managerEx.getRunningContexts();
for (GlobalInspectionContextImpl context : runningContexts) {
for (PsiElement element : selectedElements) {
- context.ignoreElement(tool, element);
+ context.ignoreElement(toolWrapper.getTool(), element);
}
context.refreshViews();
}
}
- private static void refreshViews(final Project project, final RefElement[] refElements, final InspectionTool tool) {
+ private static void refreshViews(@NotNull Project project, @NotNull RefEntity[] refElements, @NotNull InspectionToolWrapper toolWrapper) {
final Set<PsiElement> ignoredElements = new HashSet<PsiElement>();
- for (RefElement element : refElements) {
- final PsiElement psiElement = element != null ? element.getElement() : null;
+ for (RefEntity element : refElements) {
+ final PsiElement psiElement = element instanceof RefElement ? ((RefElement)element).getElement() : null;
if (psiElement != null && psiElement.isValid()) {
ignoredElements.add(psiElement);
}
}
- refreshViews(project, ignoredElements, tool);
+ refreshViews(project, ignoredElements, toolWrapper);
}
/**
* @return true if immediate UI update needed.
+ * @param refElements
*/
- protected boolean applyFix(RefElement[] refElements) {
+ protected boolean applyFix(RefEntity[] refElements) {
Set<VirtualFile> readOnlyFiles = getReadOnlyFiles(refElements);
if (!readOnlyFiles.isEmpty()) {
final Project project = refElements[0].getRefManager().getProject();
@@ -294,19 +296,21 @@
}
private class PerformFixesTask implements SequentialTask {
+ @NotNull
private final Project myProject;
private final CommonProblemDescriptor[] myDescriptors;
+ @NotNull
private final Set<PsiElement> myIgnoredElements;
private final SequentialModalProgressTask myTask;
private int myCount = 0;
- public PerformFixesTask(Project project,
- CommonProblemDescriptor[] descriptors,
- Set<PsiElement> elements,
- SequentialModalProgressTask task) {
+ public PerformFixesTask(@NotNull Project project,
+ @NotNull CommonProblemDescriptor[] descriptors,
+ @NotNull Set<PsiElement> ignoredElements,
+ @NotNull SequentialModalProgressTask task) {
myProject = project;
myDescriptors = descriptors;
- myIgnoredElements = elements;
+ myIgnoredElements = ignoredElements;
myTask = task;
}
@@ -324,7 +328,7 @@
final CommonProblemDescriptor descriptor = myDescriptors[myCount++];
ProgressIndicator indicator = myTask.getIndicator();
if (indicator != null) {
- indicator.setFraction(((double)myCount) / myDescriptors.length);
+ indicator.setFraction((double)myCount / myDescriptors.length);
if (descriptor instanceof ProblemDescriptor) {
final PsiElement psiElement = ((ProblemDescriptor)descriptor).getPsiElement();
if (psiElement != null) {
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/QuickFixWrapper.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/QuickFixWrapper.java
index 9a94bbe..98c183c 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/ex/QuickFixWrapper.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/QuickFixWrapper.java
@@ -25,7 +25,6 @@
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Comparing;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.util.IncorrectOperationException;
@@ -81,15 +80,13 @@
//if (!CodeInsightUtil.prepareFileForWrite(file)) return;
// consider all local quick fixes do it themselves
+ final PsiElement element = myDescriptor.getPsiElement();
+ final PsiFile fileForUndo = element == null ? null : element.getContainingFile();
LocalQuickFix fix = getFix();
fix.applyFix(project, myDescriptor);
DaemonCodeAnalyzer.getInstance(project).restart();
- final PsiElement element = myDescriptor.getPsiElement();
- if (element != null) {
- final PsiFile fileForUndo = element.getContainingFile();
- if (!Comparing.equal(fileForUndo, file)) {
- UndoUtil.markPsiFileForUndo(fileForUndo);
- }
+ if (fileForUndo != null && !fileForUndo.equals(file)) {
+ UndoUtil.markPsiFileForUndo(fileForUndo);
}
}
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/export/HTMLExportFrameMaker.java b/platform/lang-impl/src/com/intellij/codeInspection/export/HTMLExportFrameMaker.java
index 5399d1a..4b71d9c 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/export/HTMLExportFrameMaker.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/export/HTMLExportFrameMaker.java
@@ -25,7 +25,7 @@
package com.intellij.codeInspection.export;
import com.intellij.codeInspection.InspectionsBundle;
-import com.intellij.codeInspection.ex.InspectionTool;
+import com.intellij.codeInspection.ex.InspectionToolWrapper;
import com.intellij.openapi.application.ApplicationNamesInfo;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NonNls;
@@ -37,12 +37,11 @@
public class HTMLExportFrameMaker {
private final String myRootFolder;
private final Project myProject;
- private final List<InspectionTool> myInspectionTools;
+ private final List<InspectionToolWrapper> myInspectionToolWrappers = new ArrayList<InspectionToolWrapper>();
public HTMLExportFrameMaker(String rootFolder, Project project) {
myRootFolder = rootFolder;
myProject = project;
- myInspectionTools = new ArrayList<InspectionTool>();
}
@SuppressWarnings({"HardCodedStringLiteral"})
@@ -56,19 +55,19 @@
public void done() {
StringBuffer buf = new StringBuffer();
- for (InspectionTool tool : myInspectionTools) {
+ for (InspectionToolWrapper toolWrapper : myInspectionToolWrappers) {
buf.append("<A HREF=\"");
- buf.append(tool.getFolderName());
+ buf.append(toolWrapper.getFolderName());
buf.append("-index.html\">");
- buf.append(tool.getDisplayName());
+ buf.append(toolWrapper.getDisplayName());
buf.append("</A><BR>");
}
HTMLExportUtil.writeFile(myRootFolder, "index.html", buf, myProject);
}
- public void startInspection(@NotNull InspectionTool tool) {
- myInspectionTools.add(tool);
+ public void startInspection(@NotNull InspectionToolWrapper toolWrapper) {
+ myInspectionToolWrappers.add(toolWrapper);
@NonNls StringBuffer buf = new StringBuffer();
buf.append("<HTML><HEAD><TITLE>");
buf.append(ApplicationNamesInfo.getInstance().getFullProductName());
@@ -76,14 +75,14 @@
buf.append("</TITLE></HEAD>");
buf.append("<FRAMESET cols=\"30%,70%\"><FRAMESET rows=\"30%,70%\">");
buf.append("<FRAME src=\"");
- buf.append(tool.getFolderName());
+ buf.append(toolWrapper.getFolderName());
buf.append("/index.html\" name=\"inspectionFrame\">");
buf.append("<FRAME src=\"empty.html\" name=\"packageFrame\">");
buf.append("</FRAMESET>");
buf.append("<FRAME src=\"empty.html\" name=\"elementFrame\">");
buf.append("</FRAMESET></BODY></HTML");
- HTMLExportUtil.writeFile(myRootFolder, tool.getFolderName() + "-index.html", buf, myProject);
+ HTMLExportUtil.writeFile(myRootFolder, toolWrapper.getFolderName() + "-index.html", buf, myProject);
}
public String getRootFolder() {
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineInspectionRVContentProvider.java b/platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineInspectionRVContentProvider.java
index 87d0d29..ae4a260 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineInspectionRVContentProvider.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineInspectionRVContentProvider.java
@@ -52,14 +52,15 @@
}
@Override
- public boolean checkReportedProblems(@NotNull final InspectionTool tool) {
- final Map<String, Set<OfflineProblemDescriptor>> content = getFilteredContent(tool);
+ public boolean checkReportedProblems(@NotNull GlobalInspectionContextImpl context,
+ @NotNull final InspectionToolWrapper toolWrapper) {
+ final Map<String, Set<OfflineProblemDescriptor>> content = getFilteredContent(context, toolWrapper);
return content != null && !content.values().isEmpty();
}
@Override
@Nullable
- public QuickFixAction[] getQuickFixes(@NotNull final InspectionTool tool, @NotNull final InspectionTree tree) {
+ public QuickFixAction[] getQuickFixes(@NotNull final InspectionToolWrapper toolWrapper, @NotNull final InspectionTree tree) {
final TreePath[] treePaths = tree.getSelectionPaths();
final List<RefEntity> selectedElements = new ArrayList<RefEntity>();
final Map<RefEntity, Set<QuickFix>> actions = new HashMap<RefEntity, Set<QuickFix>>();
@@ -97,11 +98,8 @@
final RefEntity[] selectedRefElements = selectedElements.toArray(new RefEntity[selectedElements.size()]);
- if (tool instanceof DescriptorProviderInspection && !(tool instanceof CommonInspectionToolWrapper)) {
- return ((DescriptorProviderInspection)tool).extractActiveFixes(selectedRefElements, actions);
- }
-
- return tool.getQuickFixes(selectedRefElements);
+ InspectionToolPresentation presentation = ((GlobalInspectionContextImpl)toolWrapper.getContext()).getPresentation(toolWrapper);
+ return presentation.extractActiveFixes(selectedRefElements, actions);
}
@Override
@@ -110,14 +108,15 @@
}
@Override
- public void appendToolNodeContent(final InspectionNode toolNode,
- final InspectionTreeNode parentNode,
+ public void appendToolNodeContent(@NotNull GlobalInspectionContextImpl context,
+ @NotNull final InspectionNode toolNode,
+ @NotNull final InspectionTreeNode parentNode,
final boolean showStructure,
- final Map<String, Set<RefEntity>> contents,
- final Map<RefEntity, CommonProblemDescriptor[]> problems,
+ @NotNull final Map<String, Set<RefEntity>> contents,
+ @NotNull final Map<RefEntity, CommonProblemDescriptor[]> problems,
final DefaultTreeModel model) {
- final InspectionTool tool = toolNode.getTool();
- final Map<String, Set<OfflineProblemDescriptor>> filteredContent = getFilteredContent(tool);
+ InspectionToolWrapper toolWrapper = toolNode.getToolWrapper();
+ final Map<String, Set<OfflineProblemDescriptor>> filteredContent = getFilteredContent(context, toolWrapper);
if (filteredContent != null && !filteredContent.values().isEmpty()) {
final Function<OfflineProblemDescriptor, UserObjectContainer<OfflineProblemDescriptor>> computeContainer =
new Function<OfflineProblemDescriptor, UserObjectContainer<OfflineProblemDescriptor>>() {
@@ -126,7 +125,7 @@
return new OfflineProblemDescriptorContainer(descriptor);
}
};
- final List<InspectionTreeNode> list = buildTree(filteredContent, false, tool, computeContainer, showStructure);
+ final List<InspectionTreeNode> list = buildTree(context, filteredContent, false, toolWrapper, computeContainer, showStructure);
for (InspectionTreeNode node : list) {
toolNode.add(node);
}
@@ -136,13 +135,15 @@
@Nullable
@SuppressWarnings({"UnusedAssignment"})
- private Map<String, Set<OfflineProblemDescriptor>> getFilteredContent(@NotNull InspectionTool tool) {
- Map<String, Set<OfflineProblemDescriptor>> content = myContent.get(tool.getShortName());
+ private Map<String, Set<OfflineProblemDescriptor>> getFilteredContent(@NotNull GlobalInspectionContextImpl context,
+ @NotNull InspectionToolWrapper toolWrapper) {
+ Map<String, Set<OfflineProblemDescriptor>> content = myContent.get(toolWrapper.getShortName());
if (content == null) return null;
- if (tool.getContext().getUIOptions().FILTER_RESOLVED_ITEMS) {
+ if (context.getUIOptions().FILTER_RESOLVED_ITEMS) {
final Map<String, Set<OfflineProblemDescriptor>> current = new HashMap<String, Set<OfflineProblemDescriptor>>(content);
content = null; //GC it
- for (RefEntity refEntity : tool.getIgnoredRefElements()) {
+ InspectionToolPresentation presentation = context.getPresentation(toolWrapper);
+ for (RefEntity refEntity : presentation.getIgnoredRefElements()) {
if (refEntity instanceof RefElement) {
excludeProblem(refEntity.getExternalName(), current);
}
@@ -171,13 +172,16 @@
}
@Override
- protected void appendDescriptor(final InspectionTool tool,
- final UserObjectContainer container,
- final InspectionPackageNode packageNode,
+ protected void appendDescriptor(@NotNull GlobalInspectionContextImpl context,
+ @NotNull final InspectionToolWrapper toolWrapper,
+ @NotNull final UserObjectContainer container,
+ @NotNull final InspectionPackageNode packageNode,
final boolean canPackageRepeat) {
- final RefElementNode elemNode = addNodeToParent(container, tool, packageNode);
- if (tool instanceof DescriptorProviderInspection && !(tool instanceof CommonInspectionToolWrapper)) {
- elemNode.add(new OfflineProblemDescriptorNode(((OfflineProblemDescriptorContainer)container).getUserObject(), (DescriptorProviderInspection)tool));
+ InspectionToolPresentation presentation = context.getPresentation(toolWrapper);
+ final RefElementNode elemNode = addNodeToParent(container, presentation, packageNode);
+ if (toolWrapper instanceof LocalInspectionToolWrapper) {
+ elemNode.add(new OfflineProblemDescriptorNode(((OfflineProblemDescriptorContainer)container).getUserObject(),
+ (LocalInspectionToolWrapper)toolWrapper));
}
}
@@ -203,8 +207,8 @@
@NotNull
@Override
- public RefElementNode createNode(@NotNull InspectionTool tool) {
- return new OfflineRefElementNode(myDescriptor, tool);
+ public RefElementNode createNode(@NotNull InspectionToolPresentation presentation) {
+ return new OfflineRefElementNode(myDescriptor, presentation);
}
@Override
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineProblemDescriptorNode.java b/platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineProblemDescriptorNode.java
index 0bf450f..bdd9a39 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineProblemDescriptorNode.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineProblemDescriptorNode.java
@@ -24,25 +24,28 @@
import com.intellij.codeInsight.daemon.impl.analysis.HighlightLevelUtil;
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.codeInspection.*;
-import com.intellij.codeInspection.ex.DescriptorProviderInspection;
+import com.intellij.codeInspection.ex.GlobalInspectionContextImpl;
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
import com.intellij.codeInspection.ex.QuickFixWrapper;
import com.intellij.codeInspection.offline.OfflineProblemDescriptor;
import com.intellij.codeInspection.reference.RefElement;
import com.intellij.codeInspection.reference.RefEntity;
+import com.intellij.codeInspection.ui.InspectionToolPresentation;
import com.intellij.codeInspection.ui.ProblemDescriptionNode;
import com.intellij.lang.Language;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiUtilCore;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
public class OfflineProblemDescriptorNode extends ProblemDescriptionNode {
-
- public OfflineProblemDescriptorNode(final OfflineProblemDescriptor descriptor,
- final DescriptorProviderInspection tool) {
- super(descriptor, tool);
+ public OfflineProblemDescriptorNode(final OfflineProblemDescriptor descriptor, @NotNull LocalInspectionToolWrapper toolWrapper) {
+ super(descriptor, toolWrapper);
}
private static PsiElement[] getElementsIntersectingRange(PsiFile file, final int startOffset, final int endOffset) {
@@ -66,7 +69,7 @@
if (userObject == null) {
return null;
}
- myElement = ((OfflineProblemDescriptor)userObject).getRefElement(myTool.getContext().getRefManager());
+ myElement = ((OfflineProblemDescriptor)userObject).getRefElement(myToolWrapper.getContext().getRefManager());
return myElement;
}
@@ -77,42 +80,41 @@
if (userObject instanceof CommonProblemDescriptor) {
return (CommonProblemDescriptor)userObject;
}
- final InspectionManager inspectionManager = InspectionManager.getInstance(myTool.getContext().getProject());
+
+ final InspectionManager inspectionManager = InspectionManager.getInstance(myToolWrapper.getContext().getProject());
final OfflineProblemDescriptor offlineProblemDescriptor = (OfflineProblemDescriptor)userObject;
final RefEntity element = getElement();
- if (myTool instanceof LocalInspectionToolWrapper) {
+ if (myToolWrapper instanceof LocalInspectionToolWrapper) {
if (element instanceof RefElement) {
final PsiElement psiElement = ((RefElement)element).getElement();
if (psiElement != null) {
PsiFile containingFile = psiElement.getContainingFile();
final ProblemsHolder holder = new ProblemsHolder(inspectionManager, containingFile, false);
- final LocalInspectionTool localInspectionTool = ((LocalInspectionToolWrapper)myTool).getTool();
+ final LocalInspectionTool localTool = ((LocalInspectionToolWrapper)myToolWrapper).getTool();
final int startOffset = psiElement.getTextRange().getStartOffset();
final int endOffset = psiElement.getTextRange().getEndOffset();
LocalInspectionToolSession session = new LocalInspectionToolSession(containingFile, startOffset, endOffset);
- final PsiElementVisitor visitor = localInspectionTool.buildVisitor(holder, false, session);
- localInspectionTool.inspectionStarted(session, false);
+ final PsiElementVisitor visitor = localTool.buildVisitor(holder, false, session);
+ localTool.inspectionStarted(session, false);
final PsiElement[] elementsInRange = getElementsIntersectingRange(containingFile,
startOffset,
endOffset);
for (PsiElement el : elementsInRange) {
el.accept(visitor);
}
- localInspectionTool.inspectionFinished(session, holder);
+ localTool.inspectionFinished(session, holder);
if (holder.hasResults()) {
final List<ProblemDescriptor> list = holder.getResults();
final int idx = offlineProblemDescriptor.getProblemIndex();
- if (list != null) {
- int curIdx = 0;
- for (ProblemDescriptor descriptor : list) {
- final PsiNamedElement member = localInspectionTool.getProblemElement(descriptor.getPsiElement());
- if (psiElement instanceof PsiFile || member != null && member.equals(psiElement)) {
- if (curIdx == idx) {
- setUserObject(descriptor);
- return descriptor;
- }
- curIdx++;
+ int curIdx = 0;
+ for (ProblemDescriptor descriptor : list) {
+ final PsiNamedElement member = localTool.getProblemElement(descriptor.getPsiElement());
+ if (psiElement instanceof PsiFile || member != null && member.equals(psiElement)) {
+ if (curIdx == idx) {
+ setUserObject(descriptor);
+ return descriptor;
}
+ curIdx++;
}
}
}
@@ -147,11 +149,12 @@
}
@Nullable
- private LocalQuickFix[] getFixes(CommonProblemDescriptor descriptor, List<String> hints) {
- final List<LocalQuickFix> fixes = new ArrayList<LocalQuickFix>();
+ private LocalQuickFix[] getFixes(@NotNull CommonProblemDescriptor descriptor, List<String> hints) {
+ final List<LocalQuickFix> fixes = new ArrayList<LocalQuickFix>(hints == null ? 1 : hints.size());
if (hints == null) {
addFix(descriptor, fixes, null);
- } else {
+ }
+ else {
for (String hint : hints) {
addFix(descriptor, fixes, hint);
}
@@ -159,8 +162,9 @@
return fixes.isEmpty() ? null : fixes.toArray(new LocalQuickFix[fixes.size()]);
}
- private void addFix(final CommonProblemDescriptor descriptor, final List<LocalQuickFix> fixes, String hint) {
- final IntentionAction intentionAction = myTool.findQuickFixes(descriptor, hint);
+ private void addFix(@NotNull CommonProblemDescriptor descriptor, final List<LocalQuickFix> fixes, String hint) {
+ InspectionToolPresentation presentation = ((GlobalInspectionContextImpl)myToolWrapper.getContext()).getPresentation(myToolWrapper);
+ final IntentionAction intentionAction = presentation.findQuickFixes(descriptor, hint);
if (intentionAction instanceof QuickFixWrapper) {
fixes.add(((QuickFixWrapper)intentionAction).getFix());
}
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineRefElementNode.java b/platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineRefElementNode.java
index 456ff51..50f3a78 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineRefElementNode.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineRefElementNode.java
@@ -20,17 +20,16 @@
*/
package com.intellij.codeInspection.offlineViewer;
-import com.intellij.codeInspection.ex.InspectionTool;
import com.intellij.codeInspection.offline.OfflineProblemDescriptor;
import com.intellij.codeInspection.reference.RefEntity;
+import com.intellij.codeInspection.ui.InspectionToolPresentation;
import com.intellij.codeInspection.ui.RefElementNode;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class OfflineRefElementNode extends RefElementNode {
-
- public OfflineRefElementNode(@NotNull OfflineProblemDescriptor descriptor, @NotNull InspectionTool inspectionTool) {
- super(descriptor, inspectionTool);
+ public OfflineRefElementNode(@NotNull OfflineProblemDescriptor descriptor, @NotNull InspectionToolPresentation presentation) {
+ super(descriptor, presentation);
}
@Override
@@ -40,7 +39,7 @@
return (RefEntity)userObject;
}
if (userObject == null) return null;
- final RefEntity refElement = ((OfflineProblemDescriptor)userObject).getRefElement(myTool.getContext().getRefManager());
+ final RefEntity refElement = ((OfflineProblemDescriptor)userObject).getRefElement(myToolPresentation.getContext().getRefManager());
setUserObject(refElement);
return refElement;
}
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/Browser.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/Browser.java
index 66faa3f..cd9dbf3 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/ui/Browser.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/Browser.java
@@ -41,6 +41,7 @@
import com.intellij.util.ui.UIUtil;
import com.intellij.xml.util.XmlStringUtil;
import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
@@ -120,23 +121,16 @@
void referenceClicked(ClickEvent e);
}
- private void showPageFromHistory(RefEntity newEntity) {
- InspectionTool tool = getTool(newEntity);
+ private void showPageFromHistory(@NotNull RefEntity newEntity) {
+ InspectionToolWrapper toolWrapper = getToolWrapper(newEntity);
try {
- if (tool instanceof DescriptorProviderInspection && !(tool instanceof CommonInspectionToolWrapper)) {
- showEmpty();
- }
- else {
- try {
- String html = generateHTML(newEntity, tool);
- myHTMLViewer.read(new StringReader(html), null);
- setupStyle();
- myHTMLViewer.setCaretPosition(0);
- }
- catch (Exception e) {
- showEmpty();
- }
- }
+ String html = generateHTML(newEntity, toolWrapper);
+ myHTMLViewer.read(new StringReader(html), null);
+ setupStyle();
+ myHTMLViewer.setCaretPosition(0);
+ }
+ catch (Exception e) {
+ showEmpty();
}
finally {
myCurrentEntity = newEntity;
@@ -181,83 +175,7 @@
myHyperLinkListener = new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
- if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
- JEditorPane pane = (JEditorPane)e.getSource();
- if (e instanceof HTMLFrameHyperlinkEvent) {
- HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent)e;
- HTMLDocument doc = (HTMLDocument)pane.getDocument();
- doc.processHTMLFrameHyperlinkEvent(evt);
- }
- else {
- try {
- URL url = e.getURL();
- @NonNls String ref = url.getRef();
- if (ref.startsWith("pos:")) {
- int delimeterPos = ref.indexOf(':', "pos:".length() + 1);
- String startPosition = ref.substring("pos:".length(), delimeterPos);
- String endPosition = ref.substring(delimeterPos + 1);
- Integer textStartOffset = new Integer(startPosition);
- Integer textEndOffset = new Integer(endPosition);
- String fileURL = url.toExternalForm();
- fileURL = fileURL.substring(0, fileURL.indexOf('#'));
- VirtualFile vFile = VirtualFileManager.getInstance().findFileByUrl(fileURL);
- if (vFile != null) {
- fireClickEvent(vFile, textStartOffset.intValue(), textEndOffset.intValue());
- }
- }
- else if (ref.startsWith("descr:")) {
- if (myCurrentDescriptor instanceof ProblemDescriptor) {
- PsiElement psiElement = ((ProblemDescriptor)myCurrentDescriptor).getPsiElement();
- if (psiElement == null) return;
- VirtualFile vFile = psiElement.getContainingFile().getVirtualFile();
- if (vFile != null) {
- TextRange range = ((ProblemDescriptorBase)myCurrentDescriptor).getTextRange();
- fireClickEvent(vFile, range.getStartOffset(), range.getEndOffset());
- }
- }
- }
- else if (ref.startsWith("invoke:")) {
- int actionNumber = Integer.parseInt(ref.substring("invoke:".length()));
- getTool().getQuickFixes(new RefElement[]{(RefElement)myCurrentEntity})[actionNumber]
- .doApplyFix(new RefElement[]{(RefElement)myCurrentEntity}, myView);
- }
- else if (ref.startsWith("invokelocal:")) {
- int actionNumber = Integer.parseInt(ref.substring("invokelocal:".length()));
- if (actionNumber > -1) {
- invokeLocalFix(actionNumber);
- }
- } else if (ref.startsWith("suppress:")){
- final SuppressActionWrapper.SuppressTreeAction[] suppressTreeActions =
- new SuppressActionWrapper(myView.getProject(), getTool(), myView.getTree().getSelectionPaths()).getChildren(null);
- final List<AnAction> activeActions = new ArrayList<AnAction>();
- for (SuppressActionWrapper.SuppressTreeAction suppressTreeAction : suppressTreeActions) {
- if (suppressTreeAction.isAvailable()) activeActions.add(suppressTreeAction);
- }
- if (!activeActions.isEmpty()) {
- int actionNumber = Integer.parseInt(ref.substring("suppress:".length()));
- if (actionNumber > -1 && activeActions.size() > actionNumber) {
- activeActions.get(actionNumber).actionPerformed(null);
- }
- }
- }
- else {
- int offset = Integer.parseInt(ref);
- String fileURL = url.toExternalForm();
- fileURL = fileURL.substring(0, fileURL.indexOf('#'));
- VirtualFile vFile = VirtualFileManager.getInstance().findFileByUrl(fileURL);
- if (vFile == null) {
- vFile = VfsUtil.findFileByURL(url);
- }
- if (vFile != null) {
- fireClickEvent(vFile, offset, offset);
- }
- }
- }
- catch (Throwable t) {
- //???
- }
- }
- }
+ Browser.this.hyperlinkUpdate(e);
}
};
myHTMLViewer.addHyperlinkListener(myHyperLinkListener);
@@ -268,6 +186,88 @@
setupStyle();
}
+ private void hyperlinkUpdate(HyperlinkEvent e) {
+ if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED) {
+ return;
+ }
+ JEditorPane pane = (JEditorPane)e.getSource();
+ if (e instanceof HTMLFrameHyperlinkEvent) {
+ HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent)e;
+ HTMLDocument doc = (HTMLDocument)pane.getDocument();
+ doc.processHTMLFrameHyperlinkEvent(evt);
+ return;
+ }
+ try {
+ URL url = e.getURL();
+ @NonNls String ref = url.getRef();
+ if (ref.startsWith("pos:")) {
+ int delimeterPos = ref.indexOf(':', "pos:".length() + 1);
+ String startPosition = ref.substring("pos:".length(), delimeterPos);
+ String endPosition = ref.substring(delimeterPos + 1);
+ Integer textStartOffset = new Integer(startPosition);
+ Integer textEndOffset = new Integer(endPosition);
+ String fileURL = url.toExternalForm();
+ fileURL = fileURL.substring(0, fileURL.indexOf('#'));
+ VirtualFile vFile = VirtualFileManager.getInstance().findFileByUrl(fileURL);
+ if (vFile != null) {
+ fireClickEvent(vFile, textStartOffset.intValue(), textEndOffset.intValue());
+ }
+ }
+ else if (ref.startsWith("descr:")) {
+ if (myCurrentDescriptor instanceof ProblemDescriptor) {
+ PsiElement psiElement = ((ProblemDescriptor)myCurrentDescriptor).getPsiElement();
+ if (psiElement == null) return;
+ VirtualFile vFile = psiElement.getContainingFile().getVirtualFile();
+ if (vFile != null) {
+ TextRange range = ((ProblemDescriptorBase)myCurrentDescriptor).getTextRange();
+ fireClickEvent(vFile, range.getStartOffset(), range.getEndOffset());
+ }
+ }
+ }
+ else if (ref.startsWith("invoke:")) {
+ int actionNumber = Integer.parseInt(ref.substring("invoke:".length()));
+ InspectionToolWrapper toolWrapper = getToolWrapper();
+ InspectionToolPresentation presentation = myView.getGlobalInspectionContext().getPresentation(toolWrapper);
+ QuickFixAction fixAction = presentation.getQuickFixes(new RefElement[]{(RefElement)myCurrentEntity})[actionNumber];
+ fixAction.doApplyFix(new RefElement[]{(RefElement)myCurrentEntity}, myView);
+ }
+ else if (ref.startsWith("invokelocal:")) {
+ int actionNumber = Integer.parseInt(ref.substring("invokelocal:".length()));
+ if (actionNumber > -1) {
+ invokeLocalFix(actionNumber);
+ }
+ } else if (ref.startsWith("suppress:")){
+ final SuppressActionWrapper.SuppressTreeAction[] suppressTreeActions =
+ new SuppressActionWrapper(myView.getProject(), getToolWrapper(), myView.getTree().getSelectionPaths()).getChildren(null);
+ final List<AnAction> activeActions = new ArrayList<AnAction>();
+ for (SuppressActionWrapper.SuppressTreeAction suppressTreeAction : suppressTreeActions) {
+ if (suppressTreeAction.isAvailable()) activeActions.add(suppressTreeAction);
+ }
+ if (!activeActions.isEmpty()) {
+ int actionNumber = Integer.parseInt(ref.substring("suppress:".length()));
+ if (actionNumber > -1 && activeActions.size() > actionNumber) {
+ activeActions.get(actionNumber).actionPerformed(null);
+ }
+ }
+ }
+ else {
+ int offset = Integer.parseInt(ref);
+ String fileURL = url.toExternalForm();
+ fileURL = fileURL.substring(0, fileURL.indexOf('#'));
+ VirtualFile vFile = VirtualFileManager.getInstance().findFileByUrl(fileURL);
+ if (vFile == null) {
+ vFile = VfsUtil.findFileByURL(url);
+ }
+ if (vFile != null) {
+ fireClickEvent(vFile, offset, offset);
+ }
+ }
+ }
+ catch (Throwable t) {
+ //???
+ }
+ }
+
private void setupStyle() {
Document document = myHTMLViewer.getDocument();
if (!(document instanceof StyledDocument)) {
@@ -297,19 +297,19 @@
}
}
- private String generateHTML(final RefEntity refEntity, final InspectionTool tool) {
+ private String generateHTML(final RefEntity refEntity, @NotNull final InspectionToolWrapper toolWrapper) {
final StringBuffer buf = new StringBuffer();
+ final HTMLComposerImpl htmlComposer = getPresentation(toolWrapper).getComposer();
if (refEntity instanceof RefElement) {
- final Runnable action = new Runnable() {
+ ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
- tool.getComposer().compose(buf, refEntity);
+ htmlComposer.compose(buf, refEntity);
}
- };
- ApplicationManager.getApplication().runReadAction(action);
+ });
}
else {
- tool.getComposer().compose(buf, refEntity);
+ htmlComposer.compose(buf, refEntity);
}
uppercaseFirstLetter(buf);
@@ -323,6 +323,10 @@
return buf.toString();
}
+ private static InspectionToolPresentation getPresentation(@NotNull InspectionToolWrapper toolWrapper) {
+ return ((GlobalInspectionContextImpl)toolWrapper.getContext()).getPresentation(toolWrapper);
+ }
+
@SuppressWarnings({"HardCodedStringLiteral"})
private static void insertHeaderFooter(final StringBuffer buf) {
buf.insert(0, "<HTML><BODY>");
@@ -334,8 +338,8 @@
final Runnable action = new Runnable() {
@Override
public void run() {
- InspectionTool tool = getTool(refEntity);
- tool.getComposer().compose(buf, refEntity, descriptor);
+ InspectionToolWrapper toolWrapper = getToolWrapper(refEntity);
+ getPresentation(toolWrapper).getComposer().compose(buf, refEntity, descriptor);
}
};
ApplicationManager.getApplication().runReadAction(action);
@@ -350,26 +354,25 @@
return buf.toString();
}
- private InspectionTool getTool(final RefEntity refEntity) {
- InspectionTool tool = getTool();
- assert tool != null;
- final GlobalInspectionContextImpl manager = tool.getContext();
- if (manager == null) return tool;
+ private InspectionToolWrapper getToolWrapper(final RefEntity refEntity) {
+ InspectionToolWrapper toolWrapper = getToolWrapper();
+ assert toolWrapper != null;
+ final GlobalInspectionContextImpl context = myView.getGlobalInspectionContext();
if (refEntity instanceof RefElement){
PsiElement element = ((RefElement)refEntity).getElement();
- if (element == null) return tool;
- InspectionProfileWrapper profileWrapper = InspectionProjectProfileManagerImpl.getInstanceImpl(manager.getProject()).getProfileWrapper();
- tool = (InspectionTool)profileWrapper.getInspectionTool(tool.getShortName(), element);
+ if (element == null) return toolWrapper;
+ InspectionProfileWrapper profileWrapper = InspectionProjectProfileManagerImpl.getInstanceImpl(context.getProject()).getProfileWrapper();
+ toolWrapper = profileWrapper.getInspectionTool(toolWrapper.getShortName(), element);
}
- return tool;
+ return toolWrapper;
}
private void appendSuppressSection(final StringBuffer buf) {
- final InspectionTool tool = getTool();
- if (tool != null) {
- final HighlightDisplayKey key = HighlightDisplayKey.find(tool.getShortName());
+ final InspectionToolWrapper toolWrapper = getToolWrapper();
+ if (toolWrapper != null) {
+ final HighlightDisplayKey key = HighlightDisplayKey.find(toolWrapper.getShortName());
if (key != null){//dummy entry points
- final SuppressActionWrapper.SuppressTreeAction[] suppressActions = new SuppressActionWrapper(myView.getProject(), tool, myView.getTree().getSelectionPaths()).getChildren(null);
+ final SuppressActionWrapper.SuppressTreeAction[] suppressActions = new SuppressActionWrapper(myView.getProject(), toolWrapper, myView.getTree().getSelectionPaths()).getChildren(null);
if (suppressActions.length > 0) {
final List<AnAction> activeSuppressActions = new ArrayList<AnAction>();
for (SuppressActionWrapper.SuppressTreeAction suppressAction : suppressActions) {
@@ -417,8 +420,8 @@
}
}
- public void showDescription(InspectionTool tool){
- if (tool.getShortName().length() == 0){
+ public void showDescription(@NotNull InspectionToolWrapper toolWrapper){
+ if (toolWrapper.getShortName().isEmpty()){
showEmpty();
return;
}
@@ -429,7 +432,7 @@
page.append("</td></tr>");
page.append("<tr><td width='37'></td>" +
"<td>");
- page.append(tool.getShortName());
+ page.append(toolWrapper.getShortName());
page.append("</td></tr>");
page.append("<tr height='10'></tr>");
page.append("<tr><td colspan='2'>");
@@ -439,7 +442,7 @@
"<td>");
@NonNls final String underConstruction = "<b>" + UNDER_CONSTRUCTION + "</b></html>";
try {
- @NonNls String description = tool.loadDescription();
+ @NonNls String description = toolWrapper.loadDescription();
if (description == null) {
description = underConstruction;
}
@@ -455,9 +458,9 @@
}
@Nullable
- private InspectionTool getTool() {
+ private InspectionToolWrapper getToolWrapper() {
if (myView != null){
- return myView.getTree().getSelectedTool();
+ return myView.getTree().getSelectedToolWrapper();
}
return null;
}
@@ -510,9 +513,11 @@
//CCE here means QuickFix was incorrectly inherited
fix.applyFix(myView.getProject(), descriptor);
if (startCount != tracker.getModificationCount()) {
- final DescriptorProviderInspection tool = ((DescriptorProviderInspection)myView.getTree().getSelectedTool());
- if (tool != null) {
- tool.ignoreProblem(element, descriptor, idx);
+ InspectionToolWrapper toolWrapper = myView.getTree().getSelectedToolWrapper();
+ if (toolWrapper != null) {
+ InspectionToolPresentation presentation =
+ myView.getGlobalInspectionContext().getPresentation(toolWrapper);
+ presentation.ignoreProblem(element, descriptor, idx);
}
myView.updateView(false);
}
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/DescriptorProviderInspection.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/DefaultInspectionToolPresentation.java
similarity index 63%
rename from platform/lang-impl/src/com/intellij/codeInspection/ex/DescriptorProviderInspection.java
rename to platform/lang-impl/src/com/intellij/codeInspection/ui/DefaultInspectionToolPresentation.java
index 4995cb6..7a2df51 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/ex/DescriptorProviderInspection.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/DefaultInspectionToolPresentation.java
@@ -13,25 +13,34 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+package com.intellij.codeInspection.ui;
-package com.intellij.codeInspection.ex;
-
+import com.intellij.codeHighlighting.HighlightDisplayLevel;
+import com.intellij.codeInsight.daemon.HighlightDisplayKey;
+import com.intellij.codeInsight.daemon.impl.HighlightInfoType;
+import com.intellij.codeInsight.daemon.impl.SeverityRegistrar;
+import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.codeInspection.*;
-import com.intellij.codeInspection.reference.RefElement;
-import com.intellij.codeInspection.reference.RefEntity;
-import com.intellij.codeInspection.reference.RefModule;
+import com.intellij.codeInspection.ex.*;
+import com.intellij.codeInspection.reference.*;
import com.intellij.lang.annotation.HighlightSeverity;
import com.intellij.openapi.components.PathMacroManager;
import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.JDOMUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.FileStatus;
+import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
+import com.intellij.profile.codeInspection.InspectionProjectProfileManagerImpl;
import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiFile;
import com.intellij.util.ArrayUtil;
+import com.intellij.util.IncorrectOperationException;
import com.intellij.util.containers.ContainerUtil;
-import com.intellij.util.containers.HashMap;
import com.intellij.util.containers.HashSet;
+import com.intellij.util.ui.UIUtil;
import gnu.trove.THashMap;
import org.jdom.Element;
import org.jdom.IllegalDataException;
@@ -39,13 +48,17 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import javax.swing.tree.DefaultTreeModel;
import java.io.*;
import java.util.*;
-/**
- * @author max
- */
-public abstract class DescriptorProviderInspection extends InspectionTool implements ProblemDescriptionsProcessor {
+public class DefaultInspectionToolPresentation implements ProblemDescriptionsProcessor, InspectionToolPresentation {
+ @NotNull private final InspectionToolWrapper myToolWrapper;
+
+ private GlobalInspectionContextImpl myContext;
+ protected static String ourOutputPath;
+ protected InspectionNode myToolNode;
+
private static final Object lock = new Object();
private Map<RefEntity, CommonProblemDescriptor[]> myProblemElements;
private Map<String, Set<RefEntity>> myContents = null;
@@ -58,16 +71,105 @@
private Map<RefEntity, CommonProblemDescriptor[]> myOldProblemElements = null;
protected static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.ex.DescriptorProviderInspection");
+ public DefaultInspectionToolPresentation(@NotNull InspectionToolWrapper toolWrapper) {
+ myToolWrapper = toolWrapper;
+ }
+
+ @NotNull
+ protected static FileStatus calcStatus(boolean old, boolean current) {
+ if (old) {
+ if (!current) {
+ return FileStatus.DELETED;
+ }
+ }
+ else if (current) {
+ return FileStatus.ADDED;
+ }
+ return FileStatus.NOT_CHANGED;
+ }
+
+ protected static HighlightSeverity getSeverity(@NotNull RefElement element,
+ @NotNull GlobalInspectionContextImpl context,
+ @NotNull InspectionToolWrapper thisToolWrapper) {
+ final PsiElement psiElement = element.getPointer().getContainingFile();
+ if (psiElement != null) {
+ String shortName = thisToolWrapper.getShortName();
+ final Tools tools = context.getTools().get(shortName);
+ if (tools != null) {
+ for (ScopeToolState state : tools.getTools()) {
+ InspectionToolWrapper toolWrapper = state.getTool();
+ if (toolWrapper == thisToolWrapper) {
+ return context.getCurrentProfile().getErrorLevel(HighlightDisplayKey.find(shortName), psiElement).getSeverity();
+ }
+ }
+ }
+
+ final InspectionProfile profile = InspectionProjectProfileManager.getInstance(context.getProject()).getInspectionProfile();
+ final HighlightDisplayLevel level = profile.getErrorLevel(HighlightDisplayKey.find(shortName), psiElement);
+ return level.getSeverity();
+ }
+ return null;
+ }
+
+ protected static String getTextAttributeKey(@NotNull Project project,
+ @NotNull HighlightSeverity severity,
+ @NotNull ProblemHighlightType highlightType) {
+ if (highlightType == ProblemHighlightType.LIKE_DEPRECATED) {
+ return HighlightInfoType.DEPRECATED.getAttributesKey().getExternalName();
+ }
+ if (highlightType == ProblemHighlightType.LIKE_UNKNOWN_SYMBOL && severity == HighlightSeverity.ERROR) {
+ return HighlightInfoType.WRONG_REF.getAttributesKey().getExternalName();
+ }
+ if (highlightType == ProblemHighlightType.LIKE_UNUSED_SYMBOL) {
+ return HighlightInfoType.UNUSED_SYMBOL.getAttributesKey().getExternalName();
+ }
+ SeverityRegistrar registrar = InspectionProjectProfileManagerImpl.getInstanceImpl(project).getSeverityRegistrar();
+ return registrar.getHighlightInfoTypeBySeverity(severity).getAttributesKey().getExternalName();
+ }
+
+ @NotNull
+ public InspectionToolWrapper getToolWrapper() {
+ return myToolWrapper;
+ }
+
+ @NotNull
+ public RefManager getRefManager() {
+ return getContext().getRefManager();
+ }
+ @Override
+ @NotNull
+ public GlobalInspectionContextImpl getContext() {
+ return myContext;
+ }
+
+ @Override
+ public void exportResults(@NotNull final Element parentNode) {
+ getRefManager().iterate(new RefVisitor(){
+ @Override
+ public void visitElement(@NotNull RefEntity elem) {
+ exportResults(parentNode, elem);
+ }
+ });
+ }
+
+ @Override
+ public boolean isOldProblemsIncluded() {
+ final GlobalInspectionContextImpl context = getContext();
+ return context != null && context.getUIOptions().SHOW_DIFF_WITH_PREVIOUS_RUN && getOldContent() != null;
+ }
+
+
@Override
public void addProblemElement(RefEntity refElement, @NotNull CommonProblemDescriptor... descriptions){
addProblemElement(refElement, true, descriptions);
}
- protected void addProblemElement(RefEntity refElement, boolean filterSuppressed, @NotNull CommonProblemDescriptor... descriptions) {
+ @Override
+ public void addProblemElement(RefEntity refElement, boolean filterSuppressed, @NotNull CommonProblemDescriptor... descriptions) {
if (refElement == null) return;
if (descriptions.length == 0) return;
if (filterSuppressed) {
- if (ourOutputPath == null || !(this instanceof LocalInspectionToolWrapper)) {
+ if (ourOutputPath == null || !(myToolWrapper instanceof LocalInspectionToolWrapper)) {
synchronized (lock) {
Map<RefEntity, CommonProblemDescriptor[]> problemElements = getProblemElements();
CommonProblemDescriptor[] problems = problemElements.get(refElement);
@@ -88,15 +190,59 @@
getProblemToElements().put(description, refElement);
}
}
+
+ final GlobalInspectionContextImpl context = getContext();
+ if (myToolWrapper instanceof LocalInspectionToolWrapper) {
+ final InspectionResultsView view = context.getView();
+ if (view == null || !(refElement instanceof RefElement)) {
+ return;
+ }
+ InspectionNode toolNode = myToolNode;
+ if (toolNode == null) {
+ final HighlightSeverity currentSeverity = getSeverity((RefElement)refElement, context, myToolWrapper);
+ view.addTool(myToolWrapper, HighlightDisplayLevel.find(currentSeverity), context.getUIOptions().GROUP_BY_SEVERITY);
+ }
+ else if (toolNode.isTooBigForOnlineRefresh()) {
+ return;
+ }
+ final HashMap<RefEntity, CommonProblemDescriptor[]> problems = new HashMap<RefEntity, CommonProblemDescriptor[]>();
+ problems.put(refElement, descriptions);
+ final HashMap<String, Set<RefEntity>> contents = new HashMap<String, Set<RefEntity>>();
+ final String groupName = refElement.getRefManager().getGroupName((RefElement)refElement);
+ Set<RefEntity> content = contents.get(groupName);
+ if (content == null) {
+ content = new HashSet<RefEntity>();
+ contents.put(groupName, content);
+ }
+ content.add(refElement);
+
+ UIUtil.invokeLaterIfNeeded(new Runnable() {
+ @Override
+ public void run() {
+ if (!isDisposed()) {
+ view.getProvider().appendToolNodeContent(context, myToolNode,
+ (InspectionTreeNode)myToolNode.getParent(), context.getUIOptions().SHOW_STRUCTURE,
+ contents, problems, (DefaultTreeModel)view.getTree().getModel());
+ context.addView(view);
+ }
+ }
+ });
+
+ }
}
+ private boolean isDisposed() {
+ return myContext == null;
+ }
+
+
private void writeOutput(@NotNull final CommonProblemDescriptor[] descriptions, @NotNull RefEntity refElement) {
final Element parentNode = new Element(InspectionsBundle.message("inspection.problems"));
exportResults(descriptions, refElement, parentNode);
final List list = parentNode.getChildren();
@NonNls final String ext = ".xml";
- final String fileName = ourOutputPath + File.separator + getShortName() + ext;
+ final String fileName = ourOutputPath + File.separator + myToolWrapper.getShortName() + ext;
final PathMacroManager pathMacroManager = PathMacroManager.getInstance(getContext().getProject());
PrintWriter printWriter = null;
try {
@@ -105,7 +251,7 @@
final CharArrayWriter writer = new CharArrayWriter();
if (!file.exists()) {
writer.append("<").append(InspectionsBundle.message("inspection.problems")).append(" " + GlobalInspectionContextImpl.LOCAL_TOOL_ATTRIBUTE + "=\"")
- .append(Boolean.toString(this instanceof LocalInspectionToolWrapper)).append("\">\n");
+ .append(Boolean.toString(myToolWrapper instanceof LocalInspectionToolWrapper)).append("\">\n");
}
for (Object o : list) {
final Element element = (Element)o;
@@ -126,12 +272,13 @@
}
}
+ @Override
@NotNull
public Collection<CommonProblemDescriptor> getProblemDescriptors() {
return getProblemToElements().keySet();
}
- private void collectQuickFixes(final QuickFix[] fixes, final RefEntity refEntity) {
+ private void collectQuickFixes(final QuickFix[] fixes, @NotNull RefEntity refEntity) {
if (fixes != null && fixes.length != 0) {
Set<QuickFix> localQuickFixes = getQuickFixActions().get(refEntity);
if (localQuickFixes == null) {
@@ -159,6 +306,7 @@
getIgnoredElements().remove(refEntity);
}
+ @Override
public void ignoreProblem(RefEntity refEntity, CommonProblemDescriptor problem, int idx) {
if (refEntity == null) return;
final Set<QuickFix> localQuickFixes = getQuickFixActions().get(refEntity);
@@ -191,6 +339,7 @@
getIgnoredElements().put(refEntity, problemDescriptors);
}
+ @Override
public void ignoreCurrentElementProblem(RefEntity refEntity, CommonProblemDescriptor descriptor) {
CommonProblemDescriptor[] descriptors = getIgnoredElements().get(refEntity);
if (descriptors == null) {
@@ -215,8 +364,14 @@
}
@Override
+ public void initialize(@NotNull GlobalInspectionContextImpl context) {
+ myContext = context;
+ }
+
+ @Override
public void cleanup() {
- super.cleanup();
+ myContext = null;
+
myOldProblemElements = null;
synchronized (lock) {
@@ -233,8 +388,8 @@
@Override
public void finalCleanup() {
- super.finalCleanup();
myOldProblemElements = null;
+ cleanup();
}
@Override
@@ -278,15 +433,15 @@
int line = description instanceof ProblemDescriptor ? ((ProblemDescriptor)description).getLineNumber() : -1;
final PsiElement psiElement = description instanceof ProblemDescriptor ? ((ProblemDescriptor)description).getPsiElement() : null;
@NonNls String problemText = StringUtil.replace(StringUtil.replace(template, "#ref", psiElement != null ? ProblemDescriptorUtil
- .extractHighlightedText(description, psiElement): "") , " #loc ", " ");
+ .extractHighlightedText(description, psiElement) : ""), " #loc ", " ");
Element element = refEntity.getRefManager().export(refEntity, parentNode, line);
if (element == null) return;
@NonNls Element problemClassElement = new Element(InspectionsBundle.message("inspection.export.results.problem.element.tag"));
- problemClassElement.addContent(getDisplayName());
+ problemClassElement.addContent(myToolWrapper.getDisplayName());
if (refEntity instanceof RefElement){
final RefElement refElement = (RefElement)refEntity;
- final HighlightSeverity severity = getCurrentSeverity(refElement);
+ final HighlightSeverity severity = getSeverity(refElement, getContext(), getToolWrapper());
ProblemHighlightType problemHighlightType = description instanceof ProblemDescriptor
? ((ProblemDescriptor)description).getHighlightType()
: ProblemHighlightType.GENERIC_ERROR_OR_WARNING;
@@ -295,8 +450,8 @@
problemClassElement.setAttribute("attribute_key", attributeKey);
}
element.addContent(problemClassElement);
- if (this instanceof GlobalInspectionToolWrapper) {
- final GlobalInspectionTool globalInspectionTool = ((GlobalInspectionToolWrapper)this).getTool();
+ if (myToolWrapper instanceof GlobalInspectionToolWrapper) {
+ final GlobalInspectionTool globalInspectionTool = ((GlobalInspectionToolWrapper)myToolWrapper).getTool();
final QuickFix[] fixes = description.getFixes();
if (fixes != null) {
@NonNls Element hintsElement = new Element("hints");
@@ -318,7 +473,7 @@
}
catch (IllegalDataException e) {
//noinspection HardCodedStringLiteral,UseOfSystemOutOrSystemErr
- System.out.println("Cannot save results for " + refEntity.getName() + ", inspection which caused problem: " + getShortName());
+ System.out.println("Cannot save results for " + refEntity.getName() + ", inspection which caused problem: " + myToolWrapper.getShortName());
}
}
}
@@ -354,7 +509,7 @@
@Override
public void updateContent() {
- myContents = new HashMap<String, Set<RefEntity>>();
+ myContents = new com.intellij.util.containers.HashMap<String, Set<RefEntity>>();
myModulesProblems = new HashSet<RefModule>();
final Set<RefEntity> elements = getProblemElements().keySet();
for (RefEntity element : elements) {
@@ -382,14 +537,15 @@
@Override
public Map<String, Set<RefEntity>> getOldContent() {
if (myOldProblemElements == null) return null;
- final HashMap<String, Set<RefEntity>> oldContents = new HashMap<String, Set<RefEntity>>();
+ final com.intellij.util.containers.HashMap<String, Set<RefEntity>>
+ oldContents = new com.intellij.util.containers.HashMap<String, Set<RefEntity>>();
final Set<RefEntity> elements = myOldProblemElements.keySet();
for (RefEntity element : elements) {
String groupName = element instanceof RefElement ? element.getRefManager().getGroupName((RefElement)element) : element.getName();
final Set<RefEntity> collection = myContents.get(groupName);
if (collection != null) {
final Set<RefEntity> currentElements = new HashSet<RefEntity>(collection);
- if (contains(element, currentElements)) continue;
+ if (RefUtil.contains(element, currentElements)) continue;
}
Set<RefEntity> oldContent = oldContents.get(groupName);
if (oldContent == null) {
@@ -407,13 +563,15 @@
}
@Override
+ @Nullable
public QuickFixAction[] getQuickFixes(@NotNull final RefEntity[] refElements) {
return extractActiveFixes(refElements, getQuickFixActions());
}
- public QuickFixAction[] extractActiveFixes(final RefEntity[] refElements, @NotNull Map<RefEntity, Set<QuickFix>> actions) {
- if (refElements == null) return null;
- Map<Class, QuickFixAction> result = new java.util.HashMap<Class, QuickFixAction>();
+ @Override
+ @Nullable
+ public QuickFixAction[] extractActiveFixes(@NotNull RefEntity[] refElements, @NotNull Map<RefEntity, Set<QuickFix>> actions) {
+ Map<Class, QuickFixAction> result = new com.intellij.util.containers.HashMap<Class, QuickFixAction>();
for (RefEntity refElement : refElements) {
final Set<QuickFix> localQuickFixes = actions.get(refElement);
if (localQuickFixes == null) continue;
@@ -421,7 +579,7 @@
if (fix == null) continue;
final Class klass = fix instanceof ActionClassHolder ? ((ActionClassHolder ) fix).getActionClass() : fix.getClass();
final QuickFixAction quickFixAction = result.get(klass);
- if (quickFixAction != null){
+ if (quickFixAction != null) {
try {
String familyName = fix.getFamilyName();
familyName = !familyName.isEmpty() ? "\'" + familyName + "\'" : familyName;
@@ -431,8 +589,9 @@
//for plugin compatibility
((LocalQuickFixWrapper)quickFixAction).setText(InspectionsBundle.message("inspection.descriptor.provider.apply.fix", ""));
}
- } else {
- LocalQuickFixWrapper quickFixWrapper = new LocalQuickFixWrapper(fix, this);
+ }
+ else {
+ LocalQuickFixWrapper quickFixWrapper = new LocalQuickFixWrapper(fix, myToolWrapper);
result.put(klass, quickFixWrapper);
}
}
@@ -445,7 +604,8 @@
return getProblemToElements().get(descriptor);
}
- public void ignoreProblem(final CommonProblemDescriptor descriptor, final QuickFix fix) {
+ @Override
+ public void ignoreProblem(@NotNull CommonProblemDescriptor descriptor, @NotNull QuickFix fix) {
RefEntity refElement = getProblemToElements().get(descriptor);
if (refElement != null) {
final QuickFix[] fixes = descriptor.getFixes();
@@ -461,7 +621,6 @@
@Override
public boolean isElementIgnored(final RefEntity element) {
- if (getIgnoredElements() == null) return false;
for (RefEntity entity : getIgnoredElements().keySet()) {
if (Comparing.equal(entity, element)) {
return true;
@@ -470,8 +629,8 @@
return false;
}
+ @Override
public boolean isProblemResolved(RefEntity refEntity, CommonProblemDescriptor descriptor) {
- if (getIgnoredElements() == null) return false;
if (descriptor == null) return true;
for (RefEntity entity : getIgnoredElements().keySet()) {
if (Comparing.equal(entity, refEntity)) {
@@ -482,6 +641,8 @@
return false;
}
+ @Override
+ @NotNull
public FileStatus getProblemStatus(final CommonProblemDescriptor descriptor) {
final GlobalInspectionContextImpl context = getContext();
if (context != null && context.getUIOptions().SHOW_DIFF_WITH_PREVIOUS_RUN){
@@ -492,15 +653,15 @@
ContainerUtil.addAll(allAvailable, descriptors);
}
}
- final boolean old = contains(descriptor, allAvailable);
- final boolean current = contains(descriptor, getProblemToElements().keySet());
+ final boolean old = containsDescriptor(descriptor, allAvailable);
+ final boolean current = containsDescriptor(descriptor, getProblemToElements().keySet());
return calcStatus(old, current);
}
}
return FileStatus.NOT_CHANGED;
}
- private static boolean contains(CommonProblemDescriptor descriptor, Collection<CommonProblemDescriptor> descriptors){
+ private static boolean containsDescriptor(CommonProblemDescriptor descriptor, Collection<CommonProblemDescriptor> descriptors){
PsiElement element = null;
if (descriptor instanceof ProblemDescriptor){
element = ((ProblemDescriptor)descriptor).getPsiElement();
@@ -525,8 +686,8 @@
final GlobalInspectionContextImpl context = getContext();
if (context != null && context.getUIOptions().SHOW_DIFF_WITH_PREVIOUS_RUN){
if (myOldProblemElements != null){
- final boolean old = contains(element, myOldProblemElements.keySet());
- final boolean current = contains(element, getProblemElements().keySet());
+ final boolean old = RefUtil.contains(element, myOldProblemElements.keySet());
+ final boolean current = RefUtil.contains(element, getProblemElements().keySet());
return calcStatus(old, current);
}
}
@@ -539,6 +700,8 @@
return getIgnoredElements().keySet();
}
+ @Override
+ @NotNull
public Map<RefEntity, CommonProblemDescriptor[]> getProblemElements() {
synchronized (lock) {
if (myProblemElements == null) {
@@ -548,6 +711,7 @@
}
}
+ @Override
@Nullable
public Map<RefEntity, CommonProblemDescriptor[]> getOldProblemElements() {
return myOldProblemElements;
@@ -563,21 +727,84 @@
}
}
+ @NotNull
private Map<RefEntity, Set<QuickFix>> getQuickFixActions() {
synchronized (lock) {
if (myQuickFixActions == null) {
- myQuickFixActions = Collections.synchronizedMap(new HashMap<RefEntity, Set<QuickFix>>());
+ myQuickFixActions = Collections.synchronizedMap(new com.intellij.util.containers.HashMap<RefEntity, Set<QuickFix>>());
}
return myQuickFixActions;
}
}
+ @NotNull
private Map<RefEntity, CommonProblemDescriptor[]> getIgnoredElements() {
synchronized (lock) {
if (myIgnoredElements == null) {
- myIgnoredElements = Collections.synchronizedMap(new HashMap<RefEntity, CommonProblemDescriptor[]>());
+ myIgnoredElements = Collections.synchronizedMap(new com.intellij.util.containers.HashMap<RefEntity, CommonProblemDescriptor[]>());
}
return myIgnoredElements;
}
}
+
+ @NotNull
+ @Override
+ public InspectionNode createToolNode(@NotNull GlobalInspectionContextImpl globalInspectionContext, @NotNull InspectionNode node,
+ @NotNull InspectionRVContentProvider provider,
+ @NotNull InspectionTreeNode parentNode,
+ boolean showStructure) {
+ return node;
+ }
+
+
+ @Override
+ @Nullable
+ public IntentionAction findQuickFixes(@NotNull final CommonProblemDescriptor problemDescriptor, final String hint) {
+ InspectionProfileEntry tool = getToolWrapper().getTool();
+ if (!(tool instanceof GlobalInspectionTool)) return null;
+ final QuickFix fix = ((GlobalInspectionTool)tool).getQuickFix(hint);
+ if (fix == null) {
+ return null;
+ }
+ if (problemDescriptor instanceof ProblemDescriptor) {
+ final ProblemDescriptor descriptor = new ProblemDescriptorImpl(((ProblemDescriptor)problemDescriptor).getStartElement(),
+ ((ProblemDescriptor)problemDescriptor).getEndElement(),
+ problemDescriptor.getDescriptionTemplate(),
+ new LocalQuickFix[]{(LocalQuickFix)fix},
+ ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false, null, false);
+ return QuickFixWrapper.wrap(descriptor, 0);
+ }
+ return new IntentionAction() {
+ @Override
+ @NotNull
+ public String getText() {
+ return fix.getName();
+ }
+
+ @Override
+ @NotNull
+ public String getFamilyName() {
+ return fix.getFamilyName();
+ }
+
+ @Override
+ public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
+ return true;
+ }
+
+ @Override
+ public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
+ fix.applyFix(project, problemDescriptor); //todo check type consistency
+ }
+
+ @Override
+ public boolean startInWriteAction() {
+ return true;
+ }
+ };
+ }
+
+ public static void setOutputPath(final String output) {
+ ourOutputPath = output;
+ }
}
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionNode.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionNode.java
index 3a61eec..67fc4ac 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionNode.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionNode.java
@@ -16,7 +16,7 @@
package com.intellij.codeInspection.ui;
-import com.intellij.codeInspection.ex.InspectionTool;
+import com.intellij.codeInspection.ex.InspectionToolWrapper;
import com.intellij.icons.AllIcons;
import com.intellij.ui.LayeredIcon;
import com.intellij.util.IconUtil;
@@ -32,17 +32,18 @@
public static final Icon TOOL = LayeredIcon.create(AllIcons.Toolwindows.ToolWindowInspection, IconUtil.getEmptyIcon(false));
private boolean myTooBigForOnlineRefresh = false;
- public InspectionNode(@NotNull InspectionTool tool) {
- super(tool);
+ public InspectionNode(@NotNull InspectionToolWrapper toolWrapper) {
+ super(toolWrapper);
+ assert toolWrapper.getContext() != null;
}
public String toString() {
- return getTool().getDisplayName();
+ return getToolWrapper().getDisplayName();
}
@NotNull
- public InspectionTool getTool() {
- return (InspectionTool)getUserObject();
+ public InspectionToolWrapper getToolWrapper() {
+ return (InspectionToolWrapper)getUserObject();
}
@Override
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java
index 8629a31..5d0c4b9 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java
@@ -104,18 +104,20 @@
});
private final Splitter mySplitter;
+ @NotNull
private final GlobalInspectionContextImpl myGlobalInspectionContext;
private boolean myRerun = false;
+ @NotNull
private final InspectionRVContentProvider myProvider;
private AnAction myIncludeAction;
private AnAction myExcludeAction;
- public InspectionResultsView(final Project project,
+ public InspectionResultsView(@NotNull final Project project,
final InspectionProfile inspectionProfile,
- final AnalysisScope scope,
- final GlobalInspectionContextImpl globalInspectionContext,
- final InspectionRVContentProvider provider) {
+ @NotNull AnalysisScope scope,
+ @NotNull GlobalInspectionContextImpl globalInspectionContext,
+ @NotNull InspectionRVContentProvider provider) {
setLayout(new BorderLayout());
myProject = project;
@@ -423,7 +425,7 @@
showInBrowser(problemNode.getElement(), problemNode.getDescriptor());
}
else if (node instanceof InspectionNode) {
- showInBrowser(((InspectionNode)node).getTool());
+ showInBrowser(((InspectionNode)node).getToolWrapper());
}
else {
myBrowser.showEmpty();
@@ -439,10 +441,10 @@
setCursor(currentCursor);
}
- private void showInBrowser(InspectionTool tool) {
+ private void showInBrowser(@NotNull InspectionToolWrapper toolWrapper) {
Cursor currentCursor = getCursor();
setCursor(new Cursor(Cursor.WAIT_CURSOR));
- myBrowser.showDescription(tool);
+ myBrowser.showDescription(toolWrapper);
setCursor(currentCursor);
}
@@ -453,15 +455,24 @@
setCursor(currentCursor);
}
- public void addTool(InspectionTool tool, HighlightDisplayLevel errorLevel, boolean groupedBySeverity) {
- final InspectionTreeNode parentNode = getToolParentNode(
- !tool.getGroupDisplayName().isEmpty() ? tool.getGroupDisplayName() : InspectionProfileEntry.GENERAL_GROUP_NAME, errorLevel, groupedBySeverity);
- tool.createToolNode(myProvider, parentNode, myGlobalInspectionContext.getUIOptions().SHOW_STRUCTURE);
- registerActionShortcuts(tool);
+ @NotNull
+ public InspectionNode addTool(@NotNull final InspectionToolWrapper toolWrapper, HighlightDisplayLevel errorLevel, boolean groupedBySeverity) {
+ String groupName =
+ toolWrapper.getGroupDisplayName().isEmpty() ? InspectionProfileEntry.GENERAL_GROUP_NAME : toolWrapper.getGroupDisplayName();
+ InspectionTreeNode parentNode = getToolParentNode(groupName, errorLevel, groupedBySeverity);
+ InspectionNode toolNode = new InspectionNode(toolWrapper);
+ boolean showStructure = myGlobalInspectionContext.getUIOptions().SHOW_STRUCTURE;
+ myProvider.appendToolNodeContent(myGlobalInspectionContext, toolNode, parentNode, showStructure);
+ InspectionToolPresentation presentation = myGlobalInspectionContext.getPresentation(toolWrapper);
+ toolNode = presentation.createToolNode(myGlobalInspectionContext, toolNode, myProvider, parentNode, showStructure);
+ ((DefaultInspectionToolPresentation)presentation).myToolNode = toolNode;
+
+ registerActionShortcuts(presentation);
+ return toolNode;
}
- private void registerActionShortcuts(InspectionTool tool) {
- final QuickFixAction[] fixes = tool.getQuickFixes(new RefEntity[0]);
+ private void registerActionShortcuts(@NotNull InspectionToolPresentation presentation) {
+ final QuickFixAction[] fixes = presentation.getQuickFixes(RefEntity.EMPTY_ELEMENTS_ARRAY);
if (fixes != null) {
for (QuickFixAction fix : fixes) {
fix.registerCustomShortcutSet(fix.getShortcutSet(), this);
@@ -476,7 +487,7 @@
@Nullable
public String getCurrentProfileName() {
- return myInspectionProfile != null ? myInspectionProfile.getDisplayName() : null;
+ return myInspectionProfile == null ? null : myInspectionProfile.getDisplayName();
}
public InspectionProfile getCurrentProfile() {
@@ -499,18 +510,18 @@
}
private boolean buildTree() {
- final InspectionProfile profile = myInspectionProfile;
- final boolean isGroupedBySeverity = myGlobalInspectionContext.getUIOptions().GROUP_BY_SEVERITY;
+ InspectionProfile profile = myInspectionProfile;
+ boolean isGroupedBySeverity = myGlobalInspectionContext.getUIOptions().GROUP_BY_SEVERITY;
myGroups = new HashMap<HighlightDisplayLevel, Map<String, InspectionGroupNode>>();
final Map<String, Tools> tools = myGlobalInspectionContext.getTools();
boolean resultsFound = false;
for (Tools currentTools : tools.values()) {
- final InspectionTool defaultTool = (InspectionTool)currentTools.getDefaultState().getTool();
- final HighlightDisplayKey key = HighlightDisplayKey.find(defaultTool.getShortName());
+ InspectionToolWrapper defaultToolWrapper = currentTools.getDefaultState().getTool();
+ final HighlightDisplayKey key = HighlightDisplayKey.find(defaultToolWrapper.getShortName());
for (ScopeToolState state : currentTools.getTools()) {
- final InspectionTool tool = (InspectionTool)state.getTool();
- if (myProvider.checkReportedProblems(tool)) {
- addTool(tool, ((InspectionProfileImpl)profile).getErrorLevel(key, state.getScope(myProject)), isGroupedBySeverity);
+ InspectionToolWrapper toolWrapper = state.getTool();
+ if (myProvider.checkReportedProblems(myGlobalInspectionContext, toolWrapper)) {
+ addTool(toolWrapper, ((InspectionProfileImpl)profile).getErrorLevel(key, state.getScope(myProject), myProject), isGroupedBySeverity);
resultsFound = true;
}
}
@@ -518,8 +529,9 @@
return resultsFound;
}
- public InspectionTreeNode getToolParentNode(String groupName, HighlightDisplayLevel errorLevel, boolean groupedBySeverity) {
- if (groupName == null || groupName.isEmpty()) {
+ @NotNull
+ public InspectionTreeNode getToolParentNode(@NotNull String groupName, HighlightDisplayLevel errorLevel, boolean groupedBySeverity) {
+ if (groupName.isEmpty()) {
return getRelativeRootNode(groupedBySeverity, errorLevel);
}
if (myGroups == null) {
@@ -532,8 +544,8 @@
}
Map<String, InspectionGroupNode> searchMap = new HashMap<String, InspectionGroupNode>(map);
if (!groupedBySeverity) {
- for (HighlightDisplayLevel level : myGroups.keySet()) {
- searchMap.putAll(myGroups.get(level));
+ for (Map<String, InspectionGroupNode> groupMap : myGroups.values()) {
+ searchMap.putAll(groupMap);
}
}
InspectionGroupNode group = searchMap.get(groupName);
@@ -545,21 +557,18 @@
return group;
}
+ @NotNull
private InspectionTreeNode getRelativeRootNode(boolean isGroupedBySeverity, HighlightDisplayLevel level) {
if (isGroupedBySeverity) {
if (mySeverityGroupNodes.containsKey(level)) {
return mySeverityGroupNodes.get(level);
}
- else {
- final InspectionSeverityGroupNode severityGroupNode = new InspectionSeverityGroupNode(myProject, level);
- mySeverityGroupNodes.put(level, severityGroupNode);
- myTree.getRoot().add(severityGroupNode);
- return severityGroupNode;
- }
+ final InspectionSeverityGroupNode severityGroupNode = new InspectionSeverityGroupNode(myProject, level);
+ mySeverityGroupNodes.put(level, severityGroupNode);
+ myTree.getRoot().add(severityGroupNode);
+ return severityGroupNode;
}
- else {
- return myTree.getRoot();
- }
+ return myTree.getRoot();
}
@@ -597,6 +606,7 @@
return myOccurenceNavigator != null ? myOccurenceNavigator.getPreviousOccurenceActionName() : "";
}
+ @NotNull
public Project getProject() {
return myProject;
}
@@ -604,7 +614,7 @@
@Override
public Object getData(String dataId) {
if (PlatformDataKeys.HELP_ID.is(dataId)) return HELP_ID;
- if (InspectionResultsView.DATA_KEY.is(dataId)) return this;
+ if (DATA_KEY.is(dataId)) return this;
if (myTree == null) return null;
TreePath[] paths = myTree.getSelectionPaths();
@@ -614,9 +624,7 @@
if (LangDataKeys.PSI_ELEMENT_ARRAY.is(dataId)) {
return collectPsiElements();
}
- else {
- return null;
- }
+ return null;
}
TreePath path = paths[0];
@@ -629,7 +637,7 @@
if (refElement == null) return null;
final RefEntity item = refElement.getRefManager().getRefinedElement(refElement);
- if (item == null || !item.isValid()) return null;
+ if (!item.isValid()) return null;
PsiElement psiElement = item instanceof RefElement ? ((RefElement)item).getElement() : null;
if (psiElement == null) return null;
@@ -721,15 +729,15 @@
actions.addSeparator();
- final InspectionTool tool = myTree.getSelectedTool();
- if (tool != null) {
- final QuickFixAction[] quickFixes = myProvider.getQuickFixes(tool, myTree);
+ final InspectionToolWrapper toolWrapper = myTree.getSelectedToolWrapper();
+ if (toolWrapper != null) {
+ final QuickFixAction[] quickFixes = myProvider.getQuickFixes(toolWrapper, myTree);
if (quickFixes != null) {
for (QuickFixAction quickFixe : quickFixes) {
actions.add(quickFixe);
}
}
- final HighlightDisplayKey key = HighlightDisplayKey.find(tool.getShortName());
+ final HighlightDisplayKey key = HighlightDisplayKey.find(toolWrapper.getShortName());
if (key == null) return; //e.g. DummyEntryPointsTool
//options
@@ -748,20 +756,23 @@
menu.getComponent().show(component, x, y);
}
- @NotNull public InspectionTree getTree(){
+ @NotNull
+ public InspectionTree getTree(){
return myTree;
}
+ @NotNull
public GlobalInspectionContextImpl getGlobalInspectionContext() {
return myGlobalInspectionContext;
}
+ @NotNull
public InspectionRVContentProvider getProvider() {
return myProvider;
}
public boolean isSingleToolInSelection() {
- return myTree != null && myTree.getSelectedTool() != null;
+ return myTree != null && myTree.getSelectedToolWrapper() != null;
}
public boolean isRerun() {
@@ -782,12 +793,10 @@
}
}
}
- if (!profiles.isEmpty()) {
- return profiles.iterator().next();
- }
- else {
+ if (profiles.isEmpty()) {
return (InspectionProfile)profileManager.getProjectProfileImpl();
}
+ return profiles.iterator().next();
}
public boolean isProfileDefined() {
@@ -827,15 +836,15 @@
@Override
public void actionPerformed(AnActionEvent e) {
final InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(myProject);
- final InspectionTool tool = myTree.getSelectedTool();
+ final InspectionToolWrapper toolWrapper = myTree.getSelectedToolWrapper();
InspectionProfile inspectionProfile = myInspectionProfile;
final boolean profileIsDefined = isProfileDefined();
if (!profileIsDefined) {
inspectionProfile = guessProfileToSelect(profileManager);
}
- if (tool != null) {
- final HighlightDisplayKey key = HighlightDisplayKey.find(tool.getShortName()); //do not search for dead code entry point tool
+ if (toolWrapper != null) {
+ final HighlightDisplayKey key = HighlightDisplayKey.find(toolWrapper.getShortName()); //do not search for dead code entry point tool
if (key != null){
if (new EditInspectionToolsSettingsAction(key).editToolSettings(myProject, (InspectionProfileImpl)inspectionProfile, profileIsDefined)
&& profileIsDefined){
@@ -875,7 +884,7 @@
myRerun = true;
if (myScope.isValid()) {
AnalysisUIOptions.getInstance(myProject).save(myGlobalInspectionContext.getUIOptions());
- myGlobalInspectionContext.doInspections(myScope, InspectionManager.getInstance(myProject));
+ myGlobalInspectionContext.doInspections(myScope);
}
}
}
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionToolPresentation.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionToolPresentation.java
new file mode 100644
index 0000000..5aed594
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionToolPresentation.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2000-2013 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.codeInspection.ui;
+
+import com.intellij.codeInsight.intention.IntentionAction;
+import com.intellij.codeInspection.CommonProblemDescriptor;
+import com.intellij.codeInspection.ProblemDescriptionsProcessor;
+import com.intellij.codeInspection.QuickFix;
+import com.intellij.codeInspection.ex.GlobalInspectionContextImpl;
+import com.intellij.codeInspection.ex.HTMLComposerImpl;
+import com.intellij.codeInspection.ex.InspectionRVContentProvider;
+import com.intellij.codeInspection.ex.QuickFixAction;
+import com.intellij.codeInspection.reference.RefEntity;
+import com.intellij.codeInspection.reference.RefModule;
+import com.intellij.openapi.vcs.FileStatus;
+import org.jdom.Element;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+public interface InspectionToolPresentation extends ProblemDescriptionsProcessor {
+ @NotNull
+ InspectionNode createToolNode(@NotNull GlobalInspectionContextImpl globalInspectionContext,
+ @NotNull InspectionNode node,
+ @NotNull InspectionRVContentProvider provider,
+ @NotNull InspectionTreeNode parentNode,
+ final boolean showStructure);
+ void updateContent();
+
+ boolean hasReportedProblems();
+
+ Map<String, Set<RefEntity>> getContent();
+
+ Map<String, Set<RefEntity>> getOldContent();
+ void ignoreCurrentElement(RefEntity refEntity);
+ void amnesty(RefEntity refEntity);
+ void cleanup();
+ void finalCleanup();
+ void initialize(@NotNull GlobalInspectionContextImpl context);
+ boolean isGraphNeeded();
+ boolean isElementIgnored(final RefEntity element);
+ @NotNull
+ FileStatus getElementStatus(final RefEntity element);
+ @NotNull
+ Collection<RefEntity> getIgnoredRefElements();
+ @Nullable
+ IntentionAction findQuickFixes(@NotNull CommonProblemDescriptor descriptor, final String hint);
+ @NotNull
+ HTMLComposerImpl getComposer();
+ void exportResults(@NotNull final Element parentNode, @NotNull RefEntity refEntity);
+ Set<RefModule> getModuleProblems();
+ @Nullable
+ QuickFixAction[] getQuickFixes(@NotNull final RefEntity[] refElements);
+ @NotNull
+ Map<RefEntity, CommonProblemDescriptor[]> getProblemElements();
+ @NotNull
+ Collection<CommonProblemDescriptor> getProblemDescriptors();
+ @NotNull
+ FileStatus getProblemStatus(final CommonProblemDescriptor descriptor);
+ boolean isOldProblemsIncluded();
+ @Nullable
+ Map<RefEntity, CommonProblemDescriptor[]> getOldProblemElements();
+ boolean isProblemResolved(RefEntity refEntity, CommonProblemDescriptor descriptor);
+ void ignoreCurrentElementProblem(RefEntity refEntity, CommonProblemDescriptor descriptor);
+ void addProblemElement(RefEntity refElement, boolean filterSuppressed, @NotNull CommonProblemDescriptor... descriptions);
+ void ignoreProblem(@NotNull CommonProblemDescriptor descriptor, @NotNull QuickFix fix);
+ @NotNull
+ GlobalInspectionContextImpl getContext();
+ void ignoreProblem(RefEntity refEntity, CommonProblemDescriptor problem, int idx);
+ @Nullable
+ QuickFixAction[] extractActiveFixes(@NotNull RefEntity[] refElements, @NotNull Map<RefEntity, Set<QuickFix>> actions);
+ void exportResults(@NotNull final Element parentNode);
+}
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionTree.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionTree.java
index d8b2c07..9b43472 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionTree.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionTree.java
@@ -25,9 +25,7 @@
import com.intellij.codeInspection.CommonProblemDescriptor;
import com.intellij.codeInspection.InspectionsBundle;
import com.intellij.codeInspection.ProblemDescriptor;
-import com.intellij.codeInspection.ex.CommonInspectionToolWrapper;
-import com.intellij.codeInspection.ex.DescriptorProviderInspection;
-import com.intellij.codeInspection.ex.InspectionTool;
+import com.intellij.codeInspection.ex.*;
import com.intellij.codeInspection.reference.RefElement;
import com.intellij.codeInspection.reference.RefEntity;
import com.intellij.openapi.application.ApplicationManager;
@@ -59,7 +57,6 @@
public class InspectionTree extends Tree {
private final HashSet<Object> myExpandedUserObjects;
private SelectionPath mySelectionPath;
- private static final RefEntity[] EMPTY_ELEMENTS_ARRAY = new RefEntity[0];
private static final ProblemDescriptor[] EMPTY_DESCRIPTORS = new ProblemDescriptor[0];
public InspectionTree(final Project project) {
@@ -102,19 +99,20 @@
}
@Nullable
- public InspectionTool getSelectedTool() {
+ public InspectionToolWrapper getSelectedToolWrapper() {
final TreePath[] paths = getSelectionPaths();
if (paths == null) return null;
- InspectionTool tool = null;
+ InspectionToolWrapper toolWrapper = null;
for (TreePath path : paths) {
Object[] nodes = path.getPath();
for (int j = nodes.length - 1; j >= 0; j--) {
Object node = nodes[j];
if (node instanceof InspectionNode) {
- if (tool == null) {
- tool = ((InspectionNode)node).getTool();
+ InspectionToolWrapper wrapper = ((InspectionNode)node).getToolWrapper();
+ if (toolWrapper == null) {
+ toolWrapper = wrapper;
}
- else if (tool != ((InspectionNode)node).getTool()) {
+ else if (toolWrapper != wrapper) {
return null;
}
break;
@@ -122,15 +120,15 @@
}
}
- return tool;
+ return toolWrapper;
}
@NotNull
public RefEntity[] getSelectedElements() {
TreePath[] selectionPaths = getSelectionPaths();
if (selectionPaths != null) {
- final InspectionTool selectedTool = getSelectedTool();
- if (selectedTool == null) return EMPTY_ELEMENTS_ARRAY;
+ InspectionToolWrapper toolWrapper = getSelectedToolWrapper();
+ if (toolWrapper == null) return RefEntity.EMPTY_ELEMENTS_ARRAY;
List<RefEntity> result = new ArrayList<RefEntity>();
for (TreePath selectionPath : selectionPaths) {
@@ -139,7 +137,7 @@
}
return result.toArray(new RefEntity[result.size()]);
}
- return EMPTY_ELEMENTS_ARRAY;
+ return RefEntity.EMPTY_ELEMENTS_ARRAY;
}
private static void addElementsInNode(InspectionTreeNode node, List<RefEntity> out) {
@@ -164,8 +162,8 @@
}
public CommonProblemDescriptor[] getSelectedDescriptors() {
- final InspectionTool tool = getSelectedTool();
- if (getSelectionCount() == 0 || !(tool instanceof DescriptorProviderInspection && !(tool instanceof CommonInspectionToolWrapper))) return EMPTY_DESCRIPTORS;
+ final InspectionToolWrapper toolWrapper = getSelectedToolWrapper();
+ if (getSelectionCount() == 0 || !(toolWrapper instanceof LocalInspectionToolWrapper)) return EMPTY_DESCRIPTORS;
final TreePath[] paths = getSelectionPaths();
final LinkedHashSet<CommonProblemDescriptor> descriptors = new LinkedHashSet<CommonProblemDescriptor>();
for (TreePath path : paths) {
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/ProblemDescriptionNode.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/ProblemDescriptionNode.java
index db9082e..d423c63 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/ui/ProblemDescriptionNode.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/ProblemDescriptionNode.java
@@ -17,12 +17,14 @@
package com.intellij.codeInspection.ui;
import com.intellij.codeInspection.*;
-import com.intellij.codeInspection.ex.DescriptorProviderInspection;
+import com.intellij.codeInspection.ex.GlobalInspectionContextImpl;
+import com.intellij.codeInspection.ex.InspectionToolWrapper;
import com.intellij.codeInspection.reference.RefElement;
import com.intellij.codeInspection.reference.RefEntity;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.vcs.FileStatus;
import com.intellij.psi.PsiElement;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
@@ -33,21 +35,22 @@
public class ProblemDescriptionNode extends InspectionTreeNode {
protected RefEntity myElement;
private final CommonProblemDescriptor myDescriptor;
- protected final DescriptorProviderInspection myTool;
+ protected final InspectionToolWrapper myToolWrapper;
- public ProblemDescriptionNode(final Object userObject, final DescriptorProviderInspection tool) {
+ public ProblemDescriptionNode(final Object userObject, @NotNull InspectionToolWrapper toolWrapper) {
super(userObject);
- myTool = tool;
+ myToolWrapper = toolWrapper;
myDescriptor = null;
+ myElement = null;
}
public ProblemDescriptionNode(RefEntity element,
CommonProblemDescriptor descriptor,
- DescriptorProviderInspection descriptorProviderInspection) {
+ @NotNull InspectionToolWrapper toolWrapper) {
super(descriptor);
myElement = element;
myDescriptor = descriptor;
- myTool = descriptorProviderInspection;
+ myToolWrapper = toolWrapper;
}
@Nullable
@@ -89,23 +92,30 @@
@Override
public boolean isResolved() {
- return myElement instanceof RefElement && myTool.isProblemResolved(myElement, getDescriptor());
+ return myElement instanceof RefElement && getPresentation().isProblemResolved(myElement, getDescriptor());
}
@Override
public void ignoreElement() {
- myTool.ignoreCurrentElementProblem(getElement(), getDescriptor());
+ InspectionToolPresentation presentation = getPresentation();
+ presentation.ignoreCurrentElementProblem(getElement(), getDescriptor());
}
@Override
public void amnesty() {
- myTool.amnesty(getElement());
+ InspectionToolPresentation presentation = getPresentation();
+ presentation.amnesty(getElement());
+ }
+
+ @NotNull
+ private InspectionToolPresentation getPresentation() {
+ return ((GlobalInspectionContextImpl)myToolWrapper.getContext()).getPresentation(myToolWrapper);
}
@Override
public FileStatus getNodeStatus() {
if (myElement instanceof RefElement){
- return myTool.getProblemStatus(myDescriptor);
+ return getPresentation().getProblemStatus(myDescriptor);
}
return FileStatus.NOT_CHANGED;
}
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/RefElementNode.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/RefElementNode.java
index 72697db..bfd717f 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/ui/RefElementNode.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/RefElementNode.java
@@ -18,7 +18,6 @@
import com.intellij.codeInspection.CommonProblemDescriptor;
import com.intellij.codeInspection.InspectionsBundle;
-import com.intellij.codeInspection.ex.InspectionTool;
import com.intellij.codeInspection.reference.RefElement;
import com.intellij.codeInspection.reference.RefEntity;
import com.intellij.openapi.util.Computable;
@@ -36,7 +35,7 @@
public class RefElementNode extends InspectionTreeNode {
private boolean myHasDescriptorsUnder = false;
private CommonProblemDescriptor mySingleDescriptor = null;
- protected final InspectionTool myTool;
+ protected final InspectionToolPresentation myToolPresentation;
private final ComputableIcon myIcon = new ComputableIcon(new Computable<Icon>() {
@Override
public Icon compute() {
@@ -48,13 +47,13 @@
}
});
- public RefElementNode(@NotNull Object userObject, @NotNull InspectionTool tool) {
+ public RefElementNode(@NotNull Object userObject, @NotNull InspectionToolPresentation presentation) {
super(userObject);
- myTool = tool;
+ myToolPresentation = presentation;
}
- public RefElementNode(@NotNull RefElement element, @NotNull InspectionTool tool) {
- this((Object)element, tool);
+ public RefElementNode(@NotNull RefElement element, @NotNull InspectionToolPresentation presentation) {
+ this((Object)element, presentation);
}
public boolean hasDescriptorsUnder() {
@@ -93,25 +92,25 @@
@Override
public boolean isResolved() {
- return myTool.isElementIgnored(getElement());
+ return myToolPresentation.isElementIgnored(getElement());
}
@Override
public void ignoreElement() {
- myTool.ignoreCurrentElement(getElement());
+ myToolPresentation.ignoreCurrentElement(getElement());
super.ignoreElement();
}
@Override
public void amnesty() {
- myTool.amnesty(getElement());
+ myToolPresentation.amnesty(getElement());
super.amnesty();
}
@Override
public FileStatus getNodeStatus() {
- return myTool.getElementStatus(getElement());
+ return myToolPresentation.getElementStatus(getElement());
}
@Override
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/ExportHTMLAction.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/ExportHTMLAction.java
index a5add24..4604de3 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/ExportHTMLAction.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/ExportHTMLAction.java
@@ -28,6 +28,7 @@
import com.intellij.codeInspection.reference.RefModule;
import com.intellij.codeInspection.ui.InspectionNode;
import com.intellij.codeInspection.ui.InspectionResultsView;
+import com.intellij.codeInspection.ui.InspectionToolPresentation;
import com.intellij.codeInspection.ui.InspectionTreeNode;
import com.intellij.codeInspection.util.RefEntityAlphabeticalComparator;
import com.intellij.icons.AllIcons;
@@ -53,6 +54,7 @@
import org.jdom.Document;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.io.File;
@@ -157,15 +159,17 @@
if (node instanceof InspectionNode) {
InspectionNode toolNode = (InspectionNode)node;
Element problems = new Element(PROBLEMS);
- final InspectionTool tool = toolNode.getTool();
- final Set<InspectionTool> tools = getWorkedTools(toolNode);
- for (InspectionTool inspectionTool : tools) {
- inspectionTool.exportResults(problems);
+ InspectionToolWrapper toolWrapper = toolNode.getToolWrapper();
+
+ final Set<InspectionToolWrapper> toolWrappers = getWorkedTools(toolNode);
+ for (InspectionToolWrapper wrapper : toolWrappers) {
+ InspectionToolPresentation presentation = myView.getGlobalInspectionContext().getPresentation(wrapper);
+ presentation.exportResults(problems);
}
PathMacroManager.getInstance(myView.getProject()).collapsePaths(problems);
try {
JDOMUtil.writeDocument(new Document(problems),
- outputDirectoryName + File.separator + tool.getShortName() + InspectionApplication.XML_EXTENSION,
+ outputDirectoryName + File.separator + toolWrapper.getShortName() + InspectionApplication.XML_EXTENSION,
CodeStyleSettingsManager.getSettings(null).getLineSeparator());
}
catch (IOException e) {
@@ -197,19 +201,20 @@
}
}
- private Set<InspectionTool> getWorkedTools(InspectionNode node) {
- final Set<InspectionTool> result = new HashSet<InspectionTool>();
- final InspectionTool tool = node.getTool();
+ @NotNull
+ private Set<InspectionToolWrapper> getWorkedTools(@NotNull InspectionNode node) {
+ final Set<InspectionToolWrapper> result = new HashSet<InspectionToolWrapper>();
+ final InspectionToolWrapper wrapper = node.getToolWrapper();
if (myView.getCurrentProfileName() != null){
- result.add(tool);
+ result.add(wrapper);
return result;
}
- final String shortName = tool.getShortName();
+ final String shortName = wrapper.getShortName();
final GlobalInspectionContextImpl context = myView.getGlobalInspectionContext();
final Tools tools = context.getTools().get(shortName);
if (tools != null) { //dummy entry points tool
for (ScopeToolState state : tools.getTools()) {
- InspectionToolWrapper toolWrapper = (InspectionToolWrapper)state.getTool();
+ InspectionToolWrapper toolWrapper = state.getTool();
result.add(toolWrapper);
}
}
@@ -217,29 +222,31 @@
}
private void exportHTML(HTMLExportFrameMaker frameMaker, InspectionNode node) {
- final Set<InspectionTool> tools = getWorkedTools(node);
- final InspectionTool tool = node.getTool();
+ final Set<InspectionToolWrapper> toolWrappers = getWorkedTools(node);
+ final InspectionToolWrapper toolWrapper = node.getToolWrapper();
+
final HTMLExporter exporter =
- new HTMLExporter(frameMaker.getRootFolder() + "/" + tool.getShortName(), tool.getComposer());
- frameMaker.startInspection(tool);
+ new HTMLExporter(frameMaker.getRootFolder() + "/" + toolWrapper.getShortName(), myView.getGlobalInspectionContext().getPresentation(toolWrapper).getComposer());
+ frameMaker.startInspection(toolWrapper);
HTMLExportUtil.runExport(myView.getProject(), new ThrowableRunnable<IOException>() {
@Override
public void run() throws IOException {
- exportHTML(tools, exporter);
+ exportHTML(toolWrappers, exporter);
exporter.generateReferencedPages();
}
});
}
@SuppressWarnings({"HardCodedStringLiteral"})
- private void exportHTML(Set<InspectionTool> tools, HTMLExporter exporter) throws IOException {
+ private void exportHTML(@NotNull Set<InspectionToolWrapper> toolWrappers, HTMLExporter exporter) throws IOException {
StringBuffer packageIndex = new StringBuffer();
packageIndex.append("<html><body>");
final Map<String, Set<RefEntity>> content = new HashMap<String, Set<RefEntity>>();
- for (InspectionTool tool : tools) {
- final Map<String, Set<RefEntity>> toolContent = tool.getContent();
+ for (InspectionToolWrapper toolWrapper : toolWrappers) {
+ InspectionToolPresentation presentation = myView.getGlobalInspectionContext().getPresentation(toolWrapper);
+ final Map<String, Set<RefEntity>> toolContent = presentation.getContent();
if (toolContent != null) {
content.putAll(toolContent);
}
@@ -250,12 +257,12 @@
content.put("default package" , defaultPackageEntities);
}
- ArrayList<String> packageNames = new ArrayList<String>(content.keySet());
+ List<String> packageNames = new ArrayList<String>(content.keySet());
Collections.sort(packageNames);
for (String packageName : packageNames) {
appendPackageReference(packageIndex, packageName);
- final ArrayList<RefEntity> packageContent = new ArrayList<RefEntity>(content.get(packageName));
+ List<RefEntity> packageContent = new ArrayList<RefEntity>(content.get(packageName));
Collections.sort(packageContent, RefEntityAlphabeticalComparator.getInstance());
StringBuffer contentIndex = new StringBuffer();
contentIndex.append("<html><body>");
@@ -275,8 +282,9 @@
}
final Set<RefModule> modules = new HashSet<RefModule>();
- for (InspectionTool tool : tools) {
- final Set<RefModule> problems = tool.getModuleProblems();
+ for (InspectionToolWrapper toolWrapper : toolWrappers) {
+ InspectionToolPresentation presentation = myView.getGlobalInspectionContext().getPresentation(toolWrapper);
+ final Set<RefModule> problems = presentation.getModuleProblems();
if (problems != null) {
modules.addAll(problems);
}
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/InspectionsOptionsToolbarAction.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/InspectionsOptionsToolbarAction.java
index 6c59ccb..1d4635b 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/InspectionsOptionsToolbarAction.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/InspectionsOptionsToolbarAction.java
@@ -1,4 +1,3 @@
-
package com.intellij.codeInspection.ui.actions;
import com.intellij.CommonBundle;
@@ -9,7 +8,7 @@
import com.intellij.codeInspection.actions.RunInspectionIntention;
import com.intellij.codeInspection.ex.DisableInspectionToolAction;
import com.intellij.codeInspection.ex.InspectionProfileImpl;
-import com.intellij.codeInspection.ex.InspectionTool;
+import com.intellij.codeInspection.ex.InspectionToolWrapper;
import com.intellij.codeInspection.reference.RefElement;
import com.intellij.codeInspection.reference.RefEntity;
import com.intellij.codeInspection.ui.InspectionResultsView;
@@ -25,6 +24,7 @@
import com.intellij.openapi.ui.popup.ListPopup;
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
import com.intellij.psi.PsiElement;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.IOException;
@@ -54,14 +54,14 @@
}
final DataContext dataContext = e.getDataContext();
final ListPopup popup = JBPopupFactory.getInstance()
- .createActionGroupPopup(getSelectedTool().getDisplayName(), options, dataContext,
+ .createActionGroupPopup(getSelectedToolWrapper().getDisplayName(), options, dataContext,
JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false);
InspectionResultsView.showPopup(e, popup);
}
@Nullable
- private InspectionTool getSelectedTool() {
- return myView.getTree().getSelectedTool();
+ private InspectionToolWrapper getSelectedToolWrapper() {
+ return myView.getTree().getSelectedToolWrapper();
}
@Override
@@ -70,28 +70,29 @@
e.getPresentation().setEnabled(false);
return;
}
- final InspectionTool selectedTool = getSelectedTool();
- assert selectedTool != null;
- final HighlightDisplayKey key = HighlightDisplayKey.find(selectedTool.getShortName());
+ InspectionToolWrapper toolWrapper = getSelectedToolWrapper();
+ assert toolWrapper != null;
+ final HighlightDisplayKey key = HighlightDisplayKey.find(toolWrapper.getShortName());
if (key == null) {
e.getPresentation().setEnabled(false);
}
e.getPresentation().setEnabled(true);
- final String text = getToolOptions(selectedTool);
+ final String text = getToolOptions(toolWrapper);
e.getPresentation().setText(text);
e.getPresentation().setDescription(text);
}
- private static String getToolOptions(@Nullable final InspectionTool selectedTool) {
- return InspectionsBundle.message("inspections.view.options.title", selectedTool != null ? selectedTool.getDisplayName() : "");
+ @NotNull
+ private static String getToolOptions(@Nullable final InspectionToolWrapper toolWrapper) {
+ return InspectionsBundle.message("inspections.view.options.title", toolWrapper != null ? toolWrapper.getDisplayName() : "");
}
public List<AnAction> createActions() {
final List<AnAction> result = new ArrayList<AnAction>();
final InspectionTree tree = myView.getTree();
- final InspectionTool tool = tree.getSelectedTool();
- if (tool == null) return result;
- final HighlightDisplayKey key = HighlightDisplayKey.find(tool.getShortName());
+ final InspectionToolWrapper toolWrapper = tree.getSelectedToolWrapper();
+ if (toolWrapper == null) return result;
+ final HighlightDisplayKey key = HighlightDisplayKey.find(toolWrapper.getShortName());
if (key == null) return result;
result.add(new DisableInspectionAction(key));
@@ -101,7 +102,7 @@
public void actionPerformed(final AnActionEvent e) {
final PsiElement psiElement = getPsiElement(tree);
assert psiElement != null;
- new RunInspectionIntention(tool).invoke(myView.getProject(), null, psiElement.getContainingFile());
+ new RunInspectionIntention(toolWrapper).invoke(myView.getProject(), null, psiElement.getContainingFile());
}
@Override
@@ -124,7 +125,7 @@
}
});
- result.add(new SuppressActionWrapper(myView.getProject(), tool, tree.getSelectionPaths()));
+ result.add(new SuppressActionWrapper(myView.getProject(), toolWrapper, tree.getSelectionPaths()));
return result;
@@ -143,7 +144,7 @@
try {
if (myView.isProfileDefined()) {
final ModifiableModel model = myView.getCurrentProfile().getModifiableModel();
- model.disableTool(myKey.toString());
+ model.disableTool(myKey.toString(), myView.getProject());
model.commit();
myView.updateCurrentProfile();
} else {
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/InvokeQuickFixAction.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/InvokeQuickFixAction.java
index 7a4f0d2..f21b42e 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/InvokeQuickFixAction.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/InvokeQuickFixAction.java
@@ -18,7 +18,7 @@
import com.intellij.codeInspection.InspectionsBundle;
import com.intellij.codeInspection.ex.InspectionRVContentProvider;
-import com.intellij.codeInspection.ex.InspectionTool;
+import com.intellij.codeInspection.ex.InspectionToolWrapper;
import com.intellij.codeInspection.ex.QuickFixAction;
import com.intellij.codeInspection.ui.InspectionResultsView;
import com.intellij.icons.AllIcons;
@@ -55,10 +55,10 @@
}
//noinspection ConstantConditions
- final @NotNull InspectionTool tool = myView.getTree().getSelectedTool();
+ @NotNull InspectionToolWrapper toolWrapper = myView.getTree().getSelectedToolWrapper();
final InspectionRVContentProvider provider = myView.getProvider();
if (provider.isContentLoaded()) {
- final QuickFixAction[] quickFixes = provider.getQuickFixes(tool, myView.getTree());
+ final QuickFixAction[] quickFixes = provider.getQuickFixes(toolWrapper, myView.getTree());
if (quickFixes == null || quickFixes.length == 0) {
e.getPresentation().setEnabled(false);
return;
@@ -85,9 +85,9 @@
@Override
public void actionPerformed(AnActionEvent e) {
- final InspectionTool tool = myView.getTree().getSelectedTool();
- assert tool != null;
- final QuickFixAction[] quickFixes = myView.getProvider().getQuickFixes(tool, myView.getTree());
+ InspectionToolWrapper toolWrapper = myView.getTree().getSelectedToolWrapper();
+ assert toolWrapper != null;
+ final QuickFixAction[] quickFixes = myView.getProvider().getQuickFixes(toolWrapper, myView.getTree());
if (quickFixes == null || quickFixes.length == 0) {
Messages.showInfoMessage(myView, "There are no applicable quickfixes", "Nothing found to fix");
return;
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/SuppressActionWrapper.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/SuppressActionWrapper.java
index 3843469..ac801b7 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/SuppressActionWrapper.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/SuppressActionWrapper.java
@@ -1,4 +1,3 @@
-
/*
* User: anna
* Date: 29-Jan-2007
@@ -8,7 +7,7 @@
import com.intellij.codeInspection.*;
import com.intellij.codeInspection.ex.GlobalInspectionContextImpl;
import com.intellij.codeInspection.ex.InspectionManagerEx;
-import com.intellij.codeInspection.ex.InspectionTool;
+import com.intellij.codeInspection.ex.InspectionToolWrapper;
import com.intellij.codeInspection.reference.RefElement;
import com.intellij.codeInspection.reference.RefEntity;
import com.intellij.codeInspection.ui.InspectionTreeNode;
@@ -40,11 +39,11 @@
private final Project myProject;
private final InspectionManagerEx myManager;
private final Set<InspectionTreeNode> myNodesToSuppress = new HashSet<InspectionTreeNode>();
- private final InspectionTool myTool;
+ private final InspectionToolWrapper myToolWrapper;
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.actions.SuppressActionWrapper");
public SuppressActionWrapper(@NotNull final Project project,
- @NotNull final InspectionTool tool,
+ @NotNull final InspectionToolWrapper toolWrapper,
@NotNull final TreePath[] paths) {
super(InspectionsBundle.message("suppress.inspection.problem"), false);
myProject = project;
@@ -63,13 +62,13 @@
}
});
}
- myTool = tool;
+ myToolWrapper = toolWrapper;
}
@Override
@NotNull
public SuppressTreeAction[] getChildren(@Nullable final AnActionEvent e) {
- final SuppressIntentionAction[] suppressActions = myTool.getSuppressActions();
+ final SuppressIntentionAction[] suppressActions = InspectionManagerEx.getSuppressActions(myToolWrapper.getTool());
if (suppressActions == null || suppressActions.length == 0) return new SuppressTreeAction[0];
final SuppressTreeAction[] actions = new SuppressTreeAction[suppressActions.length];
for (int i = 0; i < suppressActions.length; i++) {
@@ -93,7 +92,7 @@
if (startModificationCount != tracker.getModificationCount()) {
final Set<GlobalInspectionContextImpl> globalInspectionContexts = myManager.getRunningContexts();
for (GlobalInspectionContextImpl context : globalInspectionContexts) {
- context.ignoreElement(myTool, element);
+ context.ignoreElement(myToolWrapper.getTool(), element);
}
}
}
@@ -108,7 +107,7 @@
@Override
public void update(final AnActionEvent e) {
super.update(e);
- e.getPresentation().setEnabled(myTool != null && myTool.getSuppressActions() != null);
+ e.getPresentation().setEnabled(InspectionManagerEx.getSuppressActions(myToolWrapper.getTool()) != null);
}
private static Pair<PsiElement, CommonProblemDescriptor> getContentToSuppress(InspectionTreeNode node) {
diff --git a/platform/lang-impl/src/com/intellij/execution/ExecutorRegistryImpl.java b/platform/lang-impl/src/com/intellij/execution/ExecutorRegistryImpl.java
index 0013f26..1c88630 100644
--- a/platform/lang-impl/src/com/intellij/execution/ExecutorRegistryImpl.java
+++ b/platform/lang-impl/src/com/intellij/execution/ExecutorRegistryImpl.java
@@ -201,14 +201,12 @@
private final Executor myExecutor;
private ExecutorAction(@NotNull final Executor executor) {
- super(executor.getStartActionText(), executor.getActionName(), executor.getIcon());
+ super(executor.getStartActionText(), executor.getDescription(), executor.getIcon());
myExecutor = executor;
}
@Override
public void update(final AnActionEvent e) {
- super.update(e);
-
final Presentation presentation = e.getPresentation();
final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext());
diff --git a/platform/lang-impl/src/com/intellij/execution/ProgramRunnerUtil.java b/platform/lang-impl/src/com/intellij/execution/ProgramRunnerUtil.java
index c4de58e..ff773d6 100644
--- a/platform/lang-impl/src/com/intellij/execution/ProgramRunnerUtil.java
+++ b/platform/lang-impl/src/com/intellij/execution/ProgramRunnerUtil.java
@@ -16,6 +16,7 @@
package com.intellij.execution;
+import com.intellij.execution.configurations.ConfigurationFactory;
import com.intellij.execution.configurations.ConfigurationType;
import com.intellij.execution.configurations.RunConfiguration;
import com.intellij.execution.impl.RunDialog;
@@ -121,8 +122,9 @@
final boolean invalid,
boolean isTemporary) {
RunConfiguration configuration = settings.getConfiguration();
- final Icon icon = settings.getFactory().getIcon(configuration);
- LOG.assertTrue(icon != null, "Icon should not be null!");
+ ConfigurationFactory factory = settings.getFactory();
+ Icon icon = factory != null ? factory.getIcon(configuration) : null;
+ if (icon == null) icon = AllIcons.RunConfigurations.Unknown;
final Icon configurationIcon = isTemporary ? IconLoader.getTransparentIcon(icon, 0.3f) : icon;
if (invalid) {
diff --git a/platform/lang-impl/src/com/intellij/execution/configuration/EmptyRunProfileState.java b/platform/lang-impl/src/com/intellij/execution/configuration/EmptyRunProfileState.java
new file mode 100644
index 0000000..e38ac2a
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/execution/configuration/EmptyRunProfileState.java
@@ -0,0 +1,34 @@
+package com.intellij.execution.configuration;
+
+import com.intellij.execution.ExecutionException;
+import com.intellij.execution.ExecutionResult;
+import com.intellij.execution.Executor;
+import com.intellij.execution.configurations.ConfigurationPerRunnerSettings;
+import com.intellij.execution.configurations.RunProfileState;
+import com.intellij.execution.configurations.RunnerSettings;
+import com.intellij.execution.runners.ProgramRunner;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+public final class EmptyRunProfileState implements RunProfileState {
+ public static RunProfileState INSTANCE = new EmptyRunProfileState();
+
+ private EmptyRunProfileState() {
+ }
+
+ @Nullable
+ @Override
+ public ExecutionResult execute(Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
+ return null;
+ }
+
+ @Override
+ public RunnerSettings getRunnerSettings() {
+ return null;
+ }
+
+ @Override
+ public ConfigurationPerRunnerSettings getConfigurationSettings() {
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java b/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java
index d42321a..665ea36 100644
--- a/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java
+++ b/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java
@@ -661,6 +661,9 @@
}
}
};
+ if (myProject.isDisposed()) {
+ return;
+ }
myProject.getMessageBus().connect(this).subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, fileEditorListener);
FileEditorManager editorManager = FileEditorManager.getInstance(getProject());
if (editorManager.isFileOpen(myVirtualFile)) {
diff --git a/platform/lang-impl/src/com/intellij/execution/impl/ConsoleBuffer.java b/platform/lang-impl/src/com/intellij/execution/impl/ConsoleBuffer.java
index 4d8d9a7..3a0caaa 100644
--- a/platform/lang-impl/src/com/intellij/execution/impl/ConsoleBuffer.java
+++ b/platform/lang-impl/src/com/intellij/execution/impl/ConsoleBuffer.java
@@ -114,7 +114,7 @@
public ConsoleBuffer(boolean useCyclicBuffer, int cyclicBufferSize, int cyclicBufferUnitSize) {
myUseCyclicBuffer = useCyclicBuffer;
- myCyclicBufferSize = cyclicBufferSize;
+ myCyclicBufferSize = Math.max(cyclicBufferSize, 0);
myCyclicBufferUnitSize = cyclicBufferUnitSize;
myContentTypesToNotStripOnCycling.add(ConsoleViewContentType.USER_INPUT);
}
diff --git a/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java b/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java
index b4768a2..5c67b55 100644
--- a/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java
+++ b/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java
@@ -29,7 +29,6 @@
import com.intellij.icons.AllIcons;
import com.intellij.ide.CommonActionsManager;
import com.intellij.ide.OccurenceNavigator;
-import com.intellij.injected.editor.EditorWindow;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.ApplicationManager;
@@ -49,14 +48,12 @@
import com.intellij.openapi.editor.highlighter.HighlighterClient;
import com.intellij.openapi.editor.highlighter.HighlighterIterator;
import com.intellij.openapi.editor.impl.DocumentImpl;
-import com.intellij.openapi.editor.impl.EditorImpl;
import com.intellij.openapi.editor.impl.softwrap.SoftWrapAppliancePlaces;
import com.intellij.openapi.editor.markup.HighlighterLayer;
import com.intellij.openapi.editor.markup.HighlighterTargetArea;
import com.intellij.openapi.editor.markup.RangeHighlighter;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.extensions.Extensions;
-import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.ide.CopyPasteManager;
@@ -65,9 +62,7 @@
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.ui.TitlePanel;
import com.intellij.openapi.util.*;
-import com.intellij.openapi.util.text.LineTokenizer;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
@@ -75,7 +70,6 @@
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.tree.IElementType;
import com.intellij.ui.EditorNotificationPanel;
-import com.intellij.ui.HideableTitledPanel;
import com.intellij.util.*;
import com.intellij.util.text.CharArrayUtil;
import gnu.trove.TIntObjectHashMap;
@@ -148,7 +142,7 @@
public void foldImmediately() {
ApplicationManager.getApplication().assertIsDispatchThread();
- if (myFlushAlarm.getActiveRequestCount() > 0) {
+ if (!myFlushAlarm.isEmpty()) {
cancelAllFlushRequests();
new MyFlushRunnable().run();
}
@@ -747,7 +741,7 @@
final EditorNotificationPanel comp = new EditorNotificationPanel() {
{
myLabel.setIcon(AllIcons.General.ExclMark);
- myLabel.setText("Too many output to process");
+ myLabel.setText("Too much output to process");
}
};
add(comp, BorderLayout.NORTH);
@@ -1046,7 +1040,7 @@
});
}
finally {
- if (myHeavyAlarm.getActiveRequestCount() == 0) {
+ if (myHeavyAlarm.isEmpty()) {
SwingUtilities.invokeLater(myFinishProgress);
}
}
diff --git a/platform/lang-impl/src/com/intellij/execution/impl/ModuleRunConfigurationManager.java b/platform/lang-impl/src/com/intellij/execution/impl/ModuleRunConfigurationManager.java
new file mode 100644
index 0000000..de0082f
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/execution/impl/ModuleRunConfigurationManager.java
@@ -0,0 +1,188 @@
+/*
+ * Copyright 2000-2013 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.execution.impl;
+
+import com.intellij.ProjectTopics;
+import com.intellij.execution.RunnerAndConfigurationSettings;
+import com.intellij.execution.configurations.ModuleBasedConfiguration;
+import com.intellij.execution.configurations.RunConfiguration;
+import com.intellij.openapi.components.PersistentStateComponent;
+import com.intellij.openapi.components.State;
+import com.intellij.openapi.components.Storage;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.module.Module;
+import com.intellij.openapi.module.ModuleComponent;
+import com.intellij.openapi.project.ModuleAdapter;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.*;
+import com.intellij.util.containers.ContainerUtil;
+import com.intellij.util.containers.HashSet;
+import org.jdom.Element;
+import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+@State(
+ name = ModuleRunConfigurationManager.COMPONENT_NAME,
+ storages = {
+ @Storage(
+ file = "$MODULE_FILE$"
+ )
+ }
+)
+public final class ModuleRunConfigurationManager extends ModuleAdapter implements ModuleComponent, PersistentStateComponent<Element> {
+ private static final Logger LOG = Logger.getInstance(ModuleRunConfigurationManager.class);
+ @NonNls static final String COMPONENT_NAME = "ModuleRunConfigurationManager";
+ @NotNull
+ private final Condition<RunnerAndConfigurationSettings> myModuleConfigCondition = new Condition<RunnerAndConfigurationSettings>() {
+ @Override
+ public boolean value(@Nullable RunnerAndConfigurationSettings settings) {
+ return settings != null && usesMyModule(settings.getConfiguration());
+ }
+ };
+
+ @NotNull
+ private final Module myModule;
+ @NotNull
+ private final RunManagerImpl myManager;
+ @Nullable
+ private List<Element> myUnloadedElements = null;
+
+ public ModuleRunConfigurationManager(@NotNull final Module module, @NotNull final RunManagerImpl runManager) {
+ myModule = module;
+ myManager = runManager;
+ }
+
+ @Override
+ public void projectOpened() {
+ }
+
+ @Override
+ public void projectClosed() {
+ }
+
+ @Override
+ public void moduleAdded() {
+ }
+
+ @Override
+ public void initComponent() {
+ LOG.debug("initComponent(" + myModule + ")");
+ myModule.getMessageBus().connect(myModule).subscribe(ProjectTopics.MODULES, this);
+ }
+
+ @Override
+ public void disposeComponent() {
+ }
+
+ @NotNull
+ @Override
+ public String getComponentName() {
+ return COMPONENT_NAME;
+ }
+
+ @Nullable
+ @Override
+ public Element getState() {
+ try {
+ final Element e = new Element("state");
+ writeExternal(e);
+ return e;
+ }
+ catch (WriteExternalException e1) {
+ LOG.error(e1);
+ return null;
+ }
+ }
+
+ @Override
+ public void loadState(Element state) {
+ try {
+ readExternal(state);
+ }
+ catch (InvalidDataException e) {
+ LOG.error(e);
+ }
+ }
+
+ @NotNull
+ private Collection<? extends RunnerAndConfigurationSettings> getModuleRunConfigurationSettings() {
+ return ContainerUtil.filter(myManager.getConfigurationSettings(), myModuleConfigCondition);
+ }
+
+ private boolean usesMyModule(RunConfiguration config) {
+ return config instanceof ModuleBasedConfiguration
+ && myModule.equals(((ModuleBasedConfiguration)config).getConfigurationModule().getModule());
+ }
+
+ public void writeExternal(@NotNull final Element element) throws WriteExternalException {
+ LOG.debug("writeExternal(" + myModule + ")");
+ for (final RunnerAndConfigurationSettings settings : getModuleRunConfigurationSettings()) {
+ myManager.addConfigurationElement(element, settings);
+ }
+ if (myUnloadedElements != null) {
+ for (final Element unloadedElement : myUnloadedElements) {
+ element.addContent(unloadedElement.clone());
+ }
+ }
+ }
+
+ public void readExternal(@NotNull final Element element) throws InvalidDataException {
+ LOG.debug("readExternal(" + myModule + ")");
+ myUnloadedElements = null;
+ final Set<String> existing = new HashSet<String>();
+
+ final List children = element.getChildren();
+ for (final Object child : children) {
+ final RunnerAndConfigurationSettings configuration = myManager.loadConfiguration((Element)child, true);
+ if (configuration == null && Comparing.strEqual(element.getName(), RunManagerImpl.CONFIGURATION)) {
+ if (myUnloadedElements == null) myUnloadedElements = new ArrayList<Element>(2);
+ myUnloadedElements.add(element);
+ }
+
+ if (configuration != null) {
+ existing.add(RunManagerImpl.getUniqueName(configuration.getConfiguration()));
+ }
+ }
+
+ for (final RunConfiguration configuration : myManager.getAllConfigurations()) {
+ if (!usesMyModule(configuration)) {
+ existing.add(RunManagerImpl.getUniqueName(configuration));
+ }
+ }
+ myManager.removeNotExistingSharedConfigurations(existing);
+
+ // IDEA-60004: configs may never be sorted before write, so call it manually after shared configs read
+ myManager.setOrdered(false);
+ myManager.getSortedConfigurations();
+ }
+
+ @Override
+ public void beforeModuleRemoved(Project project, Module module) {
+ if (!myModule.equals(module)) {
+ return;
+ }
+ LOG.debug("time to remove something from project (" + project + ")");
+ for (final RunnerAndConfigurationSettings settings : getModuleRunConfigurationSettings()) {
+ myManager.removeConfiguration(settings);
+ }
+ }
+}
diff --git a/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java b/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java
index 58ae0b7..14f80f3 100644
--- a/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java
+++ b/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java
@@ -821,6 +821,11 @@
return result.values();
}
+ @NotNull
+ Collection<? extends RunnerAndConfigurationSettings> getConfigurationSettings() {
+ return myConfigurations.values();
+ }
+
@Override
public boolean isTemporary(@NotNull final RunConfiguration configuration) {
return Arrays.asList(getTempConfigurations()).contains(configuration);
diff --git a/platform/lang-impl/src/com/intellij/execution/util/ProgramParametersConfigurator.java b/platform/lang-impl/src/com/intellij/execution/util/ProgramParametersConfigurator.java
index ec7463a..0cd5d16 100644
--- a/platform/lang-impl/src/com/intellij/execution/util/ProgramParametersConfigurator.java
+++ b/platform/lang-impl/src/com/intellij/execution/util/ProgramParametersConfigurator.java
@@ -23,9 +23,11 @@
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.PathUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.jetbrains.jps.model.serialization.PathMacroUtil;
import java.io.File;
import java.util.HashMap;
@@ -62,6 +64,9 @@
return null;
workingDirectory = expandPath(workingDirectory, module, project);
if (!FileUtil.isAbsolute(workingDirectory) && defaultWorkingDir != null) {
+ if (("$" + PathMacroUtil.MODULE_DIR_MACRO_NAME + "$").equals(workingDirectory)) {
+ return defaultWorkingDir;
+ }
workingDirectory = defaultWorkingDir + "/" + workingDirectory;
}
return workingDirectory;
diff --git a/platform/lang-impl/src/com/intellij/facet/impl/FacetUtil.java b/platform/lang-impl/src/com/intellij/facet/impl/FacetUtil.java
index 9443efc..6a33a55 100644
--- a/platform/lang-impl/src/com/intellij/facet/impl/FacetUtil.java
+++ b/platform/lang-impl/src/com/intellij/facet/impl/FacetUtil.java
@@ -20,11 +20,11 @@
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.application.WriteAction;
+import com.intellij.openapi.components.ComponentSerializationUtil;
import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
-import com.intellij.util.ReflectionUtil;
import com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters;
import com.intellij.util.xmlb.XmlSerializer;
import org.jdom.Element;
@@ -32,7 +32,6 @@
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.serialization.facet.JpsFacetSerializer;
-import java.lang.reflect.TypeVariable;
import java.util.Arrays;
/**
@@ -80,8 +79,7 @@
throws InvalidDataException {
if (config != null) {
if (configuration instanceof PersistentStateComponent) {
- TypeVariable<Class<PersistentStateComponent>> variable = PersistentStateComponent.class.getTypeParameters()[0];
- Class<?> stateClass = ReflectionUtil.getRawType(ReflectionUtil.resolveVariableInHierarchy(variable, configuration.getClass()));
+ Class<?> stateClass = ComponentSerializationUtil.getStateClass(((PersistentStateComponent<?>)configuration).getClass());
((PersistentStateComponent)configuration).loadState(XmlSerializer.deserialize(config, stateClass));
}
else {
diff --git a/platform/lang-impl/src/com/intellij/find/findUsages/FindUsagesManager.java b/platform/lang-impl/src/com/intellij/find/findUsages/FindUsagesManager.java
index dbdea01..20ed2d1 100644
--- a/platform/lang-impl/src/com/intellij/find/findUsages/FindUsagesManager.java
+++ b/platform/lang-impl/src/com/intellij/find/findUsages/FindUsagesManager.java
@@ -46,6 +46,7 @@
import com.intellij.openapi.util.*;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.wm.StatusBar;
+import com.intellij.openapi.wm.ex.ProgressIndicatorEx;
import com.intellij.psi.*;
import com.intellij.psi.search.*;
import com.intellij.psi.util.PsiUtilCore;
@@ -318,6 +319,7 @@
usageSearcher.generate(new Processor<Usage>() {
@Override
public boolean process(final Usage usage) {
+ if (isInComment(usage)) return true;
used.set(true);
return false;
}
@@ -325,6 +327,19 @@
return used.get();
}
+ private static boolean isInComment(Usage usage) {
+ if (!(usage instanceof UsageInfo2UsageAdapter)) return false;
+ UsageInfo usageInfo = ((UsageInfo2UsageAdapter)usage).getUsageInfo();
+ if (!usageInfo.isNonCodeUsage()) return false;
+ SmartPsiFileRange psiRangePointer = usageInfo.getPsiFileRange();
+ if (psiRangePointer == null) return false;
+ Segment range = psiRangePointer.getRange();
+ PsiFile file = psiRangePointer.getContainingFile();
+ if (file == null || range == null) return false;
+ PsiElement element = file.findElementAt(range.getStartOffset());
+ return element instanceof PsiComment;
+ }
+
@NotNull
public static ProgressIndicator startProcessUsages(@NotNull FindUsagesHandler handler,
@NotNull UsageInfoToUsageConverter.TargetElementsDescriptor descriptor,
@@ -334,6 +349,7 @@
final UsageSearcher usageSearcher = createUsageSearcher(descriptor, handler, findUsagesOptions, null);
final ProgressIndicatorBase indicator = new ProgressIndicatorBase();
+ dropResolveCacheRegularly(indicator, handler.getProject());
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
@Override
public void run() {
@@ -482,12 +498,33 @@
myAnotherManager.searchAndShowUsages(targets, new Factory<UsageSearcher>() {
@Override
public UsageSearcher create() {
+ dropResolveCacheRegularly(ProgressManager.getInstance().getProgressIndicator(), myProject);
return createUsageSearcher(descriptor, handler, findUsagesOptions, null);
}
}, !toSkipUsagePanelWhenOneUsage, true, createPresentation(elements.get(0), findUsagesOptions, toOpenInNewTab), null);
addToHistory(elements, findUsagesOptions);
}
+ private static void dropResolveCacheRegularly(ProgressIndicator indicator, final Project project) {
+ if (indicator instanceof ProgressIndicatorEx) {
+ ((ProgressIndicatorEx)indicator).addStateDelegate(new ProgressIndicatorBase() {
+ volatile long lastCleared = System.currentTimeMillis();
+
+ @Override
+ public void setFraction(double fraction) {
+ super.setFraction(fraction);
+ long current = System.currentTimeMillis();
+ if (current - lastCleared >= 500) {
+ lastCleared = current;
+ // fraction is changed when each file is processed =>
+ // resolve caches used when searching in that file are likely to be not needed anymore
+ PsiManager.getInstance(project).dropResolveCaches();
+ }
+ }
+ });
+ }
+ }
+
@NotNull
private static UsageViewPresentation createPresentation(@NotNull PsiElement psiElement,
@NotNull FindUsagesOptions findUsagesOptions,
diff --git a/platform/lang-impl/src/com/intellij/formatting/FormatterImpl.java b/platform/lang-impl/src/com/intellij/formatting/FormatterImpl.java
index 1640a59..5a41350 100644
--- a/platform/lang-impl/src/com/intellij/formatting/FormatterImpl.java
+++ b/platform/lang-impl/src/com/intellij/formatting/FormatterImpl.java
@@ -718,7 +718,7 @@
@NotNull
public Spacing createSpacing(final int minSpaces, final int maxSpaces, final int minLineFeeds, final boolean keepLineBreaks, final int keepBlankLines,
final int prefLineFeeds) {
- return getSpacingImpl(minSpaces, maxSpaces, -1, false, false, keepLineBreaks, keepBlankLines, false, prefLineFeeds);
+ return getSpacingImpl(minSpaces, maxSpaces, minLineFeeds, false, false, keepLineBreaks, keepBlankLines, false, prefLineFeeds);
}
private final Map<SpacingImpl,SpacingImpl> ourSharedProperties = new HashMap<SpacingImpl,SpacingImpl>();
diff --git a/platform/lang-impl/src/com/intellij/ide/actions/GotoActionAction.java b/platform/lang-impl/src/com/intellij/ide/actions/GotoActionAction.java
index 81a0398..9d3a49a 100644
--- a/platform/lang-impl/src/com/intellij/ide/actions/GotoActionAction.java
+++ b/platform/lang-impl/src/com/intellij/ide/actions/GotoActionAction.java
@@ -95,13 +95,13 @@
showNavigationPopup(callback, null,
ChooseByNamePopup.createPopup(project, model, new DefaultChooseByNameItemProvider(null) {
@Override
- protected void sortNamesList(@NotNull String namePattern, @NotNull List<String> namesList) {
- Collections.sort(namesList, new Comparator<String>() {
+ protected void sortNamesList(@NotNull String namePattern, @NotNull List<MatchResult> namesList) {
+ Collections.sort(namesList, new Comparator<MatchResult>() {
@Override
- public int compare(String o1, String o2) {
- if (o1.equals(GotoActionModel.SETTINGS_KEY)) return 1;
- if (o2.equals(GotoActionModel.SETTINGS_KEY)) return -1;
- return o1.compareToIgnoreCase(o2);
+ public int compare(MatchResult o1, MatchResult o2) {
+ if (o1.elementName.equals(GotoActionModel.SETTINGS_KEY)) return 1;
+ if (o2.elementName.equals(GotoActionModel.SETTINGS_KEY)) return -1;
+ return o1.elementName.compareToIgnoreCase(o2.elementName);
}
});
}
diff --git a/platform/lang-impl/src/com/intellij/ide/actions/SelectInContextImpl.java b/platform/lang-impl/src/com/intellij/ide/actions/SelectInContextImpl.java
index 5b35576..9377369 100644
--- a/platform/lang-impl/src/com/intellij/ide/actions/SelectInContextImpl.java
+++ b/platform/lang-impl/src/com/intellij/ide/actions/SelectInContextImpl.java
@@ -112,16 +112,23 @@
private static SelectInContext createEditorContext(DataContext dataContext) {
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
final FileEditor editor = PlatformDataKeys.FILE_EDITOR.getData(dataContext);
- return createEditorContext(project, editor);
+ return doCreateEditorContext(project, editor, dataContext);
}
public static SelectInContext createEditorContext(Project project, FileEditor editor) {
+ return doCreateEditorContext(project, editor, null);
+ }
+
+ private static SelectInContext doCreateEditorContext(Project project, FileEditor editor, @Nullable DataContext dataContext) {
if (project == null || editor == null) {
return null;
}
VirtualFile file = FileEditorManagerEx.getInstanceEx(project).getFile(editor);
if (file == null) {
- return null;
+ file = dataContext == null ? null : PlatformDataKeys.VIRTUAL_FILE.getData(dataContext);
+ if (file == null) {
+ return null;
+ }
}
final PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
if (psiFile == null) {
diff --git a/platform/lang-impl/src/com/intellij/ide/actions/TogglePopupHintsAction.java b/platform/lang-impl/src/com/intellij/ide/actions/TogglePopupHintsAction.java
index 3026460..db63dc8 100644
--- a/platform/lang-impl/src/com/intellij/ide/actions/TogglePopupHintsAction.java
+++ b/platform/lang-impl/src/com/intellij/ide/actions/TogglePopupHintsAction.java
@@ -20,6 +20,7 @@
package com.intellij.ide.actions;
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
+import com.intellij.codeInsight.daemon.impl.DaemonListeners;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DataContext;
@@ -28,7 +29,6 @@
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.profile.codeInspection.InspectionProjectProfileManagerImpl;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
@@ -63,6 +63,6 @@
LOG.assertTrue(project!=null);
DaemonCodeAnalyzer codeAnalyzer = DaemonCodeAnalyzer.getInstance(project);
codeAnalyzer.setImportHintsEnabled(psiFile,!codeAnalyzer.isImportHintsEnabled(psiFile));
- InspectionProjectProfileManagerImpl.getInstanceImpl(project).updateStatusBar();
+ DaemonListeners.getInstance(project).updateStatusBar();
}
}
diff --git a/platform/lang-impl/src/com/intellij/ide/bookmarks/Bookmark.java b/platform/lang-impl/src/com/intellij/ide/bookmarks/Bookmark.java
index 73d1f24..e0146bd 100644
--- a/platform/lang-impl/src/com/intellij/ide/bookmarks/Bookmark.java
+++ b/platform/lang-impl/src/com/intellij/ide/bookmarks/Bookmark.java
@@ -211,7 +211,7 @@
StructureViewBuilder builder = LanguageStructureViewBuilder.INSTANCE.getStructureViewBuilder(psiFile);
if (builder instanceof TreeBasedStructureViewBuilder) {
- StructureViewModel model = ((TreeBasedStructureViewBuilder)builder).createStructureViewModel();
+ StructureViewModel model = ((TreeBasedStructureViewBuilder)builder).createStructureViewModel(null);
Object element;
try {
element = model.getCurrentEditorElement();
diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesAutoscrollFromSourceHandler.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesAutoscrollFromSourceHandler.java
index 9e053ad..30bbf03 100644
--- a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesAutoscrollFromSourceHandler.java
+++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesAutoscrollFromSourceHandler.java
@@ -16,7 +16,6 @@
package com.intellij.ide.favoritesTreeView;
import com.intellij.ide.SelectInContext;
-import com.intellij.ide.SelectInTarget;
import com.intellij.ide.actions.SelectInContextImpl;
import com.intellij.openapi.fileEditor.FileEditor;
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx;
@@ -53,15 +52,11 @@
if (file != null) {
final PsiFile psiFile = PsiManager.getInstance(myProject).findFile(file);
if (psiFile != null) {
- final SelectInTarget target = mySelectInTarget;
- if (target != null) {
- final SelectInContext selectInContext = SelectInContextImpl.createEditorContext(myProject, editor);
-
- if (target.canSelect(selectInContext)) {
- target.selectIn(selectInContext, false);
- }
+ final SelectInContext selectInContext = SelectInContextImpl.createEditorContext(myProject, editor);
+ if (mySelectInTarget.canSelect(selectInContext)) {
+ mySelectInTarget.selectIn(selectInContext, false);
}
}
}
}
-}
+}
\ No newline at end of file
diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/UsageSerializable.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/UsageSerializable.java
index 79bbe40..ef4d3b8 100644
--- a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/UsageSerializable.java
+++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/UsageSerializable.java
@@ -56,7 +56,7 @@
//final SmartPsiElementPointer<?> pointer = info.getSmartPointer();
final GenericElementSignatureProvider provider = new GenericElementSignatureProvider();
final String signature = provider.getSignature(info.getElement());
- append(os, info.getElement().getContainingFile().getVirtualFile().getPath());
+ append(os, info.getFile().getVirtualFile().getPath());
os.append(separator);
append(os, signature);
os.append(separator);
diff --git a/platform/lang-impl/src/com/intellij/ide/hierarchy/HierarchyNodeDescriptor.java b/platform/lang-impl/src/com/intellij/ide/hierarchy/HierarchyNodeDescriptor.java
index 650ccf3..8d717a5 100644
--- a/platform/lang-impl/src/com/intellij/ide/hierarchy/HierarchyNodeDescriptor.java
+++ b/platform/lang-impl/src/com/intellij/ide/hierarchy/HierarchyNodeDescriptor.java
@@ -25,6 +25,7 @@
import com.intellij.psi.PsiFile;
import com.intellij.usageView.UsageTreeColors;
import com.intellij.usageView.UsageTreeColorsScheme;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public abstract class HierarchyNodeDescriptor extends SmartElementDescriptor {
@@ -32,7 +33,7 @@
private Object[] myCachedChildren = null;
protected final boolean myIsBase;
- protected HierarchyNodeDescriptor(final Project project, final NodeDescriptor parentDescriptor, final PsiElement element, final boolean isBase) {
+ protected HierarchyNodeDescriptor(@NotNull Project project, final NodeDescriptor parentDescriptor, @NotNull PsiElement element, final boolean isBase) {
super(project, parentDescriptor, element);
myHighlightedText = new CompositeAppearance();
myName = "";
diff --git a/platform/lang-impl/src/com/intellij/ide/hierarchy/HierarchyTreeStructure.java b/platform/lang-impl/src/com/intellij/ide/hierarchy/HierarchyTreeStructure.java
index d3ab11c..71c1440 100644
--- a/platform/lang-impl/src/com/intellij/ide/hierarchy/HierarchyTreeStructure.java
+++ b/platform/lang-impl/src/com/intellij/ide/hierarchy/HierarchyTreeStructure.java
@@ -41,6 +41,7 @@
public abstract class HierarchyTreeStructure extends AbstractTreeStructure {
protected HierarchyNodeDescriptor myBaseDescriptor;
private HierarchyNodeDescriptor myRoot;
+ @NotNull
protected final Project myProject;
protected HierarchyTreeStructure(@NotNull Project project, HierarchyNodeDescriptor baseDescriptor) {
diff --git a/platform/lang-impl/src/com/intellij/ide/impl/StructureViewSelectInTarget.java b/platform/lang-impl/src/com/intellij/ide/impl/StructureViewSelectInTarget.java
index 2c3f8d4..ba704b9 100644
--- a/platform/lang-impl/src/com/intellij/ide/impl/StructureViewSelectInTarget.java
+++ b/platform/lang-impl/src/com/intellij/ide/impl/StructureViewSelectInTarget.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -24,17 +24,19 @@
import com.intellij.ide.structureView.StructureViewWrapper;
import com.intellij.openapi.fileEditor.FileEditor;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Key;
import com.intellij.openapi.wm.ToolWindowId;
import com.intellij.openapi.wm.ToolWindowManager;
public class StructureViewSelectInTarget implements SelectInTarget {
+ public static final Key<StructureViewWrapper> CUSTOM_STRUCTURE_VIEW_KEY = Key.create("customStructureView");
+
private final Project myProject;
public StructureViewSelectInTarget(Project project) {
myProject = project;
}
-
public String toString() {
return IdeBundle.message("select.in.file.structure");
}
@@ -46,17 +48,23 @@
@Override
public void selectIn(final SelectInContext context, final boolean requestFocus) {
+ @SuppressWarnings("ConstantConditions")
final FileEditor fileEditor = context.getFileEditorProvider().openFileEditor();
- ToolWindowManager windowManager=ToolWindowManager.getInstance(context.getProject());
+ StructureViewWrapper customStructureView = CUSTOM_STRUCTURE_VIEW_KEY.get(context.getVirtualFile());
+ if (customStructureView != null) {
+ customStructureView.selectCurrentElement(fileEditor, context.getVirtualFile(), requestFocus);
+ return;
+ }
+
+ ToolWindowManager windowManager = ToolWindowManager.getInstance(context.getProject());
final Runnable runnable = new Runnable() {
@Override
public void run() {
StructureViewFactoryEx.getInstanceEx(myProject).runWhenInitialized(new Runnable() {
@Override
public void run() {
- final StructureViewWrapper structureView = getStructureViewWrapper();
- structureView.selectCurrentElement(fileEditor, context.getVirtualFile(), requestFocus);
+ getStructureViewWrapper().selectCurrentElement(fileEditor, context.getVirtualFile(), requestFocus);
}
});
}
@@ -67,7 +75,6 @@
else {
runnable.run();
}
-
}
private StructureViewWrapper getStructureViewWrapper() {
@@ -88,5 +95,4 @@
public float getWeight() {
return StandardTargetWeights.STRUCTURE_WEIGHT;
}
-
-}
+}
\ No newline at end of file
diff --git a/platform/lang-impl/src/com/intellij/ide/macro/ClipboardContentMacro.java b/platform/lang-impl/src/com/intellij/ide/macro/ClipboardContentMacro.java
new file mode 100644
index 0000000..8e92653
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/ide/macro/ClipboardContentMacro.java
@@ -0,0 +1,42 @@
+package com.intellij.ide.macro;
+
+import com.intellij.ide.IdeBundle;
+import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.ide.CopyPasteManager;
+import org.jetbrains.annotations.Nullable;
+
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.Transferable;
+
+/**
+ * @author nik
+ */
+public class ClipboardContentMacro extends Macro {
+ private static final Logger LOG = Logger.getInstance(ClipboardContentMacro.class);
+
+ @Override
+ public String getName() {
+ return "ClipboardContent";
+ }
+
+ @Override
+ public String getDescription() {
+ return IdeBundle.message("macro.clipboard.content");
+ }
+
+ @Nullable
+ @Override
+ public String expand(DataContext dataContext) throws ExecutionCancelledException {
+ Transferable contents = CopyPasteManager.getInstance().getContents();
+ if (contents == null) return null;
+
+ try {
+ return (String)contents.getTransferData(DataFlavor.stringFlavor);
+ }
+ catch (Exception e) {
+ LOG.info(e);
+ return null;
+ }
+ }
+}
diff --git a/platform/lang-impl/src/com/intellij/ide/macro/MacroManager.java b/platform/lang-impl/src/com/intellij/ide/macro/MacroManager.java
index ab89eef..bf90158 100644
--- a/platform/lang-impl/src/com/intellij/ide/macro/MacroManager.java
+++ b/platform/lang-impl/src/com/intellij/ide/macro/MacroManager.java
@@ -80,6 +80,7 @@
registerMacro(new LineNumberMacro());
registerMacro(new ColumnNumberMacro());
+ registerMacro(new ClipboardContentMacro());
registerMacro(new SelectedTextMacro());
registerMacro(new SelectionStartLineMacro());
registerMacro(new SelectionStartColumnMacro());
diff --git a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarRootPaneExtension.java b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarRootPaneExtension.java
index 0da8058..fb9ac1d 100644
--- a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarRootPaneExtension.java
+++ b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarRootPaneExtension.java
@@ -204,7 +204,7 @@
@Override
public void run() {
- if (LafManager.getInstance().getCurrentLookAndFeel().getName().equals(laf)) return;
+ //if (LafManager.getInstance().getCurrentLookAndFeel().getName().equals(laf)) return;
laf = LafManager.getInstance().getCurrentLookAndFeel().getName();
panel.get().removeAll();
myScrollPane = null;
diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/AbstractProjectViewPSIPane.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/AbstractProjectViewPSIPane.java
index 50bee8d..90dfe7e 100644
--- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/AbstractProjectViewPSIPane.java
+++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/AbstractProjectViewPSIPane.java
@@ -23,6 +23,8 @@
import com.intellij.ide.PsiCopyPasteManager;
import com.intellij.ide.projectView.BaseProjectTreeBuilder;
import com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode;
+import com.intellij.ide.ui.UISettings;
+import com.intellij.ide.ui.UISettingsListener;
import com.intellij.ide.ui.customization.CustomizationUtil;
import com.intellij.ide.util.treeView.AbstractTreeBuilder;
import com.intellij.ide.util.treeView.AbstractTreeUpdater;
@@ -55,7 +57,7 @@
import java.util.ArrayList;
import java.util.StringTokenizer;
-public abstract class AbstractProjectViewPSIPane extends AbstractProjectViewPane {
+public abstract class AbstractProjectViewPSIPane extends AbstractProjectViewPane implements UISettingsListener {
private JScrollPane myComponent;
protected AbstractProjectViewPSIPane(Project project) {
@@ -76,10 +78,20 @@
installComparator();
initTree();
+
+ UISettings.getInstance().addUISettingsListener(this, this);
return myComponent;
}
@Override
+ public void uiSettingsChanged(UISettings source) {
+ myTree.setRowHeight(-1);
+ myTree.setFont(UIUtil.getTreeFont());
+ myTree.invalidate();
+ myTree.repaint();
+ }
+
+ @Override
public final void dispose() {
myComponent = null;
super.dispose();
diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/PsiDirectoryNode.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/PsiDirectoryNode.java
index 2d70a88..c8d3ba2 100644
--- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/PsiDirectoryNode.java
+++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/PsiDirectoryNode.java
@@ -37,6 +37,7 @@
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
+import com.intellij.openapi.vfs.VFileProperty;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.pom.NavigatableWithText;
@@ -59,7 +60,7 @@
public PsiDirectoryNode(Project project, PsiDirectory value, ViewSettings viewSettings) {
super(project, value, viewSettings);
}
-
+
protected boolean shouldShowModuleName() {
return !PlatformUtils.isAppCode();
}
@@ -290,7 +291,7 @@
icon = LayeredIcon.create(icon, PlatformIcons.LOCKED_ICON);
}
- if (file.isSymLink()) {
+ if (file.is(VFileProperty.SYMLINK)) {
icon = LayeredIcon.create(icon, PlatformIcons.SYMLINK_ICON);
}
diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/PsiFileNode.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/PsiFileNode.java
index 4566233..0d92e9a 100644
--- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/PsiFileNode.java
+++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/PsiFileNode.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -31,6 +31,7 @@
import com.intellij.openapi.util.Iconable;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.JarFileSystem;
+import com.intellij.openapi.vfs.VFileProperty;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.pom.NavigatableWithText;
import com.intellij.psi.PsiDirectory;
@@ -74,7 +75,7 @@
data.setIcon(value.getIcon(Iconable.ICON_FLAG_READ_STATUS));
VirtualFile file = getVirtualFile();
- if (file != null && file.isSymLink()) {
+ if (file != null && file.is(VFileProperty.SYMLINK)) {
String target = file.getCanonicalPath();
if (target == null) {
data.setAttributesKey(CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES);
diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/PsiTreeAnchorizer.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/PsiTreeAnchorizer.java
index a7fff1a..1dd3972 100644
--- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/PsiTreeAnchorizer.java
+++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/PsiTreeAnchorizer.java
@@ -16,6 +16,9 @@
package com.intellij.ide.projectView.impl.nodes;
import com.intellij.ide.util.treeView.TreeAnchorizer;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.util.Computable;
+import com.intellij.openapi.util.Key;
import com.intellij.psi.PsiAnchor;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.Nullable;
@@ -25,20 +28,39 @@
*/
public class PsiTreeAnchorizer extends TreeAnchorizer {
+ private static final Key<PsiAnchor> PSI_ANCHORIZER_ANCHOR = Key.create("PSI_ANCHORIZER_ANCHOR");
+
@Override
public Object createAnchor(Object element) {
- if (element instanceof PsiElement && ((PsiElement)element).isValid()) {
- return PsiAnchor.create((PsiElement)element);
- }
+ if (element instanceof PsiElement) {
+ final PsiElement psiElement = (PsiElement)element;
+ return ApplicationManager.getApplication().runReadAction(new Computable<Object>() {
+ @Override
+ public Object compute() {
+ PsiAnchor anchor = psiElement.getUserData(PSI_ANCHORIZER_ANCHOR);
+ if (!psiElement.isValid()) {
+ return anchor != null ? anchor : psiElement;
+ }
+
+ if (anchor == null || anchor.retrieve() != psiElement) {
+ psiElement.putUserData(PSI_ANCHORIZER_ANCHOR, anchor = PsiAnchor.create(psiElement));
+ }
+ return anchor;
+ }
+ });
+ }
return super.createAnchor(element);
}
-
@Override
@Nullable
public Object retrieveElement(Object pointer) {
if (pointer instanceof PsiAnchor) {
- return ((PsiAnchor)pointer).retrieve();
+ PsiElement retrieve = ((PsiAnchor)pointer).retrieve();
+ if (retrieve == null) {
+ //System.out.println("Null anchor: " + pointer);
+ }
+ return retrieve;
}
return super.retrieveElement(pointer);
diff --git a/platform/lang-impl/src/com/intellij/ide/scopeView/ScopeTreeViewPanel.java b/platform/lang-impl/src/com/intellij/ide/scopeView/ScopeTreeViewPanel.java
index 25bf410..c290e4d 100644
--- a/platform/lang-impl/src/com/intellij/ide/scopeView/ScopeTreeViewPanel.java
+++ b/platform/lang-impl/src/com/intellij/ide/scopeView/ScopeTreeViewPanel.java
@@ -567,9 +567,7 @@
else if (psiElement instanceof PsiDirectory) {
final PsiElement[] children = psiElement.getChildren();
if (children.length > 0) {
- for (PsiElement child : children) {
- processNodeCreation(child);
- }
+ queueRefreshScope(getCurrentScope(), (PsiDirectory)psiElement);
} else {
final PackageDependenciesNode node = myBuilder.addDirNode((PsiDirectory)psiElement);
if (node != null) {
diff --git a/platform/lang-impl/src/com/intellij/ide/scopeView/ScopeViewPane.java b/platform/lang-impl/src/com/intellij/ide/scopeView/ScopeViewPane.java
index 8d1ebb5..051d4cb 100644
--- a/platform/lang-impl/src/com/intellij/ide/scopeView/ScopeViewPane.java
+++ b/platform/lang-impl/src/com/intellij/ide/scopeView/ScopeViewPane.java
@@ -141,6 +141,7 @@
NamedScope[] scopes = myDependencyValidationManager.getScopes();
scopes = ArrayUtil.mergeArrays(scopes, myNamedScopeManager.getScopes());
scopes = NonProjectFilesScope.removeFromList(scopes);
+ scopes = ArrayUtil.remove(scopes, CustomScopesProviderEx.getAllScope());
String[] ids = new String[scopes.length];
for (int i = 0; i < scopes.length; i++) {
final NamedScope scope = scopes[i];
diff --git a/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/StructureViewComponent.java b/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/StructureViewComponent.java
index ebfa921..0c92af1 100644
--- a/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/StructureViewComponent.java
+++ b/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/StructureViewComponent.java
@@ -16,7 +16,10 @@
package com.intellij.ide.structureView.newStructureView;
-import com.intellij.ide.*;
+import com.intellij.ide.CommonActionsManager;
+import com.intellij.ide.CopyPasteDelegator;
+import com.intellij.ide.DataManager;
+import com.intellij.ide.PsiCopyPasteManager;
import com.intellij.ide.structureView.*;
import com.intellij.ide.structureView.impl.StructureViewFactoryImpl;
import com.intellij.ide.structureView.impl.StructureViewState;
@@ -35,6 +38,8 @@
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.fileEditor.FileEditor;
import com.intellij.openapi.fileEditor.FileEditorManager;
+import com.intellij.openapi.fileEditor.OpenFileDescriptor;
+import com.intellij.openapi.fileEditor.TextEditor;
import com.intellij.openapi.project.IndexNotReadyException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.SimpleToolWindowPanel;
@@ -760,6 +765,9 @@
if (PlatformDataKeys.FILE_EDITOR.is(dataId)) {
return myFileEditor;
}
+ if (OpenFileDescriptor.NAVIGATE_IN_EDITOR.is(dataId) && myFileEditor instanceof TextEditor) {
+ return ((TextEditor)myFileEditor).getEditor();
+ }
if (PlatformDataKeys.CUT_PROVIDER.is(dataId)) {
return myCopyPasteDelegator.getCutProvider();
}
diff --git a/platform/lang-impl/src/com/intellij/ide/util/AbstractTreeClassChooserDialog.java b/platform/lang-impl/src/com/intellij/ide/util/AbstractTreeClassChooserDialog.java
index 58ede02..2d8bb9c 100644
--- a/platform/lang-impl/src/com/intellij/ide/util/AbstractTreeClassChooserDialog.java
+++ b/platform/lang-impl/src/com/intellij/ide/util/AbstractTreeClassChooserDialog.java
@@ -573,11 +573,11 @@
final List<String> names = new ArrayList<String>();
myFastMode = myInheritorsProvider.searchForInheritorsOfBaseClass().forEach(new Processor<T>() {
- private int count;
+ private long start = System.currentTimeMillis();
@Override
public boolean process(T aClass) {
- if (count++ > 1000) {
+ if (System.currentTimeMillis() - start > 500) {
return false;
}
if ((getTreeClassChooserDialog().getFilter().isAccepted(aClass)) && aClass.getName() != null) {
@@ -587,7 +587,7 @@
}
});
if (!myFastMode) {
- return getNames(checkBoxState);
+ return myInheritorsProvider.getNames();
}
if ((getTreeClassChooserDialog().getFilter().isAccepted(myInheritorsProvider.getBaseClass())) &&
myInheritorsProvider.getBaseClass().getName() != null) {
diff --git a/platform/lang-impl/src/com/intellij/ide/util/DeleteHandler.java b/platform/lang-impl/src/com/intellij/ide/util/DeleteHandler.java
index 6ca9ae4..b8bc4bc 100644
--- a/platform/lang-impl/src/com/intellij/ide/util/DeleteHandler.java
+++ b/platform/lang-impl/src/com/intellij/ide/util/DeleteHandler.java
@@ -35,6 +35,7 @@
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.ex.MessagesEx;
import com.intellij.openapi.util.Ref;
+import com.intellij.openapi.vfs.VFileProperty;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.WritingAccessProvider;
import com.intellij.psi.PsiDirectory;
@@ -193,7 +194,7 @@
if (!elementToDelete.isValid()) continue; //was already deleted
if (elementToDelete instanceof PsiDirectory) {
VirtualFile virtualFile = ((PsiDirectory)elementToDelete).getVirtualFile();
- if (virtualFile.isInLocalFileSystem() && !virtualFile.isSymLink()) {
+ if (virtualFile.isInLocalFileSystem() && !virtualFile.is(VFileProperty.SYMLINK)) {
ArrayList<VirtualFile> readOnlyFiles = new ArrayList<VirtualFile>();
CommonRefactoringUtil.collectReadOnlyFiles(virtualFile, readOnlyFiles);
diff --git a/platform/lang-impl/src/com/intellij/ide/util/PlatformModuleRendererFactory.java b/platform/lang-impl/src/com/intellij/ide/util/PlatformModuleRendererFactory.java
index ceb0d16..046de8d 100644
--- a/platform/lang-impl/src/com/intellij/ide/util/PlatformModuleRendererFactory.java
+++ b/platform/lang-impl/src/com/intellij/ide/util/PlatformModuleRendererFactory.java
@@ -18,6 +18,7 @@
import com.intellij.navigation.ItemPresentation;
import com.intellij.navigation.NavigationItem;
+import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.ui.UIUtil;
import javax.swing.*;
@@ -51,7 +52,7 @@
final ItemPresentation presentation = ((NavigationItem)value).getPresentation();
if (presentation != null) {
String containerText = presentation.getLocationString();
- if (containerText != null && containerText.length() > 0) {
+ if (!StringUtil.isEmpty(containerText)) {
text = " " + containerText;
}
}
diff --git a/platform/lang-impl/src/com/intellij/ide/util/PsiElementListCellRenderer.java b/platform/lang-impl/src/com/intellij/ide/util/PsiElementListCellRenderer.java
index 0c5b85d..0e62d6e 100644
--- a/platform/lang-impl/src/com/intellij/ide/util/PsiElementListCellRenderer.java
+++ b/platform/lang-impl/src/com/intellij/ide/util/PsiElementListCellRenderer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -124,7 +124,7 @@
if (nameAttributes == null) nameAttributes = new SimpleTextAttributes(Font.PLAIN, color);
- assert name != null : "Null name for PSI element " + element;
+ assert name != null : "Null name for PSI element " + element + " (by " + PsiElementListCellRenderer.this + ")";
SpeedSearchUtil.appendColoredFragmentForMatcher(name, this, nameAttributes, myMatcher, bgColor, selected);
if (!element.isValid()) {
append(" Invalid", SimpleTextAttributes.ERROR_ATTRIBUTES);
diff --git a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java
index 11874fe..fc85b3c 100644
--- a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java
+++ b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java
@@ -23,6 +23,7 @@
import com.intellij.ide.IdeBundle;
import com.intellij.ide.IdeEventQueue;
import com.intellij.ide.actions.CopyReferenceAction;
+import com.intellij.ide.ui.UISettings;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.MnemonicHelper;
import com.intellij.openapi.actionSystem.*;
@@ -62,6 +63,7 @@
import com.intellij.usageView.UsageViewBundle;
import com.intellij.usages.*;
import com.intellij.util.Alarm;
+import com.intellij.util.Consumer;
import com.intellij.util.Processor;
import com.intellij.util.text.Matcher;
import com.intellij.util.text.MatcherHolder;
@@ -91,7 +93,6 @@
protected final ChooseByNameModel myModel;
protected ChooseByNameItemProvider myProvider;
protected final String myInitialText;
- private boolean myPreselectInitialText;
private boolean mySearchInAnyPlace = false;
protected Component myPreviouslyFocusedComponent;
@@ -436,9 +437,6 @@
myFuture = new ArrayList<Pair<String, Integer>>();
myTextField = new MyTextField();
myTextField.setText(myInitialText);
- if (myPreselectInitialText) {
- myTextField.select(0, myInitialText.length());
- }
final ActionMap actionMap = new ActionMap();
actionMap.setParent(myTextField.getActionMap());
@@ -459,7 +457,9 @@
myTextFieldPanel.add(myTextField);
EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
- Font editorFont = new Font(scheme.getEditorFontName(), Font.PLAIN, scheme.getEditorFontSize());
+ boolean presentationMode = UISettings.getInstance().PRESENTATION_MODE;
+ int size = presentationMode ? UISettings.getInstance().PRESENTATION_MODE_FONT_SIZE - 4 : scheme.getEditorFontSize();
+ Font editorFont = new Font(scheme.getEditorFontName(), Font.PLAIN, size);
myTextField.setFont(editorFont);
if (checkBoxName != null) {
@@ -765,6 +765,7 @@
}
protected void cancelListUpdater() {
+ cancelCalcElementsThread();
myListUpdater.cancelAll();
}
@@ -922,9 +923,9 @@
final Runnable request = new Runnable() {
@Override
public void run() {
- final CalcElementsCallback callback = new CalcElementsCallback() {
+ final Consumer<Set<?>> callback = new Consumer<Set<?>>() {
@Override
- public void run(@NotNull final Set<?> elements) {
+ public void consume(Set<?> elements) {
synchronized (myRebuildMutex) {
ApplicationManager.getApplication().assertIsDispatchThread();
if (checkDisposed()) {
@@ -959,10 +960,7 @@
((MatcherHolder)cellRenderer).setPatternMatcher(matcher);
}
- CalcElementsThread calcElementsThread =
- new CalcElementsThread(text, myCheckBox.isSelected(), callback, modalityState, postRunnable == null);
- myCalcElementsThread = calcElementsThread;
- ApplicationManager.getApplication().executeOnPooledThread(calcElementsThread);
+ scheduleCalcElements(text, myCheckBox.isSelected(), postRunnable == null, modalityState, callback);
}
};
@@ -976,6 +974,16 @@
}, modalityState);
}
+ public void scheduleCalcElements(String text,
+ boolean checkboxState,
+ boolean canCancel,
+ ModalityState modalityState,
+ Consumer<Set<?>> callback) {
+ CalcElementsThread calcElementsThread = new CalcElementsThread(text, checkboxState, callback, modalityState, canCancel);
+ myCalcElementsThread = calcElementsThread;
+ ApplicationManager.getApplication().executeOnPooledThread(calcElementsThread);
+ }
+
private boolean isShowListAfterCompletionKeyStroke() {
return myShowListAfterCompletionKeyStroke;
}
@@ -1117,10 +1125,6 @@
}
myList.setVisibleRowCount(Math.min(VISIBLE_LIST_SIZE_LIMIT, myList.getModel().getSize()));
- if (!myListModel.isEmpty()) {
- int pos = selectionPos <= 0 ? detectBestStatisticalPosition() : selectionPos;
- ListScrollingUtil.selectItem(myList, Math.min(pos, myListModel.size() - 1));
- }
if (!myCommands.isEmpty()) {
myAlarm.addRequest(this, DELAY);
@@ -1131,6 +1135,11 @@
if (!checkDisposed()) {
showList();
updateDocPosition();
+
+ if (!myListModel.isEmpty()) {
+ int pos = selectionPos <= 0 ? detectBestStatisticalPosition() : selectionPos;
+ ListScrollingUtil.selectItem(myList, Math.min(pos, myListModel.size() - 1));
+ }
}
}
}, DELAY);
@@ -1391,7 +1400,7 @@
private class CalcElementsThread implements Runnable {
private final String myPattern;
private boolean myCheckboxState;
- private final CalcElementsCallback myCallback;
+ private final Consumer<Set<?>> myCallback;
private final ModalityState myModalityState;
private Set<Object> myElements = null;
@@ -1401,7 +1410,7 @@
CalcElementsThread(String pattern,
boolean checkboxState,
- CalcElementsCallback callback,
+ Consumer<Set<?>> callback,
@NotNull ModalityState modalityState,
boolean canCancel) {
myPattern = pattern;
@@ -1418,7 +1427,7 @@
showCard(SEARCHING_CARD, 200);
final Set<Object> elements = new LinkedHashSet<Object>();
- Runnable action = new Runnable() {
+ final Runnable action = new Runnable() {
@Override
public void run() {
try {
@@ -1442,7 +1451,14 @@
}
}
};
- ApplicationManager.getApplication().runReadAction(action);
+ Runnable readAction = new Runnable() {
+ @Override
+ public void run() {
+ ApplicationManager.getApplication().runReadAction(action);
+ }
+ };
+ ProgressManager.getInstance().runProcess(readAction, myCancelled);
+
if (myCancelled.isCanceled()) {
myShowCardAlarm.cancelAllRequests();
@@ -1452,7 +1468,7 @@
final String cardToShow;
if (elements.isEmpty() && !myCheckboxState) {
myCheckboxState = true;
- ApplicationManager.getApplication().runReadAction(action);
+ ProgressManager.getInstance().runProcess(readAction, myCancelled);
cardToShow = elements.isEmpty() ? NOT_FOUND_CARD : NOT_FOUND_IN_PROJECT_CARD;
}
else {
@@ -1465,7 +1481,7 @@
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
- myCallback.run(myElements);
+ myCallback.consume(myElements);
}
}, myModalityState);
}
@@ -1499,6 +1515,7 @@
}
private void showCard(final String card, final int delay) {
+ if (ApplicationManager.getApplication().isUnitTestMode()) return;
myShowCardAlarm.cancelAllRequests();
myShowCardAlarm.addRequest(new Runnable() {
@Override
@@ -1540,10 +1557,6 @@
return NameUtil.buildMatcher(pattern, 0, true, true, pattern.toLowerCase().equals(pattern));
}
- private interface CalcElementsCallback {
- void run(Set<?> elements);
- }
-
private static class HintLabel extends JLabel {
private HintLabel(String text) {
super(text, RIGHT);
@@ -1572,7 +1585,6 @@
@Override
public void actionPerformed(final AnActionEvent e) {
- cancelCalcElementsThread();
cancelListUpdater();
final UsageViewPresentation presentation = new UsageViewPresentation();
diff --git a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameFilter.java b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameFilter.java
index 100ace1..029d083 100644
--- a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameFilter.java
+++ b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameFilter.java
@@ -135,11 +135,7 @@
invert.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
- final int count = myChooser.getElementCount();
- for (int i = 0; i < count; i++) {
- T type = myChooser.getElementAt(i);
- myChooser.setElementMarked(type, !myChooser.isElementMarked(type));
- }
+ myChooser.invertSelection();
}
});
buttons.add(invert);
diff --git a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNamePopup.java b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNamePopup.java
index b88af0d..aa5302c 100644
--- a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNamePopup.java
+++ b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNamePopup.java
@@ -18,6 +18,7 @@
import com.intellij.featureStatistics.FeatureUsageTracker;
import com.intellij.ide.ui.UISettings;
+import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.keymap.KeymapUtil;
import com.intellij.openapi.project.Project;
@@ -255,14 +256,10 @@
}
cleanupUI(isOk);
+ if (ApplicationManager.getApplication().isUnitTestMode()) return;
myActionListener.onClose();
}
- @Nullable
- public static ChooseByNamePopup getActivePopup(@NotNull final Project project) {
- return CHOOSE_BY_NAME_POPUP_IN_PROJECT_KEY.get(project);
- }
-
private void cleanupUI(boolean ok) {
if (myTextPopup != null) {
if (ok) {
diff --git a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ContributorsBasedGotoByModel.java b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ContributorsBasedGotoByModel.java
index bbe1eeb..212d060 100644
--- a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ContributorsBasedGotoByModel.java
+++ b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ContributorsBasedGotoByModel.java
@@ -32,8 +32,8 @@
import com.intellij.openapi.project.Project;
import com.intellij.util.ArrayUtil;
import com.intellij.util.Processor;
-import com.intellij.util.containers.ConcurrentHashSet;
import com.intellij.util.containers.ContainerUtil;
+import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -74,36 +74,44 @@
@NotNull
@Override
public String[] getNames(final boolean checkBoxState) {
- final Set<String> names = new ConcurrentHashSet<String>();
+ final THashSet<String> allNames = ContainerUtil.newTroveSet();
long start = System.currentTimeMillis();
List<ChooseByNameContributor> liveContribs = filterDumb(myContributors);
- JobLauncher.getInstance().invokeConcurrentlyUnderProgress(liveContribs, ProgressManager.getInstance().getProgressIndicator(), false,
- new Processor<ChooseByNameContributor>() {
- @Override
- public boolean process(ChooseByNameContributor contributor) {
- try {
- if (!myProject.isDisposed()) {
- ContainerUtil.addAll(names, contributor.getNames(myProject, checkBoxState));
- }
- }
- catch (ProcessCanceledException ex) {
- // index corruption detected, ignore
- }
- catch (IndexNotReadyException ex) {
- // index corruption detected, ignore
- }
- catch (Exception ex) {
- LOG.error(ex);
- }
- return true;
- }
- });
+ ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
+ Processor<ChooseByNameContributor> processor = new Processor<ChooseByNameContributor>() {
+ @Override
+ public boolean process(ChooseByNameContributor contributor) {
+ try {
+ if (!myProject.isDisposed()) {
+ String[] names = contributor.getNames(myProject, checkBoxState);
+ synchronized (allNames) {
+ allNames.ensureCapacity(names.length);
+ ContainerUtil.addAll(allNames, names);
+ }
+ }
+ }
+ catch (ProcessCanceledException ex) {
+ // index corruption detected, ignore
+ }
+ catch (IndexNotReadyException ex) {
+ // index corruption detected, ignore
+ }
+ catch (Exception ex) {
+ LOG.error(ex);
+ }
+ return true;
+ }
+ };
+ JobLauncher.getInstance().invokeConcurrentlyUnderProgress(liveContribs, indicator, false, processor);
+ if (indicator != null) {
+ indicator.checkCanceled();
+ }
long finish = System.currentTimeMillis();
if (LOG.isDebugEnabled()) {
- LOG.debug("getNames(): "+(finish-start)+"ms; (got "+names.size()+" elements)");
+ LOG.debug("getNames(): "+(finish-start)+"ms; (got "+allNames.size()+" elements)");
}
- return ArrayUtil.toStringArray(names);
+ return ArrayUtil.toStringArray(allNames);
}
private List<ChooseByNameContributor> filterDumb(ChooseByNameContributor[] contributors) {
@@ -119,7 +127,7 @@
}
@NotNull
- public Object[] getElementsByName(final String name, final boolean checkBoxState, final String pattern, @NotNull ProgressIndicator canceled) {
+ public Object[] getElementsByName(final String name, final boolean checkBoxState, final String pattern, @NotNull final ProgressIndicator canceled) {
final List<NavigationItem> items = Collections.synchronizedList(new ArrayList<NavigationItem>());
Processor<ChooseByNameContributor> processor = new Processor<ChooseByNameContributor>() {
@@ -128,9 +136,9 @@
if (myProject.isDisposed()) {
return true;
}
-
try {
for (NavigationItem item : contributor.getItemsByName(name, pattern, myProject, checkBoxState)) {
+ canceled.checkCanceled();
if (item == null) {
PluginId pluginId = PluginManager.getPluginByClassName(contributor.getClass().getName());
if (pluginId != null) {
@@ -157,7 +165,7 @@
}
};
JobLauncher.getInstance().invokeConcurrentlyUnderProgress(filterDumb(myContributors), canceled, false, processor);
-
+ canceled.checkCanceled(); // if parallel job execution was canceled because of PCE, rethrow it from here
return ArrayUtil.toObjectArray(items);
}
diff --git a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/DefaultChooseByNameItemProvider.java b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/DefaultChooseByNameItemProvider.java
index 54854d7..a87fa90 100644
--- a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/DefaultChooseByNameItemProvider.java
+++ b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/DefaultChooseByNameItemProvider.java
@@ -15,11 +15,9 @@
*/
package com.intellij.ide.util.gotoByName;
-import com.intellij.concurrency.JobLauncher;
import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressIndicator;
-import com.intellij.openapi.util.Comparing;
+import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiCompiledElement;
@@ -27,12 +25,9 @@
import com.intellij.psi.codeStyle.MinusculeMatcher;
import com.intellij.psi.codeStyle.NameUtil;
import com.intellij.psi.util.proximity.PsiProximityComparator;
-import com.intellij.util.Function;
-import com.intellij.util.Processor;
-import com.intellij.util.SmartList;
+import com.intellij.util.*;
import com.intellij.util.containers.ContainerUtil;
-import com.intellij.util.text.Matcher;
-import gnu.trove.THashSet;
+import gnu.trove.THashMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -47,12 +42,6 @@
myContext = new WeakReference<PsiElement>(context);
}
- private enum MatchingMode {
- CASE_SENSITIVE,
- CASE_INSENSITIVE,
- STRICT_CASE_INSENSITIVE
- }
-
@Override
public boolean filterElements(@NotNull ChooseByNameBase base,
@NotNull String pattern,
@@ -62,75 +51,41 @@
String namePattern = getNamePattern(base, pattern);
String qualifierPattern = getQualifierPattern(base, pattern);
- ChooseByNameModel model = base.getModel();
- boolean empty = namePattern.isEmpty() ||
- namePattern.equals("@") && model instanceof GotoClassModel2; // TODO[yole]: remove implicit dependency
- if (empty && !base.canShowListForEmptyPattern()) return true;
+ if (removeModelSpecificMarkup(base, namePattern).isEmpty() && !base.canShowListForEmptyPattern()) return true;
- Set<String> names = new THashSet<String>(Arrays.asList(base.getNames(everywhere)));
-
- if (base.isSearchInAnyPlace() && !namePattern.trim().isEmpty()) {
- String middleMatchPattern = "*" + namePattern;
-
- // consume elements matching by prefix case-sensitively
- Integer elementsConsumed = consumeElements(base, everywhere, indicator, consumer, namePattern, qualifierPattern, names,
- MatchingMode.CASE_SENSITIVE, false);
- if (elementsConsumed == null) return false;
-
- if (elementsConsumed == 0) {
- // search for strict prefixes case-insensitively
- elementsConsumed = consumeElements(base, everywhere, indicator, consumer, namePattern,
- qualifierPattern, names, MatchingMode.STRICT_CASE_INSENSITIVE, false);
- if (elementsConsumed == null) return false;
-
- // search with original pattern without case sensitivity, don't add separator before found items
- // result: items matched by prefix will always be above middle-matched items
- Integer elementsConsumed2 = consumeElements(base, everywhere, indicator, consumer, namePattern,
- qualifierPattern, names, MatchingMode.CASE_INSENSITIVE, false);
- if (elementsConsumed2 == null) return false;
-
- elementsConsumed += elementsConsumed2;
- }
-
- // search with broadest criteria - middle match pattern, without case sensitivity
- elementsConsumed = consumeElements(base, everywhere, indicator, consumer, middleMatchPattern,
- qualifierPattern, names, MatchingMode.CASE_INSENSITIVE, elementsConsumed > 0);
- return elementsConsumed != null;
- }
- else {
- Integer elementsConsumed = consumeElements(base, everywhere, indicator, consumer, namePattern, qualifierPattern, names,
- MatchingMode.CASE_INSENSITIVE, false);
- return elementsConsumed != null;
- }
- }
-
- /**
- * @return null if consumer returned false, number of consumed elements otherwise.
- */
- @Nullable
- private Integer consumeElements(@NotNull ChooseByNameBase base,
- boolean everywhere,
- @NotNull ProgressIndicator indicator,
- @NotNull Processor<Object> consumer,
- @NotNull String namePattern,
- @NotNull String qualifierPattern,
- @NotNull Set<String> allNames,
- @NotNull MatchingMode matchingMode,
- boolean needSeparator) {
- ChooseByNameModel model = base.getModel();
- List<String> namesList = new ArrayList<String>();
- getNamesByPattern(base, new ArrayList<String>(allNames), indicator, namesList, namePattern, matchingMode);
- allNames.removeAll(namesList);
- sortNamesList(namePattern, namesList);
+ final ChooseByNameModel model = base.getModel();
+ String matchingPattern = convertToMatchingPattern(base, namePattern);
+ List<MatchResult> namesList = new ArrayList<MatchResult>();
+ processNamesByPattern(base, base.getNames(everywhere), matchingPattern, new CollectConsumer<MatchResult>(namesList));
+ sortNamesList(matchingPattern, namesList);
indicator.checkCanceled();
List<Object> sameNameElements = new SmartList<Object>();
- List<Pair<String, MinusculeMatcher>> patternsAndMatchers = getPatternsAndMatchers(qualifierPattern, base);
- int elementsConsumed = 0;
+ final Map<Object, MatchResult> sameNameWeights = new THashMap<Object, MatchResult>();
- for (String name : namesList) {
+ Comparator<Object> weightComparator = new Comparator<Object>() {
+ Comparator<Object> modelComparator = model instanceof Comparator ? (Comparator<Object>)model : new PathProximityComparator(model, myContext.get());
+
+ @Override
+ public int compare(Object o1, Object o2) {
+ int result = modelComparator.compare(o1, o2);
+ return result != 0 ? result : sameNameWeights.get(o1).compareTo(sameNameWeights.get(o2));
+ }
+ };
+
+ List<Object> qualifierMiddleMatched = new ArrayList<Object>();
+
+ List<Pair<String, MinusculeMatcher>> patternsAndMatchers = getPatternsAndMatchers(qualifierPattern, base);
+
+ boolean sortedByMatchingDegree = !(base.getModel() instanceof CustomMatcherModel);
+ boolean afterStartMatch = false;
+
+ for (MatchResult result : namesList) {
indicator.checkCanceled();
+ String name = result.elementName;
+
+ boolean needSeparator = sortedByMatchingDegree && !result.startMatch && afterStartMatch;
// use interruptible call if possible
Object[] elements = model instanceof ContributorsBasedGotoByModel ?
@@ -138,44 +93,46 @@
: model.getElementsByName(name, everywhere, namePattern);
if (elements.length > 1) {
sameNameElements.clear();
+ sameNameWeights.clear();
for (final Object element : elements) {
indicator.checkCanceled();
- if (matchesQualifier(element, base, patternsAndMatchers)) {
+ MatchResult qualifierResult = matchQualifier(element, base, patternsAndMatchers);
+ if (qualifierResult != null) {
sameNameElements.add(element);
+ sameNameWeights.put(element, qualifierResult);
}
}
- sortByProximity(base, sameNameElements);
+ Collections.sort(sameNameElements, weightComparator);
for (Object element : sameNameElements) {
- if (needSeparator && !consumer.process(ChooseByNameBase.NON_PREFIX_SEPARATOR)) return null;
- if (!consumer.process(element)) return null;
+ if (!sameNameWeights.get(element).startMatch) {
+ qualifierMiddleMatched.add(element);
+ continue;
+ }
+
+ if (needSeparator && !startMiddleMatchVariants(consumer, qualifierMiddleMatched)) return false;
+ if (!consumer.process(element)) return false;
needSeparator = false;
- elementsConsumed++;
+ afterStartMatch = result.startMatch;
}
}
- else if (elements.length == 1 && matchesQualifier(elements[0], base, patternsAndMatchers)) {
- if (needSeparator && !consumer.process(ChooseByNameBase.NON_PREFIX_SEPARATOR)) return null;
- if (!consumer.process(elements[0])) return null;
- needSeparator = false;
- elementsConsumed++;
+ else if (elements.length == 1 && matchQualifier(elements[0], base, patternsAndMatchers) != null) {
+ if (needSeparator && !startMiddleMatchVariants(consumer, qualifierMiddleMatched)) return false;
+ if (!consumer.process(elements[0])) return false;
+ afterStartMatch = result.startMatch;
}
}
- return elementsConsumed;
+ return ContainerUtil.process(qualifierMiddleMatched, consumer);
}
- protected void sortNamesList(@NotNull String namePattern, @NotNull List<String> namesList) {
- // Here we sort using namePattern to have similar logic with empty qualified patten case
- Collections.sort(namesList, new MatchesComparator(namePattern));
+ private static boolean startMiddleMatchVariants(Processor<Object> consumer, List<Object> qualifierMiddleMatched) {
+ if (!consumer.process(ChooseByNameBase.NON_PREFIX_SEPARATOR)) return false;
+ if (!ContainerUtil.process(qualifierMiddleMatched, consumer)) return false;
+ qualifierMiddleMatched.clear();
+ return true;
}
- private void sortByProximity(@NotNull ChooseByNameBase base, @NotNull List<Object> sameNameElements) {
- final ChooseByNameModel model = base.getModel();
- if (model instanceof Comparator) {
- //noinspection unchecked
- Collections.sort(sameNameElements, (Comparator)model);
- }
- else {
- Collections.sort(sameNameElements, new PathProximityComparator(model, myContext.get()));
- }
+ protected void sortNamesList(@NotNull String namePattern, @NotNull List<MatchResult> namesList) {
+ Collections.sort(namesList);
}
@NotNull
@@ -189,7 +146,7 @@
}
@NotNull
- public static String getNamePattern(@NotNull ChooseByNameBase base, String pattern) {
+ private static String getNamePattern(@NotNull ChooseByNameBase base, String pattern) {
pattern = base.transformPattern(pattern);
ChooseByNameModel model = base.getModel();
@@ -215,39 +172,47 @@
return answer.isEmpty() ? Collections.singletonList(s) : answer;
}
- private static boolean matchesQualifier(@NotNull Object element,
- @NotNull final ChooseByNameBase base,
- @NotNull List<Pair<String, MinusculeMatcher>> patternsAndMatchers) {
+ private static MatchResult matchQualifier(@NotNull Object element,
+ @NotNull final ChooseByNameBase base,
+ @NotNull List<Pair<String, MinusculeMatcher>> patternsAndMatchers) {
final String name = base.getModel().getFullName(element);
- if (name == null) return false;
+ if (name == null) return null;
final List<String> suspects = split(name, base);
- try {
- int matchPosition = 0;
- patterns:
- for (Pair<String, MinusculeMatcher> patternAndMatcher : patternsAndMatchers) {
- final String pattern = patternAndMatcher.first;
- final MinusculeMatcher matcher = patternAndMatcher.second;
- if (!pattern.isEmpty()) {
- for (int j = matchPosition; j < suspects.size() - 1; j++) {
- String suspect = suspects.get(j);
- if (matches(base, pattern, matcher, suspect)) {
- matchPosition = j + 1;
- continue patterns;
- }
+ int matchingDegree = 0;
+ int matchPosition = 0;
+ boolean startMatch = true;
+ patterns:
+ for (Pair<String, MinusculeMatcher> patternAndMatcher : patternsAndMatchers) {
+ final String pattern = patternAndMatcher.first;
+ final MinusculeMatcher matcher = patternAndMatcher.second;
+ if (!pattern.isEmpty()) {
+ for (int j = matchPosition; j < suspects.size() - 1; j++) {
+ String suspect = suspects.get(j);
+ MatchResult suspectMatch = matches(base, pattern, matcher, suspect);
+ if (suspectMatch != null) {
+ matchingDegree += suspectMatch.matchingDegree;
+ startMatch &= suspectMatch.startMatch;
+ matchPosition = j + 1;
+ continue patterns;
}
-
- return false;
+ // pattern "foo/index" should prefer "bar/foo/index.html" to "foo/bar/index.html"
+ // hence penalize every non-adjacent match
+ matchingDegree -= (j + 1)*(j + 1);
}
+
+ return null;
}
}
- catch (Exception e) {
- // Do nothing. No matches appears valid result for "bad" pattern
- return false;
+
+ // penalize last skipped path parts
+ for (int j = matchPosition; j < suspects.size() - 1; j++) {
+ matchingDegree -= (j + 1)*(j + 1);
}
- return true;
+
+ return new MatchResult(name, matchingDegree, startMatch);
}
@NotNull
@@ -256,7 +221,11 @@
@NotNull
@Override
public Pair<String, MinusculeMatcher> fun(String s) {
- return Pair.create(getNamePattern(base, s), buildPatternMatcher(getNamePattern(base, s), NameUtil.MatchingCaseSensitivity.NONE));
+ String namePattern = getNamePattern(base, s);
+ if (base.isSearchInAnyPlace() && !namePattern.trim().isEmpty()) {
+ namePattern = "*" + namePattern;
+ }
+ return Pair.create(namePattern, buildPatternMatcher(namePattern, NameUtil.MatchingCaseSensitivity.NONE));
}
});
}
@@ -264,77 +233,68 @@
@NotNull
@Override
public List<String> filterNames(@NotNull ChooseByNameBase base, @NotNull String[] names, @NotNull String pattern) {
- List<String> res = new ArrayList<String>();
- getNamesByPattern(base, Arrays.asList(names), null, res, pattern, MatchingMode.CASE_INSENSITIVE);
- return res;
+ final List<String> filtered = new ArrayList<String>();
+ processNamesByPattern(base, names, convertToMatchingPattern(base, pattern), new Consumer<MatchResult>() {
+ @Override
+ public void consume(MatchResult result) {
+ filtered.add(result.elementName);
+ }
+ });
+ return filtered;
}
- private static void getNamesByPattern(@NotNull final ChooseByNameBase base,
- @NotNull List<String> names,
- @Nullable ProgressIndicator indicator,
- @NotNull final List<String> outListFiltered, // matched items
- @NotNull String pattern,
- @NotNull MatchingMode matchingMode) throws ProcessCanceledException {
+ private static void processNamesByPattern(@NotNull final ChooseByNameBase base,
+ @NotNull String[] names,
+ final String pattern, Consumer<MatchResult> consumer) {
+ final MinusculeMatcher matcher = buildPatternMatcher(pattern, NameUtil.MatchingCaseSensitivity.NONE);
+
+ for (String name : names) {
+ ProgressManager.checkCanceled();
+ MatchResult result = matches(base, pattern, matcher, name);
+ if (result != null) {
+ consumer.consume(result);
+ }
+ }
+ }
+
+ private static String convertToMatchingPattern(ChooseByNameBase base, String pattern) {
+ pattern = removeModelSpecificMarkup(base, pattern);
+
if (!base.canShowListForEmptyPattern()) {
LOG.assertTrue(!pattern.isEmpty(), base);
}
- if (StringUtil.startsWithChar(pattern, '@') && base.getModel() instanceof GotoClassModel2) {
- pattern = pattern.substring(1);
+ if (base.isSearchInAnyPlace() && !pattern.trim().isEmpty()) {
+ pattern = "*" + pattern;
}
-
- final String finalPattern = pattern;
- final Matcher matcher;
-
- switch (matchingMode) {
- case CASE_SENSITIVE:
- matcher = buildPatternMatcher(pattern, NameUtil.MatchingCaseSensitivity.ALL);
- break;
- case CASE_INSENSITIVE:
- matcher = buildPatternMatcher(pattern, NameUtil.MatchingCaseSensitivity.NONE);
- break;
- case STRICT_CASE_INSENSITIVE:
- matcher = new Matcher() {
- @Override
- public boolean matches(@NotNull String name) {
- return StringUtil.startsWithIgnoreCase(name, finalPattern);
- }
- };
- break;
- default:
- return;
- }
-
- JobLauncher.getInstance().invokeConcurrentlyUnderProgress(names, indicator, false, new Processor<String>() {
- @Override
- public boolean process(String name) {
- if (matches(base, finalPattern, matcher, name)) {
- synchronized (outListFiltered) {
- outListFiltered.add(name);
- }
- }
- return true;
- }
- });
+ return pattern;
}
- private static boolean matches(@NotNull ChooseByNameBase base,
+ private static String removeModelSpecificMarkup(ChooseByNameBase base, String pattern) {
+ if (base.getModel() instanceof GotoClassModel2 && pattern.startsWith("@")) {
+ pattern = pattern.substring(1);
+ }
+ return pattern;
+ }
+
+ @Nullable
+ private static MatchResult matches(@NotNull ChooseByNameBase base,
@NotNull String pattern,
- @NotNull Matcher matcher,
+ @NotNull MinusculeMatcher matcher,
@Nullable String name) {
if (name == null) {
- return false;
+ return null;
}
- boolean matches = false;
if (base.getModel() instanceof CustomMatcherModel) {
- if (((CustomMatcherModel)base.getModel()).matches(name, pattern)) {
- matches = true;
+ try {
+ return ((CustomMatcherModel)base.getModel()).matches(name, pattern) ? new MatchResult(name, 0, true) : null;
+ }
+ catch (Exception e) {
+ LOG.info(e);
+ return null; // no matches appears valid result for "bad" pattern
}
}
- else if (pattern.isEmpty() || matcher.matches(name)) {
- matches = true;
- }
- return matches;
+ return matcher.matches(name) ? new MatchResult(name, matcher.matchingDegree(name), matcher.isStartMatch(name)) : null;
}
@NotNull
@@ -342,24 +302,6 @@
return NameUtil.buildMatcher(pattern, caseSensitivity);
}
- private static class MatchesComparator implements Comparator<String> {
- private final String myOriginalPattern;
-
- private MatchesComparator(@NotNull final String originalPattern) {
- myOriginalPattern = originalPattern.trim();
- }
-
- @Override
- public int compare(@NotNull final String a, @NotNull final String b) {
- boolean aStarts = a.startsWith(myOriginalPattern);
- boolean bStarts = b.startsWith(myOriginalPattern);
- if (aStarts && bStarts) return a.compareToIgnoreCase(b);
- if (aStarts) return -1;
- if (bStarts) return 1;
- return a.compareToIgnoreCase(b);
- }
- }
-
private static class PathProximityComparator implements Comparator<Object> {
private final ChooseByNameModel myModel;
@NotNull private final PsiProximityComparator myProximityComparator;
@@ -369,33 +311,44 @@
myProximityComparator = new PsiProximityComparator(context);
}
+ private static boolean isCompiledWithoutSource(Object o) {
+ return o instanceof PsiCompiledElement && ((PsiCompiledElement)o).getNavigationElement() == o;
+ }
+
@Override
public int compare(final Object o1, final Object o2) {
int rc = myProximityComparator.compare(o1, o2);
if (rc != 0) return rc;
- int compare = Comparing.compare(myModel.getFullName(o1), myModel.getFullName(o2));
- if (compare == 0) {
- int o1Weight;
- int o2Weight;
+ int o1Weight = isCompiledWithoutSource(o1) ? 1 : 0;
+ int o2Weight = isCompiledWithoutSource(o2) ? 1 : 0;
+ return o1Weight - o2Weight;
+ }
+ }
- if (o1 instanceof PsiCompiledElement) {
- PsiElement navElement = ((PsiCompiledElement)o1).getNavigationElement();
- o1Weight = navElement != o1 ? 0 : 1;
- } else {
- o1Weight = 0;
- }
+ protected static class MatchResult implements Comparable<MatchResult> {
+ public final String elementName;
+ final int matchingDegree;
+ final boolean startMatch;
- if (o2 instanceof PsiCompiledElement) {
- PsiElement navElement = ((PsiCompiledElement)o2).getNavigationElement();
- o2Weight = navElement != o2 ? 0 : 1;
- } else {
- o2Weight = 0;
- }
+ private MatchResult(String elementName, int matchingDegree, boolean startMatch) {
+ this.elementName = elementName;
+ this.matchingDegree = matchingDegree;
+ this.startMatch = startMatch;
+ }
- compare = o1Weight - o2Weight;
- }
- return compare;
+ @Override
+ public int compareTo(@NotNull MatchResult that) {
+ boolean start1 = startMatch;
+ boolean start2 = that.startMatch;
+ if (start1 != start2) return start1 ? -1 : 1;
+
+ int degree1 = matchingDegree;
+ int degree2 = that.matchingDegree;
+ if (degree2 < degree1) return -1;
+ if (degree2 > degree1) return 1;
+
+ return elementName.compareToIgnoreCase(that.elementName);
}
}
}
diff --git a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoFileCellRenderer.java b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoFileCellRenderer.java
index 08e84da..11a6b56 100644
--- a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoFileCellRenderer.java
+++ b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoFileCellRenderer.java
@@ -26,6 +26,7 @@
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ProjectFileIndex;
import com.intellij.openapi.util.Iconable;
+import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiDirectory;
@@ -126,7 +127,10 @@
assert itemPresentation != null;
renderer.setIcon(itemPresentation.getIcon(true));
- renderer.append(itemPresentation.getLocationString(), new SimpleTextAttributes(Font.PLAIN, JBColor.GRAY));
+ String locationString = itemPresentation.getLocationString();
+ if (!StringUtil.isEmpty(locationString)) {
+ renderer.append(locationString, new SimpleTextAttributes(Font.PLAIN, JBColor.GRAY));
+ }
return true;
}
diff --git a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoFileModel.java b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoFileModel.java
index 11264b4..91badbc 100644
--- a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoFileModel.java
+++ b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoFileModel.java
@@ -21,6 +21,7 @@
import com.intellij.ide.util.PsiElementListCellRenderer;
import com.intellij.navigation.ChooseByNameContributor;
import com.intellij.navigation.NavigationItem;
+import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.project.Project;
@@ -41,7 +42,7 @@
public GotoFileModel(@NotNull Project project) {
super(project, Extensions.getExtensions(ChooseByNameContributor.FILE_EP_NAME));
- myMaxSize = WindowManagerEx.getInstanceEx().getFrame(project).getSize().width;
+ myMaxSize = ApplicationManager.getApplication().isUnitTestMode() ? Integer.MAX_VALUE : WindowManagerEx.getInstanceEx().getFrame(project).getSize().width;
}
@Override
diff --git a/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeChooserConfigurable.java b/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeChooserConfigurable.java
index e4b918b..7c76f79 100644
--- a/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeChooserConfigurable.java
+++ b/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeChooserConfigurable.java
@@ -97,7 +97,8 @@
@Override
public boolean value(final Object o) {
if (o instanceof MyNode) {
- final Object editableObject = ((MyNode)o).getConfigurable().getEditableObject();
+ final NamedConfigurable namedConfigurable = ((MyNode)o).getConfigurable();
+ final Object editableObject = namedConfigurable != null ? namedConfigurable.getEditableObject() : null;
return editableObject instanceof NamedScope;
}
return false;
diff --git a/platform/lang-impl/src/com/intellij/ide/util/treeView/SmartElementDescriptor.java b/platform/lang-impl/src/com/intellij/ide/util/treeView/SmartElementDescriptor.java
index 7ed8f93..44b12d8 100644
--- a/platform/lang-impl/src/com/intellij/ide/util/treeView/SmartElementDescriptor.java
+++ b/platform/lang-impl/src/com/intellij/ide/util/treeView/SmartElementDescriptor.java
@@ -28,6 +28,7 @@
import com.intellij.psi.SmartPointerManager;
import com.intellij.psi.SmartPsiElementPointer;
import com.intellij.psi.util.PsiUtilBase;
+import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
@@ -36,7 +37,7 @@
protected PsiElement myElement;
private final SmartPsiElementPointer mySmartPointer;
- public SmartElementDescriptor(Project project, NodeDescriptor parentDescriptor, PsiElement element) {
+ public SmartElementDescriptor(@NotNull Project project, NodeDescriptor parentDescriptor, @NotNull PsiElement element) {
super(project, parentDescriptor);
myElement = element;
mySmartPointer = SmartPointerManager.getInstance(myProject).createSmartPsiElementPointer(element);
diff --git a/platform/lang-impl/src/com/intellij/injected/editor/EditorWindow.java b/platform/lang-impl/src/com/intellij/injected/editor/EditorWindow.java
index ac5c922..c993b85 100644
--- a/platform/lang-impl/src/com/intellij/injected/editor/EditorWindow.java
+++ b/platform/lang-impl/src/com/intellij/injected/editor/EditorWindow.java
@@ -527,6 +527,7 @@
return myDelegate.getContentSize();
}
+ @NotNull
@Override
public JScrollPane getScrollPane() {
return myDelegate.getScrollPane();
diff --git a/platform/lang-impl/src/com/intellij/internal/DumpInspectionDescriptionsAction.java b/platform/lang-impl/src/com/intellij/internal/DumpInspectionDescriptionsAction.java
index 397046b..a55e1f9 100644
--- a/platform/lang-impl/src/com/intellij/internal/DumpInspectionDescriptionsAction.java
+++ b/platform/lang-impl/src/com/intellij/internal/DumpInspectionDescriptionsAction.java
@@ -16,7 +16,7 @@
package com.intellij.internal;
import com.intellij.codeInspection.InspectionProfile;
-import com.intellij.codeInspection.InspectionProfileEntry;
+import com.intellij.codeInspection.ex.InspectionToolWrapper;
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationType;
@@ -52,7 +52,7 @@
@Override
public void actionPerformed(final AnActionEvent event) {
final InspectionProfile profile = (InspectionProfile)InspectionProfileManager.getInstance().getRootProfile();
- final InspectionProfileEntry[] tools = profile.getInspectionTools(null);
+ final InspectionToolWrapper[] tools = (InspectionToolWrapper[])profile.getInspectionTools(null);
final Collection<String> classes = ContainerUtil.newTreeSet();
final Map<String, Collection<String>> groups = ContainerUtil.newTreeMap();
@@ -64,17 +64,17 @@
return;
}
- for (InspectionProfileEntry tool : tools) {
- classes.add(getInspectionClass(tool).getName());
+ for (InspectionToolWrapper toolWrapper : tools) {
+ classes.add(getInspectionClass(toolWrapper).getName());
- final String group = getGroupName(tool);
+ final String group = getGroupName(toolWrapper);
Collection<String> names = groups.get(group);
if (names == null) groups.put(group, (names = ContainerUtil.newTreeSet()));
- names.add(tool.getShortName());
+ names.add(toolWrapper.getShortName());
- final URL url = getDescriptionUrl(tool);
+ final URL url = getDescriptionUrl(toolWrapper);
if (url != null) {
- doDump(new File(descDirectory, tool.getShortName() + ".html"), new Processor() {
+ doDump(new File(descDirectory, toolWrapper.getShortName() + ".html"), new Processor() {
@Override public void process(BufferedWriter writer) throws Exception {
writer.write(ResourceUtil.loadText(url));
}
@@ -116,18 +116,18 @@
}
}
- private static Class getInspectionClass(final InspectionProfileEntry tool) {
- return tool instanceof LocalInspectionToolWrapper ? ((LocalInspectionToolWrapper)tool).getTool().getClass() : tool.getClass();
+ private static Class getInspectionClass(final InspectionToolWrapper toolWrapper) {
+ return toolWrapper instanceof LocalInspectionToolWrapper ? ((LocalInspectionToolWrapper)toolWrapper).getTool().getClass() : toolWrapper.getClass();
}
- private static String getGroupName(final InspectionProfileEntry tool) {
- final String name = tool.getGroupDisplayName();
+ private static String getGroupName(final InspectionToolWrapper toolWrapper) {
+ final String name = toolWrapper.getGroupDisplayName();
return StringUtil.isEmptyOrSpaces(name) ? "General" : name;
}
- private static URL getDescriptionUrl(final InspectionProfileEntry tool) {
- final Class aClass = getInspectionClass(tool);
- return ResourceUtil.getResource(aClass, "/inspectionDescriptions", tool.getShortName() + ".html");
+ private static URL getDescriptionUrl(final InspectionToolWrapper toolWrapper) {
+ final Class aClass = getInspectionClass(toolWrapper);
+ return ResourceUtil.getResource(aClass, "/inspectionDescriptions", toolWrapper.getShortName() + ".html");
}
private interface Processor {
diff --git a/platform/lang-impl/src/com/intellij/internal/LoadAllContentsAction.java b/platform/lang-impl/src/com/intellij/internal/LoadAllContentsAction.java
index fe94674..36291e2 100644
--- a/platform/lang-impl/src/com/intellij/internal/LoadAllContentsAction.java
+++ b/platform/lang-impl/src/com/intellij/internal/LoadAllContentsAction.java
@@ -32,6 +32,7 @@
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.openapi.vfs.VFileProperty;
import com.intellij.openapi.vfs.VirtualFile;
import java.io.File;
@@ -66,7 +67,7 @@
ProjectRootManager.getInstance(project).getFileIndex().iterateContent(new ContentIterator() {
@Override
public boolean processFile(VirtualFile fileOrDir) {
- if (fileOrDir.isDirectory() || fileOrDir.is(VirtualFile.PROP_SPECIAL)) {
+ if (fileOrDir.isDirectory() || fileOrDir.is(VFileProperty.SPECIAL)) {
return true;
}
try {
diff --git a/platform/lang-impl/src/com/intellij/internal/LoadAllVfsStoredContentsAction.java b/platform/lang-impl/src/com/intellij/internal/LoadAllVfsStoredContentsAction.java
index bbfee43..aaeb486 100644
--- a/platform/lang-impl/src/com/intellij/internal/LoadAllVfsStoredContentsAction.java
+++ b/platform/lang-impl/src/com/intellij/internal/LoadAllVfsStoredContentsAction.java
@@ -30,6 +30,7 @@
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.openapi.vfs.VFileProperty;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.newvfs.ManagingFS;
import com.intellij.openapi.vfs.newvfs.NewVirtualFile;
@@ -91,18 +92,19 @@
}
public boolean processFile(NewVirtualFile file) {
- if (file.isDirectory() || file.is(VirtualFile.PROP_SPECIAL)) return true;
+ if (file.isDirectory() || file.is(VFileProperty.SPECIAL)) {
+ return true;
+ }
try {
DataInputStream stream = FSRecords.readContent(file.getId());
if (stream == null) return true;
byte[] bytes = FileUtil.loadBytes(stream);
totalSize.addAndGet(bytes.length);
count.incrementAndGet();
-
ProgressManager.getInstance().getProgressIndicator().setText(file.getPresentableUrl());
}
- catch (IOException e1) {
- LOG.error(e1);
+ catch (IOException e) {
+ LOG.error(e);
}
return true;
}
diff --git a/platform/lang-impl/src/com/intellij/lang/javascript/boilerplate/AbstractGithubTagDownloadedProjectGenerator.java b/platform/lang-impl/src/com/intellij/lang/javascript/boilerplate/AbstractGithubTagDownloadedProjectGenerator.java
index 2a86451..8c46ec5 100644
--- a/platform/lang-impl/src/com/intellij/lang/javascript/boilerplate/AbstractGithubTagDownloadedProjectGenerator.java
+++ b/platform/lang-impl/src/com/intellij/lang/javascript/boilerplate/AbstractGithubTagDownloadedProjectGenerator.java
@@ -2,14 +2,16 @@
import com.intellij.ide.util.projectWizard.WebProjectTemplate;
import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.application.ApplicationNamesInfo;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.platform.templates.github.*;
+import com.intellij.platform.templates.github.GeneratorException;
+import com.intellij.platform.templates.github.GithubTagInfo;
+import com.intellij.platform.templates.github.ZipUtil;
+import com.intellij.util.PlatformUtils;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -49,6 +51,12 @@
return getDisplayName();
}
+ @Nullable
+ @Override
+ public String getHelpId() {
+ return "create.from.template." + getGithubUserName() + "." + getGithubRepositoryName();
+ }
+
@Override
public void generateProject(@NotNull final Project project, @NotNull final VirtualFile baseDir,
@NotNull GithubTagInfo tag, @NotNull Module module) {
@@ -61,7 +69,7 @@
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
- baseDir.refresh(false, true);
+ baseDir.refresh(true, true);
}
});
}
@@ -74,7 +82,7 @@
@Override
public boolean isPrimaryGenerator() {
- return "WebStorm".equals(ApplicationNamesInfo.getInstance().getProductName());
+ return PlatformUtils.isWebStorm();
}
private void unpackToDir(@Nullable Project project,
@@ -84,7 +92,7 @@
boolean brokenZip = true;
if (zipArchiveFile.isFile()) {
try {
- ZipUtil.unzipWithProgressSynchronously(project, getTitle(), zipArchiveFile, extractToDir);
+ ZipUtil.unzipWithProgressSynchronously(project, getTitle(), zipArchiveFile, extractToDir, true);
brokenZip = false;
}
catch (GeneratorException ignored) {
@@ -124,7 +132,7 @@
);
LOG.info("Content of " + url + " has been successfully downloaded to " + zipArchiveFile.getAbsolutePath()
+ ", size " + zipArchiveFile.length() + " bytes");
- ZipUtil.unzipWithProgressSynchronously(project, getTitle(), zipArchiveFile, extractToDir);
+ ZipUtil.unzipWithProgressSynchronously(project, getTitle(), zipArchiveFile, extractToDir, true);
}
@Nullable
diff --git a/platform/lang-impl/src/com/intellij/lang/parser/GeneratedParserUtilBase.java b/platform/lang-impl/src/com/intellij/lang/parser/GeneratedParserUtilBase.java
index 5cb0564..6213db0 100644
--- a/platform/lang-impl/src/com/intellij/lang/parser/GeneratedParserUtilBase.java
+++ b/platform/lang-impl/src/com/intellij/lang/parser/GeneratedParserUtilBase.java
@@ -21,6 +21,7 @@
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.TokenSet;
import com.intellij.util.Function;
+import com.intellij.util.PairProcessor;
import com.intellij.util.containers.LimitedPool;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;
@@ -37,7 +38,7 @@
@SuppressWarnings("StringEquality")
public class GeneratedParserUtilBase {
- private static final Logger LOG = Logger.getInstance("com.intellij.lang.parser.GeneratedParserUtilBase");
+ private static final Logger LOG = Logger.getInstance("org.intellij.grammar.parser.GeneratedParserUtilBase");
public static final IElementType DUMMY_BLOCK = new DummyBlockElementType();
@@ -79,11 +80,11 @@
public static boolean invalid_left_marker_guard_(PsiBuilder builder_, PsiBuilder.Marker marker_, String funcName_) {
//builder_.error("Invalid left marker encountered in " + funcName_ +" at offset " + builder_.getCurrentOffset());
- boolean goodMarker = marker_ != null && ((LighterASTNode)marker_).getTokenType() != TokenType.ERROR_ELEMENT;
+ boolean goodMarker = marker_ != null; // && ((LighterASTNode)marker_).getTokenType() != TokenType.ERROR_ELEMENT;
if (!goodMarker) return false;
ErrorState state = ErrorState.get(builder_);
- Frame frame = state.frameStack.isEmpty() ? null : state.frameStack.getLast();
+ Frame frame = state.frameStack.peekLast();
return frame == null || frame.errorReportedAt <= builder_.getCurrentOffset();
}
@@ -91,13 +92,6 @@
return TokenSet.create(tokenTypes_);
}
- public static boolean type_extends_impl_(TokenSet[] extendsSet_, IElementType child_, IElementType parent_) {
- for (TokenSet set : extendsSet_) {
- if (set.contains(child_) && set.contains(parent_)) return true;
- }
- return false;
- }
-
public static boolean consumeTokens(PsiBuilder builder_, int pin_, IElementType... tokens_) {
ErrorState state = ErrorState.get(builder_);
if (state.completionState != null && state.predicateSign) {
@@ -282,23 +276,73 @@
}
}
-
+ // keep the old section API for compatibility
public static final String _SECTION_NOT_ = "_SECTION_NOT_";
public static final String _SECTION_AND_ = "_SECTION_AND_";
public static final String _SECTION_RECOVER_ = "_SECTION_RECOVER_";
public static final String _SECTION_GENERAL_ = "_SECTION_GENERAL_";
public static void enterErrorRecordingSection(PsiBuilder builder_, int level, @NotNull String sectionType, @Nullable String frameName) {
+ int modifiers = sectionType == _SECTION_GENERAL_ ? _NONE_ :
+ sectionType == _SECTION_NOT_ ? _NOT_ :
+ sectionType == _SECTION_AND_ ? _AND_ : _NONE_;
+ enter_section_impl_(builder_, level, modifiers, frameName);
+ }
+
+ public static boolean exitErrorRecordingSection(PsiBuilder builder_,
+ int level,
+ boolean result,
+ boolean pinned,
+ @NotNull String sectionType,
+ @Nullable Parser eatMore) {
+ exit_section_(builder_, level, null, null, result, pinned, eatMore);
+ return result;
+ }
+
+ // here's the new section API for compact parsers & less IntelliJ platform API exposure
+ public static final int _NONE_ = 0x0;
+ public static final int _COLLAPSE_ = 0x1;
+ public static final int _LEFT_ = 0x2;
+ public static final int _LEFT_INNER_ = 0x4;
+ public static final int _AND_ = 0x8;
+ public static final int _NOT_ = 0x10;
+
+ // simple enter/exit methods pair that doesn't require frame object
+ public static PsiBuilder.Marker enter_section_(PsiBuilder builder_) {
+ return builder_.mark();
+ }
+
+ public static void exit_section_(PsiBuilder builder_,
+ PsiBuilder.Marker marker,
+ @Nullable IElementType elementType,
+ boolean result) {
+ close_marker_impl_(ErrorState.get(builder_).frameStack.peekLast(), marker, elementType, result);
+ }
+
+ // complex enter/exit methods pair with frame object
+ public static PsiBuilder.Marker enter_section_(PsiBuilder builder_, int level, int modifiers, @Nullable String frameName) {
+ PsiBuilder.Marker marker = builder_.mark();
+ enter_section_impl_(builder_, level, modifiers, frameName);
+ return marker;
+ }
+
+ private static void enter_section_impl_(PsiBuilder builder_, int level, int modifiers, @Nullable String frameName) {
ErrorState state = ErrorState.get(builder_);
- Frame frame = state.FRAMES.alloc().init(builder_.getCurrentOffset(), level, sectionType, frameName, state.variants.size());
+ Frame frame = state.FRAMES.alloc().init(builder_.getCurrentOffset(), level, modifiers, frameName, state);
+ if (((frame.modifiers & _LEFT_) | (frame.modifiers & _LEFT_INNER_)) != 0) {
+ PsiBuilder.Marker left = (PsiBuilder.Marker)builder_.getLatestDoneMarker();
+ if (invalid_left_marker_guard_(builder_, left, frameName)) {
+ frame.leftMarker = left;
+ }
+ }
state.frameStack.add(frame);
- if (sectionType == _SECTION_AND_) {
+ if ((modifiers & _AND_) != 0) {
if (state.predicateCount == 0 && !state.predicateSign) {
throw new AssertionError("Incorrect false predicate sign");
}
state.predicateCount++;
}
- else if (sectionType == _SECTION_NOT_) {
+ else if ((modifiers & _NOT_) != 0) {
if (state.predicateCount == 0) {
state.predicateSign = false;
}
@@ -309,41 +353,47 @@
}
}
- public static boolean exitErrorRecordingSection(PsiBuilder builder_,
- int level,
- boolean result,
- boolean pinned,
- @NotNull String sectionType,
- @Nullable Parser eatMore) {
+ public static void exit_section_(PsiBuilder builder_,
+ int level,
+ PsiBuilder.Marker marker,
+ IElementType elementType,
+ boolean result,
+ boolean pinned,
+ @Nullable Parser eatMore) {
ErrorState state = ErrorState.get(builder_);
Frame frame = state.frameStack.pollLast();
- int initialOffset = builder_.getCurrentOffset();
- if (frame == null || level != frame.level || !sectionType.equals(frame.section)) {
- LOG.error("Unbalanced error section: got " + new Frame().init(initialOffset, level, sectionType, "", 0) + ", expected " + frame);
+ if (frame == null || level != frame.level) {
+ LOG.error("Unbalanced error section: got " + frame + ", expected level " + level);
if (frame != null) state.FRAMES.recycle(frame);
- return result;
+ close_marker_impl_(frame, marker, elementType, result);
+ return;
}
- if (sectionType == _SECTION_AND_ || sectionType == _SECTION_NOT_) {
+
+ if (((frame.modifiers & _AND_) | (frame.modifiers & _NOT_)) != 0) {
+ close_marker_impl_(frame, marker, null, false);
state.predicateCount--;
- if (sectionType == _SECTION_NOT_) state.predicateSign = !state.predicateSign;
+ if ((frame.modifiers & _NOT_) != 0) state.predicateSign = !state.predicateSign;
state.FRAMES.recycle(frame);
- return result;
+ return;
}
+ exit_section_impl_(state, frame, builder_, marker, elementType, result, pinned);
+
+ int initialOffset = builder_.getCurrentOffset();
boolean willFail = !result && !pinned;
if (willFail && initialOffset == frame.offset && state.lastExpectedVariantOffset == frame.offset &&
frame.name != null && state.variants.size() - frame.variantCount > 1) {
state.clearVariants(true, frame.variantCount);
addVariantInner(state, initialOffset, frame.name);
}
- if (sectionType == _SECTION_RECOVER_ && !state.suppressErrors && eatMore != null) {
+ if (!state.suppressErrors && eatMore != null) {
state.suppressErrors = true;
final boolean eatMoreFlagOnce = !builder_.eof() && eatMore.parse(builder_, frame.level + 1);
final int lastErrorPos = getLastVariantOffset(state, initialOffset);
boolean eatMoreFlag = eatMoreFlagOnce || !result && frame.offset == initialOffset && lastErrorPos > frame.offset;
final LighterASTNode latestDoneMarker =
- (pinned || result) && (state.altMode || lastErrorPos > initialOffset) &&
+ (pinned || result) && (state.altMode || lastErrorPos > initialOffset || level == 0) &&
eatMoreFlagOnce ? builder_.getLatestDoneMarker() : null;
PsiBuilder.Marker extensionMarker = null;
IElementType extensionTokenType = null;
@@ -364,7 +414,7 @@
builder_.advanceLexer();
eatMoreFlag = eatMore.parse(builder_, frame.level + 1);
}
- boolean errorReported = frame.errorReportedAt == initialOffset;
+ boolean errorReported = frame.errorReportedAt == initialOffset || !result && frame.errorReportedAt >= frame.offset;
if (errorReported) {
if (eatMoreFlag) {
builder_.advanceLexer();
@@ -395,11 +445,76 @@
reportError(builder_, state, frame, false, false);
}
}
- // propagate errorReportedAt up the stack to avoid duplicate reporting except marker.rollback case
- Frame prevFrame = willFail && sectionType == _SECTION_GENERAL_ || state.frameStack.isEmpty() ? null : state.frameStack.getLast();
+ // propagate errorReportedAt up the stack to avoid duplicate reporting
+ Frame prevFrame = willFail && eatMore == null ? null : state.frameStack.peekLast();
if (prevFrame != null && prevFrame.errorReportedAt < frame.errorReportedAt) prevFrame.errorReportedAt = frame.errorReportedAt;
state.FRAMES.recycle(frame);
- return result;
+ }
+
+ private static void exit_section_impl_(ErrorState state,
+ Frame frame,
+ PsiBuilder builder_,
+ PsiBuilder.Marker marker,
+ IElementType elementType,
+ boolean result,
+ boolean pinned) {
+ if (elementType != null && marker != null) {
+ if ((frame.modifiers & _COLLAPSE_) != 0) {
+ LighterASTNode last = result || pinned? builder_.getLatestDoneMarker() : null;
+ if (last != null && last.getStartOffset() == frame.offset && state.typeExtends(last.getTokenType(), elementType)) {
+ marker.drop();
+ return;
+ }
+ }
+ if (result || pinned) {
+ if ((frame.modifiers & _LEFT_INNER_) != 0 && frame.leftMarker != null) {
+ marker.done(elementType);
+ frame.leftMarker.precede().done(((LighterASTNode)frame.leftMarker).getTokenType());
+ frame.leftMarker.drop();
+ }
+ else if ((frame.modifiers & _LEFT_) != 0 && frame.leftMarker != null) {
+ marker.drop();
+ frame.leftMarker.precede().done(elementType);
+ }
+ else {
+ marker.done(elementType);
+ }
+ }
+ else {
+ close_marker_impl_(frame, marker, null, false);
+ }
+ }
+ else if (result || pinned) {
+ if (marker != null) marker.drop();
+ if ((frame.modifiers & _LEFT_INNER_) != 0 && frame.leftMarker != null) {
+ frame.leftMarker.precede().done(((LighterASTNode)frame.leftMarker).getTokenType());
+ frame.leftMarker.drop();
+ }
+ }
+ else {
+ close_marker_impl_(frame, marker, null, false);
+ }
+ }
+
+ private static void close_marker_impl_(Frame frame, PsiBuilder.Marker marker, IElementType elementType, boolean result) {
+ if (marker == null) return;
+ if (result) {
+ if (elementType != null) {
+ marker.done(elementType);
+ }
+ else {
+ marker.drop();
+ }
+ }
+ else {
+ if (frame != null) {
+ int offset = ((LighterASTNode)marker).getStartOffset();
+ if (frame.errorReportedAt > offset) {
+ frame.errorReportedAt = frame.errorReportedAtPrev;
+ }
+ }
+ marker.rollbackTo();
+ }
}
public static boolean report_error_(PsiBuilder builder_, boolean result_) {
@@ -487,12 +602,19 @@
}
public static PsiBuilder adapt_builder_(IElementType root, PsiBuilder builder, PsiParser parser) {
+ return adapt_builder_(root, builder, parser, null);
+ }
+
+ public static PsiBuilder adapt_builder_(IElementType root, PsiBuilder builder, PsiParser parser, TokenSet[] extendsSets) {
ErrorState state = new ErrorState();
- ErrorState.initState(root, builder, state);
+ ErrorState.initState(state, builder, root, extendsSets);
return new Builder(builder, state, parser);
}
public static class ErrorState {
+ TokenSet[] extendsSets;
+ public PairProcessor<IElementType, IElementType> altExtendsChecker;
+
int predicateCount;
boolean predicateSign = true;
boolean suppressErrors;
@@ -532,7 +654,8 @@
return ((Builder)builder).state;
}
- private static void initState(IElementType root, PsiBuilder builder, ErrorState state) {
+ private static void initState(ErrorState state, PsiBuilder builder, IElementType root, TokenSet[] extendsSets) {
+ state.extendsSets = extendsSets;
PsiFile file = builder.getUserDataUnprotected(FileContextUtil.CONTAINING_FILE_KEY);
state.completionState = file == null? null: file.getUserData(COMPLETION_STATE_KEY);
Language language = file == null? root.getLanguage() : file.getLanguage();
@@ -602,32 +725,55 @@
}
list.setSize(start);
}
+
+ boolean typeExtends(IElementType child_, IElementType parent_) {
+ if (extendsSets == null) {
+ return child_ == parent_ ||
+ altExtendsChecker != null && altExtendsChecker.process(child_, parent_);
+ }
+ for (TokenSet set : extendsSets) {
+ if (set.contains(child_) && set.contains(parent_)) return true;
+ }
+ return false;
+ }
}
public static class Frame {
public int offset;
public int level;
- public String section;
+ public int modifiers;
public String name;
public int variantCount;
public int errorReportedAt;
+ public int errorReportedAtPrev;
+ public PsiBuilder.Marker leftMarker;
public Frame() {
}
- public Frame init(int offset, int level, String section, String name, int variantCount) {
+ public Frame init(int offset, int level, int modifiers, String name, ErrorState state) {
this.offset = offset;
this.level = level;
- this.section = section;
+ this.modifiers = modifiers;
this.name = name;
- this.variantCount = variantCount;
+ this.variantCount = state.variants.size();
this.errorReportedAt = -1;
+
+ Frame prev = state.frameStack.peekLast();
+ errorReportedAtPrev = prev == null? -1 : prev.errorReportedAt;
+ leftMarker = null;
return this;
}
@Override
public String toString() {
- return "<"+offset+", "+section+", "+level+">";
+ String mod = modifiers == _NONE_ ? "_NONE_, " :
+ ((modifiers & _COLLAPSE_) != 0? "_CAN_COLLAPSE_, ": "") +
+ ((modifiers & _LEFT_) != 0? "_LEFT_, ": "") +
+ ((modifiers & _LEFT_INNER_) != 0? "_LEFT_INNER_, ": "") +
+ ((modifiers & _AND_) != 0? "_AND_, ": "") +
+ ((modifiers & _NOT_) != 0? "_NOT_, ": "");
+ return "<" + offset + ", " + mod + level + (errorReportedAt > -1 ? ", [" + errorReportedAt + "]" : "") + ">";
}
}
@@ -712,9 +858,11 @@
boolean checkParens = state.braces != null && checkBraces;
int totalCount = 0;
int tokenCount = 0;
- if (checkParens && builder_.rawLookup(-1) == state.braces[0].getLeftBraceType()) {
- LighterASTNode doneMarker = builder_.getLatestDoneMarker();
- if (doneMarker != null && doneMarker.getStartOffset() == builder_.rawTokenTypeStart(-1) && doneMarker.getTokenType() == TokenType.ERROR_ELEMENT) {
+ if (checkParens) {
+ int tokenIdx = -1;
+ while (builder_.rawLookup(tokenIdx) == TokenType.WHITE_SPACE) tokenIdx --;
+ LighterASTNode doneMarker = builder_.rawLookup(tokenIdx) == state.braces[0].getLeftBraceType() ? builder_.getLatestDoneMarker() : null;
+ if (doneMarker != null && doneMarker.getStartOffset() == builder_.rawTokenTypeStart(tokenIdx) && doneMarker.getTokenType() == TokenType.ERROR_ELEMENT) {
parenList.add(Pair.create(((PsiBuilder.Marker)doneMarker).precede(), (PsiBuilder.Marker)null));
}
}
@@ -748,7 +896,7 @@
if (marker == null) {
marker = builder_.mark();
}
- final boolean result = (state.altMode && !parenList.isEmpty() || eatMoreCondition.parse(builder_, level + 1)) && parser.parse(builder_, level + 1);
+ final boolean result = (!parenList.isEmpty() || eatMoreCondition.parse(builder_, level + 1)) && parser.parse(builder_, level + 1);
if (result) {
tokenCount++;
totalCount++;
@@ -792,21 +940,12 @@
super(DUMMY_BLOCK);
}
+ @NotNull
@Override
public PsiReference[] getReferences() {
return PsiReference.EMPTY_ARRAY;
}
- @Override
- public boolean canNavigateToSource() {
- return false;
- }
-
- @Override
- public boolean canNavigate() {
- return false;
- }
-
@NotNull
@Override
public Language getLanguage() {
diff --git a/platform/lang-impl/src/com/intellij/openapi/module/impl/ModuleImpl.java b/platform/lang-impl/src/com/intellij/openapi/module/impl/ModuleImpl.java
index e963210..8b252ee 100644
--- a/platform/lang-impl/src/com/intellij/openapi/module/impl/ModuleImpl.java
+++ b/platform/lang-impl/src/com/intellij/openapi/module/impl/ModuleImpl.java
@@ -329,8 +329,9 @@
return StringUtil.trimEnd(fileName, ModuleFileType.DOT_DEFAULT_EXTENSION);
}
+ @NotNull
@Override
- public <T> T[] getExtensions(final ExtensionPointName<T> extensionPointName) {
+ public <T> T[] getExtensions(@NotNull final ExtensionPointName<T> extensionPointName) {
return Extensions.getArea(this).getExtensionPoint(extensionPointName).getExtensions();
}
diff --git a/platform/lang-impl/src/com/intellij/openapi/vcs/impl/CodeSmellDetectorImpl.java b/platform/lang-impl/src/com/intellij/openapi/vcs/impl/CodeSmellDetectorImpl.java
index f05dea6..4338dd2 100644
--- a/platform/lang-impl/src/com/intellij/openapi/vcs/impl/CodeSmellDetectorImpl.java
+++ b/platform/lang-impl/src/com/intellij/openapi/vcs/impl/CodeSmellDetectorImpl.java
@@ -158,6 +158,7 @@
return result;
}
+ @NotNull
private List<CodeSmellInfo> findCodeSmells(@NotNull PsiFile psiFile, final ProgressIndicator progress, @NotNull Document document) {
final List<CodeSmellInfo> result = new ArrayList<CodeSmellInfo>();
diff --git a/platform/lang-impl/src/com/intellij/platform/templates/github/ZipUtil.java b/platform/lang-impl/src/com/intellij/platform/templates/github/ZipUtil.java
index bb943fe..28f86cb 100644
--- a/platform/lang-impl/src/com/intellij/platform/templates/github/ZipUtil.java
+++ b/platform/lang-impl/src/com/intellij/platform/templates/github/ZipUtil.java
@@ -22,7 +22,6 @@
/**
* @author Sergey Simonchik
*/
-@SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
public class ZipUtil {
private static final Logger LOG = Logger.getInstance(ZipUtil.class);
@@ -37,16 +36,22 @@
@Nullable Project project,
@NotNull String progressTitle,
@NotNull final File zipArchive,
- @NotNull final File extractToDir) throws GeneratorException
+ @NotNull final File extractToDir,
+ final boolean unwrapSingleTopLevelFolder) throws GeneratorException
{
- Outcome<Boolean> outcome = DownloadUtil.provideDataWithProgressSynchronously(
+ final Outcome<Boolean> outcome = DownloadUtil.provideDataWithProgressSynchronously(
project, progressTitle, "Unpacking ...",
new Callable<Boolean>() {
@Override
public Boolean call() throws IOException {
ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
ZipInputStream stream = new ZipInputStream(new FileInputStream(zipArchive));
- unzip(progress, extractToDir, stream, null, null);
+ try {
+ unzip(progress, extractToDir, stream, null, null, unwrapSingleTopLevelFolder);
+ }
+ finally {
+ stream.close();
+ }
return true;
}
},
@@ -69,20 +74,37 @@
}
public static void unzip(@Nullable ProgressIndicator progress,
- File extractToDir,
- ZipInputStream stream,
+ @NotNull File targetDir,
+ @NotNull ZipInputStream stream,
@Nullable NullableFunction<String, String> pathConvertor,
- @Nullable ContentProcessor contentProcessor) throws IOException {
+ @Nullable ContentProcessor contentProcessor,
+ boolean unwrapSingleTopLevelFolder) throws IOException {
if (progress != null) {
progress.setText("Extracting...");
}
- try {
- ZipEntry entry;
- while ((entry = stream.getNextEntry()) != null) {
- unzipEntryToDir(progress, entry, extractToDir, stream, pathConvertor, contentProcessor);
+ File unzipToDir = targetDir;
+ if (unwrapSingleTopLevelFolder) {
+ unzipToDir = FileUtil.createTempDirectory("unzip-dir-", null);
+ }
+
+ ZipEntry entry;
+ while ((entry = stream.getNextEntry()) != null) {
+ unzipEntryToDir(progress, entry, unzipToDir, stream, pathConvertor, contentProcessor);
+ }
+
+ if (unwrapSingleTopLevelFolder) {
+ File[] topLevelFiles = unzipToDir.listFiles();
+ File dirToMove;
+ if (topLevelFiles != null && topLevelFiles.length == 1 && topLevelFiles[0].isDirectory()) {
+ dirToMove = topLevelFiles[0];
}
- } finally {
- stream.close();
+ else {
+ dirToMove = unzipToDir;
+ }
+ if (!FileUtil.moveDirWithContent(dirToMove, targetDir)) {
+ FileUtil.copyDirContent(dirToMove, targetDir);
+ }
+ FileUtil.delete(unzipToDir);
}
}
@@ -92,7 +114,6 @@
ZipInputStream stream,
@Nullable NullableFunction<String, String> pathConvertor,
@Nullable ContentProcessor contentProcessor) throws IOException {
-
String relativeExtractPath = createRelativeExtractPath(zipEntry);
if (pathConvertor != null) {
relativeExtractPath = pathConvertor.fun(relativeExtractPath);
@@ -112,22 +133,25 @@
if (progress != null) {
progress.setText("Extracting " + relativeExtractPath + " ...");
}
- FileOutputStream fileOutputStream = null;
- try {
- if (contentProcessor == null) {
- fileOutputStream = new FileOutputStream(child);
+ if (contentProcessor == null) {
+ FileOutputStream fileOutputStream = new FileOutputStream(child);
+ try {
FileUtil.copy(stream, fileOutputStream);
}
- else {
- byte[] content = contentProcessor.processContent(FileUtil.loadBytes(stream), child);
- if (content != null) {
- fileOutputStream = new FileOutputStream(child);
+ finally {
+ fileOutputStream.close();
+ }
+ }
+ else {
+ byte[] content = contentProcessor.processContent(FileUtil.loadBytes(stream), child);
+ if (content != null) {
+ FileOutputStream fileOutputStream = new FileOutputStream(child);
+ try {
fileOutputStream.write(content);
}
- }
- } finally {
- if (fileOutputStream != null) {
- fileOutputStream.close();
+ finally {
+ fileOutputStream.close();
+ }
}
}
LOG.info("Extract: " + relativeExtractPath);
@@ -138,5 +162,4 @@
String name = StringUtil.trimStart(zipEntry.getName(), "/");
return StringUtil.trimEnd(name, "/");
}
-
}
diff --git a/platform/lang-impl/src/com/intellij/pom/wrappers/PsiEventWrapperAspect.java b/platform/lang-impl/src/com/intellij/pom/wrappers/PsiEventWrapperAspect.java
index c302804..363c622 100644
--- a/platform/lang-impl/src/com/intellij/pom/wrappers/PsiEventWrapperAspect.java
+++ b/platform/lang-impl/src/com/intellij/pom/wrappers/PsiEventWrapperAspect.java
@@ -32,6 +32,7 @@
import com.intellij.psi.impl.PsiManagerImpl;
import com.intellij.psi.impl.PsiTreeChangeEventImpl;
import com.intellij.psi.impl.source.SourceTreeToPsiMap;
+import com.intellij.psi.impl.source.tree.CompositeElement;
import java.util.Collections;
@@ -104,10 +105,10 @@
break;
case ChangeInfo.CONTENTS_CHANGED:
psiEvent.setOffset(treeElement.getStartOffset());
- psiEvent.setOldChild(psiChild);
- psiEvent.setNewChild(psiChild);
+ psiEvent.setParent(psiChild);
psiEvent.setOldLength(changeByChild.getOldLength());
- manager.childReplaced(psiEvent);
+ psiEvent.setGeneric(treeElement instanceof CompositeElement);
+ manager.childrenChanged(psiEvent);
break;
case ChangeInfo.REMOVED:
psiEvent.setOffset(changesByElement.getChildOffsetInNewTree(treeElement));
diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProfileManagerImpl.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProfileManagerImpl.java
index 2ff5d88..477a7b7 100644
--- a/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProfileManagerImpl.java
+++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProfileManagerImpl.java
@@ -17,6 +17,7 @@
import com.intellij.codeHighlighting.HighlightDisplayLevel;
import com.intellij.codeInsight.daemon.InspectionProfileConvertor;
+import com.intellij.codeInsight.daemon.impl.DaemonListeners;
import com.intellij.codeInsight.daemon.impl.HighlightInfoType;
import com.intellij.codeInsight.daemon.impl.SeveritiesProvider;
import com.intellij.codeInsight.daemon.impl.SeverityRegistrar;
@@ -26,6 +27,7 @@
import com.intellij.codeInspection.ex.InspectionToolRegistrar;
import com.intellij.lang.annotation.HighlightSeverity;
import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.components.ExportableComponent;
import com.intellij.openapi.components.NamedComponent;
import com.intellij.openapi.components.RoamingType;
@@ -39,8 +41,8 @@
import com.intellij.openapi.options.*;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
+import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.*;
-import com.intellij.openapi.util.io.FileUtil;
import com.intellij.profile.Profile;
import com.intellij.util.ArrayUtil;
import com.intellij.util.ui.UIUtil;
@@ -49,7 +51,6 @@
import org.jdom.JDOMException;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
import java.io.File;
@@ -63,7 +64,6 @@
*/
public class InspectionProfileManagerImpl extends InspectionProfileManager implements SeverityProvider, ExportableComponent, JDOMExternalizable,
NamedComponent {
- @NonNls private static final String PROFILE_NAME_TAG = "profile_name";
private final InspectionToolRegistrar myRegistrar;
private final SchemesManager<Profile, InspectionProfileImpl> mySchemesManager;
@@ -86,8 +86,8 @@
SchemeProcessor<InspectionProfileImpl> processor = new BaseSchemeProcessor<InspectionProfileImpl>() {
@Override
public InspectionProfileImpl readScheme(final Document document) {
- InspectionProfileImpl profile = new InspectionProfileImpl(getProfileName(document), myRegistrar, InspectionProfileManagerImpl.this);
- profile.load(document.getRootElement());
+ InspectionProfileImpl profile = new InspectionProfileImpl(InspectionProfileLoadUtil.getProfileName(document), myRegistrar, InspectionProfileManagerImpl.this);
+ read(profile, document.getRootElement());
return profile;
}
@@ -127,6 +127,22 @@
mySchemesManager = schemesManagerFactory.createSchemesManager(FILE_SPEC, processor, RoamingType.PER_USER);
}
+ private static void read(@NotNull final InspectionProfileImpl profile, @NotNull Element element) {
+ try {
+ profile.readExternal(element);
+ }
+ catch (Exception e) {
+ ApplicationManager.getApplication().invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ Messages.showErrorDialog(InspectionsBundle.message("inspection.error.loading.message", 0, profile.getName()),
+ InspectionsBundle.message("inspection.errors.occurred.dialog.title"));
+ }
+ }, ModalityState.NON_MODAL);
+ }
+ }
+
+ @NotNull
private static InspectionProfileImpl createSampleProfile() {
return new InspectionProfileImpl("Default");
}
@@ -207,49 +223,28 @@
public Profile loadProfile(@NotNull String path) throws IOException, JDOMException {
final File file = new File(path);
if (file.exists()){
- InspectionProfileImpl profile = new InspectionProfileImpl(getProfileName(file), myRegistrar, this);
- Element rootElement = JDOMUtil.loadDocument(file).getRootElement();
- final Element profileElement = rootElement.getChild("profile");
- if (profileElement != null) {
- rootElement = profileElement;
+ try {
+ return InspectionProfileLoadUtil.load(file, myRegistrar, this);
}
- profile.load(rootElement);
- return profile;
+ catch (IOException e) {
+ throw e;
+ }
+ catch (JDOMException e) {
+ throw e;
+ }
+ catch (Exception e) {
+ ApplicationManager.getApplication().invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ Messages.showErrorDialog(InspectionsBundle.message("inspection.error.loading.message", 0, file),
+ InspectionsBundle.message("inspection.errors.occurred.dialog.title"));
+ }
+ }, ModalityState.NON_MODAL);
+ }
}
return getProfile(path, false);
}
- private static String getProfileName(Document document) {
- String name = getRootElementAttribute(document, PROFILE_NAME_TAG);
- if (name != null) return name;
- return "unnamed";
- }
-
- private static String getProfileName(File file) {
- String name = getRootElementAttribute(file, PROFILE_NAME_TAG);
- if (name != null) return name;
- return FileUtil.getNameWithoutExtension(file);
- }
-
- private static String getRootElementAttribute(final Document document, @NonNls String name) {
- Element root = document.getRootElement();
- return root.getAttributeValue(name);
- }
-
- @Nullable
- private static String getRootElementAttribute(final File file, @NonNls String name) {
- try {
- Document doc = JDOMUtil.loadDocument(file);
- return getRootElementAttribute(doc, name);
- }
- catch (JDOMException e) {
- return null;
- }
- catch (IOException e) {
- return null;
- }
- }
-
@Override
public void updateProfile(@NotNull Profile profile) {
mySchemesManager.addNewScheme(profile, true);
@@ -312,11 +307,10 @@
if (returnRootProfileIfNamedIsAbsent) {
return getRootProfile();
}
- else {
- return null;
- }
+ return null;
}
+ @NotNull
@Override
public Profile getRootProfile() {
Profile current = mySchemesManager.getCurrentScheme();
@@ -335,7 +329,7 @@
}
@Override
- public void addProfile(final Profile profile) {
+ public void addProfile(@NotNull final Profile profile) {
mySchemesManager.addNewScheme(profile, true);
}
@@ -351,6 +345,7 @@
return getProfile(name, true);
}
+ @NotNull
public SchemesManager<Profile, InspectionProfileImpl> getSchemesManager() {
return mySchemesManager;
}
@@ -363,7 +358,9 @@
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
- InspectionProjectProfileManagerImpl.getInstanceImpl(project).updateStatusBar();
+ if (!project.isDisposed()) {
+ DaemonListeners.getInstance(project).updateStatusBar();
+ }
}
});
}
diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionConfigTreeNode.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionConfigTreeNode.java
index 6bec761..f8fdc2c 100644
--- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionConfigTreeNode.java
+++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionConfigTreeNode.java
@@ -17,7 +17,7 @@
import com.intellij.codeInspection.ex.Descriptor;
import com.intellij.codeInspection.ex.ScopeToolState;
-import com.intellij.codeInspection.ex.ScopeToolStateUtil;
+import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.ClearableLazyValue;
import com.intellij.psi.search.scope.packageSet.NamedScope;
import com.intellij.ui.CheckedTreeNode;
@@ -37,7 +37,7 @@
@Override
protected Boolean compute() {
Descriptor descriptor = getDescriptor();
- if (descriptor != null) return descriptor.getInspectionProfile().isProperSetting(descriptor.getTool().getShortName());
+ if (descriptor != null) return descriptor.getInspectionProfile().isProperSetting(descriptor.getToolWrapper().getShortName());
for (int i = 0; i < getChildCount(); i++) {
InspectionConfigTreeNode node = (InspectionConfigTreeNode)getChildAt(i);
if (node.isProperSetting()) {
@@ -48,7 +48,7 @@
}
};
- public InspectionConfigTreeNode(Object userObject, ScopeToolState state, boolean byDefault, boolean inspectionNode) {
+ public InspectionConfigTreeNode(@NotNull Object userObject, ScopeToolState state, boolean byDefault, boolean inspectionNode) {
super(userObject);
myState = state;
myByDefault = byDefault;
@@ -58,7 +58,7 @@
}
}
- public InspectionConfigTreeNode(Descriptor descriptor, ScopeToolState state, boolean byDefault, boolean isEnabled,
+ public InspectionConfigTreeNode(@NotNull Descriptor descriptor, ScopeToolState state, boolean byDefault, boolean isEnabled,
boolean inspectionNode) {
this(descriptor, state, byDefault, inspectionNode);
setChecked(isEnabled);
@@ -71,8 +71,8 @@
}
@Nullable
- public NamedScope getScope() {
- return myState != null ? ScopeToolStateUtil.getScope(myState) : null;
+ public NamedScope getScope(Project project) {
+ return myState == null ? null : myState.getScope(project);
}
public boolean isByDefault() {
diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionToolsConfigurable.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionToolsConfigurable.java
index 4caa989..7fec473 100644
--- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionToolsConfigurable.java
+++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionToolsConfigurable.java
@@ -25,6 +25,7 @@
import com.intellij.codeInsight.daemon.impl.HighlightInfoType;
import com.intellij.codeInsight.daemon.impl.SeverityRegistrar;
import com.intellij.codeInspection.ModifiableModel;
+import com.intellij.codeInspection.ex.InspectionManagerEx;
import com.intellij.codeInspection.ex.InspectionProfileImpl;
import com.intellij.codeInspection.ex.InspectionToolRegistrar;
import com.intellij.icons.AllIcons;
@@ -94,20 +95,21 @@
private JButton myCopyButton;
private JBScrollPane myJBScrollPane;
- private final ArrayList<String> myDeletedProfiles = new ArrayList<String>();
+ private final List<String> myDeletedProfiles = new ArrayList<String>();
protected final InspectionProfileManager myProfileManager;
protected final InspectionProjectProfileManager myProjectProfileManager;
private static final Logger LOG = Logger.getInstance("#" + InspectionToolsConfigurable.class.getName());
private Alarm mySelectionAlarm;
- public InspectionToolsConfigurable(InspectionProjectProfileManager projectProfileManager, InspectionProfileManager profileManager) {
- InspectionToolRegistrar.getInstance().buildInspectionSearchIndexIfNecessary();
+ public InspectionToolsConfigurable(@NotNull final InspectionProjectProfileManager projectProfileManager, InspectionProfileManager profileManager) {
+ ((InspectionManagerEx)InspectionManagerEx.getInstance(projectProfileManager.getProject())).buildInspectionSearchIndexIfNecessary();
myAddButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final Set<String> existingProfileNames = myPanels.keySet();
- final ModifiableModel model = SingleInspectionProfilePanel.createNewProfile(-1, getSelectedObject(), myWholePanel, "", existingProfileNames);
+ final ModifiableModel model = SingleInspectionProfilePanel.createNewProfile(-1, getSelectedObject(), myWholePanel, "", existingProfileNames,
+ projectProfileManager.getProject());
if (model != null) {
addProfile((InspectionProfileImpl)model);
myDeletedProfiles.remove(getProfilePrefix(model) + model.getName());
@@ -181,7 +183,7 @@
}
profile.readExternal(rootElement);
profile.setLocal(true);
- profile.initInspectionTools(null);
+ profile.initInspectionTools(project);
if (getProfilePanel(profile) != null) {
if (Messages.showOkCancelDialog(myWholePanel, "Profile with name \'" +
profile.getName() +
@@ -250,7 +252,7 @@
public void actionPerformed(ActionEvent e) {
final Set<String> existingProfileNames = myPanels.keySet();
final InspectionProfileImpl model = (InspectionProfileImpl)
- SingleInspectionProfilePanel.createNewProfile(0, getSelectedObject(), myWholePanel, "", existingProfileNames);
+ SingleInspectionProfilePanel.createNewProfile(0, getSelectedObject(), myWholePanel, "", existingProfileNames, project);
if (model != null) {
final InspectionProfileImpl modifiableModel = (InspectionProfileImpl)model.getModifiableModel();
modifiableModel.setModified(true);
diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionsConfigTreeRenderer.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionsConfigTreeRenderer.java
index 8b3b39e..8094a1b 100644
--- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionsConfigTreeRenderer.java
+++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/InspectionsConfigTreeRenderer.java
@@ -20,12 +20,13 @@
*/
package com.intellij.profile.codeInspection.ui;
-import com.intellij.codeInspection.InspectionProfileEntry;
import com.intellij.codeInspection.InspectionsBundle;
import com.intellij.codeInspection.ex.Descriptor;
import com.intellij.codeInspection.ex.GlobalInspectionToolWrapper;
+import com.intellij.codeInspection.ex.InspectionToolWrapper;
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
import com.intellij.ide.ui.search.SearchUtil;
+import com.intellij.openapi.project.Project;
import com.intellij.ui.CheckboxTree;
import com.intellij.ui.JBColor;
import com.intellij.ui.SimpleTextAttributes;
@@ -38,6 +39,12 @@
import java.awt.*;
abstract class InspectionsConfigTreeRenderer extends CheckboxTree.CheckboxTreeCellRenderer {
+ private final Project myProject;
+
+ public InspectionsConfigTreeRenderer(Project project) {
+ myProject = project;
+ }
+
protected abstract String getFilter();
@Override
@@ -58,7 +65,7 @@
Color foreground =
selected ? UIUtil.getTreeSelectionForeground() : node.isProperSetting() ? PlatformColors.BLUE : UIUtil.getTreeTextForeground();
- @NonNls String text = null;
+ @NonNls String text;
int style = SimpleTextAttributes.STYLE_PLAIN;
String hint = null;
if (object instanceof String) {
@@ -74,7 +81,7 @@
}
else {
text = "In scope \'" + scopeName + "\'";
- if (node.getScope() == null) {
+ if (node.getScope(myProject) == null) {
foreground = JBColor.RED;
}
}
@@ -97,12 +104,12 @@
@Nullable
private static String getHint(Descriptor descriptor) {
- final InspectionProfileEntry tool = descriptor.getTool();
- if (tool == null) {
+ final InspectionToolWrapper toolWrapper = descriptor.getToolWrapper();
+ if (toolWrapper == null) {
return InspectionsBundle.message("inspection.tool.availability.in.tree.node");
}
- if (tool instanceof LocalInspectionToolWrapper ||
- tool instanceof GlobalInspectionToolWrapper && !((GlobalInspectionToolWrapper)tool).worksInBatchModeOnly()) {
+ if (toolWrapper instanceof LocalInspectionToolWrapper ||
+ toolWrapper instanceof GlobalInspectionToolWrapper && !((GlobalInspectionToolWrapper)toolWrapper).worksInBatchModeOnly()) {
return null;
}
return InspectionsBundle.message("inspection.tool.availability.in.tree.node1");
diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java
index 4f31a02..d32b7f7 100644
--- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java
+++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java
@@ -24,7 +24,6 @@
import com.intellij.codeInsight.daemon.impl.SeverityUtil;
import com.intellij.codeInsight.hint.HintUtil;
import com.intellij.codeInspection.InspectionProfile;
-import com.intellij.codeInspection.InspectionProfileEntry;
import com.intellij.codeInspection.InspectionsBundle;
import com.intellij.codeInspection.ModifiableModel;
import com.intellij.codeInspection.ex.*;
@@ -40,6 +39,7 @@
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.options.ConfigurationException;
+import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.Splitter;
import com.intellij.openapi.util.Comparing;
@@ -108,6 +108,7 @@
private boolean myModified = false;
private Tree myTree;
private TreeExpander myTreeExpander;
+ @NotNull
private String myInitialProfile;
@NonNls private static final String EMPTY_HTML = "<html><body></body></html>";
private boolean myIsInRestore = false;
@@ -120,11 +121,9 @@
private Splitter myRightSplitter;
private Splitter myMainSplitter;
- public SingleInspectionProfilePanel(final String inspectionProfileName, final ModifiableModel profile) {
- this(null, inspectionProfileName, profile);
- }
-
- public SingleInspectionProfilePanel(InspectionProjectProfileManager projectProfileManager, final String inspectionProfileName, final ModifiableModel profile) {
+ public SingleInspectionProfilePanel(@NotNull InspectionProjectProfileManager projectProfileManager,
+ @NotNull String inspectionProfileName,
+ @NotNull ModifiableModel profile) {
super(new BorderLayout());
myProjectProfileManager = projectProfileManager;
mySelectedProfile = (InspectionProfileImpl)profile;
@@ -196,13 +195,13 @@
}
private boolean wereToolSettingsModified(Descriptor descriptor) {
- InspectionProfileEntry tool = descriptor.getTool();
- if (tool == null || !mySelectedProfile.isToolEnabled(descriptor.getKey())) {
+ InspectionToolWrapper toolWrapper = descriptor.getToolWrapper();
+ if (toolWrapper == null || !mySelectedProfile.isToolEnabled(descriptor.getKey())) {
return false;
}
Element oldConfig = descriptor.getConfig();
if (oldConfig == null) return false;
- Element newConfig = Descriptor.createConfigElement(tool);
+ Element newConfig = Descriptor.createConfigElement(toolWrapper);
if (!JDOMUtil.areElementsEqual(oldConfig, newConfig)) {
myAlarm.cancelAllRequests();
myAlarm.addRequest(new Runnable() {
@@ -243,27 +242,26 @@
final InspectionProfileImpl profile = mySelectedProfile;
if (profile == null) return;
myDescriptors.clear();
- List<ScopeToolState> tools = profile.getDefaultStates();
+ List<ScopeToolState> tools = profile.getDefaultStates(myProjectProfileManager.getProject());
for (ScopeToolState state : tools) {
final ArrayList<Descriptor> descriptors = new ArrayList<Descriptor>();
if (state.getLevel() == HighlightDisplayLevel.NON_SWITCHABLE_ERROR) {
continue;
}
- myDescriptors.put(new Descriptor(state, profile), descriptors);
- final List<ScopeToolState> nonDefaultTools = profile.getNonDefaultTools(state.getTool().getShortName());
- if (nonDefaultTools != null) {
- for (ScopeToolState nonDefaultToolState : nonDefaultTools) {
- descriptors.add(new Descriptor(nonDefaultToolState, profile));
- }
+ Project project = myProjectProfileManager.getProject();
+ myDescriptors.put(new Descriptor(state, profile, project), descriptors);
+ InspectionToolWrapper toolWrapper = state.getTool();
+ final List<ScopeToolState> nonDefaultTools = profile.getNonDefaultTools(toolWrapper.getShortName(), project);
+ for (ScopeToolState nonDefaultToolState : nonDefaultTools) {
+ descriptors.add(new Descriptor(nonDefaultToolState, profile, project));
}
}
-
}
private void postProcessModification() {
wereToolSettingsModified();
//resetup configs
- for (ScopeToolState state : mySelectedProfile.getAllTools()) {
+ for (ScopeToolState state : mySelectedProfile.getAllTools(myProjectProfileManager.getProject())) {
state.resetConfigPanel();
}
fillTreeData(myProfileFilter.getFilter(), true);
@@ -276,7 +274,8 @@
ModifiableModel selectedProfile,
JPanel parent,
String profileName,
- Set<String> existingProfileNames) {
+ Set<String> existingProfileNames,
+ @NotNull Project project) {
profileName = Messages.showInputDialog(parent, profileName, "Create New Inspection Profile", Messages.getQuestionIcon());
if (profileName == null) return null;
final ProfileManager profileManager = selectedProfile.getProfileManager();
@@ -288,11 +287,11 @@
InspectionProfileImpl inspectionProfile =
new InspectionProfileImpl(profileName, InspectionToolRegistrar.getInstance(), profileManager);
if (initValue == -1) {
- inspectionProfile.initInspectionTools(null);
+ inspectionProfile.initInspectionTools(project);
ModifiableModel profileModifiableModel = inspectionProfile.getModifiableModel();
- final InspectionProfileEntry[] profileEntries = profileModifiableModel.getInspectionTools(null);
- for (InspectionProfileEntry entry : profileEntries) {
- profileModifiableModel.disableTool(entry.getShortName(), (NamedScope)null);
+ final InspectionToolWrapper[] profileEntries = profileModifiableModel.getInspectionTools(null);
+ for (InspectionToolWrapper toolWrapper : profileEntries) {
+ profileModifiableModel.disableTool(toolWrapper.getShortName(), (NamedScope)null, project);
}
profileModifiableModel.setLocal(true);
profileModifiableModel.setModified(true);
@@ -300,7 +299,7 @@
} else if (initValue == 0) {
inspectionProfile.copyFrom(selectedProfile);
inspectionProfile.setName(profileName);
- inspectionProfile.initInspectionTools(null);
+ inspectionProfile.initInspectionTools(project);
inspectionProfile.setModified(true);
return inspectionProfile;
}
@@ -364,7 +363,7 @@
@Override
public void actionPerformed(AnActionEvent e) {
- mySelectedProfile.resetToBase();
+ mySelectedProfile.resetToBase(myProjectProfileManager.getProject());
postProcessModification();
}
});
@@ -373,12 +372,12 @@
@Override
public void update(AnActionEvent e) {
- e.getPresentation().setEnabled(mySelectedProfile != null && mySelectedProfile.isExecutable());
+ e.getPresentation().setEnabled(mySelectedProfile != null && mySelectedProfile.isExecutable(myProjectProfileManager.getProject()));
}
@Override
public void actionPerformed(AnActionEvent e) {
- mySelectedProfile.resetToEmpty();
+ mySelectedProfile.resetToEmpty(e.getProject());
postProcessModification();
}
});
@@ -465,7 +464,7 @@
fillTreeData(null, true);
- final InspectionsConfigTreeRenderer renderer = new InspectionsConfigTreeRenderer(){
+ final InspectionsConfigTreeRenderer renderer = new InspectionsConfigTreeRenderer(myProjectProfileManager.getProject()){
@Override
protected String getFilter() {
return myProfileFilter != null ? myProfileFilter.getFilter() : null;
@@ -615,29 +614,31 @@
private void toggleToolNode(final InspectionConfigTreeNode toolNode) {
final Descriptor descriptor = toolNode.getDescriptor();
+ Project project = myProjectProfileManager.getProject();
if (descriptor!= null) {
final HighlightDisplayKey key = descriptor.getKey();
final String toolShortName = key.toString();
if (toolNode.isChecked()) {
- if (toolNode.getScope() != null){
+ if (toolNode.getScope(project) != null){
if (toolNode.isByDefault()) {
- mySelectedProfile.enableToolByDefault(toolShortName);
- } else {
- mySelectedProfile.enableTool(toolShortName, toolNode.getScope());
+ mySelectedProfile.enableToolByDefault(toolShortName, project);
+ }
+ else {
+ mySelectedProfile.enableTool(toolShortName, toolNode.getScope(project), project);
}
} else {
- mySelectedProfile.enableTool(toolShortName);
+ mySelectedProfile.enableTool(toolShortName, project);
}
}
else {
- if (toolNode.getScope() != null) {
+ if (toolNode.getScope(project) != null) {
if (toolNode.isByDefault()) {
- mySelectedProfile.disableToolByDefault(toolShortName);
+ mySelectedProfile.disableToolByDefault(toolShortName, project);
} else {
- mySelectedProfile.disableTool(toolShortName, toolNode.getScope());
+ mySelectedProfile.disableTool(toolShortName, toolNode.getScope(project), project);
}
} else if (toolNode.getChildCount() == 0){ //default node and no scopes configured
- mySelectedProfile.disableTool(toolShortName);
+ mySelectedProfile.disableTool(toolShortName, project);
}
}
toolNode.dropCache();
@@ -656,16 +657,6 @@
}
}
- private static boolean wasModified(InspectionConfigTreeNode node) {
- for (int i = 0; i < node.getChildCount(); i++) {
- final InspectionConfigTreeNode childNode = (InspectionConfigTreeNode)node.getChildAt(i);
- if (childNode.isProperSetting()) {
- return true;
- }
- }
- return false;
- }
-
private static boolean isDescriptorAccepted(Descriptor descriptor,
@NonNls String filter,
final boolean forceInclude,
@@ -689,7 +680,7 @@
return true;
}
}
- final String description = descriptor.getTool().loadDescription();
+ final String description = descriptor.getToolWrapper().loadDescription();
if (description != null && StringUtil.containsIgnoreCase(description.toLowerCase(), stripped)) {
if (!forceInclude) return true;
} else if (forceInclude) return false;
@@ -715,23 +706,25 @@
myRoot.setChecked(false);
myRoot.dropCache();
List<Set<String>> keySetList = new ArrayList<Set<String>>();
- final Set<String> quated = new HashSet<String>();
- if (filter != null && filter.length() > 0) {
- keySetList.addAll(SearchUtil.findKeys(filter, quated));
+ final Set<String> quoted = new HashSet<String>();
+ if (filter != null && !filter.isEmpty()) {
+ keySetList.addAll(SearchUtil.findKeys(filter, quoted));
}
+ Project project = myProjectProfileManager.getProject();
for (Descriptor descriptor : myDescriptors.keySet()) {
- if (filter != null && filter.length() > 0 && !isDescriptorAccepted(descriptor, filter, forceInclude, keySetList, quated)) {
+ if (filter != null && !filter.isEmpty() && !isDescriptorAccepted(descriptor, filter, forceInclude, keySetList, quoted)) {
continue;
}
- final List<ScopeToolState> nonDefaultTools = mySelectedProfile.getNonDefaultTools(descriptor.getKey().toString());
+ final List<ScopeToolState> nonDefaultTools = mySelectedProfile.getNonDefaultTools(descriptor.getKey().toString(), project);
final HighlightDisplayKey key = descriptor.getKey();
final boolean enabled = mySelectedProfile.isToolEnabled(key);
- boolean hasNonDefaultScope = nonDefaultTools != null && !nonDefaultTools.isEmpty();
+ boolean hasNonDefaultScope = !nonDefaultTools.isEmpty();
final InspectionConfigTreeNode node = new InspectionConfigTreeNode(descriptor, null, !hasNonDefaultScope, enabled, !hasNonDefaultScope);
getGroupNode(myRoot, descriptor.getGroup()).add(node);
if (hasNonDefaultScope) {
for (ScopeToolState nonDefaultState : nonDefaultTools) {
- node.add(new InspectionConfigTreeNode(new Descriptor(nonDefaultState, mySelectedProfile), nonDefaultState, false, false));
+ node.add(new InspectionConfigTreeNode(new Descriptor(nonDefaultState, mySelectedProfile,
+ project), nonDefaultState, false, false));
}
node.add(new InspectionConfigTreeNode(descriptor, descriptor.getState(), true, false));
}
@@ -740,7 +733,7 @@
}
if (filter != null && forceInclude && myRoot.getChildCount() == 0) {
final Set<String> filters = SearchableOptionsRegistrar.getInstance().getProcessedWords(filter);
- if (filters.size() > 1) {
+ if (filters.size() > 1 || !quoted.isEmpty()) {
fillTreeData(filter, false);
}
}
@@ -783,7 +776,7 @@
myOptionsPanel.removeAll();
- final NamedScope scope = node.getScope();
+ final NamedScope scope = node.getScope(myProjectProfileManager.getProject());
if (scope != null || node.isInspectionNode()) {
final HighlightDisplayKey key = descriptor.getKey();
final LevelChooser chooser = new LevelChooser(((SeverityProvider)mySelectedProfile.getProfileManager()).getOwnSeverityRegistrar()) {
@@ -801,12 +794,14 @@
chooser.getComboBox().addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
- boolean toUpdate = mySelectedProfile.getErrorLevel(key, scope) != chooser.getLevel();
- mySelectedProfile.setErrorLevel(key, chooser.getLevel(), node.isInspectionNode() || node.isByDefault() ? -1 : node.getParent().getIndex(node));
+ Project project = myProjectProfileManager.getProject();
+ boolean toUpdate = mySelectedProfile.getErrorLevel(key, scope, project) != chooser.getLevel();
+ mySelectedProfile.setErrorLevel(key, chooser.getLevel(), node.isInspectionNode() || node.isByDefault() ? -1 : node.getParent().getIndex(node),
+ project);
if (toUpdate) node.dropCache();
}
});
- chooser.setLevel(mySelectedProfile.getErrorLevel(key, scope));
+ chooser.setLevel(mySelectedProfile.getErrorLevel(key, scope, myProjectProfileManager.getProject()));
final JPanel withSeverity = new JPanel(new GridBagLayout());
withSeverity.add(new JLabel(InspectionsBundle.message("inspection.severity")),
@@ -816,7 +811,7 @@
GridBagConstraints.NONE, new Insets(0, 0, 10, 0), 0, 0));
final JComponent comp = descriptor.getState().getAdditionalConfigPanel();
- withSeverity.add(comp != null ? comp : new JPanel(),
+ withSeverity.add(comp,
new GridBagConstraints(0, 1, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST,
GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
@@ -897,7 +892,7 @@
myAlarm.cancelAllRequests();
myProfileFilter.dispose();
if (mySelectedProfile != null) {
- for (ScopeToolState state : mySelectedProfile.getAllTools()) {
+ for (ScopeToolState state : mySelectedProfile.getAllTools(myProjectProfileManager.getProject())) {
state.resetConfigPanel();
}
}
@@ -1033,29 +1028,30 @@
private boolean descriptorsAreChanged() {
for (Map.Entry<Descriptor, List<Descriptor>> entry : myDescriptors.entrySet()) {
Descriptor desc = entry.getKey();
- if (mySelectedProfile.isToolEnabled(desc.getKey(), (NamedScope)null) != desc.isEnabled()){
+ Project project = myProjectProfileManager.getProject();
+ if (mySelectedProfile.isToolEnabled(desc.getKey(), (NamedScope)null, project) != desc.isEnabled()){
return true;
}
- if (mySelectedProfile.getErrorLevel(desc.getKey(), desc.getScope()) != desc.getLevel()) {
+ if (mySelectedProfile.getErrorLevel(desc.getKey(), desc.getScope(), project) != desc.getLevel()) {
return true;
}
final List<Descriptor> descriptors = entry.getValue();
for (Descriptor descriptor : descriptors) {
- if (mySelectedProfile.isToolEnabled(descriptor.getKey(), descriptor.getScope()) != descriptor.isEnabled()) {
+ if (mySelectedProfile.isToolEnabled(descriptor.getKey(), descriptor.getScope(), project) != descriptor.isEnabled()) {
return true;
}
- if (mySelectedProfile.getErrorLevel(descriptor.getKey(), descriptor.getScope()) != descriptor.getLevel()) {
+ if (mySelectedProfile.getErrorLevel(descriptor.getKey(), descriptor.getScope(), project) != descriptor.getLevel()) {
return true;
}
}
- final List<ScopeToolState> tools = mySelectedProfile.getNonDefaultTools(desc.getKey().toString());
+ final List<ScopeToolState> tools = mySelectedProfile.getNonDefaultTools(desc.getKey().toString(), project);
if (tools.size() != descriptors.size()) {
return true;
}
- for (int i = 0, toolsSize = tools.size(); i < toolsSize; i++) {
+ for (int i = 0; i < tools.size(); i++) {
final ScopeToolState pair = tools.get(i);
- if (!Comparing.equal(ScopeToolStateUtil.getScope(pair), descriptors.get(i).getScope())) {
+ if (!Comparing.equal(pair.getScope(project), descriptors.get(i).getScope())) {
return true;
}
}
@@ -1130,7 +1126,8 @@
final boolean showOptionsAndDescriptorPanels,
@NotNull HighlightDisplayLevel level) {
final HighlightDisplayKey key = child.getDescriptor().getKey();
- mySelectedProfile.setErrorLevel(key, level, child.isInspectionNode() || child.isByDefault() ? -1 : child.getParent().getIndex(child));
+ mySelectedProfile.setErrorLevel(key, level, child.isInspectionNode() || child.isByDefault() ? -1 : child.getParent().getIndex(child),
+ myProjectProfileManager.getProject());
child.dropCache();
if (showOptionsAndDescriptorPanels) {
updateOptionsAndDescriptionPanel(new TreePath(child.getPath()));
@@ -1140,7 +1137,7 @@
private class MyFilterComponent extends FilterComponent {
private MyFilterComponent() {
super(INSPECTION_FILTER_HISTORY, 10);
- setHistory(Arrays.asList("\"New in 12\""));
+ setHistory(Arrays.asList("\"New in 13\""));
}
@Override
@@ -1155,7 +1152,7 @@
getExpandedNodes(mySelectedProfile).saveVisibleState(myTree);
fillTreeData(filter, true);
reloadModel();
- if (filter == null || filter.length() == 0) {
+ if (filter == null || filter.isEmpty()) {
restoreTreeState();
} else {
TreeUtil.expandAll(myTree);
diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/actions/AddScopeAction.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/actions/AddScopeAction.java
index cd1c5f6..1927263 100644
--- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/actions/AddScopeAction.java
+++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/actions/AddScopeAction.java
@@ -20,13 +20,16 @@
*/
package com.intellij.profile.codeInspection.ui.actions;
-import com.intellij.codeInspection.InspectionProfileEntry;
+import com.intellij.codeHighlighting.HighlightDisplayLevel;
import com.intellij.codeInspection.ex.Descriptor;
import com.intellij.codeInspection.ex.InspectionProfileImpl;
+import com.intellij.codeInspection.ex.InspectionToolWrapper;
import com.intellij.codeInspection.ex.ScopeToolState;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.project.ProjectManager;
+import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.ui.Messages;
import com.intellij.packageDependencies.DefaultScopesProvider;
import com.intellij.profile.codeInspection.ui.InspectionConfigTreeNode;
@@ -56,8 +59,7 @@
final Presentation presentation = e.getPresentation();
presentation.setEnabled(false);
if (getSelectedProfile() == null) return;
- final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext());
- if (project == null) return;
+ final Project project = getProject(e);
final InspectionConfigTreeNode[] selectedNodes = myTree.getSelectedNodes(InspectionConfigTreeNode.class, null);
if (selectedNodes == null) return;
final List<Descriptor> descriptors = new ArrayList<Descriptor>();
@@ -68,6 +70,14 @@
presentation.setEnabled(!getAvailableScopes(project, descriptors).isEmpty());
}
+ private static Project getProject(AnActionEvent e) {
+ Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext());
+ if (project == null) {
+ project = ProjectManager.getInstance().getDefaultProject();
+ }
+ return project;
+ }
+
@Override
public void actionPerformed(AnActionEvent e) {
final List<Descriptor> descriptors = new ArrayList<Descriptor>();
@@ -79,7 +89,7 @@
collect(descriptors, nodes, node);
}
- final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext());
+ final Project project = getProject(e);
final List<String> availableScopes = getAvailableScopes(project, descriptors);
final int idx = Messages.showChooseDialog(myTree, "Scope:", "Choose Scope", ArrayUtil.toStringArray(availableScopes), availableScopes.get(0), Messages.getQuestionIcon());
if (idx == -1) return;
@@ -88,13 +98,14 @@
for (InspectionConfigTreeNode node : nodes) {
final Descriptor descriptor = node.getDescriptor();
if (node.getScopeName() != null || descriptor == null) continue;
- final InspectionProfileEntry tool = descriptor.getTool(); //copy
- final ScopeToolState scopeToolState = getSelectedProfile().addScope(tool, chosenScope,
- getSelectedProfile().getErrorLevel(descriptor.getKey(), chosenScope),
- getSelectedProfile().isToolEnabled(descriptor.getKey()));
- final Descriptor addedDescriptor = new Descriptor(scopeToolState, getSelectedProfile());
+ final InspectionToolWrapper toolWrapper = descriptor.getToolWrapper(); //copy
+ InspectionProfileImpl selectedProfile = getSelectedProfile();
+ HighlightDisplayLevel level = selectedProfile.getErrorLevel(descriptor.getKey(), chosenScope, project);
+ boolean enabled = selectedProfile.isToolEnabled(descriptor.getKey());
+ final ScopeToolState scopeToolState = selectedProfile.addScope(toolWrapper, chosenScope, level, enabled, project);
+ final Descriptor addedDescriptor = new Descriptor(scopeToolState, selectedProfile, project);
if (node.getChildCount() == 0) {
- node.add(new InspectionConfigTreeNode(descriptor, getSelectedProfile().getToolDefaultState(descriptor.getKey().toString()), true, true, false));
+ node.add(new InspectionConfigTreeNode(descriptor, selectedProfile.getToolDefaultState(descriptor.getKey().toString(), project), true, true, false));
}
node.insert(new InspectionConfigTreeNode(addedDescriptor, scopeToolState, false, false), 0);
node.setInspectionNode(false);
@@ -127,13 +138,13 @@
for (NamedScopesHolder holder : NamedScopesHolder.getAllNamedScopeHolders(project)) {
Collections.addAll(scopes, holder.getScopes());
}
- scopes.remove(DefaultScopesProvider.getAllScope());
+ scopes.remove(CustomScopesProviderEx.getAllScope());
CustomScopesProviderEx.filterNoSettingsScopes(project, scopes);
final Set<NamedScope> used = new HashSet<NamedScope>();
for (Descriptor descriptor : descriptors) {
- final List<ScopeToolState> nonDefaultTools = getSelectedProfile().getNonDefaultTools(descriptor.getKey().toString());
+ final List<ScopeToolState> nonDefaultTools = getSelectedProfile().getNonDefaultTools(descriptor.getKey().toString(), project);
if (nonDefaultTools != null) {
for (ScopeToolState state : nonDefaultTools) {
used.add(state.getScope(project));
diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/actions/DeleteScopeAction.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/actions/DeleteScopeAction.java
index cdd28fb..264d2ee 100644
--- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/actions/DeleteScopeAction.java
+++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/actions/DeleteScopeAction.java
@@ -69,12 +69,13 @@
parent = (InspectionConfigTreeNode)node.getParent();
final HighlightDisplayKey key = descriptor.getKey();
if (parent.getChildCount() <= 2) { //remove default with last non-default
- getSelectedProfile().removeAllScopes(key.toString());
+ getSelectedProfile().removeAllScopes(key.toString(), e.getProject());
parent.removeAllChildren();
parent.setInspectionNode(true);
parent.setByDefault(true);
- } else {
- getSelectedProfile().removeScope(key.toString(), parent.getIndex(node));
+ }
+ else {
+ getSelectedProfile().removeScope(key.toString(), parent.getIndex(node), e.getProject());
node.removeFromParent();
}
((DefaultTreeModel)myTree.getModel()).reload(parent);
diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/actions/MoveScopeAction.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/actions/MoveScopeAction.java
index 289b30a..40d4b43 100644
--- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/actions/MoveScopeAction.java
+++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/actions/MoveScopeAction.java
@@ -54,7 +54,7 @@
final InspectionConfigTreeNode[] nodes = myTree.getSelectedNodes(InspectionConfigTreeNode.class, null);
if (nodes.length > 0) {
final InspectionConfigTreeNode treeNode = nodes[0];
- if (treeNode.getScope() != null && !treeNode.isByDefault()) {
+ if (treeNode.getScope(getEventProject(e)) != null && !treeNode.isByDefault()) {
final TreeNode parent = treeNode.getParent();
final int index = parent.getIndex(treeNode);
presentation.setEnabled(isEnabledFor(index, (InspectionConfigTreeNode)parent));
@@ -69,7 +69,7 @@
final Descriptor descriptor = node.getDescriptor();
final TreeNode parent = node.getParent();
final int index = parent.getIndex(node);
- getSelectedProfile().moveScope(descriptor.getKey().toString(), index, myDir);
+ getSelectedProfile().moveScope(descriptor.getKey().toString(), index, myDir, e.getProject());
node.removeFromParent();
((InspectionConfigTreeNode)parent).insert(node, index + myDir);
((DefaultTreeModel)myTree.getModel()).reload(parent);
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/DocumentCommitThread.java b/platform/lang-impl/src/com/intellij/psi/impl/DocumentCommitThread.java
index 768a905..e8da8cb 100644
--- a/platform/lang-impl/src/com/intellij/psi/impl/DocumentCommitThread.java
+++ b/platform/lang-impl/src/com/intellij/psi/impl/DocumentCommitThread.java
@@ -293,7 +293,7 @@
((ProgressManagerImpl)ProgressManager.getInstance()).executeProcessUnderProgress(new Runnable() {
@Override
public void run() {
- result[0] = commitUnderProgress(commitTask, null, false);
+ result[0] = commitUnderProgress(commitTask, false);
}
}, commitTask.indicator);
finishRunnable = result[0];
@@ -331,7 +331,7 @@
}
@Override
- public void commitSynchronously(@NotNull Document document, @NotNull Project project, PsiFile excludeFile) {
+ public void commitSynchronously(@NotNull Document document, @NotNull Project project) {
assert !isDisposed;
ApplicationManager.getApplication().assertWriteAccessAllowed();
@@ -363,7 +363,7 @@
log("About to commit sync", task, true, indicator);
- Runnable finish = commitUnderProgress(task, excludeFile, true);
+ Runnable finish = commitUnderProgress(task, true);
log("Committed sync", task, true, finish, indicator);
assert finish != null;
@@ -392,7 +392,6 @@
// returns finish commit Runnable (to be invoked later in EDT), or null on failure
@Nullable
private Runnable commitUnderProgress(@NotNull final CommitTask task,
- final PsiFile excludeFile,
final boolean synchronously) {
final Project project = task.project;
final Document document = task.document;
@@ -407,8 +406,8 @@
if (viewProvider == null) return;
List<PsiFile> psiFiles = viewProvider.getAllFiles();
for (PsiFile file : psiFiles) {
- if (file.isValid() && file != excludeFile) {
- Processor<Document> finishProcessor = doCommit(task, file, synchronously, documentManager);
+ if (file.isValid()) {
+ Processor<Document> finishProcessor = doCommit(task, file, synchronously);
if (finishProcessor != null) {
finishProcessors.add(finishProcessor);
}
@@ -465,9 +464,6 @@
}
PsiDocumentManagerImpl documentManager = (PsiDocumentManagerImpl)PsiDocumentManager.getInstance(project);
- Collection<Document> uncommitted = documentManager.getUncommittedDocumentsUnsafe();
- FileViewProvider viewProvider = documentManager.getCachedViewProvider(document);
- //if (!documentManager.getSynchronizer().isInSynchronization(document) && !uncommitted.contains(document)) return; // already committed, must be the sync commit
log("Executing later finishCommit", task, false);
boolean success = documentManager.finishCommit(document, finishProcessors, synchronously, task.reason);
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/PsiDocumentManagerImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/PsiDocumentManagerImpl.java
index e8cce03..ed24be1 100644
--- a/platform/lang-impl/src/com/intellij/psi/impl/PsiDocumentManagerImpl.java
+++ b/platform/lang-impl/src/com/intellij/psi/impl/PsiDocumentManagerImpl.java
@@ -141,20 +141,6 @@
}
@Override
- public void commitOtherFilesAssociatedWithDocument(final Document document, final PsiFile psiFile) {
- super.commitOtherFilesAssociatedWithDocument(document, psiFile);
- final FileViewProvider viewProvider = getCachedViewProvider(document);
- if (viewProvider != null && viewProvider.getAllFiles().size() > 1) {
- PostprocessReformattingAspect.getInstance(myProject).disablePostprocessFormattingInside(new Runnable() {
- @Override
- public void run() {
- doCommit(document, psiFile);
- }
- });
- }
- }
-
- @Override
public boolean isDocumentBlockedByPsi(@NotNull Document doc) {
final FileViewProvider viewProvider = getCachedViewProvider(doc);
return viewProvider != null && PostprocessReformattingAspect.getInstance(myProject).isViewProviderLocked(viewProvider);
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/file/impl/PsiVFSListener.java b/platform/lang-impl/src/com/intellij/psi/impl/file/impl/PsiVFSListener.java
index 1f5abc3..9174d3c 100644
--- a/platform/lang-impl/src/com/intellij/psi/impl/file/impl/PsiVFSListener.java
+++ b/platform/lang-impl/src/com/intellij/psi/impl/file/impl/PsiVFSListener.java
@@ -208,7 +208,7 @@
VirtualFile parent = vFile.getParent();
final PsiDirectory parentDir = getCachedDirectory(parent);
- if (parentDir == null) return; // do not notifyListeners event if parent directory was never accessed via PSI
+ if (parent != null && parentDir == null) return; // do not notifyListeners event if parent directory was never accessed via PSI
ApplicationManager.getApplication().runWriteAction(
new ExternalChangeAction() {
@@ -220,6 +220,8 @@
if (VirtualFile.PROP_NAME.equals(propertyName)) {
final String newName = (String)event.getNewValue();
+ if (parentDir == null) return;
+
if (vFile.isDirectory()) {
PsiDirectory psiDir = myFileManager.findDirectory(vFile);
if (psiDir != null) {
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/search/NonPhysicalReferenceSearcher.java b/platform/lang-impl/src/com/intellij/psi/impl/search/NonPhysicalReferenceSearcher.java
new file mode 100644
index 0000000..43abc69
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/psi/impl/search/NonPhysicalReferenceSearcher.java
@@ -0,0 +1,57 @@
+package com.intellij.psi.impl.search;
+
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.QueryExecutorBase;
+import com.intellij.openapi.fileEditor.FileEditorManager;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.psi.*;
+import com.intellij.psi.search.GlobalSearchScope;
+import com.intellij.psi.search.LocalSearchScope;
+import com.intellij.psi.search.SearchScope;
+import com.intellij.psi.search.searches.ReferencesSearch;
+import com.intellij.util.Processor;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author Gregory.Shrago
+ * This searcher does the job for various console and fragment editors and other non-physical files.
+ * We need this because ScopeEnlarger functionality will not work for nonphysical files.
+ */
+public class NonPhysicalReferenceSearcher extends QueryExecutorBase<PsiReference, ReferencesSearch.SearchParameters> {
+
+ public NonPhysicalReferenceSearcher() {
+ super(true);
+ }
+
+ public void processQuery(@NotNull ReferencesSearch.SearchParameters queryParameters, @NotNull Processor<PsiReference> consumer) {
+ if (ApplicationManager.getApplication().isUnitTestMode()) return;
+ final SearchScope scope = queryParameters.getScope();
+ final PsiElement element = queryParameters.getElementToSearch();
+ final PsiFile containingFile = element.getContainingFile();
+ final boolean isPhysical = containingFile == null || containingFile.getViewProvider().isPhysical();
+ if (isPhysical && !(scope instanceof GlobalSearchScope)) return;
+ final LocalSearchScope currentScope;
+ if (scope instanceof LocalSearchScope) {
+ if (queryParameters.isIgnoreAccessScope()) return;
+ currentScope = (LocalSearchScope)scope;
+ }
+ else {
+ currentScope = null;
+ }
+ Project project = element.getProject();
+ if (!project.isInitialized()) return; // skip default and other projects that look funny
+ PsiManager psiManager = PsiManager.getInstance(project);
+
+ for (VirtualFile virtualFile : FileEditorManager.getInstance(project).getOpenFiles()) {
+ if (virtualFile.getFileType().isBinary()) continue;
+ PsiFile file = psiManager.findFile(virtualFile);
+
+ if (file != null && !file.getViewProvider().isPhysical() && !(file instanceof PsiCodeFragment)) {
+ final LocalSearchScope newScope = new LocalSearchScope(file);
+ final LocalSearchScope searchScope = currentScope == null ? newScope : newScope.intersectWith(currentScope);
+ ReferencesSearch.searchOptimized(element, searchScope, true, queryParameters.getOptimizer(), consumer);
+ }
+ }
+ }
+}
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/PostprocessReformattingAspect.java b/platform/lang-impl/src/com/intellij/psi/impl/source/PostprocessReformattingAspect.java
index 65818b2..9d7a9e9 100644
--- a/platform/lang-impl/src/com/intellij/psi/impl/source/PostprocessReformattingAspect.java
+++ b/platform/lang-impl/src/com/intellij/psi/impl/source/PostprocessReformattingAspect.java
@@ -18,6 +18,7 @@
import com.intellij.formatting.FormatTextRanges;
import com.intellij.lang.ASTNode;
import com.intellij.lang.injection.InjectedLanguageManager;
+import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationAdapter;
import com.intellij.openapi.application.ApplicationListener;
import com.intellij.openapi.application.ApplicationManager;
@@ -46,6 +47,7 @@
import com.intellij.psi.impl.source.codeStyle.IndentHelperImpl;
import com.intellij.psi.impl.source.tree.*;
import com.intellij.util.LocalTimeCounter;
+import com.intellij.util.containers.ContainerUtilRt;
import com.intellij.util.text.CharArrayUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.TestOnly;
@@ -295,33 +297,44 @@
final VirtualFile virtualFile = key.getVirtualFile();
if (!virtualFile.isValid()) return;
- final TreeSet<PostprocessFormattingTask> postprocessTasks = new TreeSet<PostprocessFormattingTask>();
- // process all roots in viewProvider to find marked for reformat before elements and create appropriate range markers
- handleReformatMarkers(key, postprocessTasks);
+ final TreeSet<PostprocessFormattingTask> postProcessTasks = new TreeSet<PostprocessFormattingTask>();
+ Collection<Disposable> toDispose = ContainerUtilRt.newArrayList();
+ try {
+ // process all roots in viewProvider to find marked for reformat before elements and create appropriate range markers
+ handleReformatMarkers(key, postProcessTasks);
+ toDispose.addAll(postProcessTasks);
- // then we create ranges by changed nodes. One per node. There ranges can intersect. Ranges are sorted by end offset.
- if (astNodes != null) createActionsMap(astNodes, key, postprocessTasks);
+ // then we create ranges by changed nodes. One per node. There ranges can intersect. Ranges are sorted by end offset.
+ if (astNodes != null) createActionsMap(astNodes, key, postProcessTasks);
- if ("true".equals(System.getProperty("check.psi.is.valid")) && ApplicationManager.getApplication().isUnitTestMode()) {
- checkPsiIsCorrect(key);
+ if ("true".equals(System.getProperty("check.psi.is.valid")) && ApplicationManager.getApplication().isUnitTestMode()) {
+ checkPsiIsCorrect(key);
+ }
+
+ while (!postProcessTasks.isEmpty()) {
+ // now we have to normalize actions so that they not intersect and ordered in most appropriate way
+ // (free reformatting -> reindent -> formatting under reindent)
+ final List<PostponedAction> normalizedActions = normalizeAndReorderPostponedActions(postProcessTasks, document);
+ toDispose.addAll(normalizedActions);
+
+ // only in following loop real changes in document are made
+ for (final PostponedAction normalizedAction : normalizedActions) {
+ CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(myPsiManager.getProject());
+ boolean old = settings.ENABLE_JAVADOC_FORMATTING;
+ settings.ENABLE_JAVADOC_FORMATTING = false;
+ try {
+ normalizedAction.execute(key);
+ }
+ finally {
+ settings.ENABLE_JAVADOC_FORMATTING = old;
+ }
+ }
+ }
}
-
- while (!postprocessTasks.isEmpty()) {
- // now we have to normalize actions so that they not intersect and ordered in most appropriate way
- // (free reformatting -> reindent -> formatting under reindent)
- final List<PostponedAction> normalizedActions = normalizeAndReorderPostponedActions(postprocessTasks, document);
-
- // only in following loop real changes in document are made
- for (final PostponedAction normalizedAction : normalizedActions) {
- CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(myPsiManager.getProject());
- boolean old = settings.ENABLE_JAVADOC_FORMATTING;
- settings.ENABLE_JAVADOC_FORMATTING = false;
- try {
- normalizedAction.execute(key);
- }
- finally {
- settings.ENABLE_JAVADOC_FORMATTING = old;
- }
+ finally {
+ for (Disposable disposable : toDispose) {
+ //noinspection SSBasedInspection
+ disposable.dispose();
}
}
}
@@ -599,10 +612,10 @@
return codeFormatter;
}
- private abstract static class PostprocessFormattingTask implements Comparable<PostprocessFormattingTask>, Segment {
- private final RangeMarker myRange;
+ private abstract static class PostprocessFormattingTask implements Comparable<PostprocessFormattingTask>, Segment, Disposable {
+ @NotNull private final RangeMarker myRange;
- public PostprocessFormattingTask(RangeMarker rangeMarker) {
+ public PostprocessFormattingTask(@NotNull RangeMarker rangeMarker) {
myRange = rangeMarker;
}
@@ -621,6 +634,7 @@
return diff;
}
+ @NotNull
public RangeMarker getRange() {
return myRange;
}
@@ -634,6 +648,12 @@
public int getEndOffset() {
return myRange.getEndOffset();
}
+
+ public void dispose() {
+ if (myRange.isValid()) {
+ myRange.dispose();
+ }
+ }
}
private static class ReformatTask extends PostprocessFormattingTask {
@@ -661,7 +681,7 @@
}
}
- private interface PostponedAction {
+ private interface PostponedAction extends Disposable {
void execute(FileViewProvider viewProvider);
}
@@ -677,6 +697,10 @@
final CodeFormatterFacade codeFormatter = getFormatterFacade(viewProvider);
codeFormatter.processText(viewProvider.getPsi(viewProvider.getBaseLanguage()), myRanges.ensureNonEmpty(), false);
}
+
+ @Override
+ public void dispose() {
+ }
}
private static class ReindentRangesAction implements PostponedAction {
@@ -700,6 +724,16 @@
if (indentAdjustment != 0) adjustIndentationInRange(psiFile, document, whitespaces, indentAdjustment);
}
}
+
+ @Override
+ public void dispose() {
+ for (Pair<Integer, RangeMarker> pair : myRangesToReindent) {
+ RangeMarker marker = pair.second;
+ if (marker.isValid()) {
+ marker.dispose();
+ }
+ }
+ }
}
@TestOnly
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeFormatterFacade.java b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeFormatterFacade.java
index 3e88105..ebf2173 100644
--- a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeFormatterFacade.java
+++ b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeFormatterFacade.java
@@ -90,11 +90,21 @@
}
public ASTNode processRange(final ASTNode element, final int startOffset, final int endOffset) {
+ return doProcessRange(element, startOffset, endOffset, null);
+ }
+
+ /**
+ * rangeMarker will be disposed
+ */
+ public ASTNode processRange(@NotNull ASTNode element, @NotNull RangeMarker rangeMarker) {
+ return doProcessRange(element, rangeMarker.getStartOffset(), rangeMarker.getEndOffset(), rangeMarker);
+ }
+
+ private ASTNode doProcessRange(final ASTNode element, final int startOffset, final int endOffset, @Nullable RangeMarker rangeMarker) {
final PsiElement psiElement = SourceTreeToPsiMap.treeElementToPsi(element);
assert psiElement != null;
final PsiFile file = psiElement.getContainingFile();
final Document document = file.getViewProvider().getDocument();
- final RangeMarker rangeMarker = document != null && endOffset < document.getTextLength()? document.createRangeMarker(startOffset, endOffset):null;
PsiElement elementToFormat = document instanceof DocumentWindow ? InjectedLanguageManager
.getInstance(file.getProject()).getTopLevelFile(file) : psiElement;
@@ -102,6 +112,10 @@
final FormattingModelBuilder builder = LanguageFormatting.INSTANCE.forContext(fileToFormat);
if (builder != null) {
+ if (rangeMarker == null && document != null && endOffset < document.getTextLength()) {
+ rangeMarker = document.createRangeMarker(startOffset, endOffset);
+ }
+
TextRange range = preprocess(element, TextRange.create(startOffset, endOffset));
if (document instanceof DocumentWindow) {
DocumentWindow documentWindow = (DocumentWindow)document;
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerImpl.java
index c0c54b2..2f6edc7 100644
--- a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerImpl.java
+++ b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerImpl.java
@@ -145,7 +145,12 @@
}
@Override
- public void reformatText(@NotNull PsiFile file, @NotNull Collection<TextRange> ranges) throws IncorrectOperationException {
+ public void reformatText(@NotNull PsiFile file, @NotNull Collection<TextRange> ranges)
+ throws IncorrectOperationException {
+ reformatText(file, ranges, null);
+ }
+
+ public void reformatText(@NotNull PsiFile file, @NotNull Collection<TextRange> ranges, @Nullable Editor editor) throws IncorrectOperationException {
if (ranges.isEmpty()) {
return;
}
@@ -163,7 +168,9 @@
final CodeFormatterFacade codeFormatter = new CodeFormatterFacade(getSettings());
LOG.assertTrue(file.isValid());
- Editor editor = PsiUtilBase.findEditor(file);
+ if (editor == null) {
+ editor = PsiUtilBase.findEditor(file);
+ }
// There is a possible case that cursor is located at the end of the line that contains only white spaces. For example:
// public void foo() {
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReferenceHelper.java b/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReferenceHelper.java
index 9b5c000..242acbb 100644
--- a/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReferenceHelper.java
+++ b/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReferenceHelper.java
@@ -27,8 +27,8 @@
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
-import java.util.List;
import java.util.Collections;
+import java.util.List;
/**
* @author peter
@@ -54,10 +54,14 @@
}
@Nullable
- public abstract PsiFileSystemItem findRoot(final Project project, @NotNull final VirtualFile file);
+ public PsiFileSystemItem findRoot(final Project project, @NotNull final VirtualFile file) {
+ return null;
+ }
@NotNull
- public abstract Collection<PsiFileSystemItem> getRoots(@NotNull Module module);
+ public Collection<PsiFileSystemItem> getRoots(@NotNull Module module) {
+ return Collections.emptyList();
+ }
@NotNull
public abstract Collection<PsiFileSystemItem> getContexts(final Project project, @NotNull final VirtualFile file);
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JarFileReferenceHelper.java b/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JarFileReferenceHelper.java
index 67bc856..1379521 100644
--- a/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JarFileReferenceHelper.java
+++ b/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JarFileReferenceHelper.java
@@ -37,11 +37,6 @@
}
@Override
- public PsiFileSystemItem findRoot(Project project, @NotNull VirtualFile file) {
- return null;
- }
-
- @Override
@NotNull
public Collection<PsiFileSystemItem> getRoots(@NotNull Module module) {
return PsiFileReferenceHelper.getContextsForModule(module, "", null);
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageManagerImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageManagerImpl.java
index b9ee3a9..e6345bc 100644
--- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageManagerImpl.java
+++ b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageManagerImpl.java
@@ -411,7 +411,9 @@
@TestOnly
public static void checkInjectorsAreDisposed(@NotNull Project project) {
InjectedLanguageManagerImpl cachedManager = (InjectedLanguageManagerImpl)project.getUserData(INSTANCE_CACHE);
- if (cachedManager == null) return;
+ if (cachedManager == null) {
+ return;
+ }
try {
for (Map.Entry<Class, MultiHostInjector[]> entry : cachedManager.injectors.entrySet()) {
Class key = entry.getKey();
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/MultiHostRegistrarImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/MultiHostRegistrarImpl.java
index a3012ad..abad2ae 100644
--- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/MultiHostRegistrarImpl.java
+++ b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/MultiHostRegistrarImpl.java
@@ -172,7 +172,7 @@
assert after >= before : "Escaper " + textEscaper + "("+textEscaper.getClass()+") must not mangle char buffer";
if (!result) {
// if there are invalid chars, adjust the range
- int offsetInHost = textEscaper.getOffsetInHost(outChars.length() - startOffset, rangeInsideHost);
+ int offsetInHost = textEscaper.getOffsetInHost(outChars.length() - before, rangeInsideHost);
relevantRange = relevantRange.intersection(new ProperTextRange(0, offsetInHost));
}
}
diff --git a/platform/lang-impl/src/com/intellij/psi/stubs/SerializedStubTree.java b/platform/lang-impl/src/com/intellij/psi/stubs/SerializedStubTree.java
index f5b3d4e..8501493 100644
--- a/platform/lang-impl/src/com/intellij/psi/stubs/SerializedStubTree.java
+++ b/platform/lang-impl/src/com/intellij/psi/stubs/SerializedStubTree.java
@@ -31,21 +31,29 @@
public class SerializedStubTree {
private final byte[] myBytes;
private final int myLength;
+ private final long myByteContentLength;
+ private final int myCharContentLength;
private Stub myStubElement;
- public SerializedStubTree(final byte[] bytes, int length, @Nullable Stub stubElement) {
+ public SerializedStubTree(final byte[] bytes, int length, @Nullable Stub stubElement, long byteContentLength, int charContentLength) {
myBytes = bytes;
myLength = length;
+ myByteContentLength = byteContentLength;
+ myCharContentLength = charContentLength;
myStubElement = stubElement;
}
public SerializedStubTree(DataInput in) throws IOException {
myBytes = CompressionUtil.readCompressed(in);
myLength = myBytes.length;
+ myByteContentLength = in.readLong();
+ myCharContentLength = in.readInt();
}
public void write(DataOutput out) throws IOException {
CompressionUtil.writeCompressed(out, myBytes, myLength);
+ out.writeLong(myByteContentLength);
+ out.writeInt(myCharContentLength);
}
// willIndexStub is one time optimization hint, once can safely pass false
@@ -61,6 +69,13 @@
return SerializationManagerEx.getInstanceEx().deserialize(new UnsyncByteArrayInputStream(myBytes));
}
+ public boolean contentLengthMatches(long byteContentLength, int charContentLength) {
+ if (myCharContentLength >= 0 && charContentLength >= 0) {
+ return myCharContentLength == charContentLength;
+ }
+ return myByteContentLength == byteContentLength;
+ }
+
public boolean equals(final Object that) {
if (this == that) {
return true;
diff --git a/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java b/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java
index 987c579..fde67af 100644
--- a/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java
+++ b/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java
@@ -27,7 +27,6 @@
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.fileEditor.FileDocumentManager;
-import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.ThrowableComputable;
@@ -44,6 +43,7 @@
import com.intellij.util.CommonProcessors;
import com.intellij.util.Processor;
import com.intellij.util.SmartList;
+import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.indexing.*;
import com.intellij.util.io.DataExternalizer;
import com.intellij.util.io.DataInputOutputUtil;
@@ -144,10 +144,8 @@
.getInstance().runProcessWithProgressSynchronously(new ThrowableComputable<MapIndexStorage<K, StubIdList>, IOException>() {
@Override
public MapIndexStorage<K, StubIdList> compute() throws IOException {
- final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
- if (indicator != null) {
- indicator.setIndeterminate(true);
- }
+ FileBasedIndexImpl.configureIndexDataLoadingProgress(ProgressManager.getInstance().getProgressIndicator());
+
return new MapIndexStorage<K, StubIdList>(
IndexInfrastructure.getStorageFile(indexKey),
extension.getKeyDescriptor(),
@@ -245,6 +243,7 @@
return container.forEach(new ValueContainer.ContainerAction<StubIdList>() {
@Override
public boolean perform(final int id, @NotNull final StubIdList value) {
+ ProgressManager.checkCanceled();
if (projectFilesFilter != null && !projectFilesFilter.contains(id)) return true;
final VirtualFile file = IndexInfrastructure.findFileByIdIfCached(fs, id);
if (file == null || scope != null && !scope.contains(file)) {
@@ -288,11 +287,18 @@
@Override
@NotNull
public <K> Collection<K> getAllKeys(@NotNull StubIndexKey<K, ?> indexKey, @NotNull Project project) {
+ Set<K> allKeys = ContainerUtil.newTroveSet();
+ processAllKeys(indexKey, project, new CommonProcessors.CollectProcessor<K>(allKeys));
+ return allKeys;
+ }
+
+ @Override
+ public <K> boolean processAllKeys(@NotNull StubIndexKey<K, ?> indexKey, @NotNull Project project, Processor<K> processor) {
FileBasedIndex.getInstance().ensureUpToDate(StubUpdatingIndex.INDEX_ID, project, GlobalSearchScope.allScope(project));
final MyIndex<K> index = (MyIndex<K>)myIndices.get(indexKey);
try {
- return index.getAllKeys();
+ return index.processAllKeys(processor);
}
catch (StorageException e) {
forceRebuild(e);
@@ -304,7 +310,7 @@
}
throw e;
}
- return Collections.emptyList();
+ return true;
}
@Override
diff --git a/platform/lang-impl/src/com/intellij/psi/stubs/StubTreeLoaderImpl.java b/platform/lang-impl/src/com/intellij/psi/stubs/StubTreeLoaderImpl.java
index f63a0f5..db8ead8 100644
--- a/platform/lang-impl/src/com/intellij/psi/stubs/StubTreeLoaderImpl.java
+++ b/platform/lang-impl/src/com/intellij/psi/stubs/StubTreeLoaderImpl.java
@@ -24,6 +24,8 @@
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
+import com.intellij.psi.PsiManager;
+import com.intellij.psi.impl.PsiManagerEx;
import com.intellij.psi.impl.source.PsiFileImpl;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.util.indexing.*;
@@ -94,20 +96,38 @@
return null;
}
+ boolean wasIndexedAlready = ((FileBasedIndexImpl)FileBasedIndex.getInstance()).isFileUpToDate(vFile);
+
+ Document document = FileDocumentManager.getInstance().getCachedDocument(vFile);
+ boolean saved = document == null || !FileDocumentManager.getInstance().isDocumentUnsaved(document);
+
final List<SerializedStubTree> datas = FileBasedIndex.getInstance().getValues(StubUpdatingIndex.INDEX_ID, id, GlobalSearchScope
.fileScope(project, vFile));
final int size = datas.size();
if (size == 1) {
+ SerializedStubTree stubTree = datas.get(0);
+
+ if (!stubTree.contentLengthMatches(vFile.getLength(), getCurrentTextContentLength(project, vFile, document))) {
+ return processError(vFile,
+ "Outdated stub in index: " + StubUpdatingIndex.getIndexingStampInfo(vFile) +
+ ", docSaved=" + saved +
+ ", queried at " + vFile.getTimeStamp(),
+ null);
+ }
+
Stub stub;
try {
- stub = datas.get(0).getStub(false);
+ stub = stubTree.getStub(false);
}
catch (SerializerNotFoundException e) {
return processError(vFile, "No stub serializer: " + vFile.getPresentableUrl() + ": " + e.getMessage(), e);
}
ObjectStubTree tree = stub instanceof PsiFileStub ? new StubTree((PsiFileStub)stub) : new ObjectStubTree((ObjectStubBase)stub, true);
- tree.setDebugInfo("created from index: " + StubUpdatingIndex.getIndexingStampInfo(vFile));
+ tree.setDebugInfo("created from index: " + StubUpdatingIndex.getIndexingStampInfo(vFile) +
+ ", wasIndexedAlready=" + wasIndexedAlready +
+ ", docSaved=" + saved +
+ ", queried at " + vFile.getTimeStamp());
return tree;
}
else if (size != 0) {
@@ -118,6 +138,21 @@
return null;
}
+ private static int getCurrentTextContentLength(Project project, VirtualFile vFile, Document document) {
+ if (vFile.getFileType().isBinary()) {
+ return -1;
+ }
+ PsiFile psiFile = ((PsiManagerEx)PsiManager.getInstance(project)).getFileManager().getCachedPsiFile(vFile);
+ if (psiFile instanceof PsiFileImpl && ((PsiFileImpl)psiFile).isContentsLoaded()) {
+ return psiFile.getTextLength();
+ }
+
+ if (document != null) {
+ return document.getTextLength();
+ }
+ return -1;
+ }
+
private static ObjectStubTree processError(final VirtualFile vFile, String message, @Nullable Exception e) {
LOG.error(message, e);
@@ -142,7 +177,7 @@
@Override
public long getStubTreeTimestamp(VirtualFile vFile) {
- return IndexingStamp.getIndexStamp(vFile, StubUpdatingIndex.INDEX_ID);
+ return IndexingStamp.getIndexStamp(vFile, IndexInfrastructure.getStubId(StubUpdatingIndex.INDEX_ID, vFile.getFileType()));
}
@Override
diff --git a/platform/lang-impl/src/com/intellij/psi/stubs/StubUpdatingIndex.java b/platform/lang-impl/src/com/intellij/psi/stubs/StubUpdatingIndex.java
index 4dcd9e6..5738781 100644
--- a/platform/lang-impl/src/com/intellij/psi/stubs/StubUpdatingIndex.java
+++ b/platform/lang-impl/src/com/intellij/psi/stubs/StubUpdatingIndex.java
@@ -50,7 +50,7 @@
public static final ID<Integer, SerializedStubTree> INDEX_ID = ID.create("Stubs");
- private static final int VERSION = 24;
+ private static final int VERSION = 25;
private static final DataExternalizer<SerializedStubTree> KEY_EXTERNALIZER = new DataExternalizer<SerializedStubTree>() {
@Override
@@ -77,15 +77,21 @@
public static boolean canHaveStub(@NotNull VirtualFile file) {
final FileType fileType = file.getFileType();
if (fileType instanceof LanguageFileType) {
- Language l = ((LanguageFileType)fileType).getLanguage();
- ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(l);
- if (parserDefinition == null) return false;
+ final Language l = ((LanguageFileType)fileType).getLanguage();
+ final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(l);
+ if (parserDefinition == null) {
+ return false;
+ }
final IFileElementType elementType = parserDefinition.getFileNodeType();
- if (elementType instanceof IStubFileElementType &&
- (((IStubFileElementType)elementType).shouldBuildStubFor(file) ||
- IndexingStamp.isFileIndexed(file, INDEX_ID, IndexInfrastructure.getIndexCreationStamp(INDEX_ID, file)))) {
- return true;
+ if (elementType instanceof IStubFileElementType) {
+ if (((IStubFileElementType)elementType).shouldBuildStubFor(file)) {
+ return true;
+ }
+ final ID indexId = IndexInfrastructure.getStubId(INDEX_ID, file.getFileType());
+ if (IndexingStamp.isFileIndexed(file, indexId, IndexInfrastructure.getIndexCreationStamp(indexId))) {
+ return true;
+ }
}
}
final BinaryFileStubBuilder builder = BinaryFileStubBuilders.INSTANCE.forFileType(fileType);
@@ -125,13 +131,15 @@
final Stub rootStub = StubTreeBuilder.buildStubTree(inputData);
if (rootStub == null) return;
- rememberIndexingStamp(inputData.getFile());
+ VirtualFile file = inputData.getFile();
+ int contentLength = file.getFileType().isBinary() ? -1 : inputData.getContentAsText().length();
+ rememberIndexingStamp(file, contentLength);
final BufferExposingByteArrayOutputStream bytes = new BufferExposingByteArrayOutputStream();
SerializationManagerEx.getInstanceEx().serialize(rootStub, bytes);
- final int key = Math.abs(FileBasedIndex.getFileId(inputData.getFile()));
- result.put(key, new SerializedStubTree(bytes.getInternalBuffer(), bytes.size(), rootStub));
+ final int key = Math.abs(FileBasedIndex.getFileId(file));
+ result.put(key, new SerializedStubTree(bytes.getInternalBuffer(), bytes.size(), rootStub, file.getLength(), contentLength));
}
});
@@ -140,11 +148,11 @@
};
}
- private static void rememberIndexingStamp(final VirtualFile file) {
+ private static void rememberIndexingStamp(final VirtualFile file, long contentLength) {
try {
DataOutputStream stream = INDEXED_STAMP.writeAttribute(file);
stream.writeLong(file.getTimeStamp());
- stream.writeLong(file.getLength());
+ stream.writeLong(contentLength);
stream.close();
}
catch (IOException e) {
diff --git a/platform/lang-impl/src/com/intellij/psi/templateLanguages/TemplateDataElementType.java b/platform/lang-impl/src/com/intellij/psi/templateLanguages/TemplateDataElementType.java
index 6e6b7e8..3cb26ed 100644
--- a/platform/lang-impl/src/com/intellij/psi/templateLanguages/TemplateDataElementType.java
+++ b/platform/lang-impl/src/com/intellij/psi/templateLanguages/TemplateDataElementType.java
@@ -77,7 +77,7 @@
final TemplateLanguageFileViewProvider viewProvider = (TemplateLanguageFileViewProvider)originalFile.getViewProvider();
- final Language language = viewProvider.getTemplateDataLanguage();
+ final Language language = getTemplateFileLanguage(viewProvider);
final CharSequence chars = chameleon.getChars();
final PsiFile templateFile = createTemplateFile(file, language, chars, viewProvider);
@@ -110,6 +110,10 @@
return childNode;
}
+ protected Language getTemplateFileLanguage(TemplateLanguageFileViewProvider viewProvider) {
+ return viewProvider.getTemplateDataLanguage();
+ }
+
protected PsiFile createTemplateFile(final PsiFile file,
final Language language,
final CharSequence chars,
diff --git a/platform/lang-impl/src/com/intellij/psi/util/proximity/SameDirectoryWeigher.java b/platform/lang-impl/src/com/intellij/psi/util/proximity/SameDirectoryWeigher.java
index eee2ddc..b9b2bc5 100644
--- a/platform/lang-impl/src/com/intellij/psi/util/proximity/SameDirectoryWeigher.java
+++ b/platform/lang-impl/src/com/intellij/psi/util/proximity/SameDirectoryWeigher.java
@@ -19,13 +19,10 @@
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiElement;
import com.intellij.psi.util.ProximityLocation;
-import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.NullableFunction;
import org.jetbrains.annotations.NotNull;
/**
- * NOTE: This class is only registered in platform-based IDEs. In IDEA, SamePackageWeigher is used instead.
- *
* @author yole
*/
public class SameDirectoryWeigher extends ProximityWeigher {
@@ -33,20 +30,23 @@
PLACE_DIRECTORY = NullableLazyKey.create("placeDirectory", new NullableFunction<ProximityLocation, PsiDirectory>() {
@Override
public PsiDirectory fun(ProximityLocation location) {
- return PsiTreeUtil.getParentOfType(location.getPosition(), PsiDirectory.class, false);
+ return getParentDirectory(location.getPosition());
}
});
+ private static PsiDirectory getParentDirectory(PsiElement element) {
+ while (element != null && !(element instanceof PsiDirectory)) {
+ element = element.getParent();
+ }
+ return (PsiDirectory)element;
+ }
+
@Override
- public Comparable weigh(@NotNull final PsiElement element, @NotNull final ProximityLocation location) {
- if (location.getPosition() == null){
- return null;
+ public Boolean weigh(@NotNull final PsiElement element, @NotNull final ProximityLocation location) {
+ if (location.getPosition() == null) {
+ return Boolean.TRUE;
}
final PsiDirectory placeDirectory = PLACE_DIRECTORY.getValue(location);
- if (placeDirectory == null) {
- return false;
- }
-
- return placeDirectory.equals(PsiTreeUtil.getParentOfType(element, PsiDirectory.class, false));
+ return placeDirectory != null && placeDirectory.equals(getParentDirectory(element));
}
}
diff --git a/platform/lang-impl/src/com/intellij/refactoring/BaseRefactoringProcessor.java b/platform/lang-impl/src/com/intellij/refactoring/BaseRefactoringProcessor.java
index 53d8c59..2393256 100644
--- a/platform/lang-impl/src/com/intellij/refactoring/BaseRefactoringProcessor.java
+++ b/platform/lang-impl/src/com/intellij/refactoring/BaseRefactoringProcessor.java
@@ -60,6 +60,7 @@
import com.intellij.util.containers.MultiMap;
import com.intellij.util.ui.UIUtil;
import gnu.trove.THashSet;
+import gnu.trove.TObjectHashingStrategy;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -288,7 +289,7 @@
}
private boolean ensureElementsWritable(@NotNull final UsageInfo[] usages, final UsageViewDescriptor descriptor) {
- Set<PsiElement> elements = new THashSet<PsiElement>();
+ Set<PsiElement> elements = new THashSet<PsiElement>(TObjectHashingStrategy.IDENTITY); // protect against poorly implemented equality
for (UsageInfo usage : usages) {
assert usage != null: "Found null element in usages array";
if (skipNonCodeUsages() && usage.isNonCodeUsage()) continue;
diff --git a/platform/lang-impl/src/com/intellij/refactoring/actions/BaseRefactoringAction.java b/platform/lang-impl/src/com/intellij/refactoring/actions/BaseRefactoringAction.java
index eb35907..aec5594 100644
--- a/platform/lang-impl/src/com/intellij/refactoring/actions/BaseRefactoringAction.java
+++ b/platform/lang-impl/src/com/intellij/refactoring/actions/BaseRefactoringAction.java
@@ -83,7 +83,7 @@
try {
handler = getHandler(dataContext);
}
- catch (ProcessCanceledException e1) {
+ catch (ProcessCanceledException ignored) {
return;
}
if (handler == null) {
diff --git a/platform/lang-impl/src/com/intellij/refactoring/changeSignature/ChangeSignatureDialogBase.java b/platform/lang-impl/src/com/intellij/refactoring/changeSignature/ChangeSignatureDialogBase.java
index 93c0ec8..401ff51 100644
--- a/platform/lang-impl/src/com/intellij/refactoring/changeSignature/ChangeSignatureDialogBase.java
+++ b/platform/lang-impl/src/com/intellij/refactoring/changeSignature/ChangeSignatureDialogBase.java
@@ -23,7 +23,6 @@
import com.intellij.openapi.editor.event.DocumentAdapter;
import com.intellij.openapi.editor.event.DocumentEvent;
import com.intellij.openapi.editor.event.DocumentListener;
-import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.fileTypes.LanguageFileType;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.project.Project;
@@ -51,7 +50,6 @@
import com.intellij.util.PlatformIcons;
import com.intellij.util.ui.UIUtil;
import com.intellij.util.ui.table.JBListTable;
-import com.intellij.util.ui.table.JBTableRow;
import com.intellij.util.ui.table.JBTableRowEditor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -457,16 +455,7 @@
@Override
protected JComponent getRowRenderer(JTable table, int row, boolean selected, boolean focused) {
final List<ParameterTableModelItem> items = myParametersTable.getItems();
- final JComponent component = getRowPresentation(items.get(row), selected, focused);
- for (EditorTextField editorTextField : UIUtil.findComponentsOfType(component, EditorTextField.class)) {
- editorTextField.addSettingsProvider(new EditorSettingsProvider() {
- @Override
- public void customizeSettings(EditorEx editor) {
- editor.getSettings().setWhitespacesShown(false);
- }
- });
- }
- return component;
+ return getRowPresentation(items.get(row), selected, focused);
}
@Override
@@ -492,16 +481,6 @@
});
return editor;
}
-
- @Override
- protected JBTableRow getRowAt(final int row) {
- return new JBTableRow() {
- @Override
- public Object getValueAt(int column) {
- return myInternalTable.getValueAt(row, column);
- }
- };
- }
};
final JPanel buttonsPanel = ToolbarDecorator.createDecorator(myParametersList.getTable())
.addExtraAction(myPropagateParamChangesButton)
diff --git a/platform/lang-impl/src/com/intellij/refactoring/extractMethod/AbstactExtractMethodDialog.form b/platform/lang-impl/src/com/intellij/refactoring/extractMethod/AbstactExtractMethodDialog.form
index db9c8a5..1de53ad 100644
--- a/platform/lang-impl/src/com/intellij/refactoring/extractMethod/AbstactExtractMethodDialog.form
+++ b/platform/lang-impl/src/com/intellij/refactoring/extractMethod/AbstactExtractMethodDialog.form
@@ -63,15 +63,9 @@
<properties/>
<border type="none"/>
<children>
- <component id="6b27f" class="javax.swing.JTextArea" binding="mySignaturePreviewTextArea">
+ <component id="4caa2" class="com.intellij.refactoring.ui.MethodSignatureComponent" binding="mySignaturePreviewTextArea" custom-create="true">
<constraints/>
- <properties>
- <columns value="10"/>
- <editable value="false"/>
- <enabled value="true"/>
- <rows value="0"/>
- <text value="def foo()"/>
- </properties>
+ <properties/>
</component>
</children>
</scrollpane>
diff --git a/platform/lang-impl/src/com/intellij/refactoring/extractMethod/AbstractExtractMethodDialog.java b/platform/lang-impl/src/com/intellij/refactoring/extractMethod/AbstractExtractMethodDialog.java
index 5c984ef..7bb0554 100644
--- a/platform/lang-impl/src/com/intellij/refactoring/extractMethod/AbstractExtractMethodDialog.java
+++ b/platform/lang-impl/src/com/intellij/refactoring/extractMethod/AbstractExtractMethodDialog.java
@@ -17,10 +17,12 @@
import com.intellij.codeInsight.codeFragment.CodeFragment;
import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.Messages;
import com.intellij.refactoring.RefactoringBundle;
+import com.intellij.refactoring.ui.MethodSignatureComponent;
import com.intellij.ui.DocumentAdapter;
import com.intellij.util.containers.HashMap;
import org.jetbrains.annotations.NotNull;
@@ -36,8 +38,9 @@
private JPanel myContentPane;
private AbstractParameterTablePanel myParametersPanel;
private JTextField myMethodNameTextField;
- private JTextArea mySignaturePreviewTextArea;
+ private MethodSignatureComponent mySignaturePreviewTextArea;
private JTextArea myOutputVariablesTextArea;
+ private final Project myProject;
private final String myDefaultName;
private final ExtractMethodValidator myValidator;
private final ExtractMethodDecorator myDecorator;
@@ -47,20 +50,23 @@
private final List<String> myArguments;
private final ArrayList<String> myOutputVariables;
+ private final FileType myFileType;
public AbstractExtractMethodDialog(final Project project,
- final String defaultName,
- final CodeFragment fragment,
- final ExtractMethodValidator validator,
- final ExtractMethodDecorator decorator) {
+ final String defaultName,
+ final CodeFragment fragment,
+ final ExtractMethodValidator validator,
+ final ExtractMethodDecorator decorator,
+ final FileType type) {
super(project, true);
+ myProject = project;
myDefaultName = defaultName;
- CodeFragment fragment1 = fragment;
myValidator = validator;
myDecorator = decorator;
- myArguments = new ArrayList<String>(fragment1.getInputVariables());
+ myFileType = type;
+ myArguments = new ArrayList<String>(fragment.getInputVariables());
Collections.sort(myArguments);
- myOutputVariables = new ArrayList<String>(fragment1.getOutputVariables());
+ myOutputVariables = new ArrayList<String>(fragment.getOutputVariables());
Collections.sort(myOutputVariables);
setModal(true);
setTitle(RefactoringBundle.message("extract.method.title"));
@@ -134,9 +140,7 @@
Messages.showInfoMessage(error, RefactoringBundle.message("error.title"));
return;
}
- final StringBuilder builder = new StringBuilder();
- builder.append(error).append(". ").append(RefactoringBundle.message("do.you.wish.to.continue"));
- if (Messages.showOkCancelDialog(builder.toString(), RefactoringBundle.message("warning.title"), Messages.getWarningIcon()) != 0){
+ if (Messages.showOkCancelDialog(error + ". " + RefactoringBundle.message("do.you.wish.to.continue"), RefactoringBundle.message("warning.title"), Messages.getWarningIcon()) != 0){
return;
}
}
@@ -171,6 +175,7 @@
AbstractExtractMethodDialog.this.updateSignature();
}
};
+ mySignaturePreviewTextArea = new MethodSignatureComponent("", myProject, myFileType);
}
private void updateOutputVariables() {
@@ -192,7 +197,7 @@
}
private void updateSignature() {
- mySignaturePreviewTextArea.setText(myDecorator.createMethodPreview(getMethodName(), myVariableData));
+ mySignaturePreviewTextArea.setSignature(myDecorator.createMethodPreview(getMethodName(), myVariableData));
}
private void updateOkStatus() {
diff --git a/platform/lang-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodHelper.java b/platform/lang-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodHelper.java
new file mode 100644
index 0000000..ab5d11a
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodHelper.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2000-2013 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.refactoring.extractMethod;
+
+import com.intellij.codeInsight.highlighting.HighlightManager;
+import com.intellij.find.FindManager;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ApplicationNamesInfo;
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.editor.LogicalPosition;
+import com.intellij.openapi.editor.ScrollType;
+import com.intellij.openapi.editor.colors.EditorColors;
+import com.intellij.openapi.editor.colors.EditorColorsManager;
+import com.intellij.openapi.editor.markup.TextAttributes;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.DialogWrapper;
+import com.intellij.openapi.ui.Messages;
+import com.intellij.openapi.util.Pair;
+import com.intellij.psi.PsiElement;
+import com.intellij.refactoring.RefactoringBundle;
+import com.intellij.ui.ReplacePromptDialog;
+import com.intellij.util.Consumer;
+import com.intellij.util.Function;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.List;
+
+/**
+ * @author Dennis.Ushakov
+ */
+public class ExtractMethodHelper {
+ public static void processDuplicates(@NotNull final PsiElement callElement,
+ @NotNull final PsiElement generatedMethod,
+ @NotNull final List<PsiElement> scope,
+ @NotNull final SimpleDuplicatesFinder finder,
+ @NotNull final Editor editor,
+ @NotNull final Function<Pair<PsiElement, PsiElement>, List<PsiElement>> collector,
+ @NotNull final Consumer<Pair<List<PsiElement>, PsiElement>> replacer) {
+ final List<Pair<PsiElement, PsiElement>> duplicates = finder.findDuplicates(scope, generatedMethod);
+
+ if (duplicates.size() > 0) {
+ final String message = RefactoringBundle
+ .message("0.has.detected.1.code.fragments.in.this.file.that.can.be.replaced.with.a.call.to.extracted.method",
+ ApplicationNamesInfo.getInstance().getProductName(), duplicates.size());
+ final boolean isUnittest = ApplicationManager.getApplication().isUnitTestMode();
+ final int exitCode = !isUnittest ? Messages.showYesNoDialog(callElement.getProject(), message,
+ RefactoringBundle.message("refactoring.extract.method.dialog.title"),
+ Messages.getInformationIcon()) :
+ DialogWrapper.OK_EXIT_CODE;
+ if (exitCode == DialogWrapper.OK_EXIT_CODE) {
+ boolean replaceAll = false;
+ for (Pair<PsiElement, PsiElement> match : duplicates) {
+ final List<PsiElement> elementsRange = collector.fun(match);
+ final Pair<List<PsiElement>, PsiElement> replacement = Pair.create(elementsRange, callElement);
+ if (!replaceAll) {
+ highlightInEditor(callElement.getProject(), match, editor);
+
+ int promptResult = FindManager.PromptResult.ALL;
+ if (!isUnittest) {
+ ReplacePromptDialog promptDialog =
+ new ReplacePromptDialog(false, RefactoringBundle.message("replace.fragment"), callElement.getProject());
+ promptDialog.show();
+ promptResult = promptDialog.getExitCode();
+ }
+ if (promptResult == FindManager.PromptResult.SKIP) continue;
+ if (promptResult == FindManager.PromptResult.CANCEL) break;
+
+ if (promptResult == FindManager.PromptResult.OK) {
+ replacer.consume(replacement);
+ }
+ else if (promptResult == FindManager.PromptResult.ALL) {
+ replacer.consume(replacement);
+ replaceAll = true;
+ }
+ }
+ else {
+ replacer.consume(replacement);
+ }
+ }
+ }
+ }
+ }
+
+ private static void highlightInEditor(@NotNull final Project project, @NotNull final Pair<PsiElement, PsiElement> pair,
+ @NotNull final Editor editor) {
+ final HighlightManager highlightManager = HighlightManager.getInstance(project);
+ final EditorColorsManager colorsManager = EditorColorsManager.getInstance();
+ final TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
+ final int startOffset = pair.getFirst().getTextRange().getStartOffset();
+ final int endOffset = pair.getSecond().getTextRange().getEndOffset();
+ highlightManager.addRangeHighlight(editor, startOffset, endOffset, attributes, true, null);
+ final LogicalPosition logicalPosition = editor.offsetToLogicalPosition(startOffset);
+ editor.getScrollingModel().scrollTo(logicalPosition, ScrollType.MAKE_VISIBLE);
+ }
+}
diff --git a/platform/lang-impl/src/com/intellij/refactoring/extractMethod/SimpleDuplicatesFinder.java b/platform/lang-impl/src/com/intellij/refactoring/extractMethod/SimpleDuplicatesFinder.java
new file mode 100644
index 0000000..6b528d1
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/refactoring/extractMethod/SimpleDuplicatesFinder.java
@@ -0,0 +1,98 @@
+package com.intellij.refactoring.extractMethod;
+
+import com.intellij.codeInsight.PsiEquivalenceUtil;
+import com.intellij.openapi.util.Pair;
+import com.intellij.psi.PsiComment;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiWhiteSpace;
+import com.intellij.psi.util.PsiTreeUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * User : ktisha
+ */
+public class SimpleDuplicatesFinder {
+ private final ArrayList<PsiElement> myPattern;
+
+ public SimpleDuplicatesFinder(@NotNull final PsiElement statement1, @NotNull final PsiElement statement2) {
+ myPattern = new ArrayList<PsiElement>();
+ PsiElement sibling = statement1;
+
+ do {
+ myPattern.add(sibling);
+ if (sibling == statement2) break;
+ sibling = PsiTreeUtil.skipSiblingsForward(sibling, PsiWhiteSpace.class, PsiComment.class);
+ } while (sibling != null);
+ }
+
+ public List<Pair<PsiElement, PsiElement>> findDuplicates(@Nullable final List<PsiElement> scope, @NotNull final PsiElement generatedMethod) {
+ final ArrayList<Pair<PsiElement, PsiElement>> result = new ArrayList<Pair<PsiElement, PsiElement>>();
+ if (scope != null) {
+ for (PsiElement element : scope) {
+ findPatternOccurrences(result, element, generatedMethod);
+ }
+ }
+ return result;
+ }
+
+ private void findPatternOccurrences(@NotNull final List<Pair<PsiElement, PsiElement>> array, @NotNull final PsiElement scope,
+ @NotNull final PsiElement generatedMethod) {
+ if (scope == generatedMethod) return;
+ final PsiElement[] children = scope.getChildren();
+ for (PsiElement child : children) {
+ final Pair<PsiElement, PsiElement> match = isDuplicateFragment(child);
+ if (match != null) {
+ array.add(match);
+ continue;
+ }
+ findPatternOccurrences(array, child, generatedMethod);
+ }
+ }
+
+ @Nullable
+ private Pair<PsiElement, PsiElement> isDuplicateFragment(@NotNull final PsiElement candidate) {
+ for (PsiElement pattern : myPattern) {
+ if (PsiTreeUtil.isAncestor(pattern, candidate, false)) return null;
+ }
+ PsiElement sibling = candidate;
+ final ArrayList<PsiElement> candidates = new ArrayList<PsiElement>();
+ for (int i = 0; i != myPattern.size(); ++i) {
+ if (sibling == null) return null;
+
+ candidates.add(sibling);
+ sibling = PsiTreeUtil.skipSiblingsForward(sibling, PsiWhiteSpace.class, PsiComment.class);
+ }
+ if (myPattern.size() != candidates.size()) return null;
+ if (candidates.size() <= 0) return null;
+ final Pair<PsiElement, PsiElement> match = new Pair<PsiElement, PsiElement>(candidates.get(0), candidates.get(candidates.size() - 1));
+ for (int i = 0; i < myPattern.size(); i++) {
+ if (!matchPattern(myPattern.get(i), candidates.get(i))) return null;
+ }
+ return match;
+ }
+
+ private static boolean matchPattern(@Nullable final PsiElement pattern,
+ @Nullable final PsiElement candidate) {
+ if (pattern == null || candidate == null) return pattern == candidate;
+ final PsiElement[] children1 = PsiEquivalenceUtil.getFilteredChildren(pattern, null, true);
+ final PsiElement[] children2 = PsiEquivalenceUtil.getFilteredChildren(candidate, null, true);
+ if (children1.length != children2.length) return false;
+
+ for (int i = 0; i < children1.length; i++) {
+ PsiElement child1 = children1[i];
+ PsiElement child2 = children2[i];
+ if (!matchPattern(child1, child2)) return false;
+ }
+
+ if (children1.length == 0) {
+ if (!pattern.textMatches(candidate)) return false;
+ }
+
+ return true;
+ }
+
+}
diff --git a/platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/AbstractInplaceIntroducer.java b/platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/AbstractInplaceIntroducer.java
index 23d9294..cf4eaf6 100644
--- a/platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/AbstractInplaceIntroducer.java
+++ b/platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/AbstractInplaceIntroducer.java
@@ -39,7 +39,9 @@
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.TextRange;
+import com.intellij.openapi.vfs.ReadonlyStatusHandler;
import com.intellij.psi.*;
+import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
import com.intellij.psi.search.searches.ReferencesSearch;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.refactoring.RefactoringActionHandler;
@@ -456,6 +458,7 @@
}
protected void restoreState(final V psiField) {
+ if (!ReadonlyStatusHandler.ensureDocumentWritable(myProject, InjectedLanguageUtil.getTopLevelEditor(myEditor).getDocument())) return;
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
diff --git a/platform/lang-impl/src/com/intellij/refactoring/move/moveFilesOrDirectories/MoveFilesOrDirectoriesProcessor.java b/platform/lang-impl/src/com/intellij/refactoring/move/moveFilesOrDirectories/MoveFilesOrDirectoriesProcessor.java
index 4b03fbf..2ada56d 100644
--- a/platform/lang-impl/src/com/intellij/refactoring/move/moveFilesOrDirectories/MoveFilesOrDirectoriesProcessor.java
+++ b/platform/lang-impl/src/com/intellij/refactoring/move/moveFilesOrDirectories/MoveFilesOrDirectoriesProcessor.java
@@ -33,6 +33,7 @@
import com.intellij.refactoring.move.FileReferenceContextUtil;
import com.intellij.refactoring.move.MoveCallback;
import com.intellij.refactoring.rename.RenameUtil;
+import com.intellij.refactoring.util.CommonRefactoringUtil;
import com.intellij.refactoring.util.NonCodeUsageInfo;
import com.intellij.usageView.UsageInfo;
import com.intellij.usageView.UsageViewDescriptor;
@@ -176,12 +177,7 @@
elementListener.elementMoved(element);
}
// sort by offset descending to process correctly several usages in one PsiElement [IDEADEV-33013]
- Arrays.sort(usages, new Comparator<UsageInfo>() {
- @Override
- public int compare(final UsageInfo o1, final UsageInfo o2) {
- return o1.getElement() == o2.getElement() ? o2.getRangeInElement().getStartOffset() - o1.getRangeInElement().getStartOffset() : 0;
- }
- });
+ CommonRefactoringUtil.sortDepthFirstRightLeftOrder(usages);
// fix references in moved files to outer files
for (PsiFile movedFile : movedFiles) {
diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/PsiElementRenameHandler.java b/platform/lang-impl/src/com/intellij/refactoring/rename/PsiElementRenameHandler.java
index 3a92b33..a27946a 100644
--- a/platform/lang-impl/src/com/intellij/refactoring/rename/PsiElementRenameHandler.java
+++ b/platform/lang-impl/src/com/intellij/refactoring/rename/PsiElementRenameHandler.java
@@ -19,6 +19,7 @@
import com.intellij.featureStatistics.FeatureUsageTracker;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.DataKey;
+import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
@@ -57,6 +58,10 @@
@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
PsiElement element = getElement(dataContext);
+ if (element == null) {
+ element = BaseRefactoringAction.getElementAtCaret(editor, file);
+ }
+
editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
final PsiElement nameSuggestionContext = InjectedLanguageUtil.findElementAtNoCommit(file, editor.getCaretModel().getOffset());
invoke(element, project, nameSuggestionContext, editor);
@@ -83,7 +88,9 @@
return;
}
- if (nameSuggestionContext != null && !PsiManager.getInstance(project).isInProject(nameSuggestionContext)) {
+ if (nameSuggestionContext != null &&
+ nameSuggestionContext.isPhysical() &&
+ !PsiManager.getInstance(project).isInProject(nameSuggestionContext)) {
final String message = "Selected element is used from non-project files. These usages won't be renamed. Proceed anyway?";
if (ApplicationManager.getApplication().isUnitTestMode()) throw new CommonRefactoringUtil.RefactoringErrorHintException(message);
if (Messages.showYesNoDialog(project, message,
diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/RenameProcessor.java b/platform/lang-impl/src/com/intellij/refactoring/rename/RenameProcessor.java
index 4c7b562..565d75e 100644
--- a/platform/lang-impl/src/com/intellij/refactoring/rename/RenameProcessor.java
+++ b/platform/lang-impl/src/com/intellij/refactoring/rename/RenameProcessor.java
@@ -220,7 +220,7 @@
@Override
public void run() {
for (final AutomaticRenamer renamer : myRenamers) {
- renamer.findUsages(variableUsages, mySearchInComments, mySearchTextOccurrences, mySkippedUsages);
+ renamer.findUsages(variableUsages, mySearchInComments, mySearchTextOccurrences, mySkippedUsages, myAllRenames);
}
}
};
diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/CompletionContributorForInplaceRename.java b/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/CompletionContributorForInplaceRename.java
index ca10bd0..f6cc909 100644
--- a/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/CompletionContributorForInplaceRename.java
+++ b/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/CompletionContributorForInplaceRename.java
@@ -33,7 +33,7 @@
final Editor editor = parameters.getLookup().getEditor();
final TemplateState state = TemplateManagerImpl.getTemplateState(editor);
if (state != null) {
- if (editor.getUserData(InplaceRefactoring.INPLACE_RENAMER) != null) {
+ if (editor.getUserData(InplaceRefactoring.INPLACE_RENAMER) != null && parameters.getInvocationCount() == 0) {
result.stopHere();
}
}
diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/InplaceRefactoring.java b/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/InplaceRefactoring.java
index 71f8ed5..05ef6ac 100644
--- a/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/InplaceRefactoring.java
+++ b/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/InplaceRefactoring.java
@@ -338,7 +338,12 @@
protected boolean isReferenceAtCaret(PsiElement selectedElement, PsiReference ref) {
final TextRange textRange = ref.getRangeInElement().shiftRight(ref.getElement().getTextRange().getStartOffset());
- return selectedElement != null && selectedElement.getTextRange().contains(textRange);
+ if (selectedElement != null){
+ final TextRange selectedElementRange = selectedElement.getTextRange();
+ LOG.assertTrue(selectedElementRange != null, selectedElement);
+ if (selectedElementRange != null && selectedElementRange.contains(textRange)) return true;
+ }
+ return false;
}
protected void beforeTemplateStart() {
diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/VariableInplaceRenameHandler.java b/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/VariableInplaceRenameHandler.java
index 83b73b2..0892f1e 100644
--- a/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/VariableInplaceRenameHandler.java
+++ b/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/VariableInplaceRenameHandler.java
@@ -130,7 +130,7 @@
try {
ourPreventInlineRenameFlag.set(Boolean.TRUE);
RenameHandler handler = RenameHandlerRegistry.getInstance().getRenameHandler(dataContext);
- assert handler != null;
+ assert handler != null : elementToRename;
handler.invoke(
elementToRename.getProject(),
editor,
diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/naming/AutomaticRenamer.java b/platform/lang-impl/src/com/intellij/refactoring/rename/naming/AutomaticRenamer.java
index 347ead9..4a2bb00 100644
--- a/platform/lang-impl/src/com/intellij/refactoring/rename/naming/AutomaticRenamer.java
+++ b/platform/lang-impl/src/com/intellij/refactoring/rename/naming/AutomaticRenamer.java
@@ -17,6 +17,7 @@
package com.intellij.refactoring.rename.naming;
import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiNamedElement;
import com.intellij.refactoring.rename.RenameProcessor;
import com.intellij.refactoring.rename.RenameUtil;
@@ -55,10 +56,18 @@
final boolean searchInStringsAndComments,
final boolean searchInNonJavaFiles,
List<UnresolvableCollisionUsageInfo> unresolvedUsages) {
+ findUsages(result, searchInStringsAndComments, searchInNonJavaFiles, unresolvedUsages, null);
+ }
+
+ public void findUsages(List<UsageInfo> result,
+ final boolean searchInStringsAndComments,
+ final boolean searchInNonJavaFiles,
+ List<UnresolvableCollisionUsageInfo> unresolvedUsages,
+ Map<PsiElement, String> allRenames) {
for (Iterator<PsiNamedElement> iterator = myElements.iterator(); iterator.hasNext();) {
final PsiNamedElement variable = iterator.next();
RenameProcessor.assertNonCompileElement(variable);
- final boolean success = findUsagesForElement(variable, result, searchInStringsAndComments, searchInNonJavaFiles, unresolvedUsages);
+ final boolean success = findUsagesForElement(variable, result, searchInStringsAndComments, searchInNonJavaFiles, unresolvedUsages, allRenames);
if (!success) {
iterator.remove();
}
@@ -68,10 +77,22 @@
private boolean findUsagesForElement(PsiNamedElement element,
List<UsageInfo> result,
final boolean searchInStringsAndComments,
- final boolean searchInNonJavaFiles, List<UnresolvableCollisionUsageInfo> unresolvedUsages) {
+ final boolean searchInNonJavaFiles,
+ List<UnresolvableCollisionUsageInfo> unresolvedUsages,
+ Map<PsiElement, String> allRenames) {
final String newName = getNewName(element);
if (newName != null) {
- final UsageInfo[] usages = RenameUtil.findUsages(element, newName, searchInStringsAndComments, searchInNonJavaFiles, myRenames);
+
+ final LinkedHashMap<PsiNamedElement, String> renames = new LinkedHashMap<PsiNamedElement, String>();
+ renames.putAll(myRenames);
+ if (allRenames != null) {
+ for (PsiElement psiElement : allRenames.keySet()) {
+ if (psiElement instanceof PsiNamedElement) {
+ renames.put((PsiNamedElement)psiElement, allRenames.get(psiElement));
+ }
+ }
+ }
+ final UsageInfo[] usages = RenameUtil.findUsages(element, newName, searchInStringsAndComments, searchInNonJavaFiles, renames);
for (final UsageInfo usage : usages) {
if (usage instanceof UnresolvableCollisionUsageInfo) {
if (unresolvedUsages != null) {
diff --git a/platform/lang-impl/src/com/intellij/refactoring/util/TextOccurrencesUtil.java b/platform/lang-impl/src/com/intellij/refactoring/util/TextOccurrencesUtil.java
index 255e5d8..4dd719e 100644
--- a/platform/lang-impl/src/com/intellij/refactoring/util/TextOccurrencesUtil.java
+++ b/platform/lang-impl/src/com/intellij/refactoring/util/TextOccurrencesUtil.java
@@ -25,13 +25,13 @@
import com.intellij.lang.LanguageParserDefinitions;
import com.intellij.lang.ParserDefinition;
import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiPolyVariantReference;
import com.intellij.psi.PsiReference;
-import com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference;
import com.intellij.psi.search.*;
import com.intellij.usageView.UsageInfo;
import com.intellij.util.PairProcessor;
@@ -42,6 +42,7 @@
import java.util.Collection;
public class TextOccurrencesUtil {
+ private static final Logger LOG = Logger.getInstance("#com.intellij.refactoring.util.TextOccurrencesUtil");
private TextOccurrencesUtil() {
}
@@ -74,13 +75,19 @@
return helper.processUsagesInNonJavaFiles(element, stringToSearch, new PsiNonJavaFileReferenceProcessor() {
@Override
public boolean process(final PsiFile psiFile, final int startOffset, final int endOffset) {
- UsageInfo usageInfo = ApplicationManager.getApplication().runReadAction(new Computable<UsageInfo>() {
- @Override
- public UsageInfo compute() {
- return factory.createUsageInfo(psiFile, startOffset, endOffset);
- }
- });
- return usageInfo == null || processor.process(usageInfo);
+ try {
+ UsageInfo usageInfo = ApplicationManager.getApplication().runReadAction(new Computable<UsageInfo>() {
+ @Override
+ public UsageInfo compute() {
+ return factory.createUsageInfo(psiFile, startOffset, endOffset);
+ }
+ });
+ return usageInfo == null || processor.process(usageInfo);
+ }
+ catch (Exception e) {
+ LOG.error(e);
+ return true;
+ }
}
}, searchScope);
}
diff --git a/platform/lang-impl/src/com/intellij/ui/popup/util/MasterDetailPopupBuilder.java b/platform/lang-impl/src/com/intellij/ui/popup/util/MasterDetailPopupBuilder.java
index 1bb26e2..8cd75d8 100644
--- a/platform/lang-impl/src/com/intellij/ui/popup/util/MasterDetailPopupBuilder.java
+++ b/platform/lang-impl/src/com/intellij/ui/popup/util/MasterDetailPopupBuilder.java
@@ -468,7 +468,7 @@
@Override
protected void addCenterComponentToContentPane(JPanel contentPane, JComponent component) {
if (myAddDetailViewToEast) {
- JBSplitter splitPane = new JBSplitter(false, 0.3f);
+ JBSplitter splitPane = new JBSplitter(0.3f);
splitPane.setSplitterProportionKey(getSplitterProportionKey());
splitPane.setFirstComponent(component);
splitPane.setSecondComponent((JComponent)myDetailView);
diff --git a/platform/lang-impl/src/com/intellij/ui/tabs/ColorSelectionComponent.java b/platform/lang-impl/src/com/intellij/ui/tabs/ColorSelectionComponent.java
new file mode 100644
index 0000000..14d9705
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/ui/tabs/ColorSelectionComponent.java
@@ -0,0 +1,236 @@
+package com.intellij.ui.tabs;
+
+import com.intellij.notification.impl.ui.StickyButton;
+import com.intellij.notification.impl.ui.StickyButtonUI;
+import com.intellij.ui.ColorChooser;
+import com.intellij.ui.ColorUtil;
+import com.intellij.ui.FileColorManager;
+import com.intellij.ui.JBColor;
+import com.intellij.util.ObjectUtils;
+import com.intellij.util.ui.UIUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+import javax.swing.plaf.ButtonUI;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * @author gregsh
+ */
+public class ColorSelectionComponent extends JPanel {
+ private static final String CUSTOM_COLOR_NAME = "Custom";
+ private Map<String, ColorButton> myColorToButtonMap = new LinkedHashMap<String, ColorButton>();
+ private final ButtonGroup myButtonGroup = new ButtonGroup();
+ private final JPanel myInnerPanel;
+ private ChangeListener myChangeListener;
+
+ public ColorSelectionComponent() {
+ setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+
+ myInnerPanel = new JPanel();
+ myInnerPanel.setLayout(new BoxLayout(myInnerPanel, BoxLayout.X_AXIS));
+ myInnerPanel.setBorder(
+ BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY, 1), BorderFactory.createEmptyBorder(5, 5, 5, 5)));
+ if (!UIUtil.isUnderDarcula()) {
+ myInnerPanel.setBackground(Color.WHITE);
+ }
+ add(myInnerPanel, BorderLayout.CENTER);
+ }
+
+ public void setChangeListener(ChangeListener changeListener) {
+ myChangeListener = changeListener;
+ }
+
+ public void setSelectedColor(String colorName) {
+ AbstractButton button = myColorToButtonMap.get(colorName);
+ if (button != null) {
+ button.setSelected(true);
+ }
+ }
+
+ @NotNull
+ public Collection<String> getColorNames() {
+ return myColorToButtonMap.keySet();
+ }
+
+ @Nullable
+ public String getColorName(@Nullable Color color) {
+ if (color == null) return null;
+ for (String name : myColorToButtonMap.keySet()) {
+ if (color.getRGB() == myColorToButtonMap.get(name).getColor().getRGB()) {
+ return name;
+ }
+ }
+ return null;
+ }
+
+ public void addCustomColorButton() {
+ CustomColorButton customButton = new CustomColorButton();
+ myButtonGroup.add(customButton);
+ myInnerPanel.add(customButton);
+ myColorToButtonMap.put(customButton.getText(), customButton);
+ myInnerPanel.add(Box.createHorizontalStrut(5));
+ }
+
+ public void addColorButton(@NotNull String name, @NotNull Color color) {
+ ColorButton colorButton = new ColorButton(name, color);
+ myButtonGroup.add(colorButton);
+ myInnerPanel.add(colorButton);
+ myColorToButtonMap.put(name, colorButton);
+ myInnerPanel.add(Box.createHorizontalStrut(5));
+ }
+
+ public void setCustomButtonColor(@NotNull Color color) {
+ CustomColorButton button = (CustomColorButton)myColorToButtonMap.get(CUSTOM_COLOR_NAME);
+ button.setColor(color);
+ button.setSelected(true);
+ button.repaint();
+ }
+
+ @Nullable
+ private ColorButton getSelectedButtonInner() {
+ for (String name : myColorToButtonMap.keySet()) {
+ ColorButton button = myColorToButtonMap.get(name);
+ if (button.isSelected()) return button;
+ }
+ return null;
+ }
+
+ @Nullable
+ public String getSelectedColorName() {
+ ColorButton button = getSelectedButtonInner();
+ return button == null? null : button instanceof CustomColorButton ? ColorUtil.toHex(button.getColor()) : button.getName();
+ }
+
+ @Nullable
+ public Color getSelectedColor() {
+ ColorButton button = getSelectedButtonInner();
+ return button == null? null : button.getColor();
+ }
+
+ public void initDefault(@NotNull FileColorManager manager, @Nullable String selectedColorName) {
+ for (String name : manager.getColorNames()) {
+ addColorButton(name, ObjectUtils.assertNotNull(manager.getColor(name)));
+ }
+ addCustomColorButton();
+ setSelectedColor(selectedColorName);
+ }
+
+ private class ColorButton extends StickyButton {
+ protected Color myColor;
+
+ protected ColorButton(final String text, final Color color) {
+ super(FileColorManagerImpl.getAlias(text));
+ setUI(new ColorButtonUI());
+ myColor = color;
+ addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ doPerformAction(e);
+ }
+ });
+
+ setBackground(new JBColor(Color.WHITE, UIUtil.getControlColor()));
+ setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));
+ }
+
+ protected void doPerformAction(ActionEvent e) {
+ stateChanged();
+ }
+
+ Color getColor() {
+ return myColor;
+ }
+
+ public void setColor(Color color) {
+ myColor = color;
+ }
+
+ @Override
+ public Color getForeground() {
+ if (getModel().isSelected()) {
+ return JBColor.foreground();
+ }
+ else if (getModel().isRollover()) {
+ return JBColor.GRAY;
+ }
+ else {
+ return getColor();
+ }
+ }
+
+ @Override
+ protected ButtonUI createUI() {
+ return new ColorButtonUI();
+ }
+ }
+
+ public void stateChanged() {
+ if (myChangeListener != null) {
+ myChangeListener.stateChanged(new ChangeEvent(this));
+ }
+ }
+
+ private class CustomColorButton extends ColorButton {
+ private CustomColorButton() {
+ super(CUSTOM_COLOR_NAME, Color.WHITE);
+ myColor = null;
+ }
+
+ @Override
+ protected void doPerformAction(ActionEvent e) {
+ final Color color = ColorChooser.chooseColor(this, "Choose Color", myColor);
+ if (color != null) {
+ myColor = color;
+ }
+ setSelected(myColor != null);
+ stateChanged();
+ }
+
+ @Override
+ public Color getForeground() {
+ return getModel().isSelected() ? Color.BLACK : JBColor.GRAY;
+ }
+
+ @Override
+ Color getColor() {
+ return myColor == null ? Color.WHITE : myColor;
+ }
+ }
+
+ private class ColorButtonUI extends StickyButtonUI<ColorButton> {
+
+ @Override
+ protected Color getBackgroundColor(final ColorButton button) {
+ return button.getColor();
+ }
+
+ @Override
+ protected Color getFocusColor(ColorButton button) {
+ return button.getColor().darker();
+ }
+
+ @Override
+ protected Color getSelectionColor(ColorButton button) {
+ return button.getColor();
+ }
+
+ @Override
+ protected Color getRolloverColor(ColorButton button) {
+ return button.getColor();
+ }
+
+ @Override
+ protected int getArcSize() {
+ return 20;
+ }
+ }
+}
diff --git a/platform/lang-impl/src/com/intellij/ui/tabs/FileColorConfigurationEditDialog.java b/platform/lang-impl/src/com/intellij/ui/tabs/FileColorConfigurationEditDialog.java
index 87701ee..c099253 100644
--- a/platform/lang-impl/src/com/intellij/ui/tabs/FileColorConfigurationEditDialog.java
+++ b/platform/lang-impl/src/com/intellij/ui/tabs/FileColorConfigurationEditDialog.java
@@ -16,8 +16,6 @@
package com.intellij.ui.tabs;
-import com.intellij.notification.impl.ui.StickyButton;
-import com.intellij.notification.impl.ui.StickyButtonUI;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.util.text.StringUtil;
@@ -25,18 +23,16 @@
import com.intellij.psi.search.scope.packageSet.NamedScope;
import com.intellij.psi.search.scope.packageSet.NamedScopeManager;
import com.intellij.psi.search.scope.packageSet.NamedScopesHolder;
-import com.intellij.ui.ColorChooser;
import com.intellij.ui.ColorUtil;
import com.intellij.ui.FileColorManager;
-import com.intellij.ui.JBColor;
import com.intellij.util.ArrayUtil;
import com.intellij.util.containers.HashMap;
-import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
-import javax.swing.plaf.ButtonUI;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@@ -51,8 +47,8 @@
private FileColorConfiguration myConfiguration;
private JComboBox myScopeComboBox;
private final FileColorManager myManager;
- private HashMap<String,AbstractButton> myColorToButtonMap;
- private static final String CUSTOM_COLOR_NAME = "Custom";
+ private final ColorSelectionComponent myColorSelectionComponent;
+
private final Map<String, NamedScope> myScopeNames = new HashMap<String, NamedScope>();
public FileColorConfigurationEditDialog(@NotNull final FileColorManager manager, @Nullable final FileColorConfiguration configuration) {
@@ -63,6 +59,14 @@
myManager = manager;
myConfiguration = configuration;
+ myColorSelectionComponent = new ColorSelectionComponent();
+ myColorSelectionComponent.initDefault(manager, configuration == null ? null : configuration.getColorName());
+ myColorSelectionComponent.setChangeListener(new ChangeListener() {
+ @Override
+ public void stateChanged(ChangeEvent e) {
+ updateOKButton();
+ }
+ });
init();
updateCustomButton();
@@ -128,7 +132,7 @@
colorPanel.setLayout(new BoxLayout(colorPanel, BoxLayout.X_AXIS));
final JLabel colorLabel = new JLabel("Color:");
colorPanel.add(colorLabel);
- colorPanel.add(createColorButtonsPanel(myConfiguration));
+ colorPanel.add(myColorSelectionComponent);
colorPanel.add(Box.createHorizontalGlue());
result.add(colorPanel);
@@ -139,17 +143,10 @@
final Object item = myScopeComboBox.getSelectedItem();
if (item instanceof String) {
Color color = myConfiguration == null ? null : ColorUtil.fromHex(myConfiguration.getColorName(), null);
- final CustomColorButton button = (CustomColorButton)myColorToButtonMap.get(CUSTOM_COLOR_NAME);
-
if (color == null) {
color = ColorUtil.getColor(myScopeNames.get(item).getClass());
}
-
- if (color != null) {
- button.setColor(color);
- button.setSelected(true);
- button.repaint();
- }
+ if (color != null) myColorSelectionComponent.setCustomButtonColor(color);
}
}
@@ -169,57 +166,9 @@
return myConfiguration;
}
- private JComponent createColorButtonsPanel(final FileColorConfiguration configuration) {
- final JPanel result = new JPanel(new BorderLayout());
- result.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
-
- final JPanel inner = new JPanel();
- inner.setLayout(new BoxLayout(inner, BoxLayout.X_AXIS));
- inner.setBorder(
- BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY, 1), BorderFactory.createEmptyBorder(5, 5, 5, 5)));
- if (!UIUtil.isUnderDarcula()) {
- inner.setBackground(Color.WHITE);
- }
- result.add(inner, BorderLayout.CENTER);
-
- final ButtonGroup group = new ButtonGroup();
-
- myColorToButtonMap = new HashMap<String, AbstractButton>();
-
- final Collection<String> names = myManager.getColorNames();
- for (final String name : names) {
- final ColorButton colorButton = new ColorButton(name, myManager.getColor(name));
- group.add(colorButton);
- inner.add(colorButton);
- myColorToButtonMap.put(name, colorButton);
- inner.add(Box.createHorizontalStrut(5));
- }
- final CustomColorButton customButton = new CustomColorButton();
- group.add(customButton);
- inner.add(customButton);
- myColorToButtonMap.put(customButton.getText(), customButton);
- inner.add(Box.createHorizontalStrut(5));
-
-
- if (configuration != null) {
- final AbstractButton button = myColorToButtonMap.get(configuration.getColorName());
- if (button != null) {
- button.setSelected(true);
- }
- }
-
- return result;
- }
-
@Nullable
private String getColorName() {
- for (String name : myColorToButtonMap.keySet()) {
- final AbstractButton button = myColorToButtonMap.get(name);
- if (button.isSelected()) {
- return button instanceof CustomColorButton ? ColorUtil.toHex(((CustomColorButton)button).getColor()) : name;
- }
- }
- return null;
+ return myColorSelectionComponent.getSelectedColorName();
}
@Override
@@ -241,106 +190,4 @@
protected JComponent createCenterPanel() {
return null;
}
-
- private class ColorButton extends StickyButton {
- protected Color myColor;
-
- protected ColorButton(final String text, final Color color) {
- super(FileColorManagerImpl.getAlias(text));
- setUI(new ColorButtonUI());
- myColor = color;
- addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- doPerformAction(e);
- }
- });
-
- setBackground(new JBColor(Color.WHITE, UIUtil.getControlColor()));
- setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));
- }
-
- protected void doPerformAction(ActionEvent e) {
- updateOKButton();
- }
-
- Color getColor() {
- return myColor;
- }
-
- public void setColor(Color color) {
- myColor = color;
- }
-
- @Override
- public Color getForeground() {
- if (getModel().isSelected()) {
- return JBColor.foreground();
- } else if (getModel().isRollover()) {
- return JBColor.GRAY;
- } else {
- return getColor();
- }
- }
-
- @Override
- protected ButtonUI createUI() {
- return new ColorButtonUI();
- }
- }
-
- private class CustomColorButton extends ColorButton {
- private CustomColorButton() {
- super(CUSTOM_COLOR_NAME, Color.WHITE);
- myColor = null;
- }
-
- @Override
- protected void doPerformAction(ActionEvent e) {
- final Color color = ColorChooser.chooseColor(FileColorConfigurationEditDialog.this.getRootPane(), "Choose Color", myColor);
- if (color != null) {
- myColor = color;
- }
- setSelected(myColor != null);
- getOKAction().setEnabled(myColor != null);
- }
-
- @Override
- public Color getForeground() {
- return getModel().isSelected() ? Color.BLACK : JBColor.GRAY;
- }
-
- @Override
- Color getColor() {
- return myColor == null ? Color.WHITE : myColor;
- }
- }
-
- private class ColorButtonUI extends StickyButtonUI<ColorButton> {
-
- @Override
- protected Color getBackgroundColor(final ColorButton button) {
- return button.getColor();
- }
-
- @Override
- protected Color getFocusColor(ColorButton button) {
- return button.getColor().darker();
- }
-
- @Override
- protected Color getSelectionColor(ColorButton button) {
- return button.getColor();
- }
-
- @Override
- protected Color getRolloverColor(ColorButton button) {
- return button.getColor();
- }
-
- @Override
- protected int getArcSize() {
- return 20;
- }
- }
}
diff --git a/platform/lang-impl/src/com/intellij/unscramble/AnnotateStackTraceAction.java b/platform/lang-impl/src/com/intellij/unscramble/AnnotateStackTraceAction.java
index 85dc4c1..8b69024 100644
--- a/platform/lang-impl/src/com/intellij/unscramble/AnnotateStackTraceAction.java
+++ b/platform/lang-impl/src/com/intellij/unscramble/AnnotateStackTraceAction.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -36,6 +36,7 @@
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
+import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.AbstractVcs;
import com.intellij.openapi.vcs.FilePath;
@@ -63,7 +64,7 @@
/**
* @author Konstantin Bulenkov
*/
-class AnnotateStackTraceAction extends AnAction {
+class AnnotateStackTraceAction extends AnAction implements DumbAware {
private final EditorHyperlinkSupport myHyperlinks;
private Map<Integer, VcsFileRevision> cache;
private int newestLine = -1;
diff --git a/platform/lang-impl/src/com/intellij/usageView/UsageViewUtil.java b/platform/lang-impl/src/com/intellij/usageView/UsageViewUtil.java
index c68b301..9de0e51 100644
--- a/platform/lang-impl/src/com/intellij/usageView/UsageViewUtil.java
+++ b/platform/lang-impl/src/com/intellij/usageView/UsageViewUtil.java
@@ -44,12 +44,12 @@
}
public static String getShortName(final PsiElement psiElement) {
- LOG.assertTrue(psiElement.isValid());
+ LOG.assertTrue(psiElement.isValid(), psiElement);
return ElementDescriptionUtil.getElementDescription(psiElement, UsageViewShortNameLocation.INSTANCE);
}
public static String getLongName(final PsiElement psiElement) {
- LOG.assertTrue(psiElement.isValid());
+ LOG.assertTrue(psiElement.isValid(), psiElement);
return ElementDescriptionUtil.getElementDescription(psiElement, UsageViewLongNameLocation.INSTANCE);
}
diff --git a/platform/lang-impl/src/com/intellij/util/indexing/AbstractIndex.java b/platform/lang-impl/src/com/intellij/util/indexing/AbstractIndex.java
index 4e4b534..60949b8 100644
--- a/platform/lang-impl/src/com/intellij/util/indexing/AbstractIndex.java
+++ b/platform/lang-impl/src/com/intellij/util/indexing/AbstractIndex.java
@@ -19,8 +19,6 @@
import com.intellij.util.Processor;
import org.jetbrains.annotations.NotNull;
-import java.util.Collection;
-
/**
* @author Eugene Zhuravlev
* Date: Dec 24, 2007
@@ -28,8 +26,6 @@
public interface AbstractIndex<Key, Value> {
@NotNull
ValueContainer<Value> getData(Key key) throws StorageException;
-
- Collection<Key> getAllKeys() throws StorageException;
boolean processAllKeys(Processor<Key> processor) throws StorageException;
}
diff --git a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java
index 13189e2..541b8d9 100644
--- a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java
+++ b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java
@@ -42,6 +42,7 @@
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.progress.*;
import com.intellij.openapi.progress.impl.BackgroundableProcessIndicator;
+import com.intellij.openapi.progress.util.ProgressWindow;
import com.intellij.openapi.project.*;
import com.intellij.openapi.roots.*;
import com.intellij.openapi.util.*;
@@ -86,6 +87,7 @@
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.Lock;
/**
@@ -96,6 +98,7 @@
private static final Logger LOG = Logger.getInstance("#com.intellij.util.indexing.FileBasedIndexImpl");
@NonNls
private static final String CORRUPTION_MARKER_NAME = "corruption.marker";
+ private static final int PROGRESS_DELAY_IN_MILLIS = 1000;
private final Map<ID<?, ?>, Pair<UpdatableIndex<?, ?, FileContent>, InputFilter>> myIndices =
new THashMap<ID<?, ?>, Pair<UpdatableIndex<?, ?, FileContent>, InputFilter>>();
private final List<ID<?, ?>> myIndicesWithoutFileTypeInfo = new ArrayList<ID<?, ?>>();
@@ -429,10 +432,7 @@
.getInstance().runProcessWithProgressSynchronously(new ThrowableComputable<MapIndexStorage<K, V>, IOException>() {
@Override
public MapIndexStorage<K, V> compute() throws IOException {
- final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
- if (indicator != null) {
- indicator.setIndeterminate(true);
- }
+ configureIndexDataLoadingProgress(ProgressManager.getInstance().getProgressIndicator());
return new MapIndexStorage<K, V>(
IndexInfrastructure.getStorageFile(name),
extension.getKeyDescriptor(),
@@ -579,10 +579,7 @@
new ThrowableComputable<PersistentHashMap<Integer, Collection<K>>, IOException>() {
@Override
public PersistentHashMap<Integer, Collection<K>> compute() throws IOException {
- final ProgressIndicator indicator = progressManager.getProgressIndicator();
- if (indicator != null) {
- indicator.setIndeterminate(true);
- }
+ configureIndexDataLoadingProgress(progressManager.getProgressIndicator());
return process.compute();
}
}, LangBundle.message("compacting.indices.title"), false, null);
@@ -610,6 +607,13 @@
return index;
}
+ public static void configureIndexDataLoadingProgress(ProgressIndicator indicator) {
+ if (indicator != null) {
+ indicator.setIndeterminate(true);
+ if (indicator instanceof ProgressWindow) ((ProgressWindow)indicator).setDelayInMillis(PROGRESS_DELAY_IN_MILLIS);
+ }
+ }
+
@NotNull
private static <K> PersistentHashMap<Integer, Collection<K>> createIdToDataKeysIndex(@NotNull final ID<K, ?> indexId,
@NotNull final KeyDescriptor<K> keyDescriptor,
@@ -859,6 +863,7 @@
@Nullable Project project,
@Nullable GlobalSearchScope filter,
@Nullable VirtualFile restrictedFile) {
+ ProgressManager.checkCanceled();
if (!needsFileContentLoading(indexId)) {
return; //indexed eagerly in foreground while building unindexed file list
}
@@ -1715,9 +1720,13 @@
});
}
+ public boolean isFileUpToDate(VirtualFile file) {
+ return !myChangedFilesCollector.myFilesToUpdate.contains(file);
+ }
+
void processRefreshedFile(@NotNull Project project, @NotNull final com.intellij.ide.caches.FileContent fileContent) {
myChangedFilesCollector.ensureAllInvalidateTasksCompleted();
- myChangedFilesCollector.processFileImpl(project, fileContent, false); // ProcessCanceledException will cause readding the file to processing list
+ myChangedFilesCollector.processFileImpl(project, fileContent, false); // ProcessCanceledException will cause re-adding the file to processing list
}
public void indexFileContent(@Nullable Project project, @NotNull com.intellij.ide.caches.FileContent content) {
@@ -1757,6 +1766,7 @@
}
catch (ProcessCanceledException e) {
cleanFileContent(fc, psiFile);
+ myChangedFilesCollector.scheduleForUpdate(file);
throw e;
}
catch (StorageException e) {
@@ -1821,9 +1831,10 @@
@Override
public void run() {
if (file.isValid()) {
- ID stubId = IndexInfrastructure.getStubId(indexId, file.getFileType());
+ FileType fileType = file.getFileType();
+ ID stubId = IndexInfrastructure.getStubId(indexId, fileType);
if (currentFC != null) {
- IndexingStamp.update(file, stubId, getIndexCreationStamp(stubId, file));
+ IndexingStamp.update(file, stubId, getIndexCreationStamp(stubId, fileType));
}
else {
// mark the file as unindexed
@@ -1887,7 +1898,11 @@
private final Queue<InvalidationTask> myFutureInvalidations = new ConcurrentLinkedQueue<InvalidationTask>();
private final ManagingFS myManagingFS = ManagingFS.getInstance();
- // No need to react on movement events since files stay valid, their ids don't change and all associated attributes remain intact.
+
+ @Override
+ public void fileMoved(VirtualFileMoveEvent event) {
+ markDirty(event, false);
+ }
@Override
public void fileCreated(@NotNull final VirtualFileEvent event) {
@@ -1992,7 +2007,7 @@
}
}
- public void scheduleForUpdate(VirtualFile file) {
+ private void scheduleForUpdate(VirtualFile file) {
myFilesToUpdate.add(file);
}
@@ -2055,8 +2070,9 @@
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
+ FileType fileType = file.getFileType();
for (ID<?, ?> indexId : affectedIndices) {
- ID id = IndexInfrastructure.getStubId(indexId, file.getFileType());
+ ID id = IndexInfrastructure.getStubId(indexId, fileType);
IndexingStamp.update(file, id, IndexInfrastructure.INVALID_STAMP2);
}
}
@@ -2082,7 +2098,9 @@
myFutureInvalidations.offer(new InvalidationTask(file) {
@Override
public void run() {
- removeFileDataFromIndices(myRequiringContentIndices, file);
+ List<ID<?, ?>> candidates = new ArrayList<ID<?, ?>>(affectedIndexCandidates);
+ candidates.retainAll(myRequiringContentIndices);
+ removeFileDataFromIndices(candidates, file);
}
});
}
@@ -2176,68 +2194,101 @@
return new ArrayList<VirtualFile>(myFilesToUpdate);
}
- private final Semaphore myForceUpdateSemaphore = new Semaphore();
+ private final AtomicReference<UpdateSemaphore> myUpdateSemaphoreRef = new AtomicReference<UpdateSemaphore>(null);
- private void forceUpdate(@Nullable Project project, @Nullable GlobalSearchScope filter, @Nullable VirtualFile restrictedTo,
- boolean onlyRemoveOutdatedData) {
- myChangedFilesCollector.ensureAllInvalidateTasksCompleted();
- ProjectIndexableFilesFilter indexableFilesFilter = projectIndexableFiles(project);
-
- for (VirtualFile file : getAllFilesToUpdate()) {
- if (indexableFilesFilter != null &&
- file instanceof VirtualFileWithId &&
- !indexableFilesFilter.contains(((VirtualFileWithId)file).getId())) {
- continue;
+ @NotNull
+ private UpdateSemaphore obtainForceUpdateSemaphore() {
+ UpdateSemaphore newValue = null;
+ while (true) {
+ final UpdateSemaphore currentValue = myUpdateSemaphoreRef.get();
+ if (currentValue != null) {
+ return currentValue;
}
-
- if (filter == null || filter.accept(file) || Comparing.equal(file, restrictedTo)) {
- try {
- myForceUpdateSemaphore.down();
- // process only files that can affect result
- processFileImpl(project, new com.intellij.ide.caches.FileContent(file), onlyRemoveOutdatedData);
- } catch (ProcessCanceledException ex) {
- LOG.assertTrue(!onlyRemoveOutdatedData);
- myChangedFilesCollector.scheduleForUpdate(file);
- throw ex;
- }
- finally {
- myForceUpdateSemaphore.up();
- }
+ if (newValue == null) { // lazy init
+ newValue = new UpdateSemaphore();
}
- }
-
- // If several threads entered the method at the same time and there were files to update,
- // all the threads should leave the method synchronously after all the files scheduled for update are reindexed,
- // no matter which thread will do reindexing job.
- // Thus we ensure that all the threads that entered the method will get the most recent data
-
- while (!myForceUpdateSemaphore.waitFor(500)) { // may need to wait until another thread is done with indexing
- if (Thread.holdsLock(PsiLock.LOCK)) {
- break; // hack. Most probably that other indexing threads is waiting for PsiLock, which we're are holding.
+ if (myUpdateSemaphoreRef.compareAndSet(null, newValue)) {
+ return newValue;
}
}
}
- private void processFileImpl(Project project,
- @NotNull final com.intellij.ide.caches.FileContent fileContent,
- boolean onlyRemoveOutdatedData) {
+ private void releaseForceUpdateSemaphore(UpdateSemaphore semaphore) {
+ myUpdateSemaphoreRef.compareAndSet(semaphore, null);
+ }
+
+ private void forceUpdate(@Nullable Project project, @Nullable GlobalSearchScope filter, @Nullable VirtualFile restrictedTo, boolean onlyRemoveOutdatedData) {
+ myChangedFilesCollector.ensureAllInvalidateTasksCompleted();
+ ProjectIndexableFilesFilter indexableFilesFilter = projectIndexableFiles(project);
+
+ UpdateSemaphore updateSemaphore;
+ do{
+ updateSemaphore = obtainForceUpdateSemaphore();
+ try {
+ for (VirtualFile file : getAllFilesToUpdate()) {
+ if (indexableFilesFilter != null && file instanceof VirtualFileWithId && !indexableFilesFilter.contains(((VirtualFileWithId)file).getId())) {
+ continue;
+ }
+
+ if (filter == null || filter.accept(file) || Comparing.equal(file, restrictedTo)) {
+ try {
+ updateSemaphore.down();
+ // process only files that can affect result
+ processFileImpl(project, new com.intellij.ide.caches.FileContent(file), onlyRemoveOutdatedData);
+ }
+ catch (ProcessCanceledException e) {
+ updateSemaphore.reportUpdateCanceled();
+ throw e;
+ }
+ finally {
+ updateSemaphore.up();
+ }
+ }
+ }
+
+ // If several threads entered the method at the same time and there were files to update,
+ // all the threads should leave the method synchronously after all the files scheduled for update are reindexed,
+ // no matter which thread will do reindexing job.
+ // Thus we ensure that all the threads that entered the method will get the most recent data
+
+ while (!updateSemaphore.waitFor(500)) { // may need to wait until another thread is done with indexing
+ if (Thread.holdsLock(PsiLock.LOCK)) {
+ break; // hack. Most probably that other indexing threads is waiting for PsiLock, which we're are holding.
+ }
+ }
+
+ }
+ finally {
+ releaseForceUpdateSemaphore(updateSemaphore);
+ }
+ // if some other thread was unable to complete indexing because of PCE,
+ // we should try again and ensure the file is indexed before proceeding further
+ }
+ while (updateSemaphore.isUpdateCanceled());
+ }
+
+ private void processFileImpl(Project project, @NotNull final com.intellij.ide.caches.FileContent fileContent, boolean onlyRemoveOutdatedData) {
final VirtualFile file = fileContent.getVirtualFile();
final boolean reallyRemoved = myFilesToUpdate.remove(file);
if (reallyRemoved && file.isValid()) {
- if (onlyRemoveOutdatedData || isTooLarge(file)) {
- // on shutdown there is no need to re-index the file, just remove outdated data from indices
- final List<ID<?, ?>> affected = new ArrayList<ID<?, ?>>();
- for (final ID<?, ?> indexId : myRequiringContentIndices) { // non requiring content indices should be flushed
- if (getInputFilter(indexId).acceptInput(file)) {
- affected.add(indexId);
+ try {
+ if (onlyRemoveOutdatedData || isTooLarge(file)) {
+ // on shutdown there is no need to re-index the file, just remove outdated data from indices
+ final List<ID<?, ?>> affected = new ArrayList<ID<?, ?>>();
+ for (final ID<?, ?> indexId : getAffectedIndexCandidates(file)) { // non requiring content indices should be flushed
+ if (needsFileContentLoading(indexId) && getInputFilter(indexId).acceptInput(file)) {
+ affected.add(indexId);
+ }
}
+ removeFileDataFromIndices(affected, file);
}
- removeFileDataFromIndices(affected, file);
+ else {
+ indexFileContent(project, fileContent);
+ }
}
- else {
- indexFileContent(project, fileContent);
+ finally {
+ IndexingStamp.flushCache(file);
}
- IndexingStamp.flushCache(file);
}
}
}
@@ -2349,8 +2400,8 @@
return IndexingStamp.isFileIndexed(file, id, IndexInfrastructure.getIndexCreationStamp(id));
}
- private static long getIndexCreationStamp(ID<?, ?> indexId, VirtualFile file) {
- return IndexInfrastructure.getIndexCreationStamp(indexId, file);
+ private static long getIndexCreationStamp(ID<?, ?> indexId, FileType fileType) {
+ return IndexInfrastructure.getIndexCreationStamp(indexId, fileType);
}
private boolean isUnderConfigOrSystem(@NotNull VirtualFile file) {
diff --git a/platform/lang-impl/src/com/intellij/util/indexing/IndexInfrastructure.java b/platform/lang-impl/src/com/intellij/util/indexing/IndexInfrastructure.java
index 17349de..1708361 100644
--- a/platform/lang-impl/src/com/intellij/util/indexing/IndexInfrastructure.java
+++ b/platform/lang-impl/src/com/intellij/util/indexing/IndexInfrastructure.java
@@ -106,8 +106,8 @@
return stamp;
}
- public static long getIndexCreationStamp(ID<?, ?> indexName, VirtualFile forFile) {
- return getIndexCreationStamp(getStubId(indexName, forFile.getFileType()));
+ public static long getIndexCreationStamp(ID<?, ?> indexName, FileType fileType) {
+ return getIndexCreationStamp(getStubId(indexName, fileType));
}
public static ID getStubId(ID<?, ?> indexName, FileType fileType) {
diff --git a/platform/lang-impl/src/com/intellij/util/indexing/IndexingStamp.java b/platform/lang-impl/src/com/intellij/util/indexing/IndexingStamp.java
index 3086e91..0b69be0 100644
--- a/platform/lang-impl/src/com/intellij/util/indexing/IndexingStamp.java
+++ b/platform/lang-impl/src/com/intellij/util/indexing/IndexingStamp.java
@@ -18,6 +18,7 @@
import com.intellij.openapi.vfs.InvalidVirtualFileAccessException;
import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.openapi.vfs.VirtualFileWithId;
import com.intellij.openapi.vfs.newvfs.FileAttribute;
import com.intellij.openapi.vfs.newvfs.NewVirtualFile;
import com.intellij.util.containers.ConcurrentHashMap;
@@ -141,7 +142,7 @@
}
public static long getIndexStamp(VirtualFile file, ID<?, ?> indexName) {
- synchronized (myTimestampsCache) {
+ synchronized (getStripedLock(file)) {
Timestamps stamp = createOrGetTimeStamp(file);
if (stamp != null) return stamp.get(indexName);
return 0;
@@ -172,7 +173,7 @@
}
public static void update(final VirtualFile file, final ID<?, ?> indexName, final long indexCreationStamp) {
- synchronized (myTimestampsCache) {
+ synchronized (getStripedLock(file)) {
try {
Timestamps stamp = createOrGetTimeStamp(file);
if (stamp != null) stamp.set(indexName, indexCreationStamp);
@@ -200,7 +201,7 @@
if (files != null) {
for(VirtualFile file:files) {
- synchronized (myTimestampsCache) {
+ synchronized (getStripedLock(file)) {
Timestamps timestamp = myTimestampsCache.remove(file);
if (timestamp == null) continue;
try {
@@ -219,4 +220,15 @@
if (finishedFile != null) myFinishedFiles.offer(finishedFile);
}
}
+
+ private static final Object[] ourLocks = new Object[16];
+ static {
+ for(int i = 0; i < ourLocks.length; ++i) ourLocks[i] = new Object();
+ }
+
+ private static Object getStripedLock(VirtualFile file) {
+ if (!(file instanceof NewVirtualFile)) return 0;
+ int id = ((NewVirtualFile)file).getId();
+ return (id & 0xFF) % ourLocks.length;
+ }
}
diff --git a/platform/lang-impl/src/com/intellij/util/indexing/MapReduceIndex.java b/platform/lang-impl/src/com/intellij/util/indexing/MapReduceIndex.java
index 34c6e76..2eeb631 100644
--- a/platform/lang-impl/src/com/intellij/util/indexing/MapReduceIndex.java
+++ b/platform/lang-impl/src/com/intellij/util/indexing/MapReduceIndex.java
@@ -21,7 +21,6 @@
import com.intellij.openapi.util.Factory;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.io.FileUtil;
-import com.intellij.util.CommonProcessors;
import com.intellij.util.Processor;
import com.intellij.util.io.PersistentHashMap;
import gnu.trove.THashMap;
@@ -158,14 +157,6 @@
return myLock.writeLock();
}
- @NotNull
- @Override
- public Collection<Key> getAllKeys() throws StorageException {
- Set<Key> allKeys = new HashSet<Key>();
- processAllKeys(new CommonProcessors.CollectProcessor<Key>(allKeys));
- return allKeys;
- }
-
@Override
public boolean processAllKeys(Processor<Key> processor) throws StorageException {
final Lock lock = getReadLock();
diff --git a/platform/lang-impl/src/com/intellij/util/indexing/UnindexedFilesUpdater.java b/platform/lang-impl/src/com/intellij/util/indexing/UnindexedFilesUpdater.java
index 994654a..beba11b 100644
--- a/platform/lang-impl/src/com/intellij/util/indexing/UnindexedFilesUpdater.java
+++ b/platform/lang-impl/src/com/intellij/util/indexing/UnindexedFilesUpdater.java
@@ -65,8 +65,11 @@
@Override
public void processFile(final FileContent fileContent) {
- myIndex.indexFileContent(myProject, fileContent);
- IndexingStamp.flushCache(fileContent.getVirtualFile());
+ try {
+ myIndex.indexFileContent(myProject, fileContent);
+ } finally {
+ IndexingStamp.flushCache(fileContent.getVirtualFile());
+ }
}
@Override
diff --git a/platform/lang-impl/src/com/intellij/util/indexing/UpdateSemaphore.java b/platform/lang-impl/src/com/intellij/util/indexing/UpdateSemaphore.java
new file mode 100644
index 0000000..4110606
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/util/indexing/UpdateSemaphore.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2000-2013 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.util.indexing;
+
+import com.intellij.util.concurrency.Semaphore;
+
+/**
+* @author Eugene Zhuravlev
+* Date: 6/26/13
+*/
+final class UpdateSemaphore extends Semaphore {
+ private volatile boolean myIsCanceled = false;
+
+ UpdateSemaphore() {
+ }
+
+ boolean isUpdateCanceled() {
+ return myIsCanceled;
+ }
+
+ void reportUpdateCanceled() {
+ myIsCanceled = true;
+ }
+}
diff --git a/platform/lang-impl/testData/platform/templates/github/simple.zip b/platform/lang-impl/testData/platform/templates/github/simple.zip
new file mode 100644
index 0000000..33204d1
--- /dev/null
+++ b/platform/lang-impl/testData/platform/templates/github/simple.zip
Binary files differ
diff --git a/platform/lang-impl/testData/platform/templates/github/single-root-dir-archive.zip b/platform/lang-impl/testData/platform/templates/github/single-root-dir-archive.zip
new file mode 100644
index 0000000..a8efe71
--- /dev/null
+++ b/platform/lang-impl/testData/platform/templates/github/single-root-dir-archive.zip
Binary files differ
diff --git a/platform/lang-impl/testSources/com/intellij/execution/impl/ModuleRunConfigurationManagerTest.java b/platform/lang-impl/testSources/com/intellij/execution/impl/ModuleRunConfigurationManagerTest.java
new file mode 100644
index 0000000..b58f01b
--- /dev/null
+++ b/platform/lang-impl/testSources/com/intellij/execution/impl/ModuleRunConfigurationManagerTest.java
@@ -0,0 +1,223 @@
+/*
+ * Copyright 2000-2013 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.execution.impl;
+
+import com.intellij.ProjectTopics;
+import com.intellij.execution.ExecutionException;
+import com.intellij.execution.Executor;
+import com.intellij.execution.RunnerAndConfigurationSettings;
+import com.intellij.execution.configurations.*;
+import com.intellij.execution.runners.ExecutionEnvironment;
+import com.intellij.ide.util.PropertiesComponent;
+import com.intellij.openapi.module.Module;
+import com.intellij.openapi.options.SettingsEditor;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.WriteExternalException;
+import com.intellij.testFramework.LightPlatformTestCase;
+import com.intellij.testFramework.PlatformTestCase;
+import com.intellij.util.containers.ContainerUtil;
+import com.intellij.util.messages.MessageBus;
+import com.intellij.util.messages.MessageBusConnection;
+import org.jdom.Element;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jmock.Expectations;
+import org.jmock.Mockery;
+
+import javax.swing.*;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+public class ModuleRunConfigurationManagerTest extends LightPlatformTestCase {
+
+ private ModuleRunConfigurationManager myManager;
+ private final Mockery context = new Mockery();
+ private Module myModule;
+ private Collection<? extends RunnerAndConfigurationSettings> myConfigurations;
+ private final List<RunnerAndConfigurationSettings> myRemovedSettings = ContainerUtil.newArrayList();
+ private RunnerAndConfigurationSettings mySettings;
+ private final List<RunnerAndConfigurationSettings> myAddedElements = ContainerUtil.newArrayList();
+
+ @Override
+ public void setUp() throws Exception {
+ PlatformTestCase.initPlatformLangPrefix();
+ super.setUp();
+ myModule = context.mock(Module.class, "myModule");
+ context.checking(new Expectations() {{
+ allowing(myModule).getName(); will(returnValue("my-module"));
+ }});
+ myManager = new ModuleRunConfigurationManager(myModule, new MyRunManagerImpl());
+
+ mySettings = createSettings("my-module-run", new MyModuleBasedConfiguration("my-module-run-config", getProject(), myModule));
+ final List<? extends RunnerAndConfigurationSettings> configs = ContainerUtil.newArrayList(
+ createSettings("other-run", context.mock(RunConfiguration.class, "other-run-run-config")),
+ createSettings("other-module-run", new MyModuleBasedConfiguration("other-module-run-config", getProject(), getModule())),
+ mySettings
+ );
+ myConfigurations = Collections.unmodifiableCollection(configs);
+ }
+
+ @NotNull
+ private RunnerAndConfigurationSettings createSettings(@NotNull final String name, @NotNull final RunConfiguration runConfiguration) {
+ final RunnerAndConfigurationSettings settings = context.mock(RunnerAndConfigurationSettings.class, name);
+ context.checking(new Expectations() {{
+ allowing(settings).getConfiguration(); will(returnValue(runConfiguration));
+ }});
+ return settings;
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ myManager = null;
+ super.tearDown();
+ }
+
+ public void testInitComponentSubscribesForModulesTopic() throws Exception {
+ context.checking(new Expectations() {{
+ final MessageBus messageBus = context.mock(MessageBus.class, "messageBus");
+ final MessageBusConnection messageBusConnection = context.mock(MessageBusConnection.class, "messageBusConnection");
+ oneOf(myModule).getMessageBus();
+ will(returnValue(messageBus));
+ oneOf(messageBus).connect(myModule); will(returnValue(messageBusConnection));
+ oneOf(messageBusConnection).subscribe(ProjectTopics.MODULES, myManager);
+ }});
+ myManager.initComponent();
+ context.assertIsSatisfied();
+ }
+
+ public void testGetState() throws Exception {
+ myAddedElements.clear();
+ myManager.getState();
+ assertSameElements("One config should be added to state", myAddedElements, Collections.singleton(mySettings));
+ }
+
+ public void testBeforeOtherModuleRemoved() throws Exception {
+ myRemovedSettings.clear();
+ myManager.beforeModuleRemoved(getProject(), getModule());
+ assertEmpty("No settings should be removed", myRemovedSettings);
+ }
+
+ public void testBeforeMyModuleRemoved() throws Exception {
+ myRemovedSettings.clear();
+ myManager.beforeModuleRemoved(getProject(), myModule);
+ assertSameElements("one run config should be removed", myRemovedSettings, Collections.singleton(mySettings));
+ }
+
+ private static final class MyRunConfigurationModule extends RunConfigurationModule {
+ private final Module myModule;
+ public MyRunConfigurationModule(@NotNull final Project project, @NotNull final Module module) {
+ super(project);
+ setModule(module);
+ myModule = module;
+ }
+
+ @Nullable
+ @Override
+ public Module getModule() {
+ return myModule;
+ }
+ }
+
+ private final class MyRunManagerImpl extends RunManagerImpl {
+ public MyRunManagerImpl() {
+ super(LightPlatformTestCase.getProject(), PropertiesComponent.getInstance());
+ }
+
+ @NotNull
+ @Override
+ Collection<? extends RunnerAndConfigurationSettings> getConfigurationSettings() {
+ return myConfigurations;
+ }
+
+ @Override
+ public void removeConfiguration(@Nullable RunnerAndConfigurationSettings settings) {
+ myRemovedSettings.add(settings);
+ }
+
+ @Override
+ void addConfigurationElement(final Element parentNode, RunnerAndConfigurationSettings template) throws WriteExternalException {
+ myAddedElements.add(template);
+ }
+ }
+
+ private final class MyModuleBasedConfiguration extends ModuleBasedConfiguration<RunConfigurationModule> {
+ public MyModuleBasedConfiguration(@NotNull final String name, @NotNull final Project project, @NotNull final Module module) {
+ super(name, new MyRunConfigurationModule(project, module), new MockConfigurationFactory());
+ }
+
+ @Override
+ public Collection<Module> getValidModules() {
+ return null;
+ }
+
+ @Override
+ protected ModuleBasedConfiguration createInstance() {
+ return null;
+ }
+
+ @Override
+ public SettingsEditor<? extends RunConfiguration> getConfigurationEditor() {
+ return null;
+ }
+
+ @Nullable
+ @Override
+ public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException {
+ return null;
+ }
+ }
+
+ private static class MockConfigurationFactory extends ConfigurationFactory {
+ public MockConfigurationFactory() {
+ super(new MyConfigurationType());
+ }
+
+ @Override
+ public RunConfiguration createTemplateConfiguration(Project project) {
+ throw new UnsupportedOperationException("Not Implemented");
+ }
+
+ }
+
+ private static class MyConfigurationType implements ConfigurationType {
+ @Override
+ public String getDisplayName() {
+ return "mock";
+ }
+
+ @Override
+ public String getConfigurationTypeDescription() {
+ return "mock type";
+ }
+
+ @Override
+ public Icon getIcon() {
+ return null;
+ }
+
+ @Override
+ @NotNull
+ public String getId() {
+ return "MockRuntimeConfiguration";
+ }
+
+ @Override
+ public ConfigurationFactory[] getConfigurationFactories() {
+ return new ConfigurationFactory[0];
+ }
+ }
+}
diff --git a/platform/lang-impl/testSources/com/intellij/platform/templates/github/ZipUtilTest.java b/platform/lang-impl/testSources/com/intellij/platform/templates/github/ZipUtilTest.java
new file mode 100644
index 0000000..95e065f
--- /dev/null
+++ b/platform/lang-impl/testSources/com/intellij/platform/templates/github/ZipUtilTest.java
@@ -0,0 +1,64 @@
+package com.intellij.platform.templates.github;
+
+import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.testFramework.PlatformTestUtil;
+import com.intellij.util.io.TestFileSystemBuilder;
+import org.jetbrains.annotations.NotNull;
+import org.junit.Test;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.zip.ZipInputStream;
+
+import static com.intellij.util.io.TestFileSystemBuilder.fs;
+
+/**
+ * @author Sergey Simonchik
+ */
+public class ZipUtilTest {
+
+ @Test
+ public void testSimpleUnzip() throws Exception {
+ File tempDir = FileUtil.createTempDirectory("unzip-test-", null);
+ File simpleZipFile = new File(getZipParentDir(), "simple.zip");
+ ZipInputStream stream = new ZipInputStream(new FileInputStream(simpleZipFile));
+ try {
+ ZipUtil.unzip(null, tempDir, stream, null, null, true);
+ checkFileStructure(tempDir,
+ fs()
+ .file("a.txt")
+ .dir("dir").file("b.txt"));
+ }
+ finally {
+ stream.close();
+ }
+ }
+
+ @Test
+ public void testSingleRootDirUnzip() throws Exception {
+ File tempDir = FileUtil.createTempDirectory("unzip-test-", null);
+ File simpleZipFile = new File(getZipParentDir(), "single-root-dir-archive.zip");
+ ZipInputStream stream = new ZipInputStream(new FileInputStream(simpleZipFile));
+ try {
+ ZipUtil.unzip(null, tempDir, stream, null, null, true);
+ checkFileStructure(tempDir,
+ fs()
+ .file("a.txt")
+ .dir("dir").file("b.txt"));
+ }
+ finally {
+ stream.close();
+ }
+ }
+
+ private static void checkFileStructure(@NotNull File parentDir, @NotNull TestFileSystemBuilder expected) {
+ expected.build().assertDirectoryEqual(parentDir);
+ }
+
+ @NotNull
+ private static File getZipParentDir() {
+ File communityDir = new File(PlatformTestUtil.getCommunityPath().replace(File.separatorChar, '/'));
+ return new File(communityDir, "platform/lang-impl/testData/platform/templates/github");
+ }
+
+}
diff --git a/platform/platform-api/src/com/intellij/ide/SelectInContext.java b/platform/platform-api/src/com/intellij/ide/SelectInContext.java
index 2568e95..6b4075d 100644
--- a/platform/platform-api/src/com/intellij/ide/SelectInContext.java
+++ b/platform/platform-api/src/com/intellij/ide/SelectInContext.java
@@ -40,4 +40,4 @@
@Nullable
FileEditorProvider getFileEditorProvider();
-}
+}
\ No newline at end of file
diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/NodeRenderer.java b/platform/platform-api/src/com/intellij/ide/util/treeView/NodeRenderer.java
index 21c8b75..f3e267d 100644
--- a/platform/platform-api/src/com/intellij/ide/util/treeView/NodeRenderer.java
+++ b/platform/platform-api/src/com/intellij/ide/util/treeView/NodeRenderer.java
@@ -22,6 +22,7 @@
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.editor.markup.TextAttributes;
+import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.ColoredTreeCellRenderer;
import com.intellij.ui.SimpleTextAttributes;
import org.jetbrains.annotations.Nls;
@@ -71,7 +72,7 @@
}
final String location = presentation.getLocationString();
- if (location != null && !location.isEmpty()) {
+ if (!StringUtil.isEmpty(location)) {
doAppend(presentation.getLocationPrefix() + location + presentation.getLocationSuffix(),
SimpleTextAttributes.GRAY_ATTRIBUTES, false, selected);
}
diff --git a/platform/platform-api/src/com/intellij/notification/Notifications.java b/platform/platform-api/src/com/intellij/notification/Notifications.java
index 8524f42..1180aaf 100644
--- a/platform/platform-api/src/com/intellij/notification/Notifications.java
+++ b/platform/platform-api/src/com/intellij/notification/Notifications.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -39,7 +39,6 @@
@SuppressWarnings({"UtilityClassWithoutPrivateConstructor"})
class Bus {
-
/**
* Registration is OPTIONAL: STICKY_BALLOON display type will be used by default.
*/
@@ -58,11 +57,6 @@
});
}
- @Deprecated
- public static void notify(@NotNull final Notification notification, @SuppressWarnings("UnusedParameters") final NotificationDisplayType displayType, @Nullable final Project project) {
- notify(notification, project);
- }
-
public static void notify(@NotNull final Notification notification) {
notify(notification, null);
}
diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/CommonShortcuts.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/CommonShortcuts.java
index 78cc372..57315ae 100644
--- a/platform/platform-api/src/com/intellij/openapi/actionSystem/CommonShortcuts.java
+++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/CommonShortcuts.java
@@ -138,6 +138,10 @@
return shortcutsById(IdeActions.ACTION_EDITOR_MOVE_LINE_START);
}
+ public static ShortcutSet getRecentFiles() {
+ return shortcutsById(IdeActions.ACTION_RECENT_FILES);
+ }
+
private static CustomShortcutSet shortcutsById(String actionId) {
if (ApplicationManager.getApplication() == null) return new CustomShortcutSet(Shortcut.EMPTY_ARRAY);
diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/CompactActionGroup.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/CompactActionGroup.java
new file mode 100644
index 0000000..cf74d8b
--- /dev/null
+++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/CompactActionGroup.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2000-2013 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.actionSystem;
+
+/**
+ * Markup interface to tell Action Manager that disabled actions shouldn't be shown
+ *
+ * @author Konstantin Bulenkov
+ */
+public interface CompactActionGroup {
+}
diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/DefaultCompactActionGroup.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/DefaultCompactActionGroup.java
new file mode 100644
index 0000000..e023324
--- /dev/null
+++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/DefaultCompactActionGroup.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2000-2013 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.actionSystem;
+
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author Konstantin Bulenkov
+ */
+public class DefaultCompactActionGroup extends DefaultActionGroup implements CompactActionGroup {
+ public DefaultCompactActionGroup() {
+ super();
+ }
+
+ public DefaultCompactActionGroup(@NotNull AnAction... actions) {
+ super(actions);
+ }
+
+ public DefaultCompactActionGroup(String shortName, boolean popup) {
+ super(shortName, popup);
+ }
+}
diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/IdeActions.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/IdeActions.java
index 8320022..efad501 100644
--- a/platform/platform-api/src/com/intellij/openapi/actionSystem/IdeActions.java
+++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/IdeActions.java
@@ -261,4 +261,6 @@
String CONSOLE_CLEAR_ALL = "ConsoleView.ClearAll";
String MOVE_TO_ANOTHER_CHANGE_LIST = "ChangesView.Move";
+
+ String ACTION_RECENT_FILES = "RecentFiles";
}
diff --git a/platform/platform-api/src/com/intellij/openapi/editor/colors/FontPreferences.java b/platform/platform-api/src/com/intellij/openapi/editor/colors/FontPreferences.java
index 3ea825a..3ca505d 100644
--- a/platform/platform-api/src/com/intellij/openapi/editor/colors/FontPreferences.java
+++ b/platform/platform-api/src/com/intellij/openapi/editor/colors/FontPreferences.java
@@ -15,7 +15,6 @@
*/
package com.intellij.openapi.editor.colors;
-import com.intellij.ide.ui.UISettings;
import com.intellij.openapi.options.FontSize;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.util.containers.ContainerUtilRt;
@@ -84,9 +83,6 @@
}
public int getSize(@NotNull String fontFamily) {
- if (UISettings.getInstance().PRESENTATION_MODE) {
- return UISettings.getInstance().PRESENTATION_MODE_FONT_SIZE;
- }
int result = myFontSizes.get(fontFamily);
if (result <= 0) {
result = myTemplateFontSize;
diff --git a/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDescriptor.java b/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDescriptor.java
index ae6f6bb..d307640 100644
--- a/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDescriptor.java
+++ b/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDescriptor.java
@@ -20,6 +20,7 @@
import com.intellij.openapi.fileTypes.FileTypes;
import com.intellij.openapi.util.Iconable;
import com.intellij.openapi.vfs.JarFileSystem;
+import com.intellij.openapi.vfs.VFileProperty;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.LayeredIcon;
import com.intellij.ui.UIBundle;
@@ -166,7 +167,7 @@
}
protected static Icon dressIcon(final VirtualFile file, final Icon baseIcon) {
- return file.isValid() && file.isSymLink() ? new LayeredIcon(baseIcon, PlatformIcons.SYMLINK_ICON) : baseIcon;
+ return file.isValid() && file.is(VFileProperty.SYMLINK) ? new LayeredIcon(baseIcon, PlatformIcons.SYMLINK_ICON) : baseIcon;
}
public String getName(final VirtualFile file) {
diff --git a/platform/platform-api/src/com/intellij/openapi/fileChooser/FileElement.java b/platform/platform-api/src/com/intellij/openapi/fileChooser/FileElement.java
index 9ea2619..9a0cd32 100644
--- a/platform/platform-api/src/com/intellij/openapi/fileChooser/FileElement.java
+++ b/platform/platform-api/src/com/intellij/openapi/fileChooser/FileElement.java
@@ -17,7 +17,9 @@
import com.intellij.openapi.fileTypes.FileTypes;
import com.intellij.openapi.util.Comparing;
+import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.vfs.JarFileSystem;
+import com.intellij.openapi.vfs.VFileProperty;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -97,7 +99,10 @@
}
public static boolean isFileHidden(@Nullable VirtualFile file) {
- return file != null && file.isValid() && file.isInLocalFileSystem() && file.is(VirtualFile.PROP_HIDDEN);
+ return file != null &&
+ file.isValid() &&
+ file.isInLocalFileSystem() &&
+ (file.is(VFileProperty.HIDDEN) || SystemInfo.isUnix && file.getName().startsWith("."));
}
public static boolean isArchive(@Nullable VirtualFile file) {
diff --git a/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java b/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java
index bb4e680..873fce9 100644
--- a/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java
+++ b/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java
@@ -100,6 +100,8 @@
@NonNls public static final String FOCUSED_ACTION = "FocusedAction";
+ @NonNls private static final String NO_AUTORESIZE = "NoAutoResizeAndFit";
+
private static final KeyStroke SHOW_OPTION_KEYSTROKE = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,
InputEvent.ALT_MASK | InputEvent.SHIFT_MASK);
@@ -771,6 +773,18 @@
myPeer.toBack();
}
+ protected boolean setAutoAdjustable(boolean autoAdjustable) {
+ JRootPane rootPane = getRootPane();
+ if (rootPane == null) return false;
+ rootPane.putClientProperty(NO_AUTORESIZE, autoAdjustable? null : Boolean.TRUE);
+ return true;
+ }
+ //true by default
+ public boolean isAutoAdjustable() {
+ JRootPane rootPane = getRootPane();
+ return rootPane == null || rootPane.getClientProperty(NO_AUTORESIZE) == null;
+ }
+
/**
* Dispose the wrapped and releases all resources allocated be the wrapper to help
* more effecient garbage collection. You should never invoke this method twice or
@@ -793,7 +807,7 @@
// if rootPane = null, dialog has already been disposed
if (rootPane != null) {
unregisterKeyboardActions(rootPane);
- if (myActualSize != null) {
+ if (myActualSize != null && isAutoAdjustable()) {
setSize(myActualSize.width, myActualSize.height);
}
myPeer.dispose();
@@ -1102,7 +1116,7 @@
myErrorText = new ErrorText();
myErrorText.setVisible(false);
- final JPanel root = new JPanel(new BorderLayout());
+ final JPanel root = new JPanel(createRootLayout());
//{
// @Override
// public void paint(Graphics g) {
@@ -1168,6 +1182,10 @@
}
}
+ LayoutManager createRootLayout() {
+ return new BorderLayout();
+ }
+
private static void installEnterHook(JComponent root) {
new AnAction() {
@Override
@@ -1518,8 +1536,12 @@
menuSelectionManager.clearSelectedPath();
}
else {
+ if (ApplicationManager.getApplication() == null) {
+ doCancelAction(e);
+ return;
+ }
final StackingPopupDispatcher popupDispatcher = StackingPopupDispatcher.getInstance();
- if (ApplicationManager.getApplication() == null || popupDispatcher != null && !popupDispatcher.isPopupFocused()) {
+ if (popupDispatcher != null && !popupDispatcher.isPopupFocused()) {
doCancelAction(e);
}
}
diff --git a/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsComponent.java b/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsComponent.java
index 72acbaee..bce394b 100644
--- a/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsComponent.java
+++ b/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsComponent.java
@@ -28,6 +28,7 @@
import com.intellij.openapi.util.ActionCallback;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Condition;
+import com.intellij.openapi.util.Conditions;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.*;
import com.intellij.ui.navigation.History;
@@ -779,6 +780,10 @@
protected class MyDeleteAction extends AnAction implements DumbAware {
private final Condition<Object[]> myCondition;
+ public MyDeleteAction() {
+ this(Conditions.<Object[]>alwaysTrue());
+ }
+
public MyDeleteAction(Condition<Object[]> availableCondition) {
super(CommonBundle.message("button.delete"), CommonBundle.message("button.delete"), PlatformIcons.DELETE_ICON);
registerCustomShortcutSet(CommonShortcuts.DELETE, myTree);
diff --git a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java
index 16898ab..2de6e2b 100644
--- a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java
+++ b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java
@@ -18,17 +18,22 @@
import com.intellij.CommonBundle;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.openapi.wm.IdeFrame;
import com.intellij.openapi.wm.WindowManager;
import com.intellij.ui.*;
import com.intellij.ui.components.JBScrollPane;
import com.intellij.ui.mac.MacMessages;
+import com.intellij.ui.mac.foundation.MacUtil;
+import com.intellij.util.Alarm;
import com.intellij.util.Function;
import com.intellij.util.PairFunction;
import com.intellij.util.execution.ParametersListUtil;
@@ -41,11 +46,11 @@
import javax.swing.text.JTextComponent;
import javax.swing.text.html.HTMLEditorKit;
import java.awt.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
+import java.awt.event.*;
+import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
public class Messages {
public static final int OK = 0;
@@ -138,6 +143,10 @@
&& !DialogWrapper.isMultipleModalDialogs();
}
+ public static boolean isMacSheetEmulation() {
+ return SystemInfo.isMac && !Registry.is("ide.mac.message.dialogs.as.sheets");
+ }
+
public static int showDialog(Project project, String message, String title, String moreInfo, String[] options, int defaultOptionIndex, int focusedOptionIndex, Icon icon) {
if (isApplicationInUnitTestOrHeadless()) {
return ourTestImplementation.show(message);
@@ -944,6 +953,7 @@
protected int myDefaultOptionIndex;
protected int myFocusedOptionIndex;
protected Icon myIcon;
+ private MyBorderLayout myLayout;
public MessageDialog(@Nullable Project project, String message, String title, String[] options, int defaultOptionIndex, @Nullable Icon icon, boolean canBeParent) {
this(project, message, title, options, defaultOptionIndex, -1, icon, canBeParent);
@@ -1003,6 +1013,9 @@
protected void _init(String title, String message, String[] options, int defaultOptionIndex, int focusedOptionIndex, @Nullable Icon icon, @Nullable DoNotAskOption doNotAskOption) {
setTitle(title);
+ if (isMacSheetEmulation()) {
+ setUndecorated(true);
+ }
myMessage = message;
myOptions = options;
myDefaultOptionIndex = defaultOptionIndex;
@@ -1011,6 +1024,7 @@
setButtonsAlignment(SwingConstants.CENTER);
setDoNotAskOption(doNotAskOption);
init();
+ MacUtil.adjustFocusTraversal(myDisposable);
}
@NotNull
@@ -1061,6 +1075,90 @@
return doCreateCenterPanel();
}
+ @Override
+ LayoutManager createRootLayout() {
+ return isMacSheetEmulation() ? myLayout = new MyBorderLayout() : super.createRootLayout();
+ }
+
+ @Override
+ protected void dispose() {
+ if (isMacSheetEmulation()) {
+ animate();
+ } else {
+ super.dispose();
+ }
+ }
+
+ @Override
+ public void show() {
+ if (isMacSheetEmulation()) {
+ setInitialLocationCallback(new Computable<Point>() {
+ @Override
+ public Point compute() {
+ JRootPane rootPane = SwingUtilities.getRootPane(getWindow().getParent());
+ if (rootPane == null) {
+ rootPane = SwingUtilities.getRootPane(getWindow().getOwner());
+ }
+
+ Point p = rootPane.getLocationOnScreen();
+ p.x += (rootPane.getWidth() - getWindow().getWidth()) / 2;
+ return p;
+ }
+ });
+ animate();
+ if (SystemInfo.isJavaVersionAtLeast("1.7")) {
+ try {
+ Method method = Class.forName("java.awt.Window").getDeclaredMethod("setOpacity", float.class);
+ if (method != null) method.invoke(getPeer().getWindow(), .8f);
+ }
+ catch (Exception ignored) {
+ }
+ }
+ setAutoAdjustable(false);
+ setSize(getPreferredSize().width, 0);//initial state before animation, zero height
+ }
+ super.show();
+ }
+
+ private void animate() {
+ final int height = getPreferredSize().height;
+ final int frameCount = 10;
+ final boolean toClose = isShowing();
+
+
+ final AtomicInteger i = new AtomicInteger(-1);
+ final Alarm animator = new Alarm(myDisposable);
+ final Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ int state = i.addAndGet(1);
+
+ double linearProgress = (double)state / frameCount;
+ if (toClose) {
+ linearProgress = 1 - linearProgress;
+ }
+ myLayout.myPhase = (1 - Math.cos(Math.PI * linearProgress)) / 2;
+ Window window = getPeer().getWindow();
+ Rectangle bounds = window.getBounds();
+ bounds.height = (int)(height * myLayout.myPhase);
+
+ window.setBounds(bounds);
+
+ if (state == 0 && !toClose && window.getOwner() instanceof IdeFrame) {
+ WindowManager.getInstance().requestUserAttention((IdeFrame)window.getOwner(), true);
+ }
+
+ if (state < frameCount) {
+ animator.addRequest(this, 10);
+ }
+ else if (toClose) {
+ MessageDialog.super.dispose();
+ }
+ }
+ };
+ animator.addRequest(runnable, 10, ModalityState.stateForComponent(getRootPane()));
+ }
+
protected JComponent doCreateCenterPanel() {
JPanel panel = new JPanel(new BorderLayout(15, 0));
if (myIcon != null) {
@@ -1105,6 +1203,33 @@
}
}
+ private static class MyBorderLayout extends BorderLayout {
+ private double myPhase = 0;//it varies from 0 (hidden state) to 1 (fully visible)
+
+ private MyBorderLayout() {
+ }
+
+ @Override
+ public void layoutContainer(Container target) {
+ final Dimension realSize = target.getSize();
+ target.setSize(target.getPreferredSize());
+
+ super.layoutContainer(target);
+
+ target.setSize(realSize);
+
+ synchronized (target.getTreeLock()) {
+ int yShift = (int)((1 - myPhase) * target.getPreferredSize().height);
+ Component[] components = target.getComponents();
+ for (Component component : components) {
+ Point point = component.getLocation();
+ point.y -= yShift;
+ component.setLocation(point);
+ }
+ }
+ }
+ }
+
public static void installHyperlinkSupport(JTextPane messageComponent) {
configureMessagePaneUi(messageComponent, "<html></html>");
}
diff --git a/platform/platform-api/src/com/intellij/openapi/ui/popup/Balloon.java b/platform/platform-api/src/com/intellij/openapi/ui/popup/Balloon.java
index 15f24af..4b2752b 100644
--- a/platform/platform-api/src/com/intellij/openapi/ui/popup/Balloon.java
+++ b/platform/platform-api/src/com/intellij/openapi/ui/popup/Balloon.java
@@ -45,6 +45,7 @@
void addListener(JBPopupListener listener);
void hide();
+ void hide(boolean ok);
void setAnimationEnabled(boolean enabled);
diff --git a/platform/platform-api/src/com/intellij/openapi/util/process/InterruptibleActivity.java b/platform/platform-api/src/com/intellij/openapi/util/process/InterruptibleActivity.java
index 88055b4..05a895a 100644
--- a/platform/platform-api/src/com/intellij/openapi/util/process/InterruptibleActivity.java
+++ b/platform/platform-api/src/com/intellij/openapi/util/process/InterruptibleActivity.java
@@ -21,17 +21,13 @@
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.progress.ProgressManager;
import com.intellij.ui.GuiUtils;
+import com.intellij.util.concurrency.Semaphore;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
public abstract class InterruptibleActivity {
- private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.util.process.InterruptibleActivity");
-
private volatile boolean myIsTouched = true;
private final long myTimeout;
private final TimeUnit myTimeUnit;
@@ -45,12 +41,6 @@
myIsTouched = true;
}
- private boolean isTouched() {
- boolean touched = myIsTouched;
- myIsTouched = false;
- return touched;
- }
-
protected abstract void start();
protected abstract void interrupt();
@@ -64,13 +54,20 @@
LOG.assertTrue(!application.isDispatchThread(), "InterruptibleActivity is supposed to be lengthy thus must not block Swing UI thread");
*/
- final Future<?> future = application.executeOnPooledThread(new Runnable() {
+ final Semaphore semaphore = new Semaphore();
+ semaphore.down();
+ application.executeOnPooledThread(new Runnable() {
public void run() {
- start();
+ try {
+ start();
+ }
+ finally {
+ semaphore.up();
+ }
}
});
- final int rc = waitForFuture(future);
+ final int rc = waitForSemaphore(semaphore);
if (rc != 0) {
application.executeOnPooledThread(new Runnable() {
public void run() {
@@ -82,27 +79,28 @@
return rc;
}
- private int waitForFuture(final Future<?> future) {
+ private int waitForSemaphore(final Semaphore semaphore) {
+ long timeoutMs = myTimeUnit.toMillis(myTimeout);
+ long lastActiveMoment = System.currentTimeMillis();
while (true) {
- try {
- future.get(myTimeout, myTimeUnit);
- break;
+ long current = System.currentTimeMillis();
+ if (myIsTouched) {
+ myIsTouched = false;
+ lastActiveMoment = current;
}
- catch (InterruptedException e) {
- //LOG.error(e); // Shall not happen
+
+ long idleTime = current - lastActiveMoment;
+ if (idleTime > timeoutMs) {
+ int retCode = processTimeoutInEDT();
+ return semaphore.waitFor(0) ? 0 : retCode;
}
- catch (ExecutionException e) {
- throw new RuntimeException(e);
- }
- catch (TimeoutException e) {
- if (!isTouched()) {
- int retCode = processTimeoutInEDT();
- if (retCode != 0) return future.isDone() ? 0 : retCode;
- }
+
+ ProgressManager.checkCanceled();
+
+ if (semaphore.waitFor(Math.min(500, timeoutMs - idleTime))) {
+ return 0;
}
}
-
- return 0;
}
protected int processTimeoutInEDT() {
diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/VfsUtil.java b/platform/platform-api/src/com/intellij/openapi/vfs/VfsUtil.java
index 96f8bc3..148a7e9 100644
--- a/platform/platform-api/src/com/intellij/openapi/vfs/VfsUtil.java
+++ b/platform/platform-api/src/com/intellij/openapi/vfs/VfsUtil.java
@@ -75,7 +75,7 @@
@Nullable VirtualFileFilter filter) throws IOException {
@SuppressWarnings("UnsafeVfsRecursion") VirtualFile[] children = fromDir.getChildren();
for (VirtualFile child : children) {
- if (!child.isSymLink() && !child.is(VirtualFile.PROP_SPECIAL) && (filter == null || filter.accept(child))) {
+ if (!child.is(VFileProperty.SYMLINK) && !child.is(VFileProperty.SPECIAL) && (filter == null || filter.accept(child))) {
if (!child.isDirectory()) {
copyFile(requestor, child, toDir);
}
diff --git a/platform/platform-api/src/com/intellij/openapi/wm/WindowManager.java b/platform/platform-api/src/com/intellij/openapi/wm/WindowManager.java
index 74cc611..e4252f1 100644
--- a/platform/platform-api/src/com/intellij/openapi/wm/WindowManager.java
+++ b/platform/platform-api/src/com/intellij/openapi/wm/WindowManager.java
@@ -127,4 +127,6 @@
* @return <code>true</code> if full screen mode is supported in current OS.
*/
public abstract boolean isFullScreenSupportedInCurrentOS();
+
+ public abstract void requestUserAttention(@NotNull IdeFrame frame, boolean critical);
}
diff --git a/platform/platform-api/src/com/intellij/ui/AncestorListenerAdapter.java b/platform/platform-api/src/com/intellij/ui/AncestorListenerAdapter.java
new file mode 100644
index 0000000..604e70c
--- /dev/null
+++ b/platform/platform-api/src/com/intellij/ui/AncestorListenerAdapter.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2000-2013 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.ui;
+
+import javax.swing.event.AncestorEvent;
+import javax.swing.event.AncestorListener;
+
+public abstract class AncestorListenerAdapter implements AncestorListener {
+ @Override
+ public void ancestorAdded(AncestorEvent event) {
+ }
+
+ @Override
+ public void ancestorRemoved(AncestorEvent event) {
+ }
+
+ @Override
+ public void ancestorMoved(AncestorEvent event) {
+ }
+}
\ No newline at end of file
diff --git a/platform/platform-api/src/com/intellij/ui/CollectionListModel.java b/platform/platform-api/src/com/intellij/ui/CollectionListModel.java
index 5b00b17..1a6f024 100644
--- a/platform/platform-api/src/com/intellij/ui/CollectionListModel.java
+++ b/platform/platform-api/src/com/intellij/ui/CollectionListModel.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
diff --git a/platform/platform-api/src/com/intellij/ui/EnumComboBoxModel.java b/platform/platform-api/src/com/intellij/ui/EnumComboBoxModel.java
index ef70df6..1263d4f 100644
--- a/platform/platform-api/src/com/intellij/ui/EnumComboBoxModel.java
+++ b/platform/platform-api/src/com/intellij/ui/EnumComboBoxModel.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -13,9 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.intellij.ui;
+import org.jetbrains.annotations.NotNull;
+
import javax.swing.*;
import java.util.ArrayList;
import java.util.EnumSet;
@@ -25,27 +26,36 @@
* @author Dmitry Avdeev
*/
public class EnumComboBoxModel<E extends Enum<E>> extends AbstractListModel implements ComboBoxModel {
- private E mySelected = null;
private final List<E> myList;
+ private E mySelected = null;
- public EnumComboBoxModel(Class<E> en) {
+ public EnumComboBoxModel(@NotNull Class<E> en) {
myList = new ArrayList<E>(EnumSet.allOf(en));
mySelected = myList.get(0);
}
+ @Override
public int getSize() {
return myList.size();
}
+ @Override
public E getElementAt(int index) {
return myList.get(index);
}
+ @Override
public void setSelectedItem(Object item) {
- mySelected = (E)item;
+ @SuppressWarnings("unchecked") E e = (E)item;
+ setSelectedItem(e);
+ }
+
+ public void setSelectedItem(E item) {
+ mySelected = item;
fireContentsChanged(this, 0, getSize());
}
+ @Override
public E getSelectedItem() {
return mySelected;
}
diff --git a/platform/platform-api/src/com/intellij/ui/GuiUtils.java b/platform/platform-api/src/com/intellij/ui/GuiUtils.java
index 38ea15e..91e9fc2 100644
--- a/platform/platform-api/src/com/intellij/ui/GuiUtils.java
+++ b/platform/platform-api/src/com/intellij/ui/GuiUtils.java
@@ -336,10 +336,10 @@
final JLabel label = (JLabel)component;
@NonNls String text = label.getText();
if (text != null && text.startsWith("<html>")) {
- if (StringUtil.startsWithConcatenationOf(text, "<html>", changeColorString) && enabled) {
+ if (StringUtil.startsWithConcatenation(text, "<html>", changeColorString) && enabled) {
text = "<html>"+text.substring(("<html>"+changeColorString).length());
}
- else if (!StringUtil.startsWithConcatenationOf(text, "<html>", changeColorString) && !enabled) {
+ else if (!StringUtil.startsWithConcatenation(text, "<html>", changeColorString) && !enabled) {
text = "<html>"+changeColorString+text.substring("<html>".length());
}
label.setText(text);
diff --git a/platform/platform-api/src/com/intellij/ui/JBSplitter.java b/platform/platform-api/src/com/intellij/ui/JBSplitter.java
index d0f78df..f25c2ae 100644
--- a/platform/platform-api/src/com/intellij/ui/JBSplitter.java
+++ b/platform/platform-api/src/com/intellij/ui/JBSplitter.java
@@ -46,6 +46,10 @@
super(vertical, proportion);
}
+ public JBSplitter(float proportion) {
+ super(false, proportion);
+ }
+
public JBSplitter(boolean vertical, float proportion, float minProp, float maxProp) {
super(vertical, proportion, minProp, maxProp);
}
diff --git a/platform/platform-api/src/com/intellij/ui/components/JBLoadingPanel.java b/platform/platform-api/src/com/intellij/ui/components/JBLoadingPanel.java
index f46e9db..05bcf4a 100644
--- a/platform/platform-api/src/com/intellij/ui/components/JBLoadingPanel.java
+++ b/platform/platform-api/src/com/intellij/ui/components/JBLoadingPanel.java
@@ -38,9 +38,13 @@
private final Collection<JBLoadingPanelListener> myListeners = ContainerUtil.createLockFreeCopyOnWriteList();
public JBLoadingPanel(@Nullable LayoutManager manager, @NotNull Disposable parent) {
+ this(manager, parent, -1);
+ }
+
+ public JBLoadingPanel(@Nullable LayoutManager manager, @NotNull Disposable parent, int startDelayMs) {
super(new BorderLayout());
myPanel = manager == null ? new JPanel() : new JPanel(manager);
- myDecorator = new LoadingDecorator(myPanel, parent, -1) {
+ myDecorator = new LoadingDecorator(myPanel, parent, startDelayMs) {
@Override
protected NonOpaquePanel customizeLoadingLayer(JPanel parent, JLabel text, AsyncProcessIcon icon) {
final NonOpaquePanel panel = super.customizeLoadingLayer(parent, text, icon);
diff --git a/platform/platform-api/src/com/intellij/ui/components/panels/Wrapper.java b/platform/platform-api/src/com/intellij/ui/components/panels/Wrapper.java
index ac9d5a7..24eda54 100644
--- a/platform/platform-api/src/com/intellij/ui/components/panels/Wrapper.java
+++ b/platform/platform-api/src/com/intellij/ui/components/panels/Wrapper.java
@@ -70,10 +70,12 @@
validate();
}
+ @Override
public boolean isNull() {
return getComponentCount() == 0;
}
+ @Override
public void requestFocus() {
if (getTargetComponent() == this) {
super.requestFocus();
@@ -82,6 +84,7 @@
getTargetComponent().requestFocus();
}
+ @Override
public boolean requestFocusInWindow() {
if (getTargetComponent() == this) {
return super.requestFocusInWindow();
@@ -93,6 +96,7 @@
super.requestFocus();
}
+ @Override
public final boolean requestFocus(boolean temporary) {
if (getTargetComponent() == this) {
return super.requestFocus(temporary);
@@ -157,6 +161,7 @@
}
}
+ @Override
public void focusGained(final FocusEvent e) {
processCallback();
}
@@ -169,6 +174,7 @@
}
}
+ @Override
public void focusLost(final FocusEvent e) {
}
}
diff --git a/platform/platform-api/src/com/intellij/ui/content/ContentManager.java b/platform/platform-api/src/com/intellij/ui/content/ContentManager.java
index 2243be2..4a6dcbc 100644
--- a/platform/platform-api/src/com/intellij/ui/content/ContentManager.java
+++ b/platform/platform-api/src/com/intellij/ui/content/ContentManager.java
@@ -27,8 +27,6 @@
import java.util.List;
public interface ContentManager extends Disposable, BusyObject {
-
-
boolean canCloseContents();
@NotNull
diff --git a/platform/platform-api/src/com/intellij/ui/speedSearch/SpeedSearch.java b/platform/platform-api/src/com/intellij/ui/speedSearch/SpeedSearch.java
index 4749a48..1c4cd48 100644
--- a/platform/platform-api/src/com/intellij/ui/speedSearch/SpeedSearch.java
+++ b/platform/platform-api/src/com/intellij/ui/speedSearch/SpeedSearch.java
@@ -57,7 +57,7 @@
}
else {
final char ch = e.getKeyChar();
- if (Character.isLetterOrDigit(ch) || ch == ' ' || ch == '*' || ch == '_' || ch == '-') {
+ if (Character.isLetterOrDigit(ch) || ch == ' ' || ch == '*' || ch == '_' || ch == '-' || ch == '"' || ch == '\'') {
type(Character.toString(ch));
e.consume();
}
diff --git a/platform/platform-api/src/com/intellij/util/Alarm.java b/platform/platform-api/src/com/intellij/util/Alarm.java
index de50eb1..ba1c144 100644
--- a/platform/platform-api/src/com/intellij/util/Alarm.java
+++ b/platform/platform-api/src/com/intellij/util/Alarm.java
@@ -233,6 +233,12 @@
}
}
+ public boolean isEmpty() {
+ synchronized (LOCK) {
+ return myRequests.isEmpty();
+ }
+ }
+
protected boolean isEdt() {
return isEventDispatchThread();
}
diff --git a/platform/platform-api/src/com/intellij/util/PlatformUtils.java b/platform/platform-api/src/com/intellij/util/PlatformUtils.java
index d1c1b8b..36577d1 100644
--- a/platform/platform-api/src/com/intellij/util/PlatformUtils.java
+++ b/platform/platform-api/src/com/intellij/util/PlatformUtils.java
@@ -26,7 +26,6 @@
public static final String IDEA_PREFIX = "idea";
public static final String COMMUNITY_PREFIX = "Idea";
public static final String APPCODE_PREFIX = "AppCode";
- public static final String ANDROID_PREFIX = "AndroidStudio";
public static final String PYCHARM_PREFIX = "Python";
public static final String RUBY_PREFIX = "Ruby";
public static final String PHP_PREFIX = "PhpStorm";
diff --git a/platform/platform-api/src/com/intellij/util/io/ReadOnlyAttributeUtil.java b/platform/platform-api/src/com/intellij/util/io/ReadOnlyAttributeUtil.java
index 9529900..194cf34 100644
--- a/platform/platform-api/src/com/intellij/util/io/ReadOnlyAttributeUtil.java
+++ b/platform/platform-api/src/com/intellij/util/io/ReadOnlyAttributeUtil.java
@@ -17,7 +17,6 @@
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.openapi.vfs.newvfs.NewVirtualFile;
import java.io.IOException;
@@ -42,14 +41,7 @@
return;
}
- if (file instanceof NewVirtualFile) {
- ((NewVirtualFile)file).setWritable(!readOnlyStatus);
- }
- else {
- String path = file.getPresentableUrl();
- setReadOnlyAttribute(path, readOnlyStatus);
- file.refresh(false, false);
- }
+ file.setWritable(!readOnlyStatus);
}
public static void setReadOnlyAttribute(String path, boolean readOnlyStatus) throws IOException {
diff --git a/platform/platform-api/src/com/intellij/util/net/IOExceptionDialog.java b/platform/platform-api/src/com/intellij/util/net/IOExceptionDialog.java
index 1b544ac..4e0640e 100644
--- a/platform/platform-api/src/com/intellij/util/net/IOExceptionDialog.java
+++ b/platform/platform-api/src/com/intellij/util/net/IOExceptionDialog.java
@@ -34,7 +34,7 @@
private JButton cancelButton;
private JButton tryAgainButton;
private JButton setupButton;
- private JLabel errorLabel;
+ private JTextArea errorLabel;
private boolean cancelPressed = false;
public IOExceptionDialog(String title, String errorText) {
diff --git a/platform/platform-api/src/com/intellij/util/net/IOExceptionForm.form b/platform/platform-api/src/com/intellij/util/net/IOExceptionForm.form
index 846eecc..6ef45b8 100644
--- a/platform/platform-api/src/com/intellij/util/net/IOExceptionForm.form
+++ b/platform/platform-api/src/com/intellij/util/net/IOExceptionForm.form
@@ -41,11 +41,12 @@
</grid>
</constraints>
</vspacer>
- <component id="fe71b" class="javax.swing.JLabel" binding="errorLabel">
+ <component id="9afc2" class="javax.swing.JTextArea" binding="errorLabel">
<constraints>
- <grid row="0" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
+ <grid row="0" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
+ <editable value="false"/>
<text value="##"/>
</properties>
</component>
diff --git a/platform/platform-api/src/com/intellij/util/net/NetUtils.java b/platform/platform-api/src/com/intellij/util/net/NetUtils.java
index abfc320..2334770 100644
--- a/platform/platform-api/src/com/intellij/util/net/NetUtils.java
+++ b/platform/platform-api/src/com/intellij/util/net/NetUtils.java
@@ -57,7 +57,7 @@
}
}
- private static boolean isLocalhost(String host) {
+ public static boolean isLocalhost(String host) {
return host.equals("localhost") || host.equals("127.0.0.1");
}
@@ -84,7 +84,7 @@
}
}
- private static boolean canConnectToRemoteSocket(String host, int port) {
+ public static boolean canConnectToRemoteSocket(String host, int port) {
try {
Socket socket = new Socket(host, port);
socket.close();
diff --git a/platform/platform-api/src/com/intellij/util/ui/ButtonlessScrollBarUI.java b/platform/platform-api/src/com/intellij/util/ui/ButtonlessScrollBarUI.java
index 5a8d380..d0ceb66 100644
--- a/platform/platform-api/src/com/intellij/util/ui/ButtonlessScrollBarUI.java
+++ b/platform/platform-api/src/com/intellij/util/ui/ButtonlessScrollBarUI.java
@@ -22,6 +22,7 @@
import com.intellij.ui.LightColors;
import javax.swing.*;
+import javax.swing.event.ChangeEvent;
import javax.swing.plaf.basic.BasicScrollBarUI;
import java.awt.*;
import java.awt.event.*;
@@ -105,6 +106,18 @@
}
}
+ @Override
+ protected ModelListener createModelListener() {
+ return new ModelListener() {
+ @Override
+ public void stateChanged(ChangeEvent e) {
+ if (scrollbar != null) {
+ super.stateChanged(e);
+ }
+ }
+ };
+ }
+
public int getDecrementButtonHeight() {
return decrButton.getHeight();
}
diff --git a/platform/platform-api/src/com/intellij/util/ui/EditorAdapter.java b/platform/platform-api/src/com/intellij/util/ui/EditorAdapter.java
index 7080e95..9dd4dd0 100644
--- a/platform/platform-api/src/com/intellij/util/ui/EditorAdapter.java
+++ b/platform/platform-api/src/com/intellij/util/ui/EditorAdapter.java
@@ -92,7 +92,7 @@
myLines.add(new Line(string, attrs));
}
- if (myFlushAlarm.getActiveRequestCount() == 0) {
+ if (myFlushAlarm.isEmpty()) {
myFlushAlarm.addRequest(myFlushDeferredRunnable, 200, ModalityState.NON_MODAL);
}
}
diff --git a/platform/platform-api/src/com/intellij/util/ui/FormBuilder.java b/platform/platform-api/src/com/intellij/util/ui/FormBuilder.java
index bac8af1..aa48a37 100644
--- a/platform/platform-api/src/com/intellij/util/ui/FormBuilder.java
+++ b/platform/platform-api/src/com/intellij/util/ui/FormBuilder.java
@@ -42,7 +42,7 @@
private int myVerticalGap;
private int myHorizontalGap;
- private FormBuilder() {
+ public FormBuilder() {
myPanel = new JPanel(new GridBagLayout());
myVertical = false;
myIndent = 0;
@@ -185,7 +185,7 @@
return honorAlignment && myAlignLabelOnRight ? EAST : WEST;
}
- private static int getFill(JComponent component) {
+ protected int getFill(JComponent component) {
if (component instanceof JComboBox || component instanceof JSpinner) {
return NONE;
}
diff --git a/platform/platform-api/src/org/jetbrains/ide/CustomPortServerManager.java b/platform/platform-api/src/org/jetbrains/ide/CustomPortServerManager.java
index 25633b5..dc97a41 100644
--- a/platform/platform-api/src/org/jetbrains/ide/CustomPortServerManager.java
+++ b/platform/platform-api/src/org/jetbrains/ide/CustomPortServerManager.java
@@ -1,13 +1,27 @@
+/*
+ * Copyright 2000-2013 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 org.jetbrains.ide;
import com.intellij.openapi.extensions.ExtensionPointName;
-import org.jboss.netty.channel.ChannelException;
import org.jetbrains.annotations.Nullable;
public abstract class CustomPortServerManager {
public static final ExtensionPointName<CustomPortServerManager> EP_NAME = ExtensionPointName.create("com.intellij.customPortServerManager");
- public abstract void cannotBind(ChannelException e);
+ public abstract void cannotBind(Exception e, int port);
public interface CustomPortService {
boolean rebind();
@@ -17,5 +31,7 @@
public abstract int getPort();
+ public abstract boolean isAvailableExternally();
+
public abstract void setManager(@Nullable CustomPortService manager);
}
\ No newline at end of file
diff --git a/platform/platform-impl/src/com/intellij/designer/propertyTable/PropertyTable.java b/platform/platform-impl/src/com/intellij/designer/propertyTable/PropertyTable.java
index e19185a..acbfe63 100644
--- a/platform/platform-impl/src/com/intellij/designer/propertyTable/PropertyTable.java
+++ b/platform/platform-impl/src/com/intellij/designer/propertyTable/PropertyTable.java
@@ -861,15 +861,11 @@
message = "No message";
}
- Messages.showMessageDialog(formatErrorGettingValueMessage(message),
+ Messages.showMessageDialog(MessageFormat.format("Error setting value: {0}", message),
"Invalid Input",
Messages.getErrorIcon());
}
- private static String formatErrorGettingValueMessage(String message) {
- return MessageFormat.format("Error setting value: {0}", message);
- }
-
//////////////////////////////////////////////////////////////////////////////////////////
//
//
@@ -1324,7 +1320,7 @@
}
catch (Exception e) {
LOG.debug(e);
- renderer.append(formatErrorGettingValueMessage(e.getMessage()), SimpleTextAttributes.ERROR_ATTRIBUTES);
+ renderer.append(MessageFormat.format("Error getting value: {0}", e.getMessage()), SimpleTextAttributes.ERROR_ATTRIBUTES);
return renderer;
}
}
diff --git a/platform/platform-impl/src/com/intellij/diagnostic/DialogAppender.java b/platform/platform-impl/src/com/intellij/diagnostic/DialogAppender.java
index 3336766..891984f 100644
--- a/platform/platform-impl/src/com/intellij/diagnostic/DialogAppender.java
+++ b/platform/platform-impl/src/com/intellij/diagnostic/DialogAppender.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -15,6 +15,8 @@
*/
package com.intellij.diagnostic;
+import com.intellij.idea.IdeaApplication;
+import com.intellij.idea.Main;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.ErrorLogger;
@@ -22,7 +24,7 @@
import com.intellij.util.ExceptionUtil;
import com.intellij.util.containers.ContainerUtil;
import org.apache.log4j.AppenderSkeleton;
-import org.apache.log4j.Priority;
+import org.apache.log4j.Level;
import org.apache.log4j.spi.LoggingEvent;
import org.apache.log4j.spi.ThrowableInformation;
import org.jetbrains.annotations.NotNull;
@@ -37,7 +39,7 @@
* @author Mike
*/
public class DialogAppender extends AppenderSkeleton {
- private static final DefaultIdeaErrorLogger DEFAULT_LOGGER = new DefaultIdeaErrorLogger();
+ private static final ErrorLogger DEFAULT_LOGGER = new DefaultIdeaErrorLogger();
private static final int MAX_ASYNC_LOGGING_EVENTS = 5;
private volatile Runnable myDialogRunnable = null;
@@ -45,7 +47,11 @@
@Override
protected synchronized void append(@NotNull final LoggingEvent event) {
- if (!event.level.isGreaterOrEqual(Priority.ERROR)) return;
+ if (!event.getLevel().isGreaterOrEqual(Level.ERROR) ||
+ Main.isCommandLine() ||
+ !IdeaApplication.isLoaded()) {
+ return;
+ }
Runnable action = new Runnable() {
@Override
@@ -70,11 +76,11 @@
if (myPendingAppendCounts.addAndGet(1) > MAX_ASYNC_LOGGING_EVENTS) {
// Stop adding requests to the queue or we can get OOME on pending logging requests (IDEA-95327)
- // Note, we MUST avoid SYNCHRONOUS invokeAndWait to prevent deadlocks
- // UIUtil.invokeAndWaitIfNeeded(action);
-
myPendingAppendCounts.decrementAndGet(); // number of pending logging events should not increase
- } else {
+ }
+ else {
+ // Note, we MUST avoid SYNCHRONOUS invokeAndWait to prevent deadlocks
+ //noinspection SSBasedInspection
SwingUtilities.invokeLater(action);
}
}
diff --git a/platform/platform-impl/src/com/intellij/diagnostic/IdeErrorsDialog.java b/platform/platform-impl/src/com/intellij/diagnostic/IdeErrorsDialog.java
index 5176741..3349d4b 100644
--- a/platform/platform-impl/src/com/intellij/diagnostic/IdeErrorsDialog.java
+++ b/platform/platform-impl/src/com/intellij/diagnostic/IdeErrorsDialog.java
@@ -1000,11 +1000,6 @@
}
ErrorReportSubmitter submitter = null;
for (ErrorReportSubmitter reporter : reporters) {
- /** Android Studio: Always use the android error reporter */
- String canonicalName = reporter.getClass().getCanonicalName();
- if (canonicalName != null && canonicalName.contains("android")) {
- return reporter;
- }
final PluginDescriptor descriptor = reporter.getPluginDescriptor();
if (pluginId == null && (descriptor == null || PluginId.getId("com.intellij") == descriptor.getPluginId())
|| descriptor != null && Comparing.equal(pluginId, descriptor.getPluginId())) {
diff --git a/platform/platform-impl/src/com/intellij/diagnostic/errordialog/LabeledTextComponent.java b/platform/platform-impl/src/com/intellij/diagnostic/errordialog/LabeledTextComponent.java
index de26a61..b829d70 100644
--- a/platform/platform-impl/src/com/intellij/diagnostic/errordialog/LabeledTextComponent.java
+++ b/platform/platform-impl/src/com/intellij/diagnostic/errordialog/LabeledTextComponent.java
@@ -8,6 +8,7 @@
import javax.swing.*;
import javax.swing.event.DocumentEvent;
+import javax.swing.text.JTextComponent;
import java.awt.*;
/**
@@ -21,10 +22,10 @@
private LabeledComponent<JPanel> myComponent;
private JPanel myContentPane;
- private final JTextPane myTextPane;
+ private final JTextArea myTextPane;
public LabeledTextComponent() {
- myTextPane = new JTextPane();
+ myTextPane = new JTextArea();
myComponent.getLabel().setMinimumSize(new Dimension(0, -1));
myComponent.getComponent().setLayout(new BorderLayout());
@@ -41,11 +42,11 @@
return myContentPane;
}
- public JTextPane getTextComponent() {
+ public JTextArea getTextComponent() {
return myTextPane;
}
- static void setText(JTextPane pane, String text, boolean caretToTheEnd) {
+ static void setText(JTextComponent pane, String text, boolean caretToTheEnd) {
pane.setText(text);
if (text != null && !caretToTheEnd && pane.getCaret() != null) {
// Upon some strange circumstances caret may be missing from the text component making the following line fail with NPE.
diff --git a/platform/platform-impl/src/com/intellij/help/impl/MacHelpUtil.java b/platform/platform-impl/src/com/intellij/help/impl/MacHelpUtil.java
index 66ed9bc..cfbe60e 100644
--- a/platform/platform-impl/src/com/intellij/help/impl/MacHelpUtil.java
+++ b/platform/platform-impl/src/com/intellij/help/impl/MacHelpUtil.java
@@ -21,13 +21,14 @@
import com.intellij.ui.mac.foundation.ID;
import com.intellij.util.PlatformUtils;
import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.Nullable;
/**
* @author Dennis.Ushakov
*/
public class MacHelpUtil {
- static boolean invokeHelp(@NonNls String id) {
- id = "top".equals(id) ? "startpage" : id;
+ static boolean invokeHelp(@NonNls @Nullable String id) {
+ id = id == null || "top".equals(id) ? "startpage" : id;
final ID mainBundle = Foundation.invoke("NSBundle", "mainBundle");
final ID helpBundle = Foundation.invoke(mainBundle, "objectForInfoDictionaryKey:", Foundation.nsString("CFBundleHelpBookName"));
diff --git a/platform/platform-impl/src/com/intellij/ide/ApplicationLoadListener.java b/platform/platform-impl/src/com/intellij/ide/ApplicationLoadListener.java
index c91b306..4f53da0 100644
--- a/platform/platform-impl/src/com/intellij/ide/ApplicationLoadListener.java
+++ b/platform/platform-impl/src/com/intellij/ide/ApplicationLoadListener.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -17,7 +17,8 @@
import com.intellij.openapi.application.Application;
-
public interface ApplicationLoadListener {
+ String EP_NAME = "com.intellij.ApplicationLoadListener";
+
void beforeApplicationLoaded(Application application);
}
diff --git a/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java b/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java
index c210214..64350d7 100644
--- a/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java
+++ b/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java
@@ -15,11 +15,12 @@
*/
package com.intellij.ide;
-
import com.intellij.Patches;
import com.intellij.ide.dnd.DnDManager;
import com.intellij.ide.dnd.DnDManagerImpl;
+import com.intellij.ide.plugins.PluginManager;
import com.intellij.ide.ui.UISettings;
+import com.intellij.idea.IdeaApplication;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
@@ -31,7 +32,6 @@
import com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher;
import com.intellij.openapi.keymap.impl.IdeMouseEventDispatcher;
import com.intellij.openapi.keymap.impl.KeyState;
-import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.ExpirableRunnable;
@@ -53,17 +53,14 @@
import java.awt.event.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.*;
import java.util.List;
-
/**
* @author Vladimir Kondratyev
* @author Anton Katilin
*/
-
public class IdeEventQueue extends EventQueue {
private static final Logger LOG = Logger.getInstance("#com.intellij.ide.IdeEventQueue");
@@ -319,27 +316,20 @@
myEventCount = evCount;
}
-
public AWTEvent getTrueCurrentEvent() {
return myCurrentEvent;
}
@Override
public void dispatchEvent(AWTEvent e) {
- if (SystemInfo.isXWindow && e instanceof MouseEvent && ((MouseEvent)e).getButton() > 3) {
- MouseEvent src = (MouseEvent)e;
- if (src.getButton() < 6) {//Convert these events(buttons 4&5 in are produced by touchpad, they must be converted to horizontal scrolling events
- e = new MouseWheelEvent(src.getComponent(), src.getID(), src.getWhen(),
- src.getModifiers() | InputEvent.SHIFT_DOWN_MASK, src.getX(), src.getY(),
- 0, false, MouseWheelEvent.WHEEL_UNIT_SCROLL, src.getClickCount(), src.getButton() == 4 ? -1 : 1);
- }
- else {
- //Here we "shift" events with buttons 6 and 7 to similar events with buttons 4 and 5
- //See java.awt.InputEvent#BUTTON_DOWN_MASK, 1<<14 is 4th physical button, 1<<15 is 5th.
- e = new MouseEvent(src.getComponent(), src.getID(), src.getWhen(), src.getModifiers() | (1 << 8 + src.getButton()),
- src.getX(), src.getY(), 1, src.isPopupTrigger(), src.getButton() - 2);
- }
+ if (e instanceof InputEvent && !IdeaApplication.isLoaded()) {
+ // input event processing requires application components to be instantiated
+ ((InputEvent)e).consume();
+ return;
}
+
+ e = mapEvent(e);
+
boolean wasInputEvent = myIsInInputEvent;
myIsInInputEvent = e instanceof InputEvent || e instanceof InputMethodEvent || e instanceof WindowEvent || e instanceof ActionEvent;
AWTEvent oldEvent = myCurrentEvent;
@@ -348,12 +338,9 @@
try {
_dispatchEvent(e, false);
}
- catch (ProcessCanceledException pce) {
- throw pce;
- }
- catch (Throwable exc) {
- if (!myToolkitBugsProcessor.process(exc)) {
- LOG.error("Error during dispatching of " + e, exc);
+ catch (Throwable t) {
+ if (!myToolkitBugsProcessor.process(t)) {
+ PluginManager.processException(t);
}
}
finally {
@@ -370,25 +357,26 @@
}
}
- @SuppressWarnings({"ALL"})
- private static String toDebugString(final AWTEvent e) {
- if (e instanceof InvocationEvent) {
- try {
- final Field f = InvocationEvent.class.getDeclaredField("runnable");
- f.setAccessible(true);
- Object runnable = f.get(e);
-
- return "Invoke Later[" + runnable.toString() + "]";
+ private static AWTEvent mapEvent(AWTEvent e) {
+ if (SystemInfo.isXWindow && e instanceof MouseEvent && ((MouseEvent)e).getButton() > 3) {
+ MouseEvent src = (MouseEvent)e;
+ if (src.getButton() < 6) {
+ // Convert these events(buttons 4&5 in are produced by touchpad, they must be converted to horizontal scrolling events
+ e = new MouseWheelEvent(src.getComponent(), src.getID(), src.getWhen(),
+ src.getModifiers() | InputEvent.SHIFT_DOWN_MASK, src.getX(), src.getY(),
+ 0, false, MouseWheelEvent.WHEEL_UNIT_SCROLL, src.getClickCount(), src.getButton() == 4 ? -1 : 1);
}
- catch (NoSuchFieldException e1) {
- }
- catch (IllegalAccessException e1) {
+ else {
+ // Here we "shift" events with buttons 6 and 7 to similar events with buttons 4 and 5
+ // See java.awt.InputEvent#BUTTON_DOWN_MASK, 1<<14 is 4th physical button, 1<<15 is 5th.
+ //noinspection MagicConstant
+ e = new MouseEvent(src.getComponent(), src.getID(), src.getWhen(), src.getModifiers() | (1 << 8 + src.getButton()),
+ src.getX(), src.getY(), 1, src.isPopupTrigger(), src.getButton() - 2);
}
}
- return e.toString();
+ return e;
}
-
public void _dispatchEvent(@NotNull AWTEvent e, boolean typeAheadFlushing) {
if (e.getID() == MouseEvent.MOUSE_DRAGGED) {
DnDManagerImpl dndManager = (DnDManagerImpl)DnDManager.getInstance();
@@ -668,22 +656,20 @@
}
private static boolean processAppActivationEvents(AWTEvent e) {
- final Application app = ApplicationManager.getApplication();
+ Application app = ApplicationManager.getApplication();
if (!(app instanceof ApplicationImpl)) return false;
-
ApplicationImpl appImpl = (ApplicationImpl)app;
- boolean consumed = false;
if (e instanceof WindowEvent) {
WindowEvent we = (WindowEvent)e;
if (we.getID() == WindowEvent.WINDOW_GAINED_FOCUS && we.getWindow() != null) {
if (we.getOppositeWindow() == null && !appImpl.isActive()) {
- consumed = appImpl.tryToApplyActivationState(true, we.getWindow());
+ appImpl.tryToApplyActivationState(true, we.getWindow());
}
}
else if (we.getID() == WindowEvent.WINDOW_LOST_FOCUS && we.getWindow() != null) {
if (we.getOppositeWindow() == null && appImpl.isActive()) {
- consumed = appImpl.tryToApplyActivationState(false, we.getWindow());
+ appImpl.tryToApplyActivationState(false, we.getWindow());
}
}
}
@@ -691,7 +677,6 @@
return false;
}
-
private void defaultDispatchEvent(final AWTEvent e) {
try {
myDispatchingFocusEvent = e instanceof FocusEvent;
@@ -700,14 +685,12 @@
super.dispatchEvent(e);
}
- catch (ProcessCanceledException pce) {
- throw pce;
- }
- catch (Throwable exc) {
- if (!myToolkitBugsProcessor.process(exc)) {
- LOG.error("Error during dispatching of " + e, exc);
+ catch (Throwable t) {
+ if (!myToolkitBugsProcessor.process(t)) {
+ PluginManager.processException(t);
}
- } finally {
+ }
+ finally {
myDispatchingFocusEvent = false;
}
}
@@ -963,7 +946,7 @@
});
}
- private final FrequentEventDetector myFrequentEventDetector = new FrequentEventDetector(1000, 100);
+ private final FrequentEventDetector myFrequentEventDetector = new FrequentEventDetector(1009, 100);
@Override
public void postEvent(AWTEvent theEvent) {
myFrequentEventDetector.eventHappened();
diff --git a/platform/platform-impl/src/com/intellij/ide/RecentProjectsManagerBase.java b/platform/platform-impl/src/com/intellij/ide/RecentProjectsManagerBase.java
index 26ece19..e434cf2 100644
--- a/platform/platform-impl/src/com/intellij/ide/RecentProjectsManagerBase.java
+++ b/platform/platform-impl/src/com/intellij/ide/RecentProjectsManagerBase.java
@@ -202,7 +202,13 @@
if (StringUtil.isEmptyOrSpaces(displayName)) {
displayName = duplicates.contains(path) ? path : projectName;
}
- actions.add(new ReopenProjectAction(path, projectName, displayName));
+
+ // It's better don't to remove non-existent projects. Sometimes projects stored
+ // on USB-sticks or flash-cards, and it will be nice to have them in the list
+ // when USB device or SD-card is mounted
+ if (new File(path).exists()) {
+ actions.add(new ReopenProjectAction(path, projectName, displayName));
+ }
}
if (actions.isEmpty()) {
diff --git a/platform/platform-impl/src/com/intellij/ide/SaveAndSyncHandlerImpl.java b/platform/platform-impl/src/com/intellij/ide/SaveAndSyncHandlerImpl.java
index 80a6b1a..1cec7a4 100644
--- a/platform/platform-impl/src/com/intellij/ide/SaveAndSyncHandlerImpl.java
+++ b/platform/platform-impl/src/com/intellij/ide/SaveAndSyncHandlerImpl.java
@@ -32,6 +32,7 @@
import com.intellij.openapi.vfs.newvfs.ManagingFS;
import com.intellij.openapi.vfs.newvfs.NewVirtualFile;
import com.intellij.openapi.vfs.newvfs.RefreshQueue;
+import com.intellij.openapi.vfs.newvfs.RefreshSession;
import com.intellij.util.Alarm;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
@@ -56,6 +57,8 @@
private final AtomicInteger myBlockSyncOnFrameActivationCount = new AtomicInteger();
private final Alarm myRefreshDelayAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD);
+ private long myRefreshSessionId = 0;
+
public static SaveAndSyncHandlerImpl getInstance(){
return (SaveAndSyncHandlerImpl) ApplicationManager.getApplication().getComponent(SaveAndSyncHandler.class);
}
@@ -168,7 +171,6 @@
if (canSyncOrSave()) {
refreshOpenFiles();
}
-
maybeRefresh(ModalityState.NON_MODAL);
}
}, 300, ModalityState.NON_MODAL);
@@ -178,7 +180,15 @@
public void maybeRefresh(@NotNull ModalityState modalityState) {
if (myBlockSyncOnFrameActivationCount.get() == 0) {
LOG.debug("VFS refresh started");
- RefreshQueue.getInstance().refresh(true, true, null, modalityState, ManagingFS.getInstance().getLocalRoots());
+
+ RefreshQueue queue = RefreshQueue.getInstance();
+ queue.cancelSession(myRefreshSessionId);
+
+ RefreshSession session = queue.createSession(true, true, null, modalityState);
+ session.addAllFiles(ManagingFS.getInstance().getLocalRoots());
+ myRefreshSessionId = session.getId();
+ session.launch();
+
LOG.debug("VFS refresh finished");
}
}
diff --git a/platform/platform-impl/src/com/intellij/ide/ToolkitBugsProcessor.java b/platform/platform-impl/src/com/intellij/ide/ToolkitBugsProcessor.java
index 5bb3cb4..58eb699 100644
--- a/platform/platform-impl/src/com/intellij/ide/ToolkitBugsProcessor.java
+++ b/platform/platform-impl/src/com/intellij/ide/ToolkitBugsProcessor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -19,22 +19,21 @@
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.util.BitUtil;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;
public class ToolkitBugsProcessor {
-
private static final Logger LOG = Logger.getInstance("ToolkitBugProcessor");
- List<Handler> myHandlers = new ArrayList<Handler>();
+ private final List<Handler> myHandlers = new ArrayList<Handler>();
public ToolkitBugsProcessor() {
Class<?>[] classes = getClass().getDeclaredClasses();
for (Class<?> each : classes) {
- if ((each.getModifiers() & Modifier.ABSTRACT) > 0) continue;
- if (Handler.class.isAssignableFrom(each)) {
+ if (!BitUtil.isSet(each.getModifiers(), Modifier.ABSTRACT) && Handler.class.isAssignableFrom(each)) {
try {
Handler eachHandler = (Handler)each.newInstance();
if (eachHandler.isActual()) {
@@ -43,7 +42,6 @@
}
catch (Throwable e) {
LOG.error(e);
- continue;
}
}
}
@@ -63,8 +61,7 @@
}
- abstract static class Handler {
-
+ private abstract static class Handler {
private final String myDetails;
protected Handler() {
@@ -75,9 +72,9 @@
myDetails = details;
}
- abstract boolean process(Throwable e, StackTraceElement[] stack);
+ public abstract boolean process(Throwable e, StackTraceElement[] stack);
- boolean isActual() {
+ public boolean isActual() {
return true;
}
@@ -97,8 +94,9 @@
}
}
- static class Sun_6857057 extends Handler {
- Sun_6857057() {
+ @SuppressWarnings("UnusedDeclaration")
+ private static class Sun_6857057 extends Handler {
+ public Sun_6857057() {
super("text editor component - sync between model and view while dnd operations");
}
@@ -114,13 +112,14 @@
}
}
- static class Sun_6785663 extends Handler {
- Sun_6785663() {
- super("Numbus L&F problem -- update style");
+ @SuppressWarnings("UnusedDeclaration")
+ private static class Sun_6785663 extends Handler {
+ public Sun_6785663() {
+ super("Nimbus L&F problem -- update style");
}
@Override
- boolean process(Throwable e, StackTraceElement[] stack) {
+ public boolean process(Throwable e, StackTraceElement[] stack) {
if (e instanceof ClassCastException && stack.length > 1) {
return stack[0].getClassName().equals("javax.swing.plaf.synth.SynthButtonUI")
&& stack[0].getMethodName().equals("updateStyle");
@@ -129,13 +128,14 @@
}
}
- static class Tricky_JEditorPane_registerEditorKitForContentType_NPE extends Handler {
- Tricky_JEditorPane_registerEditorKitForContentType_NPE() {
+ @SuppressWarnings("UnusedDeclaration")
+ private static class Tricky_JEditorPane_registerEditorKitForContentType_NPE extends Handler {
+ public Tricky_JEditorPane_registerEditorKitForContentType_NPE() {
super("http://ea.jetbrains.com/browser/ea_problems/13587 - JEditorPane_registerEditorKitForContentType_NPE");
}
@Override
- boolean process(Throwable e, StackTraceElement[] stack) {
+ public boolean process(Throwable e, StackTraceElement[] stack) {
if (e instanceof NullPointerException && stack.length > 3) {
//bombed for possible future fix
if (SystemInfo.isJavaVersionAtLeast("1.7")) return false;
@@ -144,21 +144,22 @@
&& stack[0].getMethodName().equals("put")
&& stack[3].getClassName().equals("javax.swing.JEditorPane")
&& stack[3].getMethodName().equals("loadDefaultKitsIfNecessary");
-
}
return false;
}
}
- static class Apple_ExceptionOnChangingMonitors extends Handler {
+ @SuppressWarnings("UnusedDeclaration")
+ private static class Apple_ExceptionOnChangingMonitors extends Handler {
+ public Apple_ExceptionOnChangingMonitors() { }
@Override
- boolean isActual() {
+ public boolean isActual() {
return SystemInfo.isMac;
}
@Override
- boolean process(Throwable e, StackTraceElement[] stack) {
+ public boolean process(Throwable e, StackTraceElement[] stack) {
if (e instanceof ArrayIndexOutOfBoundsException && stack.length > 1) {
return stack[0].getClassName().equals("apple.awt.CWindow")
&& stack[0].getMethodName().equals("displayChanged");
@@ -173,19 +174,19 @@
}
}
- static class Apple_CAccessible_NPE extends Handler {
-
- Apple_CAccessible_NPE() {
+ @SuppressWarnings("UnusedDeclaration")
+ private static class Apple_CAccessible_NPE extends Handler {
+ public Apple_CAccessible_NPE() {
super("apple.awt.CAccessible.getAccessibleContext(CAccessible.java:74)");
}
@Override
- boolean isActual() {
+ public boolean isActual() {
return SystemInfo.isMac;
}
@Override
- boolean process(Throwable e, StackTraceElement[] stack) {
+ public boolean process(Throwable e, StackTraceElement[] stack) {
if (e instanceof NullPointerException && stack.length > 1) {
return stack[0].getClassName().equals("apple.awt.CAccessible") && stack[0].getMethodName().equals("getAccessibleContext");
}
diff --git a/platform/platform-impl/src/com/intellij/ide/actions/ChooseComponentsToExportDialog.java b/platform/platform-impl/src/com/intellij/ide/actions/ChooseComponentsToExportDialog.java
index 6f12cf6..356ad8f 100644
--- a/platform/platform-impl/src/com/intellij/ide/actions/ChooseComponentsToExportDialog.java
+++ b/platform/platform-impl/src/com/intellij/ide/actions/ChooseComponentsToExportDialog.java
@@ -32,6 +32,7 @@
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.FieldPanel;
import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
@@ -112,6 +113,30 @@
setOKActionEnabled(!StringUtil.isEmptyOrSpaces(myPathPanel.getText()));
}
+ @NotNull
+ @Override
+ protected Action[] createLeftSideActions() {
+ AbstractAction selectAll = new AbstractAction("Select &All") {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ myChooser.setAllElementsMarked(true);
+ }
+ };
+ AbstractAction selectNone = new AbstractAction("Select &None") {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ myChooser.setAllElementsMarked(false);
+ }
+ };
+ AbstractAction invert = new AbstractAction("&Invert") {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ myChooser.invertSelection();
+ }
+ };
+ return new Action[]{selectAll, selectNone, invert};
+ }
+
@Override
protected void doOKAction() {
PropertiesComponent.getInstance().setValue("export.settings.path", myPathPanel.getText());
diff --git a/platform/platform-impl/src/com/intellij/ide/actions/CloseProjectAction.java b/platform/platform-impl/src/com/intellij/ide/actions/CloseProjectAction.java
index 93ce95b..ecbc0f9 100644
--- a/platform/platform-impl/src/com/intellij/ide/actions/CloseProjectAction.java
+++ b/platform/platform-impl/src/com/intellij/ide/actions/CloseProjectAction.java
@@ -42,7 +42,7 @@
Project project = event.getData(PlatformDataKeys.PROJECT);
presentation.setEnabled(project != null);
if (ProjectAttachProcessor.canAttachToProject() && project != null && ModuleManager.getInstance(project).getModules().length > 1) {
- presentation.setText("Close Proj_ects in Current Window");
+ presentation.setText("Close Pro_jects in Current Window");
}
else {
presentation.setText("Close Pro_ject");
diff --git a/platform/platform-impl/src/com/intellij/ide/actions/CreateDesktopEntryAction.java b/platform/platform-impl/src/com/intellij/ide/actions/CreateDesktopEntryAction.java
index 48b9698..c84f7e2 100644
--- a/platform/platform-impl/src/com/intellij/ide/actions/CreateDesktopEntryAction.java
+++ b/platform/platform-impl/src/com/intellij/ide/actions/CreateDesktopEntryAction.java
@@ -198,10 +198,6 @@
execPath = binPath + '/' + productName.toLowerCase() + ".sh";
if (new File(execPath).canExecute()) return execPath;
- final String scriptName = ApplicationNamesInfo.getInstance().getScriptName();
- String scriptPath = binPath + '/' + scriptName + ".sh";
- if (new File(scriptPath).canExecute()) return scriptPath;
-
return null;
}
diff --git a/platform/platform-impl/src/com/intellij/ide/actions/ExportSettingsAction.java b/platform/platform-impl/src/com/intellij/ide/actions/ExportSettingsAction.java
index 1eb8dbd..5dcf70e 100644
--- a/platform/platform-impl/src/com/intellij/ide/actions/ExportSettingsAction.java
+++ b/platform/platform-impl/src/com/intellij/ide/actions/ExportSettingsAction.java
@@ -29,7 +29,6 @@
import com.intellij.openapi.components.ExportableApplicationComponent;
import com.intellij.openapi.components.ExportableComponent;
import com.intellij.openapi.components.ServiceBean;
-import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
@@ -45,7 +44,6 @@
import java.util.jar.JarOutputStream;
public class ExportSettingsAction extends AnAction implements DumbAware {
- private static final Logger LOG = Logger.getInstance("#com.intellij.ide.actions.ExportSettingsAction");
public void actionPerformed(AnActionEvent e) {
Project project = getEventProject(e);
diff --git a/platform/platform-impl/src/com/intellij/ide/actions/InvalidateCachesAction.java b/platform/platform-impl/src/com/intellij/ide/actions/InvalidateCachesAction.java
index 5538420..6066191 100644
--- a/platform/platform-impl/src/com/intellij/ide/actions/InvalidateCachesAction.java
+++ b/platform/platform-impl/src/com/intellij/ide/actions/InvalidateCachesAction.java
@@ -18,33 +18,51 @@
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
-import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ex.ApplicationEx;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.vfs.newvfs.persistent.FSRecords;
public class InvalidateCachesAction extends AnAction implements DumbAware {
+
+ @Override
+ public void update(AnActionEvent e) {
+ super.update(e);
+ e.getPresentation().setText(ApplicationManager.getApplication().isRestartCapable() ? "Invalidate Caches / Restart..." : "Invalidate Caches...");
+ }
+
public void actionPerformed(AnActionEvent e) {
- final Application app = ApplicationManager.getApplication();
+ final ApplicationEx app = (ApplicationEx)ApplicationManager.getApplication();
final boolean mac = Messages.canShowMacSheetPanel();
- String[] options = new String[3];
- options[0] = app.isRestartCapable() ? "Invalidate and Restart" : "Invalidate and Exit";
+ boolean canRestart = app.isRestartCapable();
+
+ String[] options = new String[canRestart ? 4 : 3];
+ options[0] = canRestart ? "Invalidate and Restart" : "Invalidate and Exit";
options[1] = mac ? "Cancel" : "Invalidate";
options[2] = mac ? "Invalidate" : "Cancel";
+ if (canRestart) {
+ options[3] = "Just Restart";
+ }
- int result = Messages.showYesNoCancelDialog(e.getData(PlatformDataKeys.PROJECT),
+ int result = Messages.showDialog(e.getData(PlatformDataKeys.PROJECT),
"The caches will be invalidated and rebuilt on the next startup.\n" +
"WARNING: Local History will be also cleared.\n\n" +
"Would you like to continue?\n\n",
"Invalidate Caches",
- options[0], options[1], options[2],
+ options, 0,
Messages.getWarningIcon());
if (result == -1 || result == (mac ? 1 : 2)) {
return;
}
+
+ if (result == 3) {
+ app.restart(true);
+ return;
+ }
+
FSRecords.invalidateCaches();
- if (result == 0) app.restart();
+ if (result == 0) app.restart(true);
}
}
diff --git a/platform/platform-impl/src/com/intellij/ide/actions/SendFeedbackAction.java b/platform/platform-impl/src/com/intellij/ide/actions/SendFeedbackAction.java
index 4f4e5ab..c1e32c6 100644
--- a/platform/platform-impl/src/com/intellij/ide/actions/SendFeedbackAction.java
+++ b/platform/platform-impl/src/com/intellij/ide/actions/SendFeedbackAction.java
@@ -40,7 +40,6 @@
urlTemplate = urlTemplate
.replace("$BUILD", appInfo.getBuild().asString())
.replace("$TIMEZONE", System.getProperty("user.timezone"))
- .replace("$VERSION", appInfo.getFullVersion())
.replace("$EVAL", isEvaluationLicense() ? "true" : "false");
BrowserUtil.launchBrowser(urlTemplate);
}
diff --git a/platform/platform-impl/src/com/intellij/ide/actions/ShowRecentlyEditedFilesAction.java b/platform/platform-impl/src/com/intellij/ide/actions/ShowRecentlyEditedFilesAction.java
index c7bc52c..faa2c6d 100644
--- a/platform/platform-impl/src/com/intellij/ide/actions/ShowRecentlyEditedFilesAction.java
+++ b/platform/platform-impl/src/com/intellij/ide/actions/ShowRecentlyEditedFilesAction.java
@@ -19,6 +19,7 @@
*/
package com.intellij.ide.actions;
+import com.intellij.openapi.actionSystem.IdeActions;
import com.intellij.openapi.fileEditor.ex.IdeDocumentHistory;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
@@ -30,7 +31,7 @@
@Override
protected String getPeerActionId() {
- return "RecentFiles";
+ return IdeActions.ACTION_RECENT_FILES;
}
protected String getTitle() {
diff --git a/platform/platform-impl/src/com/intellij/ide/actions/Switcher.java b/platform/platform-impl/src/com/intellij/ide/actions/Switcher.java
index e606893..674ca68 100644
--- a/platform/platform-impl/src/com/intellij/ide/actions/Switcher.java
+++ b/platform/platform-impl/src/com/intellij/ide/actions/Switcher.java
@@ -28,6 +28,7 @@
import com.intellij.openapi.fileEditor.UniqueVFilePathBuilder;
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx;
import com.intellij.openapi.fileEditor.impl.EditorHistoryManager;
+import com.intellij.openapi.fileEditor.impl.EditorTabbedContainer;
import com.intellij.openapi.fileEditor.impl.EditorWindow;
import com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl;
import com.intellij.openapi.project.DumbAware;
@@ -218,7 +219,7 @@
}
};
- @SuppressWarnings({"ManualArrayToCollectionCopy"})
+ @SuppressWarnings({"ManualArrayToCollectionCopy", "ConstantConditions"})
SwitcherPanel(final Project project, String title, boolean pinned) {
setLayout(new SwitcherLayouter());
this.project = project;
@@ -229,11 +230,11 @@
setFocusable(true);
addKeyListener(this);
setBorder(new EmptyBorder(0, 0, 0, 0));
- setBackground(Color.WHITE);
+ setBackground(JBColor.background());
pathLabel.setHorizontalAlignment(SwingConstants.LEFT);
final Font font = pathLabel.getFont();
- pathLabel.setFont(font.deriveFont((float)10));
+ pathLabel.setFont(font.deriveFont(Math.max(10f, font.getSize() - 4f)));
descriptions = new JPanel(new BorderLayout()) {
@Override
@@ -1104,7 +1105,8 @@
TextAttributes attributes = new TextAttributes(fileStatus.getColor(), null , null, EffectType.LINE_UNDERSCORE, Font.PLAIN);
append(name, SimpleTextAttributes.fromTextAttributes(attributes));
- final Color color = FileColorManager.getInstance(myProject).getFileColor(virtualFile);
+ // calc color the same way editor tabs do this, i.e. including extensions
+ Color color = EditorTabbedContainer.calcTabColor(myProject, virtualFile);
if (!selected && color != null) {
setBackground(color);
diff --git a/platform/platform-impl/src/com/intellij/ide/actions/TogglePresentationModeAction.java b/platform/platform-impl/src/com/intellij/ide/actions/TogglePresentationModeAction.java
index faa4997..6c8e9e8 100644
--- a/platform/platform-impl/src/com/intellij/ide/actions/TogglePresentationModeAction.java
+++ b/platform/platform-impl/src/com/intellij/ide/actions/TogglePresentationModeAction.java
@@ -20,6 +20,10 @@
import com.intellij.ide.util.PropertiesComponent;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.editor.EditorFactory;
+import com.intellij.openapi.editor.colors.EditorColorsManager;
+import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.editor.ex.util.EditorUtil;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
@@ -27,8 +31,10 @@
import com.intellij.openapi.wm.ex.ToolWindowManagerEx;
import com.intellij.openapi.wm.impl.DesktopLayout;
import com.intellij.openapi.wm.impl.IdeFrameImpl;
+import com.intellij.util.containers.HashMap;
import javax.swing.*;
+import javax.swing.plaf.FontUIResource;
import java.awt.*;
import java.util.Enumeration;
@@ -36,6 +42,8 @@
* @author Konstantin Bulenkov
*/
public class TogglePresentationModeAction extends AnAction implements DumbAware {
+ private static final HashMap<Object, Font> oldFonts = new HashMap<Object, Font>();
+
@Override
public void update(AnActionEvent e) {
boolean selected = UISettings.getInstance().PRESENTATION_MODE;
@@ -60,21 +68,20 @@
if (settings.PRESENTATION_MODE) {
while (keys.hasMoreElements()) {
Object key = keys.nextElement();
- if (key instanceof String && !((String)key).startsWith("old.") && ((String)key).endsWith(".font")) {
+ if (key instanceof String && ((String)key).endsWith(".font")) {
Font font = defaults.getFont(key);
- defaults.put("old." + key, font);
- defaults.put(key, font.deriveFont((float)Math.min(20, settings.PRESENTATION_MODE_FONT_SIZE)));
+ oldFonts.put(key, font);
}
}
+ for (Object key : oldFonts.keySet()) {
+ Font font = oldFonts.get(key);
+ defaults.put(key, new FontUIResource(font.getName(), font.getStyle(), Math.min(20, settings.PRESENTATION_MODE_FONT_SIZE)));
+ }
} else {
- while (keys.hasMoreElements()) {
- Object key = keys.nextElement();
- if (key instanceof String && ((String)key).startsWith("old.") && ((String)key).endsWith(".font")) {
- Font font = defaults.getFont(key);
- defaults.put(((String)key).substring(4), font);
- defaults.put(key, font);
- }
+ for (Object key : oldFonts.keySet()) {
+ defaults.put(key, oldFonts.get(key));
}
+ oldFonts.clear();
}
if (project != null) {
@@ -91,10 +98,18 @@
}
}
+ int fontSize = settings.PRESENTATION_MODE
+ ? settings.PRESENTATION_MODE_FONT_SIZE
+ : EditorColorsManager.getInstance().getGlobalScheme().getEditorFontSize();
+ for (Editor editor : EditorFactory.getInstance().getAllEditors()) {
+ if (editor instanceof EditorEx) {
+ ((EditorEx)editor).setFontSize(fontSize);
+ }
+ }
UISettings.getInstance().fireUISettingsChanged();
LafManager.getInstance().updateUI();
-
EditorUtil.reinitSettings();
+
}
private static void hideToolWindows(Project project) {
diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/InstalledPluginsManagerMain.java b/platform/platform-impl/src/com/intellij/ide/plugins/InstalledPluginsManagerMain.java
index e1454ef..ed3bf34 100644
--- a/platform/platform-impl/src/com/intellij/ide/plugins/InstalledPluginsManagerMain.java
+++ b/platform/platform-impl/src/com/intellij/ide/plugins/InstalledPluginsManagerMain.java
@@ -34,8 +34,10 @@
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.ui.ScrollPaneFactory;
-import com.intellij.util.ArrayUtil;
+import com.intellij.ui.SimpleTextAttributes;
+import com.intellij.util.ArrayUtilRt;
import com.intellij.util.Function;
+import com.intellij.util.ui.StatusText;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -98,7 +100,7 @@
Messages.showErrorDialog("Fail to load plugin descriptor from file " + file.getName(), CommonBundle.getErrorTitle());
return;
}
- if (PluginManager.isIncompatible(pluginDescriptor)) {
+ if (PluginManagerCore.isIncompatible(pluginDescriptor)) {
Messages.showErrorDialog("Plugin " + pluginDescriptor.getName() + " is incompatible with current installation", CommonBundle.getErrorTitle());
return;
}
@@ -130,6 +132,11 @@
}
});
myActionsPanel.add(installPluginFromFileSystem);
+ final StatusText emptyText = pluginTable.getEmptyText();
+ emptyText.setText("Nothing to show.");
+ emptyText.appendText(" Click ");
+ emptyText.appendText("Browse", SimpleTextAttributes.LINK_ATTRIBUTES, new BrowseRepoListener(null));
+ emptyText.appendText(" to search for non-bundled plugins.");
}
private void checkInstalledPluginDependencies(IdeaPluginDescriptorImpl pluginDescriptor) {
@@ -138,10 +145,10 @@
final PluginId[] dependentPluginIds = pluginDescriptor.getDependentPluginIds();
final PluginId[] optionalDependentPluginIds = pluginDescriptor.getOptionalDependentPluginIds();
for (PluginId id : dependentPluginIds) {
- if (ArrayUtil.find(optionalDependentPluginIds, id) > -1) continue;
+ if (ArrayUtilRt.find(optionalDependentPluginIds, id) > -1) continue;
final boolean disabled = ((InstalledPluginsTableModel)pluginsModel).isDisabled(id);
final boolean enabled = ((InstalledPluginsTableModel)pluginsModel).isEnabled(id);
- if (!enabled && !disabled && !PluginManager.isModuleDependency(id)) {
+ if (!enabled && !disabled && !PluginManagerCore.isModuleDependency(id)) {
notInstalled.add(id);
} else if (disabled) {
disabledIds.add(id);
@@ -263,7 +270,7 @@
return true;
}
}
- final List<String> disabledPlugins = PluginManager.getDisabledPlugins();
+ final List<String> disabledPlugins = PluginManagerCore.getDisabledPlugins();
for (Map.Entry<PluginId, Boolean> entry : ((InstalledPluginsTableModel)pluginsModel).getEnabledMap().entrySet()) {
final Boolean enabled = entry.getValue();
if (enabled != null && !enabled.booleanValue() && !disabledPlugins.contains(entry.getKey().toString())) {
@@ -295,7 +302,7 @@
ids.add(entry.getKey().getIdString());
}
}
- PluginManager.saveDisabledPlugins(ids, false);
+ PluginManagerCore.saveDisabledPlugins(ids, false);
}
catch (IOException e) {
LOG.error(e);
@@ -312,7 +319,7 @@
final PluginId id = iterator.next();
boolean hasNonModuleDeps = false;
for (PluginId pluginId : dependentToRequiredListMap.get(id)) {
- if (!PluginManager.isModuleDependency(pluginId)) {
+ if (!PluginManagerCore.isModuleDependency(pluginId)) {
hasNonModuleDeps = true;
break;
}
@@ -322,16 +329,15 @@
}
}
if (!dependentToRequiredListMap.isEmpty()) {
- final StringBuffer sb = new StringBuffer("<html><body style=\"padding: 5px;\">Unable to apply changes: plugin")
- .append(dependentToRequiredListMap.size() == 1 ? " " : "s ");
- sb.append(StringUtil.join(dependentToRequiredListMap.keySet(), new Function<PluginId, String>() {
- public String fun(final PluginId pluginId) {
- final IdeaPluginDescriptor ideaPluginDescriptor = PluginManager.getPlugin(pluginId);
- return "\"" + (ideaPluginDescriptor != null ? ideaPluginDescriptor.getName() : pluginId.getIdString()) + "\"";
- }
- }, ", "));
- sb.append(" won't be able to load.</body></html>");
- return sb.toString();
+ return "<html><body style=\"padding: 5px;\">Unable to apply changes: plugin" +
+ (dependentToRequiredListMap.size() == 1 ? " " : "s ") +
+ StringUtil.join(dependentToRequiredListMap.keySet(), new Function<PluginId, String>() {
+ public String fun(final PluginId pluginId) {
+ final IdeaPluginDescriptor ideaPluginDescriptor = PluginManager.getPlugin(pluginId);
+ return "\"" + (ideaPluginDescriptor != null ? ideaPluginDescriptor.getName() : pluginId.getIdString()) + "\"";
+ }
+ }, ", ") +
+ " won't be able to load.</body></html>";
}
return super.canApply();
}
@@ -397,6 +403,12 @@
{
setOKButtonText(CommonBundle.message("close.action.name"));
setOKButtonMnemonic('C');
+ final String filter = myFilter.getFilter();
+ if (!StringUtil.isEmptyOrSpaces(filter)) {
+ final Runnable searchRunnable = configurable.enableSearch(filter);
+ LOG.assertTrue(searchRunnable != null);
+ searchRunnable.run();
+ }
}
@NotNull
diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/PluginInstaller.java b/platform/platform-impl/src/com/intellij/ide/plugins/PluginInstaller.java
index 069c627..1bc0813 100644
--- a/platform/platform-impl/src/com/intellij/ide/plugins/PluginInstaller.java
+++ b/platform/platform-impl/src/com/intellij/ide/plugins/PluginInstaller.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -15,9 +15,11 @@
*/
package com.intellij.ide.plugins;
-import com.intellij.CommonBundle;
import com.intellij.ide.IdeBundle;
import com.intellij.ide.startup.StartupActionScriptManager;
+import com.intellij.notification.Notification;
+import com.intellij.notification.NotificationType;
+import com.intellij.notification.Notifications;
import com.intellij.openapi.extensions.PluginId;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
@@ -29,21 +31,18 @@
import com.intellij.ui.GuiUtils;
import com.intellij.util.ArrayUtil;
-import javax.swing.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
- * Created by IntelliJ IDEA.
- * User: stathik
- * Date: Nov 29, 2003
- * Time: 9:15:30 PM
- * To change this template use Options | File Templates.
+ * @author stathik
+ * @since Nov 29, 2003
*/
public class PluginInstaller {
+ private static final Object myLock = new Object();
- private PluginInstaller() {}
+ private PluginInstaller() { }
public static boolean prepareToInstall(List<PluginNode> pluginsToInstall, List<IdeaPluginDescriptor> allPlugins) {
ProgressIndicator pi = ProgressManager.getInstance().getProgressIndicator();
@@ -61,15 +60,13 @@
try {
result |= prepareToInstall(pluginNode, pluginIds, allPlugins);
}
- catch (final IOException e) {
- SwingUtilities.invokeLater(new Runnable(){
- public void run() {
- Messages.showErrorDialog(pluginNode.getName() + ": " + e.getMessage(), CommonBundle.message("title.error"));
- }
- });
+ catch (IOException e) {
+ String title = IdeBundle.message("title.plugin.error");
+ Notifications.Bus.notify(new Notification(title, title, pluginNode.getName() + ": " + e.getMessage(), NotificationType.ERROR));
return false;
}
}
+
return result;
}
@@ -79,16 +76,15 @@
// check for dependent plugins at first.
if (pluginNode.getDepends() != null && pluginNode.getDepends().size() > 0) {
// prepare plugins list for install
-
final PluginId[] optionalDependentPluginIds = pluginNode.getOptionalDependentPluginIds();
- final List <PluginNode> depends = new ArrayList <PluginNode> ();
+ final List<PluginNode> depends = new ArrayList<PluginNode>();
final List<PluginNode> optionalDeps = new ArrayList<PluginNode>();
for (int i = 0; i < pluginNode.getDepends().size(); i++) {
PluginId depPluginId = pluginNode.getDepends().get(i);
- if (PluginManager.isPluginInstalled(depPluginId) || PluginManager.isModuleDependency(depPluginId) ||
+ if (PluginManager.isPluginInstalled(depPluginId) || PluginManagerCore.isModuleDependency(depPluginId) ||
(pluginIds != null && pluginIds.contains(depPluginId))) {
- // ignore installed or installing plugins
+ // ignore installed or installing plugins
continue;
}
@@ -107,7 +103,7 @@
}
if (depends.size() > 0) { // has something to install prior installing the plugin
- final boolean [] proceed = new boolean[1];
+ final boolean[] proceed = new boolean[1];
final StringBuffer buf = new StringBuffer();
for (PluginNode depend : depends) {
buf.append(depend.getName()).append(",");
@@ -115,8 +111,9 @@
try {
GuiUtils.runOrInvokeAndWait(new Runnable() {
public void run() {
- proceed[0] = Messages.showYesNoDialog(IdeBundle.message("plugin.manager.dependencies.detected.message", depends.size(), buf.substring(0, buf.length() - 1)),
- IdeBundle.message("plugin.manager.dependencies.detected.title"), Messages.getWarningIcon()) == DialogWrapper.OK_EXIT_CODE;
+ String title = IdeBundle.message("plugin.manager.dependencies.detected.title");
+ String message = IdeBundle.message("plugin.manager.dependencies.detected.message", depends.size(), buf.substring(0, buf.length() - 1));
+ proceed[0] = Messages.showYesNoDialog(message, title, Messages.getWarningIcon()) == DialogWrapper.OK_EXIT_CODE;
}
});
}
@@ -127,7 +124,8 @@
if (!prepareToInstall(depends, allPlugins)) {
return false;
}
- } else {
+ }
+ else {
return false;
}
}
@@ -137,13 +135,15 @@
for (PluginNode depend : optionalDeps) {
buf.append(depend.getName()).append(",");
}
- final boolean [] proceed = new boolean[1];
+ final boolean[] proceed = new boolean[1];
try {
GuiUtils.runOrInvokeAndWait(new Runnable() {
public void run() {
- proceed[0] = Messages.showYesNoDialog(IdeBundle.message("plugin.manager.optional.dependencies.detected.message", optionalDeps.size(),
- buf.substring(0, buf.length() - 1)), IdeBundle.message("plugin.manager.dependencies.detected.title"),
- Messages.getWarningIcon()) == DialogWrapper.OK_EXIT_CODE;
+ proceed[0] =
+ Messages.showYesNoDialog(IdeBundle.message("plugin.manager.optional.dependencies.detected.message", optionalDeps.size(),
+ buf.substring(0, buf.length() - 1)),
+ IdeBundle.message("plugin.manager.dependencies.detected.title"),
+ Messages.getWarningIcon()) == DialogWrapper.OK_EXIT_CODE;
}
});
}
@@ -158,12 +158,12 @@
}
}
- synchronized (PluginManager.lock) {
+ synchronized (myLock) {
PluginDownloader downloader = null;
final String repositoryName = pluginNode.getRepositoryName();
if (repositoryName != null) {
try {
- final ArrayList<PluginDownloader> downloaders = new ArrayList<PluginDownloader>();
+ final List<PluginDownloader> downloaders = new ArrayList<PluginDownloader>();
if (!UpdateChecker.checkPluginsHost(repositoryName, downloaders)) {
return false;
}
@@ -178,13 +178,15 @@
catch (Exception e) {
return false;
}
- } else {
+ }
+ else {
downloader = PluginDownloader.createDownloader(pluginNode);
}
if (downloader.prepareToInstall(ProgressManager.getInstance().getProgressIndicator())) {
downloader.install();
pluginNode.setStatus(PluginNode.STATUS_DOWNLOADED);
- } else {
+ }
+ else {
return false;
}
}
@@ -201,14 +203,18 @@
return false;
}
- public static void prepareToUninstall (PluginId pluginId) throws IOException {
- synchronized (PluginManager.lock) {
+ public static void prepareToUninstall(PluginId pluginId) throws IOException {
+ synchronized (myLock) {
if (PluginManager.isPluginInstalled(pluginId)) {
// add command to delete the 'action script' file
IdeaPluginDescriptor pluginDescriptor = PluginManager.getPlugin(pluginId);
-
- StartupActionScriptManager.ActionCommand deleteOld = new StartupActionScriptManager.DeleteCommand(pluginDescriptor.getPath());
- StartupActionScriptManager.addActionCommand(deleteOld);
+ if (pluginDescriptor != null) {
+ StartupActionScriptManager.ActionCommand deleteOld = new StartupActionScriptManager.DeleteCommand(pluginDescriptor.getPath());
+ StartupActionScriptManager.addActionCommand(deleteOld);
+ }
+ else {
+ PluginManagerMain.LOG.error("Plugin not found: " + pluginId);
+ }
}
}
}
diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/PluginManager.java b/platform/platform-impl/src/com/intellij/ide/plugins/PluginManager.java
index 5c9f61e..95bbfdc 100644
--- a/platform/platform-impl/src/com/intellij/ide/plugins/PluginManager.java
+++ b/platform/platform-impl/src/com/intellij/ide/plugins/PluginManager.java
@@ -17,6 +17,7 @@
import com.intellij.ide.ClassUtilCore;
import com.intellij.ide.IdeBundle;
+import com.intellij.idea.IdeaApplication;
import com.intellij.idea.Main;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationListener;
@@ -49,14 +50,12 @@
public class PluginManager extends PluginManagerCore {
@NonNls public static final String INSTALLED_TXT = "installed.txt";
- static final Object lock = new Object();
-
public static long startupStart;
/**
* Called via reflection
*/
- @SuppressWarnings({"UnusedDeclaration", "HardCodedStringLiteral", "finally"})
+ @SuppressWarnings({"UnusedDeclaration", "HardCodedStringLiteral"})
protected static void start(final String mainClass, final String methodName, final String[] args) {
startupStart = System.nanoTime();
@@ -69,24 +68,7 @@
ThreadGroup threadGroup = new ThreadGroup("Idea Thread Group") {
@Override
public void uncaughtException(Thread t, Throwable e) {
- if (e instanceof StartupAbortedException) {
- StartupAbortedException se = (StartupAbortedException)e;
- try {
- if (se.logError()) {
- if (Logger.isInitialized()) {
- getLogger().error(e);
- }
- Main.showMessage("Start Failed", e);
- }
- }
- finally {
- System.exit(se.exitCode());
- }
- }
-
- if (!(e instanceof ProcessCanceledException)) {
- getLogger().error(e);
- }
+ processException(e);
}
};
@@ -111,10 +93,51 @@
new Thread(threadGroup, runnable, "Idea Main Thread").start();
}
+ public static void processException(Throwable t) {
+ StartupAbortedException se = null;
+
+ if (t instanceof StartupAbortedException) {
+ se = (StartupAbortedException)t;
+ }
+ else if (!IdeaApplication.isLoaded()) {
+ se = new StartupAbortedException(t);
+ }
+
+ if (se != null) {
+ if (se.logError()) {
+ try {
+ if (Logger.isInitialized() && !(t instanceof ProcessCanceledException)) {
+ getLogger().error(t);
+ }
+ }
+ catch (Throwable ignore) { }
+
+ Main.showMessage("Start Failed", t);
+ }
+
+ System.exit(se.exitCode());
+ }
+
+ if (!(t instanceof ProcessCanceledException)) {
+ getLogger().error(t);
+ }
+ }
+
+ private static Thread.UncaughtExceptionHandler HANDLER = new Thread.UncaughtExceptionHandler() {
+ @Override
+ public void uncaughtException(Thread t, Throwable e) {
+ processException(e);
+ }
+ };
+
+ public static void installExceptionHandler() {
+ Thread.currentThread().setUncaughtExceptionHandler(HANDLER);
+ }
+
public static void reportPluginError() {
if (myPluginError != null) {
- String message = IdeBundle.message("title.plugin.error");
- Notifications.Bus.notify(new Notification(message, message, myPluginError, NotificationType.ERROR, new NotificationListener() {
+ String title = IdeBundle.message("title.plugin.error");
+ Notifications.Bus.notify(new Notification(title, title, myPluginError, NotificationType.ERROR, new NotificationListener() {
@SuppressWarnings("AssignmentToStaticFieldFromInstanceMethod")
@Override
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
@@ -193,7 +216,7 @@
}
}
- public static class StartupAbortedException extends RuntimeException {
+ private static class StartupAbortedException extends RuntimeException {
private int exitCode = Main.STARTUP_EXCEPTION;
private boolean logError = true;
diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerMain.java b/platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerMain.java
index f81c842..22fdb18 100644
--- a/platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerMain.java
+++ b/platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerMain.java
@@ -63,14 +63,10 @@
import static com.intellij.openapi.util.text.StringUtil.isEmptyOrSpaces;
/**
- * Created by IntelliJ IDEA.
- * User: stathik
- * Date: Dec 25, 2003
- * Time: 9:47:59 PM
- * To change this template use Options | File Templates.
+ * @author stathik
+ * @since Dec 25, 2003
*/
public abstract class PluginManagerMain implements Disposable {
-
public static Logger LOG = Logger.getInstance("#com.intellij.ide.plugins.PluginManagerMain");
@NonNls private static final String TEXT_PREFIX = "<html><head>" +
@@ -80,10 +76,10 @@
" }" +
" </style>" +
"</head><body style=\"font-family: Arial,serif; font-size: 12pt; margin: 5px 5px;\">";
- @NonNls private static final String TEXT_SUFIX = "</body></html>";
+ @NonNls private static final String TEXT_SUFFIX = "</body></html>";
@NonNls private static final String HTML_PREFIX = "<a href=\"";
- @NonNls private static final String HTML_SUFIX = "</a>";
+ @NonNls private static final String HTML_SUFFIX = "</a>";
private boolean requireShutdown = false;
@@ -398,17 +394,17 @@
private static void setTextValue(@Nullable StringBuilder text, @Nullable String filter, JEditorPane pane) {
if (text != null) {
text.insert(0, TEXT_PREFIX);
- text.append(TEXT_SUFIX);
+ text.append(TEXT_SUFFIX);
pane.setText(SearchUtil.markup(text.toString(), filter).trim());
pane.setCaretPosition(0);
}
else {
- pane.setText(TEXT_PREFIX + TEXT_SUFIX);
+ pane.setText(TEXT_PREFIX + TEXT_SUFFIX);
}
}
private static String composeHref(String vendorUrl) {
- return HTML_PREFIX + vendorUrl + "\">" + vendorUrl + HTML_SUFIX;
+ return HTML_PREFIX + vendorUrl + "\">" + vendorUrl + HTML_SUFFIX;
}
public boolean isModified() {
diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/RepositoryHelper.java b/platform/platform-impl/src/com/intellij/ide/plugins/RepositoryHelper.java
index 47c0cdc..a179625 100644
--- a/platform/platform-impl/src/com/intellij/ide/plugins/RepositoryHelper.java
+++ b/platform/platform-impl/src/com/intellij/ide/plugins/RepositoryHelper.java
@@ -18,12 +18,10 @@
import com.google.common.hash.Hashing;
import com.google.common.io.Files;
import com.intellij.ide.IdeBundle;
-import com.intellij.openapi.application.ApplicationInfo;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.application.ex.ApplicationInfoEx;
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
import com.intellij.openapi.progress.ProgressIndicator;
-import com.intellij.openapi.util.BuildNumber;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.util.net.HttpConfigurable;
import org.jetbrains.annotations.NonNls;
@@ -46,7 +44,7 @@
public static List<IdeaPluginDescriptor> loadPluginsFromRepository(@Nullable ProgressIndicator indicator) throws Exception {
ApplicationInfoEx appInfo = ApplicationInfoImpl.getShadowInstance();
- String url = appInfo.getPluginsListUrl() + "?build=" + getDownloadBuildNumber();
+ String url = appInfo.getPluginsListUrl() + "?build=" + appInfo.getBuild().asString();
if (indicator != null) {
indicator.setText2(IdeBundle.message("progress.connecting.to.plugin.manager", appInfo.getPluginManagerUrl()));
@@ -96,7 +94,9 @@
}
}
- private synchronized static List<IdeaPluginDescriptor> readPluginsStream(InputStream is, ProgressIndicator indicator, String file) throws Exception {
+ private synchronized static List<IdeaPluginDescriptor> readPluginsStream(InputStream is,
+ ProgressIndicator indicator,
+ String file) throws Exception {
File temp = createLocalPluginsDescriptions(file);
OutputStream os = new FileOutputStream(temp, false);
@@ -150,11 +150,4 @@
public static String getDownloadUrl() {
return ApplicationInfoImpl.getShadowInstance().getPluginsDownloadUrl() + "?action=download&id=";
}
-
- // temp. hack to deal with plugin repository
- public static String getDownloadBuildNumber() {
- BuildNumber buildNumber = ApplicationInfo.getInstance().getBuild();
- String string = buildNumber.asString();
- return buildNumber.isSnapshot() ? string.replace(".SNAPSHOT", ".998") : string;
- }
}
diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/DarculaLaf.java b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/DarculaLaf.java
index 1e858ed..b469188 100644
--- a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/DarculaLaf.java
+++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/DarculaLaf.java
@@ -28,6 +28,7 @@
import javax.swing.*;
import javax.swing.plaf.ColorUIResource;
+import javax.swing.plaf.FontUIResource;
import javax.swing.plaf.IconUIResource;
import javax.swing.plaf.InsetsUIResource;
import javax.swing.plaf.basic.BasicLookAndFeel;
@@ -86,6 +87,16 @@
superMethod.setAccessible(true);
final UIDefaults metalDefaults = (UIDefaults)superMethod.invoke(new MetalLookAndFeel());
final UIDefaults defaults = (UIDefaults)superMethod.invoke(base);
+ if (SystemInfo.isLinux) {
+ Font font = findFont("DejaVu Sans");
+ if (font != null) {
+ for (Object key : defaults.keySet()) {
+ if (key instanceof String && ((String)key).endsWith(".font")) {
+ defaults.put(key, new FontUIResource(font.deriveFont(13f)));
+ }
+ }
+ }
+ }
LafManagerImpl.initInputMapDefaults(defaults);
initIdeaDefaults(defaults);
@@ -102,6 +113,15 @@
return super.getDefaults();
}
+ private static Font findFont(String name) {
+ for (Font font : GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts()) {
+ if (font.getName().equals(name)) {
+ return font;
+ }
+ }
+ return null;
+ }
+
private static void patchComboBox(UIDefaults metalDefaults, UIDefaults defaults) {
defaults.remove("ComboBox.ancestorInputMap");
defaults.remove("ComboBox.actionMap");
diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaTextFieldUI.java b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaTextFieldUI.java
index f7c24ed..a691396 100644
--- a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaTextFieldUI.java
+++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaTextFieldUI.java
@@ -64,7 +64,7 @@
c.addMouseMotionListener(new MouseMotionAdapter() {
@Override
public void mouseMoved(MouseEvent e) {
- if (isSearchField(c)) {
+ if (ui.getComponent() != null && isSearchField(c)) {
if (ui.getActionUnder(e) != null) {
c.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
} else {
diff --git a/platform/platform-impl/src/com/intellij/ide/util/ElementsChooser.java b/platform/platform-impl/src/com/intellij/ide/util/ElementsChooser.java
index b0cb460..83d4893 100644
--- a/platform/platform-impl/src/com/intellij/ide/util/ElementsChooser.java
+++ b/platform/platform-impl/src/com/intellij/ide/util/ElementsChooser.java
@@ -394,6 +394,14 @@
return myTable;
}
+ public void invertSelection() {
+ final int count = getElementCount();
+ for (int i = 0; i < count; i++) {
+ T type = getElementAt(i);
+ setElementMarked(type, !isElementMarked(type));
+ }
+ }
+
public void setAllElementsMarked(boolean marked) {
final int[] rows = new int[myTableModel.getRowCount()];
for (int idx = 0; idx < rows.length; idx++) {
diff --git a/platform/platform-impl/src/com/intellij/ide/util/TipUIUtil.java b/platform/platform-impl/src/com/intellij/ide/util/TipUIUtil.java
index 074e0bd..431560b 100644
--- a/platform/platform-impl/src/com/intellij/ide/util/TipUIUtil.java
+++ b/platform/platform-impl/src/com/intellij/ide/util/TipUIUtil.java
@@ -20,11 +20,14 @@
import com.intellij.openapi.actionSystem.Shortcut;
import com.intellij.openapi.application.ApplicationInfo;
import com.intellij.openapi.application.ApplicationNamesInfo;
+import com.intellij.openapi.keymap.Keymap;
import com.intellij.openapi.keymap.KeymapManager;
import com.intellij.openapi.keymap.KeymapUtil;
+import com.intellij.openapi.keymap.impl.DefaultKeymap;
import com.intellij.util.ResourceUtil;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.io.IOException;
@@ -92,16 +95,31 @@
return;
}
final String actionId = text.substring(actionIdStart, actionIdEnd);
- final Shortcut[] shortcuts = KeymapManager.getInstance().getActiveKeymap().getShortcuts(actionId);
- String shortcutText = "";
- for (final Shortcut shortcut : shortcuts) {
- if (shortcut instanceof KeyboardShortcut) {
- shortcutText = KeymapUtil.getShortcutText(shortcut);
- break;
+ String shortcutText = getShortcutText(actionId, KeymapManager.getInstance().getActiveKeymap());
+ if (shortcutText == null) {
+ Keymap defKeymap = KeymapManager.getInstance().getKeymap(DefaultKeymap.getInstance().getDefaultKeymapName());
+ if (defKeymap != null) {
+ shortcutText = getShortcutText(actionId, defKeymap);
+ if (shortcutText != null) {
+ shortcutText += " in default keymap";
+ }
}
}
+ if (shortcutText == null) {
+ shortcutText = "<no shortcut for action " + actionId + ">";
+ }
text.replace(lastIndex, actionIdEnd + 1, shortcutText);
lastIndex += shortcutText.length();
}
}
+
+ @Nullable
+ private static String getShortcutText(String actionId, Keymap keymap) {
+ for (final Shortcut shortcut : keymap.getShortcuts(actionId)) {
+ if (shortcut instanceof KeyboardShortcut) {
+ return KeymapUtil.getShortcutText(shortcut);
+ }
+ }
+ return null;
+ }
}
diff --git a/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java b/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java
index 4604d57..6c13c17 100644
--- a/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java
+++ b/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java
@@ -60,7 +60,6 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
-@SuppressWarnings({"CallToPrintStackTrace"})
public class IdeaApplication {
@NonNls public static final String IDEA_IS_INTERNAL_PROPERTY = "idea.is.internal";
@@ -68,9 +67,18 @@
private static IdeaApplication ourInstance;
- protected final String[] myArgs;
+ public static IdeaApplication getInstance() {
+ return ourInstance;
+ }
+
+ public static boolean isLoaded() {
+ return ourInstance != null && ourInstance.myLoaded;
+ }
+
+ private final String[] myArgs;
private boolean myPerformProjectLoad = true;
private ApplicationStarter myStarter;
+ private volatile boolean myLoaded = false;
public IdeaApplication(String[] args) {
LOG.assertTrue(ourInstance == null);
@@ -174,16 +182,19 @@
return new IdeStarter();
}
- public static IdeaApplication getInstance() {
- return ourInstance;
- }
+ public void run() {
+ try {
+ ApplicationEx app = ApplicationManagerEx.getApplicationEx();
+ app.load(PathManager.getOptionsPath());
- public void run() throws Exception {
- ApplicationEx app = ApplicationManagerEx.getApplicationEx();
- app.load(PathManager.getOptionsPath());
+ myStarter.main(myArgs);
+ myStarter = null; //GC it
- myStarter.main(myArgs);
- myStarter = null; //GC it
+ myLoaded = true;
+ }
+ catch (Exception e) {
+ throw new RuntimeException(e);
+ }
}
@SuppressWarnings({"HardCodedStringLiteral"})
diff --git a/platform/platform-impl/src/com/intellij/idea/StartupUtil.java b/platform/platform-impl/src/com/intellij/idea/StartupUtil.java
index 28ee2fb..934ef30 100644
--- a/platform/platform-impl/src/com/intellij/idea/StartupUtil.java
+++ b/platform/platform-impl/src/com/intellij/idea/StartupUtil.java
@@ -15,13 +15,10 @@
*/
package com.intellij.idea;
-import com.intellij.ide.plugins.PluginManagerCore;
-import com.intellij.ide.startupWizard.StartupWizard;
import com.intellij.openapi.application.ApplicationInfo;
import com.intellij.openapi.application.ApplicationNamesInfo;
import com.intellij.openapi.application.ConfigImportHelper;
import com.intellij.openapi.application.PathManager;
-import com.intellij.openapi.application.ex.ApplicationInfoEx;
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.SystemInfo;
@@ -114,16 +111,6 @@
appStarter.start(newConfigFolder);
}
- static void runStartupWizard() {
- final List<ApplicationInfoEx.PluginChooserPage> pages = ApplicationInfoImpl.getShadowInstance().getPluginChooserPages();
- if (!pages.isEmpty()) {
- final StartupWizard startupWizard = new StartupWizard(pages);
- startupWizard.setCancelText("Skip");
- startupWizard.show();
- PluginManagerCore.invalidatePlugins();
- }
- }
-
/**
* Checks if the program can run under the JDK it was started with.
*/
diff --git a/platform/platform-impl/src/com/intellij/internal/RestartInfoAction.java b/platform/platform-impl/src/com/intellij/internal/RestartInfoAction.java
deleted file mode 100644
index 4a9921d..0000000
--- a/platform/platform-impl/src/com/intellij/internal/RestartInfoAction.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2000-2009 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.internal;
-
-import com.intellij.openapi.actionSystem.AnAction;
-import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.openapi.application.Application;
-import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.project.DumbAware;
-
-/**
- * @author yole
- */
-public class RestartInfoAction extends AnAction implements DumbAware {
- public void actionPerformed(AnActionEvent e) {
- final Application app = ApplicationManager.getApplication();
- if (app.isRestartCapable()) {
- app.restart();
- }
- }
-
- @Override
- public void update(AnActionEvent e) {
- boolean restartCapable = ApplicationManager.getApplication().isRestartCapable();
- e.getPresentation().setEnabled(restartCapable);
- e.getPresentation().setVisible(restartCapable);
- }
-}
diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/StatisticsUploadAssistant.java b/platform/platform-impl/src/com/intellij/internal/statistic/StatisticsUploadAssistant.java
index 300cfae..b81fbe5 100755
--- a/platform/platform-impl/src/com/intellij/internal/statistic/StatisticsUploadAssistant.java
+++ b/platform/platform-impl/src/com/intellij/internal/statistic/StatisticsUploadAssistant.java
@@ -35,7 +35,6 @@
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.KeyedExtensionCollector;
import com.intellij.openapi.util.Pair;
-import com.intellij.openapi.vfs.VirtualFileSystem;
import com.intellij.util.Function;
import com.intellij.util.Time;
import com.intellij.util.containers.ContainerUtil;
diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/configurable/StatisticsConfigurationComponent.form b/platform/platform-impl/src/com/intellij/internal/statistic/configurable/StatisticsConfigurationComponent.form
old mode 100755
new mode 100644
index 46edcf3..5a20875
--- a/platform/platform-impl/src/com/intellij/internal/statistic/configurable/StatisticsConfigurationComponent.form
+++ b/platform/platform-impl/src/com/intellij/internal/statistic/configurable/StatisticsConfigurationComponent.form
@@ -35,7 +35,7 @@
</constraints>
<properties>
<selected value="true"/>
- <text value="Allow to send usages statistics to %company%"/>
+ <text value=""/>
</properties>
</component>
<grid id="d4bdc" binding="myRadioButtonPanel" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
@@ -98,7 +98,7 @@
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
- <text value="<html>Help improve our products by sending anonymous usage statistics to %company%</html>"/>
+ <text value=""/>
</properties>
</component>
<hspacer id="244b1">
diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/configurable/StatisticsConfigurationComponent.java b/platform/platform-impl/src/com/intellij/internal/statistic/configurable/StatisticsConfigurationComponent.java
old mode 100755
new mode 100644
index bc110bf..6aa0329
--- a/platform/platform-impl/src/com/intellij/internal/statistic/configurable/StatisticsConfigurationComponent.java
+++ b/platform/platform-impl/src/com/intellij/internal/statistic/configurable/StatisticsConfigurationComponent.java
@@ -40,13 +40,10 @@
private JPanel myRadioButtonPanel;
public StatisticsConfigurationComponent() {
-
+ String product = ApplicationNamesInfo.getInstance().getFullProductName();
String company = ApplicationInfo.getInstance().getCompanyName();
-
- myTitle.setText("Help improve " + ApplicationNamesInfo.getInstance().getFullProductName() +
- " by sending anonymous usage statistics to " + company);
- myLabel.setText("<html>We're asking your permission to send information about your plugins configuration (what is enabled <br>and what is not) and feature usage statistics (e.g. how frequently you're using code completion).<br> " +
- "This data is anonymous, does not contain any personal information, collected for use only by " + company + "<br> and will never be transmitted to any third party.</html>");
+ myTitle.setText(StatisticsBundle.message("stats.title", product, company));
+ myLabel.setText(StatisticsBundle.message("stats.config.details", company));
myLabel.setFont(UIUtil.getLabelFont(UIUtil.FontSize.SMALL));
myAllowToSendUsagesCheckBox.setText(StatisticsBundle.message("stats.config.allow.send.stats.text", company));
@@ -62,15 +59,15 @@
if (service != null) {
Map<String, String> overrides = service.getStatisticsConfigurationLabels();
if (overrides != null) {
- String s = overrides.get("title");
+ String s = overrides.get(StatisticsService.TITLE);
if (s != null) {
myTitle.setText(s);
}
- s = overrides.get("details");
+ s = overrides.get(StatisticsService.DETAILS);
if (s != null) {
myLabel.setText(s);
}
- s = overrides.get("allow-checkbox");
+ s = overrides.get(StatisticsService.ALLOW_CHECKBOX);
if (s != null) {
myAllowToSendUsagesCheckBox.setText(s);
}
diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/connect/StatisticsService.java b/platform/platform-impl/src/com/intellij/internal/statistic/connect/StatisticsService.java
old mode 100755
new mode 100644
index e19544d..a590e03
--- a/platform/platform-impl/src/com/intellij/internal/statistic/connect/StatisticsService.java
+++ b/platform/platform-impl/src/com/intellij/internal/statistic/connect/StatisticsService.java
@@ -19,6 +19,7 @@
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationListener;
import com.intellij.openapi.extensions.ExtensionPointName;
+import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -26,12 +27,22 @@
public interface StatisticsService {
- ExtensionPointName<StatisticsService> EP_NAME = ExtensionPointName.create("com.intellij.statisticsService");
+ ExtensionPointName<StatisticsServiceEP> EP_NAME = ExtensionPointName.create("com.intellij.statisticsService");
+
+ @NonNls String TITLE = "title";
+ @NonNls String DETAILS = "details";
+ @NonNls String ALLOW_CHECKBOX = "allow-checkbox";
StatisticsResult send();
Notification createNotification(@NotNull String groupDisplayId, @Nullable NotificationListener listener);
+ /**
+ * Returns the custom text to be displayed in the statistics dialog. The keys in the map are control IDs ({@link #TITLE}, {@link #DETAILS}
+ * and {@link #ALLOW_CHECKBOX} and the values are the text to be displayed in the dialog.
+ *
+ * @return the text override map, or null if the standard text should be used.
+ */
@Nullable
Map<String, String> getStatisticsConfigurationLabels();
}
diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/connect/StatisticsServiceEP.java b/platform/platform-impl/src/com/intellij/internal/statistic/connect/StatisticsServiceEP.java
index f9ceb74..1c3f51a 100755
--- a/platform/platform-impl/src/com/intellij/internal/statistic/connect/StatisticsServiceEP.java
+++ b/platform/platform-impl/src/com/intellij/internal/statistic/connect/StatisticsServiceEP.java
@@ -21,22 +21,22 @@
import com.intellij.util.KeyedLazyInstance;
import com.intellij.util.xmlb.annotations.Attribute;
-public class StatisticsServiceEP<T> extends AbstractExtensionPointBean implements KeyedLazyInstance<T> {
+public class StatisticsServiceEP extends AbstractExtensionPointBean implements KeyedLazyInstance<StatisticsService> {
@Attribute("key")
public String key;
@Attribute("implementationClass")
public String implementationClass;
- private final LazyInstance<T> myHandler = new LazyInstance<T>() {
+ private final LazyInstance<StatisticsService> myHandler = new LazyInstance<StatisticsService>() {
@Override
- protected Class<T> getInstanceClass() throws ClassNotFoundException {
+ protected Class<StatisticsService> getInstanceClass() throws ClassNotFoundException {
return findClass(implementationClass);
}
};
@Override
- public T getInstance() {
+ public StatisticsService getInstance() {
return myHandler.getValue();
}
diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/updater/SendStatisticsProjectComponent.java b/platform/platform-impl/src/com/intellij/internal/statistic/updater/SendStatisticsProjectComponent.java
old mode 100755
new mode 100644
index b5f5eb8..0e5ac83
--- a/platform/platform-impl/src/com/intellij/internal/statistic/updater/SendStatisticsProjectComponent.java
+++ b/platform/platform-impl/src/com/intellij/internal/statistic/updater/SendStatisticsProjectComponent.java
@@ -16,10 +16,8 @@
package com.intellij.internal.statistic.updater;
import com.intellij.internal.statistic.StatisticsUploadAssistant;
-import com.intellij.internal.statistic.connect.RemotelyConfigurableStatisticsService;
-import com.intellij.internal.statistic.connect.StatisticsConnectionService;
-import com.intellij.internal.statistic.connect.StatisticsHttpClientSender;
import com.intellij.internal.statistic.connect.StatisticsService;
+import com.intellij.internal.statistic.connect.StatisticsServiceEP;
import com.intellij.notification.NotificationDisplayType;
import com.intellij.notification.NotificationsConfiguration;
import com.intellij.notification.impl.NotificationsConfigurationImpl;
@@ -30,11 +28,9 @@
import com.intellij.openapi.project.Project;
import com.intellij.openapi.startup.StartupManager;
import com.intellij.util.Alarm;
-import com.intellij.util.containers.ContainerUtilRt;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
-import java.util.Collection;
public class SendStatisticsProjectComponent implements ProjectComponent {
@@ -75,7 +71,18 @@
StatisticsNotificationManager.showNotification(statisticsService, myProject);
}
else if (StatisticsUploadAssistant.isSendAllowed() && StatisticsUploadAssistant.isTimeToSend()) {
- runWithDelay(statisticsService);
+ StatisticsService serviceToUse = null;
+ StatisticsServiceEP[] extensions = StatisticsService.EP_NAME.getExtensions();
+ if (extensions.length > 1) {
+ LOG.warn(String.format("More than one stats service detected (%s). Falling back to the built-in one", Arrays.toString(extensions)));
+ }
+ else if (extensions.length == 1) {
+ serviceToUse = extensions[0].getInstance();
+ }
+ if (serviceToUse == null) {
+ serviceToUse = statisticsService;
+ }
+ runWithDelay(serviceToUse);
}
}
@@ -87,12 +94,7 @@
runWithDelay(statisticsService);
}
else {
- try {
- statisticsService.send();
- }
- catch (Exception e) {
- LOG.warn("Unexpected error during sending stats data via service " + statisticsService, e);
- }
+ statisticsService.send();
}
}
}, DELAY_IN_MIN * 60 * 1000);
diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/updater/StatisticsNotificationManager.java b/platform/platform-impl/src/com/intellij/internal/statistic/updater/StatisticsNotificationManager.java
old mode 100755
new mode 100644
index 79cbe74..37cb3bd
--- a/platform/platform-impl/src/com/intellij/internal/statistic/updater/StatisticsNotificationManager.java
+++ b/platform/platform-impl/src/com/intellij/internal/statistic/updater/StatisticsNotificationManager.java
@@ -1,17 +1,12 @@
package com.intellij.internal.statistic.updater;
-import com.intellij.internal.statistic.StatisticsBundle;
import com.intellij.internal.statistic.configurable.StatisticsConfigurable;
-import com.intellij.internal.statistic.connect.RemotelyConfigurableStatisticsService;
import com.intellij.internal.statistic.connect.StatisticsService;
import com.intellij.internal.statistic.persistence.UsageStatisticsPersistenceComponent;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationListener;
-import com.intellij.notification.NotificationType;
import com.intellij.notification.Notifications;
-import com.intellij.openapi.application.ApplicationInfo;
import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.application.ApplicationNamesInfo;
import com.intellij.openapi.options.ShowSettingsUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.IdeFrame;
diff --git a/platform/platform-impl/src/com/intellij/notification/EventLog.java b/platform/platform-impl/src/com/intellij/notification/EventLog.java
index 2979cd7..c46ed60 100644
--- a/platform/platform-impl/src/com/intellij/notification/EventLog.java
+++ b/platform/platform-impl/src/com/intellij/notification/EventLog.java
@@ -444,7 +444,7 @@
hideBalloon(notification);
}
- RelativePoint target = EventLog.getProjectComponent(project).myConsole.getHyperlinkLocation(this);
+ RelativePoint target = getProjectComponent(project).myConsole.getHyperlinkLocation(this);
if (target != null) {
IdeFrame frame = WindowManager.getInstance().getIdeFrame(project);
assert frame != null;
@@ -457,7 +457,7 @@
private static void hideBalloon(Notification notification1) {
Balloon balloon = notification1.getBalloon();
if (balloon != null) {
- balloon.hide();
+ balloon.hide(true);
}
}
}
diff --git a/platform/platform-impl/src/com/intellij/notification/EventLogToolWindowFactory.java b/platform/platform-impl/src/com/intellij/notification/EventLogToolWindowFactory.java
index 66efacd..6db8dc7 100644
--- a/platform/platform-impl/src/com/intellij/notification/EventLogToolWindowFactory.java
+++ b/platform/platform-impl/src/com/intellij/notification/EventLogToolWindowFactory.java
@@ -31,12 +31,12 @@
import com.intellij.openapi.ui.SimpleToolWindowPanel;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowFactory;
+import com.intellij.ui.AncestorListenerAdapter;
import com.intellij.ui.content.Content;
import com.intellij.ui.content.ContentFactory;
import org.jetbrains.annotations.NonNls;
import javax.swing.event.AncestorEvent;
-import javax.swing.event.AncestorListener;
/**
* @author peter
@@ -143,7 +143,7 @@
}
}
- private static class LogShownTracker implements AncestorListener {
+ private static class LogShownTracker extends AncestorListenerAdapter {
private final Project myProject;
public LogShownTracker(Project project) {
@@ -157,13 +157,5 @@
EventLog.getLogModel(myProject).logShown();
}
}
-
- @Override
- public void ancestorRemoved(AncestorEvent event) {
- }
-
- @Override
- public void ancestorMoved(AncestorEvent event) {
- }
}
}
diff --git a/platform/platform-impl/src/com/intellij/notification/impl/NotificationsConfigurationImpl.java b/platform/platform-impl/src/com/intellij/notification/impl/NotificationsConfigurationImpl.java
index 0f90781..75cf23a 100644
--- a/platform/platform-impl/src/com/intellij/notification/impl/NotificationsConfigurationImpl.java
+++ b/platform/platform-impl/src/com/intellij/notification/impl/NotificationsConfigurationImpl.java
@@ -18,6 +18,7 @@
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationDisplayType;
import com.intellij.notification.NotificationsConfiguration;
+import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.components.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.util.Function;
@@ -30,6 +31,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import java.io.File;
import java.util.*;
/**
@@ -37,7 +39,7 @@
*/
@State(name = "NotificationConfiguration",
storages = {@Storage( file = StoragePathMacros.APP_CONFIG + "/notifications.xml")})
-public class NotificationsConfigurationImpl extends NotificationsConfiguration implements ApplicationComponent,
+public class NotificationsConfigurationImpl extends NotificationsConfiguration implements ExportableApplicationComponent,
PersistentStateComponent<Element> {
private static final Logger LOG = Logger.getInstance("#com.intellij.notification.impl.NotificationsConfiguration");
private static final String SHOW_BALLOONS_ATTRIBUTE = "showBalloons";
@@ -195,4 +197,16 @@
SHOW_BALLOONS = false;
}
}
+
+ @NotNull
+ @Override
+ public File[] getExportFiles() {
+ return new File[]{PathManager.getOptionsFile("notifications")};
+ }
+
+ @NotNull
+ @Override
+ public String getPresentableName() {
+ return "Notifications";
+ }
}
diff --git a/platform/platform-impl/src/com/intellij/notification/impl/NotificationsManagerImpl.java b/platform/platform-impl/src/com/intellij/notification/impl/NotificationsManagerImpl.java
index dda2344..9234247 100644
--- a/platform/platform-impl/src/com/intellij/notification/impl/NotificationsManagerImpl.java
+++ b/platform/platform-impl/src/com/intellij/notification/impl/NotificationsManagerImpl.java
@@ -156,7 +156,9 @@
balloon.addListener(new JBPopupAdapter() {
@Override
public void onClosed(LightweightWindowEvent event) {
- notification.expire();
+ if (!event.isOk()) {
+ notification.expire();
+ }
}
});
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/ex/QuickListsManager.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/ex/QuickListsManager.java
index fad128f..176db43 100644
--- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/ex/QuickListsManager.java
+++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/ex/QuickListsManager.java
@@ -54,7 +54,7 @@
private final ActionManager myActionManager;
private final SchemesManager<QuickList, QuickList> mySchemesManager;
- private final static Logger LOG = Logger.getInstance("#" + QuickListsManager.class.getName());
+ private static final Logger LOG = Logger.getInstance("#" + QuickListsManager.class.getName());
public static QuickListsManager getInstance() {
return ApplicationManager.getApplication().getComponent(QuickListsManager.class);
@@ -116,7 +116,7 @@
public void initComponent() {
mySchemesManager.loadSchemes();
- registerActions();
+ registerActions();
}
public void disposeComponent() {
diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionManagerImpl.java
index 59e9e3c..26219ca 100644
--- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionManagerImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionManagerImpl.java
@@ -98,6 +98,7 @@
@NonNls public static final String DESCRIPTION = "description";
@NonNls public static final String TEXT_ATTR_NAME = "text";
@NonNls public static final String POPUP_ATTR_NAME = "popup";
+ @NonNls public static final String COMPACT_ATTR_NAME = "compact";
@NonNls public static final String SEPARATOR_ELEMENT_NAME = "separator";
@NonNls public static final String REFERENCE_ELEMENT_NAME = "reference";
@NonNls public static final String GROUPID_ATTR_NAME = "group-id";
@@ -502,7 +503,11 @@
}
String className = element.getAttributeValue(CLASS_ATTR_NAME);
if (className == null) { // use default group if class isn't specified
- className = DefaultActionGroup.class.getName();
+ if ("true".equals(element.getAttributeValue(COMPACT_ATTR_NAME))) {
+ className = DefaultCompactActionGroup.class.getName();
+ } else {
+ className = DefaultActionGroup.class.getName();
+ }
}
try {
Class aClass = Class.forName(className, true, loader);
diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/Utils.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/Utils.java
index 1fc9f70..14d95e0 100644
--- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/Utils.java
+++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/Utils.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -82,8 +82,19 @@
@NotNull DataContext context,
String place,
ActionManager actionManager){
- expandActionGroup(group, list, presentationFactory, context, place, actionManager, false);
+ expandActionGroup(group, list, presentationFactory, context, place, actionManager, false, group instanceof CompactActionGroup);
}
+
+ public static void expandActionGroup(@NotNull ActionGroup group,
+ List<AnAction> list,
+ PresentationFactory presentationFactory,
+ DataContext context,
+ @NotNull String place,
+ ActionManager actionManager,
+ boolean transparentOnly) {
+ expandActionGroup(group, list, presentationFactory, context, place, actionManager, transparentOnly, false);
+ }
+
/**
* @param list this list contains expanded actions.
* @param actionManager manager
@@ -94,7 +105,8 @@
DataContext context,
@NotNull String place,
ActionManager actionManager,
- boolean transparentOnly) {
+ boolean transparentOnly,
+ boolean hideDisabled) {
Presentation presentation = presentationFactory.getPresentation(group);
AnActionEvent e = new AnActionEvent(
null,
@@ -126,11 +138,15 @@
if (!doUpdate(child, e1, presentation)) continue;
}
- if (!presentation.isVisible()) { // don't create invisible items in the menu
+ if (!presentation.isVisible() || (!presentation.isEnabled() && hideDisabled)) { // don't create invisible items in the menu
continue;
}
if (child instanceof ActionGroup) {
ActionGroup actionGroup = (ActionGroup)child;
+ boolean skip = hideDisabled && !hasEnabledChildren(actionGroup, presentationFactory, context, place);
+ if (skip) {
+ continue;
+ }
if (actionGroup.isPopup()) { // popup menu has its own presentation
if (actionGroup.disableIfNoVisibleChildren()) {
final boolean visibleChildren = hasVisibleChildren(actionGroup, presentationFactory, context, place);
@@ -140,10 +156,11 @@
presentation.setEnabled(actionGroup.canBePerformed(context) || visibleChildren);
}
+
list.add(child);
}
else {
- expandActionGroup((ActionGroup)child, list, presentationFactory, context, place, actionManager);
+ expandActionGroup((ActionGroup)child, list, presentationFactory, context, place, actionManager, false, hideDisabled);
}
}
else if (child instanceof Separator) {
@@ -152,6 +169,9 @@
}
}
else {
+ if (hideDisabled && !hasEnabledChildren(new DefaultActionGroup(child), presentationFactory, context, place)) {
+ continue;
+ }
list.add(child);
}
}
@@ -181,6 +201,19 @@
}
private static boolean hasVisibleChildren(ActionGroup group, PresentationFactory factory, DataContext context, String place) {
+ return hasChildrenWithState(group, factory, context, place, true, false);
+ }
+
+ private static boolean hasEnabledChildren(ActionGroup group, PresentationFactory factory, DataContext context, String place) {
+ return hasChildrenWithState(group, factory, context, place, false, true);
+ }
+
+ private static boolean hasChildrenWithState(ActionGroup group,
+ PresentationFactory factory,
+ DataContext context,
+ String place,
+ boolean checkVisible,
+ boolean checkEnabled) {
AnActionEvent event = new AnActionEvent(null, context, place, factory.getPresentation(group), ActionManager.getInstance(), 0);
event.setInjectedContext(group.isInInjectedContext());
for (AnAction anAction : group.getChildren(event)) {
@@ -203,16 +236,16 @@
// popup menu must be visible itself
if (childGroup.isPopup()) {
- if (!presentation.isVisible()) {
+ if ((checkVisible && !presentation.isVisible()) || (checkEnabled && !presentation.isEnabled())) {
continue;
}
}
- if (hasVisibleChildren(childGroup, factory, context, place)) {
+ if (hasChildrenWithState(childGroup, factory, context, place, checkVisible, checkEnabled)) {
return true;
}
}
- else if (presentation.isVisible()) {
+ else if ((checkVisible && presentation.isVisible()) || (checkEnabled && presentation.isEnabled())) {
return true;
}
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/application/ConfigImportHelper.java b/platform/platform-impl/src/com/intellij/openapi/application/ConfigImportHelper.java
index 6a5d6f9..bb7f1e2 100644
--- a/platform/platform-impl/src/com/intellij/openapi/application/ConfigImportHelper.java
+++ b/platform/platform-impl/src/com/intellij/openapi/application/ConfigImportHelper.java
@@ -402,7 +402,7 @@
dir = dir.substring(1, dir.length() - 1);
}
if (replaceUserHome) {
- if (dir.startsWith("~\\") || dir.startsWith("~//") || StringUtil.startsWithConcatenationOf(dir, "~", File.separator)) {
+ if (dir.startsWith("~\\") || dir.startsWith("~//") || StringUtil.startsWithConcatenation(dir, "~", File.separator)) {
dir = SystemProperties.getUserHome() + dir.substring(1);
}
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java
index f092d21..667a432 100644
--- a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java
@@ -421,6 +421,7 @@
return myCommandLineMode;
}
+ @NotNull
@Override
public Future<?> executeOnPooledThread(@NotNull final Runnable action) {
return ourThreadExecutorsService.submit(new Runnable() {
@@ -443,6 +444,7 @@
});
}
+ @NotNull
@Override
public <T> Future<T> executeOnPooledThread(@NotNull final Callable<T> action) {
return ourThreadExecutorsService.submit(new Callable<T>() {
@@ -568,19 +570,17 @@
}
private void fireBeforeApplicationLoaded() {
- ExtensionPoint<ApplicationLoadListener> point = Extensions.getRootArea().getExtensionPoint("com.intellij.ApplicationLoadListener");
- final ApplicationLoadListener[] objects = point.getExtensions();
- for (ApplicationLoadListener object : objects) {
+ ExtensionPoint<ApplicationLoadListener> point = Extensions.getRootArea().getExtensionPoint(ApplicationLoadListener.EP_NAME);
+ for (ApplicationLoadListener listener : point.getExtensions()) {
try {
- object.beforeApplicationLoaded(this);
+ listener.beforeApplicationLoaded(this);
}
- catch(Exception e) {
+ catch (Exception e) {
LOG.error(e);
}
}
}
-
@Override
public void dispose() {
fireApplicationExiting();
@@ -801,7 +801,7 @@
Runnable runnable = new Runnable() {
@Override
public void run() {
- if (!force && !showConfirmation()) {
+ if (!confirmExitIfNeeded(force)) {
saveAll();
return;
}
@@ -847,8 +847,11 @@
return true;
}
- private static boolean showConfirmation() {
+ private static boolean confirmExitIfNeeded(boolean force) {
final boolean hasUnsafeBgTasks = ProgressManager.getInstance().hasUnsafeProgressIndicator();
+ if (force && !hasUnsafeBgTasks) {
+ return true;
+ }
DialogWrapper.DoNotAskOption option = new DialogWrapper.DoNotAskOption() {
@Override
@@ -1209,6 +1212,7 @@
return myActive;
}
+ @NotNull
@Override
public AccessToken acquireReadActionLock() {
// if we are inside read action, do not try to acquire read lock again since it will deadlock if there is a pending writeAction
@@ -1217,6 +1221,7 @@
return new ReadAccessToken();
}
+ @NotNull
@Override
public AccessToken acquireWriteActionLock(Class clazz) {
return new WriteAccessToken(clazz);
@@ -1468,8 +1473,9 @@
return myDoNotSave;
}
+ @NotNull
@Override
- public <T> T[] getExtensions(final ExtensionPointName<T> extensionPointName) {
+ public <T> T[] getExtensions(@NotNull final ExtensionPointName<T> extensionPointName) {
return Extensions.getRootArea().getExtensionPoint(extensionPointName).getExtensions();
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/application/impl/LaterInvocator.java b/platform/platform-impl/src/com/intellij/openapi/application/impl/LaterInvocator.java
index 936adcd..e44d13e 100644
--- a/platform/platform-impl/src/com/intellij/openapi/application/impl/LaterInvocator.java
+++ b/platform/platform-impl/src/com/intellij/openapi/application/impl/LaterInvocator.java
@@ -51,7 +51,7 @@
public static final Object LOCK = new Object(); //public for tests
private static final IdeEventQueue ourEventQueue = IdeEventQueue.getInstance();
- private static final FrequentEventDetector ourFrequentEventDetector = new FrequentEventDetector(1000, 100);
+ private static final FrequentEventDetector ourFrequentEventDetector = new FrequentEventDetector(1009, 100);
private LaterInvocator() {
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/command/impl/DummyProject.java b/platform/platform-impl/src/com/intellij/openapi/command/impl/DummyProject.java
index f096b7e..053e0e6 100644
--- a/platform/platform-impl/src/com/intellij/openapi/command/impl/DummyProject.java
+++ b/platform/platform-impl/src/com/intellij/openapi/command/impl/DummyProject.java
@@ -105,12 +105,12 @@
}
@Override
- public BaseComponent getComponent(String name) {
+ public BaseComponent getComponent(@NotNull String name) {
return null;
}
@Override
- public <T> T getComponent(Class<T> interfaceClass) {
+ public <T> T getComponent(@NotNull Class<T> interfaceClass) {
return null;
}
@@ -121,7 +121,7 @@
@Override
@NotNull
- public <T> T[] getComponents(Class<T> baseClass) {
+ public <T> T[] getComponents(@NotNull Class<T> baseClass) {
return (T[]) ArrayUtil.EMPTY_OBJECT_ARRAY;
}
@@ -132,7 +132,7 @@
}
@Override
- public <T> T getComponent(Class<T> interfaceClass, T defaultImplementation) {
+ public <T> T getComponent(@NotNull Class<T> interfaceClass, T defaultImplementation) {
return null;
}
@@ -177,17 +177,19 @@
return false;
}
+ @NotNull
@Override
public MessageBus getMessageBus() {
- return null;
+ throw new UnsupportedOperationException();
}
@Override
public void dispose() {
}
+ @NotNull
@Override
- public <T> T[] getExtensions(final ExtensionPointName<T> extensionPointName) {
+ public <T> T[] getExtensions(@NotNull final ExtensionPointName<T> extensionPointName) {
throw new UnsupportedOperationException("getExtensions()");
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/actions/TabAction.java b/platform/platform-impl/src/com/intellij/openapi/editor/actions/TabAction.java
index ec2556f..5064ad1 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/actions/TabAction.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/actions/TabAction.java
@@ -57,7 +57,7 @@
@Override
public boolean isEnabled(Editor editor, DataContext dataContext) {
- return !editor.isOneLineMode() && !((EditorEx)editor).isEmbeddedIntoDialogWrapper();
+ return !editor.isOneLineMode() && !((EditorEx)editor).isEmbeddedIntoDialogWrapper() && !editor.isViewer();
}
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java
index ff0fa50..7f29254 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java
@@ -28,6 +28,7 @@
import com.intellij.openapi.options.FontSize;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.InvalidDataException;
+import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.util.containers.ContainerUtilRt;
import com.intellij.util.containers.HashMap;
@@ -41,7 +42,7 @@
import java.util.List;
public abstract class AbstractColorsScheme implements EditorColorsScheme {
-
+ private static final String OS_VALUE_PREFIX = SystemInfo.isWindows ? "windows" : SystemInfo.isMac ? "mac" : "linux";
private static final int CURR_VERSION = 124;
private static final FontSize DEFAULT_FONT_SIZE = FontSize.SMALL;
@@ -373,7 +374,7 @@
}
private static Color readColorValue(final Element colorElement) {
- String value = colorElement.getAttributeValue(VALUE_ELEMENT);
+ String value = getValue(colorElement);
Color valueColor = null;
if (value != null && value.trim().length() > 0) {
try {
@@ -387,7 +388,7 @@
private void readSettings(Element childNode) {
String name = childNode.getAttributeValue(NAME_ATTR);
- String value = childNode.getAttributeValue(VALUE_ELEMENT);
+ String value = getValue(childNode);
if (LINE_SPACING.equals(name)) {
myLineSpacing = Float.parseFloat(value);
}
@@ -418,11 +419,11 @@
for (Object child : children) {
Element e = (Element)child;
if (EDITOR_FONT_NAME.equals(e.getAttributeValue(NAME_ATTR))) {
- fontFamily = e.getAttributeValue(VALUE_ELEMENT);
+ fontFamily = getValue(e);
}
else if (EDITOR_FONT_SIZE.equals(e.getAttributeValue(NAME_ATTR))) {
try {
- size = Integer.parseInt(e.getAttributeValue(VALUE_ELEMENT));
+ size = Integer.parseInt(getValue(e));
}
catch (NumberFormatException ex) {
// ignore
@@ -437,6 +438,11 @@
}
}
+ private static String getValue(Element e) {
+ final String value = e.getAttributeValue(OS_VALUE_PREFIX);
+ return value == null ? e.getAttributeValue(VALUE_ELEMENT) : value;
+ }
+
@Override
public void writeExternal(Element parentNode) throws WriteExternalException {
parentNode.setAttribute(NAME_ATTR, getName());
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/ex/EditorEx.java b/platform/platform-impl/src/com/intellij/openapi/editor/ex/EditorEx.java
index 85039d2..87c4b7f 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/ex/EditorEx.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/ex/EditorEx.java
@@ -111,6 +111,7 @@
void setOneLineMode(boolean b);
+ @NotNull
JScrollPane getScrollPane();
boolean isRendererMode();
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java
index c0c6547..c1099fa 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -54,7 +54,6 @@
import com.intellij.ui.HintHint;
import com.intellij.ui.JBColor;
import com.intellij.ui.awt.RelativePoint;
-import com.intellij.ui.awt.RelativeRectangle;
import com.intellij.util.Function;
import com.intellij.util.IconUtil;
import com.intellij.util.NullableFunction;
@@ -161,7 +160,11 @@
@Override
public Dimension getPreferredSize() {
if (UISettings.getInstance().PRESENTATION_MODE) {
- return new Dimension(myEditor.getFontMetrics(Font.PLAIN).getHeight(), myEditor.getPreferredHeight());
+ final Dimension dimension = new Dimension(myEditor.getFontMetrics(Font.PLAIN).getHeight(), myEditor.getPreferredHeight());
+ if (isLineMarkersShown()) {
+ dimension.width += getLineNumberAreaWidth() + getLineMarkerAreaWidth();
+ }
+ return dimension;
}
int w = getLineNumberAreaWidth() + getLineMarkerAreaWidth() + getFoldingAreaWidth() + getAnnotationsAreaWidth();
myLastPreferredHeight = myEditor.getPreferredHeight();
@@ -190,11 +193,19 @@
public void paint(Graphics g) {
if (UISettings.getInstance().PRESENTATION_MODE) {
g.setColor(myEditor.getColorsScheme().getDefaultBackground());
- Dimension size = getPreferredSize();
- Rectangle bounds = g.getClipBounds();
- if (bounds.height >= 0) {
- g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
+ final Rectangle clip = g.getClipBounds();
+
+ if (clip.height >= 0) {
+ g.fillRect(clip.x, clip.y, clip.width, clip.height);
}
+
+ paintCaretRowBackground(g, clip.x, clip.width);
+
+ if (isLineNumbersShown()) {
+ UISettings.setupAntialiasing(g);
+ paintLineNumbers(g, clip);
+ }
+
return;
}
@@ -578,9 +589,10 @@
int editorLocationX = (int)editorLocationInWindow.getX();
int rightMarginX = rightMargin * EditorUtil.getSpaceWidth(Font.PLAIN, myEditor) + editorLocationX;
- int width = (int)(editorComponent.getLocation().getX() + editorComponent.getWidth());
+ int width = editorLocationX + editorComponent.getWidth();
if (rightMarginX < width && editorLocationX < width - rightMarginX) {
- myTextAnnotationGuttersSize = Math.max(myTextAnnotationGuttersSize, (width - rightMarginX - editorLocationX)/2 - myIconsAreaWidth - 10);
+ myTextAnnotationGuttersSize = Math.max(myTextAnnotationGuttersSize, (width - rightMarginX - editorLocationX)/2 -
+ (myLineMarkerAreaWidth + myLineNumberAreaWidth));
}
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java
index d399123..0f91c8f 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java
@@ -475,8 +475,10 @@
myVerticalScrollBar = new MyScrollBar(Adjustable.VERTICAL);
myGutterComponent = new EditorGutterComponentImpl(this);
initComponent();
-
myScrollingModel = new ScrollingModelImpl(this);
+ if (UISettings.getInstance().PRESENTATION_MODE) {
+ setFontSize(UISettings.getInstance().PRESENTATION_MODE_FONT_SIZE);
+ }
myGutterComponent.updateSize();
Dimension preferredSize = getPreferredSize();
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/ScrollingModelImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/ScrollingModelImpl.java
index 8973b76..a43d4e9 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/ScrollingModelImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/ScrollingModelImpl.java
@@ -250,9 +250,8 @@
@Nullable
public JScrollBar getVerticalScrollBar() {
assertIsDispatchThread();
- if (myEditor.getScrollPane() == null) return null;
-
- return myEditor.getScrollPane().getVerticalScrollBar();
+ JScrollPane scrollPane = myEditor.getScrollPane();
+ return scrollPane.getVerticalScrollBar();
}
@Nullable
diff --git a/platform/platform-impl/src/com/intellij/openapi/fileChooser/ex/FileTextFieldImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileChooser/ex/FileTextFieldImpl.java
index 26e3947..63843a9 100644
--- a/platform/platform-impl/src/com/intellij/openapi/fileChooser/ex/FileTextFieldImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/fileChooser/ex/FileTextFieldImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -498,7 +498,7 @@
result.currentGrandparent = result.current.getParent();
if (result.currentGrandparent != null && result.currentParentMatch && !result.closedPath) {
final String currentGrandparentText = result.currentGrandparent.getAbsolutePath();
- if (StringUtil.startsWithConcatenationOf(typedText, currentGrandparentText, myFinder.getSeparator())) {
+ if (StringUtil.startsWithConcatenation(typedText, currentGrandparentText, myFinder.getSeparator())) {
result.grandparentPrefix = currentParentText.substring(currentGrandparentText.length() + myFinder.getSeparator().length());
}
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java
index d637367..7cb99dd 100644
--- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java
+++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java
@@ -18,6 +18,7 @@
import com.intellij.ide.actions.ShowFilePathAction;
import com.intellij.ide.ui.UISettings;
import com.intellij.ide.ui.UISettingsListener;
+import com.intellij.openapi.actionSystem.IdeActions;
import com.intellij.openapi.actionSystem.KeyboardShortcut;
import com.intellij.openapi.actionSystem.Shortcut;
import com.intellij.openapi.application.ApplicationManager;
@@ -188,7 +189,7 @@
}
painter.appendLine("Open a file by name with " + getActionShortcutText("GotoFile")).smaller().withBullet()
- .appendLine("Open Recent files with " + getActionShortcutText("RecentFiles")).smaller().withBullet()
+ .appendLine("Open Recent files with " + getActionShortcutText(IdeActions.ACTION_RECENT_FILES)).smaller().withBullet()
.appendLine("Open Navigation Bar with " + getActionShortcutText("ShowNavBar")).smaller().withBullet()
.appendLine("Drag'n'Drop file(s) here from " + ShowFilePathAction.getFileManagerName()).smaller().withBullet()
.draw(g, new PairFunction<Integer, Integer, Pair<Integer, Integer>>() {
diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/OpenFilesActivity.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/OpenFilesActivity.java
index 48507c7..dadf8b6 100644
--- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/OpenFilesActivity.java
+++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/OpenFilesActivity.java
@@ -33,6 +33,7 @@
final FileEditorManager fileEditorManager = FileEditorManager.getInstance(project);
if (fileEditorManager instanceof FileEditorManagerImpl) {
Runnable runnable = new Runnable() {
+ @Override
public void run() {
FileEditorManagerImpl manager = (FileEditorManagerImpl)fileEditorManager;
manager.getMainSplitters().openFiles();
diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/text/TextEditorProvider.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/text/TextEditorProvider.java
index 9e6c75b..3a6913c 100644
--- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/text/TextEditorProvider.java
+++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/text/TextEditorProvider.java
@@ -202,9 +202,10 @@
state.VERTICAL_SCROLL_PROPORTION = level == FileEditorStateLevel.UNDO ? -1 : EditorUtil.calcVerticalScrollProportion(editor);
if (editor instanceof EditorEx) {
state.VERTICAL_SCROLL_OFFSET = editor.getScrollingModel().getVerticalScrollOffset();
- state.MAX_VERTICAL_SCROLL_OFFSET = ((EditorEx)editor).getScrollPane().getVerticalScrollBar().getMaximum();
+ JScrollBar scrollBar = ((EditorEx)editor).getScrollPane().getVerticalScrollBar();
+ state.MAX_VERTICAL_SCROLL_OFFSET = scrollBar == null ? 0 : scrollBar.getMaximum();
}
-
+
return state;
}
@@ -216,6 +217,7 @@
boolean preciselyScrollVertically =
state.VERTICAL_SCROLL_OFFSET > 0
&& editorEx != null
+ && editorEx.getScrollPane().getVerticalScrollBar() != null
&& editorEx.getScrollPane().getVerticalScrollBar().getMaximum() == state.MAX_VERTICAL_SCROLL_OFFSET;
if (preciselyScrollVertically) {
editor.getScrollingModel().scrollVertically(state.VERTICAL_SCROLL_OFFSET);
diff --git a/platform/platform-impl/src/com/intellij/openapi/fileTypes/ex/FileTypeChooser.java b/platform/platform-impl/src/com/intellij/openapi/fileTypes/ex/FileTypeChooser.java
index 41d31cb..155f06a 100644
--- a/platform/platform-impl/src/com/intellij/openapi/fileTypes/ex/FileTypeChooser.java
+++ b/platform/platform-impl/src/com/intellij/openapi/fileTypes/ex/FileTypeChooser.java
@@ -166,7 +166,7 @@
chooser.show();
if (!chooser.isOK()) return null;
final FileType type = chooser.getSelectedType();
- if (type == FileTypes.UNKNOWN) return null;
+ if (type == FileTypes.UNKNOWN || type == null) return null;
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
diff --git a/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java
index f08afe9..ecc0904 100644
--- a/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java
@@ -37,6 +37,7 @@
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.CharsetToolkit;
+import com.intellij.openapi.vfs.VFileProperty;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileSystem;
import com.intellij.openapi.vfs.newvfs.FileSystemInterface;
@@ -340,7 +341,7 @@
@NotNull
@Override
public FileType detectFileTypeFromContent(@NotNull VirtualFile file) {
- if (file.isDirectory() || !file.isValid() || file.is(VirtualFile.PROP_SPECIAL)) {
+ if (file.isDirectory() || !file.isValid() || file.is(VFileProperty.SPECIAL)) {
return UnknownFileType.INSTANCE;
}
FileType fileType = file.getUserData(DETECTED_FROM_CONTENT_FILE_TYPE_KEY);
diff --git a/platform/platform-impl/src/com/intellij/openapi/project/FileContentQueue.java b/platform/platform-impl/src/com/intellij/openapi/project/FileContentQueue.java
index b0590c0..ce1c601 100644
--- a/platform/platform-impl/src/com/intellij/openapi/project/FileContentQueue.java
+++ b/platform/platform-impl/src/com/intellij/openapi/project/FileContentQueue.java
@@ -21,16 +21,17 @@
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.vfs.InvalidVirtualFileAccessException;
+import com.intellij.openapi.vfs.VFileProperty;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.util.SystemProperties;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.IOException;
-import java.util.ArrayDeque;
import java.util.Collection;
-import java.util.Queue;
-import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.LinkedBlockingDeque;
+import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
/**
@@ -39,30 +40,38 @@
@SuppressWarnings({"SynchronizeOnThis"})
public class FileContentQueue {
private static final Logger LOG = Logger.getInstance("#com.intellij.ide.startup.FileContentQueue");
- private static final long SIZE_THRESHOLD = 1024*1024;
- private static final long TAKEN_FILES_THRESHOLD = 1024*1024*3;
- private static final long LARGE_SIZE_REQUEST_THRESHOLD = TAKEN_FILES_THRESHOLD - 1024 * 300; // 300k for other threads
+ private static final long MAX_SIZE_OF_BYTES_IN_QUEUE = 1024*1024;
+ private static final long PROCESSED_FILE_BYTES_THRESHOLD = 1024*1024*3;
+ private static final long LARGE_SIZE_REQUEST_THRESHOLD = PROCESSED_FILE_BYTES_THRESHOLD - 1024 * 300; // 300k for other threads
- private long myTotalSize;
- private long myTakenSize;
- private boolean myLargeSizeRequested;
-
- private final ArrayBlockingQueue<FileContent> myQueue = new ArrayBlockingQueue<FileContent>(256);
- private final Queue<FileContent> myPushbackBuffer = new ArrayDeque<FileContent>();
+ // Unbounded (!)
+ private final LinkedBlockingDeque<FileContent> myLoadedContentsQueue = new LinkedBlockingDeque<FileContent>();
+ private final LinkedBlockingQueue<VirtualFile> myFilesToLoadQueue = new LinkedBlockingQueue<VirtualFile>();
private volatile boolean myContentLoadingThreadTerminated = false;
+ private volatile long myLoadedBytesInQueue;
+ private final Object myProceedWithLoadingLock = new Object();
+
+ private volatile long myBytesBeingProcessed;
+ private volatile boolean myLargeSizeRequested;
+ private final Object myProceedWithProcessingLock = new Object();
+ private static final boolean ourAllowParallelFileReading = SystemProperties.getBooleanProperty("idea.allow.parallel.file.reading", true);
+
public void queue(final Collection<VirtualFile> files, @NotNull final ProgressIndicator indicator) {
+ myFilesToLoadQueue.addAll(files);
final Runnable contentLoadingRunnable = new Runnable() {
public void run() {
try {
- for (VirtualFile file : files) {
+ VirtualFile file = myFilesToLoadQueue.poll();
+ while( file != null) {
indicator.checkCanceled();
addLast(file, indicator);
+ file = myFilesToLoadQueue.poll();
}
// put end-of-queue marker only if not canceled
try {
- myQueue.put(new FileContent(null));
+ myLoadedContentsQueue.put(new FileContent(null));
}
catch (InterruptedException e) {
LOG.error(e);
@@ -86,7 +95,7 @@
private void addLast(VirtualFile file, @NotNull final ProgressIndicator indicator) throws InterruptedException {
FileContent content = new FileContent(file);
- if (file.isValid() && !file.isDirectory() && !file.is(VirtualFile.PROP_SPECIAL) && !VfsUtilCore.isBrokenLink(file)) {
+ if (isValidFile(file)) {
if (!doLoadContent(content, indicator)) {
content.setEmptyContent();
}
@@ -95,7 +104,11 @@
content.setEmptyContent();
}
- myQueue.put(content);
+ myLoadedContentsQueue.put(content);
+ }
+
+ private static boolean isValidFile(VirtualFile file) {
+ return file.isValid() && !file.isDirectory() && !file.is(VFileProperty.SPECIAL) && !VfsUtilCore.isBrokenLink(file);
}
@SuppressWarnings("InstanceofCatchParameter")
@@ -104,12 +117,12 @@
boolean counterUpdated = false;
try {
- synchronized (this) {
- while (myTotalSize > SIZE_THRESHOLD) {
+ synchronized (myProceedWithLoadingLock) {
+ while (myLoadedBytesInQueue > MAX_SIZE_OF_BYTES_IN_QUEUE) {
indicator.checkCanceled();
- wait(300L);
+ myProceedWithLoadingLock.wait(300);
}
- myTotalSize += contentLength;
+ myLoadedBytesInQueue += contentLength;
counterUpdated = true;
}
@@ -119,9 +132,8 @@
}
catch (Throwable e) {
if (counterUpdated) {
- synchronized (this) {
- myTotalSize -= contentLength; // revert size counter
- notifyAll();
+ synchronized (myProceedWithLoadingLock) {
+ myLoadedBytesInQueue -= contentLength; // revert size counter
}
}
@@ -159,17 +171,18 @@
pushback(content);
throw e;
}
- synchronized (this) {
+
+ synchronized (myProceedWithProcessingLock) {
final boolean requestingLargeSize = length > LARGE_SIZE_REQUEST_THRESHOLD;
if (requestingLargeSize) {
myLargeSizeRequested = true;
}
try {
- if (myLargeSizeRequested && !requestingLargeSize || myTakenSize + length > Math.max(TAKEN_FILES_THRESHOLD, length)) {
- wait(300L);
+ if (myLargeSizeRequested && !requestingLargeSize || myBytesBeingProcessed + length > Math.max(PROCESSED_FILE_BYTES_THRESHOLD, length)) {
+ myProceedWithProcessingLock.wait(300);
}
else {
- myTakenSize += length;
+ myBytesBeingProcessed += length;
if (requestingLargeSize) {
myLargeSizeRequested = false;
}
@@ -186,54 +199,82 @@
@Nullable
private FileContent doTake() {
- FileContent result;
- synchronized (this) {
- result = myPushbackBuffer.poll();
- if (result != null) {
- return result;
- }
- }
+ FileContent result = null;
- try {
- while (result == null) {
- result = myQueue.poll(300L, TimeUnit.MILLISECONDS);
- if (result == null && myContentLoadingThreadTerminated) {
- return null;
+ while (result == null) {
+ if (ourAllowParallelFileReading) {
+ result = myLoadedContentsQueue.poll();
+ if (result == null) {
+ VirtualFile virtualFileToLoad = myFilesToLoadQueue.poll();
+ while (virtualFileToLoad != null) {
+ if (isValidFile(virtualFileToLoad)) {
+ FileContent content = new FileContent(virtualFileToLoad);
+ try {
+ content.getBytes();
+ return content;
+ } catch (Throwable t) {
+ if (t instanceof IOException || t instanceof InvalidVirtualFileAccessException) {
+ LOG.info(t);
+ } else {
+ LOG.error(t);
+ }
+ }
+ }
+ virtualFileToLoad = myFilesToLoadQueue.poll();
+ }
+
+ // take last content which is loaded by another thread
+ while(!myContentLoadingThreadTerminated) {
+ try {
+ result = myLoadedContentsQueue.poll(300, TimeUnit.MILLISECONDS);
+ if (result != null) break;
+ } catch (InterruptedException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+ }
+ } else {
+ try {
+ result = myLoadedContentsQueue.poll(300, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException ex) {
+ throw new RuntimeException(ex);
}
}
- }
- catch (InterruptedException e) {
- throw new RuntimeException(e);
+ if (result == null && myContentLoadingThreadTerminated) {
+ return null;
+ }
}
final VirtualFile file = result.getVirtualFile();
if (file == null) {
try {
- myQueue.put(result); // put it back to notify the others
+ myLoadedContentsQueue.put(result); // put it back to notify the others
}
catch (InterruptedException ignore) {
// should not happen
}
return null;
}
- synchronized (this) {
- try {
- myTotalSize -= result.getLength();
- }
- finally {
- notifyAll();
- }
+
+ synchronized (myProceedWithLoadingLock) {
+ myLoadedBytesInQueue -= result.getLength();
+ myProceedWithLoadingLock.notifyAll(); // we actually ask only content loading thread to proceed, so there should not be much difference with plain notify
}
return result;
}
- public synchronized void release(@NotNull FileContent content) {
- myTakenSize -= content.getLength();
- notifyAll();
+ public void release(@NotNull FileContent content) {
+ synchronized (myProceedWithProcessingLock) {
+ myBytesBeingProcessed -= content.getLength();
+ myProceedWithProcessingLock.notifyAll(); // ask all sleeping threads to proceed, there can be more than one of them
+ }
}
- public synchronized void pushback(@NotNull FileContent content) {
- myPushbackBuffer.add(content);
+ public void pushback(@NotNull FileContent content) {
+ synchronized (myProceedWithLoadingLock) {
+ myLoadedBytesInQueue += content.getLength();
+ }
+ myLoadedContentsQueue.addFirst(content);
}
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectImpl.java b/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectImpl.java
index 995c845..5e7ccd0 100644
--- a/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectImpl.java
@@ -438,15 +438,16 @@
}
}
+ @NotNull
@Override
- public <T> T[] getExtensions(final ExtensionPointName<T> extensionPointName) {
+ public <T> T[] getExtensions(@NotNull final ExtensionPointName<T> extensionPointName) {
return Extensions.getArea(this).getExtensionPoint(extensionPointName).getExtensions();
}
public String getDefaultName() {
if (isDefault()) return TEMPLATE_PROJECT_NAME;
- return getStateStore().getProjectName();
+ return getStateStore().getProjectName();
}
private class MyProjectManagerListener extends ProjectManagerAdapter {
diff --git a/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java
index ddd2f2f..73025e5 100644
--- a/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java
@@ -450,7 +450,7 @@
if (!application.isHeadlessEnvironment() && !application.isUnitTestMode()) {
// should be invoked last
- StartupManager.getInstance(project).runWhenProjectIsInitialized(new Runnable() {
+ startupManager.runWhenProjectIsInitialized(new Runnable() {
@Override
public void run() {
final TrackingPathMacroSubstitutor macroSubstitutor =
diff --git a/platform/platform-impl/src/com/intellij/openapi/ui/FrameWrapper.java b/platform/platform-impl/src/com/intellij/openapi/ui/FrameWrapper.java
index efe1d7e..5cb962c 100644
--- a/platform/platform-impl/src/com/intellij/openapi/ui/FrameWrapper.java
+++ b/platform/platform-impl/src/com/intellij/openapi/ui/FrameWrapper.java
@@ -36,6 +36,7 @@
import com.intellij.openapi.wm.impl.IdeFrameImpl;
import com.intellij.openapi.wm.impl.IdeGlassPaneImpl;
import com.intellij.openapi.wm.impl.IdeMenuBar;
+import com.intellij.ui.AppUIUtil;
import com.intellij.ui.BalloonLayout;
import com.intellij.ui.FocusTrackback;
import com.intellij.util.ImageLoader;
@@ -71,6 +72,7 @@
protected StatusBar myStatusBar;
private boolean myShown;
private boolean myIsDialog;
+ private boolean myImageWasChanged;
public FrameWrapper(Project project) {
this(project, null);
@@ -159,7 +161,12 @@
} else {
((JDialog)frame).setTitle(myTitle);
}
- frame.setIconImage(myImage);
+ if (myImageWasChanged) {
+ frame.setIconImage(myImage);
+ }
+ else {
+ AppUIUtil.updateWindowIcon(myFrame);
+ }
if (restoreBounds) {
loadFrameState();
@@ -277,6 +284,7 @@
}
public void setImage(Image image) {
+ myImageWasChanged = true;
myImage = image;
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/ui/impl/DialogWrapperPeerImpl.java b/platform/platform-impl/src/com/intellij/openapi/ui/impl/DialogWrapperPeerImpl.java
index 1f93689..b3645a4 100644
--- a/platform/platform-impl/src/com/intellij/openapi/ui/impl/DialogWrapperPeerImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/ui/impl/DialogWrapperPeerImpl.java
@@ -112,6 +112,15 @@
window = focusedWindow;
}
}
+ if (window == null) {
+ IdeFrame[] frames = myWindowManager.getAllProjectFrames();
+ for (IdeFrame frame : frames) {
+ if (frame instanceof IdeFrameImpl && ((IdeFrameImpl)frame).isActive()) {
+ window = (IdeFrameImpl)frame;
+ break;
+ }
+ }
+ }
}
Window owner;
@@ -648,32 +657,34 @@
myFocusTrackback = new FocusTrackback(getDialogWrapper(), getParent(), true);
final DialogWrapper dialogWrapper = getDialogWrapper();
-
- pack();
-
- Dimension packedSize = getSize();
- Dimension minSize = getMinimumSize();
- setSize(Math.max(packedSize.width, minSize.width), Math.max(packedSize.height, minSize.height));
-
- setSize((int)(getWidth() * dialogWrapper.getHorizontalStretch()), (int)(getHeight() * dialogWrapper.getVerticalStretch()));
-
- // Restore dialog's size and location
-
- myDimensionServiceKey = dialogWrapper.getDimensionKey();
+ boolean isAutoAdjustable = dialogWrapper.isAutoAdjustable();
Point location = null;
+ if (isAutoAdjustable) {
+ pack();
- if (myDimensionServiceKey != null) {
- final Project projectGuess = PlatformDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(this));
- location = DimensionService.getInstance().getLocation(myDimensionServiceKey, projectGuess);
- Dimension size = DimensionService.getInstance().getSize(myDimensionServiceKey, projectGuess);
- if (size != null) {
- myInitialSize = new Dimension(size);
- _setSizeForLocation(myInitialSize.width, myInitialSize.height, location);
+ Dimension packedSize = getSize();
+ Dimension minSize = getMinimumSize();
+ setSize(Math.max(packedSize.width, minSize.width), Math.max(packedSize.height, minSize.height));
+
+ setSize((int)(getWidth() * dialogWrapper.getHorizontalStretch()), (int)(getHeight() * dialogWrapper.getVerticalStretch()));
+
+ // Restore dialog's size and location
+
+ myDimensionServiceKey = dialogWrapper.getDimensionKey();
+
+ if (myDimensionServiceKey != null) {
+ final Project projectGuess = PlatformDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(this));
+ location = DimensionService.getInstance().getLocation(myDimensionServiceKey, projectGuess);
+ Dimension size = DimensionService.getInstance().getSize(myDimensionServiceKey, projectGuess);
+ if (size != null) {
+ myInitialSize = new Dimension(size);
+ _setSizeForLocation(myInitialSize.width, myInitialSize.height, location);
+ }
}
- }
- if (myInitialSize == null) {
- myInitialSize = getSize();
+ if (myInitialSize == null) {
+ myInitialSize = getSize();
+ }
}
if (location == null) {
@@ -687,10 +698,11 @@
setLocationRelativeTo(getOwner());
}
- final Rectangle bounds = getBounds();
- ScreenUtil.fitToScreen(bounds);
- setBounds(bounds);
-
+ if (isAutoAdjustable) {
+ final Rectangle bounds = getBounds();
+ ScreenUtil.fitToScreen(bounds);
+ setBounds(bounds);
+ }
addWindowListener(new WindowAdapter() {
@Override
public void windowActivated(WindowEvent e) {
@@ -1052,7 +1064,9 @@
@Override
@SuppressWarnings({"RefusedBequest"})
public void componentResized(ComponentEvent e) {
- UIUtil.adjustWindowToMinimumSize(getWindow());
+ if (getDialogWrapper().isAutoAdjustable()) {
+ UIUtil.adjustWindowToMinimumSize(getWindow());
+ }
}
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/DetectedPluginsPanel.java b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/DetectedPluginsPanel.java
index 14fb2eb..6e7b914 100644
--- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/DetectedPluginsPanel.java
+++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/DetectedPluginsPanel.java
@@ -20,6 +20,7 @@
import com.intellij.ide.plugins.PluginManagerMain;
import com.intellij.openapi.extensions.PluginId;
import com.intellij.openapi.ui.Splitter;
+import com.intellij.openapi.util.Comparing;
import com.intellij.ui.ColoredTableCellRenderer;
import com.intellij.ui.OrderPanel;
import com.intellij.ui.ScrollPaneFactory;
@@ -56,8 +57,15 @@
final int column) {
final PluginDownloader downloader = (PluginDownloader)value;
if (downloader != null) {
- append(downloader.getPluginName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
+ final String pluginName = downloader.getPluginName();
+ append(pluginName, SimpleTextAttributes.REGULAR_ATTRIBUTES);
final IdeaPluginDescriptor ideaPluginDescriptor = PluginManager.getPlugin(PluginId.getId(downloader.getPluginId()));
+ if (ideaPluginDescriptor != null) {
+ final String oldPluginName = ideaPluginDescriptor.getName();
+ if (!Comparing.strEqual(pluginName, oldPluginName)) {
+ append(" - " + oldPluginName, SimpleTextAttributes.REGULAR_ATTRIBUTES);
+ }
+ }
final String loadedVersion = downloader.getPluginVersion();
if (loadedVersion != null || (ideaPluginDescriptor != null && ideaPluginDescriptor.getVersion() != null)) {
final String installedVersion = ideaPluginDescriptor != null && ideaPluginDescriptor.getVersion() != null
diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/PluginDownloader.java b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/PluginDownloader.java
index 5c55bd4..e68c53b 100644
--- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/PluginDownloader.java
+++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/PluginDownloader.java
@@ -19,6 +19,7 @@
import com.intellij.ide.plugins.*;
import com.intellij.ide.startup.StartupActionScriptManager;
import com.intellij.ide.util.PropertiesComponent;
+import com.intellij.openapi.application.ApplicationInfo;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.diagnostic.Logger;
@@ -132,7 +133,7 @@
return false; //was not updated
}
- if (PluginManager.isIncompatible(actualDescriptor)) {
+ if (PluginManagerCore.isIncompatible(actualDescriptor)) {
return false; //shouldn't happen
}
@@ -143,7 +144,7 @@
@Nullable
public static IdeaPluginDescriptorImpl loadDescriptionFromJar(final File file) throws IOException {
- IdeaPluginDescriptorImpl descriptor = PluginManager.loadDescriptorFromJar(file);
+ IdeaPluginDescriptorImpl descriptor = PluginManagerCore.loadDescriptorFromJar(file);
if (descriptor == null) {
if (file.getName().endsWith(".zip")) {
final File outputDir = FileUtil.createTempDirectory("plugin", "");
@@ -155,7 +156,7 @@
});
final File[] files = outputDir.listFiles();
if (files != null && files.length == 1) {
- descriptor = PluginManager.loadDescriptor(files[0], PluginManager.PLUGIN_XML);
+ descriptor = PluginManagerCore.loadDescriptor(files[0], PluginManagerCore.PLUGIN_XML);
}
}
finally {
@@ -360,8 +361,9 @@
}
if (url == null) {
String uuid = UpdateChecker.getInstallationUID(PropertiesComponent.getInstance());
+ String buildNumber = ApplicationInfo.getInstance().getBuild().asString();
url = RepositoryHelper.getDownloadUrl() + URLEncoder.encode(descriptor.getPluginId().getIdString(), "UTF8") +
- "&build=" + RepositoryHelper.getDownloadBuildNumber() + "&uuid=" + URLEncoder.encode(uuid, "UTF8");
+ "&build=" + buildNumber + "&uuid=" + URLEncoder.encode(uuid, "UTF8");
}
PluginDownloader downloader = new PluginDownloader(descriptor.getPluginId().getIdString(), url, null, null, descriptor.getName());
diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateChecker.java b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateChecker.java
old mode 100755
new mode 100644
index 2efce10..d8178d9
--- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateChecker.java
+++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateChecker.java
@@ -15,7 +15,6 @@
*/
package com.intellij.openapi.updateSettings.impl;
-import com.google.common.net.HttpHeaders;
import com.intellij.ide.IdeBundle;
import com.intellij.ide.plugins.*;
import com.intellij.ide.reporter.ConnectionException;
@@ -221,6 +220,7 @@
if (!toUpdate.isEmpty()) {
try {
final List<IdeaPluginDescriptor> process = RepositoryHelper.loadPluginsFromRepository(indicator);
+ final List<String> disabledPlugins = PluginManagerCore.getDisabledPlugins();
for (IdeaPluginDescriptor loadedPlugin : process) {
final String idString = loadedPlugin.getPluginId().getIdString();
if (!toUpdate.containsKey(idString)) continue;
@@ -229,7 +229,9 @@
prepareToInstall(downloaded, loadedPlugin);
} else if (StringUtil.compareVersionNumbers(loadedPlugin.getVersion(), installedPlugin.getVersion()) > 0) {
updateSettings.myOutdatedPlugins.add(idString);
- prepareToInstall(downloaded, loadedPlugin);
+ if (!disabledPlugins.contains(idString)) {
+ prepareToInstall(downloaded, loadedPlugin);
+ }
}
}
}
@@ -739,27 +741,7 @@
OutputStream out = new BufferedOutputStream(new FileOutputStream(tempFile));
try {
- URL requestUrl = new URL(new URL(getPatchesUrl()), fileName);
- URLConnection connection;
-
- int followCount = 2;
- while(true) {
- connection = requestUrl.openConnection();
-
- if (connection instanceof HttpURLConnection) {
- HttpURLConnection hcnx = (HttpURLConnection)connection;
- int code = hcnx.getResponseCode();
- if (code >= 301 && code <= 307 && --followCount >= 0) {
- String loc = hcnx.getHeaderField(HttpHeaders.LOCATION);
- if (loc != null) {
- requestUrl = new URL(loc);
- continue;
- }
- }
- }
- break;
- }
-
+ URLConnection connection = new URL(new URL(getPatchesUrl()), fileName).openConnection();
try {
InputStream in = UrlConnectionUtil.getConnectionInputStreamWithException(connection, i);
try {
diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdatesXmlLoader.java b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdatesXmlLoader.java
old mode 100755
new mode 100644
index 0c33e2c..d1010f5
--- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdatesXmlLoader.java
+++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdatesXmlLoader.java
@@ -16,7 +16,6 @@
package com.intellij.openapi.updateSettings.impl;
-import com.google.common.net.HttpHeaders;
import com.intellij.ide.IdeBundle;
import com.intellij.ide.reporter.ConnectionException;
import com.intellij.openapi.application.ApplicationManager;
@@ -25,7 +24,6 @@
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.net.HttpConfigurable;
-import org.apache.commons.httpclient.HttpStatus;
import org.jdom.JDOMException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -33,9 +31,7 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
-import java.net.HttpURLConnection;
import java.net.URL;
-import java.net.URLConnection;
import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;
@@ -71,27 +67,7 @@
URL requestUrl = prepareRequestUrl(updateUrl);
- URLConnection cnx;
- int followCount = 2;
- while(true) {
- cnx = requestUrl.openConnection();
-
- if (cnx instanceof HttpURLConnection) {
- HttpURLConnection hcnx = (HttpURLConnection)cnx;
- int code = hcnx.getResponseCode();
- if (code >= 301 && code <= 307 && --followCount >= 0) {
- String loc = hcnx.getHeaderField(HttpHeaders.LOCATION);
- if (loc != null) {
- prepareUrl(loc);
- requestUrl = prepareRequestUrl(loc);
- continue;
- }
- }
- }
- break;
- }
-
- final InputStream inputStream = cnx.getInputStream();
+ final InputStream inputStream = requestUrl.openStream();
Reader reader = new InputStreamReader(inputStream);
try {
return new UpdatesInfo(JDOMUtil.loadDocument(inputStream).getRootElement());
diff --git a/platform/platform-impl/src/com/intellij/openapi/vcs/impl/FileStatusManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/vcs/impl/FileStatusManagerImpl.java
index fb64f71..70100dc 100644
--- a/platform/platform-impl/src/com/intellij/openapi/vcs/impl/FileStatusManagerImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/vcs/impl/FileStatusManagerImpl.java
@@ -36,6 +36,7 @@
import com.intellij.openapi.vcs.FileStatus;
import com.intellij.openapi.vcs.FileStatusListener;
import com.intellij.openapi.vcs.FileStatusManager;
+import com.intellij.openapi.vfs.VFileProperty;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.testFramework.LightVirtualFile;
import com.intellij.util.ThreeState;
@@ -139,7 +140,7 @@
}
public static FileStatus getDefaultStatus(@NotNull final VirtualFile file) {
- return file.isValid() && file.is(VirtualFile.PROP_SPECIAL) ? FileStatus.IGNORED : FileStatus.NOT_CHANGED;
+ return file.isValid() && file.is(VFileProperty.SPECIAL) ? FileStatus.IGNORED : FileStatus.NOT_CHANGED;
}
public void projectClosed() {
diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/jar/JarFileSystemImpl.java b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/jar/JarFileSystemImpl.java
index 32e02ea..9cdc900 100644
--- a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/jar/JarFileSystemImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/jar/JarFileSystemImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -49,13 +49,15 @@
private static final class JarFileSystemImplLock { }
private static final JarFileSystemImplLock LOCK = new JarFileSystemImplLock();
- private final Set<String> myNoCopyJarPaths =
- SystemProperties.getBooleanProperty("idea.jars.nocopy", !SystemInfo.isWindows) ? null : new ConcurrentHashSet<String>(FileUtil.PATH_HASHING_STRATEGY);
+ private final Set<String> myNoCopyJarPaths;
private File myNoCopyJarDir;
private final Map<String, JarHandler> myHandlers = new THashMap<String, JarHandler>(FileUtil.PATH_HASHING_STRATEGY);
private String[] jarPathsCache;
public JarFileSystemImpl(MessageBus bus) {
+ boolean noCopy = SystemProperties.getBooleanProperty("idea.jars.nocopy", !SystemInfo.isWindows);
+ myNoCopyJarPaths = noCopy ? null : new ConcurrentHashSet<String>(FileUtil.PATH_HASHING_STRATEGY);
+
bus.connect().subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener.Adapter() {
@Override
public void after(@NotNull final List<? extends VFileEvent> events) {
diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemBase.java b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemBase.java
index 9da0108..59023d3 100644
--- a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemBase.java
+++ b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemBase.java
@@ -474,7 +474,7 @@
}
private static boolean shallUseSafeStream(final Object requestor, @NotNull VirtualFile file) {
- return requestor instanceof SafeWriteRequestor && GeneralSettings.getInstance().isUseSafeWrite() && !file.isSymLink();
+ return requestor instanceof SafeWriteRequestor && GeneralSettings.getInstance().isUseSafeWrite() && !file.is(VFileProperty.SYMLINK);
}
@Override
diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/VfsImplUtil.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/VfsImplUtil.java
index 20dd498..bc5afa0 100644
--- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/VfsImplUtil.java
+++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/VfsImplUtil.java
@@ -18,6 +18,7 @@
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.openapi.vfs.VFileProperty;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -42,7 +43,7 @@
for (String pathElement : data.second) {
if (pathElement.isEmpty() || ".".equals(pathElement)) continue;
if ("..".equals(pathElement)) {
- if (file.isSymLink()) {
+ if (file.is(VFileProperty.SYMLINK)) {
final NewVirtualFile canonicalFile = file.getCanonicalFile();
file = canonicalFile != null ? canonicalFile.getParent() : null;
}
@@ -71,7 +72,7 @@
for (String pathElement : data.second) {
if (pathElement.isEmpty() || ".".equals(pathElement)) continue;
if ("..".equals(pathElement)) {
- if (file.isSymLink()) {
+ if (file.is(VFileProperty.SYMLINK)) {
final String canonicalPath = file.getCanonicalPath();
final NewVirtualFile canonicalFile = canonicalPath != null ? findFileByPathIfCached(vfs, canonicalPath) : null;
file = canonicalFile != null ? canonicalFile.getParent() : null;
@@ -101,7 +102,7 @@
for (String pathElement : data.second) {
if (pathElement.isEmpty() || ".".equals(pathElement)) continue;
if ("..".equals(pathElement)) {
- if (file.isSymLink()) {
+ if (file.is(VFileProperty.SYMLINK)) {
final String canonicalPath = file.getCanonicalPath();
final NewVirtualFile canonicalFile = canonicalPath != null ? refreshAndFindFileByPath(vfs, canonicalPath) : null;
file = canonicalFile != null ? canonicalFile.getParent() : null;
diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/FileNameCache.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/FileNameCache.java
index 5e6b315..1afa309 100644
--- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/FileNameCache.java
+++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/FileNameCache.java
@@ -33,7 +33,14 @@
public class FileNameCache {
private static final PersistentStringEnumerator ourNames = FSRecords.getNames();
@NonNls private static final String EMPTY = "";
- private static final IntSLRUCache<IntObjectLinkedMap.MapEntry<Object>> ourNameCache = new IntSLRUCache<IntObjectLinkedMap.MapEntry<Object>>(40000, 20000);
+ @SuppressWarnings("unchecked") private static final IntSLRUCache<IntObjectLinkedMap.MapEntry<Object>>[] ourNameCache = new IntSLRUCache[16];
+ static {
+ final int protectedSize = 40000 / ourNameCache.length;
+ final int probationalSize = 20000 / ourNameCache.length;
+ for(int i = 0; i < ourNameCache.length; ++i) {
+ ourNameCache[i] = new IntSLRUCache<IntObjectLinkedMap.MapEntry<Object>>(protectedSize, probationalSize);
+ }
+ }
public static int storeName(@NotNull String name) {
final int idx = FSRecords.getNameId(name);
@@ -50,8 +57,9 @@
Object rawName = convertToBytesIfAsciiString(name);
IntObjectLinkedMap.MapEntry<Object> entry = new IntObjectLinkedMap.MapEntry<Object>(id, rawName);
- synchronized (ourNameCache) {
- return ourNameCache.cacheEntry(entry);
+ final int stripe = id % ourNameCache.length;
+ synchronized (ourNameCache[stripe]) {
+ return ourNameCache[stripe].cacheEntry(entry);
}
}
@@ -72,8 +80,9 @@
@NotNull
private static IntObjectLinkedMap.MapEntry<Object> getEntry(int id) {
- synchronized (ourNameCache) {
- IntObjectLinkedMap.MapEntry<Object> entry = ourNameCache.getCachedEntry(id);
+ final int stripe = id % ourNameCache.length;
+ synchronized (ourNameCache[stripe]) {
+ IntObjectLinkedMap.MapEntry<Object> entry = ourNameCache[stripe].getCachedEntry(id);
if (entry != null) {
return entry;
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VirtualDirectoryImpl.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VirtualDirectoryImpl.java
index f51b26d..47f7794 100644
--- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VirtualDirectoryImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VirtualDirectoryImpl.java
@@ -100,8 +100,8 @@
boolean ensureCanonicalName,
@NotNull NewVirtualFileSystem delegate) {
boolean ignoreCase = !delegate.isCaseSensitive();
- Comparer comparer = getComparer(name, ignoreCase);
- VirtualFileSystemEntry result = doFindChild(name, ensureCanonicalName, delegate, comparer);
+ Comparator comparator = getComparator(name, ignoreCase);
+ VirtualFileSystemEntry result = doFindChild(name, ensureCanonicalName, delegate, comparator);
if (result == NULL_VIRTUAL_FILE) {
result = doRefresh ? createAndFindChildWithEventFire(name, delegate) : null;
}
@@ -113,15 +113,15 @@
}
if (result == null) {
- addToAdoptedChildren(name, !delegate.isCaseSensitive(), comparer);
+ addToAdoptedChildren(name, !delegate.isCaseSensitive(), comparator);
}
return result;
}
private synchronized void addToAdoptedChildren(@NotNull final String name,
final boolean ignoreCase,
- @NotNull Comparer comparer) {
- long r = findIndexInBoth(myChildren, comparer);
+ @NotNull Comparator comparator) {
+ long r = findIndexInBoth(myChildren, comparator);
int indexInReal = (int)(r >> 32);
int indexInAdopted = (int)r;
if (indexInAdopted >= 0) return; //already added
@@ -144,9 +144,9 @@
}
@Nullable // null if there can't be a child with this name, NULL_VIRTUAL_FILE
- private synchronized VirtualFileSystemEntry doFindChildInArray(@NotNull Comparer comparer) {
+ private synchronized VirtualFileSystemEntry doFindChildInArray(@NotNull Comparator comparator) {
VirtualFileSystemEntry[] array = myChildren;
- long r = findIndexInBoth(array, comparer);
+ long r = findIndexInBoth(array, comparator);
int indexInReal = (int)(r >> 32);
int indexInAdopted = (int)r;
if (indexInAdopted >= 0) return NULL_VIRTUAL_FILE;
@@ -161,12 +161,12 @@
private VirtualFileSystemEntry doFindChild(@NotNull String name,
boolean ensureCanonicalName,
@NotNull NewVirtualFileSystem delegate,
- @NotNull Comparer comparer) {
+ @NotNull Comparator comparator) {
if (name.isEmpty()) {
return null;
}
- VirtualFileSystemEntry found = doFindChildInArray(comparer);
+ VirtualFileSystemEntry found = doFindChildInArray(comparator);
if (found != null) return found;
if (allChildrenLoaded()) {
@@ -187,7 +187,7 @@
}
// maybe another doFindChild() sneaked in the middle
VirtualFileSystemEntry[] array = myChildren;
- long r = findIndexInBoth(array, comparer);
+ long r = findIndexInBoth(array, comparator);
int indexInReal = (int)(r >> 32);
int indexInAdopted = (int)r;
if (indexInAdopted >= 0) return NULL_VIRTUAL_FILE;
@@ -214,8 +214,8 @@
}
@NotNull
- private static Comparer getComparer(@NotNull final String name, final boolean ignoreCase) {
- return new Comparer() {
+ private static Comparator getComparator(@NotNull final String name, final boolean ignoreCase) {
+ return new Comparator() {
@Override
public int compareMyKeyTo(@NotNull VirtualFileSystemEntry file) {
return -file.compareNameTo(name, ignoreCase);
@@ -388,19 +388,19 @@
int start,
int end,
final boolean isAdopted,
- @NotNull final Comparer comparer) {
- return binSearch(array, start, end, new Comparer() {
+ @NotNull final Comparator comparator) {
+ return binSearch(array, start, end, new Comparator() {
@Override
public int compareMyKeyTo(@NotNull VirtualFileSystemEntry file) {
if (isAdopted && !isAdoptedChild(file)) return 1;
if (!isAdopted && isAdoptedChild(file)) return -1;
- return comparer.compareMyKeyTo(file);
+ return comparator.compareMyKeyTo(file);
}
});
}
// returns two int indices packed into one long. left index is for the real file array half, right is for the adopted children name array
- private static long findIndexInBoth(@NotNull VirtualFileSystemEntry[] array, @NotNull Comparer comparer) {
+ private static long findIndexInBoth(@NotNull VirtualFileSystemEntry[] array, @NotNull Comparator comparator) {
int high = array.length - 1;
if (high == -1) {
return pack(-1, -1);
@@ -409,7 +409,7 @@
boolean startInAdopted = isAdoptedChild(array[low]);
boolean endInAdopted = isAdoptedChild(array[high]);
if (startInAdopted == endInAdopted) {
- int index = findIndexInOneHalf(array, low, high + 1, startInAdopted, comparer);
+ int index = findIndexInOneHalf(array, low, high + 1, startInAdopted, comparator);
int otherIndex = startInAdopted ? -1 : -array.length - 1;
return startInAdopted ? pack(otherIndex, index) : pack(index, otherIndex);
}
@@ -420,15 +420,15 @@
while (low <= high) {
mid = low + high >>> 1;
VirtualFileSystemEntry file = array[mid];
- cmp = comparer.compareMyKeyTo(file);
+ cmp = comparator.compareMyKeyTo(file);
adopted = isAdoptedChild(file);
if (cmp == 0) {
foundIndex = mid;
break;
}
if ((adopted || cmp <= 0) && (!adopted || cmp >= 0)) {
- int indexInAdopted = findIndexInOneHalf(array, mid + 1, high + 1, true, comparer);
- int indexInReal = findIndexInOneHalf(array, low, mid, false, comparer);
+ int indexInAdopted = findIndexInOneHalf(array, mid + 1, high + 1, true, comparator);
+ int indexInReal = findIndexInOneHalf(array, low, mid, false, comparator);
return pack(indexInReal, indexInAdopted);
}
@@ -444,7 +444,7 @@
if (cmp != 0) foundIndex = -low-1;
int newStart = adopted ? low : mid + 1;
int newEnd = adopted ? mid + 1 : high + 1;
- int theOtherHalfIndex = newStart < newEnd ? findIndexInOneHalf(array, newStart, newEnd, !adopted, comparer) : -newStart-1;
+ int theOtherHalfIndex = newStart < newEnd ? findIndexInOneHalf(array, newStart, newEnd, !adopted, comparator) : -newStart-1;
return adopted ? pack(theOtherHalfIndex, foundIndex) : pack(foundIndex, theOtherHalfIndex);
}
@@ -456,8 +456,8 @@
@Nullable
public synchronized NewVirtualFile findChildIfCached(@NotNull String name) {
final boolean ignoreCase = !getFileSystem().isCaseSensitive();
- Comparer comparer = getComparer(name, ignoreCase);
- VirtualFileSystemEntry found = doFindChildInArray(comparer);
+ Comparator comparator = getComparator(name, ignoreCase);
+ VirtualFileSystemEntry found = doFindChildInArray(comparator);
return found == NULL_VIRTUAL_FILE ? null : found;
}
@@ -495,7 +495,7 @@
result = EMPTY_ARRAY;
}
else {
- Arrays.sort(childrenIds, new Comparator<FSRecords.NameId>() {
+ Arrays.sort(childrenIds, new java.util.Comparator<FSRecords.NameId>() {
@Override
public int compare(FSRecords.NameId o1, FSRecords.NameId o2) {
String name1 = o1.name;
@@ -616,7 +616,7 @@
VirtualFileSystemEntry[] array = myChildren;
final String childName = child.getName();
final boolean ignoreCase = !getFileSystem().isCaseSensitive();
- long r = findIndexInBoth(array, getComparer(childName, ignoreCase));
+ long r = findIndexInBoth(array, getComparator(childName, ignoreCase));
int indexInReal = (int)(r >> 32);
int indexInAdopted = (int)r;
@@ -645,7 +645,7 @@
boolean ignoreCase = !getFileSystem().isCaseSensitive();
String name = file.getName();
- addToAdoptedChildren(name, ignoreCase, getComparer(name, ignoreCase));
+ addToAdoptedChildren(name, ignoreCase, getComparator(name, ignoreCase));
assertConsistency(myChildren, ignoreCase, file);
}
@@ -678,7 +678,7 @@
}
private int getAdoptedChildrenStart() {
- int index = binSearch(myChildren, 0, myChildren.length, new Comparer() {
+ int index = binSearch(myChildren, 0, myChildren.length, new Comparator() {
@Override
public int compareMyKeyTo(@NotNull VirtualFileSystemEntry v) {
return isAdoptedChild(v) ? -1 : 1;
@@ -691,21 +691,21 @@
return v.getParent() == NULL_VIRTUAL_FILE;
}
- interface Comparer {
+ private interface Comparator {
int compareMyKeyTo(@NotNull VirtualFileSystemEntry file);
}
private static int binSearch(@NotNull VirtualFileSystemEntry[] array,
int start,
int end,
- @NotNull Comparer comparer) {
+ @NotNull Comparator comparator) {
int low = start;
int high = end - 1;
assert low >= 0 && low <= array.length;
while (low <= high) {
int mid = low + high >>> 1;
- int cmp = comparer.compareMyKeyTo(array[mid]);
+ int cmp = comparator.compareMyKeyTo(array[mid]);
if (cmp > 0) {
low = mid + 1;
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VirtualFileSystemEntry.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VirtualFileSystemEntry.java
index 847a74a..d79fa6b 100644
--- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VirtualFileSystemEntry.java
+++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VirtualFileSystemEntry.java
@@ -23,6 +23,7 @@
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
+import com.intellij.openapi.vfs.VFileProperty;
import com.intellij.openapi.vfs.VfsBundle;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.encoding.EncodingManager;
@@ -45,6 +46,7 @@
*/
public abstract class VirtualFileSystemEntry extends NewVirtualFile {
public static final VirtualFileSystemEntry[] EMPTY_ARRAY = new VirtualFileSystemEntry[0];
+
protected static final PersistentFS ourPersistence = PersistentFS.getInstance();
private static final Key<String> SYMLINK_TARGET = Key.create("local.vfs.symlink.target");
@@ -53,10 +55,13 @@
private static final int IS_SYMLINK_FLAG = 0x20000000;
private static final int HAS_SYMLINK_FLAG = 0x40000000;
private static final int IS_SPECIAL_FLAG = 0x80000000;
+ private static final int IS_WRITABLE_FLAG = 0x01000000;
+ private static final int IS_HIDDEN_FLAG = 0x02000000;
private static final int INDEXED_FLAG = 0x04000000;
- static final int CHILDREN_CACHED = 0x08000000;
+ static final int CHILDREN_CACHED = 0x08000000;
+
private static final int ALL_FLAGS_MASK =
- DIRTY_FLAG | IS_SYMLINK_FLAG | HAS_SYMLINK_FLAG | IS_SPECIAL_FLAG | INDEXED_FLAG | CHILDREN_CACHED;
+ DIRTY_FLAG | IS_SYMLINK_FLAG | HAS_SYMLINK_FLAG | IS_SPECIAL_FLAG | IS_WRITABLE_FLAG | IS_HIDDEN_FLAG | INDEXED_FLAG | CHILDREN_CACHED;
private volatile int myNameId;
private volatile VirtualDirectoryImpl myParent;
@@ -74,7 +79,10 @@
setFlagInt(IS_SPECIAL_FLAG, PersistentFS.isSpecialFile(attributes));
updateLinkStatus();
}
-
+
+ setFlagInt(IS_WRITABLE_FLAG, PersistentFS.isWritable(attributes));
+ setFlagInt(IS_HIDDEN_FLAG, PersistentFS.isHidden(attributes));
+
setModificationStamp(LocalTimeCounter.currentTime());
}
@@ -83,7 +91,7 @@
}
private void updateLinkStatus() {
- boolean isSymLink = isSymLink();
+ boolean isSymLink = is(VFileProperty.SYMLINK);
if (isSymLink) {
String target = myParent.getFileSystem().resolveSymLink(this);
putUserData(SYMLINK_TARGET, target != null ? FileUtil.toSystemIndependentName(target) : target);
@@ -237,7 +245,7 @@
@Override
public boolean isWritable() {
- return ourPersistence.isWritable(this);
+ return getFlagInt(IS_WRITABLE_FLAG);
}
@Override
@@ -405,21 +413,22 @@
}
@Override
- public boolean isSymLink() {
- return getFlagInt(IS_SYMLINK_FLAG);
+ public boolean is(@NotNull VFileProperty property) {
+ if (property == VFileProperty.SPECIAL) return getFlagInt(IS_SPECIAL_FLAG);
+ if (property == VFileProperty.HIDDEN) return getFlagInt(IS_HIDDEN_FLAG);
+ if (property == VFileProperty.SYMLINK) return getFlagInt(IS_SYMLINK_FLAG);
+ return super.is(property);
}
- @Override
- public boolean is(String property) {
- if (property == PROP_SPECIAL) return getFlagInt(IS_SPECIAL_FLAG);
- if (property == PROP_HIDDEN) return ourPersistence.isHidden(this);
- return super.is(property);
+ public void updateProperty(String property, boolean value) {
+ if (property == PROP_WRITABLE) setFlagInt(IS_WRITABLE_FLAG, value);
+ if (property == PROP_HIDDEN) setFlagInt(IS_HIDDEN_FLAG, value);
}
@Override
public String getCanonicalPath() {
if (getFlagInt(HAS_SYMLINK_FLAG)) {
- if (isSymLink()) {
+ if (is(VFileProperty.SYMLINK)) {
return getUserData(SYMLINK_TARGET);
}
VirtualDirectoryImpl parent = myParent;
diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFS.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFS.java
index b810ede..52a2fc0 100644
--- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFS.java
+++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFS.java
@@ -72,8 +72,10 @@
public abstract int getFileAttributes(int id);
public static boolean isDirectory(@Attributes int attributes) { return isSet(attributes, IS_DIRECTORY_FLAG); }
+ public static boolean isWritable(@Attributes int attributes) { return !isSet(attributes, IS_READ_ONLY); }
public static boolean isSymLink(@Attributes int attributes) { return isSet(attributes, IS_SYMLINK); }
public static boolean isSpecialFile(@Attributes int attributes) { return isSet(attributes, IS_SPECIAL); }
+ public static boolean isHidden(@Attributes int attributes) { return isSet(attributes, IS_HIDDEN); }
@Nullable
public abstract NewVirtualFile findFileByIdIfCached(int id);
diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSImpl.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSImpl.java
index e90fc5c..a631f99 100644
--- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSImpl.java
@@ -1164,12 +1164,14 @@
FSRecords.setName(id, newName);
}
- private static void executeSetWritable(@NotNull VirtualFile file, final boolean writableFlag) {
+ private static void executeSetWritable(@NotNull VirtualFile file, boolean writableFlag) {
setFlag(file, IS_READ_ONLY, !writableFlag);
+ ((VirtualFileSystemEntry)file).updateProperty(VirtualFile.PROP_WRITABLE, writableFlag);
}
- private static void executeSetHidden(@NotNull VirtualFile file, final boolean hiddenFlag) {
+ private static void executeSetHidden(@NotNull VirtualFile file, boolean hiddenFlag) {
setFlag(file, IS_HIDDEN, hiddenFlag);
+ ((VirtualFileSystemEntry)file).updateProperty(VirtualFile.PROP_HIDDEN, hiddenFlag);
}
private static void setFlag(@NotNull VirtualFile file, int mask, boolean value) {
diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/RefreshWorker.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/RefreshWorker.java
index 0c18aa4..e11a9ef 100644
--- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/RefreshWorker.java
+++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/RefreshWorker.java
@@ -21,6 +21,7 @@
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileAttributes;
import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.openapi.vfs.VFileProperty;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.newvfs.NewVirtualFile;
@@ -194,7 +195,7 @@
}
if (SystemInfo.isWindows) {
- boolean currentHidden = file.is(VirtualFile.PROP_HIDDEN);
+ boolean currentHidden = file.is(VFileProperty.HIDDEN);
boolean upToDateHidden = attributes.isHidden();
if (currentHidden != upToDateHidden) {
scheduleAttributeChange(file, VirtualFile.PROP_HIDDEN, currentHidden, upToDateHidden);
@@ -221,8 +222,8 @@
@NotNull VirtualFile child,
@NotNull FileAttributes childAttributes) {
boolean currentIsDirectory = child.isDirectory();
- boolean currentIsSymlink = child.isSymLink();
- boolean currentIsSpecial = child.is(VirtualFile.PROP_SPECIAL);
+ boolean currentIsSymlink = child.is(VFileProperty.SYMLINK);
+ boolean currentIsSpecial = child.is(VFileProperty.SPECIAL);
boolean upToDateIsDirectory = childAttributes.isDirectory();
boolean upToDateIsSymlink = childAttributes.isSymLink();
boolean upToDateIsSpecial = childAttributes.isSpecial();
diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/ex/WindowManagerEx.java b/platform/platform-impl/src/com/intellij/openapi/wm/ex/WindowManagerEx.java
index 4adfdb9..36dd639 100644
--- a/platform/platform-impl/src/com/intellij/openapi/wm/ex/WindowManagerEx.java
+++ b/platform/platform-impl/src/com/intellij/openapi/wm/ex/WindowManagerEx.java
@@ -21,6 +21,7 @@
import com.intellij.openapi.wm.impl.CommandProcessor;
import com.intellij.openapi.wm.impl.DesktopLayout;
import com.intellij.openapi.wm.impl.IdeFrameImpl;
+import com.intellij.ui.AppIcon;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -41,6 +42,13 @@
public abstract IdeFrameImpl getFrame(@Nullable Project project);
+ @Override
+ public void requestUserAttention(@NotNull IdeFrame frame, boolean critical) {
+ Project project = frame.getProject();
+ if (project != null)
+ AppIcon.getInstance().requestAttention(project, critical);
+ }
+
public abstract IdeFrameImpl allocateFrame(Project project);
public abstract void releaseFrame(IdeFrameImpl frame);
diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeFrameImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeFrameImpl.java
index 52f7509..216f6a7 100644
--- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeFrameImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeFrameImpl.java
@@ -140,6 +140,7 @@
return;
}
+ myRootPane.setBorder(null);
boolean isNotClassic = Boolean.parseBoolean(String.valueOf(Toolkit.getDefaultToolkit().getDesktopProperty("win.xpstyle.themeActive")));
if (isNotClassic && (state & MAXIMIZED_BOTH) != 0) {
IdeFrame[] projectFrames = WindowManager.getInstance().getAllProjectFrames();
@@ -159,9 +160,6 @@
}
}
}
- else {
- myRootPane.setBorder(null);
- }
}
protected IdeRootPane createRootPane(ActionManagerEx actionManager,
@@ -536,6 +534,10 @@
if (myFrameDecorator != null) {
myFrameDecorator.toggleFullScreen(state);
}
+ IdeFrame[] frames = WindowManager.getInstance().getAllProjectFrames();
+ for (IdeFrame frame : frames) {
+ ((IdeFrameImpl)frame).updateBorder();
+ }
}
@Override
diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowHeader.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowHeader.java
index 86a848f..746c047 100644
--- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowHeader.java
+++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowHeader.java
@@ -17,6 +17,8 @@
import com.intellij.icons.AllIcons;
import com.intellij.ide.DataManager;
+import com.intellij.ide.ui.UISettings;
+import com.intellij.ide.ui.UISettingsListener;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.actionSystem.ex.ActionManagerEx;
@@ -51,7 +53,7 @@
/**
* @author pegov
*/
-public abstract class ToolWindowHeader extends JPanel implements Disposable {
+public abstract class ToolWindowHeader extends JPanel implements Disposable, UISettingsListener {
@NonNls private static final String HIDE_ACTIVE_WINDOW_ACTION_ID = "HideActiveWindow";
@NonNls private static final String HIDE_ACTIVE_SIDE_WINDOW_ACTION_ID = "HideSideWindows";
@@ -186,6 +188,13 @@
setOpaque(true);
setBorder(BorderFactory.createEmptyBorder(TabsUtil.TABS_BORDER, 1, TabsUtil.TABS_BORDER, 1));
+
+ UISettings.getInstance().addUISettingsListener(this, toolWindow.getContentUI());
+ }
+
+ @Override
+ public void uiSettingsChanged(UISettings source) {
+ clearCaches();
}
private void addDefaultActions(JPanel eastPanel) {
@@ -322,12 +331,16 @@
@Override
public void setUI(PanelUI ui) {
- myImage = null;
- myActiveImage = null;
+ clearCaches();
super.setUI(ui);
}
+ public void clearCaches() {
+ myImage = null;
+ myActiveImage = null;
+ }
+
@Override
protected void paintChildren(Graphics g) {
Graphics2D graphics = (Graphics2D) g.create();
diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowImpl.java
index 9645847..cc9180e 100644
--- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowImpl.java
@@ -71,7 +71,7 @@
private ToolWindowFactory myContentFactory;
private ActionCallback myActivation = new ActionCallback.Done();
- private BusyObject.Impl myShowing = new BusyObject.Impl() {
+ private final BusyObject.Impl myShowing = new BusyObject.Impl() {
@Override
public boolean isReady() {
return myComponent != null && myComponent.isShowing();
@@ -79,7 +79,7 @@
};
private boolean myUseLastFocused = true;
- private final static Logger LOG = Logger.getInstance(ToolWindowImpl.class);
+ private static final Logger LOG = Logger.getInstance(ToolWindowImpl.class);
ToolWindowImpl(final ToolWindowManagerImpl toolWindowManager, final String id, boolean canCloseContent, @Nullable final JComponent component) {
myToolWindowManager = toolWindowManager;
@@ -151,7 +151,7 @@
public final boolean isActive() {
ApplicationManager.getApplication().assertIsDispatchThread();
if (myToolWindowManager.isEditorComponentActive()) return false;
- return myToolWindowManager.isToolWindowActive(myId) || (myDecorator != null && myDecorator.isFocused());
+ return myToolWindowManager.isToolWindowActive(myId) || myDecorator != null && myDecorator.isFocused();
}
@Override
@@ -167,6 +167,7 @@
IdeFocusManager.getInstance(myToolWindowManager.getProject()).doWhenFocusSettlesDown(new Runnable() {
@Override
public void run() {
+ if (myContentManager.isDisposed()) return;
myContentManager.getReady(requestor).notify(result);
}
});
diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/BaseLabel.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/BaseLabel.java
index b8236b9..1e07167 100644
--- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/BaseLabel.java
+++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/BaseLabel.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -43,22 +43,17 @@
setActiveFg(DEFAULT_ACTIVE_FORE);
setPassiveFg(DEFAULT_PASSIVE_FORE);
myBold = bold;
- updateFont();
}
- public void updateUI() {
- super.updateUI();
- updateFont();
- }
-
- private void updateFont() {
- Font baseFont = getLabelFont();
+ @Override
+ public Font getFont() {
+ Font f = UIUtil.getLabelFont();
+ f = f.deriveFont(f.getStyle(), Math.max(11, f.getSize() - 2));
if (myBold) {
- setFont(baseFont.deriveFont(Font.BOLD));
+ f = f.deriveFont(Font.BOLD);
}
- else {
- setFont(baseFont);
- }
+
+ return f;
}
public static Font getLabelFont() {
@@ -125,7 +120,6 @@
}
myBold = false; //isSelected;
- updateFont();
}
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/EncodingPanel.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/EncodingPanel.java
index 848141b..9cce614 100644
--- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/EncodingPanel.java
+++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/EncodingPanel.java
@@ -187,7 +187,7 @@
}
}
- private void showPopup(MouseEvent e) {
+ private void showPopup(@NotNull MouseEvent e) {
if (!actionEnabled) {
return;
}
diff --git a/platform/platform-impl/src/com/intellij/ui/BalloonImpl.java b/platform/platform-impl/src/com/intellij/ui/BalloonImpl.java
index 8597661..934b02a 100644
--- a/platform/platform-impl/src/com/intellij/ui/BalloonImpl.java
+++ b/platform/platform-impl/src/com/intellij/ui/BalloonImpl.java
@@ -725,16 +725,21 @@
public void hide() {
+ hide(false);
+ }
+
+ @Override
+ public void hide(boolean ok) {
if (myDisposed) return;
- hideAndDispose();
+ hideAndDispose(ok);
}
public void addListener(JBPopupListener listener) {
myListeners.add(listener);
}
- private void hideAndDispose() {
+ private void hideAndDispose(final boolean ok) {
if (myDisposed) return;
myDisposed = true;
@@ -745,7 +750,7 @@
myFadedOut = true;
for (JBPopupListener each : myListeners) {
- each.onClosed(new LightweightWindowEvent(BalloonImpl.this));
+ each.onClosed(new LightweightWindowEvent(BalloonImpl.this, ok));
}
Disposer.dispose(BalloonImpl.this);
@@ -773,7 +778,7 @@
public void dispose() {
if (myDisposed) return;
- hideAndDispose();
+ hideAndDispose(false);
}
protected void onDisposed() {
diff --git a/platform/platform-impl/src/com/intellij/ui/EditorSettingsProvider.java b/platform/platform-impl/src/com/intellij/ui/EditorSettingsProvider.java
index bf5709a..6685d6c 100644
--- a/platform/platform-impl/src/com/intellij/ui/EditorSettingsProvider.java
+++ b/platform/platform-impl/src/com/intellij/ui/EditorSettingsProvider.java
@@ -21,5 +21,12 @@
* @author Konstantin Bulenkov
*/
public interface EditorSettingsProvider {
+ EditorSettingsProvider NO_WHITESPACE = new EditorSettingsProvider() {
+ @Override
+ public void customizeSettings(EditorEx editor) {
+ editor.getSettings().setWhitespacesShown(false);
+ }
+ };
+
void customizeSettings(EditorEx editor);
}
diff --git a/platform/platform-impl/src/com/intellij/ui/Splash.java b/platform/platform-impl/src/com/intellij/ui/Splash.java
index b9a5d3a..8115dda 100644
--- a/platform/platform-impl/src/com/intellij/ui/Splash.java
+++ b/platform/platform-impl/src/com/intellij/ui/Splash.java
@@ -54,12 +54,16 @@
private final JLabel myLabel;
private Icon myProgressTail;
-
-
public Splash(String imageName, final Color textColor) {
+ //It's a dirty hack to protect Splash Window to appear with a native window header on Ubuntu 13.04
+ super(SystemInfo.isLinux ? new Frame(ApplicationInfoImpl.getShadowInstance().getFullApplicationName()) {
+ {
+ setVisible(true);
+ }
+ } : null, false);
+
setUndecorated(true);
setResizable(false);
- setModal(false);
setFocusableWindowState(false);
Icon originalImage = IconLoader.getIcon(imageName);
@@ -97,6 +101,7 @@
public void show() {
super.show();
toFront();
+ //noinspection AssignmentToStaticFieldFromInstanceMethod
BOUNDS = getBounds();
//Sometimes this causes deadlock in EDT
// http://bugs.sun.com/view_bug.do?bug_id=6724890
@@ -105,6 +110,15 @@
}
@Override
+ public void hide() {
+ super.hide();
+ Window owner = getOwner();
+ if (SystemInfo.isLinux && owner != null) {
+ owner.setVisible(false);
+ }
+ }
+
+ @Override
public void showProgress(String message, float progress) {
if (getProgressColor() == null) return;
//myMessage = message;
diff --git a/platform/platform-impl/src/com/intellij/ui/content/impl/ContentManagerImpl.java b/platform/platform-impl/src/com/intellij/ui/content/impl/ContentManagerImpl.java
index ce28504..b38eaed 100644
--- a/platform/platform-impl/src/com/intellij/ui/content/impl/ContentManagerImpl.java
+++ b/platform/platform-impl/src/com/intellij/ui/content/impl/ContentManagerImpl.java
@@ -172,11 +172,7 @@
@Override
public boolean isCycleRoot() {
- if (myUI instanceof SwitchProvider) {
- return ((SwitchProvider)myUI).isCycleRoot();
- }
-
- return false;
+ return myUI instanceof SwitchProvider && ((SwitchProvider)myUI).isCycleRoot();
}
}
@@ -212,7 +208,7 @@
if (myContents.contains(content)) return;
((ContentImpl)content).setManager(this);
- final int insertIndex = (index == -1) ? myContents.size() : index;
+ final int insertIndex = index == -1 ? myContents.size() : index;
myContents.add(insertIndex, content);
content.addPropertyChangeListener(this);
fireContentAdded(content, insertIndex, ContentManagerEvent.ContentOperation.add);
@@ -531,9 +527,8 @@
if (requestFocus) {
return requestFocus(content, forcedFocus);
- } else {
- return new ActionCallback.Done();
}
+ return new ActionCallback.Done();
}
};
@@ -547,9 +542,8 @@
selection.run().notify(result);
}
});
- } else {
- return selection.run().notify(result);
}
+ return selection.run().notify(result);
}
else {
return selection.run().notify(result);
diff --git a/platform/platform-impl/src/com/intellij/ui/mac/MacFileChooserDialogImpl.java b/platform/platform-impl/src/com/intellij/ui/mac/MacFileChooserDialogImpl.java
index 5993a4b..fa81ab4 100644
--- a/platform/platform-impl/src/com/intellij/ui/mac/MacFileChooserDialogImpl.java
+++ b/platform/platform-impl/src/com/intellij/ui/mac/MacFileChooserDialogImpl.java
@@ -135,6 +135,7 @@
}
finally {
Foundation.cfRelease(self);
+ Foundation.cfRelease(contextInfo);
}
}
};
@@ -184,6 +185,8 @@
public void callback(ID self, String selector, ID toSelect) {
final ID nsOpenPanel = Foundation.getObjcClass("NSOpenPanel");
final ID chooser = invoke(nsOpenPanel, "openPanel");
+ // Release in OPEN_PANEL_DID_END panel
+ Foundation.cfRetain(chooser);
final FileChooserDescriptor chooserDescriptor = ourImplMap.get(self).myChooserDescriptor;
@@ -241,7 +244,7 @@
final ID focusedWindow = MacUtil.findWindowForTitle(activeWindowTitle);
if (focusedWindow != null) {
invoke(chooser, "beginSheetForDirectory:file:types:modalForWindow:modalDelegate:didEndSelector:contextInfo:",
- directory, file, types, focusedWindow, self, Foundation.createSelector("openPanelDidEnd:returnCode:contextInfo:"), null);
+ directory, file, types, focusedWindow, self, Foundation.createSelector("openPanelDidEnd:returnCode:contextInfo:"), chooser);
}
}
}
@@ -313,23 +316,13 @@
bar.disableUpdates();
}
- final ID autoReleasePool = createAutoReleasePool();
- try {
- final ID delegate = invoke(Foundation.getObjcClass("NSOpenPanelDelegate_"), "new");
- Foundation.cfRetain(delegate);
- ourImplMap.put(delegate, impl);
+ final ID delegate = invoke(Foundation.getObjcClass("NSOpenPanelDelegate_"), "new");
+ // Release in OPEN_PANEL_DID_END panel
+ Foundation.cfRetain(delegate);
+ ourImplMap.put(delegate, impl);
- final ID select = toSelect == null ? null : Foundation.nsString(toSelect);
-
- invoke(delegate, "performSelectorOnMainThread:withObject:waitUntilDone:", Foundation.createSelector("showOpenPanel:"), select, false);
- }
- finally {
- invoke(autoReleasePool, "release");
- }
- }
-
- private static ID createAutoReleasePool() {
- return invoke("NSAutoreleasePool", "new");
+ final ID select = toSelect == null ? null : Foundation.nsString(toSelect);
+ invoke(delegate, "performSelectorOnMainThread:withObject:waitUntilDone:", Foundation.createSelector("showOpenPanel:"), select, false);
}
private static ID invoke(@NotNull final String className, @NotNull final String selector, Object... args) {
diff --git a/platform/platform-impl/src/com/intellij/ui/mac/MacMessagesImpl.java b/platform/platform-impl/src/com/intellij/ui/mac/MacMessagesImpl.java
index e6c6b87..cf60575 100644
--- a/platform/platform-impl/src/com/intellij/ui/mac/MacMessagesImpl.java
+++ b/platform/platform-impl/src/com/intellij/ui/mac/MacMessagesImpl.java
@@ -21,12 +21,12 @@
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.openapi.wm.WindowManager;
-import com.intellij.ui.FocusTrackback;
import com.intellij.ui.mac.foundation.Foundation;
import com.intellij.ui.mac.foundation.ID;
import com.intellij.ui.mac.foundation.MacUtil;
import com.intellij.util.ui.UIUtil;
import com.sun.jna.Callback;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import sun.awt.SunToolkit;
@@ -52,13 +52,13 @@
private static final Callback SHEET_DID_END = new Callback() {
public void callback(ID self, String selector, ID alert, ID returnCode, ID contextInfo) {
- cfRelease(self);
synchronized (lock) {
Window documentRoot = windowFromId.get(contextInfo.longValue());
processResult(documentRoot);
resultsFromDocumentRoot.put(documentRoot, returnCode.intValue());
queuesFromDocumentRoot.get(windowFromId.get(contextInfo.longValue())).runFromQueue();
}
+ cfRelease(self);
}
};
@@ -114,6 +114,7 @@
invoke(alert, "beginSheetModalForWindow:modalDelegate:didEndSelector:contextInfo:", focusedWindow, self,
createSelector("alertDidEnd:returnCode:contextInfo:"), focusedWindow);
+ cfRelease(alert);
}
};
@@ -330,77 +331,213 @@
pumpEventsDocumentExclusively(w);
}
+ private static enum COMMON_DIALOG_PARAM_TYPE {
+ title,
+ message,
+ errorStyle,
+ doNotAskDialogOption1,
+ doNotAskDialogOption2,
+ nativeFocusedWindow
+ }
- public int showMessageDialog(final String title, final String message, final String[] buttons, final boolean errorStyle,
- @Nullable Window window, final int defaultOptionIndex,
- final int focusedOptionIndex, @Nullable final DialogWrapper.DoNotAskOption doNotAskDialogOption) {
+ private static enum MESSAGE_DIALOG_PARAM_TYPE {
+ buttonsArray,
+ errorStyle,
+ defaultOptionIndex,
+ focusedOptionIndex
+ }
+
+ private static enum ALERT_DIALOG_PARAM_TYPE {
+ defaultText,
+ alternateText,
+ otherText
+ }
+
+ private static class DialogParamsWrapper {
+ private ID window = null;
+ private HashMap params = null;
+ private DialogType dialogType = null;
+
+ private enum DialogType {
+ alert,
+ message
+ }
+
+ private DialogParamsWrapper(@NotNull DialogType t, @NotNull HashMap p) {
+ dialogType = t;
+ params = p;
+ }
+
+ private void setNativeWindow (final ID w) {
+ window = w;
+ }
+
+ private ID getParamsAsID() {
+ LOG.assertTrue(window != null, "Native window must be set first.");
+ params.put(COMMON_DIALOG_PARAM_TYPE.nativeFocusedWindow, window);
+
+ ID paramsAsID = null;
+
+ switch (dialogType) {
+ case alert: {
+ paramsAsID = getParamsForAlertDialog(params);
+ break;
+ }
+ case message: {
+ paramsAsID = getParamsForMessageDialog(params);
+ break;
+ }
+ }
+ return paramsAsID;
+ }
- Window foremostWindow = getForemostWindow(window);
- String foremostWindowTitle = getWindowTitle(foremostWindow);
+ private static ID getParamsForAlertDialog(HashMap params) {
+ return invoke("NSArray", "arrayWithObjects:",
+ params.get(COMMON_DIALOG_PARAM_TYPE.title),
+ params.get(ALERT_DIALOG_PARAM_TYPE.defaultText),
+ params.get(ALERT_DIALOG_PARAM_TYPE.alternateText),
+ params.get(ALERT_DIALOG_PARAM_TYPE.otherText),
+ params.get(COMMON_DIALOG_PARAM_TYPE.message),
+ params.get(COMMON_DIALOG_PARAM_TYPE.nativeFocusedWindow),
+ nsString(""),
+ params.get(COMMON_DIALOG_PARAM_TYPE.errorStyle),
+ params.get(COMMON_DIALOG_PARAM_TYPE.doNotAskDialogOption1),
+ params.get(COMMON_DIALOG_PARAM_TYPE.doNotAskDialogOption2),
+ null);
+ }
- Window documentRoot = getDocumentRootFromWindow(foremostWindow);
+ private static ID getParamsForMessageDialog(HashMap params) {
+ return invoke("NSArray", "arrayWithObjects:",
+ params.get(COMMON_DIALOG_PARAM_TYPE.title),
+ params.get(COMMON_DIALOG_PARAM_TYPE.message),
+ params.get(COMMON_DIALOG_PARAM_TYPE.nativeFocusedWindow),
+ nsString(""),
+ params.get(MESSAGE_DIALOG_PARAM_TYPE.errorStyle),
+ params.get(COMMON_DIALOG_PARAM_TYPE.doNotAskDialogOption1),
+ params.get(MESSAGE_DIALOG_PARAM_TYPE.defaultOptionIndex),
+ params.get(MESSAGE_DIALOG_PARAM_TYPE.focusedOptionIndex),
+ params.get(MESSAGE_DIALOG_PARAM_TYPE.buttonsArray),
+ params.get(COMMON_DIALOG_PARAM_TYPE.doNotAskDialogOption2),
+ null);
+ }
+ }
- final ID nativeFocusedWindow = MacUtil.findWindowForTitle(foremostWindowTitle);
- if (foremostWindow != null) {
+ public static int showAlertDialog(final String title,
+ final String defaultText,
+ @Nullable final String alternateText,
+ @Nullable final String otherText,
+ final String message,
+ @Nullable Window window ,
+ final boolean errorStyle,
+ @Nullable final DialogWrapper.DoNotAskOption doNotAskDialogOption) {
- final FocusTrackback[] focusTrackback = {new FocusTrackback(new Object(), documentRoot, true)};
+ HashMap params = new HashMap ();
- final ID delegate = invoke(Foundation.getObjcClass("NSAlertDelegate_"), "new");
- invoke(delegate, "autorelease");
- cfRetain(delegate);
+ ID pool = invoke(invoke("NSAutoreleasePool", "alloc"), "init");
+ try {
+ params.put(COMMON_DIALOG_PARAM_TYPE.title, nsString(title));
+ params.put(ALERT_DIALOG_PARAM_TYPE.defaultText, nsString(UIUtil.removeMnemonic(defaultText)));
+ params.put(ALERT_DIALOG_PARAM_TYPE.alternateText, nsString(otherText == null ? "-1" : UIUtil.removeMnemonic(otherText)));
+ params.put(ALERT_DIALOG_PARAM_TYPE.otherText, nsString(alternateText == null ? "-1" : UIUtil.removeMnemonic(alternateText)));
+ // replace % -> %% to avoid formatted parameters (causes SIGTERM)
+ params.put(COMMON_DIALOG_PARAM_TYPE.message, nsString(StringUtil.stripHtml(message == null ? "" : message, true).replace("%", "%%")));
+ params.put(COMMON_DIALOG_PARAM_TYPE.errorStyle, nsString(errorStyle ? "error" : "-1"));
+ params.put(COMMON_DIALOG_PARAM_TYPE.doNotAskDialogOption1, nsString(doNotAskDialogOption == null || !doNotAskDialogOption.canBeHidden()
+ // TODO: state=!doNotAsk.shouldBeShown()
+ ? "-1"
+ : doNotAskDialogOption.getDoNotShowMessage()));
+ params.put(COMMON_DIALOG_PARAM_TYPE.doNotAskDialogOption2, nsString(doNotAskDialogOption != null && !doNotAskDialogOption.isToBeShown() ? "checked" : "-1"));
+
+
+ return convertRetunCodeFromNativeAlertDialog(showDialog(window, "showSheet:",
+ new DialogParamsWrapper(DialogParamsWrapper.DialogType.alert, params)), alternateText);
+ }
+ finally {
+ invoke(pool, "release");
+ }
+ }
+
+ public int showMessageDialog(final String title,
+ final String message,
+ final String[] buttons,
+ final boolean errorStyle,
+ @Nullable Window window,
+ final int defaultOptionIndex,
+ final int focusedOptionIndex,
+ @Nullable final DialogWrapper.DoNotAskOption doNotAskDialogOption)
+ {
+
+ ID pool = invoke(invoke("NSAutoreleasePool", "alloc"), "init");
+ try {
final ID buttonsArray = invoke("NSMutableArray", "array");
for (String s : buttons) {
ID s1 = nsString(UIUtil.removeMnemonic(s));
invoke(buttonsArray, "addObject:", s1);
- cfRelease(s1);
}
- final ID paramsArray = invoke("NSArray", "arrayWithObjects:", nsString(title),
- // replace % -> %% to avoid formatted parameters (causes SIGTERM)
- nsString(StringUtil.stripHtml(message == null ? "" : message, true).replace("%", "%%")),
- nativeFocusedWindow, nsString(""), nsString(errorStyle ? "error" : "-1"),
- nsString(doNotAskDialogOption == null || !doNotAskDialogOption.canBeHidden()
- // TODO: state=!doNotAsk.shouldBeShown()
- ? "-1"
- : doNotAskDialogOption.getDoNotShowMessage()),
- nsString(Integer.toString(defaultOptionIndex)),
- nsString(Integer.toString(focusedOptionIndex)), buttonsArray,
- nsString(doNotAskDialogOption != null && !doNotAskDialogOption.isToBeShown() ? "checked" : "-1"), null);
+ HashMap params = new HashMap ();
- IdeFocusManager.getGlobalInstance().setTypeaheadEnabled(false);
+ params.put(COMMON_DIALOG_PARAM_TYPE.title, nsString(title));
+ // replace % -> %% to avoid formatted parameters (causes SIGTERM)
+ params.put(COMMON_DIALOG_PARAM_TYPE.message, nsString(StringUtil.stripHtml(message == null ? "" : message, true).replace("%", "%%")));
- runOrPostponeForWindow(documentRoot, new Runnable() {
- @Override
- public void run() {
- invoke(delegate, "performSelectorOnMainThread:withObject:waitUntilDone:",
- createSelector("showVariableButtonsSheet:"), paramsArray, false);
- }
- });
-
- startModal(documentRoot, nativeFocusedWindow);
-
- IdeFocusManager.getGlobalInstance().setTypeaheadEnabled(true);
+ params.put(MESSAGE_DIALOG_PARAM_TYPE.errorStyle, nsString(errorStyle ? "error" : "-1"));
+ params.put(COMMON_DIALOG_PARAM_TYPE.doNotAskDialogOption1, nsString(doNotAskDialogOption == null || !doNotAskDialogOption.canBeHidden()
+ // TODO: state=!doNotAsk.shouldBeShown()
+ ? "-1"
+ : doNotAskDialogOption.getDoNotShowMessage()));
+ params.put(COMMON_DIALOG_PARAM_TYPE.doNotAskDialogOption2, nsString(doNotAskDialogOption != null && !doNotAskDialogOption.isToBeShown() ? "checked" : "-1"));
+ params.put(MESSAGE_DIALOG_PARAM_TYPE.defaultOptionIndex, Integer.toString(defaultOptionIndex));
+ params.put(MESSAGE_DIALOG_PARAM_TYPE.focusedOptionIndex, Integer.toString(focusedOptionIndex));
+ params.put(MESSAGE_DIALOG_PARAM_TYPE.buttonsArray, buttonsArray);
- if (focusTrackback[0] != null &&
- !(focusTrackback[0].isSheduledForRestore() || focusTrackback[0].isWillBeSheduledForRestore())) {
- focusTrackback[0].setWillBeSheduledForRestore();
-
- IdeFocusManager mgr = IdeFocusManager.findInstanceByComponent(documentRoot);
- Runnable r = new Runnable() {
- public void run() {
- if (focusTrackback[0] != null) focusTrackback[0].restoreFocus();
- focusTrackback[0] = null;
- }
- };
- mgr.doWhenFocusSettlesDown(r);
- }
- return convertReturnCodeFromNativeMessageDialog(documentRoot);
+ return convertReturnCodeFromNativeMessageDialog(showDialog(window, "showVariableButtonsSheet:",
+ new DialogParamsWrapper(DialogParamsWrapper.DialogType.message, params)));
}
- return -1;
+ finally {
+ invoke(pool, "release");
+ }
+ }
+
+ //title, message, errorStyle, window, paramsArray, doNotAskDialogOption, "showVariableButtonsSheet:"
+ private static Window showDialog(@Nullable Window window,
+ final String methodName, DialogParamsWrapper paramsWrapper) {
+
+ Window foremostWindow = getForemostWindow(window);
+
+ String foremostWindowTitle = getWindowTitle(foremostWindow);
+
+ Window documentRoot = getDocumentRootFromWindow(foremostWindow);
+
+ final ID nativeFocusedWindow = invoke(MacUtil.findWindowForTitle(foremostWindowTitle), "retain");
+
+ paramsWrapper.setNativeWindow(nativeFocusedWindow);
+
+ final ID paramsArray = paramsWrapper.getParamsAsID();
+
+
+ final ID delegate = invoke(invoke(getObjcClass("NSAlertDelegate_"), "alloc"), "init");
+
+ IdeFocusManager.getGlobalInstance().setTypeaheadEnabled(false);
+
+ runOrPostponeForWindow(documentRoot, new Runnable() {
+ @Override
+ public void run() {
+ invoke(delegate, "performSelectorOnMainThread:withObject:waitUntilDone:",
+ createSelector(methodName), paramsArray, false);
+ }
+ });
+
+ startModal(documentRoot, nativeFocusedWindow);
+
+ invoke(nativeFocusedWindow, "release");
+
+ IdeFocusManager.getGlobalInstance().setTypeaheadEnabled(true);
+ return documentRoot;
}
private static int convertReturnCodeFromNativeMessageDialog(Window documentRoot) {
@@ -419,62 +556,6 @@
return windowTitle;
}
- public static int showAlertDialog(final String title,
- final String defaultText,
- @Nullable final String alternateText,
- @Nullable final String otherText,
- final String message,
- @Nullable Window window ,
- final boolean errorStyle,
- @Nullable final DialogWrapper.DoNotAskOption doNotAskDialogOption) {
-
- Window foremostWindow = getForemostWindow(window);
- String foremostWindowTitle = getWindowTitle(foremostWindow);
-
- Window documentRoot = getDocumentRootFromWindow(foremostWindow);
-
- final ID nativeFocusedWindow = MacUtil.findWindowForTitle(foremostWindowTitle);
-
- ID pool = invoke("NSAutoreleasePool", "new");
- try {
-
- final ID delegate = invoke(getObjcClass("NSAlertDelegate_"), "new");
- cfRetain(delegate);
-
- final ID paramsArray = invoke("NSArray", "arrayWithObjects:", nsString(title), nsString(UIUtil.removeMnemonic(defaultText)),
- nsString(otherText == null ? "-1" : UIUtil.removeMnemonic(otherText)),
- nsString(alternateText == null ? "-1" : UIUtil.removeMnemonic(alternateText)),
- // replace % -> %% to avoid formatted parameters (causes SIGTERM)
- nsString(StringUtil.stripHtml(message == null ? "" : message, true).replace("%", "%%")),
- nativeFocusedWindow, nsString(""), nsString(errorStyle ? "error" : "-1"),
- nsString(doNotAskDialogOption == null || !doNotAskDialogOption.canBeHidden()
- // TODO: state=!doNotAsk.shouldBeShown()
- ? "-1"
- : doNotAskDialogOption.getDoNotShowMessage()),
- nsString(doNotAskDialogOption != null && !doNotAskDialogOption.isToBeShown() ? "checked" : "-1"), null);
-
-
-
- IdeFocusManager.getGlobalInstance().setTypeaheadEnabled(false);
-
- runOrPostponeForWindow(documentRoot, new Runnable() {
- @Override
- public void run() {
- invoke(delegate, "performSelectorOnMainThread:withObject:waitUntilDone:",
- createSelector("showSheet:"), paramsArray, false);
- }
- });
- startModal(documentRoot, nativeFocusedWindow);
- IdeFocusManager.getGlobalInstance().setTypeaheadEnabled(true);
-
- }
- finally {
- invoke(pool, "release");
- }
- return convertRetunCodeFromNativeAlertDialog(documentRoot, alternateText);
-
- }
-
private static int convertRetunCodeFromNativeAlertDialog(Window documentRoot, String alternateText) {
Integer result = resultsFromDocumentRoot.remove(documentRoot);
@@ -540,6 +621,7 @@
}
}
+ @NotNull
private static Window getForemostWindow(final Window window) {
Window _window = null;
@@ -585,6 +667,11 @@
}
}
+ while (getWindowTitle(_window) == null) {
+ _window = _window.getOwner();
+ //At least our frame should have a title
+ }
+
return _window;
}
diff --git a/platform/platform-impl/src/com/intellij/ui/popup/BalloonPopupBuilderImpl.java b/platform/platform-impl/src/com/intellij/ui/popup/BalloonPopupBuilderImpl.java
index 9fae903..570e45a 100644
--- a/platform/platform-impl/src/com/intellij/ui/popup/BalloonPopupBuilderImpl.java
+++ b/platform/platform-impl/src/com/intellij/ui/popup/BalloonPopupBuilderImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -16,6 +16,7 @@
package com.intellij.ui.popup;
import com.intellij.openapi.Disposable;
+import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.ui.popup.Balloon;
import com.intellij.openapi.ui.popup.BalloonBuilder;
import com.intellij.openapi.ui.popup.JBPopupAdapter;
@@ -40,8 +41,8 @@
@Nullable private Disposable myAnchor;
JComponent myContent;
- Color myBorder = new JBColor(Color.gray, Gray._200);
- Color myFill = new Color(186, 238, 186, 230);
+ Color myBorder = new JBColor(JBColor.GRAY, Gray._200);
+ Color myFill = MessageType.INFO.getPopupBackground();
boolean myHideOnMouseOutside = true;
boolean myHideOnKeyOutside = true;
long myFadeoutTime = -1;
diff --git a/platform/platform-impl/src/com/intellij/util/ui/table/JBListTable.java b/platform/platform-impl/src/com/intellij/util/ui/table/JBListTable.java
index c9171cb..cdb85f3 100644
--- a/platform/platform-impl/src/com/intellij/util/ui/table/JBListTable.java
+++ b/platform/platform-impl/src/com/intellij/util/ui/table/JBListTable.java
@@ -15,7 +15,13 @@
*/
package com.intellij.util.ui.table;
+import com.intellij.openapi.editor.colors.EditorColorsManager;
+import com.intellij.openapi.editor.colors.EditorFontType;
+import com.intellij.openapi.fileTypes.FileType;
+import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Ref;
+import com.intellij.ui.DottedBorder;
+import com.intellij.ui.EditorSettingsProvider;
import com.intellij.ui.EditorTextField;
import com.intellij.ui.TableUtil;
import com.intellij.ui.table.JBTable;
@@ -214,6 +220,10 @@
mainTable.setStriped(true);
}
+ public void stopEditing() {
+ TableUtil.stopEditing(mainTable);
+ }
+
private void installPaddingAndBordersForEditors(JBTableRowEditor editor) {
final List<EditorTextField> editors = UIUtil.findComponentsOfType(editor, EditorTextField.class);
for (EditorTextField textField : editors) {
@@ -230,7 +240,14 @@
protected abstract JBTableRowEditor getRowEditor(int row);
- protected abstract JBTableRow getRowAt(int row);
+ protected JBTableRow getRowAt(final int row) {
+ return new JBTableRow() {
+ @Override
+ public Object getValueAt(int column) {
+ return myInternalTable.getValueAt(row, column);
+ }
+ };
+ }
protected boolean isRowEditable(int row) {
return true;
@@ -240,6 +257,37 @@
return false;
}
+ public static JComponent createEditorTextFieldPresentation(final Project project,
+ final FileType type,
+ final String text,
+ boolean selected,
+ boolean focused) {
+ final JPanel panel = new JPanel(new BorderLayout());
+ final EditorTextField field = new EditorTextField(text, project, type) {
+ @Override
+ protected boolean shouldHaveBorder() {
+ return false;
+ }
+ };
+
+ Font font = EditorColorsManager.getInstance().getGlobalScheme().getFont(EditorFontType.PLAIN);
+ font = new Font(font.getFontName(), font.getStyle(), 12);
+ field.setFont(font);
+ field.addSettingsProvider(EditorSettingsProvider.NO_WHITESPACE);
+
+ if (selected && focused) {
+ panel.setBackground(UIUtil.getTableSelectionBackground());
+ field.setAsRendererWithSelection(UIUtil.getTableSelectionBackground(), UIUtil.getTableSelectionForeground());
+ } else {
+ panel.setBackground(UIUtil.getTableBackground());
+ if (selected) {
+ panel.setBorder(new DottedBorder(UIUtil.getTableForeground()));
+ }
+ }
+ panel.add(field, BorderLayout.WEST);
+ return panel;
+ }
+
private static class RowResizeAnimator extends Thread {
private final JTable myTable;
private final int myRow;
diff --git a/platform/platform-impl/src/com/intellij/util/ui/table/JBTableRowEditor.java b/platform/platform-impl/src/com/intellij/util/ui/table/JBTableRowEditor.java
index a54a084..f63ea2c 100644
--- a/platform/platform-impl/src/com/intellij/util/ui/table/JBTableRowEditor.java
+++ b/platform/platform-impl/src/com/intellij/util/ui/table/JBTableRowEditor.java
@@ -15,8 +15,13 @@
*/
package com.intellij.util.ui.table;
+import com.intellij.openapi.editor.event.DocumentAdapter;
import com.intellij.openapi.editor.event.DocumentEvent;
+import com.intellij.openapi.ui.VerticalFlowLayout;
+import com.intellij.ui.components.JBLabel;
+import com.intellij.util.IJSwingUtilities;
import com.intellij.util.containers.ContainerUtil;
+import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
@@ -61,4 +66,26 @@
public final void setMouseEvent(@Nullable MouseEvent e) {
myMouseEvent = e;
}
+
+ public static JPanel createLabeledPanel(String labelText, JComponent component) {
+ final JPanel panel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, 4, 2, true, false));
+ final JBLabel label = new JBLabel(labelText, UIUtil.ComponentStyle.SMALL);
+ IJSwingUtilities.adjustComponentsOnMac(label, component);
+ panel.add(label);
+ panel.add(component);
+ return panel;
+ }
+
+ public class RowEditorChangeListener extends DocumentAdapter {
+ private int myColumn;
+
+ public RowEditorChangeListener(int column) {
+ myColumn = column;
+ }
+
+ @Override
+ public void documentChanged(DocumentEvent e) {
+ fireDocumentChanged(e, myColumn);
+ }
+ }
}
diff --git a/platform/platform-impl/src/org/jetbrains/ide/BuiltInServerManagerImpl.java b/platform/platform-impl/src/org/jetbrains/ide/BuiltInServerManagerImpl.java
index 79a6899..a720565 100644
--- a/platform/platform-impl/src/org/jetbrains/ide/BuiltInServerManagerImpl.java
+++ b/platform/platform-impl/src/org/jetbrains/ide/BuiltInServerManagerImpl.java
@@ -37,7 +37,7 @@
@Nullable
private BuiltInServer server;
- private boolean myEnabledInUnitTestMode;
+ private boolean myEnabledInUnitTestMode = true;
@Override
public int getPort() {
@@ -48,7 +48,7 @@
public BuiltInServerManager waitForStart() {
Future<?> serverStartFuture = startServerInPooledThread();
if (serverStartFuture != null) {
- LOG.assertTrue(!ApplicationManager.getApplication().isDispatchThread());
+ LOG.assertTrue(ApplicationManager.getApplication().isUnitTestMode() || !ApplicationManager.getApplication().isDispatchThread());
try {
serverStartFuture.get();
}
diff --git a/platform/platform-impl/src/org/jetbrains/io/BuiltInServer.java b/platform/platform-impl/src/org/jetbrains/io/BuiltInServer.java
index 78e97a6..f38367b 100644
--- a/platform/platform-impl/src/org/jetbrains/io/BuiltInServer.java
+++ b/platform/platform-impl/src/org/jetbrains/io/BuiltInServer.java
@@ -16,21 +16,13 @@
package org.jetbrains.io;
import com.intellij.openapi.Disposable;
-import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Disposer;
-import com.intellij.openapi.util.SystemInfo;
-import com.intellij.util.concurrency.Semaphore;
-import org.jboss.netty.bootstrap.ClientBootstrap;
import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.channel.*;
import org.jboss.netty.channel.group.ChannelGroup;
import org.jboss.netty.channel.group.DefaultChannelGroup;
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
-import org.jboss.netty.channel.socket.oio.OioClientSocketChannelFactory;
-import org.jboss.netty.handler.codec.http.*;
-import org.jboss.netty.util.CharsetUtil;
-import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.ide.CustomPortServerManager;
import org.jetbrains.ide.PooledThreadExecutor;
@@ -39,22 +31,14 @@
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.util.concurrent.Executor;
-import java.util.concurrent.atomic.AtomicBoolean;
import static org.jboss.netty.channel.Channels.pipeline;
-import static org.jboss.netty.handler.codec.http.HttpResponseStatus.OK;
-import static org.jboss.netty.handler.codec.http.HttpVersion.HTTP_1_1;
public class BuiltInServer implements Disposable {
- static final String START_TIME_PATH = "/startTime";
-
private final ChannelGroup openChannels = new DefaultChannelGroup();
static final Logger LOG = Logger.getInstance(BuiltInServer.class);
- @NonNls
- private static final String PROPERTY_ONLY_ANY_HOST = "rpc.onlyAnyHost";
-
private final NioServerSocketChannelFactory channelFactory;
public BuiltInServer() {
@@ -79,19 +63,25 @@
throw new IllegalStateException("server already started");
}
- ServerBootstrap bootstrap = new ServerBootstrap(channelFactory);
- bootstrap.setOption("child.tcpNoDelay", true);
- bootstrap.setPipelineFactory(new ChannelPipelineFactoryImpl(new PortUnificationServerHandler(openChannels)));
+ ServerBootstrap bootstrap = createServerBootstrap(channelFactory, openChannels);
int port = bind(firstPort, portsCount, tryAnyPort, bootstrap);
- bindCustomPorts(firstPort, port, bootstrap);
+ bindCustomPorts(firstPort, port);
return port;
}
- private void bindCustomPorts(int firstPort, int port, ServerBootstrap bootstrap) {
+ static ServerBootstrap createServerBootstrap(NioServerSocketChannelFactory channelFactory, ChannelGroup openChannels) {
+ ServerBootstrap bootstrap = new ServerBootstrap(channelFactory);
+ bootstrap.setOption("child.tcpNoDelay", true);
+ bootstrap.setOption("child.keepAlive", true);
+ bootstrap.setPipelineFactory(new ChannelPipelineFactoryImpl(new PortUnificationServerHandler(openChannels)));
+ return bootstrap;
+ }
+
+ private void bindCustomPorts(int firstPort, int port) {
for (CustomPortServerManager customPortServerManager : CustomPortServerManager.EP_NAME.getExtensions()) {
try {
int customPortServerManagerPort = customPortServerManager.getPort();
- SubServer subServer = new SubServer(customPortServerManager, bootstrap);
+ SubServer subServer = new SubServer(customPortServerManager, channelFactory);
Disposer.register(this, subServer);
if (customPortServerManagerPort != firstPort && customPortServerManagerPort != port) {
subServer.bind(customPortServerManagerPort);
@@ -103,139 +93,36 @@
}
}
- private static boolean checkPort(final InetSocketAddress remoteAddress) {
- final ClientBootstrap bootstrap = new ClientBootstrap(new OioClientSocketChannelFactory(new PooledThreadExecutor()));
- bootstrap.setOption("child.tcpNoDelay", true);
-
- final AtomicBoolean result = new AtomicBoolean(false);
- final Semaphore semaphore = new Semaphore();
- semaphore.down(); // must call to down() here to ensure that down was called _before_ up()
- bootstrap.setPipeline(
- pipeline(new HttpResponseDecoder(), new HttpRequestEncoder(), new SimpleChannelUpstreamHandler() {
- @Override
- public void messageReceived(ChannelHandlerContext context, MessageEvent e) throws Exception {
- try {
- if (e.getMessage() instanceof HttpResponse) {
- HttpResponse response = (HttpResponse)e.getMessage();
- if (response.getStatus().equals(OK) &&
- response.getContent().toString(CharsetUtil.US_ASCII).equals(getApplicationStartTime())) {
- LOG.info("port check: current OS must be marked as normal");
- result.set(true);
- }
- }
- }
- finally {
- semaphore.up();
- }
- }
-
- @Override
- public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
- try {
- LOG.error(e.getCause());
- }
- finally {
- semaphore.up();
- }
- }
- }));
-
- ChannelFuture connectFuture = null;
- try {
- connectFuture = bootstrap.connect(remoteAddress);
- if (!waitComplete(connectFuture, "connect")) {
- return false;
- }
- ChannelFuture writeFuture = connectFuture.getChannel().write(new DefaultHttpRequest(HTTP_1_1, HttpMethod.GET, START_TIME_PATH));
- if (!waitComplete(writeFuture, "write")) {
- return false;
- }
-
- try {
- // yes, 30 seconds. I always get timeout in Linux in Parallels if I set to 2 seconds.
- // In any case all work is done in pooled thread (IDE init time isn't affected)
- if (!semaphore.waitForUnsafe(30000)) {
- LOG.info("port check: semaphore down timeout");
- }
- }
- catch (InterruptedException e) {
- LOG.info("port check: semaphore interrupted", e);
- }
- }
- finally {
- if (connectFuture != null) {
- connectFuture.getChannel().close().awaitUninterruptibly();
- }
- bootstrap.releaseExternalResources();
- }
- return result.get();
- }
-
- private static boolean waitComplete(ChannelFuture writeFuture, String failedMessage) {
- if (!writeFuture.awaitUninterruptibly(500) || !writeFuture.isSuccess()) {
- LOG.info("port check: " + failedMessage + ", " + writeFuture.isSuccess());
- return false;
- }
- return true;
- }
-
- static String getApplicationStartTime() {
- return Long.toString(ApplicationManager.getApplication().getStartTime());
- }
-
// IDEA-91436 idea <121 binds to 127.0.0.1, but >=121 must be available not only from localhost
// but if we bind only to any local port (0.0.0.0), instance of idea <121 can bind to our ports and any request to us will be intercepted
// so, we bind to 127.0.0.1 and 0.0.0.0
private int bind(int firstPort, int portsCount, boolean tryAnyPort, ServerBootstrap bootstrap) {
- String property = System.getProperty(PROPERTY_ONLY_ANY_HOST);
- boolean onlyAnyHost = property == null
- ? (SystemInfo.isLinux || SystemInfo.isWindows && !SystemInfo.isWinVistaOrNewer)
- : (property.isEmpty() || Boolean.valueOf(property));
- boolean portChecked = false;
+ InetAddress localAddress;
+ try {
+ localAddress = InetAddress.getByName("127.0.0.1");
+ }
+ catch (UnknownHostException e) {
+ LOG.error(e);
+ return -1;
+ }
+
for (int i = 0; i < portsCount; i++) {
int port = firstPort + i;
- ChannelException channelException = null;
try {
- openChannels.add(bootstrap.bind(new InetSocketAddress(port)));
- if (!onlyAnyHost) {
- InetSocketAddress localAddress = null;
- try {
- localAddress = new InetSocketAddress(InetAddress.getByName("127.0.0.1"), port);
- openChannels.add(bootstrap.bind(localAddress));
- }
- catch (UnknownHostException ignored) {
- return port;
- }
- catch (ChannelException e) {
- channelException = e;
- if (!portChecked) {
- portChecked = true;
- assert localAddress != null;
- if (checkPortSafe(localAddress)) {
- return port;
- }
- }
- }
- }
- }
- catch (ChannelException e) {
- channelException = e;
- }
-
- if (channelException == null) {
+ openChannels.add(bootstrap.bind(new InetSocketAddress(localAddress, port)));
return port;
}
- else {
+ catch (ChannelException e) {
if (!openChannels.isEmpty()) {
openChannels.close();
openChannels.clear();
}
if (portsCount == 1) {
- throw channelException;
+ throw e;
}
else if (!tryAnyPort && i == (portsCount - 1)) {
- LOG.error(channelException);
+ LOG.error(e);
}
}
}
@@ -243,7 +130,7 @@
if (tryAnyPort) {
LOG.info("We cannot bind to our default range, so, try to bind to any free port");
try {
- Channel channel = bootstrap.bind(new InetSocketAddress(0));
+ Channel channel = bootstrap.bind(new InetSocketAddress(localAddress, 0));
openChannels.add(channel);
return ((InetSocketAddress)channel.getLocalAddress()).getPort();
}
@@ -255,19 +142,6 @@
return -1;
}
- private static boolean checkPortSafe(@NotNull InetSocketAddress localAddress) {
- LOG.info("We have tried to bind to 127.0.0.1 host but have got exception (" +
- SystemInfo.OS_NAME + " " + SystemInfo.OS_VERSION + "), " +
- "so, try to check - are we really need to bind to 127.0.0.1");
- try {
- return checkPort(localAddress);
- }
- catch (Throwable innerE) {
- LOG.error(innerE);
- return false;
- }
- }
-
@Override
public void dispose() {
try {
diff --git a/platform/platform-impl/src/org/jetbrains/io/CustomPortServerManagerBase.java b/platform/platform-impl/src/org/jetbrains/io/CustomPortServerManagerBase.java
index acccc3b..d955e84 100644
--- a/platform/platform-impl/src/org/jetbrains/io/CustomPortServerManagerBase.java
+++ b/platform/platform-impl/src/org/jetbrains/io/CustomPortServerManagerBase.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2000-2013 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 org.jetbrains.io;
import org.jetbrains.annotations.Nullable;
diff --git a/platform/platform-impl/src/org/jetbrains/io/DelegatingHttpRequestHandler.java b/platform/platform-impl/src/org/jetbrains/io/DelegatingHttpRequestHandler.java
index 81bfaf9..b189660 100644
--- a/platform/platform-impl/src/org/jetbrains/io/DelegatingHttpRequestHandler.java
+++ b/platform/platform-impl/src/org/jetbrains/io/DelegatingHttpRequestHandler.java
@@ -23,8 +23,8 @@
import org.jboss.netty.channel.*;
import org.jboss.netty.handler.codec.http.HttpRequest;
import org.jboss.netty.handler.codec.http.QueryStringDecoder;
-import org.jetbrains.ide.HttpRequestHandler;
import org.jetbrains.ide.BuiltInServerManager;
+import org.jetbrains.ide.HttpRequestHandler;
import javax.swing.*;
import java.awt.image.BufferedImage;
@@ -41,9 +41,9 @@
}
HttpRequest request = (HttpRequest)event.getMessage();
- if (BuiltInServer.LOG.isDebugEnabled()) {
- BuiltInServer.LOG.debug(request.toString());
- }
+ //if (BuiltInServer.LOG.isDebugEnabled()) {
+ //BuiltInServer.LOG.debug(request.toString());
+ //}
QueryStringDecoder urlDecoder = new QueryStringDecoder(request.getUri());
@@ -66,10 +66,6 @@
return;
}
}
- else if (urlDecoder.getPath().equals(BuiltInServer.START_TIME_PATH)) {
- Responses.send(BuiltInServer.getApplicationStartTime(), request, context);
- return;
- }
for (HttpRequestHandler handler : BuiltInServerManager.EP_NAME.getExtensions()) {
try {
diff --git a/platform/platform-impl/src/org/jetbrains/io/Responses.java b/platform/platform-impl/src/org/jetbrains/io/Responses.java
index 24a9735..5838a00 100644
--- a/platform/platform-impl/src/org/jetbrains/io/Responses.java
+++ b/platform/platform-impl/src/org/jetbrains/io/Responses.java
@@ -21,6 +21,7 @@
import com.intellij.openapi.util.text.StringUtil;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
+import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelFuture;
import org.jboss.netty.channel.ChannelFutureListener;
import org.jboss.netty.channel.ChannelHandlerContext;
@@ -143,7 +144,12 @@
}
public static void send(HttpResponse response, ChannelHandlerContext context, boolean close) {
- ChannelFuture future = context.getChannel().write(response);
+ Channel channel = context.getChannel();
+ if (!channel.isOpen()) {
+ return;
+ }
+
+ ChannelFuture future = channel.write(response);
if (close) {
future.addListener(ChannelFutureListener.CLOSE);
}
diff --git a/platform/platform-impl/src/org/jetbrains/io/SubServer.java b/platform/platform-impl/src/org/jetbrains/io/SubServer.java
index 5440afe..663f9de 100644
--- a/platform/platform-impl/src/org/jetbrains/io/SubServer.java
+++ b/platform/platform-impl/src/org/jetbrains/io/SubServer.java
@@ -1,24 +1,40 @@
+/*
+ * Copyright 2000-2013 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 org.jetbrains.io;
import com.intellij.openapi.Disposable;
import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelException;
import org.jboss.netty.channel.group.ChannelGroup;
import org.jboss.netty.channel.group.DefaultChannelGroup;
+import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
import org.jetbrains.ide.BuiltInServerManager;
import org.jetbrains.ide.CustomPortServerManager;
+import java.net.InetAddress;
import java.net.InetSocketAddress;
-public class SubServer implements CustomPortServerManager.CustomPortService, Disposable {
+final class SubServer implements CustomPortServerManager.CustomPortService, Disposable {
private final ChannelGroup openChannels = new DefaultChannelGroup();
private final CustomPortServerManager user;
private final ServerBootstrap bootstrap;
- public SubServer(CustomPortServerManager user, ServerBootstrap bootstrap) {
+ public SubServer(CustomPortServerManager user, NioServerSocketChannelFactory channelFactory) {
this.user = user;
user.setManager(this);
- this.bootstrap = bootstrap;
+ bootstrap = BuiltInServer.createServerBootstrap(channelFactory, openChannels);
}
public boolean bind(int port) {
@@ -27,12 +43,12 @@
}
try {
- openChannels.add(bootstrap.bind(new InetSocketAddress(port)));
+ openChannels.add(bootstrap.bind(user.isAvailableExternally() ? new InetSocketAddress(port) : new InetSocketAddress(InetAddress.getByName("127.0.0.1"), port)));
return true;
}
- catch (ChannelException e) {
+ catch (Exception e) {
BuiltInServer.LOG.error(e);
- user.cannotBind(e);
+ user.cannotBind(e, port);
return false;
}
}
@@ -45,6 +61,7 @@
private void stop() {
// todo should we call releaseExternalResources? We use only 1 boss&worker thread
openChannels.close().awaitUninterruptibly();
+ openChannels.clear();
}
@Override
diff --git a/platform/platform-main/src/com/intellij/idea/MainImpl.java b/platform/platform-main/src/com/intellij/idea/MainImpl.java
index 32660d9..32269af 100644
--- a/platform/platform-main/src/com/intellij/idea/MainImpl.java
+++ b/platform/platform-main/src/com/intellij/idea/MainImpl.java
@@ -39,15 +39,8 @@
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
- try {
- app.run();
- }
- catch (PluginManager.StartupAbortedException e) {
- throw e;
- }
- catch (Throwable t) {
- throw new PluginManager.StartupAbortedException(t);
- }
+ PluginManager.installExceptionHandler();
+ app.run();
}
});
}
diff --git a/platform/platform-resources-en/src/messages/ActionsBundle.properties b/platform/platform-resources-en/src/messages/ActionsBundle.properties
index 372a2ac..1e9426d 100644
--- a/platform/platform-resources-en/src/messages/ActionsBundle.properties
+++ b/platform/platform-resources-en/src/messages/ActionsBundle.properties
@@ -1143,11 +1143,11 @@
action.FileChooser.NewFolder.description=Create new folder
action.FileChooser.NewFile.text=New File...
action.FileChooser.NewFile.description=Create new file
-action.FileChooser.GotoHome.text=Home
+action.FileChooser.GotoHome.text=Home Directory
action.FileChooser.GotoHome.description=Go to home directory
-action.FileChooser.GotoProject.text=Project
+action.FileChooser.GotoProject.text=Project Directory
action.FileChooser.GotoProject.description=Go to project directory
-action.FileChooser.GotoModule.text=Module
+action.FileChooser.GotoModule.text=Module Directory
action.FileChooser.GotoModule.description=Go to module directory
action.WelcomeScreen.DevelopPlugins.text=Plugin Development
diff --git a/platform/platform-resources-en/src/messages/IdeBundle.properties b/platform/platform-resources-en/src/messages/IdeBundle.properties
index f165964..212e5a5 100644
--- a/platform/platform-resources-en/src/messages/IdeBundle.properties
+++ b/platform/platform-resources-en/src/messages/IdeBundle.properties
@@ -476,6 +476,7 @@
macro.project.file.name=The name of the project file without extension
macro.project.source.path=Project source path
macro.prompt=Displays a string input dialog
+macro.clipboard.content=The clipboard content
prompt.enter.parameters=Enter parameters:
title.input=Input
macro.prompt.preview=<params>
diff --git a/platform/platform-resources-en/src/messages/OptionsBundle.properties b/platform/platform-resources-en/src/messages/OptionsBundle.properties
index 9e19645..920fd45 100644
--- a/platform/platform-resources-en/src/messages/OptionsBundle.properties
+++ b/platform/platform-resources-en/src/messages/OptionsBundle.properties
@@ -80,7 +80,7 @@
options.java.attribute.descriptor.implicit.anonymous.parameter=Implicit anonymous class parameter
options.java.attribute.descriptor.instance.field=Instance field
options.java.attribute.descriptor.static.field=Static field
-options.java.attribute.descriptor.static.final.field=Constant
+options.java.attribute.descriptor.static.final.field=Constant (static final field)
options.java.attribute.descriptor.parameter=Parameter
options.java.attribute.descriptor.method.call=Method call
options.java.attribute.descriptor.method.declaration=Method declaration
diff --git a/platform/platform-resources-en/src/misc/registry.properties b/platform/platform-resources-en/src/misc/registry.properties
index 7f5f3a8..811c080 100644
--- a/platform/platform-resources-en/src/misc/registry.properties
+++ b/platform/platform-resources-en/src/misc/registry.properties
@@ -293,4 +293,5 @@
search.everywhere.enabled=false
junit_sm_runner=false
testng_sm_runner=false
+show.flex.debug.design.view=false
diff --git a/platform/platform-resources-en/src/tips/TabInLookups.html b/platform/platform-resources-en/src/tips/TabInLookups.html
index adebbf7..3280473 100644
--- a/platform/platform-resources-en/src/tips/TabInLookups.html
+++ b/platform/platform-resources-en/src/tips/TabInLookups.html
@@ -6,7 +6,7 @@
<p>When using Code Completion, you can accept the currently highlighted selection in the popup list
- with the <span class="shortcut">&shortcut:EditorChooseLookupItemReplace;</span> key.</p>
+ with <span class="shortcut">&shortcut:EditorChooseLookupItemReplace;</span> key.</p>
<p>Unlike accepting with the <span class="shortcut">&shortcut:EditorChooseLookupItem;</span> key, the selected name will overwrite
the rest of the name to the right of the caret. This can be especially useful for replacing one method
or variable name with another.</p>
diff --git a/platform/platform-resources/src/META-INF/LangExtensionPoints.xml b/platform/platform-resources/src/META-INF/LangExtensionPoints.xml
index a82a32e..56bd62e 100644
--- a/platform/platform-resources/src/META-INF/LangExtensionPoints.xml
+++ b/platform/platform-resources/src/META-INF/LangExtensionPoints.xml
@@ -285,9 +285,6 @@
beanClass="com.intellij.codeInspection.InspectionEP">
<with attribute="implementationClass" implements="com.intellij.codeInspection.GlobalInspectionTool"/>
</extensionPoint>
- <!-- please use localInspection or globalInspection instead-->
- <extensionPoint name="specialTool"
- beanClass="com.intellij.codeInspection.InspectionEP"/>
<extensionPoint name="inspectionToolProvider"
interface="com.intellij.codeInspection.InspectionToolProvider"/>
<extensionPoint name="inspectionToolsFactory"
@@ -721,7 +718,9 @@
<extensionPoint name="projectViewNodeDecorator" interface="com.intellij.ide.projectView.ProjectViewNodeDecorator" area="IDEA_PROJECT"/>
+ <extensionPoint name="elementPreviewProvider" interface="com.intellij.codeInsight.preview.ElementPreviewProvider"/>
<extensionPoint name="previewHintProvider" interface="com.intellij.codeInsight.preview.PreviewHintProvider"/>
+
<extensionPoint name="testActionProvider" interface="com.intellij.execution.testframework.ToggleModelActionProvider"/>
<extensionPoint name="psiViewerExtension" interface="com.intellij.internal.psiView.PsiViewerExtension"/>
diff --git a/platform/platform-resources/src/META-INF/LangExtensions.xml b/platform/platform-resources/src/META-INF/LangExtensions.xml
index bfca90a..bec5f90 100644
--- a/platform/platform-resources/src/META-INF/LangExtensions.xml
+++ b/platform/platform-resources/src/META-INF/LangExtensions.xml
@@ -4,6 +4,7 @@
<appStarter implementation="com.intellij.ide.ui.search.TraverseUIStarter"/>
<referencesSearch implementation="com.intellij.psi.impl.search.CachesBasedRefSearcher"/>
+ <referencesSearch implementation="com.intellij.psi.impl.search.NonPhysicalReferenceSearcher"/>
<applicationService serviceInterface="com.intellij.codeInsight.completion.CompletionService"
serviceImplementation="com.intellij.codeInsight.completion.impl.CompletionServiceImpl"/>
@@ -463,8 +464,10 @@
<statistician key="completion" implementationClass="com.intellij.codeInsight.completion.DefaultCompletionStatistician" order="last"/>
<weigher key="proximity" implementationClass="com.intellij.psi.util.proximity.OpenedInEditorWeigher" id="openedInEditor"/>
- <weigher key="proximity" implementationClass="com.intellij.psi.util.proximity.SameLogicalRootWeigher" id="sameLogicalRoot"
+ <weigher key="proximity" implementationClass="com.intellij.psi.util.proximity.SameDirectoryWeigher" id="sameDirectory"
order="after openedInEditor"/>
+ <weigher key="proximity" implementationClass="com.intellij.psi.util.proximity.SameLogicalRootWeigher" id="sameLogicalRoot"
+ order="after sameDirectory"/>
<weigher key="proximity" implementationClass="com.intellij.psi.util.proximity.SameModuleWeigher" id="sameModule"
order="after sameLogicalRoot"/>
<weigher key="proximity" implementationClass="com.intellij.psi.util.proximity.SdkOrLibraryWeigher" id="sdkOrLibrary"
@@ -837,6 +840,8 @@
serviceImplementation="com.intellij.codeInsight.CodeInsightUtilBase"/>
<applicationService serviceInterface="com.intellij.ide.util.treeView.TreeAnchorizer"
serviceImplementation="com.intellij.ide.projectView.impl.nodes.PsiTreeAnchorizer"/>
+
+ <elementPreviewProvider implementation="com.intellij.codeInsight.preview.ElementPreviewHintProvider"/>
</extensions>
</idea-plugin>
diff --git a/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml b/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml
old mode 100755
new mode 100644
diff --git a/platform/platform-resources/src/META-INF/PlatformLangPlugin.xml b/platform/platform-resources/src/META-INF/PlatformLangPlugin.xml
index 5b099a8..250b011 100644
--- a/platform/platform-resources/src/META-INF/PlatformLangPlugin.xml
+++ b/platform/platform-resources/src/META-INF/PlatformLangPlugin.xml
@@ -30,6 +30,7 @@
serviceImplementation="com.intellij.codeInsight.TargetElementUtilBase"/>
<applicationService serviceInterface="com.intellij.profile.codeInspection.InspectionProfileManager"
serviceImplementation="com.intellij.profile.codeInspection.InspectionProfileManagerImpl"/>
+
<exportable serviceInterface="com.intellij.profile.codeInspection.InspectionProfileManager"/>
<schemeOwner serviceInterface="com.intellij.profile.codeInspection.InspectionProfileManager"/>
@@ -84,9 +85,6 @@
<checkoutCompletedListener implementation="com.intellij.openapi.vcs.checkout.PlatformProjectCheckoutListener" id="PlatformProjectCheckoutListener"/>
- <weigher key="proximity" implementationClass="com.intellij.psi.util.proximity.SameDirectoryWeigher" id="sameDirectory"
- order="after openedInEditor"/>
-
</extensions>
<xi:include href="xdebugger.xml" xpointer="xpointer(/idea-plugin/*)"/>
diff --git a/platform/platform-resources/src/META-INF/RemoteServers.xml b/platform/platform-resources/src/META-INF/RemoteServers.xml
new file mode 100644
index 0000000..89386b6
--- /dev/null
+++ b/platform/platform-resources/src/META-INF/RemoteServers.xml
@@ -0,0 +1,19 @@
+<idea-plugin>
+ <extensionPoints>
+ <extensionPoint name="remoteServer.type" interface="com.intellij.remoteServer.ServerType"/>
+ </extensionPoints>
+
+ <extensions defaultExtensionNs="com.intellij">
+ <applicationService serviceInterface="com.intellij.remoteServer.configuration.RemoteServersManager"
+ serviceImplementation="com.intellij.remoteServer.configuration.impl.RemoteServersManagerImpl"/>
+ <applicationService serviceInterface="com.intellij.remoteServer.deployment.DeploymentSourceUtil"
+ serviceImplementation="com.intellij.remoteServer.deployment.impl.DeploymentSourceUtilImpl"/>
+ <applicationConfigurable instance="com.intellij.remoteServer.configuration.impl.RemoteServerListConfigurable"/>
+ <programRunner implementation="com.intellij.remoteServer.run.DeployToServerRunner"/>
+ </extensions>
+ <application-components>
+ <component>
+ <implementation-class>com.intellij.remoteServer.run.DeployToServerConfigurationTypesRegistrar</implementation-class>
+ </component>
+ </application-components>
+</idea-plugin>
\ No newline at end of file
diff --git a/platform/platform-resources/src/componentSets/Lang.xml b/platform/platform-resources/src/componentSets/Lang.xml
index 691cb51..ba2feea 100644
--- a/platform/platform-resources/src/componentSets/Lang.xml
+++ b/platform/platform-resources/src/componentSets/Lang.xml
@@ -33,6 +33,10 @@
<component>
<implementation-class>com.intellij.openapi.roots.impl.libraries.LibraryKindLoader</implementation-class>
</component>
+
+ <component>
+ <implementation-class>com.intellij.codeInsight.preview.ImageOrColorPreviewManager</implementation-class>
+ </component>
</application-components>
<project-components>
@@ -204,11 +208,6 @@
</component>
<component>
- <interface-class>com.intellij.codeInsight.preview.ImageOrColorPreviewProjectComponent</interface-class>
- <implementation-class>com.intellij.codeInsight.preview.ImageOrColorPreviewProjectComponent</implementation-class>
- </component>
-
- <component>
<implementation-class>com.intellij.openapi.roots.impl.PushedFilePropertiesUpdater</implementation-class>
</component>
diff --git a/platform/platform-resources/src/entry.desktop b/platform/platform-resources/src/entry.desktop
index 159c7ca..54b9b99 100644
--- a/platform/platform-resources/src/entry.desktop
+++ b/platform/platform-resources/src/entry.desktop
@@ -7,5 +7,4 @@
Comment=Develop with pleasure!
Categories=Development;IDE;
Terminal=false
-StartupNotify=true
StartupWMClass=$WM_CLASS$
diff --git a/platform/platform-resources/src/idea/ExternalSystemActions.xml b/platform/platform-resources/src/idea/ExternalSystemActions.xml
index e99c6ae..c92e52a 100644
--- a/platform/platform-resources/src/idea/ExternalSystemActions.xml
+++ b/platform/platform-resources/src/idea/ExternalSystemActions.xml
@@ -14,6 +14,7 @@
<group id="ExternalSystem.ToolWindow.Toolbar">
<reference id="ExternalSystem.RefreshAllProjects"/>
<reference id="ExternalSystem.AttachProject"/>
+ <reference ref="ExternalSystem.DetachProject"/>
</group>
<!--Context menu action-->
diff --git a/platform/platform-resources/src/idea/Keymap_Eclipse.xml b/platform/platform-resources/src/idea/Keymap_Eclipse.xml
index 788449e..c658568 100644
--- a/platform/platform-resources/src/idea/Keymap_Eclipse.xml
+++ b/platform/platform-resources/src/idea/Keymap_Eclipse.xml
@@ -107,9 +107,6 @@
<action id="ExtractMethod">
<keyboard-shortcut first-keystroke="shift alt M" />
</action>
- <action id="Faces.Create.Model.Element">
- <keyboard-shortcut first-keystroke="alt INSERT" />
- </action>
<action id="FileStructurePopup">
<keyboard-shortcut first-keystroke="control F3" />
<keyboard-shortcut first-keystroke="control O" />
diff --git a/platform/platform-resources/src/idea/Keymap_EclipseMac.xml b/platform/platform-resources/src/idea/Keymap_EclipseMac.xml
index 1f6d59d..dc1dcb5 100644
--- a/platform/platform-resources/src/idea/Keymap_EclipseMac.xml
+++ b/platform/platform-resources/src/idea/Keymap_EclipseMac.xml
@@ -97,9 +97,6 @@
<action id="ExtractMethod">
<keyboard-shortcut first-keystroke="meta alt M" />
</action>
- <action id="Faces.Create.Model.Element">
- <keyboard-shortcut first-keystroke="meta N" />
- </action>
<action id="FileStructurePopup">
<keyboard-shortcut first-keystroke="meta O" />
</action>
diff --git a/platform/platform-resources/src/idea/PlatformActions.xml b/platform/platform-resources/src/idea/PlatformActions.xml
index 9d6c838..85ac5e6 100644
--- a/platform/platform-resources/src/idea/PlatformActions.xml
+++ b/platform/platform-resources/src/idea/PlatformActions.xml
@@ -196,7 +196,6 @@
<action id="ToggleReadOnlyAttribute" class="com.intellij.ide.actions.ToggleReadOnlyAttributeAction"/>
<separator/>
<action id="Exit" class="com.intellij.ide.actions.ExitAction"/>
- <action id="Restart" class="com.intellij.internal.RestartInfoAction" text="Restart"/>
</group>
<!-- Edit -->
@@ -264,7 +263,7 @@
</group>
<!-- View -->
- <group id="ViewMenu" popup="true">
+ <group id="ViewMenu" popup="true" compact="true">
<group id="ToolWindowsGroup" class="com.intellij.ide.actions.ToolWindowsGroup" popup="true"/>
<action id="EditSource" class="com.intellij.ide.actions.EditSourceAction"/>
@@ -320,7 +319,7 @@
</group>
<!-- Tools -->
- <group id="ToolsMenu" configurable="true" popup="true">
+ <group id="ToolsMenu" configurable="true" popup="true" compact="true">
<action id="PsiViewer" class="com.intellij.internal.psiView.PsiViewerAction"/>
<action id="PsiViewerForContext" class="com.intellij.internal.psiView.PsiViewerForContextAction"/>
<separator/>
@@ -623,6 +622,7 @@
<action id="DirDiffMenu.SetNoOperation" class="com.intellij.openapi.diff.impl.dir.actions.popup.SetNoOperation" text="Set Do Nothing"/>
<separator/>
<action id="DirDiffMenu.SetDefault" class="com.intellij.openapi.diff.impl.dir.actions.popup.SetDefault" text="Set Default"/>
+ <action id="DirDiffMenu.WarnOnDeletion" class="com.intellij.openapi.diff.impl.dir.actions.popup.WarnOnDeletion" text="Warn When Delete" />
</group>
<action id="Rerun" class="com.intellij.execution.runners.FakeRerunAction" text="Rerun"/>
diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/FileWatcherTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/FileWatcherTest.java
index c5fb489..c133139 100644
--- a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/FileWatcherTest.java
+++ b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/FileWatcherTest.java
@@ -292,6 +292,26 @@
}
}
+ public void testIncorrectPath() throws Exception {
+ File topDir = createTestDir("top");
+ File file = createTestFile(topDir, "file.zip");
+ File subDir = new File(file, "sub/zip");
+ refresh(topDir);
+
+ LocalFileSystem.WatchRequest request = watch(subDir, false);
+ try {
+ myTimeout = 10 * INTER_RESPONSE_DELAY;
+ myAccept = true;
+ FileUtil.writeToFile(file, "new content");
+ assertEvent(VFileEvent.class);
+ myTimeout = NATIVE_PROCESS_DELAY;
+ }
+ finally {
+ unwatch(request);
+ delete(topDir);
+ }
+ }
+
public void testDirectoryOverlapping() throws Exception {
File topDir = createTestDir("top");
File fileInTopDir = createTestFile(topDir, "file1.txt");
diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/SymlinkHandlingTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/SymlinkHandlingTest.java
index 5537435..91e91fd 100644
--- a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/SymlinkHandlingTest.java
+++ b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/SymlinkHandlingTest.java
@@ -20,10 +20,7 @@
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.openapi.vfs.LocalFileSystem;
-import com.intellij.openapi.vfs.VfsUtilCore;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.openapi.vfs.VirtualFileVisitor;
+import com.intellij.openapi.vfs.*;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.HashSet;
@@ -60,7 +57,7 @@
File dotLinkFile = createSymLink(".", myTempDir + "/dot_link");
VirtualFile dotLinkVFile = refreshAndFind(dotLinkFile);
assertNotNull(dotLinkVFile);
- assertTrue(dotLinkVFile.isSymLink());
+ assertTrue(dotLinkVFile.is(VFileProperty.SYMLINK));
assertTrue(dotLinkVFile.isDirectory());
assertPathsEqual(myTempDir.getPath(), dotLinkVFile.getCanonicalPath());
assertVisitedPaths(dotLinkVFile.getPath());
@@ -71,7 +68,7 @@
File upLinkFile = createSymLink(upDir.getPath(), upDir.getPath() + "/up_link");
VirtualFile upLinkVFile = refreshAndFind(upLinkFile);
assertNotNull(upLinkVFile);
- assertTrue(upLinkVFile.isSymLink());
+ assertTrue(upLinkVFile.is(VFileProperty.SYMLINK));
assertTrue(upLinkVFile.isDirectory());
assertPathsEqual(upDir.getPath(), upLinkVFile.getCanonicalPath());
assertVisitedPaths(upDir.getPath(), upLinkVFile.getPath());
@@ -80,7 +77,7 @@
assertTrue(repeatedLinksFile.getPath(), repeatedLinksFile.isDirectory());
VirtualFile repeatedLinksVFile = refreshAndFind(repeatedLinksFile);
assertNotNull(repeatedLinksFile.getPath(), repeatedLinksVFile);
- assertTrue(repeatedLinksVFile.isSymLink());
+ assertTrue(repeatedLinksVFile.is(VFileProperty.SYMLINK));
assertTrue(repeatedLinksVFile.isDirectory());
assertPathsEqual(upDir.getPath(), repeatedLinksVFile.getCanonicalPath());
assertEquals(upLinkVFile.getCanonicalFile(), repeatedLinksVFile.getCanonicalFile());
@@ -110,7 +107,8 @@
File targetFile = createTestFile(myTempDir, "target.txt");
File linkFile = createSymLink(targetFile.getPath(), myTempDir + "/link");
VirtualFile linkVFile = refreshAndFind(linkFile);
- assertTrue("link=" + linkFile + ", vLink=" + linkVFile, linkVFile != null && !linkVFile.isDirectory() && linkVFile.isSymLink());
+ assertTrue("link=" + linkFile + ", vLink=" + linkVFile, linkVFile != null && !linkVFile.isDirectory() &&
+ linkVFile.is(VFileProperty.SYMLINK));
setWritableAndCheck(targetFile, true);
refresh();
@@ -122,7 +120,7 @@
File targetDir = createTestDir(myTempDir, "target");
File linkDir = createSymLink(targetDir.getPath(), myTempDir + "/linkDir");
VirtualFile linkVDir = refreshAndFind(linkDir);
- assertTrue("link=" + linkDir + ", vLink=" + linkVDir, linkVDir != null && linkVDir.isDirectory() && linkVDir.isSymLink());
+ assertTrue("link=" + linkDir + ", vLink=" + linkVDir, linkVDir != null && linkVDir.isDirectory() && linkVDir.is(VFileProperty.SYMLINK));
if (!SystemInfo.isWindows) {
setWritableAndCheck(targetDir, true);
@@ -146,7 +144,8 @@
File targetFile = createTestFile(myTempDir, "target");
File linkFile = createSymLink(targetFile.getPath(), myTempDir + "/link");
VirtualFile linkVFile = refreshAndFind(linkFile);
- assertTrue("link=" + linkFile + ", vLink=" + linkVFile, linkVFile != null && !linkVFile.isDirectory() && linkVFile.isSymLink());
+ assertTrue("link=" + linkFile + ", vLink=" + linkVFile, linkVFile != null && !linkVFile.isDirectory() &&
+ linkVFile.is(VFileProperty.SYMLINK));
AccessToken token = ApplicationManager.getApplication().acquireWriteActionLock(getClass());
try {
@@ -165,7 +164,7 @@
File linkDir = createSymLink(targetDir.getPath(), myTempDir + "/linkDir");
VirtualFile linkVDir = refreshAndFind(linkDir);
assertTrue("link=" + linkDir + ", vLink=" + linkVDir,
- linkVDir != null && linkVDir.isDirectory() && linkVDir.isSymLink() && linkVDir.getChildren().length == 1);
+ linkVDir != null && linkVDir.isDirectory() && linkVDir.is(VFileProperty.SYMLINK) && linkVDir.getChildren().length == 1);
token = ApplicationManager.getApplication().acquireWriteActionLock(getClass());
try {
@@ -188,33 +187,33 @@
File link = createSymLink(targetFile.getPath(), myTempDir + "/link");
VirtualFile vFile1 = refreshAndFind(link);
assertTrue("link=" + link + ", vLink=" + vFile1,
- vFile1 != null && !vFile1.isDirectory() && vFile1.isSymLink());
+ vFile1 != null && !vFile1.isDirectory() && vFile1.is(VFileProperty.SYMLINK));
// file link => dir
assertTrue(link.getPath(), link.delete() && link.mkdir() && link.isDirectory());
VirtualFile vFile2 = refreshAndFind(link);
assertTrue("link=" + link + ", vLink=" + vFile2,
- !vFile1.isValid() && vFile2 != null && vFile2.isDirectory() && !vFile2.isSymLink());
+ !vFile1.isValid() && vFile2 != null && vFile2.isDirectory() && !vFile2.is(VFileProperty.SYMLINK));
// dir => dir link
assertTrue(link.getPath(), link.delete());
link = createSymLink(targetDir.getPath(), myTempDir + "/link");
vFile1 = refreshAndFind(link);
assertTrue("link=" + link + ", vLink=" + vFile1,
- !vFile2.isValid() && vFile1 != null && vFile1.isDirectory() && vFile1.isSymLink());
+ !vFile2.isValid() && vFile1 != null && vFile1.isDirectory() && vFile1.is(VFileProperty.SYMLINK));
// dir link => file
assertTrue(link.getPath(), link.delete() && link.createNewFile() && link.isFile());
vFile2 = refreshAndFind(link);
assertTrue("link=" + link + ", vLink=" + vFile1,
- !vFile1.isValid() && vFile2 != null && !vFile2.isDirectory() && !vFile2.isSymLink());
+ !vFile1.isValid() && vFile2 != null && !vFile2.isDirectory() && !vFile2.is(VFileProperty.SYMLINK));
// file => file link
assertTrue(link.getPath(), link.delete());
link = createSymLink(targetFile.getPath(), myTempDir + "/link");
vFile1 = refreshAndFind(link);
assertTrue("link=" + link + ", vLink=" + vFile1,
- !vFile2.isValid() && vFile1 != null && !vFile1.isDirectory() && vFile1.isSymLink());
+ !vFile2.isValid() && vFile1 != null && !vFile1.isDirectory() && vFile1.is(VFileProperty.SYMLINK));
}
public void testDirLinkSwitch() throws Exception {
@@ -227,7 +226,7 @@
File link = createSymLink(targetDir1.getPath(), myTempDir + "/link");
VirtualFile vLink1 = refreshAndFind(link);
assertTrue("link=" + link + ", vLink=" + vLink1,
- vLink1 != null && vLink1.isDirectory() && vLink1.isSymLink());
+ vLink1 != null && vLink1.isDirectory() && vLink1.is(VFileProperty.SYMLINK));
assertEquals(1, vLink1.getChildren().length);
assertTrue(link.toString(), link.delete());
@@ -237,7 +236,7 @@
assertFalse(vLink1.isValid());
VirtualFile vLink2 = myFileSystem.findFileByIoFile(link);
assertTrue("link=" + link + ", vLink=" + vLink2,
- vLink2 != null && vLink2.isDirectory() && vLink2.isSymLink());
+ vLink2 != null && vLink2.isDirectory() && vLink2.is(VFileProperty.SYMLINK));
assertEquals(2, vLink2.getChildren().length);
}
@@ -250,7 +249,7 @@
File link = createSymLink(target1.getPath(), myTempDir + "/link");
VirtualFile vLink1 = refreshAndFind(link);
assertTrue("link=" + link + ", vLink=" + vLink1,
- vLink1 != null && !vLink1.isDirectory() && vLink1.isSymLink());
+ vLink1 != null && !vLink1.isDirectory() && vLink1.is(VFileProperty.SYMLINK));
assertEquals(FileUtil.loadFile(target1), VfsUtilCore.loadText(vLink1));
assertTrue(link.toString(), link.delete());
@@ -260,7 +259,7 @@
assertFalse(vLink1.isValid());
VirtualFile vLink2 = myFileSystem.findFileByIoFile(link);
assertTrue("link=" + link + ", vLink=" + vLink2,
- vLink2 != null && !vLink2.isDirectory() && vLink2.isSymLink());
+ vLink2 != null && !vLink2.isDirectory() && vLink2.is(VFileProperty.SYMLINK));
assertEquals(FileUtil.loadFile(target2), VfsUtilCore.loadText(vLink2));
}
@@ -335,13 +334,13 @@
}
private static void assertBrokenLink(@NotNull VirtualFile link) {
- assertTrue(link.isSymLink());
+ assertTrue(link.is(VFileProperty.SYMLINK));
assertEquals(0, link.getLength());
assertNull(link.getCanonicalPath(), link.getCanonicalPath());
}
private void assertVisitedPaths(String... expected) {
- VirtualFile vDir = myFileSystem.findFileByIoFile(myTempDir);
+ VirtualFile vDir = refreshAndFind(myTempDir);
assertNotNull(vDir);
Set<String> expectedSet = new HashSet<String>(expected.length + 1, 1);
diff --git a/platform/platform-tests/testSrc/com/intellij/psi/util/NameUtilMatchingTest.groovy b/platform/platform-tests/testSrc/com/intellij/psi/util/NameUtilMatchingTest.groovy
index 15156d9..24c86e4 100644
--- a/platform/platform-tests/testSrc/com/intellij/psi/util/NameUtilMatchingTest.groovy
+++ b/platform/platform-tests/testSrc/com/intellij/psi/util/NameUtilMatchingTest.groovy
@@ -461,7 +461,7 @@
TextRange.from(0, 4), TextRange.from(10, 1));
}
- public void "test plus/minus in the pattern should allow to be space-surrounded"() {
+ public void "test plus or minus in the pattern should allow to be space-surrounded"() {
assertMatches("a+b", "alpha+beta")
assertMatches("a+b", "alpha_gamma+beta")
assertMatches("a+b", "alpha + beta")
@@ -499,6 +499,10 @@
assertPreference("*psfi", "PsiJavaFileBaseImpl", "PsiFileImpl", NameUtil.MatchingCaseSensitivity.NONE);
}
+ public void "test prefer matches to the end"() {
+ assertPreference("*e", "fileIndex", "file", NameUtil.MatchingCaseSensitivity.NONE);
+ }
+
public void testPreferences() {
assertPreference(" fb", "FooBar", "_fooBar", NameUtil.MatchingCaseSensitivity.NONE);
assertPreference("*foo", "barFoo", "foobar");
diff --git a/platform/platform-tests/testSrc/com/intellij/usagesStatistics/RemotelyConfigurableStatServiceTest.java b/platform/platform-tests/testSrc/com/intellij/usagesStatistics/RemotelyConfigurableStatServiceTest.java
index cb2a332..6bf2093 100644
--- a/platform/platform-tests/testSrc/com/intellij/usagesStatistics/RemotelyConfigurableStatServiceTest.java
+++ b/platform/platform-tests/testSrc/com/intellij/usagesStatistics/RemotelyConfigurableStatServiceTest.java
@@ -1,82 +1,117 @@
+/*
+ * Copyright 2000-2013 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.usagesStatistics;
import com.intellij.internal.statistic.StatisticsUploadAssistant;
-import com.intellij.internal.statistic.connect.StatisticsHttpClientSender;
import com.intellij.internal.statistic.connect.RemotelyConfigurableStatisticsService;
import com.intellij.internal.statistic.connect.StatisticsConnectionService;
+import com.intellij.internal.statistic.connect.StatisticsHttpClientSender;
import com.intellij.internal.statistic.connect.StatisticsResult;
-import junit.framework.Assert;
-import junit.framework.TestCase;
-import org.jetbrains.annotations.NonNls;
+import com.intellij.testFramework.PlatformTestCase;
+import com.intellij.util.net.NetUtils;
import org.jetbrains.annotations.NotNull;
+import org.junit.BeforeClass;
+import org.junit.Test;
import java.util.Set;
-public class RemotelyConfigurableStatServiceTest extends TestCase {
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
- @NonNls
- private static final String STAT_URL = "http://localhost:8080/stat.jsp";
+public class RemotelyConfigurableStatServiceTest {
+ private static String STAT_URL;
+ private static String STAT_CONFIG_URL;
- @NonNls
- private static final String STAT_CONFIG_URL = "http://localhost:8080/config.jsp";
+ @SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors")
+ public RemotelyConfigurableStatServiceTest() {
+ PlatformTestCase.initPlatformLangPrefix();
+ }
+ @BeforeClass
+ public static void init() throws Exception {
+ int port = NetUtils.findAvailableSocketPort();
+ STAT_URL = "http://localhost:" + port + "/stat.jsp";
+ STAT_CONFIG_URL = "http://localhost:" + port + "/config.jsp";
+ }
+
+ @Test
public void testStatisticsConnectionServiceDefaultSettings() {
- final StatisticsConnectionService connectionService = new StatisticsConnectionService(STAT_CONFIG_URL, STAT_URL);
+ StatisticsConnectionService connectionService = new StatisticsConnectionService(STAT_CONFIG_URL, STAT_URL);
+ assertEquals(STAT_URL, connectionService.getServiceUrl());
- Assert.assertEquals(STAT_URL, connectionService.getServiceUrl());
- Assert.assertTrue(connectionService.isTransmissionPermitted());
- final String[] attributeNames = connectionService.getAttributeNames();
+ assertTrue(connectionService.isTransmissionPermitted());
+ String[] attributeNames = connectionService.getAttributeNames();
- Assert.assertEquals(attributeNames.length, 2);
- Assert.assertEquals(attributeNames[0], "url");
- Assert.assertEquals(attributeNames[1], "permitted");
+ assertEquals(attributeNames.length, 2);
+ assertEquals(attributeNames[0], "url");
+ assertEquals(attributeNames[1], "permitted");
}
+ @Test
public void testEmptyDataSending() {
- RemotelyConfigurableStatisticsService service = new RemotelyConfigurableStatisticsService(new StatisticsConnectionService(),
- new StatisticsHttpClientSender(),
- new StatisticsUploadAssistant() {
- @Override
- public String getData(@NotNull Set<String> disabledGroups) {
- return "";
- }
- });
- final StatisticsResult result = service.send();
- Assert.assertEquals(StatisticsResult.ResultCode.NOTHING_TO_SEND, result.getCode());
+ RemotelyConfigurableStatisticsService service =
+ new RemotelyConfigurableStatisticsService(new StatisticsConnectionService(),
+ new StatisticsHttpClientSender(),
+ new StatisticsUploadAssistant() {
+ @Override
+ public String getData(@NotNull Set<String> disabledGroups) {
+ return "";
+ }
+ });
+ StatisticsResult result = service.send();
+ assertEquals(StatisticsResult.ResultCode.NOTHING_TO_SEND, result.getCode());
}
+ @Test
public void testIncorrectUrlSending() {
- RemotelyConfigurableStatisticsService service = new RemotelyConfigurableStatisticsService(new StatisticsConnectionService(STAT_CONFIG_URL, STAT_URL),
- new StatisticsHttpClientSender(),
- new StatisticsUploadAssistant() {
- @Override
- public String getData(@NotNull Set<String> disabledGroups) {
- return "group:key1=11";
- }
- });
- final StatisticsResult result = service.send();
- Assert.assertEquals(StatisticsResult.ResultCode.SENT_WITH_ERRORS, result.getCode());
+ RemotelyConfigurableStatisticsService service =
+ new RemotelyConfigurableStatisticsService(new StatisticsConnectionService(STAT_CONFIG_URL, STAT_URL),
+ new StatisticsHttpClientSender(),
+ new StatisticsUploadAssistant() {
+ @Override
+ public String getData(@NotNull Set<String> disabledGroups) {
+ return "group:key1=11";
+ }
+ });
+ StatisticsResult result = service.send();
+ assertEquals(StatisticsResult.ResultCode.SENT_WITH_ERRORS, result.getCode());
}
+ @Test
public void testRemotelyDisabledTransmission() {
- RemotelyConfigurableStatisticsService service = new RemotelyConfigurableStatisticsService(new StatisticsConnectionService() {
- @Override
- public Boolean isTransmissionPermitted() {
- return false;
- }
- }, new StatisticsHttpClientSender(),
- new StatisticsUploadAssistant());
-
- final StatisticsResult result = service.send();
- Assert.assertEquals(StatisticsResult.ResultCode.NOT_PERMITTED_SERVER, result.getCode());
+ RemotelyConfigurableStatisticsService service =
+ new RemotelyConfigurableStatisticsService(new StatisticsConnectionService() {
+ @Override
+ public Boolean isTransmissionPermitted() {
+ return false;
+ }
+ },
+ new StatisticsHttpClientSender(),
+ new StatisticsUploadAssistant());
+ StatisticsResult result = service.send();
+ assertEquals(StatisticsResult.ResultCode.NOT_PERMITTED_SERVER, result.getCode());
}
+ @Test
public void testErrorInRemoteConfiguration() {
RemotelyConfigurableStatisticsService service =
new RemotelyConfigurableStatisticsService(new StatisticsConnectionService(STAT_CONFIG_URL, null),
new StatisticsHttpClientSender(),
new StatisticsUploadAssistant());
- final StatisticsResult result = service.send();
- Assert.assertEquals(StatisticsResult.ResultCode.ERROR_IN_CONFIG, result.getCode());
+ StatisticsResult result = service.send();
+ assertEquals(StatisticsResult.ResultCode.ERROR_IN_CONFIG, result.getCode());
}
}
diff --git a/platform/projectModel-api/src/com/intellij/openapi/module/ModifiableModuleModel.java b/platform/projectModel-api/src/com/intellij/openapi/module/ModifiableModuleModel.java
index b6c8937..4863075 100644
--- a/platform/projectModel-api/src/com/intellij/openapi/module/ModifiableModuleModel.java
+++ b/platform/projectModel-api/src/com/intellij/openapi/module/ModifiableModuleModel.java
@@ -137,7 +137,7 @@
boolean hasModuleGroups();
- void setModuleGroupPath(Module module, String[] groupPath);
+ void setModuleGroupPath(@NotNull Module module, @Nullable("null means remove") String[] groupPath);
- void setModuleFilePath(Module module, String oldPath, String newFilePath);
+ void setModuleFilePath(@NotNull Module module, String oldPath, String newFilePath);
}
diff --git a/platform/projectModel-api/src/com/intellij/openapi/roots/ModuleExtension.java b/platform/projectModel-api/src/com/intellij/openapi/roots/ModuleExtension.java
index d3fb969..efacdd0 100644
--- a/platform/projectModel-api/src/com/intellij/openapi/roots/ModuleExtension.java
+++ b/platform/projectModel-api/src/com/intellij/openapi/roots/ModuleExtension.java
@@ -30,6 +30,26 @@
public abstract class ModuleExtension<T extends ModuleExtension> implements JDOMExternalizable, Disposable, Comparable<ModuleExtension> {
public static final ExtensionPointName<ModuleExtension> EP_NAME = ExtensionPointName.create("com.intellij.moduleExtension");
+ /**
+ * <b>Note:</b> don't call this method directly from client code. Use approach below instead:
+ * <pre>
+ * ModifiableRootModel modifiableModel = ModuleRootManager.getInstance(module).getModifiableModel();
+ * CompilerModuleExtension extension = modifiableModel.getModuleExtension(CompilerModuleExtension.class);
+ * try {
+ * // ...
+ * }
+ * finally {
+ * modifiableModel.commit();
+ * }
+ * </pre>
+ * The point is that call to commit() on CompilerModuleExtension obtained like
+ * <code>'CompilerModuleExtension.getInstance(module).getModifiableModel(true)'</code> doesn't dispose the model.
+ * <p/>
+ * Call to <code>ModifiableRootModel.commit()</code> not only commits linked extensions but disposes them as well.
+ *
+ * @param writable flag which identifies if resulting model is writable
+ * @return extension model
+ */
public abstract ModuleExtension getModifiableModel(final boolean writable);
public abstract void commit();
diff --git a/platform/projectModel-impl/src/com/intellij/application/options/PathMacrosImpl.java b/platform/projectModel-impl/src/com/intellij/application/options/PathMacrosImpl.java
index 4c36cdf..b5ba8ef 100644
--- a/platform/projectModel-impl/src/com/intellij/application/options/PathMacrosImpl.java
+++ b/platform/projectModel-impl/src/com/intellij/application/options/PathMacrosImpl.java
@@ -122,6 +122,7 @@
"SourcepathEntry",
"Sourcepath",
"SHOW_CHANGES",
+ "ClipboardContent",
"SelectedText",
"SelectionStartLine",
"SelectionEndLine",
diff --git a/platform/projectModel-impl/src/com/intellij/application/options/ReplacePathToMacroMap.java b/platform/projectModel-impl/src/com/intellij/application/options/ReplacePathToMacroMap.java
index eb03f28..ffb0096 100644
--- a/platform/projectModel-impl/src/com/intellij/application/options/ReplacePathToMacroMap.java
+++ b/platform/projectModel-impl/src/com/intellij/application/options/ReplacePathToMacroMap.java
@@ -24,6 +24,8 @@
import com.intellij.util.containers.ContainerUtilRt;
import gnu.trove.TObjectIntHashMap;
import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Comparator;
@@ -75,7 +77,7 @@
}
@Override
- public String substitute(String text, boolean caseSensitive) {
+ public String substitute(@Nullable String text, boolean caseSensitive) {
if (text == null) {
//noinspection ConstantConditions
return null;
@@ -87,7 +89,7 @@
return text;
}
- private String replacePathMacro(String text, final String path, boolean caseSensitive) {
+ private String replacePathMacro(@NotNull String text, @NotNull final String path, boolean caseSensitive) {
if (text.length() < path.length() || path.isEmpty()) {
return text;
}
@@ -111,14 +113,14 @@
}
@Override
- public String substituteRecursively(String text, final boolean caseSensitive) {
+ public String substituteRecursively(@NotNull String text, final boolean caseSensitive) {
for (final String path : getPathIndex()) {
text = replacePathMacroRecursively(text, path, caseSensitive);
}
return text;
}
- private String replacePathMacroRecursively(String text, final String path, boolean caseSensitive) {
+ private String replacePathMacroRecursively(@NotNull final String text, @NotNull final String path, boolean caseSensitive) {
if (text.length() < path.length()) {
return text;
}
@@ -167,7 +169,7 @@
return newText.toString();
}
- private static int getIndex(final Map.Entry<String, String> s) {
+ private static int getIndex(@NotNull final Map.Entry<String, String> s) {
final String replacement = s.getValue();
if (replacement.contains("..")) return 1;
if (replacement.contains("$" + PathMacrosImpl.USER_HOME_MACRO_NAME + "$")) return 1;
@@ -176,7 +178,7 @@
return 2;
}
- private static int stripPrefix(String key) {
+ private static int stripPrefix(@NotNull String key) {
key = StringUtil.trimStart(key, "jar:");
key = StringUtil.trimStart(key, "file:");
while (key.startsWith("/")) {
@@ -185,6 +187,7 @@
return key.length();
}
+ @NotNull
public List<String> getPathIndex() {
if (myPathsIndex == null || myPathsIndex.size() != myMacroMap.size()) {
List<Map.Entry<String, String>> entries = new ArrayList<Map.Entry<String, String>>(myMacroMap.entrySet());
diff --git a/platform/projectModel-impl/src/com/intellij/openapi/components/PathMacroManager.java b/platform/projectModel-impl/src/com/intellij/openapi/components/PathMacroManager.java
index 8e8d484..8999bb9 100644
--- a/platform/projectModel-impl/src/com/intellij/openapi/components/PathMacroManager.java
+++ b/platform/projectModel-impl/src/com/intellij/openapi/components/PathMacroManager.java
@@ -26,14 +26,14 @@
}
@Override
- public abstract void expandPaths(Element element);
+ public abstract void expandPaths(@NotNull Element element);
@Override
- public abstract void collapsePaths(Element element);
+ public abstract void collapsePaths(@NotNull Element element);
- public abstract void collapsePathsRecursively(Element element);
+ public abstract void collapsePathsRecursively(@NotNull Element element);
- public abstract String collapsePathsRecursively(String text);
+ public abstract String collapsePathsRecursively(@NotNull String text);
public abstract TrackingPathMacroSubstitutor createTrackingSubstitutor();
}
diff --git a/platform/projectModel-impl/src/com/intellij/openapi/components/impl/BasePathMacroManager.java b/platform/projectModel-impl/src/com/intellij/openapi/components/impl/BasePathMacroManager.java
index 47e4093..48cf3fc 100644
--- a/platform/projectModel-impl/src/com/intellij/openapi/components/impl/BasePathMacroManager.java
+++ b/platform/projectModel-impl/src/com/intellij/openapi/components/impl/BasePathMacroManager.java
@@ -30,6 +30,7 @@
import com.intellij.openapi.vfs.VirtualFileSystem;
import com.intellij.util.containers.FactoryMap;
import org.jdom.Element;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.serialization.PathMacroUtil;
@@ -111,22 +112,22 @@
}
@Override
- public void collapsePathsRecursively(final Element element) {
+ public void collapsePathsRecursively(@NotNull final Element element) {
getReplacePathMap().substitute(element, SystemInfo.isFileSystemCaseSensitive, true);
}
@Override
- public String collapsePathsRecursively(final String text) {
+ public String collapsePathsRecursively(@NotNull final String text) {
return getReplacePathMap().substituteRecursively(text, SystemInfo.isFileSystemCaseSensitive);
}
@Override
- public void expandPaths(final Element element) {
+ public void expandPaths(@NotNull final Element element) {
getExpandMacroMap().substitute(element, SystemInfo.isFileSystemCaseSensitive);
}
@Override
- public void collapsePaths(final Element element) {
+ public void collapsePaths(@NotNull final Element element) {
getReplacePathMap().substitute(element, SystemInfo.isFileSystemCaseSensitive);
}
diff --git a/platform/projectModel-impl/src/com/intellij/openapi/components/impl/stores/DirectoryStorageData.java b/platform/projectModel-impl/src/com/intellij/openapi/components/impl/stores/DirectoryStorageData.java
index 98c505b..4a9aaed 100644
--- a/platform/projectModel-impl/src/com/intellij/openapi/components/impl/stores/DirectoryStorageData.java
+++ b/platform/projectModel-impl/src/com/intellij/openapi/components/impl/stores/DirectoryStorageData.java
@@ -61,10 +61,16 @@
try {
final Document document = JDOMUtil.loadDocument(file.contentsToByteArray());
final Element element = document.getRootElement();
- assert element.getName().equals(StorageData.COMPONENT);
+ if (!element.getName().equals(StorageData.COMPONENT)) {
+ LOG.error("Incorrect root tag name (" + element.getName() + ") in " + file.getPresentableUrl());
+ continue;
+ }
String componentName = element.getAttributeValue(StorageData.NAME);
- assert componentName != null;
+ if (componentName == null) {
+ LOG.error("Component name isn't specified in " + file.getPresentableUrl());
+ continue;
+ }
if (pathMacroSubstitutor != null) {
pathMacroSubstitutor.expandPaths(element);
diff --git a/platform/projectModel-impl/src/com/intellij/openapi/module/impl/ModuleManagerImpl.java b/platform/projectModel-impl/src/com/intellij/openapi/module/impl/ModuleManagerImpl.java
index 0b913f2..6e3571e 100644
--- a/platform/projectModel-impl/src/com/intellij/openapi/module/impl/ModuleManagerImpl.java
+++ b/platform/projectModel-impl/src/com/intellij/openapi/module/impl/ModuleManagerImpl.java
@@ -136,9 +136,9 @@
}
});
- private void setModuleGroupPath(ModifiableModuleModel model, Module module, String[] group) {
- String[] cached = paths.get(group);
- if (cached == null) {
+ private void setModuleGroupPath(@NotNull ModifiableModuleModel model, Module module, @Nullable String[] group) {
+ String[] cached = group == null ? null : paths.get(group);
+ if (cached == null && group != null) {
cached = new String[group.length];
for (int i = 0; i < group.length; i++) {
String g = group[i];
@@ -169,7 +169,7 @@
myModulePaths.remove(correspondingPath);
String groupStr = correspondingPath.getModuleGroup();
- String[] group = groupStr != null ? groupStr.split(MODULE_GROUP_SEPARATOR) : null;
+ String[] group = groupStr == null ? null : groupStr.split(MODULE_GROUP_SEPARATOR);
if (!Arrays.equals(group, model.getModuleGroupPath(existingModule))) {
groupInterner.setModuleGroupPath(model, existingModule, group);
}
@@ -914,7 +914,7 @@
}
@Override
- public void setModuleGroupPath(Module module, String[] groupPath) {
+ public void setModuleGroupPath(@NotNull Module module, @Nullable("null means remove") String[] groupPath) {
if (myModuleGroupPath == null) {
myModuleGroupPath = new THashMap<Module, String[]>();
}
@@ -927,7 +927,7 @@
}
@Override
- public void setModuleFilePath(Module module, String oldPath, String newFilePath) {
+ public void setModuleFilePath(@NotNull Module module, String oldPath, String newFilePath) {
myPathToModule.remove(oldPath);
myPathToModule.put(newFilePath, module);
}
diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryImpl.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryImpl.java
index 0d699f7..310932c 100644
--- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryImpl.java
+++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryImpl.java
@@ -17,7 +17,7 @@
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.components.PersistentStateComponent;
+import com.intellij.openapi.components.ComponentSerializationUtil;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.roots.ModifiableRootModel;
@@ -36,7 +36,6 @@
import com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer;
import com.intellij.openapi.vfs.pointers.VirtualFilePointerManager;
import com.intellij.util.ArrayUtil;
-import com.intellij.util.ReflectionUtil;
import com.intellij.util.SmartList;
import com.intellij.util.containers.HashMap;
import com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters;
@@ -271,7 +270,7 @@
myProperties = myKind.createDefaultProperties();
final Element propertiesElement = element.getChild(PROPERTIES_ELEMENT);
if (propertiesElement != null) {
- final Class<?> stateClass = ReflectionUtil.getRawType(ReflectionUtil.resolveVariableInHierarchy(PersistentStateComponent.class.getTypeParameters()[0], myProperties.getClass()));
+ final Class<?> stateClass = ComponentSerializationUtil.getStateClass(myProperties.getClass());
//noinspection unchecked
myProperties.loadState(XmlSerializer.deserialize(propertiesElement, stateClass));
}
diff --git a/platform/remote-servers/api/remote-servers-api.iml b/platform/remote-servers/api/remote-servers-api.iml
new file mode 100644
index 0000000..deb49db
--- /dev/null
+++ b/platform/remote-servers/api/remote-servers-api.iml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
+ <exclude-output />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="module" module-name="core-api" />
+ <orderEntry type="module" module-name="platform-api" />
+ <orderEntry type="module" module-name="compiler-openapi" />
+ </component>
+</module>
+
diff --git a/platform/remote-servers/api/src/com/intellij/remoteServer/ServerType.java b/platform/remote-servers/api/src/com/intellij/remoteServer/ServerType.java
new file mode 100644
index 0000000..c3b2029
--- /dev/null
+++ b/platform/remote-servers/api/src/com/intellij/remoteServer/ServerType.java
@@ -0,0 +1,41 @@
+package com.intellij.remoteServer;
+
+import com.intellij.openapi.extensions.ExtensionPointName;
+import com.intellij.openapi.options.UnnamedConfigurable;
+import com.intellij.openapi.project.Project;
+import com.intellij.remoteServer.configuration.ServerConfiguration;
+import com.intellij.remoteServer.deployment.Deployer;
+import org.jetbrains.annotations.NotNull;
+
+import javax.swing.*;
+
+/**
+ * @author nik
+ */
+public abstract class ServerType<C extends ServerConfiguration> {
+ public static final ExtensionPointName<ServerType> EP_NAME = ExtensionPointName.create("com.intellij.remoteServer.type");
+ private final String myId;
+
+ protected ServerType(String id) {
+ myId = id;
+ }
+
+ public final String getId() {
+ return myId;
+ }
+
+ @NotNull
+ public abstract String getPresentableName();
+
+ @NotNull
+ public abstract Icon getIcon();
+
+ @NotNull
+ public abstract C createDefaultConfiguration();
+
+ @NotNull
+ public abstract UnnamedConfigurable createConfigurable(@NotNull C configuration);
+
+ @NotNull
+ public abstract Deployer<C> createDeployer(Project project);
+}
diff --git a/platform/remote-servers/api/src/com/intellij/remoteServer/configuration/RemoteServer.java b/platform/remote-servers/api/src/com/intellij/remoteServer/configuration/RemoteServer.java
new file mode 100644
index 0000000..e845ade
--- /dev/null
+++ b/platform/remote-servers/api/src/com/intellij/remoteServer/configuration/RemoteServer.java
@@ -0,0 +1,20 @@
+package com.intellij.remoteServer.configuration;
+
+import com.intellij.remoteServer.ServerType;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author nik
+ */
+public interface RemoteServer<C extends ServerConfiguration> {
+ @NotNull
+ String getName();
+
+ @NotNull
+ ServerType<C> getType();
+
+ @NotNull
+ C getConfiguration();
+
+ void setName(String name);
+}
diff --git a/platform/remote-servers/api/src/com/intellij/remoteServer/configuration/RemoteServersManager.java b/platform/remote-servers/api/src/com/intellij/remoteServer/configuration/RemoteServersManager.java
new file mode 100644
index 0000000..5c29088
--- /dev/null
+++ b/platform/remote-servers/api/src/com/intellij/remoteServer/configuration/RemoteServersManager.java
@@ -0,0 +1,30 @@
+package com.intellij.remoteServer.configuration;
+
+import com.intellij.openapi.components.ServiceManager;
+import com.intellij.remoteServer.ServerType;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.List;
+
+/**
+ * @author nik
+ */
+public abstract class RemoteServersManager {
+ public static RemoteServersManager getInstance() {
+ return ServiceManager.getService(RemoteServersManager.class);
+ }
+
+ public abstract List<RemoteServer<?>> getServers();
+
+ public abstract <C extends ServerConfiguration> List<RemoteServer<C>> getServers(@NotNull ServerType<C> type);
+
+ @Nullable
+ public abstract <C extends ServerConfiguration> RemoteServer<C> findByName(@NotNull String name, @NotNull ServerType<C> type);
+
+ public abstract <C extends ServerConfiguration> RemoteServer<C> createServer(@NotNull ServerType<C> type, @NotNull String name);
+
+ public abstract void addServer(RemoteServer<?> server);
+
+ public abstract void removeServer(RemoteServer<?> server);
+}
diff --git a/platform/remote-servers/api/src/com/intellij/remoteServer/configuration/ServerConfiguration.java b/platform/remote-servers/api/src/com/intellij/remoteServer/configuration/ServerConfiguration.java
new file mode 100644
index 0000000..255bdb8
--- /dev/null
+++ b/platform/remote-servers/api/src/com/intellij/remoteServer/configuration/ServerConfiguration.java
@@ -0,0 +1,10 @@
+package com.intellij.remoteServer.configuration;
+
+import com.intellij.openapi.components.PersistentStateComponent;
+
+/**
+ * @author nik
+ */
+public abstract class ServerConfiguration {
+ public abstract PersistentStateComponent<?> getSerializer();
+}
diff --git a/platform/remote-servers/api/src/com/intellij/remoteServer/deployment/ArtifactDeploymentSource.java b/platform/remote-servers/api/src/com/intellij/remoteServer/deployment/ArtifactDeploymentSource.java
new file mode 100644
index 0000000..1a3838e
--- /dev/null
+++ b/platform/remote-servers/api/src/com/intellij/remoteServer/deployment/ArtifactDeploymentSource.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2000-2013 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.remoteServer.deployment;
+
+import com.intellij.packaging.artifacts.Artifact;
+import com.intellij.packaging.artifacts.ArtifactPointer;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * @author nik
+ */
+public interface ArtifactDeploymentSource extends DeploymentSource {
+ @NotNull
+ ArtifactPointer getArtifactPointer();
+
+ @Nullable
+ Artifact getArtifact();
+}
diff --git a/platform/remote-servers/api/src/com/intellij/remoteServer/deployment/Deployer.java b/platform/remote-servers/api/src/com/intellij/remoteServer/deployment/Deployer.java
new file mode 100644
index 0000000..c16322c
--- /dev/null
+++ b/platform/remote-servers/api/src/com/intellij/remoteServer/deployment/Deployer.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2000-2013 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.remoteServer.deployment;
+
+import com.intellij.remoteServer.configuration.RemoteServer;
+import com.intellij.remoteServer.configuration.ServerConfiguration;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.List;
+
+/**
+ * @author nik
+ */
+public abstract class Deployer<C extends ServerConfiguration> {
+ @NotNull
+ public abstract List<DeploymentSource> getAvailableDeploymentSources();
+
+ public abstract void startDeployment(@NotNull RemoteServer<C> server, @NotNull DeploymentSource source);
+}
diff --git a/platform/remote-servers/api/src/com/intellij/remoteServer/deployment/DeploymentSource.java b/platform/remote-servers/api/src/com/intellij/remoteServer/deployment/DeploymentSource.java
new file mode 100644
index 0000000..123ae3e
--- /dev/null
+++ b/platform/remote-servers/api/src/com/intellij/remoteServer/deployment/DeploymentSource.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2000-2013 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.remoteServer.deployment;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+import java.io.File;
+
+/**
+ * @author nik
+ */
+public interface DeploymentSource {
+ @Nullable
+ File getFile();
+
+ @Nullable
+ String getFilePath();
+
+ @NotNull
+ String getPresentableName();
+
+ @Nullable
+ Icon getIcon();
+
+ boolean isValid();
+}
diff --git a/platform/remote-servers/api/src/com/intellij/remoteServer/deployment/DeploymentSourceUtil.java b/platform/remote-servers/api/src/com/intellij/remoteServer/deployment/DeploymentSourceUtil.java
new file mode 100644
index 0000000..1d10281
--- /dev/null
+++ b/platform/remote-servers/api/src/com/intellij/remoteServer/deployment/DeploymentSourceUtil.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2000-2013 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.remoteServer.deployment;
+
+import com.intellij.openapi.components.ServiceManager;
+import com.intellij.openapi.project.Project;
+import com.intellij.packaging.artifacts.ArtifactPointer;
+import org.jdom.Element;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author nik
+ */
+public abstract class DeploymentSourceUtil {
+ public static DeploymentSourceUtil getInstance() {
+ return ServiceManager.getService(DeploymentSourceUtil.class);
+ }
+
+ @NotNull
+ public abstract ArtifactDeploymentSource createArtifactDeploymentSource(@NotNull ArtifactPointer artifactPointer);
+
+ public abstract DeploymentSource loadDeploymentSource(@NotNull Element element, @NotNull Project project);
+
+ public abstract void saveDeploymentSource(@NotNull DeploymentSource source, @NotNull Element element, @NotNull Project project);
+}
diff --git a/platform/remote-servers/impl/remote-servers-impl.iml b/platform/remote-servers/impl/remote-servers-impl.iml
new file mode 100644
index 0000000..51c6c6f
--- /dev/null
+++ b/platform/remote-servers/impl/remote-servers-impl.iml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
+ <exclude-output />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="module" module-name="platform-api" />
+ <orderEntry type="module" module-name="remote-servers-api" />
+ <orderEntry type="module" module-name="core-impl" />
+ <orderEntry type="module" module-name="lang-api" />
+ <orderEntry type="module" module-name="compiler-openapi" />
+ <orderEntry type="module" module-name="lang-impl" />
+ </component>
+</module>
+
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/configuration/impl/RemoteServerConfigurable.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/configuration/impl/RemoteServerConfigurable.java
new file mode 100644
index 0000000..6633e15
--- /dev/null
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/configuration/impl/RemoteServerConfigurable.java
@@ -0,0 +1,93 @@
+package com.intellij.remoteServer.configuration.impl;
+
+import com.intellij.openapi.options.ConfigurationException;
+import com.intellij.openapi.options.UnnamedConfigurable;
+import com.intellij.openapi.ui.NamedConfigurable;
+import com.intellij.remoteServer.configuration.RemoteServer;
+import com.intellij.remoteServer.configuration.ServerConfiguration;
+import org.jetbrains.annotations.Nls;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+import java.awt.*;
+
+/**
+ * @author nik
+ */
+public class RemoteServerConfigurable extends NamedConfigurable<RemoteServer<?>> {
+ private final UnnamedConfigurable myConfigurable;
+ private final RemoteServer<?> myServer;
+ private String myServerName;
+ private boolean myNew;
+
+ public <C extends ServerConfiguration> RemoteServerConfigurable(RemoteServer<C> server, Runnable treeUpdater, boolean isNew) {
+ super(true, treeUpdater);
+ myServer = server;
+ myNew = isNew;
+ myServerName = myServer.getName();
+ C c = server.getConfiguration();
+ myConfigurable = server.getType().createConfigurable(c);
+ }
+
+ @Override
+ public RemoteServer<?> getEditableObject() {
+ return myServer;
+ }
+
+ @Override
+ public String getBannerSlogan() {
+ return myServer.getName();
+ }
+
+ @Override
+ public JComponent createOptionsPanel() {
+ JComponent component = myConfigurable.createComponent();
+ JPanel panel = new JPanel(new BorderLayout());
+ panel.add(component, BorderLayout.NORTH);
+ return panel;
+ }
+
+ @Nls
+ @Override
+ public String getDisplayName() {
+ return myServerName;
+ }
+
+ @Nullable
+ @Override
+ public String getHelpTopic() {
+ return null;
+ }
+
+ @Override
+ public void setDisplayName(String name) {
+ myServerName = name;
+ }
+
+ @Override
+ public boolean isModified() {
+ return myNew || myConfigurable.isModified() || !myServerName.equals(myServer.getName());
+ }
+
+ @Override
+ public void apply() throws ConfigurationException {
+ myConfigurable.apply();
+ myNew = false;
+ }
+
+ @Override
+ public void reset() {
+ myConfigurable.reset();
+ }
+
+ @Override
+ public void disposeUIResources() {
+ myConfigurable.disposeUIResources();
+ }
+
+ @Nullable
+ @Override
+ public Icon getIcon(boolean expanded) {
+ return myServer.getType().getIcon();
+ }
+}
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/configuration/impl/RemoteServerImpl.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/configuration/impl/RemoteServerImpl.java
new file mode 100644
index 0000000..a210be0
--- /dev/null
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/configuration/impl/RemoteServerImpl.java
@@ -0,0 +1,44 @@
+package com.intellij.remoteServer.configuration.impl;
+
+import com.intellij.remoteServer.ServerType;
+import com.intellij.remoteServer.configuration.RemoteServer;
+import com.intellij.remoteServer.configuration.ServerConfiguration;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author nik
+ */
+public class RemoteServerImpl<C extends ServerConfiguration> implements RemoteServer<C> {
+ private String myName;
+ private ServerType<C> myType;
+ private C myConfiguration;
+
+ public RemoteServerImpl(String name, ServerType<C> type, C configuration) {
+ myName = name;
+ myType = type;
+ myConfiguration = configuration;
+ }
+
+ @NotNull
+ @Override
+ public String getName() {
+ return myName;
+ }
+
+ @NotNull
+ @Override
+ public ServerType<C> getType() {
+ return myType;
+ }
+
+ @NotNull
+ @Override
+ public C getConfiguration() {
+ return myConfiguration;
+ }
+
+ @Override
+ public void setName(String name) {
+ myName = name;
+ }
+}
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/configuration/impl/RemoteServerListConfigurable.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/configuration/impl/RemoteServerListConfigurable.java
new file mode 100644
index 0000000..f2ff8c9
--- /dev/null
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/configuration/impl/RemoteServerListConfigurable.java
@@ -0,0 +1,171 @@
+package com.intellij.remoteServer.configuration.impl;
+
+import com.intellij.openapi.actionSystem.ActionGroup;
+import com.intellij.openapi.actionSystem.AnAction;
+import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.actionSystem.CommonShortcuts;
+import com.intellij.openapi.options.ConfigurationException;
+import com.intellij.openapi.options.OptionalConfigurable;
+import com.intellij.openapi.project.DumbAwareAction;
+import com.intellij.openapi.ui.MasterDetailsComponent;
+import com.intellij.openapi.ui.NamedConfigurable;
+import com.intellij.openapi.util.Condition;
+import com.intellij.remoteServer.ServerType;
+import com.intellij.remoteServer.configuration.RemoteServer;
+import com.intellij.remoteServer.configuration.RemoteServersManager;
+import com.intellij.util.IconUtil;
+import com.intellij.util.text.UniqueNameGenerator;
+import org.jetbrains.annotations.Nls;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author nik
+ */
+public class RemoteServerListConfigurable extends MasterDetailsComponent implements OptionalConfigurable {
+ private final RemoteServersManager myServersManager;
+
+ public RemoteServerListConfigurable(RemoteServersManager manager) {
+ myServersManager = manager;
+ initTree();
+ }
+
+ @Nls
+ @Override
+ public String getDisplayName() {
+ return "Clouds";
+ }
+
+ @Override
+ public void reset() {
+ myRoot.removeAllChildren();
+ for (RemoteServer<?> server : myServersManager.getServers()) {
+ addServerNode(server, false);
+ }
+ super.reset();
+ }
+
+ private MyNode addServerNode(RemoteServer<?> server, boolean isNew) {
+ MyNode node = new MyNode(new RemoteServerConfigurable(server, TREE_UPDATER, isNew));
+ addNode(node, myRoot);
+ return node;
+ }
+
+ @Override
+ protected void processRemovedItems() {
+ Set<RemoteServer<?>> servers = new HashSet<RemoteServer<?>>();
+ for (NamedConfigurable<RemoteServer<?>> configurable : getConfiguredServers()) {
+ servers.add(configurable.getEditableObject());
+ }
+
+ List<RemoteServer<?>> toDelete = new ArrayList<RemoteServer<?>>();
+ for (RemoteServer<?> server : myServersManager.getServers()) {
+ if (!servers.contains(server)) {
+ toDelete.add(server);
+ }
+ }
+ for (RemoteServer<?> server : toDelete) {
+ myServersManager.removeServer(server);
+ }
+ }
+
+ @Override
+ public void apply() throws ConfigurationException {
+ super.apply();
+ Set<RemoteServer<?>> servers = new HashSet<RemoteServer<?>>(myServersManager.getServers());
+ for (NamedConfigurable<RemoteServer<?>> configurable : getConfiguredServers()) {
+ RemoteServer<?> server = configurable.getEditableObject();
+ server.setName(configurable.getDisplayName());
+ if (!servers.contains(server)) {
+ myServersManager.addServer(server);
+ }
+ }
+ }
+
+ @Nullable
+ @Override
+ protected ArrayList<AnAction> createActions(boolean fromPopup) {
+ ArrayList<AnAction> actions = new ArrayList<AnAction>();
+ actions.add(new AddRemoteServerGroup());
+ actions.add(new MyDeleteAction());
+ return actions;
+ }
+
+ @Override
+ public boolean needDisplay() {
+ return ServerType.EP_NAME.getExtensions().length > 0;
+ }
+
+ @Override
+ protected boolean wasObjectStored(Object editableObject) {
+ return true;
+ }
+
+ private List<NamedConfigurable<RemoteServer<?>>> getConfiguredServers() {
+ List<NamedConfigurable<RemoteServer<?>>> configurables = new ArrayList<NamedConfigurable<RemoteServer<?>>>();
+ for (int i = 0; i < myRoot.getChildCount(); i++) {
+ MyNode node = (MyNode)myRoot.getChildAt(i);
+ configurables.add((NamedConfigurable<RemoteServer<?>>)node.getConfigurable());
+ }
+ return configurables;
+ }
+
+ private class AddRemoteServerGroup extends ActionGroup implements ActionGroupWithPreselection {
+ private AddRemoteServerGroup() {
+ super("Add", "", IconUtil.getAddIcon());
+ registerCustomShortcutSet(CommonShortcuts.INSERT, myTree);
+ }
+
+ @NotNull
+ @Override
+ public AnAction[] getChildren(@Nullable AnActionEvent e) {
+ ServerType[] serverTypes = ServerType.EP_NAME.getExtensions();
+ AnAction[] actions = new AnAction[serverTypes.length];
+ for (int i = 0; i < serverTypes.length; i++) {
+ actions[i] = new AddRemoteServerAction(serverTypes[i]);
+ }
+ return actions;
+ }
+
+ @Override
+ public ActionGroup getActionGroup() {
+ return this;
+ }
+
+ @Override
+ public int getDefaultIndex() {
+ return 0;
+ }
+ }
+
+ private class AddRemoteServerAction extends DumbAwareAction {
+ private final ServerType<?> myServerType;
+
+ private AddRemoteServerAction(ServerType<?> serverType) {
+ super(serverType.getPresentableName(), null, serverType.getIcon());
+ myServerType = serverType;
+ }
+
+ @Override
+ public void actionPerformed(AnActionEvent e) {
+ String name = UniqueNameGenerator.generateUniqueName(myServerType.getPresentableName(), new Condition<String>() {
+ @Override
+ public boolean value(String s) {
+ for (NamedConfigurable<RemoteServer<?>> configurable : getConfiguredServers()) {
+ if (configurable.getDisplayName().equals(s)) {
+ return false;
+ }
+ }
+ return true;
+ }
+ });
+ MyNode node = addServerNode(myServersManager.createServer(myServerType, name), true);
+ selectNodeInTree(node);
+ }
+ }
+}
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/configuration/impl/RemoteServerState.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/configuration/impl/RemoteServerState.java
new file mode 100644
index 0000000..fcf6f2d
--- /dev/null
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/configuration/impl/RemoteServerState.java
@@ -0,0 +1,18 @@
+package com.intellij.remoteServer.configuration.impl;
+
+import com.intellij.util.xmlb.annotations.Attribute;
+import com.intellij.util.xmlb.annotations.Tag;
+import org.jdom.Element;
+
+/**
+* @author nik
+*/
+@Tag("remote-server")
+public class RemoteServerState {
+ @Attribute("name")
+ public String myName;
+ @Attribute("type")
+ public String myTypeId;
+ @Tag("configuration")
+ public Element myConfiguration;
+}
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/configuration/impl/RemoteServersManagerImpl.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/configuration/impl/RemoteServersManagerImpl.java
new file mode 100644
index 0000000..3065bbc
--- /dev/null
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/configuration/impl/RemoteServersManagerImpl.java
@@ -0,0 +1,125 @@
+package com.intellij.remoteServer.configuration.impl;
+
+import com.intellij.openapi.components.ComponentSerializationUtil;
+import com.intellij.openapi.components.PersistentStateComponent;
+import com.intellij.openapi.components.State;
+import com.intellij.openapi.components.Storage;
+import com.intellij.openapi.components.StoragePathMacros;
+import com.intellij.remoteServer.ServerType;
+import com.intellij.remoteServer.configuration.RemoteServer;
+import com.intellij.remoteServer.configuration.RemoteServersManager;
+import com.intellij.remoteServer.configuration.ServerConfiguration;
+import com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters;
+import com.intellij.util.xmlb.XmlSerializer;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author nik
+ */
+@State(name = "RemoteServers", storages = {
+ @Storage(file = StoragePathMacros.APP_CONFIG + "/remote-servers.xml")
+})
+public class RemoteServersManagerImpl extends RemoteServersManager implements PersistentStateComponent<RemoteServersManagerState> {
+ public static final SkipDefaultValuesSerializationFilters SERIALIZATION_FILTERS = new SkipDefaultValuesSerializationFilters();
+ private List<RemoteServer<?>> myServers = new ArrayList<RemoteServer<?>>();
+ private List<RemoteServerState> myUnknownServers = new ArrayList<RemoteServerState>();
+
+ @Override
+ public List<RemoteServer<?>> getServers() {
+ return Collections.unmodifiableList(myServers);
+ }
+
+ @Override
+ public <C extends ServerConfiguration> List<RemoteServer<C>> getServers(@NotNull ServerType<C> type) {
+ List<RemoteServer<C>> servers = new ArrayList<RemoteServer<C>>();
+ for (RemoteServer<?> server : myServers) {
+ if (server.getType().equals(type)) {
+ servers.add((RemoteServer<C>)server);
+ }
+ }
+ return servers;
+ }
+
+ @Nullable
+ @Override
+ public <C extends ServerConfiguration> RemoteServer<C> findByName(@NotNull String name, @NotNull ServerType<C> type) {
+ for (RemoteServer<?> server : myServers) {
+ if (server.getType().equals(type) && server.getName().equals(name)) {
+ return (RemoteServer<C>)server;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public <C extends ServerConfiguration> RemoteServer<C> createServer(@NotNull ServerType<C> type, @NotNull String name) {
+ return new RemoteServerImpl<C>(name, type, type.createDefaultConfiguration());
+ }
+
+ @Override
+ public void addServer(RemoteServer<?> server) {
+ myServers.add(server);
+ }
+
+ @Override
+ public void removeServer(RemoteServer<?> server) {
+ myServers.remove(server);
+ }
+
+ @Nullable
+ @Override
+ public RemoteServersManagerState getState() {
+ RemoteServersManagerState state = new RemoteServersManagerState();
+ for (RemoteServer<?> server : myServers) {
+ RemoteServerState serverState = new RemoteServerState();
+ serverState.myName = server.getName();
+ serverState.myTypeId = server.getType().getId();
+ serverState.myConfiguration = XmlSerializer.serialize(server.getConfiguration().getSerializer().getState(), SERIALIZATION_FILTERS);
+ state.myServers.add(serverState);
+ }
+ state.myServers.addAll(myUnknownServers);
+ return state;
+ }
+
+ @Override
+ public void loadState(RemoteServersManagerState state) {
+ myUnknownServers.clear();
+ myServers.clear();
+ for (RemoteServerState server : state.myServers) {
+ ServerType<?> type = findServerType(server.myTypeId);
+ if (type == null) {
+ myUnknownServers.add(server);
+ }
+ else {
+ myServers.add(createConfiguration(type, server));
+ }
+ }
+ }
+
+ private static <C extends ServerConfiguration> RemoteServerImpl<C> createConfiguration(ServerType<C> type, RemoteServerState server) {
+ C configuration = type.createDefaultConfiguration();
+ PersistentStateComponent<?> serializer = configuration.getSerializer();
+ loadConfiguration(server, serializer);
+ return new RemoteServerImpl<C>(server.myName, type, configuration);
+ }
+
+ private static <S> void loadConfiguration(RemoteServerState server, PersistentStateComponent<S> serializer) {
+ S deserialize = (S)XmlSerializer.deserialize(server.myConfiguration, ComponentSerializationUtil.getStateClass(serializer.getClass()));
+ serializer.loadState(deserialize);
+ }
+
+ @Nullable
+ private static ServerType<?> findServerType(@NotNull String typeId) {
+ for (ServerType serverType : ServerType.EP_NAME.getExtensions()) {
+ if (serverType.getId().equals(typeId)) {
+ return serverType;
+ }
+ }
+ return null;
+ }
+}
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/configuration/impl/RemoteServersManagerState.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/configuration/impl/RemoteServersManagerState.java
new file mode 100644
index 0000000..0f233f6
--- /dev/null
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/configuration/impl/RemoteServersManagerState.java
@@ -0,0 +1,16 @@
+package com.intellij.remoteServer.configuration.impl;
+
+import com.intellij.util.xmlb.annotations.AbstractCollection;
+import com.intellij.util.xmlb.annotations.Property;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author nik
+ */
+public class RemoteServersManagerState {
+ @Property(surroundWithTag = false)
+ @AbstractCollection(surroundWithTag = false)
+ public List<RemoteServerState> myServers = new ArrayList<RemoteServerState>();
+}
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/deployment/impl/ArtifactDeploymentSourceImpl.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/deployment/impl/ArtifactDeploymentSourceImpl.java
new file mode 100644
index 0000000..3be71fe
--- /dev/null
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/deployment/impl/ArtifactDeploymentSourceImpl.java
@@ -0,0 +1,88 @@
+package com.intellij.remoteServer.deployment.impl;
+
+import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.packaging.artifacts.Artifact;
+import com.intellij.packaging.artifacts.ArtifactPointer;
+import com.intellij.packaging.elements.ArtifactRootElement;
+import com.intellij.packaging.elements.CompositePackagingElement;
+import com.intellij.remoteServer.deployment.ArtifactDeploymentSource;
+import com.intellij.remoteServer.deployment.DeploymentSource;
+import org.jetbrains.annotations.NotNull;
+
+import javax.swing.*;
+import java.io.File;
+
+/**
+ * @author nik
+ */
+public class ArtifactDeploymentSourceImpl implements ArtifactDeploymentSource, DeploymentSource {
+ private final ArtifactPointer myPointer;
+
+ public ArtifactDeploymentSourceImpl(@NotNull ArtifactPointer pointer) {
+ myPointer = pointer;
+ }
+
+ @NotNull
+ @Override
+ public ArtifactPointer getArtifactPointer() {
+ return myPointer;
+ }
+
+ @Override
+ public Artifact getArtifact() {
+ return myPointer.getArtifact();
+ }
+
+ @Override
+ public File getFile() {
+ final String path = getFilePath();
+ return path != null ? new File(path) : null;
+ }
+
+ @Override
+ public String getFilePath() {
+ final Artifact artifact = getArtifact();
+ if (artifact != null) {
+ String outputPath = artifact.getOutputPath();
+ if (outputPath != null) {
+ final CompositePackagingElement<?> rootElement = artifact.getRootElement();
+ if (!(rootElement instanceof ArtifactRootElement<?>)) {
+ outputPath += "/" + rootElement.getName();
+ }
+ return FileUtil.toSystemDependentName(outputPath);
+ }
+ }
+ return null;
+ }
+
+ @NotNull
+ @Override
+ public String getPresentableName() {
+ return myPointer.getArtifactName();
+ }
+
+ @Override
+ public Icon getIcon() {
+ final Artifact artifact = getArtifact();
+ return artifact != null ? artifact.getArtifactType().getIcon() : null;
+ }
+
+ @Override
+ public boolean isValid() {
+ return getArtifact() != null;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof ArtifactDeploymentSourceImpl)) return false;
+
+ return myPointer.equals(((ArtifactDeploymentSourceImpl)o).myPointer);
+
+ }
+
+ @Override
+ public int hashCode() {
+ return myPointer.hashCode();
+ }
+}
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/deployment/impl/DeploymentSourceUtilImpl.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/deployment/impl/DeploymentSourceUtilImpl.java
new file mode 100644
index 0000000..1acb1cb
--- /dev/null
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/deployment/impl/DeploymentSourceUtilImpl.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2000-2013 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.remoteServer.deployment.impl;
+
+import com.intellij.openapi.project.Project;
+import com.intellij.packaging.artifacts.ArtifactPointer;
+import com.intellij.packaging.artifacts.ArtifactPointerManager;
+import com.intellij.remoteServer.deployment.ArtifactDeploymentSource;
+import com.intellij.remoteServer.deployment.DeploymentSource;
+import com.intellij.remoteServer.deployment.DeploymentSourceUtil;
+import org.jdom.Element;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author nik
+ */
+public class DeploymentSourceUtilImpl extends DeploymentSourceUtil {
+ @NotNull
+ @Override
+ public ArtifactDeploymentSource createArtifactDeploymentSource(@NotNull ArtifactPointer artifactPointer) {
+ return new ArtifactDeploymentSourceImpl(artifactPointer);
+ }
+
+ @Override
+ public DeploymentSource loadDeploymentSource(@NotNull Element element, @NotNull Project project) {
+ ArtifactPointerManager artifactPointerManager = ArtifactPointerManager.getInstance(project);
+ Element artifact = element.getChild("artifact");
+ return createArtifactDeploymentSource(artifactPointerManager.createPointer(artifact.getAttributeValue("name")));
+ }
+
+ @Override
+ public void saveDeploymentSource(@NotNull DeploymentSource source, @NotNull Element element, @NotNull Project project) {
+ if (source instanceof ArtifactDeploymentSource) {
+ String artifactName = ((ArtifactDeploymentSource)source).getArtifactPointer().getArtifactName();
+ element.addContent(new Element("artifact").setAttribute("name", artifactName));
+ }
+ }
+}
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/run/DeployToServerConfigurationType.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/run/DeployToServerConfigurationType.java
new file mode 100644
index 0000000..166b6c2
--- /dev/null
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/run/DeployToServerConfigurationType.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2000-2013 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.remoteServer.run;
+
+import com.intellij.execution.configuration.ConfigurationFactoryEx;
+import com.intellij.execution.configurations.ConfigurationTypeBase;
+import com.intellij.execution.configurations.RunConfiguration;
+import com.intellij.openapi.project.Project;
+import com.intellij.remoteServer.ServerType;
+import com.intellij.remoteServer.configuration.RemoteServer;
+import com.intellij.remoteServer.configuration.RemoteServersManager;
+import com.intellij.remoteServer.deployment.DeploymentSource;
+import com.intellij.util.containers.ContainerUtil;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.List;
+
+/**
+ * @author nik
+ */
+public class DeployToServerConfigurationType extends ConfigurationTypeBase {
+ private ServerType<?> myServerType;
+
+ public DeployToServerConfigurationType(ServerType<?> serverType) {
+ super(serverType.getId() + "-deploy", serverType.getPresentableName() + " Deployment",
+ "Deploy to " + serverType.getPresentableName() + " run configuration", serverType.getIcon());
+ addFactory(new DeployToServerConfigurationFactory());
+ myServerType = serverType;
+ }
+
+ public class DeployToServerConfigurationFactory extends ConfigurationFactoryEx {
+ public DeployToServerConfigurationFactory() {
+ super(DeployToServerConfigurationType.this);
+ }
+
+ @Override
+ public void onNewConfigurationCreated(@NotNull RunConfiguration configuration) {
+ DeployToServerRunConfiguration deployConfiguration = (DeployToServerRunConfiguration)configuration;
+ if (deployConfiguration.getServerName() == null) {
+ RemoteServer<?> server = ContainerUtil.getFirstItem(RemoteServersManager.getInstance().getServers(myServerType));
+ if (server != null) {
+ deployConfiguration.setServerName(server.getName());
+ }
+ }
+
+ if (deployConfiguration.getDeploymentSource() == null) {
+ List<DeploymentSource> sources = deployConfiguration.getDeployer().getAvailableDeploymentSources();
+ DeploymentSource source = ContainerUtil.getFirstItem(sources);
+ if (source != null) {
+ deployConfiguration.setDeploymentSource(source);
+ }
+ }
+ }
+
+ @Override
+ public RunConfiguration createTemplateConfiguration(Project project) {
+ return new DeployToServerRunConfiguration(project, this, "", myServerType);
+ }
+ }
+}
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/run/DeployToServerConfigurationTypesRegistrar.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/run/DeployToServerConfigurationTypesRegistrar.java
new file mode 100644
index 0000000..422cc5c
--- /dev/null
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/run/DeployToServerConfigurationTypesRegistrar.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2000-2013 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.remoteServer.run;
+
+import com.intellij.execution.configurations.ConfigurationType;
+import com.intellij.openapi.components.ApplicationComponent;
+import com.intellij.openapi.extensions.ExtensionPoint;
+import com.intellij.openapi.extensions.Extensions;
+import com.intellij.remoteServer.ServerType;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author nik
+ */
+public class DeployToServerConfigurationTypesRegistrar implements ApplicationComponent {
+ @Override
+ public void initComponent() {
+ //todo[nik] improve this: configuration types should be loaded lazily
+ ExtensionPoint<ConfigurationType> point = Extensions.getRootArea().getExtensionPoint(ConfigurationType.CONFIGURATION_TYPE_EP);
+ for (ServerType serverType : ServerType.EP_NAME.getExtensions()) {
+ point.registerExtension(new DeployToServerConfigurationType(serverType));
+ }
+ }
+
+ @Override
+ public void disposeComponent() {
+ }
+
+ @NotNull
+ @Override
+ public String getComponentName() {
+ return "DeployToServerConfigurationTypesRegistrar";
+ }
+}
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/run/DeployToServerRunConfiguration.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/run/DeployToServerRunConfiguration.java
new file mode 100644
index 0000000..6ba8cf1
--- /dev/null
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/run/DeployToServerRunConfiguration.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2000-2013 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.remoteServer.run;
+
+import com.intellij.execution.ExecutionException;
+import com.intellij.execution.Executor;
+import com.intellij.execution.configurations.ConfigurationFactory;
+import com.intellij.execution.configurations.RunConfigurationBase;
+import com.intellij.execution.configurations.RunProfileState;
+import com.intellij.execution.configurations.RuntimeConfigurationException;
+import com.intellij.execution.runners.ExecutionEnvironment;
+import com.intellij.openapi.options.SettingsEditor;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.InvalidDataException;
+import com.intellij.openapi.util.WriteExternalException;
+import com.intellij.remoteServer.ServerType;
+import com.intellij.remoteServer.configuration.RemoteServer;
+import com.intellij.remoteServer.configuration.RemoteServersManager;
+import com.intellij.remoteServer.configuration.ServerConfiguration;
+import com.intellij.remoteServer.deployment.Deployer;
+import com.intellij.remoteServer.deployment.DeploymentSource;
+import com.intellij.remoteServer.deployment.DeploymentSourceUtil;
+import org.jdom.Element;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * @author nik
+ */
+public class DeployToServerRunConfiguration<C extends ServerConfiguration> extends RunConfigurationBase {
+ public static final String SERVER_NAME_ATTRIBUTE = "server-name";
+ public static final String SOURCE_ELEMENT = "source";
+ private final ServerType<C> myServerType;
+ private final Deployer<C> myDeployer;
+ private String myServerName;
+ private DeploymentSource myDeploymentSource;
+
+ public DeployToServerRunConfiguration(Project project, ConfigurationFactory factory, String name, ServerType<C> serverType) {
+ super(project, factory, name);
+ myServerType = serverType;
+ myDeployer = myServerType.createDeployer(project);
+ }
+
+ public String getServerName() {
+ return myServerName;
+ }
+
+ @NotNull
+ public Deployer getDeployer() {
+ return myDeployer;
+ }
+
+ @Override
+ public SettingsEditor<DeployToServerRunConfiguration> getConfigurationEditor() {
+ return new DeployToServerSettingsEditor(myServerType, myDeployer, getProject());
+ }
+
+ @Nullable
+ @Override
+ public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException {
+ String serverName = getServerName();
+ if (serverName == null) {
+ throw new ExecutionException("Server is not specified");
+ }
+
+ RemoteServer<C> server = RemoteServersManager.getInstance().findByName(serverName, myServerType);
+ if (server == null) {
+ throw new ExecutionException("Server '" + serverName + " not found");
+ }
+
+ if (myDeploymentSource == null) {
+ throw new ExecutionException("Deployment is not selected");
+ }
+
+ return new DeployToServerState(env, myDeployer, server, myDeploymentSource);
+ }
+
+ @Override
+ public void checkConfiguration() throws RuntimeConfigurationException {
+ }
+
+ public void setServerName(String serverName) {
+ myServerName = serverName;
+ }
+
+ public DeploymentSource getDeploymentSource() {
+ return myDeploymentSource;
+ }
+
+ public void setDeploymentSource(DeploymentSource deploymentSource) {
+ myDeploymentSource = deploymentSource;
+ }
+
+ @Override
+ public void readExternal(Element element) throws InvalidDataException {
+ super.readExternal(element);
+ myServerName = element.getAttributeValue(SERVER_NAME_ATTRIBUTE);
+ Element sourceElement = element.getChild(SOURCE_ELEMENT);
+ myDeploymentSource = sourceElement != null ? DeploymentSourceUtil.getInstance().loadDeploymentSource(sourceElement, getProject()) : null;
+ }
+
+ @Override
+ public void writeExternal(Element element) throws WriteExternalException {
+ if (myServerName != null) {
+ element.setAttribute(SERVER_NAME_ATTRIBUTE, myServerName);
+ }
+ if (myDeploymentSource != null) {
+ Element source = new Element(SOURCE_ELEMENT);
+ DeploymentSourceUtil.getInstance().saveDeploymentSource(myDeploymentSource, source, getProject());
+ element.addContent(source);
+ }
+ super.writeExternal(element);
+ }
+}
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/run/DeployToServerRunner.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/run/DeployToServerRunner.java
new file mode 100644
index 0000000..a4b9008
--- /dev/null
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/run/DeployToServerRunner.java
@@ -0,0 +1,22 @@
+package com.intellij.remoteServer.run;
+
+import com.intellij.execution.configurations.RunProfile;
+import com.intellij.execution.executors.DefaultRunExecutor;
+import com.intellij.execution.runners.DefaultProgramRunner;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author nik
+ */
+public class DeployToServerRunner extends DefaultProgramRunner {
+ @NotNull
+ @Override
+ public String getRunnerId() {
+ return "DeployToServer";
+ }
+
+ @Override
+ public boolean canRun(@NotNull String executorId, @NotNull RunProfile profile) {
+ return executorId.equals(DefaultRunExecutor.EXECUTOR_ID) && profile instanceof DeployToServerRunConfiguration;
+ }
+}
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/run/DeployToServerSettingsEditor.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/run/DeployToServerSettingsEditor.java
new file mode 100644
index 0000000..a2283cb
--- /dev/null
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/run/DeployToServerSettingsEditor.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2000-2013 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.remoteServer.run;
+
+import com.intellij.openapi.options.ConfigurationException;
+import com.intellij.openapi.options.SettingsEditor;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.ComboBox;
+import com.intellij.remoteServer.ServerType;
+import com.intellij.remoteServer.configuration.RemoteServer;
+import com.intellij.remoteServer.configuration.RemoteServersManager;
+import com.intellij.remoteServer.configuration.ServerConfiguration;
+import com.intellij.remoteServer.deployment.Deployer;
+import com.intellij.remoteServer.deployment.DeploymentSource;
+import com.intellij.ui.ColoredListCellRendererWrapper;
+import com.intellij.ui.ListCellRendererWrapper;
+import com.intellij.ui.SimpleTextAttributes;
+import com.intellij.ui.SortedComboBoxModel;
+import com.intellij.util.ui.FormBuilder;
+import org.jetbrains.annotations.NotNull;
+
+import javax.swing.*;
+import java.util.Comparator;
+
+/**
+ * @author nik
+ */
+public class DeployToServerSettingsEditor extends SettingsEditor<DeployToServerRunConfiguration> {
+ private ComboBox myServerComboBox;
+ private ComboBox mySourceComboBox;
+ private final SortedComboBoxModel<String> myServerListModel;
+ private final SortedComboBoxModel<DeploymentSource> mySourceListModel;
+
+ public DeployToServerSettingsEditor(final ServerType<?> type, Deployer deployer, Project project) {
+ myServerListModel = new SortedComboBoxModel<String>(String.CASE_INSENSITIVE_ORDER);
+ for (RemoteServer<? extends ServerConfiguration> server : RemoteServersManager.getInstance().getServers(type)) {
+ myServerListModel.add(server.getName());
+ }
+
+ myServerComboBox = new ComboBox(myServerListModel);
+ myServerComboBox.setRenderer(new ColoredListCellRendererWrapper<String>() {
+ @Override
+ protected void doCustomize(JList list, String value, int index, boolean selected, boolean hasFocus) {
+ if (value == null) return;
+ SimpleTextAttributes attributes = RemoteServersManager.getInstance().findByName(value, type) == null
+ ? SimpleTextAttributes.ERROR_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES;
+ append(value, attributes);
+ }
+ });
+
+ mySourceListModel = new SortedComboBoxModel<DeploymentSource>(new Comparator<DeploymentSource>() {
+ @Override
+ public int compare(DeploymentSource o1, DeploymentSource o2) {
+ return o1.getPresentableName().compareToIgnoreCase(o2.getPresentableName());
+ }
+ });
+ mySourceListModel.addAll(deployer.getAvailableDeploymentSources());
+ mySourceComboBox = new ComboBox(mySourceListModel);
+ mySourceComboBox.setRenderer(new ListCellRendererWrapper<DeploymentSource>() {
+ @Override
+ public void customize(JList list, DeploymentSource value, int index, boolean selected, boolean hasFocus) {
+ if (value == null) return;
+ setIcon(value.getIcon());
+ setText(value.getPresentableName());
+ }
+ });
+ }
+
+ @Override
+ protected void resetEditorFrom(DeployToServerRunConfiguration configuration) {
+ String serverName = configuration.getServerName();
+ if (serverName != null && !myServerListModel.getItems().contains(serverName)) {
+ myServerListModel.add(serverName);
+ }
+ myServerComboBox.setSelectedItem(serverName);
+ mySourceComboBox.setSelectedItem(configuration.getDeploymentSource());
+ }
+
+ @Override
+ protected void applyEditorTo(DeployToServerRunConfiguration configuration) throws ConfigurationException {
+ configuration.setServerName(myServerListModel.getSelectedItem());
+ configuration.setDeploymentSource(mySourceListModel.getSelectedItem());
+ }
+
+ @NotNull
+ @Override
+ protected JComponent createEditor() {
+ return FormBuilder.createFormBuilder()
+ .addLabeledComponent("Server:", myServerComboBox)
+ .addLabeledComponent("Deployment:", mySourceComboBox)
+ .getPanel();
+ }
+
+ @Override
+ protected void disposeEditor() {
+
+ }
+}
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/run/DeployToServerState.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/run/DeployToServerState.java
new file mode 100644
index 0000000..ec88486
--- /dev/null
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/run/DeployToServerState.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2000-2013 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.remoteServer.run;
+
+import com.intellij.execution.ExecutionException;
+import com.intellij.execution.ExecutionResult;
+import com.intellij.execution.Executor;
+import com.intellij.execution.configurations.ConfigurationPerRunnerSettings;
+import com.intellij.execution.configurations.RunProfileState;
+import com.intellij.execution.configurations.RunnerSettings;
+import com.intellij.execution.runners.ExecutionEnvironment;
+import com.intellij.execution.runners.ProgramRunner;
+import com.intellij.remoteServer.configuration.RemoteServer;
+import com.intellij.remoteServer.configuration.ServerConfiguration;
+import com.intellij.remoteServer.deployment.Deployer;
+import com.intellij.remoteServer.deployment.DeploymentSource;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * @author nik
+ */
+public class DeployToServerState<C extends ServerConfiguration> implements RunProfileState {
+ private final ExecutionEnvironment myExecutionEnvironment;
+ @NotNull private final Deployer<C> myDeployer;
+ @NotNull private final RemoteServer<C> myServer;
+ @NotNull private final DeploymentSource mySource;
+
+ public DeployToServerState(@NotNull ExecutionEnvironment executionEnvironment,
+ @NotNull Deployer<C> deployer,
+ @NotNull RemoteServer<C> server,
+ @NotNull DeploymentSource deploymentSource) {
+ myExecutionEnvironment = executionEnvironment;
+ myDeployer = deployer;
+ myServer = server;
+ mySource = deploymentSource;
+ }
+
+ @Nullable
+ @Override
+ public ExecutionResult execute(Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
+ myDeployer.startDeployment(myServer, mySource);
+ return null;
+ }
+
+ @Override
+ public RunnerSettings getRunnerSettings() {
+ return myExecutionEnvironment.getRunnerSettings();
+ }
+
+ @Override
+ public ConfigurationPerRunnerSettings getConfigurationSettings() {
+ return myExecutionEnvironment.getConfigurationSettings();
+ }
+}
diff --git a/platform/smRunner/smRunner.iml b/platform/smRunner/smRunner.iml
index 013cdd8..46b398c 100644
--- a/platform/smRunner/smRunner.iml
+++ b/platform/smRunner/smRunner.iml
@@ -16,6 +16,5 @@
<orderEntry type="module" module-name="annotations" />
<orderEntry type="module" module-name="testFramework" scope="TEST" />
</component>
- <component name="RModuleSettingsStorage" number="0" />
</module>
diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/statistics/StatisticsPanel.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/statistics/StatisticsPanel.java
index 1326068..4c22ac2 100644
--- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/statistics/StatisticsPanel.java
+++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/statistics/StatisticsPanel.java
@@ -259,7 +259,7 @@
protected void selectRowOf(final SMTestProxy proxy) {
SMRunnerUtil.addToInvokeLater(new Runnable() {
public void run() {
- final int rowIndex = myTableModel.getIndexOf(proxy);
+ final int rowIndex = myStatisticsTableView.convertRowIndexToView(myTableModel.getIndexOf(proxy));
myStatisticsTableView.setRowSelectionInterval(rowIndex, rowIndex >= 0 ? rowIndex : 0);
// Scroll to visible
TableUtil.scrollSelectionToVisible(myStatisticsTableView);
diff --git a/platform/testFramework/src/com/intellij/mock/MockApplicationEx.java b/platform/testFramework/src/com/intellij/mock/MockApplicationEx.java
index 4aaa181..ffe2799 100644
--- a/platform/testFramework/src/com/intellij/mock/MockApplicationEx.java
+++ b/platform/testFramework/src/com/intellij/mock/MockApplicationEx.java
@@ -71,7 +71,7 @@
@Override
public boolean isDoNotSave() {
- return false;
+ return false;
}
@Override
@@ -104,8 +104,9 @@
}
+ @NotNull
@Override
- public <T> T[] getExtensions(final ExtensionPointName<T> extensionPointName) {
+ public <T> T[] getExtensions(@NotNull final ExtensionPointName<T> extensionPointName) {
return Extensions.getRootArea().getExtensionPoint(extensionPointName).getExtensions();
}
diff --git a/platform/testFramework/src/com/intellij/mock/MockInspectionProfile.java b/platform/testFramework/src/com/intellij/mock/MockInspectionProfile.java
index 030a5d6..6206eae 100644
--- a/platform/testFramework/src/com/intellij/mock/MockInspectionProfile.java
+++ b/platform/testFramework/src/com/intellij/mock/MockInspectionProfile.java
@@ -4,8 +4,8 @@
package com.intellij.mock;
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
-import com.intellij.codeInspection.InspectionProfileEntry;
import com.intellij.codeInspection.ex.InspectionProfileImpl;
+import com.intellij.codeInspection.ex.InspectionToolWrapper;
import com.intellij.openapi.util.Condition;
import com.intellij.psi.PsiElement;
import com.intellij.util.containers.ContainerUtil;
@@ -18,26 +18,27 @@
* @author peter
*/
public class MockInspectionProfile extends InspectionProfileImpl {
- private InspectionProfileEntry[] myInspectionTools = new InspectionProfileEntry[0];
- private final Set<InspectionProfileEntry> myDisabledTools = new THashSet<InspectionProfileEntry>();
+ private InspectionToolWrapper[] myInspectionTools = new InspectionToolWrapper[0];
+ private final Set<InspectionToolWrapper> myDisabledTools = new THashSet<InspectionToolWrapper>();
public MockInspectionProfile() {
super("a");
}
- public void setEnabled(InspectionProfileEntry tool, boolean enabled) {
+ public void setEnabled(@NotNull InspectionToolWrapper tool, boolean enabled) {
if (enabled) {
myDisabledTools.remove(tool);
- } else {
+ }
+ else {
myDisabledTools.add(tool);
}
}
@Override
public boolean isToolEnabled(final HighlightDisplayKey key, PsiElement element) {
- final InspectionProfileEntry entry = ContainerUtil.find(myInspectionTools, new Condition<InspectionProfileEntry>() {
+ final InspectionToolWrapper entry = ContainerUtil.find(myInspectionTools, new Condition<InspectionToolWrapper>() {
@Override
- public boolean value(final InspectionProfileEntry inspectionProfileEntry) {
+ public boolean value(final InspectionToolWrapper inspectionProfileEntry) {
return key.equals(HighlightDisplayKey.find(inspectionProfileEntry.getShortName()));
}
});
@@ -45,13 +46,13 @@
return !myDisabledTools.contains(entry);
}
- public void setInspectionTools(final InspectionProfileEntry... entries) {
+ public void setInspectionTools(final InspectionToolWrapper... entries) {
myInspectionTools = entries;
}
@Override
@NotNull
- public InspectionProfileEntry[] getInspectionTools(PsiElement element) {
+ public InspectionToolWrapper[] getInspectionTools(PsiElement element) {
return myInspectionTools;
}
}
diff --git a/platform/testFramework/src/com/intellij/mock/MockVirtualLink.java b/platform/testFramework/src/com/intellij/mock/MockVirtualLink.java
index 4b0cab8..4e9eb28 100644
--- a/platform/testFramework/src/com/intellij/mock/MockVirtualLink.java
+++ b/platform/testFramework/src/com/intellij/mock/MockVirtualLink.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -15,6 +15,7 @@
*/
package com.intellij.mock;
+import com.intellij.openapi.vfs.VFileProperty;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -28,8 +29,8 @@
}
@Override
- public boolean isSymLink() {
- return true;
+ public boolean is(@NotNull VFileProperty property) {
+ return property == VFileProperty.SYMLINK || super.is(property);
}
@Nullable
diff --git a/platform/testFramework/src/com/intellij/openapi/application/ex/PathManagerEx.java b/platform/testFramework/src/com/intellij/openapi/application/ex/PathManagerEx.java
index a9a1eb4..3780351 100644
--- a/platform/testFramework/src/com/intellij/openapi/application/ex/PathManagerEx.java
+++ b/platform/testFramework/src/com/intellij/openapi/application/ex/PathManagerEx.java
@@ -26,6 +26,7 @@
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.module.impl.ModuleManagerImpl;
+import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.JDOMUtil;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
@@ -387,7 +388,7 @@
}
ourCommunityModules = new THashSet<String>();
- File modulesXml = findFileUnderCommunityHome(".idea/modules.xml");
+ File modulesXml = findFileUnderCommunityHome(Project.DIRECTORY_STORE_FOLDER + "/modules.xml");
if (!modulesXml.exists()) {
throw new IllegalStateException("Cannot obtain test data path: " + modulesXml.getAbsolutePath() + " not found");
}
diff --git a/platform/testFramework/src/com/intellij/testFramework/EditorTestUtil.java b/platform/testFramework/src/com/intellij/testFramework/EditorTestUtil.java
index a3c1f00..5f7eb53 100644
--- a/platform/testFramework/src/com/intellij/testFramework/EditorTestUtil.java
+++ b/platform/testFramework/src/com/intellij/testFramework/EditorTestUtil.java
@@ -44,6 +44,7 @@
public static final char BACKSPACE_FAKE_CHAR = '\uFFFF';
public static final char SMART_ENTER_FAKE_CHAR = '\uFFFE';
+ public static final char SMART_LINE_SPLIT_CHAR = '\uFFFD';
public static void performTypingAction(Editor editor, char c) {
EditorActionManager actionManager = EditorActionManager.getInstance();
@@ -53,6 +54,9 @@
} else if (c == SMART_ENTER_FAKE_CHAR) {
EditorActionHandler actionHandler = actionManager.getActionHandler(IdeActions.ACTION_EDITOR_COMPLETE_STATEMENT);
actionHandler.execute(editor, DataManager.getInstance().getDataContext());
+ } else if (c == SMART_LINE_SPLIT_CHAR) {
+ EditorActionHandler actionHandler = actionManager.getActionHandler(IdeActions.ACTION_EDITOR_SPLIT);
+ actionHandler.execute(editor, DataManager.getInstance().getDataContext());
}
else if (c == '\n') {
EditorActionHandler actionHandler = actionManager.getActionHandler(IdeActions.ACTION_EDITOR_ENTER);
diff --git a/platform/testFramework/src/com/intellij/testFramework/FlyIdeaTestCase.java b/platform/testFramework/src/com/intellij/testFramework/FlyIdeaTestCase.java
index 358be4a..02a39f1 100644
--- a/platform/testFramework/src/com/intellij/testFramework/FlyIdeaTestCase.java
+++ b/platform/testFramework/src/com/intellij/testFramework/FlyIdeaTestCase.java
@@ -24,6 +24,7 @@
final Application old = ApplicationManagerEx.getApplication();
myRootDisposable = Disposer.newDisposable();
MockApplicationEx app = new MockApplicationEx(getRootDisposable()) {
+ @NotNull
@Override
public Future<?> executeOnPooledThread(@NotNull Runnable action) {
return old != null ? old.executeOnPooledThread(action) : super.executeOnPooledThread(action);
diff --git a/platform/testFramework/src/com/intellij/testFramework/InspectionTestUtil.java b/platform/testFramework/src/com/intellij/testFramework/InspectionTestUtil.java
index e660b40..612f35c 100644
--- a/platform/testFramework/src/com/intellij/testFramework/InspectionTestUtil.java
+++ b/platform/testFramework/src/com/intellij/testFramework/InspectionTestUtil.java
@@ -19,15 +19,14 @@
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
import com.intellij.codeInspection.ex.GlobalInspectionContextImpl;
import com.intellij.codeInspection.ex.InspectionManagerEx;
-import com.intellij.codeInspection.ex.InspectionTool;
-import com.intellij.openapi.progress.EmptyProgressIndicator;
-import com.intellij.openapi.progress.ProgressManager;
-import com.intellij.openapi.progress.impl.ProgressManagerImpl;
+import com.intellij.codeInspection.ex.InspectionToolWrapper;
+import com.intellij.codeInspection.ui.InspectionToolPresentation;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.JDOMUtil;
import junit.framework.Assert;
import org.jdom.Document;
import org.jdom.Element;
+import org.jetbrains.annotations.NotNull;
import java.io.CharArrayReader;
import java.io.File;
@@ -57,13 +56,13 @@
}
}
- Document missing = new Document((Element)expectedProblem.clone());
+ Document missing = new Document(expectedProblem.clone());
System.out.println("The following haven't been reported as expected: " + new String(JDOMUtil.printDocument(missing, "\n")));
failed = true;
}
for (Element reportedProblem : reportedProblems) {
- Document extra = new Document((Element)reportedProblem.clone());
+ Document extra = new Document(reportedProblem.clone());
System.out.println("The following has been unexpectedly reported: " + new String(JDOMUtil.printDocument(extra, "\n")));
failed = true;
}
@@ -126,11 +125,13 @@
return Comparing.equal(reportedFile.getName(), expectedProblem.getChildText("file"));
}
- public static void compareToolResults(InspectionTool tool, boolean checkRange, String testDir) {
+ public static void compareToolResults(@NotNull InspectionToolWrapper toolWrapper, boolean checkRange, String testDir) {
final Element root = new Element("problems");
final Document doc = new Document(root);
- tool.updateContent(); //e.g. dead code need check for reachables
- tool.exportResults(root);
+ InspectionToolPresentation presentation = ((GlobalInspectionContextImpl)toolWrapper.getContext()).getPresentation(toolWrapper);
+
+ presentation.updateContent(); //e.g. dead code need check for reachables
+ presentation.exportResults(root);
File file = new File(testDir + "/expected.xml");
try {
@@ -143,18 +144,16 @@
}
}
- public static void runTool(final InspectionTool tool, final AnalysisScope scope, final GlobalInspectionContextImpl globalContext, final InspectionManagerEx inspectionManager) {
- final String shortName = tool.getShortName();
+ public static void runTool(@NotNull InspectionToolWrapper toolWrapper,
+ @NotNull final AnalysisScope scope,
+ @NotNull final GlobalInspectionContextImpl globalContext,
+ @NotNull final InspectionManagerEx inspectionManager) {
+ final String shortName = toolWrapper.getShortName();
final HighlightDisplayKey key = HighlightDisplayKey.find(shortName);
if (key == null){
HighlightDisplayKey.register(shortName);
}
- ((ProgressManagerImpl)ProgressManager.getInstance()).executeProcessUnderProgress(new Runnable() {
- @Override
- public void run() {
- globalContext.performInspectionsWithProgress(scope, inspectionManager);
- }
- }, new EmptyProgressIndicator());
+ globalContext.doInspections(scope);
}
}
diff --git a/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java b/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java
index 08da459..00b8ee9 100644
--- a/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java
+++ b/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java
@@ -120,9 +120,7 @@
String fullPath = getTestDataPath() + filePath;
final File ioFile = new File(fullPath);
- String fileText = FileUtil.loadFile(ioFile, CharsetToolkit.UTF8);
- fileText = StringUtil.convertLineSeparators(fileText);
-
+ String fileText = preprocessFileText(FileUtil.loadFile(ioFile, CharsetToolkit.UTF8));
configureFromFileText(ioFile.getName(), fileText);
}
catch (IOException e) {
@@ -130,6 +128,10 @@
}
}
+ protected String preprocessFileText(String text) {
+ return StringUtil.convertLineSeparators(text);
+ }
+
@NonNls
@NotNull
protected String getTestDataPath() {
diff --git a/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java b/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java
index 531eafc..9e71f68 100644
--- a/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java
+++ b/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java
@@ -122,7 +122,7 @@
public static Thread ourTestThread;
private static LightProjectDescriptor ourProjectDescriptor;
@NonNls private static final String LIGHT_PROJECT_MARK = "Light project: ";
- private final Map<String, InspectionTool> myAvailableInspectionTools = new THashMap<String, InspectionTool>();
+ private final Map<String, InspectionToolWrapper> myAvailableInspectionTools = new THashMap<String, InspectionToolWrapper>();
private static boolean ourHaveShutdownHook;
private ThreadTracker myThreadTracker;
@@ -339,7 +339,7 @@
public static void doSetup(@NotNull LightProjectDescriptor descriptor,
@NotNull LocalInspectionTool[] localInspectionTools,
- @NotNull final Map<String, InspectionTool> availableInspectionTools)
+ @NotNull final Map<String, InspectionToolWrapper> availableInspectionTools)
throws Exception {
assertNull("Previous test " + ourTestCase + " hasn't called tearDown(). Probably overridden without super call.", ourTestCase);
IdeaLogger.ourErrorsOccurred = null;
@@ -361,16 +361,17 @@
final InspectionProfileImpl profile = new InspectionProfileImpl(PROFILE) {
@Override
@NotNull
- public InspectionProfileEntry[] getInspectionTools(PsiElement element) {
- final Collection<InspectionTool> tools = availableInspectionTools.values();
- return tools.toArray(new InspectionTool[tools.size()]);
+ public InspectionToolWrapper[] getInspectionTools(PsiElement element) {
+ final Collection<InspectionToolWrapper> tools = availableInspectionTools.values();
+ return tools.toArray(new InspectionToolWrapper[tools.size()]);
}
+ @NotNull
@Override
- public List<ToolsImpl> getAllEnabledInspectionTools(Project project) {
- List<ToolsImpl> result = new ArrayList<ToolsImpl>();
- for (InspectionProfileEntry entry : getInspectionTools(null)) {
- result.add(new ToolsImpl(entry, entry.getDefaultLevel(), true));
+ public List<Tools> getAllEnabledInspectionTools(Project project) {
+ List<Tools> result = new ArrayList<Tools>();
+ for (InspectionToolWrapper toolWrapper : getInspectionTools(null)) {
+ result.add(new ToolsImpl(toolWrapper, toolWrapper.getDefaultLevel(), true));
}
return result;
}
@@ -382,24 +383,18 @@
@Override
public HighlightDisplayLevel getErrorLevel(@NotNull HighlightDisplayKey key, PsiElement element) {
- InspectionTool localInspectionTool = availableInspectionTools.get(key.toString());
- return localInspectionTool != null ? localInspectionTool.getDefaultLevel() : HighlightDisplayLevel.WARNING;
+ InspectionToolWrapper toolWrapper = availableInspectionTools.get(key.toString());
+ return toolWrapper == null ? HighlightDisplayLevel.WARNING : toolWrapper.getDefaultLevel();
}
@Override
- public InspectionTool getInspectionTool(@NotNull String shortName, @NotNull PsiElement element) {
- if (availableInspectionTools.containsKey(shortName)) {
- return availableInspectionTools.get(shortName);
- }
- return null;
+ public InspectionToolWrapper getInspectionTool(@NotNull String shortName, @NotNull PsiElement element) {
+ return availableInspectionTools.get(shortName);
}
@Override
- public InspectionProfileEntry getToolById(@NotNull String id, @NotNull PsiElement element) {
- if (availableInspectionTools.containsKey(id)) {
- return availableInspectionTools.get(id);
- }
- return null;
+ public InspectionToolWrapper getToolById(@NotNull String id, @NotNull PsiElement element) {
+ return availableInspectionTools.get(id);
}
};
final InspectionProfileManager inspectionProfileManager = InspectionProfileManager.getInstance();
@@ -445,7 +440,6 @@
final List<InspectionEP> eps = ContainerUtil.newArrayList();
ContainerUtil.addAll(eps, Extensions.getExtensions(LocalInspectionEP.LOCAL_INSPECTION));
ContainerUtil.addAll(eps, Extensions.getExtensions(InspectionEP.GLOBAL_INSPECTION));
- ContainerUtil.addAll(eps, (InspectionEP[])Extensions.getExtensions("com.intellij.specialTool"));
next:
for (int i = 0; i < classes.length; i++) {
@@ -467,30 +461,25 @@
}
}
+ protected void enableInspectionTool(@NotNull InspectionToolWrapper toolWrapper) {
+ enableInspectionTool(myAvailableInspectionTools, toolWrapper);
+ }
protected void enableInspectionTool(@NotNull InspectionProfileEntry tool) {
- if (tool instanceof InspectionTool) {
- enableInspectionTool(myAvailableInspectionTools, (InspectionTool)tool);
- }
- else if (tool instanceof LocalInspectionTool) {
- enableInspectionTool(myAvailableInspectionTools, new LocalInspectionToolWrapper((LocalInspectionTool)tool));
- }
- else if (tool instanceof GlobalInspectionTool) {
- enableInspectionTool(myAvailableInspectionTools, new GlobalInspectionToolWrapper((GlobalInspectionTool)tool));
- }
- else {
- throw new IllegalArgumentException("Unexpected inspection type: " + tool);
- }
+ InspectionToolWrapper toolWrapper = InspectionToolRegistrar.wrapTool(tool);
+ enableInspectionTool(myAvailableInspectionTools, toolWrapper);
}
- private static void enableInspectionTool(@NotNull Map<String, InspectionTool> availableLocalTools, @NotNull InspectionTool wrapper) {
- final String shortName = wrapper.getShortName();
+ public static void enableInspectionTool(@NotNull Map<String, InspectionToolWrapper> availableLocalTools,
+ @NotNull InspectionToolWrapper toolWrapper) {
+ final String shortName = toolWrapper.getShortName();
final HighlightDisplayKey key = HighlightDisplayKey.find(shortName);
if (key == null) {
- HighlightDisplayKey.register(shortName, wrapper.getDisplayName(), wrapper instanceof LocalInspectionToolWrapper
- ? ((LocalInspectionToolWrapper)wrapper).getTool().getID()
- : wrapper.getShortName());
+ String id = toolWrapper instanceof LocalInspectionToolWrapper
+ ? ((LocalInspectionToolWrapper)toolWrapper).getTool().getID()
+ : toolWrapper.getShortName();
+ HighlightDisplayKey.register(shortName, toolWrapper.getDisplayName(), id);
}
- availableLocalTools.put(shortName, wrapper);
+ availableLocalTools.put(shortName, toolWrapper);
}
@NotNull
diff --git a/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java b/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java
index 4ff3479..ddb0c24 100644
--- a/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java
+++ b/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java
@@ -421,9 +421,9 @@
}
public <T> void assertDoesntContain(Collection<? extends T> collection, Collection<T> notExpected) {
- ArrayList<T> copy = new ArrayList<T>(collection);
- copy.retainAll(notExpected);
- assertEmpty(copy);
+ ArrayList<T> expected = new ArrayList<T>(collection);
+ expected.removeAll(notExpected);
+ assertSameElements(collection, expected);
}
public static String toString(Collection<?> collection, String separator) {
diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java
index 09bc06f..070fb7e 100644
--- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java
+++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java
@@ -147,7 +147,7 @@
private boolean myEmptyLookup;
private InspectionProfileEntry[] myInspections;
- private final Map<String, InspectionTool> myAvailableTools = new THashMap<String, InspectionTool>();
+ private final Map<String, InspectionToolWrapper> myAvailableTools = new THashMap<String, InspectionToolWrapper>();
private final TempDirTestFixture myTempDirFixture;
protected final IdeaProjectTestFixture myProjectFixture;
@@ -255,7 +255,7 @@
}
@Override
- public void enableInspections(InspectionProfileEntry... inspections) {
+ public void enableInspections(@NotNull InspectionProfileEntry... inspections) {
myInspections = inspections;
if (isInitialized()) {
configureInspections(myInspections);
@@ -267,7 +267,7 @@
}
@Override
- public void enableInspections(final Class<? extends LocalInspectionTool>... inspections) {
+ public void enableInspections(@NotNull final Class<? extends LocalInspectionTool>... inspections) {
enableInspections(Arrays.asList(inspections));
}
@@ -287,9 +287,9 @@
}
@Override
- public void disableInspections(InspectionProfileEntry... inspections) {
+ public void disableInspections(@NotNull InspectionProfileEntry... inspections) {
myAvailableTools.clear();
- final ArrayList<InspectionProfileEntry> tools = new ArrayList<InspectionProfileEntry>(Arrays.asList(myInspections));
+ List<InspectionProfileEntry> tools = new ArrayList<InspectionProfileEntry>(Arrays.asList(myInspections));
for (Iterator<InspectionProfileEntry> i = tools.iterator(); i.hasNext();) {
final InspectionProfileEntry tool = i.next();
for (InspectionProfileEntry toRemove : inspections) {
@@ -329,17 +329,15 @@
final boolean checkInfos,
final boolean checkWeakWarnings,
final String... filePaths) {
- final Ref<Long> duration = new Ref<Long>();
if (filePaths.length > 0) {
configureByFilesInner(filePaths);
}
try {
- collectAndCheckHighlightings(checkWarnings, checkInfos, checkWeakWarnings, duration);
+ return collectAndCheckHighlightings(checkWarnings, checkInfos, checkWeakWarnings);
}
catch (Exception e) {
throw new RuntimeException(e);
}
- return duration.get().longValue();
}
@Override
@@ -359,15 +357,12 @@
final boolean checkInfos,
final boolean checkWeakWarnings,
@NonNls final VirtualFile... files) {
- final Ref<Long> duration = new Ref<Long>();
- collectAndCheckHighlightings(checkWarnings, checkInfos, checkWeakWarnings, duration, files);
- return duration.get().longValue();
+ return collectAndCheckHighlightings(checkWarnings, checkInfos, checkWeakWarnings, files);
}
- private void collectAndCheckHighlightings(final boolean checkWarnings,
+ private long collectAndCheckHighlightings(final boolean checkWarnings,
final boolean checkInfos,
final boolean checkWeakWarnings,
- final Ref<Long> duration,
final VirtualFile[] files) {
final List<Trinity<PsiFile, Editor, ExpectedHighlightingData>> datas =
ContainerUtil.map2List(files, new Function<VirtualFile, Trinity<PsiFile, Editor, ExpectedHighlightingData>>() {
@@ -382,23 +377,23 @@
return Trinity.create(psiFile, createEditor(file), data);
}
});
+ long elapsed = 0;
for (Trinity<PsiFile, Editor, ExpectedHighlightingData> trinity : datas) {
myEditor = trinity.second;
myFile = trinity.first;
- collectAndCheckHighlightings(trinity.third, duration);
+ elapsed += collectAndCheckHighlightings(trinity.third);
}
+ return elapsed;
}
@Override
public long checkHighlighting(final boolean checkWarnings, final boolean checkInfos, final boolean checkWeakWarnings) {
- final Ref<Long> duration = new Ref<Long>();
try {
- collectAndCheckHighlightings(checkWarnings, checkInfos, checkWeakWarnings, duration);
+ return collectAndCheckHighlightings(checkWarnings, checkInfos, checkWeakWarnings);
}
catch (Exception e) {
throw new RuntimeException(e);
}
- return duration.get().longValue();
}
@Override
@@ -416,15 +411,13 @@
final boolean checkInfos,
final boolean checkWeakWarnings,
final VirtualFile file) {
- final Ref<Long> duration = new Ref<Long>();
openFileInEditor(file);
try {
- collectAndCheckHighlightings(checkWarnings, checkInfos, checkWeakWarnings, duration);
+ return collectAndCheckHighlightings(checkWarnings, checkInfos, checkWeakWarnings);
}
catch (Exception e) {
throw new RuntimeException(e);
}
- return duration.get().longValue();
}
@Override
@@ -436,7 +429,7 @@
ExpectedHighlightingData data = new ExpectedHighlightingData(myEditor.getDocument(), checkWarnings, checkWeakWarnings, checkInfos, myFile);
if (checkSymbolNames) data.checkSymbolNames();
data.init();
- collectAndCheckHighlightings(data, Ref.create(0L));
+ collectAndCheckHighlightings(data);
return this;
}
};
@@ -448,7 +441,7 @@
}
@Override
- public void testInspection(String testDir, @NotNull InspectionToolWrapper toolWrapper) {
+ public void testInspection(@NotNull String testDir, @NotNull InspectionToolWrapper toolWrapper) {
VirtualFile sourceDir = copyDirectoryToProject(new File(testDir, "src").getPath(), "src");
AnalysisScope scope = new AnalysisScope(getPsiManager().findDirectory(sourceDir));
@@ -461,19 +454,19 @@
InspectionTestUtil.compareToolResults(toolWrapper, false, new File(getTestDataPath(), testDir).getPath());
}
- public static GlobalInspectionContextImpl createGlobalContextForTool(AnalysisScope scope,
- final Project project,
- final InspectionManagerEx inspectionManager,
- final InspectionTool... tools) {
-
- final InspectionProfileImpl profile = InspectionProfileImpl.createSimple("test", tools);
- GlobalInspectionContextImpl globalContext = new GlobalInspectionContextImpl(project, inspectionManager.getContentManager()) {
+ @NotNull
+ public static GlobalInspectionContextImpl createGlobalContextForTool(@NotNull AnalysisScope scope,
+ @NotNull final Project project,
+ @NotNull InspectionManagerEx inspectionManager,
+ @NotNull final InspectionToolWrapper ... toolWrappers) {
+ final InspectionProfileImpl profile = InspectionProfileImpl.createSimple("test", project, toolWrappers);
+ GlobalInspectionContextImpl context = new GlobalInspectionContextImpl(project, inspectionManager.getContentManager()) {
@Override
- protected List<ToolsImpl> getUsedTools() {
+ protected List<Tools> getUsedTools() {
try {
InspectionProfileImpl.INIT_INSPECTIONS = true;
- for (InspectionTool tool : tools) {
- profile.enableTool(tool.getShortName());
+ for (InspectionToolWrapper tool : toolWrappers) {
+ profile.enableTool(tool.getShortName(), project);
}
return profile.getAllEnabledInspectionTools(project);
}
@@ -482,8 +475,9 @@
}
}
};
- globalContext.setCurrentScope(scope);
- return globalContext;
+ context.setCurrentScope(scope);
+
+ return context;
}
@Override
@@ -935,7 +929,8 @@
if (myTempDirFixture instanceof LightTempDirTestFixtureImpl) {
final VirtualFile file = myTempDirFixture.createFile(relativePath, fileText);
result.setResult(PsiManager.getInstance(getProject()).findFile(file));
- } else {
+ }
+ else {
result.setResult(((HeavyIdeaTestFixture)myProjectFixture).addFileToProject(rootPath, relativePath, fileText));
}
}
@@ -1140,19 +1135,19 @@
super.tearDown();
}
- private void enableInspectionTool(InspectionProfileEntry tool) {
- InspectionToolWrapper wrapper = InspectionToolRegistrar.wrapTool(tool);
+ private void enableInspectionTool(@NotNull InspectionProfileEntry tool) {
+ InspectionToolWrapper toolWrapper = InspectionToolRegistrar.wrapTool(tool);
final String shortName = tool.getShortName();
final HighlightDisplayKey key = HighlightDisplayKey.find(shortName);
if (key == null) {
String id = tool instanceof LocalInspectionTool ? ((LocalInspectionTool)tool).getID() : shortName;
- HighlightDisplayKey.register(shortName, wrapper.getDisplayName(), id);
+ HighlightDisplayKey.register(shortName, toolWrapper.getDisplayName(), id);
}
- myAvailableTools.put(shortName, wrapper);
+ myAvailableTools.put(shortName, toolWrapper);
}
- private void configureInspections(final InspectionProfileEntry[] tools) {
+ private void configureInspections(@NotNull InspectionProfileEntry[] tools) {
for (InspectionProfileEntry tool : tools) {
enableInspectionTool(tool);
}
@@ -1167,13 +1162,13 @@
@Override
@NotNull
- public InspectionProfileEntry[] getInspectionTools(PsiElement element) {
- final Collection<InspectionTool> tools = myAvailableTools.values();
- return tools.toArray(new InspectionTool[tools.size()]);
+ public InspectionToolWrapper[] getInspectionTools(PsiElement element) {
+ final Collection<InspectionToolWrapper> tools = myAvailableTools.values();
+ return tools.toArray(new InspectionToolWrapper[tools.size()]);
}
@Override
- public InspectionProfileEntry getToolById(@NotNull String id, @NotNull PsiElement element) {
+ public InspectionToolWrapper getToolById(@NotNull String id, @NotNull PsiElement element) {
if (myAvailableTools.containsKey(id)) {
return myAvailableTools.get(id);
}
@@ -1181,32 +1176,34 @@
return super.getToolById(id, element);
}
+ @NotNull
@Override
- public List<ToolsImpl> getAllEnabledInspectionTools(Project project) {
- List<ToolsImpl> result = new ArrayList<ToolsImpl>();
- for (InspectionProfileEntry entry : getInspectionTools(null)) {
- result.add(new ToolsImpl(entry, entry.getDefaultLevel(), true));
+ public List<Tools> getAllEnabledInspectionTools(Project project) {
+ List<Tools> result = new ArrayList<Tools>();
+ for (InspectionToolWrapper toolWrapper : getInspectionTools(getFile())) {
+ result.add(new ToolsImpl(toolWrapper, toolWrapper.getDefaultLevel(), true));
}
return result;
}
+ @Override
public boolean isToolEnabled(HighlightDisplayKey key, PsiElement element) {
return key != null && key.toString() != null && myAvailableTools.containsKey(key.toString());
}
@Override
- public InspectionProfileEntry getInspectionTool(@NotNull String shortName) {
+ public InspectionToolWrapper getInspectionTool(@NotNull String shortName, Project project) {
return myAvailableTools.get(shortName);
}
@Override
public HighlightDisplayLevel getErrorLevel(@NotNull HighlightDisplayKey key, PsiElement element) {
- final InspectionProfileEntry entry = myAvailableTools.get(key.toString());
- return entry != null ? entry.getDefaultLevel() : HighlightDisplayLevel.WARNING;
+ final InspectionToolWrapper toolWrapper = myAvailableTools.get(key.toString());
+ return toolWrapper == null ? HighlightDisplayLevel.WARNING : toolWrapper.getDefaultLevel();
}
@Override
- public InspectionProfileEntry getInspectionTool(@NotNull String shortName, @NotNull PsiElement element) {
+ public InspectionToolWrapper getInspectionTool(@NotNull String shortName, @NotNull PsiElement element) {
return myAvailableTools.get(shortName);
}
};
@@ -1306,10 +1303,6 @@
return PsiDocumentManager.getInstance(getProject()).getDocument(file);
}
- /**
- * @param filePath
- * @throws IOException
- */
private PsiFile configureByFileInner(@NonNls String filePath) {
assertInitialized();
final VirtualFile file = copyFileToProject(filePath);
@@ -1337,6 +1330,7 @@
private PsiFile configureInner(@NotNull final VirtualFile copy, final SelectionAndCaretMarkupLoader loader) {
assertInitialized();
new WriteCommandAction.Simple(getProject()) {
+ @Override
public void run() {
try {
copy.setBinaryContent(loader.newFileText.getBytes(copy.getCharset()), 0, 0, null);
@@ -1399,15 +1393,15 @@
return instance.openTextEditor(new OpenFileDescriptor(project, file, 0), false);
}
- private void collectAndCheckHighlightings(boolean checkWarnings, boolean checkInfos, boolean checkWeakWarnings, Ref<Long> duration)
+ private long collectAndCheckHighlightings(boolean checkWarnings, boolean checkInfos, boolean checkWeakWarnings)
throws Exception {
ExpectedHighlightingData data =
new ExpectedHighlightingData(myEditor.getDocument(), checkWarnings, checkWeakWarnings, checkInfos, myFile);
data.init();
- collectAndCheckHighlightings(data, duration);
+ return collectAndCheckHighlightings(data);
}
- private void collectAndCheckHighlightings(final ExpectedHighlightingData data, final Ref<Long> duration) {
+ private long collectAndCheckHighlightings(final ExpectedHighlightingData data) {
final Project project = getProject();
PsiDocumentManager.getInstance(project).commitAllDocuments();
@@ -1419,24 +1413,23 @@
}
List<HighlightInfo> infos;
+ final long start = System.currentTimeMillis();
try {
((PsiManagerImpl)PsiManager.getInstance(project)).setAssertOnFileLoadingFilter(myJavaFilesFilter);
- final long start = System.currentTimeMillis();
// ProfilingUtil.startCPUProfiling();
infos = doHighlighting();
removeDuplicatedRangesForInjected(infos);
- final long elapsed = System.currentTimeMillis() - start;
- duration.set(duration.isNull() ? elapsed : duration.get().longValue() + elapsed);
// ProfilingUtil.captureCPUSnapshot("testing");
}
finally {
((PsiManagerImpl)PsiManager.getInstance(project)).setAssertOnFileLoadingFilter(VirtualFileFilter.NONE);
}
-
+ final long elapsed = System.currentTimeMillis() - start;
data.checkResult(infos, myEditor.getDocument().getText());
hardRefToFileElement.hashCode(); // use it so gc won't collect it
+ return elapsed;
}
private static void removeDuplicatedRangesForInjected(List<HighlightInfo> infos) {
@@ -1741,12 +1734,9 @@
selStartLine == selStartLineActual &&
selEndCol == selEndColActual &&
selEndLine == selEndLineActual;
- Assert.assertTrue("selection in " +
- expectedFile +
- " differs. Expected " +
- genSelectionPresentation(selStartLine, selStartCol, selEndLine, selEndCol) +
- ". Actual " +
- genSelectionPresentation(selStartLineActual, selStartColActual, selEndLineActual, selEndColActual),
+ Assert.assertTrue("selection in " + expectedFile +
+ " differs. Expected " + genSelectionPresentation(selStartLine, selStartCol, selEndLine, selEndCol) +
+ ". Actual " + genSelectionPresentation(selStartLineActual, selStartColActual, selEndLineActual, selEndColActual),
selectionEquals);
}
else if (myEditor != null) {
@@ -1813,6 +1803,7 @@
return myText;
}
+ @Override
public int compareTo(Border o) {
return getOffset() < o.getOffset() ? 1 : -1;
}
@@ -1862,10 +1853,12 @@
assertEquals(expectedContent, actual);
}
+ @Override
public void testFoldingWithCollapseStatus(final String verificationFileName) {
testFoldingRegions(verificationFileName, true);
}
+ @Override
public void testFolding(final String verificationFileName) {
testFoldingRegions(verificationFileName, false);
}
@@ -1908,6 +1901,7 @@
}
}
+ @Override
public LookupImpl getLookup() {
return (LookupImpl)LookupManager.getActiveLookup(myEditor);
}
diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/LightIdeaTestFixtureImpl.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/LightIdeaTestFixtureImpl.java
index 64edc56..d2aef9b 100644
--- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/LightIdeaTestFixtureImpl.java
+++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/LightIdeaTestFixtureImpl.java
@@ -17,7 +17,7 @@
package com.intellij.testFramework.fixtures.impl;
import com.intellij.codeInspection.LocalInspectionTool;
-import com.intellij.codeInspection.ex.InspectionTool;
+import com.intellij.codeInspection.ex.InspectionToolWrapper;
import com.intellij.idea.IdeaTestApplication;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
@@ -49,7 +49,7 @@
super.setUp();
IdeaTestApplication application = LightPlatformTestCase.initApplication();
- LightPlatformTestCase.doSetup(myProjectDescriptor, LocalInspectionTool.EMPTY_ARRAY, new THashMap<String, InspectionTool>());
+ LightPlatformTestCase.doSetup(myProjectDescriptor, LocalInspectionTool.EMPTY_ARRAY, new THashMap<String, InspectionToolWrapper>());
InjectedLanguageManagerImpl.pushInjectors(getProject());
storeSettings();
application.setDataProvider(new TestDataProvider(getProject()));
diff --git a/platform/testFramework/testSrc/com/intellij/testFramework/vcs/AbstractVcsTestCase.java b/platform/testFramework/testSrc/com/intellij/testFramework/vcs/AbstractVcsTestCase.java
index 288a5a8..f6b70b6 100644
--- a/platform/testFramework/testSrc/com/intellij/testFramework/vcs/AbstractVcsTestCase.java
+++ b/platform/testFramework/testSrc/com/intellij/testFramework/vcs/AbstractVcsTestCase.java
@@ -296,7 +296,7 @@
}.execute().throwException();
}
- protected void deleteFileInCommand(final VirtualFile file) {
+ public void deleteFileInCommand(final VirtualFile file) {
deleteFileInCommand(myProject, file);
}
@@ -314,7 +314,7 @@
}.execute();
}
- protected void editFileInCommand(final VirtualFile file, final String newContent) {
+ public void editFileInCommand(final VirtualFile file, final String newContent) {
editFileInCommand(myProject, file, newContent);
}
diff --git a/platform/testRunner/src/com/intellij/execution/testframework/TestsUIUtil.java b/platform/testRunner/src/com/intellij/execution/testframework/TestsUIUtil.java
index 936c36a..090ad93 100644
--- a/platform/testRunner/src/com/intellij/execution/testframework/TestsUIUtil.java
+++ b/platform/testRunner/src/com/intellij/execution/testframework/TestsUIUtil.java
@@ -100,7 +100,8 @@
public static void notifyByBalloon(@NotNull final Project project,
boolean started,
final AbstractTestProxy root,
- final TestConsoleProperties properties) {
+ final TestConsoleProperties properties,
+ @Nullable final String comment) {
if (project.isDisposed()) return;
if (properties == null) return;
@@ -111,7 +112,7 @@
String text;
String balloonText;
MessageType type;
- TestResultPresentation testResultPresentation = new TestResultPresentation(root, started).getPresentation();
+ TestResultPresentation testResultPresentation = new TestResultPresentation(root, started, comment).getPresentation();
type = testResultPresentation.getType();
balloonText = testResultPresentation.getBalloonText();
title = testResultPresentation.getTitle();
@@ -162,18 +163,20 @@
private static class TestResultPresentation {
private AbstractTestProxy myRoot;
private boolean myStarted;
+ private final String myComment;
private String myTitle;
private String myText;
private String myBalloonText;
private MessageType myType;
- public TestResultPresentation(AbstractTestProxy root, boolean started) {
+ public TestResultPresentation(AbstractTestProxy root, boolean started, String comment) {
myRoot = root;
myStarted = started;
+ myComment = comment;
}
public TestResultPresentation(AbstractTestProxy root) {
- this(root, true);
+ this(root, true, null);
}
public String getTitle() {
@@ -222,6 +225,9 @@
myText = passedCount + " passed";
myType = MessageType.INFO;
}
+ if (myComment != null) {
+ myText += " " + myComment;
+ }
myBalloonText = myTitle + ": " + myText;
}
return this;
diff --git a/platform/testRunner/src/com/intellij/execution/testframework/ui/TestResultsPanel.java b/platform/testRunner/src/com/intellij/execution/testframework/ui/TestResultsPanel.java
index 7429069..cf3bed4 100644
--- a/platform/testRunner/src/com/intellij/execution/testframework/ui/TestResultsPanel.java
+++ b/platform/testRunner/src/com/intellij/execution/testframework/ui/TestResultsPanel.java
@@ -139,6 +139,7 @@
private static JComponent createOutputTab(JComponent console, AnAction[] consoleActions) {
JPanel outputTab = new JPanel(new BorderLayout());
+ console.setFocusable(true);
outputTab.add(console, BorderLayout.CENTER);
final DefaultActionGroup actionGroup = new DefaultActionGroup(consoleActions);
final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, actionGroup, false);
diff --git a/platform/usageView/src/com/intellij/usages/UsageInfo2UsageAdapter.java b/platform/usageView/src/com/intellij/usages/UsageInfo2UsageAdapter.java
index 657d12e..7472db0 100644
--- a/platform/usageView/src/com/intellij/usages/UsageInfo2UsageAdapter.java
+++ b/platform/usageView/src/com/intellij/usages/UsageInfo2UsageAdapter.java
@@ -35,6 +35,7 @@
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
import com.intellij.reference.SoftReference;
+import com.intellij.ui.SimpleTextAttributes;
import com.intellij.usageView.UsageInfo;
import com.intellij.usageView.UsageViewBundle;
import com.intellij.usages.rules.*;
@@ -132,7 +133,12 @@
if (document == null) {
// element over light virtual file
PsiElement element = getElement();
- chunks = new TextChunk[] {new TextChunk(new TextAttributes(), element.getText())};
+ if (element == null) {
+ chunks = new TextChunk[]{new TextChunk(SimpleTextAttributes.ERROR_ATTRIBUTES.toTextAttributes(), UsageViewBundle.message("node.invalid"))};
+ }
+ else {
+ chunks = new TextChunk[] {new TextChunk(new TextAttributes(), element.getText())};
+ }
}
else {
chunks = ChunkExtractor.extractChunks(psiFile, this);
diff --git a/platform/util-rt/src/com/intellij/openapi/util/io/FileUtilRt.java b/platform/util-rt/src/com/intellij/openapi/util/io/FileUtilRt.java
index a82a534..3e8395d 100644
--- a/platform/util-rt/src/com/intellij/openapi/util/io/FileUtilRt.java
+++ b/platform/util-rt/src/com/intellij/openapi/util/io/FileUtilRt.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -459,13 +459,13 @@
return true;
}
- public interface RetriableIOOperation<T, E extends Throwable> {
+ public interface RepeatableIOOperation<T, E extends Throwable> {
@Nullable T execute(boolean lastAttempt) throws E;
}
- public static @Nullable <T, E extends Throwable> T doIOOperation(@NotNull RetriableIOOperation<T, E> ioTask) throws E {
- for (int i = 0; i < MAX_FILE_IO_ATTEMPTS;) {
- T result = ioTask.execute(++i == MAX_FILE_IO_ATTEMPTS);
+ public static @Nullable <T, E extends Throwable> T doIOOperation(@NotNull RepeatableIOOperation<T, E> ioTask) throws E {
+ for (int i = MAX_FILE_IO_ATTEMPTS; i > 0; i--) {
+ T result = ioTask.execute(i == 1);
if (result != null) return result;
try {
@@ -478,10 +478,12 @@
}
protected static boolean deleteFile(@NotNull final File file) {
- Boolean result = doIOOperation(new RetriableIOOperation<Boolean, RuntimeException>() {
+ Boolean result = doIOOperation(new RepeatableIOOperation<Boolean, RuntimeException>() {
@Override
public Boolean execute(boolean lastAttempt) {
- return file.delete() || !file.exists();
+ if (file.delete() || !file.exists()) return Boolean.TRUE;
+ else if (lastAttempt) return Boolean.FALSE;
+ else return null;
}
});
return Boolean.TRUE.equals(result);
diff --git a/platform/util/src/com/intellij/execution/configurations/CommandLineTokenizer.java b/platform/util/src/com/intellij/execution/configurations/CommandLineTokenizer.java
index 751cbbf..15eee17 100644
--- a/platform/util/src/com/intellij/execution/configurations/CommandLineTokenizer.java
+++ b/platform/util/src/com/intellij/execution/configurations/CommandLineTokenizer.java
@@ -5,7 +5,7 @@
import java.util.StringTokenizer;
/**
- * Splits input String to tokens being aware of quoted tokens,
+ * Splits input String to tokens being aware of quoted tokens ("foo bar") and escaped spaces (foo\ bar),
* usually used for splitting command line to separate arguments that may contain space symbols.
* Escaped symbols are not handled so there's no way to get token that itself contains quotation mark.
*/
@@ -15,12 +15,22 @@
// keep source level 1.4
private List myTokens = new ArrayList();
private int myCurrentToken = 0;
+ private boolean myHandleEscapedWhitespaces = false;
public CommandLineTokenizer(String str) {
+ this(str, false);
+ }
+
+ public CommandLineTokenizer(String str, boolean handleEscapedWhitespaces) {
super(str, DEFAULT_DELIMITERS, true);
+ myHandleEscapedWhitespaces = handleEscapedWhitespaces;
parseTokens();
}
+ /**
+ * @deprecated Do not pass custom delimiters to the CommandLineTokenizer as it may break its logic
+ */
+ @Deprecated()
public CommandLineTokenizer(String str, String delim) {
super(str, delim, true);
parseTokens();
@@ -78,8 +88,18 @@
buffer.append(nextToken.substring(0, i));
nextToken = nextToken.substring(i + 1);
}
- buffer.append(nextToken);
- if (quotationMarks % 2 == 1 && super.hasMoreTokens()) {
+
+ boolean isEscapedWhitespace = false;
+ if (myHandleEscapedWhitespaces && quotationMarks == 0 && nextToken.endsWith("\\") && super.hasMoreTokens()) {
+ isEscapedWhitespace = true;
+ buffer.append(nextToken.substring(0, nextToken.length() - 1));
+ buffer.append(super.nextToken());
+ }
+ else {
+ buffer.append(nextToken);
+ }
+
+ if ((isEscapedWhitespace || quotationMarks % 2 == 1) && super.hasMoreTokens()) {
nextToken = super.nextToken();
} else {
nextToken = null;
diff --git a/platform/util/src/com/intellij/openapi/application/PathManager.java b/platform/util/src/com/intellij/openapi/application/PathManager.java
index 9304b29..24b26b3 100644
--- a/platform/util/src/com/intellij/openapi/application/PathManager.java
+++ b/platform/util/src/com/intellij/openapi/application/PathManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.intellij.openapi.application;
import com.intellij.openapi.util.NamedJDOMExternalizable;
+import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.SystemInfoRt;
import com.intellij.openapi.util.io.FileUtil;
@@ -55,10 +55,6 @@
@NonNls private static String ourPluginsPath;
@NonNls private static String ourLogPath;
- @NonNls private static final String FILE = "file";
- @NonNls private static final String JAR = "jar";
- @NonNls private static final String JAR_DELIMITER = "!";
- @NonNls private static final String PROTOCOL_DELIMITER = ":";
@NonNls public static final String DEFAULT_OPTIONS_FILE_NAME = "other";
@NonNls private static final String LIB_FOLDER = "lib";
@NonNls public static final String PLUGINS_DIRECTORY = "plugins";
@@ -333,27 +329,24 @@
System.err.println("precondition failed: " + resourcePath);
return null;
}
- String protocol = resourceURL.getProtocol();
- String resultPath = null;
- if (FILE.equals(protocol)) {
+ String resultPath = null;
+ String protocol = resourceURL.getProtocol();
+ if (URLUtil.FILE_PROTOCOL.equals(protocol)) {
String path = resourceURL.getFile();
- final String testPath = path.replace('\\', '/');
- final String testResourcePath = resourcePath.replace('\\', '/');
+ String testPath = path.replace('\\', '/');
+ String testResourcePath = resourcePath.replace('\\', '/');
if (StringUtil.endsWithIgnoreCase(testPath, testResourcePath)) {
resultPath = path.substring(0, path.length() - resourcePath.length());
}
}
- else if (JAR.equals(protocol)) {
- String fullPath = resourceURL.getFile();
- int delimiter = fullPath.indexOf(JAR_DELIMITER);
- if (delimiter >= 0) {
- String archivePath = fullPath.substring(0, delimiter);
- if (StringUtil.startsWithConcatenationOf(archivePath, FILE, PROTOCOL_DELIMITER)) {
- resultPath = archivePath.substring(FILE.length() + PROTOCOL_DELIMITER.length());
- }
+ else if (URLUtil.JAR_PROTOCOL.equals(protocol)) {
+ Pair<String, String> paths = URLUtil.splitJarUrl(resourceURL.getFile());
+ if (paths != null) {
+ resultPath = paths.first;
}
}
+
if (resultPath == null) {
//noinspection HardCodedStringLiteral,UseOfSystemOutOrSystemErr
System.err.println("cannot extract: " + resultPath + " from " + resourceURL);
diff --git a/platform/util/src/com/intellij/openapi/util/ShutDownTracker.java b/platform/util/src/com/intellij/openapi/util/ShutDownTracker.java
index af89263..f9e282e 100644
--- a/platform/util/src/com/intellij/openapi/util/ShutDownTracker.java
+++ b/platform/util/src/com/intellij/openapi/util/ShutDownTracker.java
@@ -78,6 +78,7 @@
public final void ensureStopperThreadsFinished() {
Thread[] threads = getStopperThreads();
+ final long started = System.currentTimeMillis();
while (threads.length > 0) {
Thread thread = threads[0];
if (!thread.isAlive()) {
@@ -87,6 +88,13 @@
}
}
else {
+ final long totalTimeWaited = System.currentTimeMillis() - started;
+ if (totalTimeWaited > 3000) {
+ // okay, we are waiting fo too long already, lets stop everyone:
+ // in some cases, stopper thread may try to run readAction while we are shutting down (under a writeAction) and deadlock.
+ thread.interrupt();
+ }
+
try {
thread.join(100);
}
diff --git a/platform/util/src/com/intellij/openapi/util/io/FileUtil.java b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java
index 27a4406..cd9192e 100644
--- a/platform/util/src/com/intellij/openapi/util/io/FileUtil.java
+++ b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java
@@ -36,7 +36,9 @@
import java.io.*;
import java.lang.reflect.Method;
import java.util.*;
-import java.util.concurrent.*;
+import java.util.concurrent.Future;
+import java.util.concurrent.FutureTask;
+import java.util.concurrent.RunnableFuture;
import java.util.regex.Pattern;
@SuppressWarnings({"UtilityClassWithoutPrivateConstructor", "MethodOverridesStaticMethodOfSuperclass"})
@@ -638,6 +640,16 @@
@Nullable
public static String toCanonicalPath(@Nullable String path, final char separatorChar) {
+ return toCanonicalPath(path, separatorChar, true);
+ }
+
+ @Nullable
+ public static String toCanonicalUriPath(@Nullable String path) {
+ return toCanonicalPath(path, '/', false);
+ }
+
+ @Nullable
+ private static String toCanonicalPath(@Nullable String path, final char separatorChar, boolean removeLastSlash) {
if (path == null || path.isEmpty()) {
return path;
}
@@ -689,7 +701,7 @@
}
int lastChar = result.length() - 1;
- if (lastChar >= 0 && result.charAt(lastChar) == '/' && lastChar > start) {
+ if (removeLastSlash && lastChar >= 0 && result.charAt(lastChar) == '/' && lastChar > start) {
result.deleteCharAt(lastChar);
}
diff --git a/platform/util/src/com/intellij/openapi/util/text/StringUtil.java b/platform/util/src/com/intellij/openapi/util/text/StringUtil.java
index 643d822..2c6cce5 100644
--- a/platform/util/src/com/intellij/openapi/util/text/StringUtil.java
+++ b/platform/util/src/com/intellij/openapi/util/text/StringUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -792,34 +792,33 @@
}
/**
- * Equivalent to testee.startsWith(firstPrefix + secondPrefix) but avoids creating an object for concatenation.
- *
- * @param testee
- * @param firstPrefix
- * @param secondPrefix
- * @return
+ * Equivalent to string.startsWith(prefixes[0] + prefixes[1] + ...) but avoids creating an object for concatenation.
*/
- public static boolean startsWithConcatenationOf(@NotNull String testee, @NotNull String firstPrefix, @NotNull String secondPrefix) {
- int l1 = firstPrefix.length();
- int l2 = secondPrefix.length();
- if (testee.length() < l1 + l2) return false;
- return testee.startsWith(firstPrefix) && testee.regionMatches(l1, secondPrefix, 0, l2);
+ public static boolean startsWithConcatenation(@NotNull String string, @NotNull String... prefixes) {
+ int offset = 0;
+ for (String prefix : prefixes) {
+ int prefixLen = prefix.length();
+ if (!string.regionMatches(offset, prefix, 0, prefixLen)) {
+ return false;
+ }
+ offset += prefixLen;
+ }
+ return true;
}
- /**
- * Equivalent to testee.startsWith(firstPrefix + secondPrefix + thirdPrefix) but avoids creating an object for concatenation.
- */
- public static boolean startsWithConcatenationOf(@NotNull String testee,
+ /** @deprecated use {@link #startsWithConcatenation(String, String...)} (to remove in IDEA 14). */
+ @SuppressWarnings("UnusedDeclaration")
+ public static boolean startsWithConcatenationOf(@NotNull String string, @NotNull String firstPrefix, @NotNull String secondPrefix) {
+ return startsWithConcatenation(string, firstPrefix, secondPrefix);
+ }
+
+ /** @deprecated use {@link #startsWithConcatenation(String, String...)} (to remove in IDEA 14). */
+ @SuppressWarnings("UnusedDeclaration")
+ public static boolean startsWithConcatenationOf(@NotNull String string,
@NotNull String firstPrefix,
@NotNull String secondPrefix,
@NotNull String thirdPrefix) {
- int l1 = firstPrefix.length();
- int l2 = secondPrefix.length();
- int l3 = thirdPrefix.length();
- if (testee.length() < l1 + l2 + l3) return false;
- return testee.startsWith(firstPrefix)
- && testee.regionMatches(l1, secondPrefix, 0, l2)
- && testee.regionMatches(l1 + l2, thirdPrefix, 0, l3);
+ return startsWithConcatenation(string, firstPrefix, secondPrefix, thirdPrefix);
}
@NotNull
@@ -1213,15 +1212,25 @@
}
@NotNull
- public static String join(@NotNull Collection<? extends String> strings, @NotNull final String separator) {
- final StringBuilder result = new StringBuilder();
+ public static String join(@NotNull Collection<? extends String> strings, @NotNull String separator) {
+ StringBuilder result = new StringBuilder();
+ join(strings, separator, result);
+ return result.toString();
+ }
+
+ public static void join(@NotNull Collection<? extends String> strings, @NotNull String separator, @NotNull StringBuilder result) {
+ boolean isFirst = true;
for (String string : strings) {
if (string != null && !string.isEmpty()) {
- if (result.length() != 0) result.append(separator);
+ if (isFirst) {
+ isFirst = false;
+ }
+ else {
+ result.append(separator);
+ }
result.append(string);
}
}
- return result.toString();
}
@NotNull
@@ -2333,12 +2342,17 @@
@NotNull
public static String shortenTextWithEllipsis(@NotNull final String text, final int maxLength, final int suffixLength) {
+ return shortenTextWithEllipsis(text, maxLength, suffixLength, false);
+ }
+
+ @NotNull
+ public static String shortenTextWithEllipsis(@NotNull final String text, final int maxLength, final int suffixLength, boolean useEllipsisSymbol) {
final int prefix_length = maxLength - suffixLength - 3;
assert prefix_length > 0;
String result;
final int textLength = text.length();
if (textLength > maxLength) {
- result = text.substring(0, prefix_length) + "..." + text.substring(textLength - suffixLength);
+ result = text.substring(0, prefix_length) + (useEllipsisSymbol ? "\u2026" : "...") + text.substring(textLength - suffixLength);
}
else {
result = text;
@@ -2347,8 +2361,13 @@
}
@NotNull
- public static String shortenPathWithEllipsis(@NotNull final String path, final int max_length) {
- return shortenTextWithEllipsis(path, max_length, (int)(max_length * 0.7));
+ public static String shortenPathWithEllipsis(@NotNull final String path, final int maxLength, boolean useEllipsisSymbol) {
+ return shortenTextWithEllipsis(path, maxLength, (int)(maxLength * 0.7), useEllipsisSymbol);
+ }
+
+ @NotNull
+ public static String shortenPathWithEllipsis(@NotNull final String path, final int maxLength) {
+ return shortenPathWithEllipsis(path, maxLength, false);
}
public static boolean charsEqual(char a, char b, boolean ignoreCase) {
diff --git a/platform/util/src/com/intellij/psi/codeStyle/MinusculeMatcher.java b/platform/util/src/com/intellij/psi/codeStyle/MinusculeMatcher.java
index 8473281..d5013d2 100644
--- a/platform/util/src/com/intellij/psi/codeStyle/MinusculeMatcher.java
+++ b/platform/util/src/com/intellij/psi/codeStyle/MinusculeMatcher.java
@@ -182,30 +182,22 @@
int startIndex = first.getStartOffset();
boolean afterSeparator = StringUtil.indexOfAny(name, HARD_SEPARATORS, 0, startIndex) >= 0;
boolean wordStart = startIndex == 0 || isWordStart(name, startIndex) && !isWordStart(name, startIndex - 1);
+ boolean finalMatch = iterable.get(iterable.size() - 1).getEndOffset() == name.length();
- return (wordStart ? 1000 : 0) - integral * 10 + matchingCase + (afterSeparator ? 0 : 1);
+ return (wordStart ? 1000 : 0) - integral * 10 + matchingCase + (afterSeparator ? 0 : 2) + (finalMatch ? 1 : 0);
}
public boolean isStartMatch(@NotNull String name) {
Iterable<TextRange> fragments = matchingFragments(name);
if (fragments != null) {
Iterator<TextRange> iterator = fragments.iterator();
- if (!iterator.hasNext() || isStartMatch(name, iterator.next().getStartOffset())) {
+ if (!iterator.hasNext() || iterator.next().getStartOffset() == 0) {
return true;
}
}
return false;
}
- private static boolean isStartMatch(@NotNull String name, int startIndex) {
- for (int i = 0; i < startIndex; i++) {
- if (!isWordSeparator(name.charAt(i))) {
- return false;
- }
- }
- return true;
- }
-
@Override
public boolean matches(@NotNull String name) {
// optimisation: name too short for this pattern
diff --git a/platform/util/src/com/intellij/ui/mac/foundation/MacUtil.java b/platform/util/src/com/intellij/ui/mac/foundation/MacUtil.java
index 64ddda5..092a36b 100644
--- a/platform/util/src/com/intellij/ui/mac/foundation/MacUtil.java
+++ b/platform/util/src/com/intellij/ui/mac/foundation/MacUtil.java
@@ -15,11 +15,18 @@
*/
package com.intellij.ui.mac.foundation;
+import com.intellij.openapi.Disposable;
import com.intellij.openapi.util.Comparing;
+import com.intellij.openapi.util.Disposer;
+import com.intellij.openapi.util.SystemInfo;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
+import javax.swing.text.JTextComponent;
import java.awt.*;
+import java.awt.event.AWTEventListener;
+import java.awt.event.KeyEvent;
import static com.intellij.ui.mac.foundation.Foundation.invoke;
import static com.intellij.ui.mac.foundation.Foundation.toStringViaUTF8;
@@ -103,6 +110,31 @@
public static synchronized void startModal(JComponent component) {
startModal(component, MAC_NATIVE_WINDOW_SHOWING);
}
-
-
+
+ public static boolean isFullKeyboardAccessEnabled() {
+ return SystemInfo.isMacOSSnowLeopard
+ && invoke(invoke("NSApplication", "sharedApplication"), "isFullKeyboardAccessEnabled").intValue() == 1;
+ }
+
+ public static void adjustFocusTraversal(@NotNull Disposable disposable) {
+ if (!SystemInfo.isMacOSSnowLeopard) return;
+ final AWTEventListener listener = new AWTEventListener() {
+ @Override
+ public void eventDispatched(AWTEvent event) {
+ if (event instanceof KeyEvent
+ && ((KeyEvent)event).getKeyCode() == KeyEvent.VK_TAB
+ && (!(event.getSource() instanceof JTextComponent))
+ && (!(event.getSource() instanceof JList))
+ && !isFullKeyboardAccessEnabled())
+ ((KeyEvent)event).consume();
+ }
+ };
+ Disposer.register(disposable, new Disposable() {
+ @Override
+ public void dispose() {
+ Toolkit.getDefaultToolkit().removeAWTEventListener(listener);
+ }
+ });
+ Toolkit.getDefaultToolkit().addAWTEventListener(listener, AWTEvent.KEY_EVENT_MASK);
+ }
}
diff --git a/platform/util/src/com/intellij/util/concurrency/FutureResult.java b/platform/util/src/com/intellij/util/concurrency/FutureResult.java
index 47a08e2..0e1eb84 100644
--- a/platform/util/src/com/intellij/util/concurrency/FutureResult.java
+++ b/platform/util/src/com/intellij/util/concurrency/FutureResult.java
@@ -1,7 +1,7 @@
package com.intellij.util.concurrency;
import com.intellij.openapi.util.Pair;
-import com.intellij.openapi.util.Ref;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.concurrent.*;
@@ -9,13 +9,37 @@
public class FutureResult<T> implements Future<T> {
private final Semaphore mySema = new Semaphore(0);
- private volatile Ref<Pair<Object, Boolean>> myValue;
+ private volatile Pair<Object, Boolean> myValue;
- public void reset() {
- mySema.drainPermits();
+ public synchronized void set(@Nullable T result) {
+ assertNotSet();
+
+ myValue = Pair.create((Object)result, true);
+ mySema.release();
+ }
+
+ public synchronized void setException(@NotNull Throwable e) {
+ assertNotSet();
+
+ myValue = Pair.create((Object)e, false);
+ mySema.release();
+ }
+
+ public synchronized void reset() {
+ try {
+ // wait till readers get their results
+ if (isDone()) mySema.acquire();
+ }
+ catch (InterruptedException ignore) {
+ return;
+ }
myValue = null;
}
+ private void assertNotSet() {
+ if (isDone()) throw new IllegalStateException("Result is already set");
+ }
+
public boolean cancel(boolean mayInterruptIfRunning) {
return false;
}
@@ -28,20 +52,6 @@
return myValue != null;
}
- public void set(@Nullable T result) {
- if (myValue != null) throw new IllegalStateException("Result is already set");
-
- myValue = Ref.create(Pair.create((Object)result, true));
- mySema.release();
- }
-
- public void setException(Throwable e) {
- assert myValue == null;
-
- myValue = Ref.create(Pair.create((Object)e, false));
- mySema.release();
- }
-
public T get() throws InterruptedException, ExecutionException {
mySema.acquire();
try {
@@ -52,7 +62,7 @@
}
}
- public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
+ public T get(long timeout, @NotNull TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
if (!mySema.tryAcquire(timeout, unit)) throw new TimeoutException();
try {
return doGet();
@@ -62,9 +72,18 @@
}
}
+ @Nullable
+ public T tryGet() throws ExecutionException {
+ return doGet();
+ }
+
+ @Nullable
private T doGet() throws ExecutionException {
- Pair<Object, Boolean> pair = myValue.get();
+ Pair<Object, Boolean> pair = myValue;
+ if (pair == null) return null;
+
if (!pair.second) throw new ExecutionException(((Throwable)pair.first).getMessage(), (Throwable)pair.first);
+ //noinspection unchecked
return (T)pair.first;
}
}
diff --git a/platform/util/src/com/intellij/util/containers/MostlySingularMultiMap.java b/platform/util/src/com/intellij/util/containers/MostlySingularMultiMap.java
index 92c5cb0..579aa51 100644
--- a/platform/util/src/com/intellij/util/containers/MostlySingularMultiMap.java
+++ b/platform/util/src/com/intellij/util/containers/MostlySingularMultiMap.java
@@ -59,6 +59,30 @@
}
}
+ public boolean remove(@NotNull K key, @NotNull V value) {
+ Object current = myMap.get(key);
+ if (current == null) {
+ return false;
+ }
+ if (current instanceof Object[]) {
+ Object[] curArr = (Object[])current;
+ Object[] newArr = ArrayUtil.remove(curArr, value, ArrayUtil.OBJECT_ARRAY_FACTORY);
+ myMap.put(key, newArr);
+ return newArr.length == curArr.length-1;
+ }
+
+ if (value.equals(current)) {
+ myMap.remove(key);
+ return true;
+ }
+
+ return false;
+ }
+
+ public boolean removeAllValues(@NotNull K key) {
+ return myMap.remove(key) != null;
+ }
+
@NotNull
public Set<K> keySet() {
return myMap.keySet();
@@ -192,7 +216,7 @@
@NotNull
@Override
public Iterable get(@NotNull Object name) {
- return EmptyIterable.getInstance();
+ return ContainerUtil.emptyList();
}
}
}
diff --git a/platform/util/src/com/intellij/util/io/ReadWriteDirectBufferWrapper.java b/platform/util/src/com/intellij/util/io/ReadWriteDirectBufferWrapper.java
index a7cf14b..4dee6f9 100644
--- a/platform/util/src/com/intellij/util/io/ReadWriteDirectBufferWrapper.java
+++ b/platform/util/src/com/intellij/util/io/ReadWriteDirectBufferWrapper.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -55,7 +55,7 @@
}
private RandomAccessFile createFile() throws FileNotFoundException {
- return FileUtilRt.doIOOperation(new FileUtilRt.RetriableIOOperation<RandomAccessFile, FileNotFoundException>() {
+ return FileUtilRt.doIOOperation(new FileUtilRt.RepeatableIOOperation<RandomAccessFile, FileNotFoundException>() {
@Nullable
@Override
public RandomAccessFile execute(boolean finalAttempt) throws FileNotFoundException {
diff --git a/platform/util/src/com/intellij/util/io/ResizeableMappedFile.java b/platform/util/src/com/intellij/util/io/ResizeableMappedFile.java
index ac1d4ed..76ad6da 100644
--- a/platform/util/src/com/intellij/util/io/ResizeableMappedFile.java
+++ b/platform/util/src/com/intellij/util/io/ResizeableMappedFile.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -100,7 +100,7 @@
final File lengthFile = getLengthFile();
DataOutputStream stream = null;
try {
- stream = FileUtilRt.doIOOperation(new FileUtilRt.RetriableIOOperation<DataOutputStream, FileNotFoundException>() {
+ stream = FileUtilRt.doIOOperation(new FileUtilRt.RepeatableIOOperation<DataOutputStream, FileNotFoundException>() {
@Nullable
@Override
public DataOutputStream execute(boolean lastAttempt) throws FileNotFoundException {
diff --git a/platform/util/src/com/intellij/util/io/URLUtil.java b/platform/util/src/com/intellij/util/io/URLUtil.java
index a55c152..d06217f 100644
--- a/platform/util/src/com/intellij/util/io/URLUtil.java
+++ b/platform/util/src/com/intellij/util/io/URLUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -13,21 +13,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.intellij.util.io;
import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.openapi.util.text.StringUtil;
import gnu.trove.TIntArrayList;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.io.FileNotFoundException;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.ArrayList;
@@ -35,11 +37,12 @@
import java.util.zip.ZipFile;
public class URLUtil {
-
public static final String SCHEME_SEPARATOR = "://";
+ public static final String JAR_PROTOCOL = "jar";
+ public static final String FILE_PROTOCOL = "file";
+ public static final String JAR_SEPARATOR = "!/";
- private URLUtil() {
- }
+ private URLUtil() { }
/**
* Opens a url stream. The semantics is the sames as {@link java.net.URL#openStream()}. The
@@ -48,12 +51,8 @@
*/
@NotNull
public static InputStream openStream(@NotNull URL url) throws IOException {
- @NonNls final String protocol = url.getProtocol();
- if (protocol.equals("jar")) {
- return openJarStream(url);
- }
-
- return url.openStream();
+ @NonNls String protocol = url.getProtocol();
+ return protocol.equals(JAR_PROTOCOL) ? openJarStream(url) : url.openStream();
}
@NotNull
@@ -64,10 +63,10 @@
catch(FileNotFoundException ex) {
@NonNls final String protocol = url.getProtocol();
String file = null;
- if (protocol.equals("file")) {
+ if (protocol.equals(FILE_PROTOCOL)) {
file = url.getFile();
}
- else if (protocol.equals("jar")) {
+ else if (protocol.equals(JAR_PROTOCOL)) {
int pos = url.getFile().indexOf("!");
if (pos >= 0) {
file = url.getFile().substring(pos+1);
@@ -83,16 +82,17 @@
@NotNull
private static InputStream openJarStream(@NotNull URL url) throws IOException {
- String file = url.getFile();
- assert file.startsWith("file:");
- file = file.substring("file:".length());
- assert file.indexOf("!/") > 0;
+ Pair<String, String> paths = splitJarUrl(url.getFile());
+ if (paths == null) {
+ throw new MalformedURLException(url.getFile());
+ }
- String resource = file.substring(file.indexOf("!/") + 2);
- file = file.substring(0, file.indexOf("!"));
- final ZipFile zipFile = new ZipFile(FileUtil.unquote(file));
- final ZipEntry zipEntry = zipFile.getEntry(resource);
- if (zipEntry == null) throw new FileNotFoundException("Entry " + resource + " not found in " + file);
+ @SuppressWarnings("IOResourceOpenedButNotSafelyClosed") final ZipFile zipFile = new ZipFile(FileUtil.unquote(paths.first));
+ ZipEntry zipEntry = zipFile.getEntry(paths.second);
+ if (zipEntry == null) {
+ throw new FileNotFoundException("Entry " + paths.second + " not found in " + paths.first);
+ }
+
return new FilterInputStream(zipFile.getInputStream(zipEntry)) {
@Override
public void close() throws IOException {
@@ -102,6 +102,20 @@
};
}
+ @Nullable
+ public static Pair<String, String> splitJarUrl(@NotNull String fullPath) {
+ int delimiter = fullPath.indexOf(JAR_SEPARATOR);
+ if (delimiter >= 0) {
+ String resourcePath = fullPath.substring(delimiter + 2);
+ String jarPath = fullPath.substring(0, delimiter);
+ if (StringUtil.startsWithConcatenation(jarPath, FILE_PROTOCOL, ":")) {
+ jarPath = jarPath.substring(FILE_PROTOCOL.length() + 1);
+ return Pair.create(jarPath, resourcePath);
+ }
+ }
+ return null;
+ }
+
@NotNull
public static String unescapePercentSequences(@NotNull String s) {
if (s.indexOf('%') == -1) {
diff --git a/platform/util/src/com/intellij/util/text/CharArrayCharSequence.java b/platform/util/src/com/intellij/util/text/CharArrayCharSequence.java
index 7d82119..18f0715 100644
--- a/platform/util/src/com/intellij/util/text/CharArrayCharSequence.java
+++ b/platform/util/src/com/intellij/util/text/CharArrayCharSequence.java
@@ -105,7 +105,7 @@
final int readChars = Math.min(len, length() - start);
if (readChars <= 0) return -1;
- System.arraycopy(myChars, start, cbuf, off, readChars);
+ System.arraycopy(myChars, myStart + start, cbuf, off, readChars);
return readChars;
}
}
diff --git a/platform/util/src/com/intellij/util/text/SemVer.java b/platform/util/src/com/intellij/util/text/SemVer.java
index 1f0ad17..c0ca07f 100644
--- a/platform/util/src/com/intellij/util/text/SemVer.java
+++ b/platform/util/src/com/intellij/util/text/SemVer.java
@@ -78,7 +78,12 @@
}
Integer major = toInteger(comps[0]);
Integer minor = toInteger(comps[1]);
- Integer patch = toInteger(comps[2]);
+ String patchStr = comps[2];
+ int dashInd = patchStr.indexOf('-');
+ if (dashInd >= 0) {
+ patchStr = patchStr.substring(0, dashInd);
+ }
+ Integer patch = toInteger(patchStr);
if (major != null && minor != null && patch != null) {
return new SemVer(major, minor, patch);
}
diff --git a/platform/util/testSrc/com/intellij/openapi/util/io/FileUtilTest.java b/platform/util/testSrc/com/intellij/openapi/util/io/FileUtilTest.java
index 00b512b..605dc42 100644
--- a/platform/util/testSrc/com/intellij/openapi/util/io/FileUtilTest.java
+++ b/platform/util/testSrc/com/intellij/openapi/util/io/FileUtilTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -20,9 +20,9 @@
import com.intellij.util.PairProcessor;
import com.intellij.util.ThreeState;
import com.intellij.util.containers.Convertor;
-import junit.framework.Assert;
import org.junit.Test;
+import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
@@ -118,12 +118,46 @@
for (int i = 0; i < arr.length; i++) {
String s = arr[i];
final ThreeState state = FileUtil.isAncestorThreeState(root, s, false);
- Assert.assertEquals("" + i, expectedResult[i], state);
+ assertEquals(String.valueOf(i), expectedResult[i], state);
}
+
for (int i = 0; i < arr.length; i++) {
String s = arr[i];
final ThreeState state = FileUtil.isAncestorThreeState(root, s, true);
- Assert.assertEquals("" + i, expectedResult2[i], state);
+ assertEquals(String.valueOf(i), expectedResult2[i], state);
}
}
+
+ @Test
+ public void testRepeatableOperation() throws Exception {
+ abstract class CountableIOOperation implements FileUtilRt.RepeatableIOOperation<Boolean, IOException> {
+ private int count = 0;
+
+ @Override
+ public Boolean execute(boolean lastAttempt) throws IOException {
+ count++;
+ return stop(lastAttempt) ? true : null;
+ }
+
+ protected abstract boolean stop(boolean lastAttempt);
+ }
+
+ CountableIOOperation successful = new CountableIOOperation() {
+ @Override protected boolean stop(boolean lastAttempt) { return true; }
+ };
+ FileUtilRt.doIOOperation(successful);
+ assertEquals(1, successful.count);
+
+ CountableIOOperation failed = new CountableIOOperation() {
+ @Override protected boolean stop(boolean lastAttempt) { return false; }
+ };
+ FileUtilRt.doIOOperation(failed);
+ assertEquals(10, failed.count);
+
+ CountableIOOperation lastShot = new CountableIOOperation() {
+ @Override protected boolean stop(boolean lastAttempt) { return lastAttempt; }
+ };
+ FileUtilRt.doIOOperation(lastShot);
+ assertEquals(10, lastShot.count);
+ }
}
diff --git a/platform/util/testSrc/com/intellij/util/text/SemVerTest.java b/platform/util/testSrc/com/intellij/util/text/SemVerTest.java
index 8d7abb9..19839b4 100644
--- a/platform/util/testSrc/com/intellij/util/text/SemVerTest.java
+++ b/platform/util/testSrc/com/intellij/util/text/SemVerTest.java
@@ -28,4 +28,11 @@
Assert.assertNotNull(semVer);
Assert.assertEquals(new SemVer(0, 9, 2), semVer);
}
+
+ @Test
+ public void testExtendedVersion() throws Exception {
+ SemVer semVer = SemVer.parseFromText("0.9.2-dart");
+ Assert.assertNotNull(semVer);
+ Assert.assertEquals(new SemVer(0, 9, 2), semVer);
+ }
}
diff --git a/platform/util/testSrc/com/intellij/util/text/StringUtilTest.java b/platform/util/testSrc/com/intellij/util/text/StringUtilTest.java
index 2e47762..c293ad5 100644
--- a/platform/util/testSrc/com/intellij/util/text/StringUtilTest.java
+++ b/platform/util/testSrc/com/intellij/util/text/StringUtilTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -23,7 +23,7 @@
/**
* @author Eugene Zhuravlev
- * Date: Dec 22, 2006
+ * @since Dec 22, 2006
*/
public class StringUtilTest extends TestCase {
public void testToUpperCase() {
@@ -74,12 +74,12 @@
}
public void testStartsWithConcatenation() {
- assertTrue(StringUtil.startsWithConcatenationOf("something.withdot", "something", "."));
- assertTrue(StringUtil.startsWithConcatenationOf("something.withdot", "", "something."));
- assertTrue(StringUtil.startsWithConcatenationOf("something.", "something", "."));
- assertTrue(StringUtil.startsWithConcatenationOf("something", "something", ""));
- assertFalse(StringUtil.startsWithConcatenationOf("something", "something", "."));
- assertFalse(StringUtil.startsWithConcatenationOf("some", "something", ""));
+ assertTrue(StringUtil.startsWithConcatenation("something.with.dot", "something", "."));
+ assertTrue(StringUtil.startsWithConcatenation("something.with.dot", "", "something."));
+ assertTrue(StringUtil.startsWithConcatenation("something.", "something", "."));
+ assertTrue(StringUtil.startsWithConcatenation("something", "something", "", "", ""));
+ assertFalse(StringUtil.startsWithConcatenation("something", "something", "", "", "."));
+ assertFalse(StringUtil.startsWithConcatenation("some", "something", ""));
}
public void testNaturalCompare() {
diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/VcsVFSListener.java b/platform/vcs-api/src/com/intellij/openapi/vcs/VcsVFSListener.java
index 5cf65ba..84fa170 100644
--- a/platform/vcs-api/src/com/intellij/openapi/vcs/VcsVFSListener.java
+++ b/platform/vcs-api/src/com/intellij/openapi/vcs/VcsVFSListener.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -240,7 +240,7 @@
}
private void addFileToMove(final VirtualFile file, final String newParentPath, final String newName) {
- if (file.isDirectory() && !file.isSymLink() && !isDirectoryVersioningSupported()) {
+ if (file.isDirectory() && !file.is(VFileProperty.SYMLINK) && !isDirectoryVersioningSupported()) {
@SuppressWarnings("UnsafeVfsRecursion") VirtualFile[] children = file.getChildren();
if (children != null) {
for (VirtualFile child : children) {
diff --git a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffTableModel.java b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffTableModel.java
index 1ac6b8b..aea844d 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffTableModel.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffTableModel.java
@@ -15,6 +15,7 @@
*/
package com.intellij.openapi.diff.impl.dir;
+import com.intellij.CommonBundle;
import com.intellij.ide.IdeBundle;
import com.intellij.ide.diff.*;
import com.intellij.openapi.Disposable;
@@ -23,8 +24,11 @@
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.diff.impl.dir.actions.popup.WarnOnDeletion;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.MessageType;
+import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.popup.Balloon;
import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.util.Condition;
@@ -755,6 +759,9 @@
}
public void synchronizeSelected() {
+ if (!checkCanDelete()) {
+ return;
+ }
rememberSelection();
for (DirDiffElementImpl element : getSelectedElements()) {
syncElement(element);
@@ -769,12 +776,67 @@
}
public void synchronizeAll() {
+ if (!checkCanDelete()) {
+ return;
+ }
for (DirDiffElementImpl element : myElements.toArray(new DirDiffElementImpl[myElements.size()])) {
syncElement(element);
}
selectFirstRow();
}
+ private boolean checkCanDelete() {
+ if (WarnOnDeletion.isWarnWhenDeleteItems()) {
+ int count = 0;
+ for (DirDiffElementImpl element : myElements) {
+ if (element.getOperation() == DirDiffOperation.DELETE) {
+ count++;
+ }
+ }
+ if (count > 0) {
+ if (!confirmDeletion(count)) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ private static boolean confirmDeletion(int count) {
+ DialogWrapper.DoNotAskOption option = new DialogWrapper.DoNotAskOption() {
+ @Override
+ public boolean isToBeShown() {
+ return WarnOnDeletion.isWarnWhenDeleteItems();
+ }
+
+ @Override
+ public void setToBeShown(boolean value, int exitCode) {
+ WarnOnDeletion.setWarnWhenDeleteItems(value);
+ }
+
+ @Override
+ public boolean canBeHidden() {
+ return true;
+ }
+
+ @Override
+ public boolean shouldSaveOptionsOnCancel() {
+ return true;
+ }
+
+ @Override
+ public String getDoNotShowMessage() {
+ return "Do not ask me again";
+ }
+ };
+
+ return DialogWrapper.OK_EXIT_CODE == Messages.showYesNoDialog("Delete " + count + " items?", "Confirm Delete",
+ "Delete",
+ CommonBundle.message("button.cancel"),
+ Messages.getQuestionIcon(),
+ option);
+ }
+
private void syncElement(DirDiffElementImpl element) {
final DirDiffOperation operation = element.getOperation();
if (operation == null) return;
diff --git a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/actions/popup/WarnOnDeletion.java b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/actions/popup/WarnOnDeletion.java
new file mode 100644
index 0000000..92dc870
--- /dev/null
+++ b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/dir/actions/popup/WarnOnDeletion.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2000-2013 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.diff.impl.dir.actions.popup;
+
+import com.intellij.ide.util.PropertiesComponent;
+import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.actionSystem.ToggleAction;
+import com.intellij.openapi.project.DumbAware;
+
+/**
+ * @author Konstantin Bulenkov
+ */
+public class WarnOnDeletion extends ToggleAction implements DumbAware {
+ private static final String PROPERTY_NAME = "dir.diff.do.not.show.warnings.when.deleting";
+
+ @Override
+ public boolean isSelected(AnActionEvent e) {
+ return isWarnWhenDeleteItems();
+ }
+
+ @Override
+ public void setSelected(AnActionEvent e, boolean state) {
+ setWarnWhenDeleteItems(state);
+ }
+
+ public static boolean isWarnWhenDeleteItems() {
+ return !PropertiesComponent.getInstance().isTrueValue(PROPERTY_NAME);
+ }
+
+ public static void setWarnWhenDeleteItems(boolean warn) {
+ PropertiesComponent.getInstance().setValue(PROPERTY_NAME, Boolean.valueOf(!warn).toString());
+ }
+}
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AnnotateToggleAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AnnotateToggleAction.java
index 37ab3dd..b869c57 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AnnotateToggleAction.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AnnotateToggleAction.java
@@ -101,7 +101,25 @@
public boolean isSelected(AnActionEvent e) {
VcsContext context = VcsContextFactory.SERVICE.getInstance().createContextOn(e);
Editor editor = context.getEditor();
- if (editor == null) return false;
+ if (editor != null) {
+ return isAnnotated(editor);
+ }
+ VirtualFile selectedFile = context.getSelectedFile();
+ if (selectedFile == null) {
+ return false;
+ }
+
+ for (FileEditor fileEditor : FileEditorManager.getInstance(context.getProject()).getEditors(selectedFile)) {
+ if (fileEditor instanceof TextEditor) {
+ if (isAnnotated(((TextEditor)fileEditor).getEditor())) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private static boolean isAnnotated(@NotNull Editor editor) {
Collection annotations = editor.getUserData(KEY_IN_EDITOR);
return annotations != null && !annotations.isEmpty();
}
@@ -109,14 +127,18 @@
public void setSelected(AnActionEvent e, boolean selected) {
final VcsContext context = VcsContextFactory.SERVICE.getInstance().createContextOn(e);
Editor editor = context.getEditor();
+ VirtualFile selectedFile = context.getSelectedFile();
+ if (selectedFile == null) return;
+
if (!selected) {
- if (editor != null) {
- editor.getGutter().closeAllAnnotations();
+ for (FileEditor fileEditor : FileEditorManager.getInstance(context.getProject()).getEditors(selectedFile)) {
+ if (fileEditor instanceof TextEditor) {
+ ((TextEditor)fileEditor).getEditor().getGutter().closeAllAnnotations();
+ }
}
}
else {
if (editor == null) {
- VirtualFile selectedFile = context.getSelectedFile();
FileEditor[] fileEditors = FileEditorManager.getInstance(context.getProject()).openFile(selectedFile, false);
for (FileEditor fileEditor : fileEditors) {
if (fileEditor instanceof TextEditor) {
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/SelectedBlockHistoryAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/SelectedBlockHistoryAction.java
index 867c009..a899185 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/SelectedBlockHistoryAction.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/SelectedBlockHistoryAction.java
@@ -90,6 +90,7 @@
final VcsHistoryDialog vcsHistoryDialog =
new VcsHistoryDialog(project,
context.getSelectedFiles()[0],
+ context.getEditor(),
provider,
session,
activeVcs,
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/DeleteUnversionedFilesAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/DeleteUnversionedFilesAction.java
index 08fc235..1341024 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/DeleteUnversionedFilesAction.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/DeleteUnversionedFilesAction.java
@@ -23,12 +23,12 @@
package com.intellij.openapi.vcs.changes.actions;
import com.intellij.ide.DeleteProvider;
-import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
+import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.util.IconUtil;
-public class DeleteUnversionedFilesAction extends AnAction {
+public class DeleteUnversionedFilesAction extends DumbAwareAction {
public DeleteUnversionedFilesAction() {
super("Delete", "Delete", IconUtil.getRemoveIcon());
}
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/impl/VcsHistoryDialog.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/impl/VcsHistoryDialog.java
index 2dbbf73..0225e5e 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/impl/VcsHistoryDialog.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/impl/VcsHistoryDialog.java
@@ -23,6 +23,7 @@
import com.intellij.openapi.diff.DiffManager;
import com.intellij.openapi.diff.DiffPanel;
import com.intellij.openapi.diff.SimpleContent;
+import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.help.HelpManager;
import com.intellij.openapi.project.Project;
@@ -56,6 +57,7 @@
import java.util.List;
public class VcsHistoryDialog extends DialogWrapper implements DataProvider {
+ private final Editor myEditor;
private final int mySelectionStart;
private final int mySelectionEnd;
@@ -115,7 +117,7 @@
public VcsHistoryDialog(Project project,
final VirtualFile file,
- final VcsHistoryProvider vcsHistoryProvider,
+ Editor editor, final VcsHistoryProvider vcsHistoryProvider,
VcsHistorySession session,
AbstractVcs vcs,
int selectionStart,
@@ -123,6 +125,7 @@
final String title, final CachedRevisionsContents cachedContents){
super(project, true);
myProject = project;
+ myEditor = editor;
mySelectionStart = selectionStart;
mySelectionEnd = selectionEnd;
myCachedContents = cachedContents;
@@ -456,20 +459,23 @@
@Nullable
private Block getBlock(VcsFileRevision revision) throws FilesTooBigForDiffException, VcsException {
- if (myRevisionToContentMap.containsKey(revision))
+ if (myRevisionToContentMap.containsKey(revision)) {
return myRevisionToContentMap.get(revision);
-
- int index = myRevisions.indexOf(revision);
+ }
final String revisionContent = getContentOf(revision);
if (revisionContent == null) return null;
- if (index == 0)
- myRevisionToContentMap.put(revision, new Block(revisionContent, mySelectionStart, mySelectionEnd));
- else {
- Block prevBlock = getBlock(myRevisions.get(index - 1));
- if (prevBlock == null) return null;
- myRevisionToContentMap.put(revision, new FindBlock(revisionContent, prevBlock).getBlockInThePrevVersion());
- }
+
+ int index = myRevisions.indexOf(revision);
+ Block blockByIndex = getBlock(index);
+ if (blockByIndex == null) return null;
+
+ myRevisionToContentMap.put(revision, new FindBlock(revisionContent, blockByIndex).getBlockInThePrevVersion());
return myRevisionToContentMap.get(revision);
}
+
+ private Block getBlock(int index) throws FilesTooBigForDiffException, VcsException {
+ return index > 0 ? getBlock(myRevisions.get(index - 1)) : new Block(myEditor.getDocument().getText(), mySelectionStart, mySelectionEnd);
+ }
+
}
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/DefaultVcsRootPolicy.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/DefaultVcsRootPolicy.java
index 2be72ff..622099e 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/DefaultVcsRootPolicy.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/DefaultVcsRootPolicy.java
@@ -52,7 +52,7 @@
final StorageScheme storageScheme = ((ProjectEx) project).getStateStore().getStorageScheme();
boolean isDirectoryBased = StorageScheme.DIRECTORY_BASED.equals(storageScheme);
final String[] parts = new String[] {"Content roots of all modules", "all immediate descendants of project base directory",
- ".idea directory contents"};
+ Project.DIRECTORY_STORE_FOLDER + " directory contents"};
final StringBuilder sb = new StringBuilder(parts[0]);
if (isDirectoryBased) {
sb.append(", ");
diff --git a/platform/xdebugger-api/src/com/intellij/xdebugger/XDebuggerManager.java b/platform/xdebugger-api/src/com/intellij/xdebugger/XDebuggerManager.java
index dea7f5f..84000c1 100644
--- a/platform/xdebugger-api/src/com/intellij/xdebugger/XDebuggerManager.java
+++ b/platform/xdebugger-api/src/com/intellij/xdebugger/XDebuggerManager.java
@@ -27,7 +27,7 @@
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
-import java.util.Collection;
+import java.util.List;
/**
* @author nik
@@ -49,7 +49,7 @@
public abstract XDebugSession getDebugSession(@NotNull ExecutionConsole executionConsole);
@NotNull
- public abstract <T extends XDebugProcess> Collection<? extends T> getDebugProcesses(Class<T> processClass);
+ public abstract <T extends XDebugProcess> List<? extends T> getDebugProcesses(Class<T> processClass);
@Nullable
public abstract XDebugSession getCurrentSession();
diff --git a/platform/xdebugger-api/src/com/intellij/xdebugger/evaluation/XDebuggerEditorsProvider.java b/platform/xdebugger-api/src/com/intellij/xdebugger/evaluation/XDebuggerEditorsProvider.java
index 16f473d..afdac13 100644
--- a/platform/xdebugger-api/src/com/intellij/xdebugger/evaluation/XDebuggerEditorsProvider.java
+++ b/platform/xdebugger-api/src/com/intellij/xdebugger/evaluation/XDebuggerEditorsProvider.java
@@ -22,31 +22,13 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-/**
- * @author nik
- */
public abstract class XDebuggerEditorsProvider {
-
@NotNull
public abstract FileType getFileType();
- /**
- * @deprecated use createDocument(Project,String,XSourcePosition,EvaluationMode) instead
- * @return
- */
@NotNull
- @Deprecated
- @SuppressWarnings("MethodMayBeStatic")
- public Document createDocument(@NotNull Project project, @NotNull String text, @Nullable XSourcePosition sourcePosition) {
- throw new UnsupportedOperationException("This method should not be called");
- }
-
- @NotNull
- public Document createDocument(@NotNull Project project,
- @NotNull String text,
- @Nullable XSourcePosition sourcePosition,
- @NotNull EvaluationMode mode) {
- return createDocument(project, text, sourcePosition);
- }
-
-}
+ public abstract Document createDocument(@NotNull Project project,
+ @NotNull String text,
+ @Nullable XSourcePosition sourcePosition,
+ @NotNull EvaluationMode mode);
+}
\ No newline at end of file
diff --git a/platform/xdebugger-api/src/com/intellij/xdebugger/frame/XExecutionStack.java b/platform/xdebugger-api/src/com/intellij/xdebugger/frame/XExecutionStack.java
index 950d773..247a876 100644
--- a/platform/xdebugger-api/src/com/intellij/xdebugger/frame/XExecutionStack.java
+++ b/platform/xdebugger-api/src/com/intellij/xdebugger/frame/XExecutionStack.java
@@ -93,10 +93,5 @@
* @param last <code>true</code> if all frames are added
*/
void addStackFrames(@NotNull List<? extends XStackFrame> stackFrames, final boolean last);
-
- /**
- * @deprecated use {@link #errorOccurred(String)} instead
- */
- void errorOccured(String errorMessage);
}
}
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java
index 254235a..f972f6e 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java
@@ -36,6 +36,7 @@
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.impl.http.HttpVirtualFile;
+import com.intellij.util.SmartList;
import com.intellij.util.messages.MessageBus;
import com.intellij.util.xmlb.annotations.Property;
import com.intellij.xdebugger.*;
@@ -288,15 +289,18 @@
@NotNull
@Override
- public <T extends XDebugProcess> Collection<? extends T> getDebugProcesses(Class<T> processClass) {
- final List<T> list = new ArrayList<T>();
+ public <T extends XDebugProcess> List<? extends T> getDebugProcesses(Class<T> processClass) {
+ List<T> list = null;
for (XDebugSessionImpl session : mySessions.values()) {
final XDebugProcess process = session.getDebugProcess();
if (processClass.isInstance(process)) {
+ if (list == null) {
+ list = new SmartList<T>();
+ }
list.add(processClass.cast(process));
}
}
- return list;
+ return list == null ? Collections.<T>emptyList() : list;
}
@Override
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerUtilImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerUtilImpl.java
index f48344c..d85a155 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerUtilImpl.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerUtilImpl.java
@@ -19,7 +19,6 @@
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.application.WriteAction;
-import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.fileEditor.FileDocumentManager;
@@ -30,7 +29,6 @@
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.util.Processor;
-import com.intellij.util.ReflectionUtil;
import com.intellij.xdebugger.XDebuggerManager;
import com.intellij.xdebugger.XDebuggerUtil;
import com.intellij.xdebugger.XSourcePosition;
@@ -192,10 +190,6 @@
};
}
- public static Class getStateClass(final Class<? extends PersistentStateComponent> aClass) {
- return ReflectionUtil.getRawType(ReflectionUtil.resolveVariableInHierarchy(PersistentStateComponent.class.getTypeParameters()[0], aClass));
- }
-
@Nullable
public static XDebuggerEvaluator getEvaluator(final XSuspendContext suspendContext) {
XExecutionStack executionStack = suspendContext.getActiveExecutionStack();
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointBase.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointBase.java
index da0725c..e820785 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointBase.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointBase.java
@@ -16,11 +16,9 @@
package com.intellij.xdebugger.impl.breakpoints;
import com.intellij.icons.AllIcons;
-import com.intellij.idea.ActionsBundle;
import com.intellij.openapi.actionSystem.ActionGroup;
import com.intellij.openapi.actionSystem.AnAction;
-import com.intellij.openapi.actionSystem.DefaultActionGroup;
-import com.intellij.openapi.actionSystem.Separator;
+import com.intellij.openapi.components.ComponentSerializationUtil;
import com.intellij.openapi.editor.markup.GutterDraggableObject;
import com.intellij.openapi.editor.markup.GutterIconRenderer;
import com.intellij.openapi.project.Project;
@@ -32,16 +30,12 @@
import com.intellij.util.xmlb.XmlSerializer;
import com.intellij.xdebugger.XDebugSession;
import com.intellij.xdebugger.XDebuggerBundle;
-import com.intellij.xdebugger.XDebuggerManager;
import com.intellij.xdebugger.XSourcePosition;
import com.intellij.xdebugger.breakpoints.*;
import com.intellij.xdebugger.impl.DebuggerSupport;
import com.intellij.xdebugger.impl.XDebugSessionImpl;
import com.intellij.xdebugger.impl.XDebuggerSupport;
-import com.intellij.xdebugger.impl.XDebuggerUtilImpl;
import com.intellij.xdebugger.impl.actions.EditBreakpointAction;
-import com.intellij.xdebugger.impl.actions.ViewBreakpointsAction;
-import com.intellij.xdebugger.impl.actions.XDebuggerActions;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -81,7 +75,7 @@
Element element = myState.getPropertiesElement();
if (element != null) {
//noinspection unchecked
- myProperties.loadState(XmlSerializer.deserialize(element, XDebuggerUtilImpl.getStateClass(myProperties.getClass())));
+ myProperties.loadState(XmlSerializer.deserialize(element, ComponentSerializationUtil.getStateClass(myProperties.getClass())));
}
}
}
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointsDialog.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointsDialog.java
index bda64b0..a662cb4 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointsDialog.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointsDialog.java
@@ -29,7 +29,7 @@
import com.intellij.ui.popup.util.ItemWrapper;
import com.intellij.ui.popup.util.MasterController;
import com.intellij.util.Function;
-import com.intellij.util.containers.*;
+import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.HashSet;
import com.intellij.util.ui.UIUtil;
import com.intellij.xdebugger.XDebuggerManager;
@@ -38,7 +38,6 @@
import com.intellij.xdebugger.impl.breakpoints.XBreakpointsDialogState;
import com.intellij.xdebugger.impl.breakpoints.ui.tree.BreakpointItemsTreeController;
import com.intellij.xdebugger.impl.breakpoints.ui.tree.BreakpointsCheckboxTree;
-
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -118,7 +117,7 @@
protected JComponent createCenterPanel() {
JPanel mainPanel = new JPanel(new BorderLayout());
- JBSplitter splitPane = new JBSplitter(false, 0.3f);
+ JBSplitter splitPane = new JBSplitter(0.3f);
splitPane.setSplitterProportionKey(getSplitterProportionKey());
splitPane.setFirstComponent(createMasterView());
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XDebugViewBase.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XDebugViewBase.java
index be094de..49d15d6 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XDebugViewBase.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XDebugViewBase.java
@@ -42,6 +42,7 @@
private void onSessionEvent(final SessionEvent event) {
AppUIUtil.invokeLaterIfProjectAlive(mySession.getProject(), new Runnable() {
+ @Override
public void run() {
rebuildView(event);
}
@@ -50,29 +51,35 @@
protected abstract void rebuildView(final SessionEvent event);
+ @Override
public void dispose() {
mySession.removeSessionListener(mySessionListener);
}
private class MyDebugSessionListener extends XDebugSessionAdapter {
+ @Override
public void sessionPaused() {
onSessionEvent(SessionEvent.PAUSED);
}
+ @Override
public void sessionResumed() {
onSessionEvent(SessionEvent.RESUMED);
}
+ @Override
public void sessionStopped() {
onSessionEvent(SessionEvent.STOPPED);
}
+ @Override
public void stackFrameChanged() {
onSessionEvent(SessionEvent.FRAME_CHANGED);
}
+ @Override
public void beforeSessionResume() {
onSessionEvent(SessionEvent.BEFORE_RESUME);
}
}
-}
+}
\ No newline at end of file
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XFramesView.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XFramesView.java
index 37ec0a6..7501141 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XFramesView.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XFramesView.java
@@ -68,6 +68,7 @@
myFramesList = new XDebuggerFramesList(session.getProject());
myFramesList.addListSelectionListener(new ListSelectionListener() {
+ @Override
public void valueChanged(final ListSelectionEvent e) {
if (e.getValueIsAdjusting()) return;
processFrameSelection();
@@ -85,6 +86,7 @@
myMainPanel.add(ScrollPaneFactory.createScrollPane(myFramesList), BorderLayout.CENTER);
myThreadComboBox = new JComboBox();
+ //noinspection unchecked
myThreadComboBox.setRenderer(new ThreadComboBoxRenderer(myThreadComboBox));
myThreadComboBox.addItemListener(new MyItemListener());
myToolbar = createToolbar();
@@ -121,6 +123,7 @@
return builder;
}
+ @Override
protected void rebuildView(final SessionEvent event) {
if (event == SessionEvent.BEFORE_RESUME) return;
if (event == SessionEvent.FRAME_CHANGED) {
@@ -148,6 +151,7 @@
XExecutionStack[] executionStacks = suspendContext.getExecutionStacks();
for (XExecutionStack executionStack : executionStacks) {
if (!myExecutionStacks.contains(executionStack)) {
+ //noinspection unchecked
myThreadComboBox.addItem(executionStack);
myExecutionStacks.add(executionStack);
}
@@ -207,6 +211,7 @@
}
private class MyItemListener implements ItemListener {
+ @Override
public void itemStateChanged(final ItemEvent e) {
if (!myListenersEnabled) return;
@@ -237,8 +242,10 @@
myNextFrameIndex = 1;
}
+ @Override
public void addStackFrames(@NotNull final List<? extends XStackFrame> stackFrames, final boolean last) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
+ @Override
public void run() {
myStackFrames.addAll(stackFrames);
addFrameListElements(stackFrames, last);
@@ -252,8 +259,9 @@
}
@Override
- public void errorOccurred(final String errorMessage) {
+ public void errorOccurred(@NotNull final String errorMessage) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
+ @Override
public void run() {
if (myErrorMessage == null) {
myErrorMessage = errorMessage;
@@ -271,23 +279,22 @@
model.removeElementAt(model.getSize() - 1);
}
for (Object value : values) {
+ //noinspection unchecked
model.addElement(value);
}
if (!last) {
+ //noinspection unchecked
model.addElement(null);
}
myFramesList.repaint();
}
}
+ @Override
public boolean isObsolete() {
return !myRunning;
}
- public void errorOccured(final String errorMessage) {
- errorOccurred(errorMessage);
- }
-
public void dispose() {
myRunning = false;
myExecutionStack = null;
@@ -305,6 +312,7 @@
myRunning = false;
}
+ @SuppressWarnings("unchecked")
public void initModel(final DefaultListModel model) {
model.removeAllElements();
for (XStackFrame stackFrame : myStackFrames) {
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XVariablesView.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XVariablesView.java
index 0d0bf79..f6c3f4e 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XVariablesView.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XVariablesView.java
@@ -52,6 +52,7 @@
DnDManager.getInstance().registerSource(myDebuggerTreePanel, myDebuggerTreePanel.getTree());
}
+ @Override
protected void rebuildView(final SessionEvent event) {
XStackFrame stackFrame = mySession.getCurrentStackFrame();
XDebuggerTree tree = myDebuggerTreePanel.getTree();
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/settings/XDebuggerSettingsManager.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/settings/XDebuggerSettingsManager.java
index 51306f0..b30a4ac 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/settings/XDebuggerSettingsManager.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/settings/XDebuggerSettingsManager.java
@@ -23,7 +23,6 @@
import com.intellij.util.xmlb.annotations.Attribute;
import com.intellij.util.xmlb.annotations.Property;
import com.intellij.util.xmlb.annotations.Tag;
-import com.intellij.xdebugger.impl.XDebuggerUtilImpl;
import com.intellij.xdebugger.settings.XDebuggerSettings;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
@@ -83,7 +82,7 @@
}
private static <T> void loadState(final XDebuggerSettings<T> settings, final Element settingsElement) {
- Class stateClass = XDebuggerUtilImpl.getStateClass(settings.getClass());
+ Class stateClass = ComponentSerializationUtil.getStateClass(settings.getClass());
//noinspection unchecked
settings.loadState((T)XmlSerializer.deserialize(settingsElement, stateClass));
}
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/DebuggerSessionTabBase.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/DebuggerSessionTabBase.java
index 36cb5fe..57b2e9d 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/DebuggerSessionTabBase.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/DebuggerSessionTabBase.java
@@ -98,6 +98,7 @@
return AllIcons.FileTypes.Text;
}
+ @Override
@NotNull
public RunnerLayoutUi getUi() {
return myUi;
@@ -124,6 +125,7 @@
if (myConsole instanceof ObservableConsoleView) {
ObservableConsoleView observable = (ObservableConsoleView)myConsole;
observable.addChangeListener(new ObservableConsoleView.ChangeListener() {
+ @Override
public void contentAdded(final Collection<ConsoleViewContentType> types) {
if (types.contains(ConsoleViewContentType.ERROR_OUTPUT) || types.contains(ConsoleViewContentType.NORMAL_OUTPUT)) {
content.fireAlert();
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionTab.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionTab.java
index 68d5664..ff280e6 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionTab.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionTab.java
@@ -221,6 +221,7 @@
}
+ @Override
@Nullable
public RunContentDescriptor getRunContentDescriptor() {
return myRunContentDescriptor;
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerMultilineEditor.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerMultilineEditor.java
index f8d23bc..a59baaf 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerMultilineEditor.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerMultilineEditor.java
@@ -54,24 +54,29 @@
};
}
+ @Override
public JComponent getComponent() {
return myEditorTextField;
}
+ @Override
protected void doSetText(String text) {
myEditorTextField.setText(text);
}
+ @Override
public String getText() {
return myEditorTextField.getText();
}
+ @Override
@Nullable
public JComponent getPreferredFocusedComponent() {
final Editor editor = myEditorTextField.getEditor();
return editor != null ? editor.getContentComponent() : null;
}
+ @Override
public void selectAll() {
myEditorTextField.selectAll();
}
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/MessageTreeNode.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/MessageTreeNode.java
index bee1f04..94d4093 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/MessageTreeNode.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/MessageTreeNode.java
@@ -41,7 +41,7 @@
* @author nik
*/
public class MessageTreeNode extends XDebuggerTreeNode {
- private boolean myEllipsis;
+ private final boolean myEllipsis;
private XDebuggerTreeNodeHyperlink myLink;
private MessageTreeNode(XDebuggerTree tree, @Nullable final XDebuggerTreeNode parent, final String message, final SimpleTextAttributes attributes,
@@ -68,6 +68,7 @@
myEllipsis = false;
}
+ @Override
protected List<? extends TreeNode> getChildren() {
return Collections.emptyList();
}
@@ -82,6 +83,7 @@
return myLink;
}
+ @Override
public List<? extends XDebuggerTreeNode> getLoadedChildren() {
return null;
}
@@ -144,7 +146,7 @@
}
while (matcher.find());
- if (prev < (message.length() - 1)) {
+ if (prev < message.length()) {
objects.add(message.substring(prev));
}
return new MessageTreeNodeWithLinks(tree, objects);
diff --git a/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XDebuggerTestUtil.java b/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XDebuggerTestUtil.java
index bd0c541..c15dad5 100644
--- a/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XDebuggerTestUtil.java
+++ b/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XDebuggerTestUtil.java
@@ -116,9 +116,13 @@
}
public static List<XStackFrame> collectStacks(@NotNull XExecutionStack thread) throws InterruptedException {
+ return collectStacks(thread, TIMEOUT * 2);
+ }
+
+ public static List<XStackFrame> collectStacks(XExecutionStack thread, long timeout) throws InterruptedException {
XTestStackFrameContainer container = new XTestStackFrameContainer();
thread.computeStackFrames(0, container);
- return container.waitFor(TIMEOUT * 2).first;
+ return container.waitFor(timeout).first;
}
public static Pair<XValue, String> evaluate(XDebugSession session, String expression) throws InterruptedException {
@@ -163,12 +167,16 @@
}
public static XTestValueNode computePresentation(@NotNull XValue value) throws InterruptedException {
+ return computePresentation(value, TIMEOUT);
+ }
+
+ public static XTestValueNode computePresentation(XValue value, long timeout) throws InterruptedException {
XTestValueNode node = new XTestValueNode();
if (value instanceof XNamedValue) {
node.myName = ((XNamedValue)value).getName();
}
value.computePresentation(node, XValuePlace.TREE);
- Assert.assertTrue("timed out", node.waitFor(TIMEOUT));
+ node.waitFor(timeout);
return node;
}
diff --git a/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XTestContainer.java b/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XTestContainer.java
index c2efb05..286c965 100644
--- a/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XTestContainer.java
+++ b/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XTestContainer.java
@@ -59,7 +59,8 @@
}
public Pair<List<T>, String> waitFor(long timeout) throws InterruptedException {
- XDebuggerTestUtil.waitFor(myFinished, timeout);
+ if (!XDebuggerTestUtil.waitFor(myFinished, timeout)) throw new AssertionError("Waiting timed out");
+
return new Pair<List<T>, String>(myChildren, myErrorMessage);
}
}
diff --git a/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XTestValueNode.java b/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XTestValueNode.java
index e7a5216..6c4ba46 100644
--- a/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XTestValueNode.java
+++ b/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XTestValueNode.java
@@ -94,7 +94,7 @@
return false;
}
- public boolean waitFor(long timeoutInMillis) throws InterruptedException {
- return XDebuggerTestUtil.waitFor(myFinished, timeoutInMillis);
+ public void waitFor(long timeoutInMillis) throws InterruptedException {
+ if (!XDebuggerTestUtil.waitFor(myFinished, timeoutInMillis)) throw new AssertionError("Waiting timed out");
}
}
diff --git a/plugins/InspectionGadgets/src/META-INF/plugin.xml b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/META-INF/InspectionGadgets.xml
similarity index 99%
rename from plugins/InspectionGadgets/src/META-INF/plugin.xml
rename to plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/META-INF/InspectionGadgets.xml
index 32736c9..2c82c82 100644
--- a/plugins/InspectionGadgets/src/META-INF/plugin.xml
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/META-INF/InspectionGadgets.xml
@@ -1,15 +1,6 @@
<idea-plugin version="2">
- <name>Inspection Gadgets</name>
- <id>InspectionGadgets</id>
- <vendor>JetBrains</vendor>
-
- <category>inspection</category>
- <version>1.0</version>
-
- <resource-bundle>com.siyeh.InspectionGadgetsBundle</resource-bundle>
<extensions xmlns="com.intellij">
- <errorHandler implementation="com.intellij.diagnostic.ITNReporter"/>
<!--group.names.abstraction.issues-->
<localInspection language="JAVA" shortName="CastToConcreteClass" bundle="com.siyeh.InspectionGadgetsBundle" key="cast.to.concrete.class.display.name"
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties
index 69f312b..c0c92f9 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties
@@ -810,7 +810,7 @@
field.may.be.static.display.name=Field may be 'static'
class.may.be.interface.display.name=Class may be interface
abstract.class.without.abstract.methods.display.name=Abstract class without abstract methods
-divide.by.zero.display.name=Division by zero
+divide.by.zero.display.name=Divide by zero
default.not.last.case.in.switch.display.name='default' not last case in 'switch' statement
nested.synchronized.statement.display.name=Nested 'synchronized' statement
constant.conditional.expression.display.name=Constant conditional expression
@@ -1853,7 +1853,8 @@
overloaded.methods.with.same.number.parameters.option=<html>Ignore overloaded methods whose parameter types are definitely incompatible</html>
string.concatenation.in.format.call.display.name=String concatenation as argument to 'format()' call
string.concatenation.in.format.call.problem.descriptor=<code>#ref()</code> call has a String concatenation argument #loc
-string.concatenation.in.format.call.quickfix=Replace concatenation with parameterized log message
+string.concatenation.in.format.call.quickfix=Replace concatenation with separate argument
+string.concatenation.in.format.call.plural.quickfix=Replace concatenation with separate arguments
string.concatenation.in.message.format.call.display.name=String concatenation as argument to 'MessageFormat.format()' call
string.concatenation.in.message.format.call.problem.descriptor=String concatenation as argument to 'MessageFormat.format()' call #loc
shift.out.of.range.quickfix=Replace ''{0}'' with ''{1}''
@@ -2018,6 +2019,7 @@
ignore.classes.extending.throwable.option=Ignore classes extending 'Throwable'
string.concatenation.argument.to.log.call.display.name=Non-constant string concatenation as argument to logging call
string.concatenation.argument.to.log.call.problem.descriptor=Non-constant string concatenation as argument to <code>#ref()</code> logging call #loc
+string.concatenation.argument.to.log.call.quickfix=Replace concatenation with parameterized log message
placeholder.count.matches.argument.count.display.name=Number of placeholders does not match number of arguments in logging call
placeholder.count.matches.argument.count.more.problem.descriptor=<code>#ref()</code> call has more arguments ({0}) than placeholders ({1}) #loc
placeholder.count.matches.argument.count.fewer.problem.descriptor=<code>#ref()</code> call has fewer arguments ({0}) than placeholders ({1}) #loc
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/assignment/AssignmentUsedAsConditionInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/assignment/AssignmentUsedAsConditionInspection.java
index 8f2b629..cd4eb42 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/assignment/AssignmentUsedAsConditionInspection.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/assignment/AssignmentUsedAsConditionInspection.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2007 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2013 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,12 +18,10 @@
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
-import com.intellij.util.IncorrectOperationException;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
import com.siyeh.ig.InspectionGadgetsFix;
-import com.siyeh.ig.psiutils.WellFormednessUtils;
import org.jetbrains.annotations.NotNull;
public class AssignmentUsedAsConditionInspection extends BaseInspection {
@@ -31,15 +29,13 @@
@Override
@NotNull
public String getDisplayName() {
- return InspectionGadgetsBundle.message(
- "assignment.used.as.condition.display.name");
+ return InspectionGadgetsBundle.message("assignment.used.as.condition.display.name");
}
@Override
@NotNull
public String buildErrorString(Object... infos) {
- return InspectionGadgetsBundle.message(
- "assignment.used.as.condition.problem.descriptor");
+ return InspectionGadgetsBundle.message("assignment.used.as.condition.problem.descriptor");
}
@Override
@@ -47,26 +43,21 @@
return new AssignmentUsedAsConditionFix();
}
- private static class AssignmentUsedAsConditionFix
- extends InspectionGadgetsFix {
+ private static class AssignmentUsedAsConditionFix extends InspectionGadgetsFix {
@Override
@NotNull
public String getName() {
- return InspectionGadgetsBundle.message(
- "assignment.used.as.condition.replace.quickfix");
+ return InspectionGadgetsBundle.message("assignment.used.as.condition.replace.quickfix");
}
@Override
- public void doFix(Project project, ProblemDescriptor descriptor)
- throws IncorrectOperationException {
- final PsiAssignmentExpression expression =
- (PsiAssignmentExpression)descriptor.getPsiElement();
+ public void doFix(Project project, ProblemDescriptor descriptor) {
+ final PsiAssignmentExpression expression = (PsiAssignmentExpression)descriptor.getPsiElement();
final PsiExpression leftExpression = expression.getLExpression();
final PsiExpression rightExpression = expression.getRExpression();
assert rightExpression != null;
- final String newExpression =
- leftExpression.getText() + "==" + rightExpression.getText();
+ final String newExpression = leftExpression.getText() + "==" + rightExpression.getText();
replaceExpression(expression, newExpression);
}
}
@@ -76,63 +67,35 @@
return new AssignmentUsedAsConditionVisitor();
}
- private static class AssignmentUsedAsConditionVisitor
- extends BaseInspectionVisitor {
+ private static class AssignmentUsedAsConditionVisitor extends BaseInspectionVisitor {
@Override
- public void visitAssignmentExpression(
- @NotNull PsiAssignmentExpression expression) {
+ public void visitAssignmentExpression(@NotNull PsiAssignmentExpression expression) {
super.visitAssignmentExpression(expression);
- if (!WellFormednessUtils.isWellFormed(expression)) {
+ if (expression.getRExpression() == null || !(expression.getLExpression() instanceof PsiReferenceExpression)) {
return;
}
final PsiElement parent = expression.getParent();
- if (parent == null) {
+ final PsiExpression condition;
+ if (parent instanceof PsiIfStatement) {
+ final PsiIfStatement ifStatement = (PsiIfStatement)parent;
+ condition = ifStatement.getCondition();
+ }
+ else if (parent instanceof PsiWhileStatement) {
+ final PsiWhileStatement whileStatement = (PsiWhileStatement)parent;
+ condition = whileStatement.getCondition();
+ }
+ else if (parent instanceof PsiForStatement) {
+ final PsiForStatement forStatement = (PsiForStatement)parent;
+ condition = forStatement.getCondition();
+ }
+ else if (parent instanceof PsiDoWhileStatement) {
+ final PsiDoWhileStatement doWhileStatement = (PsiDoWhileStatement)parent;
+ condition = doWhileStatement.getCondition();
+ }
+ else {
return;
}
- if (parent instanceof PsiIfStatement) {
- checkIfStatementCondition((PsiIfStatement)parent, expression);
- }
- if (parent instanceof PsiWhileStatement) {
- checkWhileStatementCondition((PsiWhileStatement)parent,
- expression);
- }
- if (parent instanceof PsiForStatement) {
- checkForStatementCondition((PsiForStatement)parent, expression);
- }
- if (parent instanceof PsiDoWhileStatement) {
- checkDoWhileStatementCondition((PsiDoWhileStatement)parent,
- expression);
- }
- }
-
- private void checkIfStatementCondition(
- PsiIfStatement ifStatement, PsiAssignmentExpression expression) {
- final PsiExpression condition = ifStatement.getCondition();
- if (expression.equals(condition)) {
- registerError(expression);
- }
- }
-
- private void checkDoWhileStatementCondition(
- PsiDoWhileStatement doWhileStatement, PsiAssignmentExpression expression) {
- final PsiExpression condition = doWhileStatement.getCondition();
- if (expression.equals(condition)) {
- registerError(expression);
- }
- }
-
- private void checkForStatementCondition(
- PsiForStatement forStatement, PsiAssignmentExpression expression) {
- final PsiExpression condition = forStatement.getCondition();
- if (expression.equals(condition)) {
- registerError(expression);
- }
- }
-
- private void checkWhileStatementCondition(
- PsiWhileStatement whileStatement, PsiAssignmentExpression expression) {
- final PsiExpression condition = whileStatement.getCondition();
if (expression.equals(condition)) {
registerError(expression);
}
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/EmptyStatementBodyInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/EmptyStatementBodyInspection.java
index 5891045..722c2d1 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/EmptyStatementBodyInspection.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/EmptyStatementBodyInspection.java
@@ -15,23 +15,34 @@
*/
package com.siyeh.ig.bugs;
-import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel;
+import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel;
+import com.intellij.openapi.util.WriteExternalException;
import com.intellij.psi.*;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
import com.siyeh.ig.psiutils.FileTypeUtils;
+import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
public class EmptyStatementBodyInspection extends BaseInspection {
- /**
- * @noinspection PublicField
- */
+ @SuppressWarnings("PublicField")
public boolean m_reportEmptyBlocks = true;
+ @SuppressWarnings("PublicField")
+ public boolean commentsAreContent = false;
+
+ @Override
+ public void writeSettings(@NotNull Element node) throws WriteExternalException {
+ node.addContent(new Element("option").setAttribute("name", "m_reportEmptyBlocks").setAttribute("value", String.valueOf(m_reportEmptyBlocks)));
+ if (commentsAreContent) {
+ node.addContent(new Element("option").setAttribute("name", "commentsAreContent").setAttribute("value", "true"));
+ }
+ }
+
@Override
@NotNull
public String getID() {
@@ -57,8 +68,10 @@
@Override
public JComponent createOptionsPanel() {
- return new SingleCheckboxOptionsPanel(InspectionGadgetsBundle.message("statement.with.empty.body.include.option"),
- this, "m_reportEmptyBlocks");
+ final MultipleCheckboxOptionsPanel panel = new MultipleCheckboxOptionsPanel(this);
+ panel.addCheckbox(InspectionGadgetsBundle.message("statement.with.empty.body.include.option"), "m_reportEmptyBlocks");
+ panel.addCheckbox(InspectionGadgetsBundle.message("empty.catch.block.comments.option"), "commentsAreContent");
+ return panel;
}
@Override
@@ -137,22 +150,36 @@
registerStatementError(statement);
}
- private boolean isEmpty(PsiElement body) {
- if (body instanceof PsiEmptyStatement) {
+ private boolean isEmpty(PsiElement element) {
+ if (!commentsAreContent && element instanceof PsiComment) {
+ return true;
+ } else if (element instanceof PsiEmptyStatement) {
+ if (commentsAreContent) {
+ final PsiElement[] children = element.getChildren();
+ for (PsiElement child : children) {
+ if (child instanceof PsiComment) {
+ return false;
+ }
+ }
+ }
return true;
}
- else if (body instanceof PsiBlockStatement) {
- final PsiBlockStatement block = (PsiBlockStatement)body;
+ else if (element instanceof PsiWhiteSpace) {
+ return true;
+ }
+ else if (element instanceof PsiBlockStatement) {
+ final PsiBlockStatement block = (PsiBlockStatement)element;
return isEmpty(block.getCodeBlock());
}
- else if (m_reportEmptyBlocks && body instanceof PsiCodeBlock) {
- final PsiCodeBlock codeBlock = (PsiCodeBlock)body;
- final PsiStatement[] statements = codeBlock.getStatements();
- if (statements.length == 0) {
+ else if (m_reportEmptyBlocks && element instanceof PsiCodeBlock) {
+ final PsiCodeBlock codeBlock = (PsiCodeBlock)element;
+ final PsiElement[] children = codeBlock.getChildren();
+ if (children.length == 2) {
return true;
}
- for (PsiStatement statement : statements) {
- if (!isEmpty(statement)) {
+ for (int i = 1; i < children.length - 1; i++) {
+ final PsiElement child = children[i];
+ if (!isEmpty(child)) {
return false;
}
}
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/IgnoreResultOfCallInspectionBase.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/IgnoreResultOfCallInspectionBase.java
index f597892..7e197d9 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/IgnoreResultOfCallInspectionBase.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/IgnoreResultOfCallInspectionBase.java
@@ -37,6 +37,7 @@
import java.util.regex.PatternSyntaxException;
public class IgnoreResultOfCallInspectionBase extends BaseInspection {
+
final List<String> methodNamePatterns = new ArrayList();
final List<String> classNames = new ArrayList();
/**
@@ -55,7 +56,9 @@
"java.math.BigDecimal,.*," +
"java.net.InetAddress,.*," +
"java.io.File,.*," +
- "java.lang.Object,equals|hashCode";Map<String, Pattern> patternCache = null;
+ "java.lang.Object,equals|hashCode," +
+ "java.util.regex.Matcher,.*";
+ Map<String, Pattern> patternCache = null;
public IgnoreResultOfCallInspectionBase() {
parseString(callCheckString, classNames, methodNamePatterns);
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/SubtractionInCompareToInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/SubtractionInCompareToInspection.java
index 5e5c2cb..e6e2a83 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/SubtractionInCompareToInspection.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/SubtractionInCompareToInspection.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2011 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2013 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,15 +15,14 @@
*/
package com.siyeh.ig.bugs;
-import com.intellij.psi.JavaTokenType;
-import com.intellij.psi.PsiClass;
-import com.intellij.psi.PsiMethod;
-import com.intellij.psi.PsiPolyadicExpression;
+import com.intellij.psi.*;
import com.intellij.psi.tree.IElementType;
+import com.intellij.psi.util.PsiSuperMethodUtil;
import com.intellij.psi.util.PsiTreeUtil;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
+import com.siyeh.ig.psiutils.ClassUtils;
import com.siyeh.ig.psiutils.MethodUtils;
import org.jetbrains.annotations.NotNull;
@@ -32,15 +31,13 @@
@Override
@NotNull
public String getDisplayName() {
- return InspectionGadgetsBundle.message(
- "subtraction.in.compareto.display.name");
+ return InspectionGadgetsBundle.message("subtraction.in.compareto.display.name");
}
@Override
@NotNull
public String buildErrorString(Object... infos) {
- return InspectionGadgetsBundle.message(
- "subtraction.in.compareto.problem.descriptor");
+ return InspectionGadgetsBundle.message("subtraction.in.compareto.problem.descriptor");
}
@Override
@@ -58,7 +55,20 @@
return;
}
final PsiMethod method = PsiTreeUtil.getParentOfType(expression, PsiMethod.class, true, PsiClass.class);
- if (!MethodUtils.isCompareTo(method)) {
+ if (method == null) {
+ return;
+ }
+ if (MethodUtils.isCompareTo(method)) {
+ registerError(expression);
+ }
+ final PsiClass comparatorClass = ClassUtils.findClass(CommonClassNames.JAVA_UTIL_COMPARATOR, expression);
+ if (comparatorClass == null) {
+ return;
+ }
+ final PsiMethod[] methods = comparatorClass.findMethodsByName("compare", false);
+ assert methods.length == 1;
+ final PsiMethod compareMethod = methods[0];
+ if (!PsiSuperMethodUtil.isSuperMethod(method, compareMethod)) {
return;
}
registerError(expression);
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/classmetrics/CouplingVisitor.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/classmetrics/CouplingVisitor.java
index a277783..9d532e8 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/classmetrics/CouplingVisitor.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/classmetrics/CouplingVisitor.java
@@ -179,7 +179,7 @@
return;
}
}
- if (StringUtil.startsWithConcatenationOf(baseTypeName, qualifiedName, ".")) {
+ if (StringUtil.startsWithConcatenation(baseTypeName, qualifiedName, ".")) {
return;
}
m_dependencies.add(baseTypeName);
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/errorhandling/EmptyCatchBlockInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/errorhandling/EmptyCatchBlockInspection.java
index 479513f..bb6cf98 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/errorhandling/EmptyCatchBlockInspection.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/errorhandling/EmptyCatchBlockInspection.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2012 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2013 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,6 @@
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiUtil;
-import com.intellij.util.IncorrectOperationException;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
@@ -51,15 +50,13 @@
@Override
@NotNull
public String getDisplayName() {
- return InspectionGadgetsBundle.message(
- "empty.catch.block.display.name");
+ return InspectionGadgetsBundle.message("empty.catch.block.display.name");
}
@Override
@NotNull
protected String buildErrorString(Object... infos) {
- return InspectionGadgetsBundle.message(
- "empty.catch.block.problem.descriptor");
+ return InspectionGadgetsBundle.message("empty.catch.block.problem.descriptor");
}
@Override
@@ -69,15 +66,10 @@
@Override
public JComponent createOptionsPanel() {
- final MultipleCheckboxOptionsPanel optionsPanel =
- new MultipleCheckboxOptionsPanel(this);
- optionsPanel.addCheckbox(InspectionGadgetsBundle.message(
- "empty.catch.block.comments.option"), "m_includeComments");
- optionsPanel.addCheckbox(InspectionGadgetsBundle.message(
- "empty.catch.block.ignore.option"), "m_ignoreTestCases");
- optionsPanel.addCheckbox(InspectionGadgetsBundle.message(
- "empty.catch.block.ignore.ignore.option"),
- "m_ignoreIgnoreParameter");
+ final MultipleCheckboxOptionsPanel optionsPanel = new MultipleCheckboxOptionsPanel(this);
+ optionsPanel.addCheckbox(InspectionGadgetsBundle.message("empty.catch.block.comments.option"), "m_includeComments");
+ optionsPanel.addCheckbox(InspectionGadgetsBundle.message("empty.catch.block.ignore.option"), "m_ignoreTestCases");
+ optionsPanel.addCheckbox(InspectionGadgetsBundle.message("empty.catch.block.ignore.ignore.option"), "m_ignoreIgnoreParameter");
return optionsPanel;
}
@@ -92,13 +84,11 @@
@Override
@NotNull
public String getName() {
- return InspectionGadgetsBundle.message(
- "rename.catch.parameter.to.ignored");
+ return InspectionGadgetsBundle.message("rename.catch.parameter.to.ignored");
}
@Override
- protected void doFix(Project project, ProblemDescriptor descriptor)
- throws IncorrectOperationException {
+ protected void doFix(Project project, ProblemDescriptor descriptor) {
final PsiElement element = descriptor.getPsiElement();
final PsiElement parent = element.getParent();
if (!(parent instanceof PsiCatchSection)) {
@@ -113,10 +103,8 @@
if (identifier == null) {
return;
}
- final PsiElementFactory factory =
- JavaPsiFacade.getInstance(project).getElementFactory();
- final PsiIdentifier newIdentifier =
- factory.createIdentifier("ignored");
+ final PsiElementFactory factory = JavaPsiFacade.getInstance(project).getElementFactory();
+ final PsiIdentifier newIdentifier = factory.createIdentifier("ignored");
identifier.replace(newIdentifier);
}
}
@@ -145,7 +133,7 @@
private void checkCatchSection(PsiCatchSection section) {
final PsiCodeBlock block = section.getCatchBlock();
- if (block == null || !isCatchBlockEmpty(block)) {
+ if (block == null || !isEmpty(block)) {
return;
}
final PsiParameter parameter = section.getParameter();
@@ -167,21 +155,39 @@
registerError(catchToken);
}
- private boolean isCatchBlockEmpty(PsiCodeBlock block) {
- if (m_includeComments) {
- final PsiElement[] children = block.getChildren();
- for (final PsiElement child : children) {
- if (child instanceof PsiComment ||
- child instanceof PsiStatement) {
+ private boolean isEmpty(PsiElement element) {
+ if (!m_includeComments && element instanceof PsiComment) {
+ return true;
+ } else if (element instanceof PsiEmptyStatement) {
+ if (m_includeComments) {
+ final PsiElement[] children = element.getChildren();
+ for (PsiElement child : children) {
+ if (child instanceof PsiComment) {
+ return false;
+ }
+ }
+ }
+ return true;
+ } else if (element instanceof PsiWhiteSpace) {
+ return true;
+ } else if (element instanceof PsiBlockStatement) {
+ final PsiBlockStatement block = (PsiBlockStatement)element;
+ return isEmpty(block.getCodeBlock());
+ } else if (element instanceof PsiCodeBlock) {
+ final PsiCodeBlock codeBlock = (PsiCodeBlock)element;
+ final PsiElement[] children = codeBlock.getChildren();
+ if (children.length == 2) {
+ return true;
+ }
+ for (int i = 1; i < children.length - 1; i++) {
+ final PsiElement child = children[i];
+ if (!isEmpty(child)) {
return false;
}
}
return true;
}
- else {
- final PsiStatement[] statements = block.getStatements();
- return statements.length == 0;
- }
+ return false;
}
}
}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/errorhandling/ExceptionFromCatchWhichDoesntWrapInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/errorhandling/ExceptionFromCatchWhichDoesntWrapInspection.java
index 3b609c9..bc92645 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/errorhandling/ExceptionFromCatchWhichDoesntWrapInspection.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/errorhandling/ExceptionFromCatchWhichDoesntWrapInspection.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2012 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2013 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@
import com.intellij.psi.*;
import com.intellij.psi.search.searches.ReferencesSearch;
import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.psi.util.PsiUtil;
import com.intellij.util.Processor;
import com.intellij.util.Query;
import com.siyeh.InspectionGadgetsBundle;
@@ -87,7 +88,7 @@
return;
}
@NonNls final String parameterName = parameter.getName();
- if ("ignore".equals(parameterName) || "ignored".equals(parameterName)) {
+ if (PsiUtil.isIgnoredName(parameterName)) {
return;
}
final PsiExpression exception = statement.getException();
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/methodmetrics/CouplingVisitor.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/methodmetrics/CouplingVisitor.java
index d0a6cfc..eefdcef 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/methodmetrics/CouplingVisitor.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/methodmetrics/CouplingVisitor.java
@@ -151,7 +151,7 @@
baseTypeName.startsWith("javax."))) {
return;
}
- if (StringUtil.startsWithConcatenationOf(baseTypeName, qualifiedName, ".")) {
+ if (StringUtil.startsWithConcatenation(baseTypeName, qualifiedName, ".")) {
return;
}
if (!m_includeLibraryClasses) {
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/numeric/DivideByZeroInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/numeric/DivideByZeroInspection.java
index f178279..2705ac5 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/numeric/DivideByZeroInspection.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/numeric/DivideByZeroInspection.java
@@ -40,8 +40,7 @@
@Override
@NotNull
protected String buildErrorString(Object... infos) {
- return InspectionGadgetsBundle.message(
- "divide.by.zero.problem.descriptor");
+ return InspectionGadgetsBundle.message("divide.by.zero.problem.descriptor");
}
@Override
@@ -76,7 +75,7 @@
return;
}
final IElementType tokenType = expression.getOperationTokenType();
- if (!tokenType.equals(JavaTokenType.DIVEQ) && !tokenType.equals(JavaTokenType.PERCEQ) || isZero(rhs)) {
+ if (!tokenType.equals(JavaTokenType.DIVEQ) && !tokenType.equals(JavaTokenType.PERCEQ) || !isZero(rhs)) {
return;
}
registerError(expression);
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/ClassInitializerMayBeStaticInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/ClassInitializerMayBeStaticInspection.java
index e43f6a8..3ab8bd8 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/ClassInitializerMayBeStaticInspection.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/ClassInitializerMayBeStaticInspection.java
@@ -19,7 +19,7 @@
*/
package com.siyeh.ig.performance;
-import com.intellij.openapi.extensions.ExtensionPoint;
+import com.intellij.codeInspection.InspectionManager;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.extensions.ExtensionsArea;
import com.intellij.openapi.util.Condition;
@@ -74,10 +74,7 @@
if (containingClass == null) {
return;
}
- final ExtensionsArea rootArea = Extensions.getRootArea();
- final ExtensionPoint<Condition<PsiElement>> extensionPoint = rootArea.getExtensionPoint(
- "com.intellij.cantBeStatic");
- final Condition<PsiElement>[] addins = extensionPoint.getExtensions();
+ final Condition<PsiElement>[] addins = InspectionManager.CANT_BE_STATIC_EXTENSION.getExtensions();
for (Condition<PsiElement> addin : addins) {
if (addin.value(initializer)) {
return;
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/InnerClassMayBeStaticInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/InnerClassMayBeStaticInspection.java
index b175055..aac5783 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/InnerClassMayBeStaticInspection.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/InnerClassMayBeStaticInspection.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2011 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2013 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,6 @@
import com.intellij.psi.*;
import com.intellij.psi.search.SearchScope;
import com.intellij.psi.search.searches.ReferencesSearch;
-import com.intellij.util.IncorrectOperationException;
import com.intellij.util.Query;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
@@ -35,15 +34,13 @@
@Override
@NotNull
public String getDisplayName() {
- return InspectionGadgetsBundle.message(
- "inner.class.may.be.static.display.name");
+ return InspectionGadgetsBundle.message("inner.class.may.be.static.display.name");
}
@Override
@NotNull
protected String buildErrorString(Object... infos) {
- return InspectionGadgetsBundle.message(
- "inner.class.may.be.static.problem.descriptor");
+ return InspectionGadgetsBundle.message("inner.class.may.be.static.problem.descriptor");
}
@Override
@@ -65,15 +62,12 @@
}
@Override
- public void doFix(Project project, ProblemDescriptor descriptor)
- throws IncorrectOperationException {
- final PsiJavaToken classNameToken =
- (PsiJavaToken)descriptor.getPsiElement();
+ public void doFix(Project project, ProblemDescriptor descriptor) {
+ final PsiJavaToken classNameToken = (PsiJavaToken)descriptor.getPsiElement();
final PsiClass innerClass = (PsiClass)classNameToken.getParent();
assert innerClass != null;
final SearchScope useScope = innerClass.getUseScope();
- final Query<PsiReference> query =
- ReferencesSearch.search(innerClass, useScope);
+ final Query<PsiReference> query = ReferencesSearch.search(innerClass, useScope);
final Collection<PsiReference> references = query.findAll();
for (final PsiReference reference : references) {
final PsiElement element = reference.getElement();
@@ -81,10 +75,8 @@
if (!(parent instanceof PsiNewExpression)) {
continue;
}
- final PsiNewExpression newExpression =
- (PsiNewExpression)parent;
- final PsiExpression qualifier =
- newExpression.getQualifier();
+ final PsiNewExpression newExpression = (PsiNewExpression)parent;
+ final PsiExpression qualifier = newExpression.getQualifier();
if (qualifier == null) {
continue;
}
@@ -103,15 +95,11 @@
return new InnerClassMayBeStaticVisitor();
}
- private static class InnerClassMayBeStaticVisitor
- extends BaseInspectionVisitor {
+ private static class InnerClassMayBeStaticVisitor extends BaseInspectionVisitor {
@Override
public void visitClass(@NotNull PsiClass aClass) {
- // no call to super, so that it doesn't drill down to inner classes
- if (aClass.getContainingClass() != null &&
- !aClass.hasModifierProperty(PsiModifier.STATIC)) {
- // inner class cannot have static declarations
+ if (aClass.getContainingClass() != null && !aClass.hasModifierProperty(PsiModifier.STATIC)) {
return;
}
if (aClass instanceof PsiAnonymousClass) {
@@ -122,8 +110,7 @@
if (innerClass.hasModifierProperty(PsiModifier.STATIC)) {
continue;
}
- final InnerClassReferenceVisitor visitor =
- new InnerClassReferenceVisitor(innerClass);
+ final InnerClassReferenceVisitor visitor = new InnerClassReferenceVisitor(innerClass);
innerClass.accept(visitor);
if (!visitor.canInnerClassBeStatic()) {
continue;
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/InnerClassReferenceVisitor.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/InnerClassReferenceVisitor.java
index 7a515d0..46aca8e 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/InnerClassReferenceVisitor.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/InnerClassReferenceVisitor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2011 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2013 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,8 +35,7 @@
}
private boolean isClassStaticallyAccessible(PsiClass aClass) {
- if (aClass.getContainingClass() != null &&
- aClass.hasModifierProperty(PsiModifier.STATIC)) {
+ if (aClass.getContainingClass() != null && aClass.hasModifierProperty(PsiModifier.STATIC)) {
if (!PsiTreeUtil.isAncestor(aClass, innerClass, false)) {
return true;
}
@@ -45,11 +44,9 @@
return true;
}
PsiClass classScope = aClass;
- final PsiClass outerClass =
- ClassUtils.getContainingClass(innerClass);
+ final PsiClass outerClass = ClassUtils.getContainingClass(innerClass);
while (classScope != null) {
- if (InheritanceUtil.isInheritorOrSelf(outerClass, classScope,
- true)) {
+ if (InheritanceUtil.isInheritorOrSelf(outerClass, classScope, true)) {
return false;
}
final PsiElement scope = classScope.getScope();
@@ -64,33 +61,29 @@
}
@Override
- public void visitThisExpression(
- @NotNull PsiThisExpression expression) {
+ public void visitThisExpression(@NotNull PsiThisExpression expression) {
if (!referencesStaticallyAccessible) {
return;
}
super.visitThisExpression(expression);
- final PsiJavaCodeReferenceElement qualifier = expression.getQualifier();
- if (isContainingClassQualifier(qualifier)) {
+ if (hasContainingClassQualifier(expression)) {
referencesStaticallyAccessible = false;
}
}
@Override
- public void visitSuperExpression(
- @NotNull PsiSuperExpression expression) {
+ public void visitSuperExpression(@NotNull PsiSuperExpression expression) {
if (!referencesStaticallyAccessible) {
return;
}
super.visitSuperExpression(expression);
- final PsiJavaCodeReferenceElement qualifier = expression.getQualifier();
- if (isContainingClassQualifier(qualifier)) {
+ if (hasContainingClassQualifier(expression)) {
referencesStaticallyAccessible = false;
}
}
- private boolean isContainingClassQualifier(
- PsiJavaCodeReferenceElement qualifier) {
+ private boolean hasContainingClassQualifier(PsiQualifiedExpression expression) {
+ final PsiJavaCodeReferenceElement qualifier = expression.getQualifier();
if (qualifier == null) {
return false;
}
@@ -103,72 +96,58 @@
}
@Override
- public void visitReferenceElement(
- @NotNull PsiJavaCodeReferenceElement reference) {
+ public void visitReferenceElement(@NotNull PsiJavaCodeReferenceElement reference) {
if (!referencesStaticallyAccessible) {
return;
}
final PsiElement parent = reference.getParent();
- if (parent instanceof PsiThisExpression ||
- parent instanceof PsiSuperExpression) {
+ if (parent instanceof PsiThisExpression || parent instanceof PsiSuperExpression) {
return;
}
super.visitReferenceElement(reference);
- final PsiElement element = reference.resolve();
- if (!(element instanceof PsiClass)) {
- return;
- }
- final PsiClass aClass = (PsiClass)element;
- final PsiElement scope = aClass.getScope();
- if (!(scope instanceof PsiClass)) {
- return;
- }
- referencesStaticallyAccessible &=
- aClass.hasModifierProperty(PsiModifier.STATIC);
- }
- @Override
- public void visitReferenceExpression(
- @NotNull PsiReferenceExpression expression) {
- if (!referencesStaticallyAccessible) {
- return;
- }
- super.visitReferenceExpression(expression);
- final PsiExpression qualifier =
- expression.getQualifierExpression();
+ final PsiElement qualifier = reference.getQualifier();
if (qualifier instanceof PsiSuperExpression) {
return;
}
if (qualifier instanceof PsiReferenceExpression) {
- final PsiReferenceExpression referenceExpression =
- (PsiReferenceExpression)qualifier;
+ final PsiReferenceExpression referenceExpression = (PsiReferenceExpression)qualifier;
final PsiElement resolvedExpression = referenceExpression.resolve();
- if (!(resolvedExpression instanceof PsiField) &&
- !(resolvedExpression instanceof PsiMethod)) {
+ if (!(resolvedExpression instanceof PsiField) && !(resolvedExpression instanceof PsiMethod)) {
return;
}
}
- final PsiElement element = expression.resolve();
+ final PsiElement element = reference.resolve();
if (element instanceof PsiMethod || element instanceof PsiField) {
final PsiMember member = (PsiMember)element;
if (member.hasModifierProperty(PsiModifier.STATIC)) {
return;
}
final PsiClass containingClass = member.getContainingClass();
- referencesStaticallyAccessible &=
- isClassStaticallyAccessible(containingClass);
+ if (innerClass.equals(containingClass)) {
+ return;
+ }
+ if (member.hasModifierProperty(PsiModifier.PRIVATE)) {
+ referencesStaticallyAccessible = false;
+ return;
+ }
+ referencesStaticallyAccessible &= isClassStaticallyAccessible(containingClass);
}
- if (element instanceof PsiLocalVariable ||
- element instanceof PsiParameter) {
- final PsiElement containingMethod =
- PsiTreeUtil.getParentOfType(expression,
- PsiMethod.class);
- final PsiElement referencedMethod =
- PsiTreeUtil.getParentOfType(element, PsiMethod.class);
+ else if (element instanceof PsiLocalVariable || element instanceof PsiParameter) {
+ final PsiElement containingMethod = PsiTreeUtil.getParentOfType(reference, PsiMethod.class);
+ final PsiElement referencedMethod = PsiTreeUtil.getParentOfType(element, PsiMethod.class);
if (containingMethod != null && referencedMethod != null &&
!containingMethod.equals(referencedMethod)) {
referencesStaticallyAccessible = false;
}
}
+ else if ((element instanceof PsiClass)) {
+ final PsiClass aClass = (PsiClass)element;
+ final PsiElement scope = aClass.getScope();
+ if (!(scope instanceof PsiClass)) {
+ return;
+ }
+ referencesStaticallyAccessible &= aClass.hasModifierProperty(PsiModifier.STATIC);
+ }
}
}
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/MethodMayBeStaticInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/MethodMayBeStaticInspection.java
index d97ae11..4ff318f 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/MethodMayBeStaticInspection.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/MethodMayBeStaticInspection.java
@@ -15,8 +15,8 @@
*/
package com.siyeh.ig.performance;
+import com.intellij.codeInspection.InspectionManager;
import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel;
-import com.intellij.openapi.extensions.ExtensionPoint;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.extensions.ExtensionsArea;
import com.intellij.openapi.util.Condition;
@@ -98,9 +98,7 @@
if (containingClass == null) {
return;
}
- final ExtensionsArea rootArea = Extensions.getRootArea();
- final ExtensionPoint<Condition<PsiElement>> extensionPoint = rootArea.getExtensionPoint("com.intellij.cantBeStatic");
- final Condition<PsiElement>[] addins = extensionPoint.getExtensions();
+ final Condition<PsiElement>[] addins = InspectionManager.CANT_BE_STATIC_EXTENSION.getExtensions();
for (Condition<PsiElement> addin : addins) {
if (addin.value(method)) {
return;
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/RedundantStringFormatCallInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/RedundantStringFormatCallInspection.java
index ca750e7..957e987 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/RedundantStringFormatCallInspection.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/RedundantStringFormatCallInspection.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2008-2012 Bas Leijdekkers
+ * Copyright 2008-2013 Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,15 +15,15 @@
*/
package com.siyeh.ig.performance;
-import com.intellij.psi.*;
-import com.intellij.openapi.project.Project;
import com.intellij.codeInspection.ProblemDescriptor;
+import com.intellij.openapi.project.Project;
+import com.intellij.psi.*;
import com.intellij.psi.tree.IElementType;
-import com.intellij.util.IncorrectOperationException;
+import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
import com.siyeh.ig.InspectionGadgetsFix;
-import com.siyeh.InspectionGadgetsBundle;
+import com.siyeh.ig.psiutils.FormatUtils;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -48,8 +48,7 @@
return new RedundantStringFormatCallFix();
}
- private static class RedundantStringFormatCallFix
- extends InspectionGadgetsFix {
+ private static class RedundantStringFormatCallFix extends InspectionGadgetsFix {
@Override
@NotNull
@@ -59,7 +58,7 @@
}
@Override
- protected void doFix(Project project, ProblemDescriptor descriptor) throws IncorrectOperationException {
+ protected void doFix(Project project, ProblemDescriptor descriptor) {
final PsiElement element = descriptor.getPsiElement();
final PsiElement parent = element.getParent();
final PsiElement grandParent = parent.getParent();
@@ -108,11 +107,13 @@
}
final PsiExpression firstArgument = arguments[0];
final PsiType firstType = firstArgument.getType();
- if (firstType == null || containsPercentN(firstArgument)) {
+ if (firstType == null) {
return;
}
- if (firstType.equalsToText(CommonClassNames.JAVA_LANG_STRING) && arguments.length == 1) {
- registerMethodCallError(expression);
+ if (firstType.equalsToText(CommonClassNames.JAVA_LANG_STRING)) {
+ if (arguments.length == 1 && !containsPercentN(firstArgument)) {
+ registerMethodCallError(expression);
+ }
}
else if (firstType.equalsToText("java.util.Locale")) {
if (arguments.length != 2) {
@@ -120,12 +121,13 @@
}
final PsiExpression secondArgument = arguments[1];
final PsiType secondType = secondArgument.getType();
- if (secondType == null) {
+ if (secondType == null || !secondType.equalsToText(CommonClassNames.JAVA_LANG_STRING)) {
return;
}
- if (secondType.equalsToText(CommonClassNames.JAVA_LANG_STRING)) {
- registerMethodCallError(expression);
+ if (containsPercentN(secondArgument)) {
+ return;
}
+ registerMethodCallError(expression);
}
}
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/style/StringBufferReplaceableByStringInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/style/StringBufferReplaceableByStringInspection.java
index 2bd6ac9..b8656d6 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/style/StringBufferReplaceableByStringInspection.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/style/StringBufferReplaceableByStringInspection.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2012 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2013 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,11 +27,13 @@
import com.siyeh.ig.InspectionGadgetsFix;
import com.siyeh.ig.psiutils.ParenthesesUtils;
import com.siyeh.ig.psiutils.TypeUtils;
-import com.siyeh.ig.psiutils.VariableAccessUtils;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import java.util.ArrayList;
+import java.util.List;
+
public class StringBufferReplaceableByStringInspection extends BaseInspection {
@Override
@@ -82,8 +84,7 @@
final PsiElement parent = element.getParent();
if (!(parent instanceof PsiVariable)) {
if (parent instanceof PsiNewExpression) {
- final PsiNewExpression newExpression = (PsiNewExpression)parent;
- final PsiExpression stringBuilderExpression = getCompleteExpression(newExpression);
+ final PsiExpression stringBuilderExpression = getCompleteExpression(parent);
final StringBuilder stringExpression = buildStringExpression(stringBuilderExpression, new StringBuilder());
if (stringExpression != null && stringBuilderExpression != null) {
replaceExpression(stringBuilderExpression, stringExpression.toString());
@@ -100,14 +101,41 @@
if (initializer == null) {
return;
}
- final StringBuilder stringExpression = buildStringExpression(initializer, new StringBuilder());
- if (stringExpression == null) {
+ final StringBuilder stringExpression;
+ if (isAppendCall(initializer)) {
+ stringExpression = buildStringExpression(initializer, new StringBuilder());
+ if (stringExpression == null) {
+ return;
+ }
+ } else if (initializer instanceof PsiNewExpression) {
+ final PsiNewExpression newExpression = (PsiNewExpression)initializer;
+ final PsiExpressionList argumentList = newExpression.getArgumentList();
+ if (argumentList == null) {
+ return;
+ }
+ final PsiExpression[] arguments = argumentList.getExpressions();
+ if (arguments.length == 0 || PsiType.INT.equals(arguments[0].getType())) {
+ stringExpression = new StringBuilder();
+ } else {
+ stringExpression = new StringBuilder(arguments[0].getText());
+ }
+ } else {
return;
}
- final PsiClassType javaLangString = TypeUtils.getStringType(variable);
- final PsiTypeElement typeElement = JavaPsiFacade.getElementFactory(project).createTypeElement(javaLangString);
- replaceExpression(initializer, stringExpression.toString());
- originalTypeElement.replace(typeElement);
+ final PsiCodeBlock codeBlock = PsiTreeUtil.getParentOfType(variable, PsiCodeBlock.class);
+ if (codeBlock == null) {
+ return;
+ }
+ final StringBuildingVisitor visitor = new StringBuildingVisitor(variable, stringExpression);
+ codeBlock.accept(visitor);
+ final List<PsiMethodCallExpression> expressions = visitor.getExpressions();
+ variable.delete();
+ for (int i = 0, size = expressions.size() - 1; i < size; i++) {
+ final PsiMethodCallExpression expression = expressions.get(i);
+ expression.getParent().delete();
+ }
+ final PsiMethodCallExpression lastExpression = expressions.get(expressions.size() - 1);
+ replaceExpression(lastExpression, stringExpression.toString());
}
@Nullable
@@ -123,9 +151,14 @@
final PsiExpression argument = arguments[0];
final PsiType type = argument.getType();
if (!PsiType.INT.equals(type)) {
- result.append(argument.getText());
if (type != null && type.equalsToText("java.lang.CharSequence")) {
- result.append(".toString()");
+ result.append("String.valueOf(").append(argument.getText()).append(')');
+ }
+ else if (ParenthesesUtils.getPrecedence(argument) > ParenthesesUtils.ADDITIVE_PRECEDENCE) {
+ result.append('(').append(argument.getText()).append(')');
+ }
+ else {
+ result.append(argument.getText());
}
}
}
@@ -133,7 +166,6 @@
if (result.length() == 0 && parent instanceof PsiVariable) {
result.append("\"\"");
}
- return result;
}
else if (expression instanceof PsiMethodCallExpression) {
final PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression)expression;
@@ -151,8 +183,12 @@
else {
final PsiExpressionList argumentList = methodCallExpression.getArgumentList();
final PsiExpression[] arguments = argumentList.getExpressions();
- if (arguments.length != 1) {
- return null;
+ if (arguments.length > 1) {
+ if (result.length() != 0) {
+ result.append('+');
+ }
+ result.append("String.valueOf").append(argumentList.getText());
+ return result;
}
final PsiExpression argument = arguments[0];
final PsiType type = argument.getType();
@@ -195,9 +231,46 @@
}
}
}
- return result;
}
- return null;
+ return result;
+ }
+
+ private static class StringBuildingVisitor extends JavaRecursiveElementVisitor {
+
+ private PsiVariable myVariable;
+ private StringBuilder myBuilder;
+ private List<PsiMethodCallExpression> expressions = new ArrayList();
+
+ public StringBuildingVisitor(@NotNull PsiVariable variable, StringBuilder builder) {
+ myVariable = variable;
+ myBuilder = builder;
+ }
+
+ @Override
+ public void visitReferenceExpression(PsiReferenceExpression expression) {
+ super.visitReferenceExpression(expression);
+ if (expression.getQualifierExpression() != null) {
+ return;
+ }
+ final PsiElement target = expression.resolve();
+ if (!myVariable.equals(target)) {
+ return;
+ }
+ PsiMethodCallExpression methodCallExpression = null;
+ PsiElement parent = expression.getParent();
+ PsiElement grandParent = parent.getParent();
+ while (parent instanceof PsiReferenceExpression && grandParent instanceof PsiMethodCallExpression) {
+ methodCallExpression = (PsiMethodCallExpression)grandParent;
+ parent = methodCallExpression.getParent();
+ grandParent = parent.getParent();
+ }
+ buildStringExpression(methodCallExpression, myBuilder);
+ expressions.add(methodCallExpression);
+ }
+
+ public List<PsiMethodCallExpression> getExpressions() {
+ return expressions;
+ }
}
}
@@ -221,25 +294,12 @@
return;
}
final PsiExpression initializer = variable.getInitializer();
- if (initializer == null) {
- return;
- }
if (!isNewStringBufferOrStringBuilder(initializer)) {
return;
}
- if (VariableAccessUtils.variableIsAssigned(variable, codeBlock)) {
- return;
- }
- if (VariableAccessUtils.variableIsAssignedFrom(variable, codeBlock)) {
- return;
- }
- if (VariableAccessUtils.variableIsReturned(variable, codeBlock)) {
- return;
- }
- if (VariableAccessUtils.variableIsPassedAsMethodArgument(variable, codeBlock)) {
- return;
- }
- if (variableIsModified(variable, codeBlock)) {
+ final ReplaceableByStringVisitor visitor = new ReplaceableByStringVisitor(variable);
+ codeBlock.accept(visitor);
+ if (!visitor.isReplaceable()) {
return;
}
registerVariableError(variable, variable, type);
@@ -260,66 +320,71 @@
registerNewExpressionError(expression, expression, type);
}
- public static boolean variableIsModified(PsiVariable variable, PsiElement context) {
- final VariableIsModifiedVisitor visitor = new VariableIsModifiedVisitor(variable);
- context.accept(visitor);
- return visitor.isModified();
- }
-
private static boolean isNewStringBufferOrStringBuilder(PsiExpression expression) {
if (expression == null) {
return false;
}
- else if (expression instanceof PsiNewExpression) {
+ if (expression instanceof PsiNewExpression) {
return true;
}
- else if (expression instanceof PsiMethodCallExpression) {
- final PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression)expression;
- if (!isAppend(methodCallExpression)) {
- return false;
- }
- final PsiReferenceExpression methodExpression = methodCallExpression.getMethodExpression();
- final PsiExpression qualifier = methodExpression.getQualifierExpression();
- return isNewStringBufferOrStringBuilder(qualifier);
+ if (!isAppendCall(expression) || !(expression instanceof PsiMethodCallExpression)) {
+ return false;
}
- return false;
- }
-
- public static boolean isAppend(PsiMethodCallExpression methodCallExpression) {
+ final PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression)expression;
final PsiReferenceExpression methodExpression = methodCallExpression.getMethodExpression();
- @NonNls final String methodName = methodExpression.getReferenceName();
- return "append".equals(methodName);
+ final PsiExpression qualifier = methodExpression.getQualifierExpression();
+ return isNewStringBufferOrStringBuilder(qualifier);
}
}
+ public static boolean isAppendCall(PsiElement element) {
+ if (!(element instanceof PsiMethodCallExpression)) {
+ return false;
+ }
+ final PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression)element;
+ final PsiReferenceExpression methodExpression = methodCallExpression.getMethodExpression();
+ @NonNls final String methodName = methodExpression.getReferenceName();
+ if (!"append".equals(methodName)) {
+ return false;
+ }
+ final PsiExpressionList argumentList = methodCallExpression.getArgumentList();
+ final PsiExpression[] arguments = argumentList.getExpressions();
+ if (arguments.length == 3) {
+ return arguments[0].getType() instanceof PsiArrayType &&
+ arguments[1].getType() == PsiType.INT && arguments[2].getType() == PsiType.INT;
+ }
+ return arguments.length == 1;
+ }
+
+ public static boolean isToStringCall(PsiElement element) {
+ if (!(element instanceof PsiMethodCallExpression)) {
+ return false;
+ }
+ final PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression)element;
+ final PsiReferenceExpression methodExpression = methodCallExpression.getMethodExpression();
+ @NonNls final String methodName = methodExpression.getReferenceName();
+ if (!"toString".equals(methodName)) {
+ return false;
+ }
+ final PsiExpressionList argumentList = methodCallExpression.getArgumentList();
+ final PsiExpression[] arguments = argumentList.getExpressions();
+ return arguments.length == 0;
+ }
+
@Nullable
- private static PsiExpression getCompleteExpression(PsiNewExpression expression) {
- PsiElement completeExpression = expression;
+ private static PsiExpression getCompleteExpression(PsiElement element) {
+ PsiElement completeExpression = element;
boolean found = false;
while (true) {
final PsiElement parent = completeExpression.getParent();
if (!(parent instanceof PsiReferenceExpression)) {
break;
}
- final PsiReferenceExpression referenceExpression = (PsiReferenceExpression)parent;
final PsiElement grandParent = parent.getParent();
- if (!(grandParent instanceof PsiMethodCallExpression)) {
- break;
- }
- @NonNls final String name = referenceExpression.getReferenceName();
- if ("append".equals(name)) {
- final PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression)grandParent;
- final PsiExpressionList argumentList = methodCallExpression.getArgumentList();
- final PsiExpression[] arguments = argumentList.getExpressions();
- if (arguments.length != 1) {
- return null;
- }
- }
- else {
- if (!"toString".equals(name)) {
- return null;
- }
+ if (isToStringCall(grandParent)) {
found = true;
+ } else if (!isAppendCall(grandParent)) {
+ return null;
}
completeExpression = grandParent;
if (found) {
@@ -328,4 +393,98 @@
}
return null;
}
+
+ private static class ReplaceableByStringVisitor extends JavaRecursiveElementVisitor {
+
+ private final PsiCodeBlock myCodeBlock;
+ private PsiVariable myVariable;
+ private boolean myReplaceable = true;
+ private boolean myToStringFound = false;
+
+ public ReplaceableByStringVisitor(@NotNull PsiVariable variable) {
+ myVariable = variable;
+ myCodeBlock = PsiTreeUtil.getParentOfType(variable, PsiCodeBlock.class);
+ }
+
+ public boolean isReplaceable() {
+ return myReplaceable && myToStringFound;
+ }
+
+ @Override
+ public void visitElement(PsiElement element) {
+ if (!myReplaceable) {
+ return;
+ }
+ super.visitElement(element);
+ }
+
+ @Override
+ public void visitAssignmentExpression(PsiAssignmentExpression expression) {
+ super.visitAssignmentExpression(expression);
+ if (expression.getTextOffset() > myVariable.getTextOffset() && !myToStringFound) {
+ myReplaceable = false;
+ }
+ }
+
+ @Override
+ public void visitPostfixExpression(PsiPostfixExpression expression) {
+ super.visitPostfixExpression(expression);
+ if (expression.getTextOffset() > myVariable.getTextOffset() && !myToStringFound) {
+ myReplaceable = false;
+ }
+ }
+
+ @Override
+ public void visitPrefixExpression(PsiPrefixExpression expression) {
+ super.visitPrefixExpression(expression);
+ if (expression.getTextOffset() > myVariable.getTextOffset() && !myToStringFound) {
+ myReplaceable = false;
+ }
+ }
+
+ @Override
+ public void visitReferenceExpression(PsiReferenceExpression expression) {
+ if (!myReplaceable || expression.getTextOffset() < myVariable.getTextOffset()) {
+ return;
+ }
+ super.visitReferenceExpression(expression);
+ final PsiExpression qualifier = expression.getQualifierExpression();
+ if (qualifier != null) {
+ return;
+ }
+ final PsiElement target = expression.resolve();
+ if (!myVariable.equals(target)) {
+ return;
+ }
+ if (myToStringFound) {
+ myReplaceable = false;
+ return;
+ }
+ final PsiCodeBlock codeBlock = PsiTreeUtil.getParentOfType(expression, PsiCodeBlock.class);
+ if (!myCodeBlock.equals(codeBlock)) {
+ myReplaceable = false;
+ return;
+ }
+ PsiElement parent = expression.getParent();
+ while (true) {
+ if (!(parent instanceof PsiReferenceExpression)) {
+ myReplaceable = false;
+ return;
+ }
+ final PsiElement grandParent = parent.getParent();
+ if (!isAppendCall(grandParent)) {
+ if (!isToStringCall(grandParent)) {
+ myReplaceable = false;
+ return;
+ }
+ myToStringFound = true;
+ return;
+ }
+ parent = grandParent.getParent();
+ if (parent instanceof PsiExpressionStatement) {
+ return;
+ }
+ }
+ }
+ }
}
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/style/UnnecessaryCallToStringValueOfInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/style/UnnecessaryCallToStringValueOfInspection.java
index b8c0394..8544595 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/style/UnnecessaryCallToStringValueOfInspection.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/style/UnnecessaryCallToStringValueOfInspection.java
@@ -26,6 +26,7 @@
import com.siyeh.ig.psiutils.ParenthesesUtils;
import com.siyeh.ig.psiutils.TypeUtils;
import org.jetbrains.annotations.Nls;
+import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -101,7 +102,7 @@
public void visitMethodCallExpression(PsiMethodCallExpression expression) {
super.visitMethodCallExpression(expression);
final PsiReferenceExpression methodExpression = expression.getMethodExpression();
- final String referenceName = methodExpression.getReferenceName();
+ @NonNls final String referenceName = methodExpression.getReferenceName();
if (!"valueOf".equals(referenceName)) {
return;
}
@@ -137,7 +138,7 @@
registerError(expression, calculateReplacementText(argument));
}
- private boolean isCallToStringValueOfNecessary(PsiMethodCallExpression expression) {
+ private static boolean isCallToStringValueOfNecessary(PsiMethodCallExpression expression) {
final PsiElement parent = ParenthesesUtils.getParentSkipParentheses(expression);
if (parent instanceof PsiPolyadicExpression) {
final PsiPolyadicExpression polyadicExpression = (PsiPolyadicExpression)parent;
@@ -172,7 +173,7 @@
}
final PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression)grandParent;
final PsiReferenceExpression methodExpression1 = methodCallExpression.getMethodExpression();
- final String name = methodExpression1.getReferenceName();
+ @NonNls final String name = methodExpression1.getReferenceName();
final PsiExpression[] expressions = expressionList.getExpressions();
if ("insert".equals(name)) {
if (expressions.length < 2 || !expression.equals(ParenthesesUtils.stripParentheses(expressions[1]))) {
@@ -193,6 +194,8 @@
if (!isCallToMethodIn(methodCallExpression, "java.io.PrintStream", "java.io.PrintWriter")) {
return true;
}
+ } else {
+ return true;
}
} else {
return true;
@@ -200,7 +203,7 @@
return false;
}
- private boolean isCallToMethodIn(PsiMethodCallExpression methodCallExpression, String... classNames) {
+ private static boolean isCallToMethodIn(PsiMethodCallExpression methodCallExpression, String... classNames) {
final PsiMethod method = methodCallExpression.resolveMethod();
if (method == null) {
return false;
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/style/VariableIsModifiedVisitor.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/style/VariableIsModifiedVisitor.java
deleted file mode 100644
index 748ce1b..0000000
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/style/VariableIsModifiedVisitor.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2003-2012 Dave Griffith, Bas Leijdekkers
- *
- * 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.siyeh.ig.style;
-
-import com.intellij.psi.*;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.HashSet;
-import java.util.Set;
-
-class VariableIsModifiedVisitor extends JavaRecursiveElementVisitor {
-
- @NonNls private static final Set<String> updateNames = new HashSet<String>(9);
-
- static {
- updateNames.add("append");
- updateNames.add("appendCodePoint");
- updateNames.add("capacity"); // does not strictly modify, but is not a String method
- updateNames.add("delete");
- updateNames.add("deleteCharAt");
- updateNames.add("ensureCapacity"); // does not strictly modify, but is not a String method
- updateNames.add("insert");
- updateNames.add("replace");
- updateNames.add("reverse");
- updateNames.add("setCharAt");
- updateNames.add("setLength");
- }
-
- private boolean modified = false;
- private final PsiVariable variable;
-
- VariableIsModifiedVisitor(PsiVariable variable) {
- this.variable = variable;
- }
-
- @Override
- public void visitElement(@NotNull PsiElement element) {
- if (!modified) {
- super.visitElement(element);
- }
- }
-
- @Override
- public void visitMethodCallExpression(
- @NotNull PsiMethodCallExpression call) {
- if (modified) {
- return;
- }
- super.visitMethodCallExpression(call);
- if (!isStringBufferUpdate(call)) {
- return;
- }
- final PsiReferenceExpression methodExpression = call.getMethodExpression();
- final PsiExpression qualifier = methodExpression.getQualifierExpression();
- if (!(qualifier instanceof PsiReferenceExpression)) {
- return;
- }
- final PsiReferenceExpression reference = (PsiReferenceExpression)qualifier;
- final PsiElement referent = reference.resolve();
- if (variable.equals(referent)) {
- modified = true;
- }
- }
-
- public static boolean isStringBufferUpdate(@Nullable PsiMethodCallExpression methodCallExpression) {
- if (methodCallExpression == null) {
- return false;
- }
- final PsiReferenceExpression methodExpression = methodCallExpression.getMethodExpression();
- final String methodName = methodExpression.getReferenceName();
- return updateNames.contains(methodName);
- }
-
- public boolean isModified() {
- return modified;
- }
-}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/com/intellij/codeInspection/booleanIsAlwaysInverted/BooleanMethodIsAlwaysInvertedInspection.java b/plugins/InspectionGadgets/src/com/intellij/codeInspection/booleanIsAlwaysInverted/BooleanMethodIsAlwaysInvertedInspection.java
index 48a5a9d..f269175 100644
--- a/plugins/InspectionGadgets/src/com/intellij/codeInspection/booleanIsAlwaysInverted/BooleanMethodIsAlwaysInvertedInspection.java
+++ b/plugins/InspectionGadgets/src/com/intellij/codeInspection/booleanIsAlwaysInverted/BooleanMethodIsAlwaysInvertedInspection.java
@@ -87,7 +87,8 @@
}
@Override
- protected boolean queryExternalUsagesRequests(@NotNull final RefManager manager, @NotNull final GlobalJavaInspectionContext context,
+ protected boolean queryExternalUsagesRequests(@NotNull final RefManager manager,
+ @NotNull final GlobalJavaInspectionContext context,
@NotNull final ProblemDescriptionsProcessor descriptionsProcessor) {
manager.iterate(new RefJavaVisitor() {
@Override
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/dataflow/UnnecessaryLocalVariableInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/dataflow/UnnecessaryLocalVariableInspection.java
index 483e9f3..5da5ba2 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/dataflow/UnnecessaryLocalVariableInspection.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/dataflow/UnnecessaryLocalVariableInspection.java
@@ -25,6 +25,7 @@
import com.siyeh.ig.BaseInspectionVisitor;
import com.siyeh.ig.InspectionGadgetsFix;
import com.siyeh.ig.fixes.InlineVariableFix;
+import com.siyeh.ig.psiutils.ParenthesesUtils;
import com.siyeh.ig.psiutils.VariableAccessUtils;
import org.jetbrains.annotations.NotNull;
@@ -114,7 +115,7 @@
}
private boolean isCopyVariable(PsiVariable variable) {
- final PsiExpression initializer = variable.getInitializer();
+ final PsiExpression initializer = ParenthesesUtils.stripParentheses(variable.getInitializer());
if (!(initializer instanceof PsiReferenceExpression)) {
return false;
}
@@ -126,6 +127,9 @@
if (!(referent instanceof PsiLocalVariable || referent instanceof PsiParameter)) {
return false;
}
+ if (!(referent instanceof PsiResourceVariable) && variable instanceof PsiResourceVariable) {
+ return false;
+ }
final PsiCodeBlock containingScope = PsiTreeUtil.getParentOfType(variable, PsiCodeBlock.class);
if (containingScope == null) {
return false;
@@ -169,7 +173,7 @@
return false;
}
final PsiReturnStatement returnStatement = (PsiReturnStatement)nextStatement;
- final PsiExpression returnValue = returnStatement.getReturnValue();
+ final PsiExpression returnValue = ParenthesesUtils.stripParentheses(returnStatement.getReturnValue());
if (!(returnValue instanceof PsiReferenceExpression)) {
return false;
}
@@ -178,10 +182,7 @@
if (referent == null || !referent.equals(variable)) {
return false;
}
- if (isVariableUsedInFollowingDeclarations(variable, declarationStatement)) {
- return false;
- }
- return true;
+ return !isVariableUsedInFollowingDeclarations(variable, declarationStatement);
}
private boolean isImmediatelyThrown(PsiVariable variable) {
@@ -206,7 +207,7 @@
return false;
}
final PsiThrowStatement throwStatement = (PsiThrowStatement)nextStatement;
- final PsiExpression returnValue = throwStatement.getException();
+ final PsiExpression returnValue = ParenthesesUtils.stripParentheses(throwStatement.getException());
if (!(returnValue instanceof PsiReferenceExpression)) {
return false;
}
@@ -214,10 +215,7 @@
if (referent == null || !referent.equals(variable)) {
return false;
}
- if (isVariableUsedInFollowingDeclarations(variable, declarationStatement)) {
- return false;
- }
- return true;
+ return !isVariableUsedInFollowingDeclarations(variable, declarationStatement);
}
private boolean isImmediatelyAssigned(PsiVariable variable) {
@@ -253,7 +251,7 @@
if (tokenType != JavaTokenType.EQ) {
return false;
}
- final PsiExpression rhs = assignmentExpression.getRExpression();
+ final PsiExpression rhs = ParenthesesUtils.stripParentheses(assignmentExpression.getRExpression());
if (!(rhs instanceof PsiReferenceExpression)) {
return false;
}
@@ -305,7 +303,7 @@
continue;
}
final PsiVariable nextVariable = (PsiVariable)declaration;
- final PsiExpression initializer = nextVariable.getInitializer();
+ final PsiExpression initializer = ParenthesesUtils.stripParentheses(nextVariable.getInitializer());
if (!referenceFound && initializer instanceof PsiReferenceExpression) {
final PsiReferenceExpression referenceExpression = (PsiReferenceExpression)initializer;
final PsiElement referent = referenceExpression.resolve();
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/UnusedCatchParameterInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/UnusedCatchParameterInspection.java
index 7d68417..d217e84 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/UnusedCatchParameterInspection.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/UnusedCatchParameterInspection.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2012 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2013 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel;
import com.intellij.psi.*;
+import com.intellij.psi.util.PsiUtil;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
@@ -108,7 +109,6 @@
return;
}
@NonNls final String parameterName = parameter.getName();
- final boolean namedIgnore = parameterName.contains("ignore");
final PsiCodeBlock block = section.getCatchBlock();
if (block == null) {
return;
@@ -124,6 +124,7 @@
final CatchParameterUsedVisitor visitor =
new CatchParameterUsedVisitor(parameter);
block.accept(visitor);
+ final boolean namedIgnore = PsiUtil.isIgnoredName(parameterName);
if (visitor.isUsed()) {
if (namedIgnore) {
registerVariableError(parameter, Boolean.valueOf(true));
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/fixes/InlineVariableFix.java b/plugins/InspectionGadgets/src/com/siyeh/ig/fixes/InlineVariableFix.java
index 91f20b5..5bdf57b 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/fixes/InlineVariableFix.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/fixes/InlineVariableFix.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2011 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2013 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,10 +18,8 @@
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
-import com.intellij.psi.search.LocalSearchScope;
import com.intellij.psi.search.searches.ReferencesSearch;
-import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.util.Query;
+import com.intellij.refactoring.util.InlineUtil;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.InspectionGadgetsFix;
import com.siyeh.ig.psiutils.HighlightUtils;
@@ -41,36 +39,16 @@
@Override
public void doFix(@NotNull final Project project, final ProblemDescriptor descriptor) {
final PsiElement nameElement = descriptor.getPsiElement();
- final PsiLocalVariable variable =
- (PsiLocalVariable)nameElement.getParent();
- PsiExpression initializer = variable.getInitializer();
+ final PsiLocalVariable variable = (PsiLocalVariable)nameElement.getParent();
+ final PsiExpression initializer = variable.getInitializer();
if (initializer == null) {
return;
}
- if (initializer instanceof PsiArrayInitializerExpression) {
- final PsiElementFactory factory =
- JavaPsiFacade.getElementFactory(project);
- final PsiType type = initializer.getType();
- final String typeText;
- if (type == null) {
- typeText = "";
- }
- else {
- typeText = type.getCanonicalText();
- }
- initializer = factory.createExpressionFromText("new " + typeText +
- initializer.getText(), variable);
- }
- final PsiMember member =
- PsiTreeUtil.getParentOfType(variable, PsiMember.class);
- final Query<PsiReference> search =
- ReferencesSearch.search(variable, new LocalSearchScope(member));
+ final Collection<PsiReference> references = ReferencesSearch.search(variable).findAll();
final Collection<PsiElement> replacedElements = new ArrayList<PsiElement>();
- final Collection<PsiReference> references = search.findAll();
for (PsiReference reference : references) {
- final PsiElement replacedElement =
- reference.getElement().replace(initializer);
- replacedElements.add(replacedElement);
+ final PsiExpression expression = InlineUtil.inlineVariable(variable, initializer, (PsiJavaCodeReferenceElement)reference);
+ replacedElements.add(expression);
}
HighlightUtils.highlightElements(replacedElements);
variable.delete();
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/logging/StringConcatenationArgumentToLogCallInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/logging/StringConcatenationArgumentToLogCallInspection.java
index 4c96475..5169392 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/logging/StringConcatenationArgumentToLogCallInspection.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/logging/StringConcatenationArgumentToLogCallInspection.java
@@ -76,13 +76,12 @@
private static class StringConcatenationArgumentToLogCallFix extends InspectionGadgetsFix {
-
public StringConcatenationArgumentToLogCallFix() {}
@NotNull
@Override
public String getName() {
- return InspectionGadgetsBundle.message("string.concatenation.in.format.call.quickfix");
+ return InspectionGadgetsBundle.message("string.concatenation.argument.to.log.call.quickfix");
}
@Override
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/ConventionInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/ConventionInspection.java
index 10d8135..ddba1dc 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/naming/ConventionInspection.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/naming/ConventionInspection.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2011 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2013 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,8 +44,6 @@
public abstract class ConventionInspection extends BaseInspection {
/**
- * public fields for the DefaultJDomExternalizer
- *
* @noinspection PublicField
*/
public String m_regex = getDefaultRegex();
@@ -83,7 +81,7 @@
if (length < m_minLength) {
return false;
}
- if (length > m_maxLength) {
+ if (m_maxLength > 0 && length > m_maxLength) {
return false;
}
if (HardcodedMethodConstants.SERIAL_VERSION_UID.equals(name)) {
@@ -99,8 +97,6 @@
m_regexPattern = Pattern.compile(m_regex);
}
- private static final int REGEX_COLUMN_COUNT = 25;
-
public Collection<? extends JComponent> createExtraOptions() {
return Collections.emptyList();
}
@@ -110,42 +106,37 @@
final GridBagLayout layout = new GridBagLayout();
final JPanel panel = new JPanel(layout);
- final JLabel patternLabel = new JLabel(
- InspectionGadgetsBundle.message("convention.pattern.option"));
- final JLabel minLengthLabel = new JLabel(
- InspectionGadgetsBundle.message("convention.min.length.option"));
- final JLabel maxLengthLabel = new JLabel(
- InspectionGadgetsBundle.message("convention.max.length.option"));
+ final JLabel patternLabel = new JLabel(InspectionGadgetsBundle.message("convention.pattern.option"));
+ final JLabel minLengthLabel = new JLabel(InspectionGadgetsBundle.message("convention.min.length.option"));
+ final JLabel maxLengthLabel = new JLabel(InspectionGadgetsBundle.message("convention.max.length.option"));
final NumberFormat numberFormat = NumberFormat.getIntegerInstance();
numberFormat.setParseIntegerOnly(true);
numberFormat.setMinimumIntegerDigits(1);
- numberFormat.setMaximumIntegerDigits(2);
- final InternationalFormatter formatter =
- new InternationalFormatter(numberFormat);
+ numberFormat.setMaximumIntegerDigits(3);
+ final InternationalFormatter formatter = new InternationalFormatter(numberFormat);
formatter.setAllowsInvalid(true);
- formatter.setCommitsOnValidEdit(true);
+ formatter.setCommitsOnValidEdit(false);
+ formatter.setMinimum(Integer.valueOf(0));
+ formatter.setMaximum(Integer.valueOf(999));
- final JFormattedTextField minLengthField =
- new JFormattedTextField(formatter);
+ final JFormattedTextField minLengthField = new JFormattedTextField(formatter);
final Font panelFont = panel.getFont();
minLengthField.setFont(panelFont);
minLengthField.setValue(Integer.valueOf(m_minLength));
minLengthField.setColumns(2);
UIUtil.fixFormattedField(minLengthField);
- final JFormattedTextField maxLengthField =
- new JFormattedTextField(formatter);
+ final JFormattedTextField maxLengthField = new JFormattedTextField(formatter);
maxLengthField.setFont(panelFont);
maxLengthField.setValue(Integer.valueOf(m_maxLength));
maxLengthField.setColumns(2);
UIUtil.fixFormattedField(minLengthField);
- final JFormattedTextField regexField =
- new JFormattedTextField(new RegExFormatter());
+ final JFormattedTextField regexField = new JFormattedTextField(new RegExFormatter());
regexField.setFont(panelFont);
regexField.setValue(m_regexPattern);
- regexField.setColumns(REGEX_COLUMN_COUNT);
+ regexField.setColumns(25);
regexField.setInputVerifier(new RegExInputVerifier());
regexField.setFocusLostBehavior(JFormattedTextField.COMMIT);
UIUtil.fixFormattedField(minLengthField);
@@ -212,8 +203,7 @@
constraints.insets.right = 0;
panel.add(maxLengthField, constraints);
- final Collection<? extends JComponent> extraOptions =
- createExtraOptions();
+ final Collection<? extends JComponent> extraOptions = createExtraOptions();
constraints.gridx = 0;
constraints.gridwidth = 2;
for (JComponent extraOption : extraOptions) {
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AbsoluteAlignmentInUserInterface.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AbsoluteAlignmentInUserInterface.html
index ad23d15..5acbdb9 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AbsoluteAlignmentInUserInterface.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AbsoluteAlignmentInUserInterface.html
@@ -4,6 +4,6 @@
relative alignment, because it respects locale component orientation settings.
<!-- tooltip end -->
<p>
-<small>New in 11, Powered by InspectionGadgets</small>
+<small>New in 11</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractClassExtendsConcreteClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractClassExtendsConcreteClass.html
index f7e86c1..cefaccd 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractClassExtendsConcreteClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractClassExtendsConcreteClass.html
@@ -3,6 +3,6 @@
Reports abstract classes which extend concrete classes.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractClassNeverImplemented.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractClassNeverImplemented.html
index ce076a4..1cce35b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractClassNeverImplemented.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractClassNeverImplemented.html
@@ -4,6 +4,6 @@
concrete subclasses.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractClassWithOnlyOneDirectInheritor.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractClassWithOnlyOneDirectInheritor.html
index 41f07bb..f4c4d23 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractClassWithOnlyOneDirectInheritor.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractClassWithOnlyOneDirectInheritor.html
@@ -9,6 +9,6 @@
the total footprint of the application. Consider merging the abstract class with its inheritor.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractClassWithoutAbstractMethods.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractClassWithoutAbstractMethods.html
index 39fff09..cd3a13e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractClassWithoutAbstractMethods.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractClassWithoutAbstractMethods.html
@@ -3,6 +3,6 @@
Reports abstract classes without abstract methods.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractMethodCallInConstructor.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractMethodCallInConstructor.html
index 2910142..95956bf 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractMethodCallInConstructor.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractMethodCallInConstructor.html
@@ -12,6 +12,6 @@
<i>Abstract method called during object construction</i> report overlapping problem sets and only one should be enabled at a time
to prevent duplicate warnings.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractMethodOverridesAbstractMethod.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractMethodOverridesAbstractMethod.html
index 4c12187..3664524 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractMethodOverridesAbstractMethod.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractMethodOverridesAbstractMethod.html
@@ -9,6 +9,6 @@
<p>
Use the second checkbox to ignore any abstract methods that have one or more annotations that are not present on their super method.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractMethodOverridesConcreteMethod.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractMethodOverridesConcreteMethod.html
index 9a2e3bd..b0d8233 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractMethodOverridesConcreteMethod.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractMethodOverridesConcreteMethod.html
@@ -5,6 +5,6 @@
by this inspection.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractMethodWithMissingImplementations.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractMethodWithMissingImplementations.html
index 334f803..486da33 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractMethodWithMissingImplementations.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AbstractMethodWithMissingImplementations.html
@@ -5,6 +5,6 @@
reports the problem at the point of the abstract method.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AccessToNonThreadSafeStaticFieldFromInstance.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AccessToNonThreadSafeStaticFieldFromInstance.html
index 6ecb309..2288f1b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AccessToNonThreadSafeStaticFieldFromInstance.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AccessToNonThreadSafeStaticFieldFromInstance.html
@@ -6,6 +6,6 @@
multiple threads, which can lead to unspecified side effects.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AccessToStaticFieldLockedOnInstance.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AccessToStaticFieldLockedOnInstance.html
index 7231f59..7ecfdae 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AccessToStaticFieldLockedOnInstance.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AccessToStaticFieldLockedOnInstance.html
@@ -8,6 +8,6 @@
<p>
Use the table below to specify classes to ignore. Any static fields of the types specified will be ignored by this inspection.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AmbiguousFieldAccess.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AmbiguousFieldAccess.html
index 50f4848..67f0068 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AmbiguousFieldAccess.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AmbiguousFieldAccess.html
@@ -19,6 +19,6 @@
</code></pre>
<!-- tooltip end -->
<p>
-<small>New in 11, Powered by InspectionGadgets</small>
+<small>New in 11</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AmbiguousMethodCall.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AmbiguousMethodCall.html
index 82b3a24..ef7dc8a 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AmbiguousMethodCall.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AmbiguousMethodCall.html
@@ -8,6 +8,6 @@
<b>super</b> qualifier to the method call.
<!-- tooltip end -->
<p>
-<small>New in 8, Powered by InspectionGadgets</small>
+<small>New in 8</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/Annotation.html b/plugins/InspectionGadgets/src/inspectionDescriptions/Annotation.html
index 9892b6e..0787d47 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/Annotation.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/Annotation.html
@@ -4,6 +4,6 @@
Annotations are not supported under Java 1.4 or earlier JVMs.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AnnotationClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AnnotationClass.html
index 6bad5d4..800e759 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AnnotationClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AnnotationClass.html
@@ -4,6 +4,6 @@
Such interfaces are not supported under Java 1.4 or earlier JVMs.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AnnotationNamingConvention.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AnnotationNamingConvention.html
index db2187b..a99f2d9 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AnnotationNamingConvention.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AnnotationNamingConvention.html
@@ -5,8 +5,8 @@
<!-- tooltip end -->
<p>
Use the fields below to specify minimum length, maximum length and regular expression expected for annotation names.
-(Regular expressions are in standard <b>java.util.regex</b> format.)
+Specify <b>0</b> to not check the length of names. Regular expressions are in standard <b>java.util.regex</b> format.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AnonymousClassComplexity.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AnonymousClassComplexity.html
index ba9645b..f170492 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AnonymousClassComplexity.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AnonymousClassComplexity.html
@@ -9,6 +9,6 @@
<p>
Use the field below to specify the maximum complexity a class is allowed to have.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AnonymousClassMethodCount.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AnonymousClassMethodCount.html
index 562dcd0..b3859bf 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AnonymousClassMethodCount.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AnonymousClassMethodCount.html
@@ -7,6 +7,6 @@
<p>
Use the field below to specify the maximum number of methods an anonymous inner <b>class</b> is allowed to have.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AnonymousClassVariableHidesContainingMethodVariable.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AnonymousClassVariableHidesContainingMethodVariable.html
index fd91e73..36ebac3 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AnonymousClassVariableHidesContainingMethodVariable.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AnonymousClassVariableHidesContainingMethodVariable.html
@@ -4,6 +4,6 @@
Such a variable name may be confusing.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AnonymousInnerClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AnonymousInnerClass.html
index 48a5568..238300f 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AnonymousInnerClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AnonymousInnerClass.html
@@ -4,6 +4,6 @@
Some code standards discourage the use of anonymous inner classes.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AnonymousInnerClassMayBeStatic.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AnonymousInnerClassMayBeStatic.html
index 800c584..9311966 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AnonymousInnerClassMayBeStatic.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AnonymousInnerClassMayBeStatic.html
@@ -8,6 +8,6 @@
its enclosing class instance or local variables. A static inner class uses slightly less memory.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ArchaicSystemPropertyAccess.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ArchaicSystemPropertyAccess.html
index 593c93c..3a15c30 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ArchaicSystemPropertyAccess.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ArchaicSystemPropertyAccess.html
@@ -7,6 +7,6 @@
for other purposes, such as string parsing.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ArrayEquality.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ArrayEquality.html
index 253ad5b..2b0e729 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ArrayEquality.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ArrayEquality.html
@@ -4,6 +4,6 @@
rather than the <b>"java.util.Arrays.equals()"</b> method.
<!-- tooltip end -->
<p>
-<small>New in 10.5, Powered by InspectionGadgets</small>
+<small>New in 10.5</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ArrayEquals.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ArrayEquals.html
index 7fa82e5..ca95126 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ArrayEquals.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ArrayEquals.html
@@ -8,6 +8,6 @@
multi-dimensional arrays.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ArrayHashCode.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ArrayHashCode.html
index 2c439ad..bf03e45 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ArrayHashCode.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ArrayHashCode.html
@@ -7,6 +7,6 @@
code of a multi-dimensional array.
<!-- tooltip end -->
<p>
-<small>New in 10.5, Powered by InspectionGadgets</small>
+<small>New in 10.5</small>
</body>
</html>
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ArrayLengthInLoopCondition.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ArrayLengthInLoopCondition.html
index 00dcf39..152c270 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ArrayLengthInLoopCondition.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ArrayLengthInLoopCondition.html
@@ -8,6 +8,6 @@
have adverse performance implications.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ArraysAsListWithZeroOrOneArgument.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ArraysAsListWithZeroOrOneArgument.html
index 1402285..1ac168e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ArraysAsListWithZeroOrOneArgument.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ArraysAsListWithZeroOrOneArgument.html
@@ -4,6 +4,6 @@
with either a call to <b>Collections.singletonList()</b> or <b>Collections.emptyList()</b> which will save some memory.
<!-- tooltip end -->
<p>
-<small>New in 12, Powered by InspectionGadgets</small>
+<small>New in 12</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AssertAsName.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AssertAsName.html
index 20150c4..f8147a6 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AssertAsName.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AssertAsName.html
@@ -5,6 +5,6 @@
earlier JVMs, but will cause problems under Java 1.4 or later.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AssertEqualsBetweenInconvertibleTypes.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AssertEqualsBetweenInconvertibleTypes.html
index 57aa66e..7ccf889 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AssertEqualsBetweenInconvertibleTypes.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AssertEqualsBetweenInconvertibleTypes.html
@@ -5,6 +5,6 @@
types. While such a call might theoretically be useful, most likely it represents a bug.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AssertEqualsCalledOnArray.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AssertEqualsCalledOnArray.html
index 29e2db6..515782b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AssertEqualsCalledOnArray.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AssertEqualsCalledOnArray.html
@@ -5,6 +5,6 @@
<b>assertArrayEquals()</b> methods.
<!-- tooltip end -->
<p>
-<small>New in 10, Powered by InspectionGadgets</small>
+<small>New in 10</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AssertEqualsMayBeAssertSame.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AssertEqualsMayBeAssertSame.html
index 7be047f..e028494 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AssertEqualsMayBeAssertSame.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AssertEqualsMayBeAssertSame.html
@@ -7,6 +7,6 @@
the <b>equals()</b> method.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AssertStatement.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AssertStatement.html
index 15092a3..2e24abe 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AssertStatement.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AssertStatement.html
@@ -4,6 +4,6 @@
Such statements are not supported under Java 1.3 or earlier JVMs.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AssertWithSideEffects.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AssertWithSideEffects.html
index 7b179f6..efa9ad5 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AssertWithSideEffects.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AssertWithSideEffects.html
@@ -8,6 +8,6 @@
for any modifications of fields.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AssertsWithoutMessages.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AssertsWithoutMessages.html
index 67faa0d..bf5232e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AssertsWithoutMessages.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AssertsWithoutMessages.html
@@ -4,6 +4,6 @@
An error message on assertion failure may help clarify the test case's intent.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AssignmentToCatchBlockParameter.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AssignmentToCatchBlockParameter.html
index e479017..1d3e5df 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AssignmentToCatchBlockParameter.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AssignmentToCatchBlockParameter.html
@@ -4,6 +4,6 @@
While occasionally intended, this construct can be confusing.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AssignmentToCollectionFieldFromParameter.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AssignmentToCollectionFieldFromParameter.html
index 0662276..d7aef76 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AssignmentToCollectionFieldFromParameter.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AssignmentToCollectionFieldFromParameter.html
@@ -6,6 +6,6 @@
reasons, this construct is inherently bug-prone.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AssignmentToDateFieldFromParameter.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AssignmentToDateFieldFromParameter.html
index cc1003b..eaba3a3 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AssignmentToDateFieldFromParameter.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AssignmentToDateFieldFromParameter.html
@@ -8,6 +8,6 @@
reasons, this construct is inherently bug-prone.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AssignmentToForLoopParameter.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AssignmentToForLoopParameter.html
index 94c4d40..e10c79b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AssignmentToForLoopParameter.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AssignmentToForLoopParameter.html
@@ -5,6 +5,6 @@
While occasionally intended, this construct can be extremely confusing, and is often the result of a typo.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AssignmentToMethodParameter.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AssignmentToMethodParameter.html
index 9139a9d..ed0c956 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AssignmentToMethodParameter.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AssignmentToMethodParameter.html
@@ -5,6 +5,6 @@
While occasionally intended, this construct can be extremely confusing, and is often the result of a typo.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AssignmentToNull.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AssignmentToNull.html
index 0ddd836..211c26b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AssignmentToNull.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AssignmentToNull.html
@@ -10,6 +10,6 @@
<p>
Use the checkbox below to ignore assignments to fields.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AssignmentToStaticFieldFromInstanceMethod.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AssignmentToStaticFieldFromInstanceMethod.html
index 9e049f3..2aa70b8 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AssignmentToStaticFieldFromInstanceMethod.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AssignmentToStaticFieldFromInstanceMethod.html
@@ -6,6 +6,6 @@
<b>static</b>.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AssignmentToSuperclassField.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AssignmentToSuperclassField.html
index 5a4a842..c9708f2 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AssignmentToSuperclassField.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AssignmentToSuperclassField.html
@@ -4,6 +4,6 @@
superclass to initialize the fields.
<!-- tooltip end -->
<p>
-<small>New in 12.1, Powered by InspectionGadgets</small>
+<small>New in 12.1</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AssignmentUsedAsCondition.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AssignmentUsedAsCondition.html
index 6bf27a1..709f163 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AssignmentUsedAsCondition.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AssignmentUsedAsCondition.html
@@ -7,6 +7,6 @@
(<b>=</b> instead of <b>==</b>).
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AutoBoxing.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AutoBoxing.html
index 947a583..c089a3e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AutoBoxing.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AutoBoxing.html
@@ -4,6 +4,6 @@
Code which relies on auto-boxing will not work in pre-Java 5.0 environments.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AutoUnboxing.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AutoUnboxing.html
index 62ace95..484b96e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AutoUnboxing.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AutoUnboxing.html
@@ -4,6 +4,6 @@
Code which relies on auto-boxing will not work in pre-Java 5.0 environments.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AwaitNotInLoop.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AwaitNotInLoop.html
index be1242a..a243d02 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AwaitNotInLoop.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AwaitNotInLoop.html
@@ -6,6 +6,6 @@
returns. A loop is the clearest way to achieve this.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AwaitWithoutCorrespondingSignal.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AwaitWithoutCorrespondingSignal.html
index 330165e..3924366 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AwaitWithoutCorrespondingSignal.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AwaitWithoutCorrespondingSignal.html
@@ -6,6 +6,6 @@
can be found. Only calls which target fields of the current class are reported by this inspection.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/BadExceptionCaught.html b/plugins/InspectionGadgets/src/inspectionDescriptions/BadExceptionCaught.html
index 46d30f4..41b1fa8 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/BadExceptionCaught.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/BadExceptionCaught.html
@@ -9,6 +9,6 @@
<p>
Use the list below to specify which exceptions should be flagged by this inspection.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/BadExceptionDeclared.html b/plugins/InspectionGadgets/src/inspectionDescriptions/BadExceptionDeclared.html
index d0d8e4a..775a9b5 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/BadExceptionDeclared.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/BadExceptionDeclared.html
@@ -10,6 +10,6 @@
<p>
Use the second checkbox below to ignore exceptions declared on methods which override a library method.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/BadExceptionThrown.html b/plugins/InspectionGadgets/src/inspectionDescriptions/BadExceptionThrown.html
index 4d8043e..3f4d8e7 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/BadExceptionThrown.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/BadExceptionThrown.html
@@ -8,6 +8,6 @@
<p>
Use the list below to specify which exceptions should be flagged by this inspection.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/BadOddness.html b/plugins/InspectionGadgets/src/inspectionDescriptions/BadOddness.html
index 809439d..506960c 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/BadOddness.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/BadOddness.html
@@ -6,6 +6,6 @@
<code><pre>x % 2 != 0</pre></code> or: <code><pre>(x & 1) == 1</pre></code> instead.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/BeforeClassOrAfterClassIsPublicStaticVoidNoArg.html b/plugins/InspectionGadgets/src/inspectionDescriptions/BeforeClassOrAfterClassIsPublicStaticVoidNoArg.html
index c7521fa..ee9e9f5 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/BeforeClassOrAfterClassIsPublicStaticVoidNoArg.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/BeforeClassOrAfterClassIsPublicStaticVoidNoArg.html
@@ -6,6 +6,6 @@
Such methods are easy to create inadvertently, and will not be executed by JUnit tests runners.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/BeforeOrAfterIsPublicVoidNoArg.html b/plugins/InspectionGadgets/src/inspectionDescriptions/BeforeOrAfterIsPublicVoidNoArg.html
index 95abe77..114d465 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/BeforeOrAfterIsPublicVoidNoArg.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/BeforeOrAfterIsPublicVoidNoArg.html
@@ -6,6 +6,6 @@
Such methods are easy to create inadvertently, and will not be executed by JUnit tests runners.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/BigDecimalEquals.html b/plugins/InspectionGadgets/src/inspectionDescriptions/BigDecimalEquals.html
index ba70c2f..cbdb592 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/BigDecimalEquals.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/BigDecimalEquals.html
@@ -8,6 +8,6 @@
use <b>.compareTo()</b> instead.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/BooleanConstructor.html b/plugins/InspectionGadgets/src/inspectionDescriptions/BooleanConstructor.html
index 8721643..d8602ca 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/BooleanConstructor.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/BooleanConstructor.html
@@ -5,6 +5,6 @@
and may cause performance problems if done often enough.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/BooleanMethodIsAlwaysInverted.html b/plugins/InspectionGadgets/src/inspectionDescriptions/BooleanMethodIsAlwaysInverted.html
index 05186ba..836dda5 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/BooleanMethodIsAlwaysInverted.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/BooleanMethodIsAlwaysInverted.html
@@ -21,6 +21,6 @@
</pre></code>
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/BooleanMethodNameMustStartWithQuestion.html b/plugins/InspectionGadgets/src/inspectionDescriptions/BooleanMethodNameMustStartWithQuestion.html
index d10fa44..a65d255 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/BooleanMethodNameMustStartWithQuestion.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/BooleanMethodNameMustStartWithQuestion.html
@@ -6,6 +6,6 @@
<p>
Use the list below to specify acceptable question words to start boolean method names with.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/BooleanVariableAlwaysNegated.html b/plugins/InspectionGadgets/src/inspectionDescriptions/BooleanVariableAlwaysNegated.html
index bb55c91..20b9f27 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/BooleanVariableAlwaysNegated.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/BooleanVariableAlwaysNegated.html
@@ -4,6 +4,6 @@
when its value is used.
<!-- tooltip end -->
<p>
-<small>New in 11, Powered by InspectionGadgets</small>
+<small>New in 11</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/BoxingBoxedValue.html b/plugins/InspectionGadgets/src/inspectionDescriptions/BoxingBoxedValue.html
index 2b88679..20ba73d 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/BoxingBoxedValue.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/BoxingBoxedValue.html
@@ -6,6 +6,6 @@
problems.
<!-- tooltip end -->
<p>
-<small>New in 10.0.2, Powered by InspectionGadgets</small>
+<small>New in 10.0.2</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/BreakStatement.html b/plugins/InspectionGadgets/src/inspectionDescriptions/BreakStatement.html
index 4e53e59..77e94f6 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/BreakStatement.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/BreakStatement.html
@@ -5,6 +5,6 @@
<b>break</b> statements complicate refactoring, and can be confusing.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/BreakStatementWithLabel.html b/plugins/InspectionGadgets/src/inspectionDescriptions/BreakStatementWithLabel.html
index ed4169d..aaf5cd7 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/BreakStatementWithLabel.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/BreakStatementWithLabel.html
@@ -4,6 +4,6 @@
Labeled <b>break</b> statements complicate refactoring, and can be confusing.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/BusyWait.html b/plugins/InspectionGadgets/src/inspectionDescriptions/BusyWait.html
index c426a3a..1a248a4 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/BusyWait.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/BusyWait.html
@@ -5,6 +5,6 @@
as busy-waiting threads do not release locked resources.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CStyleArrayDeclaration.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CStyleArrayDeclaration.html
index 6e288e2..6b8f3ff 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/CStyleArrayDeclaration.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CStyleArrayDeclaration.html
@@ -4,6 +4,6 @@
rather than Java-style syntax, with the array indicator attached to the type.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CachedNumberConstructorCall.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CachedNumberConstructorCall.html
index 42d332f..7856a99 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/CachedNumberConstructorCall.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CachedNumberConstructorCall.html
@@ -14,6 +14,6 @@
language level of 5.0 or higher.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CallToNativeMethodWhileLocked.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CallToNativeMethodWhileLocked.html
index 16879d7..dbc209f 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/CallToNativeMethodWhileLocked.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CallToNativeMethodWhileLocked.html
@@ -5,6 +5,6 @@
an expensive context switch, and are best kept out of synchronized contexts, if possible.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CallToSimpleGetterInClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CallToSimpleGetterInClass.html
index 4ba453d..24a7f7f 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/CallToSimpleGetterInClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CallToSimpleGetterInClass.html
@@ -10,6 +10,6 @@
Use the first option below to only report on getter calls on <b>this</b>, not on objects of the same type passed in as a parameter. Use
the second option below to only report when the getter is <b>private</b>.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CallToSimpleSetterInClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CallToSimpleSetterInClass.html
index 862c15c..ce23be9 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/CallToSimpleSetterInClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CallToSimpleSetterInClass.html
@@ -10,6 +10,6 @@
Use the first option below to only report on setter calls on <b>this</b>, not on objects of the same type passed in as a parameter. Use
the second option below to only report when the setter is <b>private</b>.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CallToStringConcatCanBeReplacedByOperator.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CallToStringConcatCanBeReplacedByOperator.html
index e123a79..5c5555b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/CallToStringConcatCanBeReplacedByOperator.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CallToStringConcatCanBeReplacedByOperator.html
@@ -6,6 +6,6 @@
performance if the method was invoked on a constant with a constant argument.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CastConflictsWithInstanceof.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CastConflictsWithInstanceof.html
index 542027d..c78a2fb 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/CastConflictsWithInstanceof.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CastConflictsWithInstanceof.html
@@ -6,6 +6,6 @@
result in a <b>java.lang.ClassCastException</b> at runtime.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CastThatLosesPrecision.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CastThatLosesPrecision.html
index c57cec6..fdb55f3 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/CastThatLosesPrecision.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CastThatLosesPrecision.html
@@ -11,6 +11,6 @@
<b>read()</b> method of the class
<b>java.io.Reader</b> returns an <b>int</b>l
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CastToConcreteClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CastToConcreteClass.html
index a4073a0..1ae4092 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/CastToConcreteClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CastToConcreteClass.html
@@ -9,6 +9,6 @@
<p>
Use the second checkbox below to have this inspection ignore casts inside <code>equals()</code> methods.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CastToIncompatibleInterface.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CastToIncompatibleInterface.html
index 6004938..a51c16c 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/CastToIncompatibleInterface.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CastToIncompatibleInterface.html
@@ -7,6 +7,6 @@
result in a <b>java.lang.ClassCastException</b> at runtime.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CaughtExceptionImmediatelyRethrown.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CaughtExceptionImmediatelyRethrown.html
index 6a7fc72..5dc2a76 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/CaughtExceptionImmediatelyRethrown.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CaughtExceptionImmediatelyRethrown.html
@@ -6,6 +6,6 @@
handling.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ChainedEquality.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ChainedEquality.html
index f94be23..493f9fa 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ChainedEquality.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ChainedEquality.html
@@ -4,6 +4,6 @@
Such comparisons are confusing.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ChainedMethodCall.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ChainedMethodCall.html
index 3585d15..19f9ad4 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ChainedMethodCall.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ChainedMethodCall.html
@@ -4,6 +4,6 @@
method call.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ChannelResource.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ChannelResource.html
index dd1c230..745f6e5 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ChannelResource.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ChannelResource.html
@@ -12,6 +12,6 @@
block. This style is less desirable because it is more verbose than opening a Channel
in front of a try block.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CharUsedInArithmeticContext.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CharUsedInArithmeticContext.html
index 4695875..581f711 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/CharUsedInArithmeticContext.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CharUsedInArithmeticContext.html
@@ -4,6 +4,6 @@
addition or subtraction expressions.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CharacterComparison.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CharacterComparison.html
index be73f43..c44838e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/CharacterComparison.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CharacterComparison.html
@@ -4,6 +4,6 @@
environment, such comparisons are rarely correct.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CheckForOutOfMemoryOnLargeArrayAllocation.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CheckForOutOfMemoryOnLargeArrayAllocation.html
index aa9df54..63b0a74 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/CheckForOutOfMemoryOnLargeArrayAllocation.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CheckForOutOfMemoryOnLargeArrayAllocation.html
@@ -12,6 +12,6 @@
Use the field below to specify the maximum number of elements to allow in
unchecked array allocations.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CheckedExceptionClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CheckedExceptionClass.html
index 22e6b52..186226b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/CheckedExceptionClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CheckedExceptionClass.html
@@ -5,6 +5,6 @@
classes be unchecked.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassComplexity.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassComplexity.html
index e57f1a7..d9b3c06 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassComplexity.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassComplexity.html
@@ -8,6 +8,6 @@
<p>
Use the field below to specify the maximum complexity a class is allowed to have.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassCoupling.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassCoupling.html
index 0c5c3d5..566ed5b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassCoupling.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassCoupling.html
@@ -7,6 +7,6 @@
<p>
Use the field below to specify the maximum coupling a class is allowed to have.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassEscapesItsScope.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassEscapesItsScope.html
index 278e0d5..c4923ca 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassEscapesItsScope.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassEscapesItsScope.html
@@ -7,6 +7,6 @@
confusing, and make reuse difficult.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassInTopLevelPackage.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassInTopLevelPackage.html
index 7007266..c6263f2 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassInTopLevelPackage.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassInTopLevelPackage.html
@@ -3,6 +3,6 @@
Reports any classes which do not contain package declarations.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassIndependentOfModule.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassIndependentOfModule.html
index 7f93670..0fb377e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassIndependentOfModule.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassIndependentOfModule.html
@@ -5,6 +5,6 @@
and may often profitably be moved.
<!-- tooltip end -->
<p>
-<small>New in 11, Powered by InspectionGadgets</small>
+<small>New in 11</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassInheritanceDepth.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassInheritanceDepth.html
index 037a604..ac152c1 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassInheritanceDepth.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassInheritanceDepth.html
@@ -7,6 +7,6 @@
<p>
Use the field below to specify the maximum inheritance depth a class is allowed to have.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassInitializer.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassInitializer.html
index 42c5d07..3f59450 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassInitializer.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassInitializer.html
@@ -7,6 +7,6 @@
resulting in obscure bugs.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassInitializerMayBeStatic.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassInitializerMayBeStatic.html
index 742edb4..d802c94 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassInitializerMayBeStatic.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassInitializerMayBeStatic.html
@@ -5,6 +5,6 @@
and non static fields.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassLoaderInstantiation.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassLoaderInstantiation.html
index cd4f107..668c986 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassLoaderInstantiation.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassLoaderInstantiation.html
@@ -4,6 +4,6 @@
While often benign, any instantiations to <b>ClassLoader</b> should be closely examined in any security audit.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassMayBeInterface.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassMayBeInterface.html
index ae5f234..f322e19 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassMayBeInterface.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassMayBeInterface.html
@@ -7,6 +7,6 @@
that cannot themselves be interfaces.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassNameDiffersFromFileName.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassNameDiffersFromFileName.html
index 7b5ab45..c9ebc8e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassNameDiffersFromFileName.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassNameDiffersFromFileName.html
@@ -6,6 +6,6 @@
software tools.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassNamePrefixedWithPackageName.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassNamePrefixedWithPackageName.html
index 4ac92fe..8958b9c 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassNamePrefixedWithPackageName.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassNamePrefixedWithPackageName.html
@@ -5,6 +5,6 @@
annoying.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassNameSameAsAncestorName.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassNameSameAsAncestorName.html
index 9b53c8b..2e29bcf 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassNameSameAsAncestorName.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassNameSameAsAncestorName.html
@@ -4,6 +4,6 @@
super classes (but in different packages). Such class name may be very confusing.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassNamingConvention.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassNamingConvention.html
index fb9919e..377c9e0 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassNamingConvention.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassNamingConvention.html
@@ -5,8 +5,8 @@
<!-- tooltip end -->
<p>
Use the fields below to specify minimum length, maximum length and regular expression expected for class names.
-(Regular expressions are in standard <b>java.util.regex</b> format.)
+Specify <b>0</b> to not check the length of names. Regular expressions are in standard <b>java.util.regex</b> format.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassNestingDepth.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassNestingDepth.html
index bd8b314..0780fb8 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassNestingDepth.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassNestingDepth.html
@@ -6,6 +6,6 @@
<p>
Use the field below to specify the maximum nesting depth a class is allowed have.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassNewInstance.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassNewInstance.html
index 811ae15..3ead980 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassNewInstance.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassNewInstance.html
@@ -11,6 +11,6 @@
in a <b>java.lang.reflect.InvocationTargetException</b>.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassOnlyUsedInOneModule.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassOnlyUsedInOneModule.html
index 00098bc..ce83114 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassOnlyUsedInOneModule.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassOnlyUsedInOneModule.html
@@ -5,6 +5,6 @@
that module.
<!-- tooltip end -->
<p>
-<small>New in 11, Powered by InspectionGadgets</small>
+<small>New in 11</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassOnlyUsedInOnePackage.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassOnlyUsedInOnePackage.html
index 00098bc..ce83114 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassOnlyUsedInOnePackage.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassOnlyUsedInOnePackage.html
@@ -5,6 +5,6 @@
that module.
<!-- tooltip end -->
<p>
-<small>New in 11, Powered by InspectionGadgets</small>
+<small>New in 11</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassReferencesSubclass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassReferencesSubclass.html
index b432384..c8d8b55 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassReferencesSubclass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassReferencesSubclass.html
@@ -4,6 +4,6 @@
Such references may be confusing, and violate several rules of object-oriented design.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassUnconnectedToPackage.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassUnconnectedToPackage.html
index c2a15af..ac6518c 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassUnconnectedToPackage.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassUnconnectedToPackage.html
@@ -5,6 +5,6 @@
and may often profitably be moved.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithMultipleLoggers.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithMultipleLoggers.html
index f9673d4..d040a5c 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithMultipleLoggers.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithMultipleLoggers.html
@@ -9,6 +9,6 @@
Use the table below to specify below to specify Logger class names.
Classes which declare multiple fields which have the type of one of the classes specified, will be reported by this inspection.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithTooManyDependencies.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithTooManyDependencies.html
index 0fbaf18..89e2b91 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithTooManyDependencies.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithTooManyDependencies.html
@@ -10,6 +10,6 @@
Use the field below to specify the maximum number of dependencies a class may have
before triggering this inspection
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithTooManyDependents.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithTooManyDependents.html
index 34b3beb..7634204 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithTooManyDependents.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithTooManyDependents.html
@@ -9,6 +9,6 @@
Use the field below to specify the maximum number of dependents a class may have before
triggering this inspection
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithTooManyTransitiveDependencies.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithTooManyTransitiveDependencies.html
index 92d7b98..5130bc8 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithTooManyTransitiveDependencies.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithTooManyTransitiveDependencies.html
@@ -10,6 +10,6 @@
Use the field below to specify the maximum number of direct or indirect dependencies
a class may have before triggering this inspection
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithTooManyTransitiveDependents.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithTooManyTransitiveDependents.html
index 839a4e3..4d7ac37 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithTooManyTransitiveDependents.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithTooManyTransitiveDependents.html
@@ -10,6 +10,6 @@
Use the field below to specify the maximum number of direct or indirect dependents
a class may have before triggering this inspection
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithoutConstructor.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithoutConstructor.html
index 3a15855..24229c1 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithoutConstructor.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithoutConstructor.html
@@ -3,6 +3,6 @@
Reports a classes without constructors. Some coding standards prohibit such classes.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithoutLogger.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithoutLogger.html
index 8237a18..9355202 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithoutLogger.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithoutLogger.html
@@ -8,6 +8,6 @@
Use the table below to specify below to specify Logger class names.
Classes which do not declare a field with the type of one of the classes specified, will be reported by this inspection.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithoutNoArgConstructor.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithoutNoArgConstructor.html
index 3b1d5e0..fbc102e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithoutNoArgConstructor.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithoutNoArgConstructor.html
@@ -8,6 +8,6 @@
contain no explicit constructors. These classes are provided a default no-argument constructor
by the compiler.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CloneCallsConstructors.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CloneCallsConstructors.html
index 4483324..ca0deb7 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/CloneCallsConstructors.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CloneCallsConstructors.html
@@ -5,6 +5,6 @@
instead of creating the object directly, to support later subclassing.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CloneCallsSuperClone.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CloneCallsSuperClone.html
index 18bea23..2f013e8 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/CloneCallsSuperClone.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CloneCallsSuperClone.html
@@ -4,6 +4,6 @@
Cloning an object without calling <b>super.clone()</b> may result in objects being improperly initialized.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CloneDeclaresCloneNotSupported.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CloneDeclaresCloneNotSupported.html
index 3886ded..a1010d6 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/CloneDeclaresCloneNotSupported.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CloneDeclaresCloneNotSupported.html
@@ -8,6 +8,6 @@
or <b>clone()</b> methods on <b>final</b> classes.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CloneInNonCloneableClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CloneInNonCloneableClass.html
index 5bc2901..428513e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/CloneInNonCloneableClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CloneInNonCloneableClass.html
@@ -5,6 +5,6 @@
This usually represents a programming error.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CloneableClassInSecureContext.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CloneableClassInSecureContext.html
index d34d558..c013fb4 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/CloneableClassInSecureContext.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CloneableClassInSecureContext.html
@@ -6,6 +6,6 @@
throw an error. Cloneable classes may be dangerous in code intended for secure use.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CloneableImplementsClone.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CloneableImplementsClone.html
index 3ced557..60739bb 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/CloneableImplementsClone.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CloneableImplementsClone.html
@@ -5,6 +5,6 @@
behavior.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CollectionAddedToSelf.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CollectionAddedToSelf.html
index 9532a7a..a7793a6 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/CollectionAddedToSelf.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CollectionAddedToSelf.html
@@ -6,6 +6,6 @@
if <b>hashCode()</b> is ever called on the self-containing collection.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CollectionContainsUrl.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CollectionContainsUrl.html
index 1bd48ad..c12d1aa 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/CollectionContainsUrl.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CollectionContainsUrl.html
@@ -11,6 +11,6 @@
can cause significant delays.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CollectionsFieldAccessReplaceableByMethodCall.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CollectionsFieldAccessReplaceableByMethodCall.html
index 2ed524c..773c777 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/CollectionsFieldAccessReplaceableByMethodCall.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CollectionsFieldAccessReplaceableByMethodCall.html
@@ -11,6 +11,6 @@
language level of 5.0 or higher.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CollectionsMustHaveInitialCapacity.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CollectionsMustHaveInitialCapacity.html
index 472bca6..109633b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/CollectionsMustHaveInitialCapacity.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CollectionsMustHaveInitialCapacity.html
@@ -15,6 +15,6 @@
</ul>
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ComparableImplementedButEqualsNotOverridden.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ComparableImplementedButEqualsNotOverridden.html
index e1e423a..1d7d157 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ComparableImplementedButEqualsNotOverridden.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ComparableImplementedButEqualsNotOverridden.html
@@ -9,6 +9,6 @@
<b>equals()</b>.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ComparatorMethodParameterNotUsed.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ComparatorMethodParameterNotUsed.html
index 1d73fc1..afd63bc 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ComparatorMethodParameterNotUsed.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ComparatorMethodParameterNotUsed.html
@@ -5,6 +5,6 @@
with itself or the method is not implemented correctly.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ComparatorNotSerializable.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ComparatorNotSerializable.html
index fec4f98..f6e15e8 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ComparatorNotSerializable.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ComparatorNotSerializable.html
@@ -8,6 +8,6 @@
them <b>Serializable</b> is a small cost to avoid such issues.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CompareToUsesNonFinalVariable.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CompareToUsesNonFinalVariable.html
index e36dbcb..01ca099 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/CompareToUsesNonFinalVariable.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CompareToUsesNonFinalVariable.html
@@ -6,6 +6,6 @@
using the standard Collections classes.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ComparisonOfShortAndChar.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ComparisonOfShortAndChar.html
index 5741985..3a3c02c 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ComparisonOfShortAndChar.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ComparisonOfShortAndChar.html
@@ -6,6 +6,6 @@
signed and <b>char</b> values unsigned.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ComparisonToNaN.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ComparisonToNaN.html
index 64ed56f..ccbe2ab 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ComparisonToNaN.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ComparisonToNaN.html
@@ -7,6 +7,6 @@
methods instead.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ConditionSignal.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ConditionSignal.html
index 238b104..d4dde83 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ConditionSignal.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ConditionSignal.html
@@ -4,6 +4,6 @@
<b>signalAll()</b> is a better and safer choice.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ConditionalExpression.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ConditionalExpression.html
index 75b4679..4cc4ca5 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ConditionalExpression.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ConditionalExpression.html
@@ -9,6 +9,6 @@
String s = (foo == null) ? "" : foo.toString();
</pre>
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ConditionalExpressionWithIdenticalBranches.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ConditionalExpressionWithIdenticalBranches.html
index 6ce6bc4..efdb431 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ConditionalExpressionWithIdenticalBranches.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ConditionalExpressionWithIdenticalBranches.html
@@ -5,6 +5,6 @@
programmer error.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ConfusingElse.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ConfusingElse.html
index 5355599..8aece42 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ConfusingElse.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ConfusingElse.html
@@ -11,6 +11,6 @@
<b>if</b> branch cannot complete normally and which are not followed by more statements,
similar to the Redundant Else intention.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ConfusingFloatingPointLiteral.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ConfusingFloatingPointLiteral.html
index ada7e78..b4b7d54 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ConfusingFloatingPointLiteral.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ConfusingFloatingPointLiteral.html
@@ -4,6 +4,6 @@
and numbers after the decimal point. Such literals may be confusing, and violate several coding standards.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ConfusingMainMethod.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ConfusingMainMethod.html
index 7679462..de51a02 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ConfusingMainMethod.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ConfusingMainMethod.html
@@ -5,6 +5,6 @@
are expected to be application entry points.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ConfusingOctalEscape.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ConfusingOctalEscape.html
index 32cf94d..10192e3 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ConfusingOctalEscape.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ConfusingOctalEscape.html
@@ -4,6 +4,6 @@
a digit. Such strings may be confusing, and are often the result of errors in escape code creation.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ConnectionResource.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ConnectionResource.html
index 9072a32..9e31994 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ConnectionResource.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ConnectionResource.html
@@ -8,6 +8,6 @@
be inadvertently leaked if an exception is thrown before the resource is closed.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantAssertCondition.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantAssertCondition.html
index 87bff68..2dc3896 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantAssertCondition.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantAssertCondition.html
@@ -5,6 +5,6 @@
Such statements can easily be left over after refactoring and are probably a bug.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantConditionalExpression.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantConditionalExpression.html
index cfc41fa..1cf4727 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantConditionalExpression.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantConditionalExpression.html
@@ -5,6 +5,6 @@
These expressions sometimes occur as the result of automatic refactorings, and may obviously be simplified.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantDeclaredInAbstractClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantDeclaredInAbstractClass.html
index bc20068..53084d8 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantDeclaredInAbstractClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantDeclaredInAbstractClass.html
@@ -4,6 +4,6 @@
classes. Some coding standards require that constants be declared in interfaces instead.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantDeclaredInInterface.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantDeclaredInInterface.html
index 5b49517..9f4b0ec 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantDeclaredInInterface.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantDeclaredInInterface.html
@@ -4,6 +4,6 @@
Some coding standards require that constants be declared in abstract classes instead.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantIfStatement.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantIfStatement.html
index e2223a6..791cf4e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantIfStatement.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantIfStatement.html
@@ -6,6 +6,6 @@
be simplified.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantJUnitAssertArgument.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantJUnitAssertArgument.html
index aaa4c16..b7ef069 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantJUnitAssertArgument.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantJUnitAssertArgument.html
@@ -6,6 +6,6 @@
Such statements can easily be left over after refactoring and are probably not intended.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantMathCall.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantMathCall.html
index 8fb51eb..06d86de 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantMathCall.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantMathCall.html
@@ -5,6 +5,6 @@
to be simple compile-time constants.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantNamingConvention.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantNamingConvention.html
index 9bc0bdb..73f0874 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantNamingConvention.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantNamingConvention.html
@@ -5,10 +5,10 @@
<!-- tooltip end -->
<p>
Use the fields below to specify minimum length, maximum length and regular expression expected for constant names
-(Regular expressions are in standard <b>java.util.regex</b> format).
+Specify <b>0</b> to not check the length of names. Regular expressions are in standard <b>java.util.regex</b> format.
<p>
Use the checkbox below to specify that only immutable static final fields should be checked by this inspection.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantOnLHSOfComparison.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantOnLHSOfComparison.html
index 3320700..2d5c7ed 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantOnLHSOfComparison.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantOnLHSOfComparison.html
@@ -4,6 +4,6 @@
specify that constants should be on the right-hand side of comparisons.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantOnRHSOfComparison.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantOnRHSOfComparison.html
index 027aee3..87c601a 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantOnRHSOfComparison.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantOnRHSOfComparison.html
@@ -4,6 +4,6 @@
specify that constants should be on the left-hand side of comparisons.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantStringIntern.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantStringIntern.html
index 08074ec..478f04a 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantStringIntern.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantStringIntern.html
@@ -5,6 +5,6 @@
to <b>String.intern()</b> redundant.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantValueVariableUse.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantValueVariableUse.html
index b1c98a4..b6a9007 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantValueVariableUse.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ConstantValueVariableUse.html
@@ -8,6 +8,6 @@
of a variable which is known to be constant can be replaced with the actual constant.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ConstructorCount.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ConstructorCount.html
index f5175b6..892e92e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ConstructorCount.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ConstructorCount.html
@@ -7,6 +7,6 @@
<p>
Use the field below to specify the maximum number of constructors a class is allowed to have.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ContinueOrBreakFromFinallyBlock.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ContinueOrBreakFromFinallyBlock.html
index f2a954d..59904d2 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ContinueOrBreakFromFinallyBlock.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ContinueOrBreakFromFinallyBlock.html
@@ -6,6 +6,6 @@
tremendously complicate debugging.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ContinueStatement.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ContinueStatement.html
index ce5fc5a..dc574ca 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ContinueStatement.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ContinueStatement.html
@@ -4,6 +4,6 @@
<b>continue</b> statements complicate refactoring, and can be confusing.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ContinueStatementWithLabel.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ContinueStatementWithLabel.html
index 9694df1..825777e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ContinueStatementWithLabel.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ContinueStatementWithLabel.html
@@ -4,6 +4,6 @@
Labeled <b>continue</b> statements complicate refactoring, and can be confusing.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ControlFlowStatementWithoutBraces.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ControlFlowStatementWithoutBraces.html
index accef0b..dd8eb88 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ControlFlowStatementWithoutBraces.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ControlFlowStatementWithoutBraces.html
@@ -6,6 +6,6 @@
errors when modifying the code.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CovariantCompareTo.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CovariantCompareTo.html
index 670f0b6..7ab9a5b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/CovariantCompareTo.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CovariantCompareTo.html
@@ -5,6 +5,6 @@
which does take <b>java.lang.Object</b> as its argument. Normally, this is a mistake.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CovariantEquals.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CovariantEquals.html
index 41d2ab3..817d829 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/CovariantEquals.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CovariantEquals.html
@@ -5,6 +5,6 @@
which does take <b>java.lang.Object</b> as its argument. Normally, this is a mistake.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CustomClassloader.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CustomClassloader.html
index 6eda855..f4d8689 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/CustomClassloader.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CustomClassloader.html
@@ -5,6 +5,6 @@
and professionally inspected for possible security issues.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CustomSecurityManager.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CustomSecurityManager.html
index 41bb5e6..95808f9 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/CustomSecurityManager.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CustomSecurityManager.html
@@ -5,6 +5,6 @@
and professionally inspected for possible security issues.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CyclicClassDependency.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CyclicClassDependency.html
index 08835b9..815fb32 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/CyclicClassDependency.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CyclicClassDependency.html
@@ -5,6 +5,6 @@
Since this inspection requires global code analysis, it is only available in batch inspection mode.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CyclicPackageDependency.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CyclicPackageDependency.html
index 3cd47e9..2649189 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/CyclicPackageDependency.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CyclicPackageDependency.html
@@ -5,6 +5,6 @@
Since this inspection requires global code analysis, it is only available in batch inspection mode.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CyclomaticComplexity.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CyclomaticComplexity.html
index 9b48642..6169b60 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/CyclomaticComplexity.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CyclomaticComplexity.html
@@ -7,6 +7,6 @@
<p>
Use the field below to specify the maximum cyclomatic complexity a method is allowed to have.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/DateToString.html b/plugins/InspectionGadgets/src/inspectionDescriptions/DateToString.html
index 28db58d..4fc44cf 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/DateToString.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/DateToString.html
@@ -4,6 +4,6 @@
incorrect in an internationalized environment.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/DeclareCollectionAsInterface.html b/plugins/InspectionGadgets/src/inspectionDescriptions/DeclareCollectionAsInterface.html
index cf4814e..dad179c 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/DeclareCollectionAsInterface.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/DeclareCollectionAsInterface.html
@@ -4,6 +4,6 @@
rather than an appropriate interface.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/DefaultNotLastCaseInSwitch.html b/plugins/InspectionGadgets/src/inspectionDescriptions/DefaultNotLastCaseInSwitch.html
index d4cf4b1..985cc6b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/DefaultNotLastCaseInSwitch.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/DefaultNotLastCaseInSwitch.html
@@ -4,6 +4,6 @@
comes before some other case. This construct is unnecessarily confusing.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/DeserializableClassInSecureContext.html b/plugins/InspectionGadgets/src/inspectionDescriptions/DeserializableClassInSecureContext.html
index 0641f12..4bae342 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/DeserializableClassInSecureContext.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/DeserializableClassInSecureContext.html
@@ -8,6 +8,6 @@
<p>
Use the checkbox below to ignore classes extending <b>Throwable</b> directly or indirectly.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/DesignForExtension.html b/plugins/InspectionGadgets/src/inspectionDescriptions/DesignForExtension.html
index 6ec3ff0..abe9314 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/DesignForExtension.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/DesignForExtension.html
@@ -12,6 +12,6 @@
appropriate for less restrictive environments.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/DisjointPackage.html b/plugins/InspectionGadgets/src/inspectionDescriptions/DisjointPackage.html
index 3354388..d8cad58 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/DisjointPackage.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/DisjointPackage.html
@@ -5,6 +5,6 @@
conceptual cohesion.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/DivideByZero.html b/plugins/InspectionGadgets/src/inspectionDescriptions/DivideByZero.html
index aab108c..f3004e4 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/DivideByZero.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/DivideByZero.html
@@ -3,6 +3,6 @@
Reports division by zero or remainder by zero.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/DollarSignInName.html b/plugins/InspectionGadgets/src/inspectionDescriptions/DollarSignInName.html
index a3870ac..48ba064 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/DollarSignInName.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/DollarSignInName.html
@@ -4,6 +4,6 @@
such identifiers are legal Java, their use outside of generated java code is strongly discouraged.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/DoubleCheckedLocking.html b/plugins/InspectionGadgets/src/inspectionDescriptions/DoubleCheckedLocking.html
index 5c3ddf4..efa4d7a 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/DoubleCheckedLocking.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/DoubleCheckedLocking.html
@@ -10,6 +10,6 @@
a volatile field for double-checked locking works correctly on virtual machines which
implement the new Java Memory Model.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/DoubleLiteralMayBeFloatLiteral.html b/plugins/InspectionGadgets/src/inspectionDescriptions/DoubleLiteralMayBeFloatLiteral.html
index d1f434e..e517999 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/DoubleLiteralMayBeFloatLiteral.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/DoubleLiteralMayBeFloatLiteral.html
@@ -6,6 +6,6 @@
literal.
<!-- tooltip end -->
<p>
-<small>New in 10.0.2, Powered by InspectionGadgets</small>
+<small>New in 10.0.2</small>
</body>
</html>
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/DoubleNegation.html b/plugins/InspectionGadgets/src/inspectionDescriptions/DoubleNegation.html
index 8784ea2..ecae44f 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/DoubleNegation.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/DoubleNegation.html
@@ -6,6 +6,6 @@
<code><pre>if (!!functionCall())</pre></code>
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/DriverManagerGetConnection.html b/plugins/InspectionGadgets/src/inspectionDescriptions/DriverManagerGetConnection.html
index 31d6f40..9794acc 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/DriverManagerGetConnection.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/DriverManagerGetConnection.html
@@ -6,6 +6,6 @@
allows for connection pooling and other optimizations.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/DuplicateBooleanBranch.html b/plugins/InspectionGadgets/src/inspectionDescriptions/DuplicateBooleanBranch.html
index 38c1a58..4384632 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/DuplicateBooleanBranch.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/DuplicateBooleanBranch.html
@@ -5,6 +5,6 @@
expressions. Such constructs almost always represents a typo or cut-and-paste error.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/DuplicateCondition.html b/plugins/InspectionGadgets/src/inspectionDescriptions/DuplicateCondition.html
index f6fa1cc..7fdc4af 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/DuplicateCondition.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/DuplicateCondition.html
@@ -8,6 +8,6 @@
Use the checkbox below to let this inspection ignore conditions containing method calls. Some method calls may return a different value
on an identical invocation.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/DynamicRegexReplaceableByCompiledPattern.html b/plugins/InspectionGadgets/src/inspectionDescriptions/DynamicRegexReplaceableByCompiledPattern.html
index f2cfbf5..30bb1d1 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/DynamicRegexReplaceableByCompiledPattern.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/DynamicRegexReplaceableByCompiledPattern.html
@@ -7,6 +7,6 @@
that the regular expression does not have to be compiled each time it is used.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ElementOnlyUsedFromTestCode.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ElementOnlyUsedFromTestCode.html
index 7aabf36..a46d517 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ElementOnlyUsedFromTestCode.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ElementOnlyUsedFromTestCode.html
@@ -4,6 +4,6 @@
Since this inspection requires global code analysis, it is only available in batch inspection mode.
<!-- tooltip end -->
<p>
-<small>New in 11, Powered by InspectionGadgets</small>
+<small>New in 11</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/EmptyCatchBlock.html b/plugins/InspectionGadgets/src/inspectionDescriptions/EmptyCatchBlock.html
index bb3120b..63b2848 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/EmptyCatchBlock.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/EmptyCatchBlock.html
@@ -10,6 +10,6 @@
empty catch blocks in JUnit tests should be reported and whether to ignore empty
catch blocks if the parameter is named 'ignore' or 'ignored'.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/EmptyClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/EmptyClass.html
index da69488..07c8062 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/EmptyClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/EmptyClass.html
@@ -13,6 +13,6 @@
<p>
Use the second checkbox below to ignore classes which extend <b>java.lang.Throwable</b>.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/EmptyDirectory.html b/plugins/InspectionGadgets/src/inspectionDescriptions/EmptyDirectory.html
index 6d7e46c..6e845ac 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/EmptyDirectory.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/EmptyDirectory.html
@@ -5,6 +5,6 @@
<p>
Use the checkbox below to have this inspection only report directories under source roots.
<p>
-<small>New in 11, Powered by InspectionGadgets</small>
+<small>New in 11</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/EmptyFinallyBlock.html b/plugins/InspectionGadgets/src/inspectionDescriptions/EmptyFinallyBlock.html
index 4bacad9..a37ab26 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/EmptyFinallyBlock.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/EmptyFinallyBlock.html
@@ -6,6 +6,6 @@
<p>
At present, this inspection is disabled in JSP files.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/EmptyInitializer.html b/plugins/InspectionGadgets/src/inspectionDescriptions/EmptyInitializer.html
index 4ba3d3c..c1cad9d 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/EmptyInitializer.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/EmptyInitializer.html
@@ -3,6 +3,6 @@
Reports empty class initializer blocks.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/EmptyStatementBody.html b/plugins/InspectionGadgets/src/inspectionDescriptions/EmptyStatementBody.html
index 1850e1f..d705ee4 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/EmptyStatementBody.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/EmptyStatementBody.html
@@ -5,11 +5,13 @@
having empty bodies. While occasionally intended, this construction is confusing, and often the result of a typo.
<!-- tooltip end -->
<p>
-At present, this inspection is disabled in JSP files.
+This inspection is disabled in JSP files.
<p>
-Use the checkbox below to indicate whether this inspection should report statements whose body is an
+Use the first checkbox below to indicate whether this inspection should report statements whose body is an
empty code block, rather than just empty statements.
<p>
-<small>Powered by InspectionGadgets</small>
+Use the second checkbox below to ignore empty statement bodies which contain a comment.
+<p>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/EmptySynchronizedStatement.html b/plugins/InspectionGadgets/src/inspectionDescriptions/EmptySynchronizedStatement.html
index 9f36607..44b044f 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/EmptySynchronizedStatement.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/EmptySynchronizedStatement.html
@@ -7,6 +7,6 @@
<p>
At present, this inspection is disabled in JSP files.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/EmptyTryBlock.html b/plugins/InspectionGadgets/src/inspectionDescriptions/EmptyTryBlock.html
index 2adf3b5..c3fcf8e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/EmptyTryBlock.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/EmptyTryBlock.html
@@ -5,6 +5,6 @@
<p>
At present, this inspection is disabled in JSP files.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/EnumAsName.html b/plugins/InspectionGadgets/src/inspectionDescriptions/EnumAsName.html
index 9d52502..ceda4a0 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/EnumAsName.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/EnumAsName.html
@@ -5,6 +5,6 @@
earlier JVMs, but will cause problems under Java 5.0 or later.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/EnumClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/EnumClass.html
index 7e16af0..76e42e4 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/EnumClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/EnumClass.html
@@ -4,6 +4,6 @@
Such statements are not supported under Java 1.4 or earlier JVMs.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/EnumSwitchStatementWhichMissesCases.html b/plugins/InspectionGadgets/src/inspectionDescriptions/EnumSwitchStatementWhichMissesCases.html
index feeb593..348fbd7 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/EnumSwitchStatementWhichMissesCases.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/EnumSwitchStatementWhichMissesCases.html
@@ -6,6 +6,6 @@
<p>
Use the checkbox below to ignore <b>switch</b> statements which have a <b>default</b> branch.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/EnumeratedClassNamingConvention.html b/plugins/InspectionGadgets/src/inspectionDescriptions/EnumeratedClassNamingConvention.html
index 9f2382f..018ce3a 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/EnumeratedClassNamingConvention.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/EnumeratedClassNamingConvention.html
@@ -5,8 +5,8 @@
<!-- tooltip end -->
<p>
Use the fields below to specify minimum length, maximum length and regular expression expected for enumerated class names.
-(Regular expressions are in standard <b>java.util.regex</b> format.)
+Specify <b>0</b> to not check the length of names. Regular expressions are in standard <b>java.util.regex</b> format.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/EnumeratedConstantNamingConvention.html b/plugins/InspectionGadgets/src/inspectionDescriptions/EnumeratedConstantNamingConvention.html
index c67aa6c..ea823e3 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/EnumeratedConstantNamingConvention.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/EnumeratedConstantNamingConvention.html
@@ -5,8 +5,8 @@
<!-- tooltip end -->
<p>
Use the fields below to specify minimum length, maximum length and regular expression expected for enumerated constant names.
-(Regular expressions are in standard <b>java.util.regex</b> format.)
+Specify <b>0</b> to not check the length of names. Regular expressions are in standard <b>java.util.regex</b> format.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/EnumerationCanBeIteration.html b/plugins/InspectionGadgets/src/inspectionDescriptions/EnumerationCanBeIteration.html
index ab19a8d..22219db 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/EnumerationCanBeIteration.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/EnumerationCanBeIteration.html
@@ -6,6 +6,6 @@
Collection Framework, which has been available since Java 1.2.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/EqualsBetweenInconvertibleTypes.html b/plugins/InspectionGadgets/src/inspectionDescriptions/EqualsBetweenInconvertibleTypes.html
index 1262025..a2f7e84 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/EqualsBetweenInconvertibleTypes.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/EqualsBetweenInconvertibleTypes.html
@@ -5,6 +5,6 @@
a bug.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/EqualsCalledOnEnumConstant.html b/plugins/InspectionGadgets/src/inspectionDescriptions/EqualsCalledOnEnumConstant.html
index 2510870..da79ddf 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/EqualsCalledOnEnumConstant.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/EqualsCalledOnEnumConstant.html
@@ -7,6 +7,6 @@
have the same identity.
<!-- tooltip end -->
<p>
-<small>New in 8.1, Powered by InspectionGadgets </small>
+<small>New in 8.1 </small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/EqualsHashCodeCalledOnUrl.html b/plugins/InspectionGadgets/src/inspectionDescriptions/EqualsHashCodeCalledOnUrl.html
index f790dff..be99b0f 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/EqualsHashCodeCalledOnUrl.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/EqualsHashCodeCalledOnUrl.html
@@ -9,6 +9,6 @@
significant delays.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/EqualsUsesNonFinalVariable.html b/plugins/InspectionGadgets/src/inspectionDescriptions/EqualsUsesNonFinalVariable.html
index eeec9ee..23f1be5 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/EqualsUsesNonFinalVariable.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/EqualsUsesNonFinalVariable.html
@@ -6,6 +6,6 @@
using the standard Collections classes.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/EqualsWhichDoesntCheckParameterClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/EqualsWhichDoesntCheckParameterClass.html
index 391c10b..92df0f4 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/EqualsWhichDoesntCheckParameterClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/EqualsWhichDoesntCheckParameterClass.html
@@ -5,6 +5,6 @@
in the <b>equals()</b> method may result in latent errors if the object is later used in an untyped collection.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ErrorRethrown.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ErrorRethrown.html
index 32fcddf..b4fed6b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ErrorRethrown.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ErrorRethrown.html
@@ -6,6 +6,6 @@
reported by this inspection.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ExceptionFromCatchWhichDoesntWrap.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ExceptionFromCatchWhichDoesntWrap.html
index 637c720..2fc1b72 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ExceptionFromCatchWhichDoesntWrap.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ExceptionFromCatchWhichDoesntWrap.html
@@ -14,6 +14,6 @@
Use the second checkbox below to have this inspection ignore throw statements which throw exceptions which do not have a
constructor which accepts a <b>Throwable</b> cause.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ExceptionNameDoesntEndWithException.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ExceptionNameDoesntEndWithException.html
index 9732491..1533a37 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ExceptionNameDoesntEndWithException.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ExceptionNameDoesntEndWithException.html
@@ -3,6 +3,6 @@
Reports exception classes whose names don't end with 'Exception'.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ExpectedExceptionNeverThrown.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ExpectedExceptionNeverThrown.html
index 4e6a76e..72c3bc9 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ExpectedExceptionNeverThrown.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ExpectedExceptionNeverThrown.html
@@ -4,6 +4,6 @@
which are never thrown inside the method body.
<!-- tooltip end -->
<p>
-<small>New in 10, Powered by InspectionGadgets</small>
+<small>New in 10</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ExtendsAnnotation.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ExtendsAnnotation.html
index dd0b6cf..6d43753 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ExtendsAnnotation.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ExtendsAnnotation.html
@@ -5,6 +5,6 @@
and discouraged.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ExtendsConcreteCollection.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ExtendsConcreteCollection.html
index 09fcbaf..6a515f8 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ExtendsConcreteCollection.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ExtendsConcreteCollection.html
@@ -7,6 +7,6 @@
more brittle than delegating collection calls.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ExtendsObject.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ExtendsObject.html
index 73a0de1..08b49e4 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ExtendsObject.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ExtendsObject.html
@@ -3,6 +3,6 @@
Reports any classes explicitly declared to extend <b>java.lang.Object</b>.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ExtendsThread.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ExtendsThread.html
index c051dc4..0344227 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ExtendsThread.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ExtendsThread.html
@@ -6,6 +6,6 @@
control over the thread's behavior, and to better localize all concurrency related operations.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ExtendsUtilityClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ExtendsUtilityClass.html
index 6e7f68e..a3d63bf 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ExtendsUtilityClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ExtendsUtilityClass.html
@@ -8,6 +8,6 @@
<p>
Use the checkbox below to ignore any classes that override a utility class but are also utility classes themselves.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ExternalizableWithSerializationMethods.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ExternalizableWithSerializationMethods.html
index ad36e23..217445d 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ExternalizableWithSerializationMethods.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ExternalizableWithSerializationMethods.html
@@ -5,6 +5,6 @@
<b>Externalizable</b> objects.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ExternalizableWithoutPublicNoArgConstructor.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ExternalizableWithoutPublicNoArgConstructor.html
index 59e1723..c4b75ab 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ExternalizableWithoutPublicNoArgConstructor.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ExternalizableWithoutPublicNoArgConstructor.html
@@ -5,6 +5,6 @@
method called. If a public no-arg constructor is not present a <b>java.io.InvalidClassException</b> will be thrown at runtime.
<!-- tooltip end -->
<p>
-<small>New in 12, Powered by InspectionGadgets</small>
+<small>New in 12</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/FallthruInSwitchStatement.html b/plugins/InspectionGadgets/src/inspectionDescriptions/FallthruInSwitchStatement.html
index 8847990..99e99f4 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/FallthruInSwitchStatement.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/FallthruInSwitchStatement.html
@@ -9,6 +9,6 @@
This inspection ignores any fall-through commented with a text matching the regex pattern <code>(?i)falls?\s*thro?u</code>.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/FeatureEnvy.html b/plugins/InspectionGadgets/src/inspectionDescriptions/FeatureEnvy.html
index 54dfc60..c86c69b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/FeatureEnvy.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/FeatureEnvy.html
@@ -7,6 +7,6 @@
envy is often an indication that functionality is located in the wrong class.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/FieldAccessedSynchronizedAndUnsynchronized.html b/plugins/InspectionGadgets/src/inspectionDescriptions/FieldAccessedSynchronizedAndUnsynchronized.html
index 640b175..4613d35 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/FieldAccessedSynchronizedAndUnsynchronized.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/FieldAccessedSynchronizedAndUnsynchronized.html
@@ -8,6 +8,6 @@
<p>
Use the checkbox below to specify if simple getters and setters are counted as accesses too.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/FieldCanBeMovedToSubclass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/FieldCanBeMovedToSubclass.html
index 608c82b..737b4ae 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/FieldCanBeMovedToSubclass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/FieldCanBeMovedToSubclass.html
@@ -4,6 +4,6 @@
Since this inspection requires global code analysis, it is only available in batch inspection mode.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/FieldCount.html b/plugins/InspectionGadgets/src/inspectionDescriptions/FieldCount.html
index a6cb3d4..d950547 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/FieldCount.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/FieldCount.html
@@ -11,6 +11,6 @@
<p>Per default this inspection only counts immutable <b>static final</b> objects as constant. Use the second checkbox below to
count any <b>static final</b> field as constant.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/FieldHasSetterButNoGetter.html b/plugins/InspectionGadgets/src/inspectionDescriptions/FieldHasSetterButNoGetter.html
index 432b0d3..bfcd5ab 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/FieldHasSetterButNoGetter.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/FieldHasSetterButNoGetter.html
@@ -5,6 +5,6 @@
certain bean containers.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/FieldHidesSuperclassField.html b/plugins/InspectionGadgets/src/inspectionDescriptions/FieldHidesSuperclassField.html
index 6f0bb11..b0eeae1 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/FieldHidesSuperclassField.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/FieldHidesSuperclassField.html
@@ -7,6 +7,6 @@
Use the checkbox below the indicate whether this inspection should report all name clashes, or only
clashes with fields which are visible from the subclass.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/FieldMayBeFinal.html b/plugins/InspectionGadgets/src/inspectionDescriptions/FieldMayBeFinal.html
index 3b3dab2..4085bc5 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/FieldMayBeFinal.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/FieldMayBeFinal.html
@@ -6,6 +6,6 @@
in its declaration or in one non-static class initializer or in all constructors.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/FieldMayBeStatic.html b/plugins/InspectionGadgets/src/inspectionDescriptions/FieldMayBeStatic.html
index 94a522e..30d105f 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/FieldMayBeStatic.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/FieldMayBeStatic.html
@@ -4,6 +4,6 @@
may be static if it is declared <b>final</b>, and is initialized with a constant.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/FieldRepeatedlyAccessed.html b/plugins/InspectionGadgets/src/inspectionDescriptions/FieldRepeatedlyAccessed.html
index b27dc2ec..7c5d59d 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/FieldRepeatedlyAccessed.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/FieldRepeatedlyAccessed.html
@@ -11,6 +11,6 @@
Use the checkbox below to ignore <b>final</b> fields being repeatedly accessed, as many compilers and JVMs
can optimize that case without explicit creation of a temporary local variable. Constant fields are always ignored by this inspection.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/FinalClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/FinalClass.html
index 7f29a36..b800d91 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/FinalClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/FinalClass.html
@@ -4,6 +4,6 @@
standards discourage <b>final</b> classes.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/FinalMethod.html b/plugins/InspectionGadgets/src/inspectionDescriptions/FinalMethod.html
index 41ea010..c34bc48 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/FinalMethod.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/FinalMethod.html
@@ -4,6 +4,6 @@
standards discourage <b>final</b> methods.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/FinalMethodInFinalClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/FinalMethodInFinalClass.html
index e3e2031..ed33fee 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/FinalMethodInFinalClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/FinalMethodInFinalClass.html
@@ -4,6 +4,6 @@
classes that are declared <b>final</b>. This is unnecessary, and may be confusing.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/FinalPrivateMethod.html b/plugins/InspectionGadgets/src/inspectionDescriptions/FinalPrivateMethod.html
index 17293ab..5425fb0 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/FinalPrivateMethod.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/FinalPrivateMethod.html
@@ -6,6 +6,6 @@
<b>final</b> is redundant.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/FinalStaticMethod.html b/plugins/InspectionGadgets/src/inspectionDescriptions/FinalStaticMethod.html
index 4e5cc9a..097d548 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/FinalStaticMethod.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/FinalStaticMethod.html
@@ -8,6 +8,6 @@
signature.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/Finalize.html b/plugins/InspectionGadgets/src/inspectionDescriptions/Finalize.html
index a9180e8..0061df5 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/Finalize.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/Finalize.html
@@ -13,6 +13,6 @@
implementation in a subclass. An empty final <b>finalize()</b>
implementation can also be used to prevent subclasses from overriding.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/FinalizeCallsSuperFinalize.html b/plugins/InspectionGadgets/src/inspectionDescriptions/FinalizeCallsSuperFinalize.html
index 9a60f33..7eb02c0 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/FinalizeCallsSuperFinalize.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/FinalizeCallsSuperFinalize.html
@@ -13,6 +13,6 @@
implementation in a subclass. An empty final <b>finalize()</b>
implementation can also be used to prevent subclasses from overriding.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/FinalizeNotProtected.html b/plugins/InspectionGadgets/src/inspectionDescriptions/FinalizeNotProtected.html
index 3369d9b..1d41ce4 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/FinalizeNotProtected.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/FinalizeNotProtected.html
@@ -5,6 +5,6 @@
to prevent it from being explicitly invoked by other classes.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/FinallyBlockCannotCompleteNormally.html b/plugins/InspectionGadgets/src/inspectionDescriptions/FinallyBlockCannotCompleteNormally.html
index 2688b89..6792c45 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/FinallyBlockCannotCompleteNormally.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/FinallyBlockCannotCompleteNormally.html
@@ -4,6 +4,6 @@
can not complete normally.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/FloatingPointEquality.html b/plugins/InspectionGadgets/src/inspectionDescriptions/FloatingPointEquality.html
index 89de5e4..82b9dc0 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/FloatingPointEquality.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/FloatingPointEquality.html
@@ -7,6 +7,6 @@
with zero literals.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ForCanBeForeach.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ForCanBeForeach.html
index 111adc7..f148d7e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ForCanBeForeach.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ForCanBeForeach.html
@@ -15,6 +15,6 @@
This inspection only reports if the project or module is configured to use a
language level of 5.0 or higher.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ForLoopReplaceableByWhile.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ForLoopReplaceableByWhile.html
index cb31dfb..6689e95 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ForLoopReplaceableByWhile.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ForLoopReplaceableByWhile.html
@@ -7,6 +7,6 @@
<p>
Use the checkbox below if you wish this inspection to ignore <b>for</b> loops with trivial or non-existent conditions.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ForLoopThatDoesntUseLoopVariable.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ForLoopThatDoesntUseLoopVariable.html
index 4994169..384560e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ForLoopThatDoesntUseLoopVariable.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ForLoopThatDoesntUseLoopVariable.html
@@ -4,6 +4,6 @@
update does not use the <b>for</b> loop variable.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ForLoopWithMissingComponent.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ForLoopWithMissingComponent.html
index c896331..a8bdc56 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ForLoopWithMissingComponent.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ForLoopWithMissingComponent.html
@@ -9,6 +9,6 @@
This is a standard way to iterate over a collection, in which the
<b>for</b> loop does not have an update
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ForeachStatement.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ForeachStatement.html
index fb2ca22..c6b103b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ForeachStatement.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ForeachStatement.html
@@ -4,6 +4,6 @@
Such <b>for</b> statements are not supported under Java 1.4 and older.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/HardcodedFileSeparators.html b/plugins/InspectionGadgets/src/inspectionDescriptions/HardcodedFileSeparators.html
index 3fc8741..0558782 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/HardcodedFileSeparators.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/HardcodedFileSeparators.html
@@ -10,6 +10,6 @@
header) is an error. Use the checkbox below to include <b>example/*</b> in the set of recognized media types.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/HardcodedLineSeparators.html b/plugins/InspectionGadgets/src/inspectionDescriptions/HardcodedLineSeparators.html
index 2f69ff5..0448d0d 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/HardcodedLineSeparators.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/HardcodedLineSeparators.html
@@ -4,6 +4,6 @@
character literal. These characters are commonly used as line separators, and portability may suffer they are hardcoded.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/HashCodeUsesNonFinalVariable.html b/plugins/InspectionGadgets/src/inspectionDescriptions/HashCodeUsesNonFinalVariable.html
index 207a60a..c7138d0 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/HashCodeUsesNonFinalVariable.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/HashCodeUsesNonFinalVariable.html
@@ -6,6 +6,6 @@
using the standard Collections classes.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/HibernateResource.html b/plugins/InspectionGadgets/src/inspectionDescriptions/HibernateResource.html
index 4f37918..355869a 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/HibernateResource.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/HibernateResource.html
@@ -11,6 +11,6 @@
block. This style is less desirable because it is more verbose than opening a resource
in front of a try block.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/HtmlTagCanBeJavadocTag.html b/plugins/InspectionGadgets/src/inspectionDescriptions/HtmlTagCanBeJavadocTag.html
index 48698aa..1f7b2c4 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/HtmlTagCanBeJavadocTag.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/HtmlTagCanBeJavadocTag.html
@@ -5,6 +5,6 @@
inside the comment, instead of HTML character entities.
<!-- tooltip end -->
<p>
-<small>New in 10.5, Powered by InspectionGadgets</small>
+<small>New in 10.5</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/IOResource.html b/plugins/InspectionGadgets/src/inspectionDescriptions/IOResource.html
index c212309..ecd1c7d 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/IOResource.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/IOResource.html
@@ -16,6 +16,6 @@
block. This style is less desirable because it is more verbose than opening a resource in front of a try
block.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/IfCanBeSwitch.html b/plugins/InspectionGadgets/src/inspectionDescriptions/IfCanBeSwitch.html
index f94bc8a..527cc69 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/IfCanBeSwitch.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/IfCanBeSwitch.html
@@ -14,6 +14,6 @@
Use the second checkbox below to have this inspection suggest switch statements on
enum constants.
<p>
-<small>New in 10.5, Powered by InspectionGadgets</small>
+<small>New in 10.5</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/IfMayBeConditional.html b/plugins/InspectionGadgets/src/inspectionDescriptions/IfMayBeConditional.html
index a3278d6..edfbee0 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/IfMayBeConditional.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/IfMayBeConditional.html
@@ -21,6 +21,6 @@
Use the checkbox below to let this inspection report <b>if</b> statements containing method calls which can be replaced with a single
method call with a conditional expression argument.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/IfStatementWithIdenticalBranches.html b/plugins/InspectionGadgets/src/inspectionDescriptions/IfStatementWithIdenticalBranches.html
index 7a8df92..f73b3ca 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/IfStatementWithIdenticalBranches.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/IfStatementWithIdenticalBranches.html
@@ -5,6 +5,6 @@
programmer error.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/IfStatementWithTooManyBranches.html b/plugins/InspectionGadgets/src/inspectionDescriptions/IfStatementWithTooManyBranches.html
index 6ccaf0f..d5dbdaf 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/IfStatementWithTooManyBranches.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/IfStatementWithTooManyBranches.html
@@ -7,6 +7,6 @@
<p>
Use the field below to specify the maximum number of branches an <b>if</b> statement is allowed to have.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/IgnoreResultOfCall.html b/plugins/InspectionGadgets/src/inspectionDescriptions/IgnoreResultOfCall.html
index a6c56b1..008c410 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/IgnoreResultOfCall.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/IgnoreResultOfCall.html
@@ -15,6 +15,6 @@
that class and all of its subclasses. In addition, you may choose to report any
call to a non-library call whose result is ignored
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/IgnoredJUnitTest.html b/plugins/InspectionGadgets/src/inspectionDescriptions/IgnoredJUnitTest.html
index 763e753..da6d81f 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/IgnoredJUnitTest.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/IgnoredJUnitTest.html
@@ -3,6 +3,6 @@
Reports JUnit tests which are annotated with @Ignore.
<!-- tooltip end -->
<p>
-<small>New in 11, Powered by InspectionGadgets</small>
+<small>New in 11</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ImplicitArrayToString.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ImplicitArrayToString.html
index e85e333..acc59c6 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ImplicitArrayToString.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ImplicitArrayToString.html
@@ -6,6 +6,6 @@
a case, the contents of the array were meant to be used and the not array object itself.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ImplicitCallToSuper.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ImplicitCallToSuper.html
index fc27fa7..3a1213e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ImplicitCallToSuper.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ImplicitCallToSuper.html
@@ -6,6 +6,6 @@
<b>super()</b> be made explicitly.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ImplicitNumericConversion.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ImplicitNumericConversion.html
index a86611d..3fd63ac 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ImplicitNumericConversion.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ImplicitNumericConversion.html
@@ -13,6 +13,6 @@
<p>Use the third checkbox to let this inspection ignore all conversions from literals and
compile time constants.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/IncompatibleMask.html b/plugins/InspectionGadgets/src/inspectionDescriptions/IncompatibleMask.html
index 2bbde64..8f017e1 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/IncompatibleMask.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/IncompatibleMask.html
@@ -7,6 +7,6 @@
and <b><i>constant2</i></b> are incompatible bitmask constants.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/IncrementDecrementUsedAsExpression.html b/plugins/InspectionGadgets/src/inspectionDescriptions/IncrementDecrementUsedAsExpression.html
index 3bb7ddf..3e7bb35 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/IncrementDecrementUsedAsExpression.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/IncrementDecrementUsedAsExpression.html
@@ -5,6 +5,6 @@
given construct should do precisely one thing.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/IndexOfReplaceableByContains.html b/plugins/InspectionGadgets/src/inspectionDescriptions/IndexOfReplaceableByContains.html
index a5b98b3..b600a40 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/IndexOfReplaceableByContains.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/IndexOfReplaceableByContains.html
@@ -8,6 +8,6 @@
language level of 5.0 or higher.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/InfiniteLoopStatement.html b/plugins/InspectionGadgets/src/inspectionDescriptions/InfiniteLoopStatement.html
index 30e9a1a..ee2708a 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/InfiniteLoopStatement.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/InfiniteLoopStatement.html
@@ -6,6 +6,6 @@
are often a symptom of coding errors.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/InfiniteRecursion.html b/plugins/InspectionGadgets/src/inspectionDescriptions/InfiniteRecursion.html
index 1dc1c10..f3349a9 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/InfiniteRecursion.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/InfiniteRecursion.html
@@ -5,6 +5,6 @@
return normally.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/InnerClassMayBeStatic.html b/plugins/InspectionGadgets/src/inspectionDescriptions/InnerClassMayBeStatic.html
index e9ce25f..8d81ee6 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/InnerClassMayBeStatic.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/InnerClassMayBeStatic.html
@@ -5,6 +5,6 @@
its enclosing class instance. A static inner class uses slightly less memory.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/InnerClassOnInterface.html b/plugins/InspectionGadgets/src/inspectionDescriptions/InnerClassOnInterface.html
index fae719e..c041143 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/InnerClassOnInterface.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/InnerClassOnInterface.html
@@ -6,6 +6,6 @@
by this inspection.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/InnerClassVariableHidesOuterClassVariable.html b/plugins/InspectionGadgets/src/inspectionDescriptions/InnerClassVariableHidesOuterClassVariable.html
index 77ed6e2..7c2852a 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/InnerClassVariableHidesOuterClassVariable.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/InnerClassVariableHidesOuterClassVariable.html
@@ -7,6 +7,6 @@
Use the checkbox below the indicate whether this inspection should report all name clashes, or only
clashes with fields which are visible from the inner class.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceMethodNamingConvention.html b/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceMethodNamingConvention.html
index 2d43e9b..4bf1c67 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceMethodNamingConvention.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceMethodNamingConvention.html
@@ -6,8 +6,8 @@
<!-- tooltip end -->
<p>
Use the fields below to specify minimum length, maximum length and regular expression expected for instance method names.
-(Regular expressions are in standard <b>java.util.regex</b> format.)
+Specify <b>0</b> to not check the length of names. Regular expressions are in standard <b>java.util.regex</b> format.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceVariableInitialization.html b/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceVariableInitialization.html
index 12779b8..4db2365 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceVariableInitialization.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceVariableInitialization.html
@@ -8,6 +8,6 @@
<p>
Use the checkbox below to indicate whether you want uninitialized primitive fields to be reported.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceVariableNamingConvention.html b/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceVariableNamingConvention.html
index 4a9c36f..8016ffc 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceVariableNamingConvention.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceVariableNamingConvention.html
@@ -6,8 +6,8 @@
<p>
Use the fields below to specify minimum length, maximum length and regular expression expected for
instance variable names.
-(Regular expressions are in standard <b>java.util.regex</b> format.)
+Specify <b>0</b> to not check the length of names. Regular expressions are in standard <b>java.util.regex</b> format.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceVariableOfConcreteClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceVariableOfConcreteClass.html
index c5e302f..9281a0b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceVariableOfConcreteClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceVariableOfConcreteClass.html
@@ -7,6 +7,6 @@
<p>
Use the checkbox below to have this inspection ignore instance fields whose type is an abstract class.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceVariableUninitializedUse.html b/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceVariableUninitializedUse.html
index 73c71ed..612b304 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceVariableUninitializedUse.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceVariableUninitializedUse.html
@@ -11,6 +11,6 @@
<p>
Use the checkbox below to indicate whether you want uninitialized primitive fields to be reported.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceofCatchParameter.html b/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceofCatchParameter.html
index 10e10c9..c3961a1 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceofCatchParameter.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceofCatchParameter.html
@@ -5,6 +5,6 @@
<b>catch</b> blocks, rather than <b>instanceof</b>.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceofChain.html b/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceofChain.html
index 8963e15..04a3ebd 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceofChain.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceofChain.html
@@ -8,6 +8,6 @@
<p>
Use the checkbox below to ignore instanceof expressions on library classes.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceofIncompatibleInterface.html b/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceofIncompatibleInterface.html
index d27bf68..2b1eeac 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceofIncompatibleInterface.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceofIncompatibleInterface.html
@@ -8,6 +8,6 @@
<b>false</b>
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceofInterfaces.html b/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceofInterfaces.html
index 781e1cf..37f7b0d 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceofInterfaces.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceofInterfaces.html
@@ -7,6 +7,6 @@
<p>
Use the checkbox below to have this inspection ignore <b>instanceof</b> on abstract classes.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceofThis.html b/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceofThis.html
index c36fe5c..103fddc 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceofThis.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceofThis.html
@@ -6,6 +6,6 @@
polymorphic constructions.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/InstantiatingObjectToGetClassObject.html b/plugins/InspectionGadgets/src/inspectionDescriptions/InstantiatingObjectToGetClassObject.html
index 0c8af2c..7236b0c 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/InstantiatingObjectToGetClassObject.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/InstantiatingObjectToGetClassObject.html
@@ -5,6 +5,6 @@
directly by name.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/InstantiationOfUtilityClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/InstantiationOfUtilityClass.html
index 0e4d0de..1a923f9 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/InstantiationOfUtilityClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/InstantiationOfUtilityClass.html
@@ -6,6 +6,6 @@
programmer error.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/IntLiteralMayBeLongLiteral.html b/plugins/InspectionGadgets/src/inspectionDescriptions/IntLiteralMayBeLongLiteral.html
index 12d5d1b..e4fac09 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/IntLiteralMayBeLongLiteral.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/IntLiteralMayBeLongLiteral.html
@@ -6,6 +6,6 @@
literal.
<!-- tooltip end -->
<p>
-<small>New in 9, Powered by InspectionGadgets</small>
+<small>New in 9</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/IntegerDivisionInFloatingPointContext.html b/plugins/InspectionGadgets/src/inspectionDescriptions/IntegerDivisionInFloatingPointContext.html
index 6196379..6aeffc9 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/IntegerDivisionInFloatingPointContext.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/IntegerDivisionInFloatingPointContext.html
@@ -6,6 +6,6 @@
due to truncation in integer division.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/IntegerMultiplicationImplicitCastToLong.html b/plugins/InspectionGadgets/src/inspectionDescriptions/IntegerMultiplicationImplicitCastToLong.html
index d3b0dea..03dcb8e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/IntegerMultiplicationImplicitCastToLong.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/IntegerMultiplicationImplicitCastToLong.html
@@ -8,6 +8,6 @@
Use the checkbox below to ignore compile time constant expressions which evaluate to
a non-overflowing value.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/InterfaceNamingConvention.html b/plugins/InspectionGadgets/src/inspectionDescriptions/InterfaceNamingConvention.html
index 8183383..9114dcd 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/InterfaceNamingConvention.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/InterfaceNamingConvention.html
@@ -5,8 +5,8 @@
<!-- tooltip end -->
<p>
Use the fields below to specify minimum length, maximum length and regular expression expected for interface names.
-(Regular expressions are in standard <b>java.util.regex</b> format.)
+Specify <b>0</b> to not check the length of names. Regular expressions are in standard <b>java.util.regex</b> format.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/InterfaceNeverImplemented.html b/plugins/InspectionGadgets/src/inspectionDescriptions/InterfaceNeverImplemented.html
index 4a4b142..0b11271 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/InterfaceNeverImplemented.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/InterfaceNeverImplemented.html
@@ -3,6 +3,6 @@
Reports interfaces which have no concrete subclasses.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/InterfaceWithOnlyOneDirectInheritor.html b/plugins/InspectionGadgets/src/inspectionDescriptions/InterfaceWithOnlyOneDirectInheritor.html
index d61b573..3614d67 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/InterfaceWithOnlyOneDirectInheritor.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/InterfaceWithOnlyOneDirectInheritor.html
@@ -10,6 +10,6 @@
merging the interface with its inheritor.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/IteratorHasNextCallsIteratorNext.html b/plugins/InspectionGadgets/src/inspectionDescriptions/IteratorHasNextCallsIteratorNext.html
index 1495cb2..fb8704f 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/IteratorHasNextCallsIteratorNext.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/IteratorHasNextCallsIteratorNext.html
@@ -6,6 +6,6 @@
should not modify the iterators state, while <b>next()</b> should.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/IteratorNextDoesNotThrowNoSuchElementException.html b/plugins/InspectionGadgets/src/inspectionDescriptions/IteratorNextDoesNotThrowNoSuchElementException.html
index c42a2bf..7860fec 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/IteratorNextDoesNotThrowNoSuchElementException.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/IteratorNextDoesNotThrowNoSuchElementException.html
@@ -6,6 +6,6 @@
and may result in subtle bugs if the iterator is ever used in a non-standard fashion.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/JDBCExecuteWithNonConstantString.html b/plugins/InspectionGadgets/src/inspectionDescriptions/JDBCExecuteWithNonConstantString.html
index aaf88dd..1d88e6c 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/JDBCExecuteWithNonConstantString.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/JDBCExecuteWithNonConstantString.html
@@ -5,6 +5,6 @@
Constructed SQL statements are a common source of security breaches.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/JDBCPrepareStatementWithNonConstantString.html b/plugins/InspectionGadgets/src/inspectionDescriptions/JDBCPrepareStatementWithNonConstantString.html
index 7fdd805..6ceae51 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/JDBCPrepareStatementWithNonConstantString.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/JDBCPrepareStatementWithNonConstantString.html
@@ -6,6 +6,6 @@
Constructed SQL statements are a common source of security breaches.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/JDBCResource.html b/plugins/InspectionGadgets/src/inspectionDescriptions/JDBCResource.html
index 39852c0..50d5406 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/JDBCResource.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/JDBCResource.html
@@ -14,6 +14,6 @@
block. This style is less desirable because it is more verbose than opening a resource
in front of a try block.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/JNDIResource.html b/plugins/InspectionGadgets/src/inspectionDescriptions/JNDIResource.html
index 3aad1f9..d4c7df6 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/JNDIResource.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/JNDIResource.html
@@ -12,6 +12,6 @@
block. This style is less desirable because it is more verbose than opening a resource
in front of a try block.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/JUnit3StyleTestMethodInJUnit4Class.html b/plugins/InspectionGadgets/src/inspectionDescriptions/JUnit3StyleTestMethodInJUnit4Class.html
index 06ad552..e73eefa 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/JUnit3StyleTestMethodInJUnit4Class.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/JUnit3StyleTestMethodInJUnit4Class.html
@@ -5,6 +5,6 @@
In addition to being confusing such test methods will not be run.
<!-- tooltip end -->
<p>
-<small>New in 12, Powered by InspectionGadgets</small>
+<small>New in 12</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/JUnit4AnnotatedMethodInJUnit3TestCase.html b/plugins/InspectionGadgets/src/inspectionDescriptions/JUnit4AnnotatedMethodInJUnit3TestCase.html
index bb0a5e5..d8f93a2 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/JUnit4AnnotatedMethodInJUnit3TestCase.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/JUnit4AnnotatedMethodInJUnit3TestCase.html
@@ -6,6 +6,6 @@
be actually ignored if its name starts with test.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/JUnitAbstractTestClassNamingConvention.html b/plugins/InspectionGadgets/src/inspectionDescriptions/JUnitAbstractTestClassNamingConvention.html
index 8492d81..21f1b3f 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/JUnitAbstractTestClassNamingConvention.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/JUnitAbstractTestClassNamingConvention.html
@@ -6,9 +6,9 @@
with "TestCase".
<!-- tooltip end -->
<p>
-Use the fields below to specify minimum length, maximum length and regular expression expected for class names.
-(Regular expressions are in standard <b>java.util.regex</b> format.)
+Use the fields below to specify minimum length, maximum length and regular expression expected for abstract JUnit test class names.
+Specify <b>0</b> to not check the length of names. Regular expressions are in standard <b>java.util.regex</b> format.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/JUnitDatapoint.html b/plugins/InspectionGadgets/src/inspectionDescriptions/JUnitDatapoint.html
index 2ab2b6b..3ef1c78 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/JUnitDatapoint.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/JUnitDatapoint.html
@@ -3,6 +3,6 @@
Checks for any member that is annotated with @DataPoint but is not public or not static.
<!-- tooltip end -->
<p>
-<small>New in 13, Powered by InspectionGadgets</small>
+<small>New in 13</small>
</body>
</html>
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/JUnitRule.html b/plugins/InspectionGadgets/src/inspectionDescriptions/JUnitRule.html
index de3483f..9923e66 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/JUnitRule.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/JUnitRule.html
@@ -11,6 +11,6 @@
</ul>
<!-- tooltip end -->
<p>
-<small>New in 13, Powered by InspectionGadgets</small>
+<small>New in 13</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/JUnitTestClassNamingConvention.html b/plugins/InspectionGadgets/src/inspectionDescriptions/JUnitTestClassNamingConvention.html
index 431e0ac..6e27810 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/JUnitTestClassNamingConvention.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/JUnitTestClassNamingConvention.html
@@ -6,9 +6,9 @@
with "Test".
<!-- tooltip end -->
<p>
-Use the fields below to specify minimum length, maximum length and regular expression expected for class names.
-(Regular expressions are in standard <b>java.util.regex</b> format.)
+Use the fields below to specify minimum length, maximum length and regular expression expected for JUnit test class names.
+ Specify <b>0</b> to not check the length of names. Regular expressions are in standard <b>java.util.regex</b> format.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/JavaLangImport.html b/plugins/InspectionGadgets/src/inspectionDescriptions/JavaLangImport.html
index c7bc927..141b16c 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/JavaLangImport.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/JavaLangImport.html
@@ -6,6 +6,6 @@
for off-line reporting on code bases that you don't intend to change.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/JavaLangReflect.html b/plugins/InspectionGadgets/src/inspectionDescriptions/JavaLangReflect.html
index 31914d1..44d0e20 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/JavaLangReflect.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/JavaLangReflect.html
@@ -5,6 +5,6 @@
exception checking.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/KeySetIterationMayUseEntrySet.html b/plugins/InspectionGadgets/src/inspectionDescriptions/KeySetIterationMayUseEntrySet.html
index 957b4f5..c50cf4b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/KeySetIterationMayUseEntrySet.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/KeySetIterationMayUseEntrySet.html
@@ -7,6 +7,6 @@
<b>entrySet()</b> of the map.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/LabeledStatement.html b/plugins/InspectionGadgets/src/inspectionDescriptions/LabeledStatement.html
index 46f49e2..6ab57fd 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/LabeledStatement.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/LabeledStatement.html
@@ -3,6 +3,6 @@
Reports labeled statements.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/LawOfDemeter.html b/plugins/InspectionGadgets/src/inspectionDescriptions/LawOfDemeter.html
index 8f372da..5aec449 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/LawOfDemeter.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/LawOfDemeter.html
@@ -5,6 +5,6 @@
for an explanation what the Law of Demeter is.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/LengthOneStringInIndexOf.html b/plugins/InspectionGadgets/src/inspectionDescriptions/LengthOneStringInIndexOf.html
index 94f73e5..e7e6a11 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/LengthOneStringInIndexOf.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/LengthOneStringInIndexOf.html
@@ -6,6 +6,6 @@
These String literals may be replaced by equivalent character literals, gaining some performance enhancement.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/LengthOneStringsInConcatenation.html b/plugins/InspectionGadgets/src/inspectionDescriptions/LengthOneStringsInConcatenation.html
index 409e4f9..9a82ac0 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/LengthOneStringsInConcatenation.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/LengthOneStringsInConcatenation.html
@@ -4,6 +4,6 @@
These literals may be replaced by equivalent character literals, gaining some performance enhancement.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/LimitedScopeInnerClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/LimitedScopeInnerClass.html
index 9319295..57766d3 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/LimitedScopeInnerClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/LimitedScopeInnerClass.html
@@ -5,6 +5,6 @@
confusing.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ListIndexOfReplaceableByContains.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ListIndexOfReplaceableByContains.html
index 7b9ade9..b973e19 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ListIndexOfReplaceableByContains.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ListIndexOfReplaceableByContains.html
@@ -5,6 +5,6 @@
<b>List.contains()</b>.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ListenerMayUseAdapter.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ListenerMayUseAdapter.html
index 5d3e378..0b00bbf 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ListenerMayUseAdapter.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ListenerMayUseAdapter.html
@@ -9,6 +9,6 @@
Use the checkbox below to indicate if the inspection should warn even if no empty
implementing methods are found.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/LiteralAsArgToStringEquals.html b/plugins/InspectionGadgets/src/inspectionDescriptions/LiteralAsArgToStringEquals.html
index 110d4b8..de63558 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/LiteralAsArgToStringEquals.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/LiteralAsArgToStringEquals.html
@@ -5,6 +5,6 @@
argument, thus minimizing <b>NullPointerException</b>s.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/LoadLibraryWithNonConstantString.html b/plugins/InspectionGadgets/src/inspectionDescriptions/LoadLibraryWithNonConstantString.html
index f2c36bb..2d609b6 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/LoadLibraryWithNonConstantString.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/LoadLibraryWithNonConstantString.html
@@ -5,6 +5,6 @@
Constructed library location strings are a common source of security breaches.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/LocalVariableHidingMemberVariable.html b/plugins/InspectionGadgets/src/inspectionDescriptions/LocalVariableHidingMemberVariable.html
index bfbca05..feb6e0e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/LocalVariableHidingMemberVariable.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/LocalVariableHidingMemberVariable.html
@@ -5,6 +5,6 @@
Such a variable name may be confusing.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/LocalVariableNamingConvention.html b/plugins/InspectionGadgets/src/inspectionDescriptions/LocalVariableNamingConvention.html
index 35fa839..9455544 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/LocalVariableNamingConvention.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/LocalVariableNamingConvention.html
@@ -5,8 +5,8 @@
<!-- tooltip end -->
<p>
Use the fields below to specify minimum length, maximum length and regular expression expected for local variables names.
-(Regular expressions are in standard <b>java.util.regex</b> format.)
+Specify <b>0</b> to not check the length of names. Regular expressions are in standard <b>java.util.regex</b> format.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/LocalVariableOfConcreteClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/LocalVariableOfConcreteClass.html
index ec575bb..746619d 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/LocalVariableOfConcreteClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/LocalVariableOfConcreteClass.html
@@ -8,6 +8,6 @@
<p>
Use the checkbox below to have this inspection ignore local variables whose type is an abstract class.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/LogStatementGuardedByLogCondition.html b/plugins/InspectionGadgets/src/inspectionDescriptions/LogStatementGuardedByLogCondition.html
index dd4a0b5..29dcb9c 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/LogStatementGuardedByLogCondition.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/LogStatementGuardedByLogCondition.html
@@ -15,6 +15,6 @@
<p>
Use the checkbox below to let this inspection flag all unguarded log calls, not only those with non-constant arguments.
<p>
-<small>New in 8, Powered by InspectionGadgets</small>
+<small>New in 8</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/LoggerInitializedWithForeignClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/LoggerInitializedWithForeignClass.html
index e17ca6a..d19c82e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/LoggerInitializedWithForeignClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/LoggerInitializedWithForeignClass.html
@@ -6,6 +6,6 @@
<p>
Use the table below to specify the logger factory classes and logger factory methods recognized by this inspection.
<p>
-<small>New in 8, Powered by InspectionGadgets</small>
+<small>New in 8</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/LoggingConditionDisagreesWithLogStatement.html b/plugins/InspectionGadgets/src/inspectionDescriptions/LoggingConditionDisagreesWithLogStatement.html
index ce67c05..417de23 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/LoggingConditionDisagreesWithLogStatement.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/LoggingConditionDisagreesWithLogStatement.html
@@ -12,6 +12,6 @@
<p>This inspection understands the <i>java.util</i>, <i>log4j</i>, <i>commons-logging</i> and <i>slf4j</i> logging frameworks.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/LongLiteralsEndingWithLowercaseL.html b/plugins/InspectionGadgets/src/inspectionDescriptions/LongLiteralsEndingWithLowercaseL.html
index 79fc670..04924b2 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/LongLiteralsEndingWithLowercaseL.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/LongLiteralsEndingWithLowercaseL.html
@@ -4,6 +4,6 @@
literals may be confusing, as lowercase 'l' looks very similar to '1'.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/LoopConditionNotUpdatedInsideLoop.html b/plugins/InspectionGadgets/src/inspectionDescriptions/LoopConditionNotUpdatedInsideLoop.html
index 556f88a..7903bd8 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/LoopConditionNotUpdatedInsideLoop.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/LoopConditionNotUpdatedInsideLoop.html
@@ -5,6 +5,6 @@
are probably not what was intended.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/LoopStatementsThatDontLoop.html b/plugins/InspectionGadgets/src/inspectionDescriptions/LoopStatementsThatDontLoop.html
index cce848a..cddd793 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/LoopStatementsThatDontLoop.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/LoopStatementsThatDontLoop.html
@@ -5,6 +5,6 @@
bodies are guaranteed to execute at most once. Normally, this is an indication of a bug.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/LoopWithImplicitTerminationCondition.html b/plugins/InspectionGadgets/src/inspectionDescriptions/LoopWithImplicitTerminationCondition.html
index 6ace72a..ac5cd8c 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/LoopWithImplicitTerminationCondition.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/LoopWithImplicitTerminationCondition.html
@@ -12,6 +12,6 @@
was made an explicit loop condition.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MagicCharacter.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MagicCharacter.html
index ea63920..9548316 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MagicCharacter.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MagicCharacter.html
@@ -6,6 +6,6 @@
efforts.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MagicNumber.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MagicNumber.html
index 5d7e1cc..b617007 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MagicNumber.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MagicNumber.html
@@ -15,6 +15,6 @@
Use the fourth checkbox below to ignore magic numbers used as initial capacity when constructing <b>Collection</b>, <b>Map</b>,
<b>StringBuilder</b> or <b>StringBuffer</b> objects.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MalformedFormatString.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MalformedFormatString.html
index 264c851..2c1c2bc 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MalformedFormatString.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MalformedFormatString.html
@@ -9,6 +9,6 @@
and do not fit the standard Java format string syntax.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MalformedRegex.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MalformedRegex.html
index 214879d..8839743 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MalformedRegex.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MalformedRegex.html
@@ -6,6 +6,6 @@
and do not fit the standard Java regular expression syntax.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MalformedXPath.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MalformedXPath.html
index c8f5a5d..57d5cdd 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MalformedXPath.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MalformedXPath.html
@@ -5,6 +5,6 @@
<b>javax.xml.xpath.XPath</b> and do not fit the standard XPath syntax.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ManualArrayCopy.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ManualArrayCopy.html
index 34daba1..4d2f87e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ManualArrayCopy.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ManualArrayCopy.html
@@ -4,6 +4,6 @@
calls to <b>System.arraycopy()</b>.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ManualArrayToCollectionCopy.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ManualArrayToCollectionCopy.html
index 1bf2ad4..7c64b8f 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ManualArrayToCollectionCopy.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ManualArrayToCollectionCopy.html
@@ -4,6 +4,6 @@
<b>Collection.addAll(Arrays.asList())</b> or <b>Collections.addAll()</b>.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MapReplaceableByEnumMap.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MapReplaceableByEnumMap.html
index 99f0aea..3996715 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MapReplaceableByEnumMap.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MapReplaceableByEnumMap.html
@@ -7,6 +7,6 @@
that those of other sets, as the underlying data structure is a simple array.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MarkerInterface.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MarkerInterface.html
index 56d04c1..5919937 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MarkerInterface.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MarkerInterface.html
@@ -7,6 +7,6 @@
this inspection.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MathRandomCastToInt.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MathRandomCastToInt.html
index 52b576e..b433b5d 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MathRandomCastToInt.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MathRandomCastToInt.html
@@ -9,6 +9,6 @@
<b>java.util.Random</b>.
<!-- tooltip end -->
<p>
-<small>New in 10.5, Powered by InspectionGadgets</small>
+<small>New in 10.5</small>
</body>
</html>
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MethodCallInLoopCondition.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MethodCallInLoopCondition.html
index b283f81..ce1409f 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MethodCallInLoopCondition.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MethodCallInLoopCondition.html
@@ -8,6 +8,6 @@
have adverse performance implications
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MethodCanBeVariableArityMethod.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MethodCanBeVariableArityMethod.html
index 4445fa8..1c5b255 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MethodCanBeVariableArityMethod.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MethodCanBeVariableArityMethod.html
@@ -11,6 +11,6 @@
<p>
Use the second checkbox below to ignore methods overriding a method in a super class.
<p>
-<small>New in 10.5, Powered by InspectionGadgets</small>
+<small>New in 10.5</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MethodCount.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MethodCount.html
index 28724c5..9c7dfd4 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MethodCount.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MethodCount.html
@@ -9,6 +9,6 @@
<p>
Use the checkbox below to specify that simple getters and setters should be ignored in the method count.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MethodCoupling.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MethodCoupling.html
index 4baba21..ecbbf2c 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MethodCoupling.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MethodCoupling.html
@@ -8,6 +8,6 @@
<p>
Use the field below to specify the maximum coupling a method is allowed to have.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MethodMayBeStatic.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MethodMayBeStatic.html
index f403b3c..381349e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MethodMayBeStatic.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MethodMayBeStatic.html
@@ -9,6 +9,6 @@
or <b>final</b> methods, which increases the
performance of this inspection and to ignore empty methods.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MethodMayBeSynchronized.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MethodMayBeSynchronized.html
index 3313d24..c7daa9f 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MethodMayBeSynchronized.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MethodMayBeSynchronized.html
@@ -9,6 +9,6 @@
containing method marked <b>synchronized</b>.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MethodNameSameAsClassName.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MethodNameSameAsClassName.html
index 350dfce..ef236e7 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MethodNameSameAsClassName.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MethodNameSameAsClassName.html
@@ -4,6 +4,6 @@
A method with such a name may be easily mistaken for a constructor.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MethodNameSameAsParentName.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MethodNameSameAsParentName.html
index 5df192e..a2d265f 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MethodNameSameAsParentName.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MethodNameSameAsParentName.html
@@ -4,6 +4,6 @@
Such a method name may be confusing.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MethodNamesDifferOnlyByCase.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MethodNamesDifferOnlyByCase.html
index 7fce6c0..befcbf4 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MethodNamesDifferOnlyByCase.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MethodNamesDifferOnlyByCase.html
@@ -6,6 +6,6 @@
<p>Use the checkbox below to have this inspection ignore methods which are overrides or implementations of
super methods.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MethodOnlyUsedFromInnerClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MethodOnlyUsedFromInnerClass.html
index 1c2744f..f5d0d1a 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MethodOnlyUsedFromInnerClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MethodOnlyUsedFromInnerClass.html
@@ -13,6 +13,6 @@
<p>
Use the third checkbox to only report <b>static</b> methods.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MethodOverloadsParentMethod.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MethodOverloadsParentMethod.html
index 13e1f07..76b4b36 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MethodOverloadsParentMethod.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MethodOverloadsParentMethod.html
@@ -7,6 +7,6 @@
<p>
Use the checkbox below also report even if the parameter types are not compatible.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MethodOverridesPackageLocalMethod.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MethodOverridesPackageLocalMethod.html
index 9e95584..ecd43e4 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MethodOverridesPackageLocalMethod.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MethodOverridesPackageLocalMethod.html
@@ -7,6 +7,6 @@
the subclass resides in the same package.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MethodOverridesPrivateMethod.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MethodOverridesPrivateMethod.html
index ec2af27..346f9d3 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MethodOverridesPrivateMethod.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MethodOverridesPrivateMethod.html
@@ -6,6 +6,6 @@
made publicly visible.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MethodOverridesStaticMethod.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MethodOverridesStaticMethod.html
index 4e1b35a..a89631d 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MethodOverridesStaticMethod.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MethodOverridesStaticMethod.html
@@ -4,6 +4,6 @@
methods may result in confusing semantics.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MethodReturnAlwaysConstant.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MethodReturnAlwaysConstant.html
index f689833..022eaed 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MethodReturnAlwaysConstant.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MethodReturnAlwaysConstant.html
@@ -4,6 +4,6 @@
Since this inspection requires global code analysis, it is only available in batch inspection mode.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MethodReturnOfConcreteClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MethodReturnOfConcreteClass.html
index 8c0bd45..50e8ef6 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MethodReturnOfConcreteClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MethodReturnOfConcreteClass.html
@@ -7,6 +7,6 @@
<p>
Use the checkbox below to have this inspection ignore methods whose return type is an abstract class.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MethodWithMultipleLoops.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MethodWithMultipleLoops.html
index 2c0e582..eca8eb5 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MethodWithMultipleLoops.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MethodWithMultipleLoops.html
@@ -3,6 +3,6 @@
Reports methods containing multiple loop statements.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MismatchedArrayReadWrite.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MismatchedArrayReadWrite.html
index 2835221..b1b29dc 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MismatchedArrayReadWrite.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MismatchedArrayReadWrite.html
@@ -5,6 +5,6 @@
dead, incomplete or erroneous code.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MismatchedCollectionQueryUpdate.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MismatchedCollectionQueryUpdate.html
index 025e854..9cfe2ed 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MismatchedCollectionQueryUpdate.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MismatchedCollectionQueryUpdate.html
@@ -9,6 +9,6 @@
the beginning of the method name. Query methods which return their result are automatically detected, only
query methods which return their result in an argument (e.g. write to OutputStream) need to be specified.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MismatchedStringBuilderQueryUpdate.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MismatchedStringBuilderQueryUpdate.html
index 0872191..a883418 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MismatchedStringBuilderQueryUpdate.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MismatchedStringBuilderQueryUpdate.html
@@ -5,6 +5,6 @@
dead, incomplete or erroneous code.
<!-- tooltip end -->
<p>
-<small>New in 10.5, Powered by InspectionGadgets</small>
+<small>New in 10.5</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MisorderedAssertEqualsParameters.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MisorderedAssertEqualsParameters.html
index eaaae62..117a26a 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MisorderedAssertEqualsParameters.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MisorderedAssertEqualsParameters.html
@@ -6,6 +6,6 @@
arguments differ.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MissingDeprecatedAnnotation.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MissingDeprecatedAnnotation.html
index 4bd5661..6ded618 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MissingDeprecatedAnnotation.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MissingDeprecatedAnnotation.html
@@ -7,6 +7,6 @@
language level of 5.0 or higher.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MissingOverrideAnnotation.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MissingOverrideAnnotation.html
index c7dc789..d3e7b26 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MissingOverrideAnnotation.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MissingOverrideAnnotation.html
@@ -18,6 +18,6 @@
Use the second checkbox below to have this inspection ignore overriding methods
in anonymous classes.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MissortedModifiers.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MissortedModifiers.html
index 03583ce..0207101 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MissortedModifiers.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MissortedModifiers.html
@@ -6,6 +6,6 @@
<p>
Use the checkbox below to specify that annotations should always be sorted before keyword modifiers.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MisspelledCompareTo.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MisspelledCompareTo.html
index 1c70675..1bb4d93 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MisspelledCompareTo.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MisspelledCompareTo.html
@@ -4,6 +4,6 @@
Normally, this is a typo of <b>compareTo()</b>.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MisspelledEquals.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MisspelledEquals.html
index b093a06..1354eae 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MisspelledEquals.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MisspelledEquals.html
@@ -4,6 +4,6 @@
Normally, this is a typo of <b>equals()</b>.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MisspelledHashcode.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MisspelledHashcode.html
index 85c4d06..5daace9 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MisspelledHashcode.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MisspelledHashcode.html
@@ -4,6 +4,6 @@
Normally, this is a typo of <b>hashCode()</b>.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MisspelledSetUp.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MisspelledSetUp.html
index 2c182d3..dee6b01 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MisspelledSetUp.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MisspelledSetUp.html
@@ -4,6 +4,6 @@
normally a misspelling of <b>setUp()</b>, and is entirely too easy to make.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MisspelledTearDown.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MisspelledTearDown.html
index 5ee68d9..d8cf165 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MisspelledTearDown.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MisspelledTearDown.html
@@ -4,6 +4,6 @@
normally a misspelling of <b>tearDown()</b>, and is entirely too easy to make.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MisspelledToString.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MisspelledToString.html
index c222ad1..417f92d 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MisspelledToString.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MisspelledToString.html
@@ -4,6 +4,6 @@
Normally, this is a typo of <b>toString()</b>.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ModuleWithTooFewClasses.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ModuleWithTooFewClasses.html
index 38dbc50..514e47c 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ModuleWithTooFewClasses.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ModuleWithTooFewClasses.html
@@ -7,6 +7,6 @@
<p>
Use the field below to specify the minimum number of classes a module may have before triggering this inspection.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ModuleWithTooManyClasses.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ModuleWithTooManyClasses.html
index d167a24..560592a 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ModuleWithTooManyClasses.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ModuleWithTooManyClasses.html
@@ -7,6 +7,6 @@
<p>
Use the field below to specify the maximum number of classes a module may have before triggering this inspection.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MultipleDeclaration.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MultipleDeclaration.html
index 1e3e827..60a7429 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MultipleDeclaration.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MultipleDeclaration.html
@@ -4,6 +4,6 @@
Some coding standards prohibit such declarations.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MultipleExceptionsDeclaredOnTestMethod.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MultipleExceptionsDeclaredOnTestMethod.html
index 530f604..db4fc4b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MultipleExceptionsDeclaredOnTestMethod.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MultipleExceptionsDeclaredOnTestMethod.html
@@ -6,6 +6,6 @@
<pre><b>throws</b> Exception</pre>
<!-- tooltip end -->
<p>
-<small>New in 9, Powered by InspectionGadgets </small>
+<small>New in 9 </small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MultipleReturnPointsPerMethod.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MultipleReturnPointsPerMethod.html
index e7396f7..e1c16be 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MultipleReturnPointsPerMethod.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MultipleReturnPointsPerMethod.html
@@ -11,6 +11,6 @@
<p>
Use the second checkbox below to ignore <b>return</b> points inside <b>equals()</b> methods.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MultipleTopLevelClassesInFile.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MultipleTopLevelClassesInFile.html
index e7f0f5d..0fa5992 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MultipleTopLevelClassesInFile.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MultipleTopLevelClassesInFile.html
@@ -5,6 +5,6 @@
software tools.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MultipleTypedDeclaration.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MultipleTypedDeclaration.html
index 47061ac..8012e00 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MultipleTypedDeclaration.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MultipleTypedDeclaration.html
@@ -6,6 +6,6 @@
<code><pre>String s = "", array[];</pre></code>
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MultiplyOrDivideByPowerOfTwo.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MultiplyOrDivideByPowerOfTwo.html
index c2a8578..0c3f8f9 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MultiplyOrDivideByPowerOfTwo.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MultiplyOrDivideByPowerOfTwo.html
@@ -7,6 +7,6 @@
Use the checkbox below to enable the inspection for divisions by a power of two. Note that replacing
a power of two division by a shift does not work for negative numbers.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NakedNotify.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NakedNotify.html
index 78af040..eac466b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NakedNotify.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NakedNotify.html
@@ -9,6 +9,6 @@
isn't necessarily incorrect, it is certainly worth examining.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NativeMethods.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NativeMethods.html
index fcdba9c..dfa5676 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NativeMethods.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NativeMethods.html
@@ -3,6 +3,6 @@
Reports the methods declared <b>native</b>. Native methods are inherently unportable.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NegatedConditional.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NegatedConditional.html
index ccd1b18..3e9b6cf 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NegatedConditional.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NegatedConditional.html
@@ -6,6 +6,6 @@
<p>
Use the checkbox below to ignore comparisons of the form <b>!= null</b>.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NegatedEqualityExpression.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NegatedEqualityExpression.html
index 17bb421..b7319be 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NegatedEqualityExpression.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NegatedEqualityExpression.html
@@ -4,6 +4,6 @@
<pre><code>!(i == 1)</code></pre>
<!-- tooltip end -->
<p>
-<small>New in 12, Powered by InspectionGadgets</small>
+<small>New in 12</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NegatedIfElse.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NegatedIfElse.html
index 63a12c2..efb7a2b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NegatedIfElse.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NegatedIfElse.html
@@ -8,6 +8,6 @@
<p>
Use the checkbox below to ignore comparisons of the form <b>!= null</b>.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NestedAssignment.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NestedAssignment.html
index 3f0ab8f..c6f00fe 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NestedAssignment.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NestedAssignment.html
@@ -4,6 +4,6 @@
such expressions may be confusing, and violate the general design principle that a given construct should do precisely one thing.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NestedConditionalExpression.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NestedConditionalExpression.html
index b966c98..c07f14c 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NestedConditionalExpression.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NestedConditionalExpression.html
@@ -4,6 +4,6 @@
may result in extremely confusing code.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NestedMethodCall.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NestedMethodCall.html
index 245f133..d94a1c3 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NestedMethodCall.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NestedMethodCall.html
@@ -4,6 +4,6 @@
method call.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NestedSwitchStatement.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NestedSwitchStatement.html
index 728513a..b6b0597 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NestedSwitchStatement.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NestedSwitchStatement.html
@@ -4,6 +4,6 @@
may result in extremely confusing code.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NestedSynchronizedStatement.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NestedSynchronizedStatement.html
index 55c9ff4..ad6fd49 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NestedSynchronizedStatement.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NestedSynchronizedStatement.html
@@ -4,6 +4,6 @@
are either useless (if the lock objects are identical) or prone to deadlock.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NestedTryStatement.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NestedTryStatement.html
index 4a0777f..dba3c9a 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NestedTryStatement.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NestedTryStatement.html
@@ -5,6 +5,6 @@
merged.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NestingDepth.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NestingDepth.html
index f658efd..5af8c27 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NestingDepth.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NestingDepth.html
@@ -6,6 +6,6 @@
<p>
Use the field below to specify the maximum nesting depth a method is allowed to have.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NewExceptionWithoutArguments.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NewExceptionWithoutArguments.html
index 52aef63..08d5cad 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NewExceptionWithoutArguments.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NewExceptionWithoutArguments.html
@@ -6,6 +6,6 @@
<p>
Use the checkbox below to ignore instance creation of exception classes which have no constructors that take arguments.
<p>
-<small>New in 11, Powered by InspectionGadgets</small>
+<small>New in 11</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NewStringBufferWithCharArgument.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NewStringBufferWithCharArgument.html
index f6e58c1..c24a8e6 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NewStringBufferWithCharArgument.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NewStringBufferWithCharArgument.html
@@ -7,6 +7,6 @@
not what was intended.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NoExplicitFinalizeCalls.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NoExplicitFinalizeCalls.html
index 7738172..bc50f98 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NoExplicitFinalizeCalls.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NoExplicitFinalizeCalls.html
@@ -6,6 +6,6 @@
are benign, and are not reported by this inspection.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NonAtomicOperationOnVolatileField.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NonAtomicOperationOnVolatileField.html
index aca8ae4..a60cf32 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NonAtomicOperationOnVolatileField.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NonAtomicOperationOnVolatileField.html
@@ -10,6 +10,6 @@
from the <b>java.util.concurrent.atomic</b> package.
<!-- tooltip end -->
<p>
-<small>New in 10, Powered by InspectionGadgets</small>
+<small>New in 10</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NonBooleanMethodNameMayNotStartWithQuestion.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NonBooleanMethodNameMayNotStartWithQuestion.html
index 49868ec..0602826 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NonBooleanMethodNameMayNotStartWithQuestion.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NonBooleanMethodNameMayNotStartWithQuestion.html
@@ -6,6 +6,6 @@
<p>
Use the list below to specify question words which should only be used for boolean methods.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NonCommentSourceStatements.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NonCommentSourceStatements.html
index f1b6865..917cd4a 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NonCommentSourceStatements.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NonCommentSourceStatements.html
@@ -6,6 +6,6 @@
<p>
Use the field below to specify the maximum number of non-comment source statements a method is allowed to have.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NonExceptionNameEndsWithException.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NonExceptionNameEndsWithException.html
index 36c6021..73e80e0 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NonExceptionNameEndsWithException.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NonExceptionNameEndsWithException.html
@@ -3,6 +3,6 @@
Reports non-exception classes whose names end with 'Exception'.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NonFinalClone.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NonFinalClone.html
index fca5976..b947102 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NonFinalClone.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NonFinalClone.html
@@ -8,6 +8,6 @@
method <b>final</b>.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NonFinalFieldInEnum.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NonFinalFieldInEnum.html
index bba984a..b0ead44 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NonFinalFieldInEnum.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NonFinalFieldInEnum.html
@@ -3,6 +3,6 @@
Reports non-<b>final</b> fields in enumeration types. A non-<b>final</b> field in an enum is rarely needed.
<!-- tooltip end -->
<p>
-<small>New in 12, Powered by InspectionGadgets</small>
+<small>New in 12</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NonFinalFieldOfException.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NonFinalFieldOfException.html
index 8f16c78..1391d19 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NonFinalFieldOfException.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NonFinalFieldOfException.html
@@ -7,6 +7,6 @@
logging.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NonFinalStaticVariableUsedInClassInitialization.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NonFinalStaticVariableUsedInClassInitialization.html
index e63874b..146a854 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NonFinalStaticVariableUsedInClassInitialization.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NonFinalStaticVariableUsedInClassInitialization.html
@@ -6,6 +6,6 @@
extremely difficult and confusing bugs.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NonFinalUtilityClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NonFinalUtilityClass.html
index de2612d..23f0a2e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NonFinalUtilityClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NonFinalUtilityClass.html
@@ -5,6 +5,6 @@
prevents them from being inadvertently subclassed.
<!-- tooltip end -->
<p>
-<small>New in 12, Powered by InspectionGadgets</small>
+<small>New in 12</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NonProtectedConstructorInAbstractClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NonProtectedConstructorInAbstractClass.html
index 287205b..125a1c0 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NonProtectedConstructorInAbstractClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NonProtectedConstructorInAbstractClass.html
@@ -5,6 +5,6 @@
<b>private</b>.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NonReproducibleMathCall.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NonReproducibleMathCall.html
index bafb5b0..ab6cec0 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NonReproducibleMathCall.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NonReproducibleMathCall.html
@@ -6,6 +6,6 @@
should be used instead.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NonSerializableFieldInSerializableClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NonSerializableFieldInSerializableClass.html
index 46adcb2..e06759a 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NonSerializableFieldInSerializableClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NonSerializableFieldInSerializableClass.html
@@ -20,6 +20,6 @@
Use the second list below to specify special annotations. Fields annotated with one of
these annotations will be ignored by this inspection.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NonSerializableObjectBoundToHttpSession.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NonSerializableObjectBoundToHttpSession.html
index d064d5d..770447c 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NonSerializableObjectBoundToHttpSession.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NonSerializableObjectBoundToHttpSession.html
@@ -9,6 +9,6 @@
they are declared to contain are non-<b>Serializable</b>.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NonSerializableObjectPassedToObjectStream.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NonSerializableObjectPassedToObjectStream.html
index 5893e7d..bcb2846 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NonSerializableObjectPassedToObjectStream.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NonSerializableObjectPassedToObjectStream.html
@@ -7,6 +7,6 @@
they are declared to contain are non-<b>Serializable</b>.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NonSerializableWithSerialVersionUIDField.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NonSerializableWithSerialVersionUIDField.html
index 57834b5..3421fe3 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NonSerializableWithSerialVersionUIDField.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NonSerializableWithSerialVersionUIDField.html
@@ -4,6 +4,6 @@
field. This is usually an indication of a programmer error.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NonSerializableWithSerializationMethods.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NonSerializableWithSerializationMethods.html
index 6b3fc16..2cff0cb 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NonSerializableWithSerializationMethods.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NonSerializableWithSerializationMethods.html
@@ -4,6 +4,6 @@
or <b>writeObject()</b> methods. Such methods normally indicate programmer error.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NonShortCircuitBoolean.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NonShortCircuitBoolean.html
index 0580831..6ae949e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NonShortCircuitBoolean.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NonShortCircuitBoolean.html
@@ -6,6 +6,6 @@
and <b>||</b> ), and may lead to subtle bugs.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NonStaticFinalLogger.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NonStaticFinalLogger.html
index 8e02799..ad18639 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NonStaticFinalLogger.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NonStaticFinalLogger.html
@@ -10,6 +10,6 @@
Fields which have a type equal to one of the class names specified and which are not <b>static</b>
and <b>final</b>, will be reported by this inspection.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NonStaticInnerClassInSecureContext.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NonStaticInnerClassInSecureContext.html
index c0a9440..53507c3 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NonStaticInnerClassInSecureContext.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NonStaticInnerClassInSecureContext.html
@@ -5,6 +5,6 @@
compromise security.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NonSynchronizedMethodOverridesSynchronizedMethod.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NonSynchronizedMethodOverridesSynchronizedMethod.html
index e92e225..9b6ba31 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NonSynchronizedMethodOverridesSynchronizedMethod.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NonSynchronizedMethodOverridesSynchronizedMethod.html
@@ -4,6 +4,6 @@
methods overriding <b>synchronized</b> methods.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NonThreadSafeLazyInitialization.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NonThreadSafeLazyInitialization.html
index 3cbe769..f203aa9 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NonThreadSafeLazyInitialization.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NonThreadSafeLazyInitialization.html
@@ -13,6 +13,6 @@
where the JVM guarantees thread-safety of such initializations.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NoopMethodInAbstractClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NoopMethodInAbstractClass.html
index 5c8ffb8..416c959 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NoopMethodInAbstractClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NoopMethodInAbstractClass.html
@@ -5,6 +5,6 @@
their own implementations.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NotifyCalledOnCondition.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NotifyCalledOnCondition.html
index 4bc9717..28df50d 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NotifyCalledOnCondition.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NotifyCalledOnCondition.html
@@ -7,6 +7,6 @@
<b>signalAll()</b> was intended instead.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NotifyNotInSynchronizedContext.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NotifyNotInSynchronizedContext.html
index c1765eb..f014325 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NotifyNotInSynchronizedContext.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NotifyNotInSynchronizedContext.html
@@ -7,6 +7,6 @@
the containing method is called, but it's worth looking at.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NotifyWithoutCorrespondingWait.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NotifyWithoutCorrespondingWait.html
index d388b0b..33cbabe 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NotifyWithoutCorrespondingWait.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NotifyWithoutCorrespondingWait.html
@@ -6,6 +6,6 @@
can be found. Only calls which target fields of the current class are reported by this inspection.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NullArgumentToVariableArgMethod.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NullArgumentToVariableArgMethod.html
index 331af34..5c3508f 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NullArgumentToVariableArgMethod.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NullArgumentToVariableArgMethod.html
@@ -6,6 +6,6 @@
wrapped as a single-element array, as may be expected.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NullThrown.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NullThrown.html
index 4361c8d..a777ebb 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NullThrown.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NullThrown.html
@@ -3,6 +3,6 @@
Reports any null literals which are used as the argument for a throw statement.
<!-- tooltip end -->
<p>
-<small>New in 11, Powered by InspectionGadgets</small>
+<small>New in 11</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NumberEquality.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NumberEquality.html
index 5c3882e..29933a8 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NumberEquality.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NumberEquality.html
@@ -6,6 +6,6 @@
of two ints.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NumericToString.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NumericToString.html
index 1a891c7..0597ea6 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NumericToString.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NumericToString.html
@@ -4,6 +4,6 @@
incorrect in an internationalized environment.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ObjectAllocationInLoop.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ObjectAllocationInLoop.html
index ef4d99c..a48c8fd 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ObjectAllocationInLoop.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ObjectAllocationInLoop.html
@@ -5,6 +5,6 @@
and performance issues.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ObjectEquality.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ObjectEquality.html
index c3635d1..3dccf4b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ObjectEquality.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ObjectEquality.html
@@ -10,6 +10,6 @@
Use the checkboxes below to indicate whether uses of <b>==</b> between objects of
an enumerated type, class type or types with private constructors should be reported by this inspection.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ObjectEqualsNull.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ObjectEqualsNull.html
index 9505676..f23ba92 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ObjectEqualsNull.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ObjectEqualsNull.html
@@ -4,6 +4,6 @@
as an argument. The semantics of such calls are almost certainly not what was intended.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ObjectNotify.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ObjectNotify.html
index a57222d..544d1fa 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ObjectNotify.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ObjectNotify.html
@@ -4,6 +4,6 @@
<b>notifyAll()</b> is a better choice. See Doug Lea's <I>Concurrent Programming in Java</I> for a discussion.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ObjectToString.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ObjectToString.html
index 849511a..fe1fdfb 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ObjectToString.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ObjectToString.html
@@ -7,6 +7,6 @@
<b>java.lang.Object</b> are ignored by this inspection.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ObsoleteCollection.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ObsoleteCollection.html
index 570a5dc..6d32ac0 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ObsoleteCollection.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ObsoleteCollection.html
@@ -10,6 +10,6 @@
as an argument to a method or assigned to a variable that requires the obsolete type.
Enabling this option is potentially quite processor intensive.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/OctalAndDecimalIntegersMixed.html b/plugins/InspectionGadgets/src/inspectionDescriptions/OctalAndDecimalIntegersMixed.html
index 9abbbeb..c656c92 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/OctalAndDecimalIntegersMixed.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/OctalAndDecimalIntegersMixed.html
@@ -5,6 +5,6 @@
that some of them are zero-padded, and will thus be interpreted by the Java compiler as octal.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/OctalLiteral.html b/plugins/InspectionGadgets/src/inspectionDescriptions/OctalLiteral.html
index 1c2febc..96269d0 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/OctalLiteral.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/OctalLiteral.html
@@ -4,6 +4,6 @@
use of octal literals, as they may be easily confused with decimal literals.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/OnDemandImport.html b/plugins/InspectionGadgets/src/inspectionDescriptions/OnDemandImport.html
index 94892c8..c218c6a 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/OnDemandImport.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/OnDemandImport.html
@@ -6,6 +6,6 @@
for off-line reporting on code bases that you don't intend to change.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/OrredNotEqualExpression.html b/plugins/InspectionGadgets/src/inspectionDescriptions/OrredNotEqualExpression.html
index 4381133..be0921a 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/OrredNotEqualExpression.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/OrredNotEqualExpression.html
@@ -6,6 +6,6 @@
<code>x != a && x != b</code>
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/OverloadedMethodsWithSameNumberOfParameters.html b/plugins/InspectionGadgets/src/inspectionDescriptions/OverloadedMethodsWithSameNumberOfParameters.html
index b39b639..f1b17c7 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/OverloadedMethodsWithSameNumberOfParameters.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/OverloadedMethodsWithSameNumberOfParameters.html
@@ -6,6 +6,6 @@
<p>
Use the checkbox below to ignore overloaded methods whose parameter types are definitely incompatible.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/OverloadedVarargsMethod.html b/plugins/InspectionGadgets/src/inspectionDescriptions/OverloadedVarargsMethod.html
index 52e274e..4961418 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/OverloadedVarargsMethod.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/OverloadedVarargsMethod.html
@@ -5,6 +5,6 @@
as it is often not clear which overloading gets called.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/OverlyComplexArithmeticExpression.html b/plugins/InspectionGadgets/src/inspectionDescriptions/OverlyComplexArithmeticExpression.html
index 26c746a..53b8d17 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/OverlyComplexArithmeticExpression.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/OverlyComplexArithmeticExpression.html
@@ -6,6 +6,6 @@
<p>
Use the field below to specify the maximum number of terms allowed in an arithmetic expression.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/OverlyComplexBooleanExpression.html b/plugins/InspectionGadgets/src/inspectionDescriptions/OverlyComplexBooleanExpression.html
index fc6f4a1..435f69f 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/OverlyComplexBooleanExpression.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/OverlyComplexBooleanExpression.html
@@ -7,6 +7,6 @@
<p>
Use the checkbox below to ignore boolean expressions which use only a single boolean operator repeatedly.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/OverlyLargePrimitiveArrayInitializer.html b/plugins/InspectionGadgets/src/inspectionDescriptions/OverlyLargePrimitiveArrayInitializer.html
index c74b61d..f7c2988 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/OverlyLargePrimitiveArrayInitializer.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/OverlyLargePrimitiveArrayInitializer.html
@@ -13,6 +13,6 @@
Use the field below to specify the maximum number of elements to allow in
primitive array initializers.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/OverlyStrongTypeCast.html b/plugins/InspectionGadgets/src/inspectionDescriptions/OverlyStrongTypeCast.html
index 4136181..4031b6a 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/OverlyStrongTypeCast.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/OverlyStrongTypeCast.html
@@ -7,6 +7,6 @@
intentionally using an overly strong cast to cause a <b>ClassCastException</b> to be generated. Use caution.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/OverridableMethodCallDuringObjectConstruction.html b/plugins/InspectionGadgets/src/inspectionDescriptions/OverridableMethodCallDuringObjectConstruction.html
index 2e72abd..30964f8 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/OverridableMethodCallDuringObjectConstruction.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/OverridableMethodCallDuringObjectConstruction.html
@@ -13,6 +13,6 @@
<i>Abstract method called during object construction</i> report overlapping problem sets and only one should be enabled at a time
to prevent duplicate warnings.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/OverriddenMethodCallDuringObjectConstruction.html b/plugins/InspectionGadgets/src/inspectionDescriptions/OverriddenMethodCallDuringObjectConstruction.html
index 5d9b867..f2a7803 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/OverriddenMethodCallDuringObjectConstruction.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/OverriddenMethodCallDuringObjectConstruction.html
@@ -12,6 +12,6 @@
<i>Abstract method called during object construction</i> report overlapping problem sets and only one should be enabled at a time
to prevent duplicate warnings.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/PackageDotHtmlMayBePackageInfo.html b/plugins/InspectionGadgets/src/inspectionDescriptions/PackageDotHtmlMayBePackageInfo.html
index 4182182..cbf1c73 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/PackageDotHtmlMayBePackageInfo.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/PackageDotHtmlMayBePackageInfo.html
@@ -10,6 +10,6 @@
the package.html file, since the Javadoc tool would ignore it then anyway.
<!-- tooltip end -->
<p>
-<small>New in 10.0.3, Powered by InspectionGadgets</small>
+<small>New in 10.0.3</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/PackageInMultipleModules.html b/plugins/InspectionGadgets/src/inspectionDescriptions/PackageInMultipleModules.html
index c0ebd48..3a98ce6 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/PackageInMultipleModules.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/PackageInMultipleModules.html
@@ -4,6 +4,6 @@
Since this inspection requires global code analysis, it is only available in batch inspection mode.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/PackageNamingConvention.html b/plugins/InspectionGadgets/src/inspectionDescriptions/PackageNamingConvention.html
index 55fce2a..24f590b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/PackageNamingConvention.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/PackageNamingConvention.html
@@ -7,6 +7,6 @@
Use the fields below to specify minimum length, maximum length and regular expression expected for method parameter names
(Regular expressions are in standard <b>java.util.regex</b> format).
<p>
-<small>New in 11, Powered by InspectionGadgets</small>
+<small>New in 11</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/PackageVisibleField.html b/plugins/InspectionGadgets/src/inspectionDescriptions/PackageVisibleField.html
index abae2e4..4036ae3 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/PackageVisibleField.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/PackageVisibleField.html
@@ -4,6 +4,6 @@
Constants (i.e. variables marked <b>static</b> and <b>final</b>) are not reported.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/PackageVisibleInnerClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/PackageVisibleInnerClass.html
index 94796c5..7bcb911 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/PackageVisibleInnerClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/PackageVisibleInnerClass.html
@@ -7,6 +7,6 @@
<p>
Use the seconds checkbox below to ignore package-local inner interface.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/PackageWithTooFewClasses.html b/plugins/InspectionGadgets/src/inspectionDescriptions/PackageWithTooFewClasses.html
index 83df05e..8c22904 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/PackageWithTooFewClasses.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/PackageWithTooFewClasses.html
@@ -6,6 +6,6 @@
<p>
Use the field below to specify the minimum number of classes a package may have before triggering this inspection.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/PackageWithTooManyClasses.html b/plugins/InspectionGadgets/src/inspectionDescriptions/PackageWithTooManyClasses.html
index f93d3c6..32532d7 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/PackageWithTooManyClasses.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/PackageWithTooManyClasses.html
@@ -7,6 +7,6 @@
<p>
Use the field below to specify the maximum number of classes a package may have before triggering this inspection.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ParameterHidingMemberVariable.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ParameterHidingMemberVariable.html
index 977c631..6c713d6 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ParameterHidingMemberVariable.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ParameterHidingMemberVariable.html
@@ -5,6 +5,6 @@
Such a parameter name may be confusing.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ParameterNameDiffersFromOverriddenParameter.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ParameterNameDiffersFromOverriddenParameter.html
index 120087f..490362c 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ParameterNameDiffersFromOverriddenParameter.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ParameterNameDiffersFromOverriddenParameter.html
@@ -9,6 +9,6 @@
a single character long or come from a library method should be ignored. Both can be useful if
you do not wish to be bound by dubious naming conventions used in libraries.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ParameterNamingConvention.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ParameterNamingConvention.html
index 9557e33..0cb4af1 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ParameterNamingConvention.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ParameterNamingConvention.html
@@ -5,8 +5,8 @@
<!-- tooltip end -->
<p>
Use the fields below to specify minimum length, maximum length and regular expression expected for method parameter names.
-(Regular expressions are in standard <b>java.util.regex</b> format.)
+Specify <b>0</b> to not check the length of names. Regular expressions are in standard <b>java.util.regex</b> format.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ParameterOfConcreteClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ParameterOfConcreteClass.html
index 7c815a9..9cd5a0e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ParameterOfConcreteClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ParameterOfConcreteClass.html
@@ -7,6 +7,6 @@
<p>
Use the checkbox below to have this inspection ignore method parameters whose type is an abstract class.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ParameterizedParametersStaticCollection.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ParameterizedParametersStaticCollection.html
index 80ce3d9..d1674e5 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ParameterizedParametersStaticCollection.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ParameterizedParametersStaticCollection.html
@@ -4,6 +4,6 @@
data provider method annotated with @Parameterized.Parameters
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ParametersPerConstructor.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ParametersPerConstructor.html
index 97c9c40..01b680e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ParametersPerConstructor.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ParametersPerConstructor.html
@@ -9,6 +9,6 @@
Use the combobox below to specify if the inspection should ignore private, package local & private or protected, package local and
private constructors
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ParametersPerMethod.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ParametersPerMethod.html
index 6d6075e..6058e04 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ParametersPerMethod.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ParametersPerMethod.html
@@ -7,6 +7,6 @@
<p>
Use the field below to specify the maximum number of parameters a method is allowed to have.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/PlaceholderCountMatchesArgumentCount.html b/plugins/InspectionGadgets/src/inspectionDescriptions/PlaceholderCountMatchesArgumentCount.html
index a89605b..aaa60cd 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/PlaceholderCountMatchesArgumentCount.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/PlaceholderCountMatchesArgumentCount.html
@@ -4,6 +4,6 @@
does not match the number of other arguments to the logging call.
<!-- tooltip end -->
<p>
-<small>New in 12.1, Powered by InspectionGadgets</small>
+<small>New in 12.1</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/PointlessArithmeticExpression.html b/plugins/InspectionGadgets/src/inspectionDescriptions/PointlessArithmeticExpression.html
index b63273a..051e0a2 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/PointlessArithmeticExpression.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/PointlessArithmeticExpression.html
@@ -7,6 +7,6 @@
intended to do.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/PointlessBitwiseExpression.html b/plugins/InspectionGadgets/src/inspectionDescriptions/PointlessBitwiseExpression.html
index e15ae99..89ceca3 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/PointlessBitwiseExpression.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/PointlessBitwiseExpression.html
@@ -7,6 +7,6 @@
intended to do.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/PointlessBooleanExpression.html b/plugins/InspectionGadgets/src/inspectionDescriptions/PointlessBooleanExpression.html
index 30ec458..61ada91 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/PointlessBooleanExpression.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/PointlessBooleanExpression.html
@@ -10,6 +10,6 @@
<p>
Use the checkbox below to ignore named constants when determining if an expression is pointless.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/PointlessIndexOfComparison.html b/plugins/InspectionGadgets/src/inspectionDescriptions/PointlessIndexOfComparison.html
index c25efb9..30bcd44 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/PointlessIndexOfComparison.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/PointlessIndexOfComparison.html
@@ -5,6 +5,6 @@
is comparing the result of <b>.indexOf()</b> with numbers less than -1.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/PointlessNullCheck.html b/plugins/InspectionGadgets/src/inspectionDescriptions/PointlessNullCheck.html
index 8d94468..9c47a0d 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/PointlessNullCheck.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/PointlessNullCheck.html
@@ -9,6 +9,6 @@
<pre><code> if (x instanceof String) { ... }</code></pre>
<!-- tooltip end -->
<p>
-<small>New in 11, Powered by InspectionGadgets</small>
+<small>New in 11</small>
</body>
</html>
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/PrimitiveArrayArgumentToVariableArgMethod.html b/plugins/InspectionGadgets/src/inspectionDescriptions/PrimitiveArrayArgumentToVariableArgMethod.html
index b9ee138..4016a74 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/PrimitiveArrayArgumentToVariableArgMethod.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/PrimitiveArrayArgumentToVariableArgMethod.html
@@ -6,6 +6,6 @@
element being boxed, as might be expected.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/PrivateMemberAccessBetweenOuterAndInnerClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/PrivateMemberAccessBetweenOuterAndInnerClass.html
index c630bf2..815bfa6 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/PrivateMemberAccessBetweenOuterAndInnerClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/PrivateMemberAccessBetweenOuterAndInnerClass.html
@@ -11,6 +11,6 @@
member package local, thus allowing direct access without the creation of synthetic accessor methods.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ProtectedField.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ProtectedField.html
index e58b23e..3f57e82 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ProtectedField.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ProtectedField.html
@@ -4,6 +4,6 @@
Constants (i.e. variables marked <b>static</b> and <b>final</b>) are not reported.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ProtectedInnerClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ProtectedInnerClass.html
index 330a2ee..971296c 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ProtectedInnerClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ProtectedInnerClass.html
@@ -7,6 +7,6 @@
<p>
Use the seconds checkbox below to ignore <b>protected</b> inner interface.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ProtectedMemberInFinalClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ProtectedMemberInFinalClass.html
index 81f7909..a5234a1 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ProtectedMemberInFinalClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ProtectedMemberInFinalClass.html
@@ -5,6 +5,6 @@
or package-visible instead.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/PublicConstructor.html b/plugins/InspectionGadgets/src/inspectionDescriptions/PublicConstructor.html
index 2275db5..b4898e4 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/PublicConstructor.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/PublicConstructor.html
@@ -4,6 +4,6 @@
<b>static</b> factory methods. This way the implementation can be swapped out without affecting the call sites.
<!-- tooltip end -->
<p>
-<small>New in 12, Powered by InspectionGadgets</small>
+<small>New in 12</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/PublicConstructorInNonPublicClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/PublicConstructorInNonPublicClass.html
index 852ce2e..e4190f0 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/PublicConstructorInNonPublicClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/PublicConstructorInNonPublicClass.html
@@ -4,6 +4,6 @@
classes that are declared <b>public</b>.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/PublicField.html b/plugins/InspectionGadgets/src/inspectionDescriptions/PublicField.html
index db0c523..6915037 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/PublicField.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/PublicField.html
@@ -8,6 +8,6 @@
<p>
Use the checkbox below to ignore <b>public</b> <b>final</b> fields of an <b>enum</b> type.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/PublicFieldAccessedInSynchronizedContext.html b/plugins/InspectionGadgets/src/inspectionDescriptions/PublicFieldAccessedInSynchronizedContext.html
index 6df4728..9a68f73 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/PublicFieldAccessedInSynchronizedContext.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/PublicFieldAccessedInSynchronizedContext.html
@@ -5,6 +5,6 @@
access may result in unexpectedly inconsistent data structures.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/PublicInnerClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/PublicInnerClass.html
index 64b5ad2..9ca9715 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/PublicInnerClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/PublicInnerClass.html
@@ -7,6 +7,6 @@
<p>
Use the seconds checkbox below to ignore <b>public</b> inner interface.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/PublicMethodNotExposedInInterface.html b/plugins/InspectionGadgets/src/inspectionDescriptions/PublicMethodNotExposedInInterface.html
index e9562ee..e0cf044 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/PublicMethodNotExposedInInterface.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/PublicMethodNotExposedInInterface.html
@@ -11,6 +11,6 @@
Use the checkbox below to ignore methods of which the containing class does not
implement a non-library interface.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/PublicMethodWithoutLogging.html b/plugins/InspectionGadgets/src/inspectionDescriptions/PublicMethodWithoutLogging.html
index 6002b36..293498b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/PublicMethodWithoutLogging.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/PublicMethodWithoutLogging.html
@@ -8,6 +8,6 @@
Public methods which do not contain a call to a method of a variable with the type of one of the classes specified,
will be reported by this inspection.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/PublicStaticArrayField.html b/plugins/InspectionGadgets/src/inspectionDescriptions/PublicStaticArrayField.html
index f95b329..3c0d14d 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/PublicStaticArrayField.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/PublicStaticArrayField.html
@@ -5,6 +5,6 @@
hazard, as their contents may be modified, even if the field is declared as <b>final</b>.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/PublicStaticCollectionField.html b/plugins/InspectionGadgets/src/inspectionDescriptions/PublicStaticCollectionField.html
index 368b609..113ccbe 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/PublicStaticCollectionField.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/PublicStaticCollectionField.html
@@ -5,6 +5,6 @@
hazard, as their contents may be modified, even if the field is declared as <b>final</b>.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/QuestionableName.html b/plugins/InspectionGadgets/src/inspectionDescriptions/QuestionableName.html
index d9ae47c..b5c6ef6 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/QuestionableName.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/QuestionableName.html
@@ -7,6 +7,6 @@
<p>
Use the list below to specify names which should be reported
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/RandomDoubleForRandomInteger.html b/plugins/InspectionGadgets/src/inspectionDescriptions/RandomDoubleForRandomInteger.html
index 2f1c40e..e60d301 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/RandomDoubleForRandomInteger.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/RandomDoubleForRandomInteger.html
@@ -6,6 +6,6 @@
<b>java.util.Random.getInt()</b> is more efficient.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/RawUseOfParameterizedType.html b/plugins/InspectionGadgets/src/inspectionDescriptions/RawUseOfParameterizedType.html
index c12c6c3..a919fce 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/RawUseOfParameterizedType.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/RawUseOfParameterizedType.html
@@ -14,6 +14,6 @@
<p>
Use the third checkbox to ignore raw types in places where parameterized types would not be compilable
(for example in array creation expressions)
-<p><small>Powered by InspectionGadgets</small>
+<p>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ReadObjectAndWriteObjectPrivate.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ReadObjectAndWriteObjectPrivate.html
index 7c8caaa..7442b27 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ReadObjectAndWriteObjectPrivate.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ReadObjectAndWriteObjectPrivate.html
@@ -5,6 +5,6 @@
have greater visibility than that.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ReadObjectInitialization.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ReadObjectInitialization.html
index 9fb16da..33e03a2 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ReadObjectInitialization.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ReadObjectInitialization.html
@@ -7,6 +7,6 @@
as uninitialized incorrectly. Variables reported as initialized will always be initialized.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ReadResolveAndWriteReplaceProtected.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ReadResolveAndWriteReplaceProtected.html
index 96617fa..694f086 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ReadResolveAndWriteReplaceProtected.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ReadResolveAndWriteReplaceProtected.html
@@ -6,6 +6,6 @@
declared <b>private</b>, instead.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/RecordStoreResource.html b/plugins/InspectionGadgets/src/inspectionDescriptions/RecordStoreResource.html
index ae185d9..1f995d5 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/RecordStoreResource.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/RecordStoreResource.html
@@ -8,6 +8,6 @@
be inadvertently leaked if an exception is thrown before the resource is closed.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/RedundantFieldInitialization.html b/plugins/InspectionGadgets/src/inspectionDescriptions/RedundantFieldInitialization.html
index 1026a24..ab3b33b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/RedundantFieldInitialization.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/RedundantFieldInitialization.html
@@ -4,6 +4,6 @@
the same values that the JVM would initialize them to by default.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/RedundantImplements.html b/plugins/InspectionGadgets/src/inspectionDescriptions/RedundantImplements.html
index 2553166..b0d7a7e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/RedundantImplements.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/RedundantImplements.html
@@ -5,6 +5,6 @@
of that class. Such declarations are unnecessary, and may be safely removed.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/RedundantImport.html b/plugins/InspectionGadgets/src/inspectionDescriptions/RedundantImport.html
index 9b19d2b..194c99d 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/RedundantImport.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/RedundantImport.html
@@ -7,6 +7,6 @@
for off-line reporting on code bases that you don't intend to change.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/RedundantMethodOverride.html b/plugins/InspectionGadgets/src/inspectionDescriptions/RedundantMethodOverride.html
index cb0767c..108eee1 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/RedundantMethodOverride.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/RedundantMethodOverride.html
@@ -4,6 +4,6 @@
to its super method. Such a method is redundant and probably a coding error.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/RedundantStringFormatCall.html b/plugins/InspectionGadgets/src/inspectionDescriptions/RedundantStringFormatCall.html
index a9d0a87..8e16d63 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/RedundantStringFormatCall.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/RedundantStringFormatCall.html
@@ -5,6 +5,6 @@
the string.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ReflectionForUnavailableAnnotation.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ReflectionForUnavailableAnnotation.html
index 42ef1cd..a8312d0 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ReflectionForUnavailableAnnotation.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ReflectionForUnavailableAnnotation.html
@@ -7,6 +7,6 @@
but is easy to do inadvertently.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/RefusedBequest.html b/plugins/InspectionGadgets/src/inspectionDescriptions/RefusedBequest.html
index aae5e4b..e496e08 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/RefusedBequest.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/RefusedBequest.html
@@ -6,6 +6,6 @@
from <b>java.lang.Object</b> are not reported by this inspection.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ReplaceAllDot.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ReplaceAllDot.html
index 55ca588..0cc8440 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ReplaceAllDot.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ReplaceAllDot.html
@@ -7,6 +7,6 @@
More probably, <b>replaceAll("\.", ...)</b> was intended.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ReplaceAssignmentWithOperatorAssignment.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ReplaceAssignmentWithOperatorAssignment.html
index 0404e0f..b8f9d9d 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ReplaceAssignmentWithOperatorAssignment.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ReplaceAssignmentWithOperatorAssignment.html
@@ -8,6 +8,6 @@
and <b>||</b>. Replacing conditional operators with operator
assignment modifies the semantics of the expression.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ResultOfObjectAllocationIgnored.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ResultOfObjectAllocationIgnored.html
index a07bfe7..7970e18 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ResultOfObjectAllocationIgnored.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ResultOfObjectAllocationIgnored.html
@@ -5,6 +5,6 @@
evidence of a very odd object initialization strategy.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ResultSetIndexZero.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ResultSetIndexZero.html
index a126da4..281a053 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ResultSetIndexZero.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ResultSetIndexZero.html
@@ -5,6 +5,6 @@
0, and accessing column 0 is a common error in JDBC programming.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ReturnFromFinallyBlock.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ReturnFromFinallyBlock.html
index 4c9f0cd..48c1caf 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ReturnFromFinallyBlock.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ReturnFromFinallyBlock.html
@@ -5,6 +5,6 @@
tremendously complicate debugging.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ReturnNull.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ReturnNull.html
index d6c5f43..70255c1 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ReturnNull.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ReturnNull.html
@@ -12,6 +12,6 @@
<b>null</b> values on array returns, collection
object returns, plain object returns, or a combination of the three.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ReturnOfCollectionField.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ReturnOfCollectionField.html
index 38bc67a..b755982 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ReturnOfCollectionField.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ReturnOfCollectionField.html
@@ -6,6 +6,6 @@
reasons, this construct is inherently bug-prone.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ReturnOfDateField.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ReturnOfDateField.html
index 3667f76..ea0cd11 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ReturnOfDateField.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ReturnOfDateField.html
@@ -11,6 +11,6 @@
Use the checkbox below to ignore private methods returning a <b>java.lang.Date</b> or
<b>java.lang.Calendar</b> field.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ReturnThis.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ReturnThis.html
index 8995be9..fb0993f 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ReturnThis.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ReturnThis.html
@@ -6,6 +6,6 @@
Such chains are frowned upon by many coding standards.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ReuseOfLocalVariable.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ReuseOfLocalVariable.html
index 1916f1f..e974039 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ReuseOfLocalVariable.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ReuseOfLocalVariable.html
@@ -8,6 +8,6 @@
reuse local variables for the sake of brevity.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/RuntimeExec.html b/plugins/InspectionGadgets/src/inspectionDescriptions/RuntimeExec.html
index ef5e0a7..e266c7c 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/RuntimeExec.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/RuntimeExec.html
@@ -5,6 +5,6 @@
between operating systems.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/RuntimeExecWithNonConstantString.html b/plugins/InspectionGadgets/src/inspectionDescriptions/RuntimeExecWithNonConstantString.html
index a91fdf2..cea8224 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/RuntimeExecWithNonConstantString.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/RuntimeExecWithNonConstantString.html
@@ -5,6 +5,6 @@
Constructed execution strings are a common source of security breaches.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SafeLock.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SafeLock.html
index 053b379..49a0dfa 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SafeLock.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SafeLock.html
@@ -5,6 +5,6 @@
be inadvertently leaked if an exception is thrown before the resource is closed.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SamePackageImport.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SamePackageImport.html
index 9949eef..356ca83 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SamePackageImport.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SamePackageImport.html
@@ -7,6 +7,6 @@
code bases that you don't intend to change.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SerialPersistentFieldsWithWrongSignature.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SerialPersistentFieldsWithWrongSignature.html
index 6d8e158..69aaa63 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SerialPersistentFieldsWithWrongSignature.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SerialPersistentFieldsWithWrongSignature.html
@@ -4,6 +4,6 @@
is not declared <b>private static final ObjectStreamField</font ></b>.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SerialVersionUIDNotStaticFinal.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SerialVersionUIDNotStaticFinal.html
index ed4a47c..b993a2e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SerialVersionUIDNotStaticFinal.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SerialVersionUIDNotStaticFinal.html
@@ -4,6 +4,6 @@
is not declared <b>private static final long</font ></b>.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SerializableClassInSecureContext.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SerializableClassInSecureContext.html
index ca87c7c..9a3f69c 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SerializableClassInSecureContext.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SerializableClassInSecureContext.html
@@ -8,6 +8,6 @@
<p>
Use the checkbox below to ignore classes extending <b>Throwable</b> directly.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SerializableHasSerialVersionUIDField.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SerializableHasSerialVersionUIDField.html
index 0d18028..7800aa4 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SerializableHasSerialVersionUIDField.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SerializableHasSerialVersionUIDField.html
@@ -11,6 +11,6 @@
<p>
Use the checkbox below to ignore <b>Serializable</b> anonymous classes.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SerializableHasSerializationMethods.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SerializableHasSerializationMethods.html
index d1bd814..b8f29ef 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SerializableHasSerializationMethods.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SerializableHasSerializationMethods.html
@@ -13,6 +13,6 @@
Serializable from a superclass, are not intended for serialization. Such classes would lead this
inspection to report unnecessarily.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SerializableInnerClassHasSerialVersionUIDField.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SerializableInnerClassHasSerialVersionUIDField.html
index a5f9f1f..d00c4ec 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SerializableInnerClassHasSerialVersionUIDField.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SerializableInnerClassHasSerialVersionUIDField.html
@@ -14,6 +14,6 @@
Serializable from a superclass, are not intended for serialization. Such classes would lead this
inspection to report unnecessarily.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SerializableInnerClassWithNonSerializableOuterClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SerializableInnerClassWithNonSerializableOuterClass.html
index e859764..084cc82 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SerializableInnerClassWithNonSerializableOuterClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SerializableInnerClassWithNonSerializableOuterClass.html
@@ -10,6 +10,6 @@
Serializable from a superclass, are not intended for serialization. Such classes would lead this
inspection to report unnecessarily.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SerializableWithUnconstructableAncestor.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SerializableWithUnconstructableAncestor.html
index bce817e..4831220 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SerializableWithUnconstructableAncestor.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SerializableWithUnconstructableAncestor.html
@@ -4,6 +4,6 @@
a no-argument constructor. Such classes can not be deserialized.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SetReplaceableByEnumSet.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SetReplaceableByEnumSet.html
index 215af92..31d138d 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SetReplaceableByEnumSet.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SetReplaceableByEnumSet.html
@@ -7,6 +7,6 @@
that those of other sets, as the underlying data structure is a simple bitmap.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SetupCallsSuperSetup.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SetupCallsSuperSetup.html
index d4b99ca..114eaf5 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SetupCallsSuperSetup.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SetupCallsSuperSetup.html
@@ -4,6 +4,6 @@
does not call <b>super.setUp()</b>.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SetupIsPublicVoidNoArg.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SetupIsPublicVoidNoArg.html
index f5368b2..5b7b333 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SetupIsPublicVoidNoArg.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SetupIsPublicVoidNoArg.html
@@ -7,6 +7,6 @@
and will not be executed by JUnit tests runners.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ShiftOutOfRange.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ShiftOutOfRange.html
index 502947e..4fb67e0 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ShiftOutOfRange.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ShiftOutOfRange.html
@@ -7,6 +7,6 @@
a coding error.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SignalWithoutCorrespondingAwait.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SignalWithoutCorrespondingAwait.html
index 330165e..3924366 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SignalWithoutCorrespondingAwait.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SignalWithoutCorrespondingAwait.html
@@ -6,6 +6,6 @@
can be found. Only calls which target fields of the current class are reported by this inspection.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SimpleDateFormatWithoutLocale.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SimpleDateFormatWithoutLocale.html
index c918a6f..3b1b6c2 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SimpleDateFormatWithoutLocale.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SimpleDateFormatWithoutLocale.html
@@ -5,6 +5,6 @@
Such calls are usually incorrect in an internationalized environment.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SimplifiableAnnotation.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SimplifiableAnnotation.html
index b65732f..94cd40b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SimplifiableAnnotation.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SimplifiableAnnotation.html
@@ -5,6 +5,6 @@
of the annotation are also reported.
<!-- tooltip end -->
<p>
-<small>New in 10, Powered by InspectionGadgets </small>
+<small>New in 10 </small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SimplifiableConditionalExpression.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SimplifiableConditionalExpression.html
index 510ea1e..e35cdfd 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SimplifiableConditionalExpression.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SimplifiableConditionalExpression.html
@@ -8,6 +8,6 @@
<b>!<i>condition</i> && <i>foo</i></b>, respectively.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SimplifiableEqualsExpression.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SimplifiableEqualsExpression.html
index 5554a5d..ded9547 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SimplifiableEqualsExpression.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SimplifiableEqualsExpression.html
@@ -13,6 +13,6 @@
</pre></code>
<!-- tooltip end -->
<p>
-<small>New in 11, Powered by InspectionGadgets </small>
+<small>New in 11 </small>
</body>
</html>
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SimplifiableIfStatement.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SimplifiableIfStatement.html
index 8c7e4ac..398d5cb 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SimplifiableIfStatement.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SimplifiableIfStatement.html
@@ -11,6 +11,6 @@
<b>return !<i>condition</i> || <i>foo</i></b>, respectively.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SimplifiableJUnitAssertion.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SimplifiableJUnitAssertion.html
index 1da5159..ef6237b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SimplifiableJUnitAssertion.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SimplifiableJUnitAssertion.html
@@ -5,6 +5,6 @@
calls will normally give better error messages in case of test failure than <b>assertTrue</b> can.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SingleCharacterStartsWith.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SingleCharacterStartsWith.html
index 49b39dd..098ca5f 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SingleCharacterStartsWith.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SingleCharacterStartsWith.html
@@ -11,6 +11,6 @@
code clarity, it is recommended to do so only inside tight loops.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SingleClassImport.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SingleClassImport.html
index 037e99c..45f5bd6 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SingleClassImport.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SingleClassImport.html
@@ -6,6 +6,6 @@
for off-line reporting on code bases that you don't intend to change.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/Singleton.html b/plugins/InspectionGadgets/src/inspectionDescriptions/Singleton.html
index 16a837b..dabc6ee 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/Singleton.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/Singleton.html
@@ -6,6 +6,6 @@
and their presence may indicate a lack of object-oriented design.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SizeReplaceableByIsEmpty.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SizeReplaceableByIsEmpty.html
index 79843f5..e6b6aa7 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SizeReplaceableByIsEmpty.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SizeReplaceableByIsEmpty.html
@@ -8,6 +8,6 @@
<p>
Use the checkbox below to ignore any expressions which would be replaced with '!isEmpty()'.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SleepWhileHoldingLock.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SleepWhileHoldingLock.html
index cd88c35..74bef54 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SleepWhileHoldingLock.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SleepWhileHoldingLock.html
@@ -7,6 +7,6 @@
as it will release the lock held.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SocketResource.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SocketResource.html
index 462d319..834e624 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SocketResource.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SocketResource.html
@@ -13,6 +13,6 @@
block. This style is less desirable because it is more verbose than opening a Socket
in front of a try block.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StandardVariableNames.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StandardVariableNames.html
index 786b264..f10817b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StandardVariableNames.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StandardVariableNames.html
@@ -14,6 +14,6 @@
<!-- tooltip end -->
<p>
Use the checkbox below to ignore parameter names which are identical to the parameter name from a direct super method.
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StaticCallOnSubclass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StaticCallOnSubclass.html
index e30d25a..0103f5b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StaticCallOnSubclass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StaticCallOnSubclass.html
@@ -6,6 +6,6 @@
may be confusing, and may indicate a subtle confusion of inheritance and overriding.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StaticCollection.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StaticCollection.html
index e645ae3..27728b3 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StaticCollection.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StaticCollection.html
@@ -5,6 +5,6 @@
therefore prohibited by some coding standards.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StaticFieldCanBeMovedToUse.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StaticFieldCanBeMovedToUse.html
index 2d2f885..03da449 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StaticFieldCanBeMovedToUse.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StaticFieldCanBeMovedToUse.html
@@ -5,6 +5,6 @@
Since this inspection requires global code analysis, it is only available in batch inspection mode.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StaticFieldReferenceOnSubclass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StaticFieldReferenceOnSubclass.html
index 913b818..a2b4d2c 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StaticFieldReferenceOnSubclass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StaticFieldReferenceOnSubclass.html
@@ -6,6 +6,6 @@
may be confusing, and may indicate a subtle confusion of inheritance and overriding.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StaticImport.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StaticImport.html
index 1904a0f..1a2762d 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StaticImport.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StaticImport.html
@@ -4,6 +4,6 @@
Such import statements are not supported under Java 1.4 or earlier JVMs.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StaticInheritance.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StaticInheritance.html
index 4c623de..c8259f7 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StaticInheritance.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StaticInheritance.html
@@ -5,6 +5,6 @@
information.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StaticMethodNamingConvention.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StaticMethodNamingConvention.html
index be324e1..c0ced0b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StaticMethodNamingConvention.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StaticMethodNamingConvention.html
@@ -5,8 +5,8 @@
<!-- tooltip end -->
<p>
Use the fields below to specify minimum length, maximum length and regular expression expected for static method names.
-(Regular expressions are in standard <b>java.util.regex</b> format.)
+Specify <b>0</b> to not check the length of names. Regular expressions are in standard <b>java.util.regex</b> format.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StaticMethodOnlyUsedInOneClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StaticMethodOnlyUsedInOneClass.html
index 50c0795..e308935 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StaticMethodOnlyUsedInOneClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StaticMethodOnlyUsedInOneClass.html
@@ -9,6 +9,6 @@
<p>
Use the checkbox below to have this inspection not report when the static method is only used from a test class.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StaticNonFinalField.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StaticNonFinalField.html
index 649cd17..173d0b0 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StaticNonFinalField.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StaticNonFinalField.html
@@ -3,6 +3,6 @@
Reports non-<b>final</b> <b>static</b> fields.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StaticSuite.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StaticSuite.html
index 830ed19..9b9308a 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StaticSuite.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StaticSuite.html
@@ -4,6 +4,6 @@
are not declared <b>static</b>.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StaticVariableInitialization.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StaticVariableInitialization.html
index 38fba0a..3dfd1c9 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StaticVariableInitialization.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StaticVariableInitialization.html
@@ -8,6 +8,6 @@
<p>
Use the checkbox below to indicate whether you want uninitialized primitive fields to be reported.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StaticVariableNamingConvention.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StaticVariableNamingConvention.html
index 54040ee..a269935 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StaticVariableNamingConvention.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StaticVariableNamingConvention.html
@@ -6,8 +6,8 @@
<!-- tooltip end -->
<p>
Use the fields below to specify minimum length, maximum length and regular expression expected for static variable names.
-(Regular expressions are in standard <b>java.util.regex</b> format.)
+Specify <b>0</b> to not check the length of names. Regular expressions are in standard <b>java.util.regex</b> format.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StaticVariableOfConcreteClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StaticVariableOfConcreteClass.html
index bb26904..1a67d2b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StaticVariableOfConcreteClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StaticVariableOfConcreteClass.html
@@ -7,6 +7,6 @@
<p>
Use the checkbox below to have this inspection ignore static fields whose type is an abstract class.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StaticVariableUninitializedUse.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StaticVariableUninitializedUse.html
index 0fe8905..d2f04be 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StaticVariableUninitializedUse.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StaticVariableUninitializedUse.html
@@ -8,6 +8,6 @@
<p>
Use the checkbox below to indicate whether you want uninitialized primitive fields to be reported.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StringBufferField.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StringBufferField.html
index 5f0822d..a66e77b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StringBufferField.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StringBufferField.html
@@ -6,6 +6,6 @@
memory leaks.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StringBufferMustHaveInitialCapacity.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StringBufferMustHaveInitialCapacity.html
index 9bd6586..6c85364 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StringBufferMustHaveInitialCapacity.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StringBufferMustHaveInitialCapacity.html
@@ -7,6 +7,6 @@
memory copied when capacity is exceeded
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StringBufferReplaceableByString.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StringBufferReplaceableByString.html
index 9a9217f..9ab43de 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StringBufferReplaceableByString.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StringBufferReplaceableByString.html
@@ -5,6 +5,6 @@
more efficient code.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StringBufferReplaceableByStringBuilder.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StringBufferReplaceableByStringBuilder.html
index 58fb44e..a40000c 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StringBufferReplaceableByStringBuilder.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StringBufferReplaceableByStringBuilder.html
@@ -9,6 +9,6 @@
language level of 5.0 or higher.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StringBufferToStringInConcatenation.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StringBufferToStringInConcatenation.html
index 57b96ed..215f450 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StringBufferToStringInConcatenation.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StringBufferToStringInConcatenation.html
@@ -6,6 +6,6 @@
as of JDK1.4.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StringCompareTo.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StringCompareTo.html
index 6f340b0..d4bf66f 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StringCompareTo.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StringCompareTo.html
@@ -4,6 +4,6 @@
incorrect in an internationalized environment.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StringConcatenation.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StringConcatenation.html
index 3a4adf7..2de1513 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StringConcatenation.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StringConcatenation.html
@@ -24,6 +24,6 @@
<p>
Use the seventh checkbox to ignore string concatentations inside <b>toString()</b> methods.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StringConcatenationArgumentToLogCall.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StringConcatenationArgumentToLogCall.html
index c792888..06353a6 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StringConcatenationArgumentToLogCall.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StringConcatenationArgumentToLogCall.html
@@ -5,6 +5,6 @@
It is recommended to use a parameterized log message instead, which will not be evaluated when logging is disabled.
<!-- tooltip end -->
<p>
-<small>New in 12, Powered by InspectionGadgets </small>
+<small>New in 12 </small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StringConcatenationInFormatCall.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StringConcatenationInFormatCall.html
index b937ac3..c0a4b96 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StringConcatenationInFormatCall.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StringConcatenationInFormatCall.html
@@ -10,6 +10,6 @@
or <b>java.io.PrintStream</b>.
<!-- tooltip end -->
<p>
-<small>New in 10.0.2, Powered by InspectionGadgets </small>
+<small>New in 10.0.2 </small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StringConcatenationInLoops.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StringConcatenationInLoops.html
index 2306538..8d5603d 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StringConcatenationInLoops.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StringConcatenationInLoops.html
@@ -9,6 +9,6 @@
Use the checkbox below to indicate that this inspection should only warn when the same variable
is appended to inside the loop.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StringConcatenationInMessageFormatCall.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StringConcatenationInMessageFormatCall.html
index cc41692..e886a7f 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StringConcatenationInMessageFormatCall.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StringConcatenationInMessageFormatCall.html
@@ -6,6 +6,6 @@
a '+' when a ',' was meant.
<!-- tooltip end -->
<p>
-<small>New in 10.0.2, Powered by InspectionGadgets </small>
+<small>New in 10.0.2 </small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StringConcatenationInsideStringBufferAppend.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StringConcatenationInsideStringBufferAppend.html
index 098fd3e..04949cc 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StringConcatenationInsideStringBufferAppend.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StringConcatenationInsideStringBufferAppend.html
@@ -14,6 +14,6 @@
worsen performance.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StringConcatenationMissingWhitespace.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StringConcatenationMissingWhitespace.html
index 5d8ebdf..e63c62f 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StringConcatenationMissingWhitespace.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StringConcatenationMissingWhitespace.html
@@ -10,6 +10,6 @@
<p>
Use the checkbox below to have this inspection only report when both the left and right side of the concatenation are literals.
<p>
-<small>New in 12, Powered by InspectionGadgets</small>
+<small>New in 12</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StringConstructor.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StringConstructor.html
index a8ea2df..cbb5936 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StringConstructor.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StringConstructor.html
@@ -13,6 +13,6 @@
amount of garbage to stay in memory if the substring is small in relation to the
original <b>String</b>.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StringEquality.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StringEquality.html
index 54a5f36..0a4cc9b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StringEquality.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StringEquality.html
@@ -4,6 +4,6 @@
rather than the <b>".equals()"</b> method.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StringEquals.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StringEquals.html
index be1fa66..d9ad1a0 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StringEquals.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StringEquals.html
@@ -4,6 +4,6 @@
incorrect in an internationalized environment.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StringEqualsEmptyString.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StringEqualsEmptyString.html
index f8cbc8f..5709d55 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StringEqualsEmptyString.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StringEqualsEmptyString.html
@@ -5,6 +5,6 @@
by comparing its <b>.length()</b> to zero instead.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StringEqualsIgnoreCase.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StringEqualsIgnoreCase.html
index 14563db..3556e64 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StringEqualsIgnoreCase.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StringEqualsIgnoreCase.html
@@ -4,6 +4,6 @@
incorrect in an internationalized environment.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StringReplaceableByStringBuffer.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StringReplaceableByStringBuffer.html
index 65299e0..e7d3b3e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StringReplaceableByStringBuffer.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StringReplaceableByStringBuffer.html
@@ -8,6 +8,6 @@
Use the checkbox below to specify that this inspection should only warn when the variable is appended
to in a loop.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StringToString.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StringToString.html
index 8d20e87..6e9f5d1 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StringToString.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StringToString.html
@@ -4,6 +4,6 @@
This is entirely redundant.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StringToUpperWithoutLocale.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StringToUpperWithoutLocale.html
index badf65f..9b9cac6 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StringToUpperWithoutLocale.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StringToUpperWithoutLocale.html
@@ -6,6 +6,6 @@
Such calls are usually incorrect in an internationalized environment.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StringTokenizer.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StringTokenizer.html
index 2c96a81..47e474d 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StringTokenizer.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StringTokenizer.html
@@ -4,6 +4,6 @@
<b>StringTokenizer</b> are incorrect in an internationalized environment.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SubstringZero.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SubstringZero.html
index 6c0935a..0b43202 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SubstringZero.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SubstringZero.html
@@ -4,6 +4,6 @@
with a constant argument equal to zero. Such calls are completely redundant, and may be removed.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SubtractionInCompareTo.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SubtractionInCompareTo.html
index 6ef50b2..245c8da 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SubtractionInCompareTo.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SubtractionInCompareTo.html
@@ -1,13 +1,13 @@
<html>
<body>
Reports subtraction in
-<b>compareTo()</b> methods. While it is a common idiom to
-use the results of integer subtraction as the return of a <b>compareTo()</b>
+<b>compareTo()</b> methods and methods implementing <b>java.util.Comparator.compare()</b>. While it is a common idiom to
+use the results of integer subtraction as the result of a <b>compareTo()</b>
method, this construct may cause subtle and difficult bugs in cases of integer overflow.
Comparing the integer values directly and returning -1, 0, or 1 is better practice in almost
all cases.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SuppressionAnnotation.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SuppressionAnnotation.html
index 433d272..bbdcd04 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SuppressionAnnotation.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SuppressionAnnotation.html
@@ -3,6 +3,6 @@
Reports any inspection suppression comments or annotations.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SuspiciousArrayCast.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SuspiciousArrayCast.html
index 048f9cd..0176c71 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SuspiciousArrayCast.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SuspiciousArrayCast.html
@@ -4,6 +4,6 @@
a cast is legal at compile time but may fail with a <b>ClassCastException</b> at runtime.
<!-- tooltip end -->
<p>
-<small>New in 12, Powered by InspectionGadgets</small>
+<small>New in 12</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SuspiciousIndentAfterControlStatement.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SuspiciousIndentAfterControlStatement.html
index eef66c1..6970fec 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SuspiciousIndentAfterControlStatement.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SuspiciousIndentAfterControlStatement.html
@@ -5,6 +5,6 @@
statement, when in fact it will be executed after the control statement.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SuspiciousSystemArraycopy.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SuspiciousSystemArraycopy.html
index c72448c..cf2186e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SuspiciousSystemArraycopy.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SuspiciousSystemArraycopy.html
@@ -9,6 +9,6 @@
</ul>
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SuspiciousToArrayCall.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SuspiciousToArrayCall.html
index 5c7917f..baeec6f 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SuspiciousToArrayCall.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SuspiciousToArrayCall.html
@@ -6,6 +6,6 @@
the type parameter of the collection declaration.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SwitchStatement.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SwitchStatement.html
index c9f8277..124eb01 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SwitchStatement.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SwitchStatement.html
@@ -4,6 +4,6 @@
<b>switch</b> statements are often (but not always) indicators of poor object-oriented design.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SwitchStatementDensity.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SwitchStatementDensity.html
index dc3a4a2..f1c6772 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SwitchStatementDensity.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SwitchStatementDensity.html
@@ -5,6 +5,6 @@
may be confusing, and should probably be refactored.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SwitchStatementWithConfusingDeclaration.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SwitchStatementWithConfusingDeclaration.html
index bbc2cfd..e205502 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SwitchStatementWithConfusingDeclaration.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SwitchStatementWithConfusingDeclaration.html
@@ -4,6 +4,6 @@
and used in a different branch. Such declarations can be extremely confusing.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SwitchStatementWithTooFewBranches.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SwitchStatementWithTooFewBranches.html
index 0832a57..a87a213 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SwitchStatementWithTooFewBranches.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SwitchStatementWithTooFewBranches.html
@@ -6,6 +6,6 @@
<p>
Use the field below to specify the minimum number of <b>case</b> labels expected.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SwitchStatementWithTooManyBranches.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SwitchStatementWithTooManyBranches.html
index d1853c9..e579a11 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SwitchStatementWithTooManyBranches.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SwitchStatementWithTooManyBranches.html
@@ -5,6 +5,6 @@
<p>
Use the field below to specify the maximum number of <b>case</b> labels expected.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SwitchStatementsWithoutDefault.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SwitchStatementsWithoutDefault.html
index f2fca67..6f9a2a8 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SwitchStatementsWithoutDefault.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SwitchStatementsWithoutDefault.html
@@ -4,6 +4,6 @@
<b>default</b> labels.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SynchronizationOnLocalVariableOrMethodParameter.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SynchronizationOnLocalVariableOrMethodParameter.html
index 2f2293d..f306639 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SynchronizationOnLocalVariableOrMethodParameter.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SynchronizationOnLocalVariableOrMethodParameter.html
@@ -6,6 +6,6 @@
will usually be clearer if synchronization on a field is used.
<!-- tooltip end -->
<p>
-<small>New in 8, Powered by InspectionGadgets</small>
+<small>New in 8</small>
</body>
</html>
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SynchronizationOnStaticField.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SynchronizationOnStaticField.html
index 54eb793..537ac4d 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SynchronizationOnStaticField.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SynchronizationOnStaticField.html
@@ -4,6 +4,6 @@
synchronization on static fields can lead to bad performance because of contention.
<!-- tooltip end -->
<p>
-<small>New in 10, Powered by InspectionGadgets</small>
+<small>New in 10</small>
</body>
</html>
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SynchronizeOnLock.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SynchronizeOnLock.html
index da66174..69fd9e8 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SynchronizeOnLock.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SynchronizeOnLock.html
@@ -6,6 +6,6 @@
and <b>.unlock()</b> should be used instead.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SynchronizeOnNonFinalField.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SynchronizeOnNonFinalField.html
index c9afbaf..2ae175c 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SynchronizeOnNonFinalField.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SynchronizeOnNonFinalField.html
@@ -5,6 +5,6 @@
threads may be locking on different objects even when operating on the same object.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SynchronizeOnThis.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SynchronizeOnThis.html
index 155d75d..fcae0c9 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SynchronizeOnThis.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SynchronizeOnThis.html
@@ -9,6 +9,6 @@
locking on a private instance variable, access to which can be completely controlled.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SynchronizedMethod.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SynchronizedMethod.html
index 2016494..b5b65e6 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SynchronizedMethod.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SynchronizedMethod.html
@@ -4,6 +4,6 @@
prohibit the use of the <b>synchronized</b> modifier, in favor of <b>synchronized</b> statements.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SynchronizedOnLiteralObject.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SynchronizedOnLiteralObject.html
index cedf2b4..7f29ead 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SynchronizedOnLiteralObject.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SynchronizedOnLiteralObject.html
@@ -11,6 +11,6 @@
<p>
Use the checkbox below to warn on any synchronization on String, Character, Boolean and Number objects.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SystemExit.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SystemExit.html
index 81f2a5d..f9ba84d 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SystemExit.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SystemExit.html
@@ -7,6 +7,6 @@
<p>
Use the checkbox below to ignore calls in main methods.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SystemGC.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SystemGC.html
index 11f41d0..a11afef 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SystemGC.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SystemGC.html
@@ -5,6 +5,6 @@
a bad idea in production code, and can result in serious performance problems.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SystemGetenv.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SystemGetenv.html
index c06e4b3..97a50e8 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SystemGetenv.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SystemGetenv.html
@@ -4,6 +4,6 @@
Calls to <b>System.getenv()</b> are inherently unportable.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SystemOutErr.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SystemOutErr.html
index 5d0e7fa..b5eb5a4 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SystemOutErr.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SystemOutErr.html
@@ -5,6 +5,6 @@
logging facility.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SystemProperties.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SystemProperties.html
index 27ee4b6..4ca681d 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SystemProperties.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SystemProperties.html
@@ -5,6 +5,6 @@
Accesses to System properties should be closely examined in any security audit.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SystemRunFinalizersOnExit.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SystemRunFinalizersOnExit.html
index c8501fe..973829c 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SystemRunFinalizersOnExit.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SystemRunFinalizersOnExit.html
@@ -6,6 +6,6 @@
It is deprecated, and its use strongly discouraged.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SystemSetSecurityManager.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SystemSetSecurityManager.html
index 8bd05c1..da03d68 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SystemSetSecurityManager.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SystemSetSecurityManager.html
@@ -4,6 +4,6 @@
While often benign, any call to <b>System.setSecurityManager()</b> should be closely examined in any security audit.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/TailRecursion.html b/plugins/InspectionGadgets/src/inspectionDescriptions/TailRecursion.html
index d3bac93..ec0a399 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/TailRecursion.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/TailRecursion.html
@@ -6,6 +6,6 @@
performance characteristics on different virtual machines.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/TeardownCallsSuperTeardown.html b/plugins/InspectionGadgets/src/inspectionDescriptions/TeardownCallsSuperTeardown.html
index c4768af..369631f 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/TeardownCallsSuperTeardown.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/TeardownCallsSuperTeardown.html
@@ -4,6 +4,6 @@
does not call <b>super.tearDown()</b>.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/TeardownIsPublicVoidNoArg.html b/plugins/InspectionGadgets/src/inspectionDescriptions/TeardownIsPublicVoidNoArg.html
index a1664d9..9070b10 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/TeardownIsPublicVoidNoArg.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/TeardownIsPublicVoidNoArg.html
@@ -7,6 +7,6 @@
and will not be executed by JUnit tests runners.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/TestCaseInProductCode.html b/plugins/InspectionGadgets/src/inspectionDescriptions/TestCaseInProductCode.html
index 9731f4c..6b0c606 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/TestCaseInProductCode.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/TestCaseInProductCode.html
@@ -5,6 +5,6 @@
into production.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/TestCaseWithConstructor.html b/plugins/InspectionGadgets/src/inspectionDescriptions/TestCaseWithConstructor.html
index fb507d7..c28ce2c 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/TestCaseWithConstructor.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/TestCaseWithConstructor.html
@@ -4,6 +4,6 @@
of JUnit test cases should be done in <b>setUp()</b> methods instead.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/TestCaseWithNoTestMethods.html b/plugins/InspectionGadgets/src/inspectionDescriptions/TestCaseWithNoTestMethods.html
index 2387aaa..b351162 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/TestCaseWithNoTestMethods.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/TestCaseWithNoTestMethods.html
@@ -7,6 +7,6 @@
Use the checkbox below to specify that test cases which have super classes with
test methods should be ignored by this inspection.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/TestMethodInProductCode.html b/plugins/InspectionGadgets/src/inspectionDescriptions/TestMethodInProductCode.html
index f63c7e9..deb66cd 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/TestMethodInProductCode.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/TestMethodInProductCode.html
@@ -5,6 +5,6 @@
into production.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/TestMethodIsPublicVoidNoArg.html b/plugins/InspectionGadgets/src/inspectionDescriptions/TestMethodIsPublicVoidNoArg.html
index 137eb6c..a31b39a 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/TestMethodIsPublicVoidNoArg.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/TestMethodIsPublicVoidNoArg.html
@@ -7,6 +7,6 @@
JUnit test runners.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/TestMethodWithoutAssertion.html b/plugins/InspectionGadgets/src/inspectionDescriptions/TestMethodWithoutAssertion.html
index f99a055..0b89a8e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/TestMethodWithoutAssertion.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/TestMethodWithoutAssertion.html
@@ -6,6 +6,6 @@
qualify as assertions.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/TextLabelInSwitchStatement.html b/plugins/InspectionGadgets/src/inspectionDescriptions/TextLabelInSwitchStatement.html
index e7e8188..9a0cb52 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/TextLabelInSwitchStatement.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/TextLabelInSwitchStatement.html
@@ -13,6 +13,6 @@
</pre>
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ThisEscapedInConstructor.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ThisEscapedInConstructor.html
index 4598e74..2610f5f 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ThisEscapedInConstructor.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ThisEscapedInConstructor.html
@@ -7,6 +7,6 @@
available in a context in which it is not guaranteed to be initialized.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ThreadDeathRethrown.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ThreadDeathRethrown.html
index e970d7c..d531ad2 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ThreadDeathRethrown.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ThreadDeathRethrown.html
@@ -4,6 +4,6 @@
<b>java.lang.ThreadDeath</b> which do not rethrow the exception.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ThreadDumpStack.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ThreadDumpStack.html
index dda1146..f19930f 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ThreadDumpStack.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ThreadDumpStack.html
@@ -5,6 +5,6 @@
or replaced by a more robust logging facility.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ThreadLocalNotStaticFinal.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ThreadLocalNotStaticFinal.html
index c99538d..2cb9e55 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ThreadLocalNotStaticFinal.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ThreadLocalNotStaticFinal.html
@@ -9,6 +9,6 @@
<p>
This inspection has a quick fix to make the field <b>static final</b>
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ThreadPriority.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ThreadPriority.html
index 1684bf2..c18839b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ThreadPriority.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ThreadPriority.html
@@ -6,6 +6,6 @@
if they are used at all.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ThreadRun.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ThreadRun.html
index d499f04..12b1305 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ThreadRun.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ThreadRun.html
@@ -4,6 +4,6 @@
While occasionally intended, this is usually a mistake, with <b>start()</b> intended instead.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ThreadStartInConstruction.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ThreadStartInConstruction.html
index 2938c76..bfc1626 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ThreadStartInConstruction.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ThreadStartInConstruction.html
@@ -6,6 +6,6 @@
any initialization logic of their own before the thread has launched.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ThreadStopSuspendResume.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ThreadStopSuspendResume.html
index 6c15a88..c921b99 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ThreadStopSuspendResume.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ThreadStopSuspendResume.html
@@ -6,6 +6,6 @@
discouraged.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ThreadWithDefaultRunMethod.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ThreadWithDefaultRunMethod.html
index b6f719a..880d695 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ThreadWithDefaultRunMethod.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ThreadWithDefaultRunMethod.html
@@ -5,6 +5,6 @@
useful.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ThreadYield.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ThreadYield.html
index 2d37629..5b9ed38 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ThreadYield.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ThreadYield.html
@@ -5,6 +5,6 @@
and is often used by inexperienced programmers to mask race conditions.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ThreeNegationsPerMethod.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ThreeNegationsPerMethod.html
index 2bcdced..8b30ae5 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ThreeNegationsPerMethod.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ThreeNegationsPerMethod.html
@@ -6,6 +6,6 @@
<p>
Use the checkbox below to disable this inspection within 'equals()' methods.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ThrowCaughtLocally.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ThrowCaughtLocally.html
index fd79e47..ed69083 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ThrowCaughtLocally.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ThrowCaughtLocally.html
@@ -5,6 +5,6 @@
statements as a "goto" to change the local flow of control is both confusing and likely to have poor performance.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ThrowFromFinallyBlock.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ThrowFromFinallyBlock.html
index 5608323..e43d8d9 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ThrowFromFinallyBlock.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ThrowFromFinallyBlock.html
@@ -5,6 +5,6 @@
tremendously complicate debugging.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ThrowableInstanceNeverThrown.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ThrowableInstanceNeverThrown.html
index 63f65d9..29125e8 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ThrowableInstanceNeverThrown.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ThrowableInstanceNeverThrown.html
@@ -5,6 +5,6 @@
is never actually thrown. Most often this is the result of a simple mistake.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ThrowablePrintStackTrace.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ThrowablePrintStackTrace.html
index 4a60995..269cb64 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ThrowablePrintStackTrace.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ThrowablePrintStackTrace.html
@@ -5,6 +5,6 @@
or replaced by a more robust logging facility.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ThrowableResultOfMethodCallIgnored.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ThrowableResultOfMethodCallIgnored.html
index c29d801..0a3468b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ThrowableResultOfMethodCallIgnored.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ThrowableResultOfMethodCallIgnored.html
@@ -6,6 +6,6 @@
as factory methods for exceptions and the result should be thrown.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ThrownExceptionsPerMethod.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ThrownExceptionsPerMethod.html
index 4c94a5d..8a6b032 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ThrownExceptionsPerMethod.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ThrownExceptionsPerMethod.html
@@ -7,6 +7,6 @@
<p>
Use the field below to specify the maximum number of <b>throws</b> clauses a method might have.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ThrowsRuntimeException.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ThrowsRuntimeException.html
index eb857bc..56f3199 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ThrowsRuntimeException.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ThrowsRuntimeException.html
@@ -4,6 +4,6 @@
Declaration of unchecked exceptions are not required and may be removed or moved to a Javadoc <b>@throws</b> tag.
<!-- tooltip end -->
<p>
-<small>New in 11, Powered by InspectionGadgets</small>
+<small>New in 11</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/TimeToString.html b/plugins/InspectionGadgets/src/inspectionDescriptions/TimeToString.html
index 3e5cc27..451f29e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/TimeToString.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/TimeToString.html
@@ -4,6 +4,6 @@
incorrect in an internationalized environment.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ToArrayCallWithZeroLengthArrayArgument.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ToArrayCallWithZeroLengthArrayArgument.html
index 632ac66..22e7f1c 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ToArrayCallWithZeroLengthArrayArgument.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ToArrayCallWithZeroLengthArrayArgument.html
@@ -8,6 +8,6 @@
in an array of at least the size of the collection itself.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/TodoComment.html b/plugins/InspectionGadgets/src/inspectionDescriptions/TodoComment.html
index 9db3ffe..9a951cd 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/TodoComment.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/TodoComment.html
@@ -6,6 +6,6 @@
be used in batch mode.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/TooBroadCatch.html b/plugins/InspectionGadgets/src/inspectionDescriptions/TooBroadCatch.html
index ffbe0df..14b73fa 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/TooBroadCatch.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/TooBroadCatch.html
@@ -11,6 +11,6 @@
Use the third checkbox below to ignore any exceptions which hide other exceptions, but which may be thrown and thus
are technically not overly broad.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/TooBroadScope.html b/plugins/InspectionGadgets/src/inspectionDescriptions/TooBroadScope.html
index d8f371a..0e394bf 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/TooBroadScope.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/TooBroadScope.html
@@ -10,6 +10,6 @@
constructor has non-local side-effects, but make it more powerful in that it can find objects
that are allocated before necessary, causing increased memory usage.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/TooBroadThrows.html b/plugins/InspectionGadgets/src/inspectionDescriptions/TooBroadThrows.html
index 2760504..0a0b078 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/TooBroadThrows.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/TooBroadThrows.html
@@ -13,6 +13,6 @@
Use the fourth checkbox below to ignore any exceptions which hide other exceptions, but which may be thrown from the method body and thus
are technically not overly broad.
<p>
-<small>New in 10, Powered by InspectionGadgets</small>
+<small>New in 10</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/TransientFieldInNonSerializableClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/TransientFieldInNonSerializableClass.html
index b11cb80..27dc334 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/TransientFieldInNonSerializableClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/TransientFieldInNonSerializableClass.html
@@ -3,6 +3,6 @@
Reports <b>transient</b> fields in non-<b>Serializable</b> classes.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/TransientFieldNotInitialized.html b/plugins/InspectionGadgets/src/inspectionDescriptions/TransientFieldNotInitialized.html
index d974b33..131cd15 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/TransientFieldNotInitialized.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/TransientFieldNotInitialized.html
@@ -10,6 +10,6 @@
initialization and are not reported by this inspection.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/TrivialIf.html b/plugins/InspectionGadgets/src/inspectionDescriptions/TrivialIf.html
index 24161e2..4c31fbf 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/TrivialIf.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/TrivialIf.html
@@ -17,6 +17,6 @@
</pre></code>
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/TrivialStringConcatenation.html b/plugins/InspectionGadgets/src/inspectionDescriptions/TrivialStringConcatenation.html
index 31e38d7..72a944c 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/TrivialStringConcatenation.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/TrivialStringConcatenation.html
@@ -5,6 +5,6 @@
an idiom for formatting non-String objects or primitives into Strings.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/TryFinallyCanBeTryWithResources.html b/plugins/InspectionGadgets/src/inspectionDescriptions/TryFinallyCanBeTryWithResources.html
index 28b8411..6cbca36 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/TryFinallyCanBeTryWithResources.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/TryFinallyCanBeTryWithResources.html
@@ -7,6 +7,6 @@
This inspection only reports if the project or module is configured to use a
language level of 7.0 or higher.
<!-- tooltip end -->
-<p><small>New in 10.5, Powered by InspectionGadgets</small>
+<p><small>New in 10.5</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/TryWithIdenticalCatches.html b/plugins/InspectionGadgets/src/inspectionDescriptions/TryWithIdenticalCatches.html
index 3b10d77..e9d9648 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/TryWithIdenticalCatches.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/TryWithIdenticalCatches.html
@@ -6,6 +6,6 @@
This inspection only reports if the project or module is configured to use a
language level of 7.0 or higher.
<!-- tooltip end -->
-<p><small>New in 10.5, Powered by InspectionGadgets</small>
+<p><small>New in 10.5</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/TypeMayBeWeakened.html b/plugins/InspectionGadgets/src/inspectionDescriptions/TypeMayBeWeakened.html
index abda9d4..4b59429 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/TypeMayBeWeakened.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/TypeMayBeWeakened.html
@@ -23,6 +23,6 @@
weakened to <b>java.lang.Object</b>. Weakening to
<b>java.lang.Object</b> is often not very useful.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/TypeParameterExtendsFinalClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/TypeParameterExtendsFinalClass.html
index 3716bd2..17dbf12 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/TypeParameterExtendsFinalClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/TypeParameterExtendsFinalClass.html
@@ -5,6 +5,6 @@
of the specified final class.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/TypeParameterExtendsObject.html b/plugins/InspectionGadgets/src/inspectionDescriptions/TypeParameterExtendsObject.html
index eb3b822..d0e968a 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/TypeParameterExtendsObject.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/TypeParameterExtendsObject.html
@@ -3,6 +3,6 @@
Reports any type parameters explicitly declared to extend <b>java.lang.Object</b>.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/TypeParameterHidesVisibleType.html b/plugins/InspectionGadgets/src/inspectionDescriptions/TypeParameterHidesVisibleType.html
index 6bfc108..8d9831a 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/TypeParameterHidesVisibleType.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/TypeParameterHidesVisibleType.html
@@ -4,6 +4,6 @@
identically to visible types in the current scope. Such a parameter name may be confusing.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/TypeParameterNamingConvention.html b/plugins/InspectionGadgets/src/inspectionDescriptions/TypeParameterNamingConvention.html
index c305e8a..24fe0d4 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/TypeParameterNamingConvention.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/TypeParameterNamingConvention.html
@@ -5,8 +5,8 @@
<!-- tooltip end -->
<p>
Use the fields below to specify minimum length, maximum length and regular expression expected for type parameter names.
-(Regular expressions are in standard <b>java.util.regex</b> format.)
+Specify <b>0</b> to not check the length of names. Regular expressions are in standard <b>java.util.regex</b> format.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnaryPlus.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnaryPlus.html
index 9425d50..698a8be 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnaryPlus.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnaryPlus.html
@@ -4,6 +4,6 @@
its presence may represent a coding error, particularly in combination with the increment operator, '++'.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UncheckedExceptionClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UncheckedExceptionClass.html
index ef33d8f..1df2b81 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UncheckedExceptionClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UncheckedExceptionClass.html
@@ -4,6 +4,6 @@
Certain coding standards require that all user-defined exception classes be checked.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnclearBinaryExpression.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnclearBinaryExpression.html
index 17ace83..837a1fb 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnclearBinaryExpression.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnclearBinaryExpression.html
@@ -5,6 +5,6 @@
of the different operators. This inspection has a quickfix which adds clarifying parentheses.
<!-- tooltip end -->
<p>
-<small>New in 11, Powered by InspectionGadgets</small>
+<small>New in 11</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnconditionalWait.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnconditionalWait.html
index 6bfd8e6..948a14b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnconditionalWait.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnconditionalWait.html
@@ -10,6 +10,6 @@
are not necessarily incorrect, they are certainly worth examining.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnconstructableTestCase.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnconstructableTestCase.html
index 037bff5..85faeda 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnconstructableTestCase.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnconstructableTestCase.html
@@ -6,6 +6,6 @@
IDEA's.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessarilyQualifiedInnerClassAccess.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessarilyQualifiedInnerClassAccess.html
index 8e514db..d76730e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessarilyQualifiedInnerClassAccess.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessarilyQualifiedInnerClassAccess.html
@@ -8,6 +8,6 @@
Use the checkbox below to ignore references to inner classes where the removal of the qualification
would require the addition of an import.
<p>
-<small>New in 10, Powered by InspectionGadgets</small>
+<small>New in 10</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessarilyQualifiedStaticUsage.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessarilyQualifiedStaticUsage.html
index 680c243..0532833 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessarilyQualifiedStaticUsage.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessarilyQualifiedStaticUsage.html
@@ -5,6 +5,6 @@
and may be safely removed.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessarilyQualifiedStaticallyImportedElement.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessarilyQualifiedStaticallyImportedElement.html
index 4d508ae..f0cb4d4 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessarilyQualifiedStaticallyImportedElement.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessarilyQualifiedStaticallyImportedElement.html
@@ -5,6 +5,6 @@
and can be removed.
<!-- tooltip end -->
<p>
-<small>New in 10, Powered by InspectionGadgets</small>
+<small>New in 10</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryBlockStatement.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryBlockStatement.html
index ffb4514..6a5af80 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryBlockStatement.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryBlockStatement.html
@@ -8,6 +8,6 @@
<p>
Use the checkbox below if you wish this inspection to ignore code blocks which are used as branches of switch statements.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryBoxing.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryBoxing.html
index 68d7fa5..b657195 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryBoxing.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryBoxing.html
@@ -7,6 +7,6 @@
language level of 5.0 or higher.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryCallToStringValueOf.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryCallToStringValueOf.html
index ecbdf6f..c5214ff 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryCallToStringValueOf.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryCallToStringValueOf.html
@@ -5,6 +5,6 @@
to string will be handled by the underlying library methods without an explicit call to <b>String.valueOf()</b>.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryConditionalExpression.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryConditionalExpression.html
index ae9cea2..f839cfb 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryConditionalExpression.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryConditionalExpression.html
@@ -5,6 +5,6 @@
to <b><i>condition</i></b> or <b>!<i>condition</i></b>, respectively.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryConstantArrayCreationExpression.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryConstantArrayCreationExpression.html
index 965c156..05cedc3 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryConstantArrayCreationExpression.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryConstantArrayCreationExpression.html
@@ -6,6 +6,6 @@
assigned to.
<!-- tooltip end -->
<p>
-<small>New in 8, Powered by InspectionGadgets</small>
+<small>New in 8</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryConstructor.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryConstructor.html
index 01a79e4..b7bff96 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryConstructor.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryConstructor.html
@@ -8,6 +8,6 @@
<p>
Use the checkbox below to ignore unnecessary constructors which have an annotation.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryContinue.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryContinue.html
index 91b16f2..442e854 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryContinue.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryContinue.html
@@ -6,6 +6,6 @@
At present, this inspection is disabled in JSP files.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryDefault.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryDefault.html
index a721c95..1772229 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryDefault.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryDefault.html
@@ -6,6 +6,6 @@
over enumerated types all of whose values have corresponding <b>case</b> branches.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryEnumModifier.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryEnumModifier.html
index fa804fd..6a3696d 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryEnumModifier.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryEnumModifier.html
@@ -4,6 +4,6 @@
enumerated classes.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryExplicitNumericCast.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryExplicitNumericCast.html
index 9a7756b..8ceb97a 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryExplicitNumericCast.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryExplicitNumericCast.html
@@ -4,6 +4,6 @@
implicitly by the compiler.
<!-- tooltip end -->
<p>
-<small>New in 11, Powered by InspectionGadgets</small>
+<small>New in 11</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryFinalOnLocalVariableOrParameter.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryFinalOnLocalVariableOrParameter.html
index 98769f4..e82f257 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryFinalOnLocalVariableOrParameter.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryFinalOnLocalVariableOrParameter.html
@@ -13,6 +13,6 @@
methods, which may be considered extra unnecessary, as such markings have no
effect on the implementation of these methods.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryFullyQualifiedName.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryFullyQualifiedName.html
index a0a5865..874c410 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryFullyQualifiedName.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryFullyQualifiedName.html
@@ -4,6 +4,6 @@
inspection will shorten the fully qualified names, adding import statements as necessary.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryInheritDoc.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryInheritDoc.html
index ec29484..4136b99 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryInheritDoc.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryInheritDoc.html
@@ -7,6 +7,6 @@
adds nothing.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryInterfaceModifier.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryInterfaceModifier.html
index 97fc114..d175954 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryInterfaceModifier.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryInterfaceModifier.html
@@ -3,6 +3,6 @@
Reports any redundant modifiers on interfaces or interface components.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryJavaDocLink.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryJavaDocLink.html
index 0cc0ef2..40187a9 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryJavaDocLink.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryJavaDocLink.html
@@ -12,6 +12,6 @@
to super methods. While a link to all super methods is automatically added by the
Javadoc tool, an inline link to the super method can occasionally be needed in
the text of the Javadoc.
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryLabelOnBreakStatement.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryLabelOnBreakStatement.html
index 14c4252..d3c8a27 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryLabelOnBreakStatement.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryLabelOnBreakStatement.html
@@ -4,6 +4,6 @@
labels.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryLabelOnContinueStatement.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryLabelOnContinueStatement.html
index ab14fcf..5d2588d 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryLabelOnContinueStatement.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryLabelOnContinueStatement.html
@@ -4,6 +4,6 @@
labels.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryLocalVariable.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryLocalVariable.html
index 9e75512..47edad8 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryLocalVariable.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryLocalVariable.html
@@ -13,6 +13,6 @@
<p>
Use the second checkbox below to have this inspection ignore variable which are annotated.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryParentheses.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryParentheses.html
index 76e07e9..be5f12a 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryParentheses.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryParentheses.html
@@ -14,6 +14,6 @@
of conditional expressions. Some coding standards specify that all such conditions
must be surrounded by parentheses.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryQualifierForThis.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryQualifierForThis.html
index 6500530..cc447be 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryQualifierForThis.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryQualifierForThis.html
@@ -8,6 +8,6 @@
<pre><code>OuterClass.<b>this</b>.foo();</code></pre>
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryReturn.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryReturn.html
index a7f8bf7..b740108 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryReturn.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryReturn.html
@@ -9,6 +9,6 @@
Use the checkbox below to let this inspection ignore <b>return</b> statements in the then branch of <b>if</b> statements
which also have an <b>else</b> branch.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessarySemicolon.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessarySemicolon.html
index 9dc34f8..dcf696e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessarySemicolon.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessarySemicolon.html
@@ -4,6 +4,6 @@
class definitions. While valid Java, these semicolons are redundant, and may be removed.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessarySuperConstructor.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessarySuperConstructor.html
index b0d8512..11f8752 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessarySuperConstructor.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessarySuperConstructor.html
@@ -4,6 +4,6 @@
constructor as the first call of a constructor. Such calls are unnecessary, and may be removed.<p>
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessarySuperQualifier.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessarySuperQualifier.html
index df77d59..5c05f97 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessarySuperQualifier.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessarySuperQualifier.html
@@ -5,6 +5,6 @@
when the field or method of the super class is not overridden in the calling class.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryTemporaryOnConversionFromString.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryTemporaryOnConversionFromString.html
index f452645..f6a80ed 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryTemporaryOnConversionFromString.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryTemporaryOnConversionFromString.html
@@ -13,6 +13,6 @@
</pre></code>
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryTemporaryOnConversionToString.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryTemporaryOnConversionToString.html
index e81c4f7..a9d3f4b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryTemporaryOnConversionToString.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryTemporaryOnConversionToString.html
@@ -13,6 +13,6 @@
</pre></code>
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryThis.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryThis.html
index d2b583c..0fe889a 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryThis.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryThis.html
@@ -11,6 +11,6 @@
<p>
Use the checkbox below to ignore assignments to fields.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryToStringCall.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryToStringCall.html
index 69cfb61..ae5c110 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryToStringCall.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryToStringCall.html
@@ -8,6 +8,6 @@
throwing a <b>NullPointerException</b>).
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryUnaryMinus.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryUnaryMinus.html
index b09b0cf..8085c97 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryUnaryMinus.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryUnaryMinus.html
@@ -14,6 +14,6 @@
</pre></code>
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryUnboxing.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryUnboxing.html
index c7be185..43d4462 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryUnboxing.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryUnboxing.html
@@ -7,6 +7,6 @@
language level of 5.0 or higher.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnpredictableBigDecimalConstructorCall.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnpredictableBigDecimalConstructorCall.html
index 9fa3150..071311a 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnpredictableBigDecimalConstructorCall.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnpredictableBigDecimalConstructorCall.html
@@ -7,6 +7,6 @@
It is recommend to use the constructors which accept a String instead.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnqualifiedFieldAccess.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnqualifiedFieldAccess.html
index 750813d..484f50c 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnqualifiedFieldAccess.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnqualifiedFieldAccess.html
@@ -6,6 +6,6 @@
variable or parameter accesses.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnqualifiedInnerClassAccess.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnqualifiedInnerClassAccess.html
index fd5303b..917ae08 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnqualifiedInnerClassAccess.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnqualifiedInnerClassAccess.html
@@ -6,6 +6,6 @@
<p>
Use the checkbox below to ignore references to local inner classes that do not require an import.
<p>
-<small>New in 10, Powered by InspectionGadgets</small>
+<small>New in 10</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnqualifiedMethodAccess.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnqualifiedMethodAccess.html
index 0323cd8..c60f32d 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnqualifiedMethodAccess.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnqualifiedMethodAccess.html
@@ -3,6 +3,6 @@
Reports calls to non-static methods of the same object which are not qualified with <b>this</b>.
<!-- tooltip end -->
<p>
-<small>New in 11, Powered by InspectionGadgets</small>
+<small>New in 11</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnqualifiedStaticUsage.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnqualifiedStaticUsage.html
index 9b90ca7..bea5d3e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnqualifiedStaticUsage.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnqualifiedStaticUsage.html
@@ -5,6 +5,6 @@
the same class as the call, but may be confusing.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnsecureRandomNumberGeneration.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnsecureRandomNumberGeneration.html
index bb70fe3..b25312f 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnsecureRandomNumberGeneration.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnsecureRandomNumberGeneration.html
@@ -6,6 +6,6 @@
random number generation.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnusedCatchParameter.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnusedCatchParameter.html
index b08ac58..131f651 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnusedCatchParameter.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnusedCatchParameter.html
@@ -10,6 +10,6 @@
<p>
Use the second checkbox below to ignore catch blocks in test code.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnusedImport.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnusedImport.html
index 4b4d2c2..15558c9 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnusedImport.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnusedImport.html
@@ -5,6 +5,6 @@
for off-line reporting on code bases that you don't intend to change.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnusedLabel.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnusedLabel.html
index 8913dae..189c5a2 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnusedLabel.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnusedLabel.html
@@ -3,6 +3,6 @@
Reports unused code labels.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UpperCaseFieldNameNotConstant.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UpperCaseFieldNameNotConstant.html
index b4cb57e..0ede842 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UpperCaseFieldNameNotConstant.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UpperCaseFieldNameNotConstant.html
@@ -5,6 +5,6 @@
are often the result of developer error.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UseOfAWTPeerClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UseOfAWTPeerClass.html
index 82c4513..c46776e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UseOfAWTPeerClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UseOfAWTPeerClass.html
@@ -5,6 +5,6 @@
systems.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UseOfAnotherObjectsPrivateField.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UseOfAnotherObjectsPrivateField.html
index 8a6f05d..6e532ba 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UseOfAnotherObjectsPrivateField.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UseOfAnotherObjectsPrivateField.html
@@ -13,6 +13,6 @@
<p>
Use the second checkbox below to ignore accesses from an <b>equals()</b> method.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UseOfJDBCDriverClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UseOfJDBCDriverClass.html
index 14fad1f..020abed 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UseOfJDBCDriverClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UseOfJDBCDriverClass.html
@@ -5,6 +5,6 @@
resulting in loss of portability.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UseOfObsoleteAssert.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UseOfObsoleteAssert.html
index 07920d3..cd4ac9b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UseOfObsoleteAssert.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UseOfObsoleteAssert.html
@@ -4,6 +4,6 @@
obsolete and the calls can be replaced by calls to methods from the <b>org.junit.Assert</b> class.
<!-- tooltip end -->
<p>
-<small>New in 11, Powered by InspectionGadgets</small>
+<small>New in 11</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UseOfProcessBuilder.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UseOfProcessBuilder.html
index e8d7f4a..4d3fa3e 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UseOfProcessBuilder.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UseOfProcessBuilder.html
@@ -4,6 +4,6 @@
Uses of <b>ProcessBuilder</b> are inherently unportable between operating systems.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UseOfPropertiesAsHashtable.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UseOfPropertiesAsHashtable.html
index a51fee9..2dfbc5b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UseOfPropertiesAsHashtable.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UseOfPropertiesAsHashtable.html
@@ -8,6 +8,6 @@
to prevent corruption of properties values with non-String data.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UseOfSunClasses.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UseOfSunClasses.html
index 8e94151..8c235b3 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UseOfSunClasses.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UseOfSunClasses.html
@@ -4,6 +4,6 @@
Such classes are non-portable between different JVM's.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UtilityClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UtilityClass.html
index 05adf75..b87816f 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UtilityClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UtilityClass.html
@@ -8,6 +8,6 @@
Use the list below to specify special annotations. Classes annotated with one of
these annotations will be ignored by this inspection.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UtilityClassWithPublicConstructor.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UtilityClassWithPublicConstructor.html
index fdae5e1..07fc751 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UtilityClassWithPublicConstructor.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UtilityClassWithPublicConstructor.html
@@ -5,6 +5,6 @@
constructor is confusing, and may lead to the class being inadvertently instantiated.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UtilityClassWithoutPrivateConstructor.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UtilityClassWithoutPrivateConstructor.html
index cf51280..3705904 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UtilityClassWithoutPrivateConstructor.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UtilityClassWithoutPrivateConstructor.html
@@ -10,6 +10,6 @@
<p>
Use the checkbox below to ignore classes which only have a main method and no other methods.
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/VarargParameter.html b/plugins/InspectionGadgets/src/inspectionDescriptions/VarargParameter.html
index cbbbe90..14fc3d0 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/VarargParameter.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/VarargParameter.html
@@ -4,6 +4,6 @@
Such methods are not supported under Java 1.4 or earlier JVMs.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/VariableNotUsedInsideIf.html b/plugins/InspectionGadgets/src/inspectionDescriptions/VariableNotUsedInsideIf.html
index b3b9357..45ab67d 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/VariableNotUsedInsideIf.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/VariableNotUsedInsideIf.html
@@ -8,6 +8,6 @@
<b>if</b> statement because of a typo.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/VolatileArrayField.html b/plugins/InspectionGadgets/src/inspectionDescriptions/VolatileArrayField.html
index 3c96f83..a202379 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/VolatileArrayField.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/VolatileArrayField.html
@@ -7,6 +7,6 @@
the JDK5.0 <b>java.util.concurrent.atomic</b> classes should be used instead.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/VolatileLongOrDoubleField.html b/plugins/InspectionGadgets/src/inspectionDescriptions/VolatileLongOrDoubleField.html
index bac61d5..90d5f41 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/VolatileLongOrDoubleField.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/VolatileLongOrDoubleField.html
@@ -6,6 +6,6 @@
are certain of your JVM, it is better to synchronized access to such fields rather than declare them <b>volatile</b>.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/WaitCalledOnCondition.html b/plugins/InspectionGadgets/src/inspectionDescriptions/WaitCalledOnCondition.html
index f1e1aa8..076a19d 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/WaitCalledOnCondition.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/WaitCalledOnCondition.html
@@ -6,6 +6,6 @@
<b>await()</b> method was intended instead.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/WaitNotInLoop.html b/plugins/InspectionGadgets/src/inspectionDescriptions/WaitNotInLoop.html
index 0bff8ad..f611371 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/WaitNotInLoop.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/WaitNotInLoop.html
@@ -5,6 +5,6 @@
returns. A loop is the clearest way to achieve this.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/WaitNotInSynchronizedContext.html b/plugins/InspectionGadgets/src/inspectionDescriptions/WaitNotInSynchronizedContext.html
index 121a02c..81b11b6 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/WaitNotInSynchronizedContext.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/WaitNotInSynchronizedContext.html
@@ -7,6 +7,6 @@
the containing method is called, but its worth looking at.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/WaitOrAwaitWithoutTimeout.html b/plugins/InspectionGadgets/src/inspectionDescriptions/WaitOrAwaitWithoutTimeout.html
index fc1b095..f1c406c 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/WaitOrAwaitWithoutTimeout.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/WaitOrAwaitWithoutTimeout.html
@@ -8,6 +8,6 @@
get called.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/WaitWhileHoldingTwoLocks.html b/plugins/InspectionGadgets/src/inspectionDescriptions/WaitWhileHoldingTwoLocks.html
index 3f66c1c..563c244 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/WaitWhileHoldingTwoLocks.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/WaitWhileHoldingTwoLocks.html
@@ -5,6 +5,6 @@
only frees locks on the its target, waiting with two locks held can easily lead to deadlock.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/WaitWithoutCorrespondingNotify.html b/plugins/InspectionGadgets/src/inspectionDescriptions/WaitWithoutCorrespondingNotify.html
index 998c746..a780704 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/WaitWithoutCorrespondingNotify.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/WaitWithoutCorrespondingNotify.html
@@ -6,6 +6,6 @@
can be found. Only calls which target fields of the current class are reported by this inspection.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/WhileCanBeForeach.html b/plugins/InspectionGadgets/src/inspectionDescriptions/WhileCanBeForeach.html
index a5a7f94..fa69c5c 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/WhileCanBeForeach.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/WhileCanBeForeach.html
@@ -8,6 +8,6 @@
language level of 5.0 or higher.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/WhileLoopSpinsOnField.html b/plugins/InspectionGadgets/src/inspectionDescriptions/WhileLoopSpinsOnField.html
index 4821456..d6fb8ee 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/WhileLoopSpinsOnField.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/WhileLoopSpinsOnField.html
@@ -8,6 +8,6 @@
field's value.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ZeroLengthArrayInitialization.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ZeroLengthArrayInitialization.html
index 7506803..61701a1 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ZeroLengthArrayInitialization.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ZeroLengthArrayInitialization.html
@@ -7,6 +7,6 @@
as it is assumed that those arrays are being used to implement array sharing.
<!-- tooltip end -->
<p>
-<small>Powered by InspectionGadgets</small>
+
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/inline/ArrayInitializer.after.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/inline/ArrayInitializer.after.java
new file mode 100644
index 0000000..ce9bff7
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/inline/ArrayInitializer.after.java
@@ -0,0 +1,8 @@
+package com.siyeh.igfixes.inline;
+
+class ArrayInitializer {
+
+ void m(String[] ts) {
+ ts = new String[]{"a", "b"};
+ }
+}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/inline/ArrayInitializer.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/inline/ArrayInitializer.java
new file mode 100644
index 0000000..b213e0c
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/inline/ArrayInitializer.java
@@ -0,0 +1,9 @@
+package com.siyeh.igfixes.inline;
+
+class ArrayInitializer {
+
+ void m(String[] ts) {
+ String[] <caret>ss = {"a", "b"};
+ ts = ss;
+ }
+}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/inline/CastNeeded.after.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/inline/CastNeeded.after.java
new file mode 100644
index 0000000..d110c7b
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/inline/CastNeeded.after.java
@@ -0,0 +1,8 @@
+package com.siyeh.igfixes.inline;
+
+class CastNeeded {
+
+ double m(int p) {
+ return (double) p /100;
+ }
+}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/inline/CastNeeded.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/inline/CastNeeded.java
new file mode 100644
index 0000000..947cfdc
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/inline/CastNeeded.java
@@ -0,0 +1,9 @@
+package com.siyeh.igfixes.inline;
+
+class CastNeeded {
+
+ double m(int p) {
+ double pd<caret> = p;
+ return pd/100;
+ }
+}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/inline/SingleResourceVar.after.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/inline/SingleResourceVar.after.java
index f7d0cc3..24cd863 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igfixes/inline/SingleResourceVar.after.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/inline/SingleResourceVar.after.java
@@ -1,7 +1,6 @@
class C {
void m() throws Exception {
- AutoCloseable r1 = null;
- try {
+ try (AutoCloseable r1 = null) {
System.out.println(r1 + ", " + r1);
}
}
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/inline/SingleResourceVar.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/inline/SingleResourceVar.java
index b37e501..2beda84 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igfixes/inline/SingleResourceVar.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/inline/SingleResourceVar.java
@@ -1,8 +1,9 @@
class C {
void m() throws Exception {
- AutoCloseable r1 = null;
- try (AutoCloseable <caret>r2 = r1) {
+ try (AutoCloseable r1 = null) {
+ try (AutoCloseable <caret>r2 = r1) {
System.out.println(r1 + ", " + r2);
+ }
}
}
}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/Array.after.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/Array.after.java
new file mode 100644
index 0000000..4e22a39
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/Array.after.java
@@ -0,0 +1,7 @@
+package com.siyeh.igfixes.style.replace_with_string;
+
+class Array {
+ String array(char[] cs) {
+ return String.valueOf(cs) + String.valueOf(cs, 0, 10);
+ }
+}
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/Array.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/Array.java
new file mode 100644
index 0000000..e745b82
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/Array.java
@@ -0,0 +1,7 @@
+package com.siyeh.igfixes.style.replace_with_string;
+
+class Array {
+ String array(char[] cs) {
+ return new <caret>StringBuilder().append(cs).append(cs, 0, 10).toString();
+ }
+}
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/ConstructorArgument.after.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/ConstructorArgument.after.java
new file mode 100644
index 0000000..f017c51
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/ConstructorArgument.after.java
@@ -0,0 +1,8 @@
+package com.siyeh.igfixes.style.replace_with_string;
+
+class ConstructorArgument {
+ void m() {
+
+ String s = "init-" + "appended";
+ }
+}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/ConstructorArgument.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/ConstructorArgument.java
new file mode 100644
index 0000000..09a91e5
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/ConstructorArgument.java
@@ -0,0 +1,10 @@
+package com.siyeh.igfixes.style.replace_with_string;
+
+class ConstructorArgument {
+ void m() {
+ final StringBuilder buffer<caret> = new StringBuilder("init-");
+ buffer.append("appended");
+
+ String s = buffer.toString();
+ }
+}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/ConstructorArgument2.after.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/ConstructorArgument2.after.java
new file mode 100644
index 0000000..67ab03a
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/ConstructorArgument2.after.java
@@ -0,0 +1,8 @@
+package com.siyeh.igfixes.style.replace_with_string;
+
+class ConstructorArgument2 {
+ void m() {
+
+ String s = "appended";
+ }
+}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/ConstructorArgument2.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/ConstructorArgument2.java
new file mode 100644
index 0000000..313625e
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/ConstructorArgument2.java
@@ -0,0 +1,10 @@
+package com.siyeh.igfixes.style.replace_with_string;
+
+class ConstructorArgument2 {
+ void m() {
+ final StringBuilder buffer<caret> = new StringBuilder(100);
+ buffer.append("appended");
+
+ String s = buffer.toString();
+ }
+}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/Marathon.after.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/Marathon.after.java
new file mode 100644
index 0000000..4251dbd
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/Marathon.after.java
@@ -0,0 +1,8 @@
+package com.siyeh.igfixes.style.replace_with_string;
+
+class Marathon {
+
+ private static void test(boolean marathon) {
+ String s1 = (marathon ? "AAA" : "BBB") + "CCC";
+ }
+}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/Marathon.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/Marathon.java
new file mode 100644
index 0000000..a85d91f
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/Marathon.java
@@ -0,0 +1,8 @@
+package com.siyeh.igfixes.style.replace_with_string;
+
+class Marathon {
+
+ private static void test(boolean marathon) {
+ String s1 = new <caret>StringBuilder(marathon ? "AAA": "BBB").append("CCC").toString();
+ }
+}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/NoConstructorArgument.after.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/NoConstructorArgument.after.java
new file mode 100644
index 0000000..66a9fb9
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/NoConstructorArgument.after.java
@@ -0,0 +1,8 @@
+package com.siyeh.igfixes.style.replace_with_string;
+
+class NoConstructorArgument {
+ void m() {
+
+ String s = "appended" + "appended";
+ }
+}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/NoConstructorArgument.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/NoConstructorArgument.java
new file mode 100644
index 0000000..733521d
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/NoConstructorArgument.java
@@ -0,0 +1,11 @@
+package com.siyeh.igfixes.style.replace_with_string;
+
+class NoConstructorArgument {
+ void m() {
+ final StringBuilder buffer<caret> = new StringBuilder();
+ buffer.append("appended");
+ buffer.append("appended");
+
+ String s = buffer.toString();
+ }
+}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/NonString1.after.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/NonString1.after.java
index b1d2560..f9b434e 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/NonString1.after.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/NonString1.after.java
@@ -3,6 +3,6 @@
class NonString1 {
String foo(CharSequence text) {
- return text.toString();
+ return String.valueOf(text); // no toString() because of NPEs
}
}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/NonString1.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/NonString1.java
index 373df17..63bb491 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/NonString1.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/NonString1.java
@@ -3,6 +3,6 @@
class NonString1 {
String foo(CharSequence text) {
- return new <caret>StringBuilder(text).toString();
+ return new <caret>StringBuilder(text).toString(); // no toString() because of NPEs
}
}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/StringBufferVariable.after.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/StringBufferVariable.after.java
index 9f7b9e2..7b471c4 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/StringBufferVariable.after.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/StringBufferVariable.after.java
@@ -1,6 +1,5 @@
class StringBufferVariable {
void foo() {
- String sb = "asdf" + "asdf";
- System.out.println(sb.toString());
+ System.out.println("asdf" + "asdf");
}
}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/StringBufferVariable2.after.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/StringBufferVariable2.after.java
index 01c7a31..d5a48b0 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/StringBufferVariable2.after.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/style/replace_with_string/StringBufferVariable2.after.java
@@ -1,6 +1,5 @@
class StringBufferVariable2 {
void foo() {
- String sb = "";
- System.out.println(sb.toString());
+ System.out.println("");
}
}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/assignment/assignment_used_as_condition/AssignmentUsedAsCondition.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/assignment/assignment_used_as_condition/AssignmentUsedAsCondition.java
new file mode 100644
index 0000000..6042e6a
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/assignment/assignment_used_as_condition/AssignmentUsedAsCondition.java
@@ -0,0 +1,23 @@
+package com.siyeh.igtest.assignment.assignment_used_as_condition;
+
+public class AssignmentUsedAsCondition {
+
+ void foo(boolean b) {
+ if (b = fossa()) {
+
+ }
+ }
+
+ boolean fossa() {
+ return true;
+ }
+
+ public static void main(String[] args) {
+ boolean b = false;
+ if (b != = true) {
+
+ }
+ int i = 1;
+ if (i = 8);
+ }
+}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/assignment/assignment_used_as_condition/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/assignment/assignment_used_as_condition/expected.xml
new file mode 100644
index 0000000..26f1829
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/assignment/assignment_used_as_condition/expected.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<problems>
+ <problem>
+ <file>AssignmentUsedAsCondition.java</file>
+ <line>6</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Assignment used as condition</problem_class>
+ <description><code>b = fossa()</code> used as condition #loc</description>
+ </problem>
+
+ <problem>
+ <file>AssignmentUsedAsCondition.java</file>
+ <line>21</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Assignment used as condition</problem_class>
+ <description><code>i = 8</code> used as condition #loc</description>
+ </problem>
+</problems>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/empty_statement_body/EmptyStatementBody.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/empty_statement_body/EmptyStatementBody.java
index 38f7601..b4c8652 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/empty_statement_body/EmptyStatementBody.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/empty_statement_body/EmptyStatementBody.java
@@ -36,4 +36,14 @@
{
return true;
}
+
+ void comments(boolean b) {
+ if (b); // comment
+ while (b) {
+ // comment
+ }
+ do {
+ ; // comment
+ } while (b);
+ }
}
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/ignore_result_of_call/IgnoreResultOfCall.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/ignore_result_of_call/IgnoreResultOfCall.java
deleted file mode 100644
index 6dbce04..0000000
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/ignore_result_of_call/IgnoreResultOfCall.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.siyeh.igtest.bugs.ignore_result_of_call;
-
-class IgnoreResultOfCall {
-
- void foo(Object o, String s) {
- o.equals(s);
- o.equals()
- }
-
-}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/ignore_result_of_call/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/ignore_result_of_call/expected.xml
deleted file mode 100644
index 7f64be4..0000000
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/ignore_result_of_call/expected.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<problems>
- <problem>
- <file>IgnoreResultOfCall.java</file>
- <line>6</line>
- <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Result of method call ignored</problem_class>
- <description>Result of <code>Object.equals()</code> is ignored #loc</description>
- </problem>
-</problems>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/subtraction_in_compare_to/SubtractionInCompareTo.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/subtraction_in_compare_to/SubtractionInCompareTo.java
index 581308d..afed9c8 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/subtraction_in_compare_to/SubtractionInCompareTo.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/subtraction_in_compare_to/SubtractionInCompareTo.java
@@ -1,6 +1,6 @@
package com.siyeh.igtest.bugs.subtraction_in_compare_to;
-public class SubtractionInCompareTo
+public class SubtractionInCompareTo implements java.util.Comparator<SubtractionInCompareTo>
{
private int m_foo = 3;
@@ -9,4 +9,10 @@
final int temp = m_foo + ((SubtractionInCompareTo)foo).m_foo;
return m_foo - ((SubtractionInCompareTo)foo).m_foo;
}
+
+
+ @Override
+ public int compare(SubtractionInCompareTo o1, SubtractionInCompareTo o2) {
+ return o1.m_foo - o2.m_foo;
+ }
}
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/subtraction_in_compare_to/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/subtraction_in_compare_to/expected.xml
index 9f8af86..dcb448d 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/subtraction_in_compare_to/expected.xml
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/subtraction_in_compare_to/expected.xml
@@ -6,4 +6,11 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Subtraction in 'compareTo()'</problem_class>
<description>Subtraction <code>m_foo - ((SubtractionInCompareTo)foo).m_foo</code> in 'compareTo()' may result in overflow errors #loc</description>
</problem>
+
+ <problem>
+ <file>SubtractionInCompareTo.java</file>
+ <line>16</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Subtraction in 'compareTo()'</problem_class>
+ <description>Subtraction <code>o1.m_foo - o2.m_foo</code> in 'compareTo()' may result in overflow errors #loc</description>
+ </problem>
</problems>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/dataflow/unnecessary_local_vars/C.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/dataflow/unnecessary_local_vars/C.java
index 234c1ba..da4b4b4 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/dataflow/unnecessary_local_vars/C.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/dataflow/unnecessary_local_vars/C.java
@@ -5,8 +5,8 @@
System.out.println(s2 + s3);
AutoCloseable r1 = null;
- try (AutoCloseable r2 = r1, AutoCloseable r3 = null) {
- System.out.println(r2 + r3);
+ try (AutoCloseable r2 = r1; AutoCloseable r3 = null) {
+ System.out.println(r2.toString() + r3.toString());
}
}
@@ -20,7 +20,7 @@
System.out.println(r2 + r3);
}
}
-
+
int boxing(Long l) {
long ll = l;
return (int) ll;
@@ -83,4 +83,36 @@
return null;
}
+ public void neededResourceVariable(java.io.InputStream in) throws java.io.IOException {
+ try (java.io.InputStream inn = in) {
+ final int read = inn.read();
+ // do stuff with in
+ }
+ }
+
+ int parenthesized() {
+ final int i = 1 + 2;
+ return (i);
+ }
+
+ void parenthesized2() {
+ final RuntimeException t = new RuntimeException();
+ throw (t);
+ }
+
+ void parenthesized3(int i) {
+ int j = (i);
+ }
+
+ void parenthesized4(int k) {
+ final int j = 1;
+ k = (j);
+ }
+
+ void parenthesized5() {
+ final int j = 1;
+ int k = (j);
+ System.out.println(k);
+ }
+
}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/dataflow/unnecessary_local_vars/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/dataflow/unnecessary_local_vars/expected.xml
index bf91c5c..70ce707 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/dataflow/unnecessary_local_vars/expected.xml
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/dataflow/unnecessary_local_vars/expected.xml
@@ -23,13 +23,6 @@
<problem>
<file>C.java</file>
- <line>8</line>
- <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Redundant local variable</problem_class>
- <description>Local variable <code>r2</code> is redundant #loc</description>
- </problem>
-
- <problem>
- <file>C.java</file>
<line>15</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Redundant local variable</problem_class>
<description>Local variable <code>s2</code> is redundant #loc</description>
@@ -44,20 +37,6 @@
<problem>
<file>C.java</file>
- <line>19</line>
- <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Redundant local variable</problem_class>
- <description>Local variable <code>r2</code> is redundant #loc</description>
- </problem>
-
- <problem>
- <file>C.java</file>
- <line>19</line>
- <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Redundant local variable</problem_class>
- <description>Local variable <code>r3</code> is redundant #loc</description>
- </problem>
-
- <problem>
- <file>C.java</file>
<line>30</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Redundant local variable</problem_class>
<description>Local variable <code>a</code> is redundant #loc</description>
@@ -98,5 +77,46 @@
<description>Local variable <code>value</code> is redundant #loc</description>
</problem>
+ <problem>
+ <file>C.java</file>
+ <line>94</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Redundant local variable</problem_class>
+ <description>Local variable <code>i</code> is redundant #loc</description>
+ </problem>
+
+ <problem>
+ <file>C.java</file>
+ <line>99</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Redundant local variable</problem_class>
+ <description>Local variable <code>t</code> is redundant #loc</description>
+ </problem>
+
+ <problem>
+ <file>C.java</file>
+ <line>108</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Redundant local variable</problem_class>
+ <description>Local variable <code>j</code> is redundant #loc</description>
+ </problem>
+
+ <problem>
+ <file>C.java</file>
+ <line>104</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Redundant local variable</problem_class>
+ <description>Local variable <code>j</code> is redundant #loc</description>
+ </problem>
+
+ <problem>
+ <file>C.java</file>
+ <line>113</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Redundant local variable</problem_class>
+ <description>Local variable <code>j</code> is redundant #loc</description>
+ </problem>
+
+ <problem>
+ <file>C.java</file>
+ <line>114</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Redundant local variable</problem_class>
+ <description>Local variable <code>k</code> is redundant #loc</description>
+ </problem>
</problems>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/exceptionHandling/EmptyCatchBlockInspection.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/exceptionHandling/EmptyCatchBlockInspection.java
deleted file mode 100644
index b03a024..0000000
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/exceptionHandling/EmptyCatchBlockInspection.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.siyeh.igtest.exceptionHandling;
-
-public class EmptyCatchBlockInspection
-{
- public void foo()
- {
- try
- {
- throw new Exception();
- }
- catch(Exception e)
- {
- }
- try
- {
- throw new Exception();
- }
- catch(Exception e)
- {
- //catch comment
- }
- }
-}
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/exceptionHandling/EmptyCatchBlockInspectionInTestCase.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/exceptionHandling/EmptyCatchBlockInspectionInTestCase.java
deleted file mode 100644
index b79d71a..0000000
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/exceptionHandling/EmptyCatchBlockInspectionInTestCase.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.siyeh.igtest.exceptionHandling;
-
-import junit.framework.TestCase;
-
-public class EmptyCatchBlockInspectionInTestCase extends TestCase
-{
- public void foo()
- {
- try
- {
- throw new Exception();
- }
- catch(Exception e)
- {
- }
- try
- {
- throw new Exception();
- }
- catch(Exception e)
- {
- //catch comment
- }
- }
-}
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/divide_by_zero/DivideByZero.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/divide_by_zero/DivideByZero.java
index 9f24ebf..26254cb 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/divide_by_zero/DivideByZero.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/divide_by_zero/DivideByZero.java
@@ -10,4 +10,9 @@
return num % 0 % 1;
}
+ void assignment(int i, double d) {
+ i /= 1-1;
+ d %= 0;
+ i /= d;
+ }
}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/divide_by_zero/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/divide_by_zero/expected.xml
index 3a07cc5..6119eee 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/divide_by_zero/expected.xml
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/divide_by_zero/expected.xml
@@ -13,4 +13,18 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Division by zero</problem_class>
<description>Division by zero #loc</description>
</problem>
+
+ <problem>
+ <file>DivideByZero.java</file>
+ <line>14</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Division by zero</problem_class>
+ <description>Division by zero #loc</description>
+ </problem>
+
+ <problem>
+ <file>DivideByZero.java</file>
+ <line>15</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Division by zero</problem_class>
+ <description>Division by zero #loc</description>
+ </problem>
</problems>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/performance/inner_class_may_be_static/InnerClassMayBeStaticInspection.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/performance/inner_class_may_be_static/InnerClassMayBeStaticInspection.java
index aae6f94..7b14d86 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/performance/inner_class_may_be_static/InnerClassMayBeStaticInspection.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/performance/inner_class_may_be_static/InnerClassMayBeStaticInspection.java
@@ -46,4 +46,14 @@
class Y {}
}
}
+}
+class StaticInnerClass {
+
+ private int foo;
+
+ public class Baz extends StaticInnerClass {
+ Baz() {
+ foo = -1;
+ }
+ }
}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/performance/redundant_string_format_call/RedundantStringFormatCall.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/performance/redundant_string_format_call/RedundantStringFormatCall.java
index 8737fa9..9591444 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/performance/redundant_string_format_call/RedundantStringFormatCall.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/performance/redundant_string_format_call/RedundantStringFormatCall.java
@@ -1,9 +1,9 @@
package com.siyeh.igtest.performance.redundant_string_format_call;
+import java.util.Locale;
+
import static java.lang.String.format;
-
-
public class RedundantStringFormatCall {
public static final String A = String.format("%n");
@@ -12,4 +12,9 @@
"asdf%n");
String d = String.format("asdf" + "asdf" + "asdf%n");
String e = format("test");
+
+ void m() {
+ System.out.println(String.format("string contains %%n%n")); // ok
+ System.out.println(String.format(Locale.ENGLISH, "string contains %%n%n"));
+ }
}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/performance/string_buffer_replaceable_by_string/StringBufferReplaceableByString.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/performance/string_buffer_replaceable_by_string/StringBufferReplaceableByString.java
index 35d89c2..cfeea11 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/performance/string_buffer_replaceable_by_string/StringBufferReplaceableByString.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/performance/string_buffer_replaceable_by_string/StringBufferReplaceableByString.java
@@ -29,4 +29,43 @@
StringBuilder b = new StringBuilder();
String s = new StringBuilder().append(pcdata, 0, i).toString();
}
+
+ public void multiStatement() {
+ StringBuilder b = new StringBuilder();
+ b.append("eh");
+ b.append(" yeah").append("thus...");
+ System.out.println(b.toString());
+ }
+
+ public void assignment(int p) {
+ StringBuilder b = new StringBuilder();
+ b.append(p);
+ p++;
+ System.out.println(b.toString());
+ StringBuilder c = new StringBuilder();
+ c.append(p);
+ p = 2;
+ System.out.println(c.toString());
+
+ StringBuilder d = new StringBuilder();
+ d.append(p);
+ System.out.println(d.toString());
+ }
+
+ void clean() {
+ StringBuilder a = new StringBuilder(); // 'StringBuilder a' can be replaced with String
+ StringBuilder b = new StringBuilder(); // 'StringBuilder b' can be replaced with String
+
+ (Math.random() < 0.5 ? a : b).append("BLA");
+ System.out.println(a + "/" + b);
+ }
+
+ String incomplete(char[] cs) {
+ StringBuilder a = new StringBuilder();
+ a.append(cs, 1);
+ System.out.println(a.toString());
+ StringBuilder b = new StringBuilder();
+ b.append()
+ return b.toString();
+ }
}
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/performance/string_buffer_replaceable_by_string/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/performance/string_buffer_replaceable_by_string/expected.xml
index 0a8ee53..9d6c57a 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/performance/string_buffer_replaceable_by_string/expected.xml
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/performance/string_buffer_replaceable_by_string/expected.xml
@@ -1,18 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
- <problem>
- <file>StringBufferReplaceableByString.java</file>
- <line>6</line>
- <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'StringBuffer' can be replaced with 'String'</problem_class>
- <description><code>StringBuilder builder</code> can be replaced with 'String' #loc</description>
- </problem>
-
- <problem>
- <file>StringBufferReplaceableByString.java</file>
- <line>7</line>
- <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'StringBuffer' can be replaced with 'String'</problem_class>
- <description><code>StringBuffer buffer</code> can be replaced with 'String' #loc</description>
- </problem>
<problem>
<file>StringBufferReplaceableByString.java</file>
@@ -37,8 +24,16 @@
<problem>
<file>StringBufferReplaceableByString.java</file>
- <line>29</line>
+ <line>34</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'StringBuffer' can be replaced with 'String'</problem_class>
<description><code>StringBuilder b</code> can be replaced with 'String' #loc</description>
</problem>
+
+ <problem>
+ <file>StringBufferReplaceableByString.java</file>
+ <line>50</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'StringBuffer' can be replaced with 'String'</problem_class>
+ <description><code>StringBuilder d</code> can be replaced with 'String' #loc</description>
+ </problem>
+
</problems>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_valueof/UnnecessaryCallToStringValueOf.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_valueof/UnnecessaryCallToStringValueOf.java
index 023d86f..8c6c76b 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_valueof/UnnecessaryCallToStringValueOf.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_valueof/UnnecessaryCallToStringValueOf.java
@@ -28,4 +28,12 @@
void builder(StringBuilder builder) {
builder.append(String.valueOf(0x8));
}
+
+ public static void main22(String[] args) {
+ foo(String.valueOf(3.0));
+ }
+
+ static void foo(String s) {
+ System.out.println(s);
+ }
}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/assignment/AssignmentUsedAsConditionInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/assignment/AssignmentUsedAsConditionInspectionTest.java
new file mode 100644
index 0000000..639cebb
--- /dev/null
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/assignment/AssignmentUsedAsConditionInspectionTest.java
@@ -0,0 +1,10 @@
+package com.siyeh.ig.assignment;
+
+import com.siyeh.ig.IGInspectionTestCase;
+
+public class AssignmentUsedAsConditionInspectionTest extends IGInspectionTestCase {
+
+ public void test() {
+ doTest("com/siyeh/igtest/assignment/assignment_used_as_condition", new AssignmentUsedAsConditionInspection());
+ }
+}
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/bugs/EmptyStatementBodyInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/bugs/EmptyStatementBodyInspectionTest.java
index ad29f9e..61b92a4 100644
--- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/bugs/EmptyStatementBodyInspectionTest.java
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/bugs/EmptyStatementBodyInspectionTest.java
@@ -7,6 +7,7 @@
public void test() throws Exception {
final EmptyStatementBodyInspection tool = new EmptyStatementBodyInspection();
tool.m_reportEmptyBlocks = true;
+ tool.commentsAreContent = true;
doTest("com/siyeh/igtest/bugs/empty_statement_body", tool);
}
}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/bugs/IgnoreResultOfCallInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/bugs/IgnoreResultOfCallInspectionTest.java
index 9e575ef..922fedc 100644
--- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/bugs/IgnoreResultOfCallInspectionTest.java
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/bugs/IgnoreResultOfCallInspectionTest.java
@@ -1,10 +1,44 @@
package com.siyeh.ig.bugs;
-import com.siyeh.ig.IGInspectionTestCase;
+import com.intellij.codeInspection.LocalInspectionTool;
+import com.siyeh.ig.LightInspectionTestCase;
-public class IgnoreResultOfCallInspectionTest extends IGInspectionTestCase {
+public class IgnoreResultOfCallInspectionTest extends LightInspectionTestCase {
- public void test() throws Exception {
- doTest("com/siyeh/igtest/bugs/ignore_result_of_call", new IgnoreResultOfCallInspection());
+ @Override
+ protected LocalInspectionTool getInspection() {
+ return new IgnoreResultOfCallInspection();
+ }
+
+ @Override
+ protected String[] getEnvironmentClasses() {
+ return new String[]{
+ "package java.util.regex; public class Pattern {" +
+ " public static Pattern compile(String regex) {return null;}" +
+ " public Matcher matcher(CharSequence input) {return null;}" +
+ "}",
+ "package java.util.regex; public class Matcher {" +
+ " public boolean find() {return true;}" +
+ "}",
+ };
+ }
+
+ public void testObjectMethods() {
+ doTest("class C {\n" +
+ " void foo(Object o, String s) {\n" +
+ " o./*Result of 'Object.equals()' is ignored*/equals/**/(s);\n" +
+ " }\n" +
+ "}\n");
+ }
+
+ public void testMatcher() {
+ doTest("class C {\n" +
+ " void matcher() {\n" +
+ " final java.util.regex.Pattern pattern = java.util.regex.Pattern.compile(\"baaaa\");\n" +
+ " final java.util.regex.Matcher matcher = pattern.matcher(\"babaaaaaaaa\");\n" +
+ " matcher./*Result of 'Matcher.find()' is ignored*/find/**/();\n" +
+ " matcher.notify();\n" +
+ " }\n" +
+ "}\n");
}
}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/errorhandling/EmptyCatchBlockInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/errorhandling/EmptyCatchBlockInspectionTest.java
new file mode 100644
index 0000000..5648d57
--- /dev/null
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/errorhandling/EmptyCatchBlockInspectionTest.java
@@ -0,0 +1,80 @@
+package com.siyeh.ig.errorhandling;
+
+import com.intellij.codeInspection.LocalInspectionTool;
+import com.siyeh.ig.LightInspectionTestCase;
+
+public class EmptyCatchBlockInspectionTest extends LightInspectionTestCase {
+
+ @Override
+ protected LocalInspectionTool getInspection() {
+ final EmptyCatchBlockInspection tool = new EmptyCatchBlockInspection();
+ tool.m_includeComments = true;
+ tool.m_ignoreTestCases = true;
+ tool.m_ignoreIgnoreParameter = true;
+ return tool;
+ }
+
+ @Override
+ protected String[] getEnvironmentClasses() {
+ return new String[] {
+ "package junit.framework; public abstract class TestCase {}"
+ };
+ }
+
+ public void testSimple() {
+ doTest("class C {\n" +
+ " void m() {\n" +
+ " try {\n" +
+ " throw new Exception();\n" +
+ " } /*Empty 'catch' block*/catch/**/ (Exception e) {\n" +
+ " }\n" +
+ " }\n" +
+ "}\n");
+ }
+
+ public void testEmptyStatement() {
+ doTest("class C {\n" +
+ " void m() {\n" +
+ " try {\n" +
+ " throw new Exception();\n" +
+ " } /*Empty 'catch' block*/catch/**/ (Exception e) {\n" +
+ " ;\n" +
+ " }\n" +
+ " }\n" +
+ "}\n");
+ }
+
+ public void testComment() {
+ doTest("class C {\n" +
+ " void m() {\n" +
+ " try {\n" +
+ " throw new Exception();\n" +
+ " } catch (Exception e) {\n" +
+ " // comment\n" +
+ " }\n" +
+ " }\n" +
+ "}\n");
+ }
+
+ public void testIgnored() {
+ doTest("class C {\n" +
+ " void m() {\n" +
+ " try {\n" +
+ " throw new Exception();\n" +
+ " } catch (Exception ignored) {\n" +
+ " }\n" +
+ " }\n" +
+ "}\n");
+ }
+
+ public void testTest() {
+ doTest("import junit.framework.TestCase;\n" +
+ "class C extends TestCase {\n" +
+ " void m() {\n" +
+ " try {\n" +
+ " throw new Exception();\n" +
+ " } catch (Exception e) {}\n" +
+ " }\n" +
+ "}\n");
+ }
+}
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/InlineVariableFixTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/InlineVariableFixTest.java
index 7125a54..29987a4 100644
--- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/InlineVariableFixTest.java
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/InlineVariableFixTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -28,15 +28,9 @@
myDefaultHint = InspectionGadgetsBundle.message("inline.variable.quickfix");
}
- public void testResourceVar() {
- doTest();
- }
-
- public void testResourceVarInMiddle() {
- doTest();
- }
-
- public void testSingleResourceVar() {
- doTest();
- }
+ public void testResourceVar() { doTest(); }
+ public void testResourceVarInMiddle() { doTest(); }
+ public void testSingleResourceVar() { doTest(); }
+ public void testCastNeeded() { doTest(); }
+ public void testArrayInitializer() { doTest(); }
}
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/logging/StringConcatenationArgumentToLogCallFixTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/logging/StringConcatenationArgumentToLogCallFixTest.java
index 9257d3e..9d9e56e 100644
--- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/logging/StringConcatenationArgumentToLogCallFixTest.java
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/logging/StringConcatenationArgumentToLogCallFixTest.java
@@ -21,11 +21,12 @@
import com.siyeh.ig.logging.StringConcatenationArgumentToLogCallInspection;
public class StringConcatenationArgumentToLogCallFixTest extends IGQuickFixesTestCase {
+
@Override
public void setUp() throws Exception {
super.setUp();
- myDefaultHint = InspectionGadgetsBundle.message("string.concatenation.in.format.call.quickfix");
- myFixture.addClass("package org.slf4j; public interface Logger { void info(String format); }");
+ myDefaultHint = InspectionGadgetsBundle.message("string.concatenation.argument.to.log.call.quickfix");
+ myFixture.addClass("package org.slf4j; public interface Logger { void info(String format); }");
myFixture.addClass("package org.slf4j; public class LoggerFactory { public static Logger getLogger(Class clazz) { return null; }}");
myFixture.enableInspections(new StringConcatenationArgumentToLogCallInspection());
}
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/style/StringBufferReplaceableWithStringFixTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/style/StringBufferReplaceableWithStringFixTest.java
index 457b455..bf86b37 100644
--- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/style/StringBufferReplaceableWithStringFixTest.java
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/style/StringBufferReplaceableWithStringFixTest.java
@@ -24,4 +24,9 @@
public void testPrecedence3() { doTest(InspectionGadgetsBundle.message("string.builder.replaceable.by.string.quickfix")); }
public void testNonString1() { doTest(InspectionGadgetsBundle.message("string.builder.replaceable.by.string.quickfix")); }
public void testNonString2() { doTest(InspectionGadgetsBundle.message("string.builder.replaceable.by.string.quickfix")); }
+ public void testMarathon() { doTest(InspectionGadgetsBundle.message("string.builder.replaceable.by.string.quickfix")); }
+ public void testArray() { doTest(InspectionGadgetsBundle.message("string.builder.replaceable.by.string.quickfix")); }
+ public void testConstructorArgument() { doTest(InspectionGadgetsBundle.message("string.builder.replaceable.by.string.quickfix")); }
+ public void testConstructorArgument2() { doTest(InspectionGadgetsBundle.message("string.builder.replaceable.by.string.quickfix")); }
+ public void testNoConstructorArgument() { doTest(InspectionGadgetsBundle.message("string.builder.replaceable.by.string.quickfix")); }
}
diff --git a/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/ConcatenationInjector.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/ConcatenationInjector.java
index b8dca4d..51338f7 100644
--- a/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/ConcatenationInjector.java
+++ b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/ConcatenationInjector.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -19,6 +19,7 @@
import com.intellij.lang.injection.ConcatenationAwareInjector;
import com.intellij.lang.injection.MultiHostRegistrar;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.ProperTextRange;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.Trinity;
@@ -90,8 +91,7 @@
annoClasses.add(StringUtil.getShortName(annotationClass));
for (int cursor = 0; cursor < annoClasses.size(); cursor++) {
final String annoClass = annoClasses.get(cursor);
- for (PsiAnnotation annotation : JavaAnnotationIndex.getInstance()
- .get(annoClass, myProject, GlobalSearchScope.allScope(myProject))) {
+ for (PsiAnnotation annotation : JavaAnnotationIndex.getInstance().get(annoClass, myProject, GlobalSearchScope.allScope(myProject))) {
final PsiElement modList = annotation.getParent();
if (!(modList instanceof PsiModifierList)) continue;
final PsiElement element = modList.getParent();
@@ -402,13 +402,16 @@
}
else {
if (!(curHost instanceof PsiLiteralExpression)) {
+ TextRange textRange = ElementManipulators.getManipulator(curHost).getRangeInElement(curHost);
+ ProperTextRange.assertProperRange(textRange, injection);
result.add(Trinity.create(curHost, InjectedLanguage.create(injection.getInjectedLanguageId(), curPrefix, curSuffix, true),
- ElementManipulators.getManipulator(curHost).getRangeInElement(curHost)));
+ textRange));
}
else {
final List<TextRange> injectedArea = injection.getInjectedArea(curHost);
for (int j = 0, injectedAreaSize = injectedArea.size(); j < injectedAreaSize; j++) {
- final TextRange textRange = injectedArea.get(j);
+ TextRange textRange = injectedArea.get(j);
+ ProperTextRange.assertProperRange(textRange, injection);
result.add(Trinity.create(
curHost, InjectedLanguage.create(injection.getInjectedLanguageId(),
(separateFiles || j == 0 ? curPrefix : ""),
diff --git a/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/util/AnnotationUtilEx.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/util/AnnotationUtilEx.java
index fd30cc7..2397b47 100644
--- a/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/util/AnnotationUtilEx.java
+++ b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/util/AnnotationUtilEx.java
@@ -195,6 +195,23 @@
boolean inHierarchy) {
if (!PsiUtilEx.isLanguageAnnotationTarget(owner)) return PsiAnnotation.EMPTY_ARRAY;
+ return getAnnotationsFromImpl(owner, annotationName, allowIndirect, inHierarchy);
+ }
+
+
+ /**
+ * The parameter <code>allowIndirect</code> determines if the method should look for indirect annotations, i.e.
+ * annotations which have themselves been annotated by the supplied annotation name. Currently, this only allows
+ * one level of indirection and returns an array of [base-annotation, indirect annotation]
+ * <p/>
+ * The <code>annotationName</code> parameter is a pair of the target annotation class' fully qualified name as a
+ * String and as a Set. This is done for performance reasons because the Set is required by the
+ * {@link com.intellij.codeInsight.AnnotationUtil} utility class and allows to avoid unecessary object constructions.
+ */
+
+ public static PsiAnnotation[] getAnnotationsFromImpl(PsiModifierListOwner owner,
+ Pair<String, ? extends Set<String>> annotationName,
+ boolean allowIndirect, boolean inHierarchy) {
final PsiAnnotation directAnnotation = inHierarchy?
AnnotationUtil.findAnnotationInHierarchy(owner, annotationName.second) :
AnnotationUtil.findAnnotation(owner, annotationName.second);
@@ -241,11 +258,9 @@
@Nullable
public static String calcAnnotationValue(@NotNull PsiAnnotation annotation, @NonNls String attr) {
PsiElement value = annotation.findAttributeValue(attr);
- if (value instanceof PsiExpression) {
- Object o = CONSTANT_EVALUATION_HELPER.computeConstantExpression(value);
- if (o instanceof String) {
- return (String)o;
- }
+ Object o = CONSTANT_EVALUATION_HELPER.computeConstantExpression(value);
+ if (o instanceof String) {
+ return (String)o;
}
return null;
}
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/InjectorUtils.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/InjectorUtils.java
index 364f241..be97f2c 100644
--- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/InjectorUtils.java
+++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/InjectorUtils.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -233,9 +233,9 @@
@Nullable
public static <T> T findNearestComment(PsiElement element, NullableFunction<PsiComment, T> processor) {
if (element instanceof PsiComment) return null;
- PsiComment comment = null;
+ PsiComment comment;
PsiElement start = element;
- for (int i=0; i<2 && start != null; i++) {
+ for (int i = 0; i < 3 && start != null; i++) {
if (start instanceof PsiFile) return null;
for (PsiElement e = start.getPrevSibling(); e != null; e = e.getPrevSibling()) {
if (e instanceof PsiComment) {
@@ -244,14 +244,14 @@
if (value != null) return value;
else continue;
}
- else if (e instanceof PsiWhiteSpace) continue;
+ else if (e instanceof PsiWhiteSpace || e.getText().trim().isEmpty()) continue;
else if (e instanceof PsiLanguageInjectionHost) {
if (StringUtil.isEmptyOrSpaces(e.getText())) continue;
else return null;
}
break;
}
- start = element.getParent();
+ start = start.getParent();
}
return null;
}
diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/LanguagePanel.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/LanguagePanel.java
index c029af2..ec92040 100644
--- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/LanguagePanel.java
+++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/LanguagePanel.java
@@ -24,6 +24,7 @@
import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.ComboBox;
+import com.intellij.ui.AncestorListenerAdapter;
import com.intellij.ui.ColoredListCellRendererWrapper;
import com.intellij.ui.EditorTextField;
import com.intellij.ui.SimpleTextAttributes;
@@ -33,7 +34,6 @@
import javax.swing.*;
import javax.swing.event.AncestorEvent;
-import javax.swing.event.AncestorListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.Arrays;
@@ -75,6 +75,7 @@
}
});
myLanguage.addItemListener(new ItemListener() {
+ @Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
updateHighlighters();
@@ -82,16 +83,11 @@
}
});
- myRoot.addAncestorListener(new AncestorListener() {
+ myRoot.addAncestorListener(new AncestorListenerAdapter() {
+ @Override
public void ancestorAdded(AncestorEvent event) {
updateHighlighters();
}
-
- public void ancestorRemoved(AncestorEvent event) {
- }
-
- public void ancestorMoved(AncestorEvent event) {
- }
});
}
@@ -149,18 +145,21 @@
}
}
+ @Override
protected void resetImpl() {
setLanguage(myOrigInjection.getInjectedLanguageId());
setPrefix(myOrigInjection.getPrefix());
setSuffix(myOrigInjection.getSuffix());
}
+ @Override
protected void apply(BaseInjection i) {
i.setInjectedLanguageId(getLanguage());
i.setPrefix(getPrefix());
i.setSuffix(getSuffix());
}
+ @Override
public JPanel getComponent() {
return myRoot;
}
diff --git a/plugins/IntentionPowerPak/src/META-INF/plugin.xml b/plugins/IntentionPowerPak/src/META-INF/IntentionPowerPack.xml
similarity index 74%
rename from plugins/IntentionPowerPak/src/META-INF/plugin.xml
rename to plugins/IntentionPowerPak/src/META-INF/IntentionPowerPack.xml
index ae2854a..e22859d 100644
--- a/plugins/IntentionPowerPak/src/META-INF/plugin.xml
+++ b/plugins/IntentionPowerPak/src/META-INF/IntentionPowerPack.xml
@@ -1,159 +1,180 @@
<idea-plugin version="2">
- <name>Intention Power Pack</name>
- <id>IntentionPowerPack</id>
- <version>1.0</version>
-
- <vendor>JetBrains</vendor>
- <resource-bundle>com.siyeh.IntentionPowerPackBundle</resource-bundle>
<extensions defaultExtensionNs="com.intellij">
- <errorHandler implementation="com.intellij.diagnostic.ITNReporter"/>
<!-- Annotations -->
<intentionAction>
<className>com.siyeh.ipp.annotation.ExpandToNormalAnnotationIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.annotations</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.annotation.AnnotateOverriddenMethodsIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.annotations</categoryKey>
</intentionAction>
<!-- Numbers -->
<intentionAction>
<className>com.siyeh.ipp.integer.ConvertIntegerToDecimalIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.numbers</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.integer.ConvertIntegerToHexIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.numbers</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.integer.ConvertToScientificNotationIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.numbers</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.integer.ConvertToPlainIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.numbers</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.integer.ConvertIntegerToOctalIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.numbers</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.integer.ConvertIntegerToBinaryIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.numbers</categoryKey>
</intentionAction>
<!-- Boolean -->
<intentionAction>
<className>com.siyeh.ipp.bool.DemorgansIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.boolean</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.bool.RemoveBooleanEqualityIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.boolean</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.bool.NegateComparisonIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.boolean</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.bool.FlipComparisonIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.boolean</categoryKey>
</intentionAction>
<!--
<intentionAction>
<className>com.siyeh.ipp.bool.FlipConjunctionIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.boolean</categoryKey>
</intentionAction>
-->
<intentionAction>
<className>com.siyeh.ipp.equality.ReplaceEqualsWithEqualityIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.boolean</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.equality.ReplaceEqualityWithEqualsIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.boolean</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.trivialif.ExpandBooleanIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.boolean</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.trivialif.ConvertToNestedIfIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.boolean</categoryKey>
</intentionAction>
<!-- Conditional Operator -->
<intentionAction>
<className>com.siyeh.ipp.conditional.FlipConditionalIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.conditional.operator</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.conditional.ReplaceConditionalWithIfIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.conditional.operator</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.trivialif.ReplaceIfWithConditionalIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.conditional.operator</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.conditional.RemoveConditionalIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.conditional.operator</categoryKey>
</intentionAction>
<!-- Shift -->
<intentionAction>
<className>com.siyeh.ipp.shift.ReplaceMultiplyWithShiftIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.shift.operation</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.shift.ReplaceShiftWithMultiplyIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.shift.operation</categoryKey>
</intentionAction>
<!-- JUnit -->
<intentionAction>
<className>com.siyeh.ipp.junit.ReplaceAssertEqualsWithAssertLiteralIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.junit</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.junit.ReplaceAssertLiteralWithAssertEqualsIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.junit</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.junit.CreateAssertIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.junit</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.junit.FlipAssertLiteralIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.junit</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.junit.ConvertJUnit3TestCaseToJUnit4Intention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.junit</categoryKey>
</intentionAction>
@@ -162,74 +183,89 @@
<!--
<intentionAction>
<className>com.siyeh.ipp.decls.MoveDeclarationIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.declaration</categoryKey>
</intentionAction>
-->
<intentionAction>
<className>com.siyeh.ipp.braces.AddArrayCreationExpressionIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.declaration</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.decls.SimplifyVariableIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.declaration</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.initialization.SplitDeclarationAndInitializationIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.declaration</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.interfacetoclass.ConvertInterfaceToClassIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.declaration</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.varargs.MakeMethodVarargsIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.declaration</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.varargs.ConvertVarargParameterToArrayIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.declaration</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.varargs.WrapVarargArgumentsWithExplicitArrayIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.declaration</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.adapter.AdapterToListenerIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.declaration</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.types.ReplaceDiamondWithExplicitTypeArgumentsIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.declaration</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.types.ReplaceLambdaWithAnonymousIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.declaration</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.types.ReplaceMethodRefWithLambdaIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.declaration</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.types.InferLambdaParameterTypeIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.declaration</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.types.ExpandOneLineLambda2CodeBlockIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.declaration</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.decls.ChangeVariableTypeToRhsTypeIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.declaration</categoryKey>
</intentionAction>
@@ -237,27 +273,32 @@
<intentionAction>
<className>com.siyeh.ipp.fqnames.ReplaceFullyQualifiedNameWithImportIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.declaration</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.imports.ReplaceOnDemandImportIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.declaration</categoryKey>
</intentionAction>
<!-- Comments -->
<intentionAction>
<className>com.siyeh.ipp.comment.ChangeToCStyleCommentIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.comments</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.comment.ChangeToEndOfLineCommentIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.comments</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.comment.MoveCommentToSeparateLineIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.comments</categoryKey>
</intentionAction>
@@ -265,74 +306,92 @@
<!-- Control Flow -->
<intentionAction>
<className>com.siyeh.ipp.trivialif.SplitElseIfIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.control.flow</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.trivialif.MergeElseIfIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.control.flow</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.trivialif.MergeIfAndIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.control.flow</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.trivialif.MergeIfOrIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.control.flow</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.trivialif.MergeParallelIfsIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.control.flow</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.switchtoif.ReplaceSwitchWithIfIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.control.flow</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.switchtoif.ReplaceIfWithSwitchIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.control.flow</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.trivialif.SimplifyIfElseIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.control.flow</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.forloop.ReplaceForEachLoopWithIndexedForLoopIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.control.flow</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.forloop.ReplaceForEachLoopWithOptimizedIndexedForLoopIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.control.flow</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.forloop.ReplaceForEachLoopWithIteratorForLoopIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.control.flow</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.forloop.ReplaceForLoopWithWhileLoopIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.control.flow</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.whileloop.ReplaceWhileLoopWithDoWhileLoopIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.control.flow</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.whileloop.ReplaceDoWhileLoopWithWhileLoopIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.control.flow</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.whileloop.ExtractWhileLoopConditionToIfStatementIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.control.flow</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.braces.AddBracesIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.control.flow</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.braces.RemoveBracesIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.control.flow</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.forloop.ReverseForLoopDirectionIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.control.flow</categoryKey>
</intentionAction>
@@ -340,153 +399,195 @@
<intentionAction>
<className>com.siyeh.ipp.modifiers.MakePublicIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.modifiers</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.modifiers.MakePackagePrivateIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.modifiers</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.modifiers.MakeProtectedIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.modifiers</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.modifiers.MakePrivateIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.modifiers</categoryKey>
</intentionAction>
<!-- Other -->
<intentionAction>
<className>com.siyeh.ipp.expression.FlipExpressionIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.expression.FlipSetterCallIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.commutative.FlipCommutativeMethodCallIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.commutative.SwapMethodCallArgumentsIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.parenthesis.RemoveUnnecessaryParenthesesIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.concatenation.ReplaceConcatenationWithStringBufferIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.strings</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.concatenation.ReplaceConcatenationWithFormatStringIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.strings</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.concatenation.CopyConcatenatedStringToClipboardIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.strings</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.concatenation.JoinConcatenatedStringLiteralsIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.strings</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.concatenation.MakeCallChainIntoCallSequenceIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.concatenation.MergeCallSequenceToChainIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.exceptions.DetailExceptionsIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.exceptions.ConvertCatchToThrowsIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.exceptions.SplitMultiCatchIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.exceptions.ReplaceArmWithTryFinallyIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.exceptions.MergeNestedTryStatementsIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.exceptions.SplitTryWithMultipleResourcesIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.exceptions.ObscureThrownExceptionsIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.opassign.ReplaceWithOperatorAssignmentIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.opassign.ReplaceOperatorAssignmentWithAssignmentIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.opassign.ReplaceOperatorAssignmentWithPostfixExpressionIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.opassign.ReplacePostfixExpressionWithOperatorAssignmentIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.opassign.ReplacePostfixExpressionWithAssignmentIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.opassign.ReplaceAssignmentWithPostfixExpressionIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.chartostring.CharToStringIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.strings</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.chartostring.StringToCharIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.strings</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.asserttoif.AssertToIfIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.asserttoif.IfToAssertionIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.enumswitch.CreateEnumSwitchBranchesIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.constant.ConstantExpressionIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.constant.ConstantSubexpressionIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.increment.ExtractIncrementIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
</intentionAction>
<intentionAction>
<className>com.siyeh.ipp.parenthesis.AddClarifyingParenthesesIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
<categoryKey>intention.category.other</categoryKey>
</intentionAction>
+ <intentionAction>
+ <className>com.siyeh.ipp.types.MakeMethodDefaultIntention</className>
+ <bundleName>com.siyeh.IntentionPowerPackBundle</bundleName>
+ <categoryKey>intention.category.declaration</categoryKey>
+ </intentionAction>
</extensions>
</idea-plugin>
diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/types/MakeMethodDefaultIntention.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/types/MakeMethodDefaultIntention.java
new file mode 100644
index 0000000..e4c3cac
--- /dev/null
+++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/types/MakeMethodDefaultIntention.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2011 Bas Leijdekkers
+ *
+ * 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.siyeh.ipp.types;
+
+import com.intellij.codeInsight.FileModificationService;
+import com.intellij.codeInsight.daemon.impl.quickfix.AddMethodBodyFix;
+import com.intellij.codeInsight.intention.BaseElementAtCaretIntentionAction;
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.project.Project;
+import com.intellij.psi.*;
+import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.psi.util.PsiUtil;
+import com.intellij.util.IncorrectOperationException;
+import org.jetbrains.annotations.NotNull;
+
+public class MakeMethodDefaultIntention extends BaseElementAtCaretIntentionAction {
+ @NotNull
+ @Override
+ public String getText() {
+ return "Make method default";
+ }
+
+ @NotNull
+ @Override
+ public String getFamilyName() {
+ return getText();
+ }
+
+ @Override
+ public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
+ final PsiMethod psiMethod = PsiTreeUtil.getParentOfType(element, PsiMethod.class, false);
+ if (psiMethod != null && PsiUtil.isLanguageLevel8OrHigher(psiMethod)) {
+ if (psiMethod.getBody() == null && !psiMethod.hasModifierProperty(PsiModifier.DEFAULT)) {
+ final PsiClass containingClass = psiMethod.getContainingClass();
+ return containingClass != null && containingClass.isInterface();
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException {
+ if (!FileModificationService.getInstance().preparePsiElementForWrite(element)) return;
+ final PsiMethod psiMethod = PsiTreeUtil.getParentOfType(element, PsiMethod.class, false);
+ if (psiMethod != null) {
+ final PsiModifierList modifierList = psiMethod.getModifierList();
+ modifierList.setModifierProperty(PsiModifier.DEFAULT, true);
+ new AddMethodBodyFix(psiMethod).invoke(project, editor, psiMethod.getContainingFile());
+ }
+ }
+}
diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/whileloop/ReplaceDoWhileLoopWithWhileLoopIntention.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/whileloop/ReplaceDoWhileLoopWithWhileLoopIntention.java
index 573359d..9561be7 100644
--- a/plugins/IntentionPowerPak/src/com/siyeh/ipp/whileloop/ReplaceDoWhileLoopWithWhileLoopIntention.java
+++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/whileloop/ReplaceDoWhileLoopWithWhileLoopIntention.java
@@ -18,6 +18,7 @@
import com.intellij.psi.*;
import com.siyeh.ipp.base.Intention;
import com.siyeh.ipp.base.PsiElementPredicate;
+import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
public class ReplaceDoWhileLoopWithWhileLoopIntention extends Intention {
@@ -35,7 +36,7 @@
final PsiStatement body = doWhileStatement.getBody();
final PsiElement parent = doWhileStatement.getParent();
boolean noBraces = !(parent instanceof PsiCodeBlock);
- final StringBuilder replacementText = new StringBuilder();
+ @NonNls final StringBuilder replacementText = new StringBuilder();
if (noBraces) {
final PsiElement[] parentChildren = parent.getChildren();
for (PsiElement child : parentChildren) {
@@ -53,6 +54,16 @@
if (children.length > 2) {
for (int i = 1, length = children.length - 1; i < length; i++) {
final PsiElement child = children[i];
+ if (child instanceof PsiDeclarationStatement) {
+ final PsiDeclarationStatement declarationStatement = (PsiDeclarationStatement)child;
+ final PsiElement[] declaredElements = declarationStatement.getDeclaredElements();
+ for (PsiElement declaredElement : declaredElements) {
+ if (declaredElement instanceof PsiVariable) {
+ final PsiVariable variable = (PsiVariable)declaredElement;
+ variable.getModifierList().setModifierProperty(PsiModifier.FINAL, false);
+ }
+ }
+ }
if (noBraces) {
replacementText.append(child.getText());
}
diff --git a/plugins/IntentionPowerPak/src/intentionDescriptions/MakeMethodDefaultIntention/after.java.template b/plugins/IntentionPowerPak/src/intentionDescriptions/MakeMethodDefaultIntention/after.java.template
new file mode 100644
index 0000000..57243a5
--- /dev/null
+++ b/plugins/IntentionPowerPak/src/intentionDescriptions/MakeMethodDefaultIntention/after.java.template
@@ -0,0 +1,3 @@
+public interface X {
+ default void foo(){}
+}
\ No newline at end of file
diff --git a/plugins/IntentionPowerPak/src/intentionDescriptions/MakeMethodDefaultIntention/before.java.template b/plugins/IntentionPowerPak/src/intentionDescriptions/MakeMethodDefaultIntention/before.java.template
new file mode 100644
index 0000000..db31b04
--- /dev/null
+++ b/plugins/IntentionPowerPak/src/intentionDescriptions/MakeMethodDefaultIntention/before.java.template
@@ -0,0 +1,3 @@
+public interface X {
+ <spot>void foo()</spot>
+}
\ No newline at end of file
diff --git a/plugins/IntentionPowerPak/src/intentionDescriptions/MakeMethodDefaultIntention/description.html b/plugins/IntentionPowerPak/src/intentionDescriptions/MakeMethodDefaultIntention/description.html
new file mode 100644
index 0000000..d939cf8
--- /dev/null
+++ b/plugins/IntentionPowerPak/src/intentionDescriptions/MakeMethodDefaultIntention/description.html
@@ -0,0 +1,6 @@
+<html>
+<body>
+This intention adds default modifier and body to method in interface
+<!-- tooltip end -->
+</body>
+</html>
\ No newline at end of file
diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/makeDefault/AlreadyDefault.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/makeDefault/AlreadyDefault.java
new file mode 100644
index 0000000..ff1ad43
--- /dev/null
+++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/makeDefault/AlreadyDefault.java
@@ -0,0 +1,3 @@
+interface I {
+ default void fo<caret>o();
+}
\ No newline at end of file
diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/makeDefault/AlreadyHasBody.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/makeDefault/AlreadyHasBody.java
new file mode 100644
index 0000000..b2f49a2
--- /dev/null
+++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/makeDefault/AlreadyHasBody.java
@@ -0,0 +1,3 @@
+interface I {
+ void fo<caret>o() {}
+}
\ No newline at end of file
diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/makeDefault/InInterface.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/makeDefault/InInterface.java
new file mode 100644
index 0000000..5d86030
--- /dev/null
+++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/makeDefault/InInterface.java
@@ -0,0 +1,3 @@
+interface I {
+ void f<caret>oo();
+}
\ No newline at end of file
diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/makeDefault/InInterface_after.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/makeDefault/InInterface_after.java
new file mode 100644
index 0000000..49b7858
--- /dev/null
+++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/makeDefault/InInterface_after.java
@@ -0,0 +1,5 @@
+interface I {
+ default void foo() {
+ <caret>
+ }
+}
\ No newline at end of file
diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/whileloop/replace_do_while_with_while_loop/FinalVariable1.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/whileloop/replace_do_while_with_while_loop/FinalVariable1.java
new file mode 100644
index 0000000..01f24b7
--- /dev/null
+++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/whileloop/replace_do_while_with_while_loop/FinalVariable1.java
@@ -0,0 +1,10 @@
+package com.siyeh.ipp.whileloop.replace_do_while_with_while_loop;
+
+class FinalVariable1 {
+ void m() {
+ <caret>do {
+ final int j = 10;
+ System.out.println(j);
+ } while (true);
+ }
+}
\ No newline at end of file
diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/whileloop/replace_do_while_with_while_loop/FinalVariable1_after.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/whileloop/replace_do_while_with_while_loop/FinalVariable1_after.java
new file mode 100644
index 0000000..2177673
--- /dev/null
+++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/whileloop/replace_do_while_with_while_loop/FinalVariable1_after.java
@@ -0,0 +1,12 @@
+package com.siyeh.ipp.whileloop.replace_do_while_with_while_loop;
+
+class FinalVariable1 {
+ void m() {
+ int j = 10;
+ System.out.println(j);
+ while (true) {
+ j = 10;
+ System.out.println(j);
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/whileloop/replace_do_while_with_while_loop/FinalVariable2.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/whileloop/replace_do_while_with_while_loop/FinalVariable2.java
new file mode 100644
index 0000000..d00a1af
--- /dev/null
+++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/whileloop/replace_do_while_with_while_loop/FinalVariable2.java
@@ -0,0 +1,11 @@
+package com.siyeh.ipp.whileloop.replace_do_while_with_while_loop;
+
+class FinalVariable2 {
+
+ void m(boolean b) {
+ if (b) do<caret> {
+ final int i = 10;
+ System.out.println(i);
+ } while (true);
+ }
+}
\ No newline at end of file
diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/whileloop/replace_do_while_with_while_loop/FinalVariable2_after.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/whileloop/replace_do_while_with_while_loop/FinalVariable2_after.java
new file mode 100644
index 0000000..57b867d
--- /dev/null
+++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/whileloop/replace_do_while_with_while_loop/FinalVariable2_after.java
@@ -0,0 +1,15 @@
+package com.siyeh.ipp.whileloop.replace_do_while_with_while_loop;
+
+class FinalVariable2 {
+
+ void m(boolean b) {
+ if (b) {
+ int i = 10;
+ System.out.println(i);
+ while (true) {
+ i = 10;
+ System.out.println(i);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/types/MakeMethodDefaultTest.java b/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/types/MakeMethodDefaultTest.java
new file mode 100644
index 0000000..e81dda4
--- /dev/null
+++ b/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/types/MakeMethodDefaultTest.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2000-2013 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.siyeh.ipp.types;
+
+import com.siyeh.IntentionPowerPackBundle;
+import com.siyeh.ipp.IPPTestCase;
+
+public class MakeMethodDefaultTest extends IPPTestCase {
+
+ @Override
+ protected String getIntentionName() {
+ return "Make method default";
+ }
+
+ @Override
+ protected String getRelativePath() {
+ return "types/makeDefault";
+ }
+
+ public void testInInterface() throws Exception {
+ doTest();
+ }
+
+ public void testAlreadyDefault() throws Exception {
+ assertIntentionNotAvailable();
+ }
+
+ public void testAlreadyHasBody() throws Exception {
+ assertIntentionNotAvailable();
+ }
+}
diff --git a/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/whileloop/ReplaceDoWhileWithWhileLoopIntentionTest.java b/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/whileloop/ReplaceDoWhileWithWhileLoopIntentionTest.java
index be2ec43..daa7481 100644
--- a/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/whileloop/ReplaceDoWhileWithWhileLoopIntentionTest.java
+++ b/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/whileloop/ReplaceDoWhileWithWhileLoopIntentionTest.java
@@ -6,6 +6,8 @@
public class ReplaceDoWhileWithWhileLoopIntentionTest extends IPPTestCase {
public void testWithoutBraces() { doTest(); }
+ public void testFinalVariable1() { doTest(); }
+ public void testFinalVariable2() { doTest(); }
@Override
protected String getRelativePath() {
diff --git a/plugins/android/lib/guava-13.0.1.jar b/plugins/android/lib/guava-13.0.1.jar
deleted file mode 100644
index 09c5449..0000000
--- a/plugins/android/lib/guava-13.0.1.jar
+++ /dev/null
Binary files differ
diff --git a/plugins/android/lib/jarutils.jar b/plugins/android/lib/jarutils.jar
deleted file mode 100644
index 1259ccf..0000000
--- a/plugins/android/lib/jarutils.jar
+++ /dev/null
Binary files differ
diff --git a/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/build/AntArtifactBuildTaskProvider.java b/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/build/AntArtifactBuildTaskProvider.java
index f86377f..6a4c9c8 100644
--- a/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/build/AntArtifactBuildTaskProvider.java
+++ b/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/build/AntArtifactBuildTaskProvider.java
@@ -29,6 +29,7 @@
import com.intellij.util.SystemProperties;
import com.intellij.util.execution.ParametersListUtil;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.ant.model.JpsAntBuildFileOptions;
import org.jetbrains.jps.ant.model.JpsAntExtensionService;
import org.jetbrains.jps.ant.model.JpsAntInstallation;
@@ -73,9 +74,16 @@
return Collections.emptyList();
}
+ @Nullable
private static JpsAntArtifactExtension getBuildExtension(JpsArtifact artifact, ArtifactBuildPhase buildPhase) {
- return buildPhase == ArtifactBuildPhase.PRE_PROCESSING ? JpsAntExtensionService.getPreprocessingExtension(artifact)
- : JpsAntExtensionService.getPostprocessingExtension(artifact);
+ switch (buildPhase) {
+ case PRE_PROCESSING:
+ return JpsAntExtensionService.getPreprocessingExtension(artifact);
+ case POST_PROCESSING:
+ return JpsAntExtensionService.getPostprocessingExtension(artifact);
+ default:
+ return null;
+ }
}
private static class AntArtifactBuildTask extends BuildTask {
diff --git a/plugins/copyright/src/com/maddyhome/idea/copyright/psi/UpdatePsiFileCopyright.java b/plugins/copyright/src/com/maddyhome/idea/copyright/psi/UpdatePsiFileCopyright.java
index c8f51ff..72540bc 100644
--- a/plugins/copyright/src/com/maddyhome/idea/copyright/psi/UpdatePsiFileCopyright.java
+++ b/plugins/copyright/src/com/maddyhome/idea/copyright/psi/UpdatePsiFileCopyright.java
@@ -43,6 +43,7 @@
import java.util.TreeSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
public abstract class UpdatePsiFileCopyright extends AbstractUpdateCopyright {
private final CopyrightProfile myOptions;
@@ -246,6 +247,8 @@
addAction(new CommentAction(pos, prefix, suffix));
}
}
+ catch (PatternSyntaxException ignore) {
+ }
catch (Exception e) {
logger.error(e);
}
diff --git a/plugins/copyright/src/com/maddyhome/idea/copyright/ui/CopyrightConfigurable.java b/plugins/copyright/src/com/maddyhome/idea/copyright/ui/CopyrightConfigurable.java
index 5ab45c4..de3b1d7 100644
--- a/plugins/copyright/src/com/maddyhome/idea/copyright/ui/CopyrightConfigurable.java
+++ b/plugins/copyright/src/com/maddyhome/idea/copyright/ui/CopyrightConfigurable.java
@@ -23,6 +23,7 @@
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.NamedConfigurable;
import com.intellij.openapi.util.Comparing;
+import com.intellij.openapi.util.text.StringUtil;
import com.maddyhome.idea.copyright.CopyrightManager;
import com.maddyhome.idea.copyright.CopyrightProfile;
import com.maddyhome.idea.copyright.pattern.EntityUtil;
@@ -34,6 +35,8 @@
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
public class CopyrightConfigurable extends NamedConfigurable<CopyrightProfile> {
private final CopyrightProfile myCopyrightProfile;
@@ -104,7 +107,16 @@
public void apply() throws ConfigurationException {
myCopyrightProfile.setNotice(EntityUtil.encode(myCopyrightPane.getText().trim()));
- myCopyrightProfile.setKeyword(myKeywordTf.getText());
+ final String keyword = myKeywordTf.getText().trim();
+ try {
+ if (!StringUtil.isEmptyOrSpaces(keyword)) {
+ Pattern.compile(keyword);
+ }
+ }
+ catch (PatternSyntaxException e) {
+ throw new ConfigurationException("Keyword pattern syntax is incorrect: " + e.getMessage());
+ }
+ myCopyrightProfile.setKeyword(keyword);
myCopyrightProfile.setAllowReplaceKeyword(myAllowReplaceTextField.getText());
CopyrightManager.getInstance(myProject).replaceCopyright(myDisplayName, myCopyrightProfile);
myDisplayName = myCopyrightProfile.getName();
diff --git a/plugins/copyright/src/com/maddyhome/idea/copyright/ui/CopyrightProfilesPanel.java b/plugins/copyright/src/com/maddyhome/idea/copyright/ui/CopyrightProfilesPanel.java
index 2efff52..6c349e0 100644
--- a/plugins/copyright/src/com/maddyhome/idea/copyright/ui/CopyrightProfilesPanel.java
+++ b/plugins/copyright/src/com/maddyhome/idea/copyright/ui/CopyrightProfilesPanel.java
@@ -33,7 +33,6 @@
import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.ui.popup.PopupStep;
import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
-import com.intellij.openapi.util.Conditions;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.IconUtil;
@@ -167,7 +166,7 @@
addProfileNode(copyrightProfile);
}
});
- result.add(new MyDeleteAction(forAll(Conditions.alwaysTrue())));
+ result.add(new MyDeleteAction());
result.add(new AnAction("Copy", "Copy", PlatformIcons.COPY_ICON) {
{
registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_D, KeyEvent.CTRL_MASK)), myTree);
diff --git a/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/config/ProxySettings.java b/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/config/ProxySettings.java
index 4bf54fd..8f1c4f3 100644
--- a/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/config/ProxySettings.java
+++ b/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/config/ProxySettings.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -26,15 +26,16 @@
private static final Logger LOG = Logger.getInstance("#com.intellij.cvsSupport2.config.ConnectionSettingsImpl");
- public static int HTTP = 0;
- public static int SOCKS4 = 1;
- public static int SOCKS5 = 2;
+ public static final int HTTP = 0;
+ public static final int SOCKS4 = 1;
+ public static final int SOCKS5 = 2;
public boolean USE_PROXY = false;
public String PROXY_HOST = "";
public int PROXY_PORT = 8080;
public int TYPE = HTTP;
public String LOGIN = "";
+ public String PASSWORD = "";
@Override
public boolean equals(Object o) {
@@ -66,8 +67,6 @@
return result;
}
- public String PASSWORD = "";
-
@Override
public void readExternal(Element element) throws InvalidDataException {
DefaultJDOMExternalizer.readExternal(this, element);
diff --git a/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/ConnectionSettingsImpl.java b/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/ConnectionSettingsImpl.java
index abbe02f..64dce4f 100644
--- a/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/ConnectionSettingsImpl.java
+++ b/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/ConnectionSettingsImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -74,6 +74,9 @@
}
public int getProxyPort() {
+ if (myProxyPort < 0 || myProxyPort > 0xFFFF) {
+ return 80;
+ }
return myProxyPort;
}
diff --git a/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/ext/ExtConnection.java b/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/ext/ExtConnection.java
index f9b797c..dd15a20 100644
--- a/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/ext/ExtConnection.java
+++ b/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/ext/ExtConnection.java
@@ -76,16 +76,15 @@
private void check(ICvsCommandStopper stopper, String expectedResult) throws IOException, AuthenticationException {
InputStreamWrapper streamWrapper = new InputStreamWrapper(myInputStream, stopper, new ReadWriteStatistics());
try {
- int i;
StringBuilder buffer = new StringBuilder();
while (true) {
- i = streamWrapper.read();
+ int i = streamWrapper.read();
if (i == -1 || i == '\n' || i == ' ' || i == '\r') break;
buffer.append((char)i);
}
String read = buffer.toString().trim();
if (!expectedResult.equals(read)) {
- if (StringUtil.startsWithConcatenationOf(read, myUserName + "@", myHost)) {
+ if (StringUtil.startsWithConcatenation(read, myUserName, "@", myHost)) {
throw new AuthenticationException(CvsBundle.message("exception.text.ext.server.rejected.access"), null);
}
else {
@@ -110,12 +109,12 @@
command.addParameter("-l");
command.addParameter(userName);
- if (config.PRIVATE_KEY_FILE.length() > 0) {
+ if (!config.PRIVATE_KEY_FILE.isEmpty()) {
command.addParameter("-i");
command.addParameter(config.PRIVATE_KEY_FILE);
}
- if (config.ADDITIONAL_PARAMETERS.length() > 0) {
+ if (!config.ADDITIONAL_PARAMETERS.isEmpty()) {
StringTokenizer parameters = new StringTokenizer(config.ADDITIONAL_PARAMETERS, " ");
while (parameters.hasMoreTokens()) command.addParameter(parameters.nextToken());
}
diff --git a/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/ssh/SocksAuthenticatorManager.java b/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/ssh/SocksAuthenticatorManager.java
index e4ca2c4..4a310d3 100644
--- a/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/ssh/SocksAuthenticatorManager.java
+++ b/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/ssh/SocksAuthenticatorManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -15,6 +15,7 @@
*/
package com.intellij.cvsSupport2.connections.ssh;
+import com.intellij.cvsSupport2.config.ProxySettings;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.util.KeyValue;
import com.intellij.openapi.util.Pair;
@@ -30,9 +31,9 @@
import java.util.Map;
public class SocksAuthenticatorManager {
- private final static String SOCKS_REQUESTING_PROTOCOL = "SOCKS";
+
private final Object myLock;
- private CvsProxySelector mySelector;
+ private volatile CvsProxySelector mySelector;
public static SocksAuthenticatorManager getInstance() {
return ServiceManager.getService(SocksAuthenticatorManager.class);
@@ -53,6 +54,9 @@
public void unregister(final ConnectionSettings connectionSettings) {
SshLogger.debug("unregister in authenticator");
+ if (!connectionSettings.isUseProxy()) return;
+ final int proxyType = connectionSettings.getProxyType();
+ if (proxyType != ProxySettings.SOCKS4 && proxyType != ProxySettings.SOCKS5) return;
mySelector.unregister(connectionSettings.getHostName(), connectionSettings.getPort());
CommonProxy.getInstance().removeCustomAuth(getClass().getName());
}
diff --git a/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/ssh/SshProxyFactory.java b/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/ssh/SshProxyFactory.java
index 02611b0..0970025 100644
--- a/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/ssh/SshProxyFactory.java
+++ b/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/ssh/SshProxyFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -26,19 +26,18 @@
import java.net.Socket;
public class SshProxyFactory {
- private SshProxyFactory() {
- }
+
+ private SshProxyFactory() {}
@Nullable
public static ProxyData createAndRegister(final ConnectionSettings connectionSettings) {
- ProxyData result = null;
- if (! connectionSettings.isUseProxy()) return null;
+ if (!connectionSettings.isUseProxy()) return null;
final int type = connectionSettings.getProxyType();
- if ((ProxySettings.SOCKS4 == type) || (ProxySettings.SOCKS5 == type)) {
+ ProxyData result = null;
+ if (ProxySettings.SOCKS4 == type || ProxySettings.SOCKS5 == type) {
result = new SocksProxyData(connectionSettings);
SocksAuthenticatorManager.getInstance().register(connectionSettings);
} else if (ProxySettings.HTTP == type) {
- /*String proxyHost, int proxyPort, String proxyUser, String proxyPass*/
result = new HTTPProxyData(connectionSettings.getProxyHostName(), connectionSettings.getProxyPort(),
connectionSettings.getProxyLogin(), connectionSettings.getProxyPassword());
}
diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/changeBrowser/CvsChangeList.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/changeBrowser/CvsChangeList.java
index e44cce9..8227f8e 100644
--- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/changeBrowser/CvsChangeList.java
+++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/changeBrowser/CvsChangeList.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -148,7 +148,7 @@
final File localFile;
if (myRootFile != null) {
final String directorySuffix = myRootFile.isDirectory() ? "/" : "";
- if (StringUtil.startsWithConcatenationOf(path, myRootPath, directorySuffix)) {
+ if (StringUtil.startsWithConcatenation(path, myRootPath, directorySuffix)) {
path = path.substring(myRootPath.length() + directorySuffix.length());
localFile = new File(myRootFile.getPresentableUrl(), path);
}
@@ -242,7 +242,7 @@
}
public static boolean isAncestor(final String parent, final String child) {
- return child.equals(parent) || StringUtil.startsWithConcatenationOf(child, parent, "/");
+ return child.equals(parent) || StringUtil.startsWithConcatenation(child, parent, "/");
}
public boolean equals(final Object o) {
diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/ui/Cvs2SettingsEditPanel.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/ui/Cvs2SettingsEditPanel.java
index 5766ea0..4807000 100644
--- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/ui/Cvs2SettingsEditPanel.java
+++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/ui/Cvs2SettingsEditPanel.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -125,6 +125,7 @@
public void addCvsRootChangeListener(CvsRootChangeListener cvsRootChangeListener) {
myCvsRootConfigurationPanelView.addCvsRootChangeListener(cvsRootChangeListener);
+ myExtConnectionSettingsEditor.addCvsRootChangeListener(cvsRootChangeListener);
}
public void updateFrom(final CvsRootConfiguration configuration) {
@@ -275,11 +276,17 @@
}
}
- private static String getProxyPanelName(CvsRootData cvsRootData) {
+ private String getProxyPanelName(CvsRootData cvsRootData) {
if (cvsRootData.METHOD == null) {
return EMPTY;
}
- return cvsRootData.METHOD.supportsProxyConnection() ? NON_EMPTY_PROXY_SETTINGS : EMPTY;
+ if (cvsRootData.METHOD.supportsProxyConnection()) {
+ return NON_EMPTY_PROXY_SETTINGS;
+ }
+ if (cvsRootData.METHOD == CvsMethod.EXT_METHOD && myExtConnectionSettingsEditor.isUseInternalSshImplementation()) {
+ return NON_EMPTY_PROXY_SETTINGS;
+ }
+ return EMPTY;
}
private static String getSettingsPanelName(CvsRootData cvsRootData) {
diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/ui/CvsRootFieldByFieldConfigurationPanel.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/ui/CvsRootFieldByFieldConfigurationPanel.java
index 84faf4f..de9029d 100644
--- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/ui/CvsRootFieldByFieldConfigurationPanel.java
+++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/ui/CvsRootFieldByFieldConfigurationPanel.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -28,6 +28,7 @@
* author: lesya
*/
public class CvsRootFieldByFieldConfigurationPanel {
+
private JComboBox myMethods;
private JTextField myUser;
private JTextField myHost;
@@ -64,7 +65,7 @@
}
public String getSettings() {
- final int port = FormUtils.getPositiveIntFieldValue(myPort, true, true);
+ final int port = FormUtils.getPositiveIntFieldValue(myPort, true, true, 0xFFFF);
final CvsMethod cvsMethod = (CvsMethod)myMethods.getSelectedItem();
final String user = FormUtils.getFieldValue(myUser, cvsMethod.hasUserValue());
final String host = FormUtils.getFieldValue(myHost, cvsMethod.hasHostValue());
diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/ext/ExtConnectionCvsSettings.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/ext/ExtConnectionCvsSettings.java
index c844efa..96f4532 100644
--- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/ext/ExtConnectionCvsSettings.java
+++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/ext/ExtConnectionCvsSettings.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -118,9 +118,8 @@
if (!(sourceException instanceof IOException)) return t;
String localizedMessage = t.getLocalizedMessage();
if (localizedMessage == null || !localizedMessage.startsWith(UNHANDLED_RESPONSE_PREFIX)) return t;
- String response = localizedMessage.substring(UNHANDLED_RESPONSE_PREFIX.length(),
- localizedMessage.length() - 1);
- if (StringUtil.startsWithConcatenationOf(response, USER + "@", HOST)) {
+ String response = localizedMessage.substring(UNHANDLED_RESPONSE_PREFIX.length(), localizedMessage.length() - 1);
+ if (StringUtil.startsWithConcatenation(response, USER, "@", HOST)) {
return new IOCommandException(new IOException(CvsBundle.message("exception.text.ext.server.rejected.access")));
}
else {
diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/ext/ui/ExtConnectionDualPanel.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/ext/ui/ExtConnectionDualPanel.java
index aa53dec..ae5ac5c 100644
--- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/ext/ui/ExtConnectionDualPanel.java
+++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/ext/ui/ExtConnectionDualPanel.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -19,23 +19,27 @@
import com.intellij.cvsSupport2.config.ExtConfiguration;
import com.intellij.cvsSupport2.config.SshSettings;
import com.intellij.cvsSupport2.connections.ssh.ui.SshConnectionSettingsPanel;
+import com.intellij.cvsSupport2.ui.CvsRootChangeListener;
import com.intellij.openapi.project.Project;
+import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NonNls;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.util.Collection;
public class ExtConnectionDualPanel {
private final ExtConnectionSettingsPanel myExtSettingsPanel;
private final SshConnectionSettingsPanel mySshSettingsPanel;
+ private final Collection<CvsRootChangeListener> myCvsRootChangeListeners = ContainerUtil.createLockFreeCopyOnWriteList();
+
private final JPanel myPanel = new JPanel(new BorderLayout());
private final JPanel myDualPanel = new JPanel(new CardLayout());
- private final JCheckBox myUseInternalImplementationCheckBox =
- new JCheckBox(CvsBundle.message("checkbox.text.use.internal.ssh.implementation"));
+ private final JCheckBox myUseInternalImplementationCheckBox = new JCheckBox(CvsBundle.message("checkbox.text.use.internal.ssh.implementation"));
@NonNls private static final String EXT = "EXT";
@NonNls private static final String SSH = "SSH";
@@ -52,12 +56,23 @@
myUseInternalImplementationCheckBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
updatePage();
+ notifyListeners();
}
});
}
+ public void addCvsRootChangeListener(CvsRootChangeListener l) {
+ myCvsRootChangeListeners.add(l);
+ }
+
+ private void notifyListeners() {
+ for (CvsRootChangeListener cvsRootChangeListener : myCvsRootChangeListeners) {
+ cvsRootChangeListener.onCvsRootChanged();
+ }
+ }
+
private void updatePage() {
- final CardLayout cardLayout = ((CardLayout)myDualPanel.getLayout());
+ final CardLayout cardLayout = (CardLayout)myDualPanel.getLayout();
if (myUseInternalImplementationCheckBox.isSelected()){
cardLayout.show(myDualPanel, SSH);
} else {
@@ -91,4 +106,8 @@
mySshSettingsPanel.saveTo(sshSettings);
extConfiguration.USE_INTERNAL_SSH_IMPLEMENTATION = myUseInternalImplementationCheckBox.isSelected();
}
+
+ public boolean isUseInternalSshImplementation() {
+ return myUseInternalImplementationCheckBox.isSelected();
+ }
}
diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/ui/ProxySettingsPanel.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/ui/ProxySettingsPanel.java
index 2cae92d..19fe241 100644
--- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/ui/ProxySettingsPanel.java
+++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/connections/ui/ProxySettingsPanel.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -25,6 +25,7 @@
import java.awt.event.ItemListener;
public class ProxySettingsPanel {
+
private JPanel myPanel;
private JTextField myProxyPort;
private JTextField myProxyHost;
@@ -124,7 +125,7 @@
}
return myUseProxy.isSelected() == proxySettings.USE_PROXY
&& myProxyHost.getText().equals(proxySettings.PROXY_HOST)
- && FormUtils.getPositiveIntFieldValue(myProxyPort, false, false) == proxySettings.PROXY_PORT
+ && FormUtils.getPositiveIntFieldValue(myProxyPort, false, false, 0xFFFF) == proxySettings.PROXY_PORT
&& getSelectedType() == proxySettings.getType()
&& myLogin.getText().equals(proxySettings.getLogin())
&& new String(myPassword.getPassword()).equals(proxySettings.getPassword());
@@ -145,7 +146,7 @@
public void saveTo(ProxySettings proxySettings) {
proxySettings.USE_PROXY = myUseProxy.isSelected();
proxySettings.PROXY_HOST = FormUtils.getFieldValue(myProxyHost, proxySettings.USE_PROXY);
- proxySettings.PROXY_PORT = FormUtils.getPositiveIntFieldValue(myProxyPort, true, false);
+ proxySettings.PROXY_PORT = FormUtils.getPositiveIntFieldValue(myProxyPort, true, false, 0xFFFF);
proxySettings.TYPE = getSelectedType();
proxySettings.LOGIN = myLogin.getText();
proxySettings.PASSWORD = new String(myPassword.getPassword());
diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsContent/DirectoryContentListener.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsContent/DirectoryContentListener.java
index 56a5136..197ca6a 100644
--- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsContent/DirectoryContentListener.java
+++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsContent/DirectoryContentListener.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -40,7 +40,7 @@
}
else if (fileMessage(message)) {
String fileName = fileNameFromMessage(message);
- if ((myModuleName != null) && StringUtil.startsWithConcatenationOf(fileName, myModuleName, "/")) {
+ if ((myModuleName != null) && StringUtil.startsWithConcatenation(fileName, myModuleName, "/")) {
fileName = fileName.substring(myModuleName.length() + 1);
}
final int slashPos = fileName.indexOf('/');
diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/history/CvsFileRevisionImpl.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/history/CvsFileRevisionImpl.java
index 96f2d6b..b497dd4 100644
--- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/history/CvsFileRevisionImpl.java
+++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/history/CvsFileRevisionImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -84,7 +84,7 @@
//noinspection unchecked
final List<SymbolicName> symNames = myLogInformation.getAllSymbolicNames();
for (final SymbolicName symName : symNames) {
- if (StringUtil.startsWithConcatenationOf(symName.getRevision(), myCvsRevision.getNumber(), ".") &&
+ if (StringUtil.startsWithConcatenation(symName.getRevision(), myCvsRevision.getNumber(), ".") &&
!processedSymbolicNames.contains(symName)) {
CvsRevisionNumber number = new CvsRevisionNumber(symName.getRevision().trim());
final int[] subRevisions = number.getSubRevisions();
diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/ui/FormUtils.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/ui/FormUtils.java
index 7f668384..865524e 100644
--- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/ui/FormUtils.java
+++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/ui/FormUtils.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 JetBrains s.r.o.
+ * Copyright 2011-2013 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.
@@ -23,8 +23,7 @@
public class FormUtils {
- private FormUtils() {
- }
+ private FormUtils() {}
public static String getFieldValue(JTextField field, boolean check) {
final String value = field.getText().trim();
@@ -51,7 +50,7 @@
return text;
}
- public static int getPositiveIntFieldValue(JTextField field, boolean check, boolean emptyAllowed) {
+ public static int getPositiveIntFieldValue(JTextField field, boolean check, boolean emptyAllowed, int max) {
final String text = field.getText().trim();
if (text.isEmpty()) {
if (check && !emptyAllowed) {
@@ -62,7 +61,7 @@
else {
try {
final int intPort = Integer.parseInt(text);
- if (check && intPort <= 0) {
+ if (check && (intPort <= 0 || intPort > max)) {
throw new InputException(CvsBundle.message("error.message.invalid.value", getLabelText(field), text), field);
}
return intPort;
diff --git a/plugins/devkit/src/dom/Group.java b/plugins/devkit/src/dom/Group.java
index 930278c..c35c31f 100644
--- a/plugins/devkit/src/dom/Group.java
+++ b/plugins/devkit/src/dom/Group.java
@@ -39,6 +39,14 @@
@NotNull
GenericAttributeValue<Boolean> getPopup();
+ /**
+ * Returns the value of the compact child.
+ * Attribute popup
+ * @return the value of the compact child.
+ */
+ @NotNull
+ GenericAttributeValue<Boolean> getCompact();
+
/**
* Returns the value of the icon child.
diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EPathUtil.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EPathUtil.java
index 9dcbeed..c5a23e1 100644
--- a/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EPathUtil.java
+++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EPathUtil.java
@@ -90,9 +90,21 @@
/**
* @return url
*/
- static String expandEclipsePath2Url(final String path, ModifiableRootModel model, final List<String> currentRoots) {
+ static String expandEclipsePath2Url(final String path,
+ final ModifiableRootModel model,
+ final List<String> currentRoots) {
final VirtualFile contentRoot = getContentRoot(model);
LOG.assertTrue(contentRoot != null);
+ return expandEclipsePath2Url(path, model, currentRoots, contentRoot);
+ }
+
+ /**
+ * @return url
+ */
+ static String expandEclipsePath2Url(final String path,
+ final ModifiableRootModel model,
+ final List<String> currentRoots,
+ @NotNull final VirtualFile contentRoot) {
final String rootPath = contentRoot.getPath();
String url = null;
if (new File(path).exists()) { //absolute path
@@ -209,6 +221,12 @@
return url.substring(projectUrl.length()); //leading /
}
+ final String path = VfsUtilCore.urlToPath(url);
+ final String projectPath = projectBaseDir.getPath();
+ if (path.startsWith(projectPath)) {
+ return ProjectRootManagerImpl.extractLocalPath(path.substring(projectPath.length()));
+ }
+
return ProjectRootManagerImpl.extractLocalPath(url);
}
}
diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EclipseClasspathReader.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EclipseClasspathReader.java
index 951d161..ce34809 100644
--- a/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EclipseClasspathReader.java
+++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EclipseClasspathReader.java
@@ -125,6 +125,10 @@
@Override
protected String expandEclipsePath2Url(ModifiableRootModel rootModel, String path) {
+ final VirtualFile contentRoot = myContentEntry.getFile();
+ if (contentRoot != null) {
+ return EPathUtil.expandEclipsePath2Url(path, rootModel, myCurrentRoots, contentRoot);
+ }
return EPathUtil.expandEclipsePath2Url(path, rootModel, myCurrentRoots);
}
diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/IdeaSpecificSettings.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/IdeaSpecificSettings.java
index fa34a48..ce03200 100644
--- a/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/IdeaSpecificSettings.java
+++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/IdeaSpecificSettings.java
@@ -25,12 +25,13 @@
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
-import com.intellij.openapi.module.ModuleUtil;
+import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.projectRoots.ProjectJdkTable;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.roots.*;
import com.intellij.openapi.roots.impl.DirectoryIndexExcludePolicy;
+import com.intellij.openapi.roots.impl.ProjectRootManagerImpl;
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar;
import com.intellij.openapi.util.Comparing;
@@ -39,7 +40,7 @@
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.JarFileSystem;
-import com.intellij.openapi.vfs.VfsUtil;
+import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.openapi.vfs.pointers.VirtualFilePointer;
@@ -320,7 +321,7 @@
}
}
}
- if (entryFile == null || excludeFile == null || VfsUtil.isAncestor(entryFile, excludeFile, false)) {
+ if (entryFile == null || excludeFile == null || VfsUtilCore.isAncestor(entryFile, excludeFile, false)) {
Element element = new Element(IdeaXml.EXCLUDE_FOLDER_TAG);
contentEntryElement.addContent(element);
element.setAttribute(IdeaXml.URL_ATTR, exludeFolderUrl);
@@ -453,13 +454,13 @@
public static boolean appendModuleRelatedRoot(Element element, String classesUrl, final String rootName, ModuleRootModel model) {
VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(classesUrl);
+ final Project project = model.getModule().getProject();
if (file != null) {
if (file.getFileSystem() instanceof JarFileSystem) {
file = JarFileSystem.getInstance().getVirtualFileForJar(file);
assert file != null;
}
- final Project project = model.getModule().getProject();
- final Module module = ModuleUtil.findModuleForFile(file, project);
+ final Module module = ModuleUtilCore.findModuleForFile(file, project);
if (module != null) {
return appendRelatedToModule(element, classesUrl, rootName, file, module);
} else if (ProjectRootManager.getInstance(project).getFileIndex().isIgnored(file)) {
@@ -474,7 +475,7 @@
private static boolean appendRelatedToModule(Element element, String classesUrl, String rootName, VirtualFile file, Module module) {
final VirtualFile[] contentRoots = ModuleRootManager.getInstance(module).getContentRoots();
for (VirtualFile contentRoot : contentRoots) {
- if (VfsUtil.isAncestor(contentRoot, file, false)) {
+ if (VfsUtilCore.isAncestor(contentRoot, file, false)) {
final Element clsElement = new Element(rootName);
clsElement.setAttribute(PROJECT_RELATED, PathMacroManager.getInstance(module.getProject()).collapsePath(classesUrl));
element.addContent(clsElement);
diff --git a/plugins/git4idea/git4idea.iml b/plugins/git4idea/git4idea.iml
index 5699777..e361c83 100644
--- a/plugins/git4idea/git4idea.iml
+++ b/plugins/git4idea/git4idea.iml
@@ -38,7 +38,6 @@
<orderEntry type="module" module-name="lang-impl" />
<orderEntry type="module" module-name="git4idea-rt" />
<orderEntry type="module" module-name="images" />
- <orderEntry type="module" module-name="testFramework-java" scope="TEST" />
<orderEntry type="module-library">
<library name="ini4j-0.5.2-patched">
<CLASSES>
diff --git a/plugins/git4idea/src/META-INF/plugin.xml b/plugins/git4idea/src/META-INF/plugin.xml
index e093416..e8b122d 100644
--- a/plugins/git4idea/src/META-INF/plugin.xml
+++ b/plugins/git4idea/src/META-INF/plugin.xml
@@ -81,8 +81,7 @@
<project-components>
<component>
- <interface-class>git4idea.repo.GitRepositoryManager</interface-class>
- <implementation-class>git4idea.repo.GitRepositoryManagerImpl</implementation-class>
+ <implementation-class>git4idea.repo.GitRepositoryManager</implementation-class>
</component>
</project-components>
@@ -160,9 +159,10 @@
serviceImplementation="git4idea.remote.GitRememberedInputs"/>
<applicationService serviceInterface="git4idea.commands.Git"
serviceImplementation="git4idea.commands.GitImpl"/>
-
<applicationService serviceInterface="git4idea.GitPlatformFacade"
serviceImplementation="git4idea.GitPlatformFacadeImpl" />
+ <applicationService serviceInterface="git4idea.DialogManager"
+ serviceImplementation="git4idea.DialogManager" />
<ComponentRoamingType component="Git.Settings" type="DISABLED"/>
<fileTypeFactory implementation="git4idea.vfs.GitFileTypeFactory"/>
diff --git a/plugins/git4idea/src/git4idea/DialogManager.java b/plugins/git4idea/src/git4idea/DialogManager.java
new file mode 100644
index 0000000..5858621
--- /dev/null
+++ b/plugins/git4idea/src/git4idea/DialogManager.java
@@ -0,0 +1,25 @@
+package git4idea;
+
+import com.intellij.openapi.components.ServiceManager;
+import com.intellij.openapi.ui.DialogWrapper;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Use {@link DialogManager#show(DialogWrapper) DialogManager.show(DialogWrapper)} instead of {@link DialogWrapper#show()}
+ * to make the code testable:
+ * in the test environment such calls will be transferred to the TestDialogManager and can be handled by tests;
+ * in the production environment they will be simply delegated to DialogWrapper#show().
+ *
+ * @author Kirill Likhodedov
+ */
+public class DialogManager {
+
+ public static void show(@NotNull DialogWrapper dialog) {
+ ServiceManager.getService(DialogManager.class).showDialog(dialog);
+ }
+
+ protected void showDialog(@NotNull DialogWrapper dialog) {
+ dialog.show();
+ }
+
+}
diff --git a/plugins/git4idea/src/git4idea/GitPlatformFacade.java b/plugins/git4idea/src/git4idea/GitPlatformFacade.java
index 4866483..d808c1b 100644
--- a/plugins/git4idea/src/git4idea/GitPlatformFacade.java
+++ b/plugins/git4idea/src/git4idea/GitPlatformFacade.java
@@ -16,9 +16,10 @@
package git4idea;
import com.intellij.dvcs.DvcsPlatformFacade;
+import com.intellij.dvcs.repo.RepositoryManager;
import com.intellij.openapi.project.Project;
import git4idea.config.GitVcsSettings;
-import git4idea.repo.GitRepositoryManager;
+import git4idea.repo.GitRepository;
import org.jetbrains.annotations.NotNull;
/**
@@ -27,7 +28,7 @@
public interface GitPlatformFacade extends DvcsPlatformFacade {
@NotNull
- GitRepositoryManager getRepositoryManager(@NotNull Project project);
+ <T extends RepositoryManager<GitRepository>> T getRepositoryManager(@NotNull Project project);
@NotNull
GitVcsSettings getSettings(Project project);
diff --git a/plugins/git4idea/src/git4idea/GitUtil.java b/plugins/git4idea/src/git4idea/GitUtil.java
index 0039726..fec8b0b 100644
--- a/plugins/git4idea/src/git4idea/GitUtil.java
+++ b/plugins/git4idea/src/git4idea/GitUtil.java
@@ -685,15 +685,6 @@
return !manager.moreThanOneRoot();
}
- public static List<GitRepository> sortRepositories(@NotNull Collection<GitRepository> repositories) {
- List<GitRepository> repos = new ArrayList<GitRepository>(repositories);
- Collections.sort(repos, new Comparator<GitRepository>() {
- @Override public int compare(GitRepository o1, GitRepository o2) {
- return o1.getPresentableUrl().compareTo(o2.getPresentableUrl());
- }
- });
- return repos;
- }
@Nullable
public static GitRemote findRemoteByName(@NotNull GitRepository repository, @Nullable String name) {
diff --git a/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java b/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java
index 2c087f9..7d868af 100644
--- a/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java
+++ b/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java
@@ -33,6 +33,7 @@
import com.intellij.openapi.vcs.ui.RefreshableOnComponent;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.GuiUtils;
+import com.intellij.ui.NonFocusableCheckBox;
import com.intellij.util.ArrayUtil;
import com.intellij.util.FunctionUtil;
import com.intellij.util.NullableFunction;
@@ -658,7 +659,7 @@
c.insets = insets;
c.weightx = 1;
c.fill = GridBagConstraints.HORIZONTAL;
- myAmend = new JCheckBox(GitBundle.getString("commit.amend"));
+ myAmend = new NonFocusableCheckBox(GitBundle.getString("commit.amend"));
myAmend.setMnemonic('m');
myAmend.setSelected(false);
myAmend.setToolTipText(GitBundle.getString("commit.amend.tooltip"));
diff --git a/plugins/git4idea/src/git4idea/commands/Git.java b/plugins/git4idea/src/git4idea/commands/Git.java
index 67872af..e562108 100644
--- a/plugins/git4idea/src/git4idea/commands/Git.java
+++ b/plugins/git4idea/src/git4idea/commands/Git.java
@@ -94,6 +94,10 @@
@NotNull
GitCommandResult push(@NotNull GitRepository repository, @NotNull String remote, @NotNull String url, @NotNull String spec,
+ boolean updateTracking, @NotNull GitLineHandlerListener... listeners);
+
+ @NotNull
+ GitCommandResult push(@NotNull GitRepository repository, @NotNull String remote, @NotNull String url, @NotNull String spec,
@NotNull GitLineHandlerListener... listeners);
@NotNull
diff --git a/plugins/git4idea/src/git4idea/commands/GitHttpGuiAuthenticator.java b/plugins/git4idea/src/git4idea/commands/GitHttpGuiAuthenticator.java
index 2d63e07..0e6d101 100644
--- a/plugins/git4idea/src/git4idea/commands/GitHttpGuiAuthenticator.java
+++ b/plugins/git4idea/src/git4idea/commands/GitHttpGuiAuthenticator.java
@@ -204,7 +204,7 @@
if (password != null) {
return new AuthData(userName, password);
}
- return null;
+ return trySavedAuthDataFromProviders(url);
}
catch (PasswordSafeException e) {
LOG.info("Couldn't get the password for key [" + key + "]", e);
diff --git a/plugins/git4idea/src/git4idea/commands/GitImpl.java b/plugins/git4idea/src/git4idea/commands/GitImpl.java
index 750ee75..189b4d4 100644
--- a/plugins/git4idea/src/git4idea/commands/GitImpl.java
+++ b/plugins/git4idea/src/git4idea/commands/GitImpl.java
@@ -357,7 +357,7 @@
@Override
@NotNull
public GitCommandResult push(@NotNull GitRepository repository, @NotNull String remote, @NotNull String url, @NotNull String spec,
- @NotNull GitLineHandlerListener... listeners) {
+ boolean updateTracking, @NotNull GitLineHandlerListener... listeners) {
final GitLineHandlerPasswordRequestAware h = new GitLineHandlerPasswordRequestAware(repository.getProject(), repository.getRoot(),
GitCommand.PUSH);
h.setUrl(url);
@@ -366,11 +366,21 @@
h.addProgressParameter();
h.addParameters(remote);
h.addParameters(spec);
+ if (updateTracking) {
+ h.addParameters("--set-upstream");
+ }
return run(h);
}
@Override
@NotNull
+ public GitCommandResult push(@NotNull GitRepository repository, @NotNull String remote, @NotNull String url, @NotNull String spec,
+ @NotNull GitLineHandlerListener... listeners) {
+ return push(repository, remote, url, spec, false, listeners);
+ }
+
+ @Override
+ @NotNull
public GitCommandResult push(@NotNull GitRepository repository, @NotNull GitPushSpec pushSpec, @NotNull String url,
@NotNull GitLineHandlerListener... listeners) {
GitRemote remote = pushSpec.getRemote();
diff --git a/plugins/git4idea/src/git4idea/history/wholeTree/UsersFilterAction.java b/plugins/git4idea/src/git4idea/history/wholeTree/UsersFilterAction.java
index 2471108..0908ce8 100644
--- a/plugins/git4idea/src/git4idea/history/wholeTree/UsersFilterAction.java
+++ b/plugins/git4idea/src/git4idea/history/wholeTree/UsersFilterAction.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -211,7 +211,7 @@
.setTitle("Specify user names, comma separated")
.setMovable(true)
.setRequestFocus(true).setResizable(true);
- mySelectOkAction = new AnAction() {
+ mySelectOkAction = new DumbAwareAction() {
@Override
public void actionPerformed(AnActionEvent e) {
myPopup.closeOk(e.getInputEvent());
diff --git a/plugins/git4idea/src/git4idea/push/GitPushLog.java b/plugins/git4idea/src/git4idea/push/GitPushLog.java
index d8da16b..3bfbec6 100644
--- a/plugins/git4idea/src/git4idea/push/GitPushLog.java
+++ b/plugins/git4idea/src/git4idea/push/GitPushLog.java
@@ -24,6 +24,7 @@
import com.intellij.openapi.ui.Splitter;
import com.intellij.openapi.vcs.VcsDataKeys;
import com.intellij.openapi.vcs.changes.Change;
+import com.intellij.openapi.vcs.changes.issueLinks.IssueLinkHtmlRenderer;
import com.intellij.openapi.vcs.changes.ui.ChangesBrowser;
import com.intellij.ui.*;
import com.intellij.util.ArrayUtil;
@@ -95,7 +96,8 @@
Object userObject = ((DefaultMutableTreeNode)node).getUserObject();
if (userObject instanceof GitCommit) {
GitCommit commit = (GitCommit)userObject;
- return getHashString(commit) + " " + getDateString(commit) + " by " + commit.getAuthorName() + "\n\n" + commit.getFullMessage();
+ return getHashString(commit) + " " + getDateString(commit) + " by " + commit.getAuthorName() + "\n\n" +
+ IssueLinkHtmlRenderer.formatTextWithLinks(myProject, commit.getFullMessage());
}
return "";
}
diff --git a/plugins/git4idea/src/git4idea/push/GitRejectedPushUpdateDialog.java b/plugins/git4idea/src/git4idea/push/GitRejectedPushUpdateDialog.java
index 8bdeb9e..2a00d62 100644
--- a/plugins/git4idea/src/git4idea/push/GitRejectedPushUpdateDialog.java
+++ b/plugins/git4idea/src/git4idea/push/GitRejectedPushUpdateDialog.java
@@ -15,6 +15,7 @@
*/
package git4idea.push;
+import com.intellij.dvcs.repo.RepositoryUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.ui.components.JBLabel;
@@ -128,7 +129,7 @@
if (allBranchesHaveTheSameName(currentBranches)) {
String branchName = currentBranches.values().iterator().next().getName();
StringBuilder sb = new StringBuilder(DESCRIPTION_START + code(branchName) + " was rejected in repositories <br/>");
- for (GitRepository repository : GitUtil.sortRepositories(currentBranches.keySet())) {
+ for (GitRepository repository : RepositoryUtil.sortRepositories(currentBranches.keySet())) {
sb.append(HTML_IDENT).append(code(repository.getPresentableUrl())).append("<br/>");
}
sb.append(DESCRIPTION_ENDING);
diff --git a/plugins/git4idea/src/git4idea/rebase/GitRebaser.java b/plugins/git4idea/src/git4idea/rebase/GitRebaser.java
index aeee09c..c42e5b2 100644
--- a/plugins/git4idea/src/git4idea/rebase/GitRebaser.java
+++ b/plugins/git4idea/src/git4idea/rebase/GitRebaser.java
@@ -28,8 +28,10 @@
import git4idea.GitVcs;
import git4idea.commands.*;
import git4idea.merge.GitConflictResolver;
+import git4idea.update.GitUpdateResult;
import git4idea.util.GitUIUtil;
import git4idea.util.StringScanner;
+import git4idea.util.UntrackedFilesNotifier;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -238,6 +240,54 @@
"You also may <b>abort rebase</b> to restore the original branch and stop rebasing.");
}
+ @NotNull
+ public GitUpdateResult handleRebaseFailure(@NotNull GitLineHandler handler, @NotNull VirtualFile root,
+ @NotNull GitRebaseProblemDetector rebaseConflictDetector,
+ @NotNull GitMessageWithFilesDetector untrackedWouldBeOverwrittenDetector) {
+ if (rebaseConflictDetector.isMergeConflict()) {
+ LOG.info("handleRebaseFailure merge conflict");
+ final boolean allMerged = new GitRebaser.ConflictResolver(myProject, myGit, root, this).merge();
+ return allMerged ? GitUpdateResult.SUCCESS_WITH_RESOLVED_CONFLICTS : GitUpdateResult.INCOMPLETE;
+ } else if (untrackedWouldBeOverwrittenDetector.wasMessageDetected()) {
+ LOG.info("handleRebaseFailure: untracked files would be overwritten by checkout");
+ UntrackedFilesNotifier.notifyUntrackedFilesOverwrittenBy(myProject, ServiceManager.getService(myProject, GitPlatformFacade.class),
+ untrackedWouldBeOverwrittenDetector.getFiles(), "rebase", null);
+ return GitUpdateResult.ERROR;
+ } else {
+ LOG.info("handleRebaseFailure error " + handler.errors());
+ GitUIUtil.notifyImportantError(myProject, "Rebase error", GitUIUtil.stringifyErrors(handler.errors()));
+ return GitUpdateResult.ERROR;
+ }
+ }
+
+ public static class ConflictResolver extends GitConflictResolver {
+ @NotNull private final GitRebaser myRebaser;
+ @NotNull private final VirtualFile myRoot;
+
+ public ConflictResolver(@NotNull Project project, @NotNull Git git, @NotNull VirtualFile root, @NotNull GitRebaser rebaser) {
+ super(project, git, ServiceManager.getService(GitPlatformFacade.class), Collections.singleton(root), makeParams());
+ myRebaser = rebaser;
+ myRoot = root;
+ }
+
+ private static Params makeParams() {
+ Params params = new Params();
+ params.setReverse(true);
+ params.setMergeDescription("Merge conflicts detected. Resolve them before continuing rebase.");
+ params.setErrorNotificationTitle("Can't continue rebase");
+ params.setErrorNotificationAdditionalDescription("Then you may <b>continue rebase</b>. <br/> You also may <b>abort rebase</b> to restore the original branch and stop rebasing.");
+ return params;
+ }
+
+ @Override protected boolean proceedIfNothingToMerge() throws VcsException {
+ return myRebaser.continueRebase(myRoot);
+ }
+
+ @Override protected boolean proceedAfterAllMerged() throws VcsException {
+ return myRebaser.continueRebase(myRoot);
+ }
+ }
+
/**
* The rebase editor that just overrides the list of commits
*/
diff --git a/plugins/git4idea/src/git4idea/repo/GitConfig.java b/plugins/git4idea/src/git4idea/repo/GitConfig.java
index e13411a..0080bf6 100644
--- a/plugins/git4idea/src/git4idea/repo/GitConfig.java
+++ b/plugins/git4idea/src/git4idea/repo/GitConfig.java
@@ -15,28 +15,30 @@
*/
package git4idea.repo;
- import com.google.common.base.Function;
- import com.google.common.base.Predicate;
- import com.google.common.collect.Collections2;
- import com.google.common.collect.Iterables;
import com.intellij.dvcs.repo.RepoStateException;
- import com.intellij.ide.plugins.IdeaPluginDescriptor;
- import com.intellij.openapi.diagnostic.Logger;
- import com.intellij.openapi.util.Pair;
- import com.intellij.openapi.util.text.StringUtil;
- import com.intellij.util.ArrayUtil;
- import git4idea.*;
- import git4idea.branch.GitBranchUtil;
- import org.ini4j.Ini;
- import org.ini4j.Profile;
- import org.jetbrains.annotations.NotNull;
- import org.jetbrains.annotations.Nullable;
+import com.intellij.ide.plugins.IdeaPluginDescriptor;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.util.Condition;
+import com.intellij.openapi.util.Pair;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.util.ArrayUtil;
+import com.intellij.util.Function;
+import com.intellij.util.containers.ContainerUtil;
+import git4idea.GitLocalBranch;
+import git4idea.GitPlatformFacade;
+import git4idea.GitRemoteBranch;
+import git4idea.GitSvnRemoteBranch;
+import git4idea.branch.GitBranchUtil;
+import org.ini4j.Ini;
+import org.ini4j.Profile;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
- import java.io.File;
- import java.io.IOException;
- import java.util.*;
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
+import java.io.File;
+import java.io.IOException;
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/**
* <p>Reads information from the {@code .git/config} file, and parses it to actual objects.</p>
@@ -93,9 +95,9 @@
@NotNull
Collection<GitRemote> parseRemotes() {
// populate GitRemotes with substituting urls when needed
- return Collections2.transform(myRemotes, new Function<Remote, GitRemote>() {
+ return ContainerUtil.map(myRemotes, new Function<Remote, GitRemote>() {
@Override
- public GitRemote apply(@Nullable Remote remote) {
+ public GitRemote fun(@Nullable Remote remote) {
assert remote != null;
return convertRemoteToGitRemote(myUrls, remote);
}
@@ -115,16 +117,15 @@
@NotNull
Collection<GitBranchTrackInfo> parseTrackInfos(@NotNull final Collection<GitLocalBranch> localBranches,
@NotNull final Collection<GitRemoteBranch> remoteBranches) {
- return Collections2.filter(Collections2.transform(myTrackedInfos, new Function<BranchConfig, GitBranchTrackInfo>() {
- @Nullable
+ return ContainerUtil.mapNotNull(myTrackedInfos, new Function<BranchConfig, GitBranchTrackInfo>() {
@Override
- public GitBranchTrackInfo apply(@Nullable BranchConfig input) {
- if (input != null) {
- return convertBranchConfig(input, localBranches, remoteBranches);
+ public GitBranchTrackInfo fun(BranchConfig config) {
+ if (config != null) {
+ return convertBranchConfig(config, localBranches, remoteBranches);
}
return null;
}
- }), GitUtil.NOT_NULL_PREDICATE);
+ });
}
/**
@@ -208,9 +209,9 @@
private static GitLocalBranch findLocalBranch(@NotNull String branchName, @NotNull Collection<GitLocalBranch> localBranches) {
final String name = GitBranchUtil.stripRefsPrefix(branchName);
try {
- return Iterables.find(localBranches, new Predicate<GitLocalBranch>() {
+ return ContainerUtil.find(localBranches, new Condition<GitLocalBranch>() {
@Override
- public boolean apply(@Nullable GitLocalBranch input) {
+ public boolean value(@Nullable GitLocalBranch input) {
assert input != null;
return input.getName().equals(name);
}
diff --git a/plugins/git4idea/src/git4idea/repo/GitRepoInfo.java b/plugins/git4idea/src/git4idea/repo/GitRepoInfo.java
new file mode 100644
index 0000000..5e71115
--- /dev/null
+++ b/plugins/git4idea/src/git4idea/repo/GitRepoInfo.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2000-2013 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 git4idea.repo;
+
+import com.intellij.dvcs.repo.Repository;
+import git4idea.GitLocalBranch;
+import git4idea.GitRemoteBranch;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Collection;
+
+/**
+ * @author Kirill Likhodedov
+ */
+public class GitRepoInfo {
+
+ @Nullable private final GitLocalBranch myCurrentBranch;
+ @Nullable private final String myCurrentRevision;
+ @NotNull private final Repository.State myState;
+ @NotNull private final Collection<GitRemote> myRemotes;
+ @NotNull private final Collection<GitLocalBranch> myLocalBranches;
+ @NotNull private final Collection<GitRemoteBranch> myRemoteBranches;
+ @NotNull private final Collection<GitBranchTrackInfo> myBranchTrackInfos;
+
+ public GitRepoInfo(@Nullable GitLocalBranch currentBranch, @Nullable String currentRevision, @NotNull Repository.State state,
+ @NotNull Collection<GitRemote> remotes, @NotNull Collection<GitLocalBranch> localBranches,
+ @NotNull Collection<GitRemoteBranch> remoteBranches, @NotNull Collection<GitBranchTrackInfo> branchTrackInfos) {
+ myCurrentBranch = currentBranch;
+ myCurrentRevision = currentRevision;
+ myState = state;
+ myRemotes = remotes;
+ myLocalBranches = localBranches;
+ myRemoteBranches = remoteBranches;
+ myBranchTrackInfos = branchTrackInfos;
+ }
+
+ @Nullable
+ public GitLocalBranch getCurrentBranch() {
+ return myCurrentBranch;
+ }
+
+ @NotNull
+ public Collection<GitRemote> getRemotes() {
+ return myRemotes;
+ }
+
+ @NotNull
+ public Collection<GitLocalBranch> getLocalBranches() {
+ return myLocalBranches;
+ }
+
+ @NotNull
+ public Collection<GitRemoteBranch> getRemoteBranches() {
+ return myRemoteBranches;
+ }
+
+ @NotNull
+ public Collection<GitBranchTrackInfo> getBranchTrackInfos() {
+ return myBranchTrackInfos;
+ }
+
+ @Nullable
+ public String getCurrentRevision() {
+ return myCurrentRevision;
+ }
+
+ @NotNull
+ public Repository.State getState() {
+ return myState;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ GitRepoInfo info = (GitRepoInfo)o;
+
+ if (myState != info.myState) return false;
+ if (myCurrentRevision != null ? !myCurrentRevision.equals(info.myCurrentRevision) : info.myCurrentRevision != null) return false;
+ if (myCurrentBranch != null ? !myCurrentBranch.equals(info.myCurrentBranch) : info.myCurrentBranch != null) return false;
+ if (!myRemotes.equals(info.myRemotes)) return false;
+ if (!myBranchTrackInfos.equals(info.myBranchTrackInfos)) return false;
+ if (!myLocalBranches.equals(info.myLocalBranches)) return false;
+ if (!myRemoteBranches.equals(info.myRemoteBranches)) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = myCurrentBranch != null ? myCurrentBranch.hashCode() : 0;
+ result = 31 * result + (myCurrentRevision != null ? myCurrentRevision.hashCode() : 0);
+ result = 31 * result + myState.hashCode();
+ result = 31 * result + myRemotes.hashCode();
+ result = 31 * result + myLocalBranches.hashCode();
+ result = 31 * result + myRemoteBranches.hashCode();
+ result = 31 * result + myBranchTrackInfos.hashCode();
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("GitRepoInfo{current=%s, remotes=%s, localBranches=%s, remoteBranches=%s, trackInfos=%s}",
+ myCurrentBranch, myRemotes, myLocalBranches, myRemoteBranches, myBranchTrackInfos);
+ }
+}
diff --git a/plugins/git4idea/src/git4idea/repo/GitRepository.java b/plugins/git4idea/src/git4idea/repo/GitRepository.java
index 9b7dfa0..7a44b27 100644
--- a/plugins/git4idea/src/git4idea/repo/GitRepository.java
+++ b/plugins/git4idea/src/git4idea/repo/GitRepository.java
@@ -69,6 +69,9 @@
GitUntrackedFilesHolder getUntrackedFilesHolder();
+ @NotNull
+ GitRepoInfo getInfo();
+
/**
* Returns the current branch of this Git repository.
* If the repository is being rebased, then the current branch is the branch being rebased (which was current before the rebase
diff --git a/plugins/git4idea/src/git4idea/repo/GitRepositoryImpl.java b/plugins/git4idea/src/git4idea/repo/GitRepositoryImpl.java
index 3d5a59f..3fcec17 100644
--- a/plugins/git4idea/src/git4idea/repo/GitRepositoryImpl.java
+++ b/plugins/git4idea/src/git4idea/repo/GitRepositoryImpl.java
@@ -30,7 +30,6 @@
import java.io.File;
import java.util.Collection;
-import java.util.Collections;
/**
* @author Kirill Likhodedov
@@ -42,10 +41,7 @@
@NotNull private final VirtualFile myGitDir;
@Nullable private final GitUntrackedFilesHolder myUntrackedFilesHolder;
- @Nullable private volatile GitLocalBranch myCurrentBranch;
- @NotNull private volatile GitBranchesCollection myBranches = GitBranchesCollection.EMPTY;
- @NotNull private volatile Collection<GitRemote> myRemotes = Collections.emptyList();
- @NotNull private volatile Collection<GitBranchTrackInfo> myBranchTrackInfos;
+ @NotNull private volatile GitRepoInfo myInfo;
/**
* Get the GitRepository instance from the {@link GitRepositoryManager}.
@@ -116,9 +112,27 @@
}
@Override
+ @NotNull
+ public GitRepoInfo getInfo() {
+ return myInfo;
+ }
+
+ @Override
@Nullable
public GitLocalBranch getCurrentBranch() {
- return myCurrentBranch;
+ return myInfo.getCurrentBranch();
+ }
+
+ @Nullable
+ @Override
+ public String getCurrentRevision() {
+ return myInfo.getCurrentRevision();
+ }
+
+ @NotNull
+ @Override
+ public State getState() {
+ return myInfo.getState();
}
/**
@@ -127,19 +141,20 @@
@Override
@NotNull
public GitBranchesCollection getBranches() {
- return new GitBranchesCollection(myBranches);
+ GitRepoInfo info = myInfo;
+ return new GitBranchesCollection(info.getLocalBranches(), info.getRemoteBranches());
}
@Override
@NotNull
public Collection<GitRemote> getRemotes() {
- return myRemotes;
+ return myInfo.getRemotes();
}
@Override
@NotNull
public Collection<GitBranchTrackInfo> getBranchTrackInfos() {
- return myBranchTrackInfos;
+ return myInfo.getBranchTrackInfos();
}
@Override
@@ -159,30 +174,58 @@
@Override
public void update() {
- File configFile = new File(VfsUtilCore.virtualToIoFile(myGitDir), "config");
- GitConfig config = GitConfig.read(myPlatformFacade, configFile);
- myRemotes = config.parseRemotes();
- readRepository(myRemotes);
- myBranchTrackInfos = config.parseTrackInfos(myBranches.getLocalBranches(), myBranches.getRemoteBranches());
- notifyListeners();
+ myInfo = readRepoInfo(this, myPlatformFacade, myReader, myInfo);
}
- private void readRepository(@NotNull Collection<GitRemote> remotes) {
- myState = myReader.readState();
- myCurrentRevision = myReader.readCurrentRevision();
- myCurrentBranch = myReader.readCurrentBranch();
- myBranches = myReader.readBranches(remotes);
+ @NotNull
+ private static GitRepoInfo readRepoInfo(@NotNull GitRepository repository, @NotNull GitPlatformFacade platformFacade,
+ @NotNull GitRepositoryReader reader, @Nullable GitRepoInfo previousInfo) {
+ File configFile = new File(VfsUtilCore.virtualToIoFile(repository.getGitDir()), "config");
+ GitConfig config = GitConfig.read(platformFacade, configFile);
+ Collection<GitRemote> remotes = config.parseRemotes();
+ TempState tempState = readRepository(reader, remotes);
+ Collection<GitBranchTrackInfo> trackInfos = config.parseTrackInfos(tempState.myBranches.getLocalBranches(),
+ tempState.myBranches.getRemoteBranches());
+ GitRepoInfo info = new GitRepoInfo(tempState.myCurrentBranch, tempState.myCurrentRevision, tempState.myState,
+ remotes, tempState.myBranches.getLocalBranches(),
+ tempState.myBranches.getRemoteBranches(), trackInfos);
+ notifyListeners(repository, previousInfo, info);
+ return info;
}
- protected void notifyListeners() {
- if (!Disposer.isDisposed(getProject())) {
- getProject().getMessageBus().syncPublisher(GIT_REPO_CHANGE).repositoryChanged(this);
+ private static TempState readRepository(GitRepositoryReader reader, @NotNull Collection<GitRemote> remotes) {
+ return new TempState(reader.readState(), reader.readCurrentRevision(), reader.readCurrentBranch(), reader.readBranches(remotes));
+ }
+
+ // previous info can be null before the first update
+ private static void notifyListeners(@NotNull GitRepository repository, @Nullable GitRepoInfo previousInfo, @NotNull GitRepoInfo info) {
+ if (Disposer.isDisposed(repository.getProject())) {
+ return;
+ }
+ if (!info.equals(previousInfo)) {
+ repository.getProject().getMessageBus().syncPublisher(GIT_REPO_CHANGE).repositoryChanged(repository);
}
}
+ @NotNull
@Override
public String toLogString() {
- return String.format("GitRepository{myCurrentBranch=%s, myCurrentRevision='%s', myState=%s, myRootDir=%s}",
- myCurrentBranch, myCurrentRevision, myState, getRoot());
+ return String.format("GitRepository " + getRoot() + " : " + myInfo);
}
+
+ private static class TempState {
+ private final State myState;
+ private final String myCurrentRevision;
+ private final GitLocalBranch myCurrentBranch;
+ private final GitBranchesCollection myBranches;
+
+ public TempState(@NotNull State state, @Nullable String currentRevision, @Nullable GitLocalBranch currentBranch,
+ @NotNull GitBranchesCollection branches) {
+ myState = state;
+ myCurrentRevision = currentRevision;
+ myCurrentBranch = currentBranch;
+ myBranches = branches;
+ }
+ }
+
}
diff --git a/plugins/git4idea/src/git4idea/repo/GitRepositoryManager.java b/plugins/git4idea/src/git4idea/repo/GitRepositoryManager.java
index 5ef34fa..298a7d5 100644
--- a/plugins/git4idea/src/git4idea/repo/GitRepositoryManager.java
+++ b/plugins/git4idea/src/git4idea/repo/GitRepositoryManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2012 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.
@@ -15,53 +15,41 @@
*/
package git4idea.repo;
-import com.intellij.openapi.vcs.FilePath;
+import com.intellij.dvcs.repo.AbstractRepositoryManager;
+import com.intellij.dvcs.repo.RepositoryManager;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.vcs.ProjectLevelVcsManager;
import com.intellij.openapi.vfs.VirtualFile;
+import git4idea.GitPlatformFacade;
+import git4idea.GitUtil;
+import git4idea.roots.GitRootScanner;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.List;
/**
- * GitRepositoryManager initializes and stores {@link GitRepository GitRepositories} for Git roots defined in the project.
* @author Kirill Likhodedov
*/
-public interface GitRepositoryManager {
+public class GitRepositoryManager extends AbstractRepositoryManager<GitRepository> implements RepositoryManager<GitRepository> {
- /**
- * Returns the {@link GitRepository} which tracks the Git repository located in the given directory,
- * or {@code null} if the given file is not a Git root known to this {@link com.intellij.openapi.project.Project}.
- */
- @Nullable
- GitRepository getRepositoryForRoot(@Nullable VirtualFile root);
+ @NotNull private final GitPlatformFacade myPlatformFacade;
- /**
- * Returns the {@link GitRepository} which the given file belongs to, or {@code null} if the file is not under any Git repository.
- */
- @Nullable
- GitRepository getRepositoryForFile(@NotNull VirtualFile file);
+ public GitRepositoryManager(@NotNull Project project, @NotNull GitPlatformFacade platformFacade,
+ @NotNull ProjectLevelVcsManager vcsManager) {
+ super(project, vcsManager, platformFacade.getVcs(project), GitUtil.DOT_GIT);
+ myPlatformFacade = platformFacade;
+ }
- /**
- * Returns the {@link GitRepository} which the given file belongs to, or {@code null} if the file is not under any Git repository.
- */
- @Nullable
- GitRepository getRepositoryForFile(@NotNull FilePath file);
+ @Override
+ public void initComponent() {
+ super.initComponent();
+ if (!ApplicationManager.getApplication().isUnitTestMode()) {
+ GitRootScanner.start(myProject);
+ }
+ }
- /**
- * @return all repositories tracked by the manager.
- */
@NotNull
- List<GitRepository> getRepositories();
-
- boolean moreThanOneRoot();
-
- /**
- * Synchronously updates the specified information about Git repository under the given root.
- * @param root root directory of the Git repository.
- *
- */
- void updateRepository(VirtualFile root);
-
- void updateAllRepositories();
-
+ @Override
+ protected GitRepository createRepository(@NotNull VirtualFile root) {
+ return GitRepositoryImpl.getFullInstance(root, myProject, myPlatformFacade, this);
+ }
}
diff --git a/plugins/git4idea/src/git4idea/repo/GitRepositoryManagerImpl.java b/plugins/git4idea/src/git4idea/repo/GitRepositoryManagerImpl.java
deleted file mode 100644
index fd91339..0000000
--- a/plugins/git4idea/src/git4idea/repo/GitRepositoryManagerImpl.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * Copyright 2000-2012 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 git4idea.repo;
-
-import com.intellij.dvcs.repo.RepoStateException;
-import com.intellij.openapi.Disposable;
-import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.components.AbstractProjectComponent;
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Disposer;
-import com.intellij.openapi.vcs.*;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.util.ArrayUtil;
-import git4idea.GitPlatformFacade;
-import git4idea.GitUtil;
-import git4idea.roots.GitRootScanner;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-/**
- * @author Kirill Likhodedov
- */
-public class GitRepositoryManagerImpl extends AbstractProjectComponent implements Disposable, GitRepositoryManager, VcsListener {
-
- private static final Logger LOG = Logger.getInstance(GitRepositoryManager.class);
-
- @NotNull private final ProjectLevelVcsManager myVcsManager;
- @NotNull private AbstractVcs myVcs;
-
- @NotNull private final Map<VirtualFile, GitRepository> myRepositories = new HashMap<VirtualFile, GitRepository>();
-
- @NotNull private final ReentrantReadWriteLock REPO_LOCK = new ReentrantReadWriteLock();
- @NotNull private final GitPlatformFacade myPlatformFacade;
-
- public GitRepositoryManagerImpl(@NotNull Project project, @NotNull GitPlatformFacade platformFacade,
- @NotNull ProjectLevelVcsManager vcsManager) {
- super(project);
- myPlatformFacade = platformFacade;
- myVcsManager = vcsManager;
- }
-
- @Override
- public void initComponent() {
- myVcs = myPlatformFacade.getVcs(myProject);
- Disposer.register(myProject, this);
- myProject.getMessageBus().connect().subscribe(ProjectLevelVcsManager.VCS_CONFIGURATION_CHANGED, this);
- if (!ApplicationManager.getApplication().isUnitTestMode()) {
- GitRootScanner.start(myProject);
- }
- }
-
- @Override
- public void dispose() {
- try {
- REPO_LOCK.writeLock().lock();
- myRepositories.clear();
- }
- finally {
- REPO_LOCK.writeLock().unlock();
- }
- }
-
- @Override
- public void directoryMappingChanged() {
- updateRepositoriesCollection();
- }
-
- @Override
- @Nullable
- public GitRepository getRepositoryForRoot(@Nullable VirtualFile root) {
- if (root == null) {
- return null;
- }
- try {
- REPO_LOCK.readLock().lock();
- return myRepositories.get(root);
- }
- finally {
- REPO_LOCK.readLock().unlock();
- }
- }
-
- @Override
- @Nullable
- public GitRepository getRepositoryForFile(@NotNull VirtualFile file) {
- final VcsRoot vcsRoot = myVcsManager.getVcsRootObjectFor(file);
- return getRepositoryForVcsRoot(vcsRoot, file.getPath());
- }
-
- @Override
- public GitRepository getRepositoryForFile(@NotNull FilePath file) {
- final VcsRoot vcsRoot = myVcsManager.getVcsRootObjectFor(file);
- return getRepositoryForVcsRoot(vcsRoot, file.getPath());
- }
-
- @Nullable
- private GitRepository getRepositoryForVcsRoot(VcsRoot vcsRoot, String filePath) {
- if (vcsRoot == null) {
- return null;
- }
- final AbstractVcs vcs = vcsRoot.getVcs();
- if (!myVcs.equals(vcs)) {
- if (vcs != null) {
- LOG.debug(String.format("getRepositoryForFile returned non-Git (%s) root for file %s", vcs.getDisplayName(), filePath));
- }
- return null;
- }
- return getRepositoryForRoot(vcsRoot.getPath());
- }
-
- @Override
- @NotNull
- public List<GitRepository> getRepositories() {
- try {
- REPO_LOCK.readLock().lock();
- return GitUtil.sortRepositories(myRepositories.values());
- }
- finally {
- REPO_LOCK.readLock().unlock();
- }
- }
-
- @Override
- public boolean moreThanOneRoot() {
- return myRepositories.size() > 1;
- }
-
- @Override
- public void updateRepository(VirtualFile root) {
- GitRepository repo = getRepositoryForRoot(root);
- if (repo != null) {
- repo.update();
- }
- }
-
- @Override
- public void updateAllRepositories() {
- Map<VirtualFile, GitRepository> repositories;
- try {
- REPO_LOCK.readLock().lock();
- repositories = new HashMap<VirtualFile, GitRepository>(myRepositories);
- }
- finally {
- REPO_LOCK.readLock().unlock();
- }
-
- for (VirtualFile root : repositories.keySet()) {
- updateRepository(root);
- }
- }
-
- // note: we are not calling this method during the project startup - it is called anyway by the GitRootTracker
- private void updateRepositoriesCollection() {
- Map<VirtualFile, GitRepository> repositories;
- try {
- REPO_LOCK.readLock().lock();
- repositories = new HashMap<VirtualFile, GitRepository>(myRepositories);
- }
- finally {
- REPO_LOCK.readLock().unlock();
- }
-
- final VirtualFile[] roots = myVcsManager.getRootsUnderVcs(myVcs);
- // remove repositories that are not in the roots anymore
- for (Iterator<Map.Entry<VirtualFile, GitRepository>> iterator = repositories.entrySet().iterator(); iterator.hasNext(); ) {
- if (!ArrayUtil.contains(iterator.next().getValue().getRoot(), roots)) {
- iterator.remove();
- }
- }
- // add GitRepositories for all roots that don't have correspondent GitRepositories yet.
- for (VirtualFile root : roots) {
- if (!repositories.containsKey(root)) {
- if (gitRootOK(root)) {
- try {
- GitRepository repository = createGitRepository(root);
- repositories.put(root, repository);
- }
- catch (RepoStateException e) {
- LOG.error("Couldn't initialize GitRepository in " + root.getPresentableUrl(), e);
- }
- }
- else {
- LOG.info("Invalid Git root: " + root);
- }
- }
- }
-
- REPO_LOCK.writeLock().lock();
- try {
- myRepositories.clear();
- myRepositories.putAll(repositories);
- }
- finally {
- REPO_LOCK.writeLock().unlock();
- }
- }
-
- private static boolean gitRootOK(@NotNull VirtualFile root) {
- VirtualFile gitDir = root.findChild(GitUtil.DOT_GIT);
- return gitDir != null && gitDir.exists();
- }
-
- private GitRepository createGitRepository(VirtualFile root) {
- return GitRepositoryImpl.getFullInstance(root, myProject, myPlatformFacade, this);
- }
-
- @Override
- public String toString() {
- return "GitRepositoryManager{myRepositories: " + myRepositories + '}';
- }
-
-}
diff --git a/plugins/git4idea/src/git4idea/update/GitRebaseUpdater.java b/plugins/git4idea/src/git4idea/update/GitRebaseUpdater.java
index 467a604..c2f503d 100644
--- a/plugins/git4idea/src/git4idea/update/GitRebaseUpdater.java
+++ b/plugins/git4idea/src/git4idea/update/GitRebaseUpdater.java
@@ -15,7 +15,6 @@
*/
package git4idea.update;
-import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.project.Project;
@@ -25,17 +24,13 @@
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.ui.UIUtil;
import git4idea.GitBranch;
-import git4idea.GitPlatformFacade;
import git4idea.GitUtil;
import git4idea.Notificator;
import git4idea.branch.GitBranchPair;
import git4idea.commands.*;
-import git4idea.merge.GitConflictResolver;
import git4idea.rebase.GitRebaseProblemDetector;
import git4idea.rebase.GitRebaser;
import git4idea.repo.GitRepository;
-import git4idea.util.GitUIUtil;
-import git4idea.util.UntrackedFilesNotifier;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
@@ -98,7 +93,7 @@
});
if (failure.get()) {
- updateResult.set(handleRebaseFailure(rebaseHandler, rebaseConflictDetector, untrackedFilesDetector));
+ updateResult.set(myRebaser.handleRebaseFailure(rebaseHandler, myRoot, rebaseConflictDetector, untrackedFilesDetector));
}
return updateResult.get();
}
@@ -112,25 +107,6 @@
return dest.getName();
}
- private GitUpdateResult handleRebaseFailure(GitLineHandler pullHandler,
- GitRebaseProblemDetector rebaseConflictDetector,
- final GitMessageWithFilesDetector untrackedWouldBeOverwrittenDetector) {
- if (rebaseConflictDetector.isMergeConflict()) {
- LOG.info("handleRebaseFailure merge conflict");
- final boolean allMerged = new MyConflictResolver(myProject, myGit, myRoot, myRebaser).merge();
- return allMerged ? GitUpdateResult.SUCCESS_WITH_RESOLVED_CONFLICTS : GitUpdateResult.INCOMPLETE;
- } else if (untrackedWouldBeOverwrittenDetector.wasMessageDetected()) {
- LOG.info("handleRebaseFailure: untracked files would be overwritten by checkout");
- UntrackedFilesNotifier.notifyUntrackedFilesOverwrittenBy(myProject, ServiceManager.getService(myProject, GitPlatformFacade.class),
- untrackedWouldBeOverwrittenDetector.getFiles(), "rebase", null);
- return GitUpdateResult.ERROR;
- } else {
- LOG.info("handleRebaseFailure error " + pullHandler.errors());
- GitUIUtil.notifyImportantError(myProject, "Rebase error", GitUIUtil.stringifyErrors(pullHandler.errors()));
- return GitUpdateResult.ERROR;
- }
- }
-
// TODO
//if (!checkLocallyModified(myRoot)) {
// cancel();
@@ -208,31 +184,4 @@
return result.success();
}
- private static class MyConflictResolver extends GitConflictResolver {
- private final GitRebaser myRebaser;
- private final VirtualFile myRoot;
-
- public MyConflictResolver(Project project, @NotNull Git git, VirtualFile root, GitRebaser rebaser) {
- super(project, git, ServiceManager.getService(GitPlatformFacade.class), Collections.singleton(root), makeParams());
- myRebaser = rebaser;
- myRoot = root;
- }
-
- private static Params makeParams() {
- Params params = new Params();
- params.setReverse(true);
- params.setMergeDescription("Merge conflicts detected. Resolve them before continuing rebase.");
- params.setErrorNotificationTitle("Can't continue rebase");
- params.setErrorNotificationAdditionalDescription("Then you may <b>continue rebase</b>. <br/> You also may <b>abort rebase</b> to restore the original branch and stop rebasing.");
- return params;
- }
-
- @Override protected boolean proceedIfNothingToMerge() throws VcsException {
- return myRebaser.continueRebase(myRoot);
- }
-
- @Override protected boolean proceedAfterAllMerged() throws VcsException {
- return myRebaser.continueRebase(myRoot);
- }
- }
}
diff --git a/plugins/git4idea/test-stepdefs/git4idea/GitCucumberWorld.java b/plugins/git4idea/test-stepdefs/git4idea/GitCucumberWorld.java
index a830ef0..f100ba5 100644
--- a/plugins/git4idea/test-stepdefs/git4idea/GitCucumberWorld.java
+++ b/plugins/git4idea/test-stepdefs/git4idea/GitCucumberWorld.java
@@ -13,11 +13,10 @@
import com.intellij.openapi.vcs.changes.ChangeListManagerImpl;
import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager;
import com.intellij.openapi.vcs.impl.ProjectLevelVcsManagerImpl;
-import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.testFramework.PlatformTestCase;
import com.intellij.testFramework.fixtures.IdeaProjectTestFixture;
import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory;
-import com.intellij.util.PlatformUtils;
import com.intellij.util.ThrowableRunnable;
import com.intellij.util.ui.UIUtil;
import cucumber.annotation.After;
@@ -29,15 +28,12 @@
import git4idea.remote.GitHttpAuthTestService;
import git4idea.repo.GitRepository;
import git4idea.test.GitExecutor;
-import git4idea.test.GitTestInitUtil;
+import git4idea.test.GitTestUtil;
import git4idea.test.TestNotificator;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.ide.BuiltInServerManager;
-import org.jetbrains.ide.BuiltInServerManagerImpl;
import org.junit.Assert;
import org.picocontainer.MutablePicoContainer;
-import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
@@ -51,7 +47,6 @@
import static com.intellij.dvcs.test.Executor.cd;
import static com.intellij.dvcs.test.Executor.mkdir;
-import static junit.framework.Assert.assertNotNull;
import static org.junit.Assume.assumeTrue;
/**
@@ -88,7 +83,7 @@
@Before
@Order(0)
public void setUp() throws Throwable {
- System.setProperty(PlatformUtils.PLATFORM_PREFIX_KEY, "PlatformLangXml");
+ PlatformTestCase.initPlatformLangPrefix();
IdeaTestApplication.getInstance(null);
String tempFileName = getClass().getName() + "-" + new Random().nextInt();
@@ -126,7 +121,7 @@
myAsyncTasks = new ArrayList<Future>();
cd(myProjectRoot);
- myRepository = createRepo(myProjectRoot);
+ myRepository = GitTestUtil.createRepository(myProject, myProjectRoot);
ProjectLevelVcsManagerImpl vcsManager = (ProjectLevelVcsManagerImpl)ProjectLevelVcsManager.getInstance(myProject);
AbstractVcs vcs = vcsManager.findVcsByName("Git");
@@ -139,23 +134,10 @@
assumeTrue(myVcs.getVersion().isSupported());
}
- @NotNull
- private static GitRepository createRepo(String root) {
- GitTestInitUtil.initRepo(root);
- ProjectLevelVcsManagerImpl vcsManager = (ProjectLevelVcsManagerImpl)ProjectLevelVcsManager.getInstance(myProject);
- vcsManager.setDirectoryMapping(root, GitVcs.NAME);
- VirtualFile file = LocalFileSystem.getInstance().findFileByIoFile(new File(root));
- GitRepository repository = myPlatformFacade.getRepositoryManager(myProject).getRepositoryForRoot(file);
- assertNotNull("Couldn't find repository for root " + root, repository);
- return repository;
- }
-
@Before("@remote")
@Order(1)
public void setUpRemoteOperations() {
- ((BuiltInServerManagerImpl)BuiltInServerManager.getInstance()).setEnabledInUnitTestMode(true);
- // default port will be occupied by main idea instance => define the custom default to avoid searching of free port
- System.setProperty(BuiltInServerManagerImpl.PROPERTY_RPC_PORT, "64463");
+ GitTestUtil.setDefaultBuiltInServerPort();
myHttpAuthService = (GitHttpAuthTestService)ServiceManager.getService(GitHttpAuthService.class);
}
@@ -164,13 +146,12 @@
public void setUpStandardMultipleRootsConfig() {
cd(myProjectRoot);
String community = mkdir("community");
- createRepo(community);
+ GitTestUtil.createRepository(myProject, community);
}
@After("@remote")
@Order(1)
public void tearDownRemoteOperations() {
- ((BuiltInServerManagerImpl)BuiltInServerManager.getInstance()).setEnabledInUnitTestMode(false);
}
@After
diff --git a/plugins/git4idea/test-stepdefs/git4idea/GitRemoteSteps.java b/plugins/git4idea/test-stepdefs/git4idea/GitRemoteSteps.java
index 1958dac..655fffa 100644
--- a/plugins/git4idea/test-stepdefs/git4idea/GitRemoteSteps.java
+++ b/plugins/git4idea/test-stepdefs/git4idea/GitRemoteSteps.java
@@ -105,8 +105,8 @@
@NotNull
@Override
public String askPassword(@NotNull String url) {
- myPasswordAskedWaiter.countDown();
myPasswordAsked = true;
+ myPasswordAskedWaiter.countDown();
try {
assertTrue("Password was not supplied during the reasonable period of time",
myPasswordSuppliedWaiter.await(TIMEOUT, TimeUnit.SECONDS));
@@ -120,8 +120,8 @@
@NotNull
@Override
public String askUsername(@NotNull String url) {
- myUsernameAskedWaiter.countDown();
myUsernameAsked = true;
+ myUsernameAskedWaiter.countDown();
try {
assertTrue("Password was not supplied during the reasonable period of time",
myUsernameSuppliedWaiter.await(TIMEOUT, TimeUnit.SECONDS));
@@ -134,13 +134,13 @@
void supplyPassword(@NotNull String password) {
- myPasswordSuppliedWaiter.countDown();
myPassword = password;
+ myPasswordSuppliedWaiter.countDown();
}
void supplyUsername(@NotNull String username) {
- myUsernameSuppliedWaiter.countDown();
myUsername = username;
+ myUsernameSuppliedWaiter.countDown();
}
void waitUntilPasswordIsAsked() throws InterruptedException {
diff --git a/plugins/git4idea/testFramework/META-INF/plugin.xml b/plugins/git4idea/testFramework/META-INF/plugin.xml
index 90ca437..6ecf517 100644
--- a/plugins/git4idea/testFramework/META-INF/plugin.xml
+++ b/plugins/git4idea/testFramework/META-INF/plugin.xml
@@ -10,6 +10,9 @@
<applicationService serviceInterface="git4idea.commands.GitHttpAuthService"
serviceImplementation="git4idea.remote.GitHttpAuthTestService"
overrides="true" />
+ <applicationService serviceInterface="git4idea.DialogManager"
+ serviceImplementation="git4idea.test.TestDialogManager"
+ overrides="true" />
<projectService serviceInterface="git4idea.Notificator"
serviceImplementation="git4idea.test.TestNotificator"
diff --git a/plugins/git4idea/testFramework/git4idea/test/GitLightTest.groovy b/plugins/git4idea/testFramework/git4idea/test/GitLightTest.groovy
index d2cf788..20c9a84 100644
--- a/plugins/git4idea/testFramework/git4idea/test/GitLightTest.groovy
+++ b/plugins/git4idea/testFramework/git4idea/test/GitLightTest.groovy
@@ -16,11 +16,14 @@
package git4idea.test
import com.intellij.dvcs.test.MockProject
+import com.intellij.dvcs.test.MockVirtualFile
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.util.io.FileUtil
import git4idea.GitPlatformFacade
import git4idea.commands.Git
import git4idea.repo.GitRepository
+import git4idea.repo.GitRepositoryImpl
+import org.jetbrains.annotations.NotNull
import org.junit.After
import org.junit.Before
/**
@@ -67,7 +70,22 @@
}
public GitRepository createRepository(String rootDir) {
- return GitTestInitUtil.createRepository(rootDir, myPlatformFacade, myProject)
+ GitTestUtil.initRepo(rootDir);
+
+ // TODO this smells hacky
+ // the constructor and notifyListeners() should probably be private
+ // getPresentableUrl should probably be final, and we should have a better VirtualFile implementation for tests.
+ GitRepository repository = new GitRepositoryImpl(new MockVirtualFile(rootDir), myPlatformFacade, myProject, myProject, true) {
+ @NotNull
+ @Override
+ public String getPresentableUrl() {
+ return rootDir;
+ }
+
+ };
+
+ ((GitTestRepositoryManager)myPlatformFacade.getRepositoryManager(myProject)).add(repository);
+ return repository;
}
/**
diff --git a/plugins/git4idea/testFramework/git4idea/test/GitTestImpl.java b/plugins/git4idea/testFramework/git4idea/test/GitTestImpl.java
index 0f0b147..3e1aa8b 100644
--- a/plugins/git4idea/testFramework/git4idea/test/GitTestImpl.java
+++ b/plugins/git4idea/testFramework/git4idea/test/GitTestImpl.java
@@ -191,6 +191,13 @@
@NotNull
@Override
public GitCommandResult push(@NotNull GitRepository repository, @NotNull String remote, @NotNull String url, @NotNull String spec,
+ boolean updateTracking, @NotNull GitLineHandlerListener... listeners) {
+ throw new UnsupportedOperationException();
+ }
+
+ @NotNull
+ @Override
+ public GitCommandResult push(@NotNull GitRepository repository, @NotNull String remote, @NotNull String url, @NotNull String spec,
@NotNull GitLineHandlerListener... listeners) {
throw new UnsupportedOperationException();
}
diff --git a/plugins/git4idea/testFramework/git4idea/test/GitTestInitUtil.groovy b/plugins/git4idea/testFramework/git4idea/test/GitTestInitUtil.groovy
deleted file mode 100644
index fbcdacf..0000000
--- a/plugins/git4idea/testFramework/git4idea/test/GitTestInitUtil.groovy
+++ /dev/null
@@ -1,67 +0,0 @@
-package git4idea.test
-
-import com.intellij.dvcs.test.MockVirtualFile
-import com.intellij.openapi.project.Project
-import git4idea.GitPlatformFacade
-import git4idea.repo.GitRepository
-import git4idea.repo.GitRepositoryImpl
-import org.jetbrains.annotations.NotNull
-
-import static com.intellij.dvcs.test.Executor.cd
-import static com.intellij.dvcs.test.Executor.touch
-import static git4idea.test.GitExecutor.git
-
-/**
- *
- * @author Kirill Likhodedov
- */
-class GitTestInitUtil {
-
- private static final String USER_NAME = "John Doe";
- private static final String USER_EMAIL = "John.Doe@example.com";
-
- /**
- * Init, set up username and make initial commit.
- * @param repoRoot
- */
- public static void initRepo(String repoRoot) {
- cd repoRoot
- git("init")
- setupUsername();
- touch("initial.txt")
- git("add initial.txt")
- git("commit -m initial")
- }
-
- public static void setupUsername() {
- git("config user.name $USER_NAME")
- git("config user.email $USER_EMAIL")
- }
-
- public static GitRepository createRepository(String rootDir, GitPlatformFacade platformFacade, Project project) {
- GitTestInitUtil.initRepo(rootDir)
-
- // TODO this smells hacky
- // the constructor and notifyListeners() should probably be private
- // getPresentableUrl should probably be final, and we should have a better VirtualFile implementation for tests.
- GitRepository repository = new GitRepositoryImpl(new MockVirtualFile(rootDir), platformFacade, project, project, true) {
- @Override
- protected void notifyListeners() {
- }
-
- @NotNull
- @Override
- String getPresentableUrl() {
- return rootDir;
- }
- }
-
- registerRepository(repository, platformFacade, project)
-
- return repository
- }
-
- private static void registerRepository(GitRepository repository, GitPlatformFacade platformFacade, Project project) {
- ((GitTestRepositoryManager)platformFacade.getRepositoryManager(project)).add(repository)
- }
-}
diff --git a/plugins/git4idea/testFramework/git4idea/test/GitTestPlatformFacade.groovy b/plugins/git4idea/testFramework/git4idea/test/GitTestPlatformFacade.groovy
index d22c949..07f4a33 100644
--- a/plugins/git4idea/testFramework/git4idea/test/GitTestPlatformFacade.groovy
+++ b/plugins/git4idea/testFramework/git4idea/test/GitTestPlatformFacade.groovy
@@ -24,9 +24,7 @@
import git4idea.Notificator
import git4idea.config.GitVcsApplicationSettings
import git4idea.config.GitVcsSettings
-import git4idea.repo.GitRepositoryManager
import org.jetbrains.annotations.NotNull
-
/**
*
* @author Kirill Likhodedov
@@ -85,7 +83,7 @@
@NotNull
@Override
- public GitRepositoryManager getRepositoryManager(@NotNull Project project) {
+ public GitTestRepositoryManager getRepositoryManager(@NotNull Project project) {
return myRepositoryManager;
}
diff --git a/plugins/git4idea/testFramework/git4idea/test/GitTestRepositoryManager.groovy b/plugins/git4idea/testFramework/git4idea/test/GitTestRepositoryManager.groovy
index 6bb237d..4d6d89e 100644
--- a/plugins/git4idea/testFramework/git4idea/test/GitTestRepositoryManager.groovy
+++ b/plugins/git4idea/testFramework/git4idea/test/GitTestRepositoryManager.groovy
@@ -14,16 +14,17 @@
* limitations under the License.
*/
package git4idea.test
+
+import com.intellij.dvcs.repo.RepositoryManager
import com.intellij.openapi.vcs.FilePath
import com.intellij.openapi.vfs.VirtualFile
import git4idea.repo.GitRepository
-import git4idea.repo.GitRepositoryManager
import org.jetbrains.annotations.NotNull
import org.jetbrains.annotations.Nullable
/**
* @author Kirill Likhodedov
*/
-public class GitTestRepositoryManager implements GitRepositoryManager {
+public class GitTestRepositoryManager implements RepositoryManager<GitRepository> {
private final List<GitRepository> myRepositories = new ArrayList<GitRepository>();
diff --git a/plugins/git4idea/testFramework/git4idea/test/GitTestUtil.java b/plugins/git4idea/testFramework/git4idea/test/GitTestUtil.java
index 6ed246e..74eec53 100644
--- a/plugins/git4idea/testFramework/git4idea/test/GitTestUtil.java
+++ b/plugins/git4idea/testFramework/git4idea/test/GitTestUtil.java
@@ -15,20 +15,42 @@
*/
package git4idea.test;
+import com.intellij.notification.Notification;
+import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.vcs.ProjectLevelVcsManager;
+import com.intellij.openapi.vcs.impl.ProjectLevelVcsManagerImpl;
+import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
+import git4idea.GitUtil;
+import git4idea.GitVcs;
+import git4idea.Notificator;
+import git4idea.repo.GitRepository;
+import junit.framework.Assert;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.ide.BuiltInServerManagerImpl;
+import java.io.File;
import java.util.HashMap;
import java.util.Map;
+import static com.intellij.dvcs.test.Executor.cd;
+import static com.intellij.dvcs.test.Executor.touch;
import static com.intellij.dvcs.test.TestRepositoryUtil.createDir;
import static com.intellij.dvcs.test.TestRepositoryUtil.createFile;
+import static git4idea.test.GitExecutor.git;
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertNull;
/**
* @author Kirill Likhodedov
*/
public class GitTestUtil {
+ private static final String USER_NAME = "John Doe";
+ private static final String USER_EMAIL = "John.Doe@example.com";
+
/**
* <p>Creates file structure for given paths. Path element should be a relative (from project root)
* path to a file or a directory. All intermediate paths will be created if needed.
@@ -58,4 +80,58 @@
return result;
}
+ /**
+ * Init, set up username and make initial commit.
+ *
+ * @param repoRoot
+ */
+ public static void initRepo(@NotNull String repoRoot) {
+ cd(repoRoot);
+ git("init");
+ setupUsername();
+ touch("initial.txt");
+ git("add initial.txt");
+ git("commit -m initial");
+ }
+
+ public static void setupUsername() {
+ git("config user.name " + USER_NAME);
+ git("config user.email " + USER_EMAIL);
+ }
+
+ /**
+ * Creates a Git repository in the given root directory;
+ * registers it in the Settings;
+ * return the {@link GitRepository} object for this newly created repository.
+ */
+ @NotNull
+ public static GitRepository createRepository(@NotNull Project project, @NotNull String root) {
+ initRepo(root);
+ ProjectLevelVcsManagerImpl vcsManager = (ProjectLevelVcsManagerImpl)ProjectLevelVcsManager.getInstance(project);
+ vcsManager.setDirectoryMapping(root, GitVcs.NAME);
+ VirtualFile file = LocalFileSystem.getInstance().findFileByIoFile(new File(root));
+ GitRepository repository = GitUtil.getRepositoryManager(project).getRepositoryForRoot(file);
+ assertNotNull("Couldn't find repository for root " + root, repository);
+ return repository;
+ }
+
+ public static void assertNotification(@NotNull Project project, @Nullable Notification expected) {
+ if (expected == null) {
+ assertNull("Notification is unexpected here", expected);
+ return;
+ }
+
+ Notification actualNotification = ((TestNotificator)ServiceManager.getService(project, Notificator.class)).getLastNotification();
+ Assert.assertNotNull("No notification was shown", actualNotification);
+ Assert.assertEquals("Notification has wrong title", expected.getTitle(), actualNotification.getTitle());
+ Assert.assertEquals("Notification has wrong type", expected.getType(), actualNotification.getType());
+ Assert.assertEquals("Notification has wrong content", expected.getContent(), actualNotification.getContent());
+ }
+
+ /**
+ * Default port will be occupied by main idea instance => define the custom default to avoid searching of free port
+ */
+ public static void setDefaultBuiltInServerPort() {
+ System.setProperty(BuiltInServerManagerImpl.PROPERTY_RPC_PORT, "64463");
+ }
}
diff --git a/plugins/git4idea/testFramework/git4idea/test/TestDialogHandler.java b/plugins/git4idea/testFramework/git4idea/test/TestDialogHandler.java
index 506dc5b..3017ec9 100644
--- a/plugins/git4idea/testFramework/git4idea/test/TestDialogHandler.java
+++ b/plugins/git4idea/testFramework/git4idea/test/TestDialogHandler.java
@@ -15,16 +15,25 @@
*/
package git4idea.test;
+import com.intellij.openapi.ui.DialogWrapper;
+
/**
- * TestDialogHandler is invoked by {@link TestDialogManager} instead of showing a dialog on a screen (which is usually impossible for tests).
- * It's purpose is to modify dialog fields and return the dialog exit code which will be transferred to the code which has invoked the dialog.
+ * TestDialogHandler is invoked by the {@link TestDialogManager} instead of showing a dialog on a screen
+ * (which is usually impossible for tests).
+ * It's purpose is to modify dialog fields and return the dialog exit code,
+ * which will be available to the code which has invoked the dialog.
+ *
* @author Kirill Likhodedov
*/
-public interface TestDialogHandler<T> {
+public interface TestDialogHandler<T extends DialogWrapper> {
+
/**
- * Do something with dialog fields and return the exit code - as if user pressed one of exit buttons.
+ * Do something with the dialog (modify its instance fields, for example)
+ * and return the exit code - as if user pressed one of exit buttons.
+ *
* @param dialog dialog to be handled.
- * @return DialogWrapper exit code, for example, {@link com.intellij.openapi.ui.DialogWrapper#OK_EXIT_CODE}.
+ * @return DialogWrapper exit code, for example, {@link DialogWrapper#OK_EXIT_CODE}.
*/
int handleDialog(T dialog);
+
}
diff --git a/plugins/git4idea/testFramework/git4idea/test/TestDialogManager.java b/plugins/git4idea/testFramework/git4idea/test/TestDialogManager.java
index 0bb9469..513c4f9 100644
--- a/plugins/git4idea/testFramework/git4idea/test/TestDialogManager.java
+++ b/plugins/git4idea/testFramework/git4idea/test/TestDialogManager.java
@@ -16,27 +16,16 @@
package git4idea.test;
import com.intellij.openapi.ui.DialogWrapper;
-import org.jetbrains.annotations.Nullable;
+import com.intellij.util.containers.ContainerUtil;
+import git4idea.DialogManager;
+import org.jetbrains.annotations.NotNull;
-import java.lang.reflect.Field;
-import java.util.HashMap;
import java.util.Map;
/**
- * TestDialogManager instead of showing the dialog, gives the control to a {@link TestDialogHandler} which can specify the dialog exit code
- * (thus simulation different user choices) or even change other elements in the dialog.
- * To use it a test should:
- * <ol>
- * <li>register {@link TestDialogManager} as the {@link DialogManager} implementation:
- * <pre><code>
- * String key = "git4idea.DialogManager";
- * MutablePicoContainer picoContainer = (MutablePicoContainer) myProject.getPicoContainer();
- * picoContainer.unregisterComponent(key);
- * picoContainer.registerComponentImplementation(key, TestDialogManager.class);
- * TestDialogManager dialogManager = (TestDialogManager)DialogManager.getInstance(myProject);
- * </code></pre></li>
- *
- * <li>register its {@link TestDialogHandler}:
+ * <p>TestDialogManager instead of showing the dialog, gives the control to a {@link git4idea.test.TestDialogHandler} which can specify the dialog exit code
+ * (thus simulation different user choices) or even change other elements in the dialog.</p>
+ * <p>To use it a test should register the {@link TestDialogHandler} implementation. For example:
* <pre><code>
* myDialogManager.registerDialogHandler(GitConvertFilesDialog.class, new TestDialogHandler<GitConvertFilesDialog>() {
* @Override public int handleDialog(GitConvertFilesDialog dialog) {
@@ -44,48 +33,24 @@
* return GitConvertFilesDialog.OK_EXIT_CODE;
* }
* });
- * </code></pre></li></ol>
+ * </code></pre>
+ * <p>Only one TestDialogHandler can be registered per test for a certain DialogWrapper class.</p>
* @see TestDialogHandler
* @author Kirill Likhodedov
*/
-public class TestDialogManager {
+public class TestDialogManager extends DialogManager {
- private Map<Class, TestDialogHandler> myHandlers = new HashMap<Class, TestDialogHandler>();
+ private final Map<Class, TestDialogHandler> myHandlers = ContainerUtil.newHashMap();
- private DialogWrapper myLastShownDialog;
-
- public void show(DialogWrapper dialog) throws IllegalAccessException, NoSuchFieldException {
- final TestDialogHandler handler = myHandlers.get(dialog.getClass());
- int exitCode = DialogWrapper.OK_EXIT_CODE;
- if (handler != null) {
- exitCode = handler.handleDialog(dialog);
- }
- closeDialog(dialog, exitCode);
- myLastShownDialog = dialog;
+ @Override
+ protected void showDialog(@NotNull DialogWrapper dialog) {
+ TestDialogHandler handler = myHandlers.get(dialog.getClass());
+ int exitCode = handler != null ? handler.handleDialog(dialog) : DialogWrapper.OK_EXIT_CODE;
+ dialog.close(exitCode, exitCode == DialogWrapper.OK_EXIT_CODE);
}
- private static void closeDialog(DialogWrapper dialog, int exitCode) throws NoSuchFieldException, IllegalAccessException {
- Field exitCodeField = DialogWrapper.class.getDeclaredField("myExitCode");
- exitCodeField.setAccessible(true);
- exitCodeField.set(dialog, exitCode);
-
- Field closedField = DialogWrapper.class.getDeclaredField("myClosed");
- closedField.setAccessible(true);
- closedField.set(dialog, true);
- }
-
- /**
- * Registers the dialog handler. Note that a test may register only one handler for one dialog type.
- * For different dialog types it may register different handlers.
- * @param dialogClass class of the dialog which will be handled instead of showing (dialog itself have to support this in its show() method).
- * @param handler handler which will be invoked when dialog is about to show.
- */
- public void registerDialogHandler(Class dialogClass, TestDialogHandler handler) {
+ public void registerDialogHandler(@NotNull Class<? extends DialogWrapper> dialogClass, @NotNull TestDialogHandler handler) {
myHandlers.put(dialogClass, handler);
}
- @Nullable
- public DialogWrapper getLastShownDialog() {
- return myLastShownDialog;
- }
}
diff --git a/plugins/git4idea/testFramework/git4idea/test/TestNotificator.java b/plugins/git4idea/testFramework/git4idea/test/TestNotificator.java
index 143d6f0..5ec1af3 100644
--- a/plugins/git4idea/testFramework/git4idea/test/TestNotificator.java
+++ b/plugins/git4idea/testFramework/git4idea/test/TestNotificator.java
@@ -29,7 +29,7 @@
*/
public class TestNotificator extends Notificator {
- private static final String TEST_NOTIFICATION_GROUP = "Test";
+ public static final String TEST_NOTIFICATION_GROUP = "Test";
private Notification myLastNotification;
public TestNotificator(@NotNull Project project) {
@@ -40,6 +40,10 @@
return myLastNotification;
}
+ public void notify(@NotNull Notification notification) {
+ myLastNotification = notification;
+ }
+
public void notify(@NotNull NotificationGroup notificationGroup, @NotNull String title, @NotNull String message, @NotNull NotificationType type) {
notify(notificationGroup, title, message, type, null);
}
diff --git a/plugins/github/github-test/github-test.iml b/plugins/github/github-test/github-test.iml
new file mode 100644
index 0000000..847e70f
--- /dev/null
+++ b/plugins/github/github-test/github-test.iml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
+ <exclude-output />
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="module" module-name="platform-api" scope="TEST" />
+ <orderEntry type="module" module-name="testFramework" scope="TEST" />
+ <orderEntry type="module" module-name="git4idea" scope="TEST" />
+ <orderEntry type="module" module-name="github" scope="TEST" />
+ <orderEntry type="module" module-name="dvcs" scope="TEST" />
+ <orderEntry type="module" module-name="jira-connector" scope="TEST" />
+ <orderEntry type="module" module-name="vcs-impl" scope="TEST" />
+ <orderEntry type="library" name="gson" level="project" />
+ </component>
+</module>
+
diff --git a/plugins/github/github.iml b/plugins/github/github.iml
index 997d781..3ab065a 100644
--- a/plugins/github/github.iml
+++ b/plugins/github/github.iml
@@ -5,6 +5,7 @@
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/resources" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
@@ -18,6 +19,8 @@
<orderEntry type="module" module-name="util" />
<orderEntry type="library" name="gson" level="project" />
<orderEntry type="module" module-name="dvcs" />
+ <orderEntry type="module" module-name="testFramework" scope="TEST" />
+ <orderEntry type="module" module-name="jira-connector" scope="TEST" />
</component>
</module>
diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubApiUtil.java b/plugins/github/src/org/jetbrains/plugins/github/GithubApiUtil.java
index a033ddc..5c054c5 100644
--- a/plugins/github/src/org/jetbrains/plugins/github/GithubApiUtil.java
+++ b/plugins/github/src/org/jetbrains/plugins/github/GithubApiUtil.java
@@ -15,6 +15,7 @@
*/
package org.jetbrains.plugins.github;
+import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import com.google.gson.JsonSyntaxException;
@@ -22,13 +23,13 @@
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.ThrowableConvertor;
import com.intellij.util.net.HttpConfigurable;
+import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.methods.StringRequestEntity;
+import org.apache.commons.httpclient.auth.AuthenticationException;
+import org.apache.commons.httpclient.methods.*;
import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -45,30 +46,79 @@
private static final int CONNECTION_TIMEOUT = 5000;
private static final Logger LOG = Logger.getInstance(GithubApiUtil.class);
- @Nullable
- public static JsonElement getRequest(@NotNull String host, @NotNull String login, @NotNull String password,
- @NotNull String path) throws IOException {
- return request(host, login, password, path, null, false);
+ private enum HttpVerb {
+ GET, POST, DELETE, HEAD
}
@Nullable
- public static JsonElement postRequest(@NotNull String host, @Nullable String login, @Nullable String password,
- @NotNull String path, @Nullable String requestBody) throws IOException {
- return request(host, login, password, path, requestBody, true);
+ public static JsonElement getRequest(@NotNull String host, @NotNull String login, @NotNull String password,
+ @NotNull String path) throws IOException {
+ return request(host, login, password, path, null, HttpVerb.GET);
+ }
+
+ @Nullable
+ public static JsonElement getRequest(@NotNull GithubAuthData auth, @NotNull String path) throws IOException {
+ return request(auth.getHost(), auth.getLogin(), auth.getPassword(), path, null, HttpVerb.GET);
+ }
+
+ @Nullable
+ public static JsonElement postRequest(@NotNull String host, @NotNull String path, @Nullable String requestBody) throws IOException {
+ return request(host, null, null, path, requestBody, HttpVerb.POST);
+ }
+
+ @Nullable
+ public static JsonElement postRequest(@NotNull GithubAuthData auth, @NotNull String path, @Nullable String requestBody)
+ throws IOException {
+ return request(auth.getHost(), auth.getLogin(), auth.getPassword(), path, requestBody, HttpVerb.POST);
+ }
+
+ @Nullable
+ public static JsonElement postRequest(@NotNull String host,
+ @NotNull GithubAuthData auth,
+ @NotNull String path,
+ @Nullable String requestBody) throws IOException {
+ return request(host, auth.getLogin(), auth.getPassword(), path, requestBody, HttpVerb.POST);
+ }
+
+ @Nullable
+ public static JsonElement deleteRequest(@NotNull GithubAuthData auth, @NotNull String path) throws IOException {
+ return request(auth.getHost(), auth.getLogin(), auth.getPassword(), path, null, HttpVerb.DELETE);
}
@Nullable
private static JsonElement request(@NotNull String host, @Nullable String login, @Nullable String password,
- @NotNull String path, @Nullable String requestBody, boolean post) throws IOException {
+ @NotNull String path,
+ @Nullable String requestBody, @NotNull HttpVerb verb) throws IOException {
HttpMethod method = null;
try {
- method = doREST(host, login, password, path, requestBody, post);
+ method = doREST(host, login, password, path, requestBody, verb);
String resp = method.getResponseBodyAsString();
if (resp == null) {
LOG.info(String.format("Unexpectedly empty response: %s", resp));
return null;
}
- return parseResponse(resp);
+ if (method.getStatusCode() >= 400 && method.getStatusCode() <= 404) {
+ throw new AuthenticationException("Request response: " + method.getStatusText());
+ }
+
+ JsonElement ret = parseResponse(resp);
+
+ Header header = method.getResponseHeader("Link");
+ if (header != null) {
+ String s = header.getValue();
+ final int end = s.indexOf(">; rel=\"next\"");
+ final int begin = s.lastIndexOf('<', end);
+ if (begin >= 0 && end >= 0) {
+ JsonElement next = request(s.substring(begin + 1, end), login, password, "", requestBody, verb);
+ if (next != null) {
+ JsonArray merged = ret.getAsJsonArray();
+ merged.addAll(next.getAsJsonArray());
+ return merged;
+ }
+ }
+ }
+
+ return ret;
}
finally {
if (method != null) {
@@ -79,95 +129,35 @@
@NotNull
private static HttpMethod doREST(@NotNull String host, @Nullable String login, @Nullable String password, @NotNull String path,
- @Nullable final String requestBody, final boolean post) throws IOException {
+ @Nullable final String requestBody,
+ @NotNull final HttpVerb verb) throws IOException {
HttpClient client = getHttpClient(login, password);
- String uri = getApiUrl(host) + path;
+ String uri = GithubUrlUtil.getApiUrl(host) + path;
return GithubSslSupport.getInstance().executeSelfSignedCertificateAwareRequest(client, uri,
new ThrowableConvertor<String, HttpMethod, IOException>() {
@Override
public HttpMethod convert(String uri) throws IOException {
- if (post) {
- PostMethod method = new PostMethod(uri);
- if (requestBody != null) {
- method.setRequestEntity(new StringRequestEntity(requestBody, "application/json", "UTF-8"));
- }
- return method;
+ switch (verb) {
+ case POST:
+ PostMethod method = new PostMethod(uri);
+ if (requestBody != null) {
+ method.setRequestEntity(new StringRequestEntity(requestBody, "application/json", "UTF-8"));
+ }
+ return method;
+ case GET:
+ return new GetMethod(uri);
+ case DELETE:
+ return new DeleteMethod(uri);
+ case HEAD:
+ return new HeadMethod(uri);
+ default:
+ throw new IllegalStateException("Wrong HttpVerb: unknown method: " + verb.toString());
}
- return new GetMethod(uri);
}
});
}
@NotNull
- public static String removeProtocolPrefix(final String url) {
- if (url.startsWith("https://")) {
- return url.substring(8);
- }
- else if (url.startsWith("http://")) {
- return url.substring(7);
- }
- else if (url.startsWith("git@")) {
- return url.substring(4);
- }
- else {
- return url;
- }
- }
-
- @NotNull
- private static String getApiUrl(@NotNull String urlFromSettings) {
- return "https://" + getApiUrlWithoutProtocol(urlFromSettings);
- }
-
- @NotNull
- public static String getApiUrl() {
- return getApiUrl(GithubSettings.getInstance().getHost());
- }
-
- /**
- * Returns the "host" part of Git URLs.
- * E.g.: https://github.com
- * Note: there is no trailing slash in the returned url.
- */
- @NotNull
- public static String getGitHost() {
- return "https://" + removeTrailingSlash(removeProtocolPrefix(GithubSettings.getInstance().getHost()));
- }
-
- /*
- All API access is over HTTPS, and accessed from the api.github.com domain
- (or through yourdomain.com/api/v3/ for enterprise).
- http://developer.github.com/v3/
- */
- @NotNull
- private static String getApiUrlWithoutProtocol(String urlFromSettings) {
- String url = removeTrailingSlash(removeProtocolPrefix(urlFromSettings));
- final String API_PREFIX = "api.";
- final String ENTERPRISE_API_SUFFIX = "/api/v3";
-
- if (url.equals(DEFAULT_GITHUB_HOST)) {
- return API_PREFIX + url;
- }
- else if (url.equals(API_PREFIX + DEFAULT_GITHUB_HOST)) {
- return url;
- }
- else if (url.endsWith(ENTERPRISE_API_SUFFIX)) {
- return url;
- }
- else {
- return url + ENTERPRISE_API_SUFFIX;
- }
- }
-
- @NotNull
- public static String removeTrailingSlash(@NotNull String s) {
- if (s.endsWith("/")) {
- return s.substring(0, s.length() - 1);
- }
- return s;
- }
-
- @NotNull
private static HttpClient getHttpClient(@Nullable final String login, @Nullable final String password) {
final HttpClient client = new HttpClient();
HttpConnectionManagerParams params = client.getHttpConnectionManager().getParams();
diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubAuthData.java b/plugins/github/src/org/jetbrains/plugins/github/GithubAuthData.java
new file mode 100644
index 0000000..f5b07dd
--- /dev/null
+++ b/plugins/github/src/org/jetbrains/plugins/github/GithubAuthData.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2000-2013 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 org.jetbrains.plugins.github;
+
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Container for authentication data: host, login and password.
+ *
+ * @author Aleksey Pivovarov
+ */
+public class GithubAuthData {
+ @NotNull private final String myHost;
+ @NotNull private final String myLogin;
+ @NotNull private final String myPassword;
+
+ public GithubAuthData(@NotNull String host, @NotNull String login, @NotNull String password) {
+ myHost = host;
+ myLogin = login;
+ myPassword = password;
+ }
+
+ @NotNull
+ public String getHost() {
+ return myHost;
+ }
+
+ @NotNull
+ public String getLogin() {
+ return myLogin;
+ }
+
+ @NotNull
+ public String getPassword() {
+ return myPassword;
+ }
+
+}
diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubCheckoutListener.java b/plugins/github/src/org/jetbrains/plugins/github/GithubCheckoutListener.java
index 1da2e0a..c3229ea 100644
--- a/plugins/github/src/org/jetbrains/plugins/github/GithubCheckoutListener.java
+++ b/plugins/github/src/org/jetbrains/plugins/github/GithubCheckoutListener.java
@@ -9,7 +9,6 @@
import com.intellij.tasks.TaskRepository;
import com.intellij.tasks.impl.TaskManagerImpl;
import git4idea.GitUtil;
-import git4idea.repo.GitRemote;
import git4idea.repo.GitRepository;
import git4idea.repo.GitRepositoryManager;
import org.jetbrains.annotations.Nullable;
@@ -32,10 +31,9 @@
@Override
public void processOpenedProject(final Project lastOpenedProject) {
- final GithubSettings settings = GithubSettings.getInstance();
final Pair<String, String> info = getGithubProjectInfo(lastOpenedProject);
if (info != null) {
- processProject(lastOpenedProject, settings, info.first, info.second);
+ processProject(lastOpenedProject, info.first, info.second);
}
}
@@ -47,53 +45,46 @@
}
// Check if git is already initialized and presence of remote branch
GitRepositoryManager manager = GitUtil.getRepositoryManager(project);
- if (manager == null) {
- return null;
- }
final GitRepository gitRepository = manager.getRepositoryForFile(root);
- if (gitRepository == null){
+ if (gitRepository == null) {
return null;
}
// Check that given repository is properly configured git repository
- final GitRemote gitRemote = GithubUtil.findGitHubRemoteBranch(gitRepository);
- if (gitRemote == null) {
- return null;
- }
- String url = GithubUtil.getGithubUrl(gitRemote);
+ String url = GithubUtil.findGithubRemoteUrl(gitRepository);
if (url == null) {
return null;
}
int i = url.lastIndexOf("/");
- if (i == -1){
+ if (i == -1) {
return null;
}
String name = url.substring(i + 1);
- if (name.endsWith(".git")){
+ if (name.endsWith(".git")) {
name = name.substring(0, name.length() - 4);
}
url = url.substring(0, i);
// We don't want https://
- if (url.startsWith("https://")){
+ if (url.startsWith("https://")) {
url = url.substring(8);
}
i = url.lastIndexOf(':');
if (i == -1) {
i = url.lastIndexOf('/');
}
- if (i == -1){
+ if (i == -1) {
return null;
}
final String author = url.substring(i + 1);
return Pair.create(author, name);
}
- private static void processProject(final Project openedProject, final GithubSettings settings, final String author, final String name) {
+ private static void processProject(final Project openedProject, final String author, final String name) {
// try to enable git tasks integration
final Runnable taskInitializationRunnable = new Runnable() {
public void run() {
try {
- enableGithubTrackerIntegration(openedProject, settings.getLogin(), settings.getPassword(), author, name);
+ enableGithubTrackerIntegration(openedProject, author, name);
}
catch (Exception e) {
// Ignore it
@@ -102,16 +93,13 @@
};
if (openedProject.isInitialized()) {
taskInitializationRunnable.run();
- } else {
+ }
+ else {
StartupManager.getInstance(openedProject).runWhenProjectIsInitialized(taskInitializationRunnable);
}
}
- private static void enableGithubTrackerIntegration(final Project project,
- final String login,
- final String password,
- final String author,
- final String name) {
+ private static void enableGithubTrackerIntegration(final Project project, final String author, final String name) {
// Look for github repository type
final TaskManagerImpl manager = (TaskManagerImpl)TaskManager.getManager(project);
final TaskRepository[] allRepositories = manager.getAllRepositories();
@@ -121,9 +109,10 @@
}
}
// Create new one if not found exists
+ GithubSettings settings = GithubSettings.getInstance();
final GitHubRepository repository = new GitHubRepository(new GitHubRepositoryType());
- repository.setUsername(login);
- repository.setPassword(password);
+ repository.setUsername(settings.getLogin());
+ repository.setPassword(settings.getPassword());
repository.setRepoAuthor(author);
repository.setRepoName(name);
final ArrayList<TaskRepository> repositories = new ArrayList<TaskRepository>(Arrays.asList(allRepositories));
diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubCheckoutProvider.java b/plugins/github/src/org/jetbrains/plugins/github/GithubCheckoutProvider.java
index ba9cf9d..06ec801 100644
--- a/plugins/github/src/org/jetbrains/plugins/github/GithubCheckoutProvider.java
+++ b/plugins/github/src/org/jetbrains/plugins/github/GithubCheckoutProvider.java
@@ -17,10 +17,15 @@
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.progress.ProgressIndicator;
+import com.intellij.openapi.progress.ProgressManager;
+import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Ref;
import com.intellij.openapi.vcs.CheckoutProvider;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.util.ThrowableConsumer;
import git4idea.actions.BasicAction;
import git4idea.checkout.GitCheckoutProvider;
import git4idea.checkout.GitCloneDialog;
@@ -39,22 +44,33 @@
*/
public class GithubCheckoutProvider implements CheckoutProvider {
- private static Logger LOG = GithubUtil.LOG;
+ private static final Logger LOG = GithubUtil.LOG;
@Override
public void doCheckout(@NotNull final Project project, @Nullable final Listener listener) {
- if (!GithubUtil.testGitExecutable(project)){
+ if (!GithubUtil.testGitExecutable(project)) {
return;
}
BasicAction.saveAll();
- List<RepositoryInfo> availableRepos = null;
- try {
- availableRepos = GithubUtil.getAvailableRepos(project);
- }
- catch (IOException e) {
- LOG.info(e);
- GithubUtil.notifyError(project, "Couldn't get the list of GitHub repositories", GithubUtil.getErrorTextFromException(e));
- }
+
+ final Ref<List<RepositoryInfo>> repositoryInfoRef = new Ref<List<RepositoryInfo>>();
+ ProgressManager.getInstance().run(new Task.Modal(project, "Access to GitHub", true) {
+ public void run(@NotNull ProgressIndicator indicator) {
+ try {
+ GithubUtil.runAndGetValidAuth(project, indicator, new ThrowableConsumer<GithubAuthData, IOException>() {
+ @Override
+ public void consume(GithubAuthData authData) throws IOException {
+ repositoryInfoRef.set(GithubUtil.getAvailableRepos(authData));
+ }
+ });
+ }
+ catch (IOException e) {
+ LOG.info(e);
+ GithubNotifications.showError(project, "Couldn't get the list of GitHub repositories", e);
+ }
+ }
+ });
+ final List<RepositoryInfo> availableRepos = repositoryInfoRef.get();
if (availableRepos == null){
return;
}
diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubCreateGistAction.java b/plugins/github/src/org/jetbrains/plugins/github/GithubCreateGistAction.java
index b214369..e21155c 100644
--- a/plugins/github/src/org/jetbrains/plugins/github/GithubCreateGistAction.java
+++ b/plugins/github/src/org/jetbrains/plugins/github/GithubCreateGistAction.java
@@ -18,38 +18,33 @@
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.intellij.ide.BrowserUtil;
-import com.intellij.notification.Notification;
-import com.intellij.notification.NotificationListener;
-import com.intellij.notification.NotificationType;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileTypes.FileTypeManager;
import com.intellij.openapi.progress.ProgressIndicator;
+import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Computable;
+import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.changes.ChangeListManager;
import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.util.Consumer;
-import git4idea.GitVcs;
-import git4idea.Notificator;
import icons.GithubIcons;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.github.ui.GitHubCreateGistDialog;
-import org.jetbrains.plugins.github.ui.GithubLoginDialog;
-import javax.swing.event.HyperlinkEvent;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import java.util.concurrent.atomic.AtomicReference;
/**
* @author oleg
@@ -60,37 +55,26 @@
private static final String FAILED_TO_CREATE_GIST = "Can't create Gist";
protected GithubCreateGistAction() {
- super("Create Gist...", "Create github gist", GithubIcons.Github_icon);
+ super("Create Gist...", "Create GitHub Gist", GithubIcons.Github_icon);
}
@Override
public void update(final AnActionEvent e) {
- final long startTime = System.nanoTime();
- try {
- final Project project = e.getData(PlatformDataKeys.PROJECT);
- if (project == null || project.isDefault()) {
- e.getPresentation().setVisible(false);
- e.getPresentation().setEnabled(false);
- return;
- }
- final Editor editor = e.getData(PlatformDataKeys.EDITOR);
- final VirtualFile file = e.getData(PlatformDataKeys.VIRTUAL_FILE);
- final VirtualFile[] files = e.getData(PlatformDataKeys.VIRTUAL_FILE_ARRAY);
-
- if (editor == null && file == null && files == null) {
- e.getPresentation().setVisible(false);
- e.getPresentation().setEnabled(false);
- return;
- }
-
- e.getPresentation().setVisible(true);
- e.getPresentation().setEnabled(true);
+ Project project = e.getData(PlatformDataKeys.PROJECT);
+ if (project == null || project.isDefault()) {
+ e.getPresentation().setVisible(false);
+ e.getPresentation().setEnabled(false);
+ return;
}
- finally {
- if (LOG.isDebugEnabled()) {
- LOG.debug("GithubCreateGistAction#update finished in: " + (System.nanoTime() - startTime) / 10e6 + "ms");
- }
+ Editor editor = e.getData(PlatformDataKeys.EDITOR);
+ VirtualFile file = e.getData(PlatformDataKeys.VIRTUAL_FILE);
+ VirtualFile[] files = e.getData(PlatformDataKeys.VIRTUAL_FILE_ARRAY);
+
+ if ((editor == null && file == null && files == null) || (editor != null && editor.getDocument().getTextLength() == 0)) {
+ GithubUtil.setVisibleEnabled(e, false, false);
+ return;
}
+ GithubUtil.setVisibleEnabled(e, true, true);
}
@Override
@@ -107,145 +91,227 @@
return;
}
+ createGistAction(project, editor, file, files);
+ }
+
+ static void createGistAction(@NotNull final Project project,
+ @Nullable final Editor editor,
+ @Nullable final VirtualFile file,
+ @Nullable final VirtualFile[] files) {
+
// Ask for description and other params
- final GitHubCreateGistDialog dialog = new GitHubCreateGistDialog(project);
+ final GitHubCreateGistDialog dialog = new GitHubCreateGistDialog(project, editor, file);
dialog.show();
- if (!dialog.isOK()){
+ if (!dialog.isOK()) {
return;
}
- final boolean anonymous = dialog.isAnonymous();
- if (!anonymous) {
- if (!GithubUtil.checkCredentials(project)) {
- final GithubLoginDialog loginDialog = new GithubLoginDialog(project);
- loginDialog.show();
- if (!loginDialog.isOK()) {
- showError(project, FAILED_TO_CREATE_GIST, "You have to login to GitHub to create non-anonymous Gists.", null, null);
- return;
- }
- }
+ final GithubAuthData auth = dialog.isAnonymous() ? null : getValidAuthData(project);
+ if (!dialog.isAnonymous() && auth == null) {
+ GithubNotifications.showWarning(project, FAILED_TO_CREATE_GIST, "You have to login to GitHub to create non-anonymous Gists.");
+ return;
}
- GithubSettings settings = GithubSettings.getInstance();
- createGistWithProgress(project, editor, file, files, settings.getLogin(), settings.getPassword(), dialog.getDescription(),
- dialog.isPrivate(), anonymous,
- new Consumer<String>() {
-
- @Override
- public void consume(String url) {
- if (url == null) {
- return;
- }
-
- if (dialog.isOpenInBrowser()) {
- BrowserUtil.launchBrowser(url);
- }
- else {
- showNotificationWithLink(project, url);
- }
- }
- });
- }
-
- private static void createGistWithProgress(@NotNull final Project project, @Nullable final Editor editor,
- @Nullable final VirtualFile file, @Nullable final VirtualFile[] files,
- @NotNull final String login, @NotNull final String password,
- @NotNull final String description, final boolean aPrivate,
- final boolean anonymous, @NotNull final Consumer<String> resultHandler) {
- final AtomicReference<String> url = new AtomicReference<String>();
- new Task.Backgroundable(project, "Creating Gist") {
+ final Ref<String> url = new Ref<String>();
+ new Task.Backgroundable(project, "Creating Gist...") {
@Override
public void run(@NotNull ProgressIndicator indicator) {
List<NamedContent> contents = collectContents(project, editor, file, files);
- if (contents == null) {
- return;
- }
- String gistUrl = createGist(project, login, password, anonymous, contents, aPrivate, description);
+ String gistUrl = createGist(project, auth, contents, dialog.isPrivate(), dialog.getDescription(), dialog.getFileName());
url.set(gistUrl);
}
@Override
public void onSuccess() {
- resultHandler.consume(url.get());
+ if (url.isNull()) {
+ return;
+ }
+ if (dialog.isOpenInBrowser()) {
+ BrowserUtil.launchBrowser(url.get());
+ }
+ else {
+ GithubNotifications.showInfoURL(project, "Gist Created Successfully", "Your gist url", url.get());
+ }
}
}.queue();
}
- private static void showNotificationWithLink(@NotNull Project project, @NotNull final String url) {
- Notificator.getInstance(project).notify(GitVcs.IMPORTANT_ERROR_NOTIFICATION, "Gist Created Successfully",
- "Your gist url: <a href='open'>" + url + "</a>", NotificationType.INFORMATION,
- new NotificationListener() {
- @Override
- public void hyperlinkUpdate(@NotNull Notification notification,
- @NotNull HyperlinkEvent event) {
- if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
- BrowserUtil.launchBrowser(url);
- }
- }
- });
+ @Nullable
+ private static GithubAuthData getValidAuthData(@NotNull final Project project) {
+ final Ref<GithubAuthData> authDataRef = new Ref<GithubAuthData>();
+ ProgressManager.getInstance().run(new Task.Modal(project, "Access to GitHub", true) {
+ public void run(@NotNull ProgressIndicator indicator) {
+ authDataRef.set(GithubUtil.getValidAuthDataFromConfig(project, indicator));
+ }
+ });
+ return authDataRef.get();
}
- @Nullable
- private static List<NamedContent> collectContents(@NotNull Project project, @Nullable Editor editor,
- @Nullable VirtualFile file, @Nullable VirtualFile[] files) {
+ @NotNull
+ static List<NamedContent> collectContents(@NotNull Project project,
+ @Nullable Editor editor,
+ @Nullable VirtualFile file,
+ @Nullable VirtualFile[] files) {
if (editor != null) {
- NamedContent content = getContentFromEditor(editor, file, project);
- return content == null ? null : Collections.singletonList(content);
+ NamedContent content = getContentFromEditor(editor, file);
+ return content == null ? Collections.<NamedContent>emptyList() : Collections.singletonList(content);
}
if (files != null) {
List<NamedContent> contents = new ArrayList<NamedContent>();
for (VirtualFile vf : files) {
- List<NamedContent> content = getContentFromFile(vf, project, null);
- if (content == null) {
- return null;
- }
- contents.addAll(content);
+ contents.addAll(getContentFromFile(vf, project, null));
}
return contents;
}
- if (file == null) {
- LOG.error("File, files and editor can't be null all at once!");
- return null;
+ if (file != null) {
+ return getContentFromFile(file, project, null);
}
- return getContentFromFile(file, project, null);
+ LOG.error("File, files and editor can't be null all at once!");
+ throw new IllegalStateException("File, files and editor can't be null all at once!");
}
@Nullable
- private static String createGist(@NotNull Project project, @Nullable String login, @Nullable String password, boolean anonymous,
- @NotNull List<NamedContent> contents, boolean isPrivate, @NotNull String description) {
- if (anonymous) {
- login = null;
- password = null;
+ static String createGist(@NotNull Project project,
+ @Nullable GithubAuthData auth,
+ @NotNull List<NamedContent> contents,
+ boolean isPrivate,
+ @NotNull String description,
+ @Nullable String filename) {
+ if (contents.isEmpty()) {
+ GithubNotifications.showWarning(project, FAILED_TO_CREATE_GIST, "Can't create empty gist");
+ return null;
}
- String requestBody = prepareJsonRequest(description, isPrivate, contents);
+ String requestBody = prepareCreateJsonRequest(description, isPrivate, contents, filename);
try {
- JsonElement jsonElement = GithubApiUtil.postRequest(GithubApiUtil.getApiUrl(), login, password, "/gists", requestBody);
- if (jsonElement == null) {
- LOG.info("Null JSON response returned by GitHub");
- showError(project, "Failed to create gist", "Empty JSON response returned by GitHub", null, null);
- return null;
+ JsonElement jsonElement;
+ if (auth == null) {
+ jsonElement = GithubApiUtil.postRequest(GithubUrlUtil.getApiUrl(), "/gists", requestBody);
}
- if (!jsonElement.isJsonObject()) {
- LOG.error(String.format("Unexpected JSON result format: %s", jsonElement));
- return null;
+ else {
+ jsonElement = GithubApiUtil.postRequest(GithubUrlUtil.getApiUrl(), auth, "/gists", requestBody);
}
- JsonElement htmlUrl = jsonElement.getAsJsonObject().get("html_url");
- if (htmlUrl == null) {
- LOG.info("Invalid JSON response: " + jsonElement);
- showError(project, "Invalid GitHub response", "No html_url property", jsonElement.toString(), null);
- return null;
- }
- return htmlUrl.getAsString();
+ return getUrlFromJson(project, jsonElement);
}
catch (IOException e) {
LOG.info("Exception when creating a Gist", e);
- showError(project, "Failed to create gist", "", null, e);
+ GithubNotifications.showError(project, FAILED_TO_CREATE_GIST, e.getMessage());
return null;
}
}
+ @NotNull
+ private static String prepareCreateJsonRequest(@NotNull String description,
+ boolean isPrivate,
+ @NotNull List<NamedContent> contents,
+ @Nullable String filename) {
+ JsonObject json = new JsonObject();
+ json.addProperty("description", description);
+ json.addProperty("public", Boolean.toString(!isPrivate));
+
+ JsonObject files = new JsonObject();
+
+ for (NamedContent content : contents) {
+ JsonObject file = new JsonObject();
+ file.addProperty("content", content.getText());
+ if (contents.size() > 1 || filename == null) {
+ files.add(content.getName(), file);
+ }
+ else {
+ files.add(filename, file);
+ }
+ }
+
+ json.add("files", files);
+ return json.toString();
+ }
+
+ @Nullable
+ private static String getUrlFromJson(@NotNull Project project, @Nullable JsonElement jsonElement) {
+ if (jsonElement == null) {
+ LOG.info("Null JSON response returned by GitHub");
+ GithubNotifications.showError(project, FAILED_TO_CREATE_GIST, "Empty JSON response returned by GitHub");
+ return null;
+ }
+ if (!jsonElement.isJsonObject()) {
+ LOG.error(String.format("Unexpected JSON result format: %s", jsonElement));
+ GithubNotifications.showError(project, FAILED_TO_CREATE_GIST, "Invalid GitHub response: " + jsonElement.toString());
+ return null;
+ }
+ JsonElement htmlUrl = jsonElement.getAsJsonObject().get("html_url");
+ if (htmlUrl == null) {
+ LOG.info("Invalid JSON response: " + jsonElement);
+ GithubNotifications.showError(project, FAILED_TO_CREATE_GIST, "Invalid GitHub response: " + jsonElement.toString());
+ return null;
+ }
+ return htmlUrl.getAsString();
+ }
+
+ @Nullable
+ private static NamedContent getContentFromEditor(@NotNull final Editor editor, @Nullable VirtualFile selectedFile) {
+ String text = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
+ @Nullable
+ @Override
+ public String compute() {
+ return editor.getSelectionModel().getSelectedText();
+ }
+ });
+
+ if (text == null) {
+ text = editor.getDocument().getText();
+ }
+
+ if (StringUtil.isEmptyOrSpaces(text)) {
+ return null;
+ }
+
+ String name;
+ if (selectedFile == null) {
+ name = "";
+ }
+ else {
+ name = selectedFile.getName();
+ }
+ return new NamedContent(name, text);
+ }
+
+ @NotNull
+ private static List<NamedContent> getContentFromFile(@NotNull VirtualFile file, @NotNull Project project, @Nullable String prefix) {
+ if (file.isDirectory()) {
+ return getContentFromDirectory(file, project, prefix);
+ }
+ Document document = FileDocumentManager.getInstance().getDocument(file);
+ String content;
+ if (document != null) {
+ content = document.getText();
+ }
+ else {
+ content = readFile(file);
+ }
+ if (content == null) {
+ GithubNotifications.showWarning(project, FAILED_TO_CREATE_GIST, "Couldn't read the contents of the file " + file);
+ LOG.info("Couldn't read the contents of the file " + file);
+ return Collections.emptyList();
+ }
+ if (StringUtil.isEmptyOrSpaces(content)) {
+ return Collections.emptyList();
+ }
+ return Collections.singletonList(new NamedContent(addPrefix(file.getName(), prefix, false), content));
+ }
+
+ @NotNull
+ private static List<NamedContent> getContentFromDirectory(@NotNull VirtualFile dir, @NotNull Project project, @Nullable String prefix) {
+ List<NamedContent> contents = new ArrayList<NamedContent>();
+ for (VirtualFile file : dir.getChildren()) {
+ if (!isFileIgnored(file, project)) {
+ String pref = addPrefix(dir.getName(), prefix, true);
+ contents.addAll(getContentFromFile(file, project, pref));
+ }
+ }
+ return contents;
+ }
+
@Nullable
private static String readFile(@NotNull final VirtualFile file) {
return ApplicationManager.getApplication().runReadAction(new Computable<String>() {
@@ -263,58 +329,6 @@
});
}
- private static void showError(@NotNull Project project, @NotNull String title, @NotNull String content,
- @Nullable String details, @Nullable Exception e) {
- Notificator.getInstance(project).notifyError(title, content);
- LOG.info("Couldn't parse response as json data: \n" + content + "\n" + details, e);
- }
-
- private static String prepareJsonRequest(@NotNull String description, boolean isPrivate, @NotNull List<NamedContent> contents) {
- JsonObject json = new JsonObject();
- json.addProperty("description", description);
- json.addProperty("public", Boolean.toString(!isPrivate));
-
- JsonObject files = new JsonObject();
- for (NamedContent content : contents) {
- JsonObject file = new JsonObject();
- file.addProperty("content", content.getText());
- files.add(content.getName(), file);
- }
-
- json.add("files", files);
- return json.toString();
- }
-
- @Nullable
- private static List<NamedContent> getContentFromFile(@NotNull VirtualFile file, @NotNull Project project, @Nullable String prefix) {
- if (file.isDirectory()) {
- return getContentFromDirectory(file, project, prefix);
- }
- String content = readFile(file);
- if (content == null) {
- showError(project, FAILED_TO_CREATE_GIST, "Couldn't read the contents of the file " + file, null, null);
- LOG.info("Couldn't read the contents of the file " + file);
- return null;
- }
- return Collections.singletonList(new NamedContent(addPrefix(file.getName(), prefix, false), content));
- }
-
- @Nullable
- private static List<NamedContent> getContentFromDirectory(@NotNull VirtualFile dir, @NotNull Project project, @Nullable String prefix) {
- List<NamedContent> contents = new ArrayList<NamedContent>();
- for (VirtualFile file : dir.getChildren()) {
- if (!isFileIgnored(file, project)) {
- String pref = addPrefix(dir.getName(), prefix, true);
- List<NamedContent> c = getContentFromFile(file, project, pref);
- if (c == null) {
- return null;
- }
- contents.addAll(c);
- }
- }
- return contents;
- }
-
private static String addPrefix(@NotNull String name, @Nullable String prefix, boolean addTrailingSlash) {
String pref = prefix == null ? "" : prefix;
pref += name;
@@ -329,40 +343,11 @@
return manager.isIgnoredFile(file) || FileTypeManager.getInstance().isFileIgnored(file);
}
- @Nullable
- private static NamedContent getContentFromEditor(@NotNull final Editor editor, @Nullable VirtualFile selectedFile, @NotNull Project project) {
- String text = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
- @Nullable
- @Override
- public String compute() {
- return editor.getSelectionModel().getSelectedText();
- }
- });
-
- if (text == null) {
- text = editor.getDocument().getText();
- }
-
- if (StringUtil.isEmpty(text)) {
- showError(project, FAILED_TO_CREATE_GIST, "No text was selected to Gist", null, null);
- return null;
- }
-
- String name;
- if (selectedFile == null) {
- name = "";
- }
- else {
- name = selectedFile.getName();
- }
- return new NamedContent(name, text);
- }
-
- private static class NamedContent {
+ static class NamedContent {
@NotNull private final String myName;
@NotNull private final String myText;
- private NamedContent(@NotNull String name, @NotNull String text) {
+ public NamedContent(@NotNull String name, @NotNull String text) {
myName = name;
myText = text;
}
diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubHttpAuthDataProvider.java b/plugins/github/src/org/jetbrains/plugins/github/GithubHttpAuthDataProvider.java
index 3db1531..d80e3bf 100644
--- a/plugins/github/src/org/jetbrains/plugins/github/GithubHttpAuthDataProvider.java
+++ b/plugins/github/src/org/jetbrains/plugins/github/GithubHttpAuthDataProvider.java
@@ -15,12 +15,9 @@
*/
package org.jetbrains.plugins.github;
-import com.intellij.ide.passwordSafe.PasswordSafe;
-import com.intellij.ide.passwordSafe.PasswordSafeException;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.AuthData;
import git4idea.jgit.GitHttpAuthDataProvider;
-import git4idea.jgit.GitHttpCredentialsProvider;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -32,23 +29,17 @@
@Nullable
@Override
public AuthData getAuthData(@NotNull String url) {
- if (!GithubUtil.isGithubUrl(url)) {
+ if (!GithubUrlUtil.isGithubUrl(url)) {
return null;
}
- String login = GithubSettings.getInstance().getLogin();
+ GithubSettings settings = GithubSettings.getInstance();
+ String login = settings.getLogin();
if (StringUtil.isEmptyOrSpaces(login)) {
return null;
}
- String key = GithubSettings.GITHUB_SETTINGS_PASSWORD_KEY;
- try {
- return new AuthData(login, PasswordSafe.getInstance().getPassword(null, GithubSettings.class, key));
- }
- catch (PasswordSafeException e) {
- GithubUtil.LOG.info("Couldn't get the password for key [" + key + "]", e);
- return null;
- }
+ return new AuthData(login, settings.getPassword());
}
}
diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubNotifications.java b/plugins/github/src/org/jetbrains/plugins/github/GithubNotifications.java
new file mode 100644
index 0000000..7667956
--- /dev/null
+++ b/plugins/github/src/org/jetbrains/plugins/github/GithubNotifications.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2000-2013 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 org.jetbrains.plugins.github;
+
+import com.intellij.notification.Notification;
+import com.intellij.notification.NotificationListener;
+import com.intellij.notification.NotificationType;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.Messages;
+import git4idea.Notificator;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author Aleksey Pivovarov
+ */
+public class GithubNotifications {
+ private static final Logger LOG = Logger.getInstance(GithubNotifications.class);
+
+ private static final String GITHUB_NOTIFICATION_GROUP = "github";
+
+ public static void showInfo(@NotNull Project project, @NotNull String title, @NotNull String message) {
+ Notification notification = new Notification(GITHUB_NOTIFICATION_GROUP, title, message, NotificationType.INFORMATION);
+ Notificator.getInstance(project).notify(notification);
+ }
+
+ public static void showWarning(@NotNull Project project, @NotNull String title, @NotNull String message) {
+ Notification notification = new Notification(GITHUB_NOTIFICATION_GROUP, title, message, NotificationType.WARNING);
+ Notificator.getInstance(project).notify(notification);
+ }
+
+ public static void showError(@NotNull Project project, @NotNull String title, @NotNull String message) {
+ Notification notification = new Notification(GITHUB_NOTIFICATION_GROUP, title, message, NotificationType.ERROR);
+ Notificator.getInstance(project).notify(notification);
+ }
+
+ public static void showError(@NotNull Project project, @NotNull String title, @NotNull Exception e) {
+ Notification notification = new Notification(GITHUB_NOTIFICATION_GROUP, title, e.getMessage(), NotificationType.ERROR);
+ Notificator.getInstance(project).notify(notification);
+ }
+
+ public static void showInfoURL(@NotNull Project project, @NotNull String title, @NotNull String message, @NotNull String url) {
+ Notification notification =
+ new Notification(GITHUB_NOTIFICATION_GROUP, title, "<a href='" + url + "'>" + message + "</a>", NotificationType.INFORMATION,
+ NotificationListener.URL_OPENING_LISTENER);
+ Notificator.getInstance(project).notify(notification);
+ }
+
+ public static void showWarningURL(@NotNull Project project,
+ @NotNull String title,
+ @NotNull String prefix,
+ @NotNull String highlight,
+ @NotNull String postfix,
+ @NotNull String url) {
+ Notification notification =
+ new Notification(GITHUB_NOTIFICATION_GROUP, title, prefix + "<a href='" + url + "'>" + highlight + "</a>" + postfix,
+ NotificationType.WARNING, NotificationListener.URL_OPENING_LISTENER);
+ Notificator.getInstance(project).notify(notification);
+ }
+
+ public static void showErrorURL(@NotNull Project project,
+ @NotNull String title,
+ @NotNull String prefix,
+ @NotNull String highlight,
+ @NotNull String postfix,
+ @NotNull String url) {
+ Notification notification =
+ new Notification(GITHUB_NOTIFICATION_GROUP, title, prefix + "<a href='" + url + "'>" + highlight + "</a>" + postfix,
+ NotificationType.ERROR, NotificationListener.URL_OPENING_LISTENER);
+ Notificator.getInstance(project).notify(notification);
+ }
+
+ public static void showInfoDialog(final @NotNull Project project, final @NotNull String title, final @NotNull String message) {
+ Messages.showInfoMessage(project, message, title);
+ }
+
+ public static void showWarningDialog(final @NotNull Project project, final @NotNull String title, final @NotNull String message) {
+ Messages.showWarningDialog(project, message, title);
+ }
+
+ public static void showErrorDialog(final @NotNull Project project, final @NotNull String title, final @NotNull String message) {
+ Messages.showErrorDialog(project, message, title);
+ }
+
+ public static int showYesNoDialog(final @NotNull Project project, final @NotNull String title, final @NotNull String message) {
+ return Messages.showYesNoDialog(project, message, title, Messages.getQuestionIcon());
+ }
+}
diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubOpenInBrowserAction.java b/plugins/github/src/org/jetbrains/plugins/github/GithubOpenInBrowserAction.java
index 11a4a1b..dd8692b 100644
--- a/plugins/github/src/org/jetbrains/plugins/github/GithubOpenInBrowserAction.java
+++ b/plugins/github/src/org/jetbrains/plugins/github/GithubOpenInBrowserAction.java
@@ -20,6 +20,7 @@
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.editor.SelectionModel;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.changes.Change;
@@ -34,9 +35,8 @@
import icons.GithubIcons;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import org.jetbrains.plugins.github.ui.GithubLoginDialog;
-import static org.jetbrains.plugins.github.GithubUtil.*;
+import static org.jetbrains.plugins.github.GithubUtil.setVisibleEnabled;
/**
* Created by IntelliJ IDEA.
@@ -68,8 +68,7 @@
return;
}
- // Check that given repository is properly configured git repository
- if (!isRepositoryOnGitHub(gitRepository)) {
+ if (!GithubUtil.isRepositoryOnGitHub(gitRepository)) {
setVisibleEnabled(e, false, false);
return;
}
@@ -89,7 +88,6 @@
setVisibleEnabled(e, true, true);
}
- @SuppressWarnings("ConstantConditions")
@Override
public void actionPerformed(final AnActionEvent e) {
final Project project = e.getData(PlatformDataKeys.PROJECT);
@@ -98,18 +96,22 @@
return;
}
- while (!checkCredentials(project)) {
- final GithubLoginDialog dialog = new GithubLoginDialog(project);
- dialog.show();
- if (!dialog.isOK()) {
- return;
- }
- }
-
GitRepositoryManager manager = GitUtil.getRepositoryManager(project);
final GitRepository repository = manager.getRepositoryForFile(virtualFile);
+ if (repository == null) {
+ StringBuilder details = new StringBuilder("file: " + virtualFile.getPresentableUrl() + "; Git repositories: ");
+ for (GitRepository repo : manager.getRepositories()) {
+ details.append(repo.getPresentableUrl()).append("; ");
+ }
+ notifyError(project, "Can't find git repository", details.toString());
+ return;
+ }
- final String githubRemoteUrl = findGithubRemoteUrl(repository);
+ final String githubRemoteUrl = GithubUtil.findGithubRemoteUrl(repository);
+ if (githubRemoteUrl == null) {
+ notifyError(project, "Can't find github remote", null);
+ return;
+ }
final String rootPath = repository.getRoot().getPath();
final String path = virtualFile.getPath();
@@ -125,23 +127,36 @@
String relativePath = path.substring(rootPath.length());
String urlToOpen = makeUrlToOpen(e, relativePath, branch, githubRemoteUrl);
+ if (urlToOpen == null) {
+ notifyError(project, "Can't create properly url", githubRemoteUrl);
+ return;
+ }
BrowserUtil.launchBrowser(urlToOpen);
}
- private static void notifyError(@NotNull Project project, @NotNull String message, @Nullable String logDetails) {
- Notificator.getInstance(project).notifyError(CANNOT_OPEN_IN_BROWSER, message);
- LOG.info(message + (logDetails == null ? "" : logDetails));
- }
-
+ @Nullable
private static String makeUrlToOpen(@NotNull AnActionEvent e, @NotNull String relativePath, @NotNull String branch,
@NotNull String githubRemoteUrl) {
final StringBuilder builder = new StringBuilder();
- builder.append(makeGithubRepoUrlFromRemoteUrl(githubRemoteUrl)).append("/blob/").append(branch).append(relativePath);
+ final String githubRepoUrl = GithubUrlUtil.makeGithubRepoUrlFromRemoteUrl(githubRemoteUrl);
+ if (githubRepoUrl == null) {
+ return null;
+ }
+ builder.append(githubRepoUrl).append("/blob/").append(branch).append(relativePath);
+
final Editor editor = e.getData(PlatformDataKeys.EDITOR);
if (editor != null && editor.getDocument().getLineCount() >= 1) {
- final int line = editor.getCaretModel().getLogicalPosition().line + 1; // lines are counted internally from 0, but from 1 on github
- builder.append("#L").append(line);
+ // lines are counted internally from 0, but from 1 on github
+ SelectionModel selectionModel = editor.getSelectionModel();
+ final int begin = editor.getDocument().getLineNumber(selectionModel.getSelectionStart()) + 1;
+ final int selectionEnd = selectionModel.getSelectionEnd();
+ int end = editor.getDocument().getLineNumber(selectionEnd) + 1;
+ if (editor.getDocument().getLineStartOffset(end - 1) == selectionEnd) {
+ end -= 1;
+ }
+ builder.append("#L").append(begin).append('-').append(end);
}
+
return builder.toString();
}
@@ -163,4 +178,8 @@
return tracked.getNameForRemoteOperations();
}
-}
+ private static void notifyError(@NotNull Project project, @NotNull String message, @Nullable String logDetails) {
+ Notificator.getInstance(project).notifyError(CANNOT_OPEN_IN_BROWSER, message);
+ LOG.info(message + (logDetails == null ? "" : " " + logDetails));
+ }
+}
\ No newline at end of file
diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubRebaseAction.java b/plugins/github/src/org/jetbrains/plugins/github/GithubRebaseAction.java
index 18679e1..479431b 100644
--- a/plugins/github/src/org/jetbrains/plugins/github/GithubRebaseAction.java
+++ b/plugins/github/src/org/jetbrains/plugins/github/GithubRebaseAction.java
@@ -15,36 +15,38 @@
*/
package org.jetbrains.plugins.github;
-import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
+import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProgressIndicator;
-import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.ui.Messages;
-import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.util.ui.UIUtil;
+import com.intellij.util.ThrowableConvertor;
+import git4idea.GitPlatformFacade;
import git4idea.GitUtil;
import git4idea.actions.BasicAction;
-import git4idea.commands.GitCommand;
-import git4idea.commands.GitSimpleHandler;
-import git4idea.repo.GitRemote;
+import git4idea.commands.*;
+import git4idea.rebase.GitRebaseProblemDetector;
+import git4idea.rebase.GitRebaser;
import git4idea.repo.GitRepository;
import git4idea.repo.GitRepositoryManager;
import git4idea.update.GitFetchResult;
import git4idea.update.GitFetcher;
+import git4idea.update.GitUpdateResult;
+import git4idea.util.GitPreservingProcess;
import icons.GithubIcons;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.plugins.github.ui.GithubLoginDialog;
+import org.jetbrains.annotations.Nullable;
import java.io.IOException;
-import java.util.concurrent.atomic.AtomicReference;
+import java.util.Collections;
+
+import static org.jetbrains.plugins.github.GithubUtil.setVisibleEnabled;
/**
* Created by IntelliJ IDEA.
@@ -54,7 +56,7 @@
*/
public class GithubRebaseAction extends DumbAwareAction {
private static final Logger LOG = Logger.getInstance(GithubRebaseAction.class.getName());
- private static final String CANNOT_PERFORM_GITHUB_REBASE = "Cannot perform github rebase";
+ private static final String CANNOT_PERFORM_GITHUB_REBASE = "Can't perform github rebase";
public GithubRebaseAction() {
super("Rebase my GitHub fork", "Rebase your GitHub forked repository relative to the origin", GithubIcons.Github_icon);
@@ -62,173 +64,190 @@
public void update(AnActionEvent e) {
final Project project = e.getData(PlatformDataKeys.PROJECT);
- if (StringUtil.isEmptyOrSpaces(GithubSettings.getInstance().getLogin()) ||
- project == null || project.isDefault()) {
- e.getPresentation().setEnabled(false);
- e.getPresentation().setVisible(false);
+ final VirtualFile root = e.getData(PlatformDataKeys.VIRTUAL_FILE);
+ if (root == null || project == null || project.isDefault()) {
+ setVisibleEnabled(e, false, false);
return;
}
- GitRepositoryManager manager = GitUtil.getRepositoryManager(project);
- if (manager == null) {
- e.getPresentation().setVisible(false);
- e.getPresentation().setEnabled(false);
+ if (StringUtil.isEmptyOrSpaces(GithubSettings.getInstance().getLogin())) {
+ setVisibleEnabled(e, false, false);
return;
}
- final GitRepository gitRepository = manager.getRepositoryForFile(project.getBaseDir());
+ final GitRepositoryManager manager = GitUtil.getRepositoryManager(project);
+ final GitRepository gitRepository = manager.getRepositoryForFile(root);
if (gitRepository == null){
- e.getPresentation().setVisible(false);
- e.getPresentation().setEnabled(false);
+ setVisibleEnabled(e, false, false);
return;
}
- // Check that given repository is properly configured git repository
- final GitRemote gitHubRemoteBranch = GithubUtil.findGitHubRemoteBranch(gitRepository);
- if (gitHubRemoteBranch == null) {
- e.getPresentation().setVisible(false);
- e.getPresentation().setEnabled(false);
+ if (!GithubUtil.isRepositoryOnGitHub(gitRepository)) {
+ setVisibleEnabled(e, false, false);
return;
}
- e.getPresentation().setVisible(true);
- e.getPresentation().setEnabled(true);
+ setVisibleEnabled(e, true, true);
}
- @SuppressWarnings("ConstantConditions")
@Override
public void actionPerformed(final AnActionEvent e) {
final Project project = e.getData(PlatformDataKeys.PROJECT);
- while (!GithubUtil.checkCredentials(project)) {
- final GithubLoginDialog dialog = new GithubLoginDialog(project);
- dialog.show();
- if (!dialog.isOK()){
- return;
+ final VirtualFile root = e.getData(PlatformDataKeys.VIRTUAL_FILE);
+
+ if (root == null || project == null || project.isDisposed() || !GithubUtil.testGitExecutable(project)) {
+ return;
+ }
+
+ rebaseMyGithubFork(project, root);
+ }
+
+ private static void rebaseMyGithubFork(@NotNull final Project project, @NotNull final VirtualFile root) {
+ final GitRepositoryManager manager = GitUtil.getRepositoryManager(project);
+ final GitRepository gitRepository = manager.getRepositoryForFile(root);
+ if (gitRepository == null) {
+ GithubNotifications.showError(project, CANNOT_PERFORM_GITHUB_REBASE, "Can't find git repository");
+ return;
+ }
+
+ BasicAction.saveAll();
+
+ new Task.Backgroundable(project, "Rebasing GitHub fork...") {
+ @Override
+ public void run(@NotNull ProgressIndicator indicator) {
+ String upstreamRemoteUrl = GithubUtil.findGithubUpstreamRemote(gitRepository);
+
+ if (upstreamRemoteUrl == null) {
+ LOG.info("Configuring upstream remote");
+ indicator.setText("Configuring upstream remote...");
+ upstreamRemoteUrl = configureUpstreamRemote(project, root, gitRepository, indicator);
+ if (upstreamRemoteUrl == null) {
+ return;
+ }
+ }
+
+ if (!GithubUrlUtil.isGithubUrl(upstreamRemoteUrl)) {
+ GithubNotifications
+ .showError(project, CANNOT_PERFORM_GITHUB_REBASE, "Configured upstream is not a GitHub repository: " + upstreamRemoteUrl);
+ return;
+ }
+ else {
+ final GithubUserAndRepository userAndRepo = GithubUrlUtil.getUserAndRepositoryFromRemoteUrl(upstreamRemoteUrl);
+ final String login = GithubSettings.getInstance().getLogin();
+ if (userAndRepo != null) {
+ if (userAndRepo.getUserName() == login) {
+ GithubNotifications.showError(project, CANNOT_PERFORM_GITHUB_REBASE,
+ "Configured upstream seems to be your own repository: " + upstreamRemoteUrl);
+ return;
+ }
+ }
+ }
+
+ LOG.info("Fetching upstream");
+ indicator.setText("Fetching upstream...");
+ if (!fetchParent(project, gitRepository, indicator)) {
+ return;
+ }
+
+ LOG.info("Rebasing current branch");
+ indicator.setText("Rebasing current branch...");
+ rebaseCurrentBranch(project, root, gitRepository, indicator);
}
+ }.queue();
+ }
+
+ @Nullable
+ static String configureUpstreamRemote(@NotNull Project project,
+ @NotNull VirtualFile root,
+ @NotNull GitRepository gitRepository,
+ @NotNull ProgressIndicator indicator) {
+ RepositoryInfo repositoryInfo = loadRepositoryInfo(project, gitRepository, indicator);
+ if (repositoryInfo == null) {
+ return null;
}
- final VirtualFile root = project.getBaseDir();
- GitRepositoryManager manager = GitUtil.getRepositoryManager(project);
- if (manager == null) {
- LOG.info("No GitRepositoryManager instance available. Action cancelled.");
- return;
+ if (!repositoryInfo.isFork()) {
+ GithubNotifications.showWarningURL(project, CANNOT_PERFORM_GITHUB_REBASE, "GitHub repository ", "'" + repositoryInfo.getName() + "'",
+ " is not a forked one", repositoryInfo.getBrowserUrl());
+ return null;
}
- final GitRepository gitRepository = manager.getRepositoryForFile(project.getBaseDir());
- // Check that given repository is properly configured git repository
- final GitRemote remote = GithubUtil.findGitHubRemoteBranch(gitRepository);
- final String pushUrl = GithubUtil.getGithubUrl(remote);
- final String login = GithubSettings.getInstance().getLogin();
- final int index = pushUrl.lastIndexOf(login);
- if (index == -1) {
- Messages.showErrorDialog(project, "Github remote repository doesn't seem to be your own repository: " + pushUrl,
- CANNOT_PERFORM_GITHUB_REBASE);
- return;
+ final String parentRepoUrl = GithubUrlUtil.getGitHost() + '/' + repositoryInfo.getParentName() + ".git";
+
+ LOG.info("Adding GitHub parent as a remote host");
+ indicator.setText("Adding GitHub parent as a remote host...");
+ return addParentAsUpstreamRemote(project, root, parentRepoUrl, gitRepository);
+ }
+
+ @Nullable
+ private static RepositoryInfo loadRepositoryInfo(@NotNull Project project,
+ @NotNull GitRepository gitRepository,
+ @NotNull ProgressIndicator indicator) {
+ final String remoteUrl = GithubUtil.findGithubRemoteUrl(gitRepository);
+ if (remoteUrl == null) {
+ GithubNotifications.showError(project, CANNOT_PERFORM_GITHUB_REBASE, "Can't find github remote");
+ return null;
}
- String repoName = pushUrl.substring(index + login.length() + 1);
- if (repoName.endsWith(".git")) {
- repoName = repoName.substring(0, repoName.length() - 4);
+ final GithubUserAndRepository userAndRepo = GithubUrlUtil.getUserAndRepositoryFromRemoteUrl(remoteUrl);
+ if (userAndRepo == null) {
+ GithubNotifications.showError(project, CANNOT_PERFORM_GITHUB_REBASE, "Can't process remote: " + remoteUrl);
+ return null;
}
RepositoryInfo repositoryInfo;
try {
- repositoryInfo = GithubUtil.getDetailedRepositoryInfo(project, login, repoName);
+ repositoryInfo =
+ GithubUtil.runWithValidAuth(project, indicator, new ThrowableConvertor<GithubAuthData, RepositoryInfo, IOException>() {
+ @Override
+ @Nullable
+ public RepositoryInfo convert(GithubAuthData authData) throws IOException {
+ return GithubUtil.getDetailedRepoInfo(authData, userAndRepo.getUserName(), userAndRepo.getRepositoryName());
+ }
+ });
}
- catch (IOException ex) {
- LOG.info(ex);
- GithubUtil.notifyError(project, "Couldn't get information about the repository", GithubUtil.getErrorTextFromException(ex));
- return;
+ catch (IOException e) {
+ GithubNotifications.showError(project, CANNOT_PERFORM_GITHUB_REBASE, "Can't load repository info: " + e.getMessage());
+ return null;
}
if (repositoryInfo == null) {
- Messages
- .showErrorDialog(project, "Github repository doesn't seem to be your own repository: " + pushUrl, CANNOT_PERFORM_GITHUB_REBASE);
- return;
+ GithubNotifications.showError(project, CANNOT_PERFORM_GITHUB_REBASE, "Can't load repository info");
+ return null;
}
- if (!repositoryInfo.isFork()) {
- Messages.showErrorDialog(project, "Github repository '" + repoName + "' is not a forked one", CANNOT_PERFORM_GITHUB_REBASE);
- return;
- }
-
- final String parent = repositoryInfo.getParentName();
- LOG.assertTrue(parent != null, "Parent repository not found!");
- final String parentDotGit = parent + ".git";
- final String parentRepoUrl = GithubApiUtil.getGitHost() + "/" + parentDotGit;
-
- // Check that corresponding remote branch is configured for the fork origin repo
- final Ref<String> remoteForForkParentRepo = new Ref<String>();
- out: for (GitRemote gitRemote : gitRepository.getRemotes()) {
- for (String url : gitRemote.getUrls()) {
- if (isParentUrl(url, parentDotGit)) {
- remoteForForkParentRepo.set(gitRemote.getName());
- break out;
- }
- }
- }
- if (remoteForForkParentRepo.isNull()){
- final int result = Messages.showYesNoDialog(project, "It is necessary to have '" +
- parentRepoUrl +
- "' as a configured remote. Add remote?", "Github Rebase",
- Messages.getQuestionIcon());
- if (result != Messages.OK){
- return;
- }
-
- GithubUtil.accessToGithubWithModalProgress(project, new Runnable() {
- public void run() {
- try {
- LOG.info("Adding GitHub parent as a remote host");
- ProgressManager.getInstance().getProgressIndicator().setText("Adding GitHub parent as a remote host");
- final GitSimpleHandler addRemoteHandler = new GitSimpleHandler(project, root, GitCommand.REMOTE);
- addRemoteHandler.setSilent(true);
-
- remoteForForkParentRepo.set("upstream");
- addRemoteHandler.addParameters("add", remoteForForkParentRepo.get(), parentRepoUrl);
- addRemoteHandler.run();
- if (addRemoteHandler.getExitCode() != 0) {
- showErrorMessageInEDT(project, "Failed to add GitHub remote: '" + parentRepoUrl + "'");
- }
-
- // catch newly added remote
- gitRepository.update();
- }
- catch (VcsException e1) {
- final String message = "Error happened during git operation: " + e1.getMessage();
- showErrorMessageInEDT(project, message);
- }
- }
- });
- }
-
- boolean fetchedSuccessfully = fetchParentOrNotifyError(project, gitRepository, remoteForForkParentRepo.get());
- if (!fetchedSuccessfully) {
- return;
- }
- BasicAction.saveAll();
- final GithubRebase action = (GithubRebase) ActionManager.getInstance().getAction("Github.Rebase.Internal");
- action.setRebaseOrigin(remoteForForkParentRepo.get());
- final AnActionEvent actionEvent =
- new AnActionEvent(e.getInputEvent(), e.getDataContext(), e.getPlace(), e.getPresentation(), e.getActionManager(), e.getModifiers());
- action.actionPerformed(actionEvent);
+ return repositoryInfo;
}
- private static boolean isParentUrl(@NotNull String url, @NotNull String parentDotGit) {
- // the separator is checked because we may have a repository which ends with "parentDotGit", but is not a parent,
- // e.g. "my_other_repository_parent.git"
- return url.endsWith("/" + parentDotGit) // http or git
- || url.endsWith(":" + parentDotGit); // ssh
+ @Nullable
+ private static String addParentAsUpstreamRemote(@NotNull Project project,
+ @NotNull VirtualFile root,
+ @NotNull String parentRepoUrl,
+ @NotNull GitRepository gitRepository) {
+ final GitSimpleHandler handler = new GitSimpleHandler(project, root, GitCommand.REMOTE);
+ handler.setSilent(true);
+
+ try {
+ handler.addParameters("add", "upstream", parentRepoUrl);
+ handler.run();
+ if (handler.getExitCode() != 0) {
+ GithubNotifications
+ .showError(project, CANNOT_PERFORM_GITHUB_REBASE, "Failed to add GitHub remote: '" + parentRepoUrl + "'. " + handler.getStderr());
+ return null;
+ }
+ // catch newly added remote
+ gitRepository.update();
+
+ return parentRepoUrl;
+ }
+ catch (VcsException e) {
+ GithubNotifications.showError(project, CANNOT_PERFORM_GITHUB_REBASE, e);
+ return null;
+ }
}
- private static boolean fetchParentOrNotifyError(@NotNull final Project project, @NotNull final GitRepository repository,
- @NotNull final String remote) {
- final AtomicReference<GitFetchResult> fetchResult = new AtomicReference<GitFetchResult>();
- ProgressManager.getInstance().run(new Task.Modal(project, "Fetching " + remote, false) {
- @Override
- public void run(@NotNull ProgressIndicator indicator) {
- fetchResult.set(new GitFetcher(project, indicator, false).fetch(repository.getRoot(), remote));
- }
- });
- GitFetchResult result = fetchResult.get();
+ private static boolean fetchParent(@NotNull final Project project,
+ @NotNull final GitRepository repository,
+ @NotNull final ProgressIndicator indicator) {
+ GitFetchResult result = new GitFetcher(project, indicator, false).fetch(repository.getRoot(), "upstream");
if (!result.isSuccess()) {
GitFetcher.displayFetchResult(project, result, null, result.getErrors());
return false;
@@ -236,11 +255,60 @@
return true;
}
- private void showErrorMessageInEDT(final Project project, final String message) {
- UIUtil.invokeLaterIfNeeded(new Runnable(){
+ private static void rebaseCurrentBranch(@NotNull final Project project,
+ @NotNull final VirtualFile root,
+ @NotNull final GitRepository gitRepository,
+ @NotNull final ProgressIndicator indicator) {
+ final Git git = ServiceManager.getService(project, Git.class);
+ final GitPlatformFacade facade = ServiceManager.getService(project, GitPlatformFacade.class);
+ GitPreservingProcess process =
+ new GitPreservingProcess(project, facade, git, Collections.singletonList(gitRepository), "Rebasing", "upstream/master", indicator,
+ new Runnable() {
+ @Override
+ public void run() {
+ doRebaseCurrentBranch(project, root, indicator);
+ }
+ });
+ process.execute();
+ }
+
+ private static void doRebaseCurrentBranch(@NotNull final Project project,
+ @NotNull final VirtualFile root,
+ @NotNull final ProgressIndicator indicator) {
+ final GitRepositoryManager repositoryManager = GitUtil.getRepositoryManager(project);
+
+ final GitRebaser rebaser = new GitRebaser(project, ServiceManager.getService(Git.class), indicator);
+
+ final GitLineHandler handler = new GitLineHandler(project, root, GitCommand.REBASE);
+ handler.addParameters("upstream/master");
+
+ final GitRebaseProblemDetector rebaseConflictDetector = new GitRebaseProblemDetector();
+ handler.addLineListener(rebaseConflictDetector);
+
+ final GitUntrackedFilesOverwrittenByOperationDetector untrackedFilesDetector =
+ new GitUntrackedFilesOverwrittenByOperationDetector(root);
+ handler.addLineListener(untrackedFilesDetector);
+
+ GitTask pullTask = new GitTask(project, handler, "Rebasing from upstream/master");
+ pullTask.setProgressIndicator(indicator);
+ pullTask.setProgressAnalyzer(new GitStandardProgressAnalyzer());
+ pullTask.execute(true, false, new GitTaskResultHandlerAdapter() {
@Override
- public void run() {
- Messages.showErrorDialog(project, message, CANNOT_PERFORM_GITHUB_REBASE);
+ protected void onSuccess() {
+ root.refresh(false, true);
+ repositoryManager.updateRepository(root);
+ GithubNotifications.showInfo(project, "Success", "Successfully rebased GitHub fork");
+ }
+
+ @Override
+ protected void onFailure() {
+ GitUpdateResult result = rebaser.handleRebaseFailure(handler, root, rebaseConflictDetector, untrackedFilesDetector);
+ repositoryManager.updateRepository(root);
+ if (result == GitUpdateResult.NOTHING_TO_UPDATE ||
+ result == GitUpdateResult.SUCCESS ||
+ result == GitUpdateResult.SUCCESS_WITH_RESOLVED_CONFLICTS) {
+ GithubNotifications.showInfo(project, "Success", "Successfully rebased GitHub fork");
+ }
}
});
}
diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubSettings.java b/plugins/github/src/org/jetbrains/plugins/github/GithubSettings.java
index 541ad07..279d48a 100644
--- a/plugins/github/src/org/jetbrains/plugins/github/GithubSettings.java
+++ b/plugins/github/src/org/jetbrains/plugins/github/GithubSettings.java
@@ -15,17 +15,17 @@
*/
package org.jetbrains.plugins.github;
-import com.intellij.ide.passwordSafe.MasterPasswordUnavailableException;
import com.intellij.ide.passwordSafe.PasswordSafe;
import com.intellij.ide.passwordSafe.PasswordSafeException;
+import com.intellij.ide.passwordSafe.config.PasswordSafeConfigurable;
+import com.intellij.ide.passwordSafe.config.PasswordSafeSettings;
import com.intellij.ide.passwordSafe.impl.PasswordSafeImpl;
-import com.intellij.ide.passwordSafe.impl.providers.masterKey.MasterKeyPasswordSafe;
+import com.intellij.ide.passwordSafe.impl.providers.memory.MemoryPasswordSafe;
import com.intellij.openapi.components.*;
import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
-import com.intellij.openapi.ui.Messages;
+import com.intellij.openapi.util.text.StringUtil;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
@@ -47,7 +47,7 @@
private static final String GITHUB_SETTINGS_TAG = "GithubSettings";
private static final String LOGIN = "Login";
private static final String HOST = "Host";
- private static final String ANONIMOUS_GIST = "Anonymous";
+ private static final String ANONYMOUS_GIST = "Anonymous";
private static final String OPEN_IN_BROWSER_GIST = "OpenInBrowser";
private static final String PRIVATE_GIST = "Private";
public static final String GITHUB_SETTINGS_PASSWORD_KEY = "GITHUB_SETTINGS_PASSWORD_KEY";
@@ -60,40 +60,19 @@
private boolean myAnonymousGist;
private boolean myOpenInBrowserGist = true;
private boolean myPrivateGist;
- private Collection<String> myTrustedHosts = new ArrayList<String>();
+ private final Collection<String> myTrustedHosts = new ArrayList<String>();
private static final Logger LOG = Logger.getInstance(GithubSettings.class.getName());
- private boolean passwordChanged = false;
-
- // Once master password is refused, do not ask for it again
- private boolean masterPasswordRefused = false;
-
public static GithubSettings getInstance(){
return ServiceManager.getService(GithubSettings.class);
}
public Element getState() {
- LOG.assertTrue(!ProgressManager.getInstance().hasProgressIndicator(), "Password should not be accessed under modal progress");
-
- try {
- if (passwordChanged && !masterPasswordRefused) {
- PasswordSafe.getInstance().storePassword(null, GithubSettings.class, GITHUB_SETTINGS_PASSWORD_KEY, getPassword());
- }
- }
- catch (MasterPasswordUnavailableException e){
- LOG.info("Couldn't store password for key [" + GITHUB_SETTINGS_PASSWORD_KEY + "]", e);
- masterPasswordRefused = true;
- }
- catch (Exception e) {
- Messages.showErrorDialog("Error happened while storing password for github", "Error");
- LOG.info("Couldn't get password for key [" + GITHUB_SETTINGS_PASSWORD_KEY + "]", e);
- }
- passwordChanged = false;
final Element element = new Element(GITHUB_SETTINGS_TAG);
element.setAttribute(LOGIN, getLogin());
element.setAttribute(HOST, getHost());
- element.setAttribute(ANONIMOUS_GIST, String.valueOf(isAnonymous()));
+ element.setAttribute(ANONYMOUS_GIST, String.valueOf(isAnonymous()));
element.setAttribute(PRIVATE_GIST, String.valueOf(isPrivateGist()));
element.setAttribute(OPEN_IN_BROWSER_GIST, String.valueOf(isOpenInBrowserGist()));
Element trustedHosts = new Element(TRUSTED_HOSTS);
@@ -111,7 +90,7 @@
try {
setLogin(element.getAttributeValue(LOGIN));
setHost(element.getAttributeValue(HOST));
- setAnonymousGist(Boolean.valueOf(element.getAttributeValue(ANONIMOUS_GIST)));
+ setAnonymousGist(Boolean.valueOf(element.getAttributeValue(ANONYMOUS_GIST)));
setPrivateGist(Boolean.valueOf(element.getAttributeValue(PRIVATE_GIST)));
setOpenInBrowserGist(Boolean.valueOf(element.getAttributeValue(OPEN_IN_BROWSER_GIST)));
for (Object trustedHost : element.getChildren(TRUSTED_HOSTS)) {
@@ -126,40 +105,27 @@
// TODO return null if no login instead of empty string
@NotNull
public String getLogin() {
- return myLogin != null ? myLogin : "";
+ return StringUtil.notNullize(myLogin);
}
@NotNull
public String getPassword() {
- LOG.assertTrue(!ProgressManager.getInstance().hasProgressIndicator(), "Password should not be accessed under modal progress");
String password;
final Project project = ProjectManager.getInstance().getDefaultProject();
- final PasswordSafeImpl passwordSafe = (PasswordSafeImpl)PasswordSafe.getInstance();
+ final PasswordSafe passwordSafe = PasswordSafe.getInstance();
try {
- password = passwordSafe.getMemoryProvider().getPassword(project, GithubSettings.class, GITHUB_SETTINGS_PASSWORD_KEY);
- if (password != null) {
- return password;
- }
- final MasterKeyPasswordSafe masterKeyProvider = passwordSafe.getMasterKeyProvider();
- if (!masterKeyProvider.isEmpty()) {
- // workaround for: don't ask for master password, if the requested password is not there.
- // this should be fixed in PasswordSafe: don't ask master password to look for keys
- // until then we assume that is PasswordSafe was used (there is anything there), then it makes sense to look there.
- password = masterKeyProvider.getPassword(project, GithubSettings.class, GITHUB_SETTINGS_PASSWORD_KEY);
- }
+ password = passwordSafe.getPassword(project, GithubSettings.class, GITHUB_SETTINGS_PASSWORD_KEY);
}
catch (PasswordSafeException e) {
LOG.info("Couldn't get password for key [" + GITHUB_SETTINGS_PASSWORD_KEY + "]", e);
- masterPasswordRefused = true;
password = "";
}
- passwordChanged = false;
- return password != null ? password : "";
+ return StringUtil.notNullize(password);
}
public String getHost() {
- return myHost != null ? myHost : GithubApiUtil.DEFAULT_GITHUB_HOST;
+ return StringUtil.notNullize(myHost, GithubApiUtil.DEFAULT_GITHUB_HOST);
}
public boolean isAnonymous() {
@@ -175,21 +141,33 @@
}
public void setLogin(final String login) {
- myLogin = login != null ? login : "";
+ myLogin = StringUtil.notNullize(login);
}
public void setPassword(final String password) {
- passwordChanged = !getPassword().equals(password);
+ setPassword(password, true);
+ }
+
+ public void setPassword(final String password, final boolean rememberPassword) {
try {
- PasswordSafe.getInstance().storePassword(null, GithubSettings.class, GITHUB_SETTINGS_PASSWORD_KEY, password != null ? password : "");
+ if (rememberPassword) {
+ PasswordSafe.getInstance().storePassword(null, GithubSettings.class, GITHUB_SETTINGS_PASSWORD_KEY, StringUtil.notNullize(password));
+ }
+ else {
+ final PasswordSafeImpl passwordSafe = (PasswordSafeImpl)PasswordSafe.getInstance();
+ if (passwordSafe.getSettings().getProviderType() != PasswordSafeSettings.ProviderType.DO_NOT_STORE) {
+ passwordSafe.getMemoryProvider()
+ .storePassword(null, GithubSettings.class, GITHUB_SETTINGS_PASSWORD_KEY, StringUtil.notNullize(password));
+ }
+ }
}
catch (PasswordSafeException e) {
- LOG.info("Couldn't get password for key [" + GITHUB_SETTINGS_PASSWORD_KEY + "]", e);
+ LOG.info("Couldn't set password for key [" + GITHUB_SETTINGS_PASSWORD_KEY + "]", e);
}
}
public void setHost(final String host) {
- myHost = host != null ? host : GithubApiUtil.DEFAULT_GITHUB_HOST;
+ myHost = StringUtil.notNullize(host, GithubApiUtil.DEFAULT_GITHUB_HOST);
}
public void setAnonymousGist(final boolean anonymousGist) {
@@ -214,4 +192,15 @@
myTrustedHosts.add(host);
}
}
+
+ public void setAuthData(@NotNull GithubAuthData auth, boolean rememberPassword) {
+ setHost(auth.getHost());
+ setLogin(auth.getLogin());
+ setPassword(auth.getPassword(), rememberPassword);
+ }
+
+ @NotNull
+ public GithubAuthData getAuthData() {
+ return new GithubAuthData(getHost(), getLogin(), getPassword());
+ }
}
\ No newline at end of file
diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java b/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java
index 01ee9cc..32f421c 100644
--- a/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java
+++ b/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java
@@ -17,12 +17,8 @@
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
-import com.intellij.notification.Notification;
-import com.intellij.notification.NotificationType;
-import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.openapi.actionSystem.PlatformDataKeys;
+import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.application.ex.ApplicationInfoEx;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProgressIndicator;
@@ -30,22 +26,18 @@
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.ui.Messages;
-import com.intellij.openapi.util.Computable;
+import com.intellij.openapi.ui.Splitter;
import com.intellij.openapi.util.Ref;
-import com.intellij.openapi.util.ThrowableComputable;
+import com.intellij.openapi.vcs.VcsDataKeys;
import com.intellij.openapi.vcs.VcsException;
-import com.intellij.openapi.vcs.changes.ChangeListManager;
-import com.intellij.openapi.vcs.changes.ChangeListManagerImpl;
-import com.intellij.openapi.vcs.changes.InvokeAfterUpdateMode;
-import com.intellij.openapi.vfs.VfsUtil;
+import com.intellij.openapi.vcs.changes.ui.SelectFilesDialog;
+import com.intellij.openapi.vcs.ui.CommitMessage;
import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.util.concurrency.Semaphore;
+import com.intellij.util.ThrowableConsumer;
import com.intellij.util.containers.HashSet;
-import git4idea.GitDeprecatedRemote;
+import git4idea.DialogManager;
+import git4idea.GitLocalBranch;
import git4idea.GitUtil;
-import git4idea.GitVcs;
-import git4idea.Notificator;
import git4idea.actions.BasicAction;
import git4idea.actions.GitInit;
import git4idea.commands.*;
@@ -56,12 +48,18 @@
import git4idea.util.GitUIUtil;
import icons.GithubIcons;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.github.ui.GithubShareDialog;
+import javax.swing.*;
+import java.awt.*;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
+import static org.jetbrains.plugins.github.GithubUtil.setVisibleEnabled;
+
/**
* @author oleg
*/
@@ -74,101 +72,202 @@
public void update(AnActionEvent e) {
final Project project = e.getData(PlatformDataKeys.PROJECT);
- if (project == null || project.isDefault()){
- e.getPresentation().setEnabled(false);
- e.getPresentation().setVisible(false);
+ if (project == null || project.isDefault()) {
+ setVisibleEnabled(e, false, false);
return;
}
- e.getPresentation().setVisible(true);
- e.getPresentation().setEnabled(true);
+ setVisibleEnabled(e, true, true);
}
+ // get gitRepository
+ // check for existing git repo
+ // check available repos and privateRepo access (net)
+ // Show dialog (window)
+ // create GitHub repo (net)
+ // create local git repo (if not exist)
+ // add GitHub as a remote host
+ // make first commit
+ // push everything (net)
@Override
public void actionPerformed(final AnActionEvent e) {
final Project project = e.getData(PlatformDataKeys.PROJECT);
- if (project == null || !GithubUtil.testGitExecutable(project)){
+ final VirtualFile root = e.getData(PlatformDataKeys.VIRTUAL_FILE);
+
+ if (root == null || project == null || project.isDisposed()) {
return;
}
- final VirtualFile root = project.getBaseDir();
- // Check if git is already initialized and presence of remote branch
- final boolean gitDetected = GitUtil.isUnderGit(root);
- if (gitDetected) {
- try {
- final List<GitDeprecatedRemote> gitRemotes = GitDeprecatedRemote.list(project, root);
- if (!gitRemotes.isEmpty()) {
- Messages.showErrorDialog(project, "Project is already under git with configured remote", "Cannot create new GitHub repository");
- return;
- }
- }
- catch (VcsException e2) {
- Messages.showErrorDialog(project, "Error happened during git operation: " + e2.getMessage(), "Cannot create new GitHub repository");
- return;
- }
- }
- BasicAction.saveAll();
- try {
- final List<RepositoryInfo> availableRepos = GithubUtil.getAvailableRepos(project);
- if (availableRepos == null){
- return;
- }
- final HashSet<String> names = new HashSet<String>();
- for (RepositoryInfo info : availableRepos) {
- names.add(info.getName());
- }
-
- final GithubSettings settings = GithubSettings.getInstance();
- final String password = settings.getPassword();
- final Boolean privateRepoAllowed =
- GithubUtil.accessToGithubWithModalProgress(project, settings.getHost(), new ThrowableComputable<Boolean, IOException>() {
- @Override
- public Boolean compute() throws IOException {
- ProgressManager.getInstance().getProgressIndicator().setText("Trying to login to GitHub");
- return GithubUtil.isPrivateRepoAllowed(settings.getHost(), settings.getLogin(), password);
- }
- });
- if (privateRepoAllowed == null) {
- return;
- }
- final GithubShareDialog shareDialog = new GithubShareDialog(project, names, privateRepoAllowed);
- shareDialog.show();
- if (!shareDialog.isOK()) {
- return;
- }
-
- final boolean isPrivate = shareDialog.isPrivate();
- final String name = shareDialog.getRepositoryName();
- final String description = shareDialog.getDescription();
- LOG.info("Creating GitHub repository");
- boolean repositoryCreated =
- createGithubRepository(settings.getHost(), settings.getLogin(), settings.getPassword(), name, description, isPrivate);
- if (repositoryCreated) {
- LOG.info("Successfully created GitHub repository");
- }
- else {
- Messages.showErrorDialog(project, "Failed to create new GitHub repository", "Create GitHub Repository");
- return;
- }
- bindToGithub(project, root, gitDetected, settings.getLogin(), name);
- }
- catch (final Exception e1) {
- Messages.showErrorDialog(e1.getMessage(), "Failed to create new GitHub repository");
- }
+ shareProjectOnGithub(project, root);
}
- private static boolean createGithubRepository(@NotNull String host, @NotNull String login, @NotNull String password, @NotNull String name,
- @NotNull String description, boolean aPrivate) throws IOException {
+ public static void shareProjectOnGithub(@NotNull final Project project, @NotNull final VirtualFile root) {
+ BasicAction.saveAll();
+
+ // get gitRepository
+ final GitRepositoryManager manager = GitUtil.getRepositoryManager(project);
+ final GitRepository gitRepository = manager.getRepositoryForFile(root);
+ final boolean gitDetected = gitRepository != null;
+
+ // check for existing git repo
+ boolean externalRemoteDetected = false;
+ if (gitDetected) {
+ final String githubRemote = GithubUtil.findGithubRemoteUrl(gitRepository);
+ if (githubRemote != null) {
+ GithubNotifications.showInfoURL(project, "Project is already on GitHub", "GitHub", githubRemote);
+ return;
+ }
+ externalRemoteDetected = !gitRepository.getRemotes().isEmpty();
+ }
+
+ // get available GitHub repos with modal progress
+ final GithubInfo githubInfo = loadGithubInfoWithModal(project);
+ if (githubInfo == null) {
+ return;
+ }
+
+ // Show dialog (window)
+ final GithubShareDialog shareDialog =
+ new GithubShareDialog(project, githubInfo.getRepositoryNames(), githubInfo.getUser().canCreatePrivateRepo());
+ DialogManager.show(shareDialog);
+ if (!shareDialog.isOK()) {
+ return;
+ }
+ final boolean isPrivate = shareDialog.isPrivate();
+ final String name = shareDialog.getRepositoryName();
+ final String description = shareDialog.getDescription();
+
+ // finish the job in background
+ final boolean finalExternalRemoteDetected = externalRemoteDetected;
+ new Task.Backgroundable(project, "Sharing project on GitHub...") {
+ @Override
+ public void run(@NotNull ProgressIndicator indicator) {
+ // create GitHub repo (network)
+ LOG.info("Creating GitHub repository");
+ indicator.setText("Creating GitHub repository...");
+ final String url = createGithubRepository(project, githubInfo.getAuthData(), name, description, isPrivate);
+ if (url == null) {
+ return;
+ }
+ LOG.info("Successfully created GitHub repository");
+
+ // creating empty git repo if git is not initialized
+ LOG.info("Binding local project with GitHub");
+ if (!gitDetected) {
+ LOG.info("No git detected, creating empty git repo");
+ indicator.setText("Creating empty git repo...");
+ if (!createEmptyGitRepository(project, root, indicator)) {
+ return;
+ }
+ }
+
+ GitRepositoryManager repositoryManager = ServiceManager.getService(project, GitRepositoryManager.class);
+ final GitRepository repository = repositoryManager.getRepositoryForRoot(root);
+ LOG.assertTrue(repository != null, "GitRepository is null for root " + root);
+
+ final String remoteUrl = GithubUrlUtil.getGitHost() + "/" + githubInfo.getUser().getLogin() + "/" + name + ".git";
+ final String remoteName = finalExternalRemoteDetected ? "github" : "origin";
+
+ //git remote add origin git@github.com:login/name.git
+ LOG.info("Adding GitHub as a remote host");
+ indicator.setText("Adding GitHub as a remote host...");
+ if (!addGithubRemote(project, root, remoteName, remoteUrl, repository)) {
+ return;
+ }
+
+ // create sample commit for binding project
+ if (!performFirstCommitIfRequired(project, root, repository, indicator, name, url)) {
+ return;
+ }
+
+ //git push origin master
+ LOG.info("Pushing to github master");
+ indicator.setText("Pushing to github master...");
+ if (!pushCurrentBranch(project, repository, remoteName, remoteUrl, name, url)) {
+ return;
+ }
+
+ GithubNotifications.showInfoURL(project, "Successfully created project on GitHub", name, url);
+ }
+ }.queue();
+ }
+
+ @Nullable
+ private static GithubInfo loadGithubInfoWithModal(@NotNull final Project project) {
+ final Ref<GithubInfo> githubInfoRef = new Ref<GithubInfo>();
+ final Ref<IOException> exceptionRef = new Ref<IOException>();
+ ProgressManager.getInstance().run(new Task.Modal(project, "Access to GitHub", true) {
+ public void run(@NotNull ProgressIndicator indicator) {
+ try {
+ // get existing github repos (network) and validate auth data
+ final Ref<List<RepositoryInfo>> availableReposRef = new Ref<List<RepositoryInfo>>();
+ final GithubAuthData auth =
+ GithubUtil.runAndGetValidAuth(project, indicator, new ThrowableConsumer<GithubAuthData, IOException>() {
+ @Override
+ public void consume(GithubAuthData authData) throws IOException {
+ availableReposRef.set(GithubUtil.getAvailableRepos(authData));
+ }
+ });
+ if (auth == null || availableReposRef.isNull()) {
+ return;
+ }
+ final HashSet<String> names = new HashSet<String>();
+ for (RepositoryInfo info : availableReposRef.get()) {
+ names.add(info.getName());
+ }
+
+ // check access to private repos (network)
+ final GithubUser userInfo = GithubUtil.getCurrentUserInfo(auth);
+ if (userInfo == null) {
+ return;
+ }
+ githubInfoRef.set(new GithubInfo(auth, userInfo, names));
+ }
+ catch (IOException e) {
+ exceptionRef.set(e);
+ }
+ }
+ });
+ if (!exceptionRef.isNull()) {
+ GithubNotifications.showErrorDialog(project, "Failed to connect to GitHub", exceptionRef.get().getMessage());
+ return null;
+ }
+ if (githubInfoRef.isNull()) {
+ GithubNotifications.showErrorDialog(project, "Failed to connect to GitHub", "Failed to gather user information");
+ return null;
+ }
+ return githubInfoRef.get();
+ }
+
+ @Nullable
+ private static String createGithubRepository(@NotNull Project project,
+ @NotNull GithubAuthData auth,
+ @NotNull String name,
+ @NotNull String description,
+ boolean isPrivate) {
String path = "/user/repos";
- String requestBody = prepareRequest(name, description, aPrivate);
- JsonElement result = GithubApiUtil.postRequest(host, login, password, path, requestBody);
+ String requestBody = prepareRequest(name, description, isPrivate);
+ JsonElement result;
+ try {
+ result = GithubApiUtil.postRequest(auth, path, requestBody);
+ }
+ catch (IOException e) {
+ GithubNotifications.showError(project, "Creating GitHub Repository", e);
+ return null;
+ }
if (result == null) {
- return false;
+ GithubNotifications.showError(project, "Creating GitHub Repository", "Failed to create new GitHub repository");
+ return null;
}
if (!result.isJsonObject()) {
LOG.error(String.format("Unexpected JSON result format: %s", result));
- return false;
+ GithubNotifications.showError(project, "Creating GitHub Repository", "Failed to create new GitHub repository");
+ return null;
}
- return result.getAsJsonObject().has("url");
+ if (!result.getAsJsonObject().has("html_url")) {
+ GithubNotifications.showError(project, "Creating GitHub Repository", "Failed to create new GitHub repository");
+ return null;
+ }
+ return result.getAsJsonObject().get("html_url").getAsString();
}
private static String prepareRequest(String name, String description, boolean isPrivate) {
@@ -177,197 +276,192 @@
json.addProperty("description", description);
json.addProperty("public", Boolean.toString(!isPrivate));
return json.toString();
-
}
- private void bindToGithub(final Project project, final VirtualFile root, boolean gitDetected, final String login, final String name) {
- LOG.info("Binding local project with GitHub");
- // creating empty git repo if git isnot initialized
- if (!gitDetected) {
- LOG.info("No git detected, creating empty git repo");
- final GitLineHandler h = new GitLineHandler(project, root, GitCommand.INIT);
- GitHandlerUtil.doSynchronously(h, GitBundle.getString("initializing.title"), h.printableCommandLine());
- if (!h.errors().isEmpty()) {
- GitUIUtil.showOperationErrors(project, h.errors(), "git init");
- LOG.info("Failed to create empty git repo: " + h.errors());
- return;
- }
- final ProgressManager manager = ProgressManager.getInstance();
- manager.runProcessWithProgressSynchronously(new Runnable() {
- @Override
- public void run() {
- GitInit.refreshAndConfigureVcsMappings(project, root, "");
- }
- }, "Committing", false, project);
+ private static boolean createEmptyGitRepository(@NotNull Project project,
+ @NotNull VirtualFile root,
+ @NotNull ProgressIndicator indicator) {
+ final GitLineHandler h = new GitLineHandler(project, root, GitCommand.INIT);
+ GitHandlerUtil.runInCurrentThread(h, indicator, true, GitBundle.getString("initializing.title"));
+ if (!h.errors().isEmpty()) {
+ GitUIUtil.showOperationErrors(project, h.errors(), "git init");
+ LOG.info("Failed to create empty git repo: " + h.errors());
+ return false;
}
+ GitInit.refreshAndConfigureVcsMappings(project, root, root.getPath());
+ return true;
+ }
- // In this case we should create sample commit for binding project
- if (!performFirstCommitIfRequired(project, root)) {
- return;
- }
-
- GitRepositoryManager repositoryManager = ServiceManager.getService(project, GitRepositoryManager.class);
- final GitRepository repository = repositoryManager.getRepositoryForRoot(root);
- LOG.assertTrue(repository != null, "GitRepository is null for root " + root);
-
- //git remote add origin git@github.com:login/name.git
- LOG.info("Adding GitHub as a remote host");
+ private static boolean addGithubRemote(@NotNull Project project,
+ @NotNull VirtualFile root,
+ @NotNull String remoteName,
+ @NotNull String remoteUrl,
+ @NotNull GitRepository repository) {
final GitSimpleHandler addRemoteHandler = new GitSimpleHandler(project, root, GitCommand.REMOTE);
addRemoteHandler.setSilent(true);
- final String remoteUrl = GithubApiUtil.getGitHost() + "/" + login + "/" + name + ".git";
- addRemoteHandler.addParameters("add", "origin", remoteUrl);
+ addRemoteHandler.addParameters("add", remoteName, remoteUrl);
try {
addRemoteHandler.run();
repository.update();
if (addRemoteHandler.getExitCode() != 0) {
- Messages.showErrorDialog("Failed to add GitHub repository as remote", "Failed to add GitHub repository as remote");
- return;
+ GithubNotifications.showError(project, "Failed to add GitHub repository as remote", "Failed to add GitHub repository as remote");
+ return false;
}
}
catch (VcsException e) {
- Messages.showErrorDialog(e.getMessage(), "Failed to add GitHub repository as remote");
+ GithubNotifications.showError(project, "Failed to add GitHub repository as remote", e.getMessage());
LOG.info("Failed to add GitHub as remote: " + e.getMessage());
- return;
+ return false;
}
-
- //git push origin master
-
- new Task.Backgroundable(project, "Pushing to GitHub", false) {
- @Override
- public void run(@NotNull ProgressIndicator indicator) {
- Git git = ServiceManager.getService(Git.class);
- GitCommandResult result = git.push(repository, "origin", remoteUrl, "refs/heads/master:refs/heads/master");
- if (result.success()) {
- Notificator.getInstance(project).notify(new Notification(GithubUtil.GITHUB_NOTIFICATION_GROUP, "Success",
- "Successfully created project '" + name + "' on GitHub",
- NotificationType.INFORMATION));
- }
- else {
- showPushError(project, "Push failed: <br/>" + result.getErrorOutputAsHtmlString());
- }
- }
- }.queue();
+ return true;
}
- private static void showPushError(@NotNull Project project, @NotNull String message) {
- Notification notification = new Notification(GithubUtil.GITHUB_NOTIFICATION_GROUP, "Push to GitHub failed", message,
- NotificationType.ERROR);
- Notificator.getInstance(project).notify(notification);
- }
-
- private boolean performFirstCommitIfRequired(final Project project, final VirtualFile root) {
- final GitVcs gitVcs = GitVcs.getInstance(project);
- if (gitVcs == null){
- Messages.showErrorDialog(project, "Cannot find git initialized", "Failed to share");
- return false;
- }
-
- GitRepositoryManager repositoryManager = ServiceManager.getService(project, GitRepositoryManager.class);
- Git git = ServiceManager.getService(Git.class);
- if (repositoryManager == null || git == null) {
- return false;
- }
- GitRepository repository = repositoryManager.getRepositoryForRoot(root);
- if (repository == null) {
- Messages.showErrorDialog(project, "Cannot find git repository for root " + root, "Failed to share");
- return false;
- }
+ private static boolean performFirstCommitIfRequired(@NotNull final Project project, @NotNull VirtualFile root,
+ @NotNull GitRepository repository,
+ @NotNull ProgressIndicator indicator,
+ @NotNull String name,
+ @NotNull String url) {
+ // check if there is no commits
if (!repository.isFresh()) {
return true;
}
- final Ref<Exception> exceptionRef = new Ref<Exception>();
- // Creating or modifying readme file
- LOG.info("Touching file 'README' for initial commit");
- final VirtualFile readmeFile = ApplicationManager.getApplication().runWriteAction(new Computable<VirtualFile>() {
- @Override
- public VirtualFile compute() {
- VirtualFile file = null;
- try {
- file = root.findChild("README");
- if (file == null) {
- file = root.createChildData(this, "README");
- VfsUtil.saveText(file, "This file was created by " + ApplicationInfoEx.getInstanceEx().getFullApplicationName() + " for binding GitHub repository");
- } else {
- VfsUtil.saveText(file, VfsUtil.loadText(file) + "\nThis file was modified by " + ApplicationInfoEx.getInstanceEx().getFullApplicationName() + " for binding GitHub repository");
- }
- }
- catch (IOException e) {
- exceptionRef.set(e);
- LOG.info("Failed to touch file 'README' for initial commit: " + e.getMessage());
- }
- return file;
- }
- });
- if (!exceptionRef.isNull()) {
- Messages.showErrorDialog(project, exceptionRef.get().getMessage(), "Failed to modify file during post activities");
- }
- exceptionRef.set(null);
LOG.info("Trying to commit");
- final ProgressManager manager = ProgressManager.getInstance();
- manager.runProcessWithProgressSynchronously(new Runnable() {
- public void run() {
- try {
- LOG.info("Adding files for commit");
- final ProgressIndicator progressIndicator = manager.getProgressIndicator();
- if (progressIndicator != null){
- progressIndicator.setText("Adding files to git");
- }
- // Add readme files to git
- final ArrayList<VirtualFile> files2Add = new ArrayList<VirtualFile>();
- if (readmeFile != null) {
- files2Add.add(readmeFile);
- }
- final ChangeListManagerImpl changeListManager = (ChangeListManagerImpl)ChangeListManager.getInstance(project);
+ try {
+ LOG.info("Adding files for commit");
+ indicator.setText("Adding files to git...");
- // Force update
- final Semaphore semaphore = new Semaphore();
- semaphore.up();
- changeListManager.invokeAfterUpdate(new Runnable() {
- @Override
- public void run() {
- semaphore.down();
- }
- }, InvokeAfterUpdateMode.SILENT, null, null);
- if (!semaphore.waitFor(30000)) {
- exceptionRef.set(new VcsException("Too long VCS update"));
- return;
- }
-
- for (VirtualFile file : changeListManager.getUnversionedFiles()) {
- if (file.getPath().contains(Project.DIRECTORY_STORE_FOLDER)) {
- continue;
- }
- if (readmeFile != null && readmeFile.equals(file)) {
- continue;
- }
- files2Add.add(file);
- }
- if (progressIndicator != null){
- progressIndicator.setText("Adding files to git");
- }
- GitFileUtils.addFiles(project, root, files2Add);
-
- LOG.info("Performing commit");
- if (progressIndicator != null){
- progressIndicator.setText("Performing commit");
- }
- GitSimpleHandler handler = new GitSimpleHandler(project, root, GitCommand.COMMIT);
- handler.addParameters("-m", "First commit");
- handler.endOptions();
- handler.run();
+ // ask for files to add
+ final List<VirtualFile> untrackedFiles = new ArrayList<VirtualFile>(repository.getUntrackedFilesHolder().retrieveUntrackedFiles());
+ final Ref<GithubUntrackedFilesDialog> dialogRef = new Ref<GithubUntrackedFilesDialog>();
+ ApplicationManager.getApplication().invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ GithubUntrackedFilesDialog dialog = new GithubUntrackedFilesDialog(project, untrackedFiles);
+ DialogManager.show(dialog);
+ dialogRef.set(dialog);
}
- catch (VcsException e) {
- exceptionRef.set(e);
- LOG.info("Failed to commit to GitHub");
- }
+ }, indicator.getModalityState());
+ final GithubUntrackedFilesDialog dialog = dialogRef.get();
+
+ final Collection<VirtualFile> files2add = dialog.getSelectedFiles();
+ if (!dialog.isOK() || files2add.isEmpty()) {
+ GithubNotifications
+ .showWarningURL(project, "Can't finish GitHub sharing process", "No files to commit. ", "'" + name + "'", " on GitHub", url);
+ return false;
}
- }, "Performing post creating github repository activities", true, project);
+ GitFileUtils.addFiles(project, root, files2add);
- if (!exceptionRef.isNull()) {
- Messages.showErrorDialog(project, exceptionRef.get().getMessage(), "Failed to commit file during post activities");
+ // commit
+ LOG.info("Performing commit");
+ indicator.setText("Performing commit...");
+ GitSimpleHandler handler = new GitSimpleHandler(project, root, GitCommand.COMMIT);
+ handler.addParameters("-m", dialog.getCommitMessage());
+ handler.endOptions();
+ handler.run();
+ }
+ catch (VcsException e) {
+ LOG.info("Failed to perform initial commit");
+ GithubNotifications.showErrorURL(project, "Can't finish GitHub sharing process", "Successfully created project ", "'" + name + "'",
+ " on GitHub, but initial commit failed:<br/>" + e.getMessage(), url);
+ return false;
+ }
+ LOG.info("Successfully created initial commit");
+ return true;
+ }
+
+ private static boolean pushCurrentBranch(@NotNull Project project,
+ @NotNull GitRepository repository,
+ @NotNull String remoteName,
+ @NotNull String remoteUrl, @NotNull String name, @NotNull String url) {
+ Git git = ServiceManager.getService(Git.class);
+
+ GitLocalBranch currentBranch = repository.getCurrentBranch();
+ if (currentBranch == null) {
+ GithubNotifications.showErrorURL(project, "Can't finish GitHub sharing process", "Successfully created project ", "'" + name + "'",
+ " on GitHub, but initial push failed: no current branch", url);
+ return false;
+ }
+ GitCommandResult result = git.push(repository, remoteName, remoteUrl, currentBranch.getName(), true);
+ if (!result.success()) {
+ GithubNotifications.showErrorURL(project, "Can't finish GitHub sharing process", "Successfully created project ", "'" + name + "'",
+ " on GitHub, but initial push failed:<br/>" + result.getErrorOutputAsHtmlString(), url);
return false;
}
return true;
}
+
+ public static class GithubUntrackedFilesDialog extends SelectFilesDialog implements TypeSafeDataProvider {
+ @NotNull private final Project myProject;
+ private CommitMessage myCommitMessagePanel;
+
+ public GithubUntrackedFilesDialog(@NotNull Project project, @NotNull List<VirtualFile> untrackedFiles) {
+ super(project, untrackedFiles, null, null, true, false, false);
+ myProject = project;
+ setTitle("Add Files For Initial Commit");
+ init();
+ }
+
+ @Override
+ protected JComponent createNorthPanel() {
+ return null;
+ }
+
+ @Override
+ protected JComponent createCenterPanel() {
+ final JComponent tree = super.createCenterPanel();
+ final JPanel panel = new JPanel(new BorderLayout());
+
+ myCommitMessagePanel = new CommitMessage(myProject);
+ myCommitMessagePanel.setCommitMessage("Initial commit");
+
+ Splitter splitter = new Splitter(true);
+ splitter.setHonorComponentsMinimumSize(true);
+ splitter.setFirstComponent(tree);
+ splitter.setSecondComponent(myCommitMessagePanel);
+ splitter.setProportion(0.7f);
+ panel.add(splitter, BorderLayout.CENTER);
+
+ return panel;
+ }
+
+ @NotNull
+ public String getCommitMessage() {
+ return myCommitMessagePanel.getComment();
+ }
+
+ @Override
+ public void calcData(DataKey key, DataSink sink) {
+ if (key == VcsDataKeys.COMMIT_MESSAGE_CONTROL) {
+ sink.put(VcsDataKeys.COMMIT_MESSAGE_CONTROL, myCommitMessagePanel);
+ }
+ }
+ }
+
+ private static class GithubInfo {
+ @NotNull private final GithubUser myUser;
+ @NotNull private final GithubAuthData myAuthData;
+ @NotNull private final HashSet<String> myRepositoryNames;
+
+ GithubInfo(@NotNull GithubAuthData auth, @NotNull GithubUser user, @NotNull HashSet<String> repositoryNames) {
+ myUser = user;
+ myAuthData = auth;
+ myRepositoryNames = repositoryNames;
+ }
+
+ @NotNull
+ public GithubUser getUser() {
+ return myUser;
+ }
+
+ @NotNull
+ public GithubAuthData getAuthData() {
+ return myAuthData;
+ }
+
+ @NotNull
+ public HashSet<String> getRepositoryNames() {
+ return myRepositoryNames;
+ }
+ }
}
diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubShowCommitInBrowserAction.java b/plugins/github/src/org/jetbrains/plugins/github/GithubShowCommitInBrowserAction.java
index 29f64d3..2c4c8f7 100644
--- a/plugins/github/src/org/jetbrains/plugins/github/GithubShowCommitInBrowserAction.java
+++ b/plugins/github/src/org/jetbrains/plugins/github/GithubShowCommitInBrowserAction.java
@@ -35,16 +35,17 @@
String url = GithubUtil.findGithubRemoteUrl(repository);
if (url == null) {
GithubUtil.LOG.info(String.format("Repository is not under GitHub. Root: %s, Remotes: %s", repository.getRoot(),
- GitUtil.getPrintableRemotes(repository.getRemotes())));
+ GitUtil.getPrintableRemotes(repository.getRemotes())));
return;
}
- url = GithubUtil.makeGithubRepoUrlFromRemoteUrl(url);
- String userAndRepository = GithubUtil.getUserAndRepositoryOrShowError(project, url);
+ GithubUserAndRepository userAndRepository = GithubUrlUtil.getUserAndRepositoryFromRemoteUrl(url);
if (userAndRepository == null) {
+ GithubNotifications
+ .showError(project, GithubOpenInBrowserAction.CANNOT_OPEN_IN_BROWSER, "Cannot extract info about repository: " + url);
return;
}
- String githubUrl = GithubApiUtil.getGitHost() + "/" + userAndRepository + "/commit/" + revisionHash;
+ String githubUrl = GithubUrlUtil.getGitHost() + "/" + userAndRepository.toString() + "/commit/" + revisionHash;
BrowserUtil.launchBrowser(githubUrl);
}
diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubShowCommitInBrowserFromAnnotateAction.java b/plugins/github/src/org/jetbrains/plugins/github/GithubShowCommitInBrowserFromAnnotateAction.java
index 2455847..9f0b394 100644
--- a/plugins/github/src/org/jetbrains/plugins/github/GithubShowCommitInBrowserFromAnnotateAction.java
+++ b/plugins/github/src/org/jetbrains/plugins/github/GithubShowCommitInBrowserFromAnnotateAction.java
@@ -17,10 +17,14 @@
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
+import com.intellij.openapi.editor.Document;
+import com.intellij.openapi.fileEditor.FileDocumentManager;
+import com.intellij.openapi.localVcs.UpToDateLineNumberProvider;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.annotate.FileAnnotation;
import com.intellij.openapi.vcs.annotate.LineNumberListener;
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
+import com.intellij.openapi.vcs.impl.UpToDateLineNumberProviderImpl;
import com.intellij.openapi.vfs.VirtualFile;
import git4idea.GitUtil;
import git4idea.repo.GitRepository;
@@ -42,38 +46,50 @@
@Override
public void update(AnActionEvent e) {
- EventData eventData = calcData(e);
- final boolean enabled = myLineNumber != -1 && myAnnotation.getLineRevisionNumber(myLineNumber) != null;
- e.getPresentation().setEnabled(eventData != null && enabled);
- e.getPresentation().setVisible(eventData != null && GithubUtil.isRepositoryOnGitHub(eventData.getRepository()));
+ EventData eventData = calcData(e, myLineNumber);
+ if (eventData == null) {
+ e.getPresentation().setEnabled(false);
+ e.getPresentation().setVisible(false);
+ return;
+ }
+ int corrected = eventData.getCorrectedLineNumber();
+ e.getPresentation().setEnabled(corrected >= 0 && myAnnotation.getLineRevisionNumber(corrected) != null);
+ e.getPresentation().setVisible(GithubUtil.isRepositoryOnGitHub(eventData.getRepository()));
}
@Override
public void actionPerformed(AnActionEvent e) {
- EventData eventData = calcData(e);
+ EventData eventData = calcData(e, myLineNumber);
if (eventData == null) {
return;
}
- final VcsRevisionNumber revisionNumber = myAnnotation.getLineRevisionNumber(myLineNumber);
+ final VcsRevisionNumber revisionNumber = myAnnotation.getLineRevisionNumber(eventData.getCorrectedLineNumber());
if (revisionNumber != null) {
openInBrowser(eventData.getProject(), eventData.getRepository(), revisionNumber.asString());
}
}
@Nullable
- private static EventData calcData(AnActionEvent e) {
+ private static EventData calcData(AnActionEvent e, int lineNumber) {
Project project = e.getData(PlatformDataKeys.PROJECT);
VirtualFile virtualFile = e.getData(PlatformDataKeys.VIRTUAL_FILE);
if (project == null || virtualFile == null) {
return null;
}
+ Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
+ if (document == null) {
+ return null;
+ }
+ final UpToDateLineNumberProvider myGetUpToDateLineNumber = new UpToDateLineNumberProviderImpl(document, project);
+ int corrected = myGetUpToDateLineNumber.getLineNumber(lineNumber);
+
GitRepository repository = GitUtil.getRepositoryManager(project).getRepositoryForFile(virtualFile);
if (repository == null) {
return null;
}
- return new EventData(project, repository);
+ return new EventData(project, repository, corrected);
}
@Override
@@ -84,10 +100,12 @@
private static class EventData {
@NotNull private final Project myProject;
@NotNull private final GitRepository myRepository;
+ private final int myCorrectedLineNumber;
- private EventData(@NotNull Project project, @NotNull GitRepository repository) {
+ private EventData(@NotNull Project project, @NotNull GitRepository repository, int correctedLineNumber) {
myProject = project;
myRepository = repository;
+ myCorrectedLineNumber = correctedLineNumber;
}
@NotNull
@@ -100,6 +118,9 @@
return myRepository;
}
+ private int getCorrectedLineNumber() {
+ return myCorrectedLineNumber;
+ }
}
}
diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubSslSupport.java b/plugins/github/src/org/jetbrains/plugins/github/GithubSslSupport.java
index 0e95bdb..4e20aef 100644
--- a/plugins/github/src/org/jetbrains/plugins/github/GithubSslSupport.java
+++ b/plugins/github/src/org/jetbrains/plugins/github/GithubSslSupport.java
@@ -114,8 +114,10 @@
public boolean askIfShouldProceed(final String host) {
final String BACK_TO_SAFETY = "No, I don't trust";
final String TRUST = "Proceed anyway";
- int choice = Messages.showDialog("The security certificate of " + host + " is not trusted. Do you want to proceed anyway?",
- "Not Trusted Certificate", new String[] { BACK_TO_SAFETY, TRUST }, 0, Messages.getErrorIcon());
+ //int choice = Messages.showDialog("The security certificate of " + host + " is not trusted. Do you want to proceed anyway?",
+ // "Not Trusted Certificate", new String[] { BACK_TO_SAFETY, TRUST }, 0, Messages.getErrorIcon());
+ int choice = Messages.showIdeaMessageDialog(null, "The security certificate of " + host + " is not trusted. Do you want to proceed anyway?",
+ "Not Trusted Certificate", new String[] { BACK_TO_SAFETY, TRUST }, 0, Messages.getErrorIcon(), null);
boolean trust = (choice == 1);
if (trust) {
saveToTrusted(host);
diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubUrlUtil.java b/plugins/github/src/org/jetbrains/plugins/github/GithubUrlUtil.java
new file mode 100644
index 0000000..f6de159
--- /dev/null
+++ b/plugins/github/src/org/jetbrains/plugins/github/GithubUrlUtil.java
@@ -0,0 +1,170 @@
+/*
+ * Copyright 2000-2013 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 org.jetbrains.plugins.github;
+
+import com.intellij.openapi.util.text.StringUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * @author Aleksey Pivovarov
+ */
+public class GithubUrlUtil {
+ @NotNull
+ public static String removeProtocolPrefix(String url) {
+ int index = url.indexOf('@');
+ if (index != -1) {
+ return url.substring(index + 1);
+ }
+ index = url.indexOf("://");
+ if (index != -1) {
+ return url.substring(index + 3);
+ }
+ return url;
+ }
+
+ @NotNull
+ public static String removeTrailingSlash(@NotNull String s) {
+ if (s.endsWith("/")) {
+ return s.substring(0, s.length() - 1);
+ }
+ return s;
+ }
+
+ @NotNull
+ static String getApiUrl(@NotNull String urlFromSettings) {
+ return "https://" + getApiUrlWithoutProtocol(urlFromSettings);
+ }
+
+ /**
+ * E.g.: https://api.github.com
+ * https://my.company.url/api/v3
+ */
+ @NotNull
+ public static String getApiUrl() {
+ return getApiUrl(GithubSettings.getInstance().getHost());
+ }
+
+ /**
+ * Returns the "host" part of Git URLs.
+ * E.g.: https://github.com
+ * https://my.company.url
+ * Note: there is no trailing slash in the returned url.
+ */
+ @NotNull
+ public static String getGitHost() {
+ return "https://" + getGitHostWithoutProtocol();
+ }
+
+ /**
+ * E.g.: github.com
+ * my.company.url
+ */
+ @NotNull
+ public static String getGitHostWithoutProtocol() {
+ return removeTrailingSlash(removeProtocolPrefix(GithubSettings.getInstance().getHost()));
+ }
+
+ /*
+ All API access is over HTTPS, and accessed from the api.github.com domain
+ (or through yourdomain.com/api/v3/ for enterprise).
+ http://developer.github.com/v3/
+ */
+ @NotNull
+ private static String getApiUrlWithoutProtocol(@NotNull String urlFromSettings) {
+ String url = removeTrailingSlash(removeProtocolPrefix(urlFromSettings));
+ final String API_PREFIX = "api.";
+ final String ENTERPRISE_API_SUFFIX = "/api/v3";
+
+ if (url.equals(GithubApiUtil.DEFAULT_GITHUB_HOST)) {
+ return API_PREFIX + url;
+ }
+ else if (url.equals(API_PREFIX + GithubApiUtil.DEFAULT_GITHUB_HOST)) {
+ return url;
+ }
+ else if (url.endsWith(ENTERPRISE_API_SUFFIX)) {
+ return url;
+ }
+ else {
+ return url + ENTERPRISE_API_SUFFIX;
+ }
+ }
+
+ public static boolean isGithubUrl(@NotNull String url) {
+ return isGithubUrl(url, GithubSettings.getInstance().getHost());
+ }
+
+ public static boolean isGithubUrl(@NotNull String url, @NotNull String host) {
+ url = removeProtocolPrefix(url);
+ if (StringUtil.startsWithIgnoreCase(url, host)) {
+ if (url.length() > host.length() && ":/".indexOf(url.charAt(host.length())) == -1) {
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * git@github.com:user/repo.git -> user/repo
+ */
+ @Nullable
+ public static GithubUserAndRepository getUserAndRepositoryFromRemoteUrl(@NotNull String remoteUrl) {
+ remoteUrl = removeEndingDotGit(remoteUrl);
+ int index1 = remoteUrl.lastIndexOf('/');
+ if (index1 == -1) {
+ return null;
+ }
+ String url = remoteUrl.substring(0, index1);
+ int index2 = Math.max(url.lastIndexOf('/'), url.lastIndexOf(':'));
+ if (index2 == -1) {
+ return null;
+ }
+ return new GithubUserAndRepository(remoteUrl.substring(index2 + 1, index1), remoteUrl.substring(index1 + 1));
+ }
+
+ /**
+ * git@github.com:user/repo -> https://github.com/user/repo
+ */
+ @Nullable
+ public static String makeGithubRepoUrlFromRemoteUrl(@NotNull String remoteUrl) {
+ remoteUrl = removeEndingDotGit(remoteUrl);
+ if (remoteUrl.startsWith("https://")) {
+ return remoteUrl;
+ }
+ if (remoteUrl.startsWith("http://")) {
+ return "https" + remoteUrl.substring(4);
+ }
+ if (remoteUrl.startsWith("git://")) {
+ return "https" + remoteUrl.substring(3);
+ }
+ if (remoteUrl.startsWith("git@")) {
+ return "https://" + remoteUrl.substring(4).replace(':', '/');
+ }
+ GithubUtil.LOG.error("Invalid remote GitHub url: " + remoteUrl);
+ return null;
+ }
+
+ @NotNull
+ private static String removeEndingDotGit(@NotNull String url) {
+ url = removeTrailingSlash(url);
+ final String DOT_GIT = ".git";
+ if (url.endsWith(DOT_GIT)) {
+ return url.substring(0, url.length() - DOT_GIT.length());
+ }
+ return url;
+ }
+}
diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubUser.java b/plugins/github/src/org/jetbrains/plugins/github/GithubUser.java
index 3bdf5ea..eeb96b2 100644
--- a/plugins/github/src/org/jetbrains/plugins/github/GithubUser.java
+++ b/plugins/github/src/org/jetbrains/plugins/github/GithubUser.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -22,46 +22,25 @@
*
* @author Kirill Likhodedov
*/
-class GithubUser {
+public class GithubUser {
- enum Plan {
- FREE,
- MICRO,
- SMALL,
- MEDIUM,
- BRONZE,
- SILVER,
- GOLD,
- PLATINUM,
- ENTERPRISE;
+ @NotNull private final String myLogin;
+ private final int myPrivateRepos;
+ private final int myMaxPrivateRepos;
- public boolean isPrivateRepoAllowed() {
- return this != FREE;
- }
-
- public static Plan fromString(String name) {
- for (Plan plan : values()) {
- if (plan.name().equalsIgnoreCase(name)) {
- return plan;
- }
- }
- return defaultPlan();
- }
-
- private static Plan defaultPlan() {
- return FREE;
- }
- }
-
- @NotNull private final Plan myPlan;
-
- GithubUser(@NotNull Plan plan) {
- myPlan = plan;
+ GithubUser(@NotNull String login, int privateRepos, int maxPrivateRepos) {
+ myLogin = login;
+ myPrivateRepos = privateRepos;
+ myMaxPrivateRepos = maxPrivateRepos;
}
@NotNull
- Plan getPlan() {
- return myPlan;
+ public String getLogin() {
+ return myLogin;
+ }
+
+ public boolean canCreatePrivateRepo() {
+ return myMaxPrivateRepos > myPrivateRepos;
}
}
diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubUserAndRepository.java b/plugins/github/src/org/jetbrains/plugins/github/GithubUserAndRepository.java
new file mode 100644
index 0000000..9680060
--- /dev/null
+++ b/plugins/github/src/org/jetbrains/plugins/github/GithubUserAndRepository.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2000-2013 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 org.jetbrains.plugins.github;
+
+import org.jetbrains.annotations.NotNull;
+
+/**
+* @author Aleksey Pivovarov
+*/
+public class GithubUserAndRepository {
+ @NotNull final private String myUserName;
+ @NotNull final private String myRepositoryName;
+
+ public GithubUserAndRepository(@NotNull String userName, @NotNull String repositoryName) {
+ myUserName = userName;
+ myRepositoryName = repositoryName;
+ }
+
+ @NotNull
+ public String getUserName() {
+ return myUserName;
+ }
+
+ @NotNull
+ public String getRepositoryName() {
+ return myRepositoryName;
+ }
+
+ @NotNull
+ public String toString() {
+ return myUserName + '/' + myRepositoryName;
+ }
+}
diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubUtil.java b/plugins/github/src/org/jetbrains/plugins/github/GithubUtil.java
index 69989a3..b7c1182 100644
--- a/plugins/github/src/org/jetbrains/plugins/github/GithubUtil.java
+++ b/plugins/github/src/org/jetbrains/plugins/github/GithubUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -17,22 +17,20 @@
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
-import com.intellij.notification.Notification;
-import com.intellij.notification.NotificationType;
import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProgressIndicator;
-import com.intellij.openapi.progress.ProgressManager;
-import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.ui.Messages;
-import com.intellij.openapi.util.ThrowableComputable;
import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.util.ThrowableConsumer;
+import com.intellij.util.ThrowableConvertor;
import git4idea.config.GitVcsApplicationSettings;
import git4idea.config.GitVersion;
import git4idea.i18n.GitBundle;
import git4idea.repo.GitRemote;
import git4idea.repo.GitRepository;
+import org.apache.commons.httpclient.auth.AuthenticationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.github.ui.GithubLoginDialog;
@@ -41,40 +39,40 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import java.util.concurrent.atomic.AtomicReference;
/**
* Various utility methods for the GutHub plugin.
*
* @author oleg
* @author Kirill Likhodedov
+ * @author Aleksey Pivovarov
*/
public class GithubUtil {
public static final Logger LOG = Logger.getInstance("github");
- static final String GITHUB_NOTIFICATION_GROUP = "github";
-
- /**
- * @deprecated The host may be defined in different formats. Use {@link GithubApiUtil#getApiUrl(String)} instead.
- */
- @Deprecated
- public static String getHttpsUrl() {
- return "https://" + GithubSettings.getInstance().getHost();
- }
-
@Nullable
- public static <T> T accessToGithubWithModalProgress(@NotNull final Project project, @NotNull String host,
- @NotNull final ThrowableComputable<T, IOException> computable) throws IOException {
+ public static GithubAuthData runAndGetValidAuth(@NotNull Project project,
+ @NotNull ProgressIndicator indicator,
+ @NotNull ThrowableConsumer<GithubAuthData, IOException> task) throws IOException {
+ GithubAuthData auth = GithubSettings.getInstance().getAuthData();
try {
- return doAccessToGithubWithModalProgress(project, computable);
+ task.consume(auth);
+ return auth;
+ }
+ catch (AuthenticationException e) {
+ auth = getValidAuthData(project, indicator);
+ if (auth == null) {
+ return null;
+ }
+ task.consume(auth);
+ return auth;
}
catch (IOException e) {
GithubSslSupport sslSupport = GithubSslSupport.getInstance();
if (GithubSslSupport.isCertificateException(e)) {
- if (sslSupport.askIfShouldProceed(host)) {
- // retry with the host being already trusted
- return doAccessToGithubWithModalProgress(project, computable);
+ if (sslSupport.askIfShouldProceed(auth.getHost())) {
+ return runAndGetValidAuth(project, indicator, task);
}
else {
return null;
@@ -84,48 +82,91 @@
}
}
- private static <T> T doAccessToGithubWithModalProgress(@NotNull final Project project,
- @NotNull final ThrowableComputable<T, IOException> computable) throws IOException {
- final AtomicReference<T> result = new AtomicReference<T>();
- final AtomicReference<IOException> exception = new AtomicReference<IOException>();
- ProgressManager.getInstance().run(new Task.Modal(project, "Access to GitHub", true) {
- public void run(@NotNull ProgressIndicator indicator) {
- try {
- result.set(computable.compute());
- }
- catch (IOException e) {
- exception.set(e);
- }
- }
- });
- //noinspection ThrowableResultOfMethodCallIgnored
- if (exception.get() == null) {
- return result.get();
+ @Nullable
+ public static <T> T runWithValidAuth(@NotNull Project project,
+ @NotNull ProgressIndicator indicator,
+ @NotNull ThrowableConvertor<GithubAuthData, T, IOException> task) throws IOException {
+ GithubAuthData auth = GithubSettings.getInstance().getAuthData();
+ try {
+ return task.convert(auth);
}
- throw exception.get();
- }
-
- /**
- * @deprecated TODO Use background progress
- */
- @Deprecated
- public static void accessToGithubWithModalProgress(final Project project, final Runnable runnable) {
- ProgressManager.getInstance().run(new Task.Modal(project, "Access to GitHub", true) {
- public void run(@NotNull ProgressIndicator indicator) {
- runnable.run();
+ catch (AuthenticationException e) {
+ auth = getValidAuthData(project, indicator);
+ if (auth == null) {
+ return null;
}
- });
+ return task.convert(auth);
+ }
+ catch (IOException e) {
+ GithubSslSupport sslSupport = GithubSslSupport.getInstance();
+ if (GithubSslSupport.isCertificateException(e)) {
+ if (sslSupport.askIfShouldProceed(auth.getHost())) {
+ return runWithValidAuth(project, indicator, task);
+ }
+ else {
+ return null;
+ }
+ }
+ throw e;
+ }
}
- private static boolean testConnection(final String url, final String login, final String password) throws IOException {
- GithubUser user = retrieveCurrentUserInfo(url, login, password);
+ @Nullable
+ public static GithubAuthData getValidAuthData(@NotNull Project project, @NotNull ProgressIndicator indicator) {
+ final GithubLoginDialog dialog = new GithubLoginDialog(project);
+ ApplicationManager.getApplication().invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ dialog.show();
+ }
+ }, indicator.getModalityState());
+ if (!dialog.isOK()) {
+ return null;
+ }
+ return dialog.getAuthData();
+ }
+
+ @Nullable
+ public static GithubAuthData getValidAuthDataFromConfig(@NotNull Project project, @NotNull ProgressIndicator indicator) {
+ GithubAuthData auth = GithubSettings.getInstance().getAuthData();
+ boolean valid = false;
+ try {
+ valid = checkAuthData(auth);
+ }
+ catch (IOException e) {
+ LOG.error("Connection error", e);
+ }
+ if (!valid) {
+ return getValidAuthData(project, indicator);
+ }
+ else {
+ return auth;
+ }
+ }
+
+ public static boolean checkAuthData(GithubAuthData auth) throws IOException {
+ if (StringUtil.isEmptyOrSpaces(auth.getHost()) ||
+ StringUtil.isEmptyOrSpaces(auth.getLogin()) ||
+ StringUtil.isEmptyOrSpaces(auth.getPassword())) {
+ return false;
+ }
+
+ try {
+ return testConnection(auth);
+ }
+ catch (AuthenticationException e) {
+ return false;
+ }
+ }
+
+ private static boolean testConnection(@NotNull GithubAuthData auth) throws IOException {
+ GithubUser user = getCurrentUserInfo(auth);
return user != null;
}
@Nullable
- private static GithubUser retrieveCurrentUserInfo(@NotNull String url, @NotNull String login,
- @NotNull String password) throws IOException {
- JsonElement result = GithubApiUtil.getRequest(url, login, password, "/user");
+ public static GithubUser getCurrentUserInfo(@NotNull GithubAuthData auth) throws IOException {
+ JsonElement result = GithubApiUtil.getRequest(auth, "/user");
return parseUserInfo(result);
}
@@ -140,35 +181,30 @@
}
JsonObject obj = (JsonObject)result;
- if (!obj.has("plan")) {
- return null;
- }
- GithubUser.Plan plan = parsePlan(obj.get("plan"));
- return new GithubUser(plan);
+ String login = obj.get("login").getAsString();
+ int privateRepos = obj.get("owned_private_repos").getAsInt();
+ int maxPrivateRepos = obj.get("plan").getAsJsonObject().get("private_repos").getAsInt();
+ return new GithubUser(login, privateRepos, maxPrivateRepos);
}
@NotNull
- private static GithubUser.Plan parsePlan(JsonElement plan) {
- if (!plan.isJsonObject()) {
- return GithubUser.Plan.FREE;
- }
- return GithubUser.Plan.fromString(plan.getAsJsonObject().get("name").getAsString());
- }
-
- @NotNull
- private static List<RepositoryInfo> getAvailableRepos(@NotNull String url, @NotNull String login, @NotNull String password) {
+ public static List<RepositoryInfo> getAvailableRepos(@NotNull GithubAuthData auth) throws IOException {
final String request = "/user/repos";
- try {
- JsonElement result = GithubApiUtil.getRequest(url, login, password, request);
- if (result == null) {
- return Collections.emptyList();
- }
- return parseRepositoryInfos(result);
- }
- catch (IOException e) {
- LOG.error(e);
+ JsonElement result = GithubApiUtil.getRequest(auth, request);
+ if (result == null) {
return Collections.emptyList();
}
+ return parseRepositoryInfos(result);
+ }
+
+ @NotNull
+ public static List<RepositoryInfo> getAvailableRepos(@NotNull GithubAuthData auth, @NotNull String user) throws IOException {
+ final String request = "/users/" + user + "/repos";
+ JsonElement result = GithubApiUtil.getRequest(auth, request);
+ if (result == null) {
+ return Collections.emptyList();
+ }
+ return parseRepositoryInfos(result);
}
@NotNull
@@ -190,161 +226,77 @@
@NotNull
private static RepositoryInfo parseSingleRepositoryInfo(@NotNull JsonObject result) {
String name = result.get("name").getAsString();
+ String browserUrl = result.get("html_url").getAsString();
String cloneUrl = result.get("clone_url").getAsString();
String ownerName = result.get("owner").getAsJsonObject().get("login").getAsString();
- String parentName = result.has("parent") ? result.get("parent").getAsJsonObject().get("full_name").getAsString(): null;
+ String parentName = result.has("parent") ? result.get("parent").getAsJsonObject().get("full_name").getAsString() : null;
boolean fork = result.get("fork").getAsBoolean();
- return new RepositoryInfo(name, cloneUrl, ownerName, parentName, fork);
+ return new RepositoryInfo(name, browserUrl, cloneUrl, ownerName, parentName, fork);
}
@Nullable
- private static RepositoryInfo getDetailedRepoInfo(@NotNull String url, @NotNull String login, @NotNull String password,
- @NotNull String owner, @NotNull String name) {
- try {
- final String request = "/repos/" + owner + "/" + name;
- JsonElement jsonObject = GithubApiUtil.getRequest(url, login, password, request);
- if (jsonObject == null) {
- LOG.info(String.format("Information about repository is unavailable. Owner: %s, Name: %s", owner, name));
- return null;
- }
- return parseSingleRepositoryInfo(jsonObject.getAsJsonObject());
- }
- catch (IOException e) {
- LOG.info(String.format("Exception was thrown when trying to retrieve information about repository. Owner: %s, Name: %s",
- owner, name));
+ public static RepositoryInfo getDetailedRepoInfo(@NotNull GithubAuthData auth, @NotNull String owner, @NotNull String name)
+ throws IOException {
+ final String request = "/repos/" + owner + "/" + name;
+ JsonElement jsonObject = GithubApiUtil.getRequest(auth, request);
+ if (jsonObject == null) {
+ LOG.info(String.format("Information about repository is unavailable. Owner: %s, Name: %s", owner, name));
return null;
}
+ return parseSingleRepositoryInfo(jsonObject.getAsJsonObject());
}
- public static boolean isPrivateRepoAllowed(final String url, final String login, final String password) throws IOException {
- GithubUser user = retrieveCurrentUserInfo(url, login, password);
- if (user == null) {
- return false;
- }
- return user.getPlan().isPrivateRepoAllowed();
+ public static void deleteGithubRepository(@NotNull GithubAuthData auth, @NotNull String repo) throws IOException {
+ String path = "/repos/" + auth.getLogin() + "/" + repo;
+ GithubApiUtil.deleteRequest(auth, path);
}
- /**
- * Checks if user has set up correct user credentials for GitHub access in the settings.
- * @return true if we could successfully login with these credentials, false if authentication failed or in the case of some other error.
- */
- public static boolean checkCredentials(final Project project) {
- final GithubSettings settings = GithubSettings.getInstance();
- try {
- return checkCredentials(project, settings.getHost(), settings.getLogin(), settings.getPassword());
- }
- catch (IOException e) {
- // this method is a quick-check if we've got valid user setup.
- // if an exception happens, we'll show the reason in the login dialog that will be shown right after checkCredentials failure.
- LOG.info(e);
- return false;
- }
+ public static void deleteGist(@NotNull GithubAuthData auth, @NotNull String id) throws IOException {
+ String path = "/gists/" + id;
+ GithubApiUtil.deleteRequest(auth, path);
}
- public static boolean checkCredentials(Project project, final String url, final String login, final String password) throws IOException {
- if (StringUtil.isEmptyOrSpaces(url) || StringUtil.isEmptyOrSpaces(login) || StringUtil.isEmptyOrSpaces(password)){
- return false;
- }
- Boolean result = accessToGithubWithModalProgress(project, url, new ThrowableComputable<Boolean, IOException>() {
- @Override
- public Boolean compute() throws IOException {
- ProgressManager.getInstance().getProgressIndicator().setText("Trying to login to GitHub");
- return testConnection(url, login, password);
- }
- });
- return result == null ? false : result;
- }
-
- /**
- * Shows GitHub login settings if credentials are wrong or empty and return the list of all the watched repos by user
- *
- * @param project
- * @return
- */
@Nullable
- public static List<RepositoryInfo> getAvailableRepos(final Project project) throws IOException {
- while (!checkCredentials(project)){
- final GithubLoginDialog dialog = new GithubLoginDialog(project);
- dialog.show();
- if (!dialog.isOK()){
- return null;
- }
- }
- // Otherwise our credentials are valid and they are successfully stored in settings
- final GithubSettings settings = GithubSettings.getInstance();
- final String validPassword = settings.getPassword();
- return accessToGithubWithModalProgress(project, settings.getHost(), new ThrowableComputable<List<RepositoryInfo>, IOException>() {
- @Override
- public List<RepositoryInfo> compute() throws IOException {
- ProgressManager.getInstance().getProgressIndicator().setText("Extracting info about available repositories");
- return getAvailableRepos(settings.getHost(), settings.getLogin(), validPassword);
- }
- });
- }
-
- /**
- * Shows GitHub login settings if credentials are wrong or empty and return the list of all the watched repos by user
- * @param project
- * @return
- */
- @Nullable
- public static RepositoryInfo getDetailedRepositoryInfo(final Project project, final String owner, final String name) throws IOException {
- final GithubSettings settings = GithubSettings.getInstance();
- final String password = settings.getPassword();
- final Boolean validCredentials = accessToGithubWithModalProgress(project, settings.getHost(),
- new ThrowableComputable<Boolean, IOException>() {
- @Override
- public Boolean compute() throws IOException {
- ProgressManager.getInstance().getProgressIndicator().setText("Trying to login to GitHub");
- return testConnection(settings.getHost(), settings.getLogin(), password);
- }
- });
- if (validCredentials == null) {
+ public static JsonObject getGist(@NotNull GithubAuthData auth, @NotNull String id) throws IOException {
+ String path = "/gists/" + id;
+ JsonElement result = GithubApiUtil.getRequest(auth, path);
+ if (result == null) {
return null;
}
- if (!validCredentials){
- final GithubLoginDialog dialog = new GithubLoginDialog(project);
- dialog.show();
- if (!dialog.isOK()) {
- return null;
- }
- }
- // Otherwise our credentials are valid and they are successfully stored in settings
- final String validPassword = settings.getPassword();
- return accessToGithubWithModalProgress(project, settings.getHost(), new ThrowableComputable<RepositoryInfo, IOException>() {
- @Nullable
- @Override
- public RepositoryInfo compute() {
- ProgressManager.getInstance().getProgressIndicator().setText("Extracting detailed info about repository ''" + name + "''");
- return getDetailedRepoInfo(settings.getHost(), settings.getLogin(), validPassword, owner, name);
- }
- });
+ return result.getAsJsonObject();
}
@Nullable
- public static GitRemote findGitHubRemoteBranch(@NotNull GitRepository repository) {
- // i.e. find origin which points on my github repo
- // Check that given repository is properly configured git repository
+ public static String findGithubRemoteUrl(@NotNull GitRepository repository) {
+ String githubUrl = null;
for (GitRemote gitRemote : repository.getRemotes()) {
- if (getGithubUrl(gitRemote) != null){
- return gitRemote;
+ for (String remoteUrl : gitRemote.getUrls()) {
+ if (GithubUrlUtil.isGithubUrl(remoteUrl)) {
+ final String remoteName = gitRemote.getName();
+ if ("github".equals(remoteName) || "origin".equals(remoteName)) {
+ return remoteUrl;
+ }
+ if (githubUrl == null) {
+ githubUrl = remoteUrl;
+ }
+ break;
+ }
}
}
- return null;
+ return githubUrl;
}
@Nullable
- public static String getGithubUrl(final GitRemote gitRemote){
- final GithubSettings githubSettings = GithubSettings.getInstance();
- final String host = githubSettings.getHost();
- final String username = githubSettings.getLogin();
-
- // TODO this doesn't work with organizational accounts
- final String userRepoMarkerSSHProtocol = host + ":" + username + "/";
- final String userRepoMarkerOtherProtocols = host + "/" + username + "/";
- for (String pushUrl : gitRemote.getUrls()) {
- if (pushUrl.contains(userRepoMarkerSSHProtocol) || pushUrl.contains(userRepoMarkerOtherProtocols)) {
- return pushUrl;
+ public static String findGithubUpstreamRemote(@NotNull GitRepository repository) {
+ for (GitRemote gitRemote : repository.getRemotes()) {
+ final String remoteName = gitRemote.getName();
+ if ("upstream".equals(remoteName)) {
+ for (String remoteUrl : gitRemote.getUrls()) {
+ if (GithubUrlUtil.isGithubUrl(remoteUrl)) {
+ return remoteUrl;
+ }
+ }
+ return gitRemote.getFirstUrl();
}
}
return null;
@@ -356,112 +308,32 @@
final GitVersion version;
try {
version = GitVersion.identifyVersion(executable);
- } catch (Exception e) {
- Messages.showErrorDialog(project, e.getMessage(), GitBundle.getString("find.git.error.title"));
+ }
+ catch (Exception e) {
+ GithubNotifications.showErrorDialog(project, GitBundle.getString("find.git.error.title"), e.getMessage());
return false;
}
if (!version.isSupported()) {
- Messages.showWarningDialog(project, GitBundle.message("find.git.unsupported.message", version.toString(), GitVersion.MIN),
- GitBundle.getString("find.git.success.title"));
+ GithubNotifications.showWarningDialog(project, GitBundle.message("find.git.unsupported.message", version.toString(), GitVersion.MIN),
+ GitBundle.getString("find.git.success.title"));
return false;
}
return true;
}
- static boolean isRepositoryOnGitHub(@NotNull GitRepository repository) {
+ public static boolean isRepositoryOnGitHub(@NotNull GitRepository repository) {
return findGithubRemoteUrl(repository) != null;
}
- @Nullable
- static String findGithubRemoteUrl(@NotNull GitRepository repository) {
- for (GitRemote remote : repository.getRemotes()) {
- for (String url : remote.getUrls()) {
- if (isGithubUrl(url)) {
- return url;
- }
- }
- }
- return null;
- }
-
- public static boolean isGithubUrl(@NotNull String url) {
- return url.contains(GithubApiUtil.removeProtocolPrefix(GithubSettings.getInstance().getHost()));
- }
-
static void setVisibleEnabled(AnActionEvent e, boolean visible, boolean enabled) {
e.getPresentation().setVisible(visible);
e.getPresentation().setEnabled(enabled);
}
- @Nullable
- public static String getUserAndRepositoryOrShowError(@NotNull Project project, @NotNull String url) {
- int index = -1;
- if (url.startsWith(getHttpsUrl())) {
- index = url.lastIndexOf('/');
- if (index == -1) {
- Messages.showErrorDialog(project, "Cannot extract info about repository name: " + url, GithubOpenInBrowserAction.CANNOT_OPEN_IN_BROWSER);
- return null;
- }
- index = url.substring(0, index).lastIndexOf('/');
- if (index == -1) {
- Messages.showErrorDialog(project, "Cannot extract info about repository owner: " + url, GithubOpenInBrowserAction.CANNOT_OPEN_IN_BROWSER);
- return null;
- }
- }
- else {
- index = url.lastIndexOf(':');
- if (index == -1) {
- Messages.showErrorDialog(project, "Cannot extract info about repository name and owner: " + url, GithubOpenInBrowserAction.CANNOT_OPEN_IN_BROWSER);
- return null;
- }
- }
- String repoInfo = url.substring(index + 1);
- if (repoInfo.endsWith(".git")) {
- repoInfo = repoInfo.substring(0, repoInfo.length() - 4);
- }
- return repoInfo;
- }
-
- @NotNull
- static String makeGithubRepoUrlFromRemoteUrl(@NotNull String remoteUrl) {
- remoteUrl = removeEndingDotGit(remoteUrl);
- if (remoteUrl.startsWith("http")) {
- return remoteUrl;
- }
- if (remoteUrl.startsWith("git://")) {
- return "https" + remoteUrl.substring(3);
- }
- return convertFromSshToHttp(remoteUrl);
- }
-
- @NotNull
- private static String convertFromSshToHttp(@NotNull String remoteUrl) {
- // Format: git@github.com:account/repository
- int indexOfAt = remoteUrl.indexOf("@");
- if (indexOfAt < 0) {
- throw new IllegalStateException("Invalid remote Github SSH url: " + remoteUrl);
- }
- String withoutPrefix = remoteUrl.substring(indexOfAt + 1, remoteUrl.length());
- return "https://" + withoutPrefix.replace(':', '/');
- }
-
- @NotNull
- private static String removeEndingDotGit(@NotNull String url) {
- final String DOT_GIT = ".git";
- if (url.endsWith(DOT_GIT)) {
- return url.substring(0, url.length() - DOT_GIT.length());
- }
- return url;
- }
-
@NotNull
public static String getErrorTextFromException(@NotNull IOException e) {
return e.getMessage();
}
- public static void notifyError(@NotNull Project project, @NotNull String title, @NotNull String message) {
- new Notification(GITHUB_NOTIFICATION_GROUP, title, message, NotificationType.ERROR).notify(project);
- }
-
}
diff --git a/plugins/github/src/org/jetbrains/plugins/github/RepositoryInfo.java b/plugins/github/src/org/jetbrains/plugins/github/RepositoryInfo.java
index b59b0ad..a04e9ef 100644
--- a/plugins/github/src/org/jetbrains/plugins/github/RepositoryInfo.java
+++ b/plugins/github/src/org/jetbrains/plugins/github/RepositoryInfo.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2000-2013 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 org.jetbrains.plugins.github;
import org.jetbrains.annotations.NotNull;
@@ -12,17 +27,23 @@
public class RepositoryInfo {
@NotNull private final String myName;
+ @NotNull private final String myBrowserUrl;
@NotNull private final String myCloneUrl;
@NotNull private final String myOwnerName;
@Nullable private final String myParentName;
private final boolean myFork;
- public RepositoryInfo(@NotNull String name, @NotNull String cloneUrl, @NotNull String ownerName, @Nullable String parentName,
+ public RepositoryInfo(@NotNull String name,
+ @NotNull String browserUrl,
+ @NotNull String cloneUrl,
+ @NotNull String ownerName,
+ @Nullable String parentName,
boolean fork) {
myName = name;
- myParentName = parentName;
+ myBrowserUrl = browserUrl;
myCloneUrl = cloneUrl;
myOwnerName = ownerName;
+ myParentName = parentName;
myFork = fork;
}
@@ -56,4 +77,8 @@
return myCloneUrl;
}
+ @NotNull
+ public String getBrowserUrl() {
+ return myBrowserUrl;
+ }
}
diff --git a/plugins/github/src/org/jetbrains/plugins/github/ui/GitHubCreateGistDialog.java b/plugins/github/src/org/jetbrains/plugins/github/ui/GitHubCreateGistDialog.java
index 66d840b..1ea54f7 100644
--- a/plugins/github/src/org/jetbrains/plugins/github/ui/GitHubCreateGistDialog.java
+++ b/plugins/github/src/org/jetbrains/plugins/github/ui/GitHubCreateGistDialog.java
@@ -15,9 +15,12 @@
*/
package org.jetbrains.plugins.github.ui;
+import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
+import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.github.GithubSettings;
import javax.swing.*;
@@ -29,7 +32,7 @@
public class GitHubCreateGistDialog extends DialogWrapper {
private final GitHubCreateGistPanel myGithubCreateGistPanel;
- public GitHubCreateGistDialog(@NotNull final Project project) {
+ public GitHubCreateGistDialog(@NotNull final Project project, @Nullable Editor editor, @Nullable VirtualFile file) {
super(project, true);
myGithubCreateGistPanel = new GitHubCreateGistPanel();
// Use saved settings for controls
@@ -37,6 +40,13 @@
myGithubCreateGistPanel.setAnonymous(settings.isAnonymous());
myGithubCreateGistPanel.setPrivate(settings.isPrivateGist());
myGithubCreateGistPanel.setOpenInBrowser(settings.isOpenInBrowserGist());
+
+ if (file != null && !file.isDirectory()) {
+ myGithubCreateGistPanel.showFileNameField(file.getName());
+ }
+ else if (editor != null) {
+ myGithubCreateGistPanel.showFileNameField("");
+ }
setTitle("Create Gist");
init();
}
@@ -79,10 +89,16 @@
return myGithubCreateGistPanel.isAnonymous();
}
+ @NotNull
public String getDescription() {
return myGithubCreateGistPanel.getDescriptionTextArea().getText();
}
+ @Nullable
+ public String getFileName() {
+ return myGithubCreateGistPanel.getFileNameField().getText();
+ }
+
public boolean isOpenInBrowser() {
return myGithubCreateGistPanel.isOpenInBrowser();
}
diff --git a/plugins/github/src/org/jetbrains/plugins/github/ui/GitHubCreateGistPanel.form b/plugins/github/src/org/jetbrains/plugins/github/ui/GitHubCreateGistPanel.form
index 67ce3c4..9154d1e 100644
--- a/plugins/github/src/org/jetbrains/plugins/github/ui/GitHubCreateGistPanel.form
+++ b/plugins/github/src/org/jetbrains/plugins/github/ui/GitHubCreateGistPanel.form
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.plugins.github.ui.GitHubCreateGistPanel">
- <grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="4" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+ <grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="5" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
@@ -10,12 +10,12 @@
<children>
<vspacer id="1202b">
<constraints>
- <grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
+ <grid row="4" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="51bc1" class="javax.swing.JTextArea" binding="myDescriptionTextArea">
<constraints>
- <grid row="1" column="0" row-span="1" col-span="4" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false">
+ <grid row="2" column="0" row-span="1" col-span="4" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false">
<preferred-size width="150" height="50"/>
</grid>
</constraints>
@@ -23,7 +23,7 @@
</component>
<component id="b0e4d" class="javax.swing.JLabel">
<constraints>
- <grid row="0" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+ <grid row="1" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Description:"/>
@@ -31,7 +31,7 @@
</component>
<component id="5586a" class="javax.swing.JCheckBox" binding="myAnonymousCheckBox">
<constraints>
- <grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
+ <grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Anonymous"/>
@@ -39,12 +39,12 @@
</component>
<hspacer id="192a4">
<constraints>
- <grid row="2" column="3" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
+ <grid row="3" column="3" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="3fe2f" class="javax.swing.JCheckBox" binding="myPrivateCheckBox">
<constraints>
- <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
+ <grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Private"/>
@@ -52,12 +52,28 @@
</component>
<component id="9e4f3" class="javax.swing.JCheckBox" binding="myOpenInBrowserCheckBox">
<constraints>
- <grid row="2" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+ <grid row="3" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Open in browser"/>
</properties>
</component>
+ <component id="3a02a" class="javax.swing.JLabel" binding="myFileNameLabel">
+ <constraints>
+ <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+ </constraints>
+ <properties>
+ <text value="Filename:"/>
+ </properties>
+ </component>
+ <component id="6b34f" class="javax.swing.JTextField" binding="myFileNameField">
+ <constraints>
+ <grid row="0" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="1" indent="0" use-parent-layout="false">
+ <preferred-size width="150" height="-1"/>
+ </grid>
+ </constraints>
+ <properties/>
+ </component>
</children>
</grid>
</form>
diff --git a/plugins/github/src/org/jetbrains/plugins/github/ui/GitHubCreateGistPanel.java b/plugins/github/src/org/jetbrains/plugins/github/ui/GitHubCreateGistPanel.java
index ee43f40..ec4807f 100644
--- a/plugins/github/src/org/jetbrains/plugins/github/ui/GitHubCreateGistPanel.java
+++ b/plugins/github/src/org/jetbrains/plugins/github/ui/GitHubCreateGistPanel.java
@@ -15,6 +15,8 @@
*/
package org.jetbrains.plugins.github.ui;
+import org.jetbrains.annotations.NotNull;
+
import javax.swing.*;
/**
@@ -27,9 +29,13 @@
private JPanel myPanel;
private JCheckBox myAnonymousCheckBox;
private JCheckBox myOpenInBrowserCheckBox;
+ private JTextField myFileNameField;
+ private JLabel myFileNameLabel;
public GitHubCreateGistPanel() {
myDescriptionTextArea.setBorder(BorderFactory.createEtchedBorder());
+ myFileNameLabel.setVisible(false);
+ myFileNameField.setVisible(false);
}
public boolean isPrivate(){
@@ -51,10 +57,17 @@
public void setAnonymous(final boolean anonymous){
myAnonymousCheckBox.setSelected(anonymous);
}
+
public void setOpenInBrowser(final boolean openInBrowser) {
myOpenInBrowserCheckBox.setSelected(openInBrowser);
}
+ public void showFileNameField(@NotNull String filename) {
+ myFileNameLabel.setVisible(true);
+ myFileNameField.setVisible(true);
+ myFileNameField.setText(filename);
+ }
+
public JPanel getPanel() {
return myPanel;
}
@@ -63,4 +76,7 @@
return myDescriptionTextArea;
}
+ public JTextField getFileNameField() {
+ return myFileNameField;
+ }
}
diff --git a/plugins/github/src/org/jetbrains/plugins/github/ui/GithubLoginDialog.java b/plugins/github/src/org/jetbrains/plugins/github/ui/GithubLoginDialog.java
index f47404f..d40b35b 100644
--- a/plugins/github/src/org/jetbrains/plugins/github/ui/GithubLoginDialog.java
+++ b/plugins/github/src/org/jetbrains/plugins/github/ui/GithubLoginDialog.java
@@ -4,6 +4,7 @@
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.plugins.github.GithubAuthData;
import org.jetbrains.plugins.github.GithubSettings;
import org.jetbrains.plugins.github.GithubUtil;
@@ -16,20 +17,17 @@
*/
public class GithubLoginDialog extends DialogWrapper {
- private static Logger LOG = GithubUtil.LOG;
+ private static final Logger LOG = GithubUtil.LOG;
private final GithubLoginPanel myGithubLoginPanel;
- private final Project myProject;
- // TODO: login to github must be merged with tasks server settings
public GithubLoginDialog(final Project project) {
super(project, true);
- myProject = project;
myGithubLoginPanel = new GithubLoginPanel(this);
final GithubSettings settings = GithubSettings.getInstance();
myGithubLoginPanel.setHost(settings.getHost());
myGithubLoginPanel.setLogin(settings.getLogin());
- myGithubLoginPanel.setPassword(settings.getPassword());
+ myGithubLoginPanel.setPassword("");
setTitle("Login to GitHub");
setOKButtonText("Login");
init();
@@ -37,7 +35,7 @@
@NotNull
protected Action[] createActions() {
- return new Action[] {getOKAction(), getCancelAction(), getHelpAction()};
+ return new Action[]{getOKAction(), getCancelAction(), getHelpAction()};
}
@Override
@@ -57,16 +55,12 @@
@Override
protected void doOKAction() {
- final String login = myGithubLoginPanel.getLogin();
- final String password = myGithubLoginPanel.getPassword();
- final String host = myGithubLoginPanel.getHost();
+ final GithubAuthData auth = myGithubLoginPanel.getAuthData();
try {
- boolean loggedSuccessfully = GithubUtil.checkCredentials(myProject, host, login, password);
+ boolean loggedSuccessfully = GithubUtil.checkAuthData(auth);
if (loggedSuccessfully) {
final GithubSettings settings = GithubSettings.getInstance();
- settings.setLogin(login);
- settings.setPassword(password);
- settings.setHost(host);
+ settings.setAuthData(auth, myGithubLoginPanel.shouldSavePassword());
super.doOKAction();
}
else {
@@ -82,4 +76,9 @@
public void clearErrors() {
setErrorText(null);
}
+
+ @NotNull
+ public GithubAuthData getAuthData() {
+ return myGithubLoginPanel.getAuthData();
+ }
}
\ No newline at end of file
diff --git a/plugins/github/src/org/jetbrains/plugins/github/ui/GithubLoginPanel.form b/plugins/github/src/org/jetbrains/plugins/github/ui/GithubLoginPanel.form
index 918a123..9a4c2a4 100644
--- a/plugins/github/src/org/jetbrains/plugins/github/ui/GithubLoginPanel.form
+++ b/plugins/github/src/org/jetbrains/plugins/github/ui/GithubLoginPanel.form
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.plugins.github.ui.GithubLoginPanel">
- <grid id="27dc6" binding="myPane" layout-manager="GridLayoutManager" row-count="5" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+ <grid id="27dc6" binding="myPane" layout-manager="GridLayoutManager" row-count="6" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="168"/>
@@ -15,9 +15,6 @@
</grid>
</constraints>
<properties/>
- <clientProperties>
- <caretAspectRatio class="java.lang.Float" value="0.04"/>
- </clientProperties>
</component>
<component id="c0234" class="javax.swing.JLabel">
<constraints>
@@ -37,7 +34,7 @@
</component>
<component id="28ddd" class="javax.swing.JTextPane" binding="mySignupTextField">
<constraints>
- <grid row="3" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
+ <grid row="4" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<contentType value="text/html"/>
@@ -47,7 +44,6 @@
</properties>
<clientProperties>
<JEditorPane.honorDisplayProperties class="java.lang.Boolean" value="true"/>
- <caretAspectRatio class="java.lang.Float" value="0.04"/>
</clientProperties>
</component>
<component id="9edbd" class="javax.swing.JPasswordField" binding="myPasswordField">
@@ -57,13 +53,10 @@
</grid>
</constraints>
<properties/>
- <clientProperties>
- <caretAspectRatio class="java.lang.Float" value="0.04"/>
- </clientProperties>
</component>
<vspacer id="9b306">
<constraints>
- <grid row="4" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
+ <grid row="5" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="dbea1" class="javax.swing.JLabel">
@@ -81,9 +74,15 @@
</grid>
</constraints>
<properties/>
- <clientProperties>
- <caretAspectRatio class="java.lang.Float" value="0.04"/>
- </clientProperties>
+ </component>
+ <component id="b466f" class="javax.swing.JCheckBox" binding="mySavePasswordCheckBox">
+ <constraints>
+ <grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+ </constraints>
+ <properties>
+ <selected value="true"/>
+ <text value="Save password"/>
+ </properties>
</component>
</children>
</grid>
diff --git a/plugins/github/src/org/jetbrains/plugins/github/ui/GithubLoginPanel.java b/plugins/github/src/org/jetbrains/plugins/github/ui/GithubLoginPanel.java
index f88a4c1..9c12f47 100644
--- a/plugins/github/src/org/jetbrains/plugins/github/ui/GithubLoginPanel.java
+++ b/plugins/github/src/org/jetbrains/plugins/github/ui/GithubLoginPanel.java
@@ -16,9 +16,14 @@
package org.jetbrains.plugins.github.ui;
import com.intellij.ide.BrowserUtil;
+import com.intellij.ide.passwordSafe.PasswordSafe;
+import com.intellij.ide.passwordSafe.config.PasswordSafeSettings;
+import com.intellij.ide.passwordSafe.impl.PasswordSafeImpl;
import com.intellij.ui.DocumentAdapter;
import com.intellij.ui.HyperlinkAdapter;
import com.intellij.util.ui.UIUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.plugins.github.GithubAuthData;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
@@ -36,6 +41,7 @@
private JTextField myLoginTextField;
private JPasswordField myPasswordField;
private JTextPane mySignupTextField;
+ private JCheckBox mySavePasswordCheckBox;
public GithubLoginPanel(final GithubLoginDialog dialog) {
DocumentListener listener = new DocumentAdapter() {
@@ -56,6 +62,11 @@
});
mySignupTextField.setBackground(UIUtil.TRANSPARENT_COLOR);
mySignupTextField.setCursor(new Cursor(Cursor.HAND_CURSOR));
+ final PasswordSafeImpl passwordSafe = (PasswordSafeImpl)PasswordSafe.getInstance();
+ if (passwordSafe.getSettings().getProviderType() != PasswordSafeSettings.ProviderType.MASTER_PASSWORD) {
+ mySavePasswordCheckBox.setVisible(false);
+ mySavePasswordCheckBox.setSelected(true);
+ }
}
public JComponent getPanel() {
@@ -86,8 +97,17 @@
return String.valueOf(myPasswordField.getPassword());
}
+ public boolean shouldSavePassword() {
+ return mySavePasswordCheckBox.isSelected();
+ }
+
public JComponent getPreferrableFocusComponent() {
return myLoginTextField;
}
+
+ @NotNull
+ public GithubAuthData getAuthData() {
+ return new GithubAuthData(getHost(), getLogin(), getPassword());
+ }
}
diff --git a/plugins/github/src/org/jetbrains/plugins/github/ui/GithubSettingsPanel.java b/plugins/github/src/org/jetbrains/plugins/github/ui/GithubSettingsPanel.java
index 1eadf6b..627d6ae 100644
--- a/plugins/github/src/org/jetbrains/plugins/github/ui/GithubSettingsPanel.java
+++ b/plugins/github/src/org/jetbrains/plugins/github/ui/GithubSettingsPanel.java
@@ -17,10 +17,10 @@
import com.intellij.ide.BrowserUtil;
import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.HyperlinkAdapter;
+import org.jetbrains.plugins.github.GithubAuthData;
import org.jetbrains.plugins.github.GithubSettings;
import org.jetbrains.plugins.github.GithubUtil;
@@ -38,7 +38,7 @@
* @date 10/20/10
*/
public class GithubSettingsPanel {
- private static Logger LOG = GithubUtil.LOG;
+ private static final Logger LOG = GithubUtil.LOG;
private JTextField myLoginTextField;
private JPasswordField myPasswordField;
@@ -65,7 +65,7 @@
public void actionPerformed(ActionEvent e) {
String password = isPasswordModified() ? getPassword() : settings.getPassword();
try {
- if (GithubUtil.checkCredentials(ProjectManager.getInstance().getDefaultProject(), getHost(), getLogin(), password)){
+ if (GithubUtil.checkAuthData(new GithubAuthData(getHost(), getLogin(), password))) {
Messages.showInfoMessage(myPane, "Connection successful", "Success");
} else {
Messages.showErrorDialog(myPane, "Can't login to " + getHost() + " using given credentials", "Login Failure");
diff --git a/plugins/github/src/org/jetbrains/plugins/github/ui/GithubShareDialog.java b/plugins/github/src/org/jetbrains/plugins/github/ui/GithubShareDialog.java
index 2f90e69..974fb41 100644
--- a/plugins/github/src/org/jetbrains/plugins/github/ui/GithubShareDialog.java
+++ b/plugins/github/src/org/jetbrains/plugins/github/ui/GithubShareDialog.java
@@ -4,6 +4,7 @@
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.util.text.StringUtil;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.TestOnly;
import javax.swing.*;
import java.util.Set;
@@ -14,8 +15,8 @@
* @date 10/22/10
*/
public class GithubShareDialog extends DialogWrapper {
- private static final Pattern GITHUB_REPO_PATTERN = Pattern.compile("[a-zA-Z0-9_-]+");
- private GithubSharePanel myGithubSharePanel;
+ private static final Pattern GITHUB_REPO_PATTERN = Pattern.compile("[a-zA-Z0-9_.-]+");
+ private final GithubSharePanel myGithubSharePanel;
private final Set<String> myAvailableNames;
public GithubShareDialog(final Project project, final Set<String> availableNames, final boolean privateRepoAllowed) {
@@ -64,7 +65,7 @@
return;
}
if (!GITHUB_REPO_PATTERN.matcher(repositoryName).matches()){
- setErrorText("Invalid repository name. Name should consist of letters, numbers, dashes and underscores");
+ setErrorText("Invalid repository name. Name should consist of letters, numbers, dashes, dots and underscores");
setOKActionEnabled(false);
return;
}
@@ -83,4 +84,9 @@
public String getDescription() {
return myGithubSharePanel.getDescription();
}
+
+ @TestOnly
+ public void setRepositoryName(@NotNull String name) {
+ myGithubSharePanel.setRepositoryName(name);
+ }
}
diff --git a/plugins/github/test/org/jetbrains/plugins/github/GithubCreateGistContentTest.java b/plugins/github/test/org/jetbrains/plugins/github/GithubCreateGistContentTest.java
new file mode 100644
index 0000000..94667d2
--- /dev/null
+++ b/plugins/github/test/org/jetbrains/plugins/github/GithubCreateGistContentTest.java
@@ -0,0 +1,145 @@
+/*
+ * Copyright 2000-2013 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 org.jetbrains.plugins.github;
+
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.editor.impl.EditorImpl;
+import com.intellij.openapi.fileEditor.FileEditorManager;
+import com.intellij.openapi.fileEditor.OpenFileDescriptor;
+import com.intellij.openapi.vfs.VirtualFile;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.jetbrains.plugins.github.GithubCreateGistAction.NamedContent;
+
+/**
+ * @author Aleksey Pivovarov
+ */
+public class GithubCreateGistContentTest extends GithubCreateGistTestBase {
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ createProjectFiles();
+ }
+
+ public void testCreateFromFile() throws Throwable {
+ List<NamedContent> expected = new ArrayList<NamedContent>();
+ expected.add(new NamedContent("file.txt", "file.txt content"));
+
+ VirtualFile file = myProjectRoot.findFileByRelativePath("file.txt");
+ assertNotNull(file);
+
+ List<NamedContent> actual = GithubCreateGistAction.collectContents(myProject, null, file, null);
+
+ checkEquals(expected, actual);
+ }
+
+ public void testCreateFromDirectory() throws Throwable {
+ List<NamedContent> expected = new ArrayList<NamedContent>();
+ expected.add(new NamedContent("folder_file1", "file1 content"));
+ expected.add(new NamedContent("folder_file2", "file2 content"));
+ expected.add(new NamedContent("folder_dir_file3", "file3 content"));
+
+ VirtualFile file = myProjectRoot.findFileByRelativePath("folder");
+ assertNotNull(file);
+
+ List<NamedContent> actual = GithubCreateGistAction.collectContents(myProject, null, file, null);
+
+ checkEquals(expected, actual);
+ }
+
+ public void testCreateFromEmptyDirectory() throws Throwable {
+ List<NamedContent> expected = new ArrayList<NamedContent>();
+
+ VirtualFile file = myProjectRoot.findFileByRelativePath("folder/empty_folder");
+ assertNotNull(file);
+
+ List<NamedContent> actual = GithubCreateGistAction.collectContents(myProject, null, file, null);
+
+ checkEquals(expected, actual);
+ }
+
+ public void testCreateFromEmptyFile() throws Throwable {
+ List<NamedContent> expected = new ArrayList<NamedContent>();
+
+ VirtualFile file = myProjectRoot.findFileByRelativePath("folder/empty_file");
+ assertNotNull(file);
+
+ List<NamedContent> actual = GithubCreateGistAction.collectContents(myProject, null, file, null);
+
+ checkEquals(expected, actual);
+ }
+
+ public void testCreateFromFiles() throws Throwable {
+ List<NamedContent> expected = new ArrayList<NamedContent>();
+ expected.add(new NamedContent("file.txt", "file.txt content"));
+ expected.add(new NamedContent("file2", "file2 content"));
+ expected.add(new NamedContent("file3", "file3 content"));
+
+ VirtualFile[] files = new VirtualFile[3];
+ files[0] = myProjectRoot.findFileByRelativePath("file.txt");
+ files[1] = myProjectRoot.findFileByRelativePath("folder/file2");
+ files[2] = myProjectRoot.findFileByRelativePath("folder/dir/file3");
+ assertNotNull(files[0]);
+ assertNotNull(files[1]);
+ assertNotNull(files[2]);
+
+ List<NamedContent> actual = GithubCreateGistAction.collectContents(myProject, null, null, files);
+
+ checkEquals(expected, actual);
+ }
+
+ public void testCreateFromEmptyFiles() throws Throwable {
+ List<NamedContent> expected = new ArrayList<NamedContent>();
+
+ VirtualFile[] files = new VirtualFile[0];
+
+ List<NamedContent> actual = GithubCreateGistAction.collectContents(myProject, null, null, files);
+
+ checkEquals(expected, actual);
+ }
+
+ public void testCreateFromEditor() throws Throwable {
+ VirtualFile file = myProjectRoot.findFileByRelativePath("file.txt");
+ assertNotNull(file);
+ Editor editor = FileEditorManager.getInstance(myProject).openTextEditor(new OpenFileDescriptor(myProject, file, 0), false);
+ assertNotNull(editor);
+ ((EditorImpl)editor).setCaretActive();
+
+ List<NamedContent> expected = new ArrayList<NamedContent>();
+ expected.add(new NamedContent("file.txt", "file.txt content"));
+
+ List<NamedContent> actual = GithubCreateGistAction.collectContents(myProject, editor, file, null);
+
+ checkEquals(expected, actual);
+ }
+
+ public void testCreateFromEditorWithoutFile() throws Throwable {
+ VirtualFile file = myProjectRoot.findFileByRelativePath("file.txt");
+ assertNotNull(file);
+ Editor editor = FileEditorManager.getInstance(myProject).openTextEditor(new OpenFileDescriptor(myProject, file, 0), false);
+ assertNotNull(editor);
+ ((EditorImpl)editor).setCaretActive();
+
+ List<NamedContent> expected = new ArrayList<NamedContent>();
+ expected.add(new NamedContent("", "file.txt content"));
+
+ List<NamedContent> actual = GithubCreateGistAction.collectContents(myProject, editor, null, null);
+
+ checkEquals(expected, actual);
+ }
+}
diff --git a/plugins/github/test/org/jetbrains/plugins/github/GithubCreateGistTest.java b/plugins/github/test/org/jetbrains/plugins/github/GithubCreateGistTest.java
new file mode 100644
index 0000000..7cfc39f
--- /dev/null
+++ b/plugins/github/test/org/jetbrains/plugins/github/GithubCreateGistTest.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright 2000-2013 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 org.jetbrains.plugins.github;
+
+import com.intellij.notification.NotificationType;
+
+import java.util.Collections;
+import java.util.List;
+
+import static org.jetbrains.plugins.github.GithubCreateGistAction.NamedContent;
+
+/**
+ * @author Aleksey Pivovarov
+ */
+public class GithubCreateGistTest extends GithubCreateGistTestBase {
+ public void testSimple() throws Throwable {
+ List<NamedContent> expected = createContent();
+
+ String url = GithubCreateGistAction.createGist(myProject, myGitHubSettings.getAuthData(), expected, true, "description", null);
+ assertNotNull(url);
+ GIST_ID = url.substring(url.lastIndexOf('/') + 1);
+
+ checkGistExists();
+ checkGistNotAnonymous();
+ checkGistPrivate();
+ checkGistDescription("description");
+ checkGistContent(expected);
+ }
+
+ public void testAnonymous() throws Throwable {
+ List<NamedContent> expected = createContent();
+
+ String url = GithubCreateGistAction.createGist(myProject, null, expected, true, "description", null);
+ assertNotNull(url);
+ GIST_ID = url.substring(url.lastIndexOf('/') + 1);
+
+ checkGistExists();
+ checkGistAnonymous();
+ checkGistPrivate();
+ checkGistDescription("description");
+ checkGistContent(expected);
+
+ // anonymous gists - undeletable
+ GIST_ID = null;
+ GIST = null;
+ }
+
+ public void testUnusedFilenameField() throws Throwable {
+ List<NamedContent> expected = createContent();
+
+ String url = GithubCreateGistAction.createGist(myProject, myGitHubSettings.getAuthData(), expected, true, "description", "filename");
+ assertNotNull(url);
+ GIST_ID = url.substring(url.lastIndexOf('/') + 1);
+
+ checkGistExists();
+ checkGistNotAnonymous();
+ checkGistPrivate();
+ checkGistDescription("description");
+ checkGistContent(expected);
+ }
+
+ public void testUsedFilenameField() throws Throwable {
+ List<NamedContent> content = Collections.singletonList(new NamedContent("file.txt", "file.txt content"));
+ List<NamedContent> expected = Collections.singletonList(new NamedContent("filename", "file.txt content"));
+
+ String url = GithubCreateGistAction.createGist(myProject, myGitHubSettings.getAuthData(), content, true, "description", "filename");
+ assertNotNull(url);
+ GIST_ID = url.substring(url.lastIndexOf('/') + 1);
+
+ checkGistExists();
+ checkGistNotAnonymous();
+ checkGistPrivate();
+ checkGistDescription("description");
+ checkGistContent(expected);
+ }
+
+ public void testPublic() throws Throwable {
+ List<NamedContent> expected = createContent();
+
+ String url = GithubCreateGistAction.createGist(myProject, myGitHubSettings.getAuthData(), expected, false, "description", null);
+ assertNotNull(url);
+ GIST_ID = url.substring(url.lastIndexOf('/') + 1);
+
+ checkGistExists();
+ checkGistNotAnonymous();
+ checkGistPublic();
+ checkGistDescription("description");
+ checkGistContent(expected);
+ }
+
+ public void testEmpty() throws Throwable {
+ List<NamedContent> expected = Collections.emptyList();
+
+ String url = GithubCreateGistAction.createGist(myProject, myGitHubSettings.getAuthData(), expected, true, "description", null);
+ assertNull("Gist was created", url);
+
+ checkNotification(NotificationType.WARNING, "Can't create Gist", "Can't create empty gist");
+ }
+
+ public void testWrongLogin() throws Throwable {
+ List<NamedContent> expected = createContent();
+
+ GithubAuthData auth = myGitHubSettings.getAuthData();
+ GithubAuthData myAuth = new GithubAuthData(auth.getHost(), auth.getLogin() + "some_suffix", auth.getPassword());
+ String url = GithubCreateGistAction.createGist(myProject, myAuth, expected, true, "description", null);
+ assertNull("Gist was created", url);
+
+ checkNotification(NotificationType.ERROR, "Can't create Gist", null);
+ }
+
+ public void testWrongPassword() throws Throwable {
+ List<NamedContent> expected = createContent();
+
+ GithubAuthData auth = myGitHubSettings.getAuthData();
+ GithubAuthData myAuth = new GithubAuthData(auth.getHost(), auth.getLogin(), auth.getPassword() + "some_suffix");
+ String url = GithubCreateGistAction.createGist(myProject, myAuth, expected, true, "description", null);
+ assertNull("Gist was created", url);
+
+ checkNotification(NotificationType.ERROR, "Can't create Gist", null);
+ }
+
+
+}
diff --git a/plugins/github/test/org/jetbrains/plugins/github/GithubCreateGistTestBase.java b/plugins/github/test/org/jetbrains/plugins/github/GithubCreateGistTestBase.java
new file mode 100644
index 0000000..f01b5b0
--- /dev/null
+++ b/plugins/github/test/org/jetbrains/plugins/github/GithubCreateGistTestBase.java
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2000-2013 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 org.jetbrains.plugins.github;
+
+import com.google.gson.JsonObject;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.plugins.github.test.GithubTest;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.jetbrains.plugins.github.GithubCreateGistAction.NamedContent;
+
+/**
+ * @author Aleksey Pivovarov
+ */
+public abstract class GithubCreateGistTestBase extends GithubTest {
+ protected String GIST_ID = null;
+ protected JsonObject GIST = null;
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ try {
+ deleteGist();
+ }
+ finally {
+ super.tearDown();
+ }
+ }
+
+ protected void deleteGist() throws IOException {
+ if (GIST_ID != null) {
+ GithubUtil.deleteGist(myGitHubSettings.getAuthData(), GIST_ID);
+ GIST = null;
+ GIST_ID = null;
+ }
+ }
+
+ @NotNull
+ protected static List<NamedContent> createContent() {
+ List<NamedContent> content = new ArrayList<NamedContent>();
+
+ content.add(new NamedContent("file1", "file1 content"));
+ content.add(new NamedContent("file2", "file2 content"));
+ content.add(new NamedContent("dir_file3", "file3 content"));
+
+ return content;
+ }
+
+ @NotNull
+ protected JsonObject getGist() {
+ assertNotNull(GIST_ID);
+
+ if (GIST == null) {
+ try {
+ GIST = GithubUtil.getGist(myGitHubSettings.getAuthData(), GIST_ID);
+ }
+ catch (IOException e) {
+ System.err.println(e.getMessage());
+ }
+ }
+
+ assertNotNull("Gist does not exist", GIST);
+ return GIST;
+ }
+
+ protected void checkGistExists() {
+ getGist();
+ }
+
+ protected void checkGistPublic() {
+ JsonObject result = getGist();
+
+ assertTrue("Gist does not public", result.get("public").getAsBoolean());
+ }
+
+ protected void checkGistPrivate() {
+ JsonObject result = getGist();
+
+ assertFalse("Gist does not private", result.get("public").getAsBoolean());
+ }
+
+ protected void checkGistAnonymous() {
+ JsonObject result = getGist();
+
+ assertTrue("Gist does not anonymous", result.get("user").isJsonNull());
+ }
+
+ protected void checkGistNotAnonymous() {
+ JsonObject result = getGist();
+
+ assertFalse("Gist does not anonymous", result.get("user").isJsonNull());
+ }
+
+ protected void checkGistDescription(@NotNull String expected) {
+ JsonObject result = getGist();
+
+ assertEquals("Gist content differs from sample", expected, result.get("description").getAsString());
+ }
+
+ protected void checkGistContent(@NotNull List<NamedContent> expected) {
+ JsonObject result = getGist();
+
+ JsonObject files = result.get("files").getAsJsonObject();
+
+ for (NamedContent file : expected) {
+ String content = files.get(file.getName()).getAsJsonObject().get("content").getAsString();
+ assertEquals("Gist content differs from sample", file.getText(), content);
+ }
+ }
+
+ protected void checkEquals(@NotNull List<NamedContent> expected, @NotNull List<NamedContent> actual) {
+ for (NamedContent file : expected) {
+ assertTrue("Not found: <" + file.getName() + "> " + file.getText(), actual.contains(file));
+ }
+
+ assertEquals("Expected less elements", expected.size(), actual.size());
+ }
+}
diff --git a/plugins/github/test/org/jetbrains/plugins/github/GithubRequestPagingTest.java b/plugins/github/test/org/jetbrains/plugins/github/GithubRequestPagingTest.java
new file mode 100644
index 0000000..4accdbe
--- /dev/null
+++ b/plugins/github/test/org/jetbrains/plugins/github/GithubRequestPagingTest.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2000-2013 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 org.jetbrains.plugins.github;
+
+import org.jetbrains.plugins.github.test.GithubTest;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.Assume.assumeNotNull;
+
+/**
+ * @author Aleksey Pivovarov
+ */
+public class GithubRequestPagingTest extends GithubTest {
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ assumeNotNull(myLogin2);
+ }
+
+ public void testAvailableRepos() throws Throwable {
+
+ List<RepositoryInfo> availableRepos = GithubUtil.getAvailableRepos(myGitHubSettings.getAuthData(), myLogin2);
+ List<String> realData = new ArrayList<String>();
+ for (RepositoryInfo info : availableRepos) {
+ realData.add(info.getName());
+ }
+
+ List<String> expectedData = new ArrayList<String>();
+ for (int i = 1; i <= 251; i++) {
+ expectedData.add(String.valueOf(i));
+ }
+
+ assertContainsElements(realData, expectedData);
+ }
+}
diff --git a/plugins/github/test/org/jetbrains/plugins/github/GithubShareProjectTest.java b/plugins/github/test/org/jetbrains/plugins/github/GithubShareProjectTest.java
new file mode 100644
index 0000000..4a9ff67
--- /dev/null
+++ b/plugins/github/test/org/jetbrains/plugins/github/GithubShareProjectTest.java
@@ -0,0 +1,91 @@
+package org.jetbrains.plugins.github;
+
+import com.intellij.notification.NotificationType;
+import com.intellij.openapi.components.ServiceManager;
+import git4idea.commands.Git;
+
+import static com.intellij.dvcs.test.Executor.cd;
+import static git4idea.test.GitExecutor.git;
+
+/**
+ * @author Aleksey Pivovarov
+ */
+public class GithubShareProjectTest extends GithubShareProjectTestBase {
+
+ public void testSimple() throws Throwable {
+ registerDefaultShareDialogHandler();
+ registerDefaultUntrackedFilesDialogHandler();
+
+ createProjectFiles();
+
+ GithubShareAction.shareProjectOnGithub(myProject, myProjectRoot);
+
+ checkNotification(NotificationType.INFORMATION, "Successfully created project on GitHub", null);
+ checkGitExists();
+ checkGithubExists();
+ checkRemoteConfigured();
+ checkLastCommitPushed();
+ }
+
+ public void testGithubAlreadyExists() throws Throwable {
+ registerDefaultShareDialogHandler();
+ registerDefaultUntrackedFilesDialogHandler();
+
+ createProjectFiles();
+ GithubShareAction.shareProjectOnGithub(myProject, myProjectRoot);
+ GithubShareAction.shareProjectOnGithub(myProject, myProjectRoot);
+
+ checkNotification(NotificationType.INFORMATION, "Project is already on GitHub", null);
+ }
+
+ public void testExistingGit() throws Throwable {
+ registerDefaultShareDialogHandler();
+ registerDefaultUntrackedFilesDialogHandler();
+
+ createProjectFiles();
+
+ cd(myProjectRoot.getPath());
+ git("init");
+ git("add file.txt");
+ git("commit -m init");
+
+ GithubShareAction.shareProjectOnGithub(myProject, myProjectRoot);
+
+ checkNotification(NotificationType.INFORMATION, "Successfully created project on GitHub", null);
+ checkGitExists();
+ checkGithubExists();
+ checkRemoteConfigured();
+ checkLastCommitPushed();
+ }
+
+ public void testExistingFreshGit() throws Throwable {
+ registerDefaultShareDialogHandler();
+ registerDefaultUntrackedFilesDialogHandler();
+
+ createProjectFiles();
+
+ Git git = ServiceManager.getService(Git.class);
+ git.init(myProject, myProjectRoot);
+
+ GithubShareAction.shareProjectOnGithub(myProject, myProjectRoot);
+
+ checkNotification(NotificationType.INFORMATION, "Successfully created project on GitHub", null);
+ checkGitExists();
+ checkGithubExists();
+ checkRemoteConfigured();
+ checkLastCommitPushed();
+ }
+
+ public void testEmptyProject() throws Throwable {
+ registerDefaultUntrackedFilesDialogHandler();
+ registerDefaultShareDialogHandler();
+
+ GithubShareAction.shareProjectOnGithub(myProject, myProjectRoot);
+
+ checkNotification(NotificationType.WARNING, "Failed to commit file during post activities", "No files to commit");
+ checkGitExists();
+ checkGithubExists();
+ checkRemoteConfigured();
+ }
+
+}
diff --git a/plugins/github/test/org/jetbrains/plugins/github/GithubShareProjectTestBase.java b/plugins/github/test/org/jetbrains/plugins/github/GithubShareProjectTestBase.java
new file mode 100644
index 0000000..c8d6230
--- /dev/null
+++ b/plugins/github/test/org/jetbrains/plugins/github/GithubShareProjectTestBase.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2000-2013 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 org.jetbrains.plugins.github;
+
+import com.intellij.openapi.ui.DialogWrapper;
+import git4idea.GitUtil;
+import git4idea.repo.GitRepository;
+import git4idea.repo.GitRepositoryManager;
+import git4idea.test.GitExecutor;
+import git4idea.test.TestDialogHandler;
+import org.jetbrains.plugins.github.test.GithubTest;
+import org.jetbrains.plugins.github.ui.GithubShareDialog;
+
+import java.io.IOException;
+import java.util.Random;
+
+/**
+ * @author Aleksey Pivovarov
+ */
+public abstract class GithubShareProjectTestBase extends GithubTest {
+ protected String PROJECT_NAME;
+ protected GitRepositoryManager myGitRepositoryManager;
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+
+ myGitRepositoryManager = GitUtil.getRepositoryManager(myProject);
+ Random rnd = new Random();
+ PROJECT_NAME = "new_project_from_share_test_" + rnd.nextLong();
+ registerHttpAuthService();
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ try {
+ deleteGithubRepo();
+ }
+ finally {
+ super.tearDown();
+ }
+ }
+
+ protected void deleteGithubRepo() throws IOException {
+ GithubUtil.deleteGithubRepository(myGitHubSettings.getAuthData(), PROJECT_NAME);
+ }
+
+ protected void registerDefaultShareDialogHandler() {
+ myDialogManager.registerDialogHandler(GithubShareDialog.class, new TestDialogHandler<GithubShareDialog>() {
+ @Override
+ public int handleDialog(GithubShareDialog dialog) {
+ dialog.setRepositoryName(PROJECT_NAME);
+ return DialogWrapper.OK_EXIT_CODE;
+ }
+ });
+ }
+
+ protected void registerDefaultUntrackedFilesDialogHandler() {
+ myDialogManager.registerDialogHandler(GithubShareAction.GithubUntrackedFilesDialog.class,
+ new TestDialogHandler<GithubShareAction.GithubUntrackedFilesDialog>() {
+ @Override
+ public int handleDialog(GithubShareAction.GithubUntrackedFilesDialog dialog) {
+ return DialogWrapper.OK_EXIT_CODE;
+ }
+ });
+ }
+
+ protected void checkGithubExists() throws IOException {
+ GithubAuthData auth = myGitHubSettings.getAuthData();
+ RepositoryInfo githubInfo = GithubUtil.getDetailedRepoInfo(auth, auth.getLogin(), PROJECT_NAME);
+ assertNotNull("GitHub repository does not exist", githubInfo);
+ }
+
+ protected void checkGitExists() {
+ final GitRepository gitRepository = myGitRepositoryManager.getRepositoryForFile(myProjectRoot);
+ assertNotNull("Git repository does not exist", gitRepository);
+ }
+
+ protected void checkRemoteConfigured() {
+ final GitRepository gitRepository = myGitRepositoryManager.getRepositoryForFile(myProjectRoot);
+ assertNotNull(gitRepository);
+
+ assertNotNull("GitHub remote is not configured", GithubUtil.findGithubRemoteUrl(gitRepository));
+ }
+
+ protected void checkLastCommitPushed() {
+ final GitRepository gitRepository = myGitRepositoryManager.getRepositoryForFile(myProjectRoot);
+ assertNotNull(gitRepository);
+
+ String hash = GitExecutor.git(gitRepository, "log -1 --pretty=%h");
+ String ans = GitExecutor.git(gitRepository, "branch --contains " + hash + " -a");
+ assertTrue(ans.contains("remotes/origin/master"));
+ }
+}
diff --git a/plugins/github/test/org/jetbrains/plugins/github/GithubUrlUtilTest.java b/plugins/github/test/org/jetbrains/plugins/github/GithubUrlUtilTest.java
new file mode 100644
index 0000000..05c6705
--- /dev/null
+++ b/plugins/github/test/org/jetbrains/plugins/github/GithubUrlUtilTest.java
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2000-2013 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 org.jetbrains.plugins.github;
+
+import com.intellij.openapi.util.Pair;
+import com.intellij.testFramework.UsefulTestCase;
+import com.intellij.util.containers.Convertor;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.jetbrains.plugins.github.GithubUrlUtil.isGithubUrl;
+import static org.jetbrains.plugins.github.GithubUrlUtil.removeProtocolPrefix;
+import static org.jetbrains.plugins.github.GithubUrlUtil.removeTrailingSlash;
+
+/**
+ * @author Aleksey Pivovarov
+ */
+public class GithubUrlUtilTest extends UsefulTestCase {
+ private static class TestCase<T> {
+ @NotNull final public List<Pair<String, T>> tests = new ArrayList<Pair<String, T>>();
+
+ public void add(String in, T out) {
+ tests.add(Pair.create(in, out));
+ }
+
+ }
+
+ private static <T> void runTestCase(@NotNull TestCase<T> tests, @NotNull Convertor<String, T> func) {
+ for (Pair<String, T> test : tests.tests) {
+ assertEquals(test.getFirst(), test.getSecond(), func.convert(test.getFirst()));
+ }
+ }
+
+ public void testRemoveTrailingSlash() throws Throwable {
+ TestCase<String> tests = new TestCase<String>();
+
+ tests.add("http://github.com/", "http://github.com");
+ tests.add("http://github.com", "http://github.com");
+
+ tests.add("http://github.com/user/repo/", "http://github.com/user/repo");
+ tests.add("http://github.com/user/repo", "http://github.com/user/repo");
+
+ runTestCase(tests, new Convertor<String, String>() {
+ @Override
+ public String convert(String in) {
+ return removeTrailingSlash(in);
+ }
+ });
+ }
+
+ public void testRemoveProtocolPrefix() throws Throwable {
+ TestCase<String> tests = new TestCase<String>();
+
+ tests.add("github.com/user/repo/", "github.com/user/repo/");
+ tests.add("api.github.com/user/repo/", "api.github.com/user/repo/");
+
+ tests.add("http://github.com/user/repo/", "github.com/user/repo/");
+ tests.add("https://github.com/user/repo/", "github.com/user/repo/");
+ tests.add("git://github.com/user/repo/", "github.com/user/repo/");
+ tests.add("git@github.com/user/repo/", "github.com/user/repo/");
+
+ tests.add("git@github.com:username/user/repo/", "github.com:username/user/repo/");
+ tests.add("https://username:password@github.com/user/repo/", "github.com/user/repo/");
+ tests.add("https://username@github.com/user/repo/", "github.com/user/repo/");
+ tests.add("https://github.com:2233/user/repo/", "github.com:2233/user/repo/");
+
+ tests.add("HTTP://GITHUB.com/user/repo/", "GITHUB.com/user/repo/");
+ tests.add("HttP://GITHUB.com/user/repo/", "GITHUB.com/user/repo/");
+
+ runTestCase(tests, new Convertor<String, String>() {
+ @Override
+ public String convert(String in) {
+ return removeProtocolPrefix(in);
+ }
+ });
+ }
+
+ public void testIsGithubUrl() throws Throwable {
+ TestCase<Boolean> tests = new TestCase<Boolean>();
+
+ tests.add("http://github.com/user/repo", true);
+ tests.add("https://github.com/user/repo", true);
+ tests.add("git://github.com/user/repo", true);
+ tests.add("git@github.com/user/repo", true);
+
+ tests.add("https://github.com/", true);
+ tests.add("github.com", true);
+
+ tests.add("https://user@github.com/user/repo", true);
+ tests.add("https://user:password@github.com/user/repo", true);
+ tests.add("git@github.com:user/user/repo", true);
+
+ tests.add("https://github.com:2233/", true);
+
+ tests.add("HTTPS://GitHub.com:2233/", true);
+
+ tests.add("google.com", false);
+ tests.add("github.com.site.ua", false);
+ tests.add("sf@hskfh../.#fwenj 32#$", false);
+ tests.add("api.github.com", false);
+ tests.add("site.com//github.com", false);
+
+ runTestCase(tests, new Convertor<String, Boolean>() {
+ @Override
+ public Boolean convert(String in) {
+ return isGithubUrl(in, removeTrailingSlash(removeProtocolPrefix("https://github.com/")));
+ }
+ });
+ runTestCase(tests, new Convertor<String, Boolean>() {
+ @Override
+ public Boolean convert(String in) {
+ return isGithubUrl(in, removeTrailingSlash(removeProtocolPrefix("http://GitHub.com")));
+ }
+ });
+ }
+}
diff --git a/plugins/github/test/org/jetbrains/plugins/github/test/GithubTest.java b/plugins/github/test/org/jetbrains/plugins/github/test/GithubTest.java
new file mode 100644
index 0000000..49ffb77
--- /dev/null
+++ b/plugins/github/test/org/jetbrains/plugins/github/test/GithubTest.java
@@ -0,0 +1,174 @@
+/*
+ * Copyright 2000-2013 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 org.jetbrains.plugins.github.test;
+
+import com.intellij.notification.Notification;
+import com.intellij.notification.NotificationType;
+import com.intellij.openapi.components.ServiceManager;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.testFramework.PlatformTestCase;
+import com.intellij.testFramework.UsefulTestCase;
+import com.intellij.testFramework.VfsTestUtil;
+import com.intellij.testFramework.fixtures.IdeaProjectTestFixture;
+import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory;
+import git4idea.DialogManager;
+import git4idea.Notificator;
+import git4idea.commands.GitHttpAuthService;
+import git4idea.commands.GitHttpAuthenticator;
+import git4idea.config.GitVcsSettings;
+import git4idea.remote.GitHttpAuthTestService;
+import git4idea.test.GitExecutor;
+import git4idea.test.GitTestUtil;
+import git4idea.test.TestDialogManager;
+import git4idea.test.TestNotificator;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.github.GithubAuthData;
+import org.jetbrains.plugins.github.GithubSettings;
+
+import static org.junit.Assume.assumeNotNull;
+
+/**
+ * <p>The base class for JUnit platform tests of the github plugin.<br/>
+ * Extend this test to write a test on GitHub which has the following features/limitations:
+ * <ul>
+ * <li>This is a "platform test case", which means that IDEA [almost] production platform is set up before the test starts.</li>
+ * <li>Project base directory is the root of everything. </li>
+ * </ul></p>
+ * <p>All tests inherited from this class are required to have a login and a password to access the Github server.
+ * They are set up in System properties: <br/>
+ * <code>-Dtest.github.login=mylogin<br/>
+ * -Dtest.github.password=mypassword</code>
+ * </p>
+ *
+ * @author Kirill Likhodedov
+ */
+public abstract class GithubTest extends UsefulTestCase {
+
+ @NotNull protected Project myProject;
+ @NotNull protected VirtualFile myProjectRoot;
+ @NotNull protected GitVcsSettings myGitSettings;
+ @NotNull protected GithubSettings myGitHubSettings;
+
+ @NotNull protected TestDialogManager myDialogManager;
+ @NotNull protected TestNotificator myNotificator;
+
+ @NotNull private IdeaProjectTestFixture myProjectFixture;
+
+ @NotNull protected String myHost;
+ @NotNull protected String myLogin1;
+ @NotNull protected String myLogin2;
+
+ @SuppressWarnings({"JUnitTestCaseWithNonTrivialConstructors", "UnusedDeclaration"})
+ protected GithubTest() {
+ PlatformTestCase.initPlatformLangPrefix();
+ GitTestUtil.setDefaultBuiltInServerPort();
+ }
+
+ protected void createProjectFiles() {
+ VfsTestUtil.createFile(myProjectRoot, "file.txt", "file.txt content");
+ VfsTestUtil.createFile(myProjectRoot, "file", "file content");
+ VfsTestUtil.createFile(myProjectRoot, "folder/file1", "file1 content");
+ VfsTestUtil.createFile(myProjectRoot, "folder/file2", "file2 content");
+ VfsTestUtil.createFile(myProjectRoot, "folder/empty_file");
+ VfsTestUtil.createFile(myProjectRoot, "folder/dir/file3", "file3 content");
+ VfsTestUtil.createDir (myProjectRoot, "folder/empty_folder");
+ }
+
+ protected void checkNotification(@NotNull NotificationType type, @Nullable String title, @Nullable String content) {
+ Notification actualNotification = myNotificator.getLastNotification();
+ assertNotNull("No notification was shown", actualNotification);
+
+ if (title != null) {
+ assertEquals("Notification has wrong title (content: " + actualNotification.getContent() + ")", title, actualNotification.getTitle());
+ }
+ if (content != null) {
+ assertEquals("Notification has wrong content", content, actualNotification.getContent());
+ }
+ assertEquals("Notification has wrong type", type, actualNotification.getType());
+ }
+
+ protected void registerHttpAuthService() {
+ GitHttpAuthTestService myHttpAuthService = (GitHttpAuthTestService)ServiceManager.getService(GitHttpAuthService.class);
+ myHttpAuthService.register(new GitHttpAuthenticator() {
+ @NotNull
+ @Override
+ public String askPassword(@NotNull String url) {
+ return myGitHubSettings.getPassword();
+ }
+
+ @NotNull
+ @Override
+ public String askUsername(@NotNull String url) {
+ return myGitHubSettings.getLogin();
+ }
+
+ @Override
+ public void saveAuthData() {
+ }
+
+ @Override
+ public void forgetPassword() {
+ }
+ });
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ final String host = System.getenv("idea.test.github.host");
+ final String login1 = System.getenv("idea.test.github.login1");
+ final String password1 = System.getenv("idea.test.github.password1");
+ final String login2 = System.getenv("idea.test.github.login2");
+ //final String password2 = System.getenv("idea.test.github.password2");
+
+ // TODO change to assert when a stable Github testing server is ready
+ assumeNotNull(host);
+ assumeNotNull(login1);
+ assumeNotNull(password1);
+ //assumeNotNull(password2);
+
+ super.setUp();
+
+ myProjectFixture = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(getTestName(true)).getFixture();
+ myProjectFixture.setUp();
+
+ myProject = myProjectFixture.getProject();
+ myProjectRoot = myProject.getBaseDir();
+
+ myGitSettings = GitVcsSettings.getInstance(myProject);
+ myGitSettings.getAppSettings().setPathToGit(GitExecutor.GIT_EXECUTABLE);
+
+ myGitHubSettings = GithubSettings.getInstance();
+ myGitHubSettings.setHost(host);
+ myGitHubSettings.setLogin(login1);
+ myGitHubSettings.setPassword(password1);
+
+ myHost = host;
+ myLogin1 = login1;
+ myLogin2 = login2;
+
+ myDialogManager = (TestDialogManager)ServiceManager.getService(DialogManager.class);
+ myNotificator = (TestNotificator)ServiceManager.getService(myProject, Notificator.class);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ myProjectFixture.tearDown();
+ super.tearDown();
+ }
+
+}
diff --git a/plugins/google-app-engine/google-app-engine.iml b/plugins/google-app-engine/google-app-engine.iml
index 5221786..ab10400 100644
--- a/plugins/google-app-engine/google-app-engine.iml
+++ b/plugins/google-app-engine/google-app-engine.iml
@@ -24,6 +24,7 @@
<orderEntry type="module" module-name="compiler-impl" />
<orderEntry type="module" module-name="dom-openapi" />
<orderEntry type="module" module-name="java-impl" />
+ <orderEntry type="module" module-name="remote-servers-api" />
</component>
</module>
diff --git a/plugins/google-app-engine/resources/META-INF/google-app-engine-plugin.xml b/plugins/google-app-engine/resources/META-INF/google-app-engine-plugin.xml
index 9ce7afc..c885345 100644
--- a/plugins/google-app-engine/resources/META-INF/google-app-engine-plugin.xml
+++ b/plugins/google-app-engine/resources/META-INF/google-app-engine-plugin.xml
@@ -22,6 +22,8 @@
<localInspection language="JAVA" shortName="AppEngineForbiddenCode" displayName="Forbidden code in App Engine applications"
groupName="Google App Engine" enabledByDefault="true" level="ERROR"
implementationClass="com.intellij.appengine.inspections.AppEngineForbiddenCodeInspection"/>
+
+ <remoteServer.type implementation="com.intellij.appengine.cloud.AppEngineCloudType"/>
</extensions>
<actions>
diff --git a/plugins/google-app-engine/source/com/intellij/appengine/actions/AppEngineUploader.java b/plugins/google-app-engine/source/com/intellij/appengine/actions/AppEngineUploader.java
index a6dc462..2e7dae2 100644
--- a/plugins/google-app-engine/source/com/intellij/appengine/actions/AppEngineUploader.java
+++ b/plugins/google-app-engine/source/com/intellij/appengine/actions/AppEngineUploader.java
@@ -16,6 +16,7 @@
package com.intellij.appengine.actions;
import com.intellij.CommonBundle;
+import com.intellij.appengine.cloud.AppEngineServerConfiguration;
import com.intellij.appengine.descriptor.dom.AppEngineWebApp;
import com.intellij.appengine.facet.AppEngineAccountDialog;
import com.intellij.appengine.facet.AppEngineFacet;
@@ -105,7 +106,9 @@
}
@Nullable
- public static AppEngineUploader createUploader(@NotNull Project project, @NotNull Artifact artifact) {
+ public static AppEngineUploader createUploader(@NotNull Project project,
+ @NotNull Artifact artifact,
+ @Nullable AppEngineServerConfiguration configuration) {
final String explodedPath = artifact.getOutputPath();
if (explodedPath == null) {
Messages.showErrorDialog(project, "Output path isn't specified for '" + artifact.getName() + "' artifact", CommonBundle.getErrorTitle());
@@ -150,7 +153,7 @@
String password = null;
String email = null;
try {
- email = AppEngineAccountDialog.getStoredEmail(project);
+ email = AppEngineAccountDialog.getStoredEmail(configuration, project);
password = AppEngineAccountDialog.getStoredPassword(project, email);
}
catch (PasswordSafeException e) {
@@ -158,7 +161,7 @@
LOG.info(e);
}
if (StringUtil.isEmpty(email) || StringUtil.isEmpty(password)) {
- final AppEngineAccountDialog dialog = new AppEngineAccountDialog(project);
+ final AppEngineAccountDialog dialog = new AppEngineAccountDialog(project, configuration);
dialog.show();
if (!dialog.isOK()) return null;
diff --git a/plugins/google-app-engine/source/com/intellij/appengine/actions/UploadApplicationAction.java b/plugins/google-app-engine/source/com/intellij/appengine/actions/UploadApplicationAction.java
index df6daaf..15fb405 100644
--- a/plugins/google-app-engine/source/com/intellij/appengine/actions/UploadApplicationAction.java
+++ b/plugins/google-app-engine/source/com/intellij/appengine/actions/UploadApplicationAction.java
@@ -57,7 +57,7 @@
return;
}
}
- final AppEngineUploader uploader = AppEngineUploader.createUploader(project, artifact);
+ final AppEngineUploader uploader = AppEngineUploader.createUploader(project, artifact, null);
if (uploader != null) {
uploader.startUploading();
}
diff --git a/plugins/google-app-engine/source/com/intellij/appengine/cloud/AppEngineCloudType.java b/plugins/google-app-engine/source/com/intellij/appengine/cloud/AppEngineCloudType.java
new file mode 100644
index 0000000..d90d1f2
--- /dev/null
+++ b/plugins/google-app-engine/source/com/intellij/appengine/cloud/AppEngineCloudType.java
@@ -0,0 +1,147 @@
+/*
+ * Copyright 2000-2013 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.appengine.cloud;
+
+import com.intellij.appengine.actions.AppEngineUploader;
+import com.intellij.appengine.util.AppEngineUtil;
+import com.intellij.openapi.options.ConfigurationException;
+import com.intellij.openapi.options.UnnamedConfigurable;
+import com.intellij.openapi.project.Project;
+import com.intellij.packaging.artifacts.Artifact;
+import com.intellij.packaging.artifacts.ArtifactPointerManager;
+import com.intellij.remoteServer.ServerType;
+import com.intellij.remoteServer.configuration.RemoteServer;
+import com.intellij.remoteServer.deployment.ArtifactDeploymentSource;
+import com.intellij.remoteServer.deployment.Deployer;
+import com.intellij.remoteServer.deployment.DeploymentSource;
+import com.intellij.remoteServer.deployment.DeploymentSourceUtil;
+import com.intellij.util.ui.FormBuilder;
+import icons.GoogleAppEngineIcons;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+import java.awt.*;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author nik
+ */
+public class AppEngineCloudType extends ServerType<AppEngineServerConfiguration> {
+
+ public AppEngineCloudType() {
+ super("google-app-engine");
+ }
+
+ @NotNull
+ @Override
+ public String getPresentableName() {
+ return "Google App Engine";
+ }
+
+ @NotNull
+ @Override
+ public Icon getIcon() {
+ return GoogleAppEngineIcons.AppEngine;
+ }
+
+ @NotNull
+ @Override
+ public AppEngineServerConfiguration createDefaultConfiguration() {
+ return new AppEngineServerConfiguration();
+ }
+
+ @NotNull
+ @Override
+ public UnnamedConfigurable createConfigurable(@NotNull AppEngineServerConfiguration configuration) {
+ return new AppEngineCloudConfigurable(configuration);
+ }
+
+ @NotNull
+ @Override
+ public Deployer createDeployer(Project project) {
+ return new AppEngineDeployer(project);
+ }
+
+ private static class AppEngineCloudConfigurable implements UnnamedConfigurable {
+ private final JTextField myEmailField;
+ private final AppEngineServerConfiguration myConfiguration;
+
+ public AppEngineCloudConfigurable(AppEngineServerConfiguration configuration) {
+ myConfiguration = configuration;
+ myEmailField = new JTextField();
+ myEmailField.setPreferredSize(new Dimension(250, myEmailField.getPreferredSize().height));
+ }
+
+ @Nullable
+ @Override
+ public JComponent createComponent() {
+ return FormBuilder.createFormBuilder().addLabeledComponent("E-mail:", myEmailField).getPanel();
+ }
+
+ @Override
+ public boolean isModified() {
+ return !myEmailField.getText().equals(myConfiguration.getEmail());
+ }
+
+ @Override
+ public void apply() throws ConfigurationException {
+ myConfiguration.setEmail(myEmailField.getText());
+ }
+
+ @Override
+ public void reset() {
+ myEmailField.setText(myConfiguration.getEmail());
+ }
+
+ @Override
+ public void disposeUIResources() {
+ }
+ }
+
+ private static class AppEngineDeployer extends Deployer<AppEngineServerConfiguration> {
+ private final Project myProject;
+
+ public AppEngineDeployer(Project project) {
+ myProject = project;
+ }
+
+ @NotNull
+ @Override
+ public List<DeploymentSource> getAvailableDeploymentSources() {
+ List<Artifact> artifacts = AppEngineUtil.collectWebArtifacts(myProject, true);
+ List<DeploymentSource> sources = new ArrayList<DeploymentSource>();
+ ArtifactPointerManager pointerManager = ArtifactPointerManager.getInstance(myProject);
+ for (Artifact artifact : artifacts) {
+ sources.add(DeploymentSourceUtil.getInstance().createArtifactDeploymentSource(pointerManager.createPointer(artifact)));
+ }
+ return sources;
+ }
+
+ @Override
+ public void startDeployment(@NotNull RemoteServer<AppEngineServerConfiguration> server,
+ @NotNull DeploymentSource source) {
+ Artifact artifact = ((ArtifactDeploymentSource)source).getArtifact();
+ if (artifact == null) return;
+
+ AppEngineUploader uploader = AppEngineUploader.createUploader(myProject, artifact, server.getConfiguration());
+ if (uploader != null) {
+ uploader.startUploading();
+ }
+ }
+ }
+}
diff --git a/plugins/google-app-engine/source/com/intellij/appengine/cloud/AppEngineServerConfiguration.java b/plugins/google-app-engine/source/com/intellij/appengine/cloud/AppEngineServerConfiguration.java
new file mode 100644
index 0000000..9291f37
--- /dev/null
+++ b/plugins/google-app-engine/source/com/intellij/appengine/cloud/AppEngineServerConfiguration.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2000-2013 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.appengine.cloud;
+
+import com.intellij.openapi.components.PersistentStateComponent;
+import com.intellij.remoteServer.configuration.ServerConfiguration;
+import com.intellij.util.xmlb.XmlSerializerUtil;
+import com.intellij.util.xmlb.annotations.Attribute;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * @author nik
+ */
+public class AppEngineServerConfiguration extends ServerConfiguration implements PersistentStateComponent<AppEngineServerConfiguration> {
+ private String myEmail;
+
+ @Attribute("email")
+ public String getEmail() {
+ return myEmail;
+ }
+
+ public void setEmail(String email) {
+ myEmail = email;
+ }
+
+ @Nullable
+ @Override
+ public AppEngineServerConfiguration getState() {
+ return this;
+ }
+
+ @Override
+ public void loadState(AppEngineServerConfiguration state) {
+ XmlSerializerUtil.copyBean(state, this);
+ }
+
+ @Override
+ public PersistentStateComponent<?> getSerializer() {
+ return this;
+ }
+}
diff --git a/plugins/google-app-engine/source/com/intellij/appengine/facet/AppEngineAccountDialog.java b/plugins/google-app-engine/source/com/intellij/appengine/facet/AppEngineAccountDialog.java
index df92225..3e4cda6 100644
--- a/plugins/google-app-engine/source/com/intellij/appengine/facet/AppEngineAccountDialog.java
+++ b/plugins/google-app-engine/source/com/intellij/appengine/facet/AppEngineAccountDialog.java
@@ -16,6 +16,7 @@
package com.intellij.appengine.facet;
import com.intellij.CommonBundle;
+import com.intellij.appengine.cloud.AppEngineServerConfiguration;
import com.intellij.ide.passwordSafe.PasswordSafe;
import com.intellij.ide.passwordSafe.PasswordSafeException;
import com.intellij.ide.util.PropertiesComponent;
@@ -39,12 +40,14 @@
private JPasswordField myPasswordField;
private JTextField myUserEmailField;
private final Project myProject;
+ @Nullable private final AppEngineServerConfiguration myConfiguration;
- public AppEngineAccountDialog(@NotNull Project project) {
+ public AppEngineAccountDialog(@NotNull Project project, @Nullable AppEngineServerConfiguration configuration) {
super(project);
myProject = project;
+ myConfiguration = configuration;
setTitle("AppEngine Account");
- myUserEmailField.setText(StringUtil.notNullize(getStoredEmail(project)));
+ myUserEmailField.setText(StringUtil.notNullize(getStoredEmail(myConfiguration, project)));
init();
}
@@ -67,14 +70,22 @@
}
@Nullable
- public static String getStoredEmail(@NotNull Project project) {
- return PropertiesComponent.getInstance(project).getValue(EMAIL_KEY);
+ public static String getStoredEmail(@Nullable AppEngineServerConfiguration configuration, @NotNull Project project) {
+ if (configuration != null) {
+ return configuration.getEmail();
+ }
+ return PropertiesComponent.getInstance(project).getValue(EMAIL_KEY);//todo[nik] remove this
}
@Override
protected void doOKAction() {
final String email = getEmail();
- PropertiesComponent.getInstance(myProject).setValue(EMAIL_KEY, email);
+ if (myConfiguration != null) {
+ myConfiguration.setEmail(email);
+ }
+ else {
+ PropertiesComponent.getInstance(myProject).setValue(EMAIL_KEY, email);
+ }
if (myRememberPasswordCheckBox.isSelected()) {
try {
PasswordSafe.getInstance().storePassword(myProject, AppEngineAccountDialog.class, getPasswordKey(email), getPassword());
diff --git a/plugins/gradle/resources/fileTemplates/internal/Gradle File.gradle.ft b/plugins/gradle/resources/fileTemplates/internal/Gradle File.gradle.ft
new file mode 100644
index 0000000..072e5e5
--- /dev/null
+++ b/plugins/gradle/resources/fileTemplates/internal/Gradle File.gradle.ft
@@ -0,0 +1,12 @@
+apply plugin: 'java'
+
+sourceCompatibility = 1.5
+version = '1.0'
+
+repositories {
+ mavenCentral()
+}
+
+dependencies {
+ testCompile group: 'junit', name: 'junit', version: '4.11'
+}
\ No newline at end of file
diff --git a/plugins/gradle/resources/i18n/GradleBundle.properties b/plugins/gradle/resources/i18n/GradleBundle.properties
index 7c1c845..d5c12d0 100644
--- a/plugins/gradle/resources/i18n/GradleBundle.properties
+++ b/plugins/gradle/resources/i18n/GradleBundle.properties
@@ -81,7 +81,7 @@
gradle.home.setting.type.deduced=Gradle location is deduced
gradle.home.setting.type.unknown=Gradle location is unknown
gradle.home.setting.type.explicit.correct=Gradle location is defined
-gradle.home.setting.type.explicit.incorrect=Gradle location is incorrect
+gradle.home.setting.type.explicit.incorrect=Gradle location is incorrect.\nLocation:{0}
gradle.toolwindow.text.no.linked.project=\nThere is no linked Gradle project\nYou can {@action Gradle.LinkToProject} one.
gradle.toolwindow.linked.action.text=Add
diff --git a/plugins/gradle/src/META-INF/plugin.xml b/plugins/gradle/src/META-INF/plugin.xml
index 93e3fc5..9bd4ffb 100644
--- a/plugins/gradle/src/META-INF/plugin.xml
+++ b/plugins/gradle/src/META-INF/plugin.xml
@@ -29,14 +29,16 @@
<extensions defaultExtensionNs="com.intellij">
<errorHandler implementation="com.intellij.diagnostic.ITNReporter"/>
- <projectImportProvider implementation="org.jetbrains.plugins.gradle.service.settings.GradleProjectImportProvider"/>
- <projectImportBuilder implementation="org.jetbrains.plugins.gradle.service.settings.GradleProjectImportBuilder"/>
+ <projectImportProvider implementation="org.jetbrains.plugins.gradle.service.project.wizard.GradleProjectImportProvider"/>
+ <projectImportBuilder implementation="org.jetbrains.plugins.gradle.service.project.wizard.GradleProjectImportBuilder"/>
+ <moduleBuilder builderClass="org.jetbrains.plugins.gradle.service.project.wizard.GradleModuleBuilder"/>
+ <internalFileTemplate name="Gradle File"/>
<projectConfigurable id="reference.settingsdialog.project.gradle"
instance="org.jetbrains.plugins.gradle.service.settings.GradleConfigurable"
key="gradle.name" bundle="i18n.GradleBundle"/>
<library.presentationProvider implementation="org.jetbrains.plugins.gradle.config.GradleLibraryPresentationProvider" order="last"/>
<java.elementFinder implementation="org.jetbrains.plugins.gradle.config.GradleClassFinder"/>
- <projectOpenProcessor implementation="org.jetbrains.plugins.gradle.service.settings.GradleProjectOpenProcessor"/>
+ <projectOpenProcessor implementation="org.jetbrains.plugins.gradle.service.project.wizard.GradleProjectOpenProcessor"/>
<configurationType implementation="org.jetbrains.plugins.gradle.service.execution.GradleExternalTaskConfigurationType"/>
<externalSystemManager implementation="org.jetbrains.plugins.gradle.GradleManager"/>
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/GradleManager.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/GradleManager.java
index 0292709..c320c17 100644
--- a/plugins/gradle/src/org/jetbrains/plugins/gradle/GradleManager.java
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/GradleManager.java
@@ -24,12 +24,17 @@
import com.intellij.openapi.externalSystem.ExternalSystemConfigurableAware;
import com.intellij.openapi.externalSystem.ExternalSystemManager;
import com.intellij.openapi.externalSystem.ExternalSystemUiAware;
-import com.intellij.openapi.externalSystem.service.project.autoimport.CachingExternalSystemAutoImportAware;
-import com.intellij.openapi.externalSystem.task.ExternalSystemTaskManager;
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
+import com.intellij.openapi.externalSystem.model.execution.ExternalSystemTaskExecutionSettings;
+import com.intellij.openapi.externalSystem.model.execution.ExternalTaskExecutionInfo;
+import com.intellij.openapi.externalSystem.model.execution.ExternalTaskPojo;
+import com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo;
import com.intellij.openapi.externalSystem.service.project.ExternalSystemProjectResolver;
+import com.intellij.openapi.externalSystem.service.project.autoimport.CachingExternalSystemAutoImportAware;
import com.intellij.openapi.externalSystem.service.ui.DefaultExternalSystemUiAware;
+import com.intellij.openapi.externalSystem.task.ExternalSystemTaskManager;
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
+import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.module.EmptyModuleType;
import com.intellij.openapi.module.JavaModuleType;
@@ -37,6 +42,7 @@
import com.intellij.openapi.module.StdModuleTypes;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.startup.StartupActivity;
import com.intellij.openapi.util.NotNullLazyValue;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.text.StringUtil;
@@ -45,10 +51,12 @@
import com.intellij.util.PathUtil;
import com.intellij.util.PathsList;
import com.intellij.util.containers.ContainerUtilRt;
+import com.intellij.util.messages.MessageBusConnection;
import icons.GradleIcons;
import org.gradle.tooling.ProjectConnection;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.gradle.config.GradleSettingsListenerAdapter;
import org.jetbrains.plugins.gradle.remote.GradleJavaHelper;
import org.jetbrains.plugins.gradle.remote.impl.GradleTaskManager;
import org.jetbrains.plugins.gradle.service.GradleInstallationManager;
@@ -65,15 +73,17 @@
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
+import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
/**
* @author Denis Zhdanov
* @since 4/10/13 1:19 PM
*/
public class GradleManager
- implements ExternalSystemConfigurableAware, ExternalSystemUiAware, ExternalSystemAutoImportAware, ExternalSystemManager<
+implements ExternalSystemConfigurableAware, ExternalSystemUiAware, ExternalSystemAutoImportAware, StartupActivity, ExternalSystemManager<
GradleProjectSettings,
GradleSettingsListener,
GradleSettings,
@@ -270,4 +280,104 @@
public FileChooserDescriptor getExternalProjectDescriptor() {
return GradleUtil.getGradleProjectFileChooserDescriptor();
}
+
+ @Override
+ public void runActivity(final Project project) {
+ // We want to automatically refresh linked projects on gradle service directory change.
+ MessageBusConnection connection = project.getMessageBus().connect(project);
+ connection.subscribe(GradleSettings.getInstance(project).getChangesTopic(), new GradleSettingsListenerAdapter() {
+ @Override
+ public void onServiceDirectoryPathChange(@Nullable String oldPath, @Nullable String newPath) {
+ ExternalSystemUtil.refreshProjects(project, GradleConstants.SYSTEM_ID, true);
+ }
+ });
+
+ // We used to assume that gradle scripts are always named 'build.gradle' and kept path to that build.gradle file at ide settings.
+ // However, it was found out that that is incorrect assumption (IDEA-109064). Now we keep paths to gradle script's directories
+ // instead. However, we don't want to force old users to re-import gradle projects because of that. That's why we check gradle
+ // config and re-point it from build.gradle to the parent dir if necessary.
+ Map<String, String> adjustedPaths = patchLinkedProjects(project);
+ if (adjustedPaths == null) {
+ return;
+ }
+
+ GradleLocalSettings localSettings = GradleLocalSettings.getInstance(project);
+ patchRecentTasks(adjustedPaths, localSettings);
+ patchAvailableProjects(adjustedPaths, localSettings);
+ patchAvailableTasks(adjustedPaths, localSettings);
+ }
+
+ @Nullable
+ private static Map<String, String> patchLinkedProjects(@NotNull Project project) {
+ GradleSettings settings = GradleSettings.getInstance(project);
+ Collection<GradleProjectSettings> correctedSettings = ContainerUtilRt.newArrayList();
+ Map<String/* old path */, String/* new path */> adjustedPaths = ContainerUtilRt.newHashMap();
+ for (GradleProjectSettings projectSettings : settings.getLinkedProjectsSettings()) {
+ String oldPath = projectSettings.getExternalProjectPath();
+ if (!new File(oldPath).isDirectory()) {
+ try {
+ String newPath = new File(oldPath).getParentFile().getCanonicalPath();
+ projectSettings.setExternalProjectPath(newPath);
+ adjustedPaths.put(oldPath, newPath);
+ }
+ catch (IOException e) {
+ LOG.warn(String.format(
+ "Unexpected exception occurred on attempt to re-point linked gradle project path from build.gradle to its parent dir. Path: %s",
+ oldPath
+ ), e);
+ }
+ }
+ correctedSettings.add(projectSettings);
+ }
+ if (adjustedPaths.isEmpty()) {
+ return null;
+ }
+
+ settings.setLinkedProjectsSettings(correctedSettings);
+ return adjustedPaths;
+ }
+
+ private static void patchAvailableTasks(@NotNull Map<String, String> adjustedPaths, @NotNull GradleLocalSettings localSettings) {
+ Map<String, Collection<ExternalTaskPojo>> adjustedAvailableTasks = ContainerUtilRt.newHashMap();
+ for (Map.Entry<String, Collection<ExternalTaskPojo>> entry : localSettings.getAvailableTasks().entrySet()) {
+ String newPath = adjustedPaths.get(entry.getKey());
+ if (newPath == null) {
+ adjustedAvailableTasks.put(entry.getKey(), entry.getValue());
+ }
+ else {
+ for (ExternalTaskPojo task : entry.getValue()) {
+ String newTaskPath = adjustedPaths.get(task.getLinkedExternalProjectPath());
+ if (newTaskPath != null) {
+ task.setLinkedExternalProjectPath(newTaskPath);
+ }
+ }
+ adjustedAvailableTasks.put(newPath, entry.getValue());
+ }
+ }
+ localSettings.setAvailableTasks(adjustedAvailableTasks);
+ }
+
+ private static void patchAvailableProjects(@NotNull Map<String, String> adjustedPaths, @NotNull GradleLocalSettings localSettings) {
+ Map<ExternalProjectPojo, Collection<ExternalProjectPojo>> adjustedAvailableProjects = ContainerUtilRt.newHashMap();
+ for (Map.Entry<ExternalProjectPojo, Collection<ExternalProjectPojo>> entry : localSettings.getAvailableProjects().entrySet()) {
+ String newPath = adjustedPaths.get(entry.getKey().getPath());
+ if (newPath == null) {
+ adjustedAvailableProjects.put(entry.getKey(), entry.getValue());
+ }
+ else {
+ adjustedAvailableProjects.put(new ExternalProjectPojo(entry.getKey().getName(), newPath), entry.getValue());
+ }
+ }
+ localSettings.setAvailableProjects(adjustedAvailableProjects);
+ }
+
+ private static void patchRecentTasks(@NotNull Map<String, String> adjustedPaths, @NotNull GradleLocalSettings localSettings) {
+ for (ExternalTaskExecutionInfo taskInfo : localSettings.getRecentTasks()) {
+ ExternalSystemTaskExecutionSettings s = taskInfo.getSettings();
+ String newPath = adjustedPaths.get(s.getExternalProjectPath());
+ if (newPath != null) {
+ s.setExternalProjectPath(newPath);
+ }
+ }
+ }
}
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/DelegatingGradleSettingsListenerAdapter.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/DelegatingGradleSettingsListenerAdapter.java
new file mode 100644
index 0000000..5268fc1
--- /dev/null
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/DelegatingGradleSettingsListenerAdapter.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2000-2013 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 org.jetbrains.plugins.gradle.config;
+
+import com.intellij.openapi.externalSystem.settings.DelegatingExternalSystemSettingsListener;
+import com.intellij.openapi.externalSystem.settings.ExternalSystemSettingsListener;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.gradle.settings.GradleProjectSettings;
+import org.jetbrains.plugins.gradle.settings.GradleSettingsListener;
+
+/**
+ * @author Denis Zhdanov
+ * @since 6/24/13 6:35 PM
+ */
+public class DelegatingGradleSettingsListenerAdapter extends DelegatingExternalSystemSettingsListener<GradleProjectSettings>
+ implements GradleSettingsListener
+{
+
+ public DelegatingGradleSettingsListenerAdapter(@NotNull ExternalSystemSettingsListener<GradleProjectSettings> delegate) {
+ super(delegate);
+ }
+
+ @Override
+ public void onGradleHomeChange(@Nullable String oldPath, @Nullable String newPath, @NotNull String linkedProjectPath) {
+ }
+
+ @Override
+ public void onPreferLocalGradleDistributionToWrapperChange(boolean currentValue, @NotNull String linkedProjectPath) {
+ }
+
+ @Override
+ public void onServiceDirectoryPathChange(@Nullable String oldPath, @Nullable String newPath) {
+ }
+}
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleAutoImportAware.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleAutoImportAware.java
index 4e479ec..ca748ed 100644
--- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleAutoImportAware.java
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleAutoImportAware.java
@@ -45,7 +45,7 @@
ExternalSystemManager<?,?,?,?,?> manager = ExternalSystemApiUtil.getManager(GradleConstants.SYSTEM_ID);
assert manager != null;
- AbstractExternalSystemSettings<?,?> systemSettings = manager.getSettingsProvider().fun(project);
+ AbstractExternalSystemSettings<?, ?,?> systemSettings = manager.getSettingsProvider().fun(project);
Collection<? extends ExternalProjectSettings> projectsSettings = systemSettings.getLinkedProjectsSettings();
if (projectsSettings.isEmpty()) {
return null;
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleExecutionHelper.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleExecutionHelper.java
index 0a66caa..93e1949 100644
--- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleExecutionHelper.java
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleExecutionHelper.java
@@ -27,7 +27,6 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.gradle.settings.GradleExecutionSettings;
-import org.jetbrains.plugins.gradle.util.GradleBundle;
import java.io.File;
import java.io.IOException;
@@ -132,8 +131,7 @@
private static ProjectConnection getConnection(@NotNull String projectPath, @Nullable GradleExecutionSettings settings)
throws IllegalStateException
{
- File projectFile = new File(projectPath);
- File projectDir = projectFile.getParentFile();
+ File projectDir = new File(projectPath);
GradleConnector connector = GradleConnector.newConnector();
if (settings != null) {
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleProjectResolver.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleProjectResolver.java
index 473ca9f..36e4c89 100644
--- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleProjectResolver.java
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleProjectResolver.java
@@ -16,7 +16,6 @@
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.util.BooleanFunction;
import com.intellij.util.Function;
-import com.intellij.util.PathUtil;
import com.intellij.util.containers.ContainerUtilRt;
import gnu.trove.TObjectIntHashMap;
import gnu.trove.TObjectIntProcedure;
@@ -33,7 +32,10 @@
import org.jetbrains.plugins.gradle.util.GradleUtil;
import java.io.File;
-import java.util.*;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
/**
* @author Denis Zhdanov
@@ -113,7 +115,7 @@
@NotNull
private static DataNode<ProjectData> populateProject(@NotNull IdeaProject project, @NotNull String projectPath) {
- String projectDirPath = ExternalSystemApiUtil.toCanonicalPath(PathUtil.getParentPath(projectPath));
+ String projectDirPath = ExternalSystemApiUtil.toCanonicalPath(projectPath);
ProjectData projectData = new ProjectData(GradleConstants.SYSTEM_ID, projectDirPath, projectPath);
projectData.setName(project.getName());
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/OutputWrapper.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/OutputWrapper.java
index ce7e493..d2d6067 100644
--- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/OutputWrapper.java
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/OutputWrapper.java
@@ -3,6 +3,7 @@
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId;
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListener;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.io.IOException;
import java.io.OutputStream;
@@ -16,6 +17,8 @@
@NotNull private final ExternalSystemTaskNotificationListener myListener;
@NotNull private final ExternalSystemTaskId myTaskId;
+ @Nullable private StringBuilder myBuffer;
+
private final boolean myStdOut;
public OutputWrapper(@NotNull ExternalSystemTaskNotificationListener listener, @NotNull ExternalSystemTaskId taskId, boolean stdOut) {
@@ -26,11 +29,44 @@
@Override
public void write(int b) throws IOException {
- myListener.onTaskOutput(myTaskId, Character.toString((char)b), myStdOut);
+ if (myBuffer == null) {
+ myBuffer = new StringBuilder();
+ }
+ char c = (char)b;
+ myBuffer.append(Character.toString(c));
+ if (c == '\n') {
+ doFlush();
+ }
}
@Override
public void write(byte[] b, int off, int len) throws IOException {
- myListener.onTaskOutput(myTaskId, new String(b, off, len), myStdOut);
+ int start = off;
+ int maxOffset = off + len;
+ for (int i = off; i < maxOffset; i++) {
+ if (b[i] == '\n') {
+ if (myBuffer == null) {
+ myBuffer = new StringBuilder();
+ }
+ myBuffer.append(new String(b, start, i - start + 1));
+ doFlush();
+ start = i + 1;
+ }
+ }
+
+ if (start < maxOffset) {
+ if (myBuffer == null) {
+ myBuffer = new StringBuilder();
+ }
+ myBuffer.append(new String(b, start, maxOffset - start));
+ }
+ }
+
+ private void doFlush() {
+ if (myBuffer == null) {
+ return;
+ }
+ myListener.onTaskOutput(myTaskId, myBuffer.toString(), myStdOut);
+ myBuffer.setLength(0);
}
}
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/wizard/GradleModuleBuilder.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/wizard/GradleModuleBuilder.java
new file mode 100644
index 0000000..787a81d
--- /dev/null
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/wizard/GradleModuleBuilder.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2000-2013 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 org.jetbrains.plugins.gradle.service.project.wizard;
+
+import com.intellij.openapi.externalSystem.service.project.wizard.AbstractExternalModuleBuilder;
+import com.intellij.openapi.module.JavaModuleType;
+import com.intellij.openapi.module.ModuleType;
+import com.intellij.openapi.module.StdModuleTypes;
+import com.intellij.openapi.projectRoots.JavaSdk;
+import com.intellij.openapi.projectRoots.SdkTypeId;
+import com.intellij.openapi.util.io.FileUtilRt;
+import com.intellij.openapi.vfs.LocalFileSystem;
+import com.intellij.openapi.vfs.VirtualFile;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.gradle.service.settings.GradleProjectSettingsControl;
+import org.jetbrains.plugins.gradle.settings.GradleProjectSettings;
+import org.jetbrains.plugins.gradle.util.GradleConstants;
+
+import java.io.File;
+
+/**
+ * @author Denis Zhdanov
+ * @since 6/26/13 11:10 AM
+ */
+public class GradleModuleBuilder extends AbstractExternalModuleBuilder<GradleProjectSettings> {
+
+ public GradleModuleBuilder() {
+ super(GradleConstants.SYSTEM_ID, new GradleProjectSettingsControl(new GradleProjectSettings()), "Gradle File.gradle");
+ }
+
+ @Nullable
+ @Override
+ protected VirtualFile getExternalProjectConfigFile(@NotNull VirtualFile contentRootDir) {
+ File gradleScript = new File(contentRootDir.getPath(), GradleConstants.DEFAULT_SCRIPT_NAME);
+ FileUtilRt.createIfNotExists(gradleScript);
+ return LocalFileSystem.getInstance().refreshAndFindFileByIoFile(gradleScript);
+ }
+
+ @Override
+ public boolean isSuitableSdkType(SdkTypeId sdk) {
+ return sdk == JavaSdk.getInstance();
+ }
+
+ @Override
+ public String getGroupName() {
+ return JavaModuleType.JAVA_GROUP;
+ }
+
+ @Override
+ public ModuleType getModuleType() {
+ return StdModuleTypes.JAVA;
+ }
+
+ @NotNull
+ @Override
+ protected GradleProjectSettings createSettings() {
+ return new GradleProjectSettings();
+ }
+}
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/settings/GradleProjectImportBuilder.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/wizard/GradleProjectImportBuilder.java
similarity index 91%
rename from plugins/gradle/src/org/jetbrains/plugins/gradle/service/settings/GradleProjectImportBuilder.java
rename to plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/wizard/GradleProjectImportBuilder.java
index 2535fd9..e4a6ff4 100644
--- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/settings/GradleProjectImportBuilder.java
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/wizard/GradleProjectImportBuilder.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.jetbrains.plugins.gradle.service.settings;
+package org.jetbrains.plugins.gradle.service.project.wizard;
import com.intellij.externalSystem.JavaProjectData;
import com.intellij.ide.util.projectWizard.WizardContext;
@@ -26,10 +26,13 @@
import com.intellij.openapi.project.Project;
import com.intellij.openapi.projectRoots.*;
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
+import com.intellij.openapi.vfs.LocalFileSystem;
+import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.pom.java.LanguageLevel;
import icons.GradleIcons;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.gradle.service.settings.ImportFromGradleControl;
import org.jetbrains.plugins.gradle.util.GradleBundle;
import org.jetbrains.plugins.gradle.util.GradleConstants;
@@ -61,7 +64,8 @@
@Override
protected void doPrepare(@NotNull WizardContext context) {
String pathToUse = context.getProjectFileDirectory();
- if (!pathToUse.endsWith(GradleConstants.DEFAULT_SCRIPT_NAME)) {
+ VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByPath(pathToUse);
+ if (file != null && file.isDirectory()) {
pathToUse = new File(pathToUse, GradleConstants.DEFAULT_SCRIPT_NAME).getAbsolutePath();
}
getControl(context.getProject()).setLinkedProjectPath(pathToUse);
@@ -123,13 +127,7 @@
@NotNull
@Override
protected File getExternalProjectConfigToUse(@NotNull File file) {
- if (file.isDirectory()) {
- File candidate = new File(file, GradleConstants.DEFAULT_SCRIPT_NAME);
- if (candidate.isFile()) {
- return candidate;
- }
- }
- return file;
+ return file.isDirectory() ? file : file.getParentFile();
}
@Override
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/settings/GradleProjectImportProvider.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/wizard/GradleProjectImportProvider.java
similarity index 92%
rename from plugins/gradle/src/org/jetbrains/plugins/gradle/service/settings/GradleProjectImportProvider.java
rename to plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/wizard/GradleProjectImportProvider.java
index b9db922..49ba899 100644
--- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/settings/GradleProjectImportProvider.java
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/wizard/GradleProjectImportProvider.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.jetbrains.plugins.gradle.service.settings;
+package org.jetbrains.plugins.gradle.service.project.wizard;
import com.intellij.openapi.externalSystem.service.project.wizard.AbstractExternalProjectImportProvider;
import com.intellij.openapi.vfs.VirtualFile;
@@ -27,7 +27,7 @@
public class GradleProjectImportProvider extends AbstractExternalProjectImportProvider {
public GradleProjectImportProvider(GradleProjectImportBuilder builder) {
- super(builder);
+ super(builder, GradleConstants.SYSTEM_ID);
}
@Override
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/settings/GradleProjectOpenProcessor.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/wizard/GradleProjectOpenProcessor.java
similarity index 82%
rename from plugins/gradle/src/org/jetbrains/plugins/gradle/service/settings/GradleProjectOpenProcessor.java
rename to plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/wizard/GradleProjectOpenProcessor.java
index 45bd1c8..03ac43c 100644
--- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/settings/GradleProjectOpenProcessor.java
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/wizard/GradleProjectOpenProcessor.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.jetbrains.plugins.gradle.service.settings;
+package org.jetbrains.plugins.gradle.service.project.wizard;
import com.intellij.ide.util.newProjectWizard.AddModuleWizard;
import com.intellij.ide.util.projectWizard.WizardContext;
@@ -33,7 +33,7 @@
*/
public class GradleProjectOpenProcessor extends ProjectOpenProcessorBase<GradleProjectImportBuilder> {
- @NotNull public static final String[] BUILD_FILE_NAMES = {GradleConstants.DEFAULT_SCRIPT_NAME};
+ @NotNull public static final String[] BUILD_FILE_EXTENSIONS = {GradleConstants.EXTENSION};
public GradleProjectOpenProcessor(@NotNull GradleProjectImportBuilder builder) {
super(builder);
@@ -42,9 +42,22 @@
@Nullable
@Override
public String[] getSupportedExtensions() {
- return BUILD_FILE_NAMES;
+ return BUILD_FILE_EXTENSIONS;
}
-
+
+ @Override
+ public boolean canOpenProject(VirtualFile file) {
+ if (!file.isDirectory()) {
+ String fileName = file.getName();
+ for (String extension : BUILD_FILE_EXTENSIONS) {
+ if (fileName.endsWith(extension)) {
+ return true;
+ }
+ }
+ }
+ return super.canOpenProject(file);
+ }
+
@Override
protected boolean doQuickImport(VirtualFile file, WizardContext wizardContext) {
AddModuleWizard dialog = new AddModuleWizard(null, file.getPath(), new GradleProjectImportProvider(getBuilder()));
@@ -57,7 +70,6 @@
return step instanceof SelectExternalProjectStep;
}
});
- dialog.doNextAction();
if (StringUtil.isEmpty(wizardContext.getProjectName())) {
final String projectName = dialog.getWizardContext().getProjectName();
if (!StringUtil.isEmpty(projectName)) {
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/settings/GradleProjectSettingsControl.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/settings/GradleProjectSettingsControl.java
index 6319e1a..7bf0b99 100644
--- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/settings/GradleProjectSettingsControl.java
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/settings/GradleProjectSettingsControl.java
@@ -192,7 +192,7 @@
else if (!myInstallationManager.isGradleSdkHome(new File(gradleHomePath))) {
myGradleHomeSettingType = LocationSettingType.EXPLICIT_INCORRECT;
new DelayedBalloonInfo(MessageType.ERROR, myGradleHomeSettingType, 0).run();
- return GradleBundle.message("gradle.home.setting.type.explicit.incorrect");
+ return GradleBundle.message("gradle.home.setting.type.explicit.incorrect", gradleHomePath);
}
}
settings.setPreferLocalInstallationToWrapper(myUseLocalDistributionButton.isSelected());
@@ -222,6 +222,10 @@
myGradleHomePathField.getTextField().setForeground(LocationSettingType.EXPLICIT_CORRECT.getColor());
updateWrapperControls(getInitialSettings().getExternalProjectPath());
+ if (myUseWrapperButton.isSelected()) {
+ myGradleHomePathField.setEnabled(false);
+ return;
+ }
if (StringUtil.isEmpty(gradleHome)) {
myGradleHomeSettingType = LocationSettingType.UNKNOWN;
@@ -313,7 +317,7 @@
myAlarm.addRequest(this, diff);
return;
}
- if (!myGradleHomePathField.isShowing()) {
+ if (myGradleHomePathField == null || !myGradleHomePathField.isShowing()) {
// Don't schedule the balloon if the configurable is hidden.
return;
}
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/settings/GradleProjectSettings.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/settings/GradleProjectSettings.java
index 369f2f9..a254be8 100644
--- a/plugins/gradle/src/org/jetbrains/plugins/gradle/settings/GradleProjectSettings.java
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/settings/GradleProjectSettings.java
@@ -25,7 +25,8 @@
*/
public class GradleProjectSettings extends ExternalProjectSettings {
- @Nullable private String myGradleHome;
+ @Nullable private String myGradleHome;
+
private boolean myPreferLocalInstallationToWrapper;
@Nullable
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/settings/GradleSettings.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/settings/GradleSettings.java
index aff64ca..a295d75 100644
--- a/plugins/gradle/src/org/jetbrains/plugins/gradle/settings/GradleSettings.java
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/settings/GradleSettings.java
@@ -17,12 +17,14 @@
import com.intellij.openapi.components.*;
import com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings;
+import com.intellij.openapi.externalSystem.settings.ExternalSystemSettingsListener;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Comparing;
import com.intellij.util.containers.ContainerUtilRt;
import com.intellij.util.xmlb.annotations.AbstractCollection;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.gradle.config.DelegatingGradleSettingsListenerAdapter;
import java.util.Set;
@@ -38,7 +40,7 @@
@Storage(file = StoragePathMacros.PROJECT_CONFIG_DIR + "/gradle.xml", scheme = StorageScheme.DIRECTORY_BASED)
}
)
-public class GradleSettings extends AbstractExternalSystemSettings<GradleProjectSettings, GradleSettingsListener>
+public class GradleSettings extends AbstractExternalSystemSettings<GradleSettings, GradleProjectSettings, GradleSettingsListener>
implements PersistentStateComponent<GradleSettings.MyState>
{
@@ -53,6 +55,18 @@
return ServiceManager.getService(project, GradleSettings.class);
}
+ @Override
+ public void subscribe(@NotNull ExternalSystemSettingsListener<GradleProjectSettings> listener) {
+ getProject().getMessageBus().connect(getProject()).subscribe(GradleSettingsListener.TOPIC,
+ new DelegatingGradleSettingsListenerAdapter(listener));
+
+ }
+
+ @Override
+ protected void copyExtraSettingsFrom(@NotNull GradleSettings settings) {
+ myServiceDirectoryPath = settings.getServiceDirectoryPath();
+ }
+
@SuppressWarnings("unchecked")
@Nullable
@Override
@@ -80,10 +94,11 @@
return myServiceDirectoryPath;
}
- public void setServiceDirectoryPath(@Nullable String path) {
- if (!Comparing.equal(myServiceDirectoryPath, path)) {
- final String oldPath = myServiceDirectoryPath;
- getPublisher().onServiceDirectoryPathChange(oldPath, path);
+ public void setServiceDirectoryPath(@Nullable String newPath) {
+ if (!Comparing.equal(myServiceDirectoryPath, newPath)) {
+ String oldPath = myServiceDirectoryPath;
+ myServiceDirectoryPath = newPath;
+ getPublisher().onServiceDirectoryPathChange(oldPath, newPath);
}
}
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleConstants.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleConstants.java
index ba5418b..042bb16 100644
--- a/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleConstants.java
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleConstants.java
@@ -17,27 +17,15 @@
@NonNls public static final String EXTENSION = "gradle";
@NonNls public static final String DEFAULT_SCRIPT_NAME = "build.gradle";
- public static final String SYSTEM_DIRECTORY_PATH_KEY = "GRADLE_USER_HOME";
+ public static final String SYSTEM_DIRECTORY_PATH_KEY = "GRADLE_USER_HOME";
- @NonNls public static final String TOOL_WINDOW_ID = "JetGradle";
+ @NonNls public static final String TOOL_WINDOW_TOOLBAR_PLACE = "GRADLE_SYNC_CHANGES_TOOLBAR";
+ @NonNls public static final String TASKS_LIST_PLACE = "TASKS_LIST_PLACE";
+ @NonNls public static final String TASKS_CONTEXT_MENU_PLACE = "GRADLE_TASKS_CONTEXT_MENU_PLACE";
- @NonNls public static final String TOOL_WINDOW_TOOLBAR_PLACE = "GRADLE_SYNC_CHANGES_TOOLBAR";
- @NonNls public static final String SYNC_TREE_CONTEXT_MENU_PLACE = "GRADLE_SYNC_TREE_CONTEXT_MENU_PLACE";
- @NonNls public static final String SYNC_TREE_FILTER_PLACE = "GRADLE_SYNC_TREE_FILTER_PLACE";
- @NonNls public static final String TASKS_LIST_PLACE = "TASKS_LIST_PLACE";
- @NonNls public static final String TASKS_CONTEXT_MENU_PLACE = "GRADLE_TASKS_CONTEXT_MENU_PLACE";
+ @NonNls public static final String ACTION_GROUP_TASKS = "Gradle.TasksGroup";
- @NonNls public static final String ACTION_GROUP_SYNC_TREE = "Gradle.SyncTreeGroup";
- @NonNls public static final String ACTION_GROUP_TASKS = "Gradle.TasksGroup";
-
- @NonNls public static final String HELP_TOPIC_IMPORT_SELECT_PROJECT_STEP = "reference.dialogs.new.project.import.gradle.page1";
- @NonNls public static final String HELP_TOPIC_ADJUST_SETTINGS_STEP = "reference.dialogs.new.project.import.gradle.page2";
- @NonNls public static final String HELP_TOPIC_TOOL_WINDOW = "reference.toolwindows.gradle";
-
- @NonNls public static final String ACTIVE_TOOL_WINDOW_TAB_KEY = "gradle.tool.window.active";
-
- @NonNls public static final String REGISTRY_RECENT_TASKS_NUMBER_KEY = "gradle.recent.tasks.number";
- @NonNls public static final String REGISTRY_DEBUG_ON_TASK_CLICK_KEY = "gradle.debug.task.on.double.click";
+ @NonNls public static final String HELP_TOPIC_TOOL_WINDOW = "reference.toolwindows.gradle";
private GradleConstants() {
}
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleUtil.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleUtil.java
index c5254c8..fc3b070 100644
--- a/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleUtil.java
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleUtil.java
@@ -2,7 +2,6 @@
import com.intellij.ide.actions.OpenProjectFileChooserDescriptor;
import com.intellij.ide.util.PropertiesComponent;
-import com.intellij.openapi.externalSystem.model.ProjectSystemId;
import com.intellij.openapi.externalSystem.util.ExternalSystemConstants;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.fileChooser.FileTypeDescriptor;
@@ -59,8 +58,8 @@
/**
* Tries to parse what gradle version should be used with gradle wrapper for the gradle project located at the given path.
*
- * @param gradleProjectPath target gradle project path
- * @return gradle version should be used with gradle wrapper for the gradle project located at the given path
+ * @param gradleProjectPath target gradle project config's (*.gradle) path or config file's directory path.
+ * @return gradle version should be used with gradle wrapper for the gradle project located at the given path
* if any; <code>null</code> otherwise
*/
@Nullable
@@ -69,11 +68,16 @@
return null;
}
File file = new File(gradleProjectPath);
- if (!file.isFile()) {
- return null;
- }
- File gradleDir = new File(file.getParentFile(), "gradle");
+ // There is a possible case that given path points to a gradle script (*.gradle) but it's also possible that
+ // it references script's directory. We want to provide flexibility here.
+ File gradleDir;
+ if (file.isFile()) {
+ gradleDir = new File(file.getParentFile(), "gradle");
+ }
+ else {
+ gradleDir = new File(file, "gradle");
+ }
if (!gradleDir.isDirectory()) {
return null;
}
@@ -141,7 +145,7 @@
public static final FileChooserDescriptor GRADLE_BUILD_FILE_CHOOSER_DESCRIPTOR = new OpenProjectFileChooserDescriptor(true) {
@Override
public boolean isFileSelectable(VirtualFile file) {
- return GradleConstants.DEFAULT_SCRIPT_NAME.equals(file.getName());
+ return file.getName().endsWith(GradleConstants.EXTENSION);
}
@Override
@@ -149,7 +153,7 @@
if (!super.isFileVisible(file, showHiddenFiles)) {
return false;
}
- return file.isDirectory() || GradleConstants.DEFAULT_SCRIPT_NAME.equals(file.getName());
+ return file.isDirectory() || file.getName().endsWith(GradleConstants.EXTENSION);
}
};
@@ -159,14 +163,14 @@
/**
* Allows to build file system path to the target gradle sub-project given the root project path.
- *
- * @param subProject target sub-project which 'build.gradle' path we're interested in
- * @param rootProjectPath root project's 'build.gradle' path
- * @return path to the given sub-project's 'build.gradle'
+ *
+ * @param subProject target sub-project which config path we're interested in
+ * @param rootProjectPath path to root project's directory which contains 'build.gradle'
+ * @return path to the given sub-project's directory which contains 'build.gradle'
*/
@NotNull
public static String getConfigPath(@NotNull GradleProject subProject, @NotNull String rootProjectPath) {
- File rootProjectParent = new File(rootProjectPath).getParentFile().getParentFile();
+ File rootProjectParent = new File(rootProjectPath).getParentFile();
StringBuilder buffer = new StringBuilder(FileUtil.toCanonicalPath(rootProjectParent.getAbsolutePath()));
Stack<String> stack = ContainerUtilRt.newStack();
for (GradleProject p = subProject; p != null; p = p.getParent()) {
@@ -175,7 +179,6 @@
while (!stack.isEmpty()) {
buffer.append(ExternalSystemConstants.PATH_SEPARATOR).append(stack.pop());
}
- buffer.append(ExternalSystemConstants.PATH_SEPARATOR).append(GradleConstants.DEFAULT_SCRIPT_NAME);
return buffer.toString();
}
diff --git a/plugins/groovy/src/META-INF/intellilang-groovy-support.xml b/plugins/groovy/src/META-INF/intellilang-groovy-support.xml
index 4e7d595..4e5e6ae 100644
--- a/plugins/groovy/src/META-INF/intellilang-groovy-support.xml
+++ b/plugins/groovy/src/META-INF/intellilang-groovy-support.xml
@@ -11,6 +11,7 @@
</extensions>
<extensions defaultExtensionNs="com.intellij">
<multiHostInjector implementation="org.intellij.plugins.intelliLang.inject.groovy.GrConcatenation2InjectorAdapter" order="last"/>
+ <multiHostInjector implementation="org.intellij.plugins.intelliLang.inject.groovy.GrConcatenationInjector"/>
</extensions>
</idea-plugin>
diff --git a/plugins/groovy/src/META-INF/plugin.xml b/plugins/groovy/src/META-INF/plugin.xml
index 7bb1489..a296218 100644
--- a/plugins/groovy/src/META-INF/plugin.xml
+++ b/plugins/groovy/src/META-INF/plugin.xml
@@ -149,6 +149,7 @@
<typeConverter implementation="org.jetbrains.plugins.groovy.lang.psi.typeEnhancers.GrContainerTypeConverter"/>
<typeConverter implementation="org.jetbrains.plugins.groovy.lang.psi.typeEnhancers.GrStringTypeConverter"/>
<typeConverter implementation="org.jetbrains.plugins.groovy.lang.psi.typeEnhancers.GrBooleanTypeConverter"/>
+ <typeConverter implementation="org.jetbrains.plugins.groovy.lang.psi.typeEnhancers.GrGenericTypeConverter"/>
<typeConverter implementation="org.jetbrains.plugins.groovy.gpp.GppTypeConverter"/>
<expectedTypesContributor implementation="org.jetbrains.plugins.groovy.gpp.GppExpectedTypesContributor"/>
@@ -196,9 +197,7 @@
<testGenerator language="Groovy" implementationClass="org.jetbrains.plugins.groovy.testIntegration.GroovyTestGenerator"/>
<constructorBodyGenerator language="Groovy"
implementationClass="org.jetbrains.plugins.groovy.annotator.intentions.dynamic.GrConstructorBodyGenerator"/>
- <!-- In Android Studio, we don't want editor notifications to setup Groovy Path when *.gradle files are opened. This is a temporary
- hack to remove this until we figure out how to disable it just for gradle scripts.
- <editorNotificationProvider implementation="org.jetbrains.plugins.groovy.annotator.ConfigureGroovyLibraryNotificationProvider"/> -->
+ <editorNotificationProvider implementation="org.jetbrains.plugins.groovy.annotator.ConfigureGroovyLibraryNotificationProvider"/>
<refactoring.introduceParameterMethodUsagesProcessor
implementation="org.jetbrains.plugins.groovy.refactoring.introduce.parameter.java2groovy.GroovyIntroduceParameterMethodUsagesProcessor"/>
<refactoring.changeSignatureUsageProcessor
@@ -399,6 +398,9 @@
implementationClass="org.jetbrains.plugins.groovy.lang.resolve.GroovyStringLiteralManipulator"/>
<lang.elementManipulator forClass="org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentLabel"
implementationClass="org.jetbrains.plugins.groovy.lang.psi.impl.statements.arguments.GrArgumentLabelManipulator"/>
+ <lang.elementManipulator forClass="org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrStringContent"
+ implementationClass="org.jetbrains.plugins.groovy.lang.resolve.GroovyStringLiteralManipulator"/>
+
<directClassInheritorsSearch implementation="org.jetbrains.plugins.groovy.lang.psi.impl.GroovyDirectInheritorsSearcher"/>
diff --git a/plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/GrConcatenationInjector.java b/plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/GrConcatenationInjector.java
new file mode 100644
index 0000000..b83f706
--- /dev/null
+++ b/plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/GrConcatenationInjector.java
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2000-2013 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 org.intellij.plugins.intelliLang.inject.groovy;
+
+import com.intellij.lang.Language;
+import com.intellij.lang.injection.MultiHostInjector;
+import com.intellij.lang.injection.MultiHostRegistrar;
+import com.intellij.openapi.util.Pair;
+import com.intellij.openapi.util.TextRange;
+import com.intellij.openapi.util.Trinity;
+import com.intellij.psi.*;
+import org.intellij.plugins.intelliLang.Configuration;
+import org.intellij.plugins.intelliLang.inject.InjectedLanguage;
+import org.intellij.plugins.intelliLang.inject.InjectorUtils;
+import org.intellij.plugins.intelliLang.inject.config.BaseInjection;
+import org.intellij.plugins.intelliLang.util.AnnotationUtilEx;
+import org.intellij.plugins.intelliLang.util.PsiUtilEx;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrAssignmentExpression;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrCall;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
+import org.jetbrains.plugins.groovy.lang.psi.impl.signatures.GrClosureSignatureUtil;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Max Medvedev
+ */
+public class GrConcatenationInjector implements MultiHostInjector {
+ @Override
+ public void getLanguagesToInject(@NotNull MultiHostRegistrar registrar, @NotNull PsiElement context) {
+ assert context instanceof GrLiteral;
+ final GrLiteral literal = (GrLiteral)context;
+
+ final PsiElement parent = literal.getParent();
+ if (parent instanceof GrAssignmentExpression && ((GrAssignmentExpression)parent).getRValue() == literal) {
+ final GrExpression lvalue = ((GrAssignmentExpression)parent).getLValue();
+ if (lvalue instanceof GrReferenceExpression) {
+ final PsiElement resolved = ((GrReferenceExpression)lvalue).resolve();
+ if (resolved instanceof PsiModifierListOwner) {
+ processAnnotations(registrar, literal, (PsiModifierListOwner)resolved);
+ }
+ }
+ }
+ else if (parent instanceof GrVariable) {
+ processAnnotations(registrar, literal, ((GrVariable)parent));
+ }
+ else if (parent instanceof GrArgumentList) {
+ final PsiElement pparent = parent.getParent();
+
+ if (pparent instanceof GrCall) {
+ final GrCall call = (GrCall)pparent;
+ final GroovyResolveResult result = call.advancedResolve();
+ if (result.getElement() != null) {
+ final Map<GrExpression, Pair<PsiParameter, PsiType>> map = GrClosureSignatureUtil
+ .mapArgumentsToParameters(result, literal, false, false, call.getNamedArguments(), call.getExpressionArguments(), call.getClosureArguments());
+
+ if (map != null) {
+ final Pair<PsiParameter, PsiType> pair = map.get(literal);
+ processAnnotations(registrar, literal, pair.first);
+ }
+ }
+ }
+ }
+ }
+
+ private static void processAnnotations(MultiHostRegistrar registrar,
+ PsiLanguageInjectionHost host,
+ PsiModifierListOwner annotationOwner) {
+ final Pair<String, ? extends Set<String>> pair =
+ Configuration.getInstance().getAdvancedConfiguration().getLanguageAnnotationPair();
+
+ final PsiAnnotation[] annotations = getAnnotationFrom(annotationOwner, pair, true, true);
+ if (annotations.length > 0) {
+ final String id = AnnotationUtilEx.calcAnnotationValue(annotations, "value");
+ final String prefix = AnnotationUtilEx.calcAnnotationValue(annotations, "prefix");
+ final String suffix = AnnotationUtilEx.calcAnnotationValue(annotations, "suffix");
+ final BaseInjection injection = new BaseInjection(GroovyLanguageInjectionSupport.GROOVY_SUPPORT_ID);
+ if (prefix != null) injection.setPrefix(prefix);
+ if (suffix != null) injection.setSuffix(suffix);
+ if (id != null) injection.setInjectedLanguageId(id);
+
+ //todo suffixes & prefixes are not supported
+ final Language language = InjectedLanguage.findLanguageById(injection.getInjectedLanguageId());
+
+ Trinity<PsiLanguageInjectionHost, InjectedLanguage, TextRange> info = Trinity.create(
+ host,
+ InjectedLanguage.create(injection.getInjectedLanguageId(), prefix, suffix, true),
+ ElementManipulators.getManipulator(host).getRangeInElement(host)
+ );
+ InjectorUtils.registerInjection(language, Collections.singletonList(info), host.getContainingFile(), registrar);
+ }
+ }
+
+ @NotNull
+ public static PsiAnnotation[] getAnnotationFrom(PsiModifierListOwner owner,
+ Pair<String, ? extends Set<String>> annotationName,
+ boolean allowIndirect,
+ boolean inHierarchy) {
+ if (!isLanguageAnnotationTargetGroovy(owner)) return PsiAnnotation.EMPTY_ARRAY;
+
+ return AnnotationUtilEx.getAnnotationsFromImpl(owner, annotationName, allowIndirect, inHierarchy);
+ }
+
+ private static boolean isLanguageAnnotationTargetGroovy(PsiModifierListOwner owner) {
+ return owner instanceof GrMethod && ((GrMethod)owner).getReturnTypeElementGroovy() == null ||
+ owner instanceof GrVariable && ((GrVariable)owner).getTypeElementGroovy() == null ||
+ PsiUtilEx.isLanguageAnnotationTarget(owner);
+ }
+
+ @NotNull
+ @Override
+ public List<? extends Class<? extends PsiElement>> elementsToInjectIn() {
+ return Collections.singletonList(GrLiteral.class);
+ }
+}
diff --git a/plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/GroovyLanguageInjectionSupport.java b/plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/GroovyLanguageInjectionSupport.java
index ea38408..452bca1 100644
--- a/plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/GroovyLanguageInjectionSupport.java
+++ b/plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/GroovyLanguageInjectionSupport.java
@@ -50,11 +50,11 @@
* @author Gregory.Shrago
*/
public class GroovyLanguageInjectionSupport extends AbstractLanguageInjectionSupport {
- @NonNls private static final String SUPPORT_ID = "groovy";
+ @NonNls public static final String GROOVY_SUPPORT_ID = "groovy";
@NotNull
public String getId() {
- return SUPPORT_ID;
+ return GROOVY_SUPPORT_ID;
}
@NotNull
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyBundle.properties b/plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyBundle.properties
index dd5964b..f2c5137 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyBundle.properties
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyBundle.properties
@@ -361,6 +361,9 @@
named.arguments.are.not.allowed.inside.index.operations=Named arguments are not allowed inside index operations
expected.0.to.be.inline.constant=Expected ''{0}'' to be an inline constant
cannot.assign.a.value.to.final.field.0=Cannot assign a value to final field ''{0}''
+cannot.assign.a.value.to.final.parameter.0=Cannot assign a value to final parameter ''{0}''
variable.0.might.not.have.been.initialized=Variable ''{0}'' might not have been initialized
unexpected.symbol=Unexpected symbol
statement.expected=Statement expected
+annotation.attribute.expected=Annotation attribute expected
+highlight.constructor.calls.of.a.non.static.inner.classes.without.enclosing.instance.passed=Highlight constructor calls of non-static inner classes without enclosing instance passed
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java
index ff185ab..7eefc8b 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java
@@ -73,10 +73,7 @@
import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrReturnStatement;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.GrForInClause;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.*;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrRegex;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrString;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrStringInjection;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.*;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrIndexProperty;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrMethodCallExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
@@ -287,6 +284,7 @@
checkStringNameIdentifier(referenceExpression);
checkThisOrSuperReferenceExpression(referenceExpression, myHolder);
checkFinalFieldAccess(referenceExpression);
+ checkFinalParameterAccess(referenceExpression);
if (ResolveUtil.isKeyOfMap(referenceExpression)) {
PsiElement nameElement = referenceExpression.getReferenceNameElement();
LOG.assertTrue(nameElement != null);
@@ -299,6 +297,19 @@
}
}
+ private void checkFinalParameterAccess(GrReferenceExpression ref) {
+ final PsiElement resolved = ref.resolve();
+
+ if (resolved instanceof GrParameter) {
+ final GrParameter parameter = (GrParameter)resolved;
+ if (parameter.isPhysical() && parameter.hasModifierProperty(FINAL) && PsiUtil.isLValue(ref)) {
+ if (parameter.getDeclarationScope() instanceof PsiMethod) {
+ myHolder.createErrorAnnotation(ref, GroovyBundle.message("cannot.assign.a.value.to.final.parameter.0", parameter.getName()));
+ }
+ }
+ }
+ }
+
private void checkFinalFieldAccess(@NotNull GrReferenceExpression ref) {
final PsiElement resolved = ref.resolve();
@@ -1085,17 +1096,6 @@
myHolder.createErrorAnnotation(newExpression, GroovyBundle.message("qualified.new.of.static.class"));
}
}
- else {
- final PsiClass outerClass = clazz.getContainingClass();
- if (com.intellij.psi.util.PsiUtil.isInnerClass(clazz) &&
- outerClass != null &&
- !PsiUtil.hasEnclosingInstanceInScope(outerClass, newExpression, true)) {
- String qname = clazz.getQualifiedName();
- LOG.assertTrue(qname != null, clazz.getText());
- Annotation annotation = myHolder.createErrorAnnotation(refElement, GroovyBundle.message("cannot.reference.non.static", qname));
- annotation.setTextAttributes(UNRESOLVED_ACCESS);
- }
- }
}
}
@@ -1265,9 +1265,10 @@
@Override
public void visitGStringExpression(GrString gstring) {
- for (String part : gstring.getTextParts()) {
- if (!GrStringUtil.parseStringCharacters(part, new StringBuilder(part.length()), null)) {
- myHolder.createErrorAnnotation(gstring, GroovyBundle.message("illegal.escape.character.in.string.literal"));
+ for (GrStringContent part : gstring.getContents()) {
+ final String text = part.getText();
+ if (!GrStringUtil.parseStringCharacters(text, new StringBuilder(text.length()), null)) {
+ myHolder.createErrorAnnotation(part, GroovyBundle.message("illegal.escape.character.in.string.literal"));
return;
}
}
@@ -1390,6 +1391,17 @@
@Override
public void visitAnnotationNameValuePair(GrAnnotationNameValuePair nameValuePair) {
+ final PsiElement identifier = nameValuePair.getNameIdentifierGroovy();
+ if (identifier == null) {
+ final PsiElement parent = nameValuePair.getParent();
+ if (parent instanceof GrAnnotationArgumentList) {
+ final int count = ((GrAnnotationArgumentList)parent).getAttributes().length;
+ if (count > 1) {
+ myHolder.createErrorAnnotation(nameValuePair, GroovyBundle.message("attribute.name.expected"));
+ }
+ }
+ }
+
final GrAnnotationMemberValue value = nameValuePair.getValue();
checkAnnotationAttributeValue(value, value);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/GroovyAddImportAction.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/GroovyAddImportAction.java
index 015eb56..50b83cb 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/GroovyAddImportAction.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/GroovyAddImportAction.java
@@ -79,6 +79,7 @@
return false;
}
+ @NotNull
@Override
protected List<PsiClass> filterByContext(@NotNull List<PsiClass> candidates, @NotNull GrReferenceElement ref) {
PsiElement typeElement = ref.getParent();
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/GroovyInspectionBundle.properties b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/GroovyInspectionBundle.properties
index eec071a..5a9566f 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/GroovyInspectionBundle.properties
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/GroovyInspectionBundle.properties
@@ -104,4 +104,5 @@
add.to.resources=Add to resources
add.type.customizer.to.resources=Add type customizer script to resources
target.0.does.not.exist=Target ''{0}'' does not exist
-target.annotation.is.unused=@Target is unused
\ No newline at end of file
+target.annotation.is.unused=@Target is unused
+change.lvalue.type=Change variable ''{0}'' type to ''{1}''
\ No newline at end of file
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GrChangeVariableType.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GrChangeVariableType.java
new file mode 100644
index 0000000..835446b
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GrChangeVariableType.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2000-2013 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 org.jetbrains.plugins.groovy.codeInspection.assignment;
+
+import com.intellij.codeInspection.ProblemDescriptor;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.project.Project;
+import com.intellij.psi.JavaPsiFacade;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiType;
+import com.intellij.util.IncorrectOperationException;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.plugins.groovy.codeInspection.GroovyFix;
+import org.jetbrains.plugins.groovy.codeInspection.GroovyInspectionBundle;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrAssignmentExpression;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
+
+/**
+ * @author Max Medvedev
+ */
+public class GrChangeVariableType extends GroovyFix {
+ private static final Logger LOG = Logger.getInstance(GrChangeVariableType.class);
+ private final String myType;
+ private final String myName;
+
+ public GrChangeVariableType(PsiType type, String name) {
+ myType = type.getCanonicalText();
+ myName = name;
+ }
+
+ @Override
+ protected void doFix(Project project, ProblemDescriptor descriptor) throws IncorrectOperationException {
+ final PsiElement element = descriptor.getPsiElement();
+ final PsiElement parent = element.getParent();
+
+ try {
+ final PsiType type = JavaPsiFacade.getElementFactory(project).createTypeFromText(myType, element);
+
+ if (parent instanceof GrVariable) {
+ ((GrVariable)parent).setType(type);
+ }
+ else if (element instanceof GrReferenceExpression &&
+ parent instanceof GrAssignmentExpression &&
+ ((GrAssignmentExpression)parent).getLValue() == element) {
+ final PsiElement resolved = ((GrReferenceExpression)element).resolve();
+ if (resolved instanceof GrVariable && !(resolved instanceof GrParameter)) {
+ ((GrVariable)resolved).setType(type);
+ }
+ }
+ }
+ catch (IncorrectOperationException e) {
+ LOG.error(e);
+ }
+ }
+
+ @NotNull
+ @Override
+ public String getName() {
+ return GroovyInspectionBundle.message("change.lvalue.type", myName, myType);
+ }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovyAssignabilityCheckInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovyAssignabilityCheckInspection.java
index d370988..8f9629b 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovyAssignabilityCheckInspection.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovyAssignabilityCheckInspection.java
@@ -75,11 +75,10 @@
import org.jetbrains.plugins.groovy.lang.psi.impl.signatures.GrClosureSignatureUtil;
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.GrReferenceResolveUtil;
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
-import org.jetbrains.plugins.groovy.lang.psi.util.GdkMethodUtil;
-import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames;
-import org.jetbrains.plugins.groovy.lang.psi.util.GroovyConstantExpressionEvaluator;
-import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
+import org.jetbrains.plugins.groovy.lang.psi.typeEnhancers.ClosureParameterEnhancer;
+import org.jetbrains.plugins.groovy.lang.psi.util.*;
import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil;
+import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringUtil;
import java.util.ArrayList;
import java.util.List;
@@ -122,19 +121,56 @@
}
private static class MyVisitor extends BaseInspectionVisitor {
- private void checkAssignability(@NotNull PsiType expectedType, @NotNull GrExpression expression, PsiElement toHightlight) {
+ private void checkAssignability(@NotNull PsiType expectedType, @NotNull GrExpression expression, PsiElement toHighlight) {
if (PsiUtil.isRawClassMemberAccess(expression)) return;
if (checkForImplicitEnumAssigning(expectedType, expression, expression)) return;
final PsiType rType = expression.getType();
if (rType == null || rType == PsiType.VOID) return;
if (!TypesUtil.isAssignable(expectedType, rType, expression)) {
- final LocalQuickFix[] fixes = {new GrCastFix(expectedType)};
+ final List<LocalQuickFix> fixes = ContainerUtil.newArrayList();
+ fixes.add(new GrCastFix(expectedType));
+
+ String varName = getLValueVarName(toHighlight);
+ if (varName != null) {
+ fixes.add(new GrChangeVariableType(rType, varName));
+ }
+
final String message = GroovyBundle.message("cannot.assign", rType.getPresentableText(), expectedType.getPresentableText());
- registerError(toHightlight, message, fixes, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
+ registerError(toHighlight, message, fixes.toArray(new LocalQuickFix[fixes.size()]), ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
}
}
+ @Nullable
+ private static String getLValueVarName(PsiElement highlight) {
+ final PsiElement parent = highlight.getParent();
+ if (parent instanceof GrVariable) {
+ return ((GrVariable)parent).getName();
+ }
+ else if (highlight instanceof GrReferenceExpression &&
+ parent instanceof GrAssignmentExpression &&
+ ((GrAssignmentExpression)parent).getLValue() == highlight) {
+ final PsiElement resolved = ((GrReferenceExpression)highlight).resolve();
+ if (resolved instanceof GrVariable && GroovyRefactoringUtil.isLocalVariable(resolved)) {
+ return ((GrVariable)resolved).getName();
+ }
+ }
+
+ return null;
+ }
+
+ private void checkAssignability(@NotNull PsiType lType,
+ @Nullable PsiType rType,
+ @NotNull GroovyPsiElement context,
+ @NotNull final PsiElement elementToHighlight) {
+ if (rType == null) return;
+ if (!TypesUtil.isAssignable(lType, rType, context)) {
+ final String message = GroovyBundle.message("cannot.assign", rType.getPresentableText(), lType.getPresentableText());
+ registerError(elementToHighlight, message, LocalQuickFix.EMPTY_ARRAY, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
+ }
+ }
+
+
private boolean checkForImplicitEnumAssigning(PsiType expectedType, GrExpression expression, GroovyPsiElement element) {
if (!(expectedType instanceof PsiClassType)) return false;
@@ -202,7 +238,7 @@
if (lValue instanceof GrIndexProperty) return;
if (!PsiUtil.mightBeLValue(lValue)) return;
- IElementType opToken = assignment.getOperationToken();
+ IElementType opToken = assignment.getOperationTokenType();
if (opToken != GroovyTokenTypes.mASSIGN) return;
GrExpression rValue = assignment.getRValue();
@@ -308,11 +344,13 @@
}
}
else if (parent instanceof GrForInClause) {
- PsiType iteratedType = PsiUtil.extractIteratedType((GrForInClause)parent);
+ GrExpression iterated = ((GrForInClause)parent).getIteratedExpression();
+ if (iterated == null) return;
+
+ PsiType iteratedType = ClosureParameterEnhancer.findTypeForIteration(iterated, parent);
if (iteratedType == null) return;
- GrExpression iteratedExpression = ((GrForInClause)parent).getIteratedExpression();
- checkAssignability(varType, iteratedType, iteratedExpression, variable.getNameIdentifierGroovy());
+ checkAssignability(varType, iteratedType, iterated, variable.getNameIdentifierGroovy());
return;
}
@@ -348,17 +386,6 @@
checkAssignability(varType, initializer, variable.getNameIdentifierGroovy());
}
- private void checkAssignability(@NotNull PsiType lType,
- @Nullable PsiType rType,
- @NotNull GroovyPsiElement context,
- @NotNull final PsiElement elementToHighlight) {
- if (rType == null) return;
- if (!TypesUtil.isAssignable(lType, rType, context)) {
- final String message = GroovyBundle.message("cannot.assign", rType.getPresentableText(), lType.getPresentableText());
- registerError(elementToHighlight, message, LocalQuickFix.EMPTY_ARRAY, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
- }
- }
-
private static boolean isNewInstanceInitialingByTuple(GrExpression initializer) {
return initializer instanceof GrListOrMap && initializer.getReference() instanceof LiteralConstructorReference;
}
@@ -539,7 +566,13 @@
if (exprArgs.length == 0 && !PsiUtil.isConstructorHasRequiredParameters(constructor)) return true;
}
- return checkMethodApplicability(constructorResolveResult, place, checkUnknownArgs);
+
+ PsiType[] types = PsiUtil.getArgumentTypes(place, true);
+ PsiClass containingClass = constructor.getContainingClass();
+ if (types != null && containingClass != null) {
+ types = GrInnerClassConstructorUtil.addEnclosingArgIfNeeded(types, place, containingClass);
+ }
+ return checkMethodApplicability(constructorResolveResult, place, checkUnknownArgs, types);
}
@Override
@@ -854,13 +887,21 @@
return builder.toString();
}
- private boolean checkMethodApplicability(GroovyResolveResult methodResolveResult, GroovyPsiElement place, boolean checkUnknownArgs) {
+ private boolean checkMethodApplicability(@NotNull GroovyResolveResult methodResolveResult,
+ @NotNull GroovyPsiElement place,
+ boolean checkUnknownArgs) {
+ return checkMethodApplicability(methodResolveResult, place, checkUnknownArgs, PsiUtil.getArgumentTypes(place, true));
+ }
+
+ private boolean checkMethodApplicability(@NotNull GroovyResolveResult methodResolveResult,
+ @NotNull GroovyPsiElement place,
+ boolean checkUnknownArgs,
+ @Nullable PsiType[] argumentTypes) {
final PsiElement element = methodResolveResult.getElement();
if (!(element instanceof PsiMethod)) return true;
if (element instanceof GrBuilderMethod) return true;
final PsiMethod method = (PsiMethod)element;
- PsiType[] argumentTypes = PsiUtil.getArgumentTypes(place, true);
if ("call".equals(method.getName()) && place instanceof GrReferenceExpression) {
final GrExpression qualifierExpression = ((GrReferenceExpression)place).getQualifierExpression();
if (qualifierExpression != null) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovyAssignmentCanBeOperatorAssignmentInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovyAssignmentCanBeOperatorAssignmentInspection.java
index 19ff878..9245aa5 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovyAssignmentCanBeOperatorAssignmentInspection.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovyAssignmentCanBeOperatorAssignmentInspection.java
@@ -154,7 +154,7 @@
public void visitAssignmentExpression(@NotNull GrAssignmentExpression assignment) {
super.visitAssignmentExpression(assignment);
- final IElementType assignmentTokenType = assignment.getOperationToken();
+ final IElementType assignmentTokenType = assignment.getOperationTokenType();
if (!assignmentTokenType.equals(GroovyTokenTypes.mASSIGN)) {
return;
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovySillyAssignmentInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovySillyAssignmentInspection.java
index 24f5d6e..d32f298 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovySillyAssignmentInspection.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovySillyAssignmentInspection.java
@@ -62,7 +62,7 @@
public void visitAssignmentExpression(@NotNull GrAssignmentExpression assignment) {
super.visitAssignmentExpression(assignment);
- final IElementType sign = assignment.getOperationToken();
+ final IElementType sign = assignment.getOperationTokenType();
if (!sign.equals(GroovyTokenTypes.mASSIGN)) {
return;
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovyUncheckedAssignmentOfMemberOfRawTypeInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovyUncheckedAssignmentOfMemberOfRawTypeInspection.java
index e2e687d..52b091a 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovyUncheckedAssignmentOfMemberOfRawTypeInspection.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovyUncheckedAssignmentOfMemberOfRawTypeInspection.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -139,7 +139,7 @@
GrExpression lValue = assignment.getLValue();
if (!PsiUtil.mightBeLValue(lValue)) return;
- IElementType opToken = assignment.getOperationToken();
+ IElementType opToken = assignment.getOperationTokenType();
if (opToken != GroovyTokenTypes.mASSIGN) return;
GrExpression rValue = assignment.getRValue();
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/bugs/GroovyDivideByZeroInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/bugs/GroovyDivideByZeroInspection.java
index 3837705..40b9392 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/bugs/GroovyDivideByZeroInspection.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/bugs/GroovyDivideByZeroInspection.java
@@ -82,7 +82,7 @@
if (rhs == null) {
return;
}
- final IElementType tokenType = expression.getOperationToken();
+ final IElementType tokenType = expression.getOperationTokenType();
if (!tokenType.equals(GroovyTokenTypes.mDIV_ASSIGN)
&& !tokenType.equals(GroovyTokenTypes.mMOD_ASSIGN)) {
return;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/control/GroovyTrivialIfInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/control/GroovyTrivialIfInspection.java
index 3872510..ce00ed1 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/control/GroovyTrivialIfInspection.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/control/GroovyTrivialIfInspection.java
@@ -124,7 +124,7 @@
final GrAssignmentExpression assignmentExpression =
(GrAssignmentExpression) ConditionalUtils.stripBraces(thenBranch);
final IElementType operator =
- assignmentExpression.getOperationToken();
+ assignmentExpression.getOperationTokenType();
final String operatorText = getTextForOperator(operator);
final GrExpression lhs = assignmentExpression.getLValue();
final String lhsText = lhs.getText();
@@ -146,7 +146,7 @@
final GrAssignmentExpression assignmentExpression =
(GrAssignmentExpression) ConditionalUtils.stripBraces(thenBranch);
final IElementType operator =
- assignmentExpression.getOperationToken();
+ assignmentExpression.getOperationTokenType();
final GrExpression lhs = assignmentExpression.getLValue();
final String lhsText = lhs.getText();
replaceStatement(statement,
@@ -170,7 +170,7 @@
final GrAssignmentExpression assignmentExpression =
(GrAssignmentExpression) ConditionalUtils.stripBraces(thenBranch);
final IElementType operator =
- assignmentExpression.getOperationToken();
+ assignmentExpression.getOperationTokenType();
final String operatorText = getTextForOperator(operator);
final GrExpression lhs = assignmentExpression.getLValue();
final String lhsText = lhs.getText();
@@ -226,7 +226,7 @@
final GrAssignmentExpression assignmentExpression =
(GrAssignmentExpression) ConditionalUtils.stripBraces(thenBranch);
final IElementType operator =
- assignmentExpression.getOperationToken();
+ assignmentExpression.getOperationTokenType();
final String operatorText = getTextForOperator(operator);
final GrExpression lhs = assignmentExpression.getLValue();
final String lhsText = lhs.getText();
@@ -352,8 +352,8 @@
(GrAssignmentExpression) thenBranch;
final GrAssignmentExpression elseExpression =
(GrAssignmentExpression) elseBranch;
- final IElementType thenSign = thenExpression.getOperationToken();
- final IElementType elseSign = elseExpression.getOperationToken();
+ final IElementType thenSign = thenExpression.getOperationTokenType();
+ final IElementType elseSign = elseExpression.getOperationTokenType();
if (!thenSign.equals(elseSign)) {
return false;
}
@@ -377,8 +377,8 @@
(GrAssignmentExpression) thenBranch;
final GrAssignmentExpression elseExpression =
(GrAssignmentExpression) elseBranch;
- final IElementType thenSign = thenExpression.getOperationToken();
- final IElementType elseSign = elseExpression.getOperationToken();
+ final IElementType thenSign = thenExpression.getOperationTokenType();
+ final IElementType elseSign = elseExpression.getOperationTokenType();
if (!thenSign.equals(elseSign)) {
return false;
}
@@ -412,8 +412,8 @@
(GrAssignmentExpression) thenBranch;
final GrAssignmentExpression elseExpression =
(GrAssignmentExpression) elseBranch;
- final IElementType thenSign = thenExpression.getOperationToken();
- final IElementType elseSign = elseExpression.getOperationToken();
+ final IElementType thenSign = thenExpression.getOperationTokenType();
+ final IElementType elseSign = elseExpression.getOperationTokenType();
if (!thenSign.equals(elseSign)) {
return false;
}
@@ -447,8 +447,8 @@
(GrAssignmentExpression) thenBranch;
final GrAssignmentExpression elseExpression =
(GrAssignmentExpression) elseBranch;
- final IElementType thenSign = thenExpression.getOperationToken();
- final IElementType elseSign = elseExpression.getOperationToken();
+ final IElementType thenSign = thenExpression.getOperationTokenType();
+ final IElementType elseSign = elseExpression.getOperationTokenType();
if (!thenSign.equals(elseSign)) {
return false;
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/control/finalVar/GrFinalVariableAccessInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/control/finalVar/GrFinalVariableAccessInspection.java
index e10a91e..f988749 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/control/finalVar/GrFinalVariableAccessInspection.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/control/finalVar/GrFinalVariableAccessInspection.java
@@ -36,6 +36,7 @@
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrEnumConstant;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
import org.jetbrains.plugins.groovy.lang.psi.controlFlow.Instruction;
import org.jetbrains.plugins.groovy.lang.psi.controlFlow.ReadWriteVariableInstruction;
@@ -277,6 +278,7 @@
}
private static boolean isFieldInitialized(@NotNull GrField field) {
+ if (field instanceof GrEnumConstant) return true;
if (field.getInitializerGroovy() != null) return true;
final boolean isStatic = field.hasModifierProperty(PsiModifier.STATIC);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/declaration/GrMethodMayBeStaticInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/declaration/GrMethodMayBeStaticInspection.java
index 463d735..3c912d7 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/declaration/GrMethodMayBeStaticInspection.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/declaration/GrMethodMayBeStaticInspection.java
@@ -15,12 +15,10 @@
*/
package org.jetbrains.plugins.groovy.codeInspection.declaration;
+import com.intellij.codeInspection.InspectionManager;
import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.ProblemHighlightType;
import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel;
-import com.intellij.openapi.extensions.ExtensionPoint;
-import com.intellij.openapi.extensions.Extensions;
-import com.intellij.openapi.extensions.ExtensionsArea;
import com.intellij.openapi.util.Condition;
import com.intellij.psi.*;
import com.intellij.psi.search.searches.OverridingMethodsSearch;
@@ -95,9 +93,7 @@
return false;
}
- final ExtensionsArea rootArea = Extensions.getRootArea();
- final ExtensionPoint<Condition<PsiElement>> extensionPoint = rootArea.getExtensionPoint("com.intellij.cantBeStatic");
- final Condition<PsiElement>[] addins = extensionPoint.getExtensions();
+ final Condition<PsiElement>[] addins = InspectionManager.CANT_BE_STATIC_EXTENSION.getExtensions();
for (Condition<PsiElement> addin : addins) {
if (addin.value(method)) {
return false;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/untypedUnresolvedAccess/GrUnresolvedAccessInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/untypedUnresolvedAccess/GrUnresolvedAccessInspection.java
index 3ec5540..e5621b7 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/untypedUnresolvedAccess/GrUnresolvedAccessInspection.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/untypedUnresolvedAccess/GrUnresolvedAccessInspection.java
@@ -33,6 +33,8 @@
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Condition;
+import com.intellij.openapi.util.Key;
+import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
@@ -40,8 +42,10 @@
import com.intellij.pom.PomTarget;
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
import com.intellij.psi.*;
+import com.intellij.psi.scope.PsiScopeProcessor;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.CollectConsumer;
+import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -62,6 +66,7 @@
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrClassInitializer;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.*;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrExtendsClause;
@@ -73,12 +78,16 @@
import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.packaging.GrPackageDefinition;
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
import org.jetbrains.plugins.groovy.lang.psi.api.util.GrVariableDeclarationOwner;
+import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.GrReferenceResolveUtil;
+import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames;
import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil;
+import org.jetbrains.plugins.groovy.util.LightCacheKey;
import javax.swing.*;
+import java.util.Map;
import static com.intellij.psi.PsiModifier.STATIC;
import static org.jetbrains.plugins.groovy.annotator.intentions.QuickfixUtil.isCall;
@@ -93,6 +102,14 @@
public boolean myHighlightIfGroovyObjectOverridden = true;
public boolean myHighlightIfMissingMethodsDeclared = true;
+ public boolean myHighlightInnerClasses = true;
+
+ private static final LightCacheKey<Map<String, Boolean>> GROOVY_OBJECT_METHODS_CACHE = new LightCacheKey<Map<String, Boolean>>() {
+ @Override
+ protected long getModificationCount(PsiElement holder) {
+ return holder.getManager().getModificationTracker().getModificationCount();
+ }
+ };
private static boolean shouldHighlightAsUnresolved(@NotNull GrReferenceExpression referenceExpression) {
if (GrHighlightUtil.isDeclarationAssignment(referenceExpression)) return false;
@@ -125,10 +142,9 @@
@Override
public JComponent createOptionsPanel() {
final MultipleCheckboxOptionsPanel optionsPanel = new MultipleCheckboxOptionsPanel(this);
- optionsPanel
- .addCheckbox(GroovyInspectionBundle.message("highlight.if.groovy.object.methods.overridden"), "myHighlightIfGroovyObjectOverridden");
- optionsPanel
- .addCheckbox(GroovyInspectionBundle.message("highlight.if.missing.methods.declared"), "myHighlightIfMissingMethodsDeclared");
+ optionsPanel.addCheckbox(GroovyInspectionBundle.message("highlight.if.groovy.object.methods.overridden"), "myHighlightIfGroovyObjectOverridden");
+ optionsPanel.addCheckbox(GroovyInspectionBundle.message("highlight.if.missing.methods.declared"), "myHighlightIfMissingMethodsDeclared");
+ optionsPanel.addCheckbox(GroovyBundle.message("highlight.constructor.calls.of.a.non.static.inner.classes.without.enclosing.instance.passed"), "myHighlightInnerClasses");
return optionsPanel;
}
@@ -138,7 +154,7 @@
return profile.isToolEnabled(unusedDefKey, file);
}
- private static GrUnresolvedAccessInspection getInstance(PsiFile file, Project project) {
+ public static GrUnresolvedAccessInspection getInstance(PsiFile file, Project project) {
final InspectionProfile profile = InspectionProjectProfileManager.getInstance(project).getInspectionProfile();
return (GrUnresolvedAccessInspection)profile.getUnwrappedTool(SHORT_NAME, file);
}
@@ -176,8 +192,7 @@
if (!(refElement.getParent() instanceof GrPackageDefinition) && resolved == null) {
String message = GroovyBundle.message("cannot.resolve", refElement.getReferenceName());
- HighlightInfo info =
- HighlightInfo.newHighlightInfo(HighlightInfoType.WRONG_REF).range(nameElement).descriptionAndTooltip(message).create();
+ HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.WRONG_REF).range(nameElement).descriptionAndTooltip(message).create();
// todo implement for nested classes
HighlightDisplayKey displayKey = HighlightDisplayKey.find(SHORT_NAME);
@@ -189,32 +204,77 @@
return info;
}
+ if (refElement.getParent() instanceof GrNewExpression) {
+
+ boolean inStaticContext = isInStaticContext(refElement);
+
+ if (!inStaticContext && GroovySuppressableInspectionTool.isElementToolSuppressedIn(refElement, SHORT_NAME)) return null;
+
+ if (!inStaticContext) {
+ if (!isInspectionEnabled(refElement.getContainingFile(), refElement.getProject())) return null;
+ GrUnresolvedAccessInspection inspection = getInstance(refElement.getContainingFile(), refElement.getProject());
+ assert inspection != null;
+ if (!inspection.myHighlightInnerClasses) return null;
+ }
+
+ GrNewExpression newExpression = (GrNewExpression)refElement.getParent();
+ if (resolved instanceof PsiClass) {
+ PsiClass clazz = (PsiClass)resolved;
+ if (newExpression.getQualifier() == null) {
+ final PsiClass outerClass = clazz.getContainingClass();
+ if (com.intellij.psi.util.PsiUtil.isInnerClass(clazz) &&
+ outerClass != null &&
+ !PsiUtil.hasEnclosingInstanceInScope(outerClass, newExpression, true) &&
+ !hasEnclosingInstanceInArgList(newExpression.getArgumentList(), outerClass)) {
+ String qname = clazz.getQualifiedName();
+ LOG.assertTrue(qname != null, clazz.getText());
+ return createAnnotationForRef(refElement, inStaticContext, GroovyBundle.message("cannot.reference.non.static", qname));
+ }
+ }
+ }
+ }
+
return null;
}
+ private static boolean hasEnclosingInstanceInArgList(GrArgumentList list, PsiClass enclosingClass) {
+ if (PsiImplUtil.hasNamedArguments(list)) return false;
+
+ GrExpression[] args = list.getExpressionArguments();
+ if (args.length == 0) return false;
+
+ PsiType type = args[0].getType();
+ PsiClassType enclosingClassType = JavaPsiFacade.getElementFactory(list.getProject()).createType(enclosingClass);
+ return TypesUtil.isAssignableByMethodCallConversion(enclosingClassType, type, list);
+ }
+
@Nullable
private static HighlightInfo checkRefInner(GrReferenceExpression ref) {
PsiElement refNameElement = ref.getReferenceNameElement();
if (refNameElement == null) return null;
- boolean cannotBeDynamic = PsiUtil.isCompileStatic(ref) || isPropertyAccessInStaticMethod(ref);
+ boolean inStaticContext = PsiUtil.isCompileStatic(ref) || isPropertyAccessInStaticMethod(ref);
GroovyResolveResult resolveResult = getBestResolveResult(ref);
if (resolveResult.getElement() != null) {
if (!isInspectionEnabled(ref.getContainingFile(), ref.getProject())) return null;
- if (isStaticOk(resolveResult)) return null;
- String message = GroovyBundle.message("cannot.reference.non.static", ref.getReferenceName());
- return createAnnotationForRef(ref, cannotBeDynamic, message);
+ if (!isStaticOk(resolveResult)) {
+ String message = GroovyBundle.message("cannot.reference.non.static", ref.getReferenceName());
+ return createAnnotationForRef(ref, inStaticContext, message);
+ }
+
+ return null;
}
if (ResolveUtil.isKeyOfMap(ref) || isClassReference(ref)) {
return null;
}
- if (!cannotBeDynamic) {
+ if (!inStaticContext) {
if (!isInspectionEnabled(ref.getContainingFile(), ref.getProject())) return null;
GrUnresolvedAccessInspection inspection = getInstance(ref.getContainingFile(), ref.getProject());
+ assert inspection != null;
if (!inspection.myHighlightIfGroovyObjectOverridden && areGroovyObjectMethodsOverridden(ref)) return null;
if (!inspection.myHighlightIfMissingMethodsDeclared && areMissingMethodsDeclared(ref)) return null;
@@ -222,8 +282,8 @@
if (GroovySuppressableInspectionTool.isElementToolSuppressedIn(ref, SHORT_NAME)) return null;
}
- if (cannotBeDynamic || shouldHighlightAsUnresolved(ref)) {
- HighlightInfo info = createAnnotationForRef(ref, cannotBeDynamic, GroovyBundle.message("cannot.resolve", ref.getReferenceName()));
+ if (inStaticContext || shouldHighlightAsUnresolved(ref)) {
+ HighlightInfo info = createAnnotationForRef(ref, inStaticContext, GroovyBundle.message("cannot.resolve", ref.getReferenceName()));
if (info == null) return null;
HighlightDisplayKey displayKey = HighlightDisplayKey.find(SHORT_NAME);
@@ -235,7 +295,7 @@
registerAddImportFixes(ref, info, displayKey);
}
- registerReferenceFixes(ref, info, cannotBeDynamic, displayKey);
+ registerReferenceFixes(ref, info, inStaticContext, displayKey);
UnresolvedReferenceQuickFixProvider.registerReferenceFixes(ref, new QuickFixActionRegistrarAdapter(info, displayKey));
OrderEntryFix.registerFixes(new QuickFixActionRegistrarAdapter(info, displayKey), ref);
return info;
@@ -276,16 +336,98 @@
}
private static boolean areGroovyObjectMethodsOverridden(GrReferenceExpression ref) {
+ PsiMethod patternMethod = findPatternMethod(ref);
+ if (patternMethod == null) return false;
+
+ GrExpression qualifier = ref.getQualifier();
+ if (qualifier != null) {
+ return checkGroovyObjectMethodsByQualifier(ref, patternMethod);
+ }
+ else {
+ return checkMethodInPlace(ref, patternMethod);
+ }
+ }
+
+ private static boolean checkMethodInPlace(GrReferenceExpression ref, PsiMethod patternMethod) {
+ PsiElement container = PsiTreeUtil.getParentOfType(ref, GrClosableBlock.class, PsiMember.class, PsiFile.class);
+ assert container != null;
+ return checkContainer(patternMethod, container);
+ }
+
+ private static boolean checkContainer(@NotNull final PsiMethod patternMethod, @NotNull PsiElement container) {
+ final String name = patternMethod.getName();
+
+ Map<String, Boolean> cached = GROOVY_OBJECT_METHODS_CACHE.getCachedValue(container);
+ if (cached == null) {
+ GROOVY_OBJECT_METHODS_CACHE.putCachedValue(container, cached = ContainerUtil.<String, Boolean>newConcurrentMap());
+ }
+
+ Boolean cachedResult = cached.get(name);
+ if (cachedResult != null) {
+ return cachedResult.booleanValue();
+ }
+
+ boolean result = doCheckContainer(patternMethod, container, name);
+ cached.put(name, result);
+
+ return result;
+ }
+
+ private static boolean doCheckContainer(final PsiMethod patternMethod, PsiElement container, final String name) {
+ final Ref<Boolean> result = new Ref<Boolean>(false);
+ PsiScopeProcessor processor = new PsiScopeProcessor() {
+ @Override
+ public boolean execute(@NotNull PsiElement element, ResolveState state) {
+ if (element instanceof PsiMethod &&
+ name.equals(((PsiMethod)element).getName()) &&
+ patternMethod.getParameterList().getParametersCount() == ((PsiMethod)element).getParameterList().getParametersCount() &&
+ validateMethod((PsiMethod)element, patternMethod)) {
+ result.set(true);
+ return false;
+ }
+ return true;
+ }
+
+ @Nullable
+ @Override
+ public <T> T getHint(@NotNull Key<T> hintKey) {
+ return null;
+ }
+
+ @Override
+ public void handleEvent(Event event, @Nullable Object associated) {
+ }
+ };
+ ResolveUtil.treeWalkUp(container, processor, true);
+ return result.get();
+ }
+
+ private static boolean checkGroovyObjectMethodsByQualifier(GrReferenceExpression ref, PsiMethod patternMethod) {
PsiType qualifierType = GrReferenceResolveUtil.getQualifierType(ref);
if (!(qualifierType instanceof PsiClassType)) return false;
PsiClass resolved = ((PsiClassType)qualifierType).resolve();
if (resolved == null) return false;
- PsiClass groovyObject =
- JavaPsiFacade.getInstance(ref.getProject()).findClass(GroovyCommonClassNames.GROOVY_OBJECT, ref.getResolveScope());
- if (groovyObject == null) return false;
+ PsiMethod found = resolved.findMethodBySignature(patternMethod, true);
+ if (found == null) return false;
+ return validateMethod(found, patternMethod);
+ }
+
+ private static boolean validateMethod(PsiMethod found, PsiMethod patternMethod) {
+ PsiClass aClass = found.getContainingClass();
+ if (aClass == null) return false;
+ String qname = aClass.getQualifiedName();
+ if (GroovyCommonClassNames.GROOVY_OBJECT.equals(qname)) return false;
+ if (GroovyCommonClassNames.GROOVY_OBJECT_SUPPORT.equals(qname)) return false;
+ return true;
+ }
+
+ private static PsiMethod findPatternMethod(GrReferenceExpression ref) {
+ PsiClass groovyObject = JavaPsiFacade.getInstance(ref.getProject()).findClass(GroovyCommonClassNames.GROOVY_OBJECT,
+ ref.getResolveScope());
+ if (groovyObject == null) return null;
String methodName;
if (ref.getParent() instanceof GrCall) {
@@ -299,19 +441,8 @@
}
PsiMethod[] patternMethods = groovyObject.findMethodsByName(methodName, false);
- if (patternMethods.length != 1) return false;
-
- PsiMethod patternMethod = patternMethods[0];
- PsiMethod found = resolved.findMethodBySignature(patternMethod, true);
- if (found == null) return false;
-
- PsiClass aClass = found.getContainingClass();
- if (aClass == null) return false;
- String qname = aClass.getQualifiedName();
- if (GroovyCommonClassNames.GROOVY_OBJECT.equals(qname)) return false;
- if (GroovyCommonClassNames.GROOVY_OBJECT_SUPPORT.equals(qname)) return false;
-
- return true;
+ if (patternMethods.length != 1) return null;
+ return patternMethods[0];
}
private static void addEmptyIntentionIfNeeded(@Nullable HighlightInfo info) {
@@ -361,21 +492,30 @@
}
public static boolean isPropertyAccessInStaticMethod(GrReferenceExpression referenceExpression) {
- if (referenceExpression.getParent() instanceof GrMethodCall || referenceExpression.getQualifier() != null) return false;
- GrMember context = PsiTreeUtil.getParentOfType(referenceExpression, GrMember.class, true, GrClosableBlock.class);
+ return isInStaticContext(referenceExpression) &&
+ !(referenceExpression.getParent() instanceof GrMethodCall) &&
+ referenceExpression.getQualifier() == null;
+ }
+
+ private static boolean isInStaticContext(PsiElement place) {
+ GrMember context = PsiTreeUtil.getParentOfType(place, GrMember.class, true, GrClosableBlock.class);
return (context instanceof GrMethod || context instanceof GrClassInitializer) && context.hasModifierProperty(STATIC);
}
@Nullable
- private static HighlightInfo createAnnotationForRef(@NotNull GrReferenceExpression ref,
- boolean compileStatic,
+ private static HighlightInfo createAnnotationForRef(@NotNull GrReferenceElement ref,
+ boolean strongError,
@NotNull String message) {
PsiElement refNameElement = ref.getReferenceNameElement();
assert refNameElement != null;
+ if (strongError) {
+ return HighlightInfo.newHighlightInfo(HighlightInfoType.WRONG_REF).range(refNameElement).descriptionAndTooltip(message).create();
+ }
+
HighlightDisplayLevel displayLevel = getHighlightDisplayLevel(ref.getProject(), ref);
- if (compileStatic || displayLevel == HighlightDisplayLevel.ERROR) {
+ if (displayLevel == HighlightDisplayLevel.ERROR) {
return HighlightInfo.newHighlightInfo(HighlightInfoType.WRONG_REF).range(refNameElement).descriptionAndTooltip(message).create();
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/utils/EquivalenceChecker.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/utils/EquivalenceChecker.java
index 9647c00..00fb04a 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/utils/EquivalenceChecker.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/utils/EquivalenceChecker.java
@@ -727,8 +727,8 @@
private static boolean assignmentExpressionsAreEquivalent(@NotNull GrAssignmentExpression assignExp1,
@NotNull GrAssignmentExpression assignExp2) {
- final IElementType sign1 = assignExp1.getOperationToken();
- final IElementType sign2 = assignExp2.getOperationToken();
+ final IElementType sign1 = assignExp1.getOperationTokenType();
+ final IElementType sign2 = assignExp2.getOperationTokenType();
if (sign1 != sign2) {
return false;
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeStyle/GroovyLanguageCodeStyleSettingsProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeStyle/GroovyLanguageCodeStyleSettingsProvider.java
index 71f59b6..e2ce60e 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeStyle/GroovyLanguageCodeStyleSettingsProvider.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeStyle/GroovyLanguageCodeStyleSettingsProvider.java
@@ -34,9 +34,9 @@
*/
public class GroovyLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSettingsProvider {
- public static final String IN_SPOCK_ONLY = "In Spock only";
public static final String ABSOLUTE = "Absolute";
- public static final String RELATIVE = "Relative";
+ public static final String RELATIVE = "Indent statements after label";
+ public static final String RELATIVE_REVERSED = "Indent labels";
@NotNull
@Override
@@ -264,8 +264,6 @@
defaultSettings.SPACE_WITHIN_BRACES = true;
defaultSettings.KEEP_SIMPLE_CLASSES_IN_ONE_LINE = true;
defaultSettings.KEEP_SIMPLE_METHODS_IN_ONE_LINE = true;
- //defaultSettings.KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = true;
- defaultSettings.getIndentOptions().LABEL_INDENT_SIZE = 2;
return defaultSettings;
}
@@ -300,7 +298,7 @@
myStyleLabel = new JBLabel("Label indent style:");
- myLabelIndentStyle = new JComboBox(new Object[] {IN_SPOCK_ONLY, ABSOLUTE, RELATIVE});
+ myLabelIndentStyle = new JComboBox(new Object[] {ABSOLUTE, RELATIVE, RELATIVE_REVERSED});
add(myStyleLabel, myLabelIndentStyle);
}
@@ -320,7 +318,7 @@
return !RELATIVE.equals(myLabelIndentStyle.getSelectedItem());
}
else {
- return !IN_SPOCK_ONLY.equals(myLabelIndentStyle.getSelectedItem());
+ return !RELATIVE_REVERSED.equals(myLabelIndentStyle.getSelectedItem());
}
}
@@ -342,7 +340,7 @@
myLabelIndentStyle.setSelectedItem(RELATIVE);
}
else {
- myLabelIndentStyle.setSelectedItem(IN_SPOCK_ONLY);
+ myLabelIndentStyle.setSelectedItem(RELATIVE_REVERSED);
}
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/compiler/GroovyCompilerBase.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/compiler/GroovyCompilerBase.java
index f0d26c9..69450a8 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/compiler/GroovyCompilerBase.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/compiler/GroovyCompilerBase.java
@@ -143,7 +143,7 @@
if (profileGroovyc) {
parameters.getVMParametersList().defineProperty("java.library.path", PathManager.getBinPath());
parameters.getVMParametersList().defineProperty("profile.groovy.compiler", "true");
- parameters.getVMParametersList().add("-agentlib:yjpagent=disablej2ee,disablealloc,sessionname=GroovyCompiler");
+ parameters.getVMParametersList().add("-agentlib:yjpagent=disablej2ee,disablealloc,delay=10000,sessionname=GroovyCompiler");
classPathBuilder.add(PathManager.findFileInLibDirectory("yjp-controller-api-redist.jar").getAbsolutePath());
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/dsl/CustomMembersGenerator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/dsl/CustomMembersGenerator.java
index 64d0f9f..b35fb5a 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/dsl/CustomMembersGenerator.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/dsl/CustomMembersGenerator.java
@@ -178,11 +178,9 @@
if (isMethodCall(place, parent)) {
assert parent instanceof GrMethodCall && place instanceof GrReferenceExpression;
- GrMethodCall call = (GrMethodCall)parent;
GrReferenceExpression ref = (GrReferenceExpression)place;
- PsiType[] argTypes =
- PsiUtil.getArgumentTypes(call.getNamedArguments(), call.getExpressionArguments(), call.getClosureArguments(), false, null, false);
+ PsiType[] argTypes = PsiUtil.getArgumentTypes(ref, false);
if (argTypes == null) return;
String[] types = new String[argTypes.length];
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyLiteralCopyPasteProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyLiteralCopyPasteProcessor.java
index 2f86439..fd85bc2 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyLiteralCopyPasteProcessor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyLiteralCopyPasteProcessor.java
@@ -112,7 +112,8 @@
@Override
protected String getLineBreaker(@NotNull PsiElement token) {
- final String text = token.getParent().getText();
+ PsiElement parent = GrStringUtil.findContainingLiteral(token);
+ final String text = parent.getText();
if (text.contains("'''") || text.contains("\"\"\"")) {
return "\n";
}
@@ -173,7 +174,7 @@
}
if (tokenType == mGSTRING_CONTENT || tokenType == mGSTRING_LITERAL || tokenType == GroovyElementTypes.GSTRING_INJECTION) {
- boolean singleLine = !token.getParent().getText().contains("\"\"\"");
+ boolean singleLine = !GrStringUtil.findContainingLiteral(token).getText().contains("\"\"\"");
StringBuilder b = new StringBuilder();
GrStringUtil.escapeStringCharacters(s.length(), s, singleLine ? "\"" : "", singleLine, true, b);
GrStringUtil.unescapeCharacters(b, singleLine ? "'" : "'\"", true);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyReferenceCopyPasteProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyReferenceCopyPasteProcessor.java
index ed3e603..d6b80d3 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyReferenceCopyPasteProcessor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyReferenceCopyPasteProcessor.java
@@ -16,7 +16,7 @@
package org.jetbrains.plugins.groovy.editor;
import com.intellij.codeInsight.editorActions.CopyPasteReferenceProcessor;
-import com.intellij.codeInsight.editorActions.ReferenceTransferableData;
+import com.intellij.codeInsight.editorActions.ReferenceData;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.RangeMarker;
import com.intellij.openapi.util.TextRange;
@@ -36,7 +36,7 @@
public class GroovyReferenceCopyPasteProcessor extends CopyPasteReferenceProcessor<GrReferenceElement> {
private static final Logger LOG = Logger.getInstance(GroovyReferenceCopyPasteProcessor.class);
- protected void addReferenceData(PsiFile file, int startOffset, PsiElement element, ArrayList<ReferenceTransferableData.ReferenceData> to) {
+ protected void addReferenceData(PsiFile file, int startOffset, PsiElement element, ArrayList<ReferenceData> to) {
if (element instanceof GrReferenceElement) {
if (((GrReferenceElement)element).getQualifier() == null) {
final GroovyResolveResult resolveResult = ((GrReferenceElement)element).advancedResolve();
@@ -67,13 +67,13 @@
protected GrReferenceElement[] findReferencesToRestore(PsiFile file,
RangeMarker bounds,
- ReferenceTransferableData.ReferenceData[] referenceData) {
+ ReferenceData[] referenceData) {
PsiManager manager = file.getManager();
final JavaPsiFacade facade = JavaPsiFacade.getInstance(manager.getProject());
PsiResolveHelper helper = facade.getResolveHelper();
GrReferenceElement[] refs = new GrReferenceElement[referenceData.length];
for (int i = 0; i < referenceData.length; i++) {
- ReferenceTransferableData.ReferenceData data = referenceData[i];
+ ReferenceData data = referenceData[i];
PsiClass refClass = facade.findClass(data.qClassName, file.getResolveScope());
if (refClass == null) continue;
@@ -110,14 +110,14 @@
return refs;
}
- protected void restoreReferences(ReferenceTransferableData.ReferenceData[] referenceData,
+ protected void restoreReferences(ReferenceData[] referenceData,
GrReferenceElement[] refs) {
for (int i = 0; i < refs.length; i++) {
GrReferenceElement reference = refs[i];
if (reference == null) continue;
try {
PsiManager manager = reference.getManager();
- ReferenceTransferableData.ReferenceData refData = referenceData[i];
+ ReferenceData refData = referenceData[i];
PsiClass refClass = JavaPsiFacade.getInstance(manager.getProject()).findClass(refData.qClassName, reference.getResolveScope());
if (refClass != null) {
if (refData.staticMemberName == null) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/actions/GroovyEnterHandler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/actions/GroovyEnterHandler.java
index 44216de..762f3e8 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/actions/GroovyEnterHandler.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/actions/GroovyEnterHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -31,6 +31,7 @@
import com.intellij.openapi.editor.highlighter.HighlighterIterator;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.text.StringUtil;
@@ -42,6 +43,7 @@
import com.intellij.psi.tree.TokenSet;
import com.intellij.util.text.CharArrayCharSequence;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.GroovyFileType;
import org.jetbrains.plugins.groovy.codeStyle.GroovyCodeStyleSettings;
import org.jetbrains.plugins.groovy.editor.HandlerUtils;
@@ -88,21 +90,21 @@
private static final TokenSet REGEX_TOKENS = TokenSet.create(mREGEX_BEGIN, mREGEX_CONTENT, mREGEX_END, mDOLLAR_SLASH_REGEX_BEGIN,
mDOLLAR_SLASH_REGEX_CONTENT, mDOLLAR_SLASH_REGEX_END);
- private static final TokenSet AFTER_DOLLAR = TokenSet.create(mLCURLY, mIDENT, mGSTRING_CONTENT, mDOLLAR, mGSTRING_END, mREGEX_CONTENT,
- mDOLLAR_SLASH_REGEX_CONTENT, mREGEX_END, mDOLLAR_SLASH_REGEX_END);
+ private static final TokenSet AFTER_DOLLAR = TokenSet.create(mLCURLY, mIDENT, mDOLLAR, mGSTRING_END, mREGEX_END, mDOLLAR_SLASH_REGEX_END,
+ GSTRING_CONTENT, mGSTRING_CONTENT, mREGEX_CONTENT, mDOLLAR_SLASH_REGEX_CONTENT);
private static final TokenSet ALL_STRINGS = TokenSet.create(mSTRING_LITERAL, mGSTRING_LITERAL, mGSTRING_BEGIN, mGSTRING_END,
mGSTRING_CONTENT, mRCURLY, mIDENT, mDOLLAR, mREGEX_BEGIN, mREGEX_CONTENT,
mREGEX_END, mDOLLAR_SLASH_REGEX_BEGIN, mDOLLAR_SLASH_REGEX_CONTENT,
- mDOLLAR_SLASH_REGEX_END, mREGEX_LITERAL, mDOLLAR_SLASH_REGEX_LITERAL);
+ mDOLLAR_SLASH_REGEX_END, mREGEX_LITERAL, mDOLLAR_SLASH_REGEX_LITERAL, GSTRING_CONTENT);
- private static final TokenSet BEFORE_DOLLAR =TokenSet.create(mGSTRING_BEGIN, mGSTRING_CONTENT, mREGEX_BEGIN, mREGEX_CONTENT,
- mDOLLAR_SLASH_REGEX_BEGIN, mDOLLAR_SLASH_REGEX_CONTENT);
+ private static final TokenSet BEFORE_DOLLAR =TokenSet.create(mGSTRING_BEGIN, mREGEX_BEGIN, mDOLLAR_SLASH_REGEX_BEGIN, GSTRING_CONTENT,
+ mGSTRING_CONTENT, mREGEX_CONTENT, mDOLLAR_SLASH_REGEX_CONTENT);
private static final TokenSet EXPR_END = TokenSet.create(mRCURLY, mIDENT);
- private static final TokenSet AFTER_EXPR_END = TokenSet.create(mGSTRING_END, mGSTRING_CONTENT, mDOLLAR, mREGEX_END, mREGEX_CONTENT,
- mDOLLAR_SLASH_REGEX_END, mDOLLAR_SLASH_REGEX_CONTENT);
+ private static final TokenSet AFTER_EXPR_END = TokenSet.create(mGSTRING_END, mDOLLAR, mREGEX_END, mDOLLAR_SLASH_REGEX_END, GSTRING_CONTENT,
+ mGSTRING_CONTENT, mREGEX_CONTENT, mDOLLAR_SLASH_REGEX_CONTENT);
private static final TokenSet STRING_END = TokenSet.create(mSTRING_LITERAL, mGSTRING_LITERAL, mGSTRING_END, mREGEX_END,
mDOLLAR_SLASH_REGEX_END, mREGEX_LITERAL, mDOLLAR_SLASH_REGEX_LITERAL);
@@ -110,7 +112,7 @@
private static final TokenSet INNER_STRING_TOKENS = TokenSet.create(mGSTRING_BEGIN, mGSTRING_CONTENT, mGSTRING_END, mREGEX_BEGIN,
mREGEX_CONTENT, mREGEX_END, mDOLLAR_SLASH_REGEX_BEGIN,
mDOLLAR_SLASH_REGEX_CONTENT, mDOLLAR_SLASH_REGEX_END,
- GSTRING_INJECTION);
+ GSTRING_INJECTION, GSTRING_CONTENT);
public static void insertSpacesByGroovyContinuationIndent(Editor editor, Project project) {
int indentSize = CodeStyleSettingsManager.getSettings(project).getContinuationIndentSize(GroovyFileType.GROOVY_FILE_TYPE);
@@ -287,24 +289,20 @@
if (file == null) return false;
PsiDocumentManager.getInstance(project).commitDocument(document);
- PsiElement stringElement = file.findElementAt(caretOffset - 1);
- if (stringElement == null) return false;
- ASTNode node = stringElement.getNode();
- if (node == null) return false;
- // For expression injection in GString like "abc ${}<caret> abc"
- if (!INNER_STRING_TOKENS.contains(node.getElementType()) && checkGStringInjection(stringElement)) {
- stringElement = stringElement.getParent().getParent().getNextSibling();
- if (stringElement == null) return false;
- node = stringElement.getNode();
- if (node == null) return false;
- }
+ Pair<PsiElement, ASTNode> pair = inferStringPair(file, caretOffset);
+ if (pair == null) return false;
+
+ final PsiElement stringElement = pair.getFirst();
+ final ASTNode node = pair.getSecond();
+ final IElementType nodeElementType = node.getElementType();
+
boolean isInsertIndent = isInsertIndent(caretOffset, stringElement.getTextRange().getStartOffset(), fileText);
// For simple String literals like 'abcdef'
CaretModel caretModel = editor.getCaretModel();
- if (mSTRING_LITERAL == node.getElementType()) {
+ if (nodeElementType == mSTRING_LITERAL) {
if (GrStringUtil.isPlainStringLiteral(node)) {
//the case of print '\<caret>'
@@ -332,10 +330,11 @@
return true;
}
- if (GSTRING_TOKENS.contains(node.getElementType()) ||
- node.getElementType() == mDOLLAR && node.getTreeParent().getTreeParent().getElementType() == GSTRING) {
+ if (GSTRING_TOKENS.contains(nodeElementType) ||
+ nodeElementType == GSTRING_CONTENT && GSTRING_TOKENS.contains(node.getFirstChildNode().getElementType()) ||
+ nodeElementType == mDOLLAR && node.getTreeParent().getTreeParent().getElementType() == GSTRING) {
PsiElement parent = stringElement.getParent();
- if (node.getElementType() == mGSTRING_LITERAL) {
+ if (nodeElementType == mGSTRING_LITERAL) {
parent = stringElement;
}
else {
@@ -375,10 +374,11 @@
return true;
}
- if (REGEX_TOKENS.contains(node.getElementType()) ||
- node.getElementType() == mDOLLAR && node.getTreeParent().getTreeParent().getElementType() == REGEX) {
+ if (REGEX_TOKENS.contains(nodeElementType) ||
+ nodeElementType == GSTRING_CONTENT && REGEX_TOKENS.contains(node.getFirstChildNode().getElementType()) ||
+ nodeElementType == mDOLLAR && node.getTreeParent().getTreeParent().getElementType() == REGEX) {
PsiElement parent = stringElement.getParent();
- if (node.getElementType() == mREGEX_LITERAL || node.getElementType() == mDOLLAR_SLASH_REGEX_LITERAL) {
+ if (nodeElementType == mREGEX_LITERAL || nodeElementType == mDOLLAR_SLASH_REGEX_LITERAL) {
parent = stringElement;
}
else {
@@ -402,6 +402,24 @@
return false;
}
+ @Nullable
+ private static Pair<PsiElement, ASTNode> inferStringPair(PsiFile file, int caretOffset) {
+ PsiElement stringElement = file.findElementAt(caretOffset - 1);
+ if (stringElement == null) return null;
+ ASTNode node = stringElement.getNode();
+ if (node == null) return null;
+
+ // For expression injection in GString like "abc ${}<caret> abc"
+ if (!INNER_STRING_TOKENS.contains(node.getElementType()) && checkGStringInjection(stringElement)) {
+ stringElement = stringElement.getParent().getParent().getNextSibling();
+ if (stringElement == null) return null;
+ node = stringElement.getNode();
+ if (node == null) return null;
+ }
+
+ return Pair.create(stringElement, node);
+ }
+
private static boolean isSlashBeforeCaret(int caretOffset, String fileText) {
return caretOffset > 0 && fileText.charAt(caretOffset - 1) == '\\';
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/selection/GroovyGStringSelectioner.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/selection/GroovyGStringSelectioner.java
index 02793cb..baf575a 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/selection/GroovyGStringSelectioner.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/selection/GroovyGStringSelectioner.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -30,6 +30,7 @@
import java.util.List;
import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.*;
+import static org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes.GSTRING_CONTENT;
/**
* @author Maxim.Medvedev
@@ -123,7 +124,7 @@
if (node == null) break;
final IElementType type = node.getElementType();
if (type == mGSTRING_BEGIN) break;
- if (type == mGSTRING_CONTENT) {
+ if (type == GSTRING_CONTENT) {
final int i = next.getText().lastIndexOf('\n');
if (i >= 0) {
startOffset = next.getTextOffset() + i + 1;
@@ -148,7 +149,7 @@
endOffset = next.getTextOffset();
break;
}
- if (type == mGSTRING_CONTENT) {
+ if (type == GSTRING_CONTENT) {
final int i = next.getText().indexOf('\n');
if (i >= 0) {
endOffset = next.getTextOffset() + i + 1;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/AccessorMethodReferencesSearcher.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/AccessorMethodReferencesSearcher.java
index 03aad49..76dfca0 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/AccessorMethodReferencesSearcher.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/AccessorMethodReferencesSearcher.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -30,7 +30,6 @@
import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrGdkMethodImpl;
import org.jetbrains.plugins.groovy.lang.psi.util.GdkMethodUtil;
import org.jetbrains.plugins.groovy.lang.psi.util.GroovyPropertyUtils;
-import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
/**
* author ven
@@ -56,7 +55,7 @@
if (propertyName == null) return;
- final SearchScope onlyGroovyFiles = PsiUtil.restrictScopeToGroovyFiles(queryParameters.getScope());
+ final SearchScope onlyGroovyFiles = GroovyScopeUtil.restrictScopeToGroovyFiles(queryParameters.getScope(), GroovyScopeUtil.getEffectiveScope(method));
queryParameters.getOptimizer().searchWord(propertyName, onlyGroovyFiles, UsageSearchContext.IN_CODE, true, method);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/AccessorReferencesSearcher.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/AccessorReferencesSearcher.java
index f576687..2344d1e 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/AccessorReferencesSearcher.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/AccessorReferencesSearcher.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -28,7 +28,6 @@
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAccessorMethod;
import org.jetbrains.plugins.groovy.lang.psi.util.GroovyPropertyUtils;
-import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
/**
* author ven
@@ -46,7 +45,8 @@
final String propertyName = GroovyPropertyUtils.getPropertyName((PsiMethod)element);
if (propertyName == null) return;
- queryParameters.getOptimizer().searchWord(propertyName, PsiUtil.restrictScopeToGroovyFiles(queryParameters.getEffectiveSearchScope()),
+ queryParameters.getOptimizer().searchWord(propertyName, GroovyScopeUtil
+ .restrictScopeToGroovyFiles(queryParameters.getEffectiveSearchScope()),
UsageSearchContext.IN_CODE, true, element);
}
else if (element instanceof GrField) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GrAliasedImportedElementSearcher.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GrAliasedImportedElementSearcher.java
index 112e6b6..9a626f4 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GrAliasedImportedElementSearcher.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GrAliasedImportedElementSearcher.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -26,7 +26,6 @@
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAccessorMethod;
import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement;
import org.jetbrains.plugins.groovy.lang.psi.util.GroovyPropertyUtils;
-import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
/**
* @author Maxim.Medvedev
@@ -45,7 +44,7 @@
final String name = ((PsiNamedElement)target).getName();
if (name == null || StringUtil.isEmptyOrSpaces(name)) return;
- final SearchScope onlyGroovy = PsiUtil.restrictScopeToGroovyFiles(parameters.getEffectiveSearchScope());
+ final SearchScope onlyGroovy = GroovyScopeUtil.restrictScopeToGroovyFiles(parameters.getEffectiveSearchScope());
final SearchRequestCollector collector = parameters.getOptimizer();
final SearchSession session = collector.getSearchSession();
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GrLiteralMethodSearcher.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GrLiteralMethodSearcher.java
index 5a8564f..678597d 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GrLiteralMethodSearcher.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GrLiteralMethodSearcher.java
@@ -45,13 +45,8 @@
final boolean strictSignatureSearch = p.isStrictSignatureSearch();
final PsiMethod[] methods = strictSignatureSearch ? new PsiMethod[]{method} : aClass.findMethodsByName(name, false);
- SearchScope accessScope = methods[0].getUseScope();
- for (int i = 1; i < methods.length; i++) {
- PsiMethod method1 = methods[i];
- accessScope = accessScope.union(method1.getUseScope());
- }
-
- final SearchScope restrictedByAccess = p.getScope().intersectWith(accessScope);
+ SearchScope accessScope = GroovyScopeUtil.getEffectiveScope(methods);
+ final SearchScope restrictedByAccess = GroovyScopeUtil.restrictScopeToGroovyFiles(p.getScope(), accessScope);
final String textToSearch = findLongestWord(name);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GroovyConstructorUsagesSearcher.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GroovyConstructorUsagesSearcher.java
index 2628614..8da5200 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GroovyConstructorUsagesSearcher.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GroovyConstructorUsagesSearcher.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -61,7 +61,6 @@
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement;
import org.jetbrains.plugins.groovy.lang.psi.controlFlow.Instruction;
-import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
import java.util.Arrays;
import java.util.HashSet;
@@ -84,11 +83,10 @@
static void processConstructorUsages(final PsiMethod constructor, final SearchScope searchScope, final Processor<PsiReference> consumer, final SearchRequestCollector collector, final boolean searchGppCalls, final boolean includeOverloads) {
if (!constructor.isConstructor()) return;
- SearchScope onlyGroovy = PsiUtil.restrictScopeToGroovyFiles(searchScope);
-
final PsiClass clazz = constructor.getContainingClass();
if (clazz == null) return;
+ SearchScope onlyGroovy = GroovyScopeUtil.restrictScopeToGroovyFiles(searchScope, GroovyScopeUtil.getEffectiveScope(constructor));
Set<PsiClass> processed = collector.getSearchSession().getUserData(LITERALLY_CONSTRUCTED_CLASSES);
if (processed == null) {
collector.getSearchSession().putUserData(LITERALLY_CONSTRUCTED_CLASSES, processed = new ConcurrentHashSet<PsiClass>());
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GroovyScopeUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GroovyScopeUtil.java
new file mode 100644
index 0000000..87b9d04
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GroovyScopeUtil.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2000-2013 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 org.jetbrains.plugins.groovy.findUsages;
+
+import com.intellij.psi.PsiMethod;
+import com.intellij.psi.search.GlobalSearchScope;
+import com.intellij.psi.search.SearchScope;
+import org.jetbrains.plugins.groovy.GroovyFileTypeLoader;
+
+/**
+ * @author Max Medvedev
+ */
+public class GroovyScopeUtil {
+ public static SearchScope restrictScopeToGroovyFiles(SearchScope originalScope) {
+ if (originalScope instanceof GlobalSearchScope) {
+ return GlobalSearchScope
+ .getScopeRestrictedByFileTypes((GlobalSearchScope)originalScope, GroovyFileTypeLoader.getGroovyEnabledFileTypes());
+ }
+ return originalScope;
+ }
+
+ public static SearchScope restrictScopeToGroovyFiles(SearchScope originalScope, SearchScope effectiveScope) {
+ SearchScope restricted = restrictScopeToGroovyFiles(originalScope);
+ return originalScope.intersectWith(effectiveScope);
+ }
+
+
+ public static SearchScope getEffectiveScope(PsiMethod... methods) {
+ SearchScope accessScope = methods[0].getUseScope();
+ for (int i = 1; i < methods.length; i++) {
+ PsiMethod method1 = methods[i];
+ accessScope = accessScope.union(method1.getUseScope());
+ }
+ return accessScope;
+ }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/MethodLateBoundReferencesSearcher.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/MethodLateBoundReferencesSearcher.java
index 2c834a4..2c0efe9 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/MethodLateBoundReferencesSearcher.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/MethodLateBoundReferencesSearcher.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -49,7 +49,7 @@
@Override
public void processQuery(@NotNull MethodReferencesSearch.SearchParameters queryParameters, @NotNull Processor<PsiReference> consumer) {
final PsiMethod method = queryParameters.getMethod();
- SearchScope searchScope = PsiUtil.restrictScopeToGroovyFiles(queryParameters.getScope()).intersectWith(getUseScope(method));
+ SearchScope searchScope = GroovyScopeUtil.restrictScopeToGroovyFiles(queryParameters.getScope()).intersectWith(getUseScope(method));
orderSearching(searchScope, method.getName(), queryParameters.getOptimizer(), method.getParameterList().getParametersCount());
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/blocks/ClosureBodyBlock.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/blocks/ClosureBodyBlock.java
index 45c57c8..9bafca4 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/blocks/ClosureBodyBlock.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/blocks/ClosureBodyBlock.java
@@ -24,7 +24,6 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.formatter.FormattingContext;
-import org.jetbrains.plugins.groovy.formatter.processors.GroovyIndentProcessor;
import java.util.List;
@@ -53,7 +52,7 @@
GroovyBlockGenerator generator = new GroovyBlockGenerator(this);
List<ASTNode> children = GroovyBlockGenerator.getClosureBodyVisibleChildren(myNode.getTreeParent());
- mySubBlocks = generator.generateSubBlockForCodeBlocks(false, children, GroovyIndentProcessor.indentLabelBlock(myNode.getPsi(), myContext.getGroovySettings()));
+ mySubBlocks = generator.generateSubBlockForCodeBlocks(false, children, myContext.getGroovySettings().INDENT_LABEL_BLOCKS);
//at least -> exists
assert !mySubBlocks.isEmpty();
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/blocks/GroovyBlock.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/blocks/GroovyBlock.java
index 8cdf7ca..eef7050 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/blocks/GroovyBlock.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/blocks/GroovyBlock.java
@@ -219,7 +219,7 @@
return new ChildAttributes(Indent.getNormalIndent(), null);
}
if (psiParent instanceof GrLabeledStatement && newChildIndex == 2) {
- final Indent indent = GroovyIndentProcessor.indentLabelBlock(psiParent, getContext().getGroovySettings())
+ final Indent indent = getContext().getGroovySettings().INDENT_LABEL_BLOCKS
? Indent.getLabelIndent()
: Indent.getNoneIndent();
return new ChildAttributes(indent, null);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/blocks/GroovyBlockGenerator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/blocks/GroovyBlockGenerator.java
index 34789c7..5ba50a6 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/blocks/GroovyBlockGenerator.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/blocks/GroovyBlockGenerator.java
@@ -242,7 +242,7 @@
}
if (blockPsi instanceof GrCodeBlock || blockPsi instanceof GroovyFile || classLevel) {
- return generateSubBlockForCodeBlocks(classLevel, visibleChildren(myNode), GroovyIndentProcessor.indentLabelBlock(blockPsi, myContext.getGroovySettings()));
+ return generateSubBlockForCodeBlocks(classLevel, visibleChildren(myNode), myContext.getGroovySettings().INDENT_LABEL_BLOCKS);
}
if (blockPsi instanceof GrMethod) {
@@ -324,7 +324,7 @@
return wrap;
}
- public List<Block> generateSubBlockForCodeBlocks(boolean classLevel, final List<ASTNode> children, final boolean indentLabelBlocks) {
+ public List<Block> generateSubBlockForCodeBlocks(boolean classLevel, final List<ASTNode> children, boolean indentLabelBlocks) {
calculateAlignments(children, classLevel);
final ArrayList<Block> subBlocks = new ArrayList<Block>();
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovyIndentProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovyIndentProcessor.java
index a7ab5f1..2cc72c3 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovyIndentProcessor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovyIndentProcessor.java
@@ -18,15 +18,11 @@
import com.intellij.formatting.Indent;
import com.intellij.lang.ASTNode;
-import com.intellij.psi.PsiClassType;
import com.intellij.psi.PsiElement;
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.TokenSet;
-import com.intellij.psi.util.InheritanceUtil;
-import com.intellij.psi.util.PsiTreeUtil;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.plugins.groovy.codeStyle.GroovyCodeStyleSettings;
import org.jetbrains.plugins.groovy.formatter.blocks.ClosureBodyBlock;
import org.jetbrains.plugins.groovy.formatter.blocks.GrLabelBlock;
import org.jetbrains.plugins.groovy.formatter.blocks.GroovyBlock;
@@ -58,8 +54,6 @@
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinitionBody;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
-import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
-import org.jetbrains.plugins.groovy.spock.SpockUtils;
import static org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes.*;
@@ -151,46 +145,15 @@
if (indentOptions != null && indentOptions.LABEL_INDENT_ABSOLUTE) {
myResult = Indent.getAbsoluteLabelIndent();
}
- }
- else {
- if (indentLabelBlock(myChild, myBlock.getContext().getGroovySettings())) {
+ else if (!myBlock.getContext().getGroovySettings().INDENT_LABEL_BLOCKS) {
myResult = Indent.getLabelIndent();
}
}
- }
-
- public static boolean indentLabelBlock(@NotNull PsiElement place, final GroovyCodeStyleSettings settings) {
- if (settings.INDENT_LABEL_BLOCKS) {
- return true;
- }
-
- final GrTypeDefinition clazz = PsiTreeUtil.getParentOfType(place, GrTypeDefinition.class);
- if (clazz == null) return false;
- if (isDirectInheritorOfSpecification(clazz) || InheritanceUtil.isInheritor(clazz, SpockUtils.SPEC_CLASS_NAME)) {
- return true;
- }
-
- final PsiClassType[] supers = clazz.getSuperTypes();
- for (PsiClassType aSuper : supers) {
- if (aSuper.equalsToText(SpockUtils.SPEC_CLASS_NAME)) {
- return true;
+ else {
+ if (myBlock.getContext().getGroovySettings().INDENT_LABEL_BLOCKS) {
+ myResult = Indent.getLabelIndent();
}
}
-
- return false;
- }
-
- private static boolean isDirectInheritorOfSpecification(@NotNull GrTypeDefinition clazz) {
- final GrExtendsClause clause = clazz.getExtendsClause();
- if (clause != null) {
- final GrCodeReferenceElement[] refs = clause.getReferenceElements();
- for (GrCodeReferenceElement ref : refs) {
- if (SpockUtils.SPEC_CLASS_NAME.equals(ref.getClassNameText())) {
- return true;
- }
- }
- }
- return false;
}
@Override
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovySpacingProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovySpacingProcessor.java
index 89eb21e..ae5b677 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovySpacingProcessor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovySpacingProcessor.java
@@ -67,6 +67,7 @@
import static org.jetbrains.plugins.groovy.GroovyFileType.GROOVY_LANGUAGE;
import static org.jetbrains.plugins.groovy.formatter.models.spacing.SpacingTokens.*;
import static org.jetbrains.plugins.groovy.formatter.models.spacing.SpacingTokens.GROOVY_DOC_COMMENT;
+import static org.jetbrains.plugins.groovy.formatter.models.spacing.SpacingTokens.kIN;
import static org.jetbrains.plugins.groovy.formatter.models.spacing.SpacingTokens.mCOMMA;
import static org.jetbrains.plugins.groovy.formatter.models.spacing.SpacingTokens.mELVIS;
import static org.jetbrains.plugins.groovy.formatter.models.spacing.SpacingTokens.mGDOC_COMMENT_DATA;
@@ -210,7 +211,7 @@
@Override
public void visitLabeledStatement(GrLabeledStatement labeledStatement) {
if (myType1 == mCOLON) {
- if (GroovyIndentProcessor.indentLabelBlock(labeledStatement, myGroovySettings)) {
+ if (myGroovySettings.INDENT_LABEL_BLOCKS) {
createLF(true);
}
else {
@@ -363,7 +364,7 @@
else if (myType2 == PACKAGE_DEFINITION) {
myResult = Spacing.createSpacing(0, 0, mySettings.BLANK_LINES_BEFORE_PACKAGE + 1, mySettings.KEEP_LINE_BREAKS, Integer.MAX_VALUE / 2);
}
- else if (TYPE_DEFINITION_TYPES.contains(myType1) || TYPE_DEFINITION_TYPES.contains(myType2)) {
+ else if (isLeftOrRight(TYPE_DEFINITION_TYPES)) {
if (myType1 == GROOVY_DOC_COMMENT) {
createLF(true);
}
@@ -748,6 +749,7 @@
@Override
public void visitBinaryExpression(GrBinaryExpression expression) {
+
@SuppressWarnings("SimplifiableConditionalExpression" )
boolean spaceAround = isLeftOrRight(LOGICAL_OPERATORS) ? mySettings.SPACE_AROUND_LOGICAL_OPERATORS :
isLeftOrRight(EQUALITY_OPERATORS) ? mySettings.SPACE_AROUND_EQUALITY_OPERATORS :
@@ -756,7 +758,7 @@
isLeftOrRight(ADDITIVE_OPERATORS) ? mySettings.SPACE_AROUND_ADDITIVE_OPERATORS :
isLeftOrRight(MULTIPLICATIVE_OPERATORS) ? mySettings.SPACE_AROUND_MULTIPLICATIVE_OPERATORS :
isLeftOrRight(SHIFT_OPERATORS) ? mySettings.SPACE_AROUND_SHIFT_OPERATORS :
- false;
+ isLeftOrRight(kIN);
if (TokenSets.BINARY_OP_SET.contains(myType2)) {
createDependentLFSpacing(mySettings.BINARY_OPERATION_SIGN_ON_NEXT_LINE, spaceAround, expression.getTextRange());
}
@@ -769,6 +771,10 @@
return operators.contains(myType1) || operators.contains(myType2);
}
+ private boolean isLeftOrRight(IElementType type) {
+ return myType1 == type || myType2 == type;
+ }
+
@Override
public void visitUnaryExpression(GrUnaryExpression expression) {
if (!expression.isPostfix() && expression.getOperationToken() == myChild1 ||
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/IndexedExpressionConversionPredicate.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/IndexedExpressionConversionPredicate.java
index e1281a2..a4d48b1 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/IndexedExpressionConversionPredicate.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/IndexedExpressionConversionPredicate.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -51,7 +51,7 @@
if (rvalue.equals(element)) return true;
- final IElementType operator = assignmentExpression.getOperationToken();
+ final IElementType operator = assignmentExpression.getOperationTokenType();
return GroovyTokenTypes.mASSIGN.equals(operator);
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/strings/ConvertConcatenationToGstringIntention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/strings/ConvertConcatenationToGstringIntention.java
index 5780914..cfe7b52 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/strings/ConvertConcatenationToGstringIntention.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/strings/ConvertConcatenationToGstringIntention.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -45,7 +45,6 @@
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrBinaryExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrParenthesizedExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrRegex;
@@ -55,6 +54,7 @@
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.literals.GrLiteralImpl;
import org.jetbrains.plugins.groovy.lang.psi.util.GrStringUtil;
import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames;
+import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
import java.util.ArrayList;
import java.util.List;
@@ -190,8 +190,8 @@
}
private static void performIntention(GrBinaryExpression expr, StringBuilder builder, boolean multiline) {
- GrExpression left = (GrExpression)skipParentheses(expr.getLeftOperand(), false);
- GrExpression right = (GrExpression)skipParentheses(expr.getRightOperand(), false);
+ GrExpression left = (GrExpression)PsiUtil.skipParentheses(expr.getLeftOperand(), false);
+ GrExpression right = (GrExpression)PsiUtil.skipParentheses(expr.getRightOperand(), false);
getOperandText(left, builder, multiline);
getOperandText(right, builder, multiline);
}
@@ -267,23 +267,6 @@
return false;
}
- @Nullable
- private static PsiElement skipParentheses(PsiElement element, boolean up) {
- if (up) {
- PsiElement parent = element.getParent();
- while (parent instanceof GrParenthesizedExpression) {
- parent = parent.getParent();
- }
- return parent;
- }
- else {
- while (element instanceof GrParenthesizedExpression) {
- element = ((GrParenthesizedExpression)element).getOperand();
- }
- return element;
- }
- }
-
private static class MyPredicate implements PsiElementPredicate {
public boolean satisfiedBy(PsiElement element) {
return satisfied(element);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/strings/ConvertMultilineStringToSingleLineIntention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/strings/ConvertMultilineStringToSingleLineIntention.java
index cb18d61..0dd2f6c 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/strings/ConvertMultilineStringToSingleLineIntention.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/strings/ConvertMultilineStringToSingleLineIntention.java
@@ -28,9 +28,10 @@
import org.jetbrains.plugins.groovy.intentions.base.Intention;
import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
-import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
+import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrStringContent;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrStringInjection;
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.literals.GrLiteralImpl;
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.literals.GrStringImpl;
@@ -59,12 +60,12 @@
}
else {
final GrStringImpl gstring = (GrStringImpl)element;
- for (ASTNode child = gstring.getNode().getFirstChildNode(); child != null; child = child.getTreeNext()) {
- if (child.getElementType() == GroovyTokenTypes.mGSTRING_CONTENT) {
- appendSimpleStringValue(child.getPsi(), buffer, "\"");
+ for (GroovyPsiElement child : gstring.getAllContentParts()) {
+ if (child instanceof GrStringContent) {
+ appendSimpleStringValue(child, buffer, "\"");
}
- else if (child.getElementType() == GroovyElementTypes.GSTRING_INJECTION) {
- buffer.append(child.getText());
+ else if (child instanceof GrStringInjection) {
+ buffer.append(child);
}
}
old = gstring;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/strings/ConvertStringToMultilineIntention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/strings/ConvertStringToMultilineIntention.java
index d08d3dd..857819f 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/strings/ConvertStringToMultilineIntention.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/strings/ConvertStringToMultilineIntention.java
@@ -15,7 +15,6 @@
*/
package org.jetbrains.plugins.groovy.intentions.conversions.strings;
-import com.intellij.lang.ASTNode;
import com.intellij.openapi.application.AccessToken;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ReadAction;
@@ -37,12 +36,13 @@
import org.jetbrains.plugins.groovy.intentions.base.Intention;
import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
-import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrBinaryExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrString;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrStringContent;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrStringInjection;
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.literals.GrLiteralImpl;
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.literals.GrStringImpl;
import org.jetbrains.plugins.groovy.lang.psi.util.GrStringUtil;
@@ -213,11 +213,11 @@
}
else {
final GrStringImpl gstring = (GrStringImpl)literal;
- for (ASTNode child = gstring.getNode().getFirstChildNode(); child != null; child = child.getTreeNext()) {
- if (child.getElementType() == GroovyTokenTypes.mGSTRING_CONTENT) {
- appendSimpleStringValue(child.getPsi(), buffer, "\"\"\"");
+ for (PsiElement child : gstring.getAllContentParts()) {
+ if (child instanceof GrStringContent) {
+ appendSimpleStringValue(child, buffer, "\"\"\"");
}
- else if (child.getElementType() == GroovyElementTypes.GSTRING_INJECTION) {
+ else if (child instanceof GrStringInjection) {
buffer.append(child.getText());
}
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/ImportOnDemandIntention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/ImportOnDemandIntention.java
index 7b695a3..a6b5e45 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/ImportOnDemandIntention.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/ImportOnDemandIntention.java
@@ -54,7 +54,7 @@
if (!(containingFile instanceof GroovyFile)) return;
((GroovyFile)containingFile).addImport(importStatement);
- for (PsiReference reference : ReferencesSearch.search(resolved, new LocalSearchScope(containingFile), true)) {
+ for (PsiReference reference : ReferencesSearch.search(resolved, new LocalSearchScope(containingFile))) {
final PsiElement refElement = reference.getElement();
if (refElement == null) continue;
final PsiElement parent = refElement.getParent();
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionContributor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionContributor.java
index 95dbc1d..2ca5c7e 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionContributor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionContributor.java
@@ -308,7 +308,9 @@
});
if (reference.getQualifier() == null) {
- GroovySmartCompletionContributor.addExpectedClassMembers(parameters, result);
+ if (!GroovySmartCompletionContributor.AFTER_NEW.accepts(position)) {
+ GroovySmartCompletionContributor.addExpectedClassMembers(parameters, result);
+ }
if (isClassNamePossible(position) && JavaCompletionContributor.mayStartClassName(result)) {
result.stopHere();
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionUtil.java
index 71f025a..275ae14 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionUtil.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionUtil.java
@@ -418,8 +418,8 @@
return type != null ? builder.withTypeText(type.getPresentableText()) : builder;
}
- public static boolean hasConstructorParameters(@NotNull PsiClass clazz, @NotNull GroovyPsiElement place) {
- final GroovyResolveResult[] constructors = ResolveUtil.getAllClassConstructors(clazz, place, PsiSubstitutor.EMPTY, null);
+ public static boolean hasConstructorParameters(@NotNull PsiClass clazz, @NotNull PsiElement place) {
+ final GroovyResolveResult[] constructors = ResolveUtil.getAllClassConstructors(clazz, PsiSubstitutor.EMPTY, null, place);
boolean hasParameters = false;
boolean hasAccessibleConstructors = false;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovySmartCompletionContributor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovySmartCompletionContributor.java
index 604f233..f9b1ded 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovySmartCompletionContributor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovySmartCompletionContributor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -343,7 +343,7 @@
}
else if (pparent instanceof GrAssignmentExpression) {
GrAssignmentExpression assignment = (GrAssignmentExpression)pparent;
- IElementType optoken = assignment.getOperationToken();
+ IElementType optoken = assignment.getOperationTokenType();
GrExpression lvalue = assignment.getLValue();
GrExpression rvalue = assignment.getRValue();
@@ -356,7 +356,7 @@
PsiElement ppparent = pparent.getParent();
if (ppparent instanceof GrAssignmentExpression) {
GrAssignmentExpression assignment = (GrAssignmentExpression)ppparent;
- IElementType optoken = assignment.getOperationToken();
+ IElementType optoken = assignment.getOperationTokenType();
GrExpression lvalue = assignment.getLValue();
GrExpression rvalue = assignment.getRValue();
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/smartEnter/fixers/GrLiteralFixer.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/smartEnter/fixers/GrLiteralFixer.java
index ae416ea..30d6786 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/smartEnter/fixers/GrLiteralFixer.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/smartEnter/fixers/GrLiteralFixer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -22,7 +22,6 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.lang.completion.smartEnter.GroovySmartEnterProcessor;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrString;
/**
* User: Dmitry.Krasilschikov
@@ -30,20 +29,7 @@
*/
public class GrLiteralFixer extends SmartEnterProcessorWithFixers.Fixer<GroovySmartEnterProcessor> {
public void apply(@NotNull Editor editor, @NotNull GroovySmartEnterProcessor processor, @NotNull PsiElement psiElement) {
- if (psiElement instanceof GrString) {
- String text = psiElement.getText();
- if (StringUtil.startsWith(text, "\"\"\"")) {
- if (!StringUtil.endsWith(text, "\"\"\"")) {
- editor.getDocument().insertString(psiElement.getTextRange().getEndOffset(), "\"\"\"");
- }
- }
- else if (StringUtil.startsWith(text, "\"")) {
- if (!StringUtil.endsWith(text, "\"")) {
- editor.getDocument().insertString(psiElement.getTextRange().getEndOffset(), "\"");
- }
- }
- }
- else if (psiElement instanceof GrLiteral) {
+ if (psiElement instanceof GrLiteral) {
String text = psiElement.getText();
if (StringUtil.startsWith(text, "'''")) {
if (!StringUtil.endsWith(text, "'''")) {
@@ -55,6 +41,16 @@
editor.getDocument().insertString(psiElement.getTextRange().getEndOffset(), "'");
}
}
+ else if (StringUtil.startsWith(text, "\"\"\"")) {
+ if (!StringUtil.endsWith(text, "\"\"\"")) {
+ editor.getDocument().insertString(psiElement.getTextRange().getEndOffset(), "\"\"\"");
+ }
+ }
+ else if (StringUtil.startsWith(text, "\"")) {
+ if (!StringUtil.endsWith(text, "\"")) {
+ editor.getDocument().insertString(psiElement.getTextRange().getEndOffset(), "\"");
+ }
+ }
}
}
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/TokenSets.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/TokenSets.java
index 45c51b4..d2505b9 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/TokenSets.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/TokenSets.java
@@ -139,6 +139,8 @@
mDOLLAR_SLASH_REGEX_END
);
+ public static final TokenSet GSTRING_CONTENT_PARTS = TokenSet.create(GSTRING_CONTENT, GSTRING_INJECTION);
+
public static final TokenSet FOR_IN_DELIMITERS = TokenSet.create(kIN, mCOLON);
public static final TokenSet RELATIONS = TokenSet.create(
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyParameterInfoHandler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyParameterInfoHandler.java
index 85a7c04..8ac57c9 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyParameterInfoHandler.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyParameterInfoHandler.java
@@ -50,6 +50,7 @@
import org.jetbrains.plugins.groovy.lang.psi.impl.GrClosureType;
import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyResolveResultImpl;
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
+import org.jetbrains.plugins.groovy.lang.psi.util.GrInnerClassConstructorUtil;
import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil;
@@ -241,6 +242,7 @@
if (namedElement instanceof PsiMethod) {
final PsiMethod method = (PsiMethod)namedElement;
PsiParameter[] parameters = method.getParameterList().getParameters();
+ parameters = updateConstructorParams(method, parameters, context.getParameterOwner());
parameterTypes = new PsiType[parameters.length];
for (int j = 0; j < parameters.length; j++) {
parameterTypes[j] = parameters[j].getType();
@@ -364,7 +366,9 @@
buffer.append('(');
}
- final PsiParameter[] params = method.getParameterList().getParameters();
+ PsiParameter[] params = method.getParameterList().getParameters();
+
+ params = updateConstructorParams(method, params, context.getParameterOwner());
int numParams = params.length;
if (numParams > 0) {
@@ -448,6 +452,15 @@
);
}
+ private static PsiParameter[] updateConstructorParams(PsiMethod method, PsiParameter[] params, PsiElement place) {
+ if (GrInnerClassConstructorUtil.isInnerClassConstructorUsedOutsideOfItParent(method, place)) {
+ GrMethod grMethod = (GrMethod)method;
+ params = GrInnerClassConstructorUtil
+ .addEnclosingInstanceParam(grMethod, method.getContainingClass().getContainingClass(), grMethod.getParameters(), true);
+ }
+ return params;
+ }
+
private static void appendParameterText(PsiParameter param, PsiSubstitutor substitutor, StringBuilder buffer) {
if (param instanceof GrParameter) {
GrParameter grParam = (GrParameter)param;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GroovyElementTypes.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GroovyElementTypes.java
index 6cb0df6..cbf640c 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GroovyElementTypes.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GroovyElementTypes.java
@@ -249,7 +249,9 @@
// GStrings
GroovyElementType GSTRING = new GroovyElementType("GString");
- IElementType GSTRING_INJECTION =new GroovyElementType("Gstring injection");
+ GroovyElementType GSTRING_INJECTION =new GroovyElementType("Gstring injection");
+ GroovyElementType GSTRING_CONTENT = new GroovyElementType("GString content element");
+
GroovyElementType REGEX = new GroovyElementType("Regular expression");
//types
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GroovyPsiCreator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GroovyPsiCreator.java
index d8a16b7..a071bd2 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GroovyPsiCreator.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GroovyPsiCreator.java
@@ -45,10 +45,7 @@
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.*;
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.arithmetic.*;
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.bitwise.GrBitwiseExpressionImpl;
-import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.literals.GrLiteralImpl;
-import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.literals.GrRegexImpl;
-import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.literals.GrStringImpl;
-import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.literals.GrStringInjectionImpl;
+import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.literals.*;
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.logical.GrLogicalExpressionImpl;
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.path.GrIndexPropertyImpl;
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.path.GrMethodCallExpressionImpl;
@@ -225,6 +222,7 @@
if (elem == GSTRING) return new GrStringImpl(node);
if (elem == REGEX) return new GrRegexImpl(node);
if (elem == GSTRING_INJECTION) return new GrStringInjectionImpl(node);
+ if (elem == GSTRING_CONTENT) return new GrStringContentImpl(node);
if (elem == REFERENCE_EXPRESSION) return new GrReferenceExpressionImpl(node);
if (elem == PARENTHESIZED_EXPRESSION) return new GrParenthesizedExpressionImpl(node);
if (elem == NEW_EXPRESSION) return new GrNewExpressionImpl(node);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/auxiliary/annotations/AnnotationArguments.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/auxiliary/annotations/AnnotationArguments.java
index 5989f5f..89f1401 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/auxiliary/annotations/AnnotationArguments.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/auxiliary/annotations/AnnotationArguments.java
@@ -43,18 +43,9 @@
return;
}
- if (checkIdentAndAssign(builder)) {
+ if (builder.getTokenType() != mRPAREN) {
parsePairs(builder, parser);
}
- else {
- PsiBuilder.Marker pairMarker = builder.mark();
- if (parseAnnotationMemberValueInitializer(builder, parser)) {
- pairMarker.done(ANNOTATION_MEMBER_VALUE_PAIR);
- }
- else {
- pairMarker.drop();
- }
- }
ParserUtils.getToken(builder, mNLS);
ParserUtils.getToken(builder, mRPAREN, GroovyBundle.message("rparen.expected"));
@@ -122,17 +113,29 @@
private static boolean parsePair(PsiBuilder builder, GroovyParser parser) {
PsiBuilder.Marker marker = builder.mark();
+ final PsiBuilder.Marker lfMarker;
if (checkIdentAndAssign(builder)) {
ParserUtils.getToken(builder, TokenSets.CODE_REFERENCE_ELEMENT_NAME_TOKENS);
ParserUtils.getToken(builder, mASSIGN);
+
+ lfMarker = builder.mark();
ParserUtils.getToken(builder, mNLS);
}
else {
- builder.error(GroovyBundle.message("attribute.name.expected"));
+ lfMarker = null;
}
if (!parseAnnotationMemberValueInitializer(builder, parser)) {
- builder.error(GroovyBundle.message("annotation.member.value.initializer.expected"));
+ if (lfMarker != null) {
+ lfMarker.rollbackTo();
+ builder.error(GroovyBundle.message("annotation.member.value.initializer.expected"));
+ }
+ else {
+ builder.error(GroovyBundle.message("annotation.attribute.expected"));
+ }
+ }
+ else if (lfMarker != null) {
+ lfMarker.drop();
}
marker.done(ANNOTATION_MEMBER_VALUE_PAIR);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/arithmetic/PathExpression.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/arithmetic/PathExpression.java
index 14fe82f..65061b0 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/arithmetic/PathExpression.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/arithmetic/PathExpression.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -26,10 +26,8 @@
import org.jetbrains.plugins.groovy.lang.parser.GroovyParser;
import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.blocks.OpenOrClosableBlock;
import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.expressions.arguments.ArgumentList;
-import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.expressions.primary.DollarSlashRegexConstructorExpression;
+import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.expressions.primary.CompoundStringExpression;
import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.expressions.primary.PrimaryExpression;
-import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.expressions.primary.RegexConstructorExpression;
-import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.expressions.primary.StringConstructorExpression;
import org.jetbrains.plugins.groovy.lang.parser.parsing.types.TypeArguments;
import org.jetbrains.plugins.groovy.lang.parser.parsing.util.ParserUtils;
@@ -206,14 +204,22 @@
final IElementType tokenType = builder.getTokenType();
if (mGSTRING_BEGIN.equals(tokenType)) {
- StringConstructorExpression.parse(builder, parser);
- return PATH_PROPERTY_REFERENCE;
+ final boolean result = CompoundStringExpression.parse(builder, parser, true, mGSTRING_BEGIN, mGSTRING_CONTENT, mGSTRING_END, null,
+ GSTRING, GroovyBundle.message("string.end.expected"));
+ return result ? PATH_PROPERTY_REFERENCE : REFERENCE_EXPRESSION;
}
if (mREGEX_BEGIN.equals(tokenType)) {
- return RegexConstructorExpression.parse(builder, parser, true) ? PATH_PROPERTY_REFERENCE : REFERENCE_EXPRESSION;
+ final boolean result = CompoundStringExpression.parse(builder, parser, true,
+ mREGEX_BEGIN, mREGEX_CONTENT, mREGEX_END, mREGEX_LITERAL,
+ REGEX, GroovyBundle.message("regex.end.expected"));
+ return result ? PATH_PROPERTY_REFERENCE : REFERENCE_EXPRESSION;
}
if (mDOLLAR_SLASH_REGEX_BEGIN.equals(tokenType)) {
- return DollarSlashRegexConstructorExpression.parse(builder, parser, true) ? PATH_PROPERTY_REFERENCE : REFERENCE_EXPRESSION;
+ final boolean result = CompoundStringExpression.parse(builder, parser, true,
+ mDOLLAR_SLASH_REGEX_BEGIN, mDOLLAR_SLASH_REGEX_CONTENT, mDOLLAR_SLASH_REGEX_END,
+ mDOLLAR_SLASH_REGEX_LITERAL,
+ REGEX, GroovyBundle.message("dollar.slash.end.expected"));
+ return result ? PATH_PROPERTY_REFERENCE : REFERENCE_EXPRESSION;
}
if (mLCURLY.equals(tokenType)) {
OpenOrClosableBlock.parseOpenBlock(builder, parser);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/primary/CompoundStringExpression.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/primary/CompoundStringExpression.java
new file mode 100644
index 0000000..fcb7080
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/primary/CompoundStringExpression.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2000-2013 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 org.jetbrains.plugins.groovy.lang.parser.parsing.statements.expressions.primary;
+
+import com.intellij.lang.PsiBuilder;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.psi.tree.IElementType;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.groovy.GroovyBundle;
+import org.jetbrains.plugins.groovy.lang.lexer.GroovyElementType;
+import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
+import org.jetbrains.plugins.groovy.lang.parser.GroovyParser;
+import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.blocks.OpenOrClosableBlock;
+import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.expressions.arithmetic.PathExpression;
+import org.jetbrains.plugins.groovy.lang.parser.parsing.util.ParserUtils;
+
+/**
+ * @author ilyas
+ */
+public class CompoundStringExpression implements GroovyElementTypes {
+ private static final Logger LOG = Logger.getInstance(CompoundStringExpression.class);
+
+ /**
+ * Groovy lexer does not smart enough to understand whether a regex contents injections or not. So the parser should do this job.
+ * We create additional marker2 for the case of absence of injections. In this case resulting tree is as follows:
+ *
+ * Regex
+ * mRegexLiteral (mDollarSlashRegexLiteral)
+ * mRegexBegin (........................)
+ * mRegexContent (........................)
+ * mRegexEnd (........................)
+ *
+ * This tree emulates tree of simple GrLiteralImpl structure so we can use regexes where simple strings are expected.
+ *
+ * @return true if there are any injections
+ */
+ public static boolean parse(PsiBuilder builder,
+ GroovyParser parser,
+ boolean forRefExpr,
+ IElementType begin,
+ IElementType content,
+ IElementType end,
+ @Nullable IElementType literal,
+ GroovyElementType compoundLiteral, String message) {
+ PsiBuilder.Marker marker = builder.mark();
+ final PsiBuilder.Marker marker2 = builder.mark();
+ LOG.assertTrue(ParserUtils.getToken(builder, begin));
+
+ if (builder.getTokenType() == content) {
+ final PsiBuilder.Marker contentMarker = builder.mark();
+ builder.advanceLexer();
+ if (builder.getTokenType() == mDOLLAR || literal == null) {
+ contentMarker.done(GSTRING_CONTENT);
+ }
+ else {
+ contentMarker.drop();
+ }
+ }
+
+ boolean inj = builder.getTokenType() == mDOLLAR;
+ while (builder.getTokenType() == mDOLLAR || builder.getTokenType() == content) {
+ if (builder.getTokenType() == mDOLLAR) {
+ parseInjection(builder, parser);
+ }
+ else {
+ ParserUtils.eatElement(builder, GSTRING_CONTENT);
+ }
+ }
+
+ if (!ParserUtils.getToken(builder, end)) {
+ builder.error(message);
+ }
+
+ if (inj || literal == null) {
+ marker2.drop();
+ marker.done(compoundLiteral);
+ }
+ else {
+ marker2.done(literal);
+ if (forRefExpr) {
+ marker.drop();
+ }
+ else {
+ marker.done(LITERAL);
+ }
+ }
+ return inj;
+ }
+
+ /**
+ * Parses heredoc's content in GString
+ *
+ * @param builder given builder
+ * @return nothing
+ */
+ private static boolean parseInjection(PsiBuilder builder, GroovyParser parser) {
+ if (builder.getTokenType() != mDOLLAR) return false;
+
+ final PsiBuilder.Marker injection = builder.mark();
+ ParserUtils.getToken(builder, mDOLLAR);
+
+ if (mIDENT.equals(builder.getTokenType())) {
+ PathExpression.parse(builder, parser);
+ }
+ else if (mLCURLY.equals(builder.getTokenType())) {
+ OpenOrClosableBlock.parseClosableBlock(builder, parser);
+ }
+ else {
+ ParserUtils.wrapError(builder, GroovyBundle.message("identifier.or.block.expected"));
+ }
+
+ injection.done(GSTRING_INJECTION);
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/primary/DollarSlashRegexConstructorExpression.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/primary/DollarSlashRegexConstructorExpression.java
deleted file mode 100644
index b3819de..0000000
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/primary/DollarSlashRegexConstructorExpression.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright 2000-2011 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 org.jetbrains.plugins.groovy.lang.parser.parsing.statements.expressions.primary;
-
-import com.intellij.lang.PsiBuilder;
-import com.intellij.openapi.diagnostic.Logger;
-import org.jetbrains.plugins.groovy.GroovyBundle;
-import org.jetbrains.plugins.groovy.lang.parser.GroovyParser;
-import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.blocks.OpenOrClosableBlock;
-import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.expressions.arithmetic.PathExpression;
-import org.jetbrains.plugins.groovy.lang.parser.parsing.util.ParserUtils;
-
-import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mDOLLAR;
-import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mDOLLAR_SLASH_REGEX_BEGIN;
-import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mDOLLAR_SLASH_REGEX_CONTENT;
-import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mDOLLAR_SLASH_REGEX_END;
-import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mDOLLAR_SLASH_REGEX_LITERAL;
-import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mIDENT;
-import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mLCURLY;
-import static org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes.*;
-
-/**
- * @author Max Medvedev
- */
-public class DollarSlashRegexConstructorExpression {
- private static final Logger LOG = Logger.getInstance(DollarSlashRegexConstructorExpression.class);
-
- public static boolean parse(PsiBuilder builder, GroovyParser parser, boolean forRefExpr) {
- PsiBuilder.Marker marker = builder.mark();
- final PsiBuilder.Marker marker2 = builder.mark();
- final boolean result = ParserUtils.getToken(builder, mDOLLAR_SLASH_REGEX_BEGIN);
- LOG.assertTrue(result);
-
- boolean inj = false;
- ParserUtils.getToken(builder, mDOLLAR_SLASH_REGEX_CONTENT);
- while (parseInjection(builder, parser)) {
- inj = true;
- ParserUtils.getToken(builder, mDOLLAR_SLASH_REGEX_CONTENT);
- }
-
- if (!ParserUtils.getToken(builder, mDOLLAR_SLASH_REGEX_END)) {
- builder.error(GroovyBundle.message("dollar.slash.end.expected"));
- }
-
- if (inj) {
- marker2.drop();
- marker.done(REGEX);
- }
- else {
- marker2.done(mDOLLAR_SLASH_REGEX_LITERAL);
- if (forRefExpr) {
- marker.drop();
- }
- else {
- marker.done(LITERAL);
- }
- }
- return inj;
- }
-
- /**
- * Parses heredoc's content in GString
- *
- * @param builder given builder
- * @return nothing
- */
- private static boolean parseInjection(PsiBuilder builder, GroovyParser parser) {
- if (builder.getTokenType() != mDOLLAR) return false;
-
- final PsiBuilder.Marker injection = builder.mark();
- ParserUtils.getToken(builder, mDOLLAR);
-
- if (mIDENT.equals(builder.getTokenType())) {
- PathExpression.parse(builder, parser);
- }
- else if (mLCURLY.equals(builder.getTokenType())) {
- OpenOrClosableBlock.parseClosableBlock(builder, parser);
- }
- else {
- injection.drop();
- return false;
- }
-
- injection.done(GSTRING_INJECTION);
- return true;
- }
-}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/primary/PrimaryExpression.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/primary/PrimaryExpression.java
index d4eed0a..59ff837 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/primary/PrimaryExpression.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/primary/PrimaryExpression.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -58,14 +58,20 @@
return REFERENCE_EXPRESSION;
}
if (mGSTRING_BEGIN == tokenType) {
- return StringConstructorExpression.parse(builder, parser);
+ final boolean result = CompoundStringExpression.parse(builder, parser, false, mGSTRING_BEGIN, mGSTRING_CONTENT, mGSTRING_END, null,
+ GSTRING, GroovyBundle.message("string.end.expected"));
+ return result ? GSTRING : LITERAL;
}
if (mREGEX_BEGIN == tokenType) {
- RegexConstructorExpression.parse(builder, parser, false);
+ CompoundStringExpression.parse(builder, parser, false, mREGEX_BEGIN, mREGEX_CONTENT, mREGEX_END, mREGEX_LITERAL,
+ REGEX, GroovyBundle.message("regex.end.expected"));
return REGEX;
}
if (mDOLLAR_SLASH_REGEX_BEGIN == tokenType) {
- DollarSlashRegexConstructorExpression.parse(builder, parser, false);
+ CompoundStringExpression
+ .parse(builder, parser, false, mDOLLAR_SLASH_REGEX_BEGIN, mDOLLAR_SLASH_REGEX_CONTENT, mDOLLAR_SLASH_REGEX_END,
+ mDOLLAR_SLASH_REGEX_LITERAL,
+ REGEX, GroovyBundle.message("dollar.slash.end.expected"));
return REGEX;
}
if (mLBRACK == tokenType) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/primary/RegexConstructorExpression.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/primary/RegexConstructorExpression.java
deleted file mode 100644
index 2140728..0000000
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/primary/RegexConstructorExpression.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright 2000-2009 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 org.jetbrains.plugins.groovy.lang.parser.parsing.statements.expressions.primary;
-
-import com.intellij.lang.PsiBuilder;
-import com.intellij.openapi.diagnostic.Logger;
-import org.jetbrains.plugins.groovy.GroovyBundle;
-import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
-import org.jetbrains.plugins.groovy.lang.parser.GroovyParser;
-import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.blocks.OpenOrClosableBlock;
-import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.expressions.arithmetic.PathExpression;
-import org.jetbrains.plugins.groovy.lang.parser.parsing.util.ParserUtils;
-
-/**
- * @author ilyas
- */
-public class RegexConstructorExpression implements GroovyElementTypes {
- private static final Logger LOG = Logger.getInstance(RegexConstructorExpression.class);
-
- /**
- * @return true if there are any injections
- */
- public static boolean parse(PsiBuilder builder, GroovyParser parser, boolean forRefExpr) {
- PsiBuilder.Marker marker = builder.mark();
- final PsiBuilder.Marker marker2 = builder.mark();
- final boolean result = ParserUtils.getToken(builder, mREGEX_BEGIN);
- LOG.assertTrue(result);
-
- boolean inj = false;
- ParserUtils.getToken(builder, mREGEX_CONTENT);
- while (parseInjection(builder, parser)) {
- inj = true;
- ParserUtils.getToken(builder, mREGEX_CONTENT);
- }
-
- if (!ParserUtils.getToken(builder, mREGEX_END)) {
- builder.error(GroovyBundle.message("regex.end.expected"));
- }
-
- if (inj) {
- marker2.drop();
- marker.done(REGEX);
- }
- else {
- marker2.done(mREGEX_LITERAL);
- if (forRefExpr) {
- marker.drop();
- }
- else {
- marker.done(LITERAL);
- }
- }
- return inj;
- }
-
- /**
- * Parses heredoc's content in GString
- *
- * @param builder given builder
- * @return nothing
- */
- private static boolean parseInjection(PsiBuilder builder, GroovyParser parser) {
- if (builder.getTokenType() != mDOLLAR) return false;
-
- final PsiBuilder.Marker injection = builder.mark();
- ParserUtils.getToken(builder, mDOLLAR);
-
- if (mIDENT.equals(builder.getTokenType())) {
- PathExpression.parse(builder, parser);
- }
- else if (mLCURLY.equals(builder.getTokenType())) {
- OpenOrClosableBlock.parseClosableBlock(builder, parser);
- }
- else {
- injection.drop();
- return false;
- }
-
- injection.done(GSTRING_INJECTION);
- return true;
- }
-}
\ No newline at end of file
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/primary/StringConstructorExpression.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/primary/StringConstructorExpression.java
deleted file mode 100644
index 57432c1..0000000
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/primary/StringConstructorExpression.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2000-2009 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 org.jetbrains.plugins.groovy.lang.parser.parsing.statements.expressions.primary;
-
-import com.intellij.lang.PsiBuilder;
-import com.intellij.lang.PsiBuilder.Marker;
-import com.intellij.psi.tree.IElementType;
-import org.jetbrains.plugins.groovy.GroovyBundle;
-import org.jetbrains.plugins.groovy.lang.lexer.GroovyElementType;
-import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
-import org.jetbrains.plugins.groovy.lang.parser.GroovyParser;
-import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.blocks.OpenOrClosableBlock;
-import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.expressions.arithmetic.PathExpression;
-import org.jetbrains.plugins.groovy.lang.parser.parsing.util.ParserUtils;
-
-/**
- * @author ilyas
- */
-public class StringConstructorExpression implements GroovyElementTypes {
-
- public static GroovyElementType parse(PsiBuilder builder, GroovyParser parser) {
-
- Marker sMarker = builder.mark();
- if (ParserUtils.getToken(builder, mGSTRING_BEGIN)) {
- while (ParserUtils.getToken(builder, mGSTRING_CONTENT) || mDOLLAR.equals(builder.getTokenType())) {
- if (mDOLLAR.equals(builder.getTokenType())) {
- stringConstructorValuePart(builder, parser);
- }
- }
- ParserUtils.getToken(builder, mGSTRING_END, GroovyBundle.message("string.end.expected"));
- sMarker.done(GSTRING);
- return GSTRING;
- }
- else {
- sMarker.drop();
- return WRONGWAY;
- }
- }
-
- /**
- * Parses heredoc's content in GString
- *
- * @param builder given builder
- * @return nothing
- */
- private static void stringConstructorValuePart(PsiBuilder builder, GroovyParser parser) {
- final Marker injection = builder.mark();
- ParserUtils.getToken(builder, mDOLLAR);
- ParserUtils.getToken(builder, mSTAR);
- IElementType tokenType = builder.getTokenType();
- if (mIDENT == tokenType || kTHIS==tokenType || kSUPER==tokenType) {
- PathExpression.parse(builder, parser);
- }
- else if (mLCURLY == tokenType) {
- OpenOrClosableBlock.parseClosableBlock(builder, parser);
- }
- else {
- ParserUtils.wrapError(builder, GroovyBundle.message("identifier.or.block.expected"));
- }
- injection.done(GSTRING_INJECTION);
- }
-}
\ No newline at end of file
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/GroovyPsiElementFactory.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/GroovyPsiElementFactory.java
index 9f370e0..2dc3822 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/GroovyPsiElementFactory.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/GroovyPsiElementFactory.java
@@ -167,7 +167,8 @@
public abstract GrParameter createParameter(String name,
@Nullable String typeText,
@Nullable String initializer,
- @Nullable GroovyPsiElement context) throws IncorrectOperationException;
+ @Nullable GroovyPsiElement context,
+ String... modifiers) throws IncorrectOperationException;
public abstract GrCodeReferenceElement createTypeOrPackageReference(String qName);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/GrLabeledStatement.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/GrLabeledStatement.java
index 0997713..85a0408 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/GrLabeledStatement.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/GrLabeledStatement.java
@@ -17,6 +17,7 @@
package org.jetbrains.plugins.groovy.lang.psi.api.statements;
import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiNameIdentifierOwner;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.lang.psi.GrNamedElement;
@@ -24,7 +25,7 @@
/**
* @author ilyas
*/
-public interface GrLabeledStatement extends GrStatement, GrNamedElement {
+public interface GrLabeledStatement extends GrStatement, GrNamedElement, PsiNameIdentifierOwner {
@Nullable
GrStatement getStatement();
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/GrAssignmentExpression.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/GrAssignmentExpression.java
index 9a49375..b76ede2 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/GrAssignmentExpression.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/GrAssignmentExpression.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -34,10 +34,10 @@
@Nullable
GrExpression getRValue();
- IElementType getOperationToken();
+ IElementType getOperationTokenType();
@NotNull
GroovyResolveResult[] multiResolve(boolean incompleteCode);
- PsiElement getOpToken();
+ PsiElement getOperationToken();
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/literals/GrLiteral.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/literals/GrLiteral.java
index 797684b..dd060c7 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/literals/GrLiteral.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/literals/GrLiteral.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -16,11 +16,10 @@
package org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals;
-import com.intellij.psi.PsiLiteral;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
/**
* @author ilyas
*/
-public interface GrLiteral extends GrExpression, PsiLiteral {
+public interface GrLiteral extends GrExpression, GrLiteralContainer {
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/literals/GrLiteralContainer.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/literals/GrLiteralContainer.java
new file mode 100644
index 0000000..256bd7c
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/literals/GrLiteralContainer.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2000-2013 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 org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals;
+
+import com.intellij.psi.PsiLanguageInjectionHost;
+import com.intellij.psi.PsiLiteral;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
+
+/**
+ * @author Max Medvedev
+ */
+public interface GrLiteralContainer extends GroovyPsiElement, PsiLiteral, PsiLanguageInjectionHost {
+ GrLiteralContainer updateText(@NotNull String text);
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/literals/GrString.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/literals/GrString.java
index c331d44..0941ddd 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/literals/GrString.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/literals/GrString.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -16,6 +16,8 @@
package org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals;
+import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
+
/**
* @author ilyas
*/
@@ -26,4 +28,8 @@
GrStringInjection[] getInjections();
String[] getTextParts();
+
+ GrStringContent[] getContents();
+
+ GroovyPsiElement[] getAllContentParts();
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/literals/GrStringContent.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/literals/GrStringContent.java
new file mode 100644
index 0000000..0ab196a
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/literals/GrStringContent.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2000-2013 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 org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals;
+
+import com.intellij.psi.PsiElement;
+
+/**
+ * @author Max Medvedev
+ */
+public interface GrStringContent extends PsiElement, GrLiteralContainer {
+ String getValue();
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ControlFlowBuilder.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ControlFlowBuilder.java
index 45c2c67..d247fab 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ControlFlowBuilder.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ControlFlowBuilder.java
@@ -24,7 +24,6 @@
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.containers.ContainerUtil;
-import com.intellij.util.containers.hash.HashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.codeInspection.utils.ControlFlowUtils;
@@ -111,7 +110,9 @@
final PsiElement lbrace = block.getLBrace();
if (lbrace != null && parent instanceof GrMethod) {
for (GrParameter parameter : ((GrMethod)parent).getParameters()) {
- addNode(new ReadWriteVariableInstruction(parameter.getName(), parameter, WRITE));
+ if (myPolicy.isVariableInitialized(parameter)) {
+ addNode(new ReadWriteVariableInstruction(parameter.getName(), parameter, WRITE));
+ }
}
}
super.visitOpenBlock(block);
@@ -179,7 +180,9 @@
private void buildFlowForClosure(final GrClosableBlock closure) {
for (GrParameter parameter : closure.getAllParameters()) {
- addNode(new ReadWriteVariableInstruction(parameter.getName(), parameter, WRITE));
+ if (myPolicy.isVariableInitialized(parameter)) {
+ addNode(new ReadWriteVariableInstruction(parameter.getName(), parameter, WRITE));
+ }
}
addNode(new ReadWriteVariableInstruction("owner", closure.getLBrace(), WRITE));
@@ -227,7 +230,9 @@
//do not go inside closures except gstring injections
if (closure.getParent() instanceof GrStringInjection) {
for (GrParameter parameter : closure.getAllParameters()) {
- addNode(new ReadWriteVariableInstruction(parameter.getName(), parameter, WRITE));
+ if (myPolicy.isVariableInitialized(parameter)) {
+ addNode(new ReadWriteVariableInstruction(parameter.getName(), parameter, WRITE));
+ }
}
addNode(new ReadWriteVariableInstruction("owner", closure.getLBrace(), WRITE));
@@ -235,15 +240,12 @@
return;
}
- Set<String> names = new HashSet<String>();
-
ReadWriteVariableInstruction[] reads = ControlFlowBuilderUtil.getReadsWithoutPriorWrites(closure.getControlFlow(), false);
for (ReadWriteVariableInstruction read : reads) {
- names.add(read.getVariableName());
- }
-
- for (String name : names) {
- addNodeAndCheckPending(new ReadWriteVariableInstruction(name, closure, READ));
+ PsiElement element = read.getElement();
+ if (!(element instanceof GrReferenceExpression) || myPolicy.isReferenceAccepted((GrReferenceExpression)element)) {
+ addNodeAndCheckPending(new ReadWriteVariableInstruction(read.getVariableName(), closure, READ));
+ }
}
addNodeAndCheckPending(new InstructionImpl(closure));
@@ -397,8 +399,8 @@
public void visitAssignmentExpression(GrAssignmentExpression expression) {
GrExpression lValue = expression.getLValue();
- if (expression.getOperationToken() != mASSIGN) {
- if (lValue instanceof GrReferenceExpression) {
+ if (expression.getOperationTokenType() != mASSIGN) {
+ if (lValue instanceof GrReferenceExpression && myPolicy.isReferenceAccepted((GrReferenceExpression)lValue)) {
String referenceName = ((GrReferenceExpression)lValue).getReferenceName();
if (referenceName != null) {
addNodeAndCheckPending(new ReadWriteVariableInstruction(referenceName, lValue, READ));
@@ -695,7 +697,7 @@
addEdge(elseEnd, end);
}
else if (elseBranch == null) {
- addEdge(conditionEnd != null ? conditionEnd : ifInstruction, end);
+ // addEdge(conditionEnd != null ? conditionEnd : ifInstruction, end);
}
}
}
@@ -768,7 +770,7 @@
private void flushForeachLoopVariable(@Nullable GrForClause clause) {
if (clause instanceof GrForInClause) {
GrVariable variable = clause.getDeclaredVariable();
- if (variable != null) {
+ if (variable != null && myPolicy.isVariableInitialized(variable)) {
addNodeAndCheckPending(new ReadWriteVariableInstruction(variable.getName(), variable, WRITE));
}
}
@@ -1019,7 +1021,7 @@
}
final GrParameter parameter = catchClauses[i].getParameter();
- if (parameter != null) {
+ if (parameter != null && myPolicy.isVariableInitialized(parameter)) {
addNode(new ReadWriteVariableInstruction(parameter.getName(), parameter, WRITE));
}
catchClauses[i].accept(this);
@@ -1145,22 +1147,23 @@
public void visitTypeDefinition(final GrTypeDefinition typeDefinition) {
if (!(typeDefinition instanceof GrAnonymousClassDefinition)) return;
- final Set<String> vars = collectUsedVariableWithoutInitialization(typeDefinition);
+ final Set<ReadWriteVariableInstruction> vars = collectUsedVariableWithoutInitialization(typeDefinition);
- for (String var : vars) {
- addNodeAndCheckPending(new ReadWriteVariableInstruction(var, typeDefinition, READ));
+ for (ReadWriteVariableInstruction var : vars) {
+ PsiElement element = var.getElement();
+ if (!(element instanceof GrReferenceExpression) || myPolicy.isReferenceAccepted((GrReferenceExpression)element)) {
+ addNodeAndCheckPending(new ReadWriteVariableInstruction(var.getVariableName(), typeDefinition, READ));
+ }
}
addNodeAndCheckPending(new InstructionImpl(typeDefinition));
}
- private static Set<String> collectUsedVariableWithoutInitialization(GrTypeDefinition typeDefinition) {
- final Set<String> vars = new HashSet<String>();
+ private static Set<ReadWriteVariableInstruction> collectUsedVariableWithoutInitialization(GrTypeDefinition typeDefinition) {
+ final Set<ReadWriteVariableInstruction> vars = ContainerUtil.newLinkedHashSet();
typeDefinition.acceptChildren(new GroovyRecursiveElementVisitor() {
private void collectVars(Instruction[] flow) {
ReadWriteVariableInstruction[] reads = ControlFlowBuilderUtil.getReadsWithoutPriorWrites(flow, false);
- for (ReadWriteVariableInstruction instruction : reads) {
- vars.add(instruction.getVariableName());
- }
+ Collections.addAll(vars, reads);
}
@Override
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/GrResolverPolicy.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/GrResolverPolicy.java
index 77b1f30..52c875b 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/GrResolverPolicy.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/GrResolverPolicy.java
@@ -20,6 +20,7 @@
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariableDeclaration;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
/**
* @author Max Medvedev
@@ -32,7 +33,7 @@
@Override
public boolean isVariableInitialized(@NotNull GrVariable variable) {
- return variable.getInitializerGroovy() != null || hasTupleInitializer(variable);
+ return variable.getInitializerGroovy() != null || hasTupleInitializer(variable) || variable instanceof GrParameter;
}
private static boolean hasTupleInitializer(@NotNull GrVariable variable) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrMapType.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrMapType.java
index 8adb878..69f1176 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrMapType.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrMapType.java
@@ -198,7 +198,7 @@
}
public boolean isAssignableFrom(@NotNull PsiType type) {
- return type instanceof GrMapType || myFacade.getElementFactory().createTypeFromText(getJavaClassName(), null).isAssignableFrom(type);
+ return type instanceof GrMapType || super.isAssignableFrom(type);
}
public static GrMapType merge(GrMapType l, GrMapType r) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java
index f0528e8..5da74fd 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java
@@ -359,15 +359,16 @@
public GrParameter createParameter(String name,
@Nullable String typeText,
@Nullable String initializer,
- @Nullable GroovyPsiElement context) throws IncorrectOperationException {
+ @Nullable GroovyPsiElement context,
+ String... modifiers) throws IncorrectOperationException {
try {
StringBuilder fileText = new StringBuilder();
fileText.append("def dsfsadfnbhfjks_weyripouh_huihnrecuio(");
- if (typeText != null) {
- fileText.append(typeText).append(" ");
+ for (String modifier : modifiers) {
+ fileText.append(modifier).append(' ');
}
- else {
- fileText.append("def ");
+ if (StringUtil.isNotEmpty(typeText)) {
+ fileText.append(typeText).append(' ');
}
fileText.append(name);
if (initializer != null && initializer.length() > 0) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrLabeledStatementImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrLabeledStatementImpl.java
index ceb4b22..3144cfe 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrLabeledStatementImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrLabeledStatementImpl.java
@@ -99,4 +99,10 @@
public PsiElement getNameIdentifierGroovy() {
return getLabel();
}
+
+ @Nullable
+ @Override
+ public PsiElement getNameIdentifier() {
+ return getNameIdentifierGroovy();
+ }
}
\ No newline at end of file
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/blocks/GrClosableBlockImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/blocks/GrClosableBlockImpl.java
index 27d55c6..fcee7c7 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/blocks/GrClosableBlockImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/blocks/GrClosableBlockImpl.java
@@ -82,12 +82,7 @@
final @NotNull ResolveState state,
final @Nullable PsiElement lastParent,
final @NotNull PsiElement place) {
- if (lastParent == null) return true;
-
- if (!super.processDeclarations(plainProcessor, state, lastParent, place)) return false;
- if (!processParameters(plainProcessor, state, place)) return false;
- if (!ResolveUtil.processElement(plainProcessor, getOwner(), state)) return false;
- if (!processClosureClassMembers(plainProcessor, state, lastParent, place)) return false;
+ if (!processDeclarations(plainProcessor, state, lastParent, place)) return false;
if (!processOwnerAndDelegate(plainProcessor, nonCodeProcessor, state, place)) return false;
return true;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrAssignmentExpressionImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrAssignmentExpressionImpl.java
index 6aaa8a9..0f4b844 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrAssignmentExpressionImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrAssignmentExpressionImpl.java
@@ -89,11 +89,11 @@
return null;
}
- public IElementType getOperationToken() {
- return getOpToken().getNode().getElementType();
+ public IElementType getOperationTokenType() {
+ return getOperationToken().getNode().getElementType();
}
- public PsiElement getOpToken() {
+ public PsiElement getOperationToken() {
return findNotNullChildByType(TokenSets.ASSIGN_OP_SET);
}
@@ -118,7 +118,7 @@
@Override
public TextRange getRangeInElement() {
- final PsiElement token = getOpToken();
+ final PsiElement token = getOperationToken();
assert token != null;
final int offset = token.getStartOffsetInParent();
return new TextRange(offset, offset + token.getTextLength());
@@ -163,7 +163,7 @@
@Override
public PsiReference getReference() {
- final IElementType operationToken = getOperationToken();
+ final IElementType operationToken = getOperationTokenType();
if (operationToken == GroovyTokenTypes.mASSIGN) return null;
return this;
@@ -174,7 +174,7 @@
@NotNull
@Override
public GroovyResolveResult[] resolve(@NotNull GrAssignmentExpressionImpl assignmentExpression, boolean incompleteCode) {
- final IElementType opType = assignmentExpression.getOperationToken();
+ final IElementType opType = assignmentExpression.getOperationTokenType();
if (opType == null || opType == GroovyTokenTypes.mASSIGN) return GroovyResolveResult.EMPTY_ARRAY;
final GrExpression lValue = assignmentExpression.getLValue();
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrNewExpressionImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrNewExpressionImpl.java
index c3573ad..cfc1db1 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrNewExpressionImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrNewExpressionImpl.java
@@ -17,7 +17,6 @@
package org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions;
import com.intellij.lang.ASTNode;
-import com.intellij.openapi.util.TextRange;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.*;
import com.intellij.psi.util.InheritanceUtil;
@@ -46,6 +45,7 @@
import org.jetbrains.plugins.groovy.lang.psi.impl.GrMapType;
import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.path.GrCallExpressionImpl;
+import org.jetbrains.plugins.groovy.lang.psi.util.GrInnerClassConstructorUtil;
import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil;
@@ -193,7 +193,7 @@
for (GroovyResolveResult classResult : referenceElement.multiResolve(false)) {
final PsiElement element = classResult.getElement();
if (element instanceof PsiClass) {
- ContainerUtil.addAll(result, ResolveUtil.getAllClassConstructors((PsiClass)element, this, classResult.getSubstitutor(), null));
+ ContainerUtil.addAll(result, ResolveUtil.getAllClassConstructors((PsiClass)element, classResult.getSubstitutor(), null, this));
}
}
@@ -208,15 +208,15 @@
@NotNull
@Override
public GroovyResolveResult[] multiResolve(boolean incompleteCode) {
- //ResolveCache.getInstance(getProject()).resolveWithCaching()
GrCodeReferenceElement ref = getReferenceElement();
if (ref == null) return GroovyResolveResult.EMPTY_ARRAY;
- final GroovyResolveResult[] classResults = ref.multiResolve(false);
- if (classResults.length == 0) return GroovyResolveResult.EMPTY_ARRAY;
+ GroovyResolveResult classCandidate = inferClassCandidate(ref);
+ if (classCandidate == null) return GroovyResolveResult.EMPTY_ARRAY;
+ assert classCandidate.getElement() instanceof PsiClass;
if (incompleteCode) {
- return PsiUtil.getConstructorCandidates(ref, classResults, null);
+ return PsiUtil.getConstructorCandidates(ref, classCandidate, null);
}
final GrArgumentList argumentList = getArgumentList();
@@ -224,7 +224,7 @@
if (argumentList.getNamedArguments().length > 0 && argumentList.getExpressionArguments().length == 0) {
PsiType mapType = new GrMapType(argumentList, getNamedArguments());
- GroovyResolveResult[] constructorResults = PsiUtil.getConstructorCandidates(ref, classResults, new PsiType[]{mapType}); //one Map parameter, actually
+ GroovyResolveResult[] constructorResults = PsiUtil.getConstructorCandidates(ref, classCandidate, new PsiType[]{mapType}); //one Map parameter, actually
for (GroovyResolveResult result : constructorResults) {
final PsiElement resolved = result.getElement();
if (resolved instanceof PsiMethod) {
@@ -235,67 +235,28 @@
}
}
}
- final GroovyResolveResult[] emptyConstructors = PsiUtil.getConstructorCandidates(ref, classResults, PsiType.EMPTY_ARRAY);
+ final GroovyResolveResult[] emptyConstructors = PsiUtil.getConstructorCandidates(ref, classCandidate, PsiType.EMPTY_ARRAY);
if (emptyConstructors.length > 0) {
return emptyConstructors;
}
}
- return PsiUtil.getConstructorCandidates(ref, classResults, PsiUtil.getArgumentTypes(ref, true));
+ PsiType[] types = PsiUtil.getArgumentTypes(ref, true);
+
+ if (types != null) {
+ types = GrInnerClassConstructorUtil.addEnclosingArgIfNeeded(types, this, (PsiClass)classCandidate.getElement());
+ }
+ return PsiUtil.getConstructorCandidates(ref, classCandidate, types);
}
- private class MyRef implements PsiPolyVariantReference {
- @NotNull
- @Override
- public ResolveResult[] multiResolve(boolean incompleteCode) {
- return GrNewExpressionImpl.this.multiResolve(incompleteCode);
+ @Nullable
+ private static GroovyResolveResult inferClassCandidate(@NotNull GrCodeReferenceElement ref) {
+ final GroovyResolveResult[] classResults = ref.multiResolve(false);
+ for (GroovyResolveResult result : classResults) {
+ if (result.getElement() instanceof PsiClass) {
+ return result;
+ }
}
-
- @Override
- public PsiElement getElement() {
- return GrNewExpressionImpl.this;
- }
-
- @Override
- public TextRange getRangeInElement() {
- return getReferenceElement().getRangeInElement();
- }
-
- @Override
- public PsiElement resolve() {
- return resolveMethod();
- }
-
- @NotNull
- @Override
- public String getCanonicalText() {
- return "new expression reference";
- }
-
- @Override
- public PsiElement handleElementRename(String newElementName) throws IncorrectOperationException {
- return GrNewExpressionImpl.this;
- }
-
- @Override
- public PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException {
- return GrNewExpressionImpl.this;
- }
-
- @Override
- public boolean isReferenceTo(PsiElement element) {
- return getManager().areElementsEquivalent(resolveMethod(), element);
- }
-
- @NotNull
- @Override
- public Object[] getVariants() {
- return multiResolve(true);
- }
-
- @Override
- public boolean isSoft() {
- return false;
- }
+ return null;
}
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/literals/GrLiteralEscaper.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/literals/GrLiteralEscaper.java
index 794cc00..03f8b33 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/literals/GrLiteralEscaper.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/literals/GrLiteralEscaper.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -22,12 +22,13 @@
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteralContainer;
import org.jetbrains.plugins.groovy.lang.psi.util.GrStringUtil;
-public class GrLiteralEscaper extends LiteralTextEscaper<GrLiteralImpl> {
+public class GrLiteralEscaper extends LiteralTextEscaper<GrLiteralContainer> {
private int[] outSourceOffsets;
- public GrLiteralEscaper(final GrLiteralImpl literal) {
+ public GrLiteralEscaper(GrLiteralContainer literal) {
super(literal);
}
@@ -38,13 +39,13 @@
outSourceOffsets = new int[subText.length() + 1];
final IElementType elementType = myHost.getFirstChild().getNode().getElementType();
- if (elementType == GroovyTokenTypes.mSTRING_LITERAL || elementType == GroovyTokenTypes.mGSTRING_LITERAL) {
+ if (elementType == GroovyTokenTypes.mSTRING_LITERAL || elementType == GroovyTokenTypes.mGSTRING_LITERAL || elementType == GroovyTokenTypes.mGSTRING_CONTENT) {
return GrStringUtil.parseStringCharacters(subText, outChars, outSourceOffsets);
}
- else if (elementType == GroovyTokenTypes.mREGEX_LITERAL) {
+ else if (elementType == GroovyTokenTypes.mREGEX_LITERAL || elementType == GroovyTokenTypes.mREGEX_CONTENT) {
return GrStringUtil.parseRegexCharacters(subText, outChars, outSourceOffsets, true);
}
- else if (elementType == GroovyTokenTypes.mDOLLAR_SLASH_REGEX_LITERAL) {
+ else if (elementType == GroovyTokenTypes.mDOLLAR_SLASH_REGEX_LITERAL || elementType == GroovyTokenTypes.mDOLLAR_SLASH_REGEX_CONTENT) {
return GrStringUtil.parseRegexCharacters(subText, outChars, outSourceOffsets, false);
}
else return false;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/literals/GrLiteralImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/literals/GrLiteralImpl.java
index dbb5c80..4da4d13 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/literals/GrLiteralImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/literals/GrLiteralImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -29,6 +29,7 @@
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteralContainer;
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
import org.jetbrains.plugins.groovy.lang.psi.util.GrStringUtil;
@@ -185,7 +186,7 @@
}
@NotNull
- public LiteralTextEscaper<GrLiteralImpl> createLiteralTextEscaper() {
+ public LiteralTextEscaper<GrLiteralContainer> createLiteralTextEscaper() {
return new GrLiteralEscaper(this);
}
}
\ No newline at end of file
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/literals/GrRegexImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/literals/GrRegexImpl.java
index fcda166..1d0be96 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/literals/GrRegexImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/literals/GrRegexImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -17,7 +17,9 @@
package org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.literals;
import com.intellij.lang.ASTNode;
+import com.intellij.psi.LiteralTextEscaper;
import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiLanguageInjectionHost;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
@@ -78,5 +80,11 @@
}
return result;
}
+
+ @NotNull
+ @Override
+ public LiteralTextEscaper<? extends PsiLanguageInjectionHost> createLiteralTextEscaper() {
+ return null;
+ }
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/literals/GrStringContentImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/literals/GrStringContentImpl.java
new file mode 100644
index 0000000..8b68894
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/literals/GrStringContentImpl.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2000-2013 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 org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.literals;
+
+import com.intellij.lang.ASTNode;
+import com.intellij.psi.LiteralTextEscaper;
+import com.intellij.psi.PsiLanguageInjectionHost;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrString;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrStringContent;
+import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiElementImpl;
+import org.jetbrains.plugins.groovy.lang.psi.util.GrStringUtil;
+
+/**
+ * @author Max Medvedev
+ */
+public class GrStringContentImpl extends GroovyPsiElementImpl implements GrStringContent, PsiLanguageInjectionHost {
+ public GrStringContentImpl(@NotNull ASTNode node) {
+ super(node);
+ }
+
+ @Override
+ public String getValue() {
+ final String text = getText();
+ StringBuilder chars = new StringBuilder(text.length());
+ boolean result = GrStringUtil.parseStringCharacters(text, chars, null);
+ return result ? chars.toString() : null;
+ }
+
+ @Override
+ public boolean isValidHost() {
+ return getValue() != null;
+ }
+
+ @Override
+ public GrStringContentImpl updateText(@NotNull String text) {
+
+ final GrString fromText = (GrString)GroovyPsiElementFactory.getInstance(getProject()).createExpressionFromText("\"${0}" + text + "\"");
+ final GrStringContent content = fromText.getContents()[0];
+ getNode().replaceChild(getFirstChild().getNode(), content.getFirstChild().getNode());
+ return this;
+ }
+
+ @NotNull
+ @Override
+ public LiteralTextEscaper<? extends PsiLanguageInjectionHost> createLiteralTextEscaper() {
+ return new GrLiteralEscaper(this);
+ }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/literals/GrStringImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/literals/GrStringImpl.java
index de3e3d6..f7b8406 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/literals/GrStringImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/literals/GrStringImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -17,12 +17,17 @@
package org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.literals;
import com.intellij.lang.ASTNode;
+import com.intellij.psi.LiteralTextEscaper;
import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiLanguageInjectionHost;
import com.intellij.psi.PsiType;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
+import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
+import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
+import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrString;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrStringContent;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrStringInjection;
import org.jetbrains.plugins.groovy.lang.psi.util.GrStringUtil;
@@ -59,7 +64,7 @@
@Override
public String[] getTextParts() {
- List<PsiElement> parts = findChildrenByType(GroovyTokenTypes.mGSTRING_CONTENT);
+ List<PsiElement> parts = findChildrenByType(GroovyElementTypes.GSTRING_CONTENT);
String[] result = new String[parts.size()];
int i = 0;
@@ -69,6 +74,18 @@
return result;
}
+ @Override
+ public GrStringContent[] getContents() {
+ final List<PsiElement> parts = findChildrenByType(GroovyElementTypes.GSTRING_CONTENT);
+ return parts.toArray(new GrStringContent[parts.size()]);
+ }
+
+ @Override
+ public GroovyPsiElement[] getAllContentParts() {
+ final List<PsiElement> result = findChildrenByType(TokenSets.GSTRING_CONTENT_PARTS);
+ return result.toArray(new GroovyPsiElement[result.size()]);
+ }
+
public void accept(GroovyElementVisitor visitor) {
visitor.visitGStringExpression(this);
}
@@ -80,11 +97,27 @@
if (fchild == null) return null;
final PsiElement content = fchild.getNextSibling();
- if (content == null || content.getNode().getElementType() != GroovyTokenTypes.mGSTRING_CONTENT) return null;
+ if (content == null || content.getNode().getElementType() != GroovyElementTypes.GSTRING_CONTENT) return null;
final String text = content.getText();
StringBuilder chars = new StringBuilder(text.length());
boolean result = GrStringUtil.parseStringCharacters(text, chars, null);
return result ? chars.toString() : null;
}
+
+ @Override
+ public boolean isValidHost() {
+ return false;
+ }
+
+ @Override
+ public GrStringImpl updateText(@NotNull String text) {
+ return this;
+ }
+
+ @NotNull
+ @Override
+ public LiteralTextEscaper<? extends PsiLanguageInjectionHost> createLiteralTextEscaper() {
+ return new GrLiteralEscaper(this);
+ }
}
\ No newline at end of file
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/path/GrIndexPropertyImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/path/GrIndexPropertyImpl.java
index cd88eda..0de1c35 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/path/GrIndexPropertyImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/path/GrIndexPropertyImpl.java
@@ -120,6 +120,7 @@
}
+ //don't use short PsiUtil.getArgumentTypes(...) because it use incorrect 'isSetter' value
PsiType[] args = PsiUtil
.getArgumentTypes(argList.getNamedArguments(), argList.getExpressionArguments(), GrClosableBlock.EMPTY_ARRAY, true, null, false);
final GroovyResolveResult candidate = PsiImplUtil.extractUniqueResult(candidates);
@@ -151,7 +152,6 @@
private GroovyResolveResult[] resolveImpl(boolean incompleteCode, @Nullable GrExpression upToArgument, @Nullable Boolean isSetter) {
if (isSetter == null) isSetter = PsiUtil.isLValue(this);
- assert isSetter != null;
GrExpression invoked = getInvokedExpression();
PsiType thisType = invoked.getType();
@@ -162,8 +162,8 @@
GrArgumentList argList = getArgumentList();
- PsiType[] argTypes = PsiUtil
- .getArgumentTypes(argList.getNamedArguments(), argList.getExpressionArguments(), GrClosableBlock.EMPTY_ARRAY, true, upToArgument, false);
+ //don't use short PsiUtil.getArgumentTypes(...) because it use incorrect 'isSetter' value
+ PsiType[] argTypes = PsiUtil.getArgumentTypes(argList.getNamedArguments(), argList.getExpressionArguments(), GrClosableBlock.EMPTY_ARRAY, true, upToArgument, false);
if (argTypes == null) return GroovyResolveResult.EMPTY_ARRAY;
final GlobalSearchScope resolveScope = getResolveScope();
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/enumConstant/GrEnumConstantImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/enumConstant/GrEnumConstantImpl.java
index afd5148..c1c40f6 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/enumConstant/GrEnumConstantImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/enumConstant/GrEnumConstantImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -41,7 +41,7 @@
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.GrFieldImpl;
import org.jetbrains.plugins.groovy.lang.psi.stubs.GrFieldStub;
import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
-import org.jetbrains.plugins.groovy.lang.resolve.processors.MethodResolverProcessor;
+import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil;
/**
* @author: Dmitry.Krasilschikov
@@ -203,12 +203,15 @@
public GroovyResolveResult[] multiResolve(boolean incompleteCode) {
PsiType[] argTypes = PsiUtil.getArgumentTypes(getFirstChild(), false);
PsiClass clazz = getContainingClass();
- assert clazz != null;
- PsiType thisType = JavaPsiFacade.getInstance(getProject()).getElementFactory().createType(clazz, PsiSubstitutor.EMPTY);
- MethodResolverProcessor processor =
- new MethodResolverProcessor(clazz.getName(), this, true, thisType, argTypes, PsiType.EMPTY_ARRAY, incompleteCode, false);
- clazz.processDeclarations(processor, ResolveState.initial(), null, this);
- return processor.getCandidates();
+ return ResolveUtil.getAllClassConstructors(clazz, PsiSubstitutor.EMPTY, argTypes, this);
+ }
+
+ @NotNull
+ @Override
+ public PsiClass getContainingClass() {
+ PsiClass aClass = super.getContainingClass();
+ assert aClass != null;
+ return aClass;
}
private class MyReference implements PsiPolyVariantReference {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/members/GrConstructorImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/members/GrConstructorImpl.java
index 280eda2..adc7211 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/members/GrConstructorImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/members/GrConstructorImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -17,9 +17,14 @@
package org.jetbrains.plugins.groovy.lang.psi.impl.statements.typedef.members;
import com.intellij.lang.ASTNode;
+import com.intellij.psi.util.CachedValueProvider;
+import com.intellij.psi.util.CachedValuesManager;
+import com.intellij.psi.util.PsiModificationTracker;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrReflectedMethod;
+import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrReflectedMethodImpl;
import org.jetbrains.plugins.groovy.lang.psi.stubs.GrMethodStub;
/**
@@ -42,4 +47,14 @@
return true;
}
+ @NotNull
+ @Override
+ public GrReflectedMethod[] getReflectedMethods() {
+ return CachedValuesManager.getManager(getProject()).getCachedValue(this, new CachedValueProvider<GrReflectedMethod[]>() {
+ @Override
+ public Result<GrReflectedMethod[]> compute() {
+ return Result.create(GrReflectedMethodImpl.createReflectedConstructors(GrConstructorImpl.this), PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT);
+ }
+ });
+ }
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrLightParameter.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrLightParameter.java
index f88b263..b3a0b75 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrLightParameter.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrLightParameter.java
@@ -37,6 +37,7 @@
public static final GrLightParameter[] EMPTY_ARRAY = new GrLightParameter[0];
private volatile boolean myOptional;
private volatile GrModifierList myModifierList;
+ private volatile GrExpression myInitializer = null;
private final PsiElement myScope;
private final GrTypeElement myTypeElement;
private final PsiType myTypeGroovy;
@@ -72,7 +73,7 @@
@Override
public GrExpression getInitializerGroovy() {
- return null;
+ return myInitializer;
}
@Override
@@ -144,8 +145,7 @@
@Override
public void setInitializerGroovy(GrExpression initializer) {
- //todo?
- throw new UnsupportedOperationException();
+ myInitializer = initializer;
}
@Override
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrReflectedMethodImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrReflectedMethodImpl.java
index 60df55a..a973574 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrReflectedMethodImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrReflectedMethodImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -38,6 +38,7 @@
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrReflectedMethod;
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement;
import org.jetbrains.plugins.groovy.lang.psi.util.GdkMethodUtil;
+import org.jetbrains.plugins.groovy.lang.psi.util.GrInnerClassConstructorUtil;
import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
import javax.swing.*;
@@ -55,14 +56,14 @@
private final GrMethod myBaseMethod;
private GrParameter[] mySkippedParameters = null;
- public GrReflectedMethodImpl(GrMethod baseMethod, int optionalParams, PsiClassType categoryType) {
+ public GrReflectedMethodImpl(GrMethod baseMethod, GrParameter[] parameters, int optionalParams, PsiClassType categoryType) {
super(baseMethod.getManager(), baseMethod.getLanguage(), baseMethod.getName(),
new GrLightParameterListBuilder(baseMethod.getManager(), baseMethod.getLanguage()),
new GrLightModifierList(baseMethod), new LightReferenceListBuilder(baseMethod.getManager(), baseMethod.getLanguage(), null),
new LightTypeParameterListBuilder(baseMethod.getManager(), baseMethod.getLanguage())
);
- initParameterList(baseMethod, optionalParams, categoryType);
+ initParameterList(parameters, optionalParams, categoryType);
initTypeParameterList(baseMethod);
initModifiers(baseMethod, categoryType != null);
initThrowsList(baseMethod);
@@ -111,8 +112,7 @@
}
}
- private void initParameterList(GrMethod baseMethod, int optionalParams, PsiClassType categoryType) {
- final GrParameter[] parameters = baseMethod.getParameters();
+ private void initParameterList(GrParameter[] parameters, int optionalParams, PsiClassType categoryType) {
final GrLightParameterListBuilder parameterList = (GrLightParameterListBuilder)getParameterList();
List<GrParameter> skipped = new ArrayList<GrParameter>();
@@ -132,7 +132,7 @@
parameterList.addParameter(new GrLightParameter(parameter.getName(), parameter.getDeclaredType(), this));
}
- LOG.assertTrue(optionalParams == 0, optionalParams + "methodText: " + baseMethod.getText());
+ LOG.assertTrue(optionalParams == 0);
mySkippedParameters = skipped.toArray(new GrParameter[skipped.size()]);
}
@@ -255,10 +255,18 @@
return myBaseMethod.isPhysical();
}
+ @NotNull
public static GrReflectedMethod[] createReflectedMethods(GrMethod method) {
final PsiClassType categoryType = method.hasModifierProperty(PsiModifier.STATIC) ? null : getCategoryType(method);
final GrParameter[] parameters = method.getParameters();
+ return doCreateReflectedMethods(method, categoryType, parameters);
+ }
+
+ @NotNull
+ private static GrReflectedMethod[] doCreateReflectedMethods(@NotNull GrMethod targetMethod,
+ @Nullable PsiClassType categoryType,
+ @NotNull GrParameter[] parameters) {
int count = 0;
for (GrParameter parameter : parameters) {
if (parameter.isOptional()) count++;
@@ -268,12 +276,35 @@
final GrReflectedMethod[] methods = new GrReflectedMethod[count + 1];
for (int i = 0; i <= count; i++) {
- methods[i] = new GrReflectedMethodImpl(method, count - i, categoryType);
+ methods[i] = new GrReflectedMethodImpl(targetMethod, parameters, count - i, categoryType);
}
return methods;
}
+ public static GrReflectedMethod[] createReflectedConstructors(GrMethod method) {
+ assert method.isConstructor();
+
+ PsiClass aClass = method.getContainingClass();
+ if (aClass == null) return GrReflectedMethod.EMPTY_ARRAY;
+
+ PsiClass enclosingClass = aClass.getContainingClass();
+ if (enclosingClass != null && !aClass.hasModifierProperty(PsiModifier.STATIC)) {
+ GrParameter[] parameters = GrInnerClassConstructorUtil
+ .addEnclosingInstanceParam(method, enclosingClass, method.getParameterList().getParameters(), false);
+ GrReflectedMethod[] reflectedMethods = doCreateReflectedMethods(method, null, parameters);
+ if (reflectedMethods.length > 0) {
+ return reflectedMethods;
+ }
+ else {
+ return new GrReflectedMethod[]{new GrReflectedMethodImpl(method, parameters, 0, null)};
+ }
+ }
+ else {
+ return doCreateReflectedMethods(method, null, method.getParameters());
+ }
+ }
+
@Nullable
private static PsiClassType getCategoryType(GrMethod method) {
final PsiClass containingClass = method.getContainingClass();
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/patterns/GroovyAssignmentExpressionPattern.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/patterns/GroovyAssignmentExpressionPattern.java
index 52c20ad..7389332 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/patterns/GroovyAssignmentExpressionPattern.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/patterns/GroovyAssignmentExpressionPattern.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -46,7 +46,7 @@
public GroovyAssignmentExpressionPattern operation(final IElementType pattern) {
return with(new PatternCondition<GrAssignmentExpression>("operation") {
public boolean accepts(@NotNull final GrAssignmentExpression psiBinaryExpression, final ProcessingContext context) {
- return pattern == psiBinaryExpression.getOperationToken();
+ return pattern == psiBinaryExpression.getOperationTokenType();
}
});
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/stubs/index/GrFullClassNameIndex.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/stubs/index/GrFullClassNameIndex.java
index a02c021..696ea8e 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/stubs/index/GrFullClassNameIndex.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/stubs/index/GrFullClassNameIndex.java
@@ -19,6 +19,7 @@
import com.intellij.psi.PsiClass;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.stubs.IntStubIndexExtension;
+import com.intellij.psi.stubs.StubIndex;
import com.intellij.psi.stubs.StubIndexKey;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.lang.psi.impl.search.GrSourceFilterScope;
@@ -42,6 +43,6 @@
}
public Collection<PsiClass> get(final Integer integer, final Project project, final GlobalSearchScope scope) {
- return super.get(integer, project, new GrSourceFilterScope(scope));
+ return StubIndex.getInstance().safeGet(getKey(), integer, project, new GrSourceFilterScope(scope), PsiClass.class);
}
}
\ No newline at end of file
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/GrGenericTypeConverter.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/GrGenericTypeConverter.java
new file mode 100644
index 0000000..e9a7c74
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/GrGenericTypeConverter.java
@@ -0,0 +1,87 @@
+package org.jetbrains.plugins.groovy.lang.psi.typeEnhancers;
+
+import com.intellij.psi.*;
+import com.intellij.psi.util.InheritanceUtil;
+import com.intellij.psi.util.PsiUtil;
+import com.intellij.psi.util.TypeConversionUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
+import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
+
+import java.util.Iterator;
+
+/**
+ * @author Max Medvedev
+ */
+public class GrGenericTypeConverter extends GrTypeConverter {
+ @Override
+ public boolean isAllowedInMethodCall() {
+ return true;
+ }
+
+ @Override
+ public Boolean isConvertible(@NotNull PsiType ltype, @NotNull PsiType rtype, @NotNull GroovyPsiElement context) {
+ if (!(ltype instanceof PsiClassType && rtype instanceof PsiClassType)) {
+ return null;
+ }
+
+
+ PsiClassType.ClassResolveResult lresult = ((PsiClassType)ltype).resolveGenerics();
+ PsiClassType.ClassResolveResult rresult = ((PsiClassType)rtype).resolveGenerics();
+
+ PsiClass lclass = lresult.getElement();
+ PsiClass rclass = rresult.getElement();
+
+ if (lclass == null || rclass == null) return null;
+
+ if (lclass.getTypeParameters().length == 0) return null;
+
+ if (!InheritanceUtil.isInheritorOrSelf(rclass, lclass, true)) return null;
+
+ if (typeParametersAgree(lclass, rclass, lresult.getSubstitutor(), rresult.getSubstitutor(), context)) return Boolean.TRUE;
+
+ return null;
+ }
+
+ private static boolean typeParametersAgree(@NotNull PsiClass leftClass,
+ @NotNull PsiClass rightClass,
+ @NotNull PsiSubstitutor leftSubstitutor,
+ @NotNull PsiSubstitutor rightSubstitutor,
+ @NotNull PsiElement context) {
+
+ if (!leftClass.hasTypeParameters()) return true;
+
+ if (!leftClass.getManager().areElementsEquivalent(leftClass, rightClass)) {
+ rightSubstitutor = TypeConversionUtil.getSuperClassSubstitutor(leftClass, rightClass, rightSubstitutor);
+ rightClass = leftClass;
+ }
+ else if (!rightClass.hasTypeParameters()) return true;
+
+ Iterator<PsiTypeParameter> li = PsiUtil.typeParametersIterator(leftClass);
+ Iterator<PsiTypeParameter> ri = PsiUtil.typeParametersIterator(rightClass);
+
+ while (li.hasNext()) {
+ if (!ri.hasNext()) return false;
+ PsiTypeParameter lp = li.next();
+ PsiTypeParameter rp = ri.next();
+ final PsiType typeLeft = leftSubstitutor.substitute(lp);
+ if (typeLeft == null) continue;
+ final PsiType typeRight = rightSubstitutor.substituteWithBoundsPromotion(rp);
+ if (typeRight == null) {
+ // compatibility feature: allow to assign raw types to generic ones
+ return true;
+ }
+
+ if (typeLeft instanceof PsiClassType && typeRight instanceof PsiClassType) {
+ if (!TypesUtil.isAssignableByMethodCallConversion(typeLeft, typeRight, context)) {
+ return false;
+ }
+ }
+ else if (!TypeConversionUtil.typesAgree(typeLeft, typeRight, true)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrInnerClassConstructorUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrInnerClassConstructorUtil.java
new file mode 100644
index 0000000..2a9b081
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrInnerClassConstructorUtil.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2000-2013 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 org.jetbrains.plugins.groovy.lang.psi.util;
+
+import com.intellij.psi.*;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
+import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
+import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightParameter;
+
+/**
+ * @author Max Medvedev
+ */
+public class GrInnerClassConstructorUtil {
+
+ @NotNull
+ public static GrParameter[] addEnclosingInstanceParam(@NotNull GrMethod method,
+ @NotNull PsiClass enclosingClass,
+ @NotNull GrParameter[] originalParams,
+ boolean isOptional) {
+ final GrParameter[] parameters = new GrParameter[originalParams.length + 1];
+ final PsiClassType enclosingClassType = JavaPsiFacade.getElementFactory(method.getProject()).createType(enclosingClass, PsiSubstitutor.EMPTY);
+ final GrLightParameter enclosing = new GrLightParameter("enclosing", enclosingClassType, method);
+ if (isOptional) {
+ enclosing.setOptional(true);
+ enclosing.setInitializerGroovy(GroovyPsiElementFactory.getInstance(method.getProject()).createExpressionFromText("null"));
+ }
+ parameters[0] = enclosing;
+ System.arraycopy(originalParams, 0, parameters, 1, originalParams.length);
+ return parameters;
+ }
+
+ public static boolean isInnerClassConstructorUsedOutsideOfItParent(@NotNull PsiMethod method, PsiElement place) {
+ if (method instanceof GrMethod && method.isConstructor()) {
+ PsiClass aClass = method.getContainingClass();
+ if (aClass != null && !aClass.hasModifierProperty(PsiModifier.STATIC)) {
+ PsiClass containingClass = aClass.getContainingClass();
+ if (containingClass != null &&
+ PsiUtil.findEnclosingInstanceClassInScope(containingClass, place, true) == null) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ @NotNull
+ public static PsiType[] addEnclosingArgIfNeeded(@NotNull PsiType[] types, @NotNull PsiElement place, @NotNull PsiClass aClass) {
+ if (!aClass.hasModifierProperty(PsiModifier.STATIC)) {
+ PsiClass containingClass = aClass.getContainingClass();
+ if (containingClass != null) {
+ PsiElementFactory factory = JavaPsiFacade.getElementFactory(place.getProject());
+ PsiClass scopeClass = PsiUtil.findEnclosingInstanceClassInScope(containingClass, place, true);
+ if (scopeClass != null) {
+ PsiType[] newTypes = new PsiType[types.length + 1];
+ newTypes[0] = factory.createType(scopeClass);
+ System.arraycopy(types, 0, newTypes, 1, types.length);
+ types = newTypes;
+ }
+ else if (types.length == 0 || !TypesUtil.isAssignableByMethodCallConversion(factory.createType(containingClass), types[0], place)) {
+ PsiType[] newTypes = new PsiType[types.length + 1];
+ newTypes[0] = PsiType.NULL;
+ System.arraycopy(types, 0, newTypes, 1, types.length);
+ types = newTypes;
+ }
+ }
+ }
+ return types;
+ }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrStringUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrStringUtil.java
index 74bf288..d21b587 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrStringUtil.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrStringUtil.java
@@ -18,7 +18,6 @@
import com.intellij.lang.ASTNode;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.psi.PsiElement;
-import com.intellij.psi.impl.source.tree.LeafPsiElement;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -30,13 +29,11 @@
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrRegex;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrString;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrStringInjection;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.*;
import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringUtil;
import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.*;
+import static org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes.GSTRING_CONTENT;
import static org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes.GSTRING_INJECTION;
/**
@@ -532,7 +529,6 @@
if (!(statements[0] instanceof GrReferenceExpression)) return false;
final PsiElement next = injection.getNextSibling();
- if (!(next instanceof LeafPsiElement)) return false;
return checkBraceIsUnnecessary(statements[0], next);
}
@@ -814,7 +810,7 @@
builder.append(quote);
for (PsiElement child = regex.getFirstChild(); child!=null; child = child.getNextSibling()) {
final IElementType type = child.getNode().getElementType();
- if (type == mREGEX_CONTENT) {
+ if (type == mREGEX_CONTENT || type == GSTRING_CONTENT) {
builder.append(escapeSymbolsForGString(unescapeSlashyString(child.getText()), quote.equals(DOUBLE_QUOTES), false));
}
else if (type == mDOLLAR_SLASH_REGEX_CONTENT) {
@@ -960,4 +956,12 @@
}
return buffer;
}
+
+ public static PsiElement findContainingLiteral(PsiElement token) {
+
+ PsiElement parent = token.getParent();
+ if (parent instanceof GrStringContent) parent = parent.getParent();
+
+ return parent;
+ }
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/PsiUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/PsiUtil.java
index f73b3e0..64f8314 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/PsiUtil.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/PsiUtil.java
@@ -27,7 +27,6 @@
import com.intellij.psi.impl.light.LightElement;
import com.intellij.psi.impl.source.tree.LeafElement;
import com.intellij.psi.search.GlobalSearchScope;
-import com.intellij.psi.search.SearchScope;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.TokenSet;
import com.intellij.psi.util.InheritanceUtil;
@@ -40,7 +39,6 @@
import gnu.trove.TIntStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import org.jetbrains.plugins.groovy.GroovyFileTypeLoader;
import org.jetbrains.plugins.groovy.codeInspection.utils.ControlFlowUtils;
import org.jetbrains.plugins.groovy.config.GroovyConfigUtils;
import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocComment;
@@ -346,14 +344,6 @@
return result.toArray(new PsiType[result.size()]);
}
- public static SearchScope restrictScopeToGroovyFiles(SearchScope originalScope) {
- if (originalScope instanceof GlobalSearchScope) {
- return GlobalSearchScope
- .getScopeRestrictedByFileTypes((GlobalSearchScope)originalScope, GroovyFileTypeLoader.getGroovyEnabledFileTypes());
- }
- return originalScope;
- }
-
@Nullable
public static PsiClass getJavaLangClass(PsiElement resolved, GlobalSearchScope scope) {
return JavaPsiFacade.getInstance(resolved.getProject()).findClass(CommonClassNames.JAVA_LANG_CLASS, scope);
@@ -723,23 +713,28 @@
final GrExpression expression = call.getInvokedExpression();
return expression instanceof GrReferenceExpression && methodName.equals(expression.getText().trim());
}
-
public static boolean hasEnclosingInstanceInScope(@NotNull PsiClass clazz, @Nullable PsiElement scope, boolean isSuperClassAccepted) {
+ return findEnclosingInstanceClassInScope(clazz, scope, isSuperClassAccepted) != null;
+ }
+
+ public static PsiClass findEnclosingInstanceClassInScope(@NotNull PsiClass clazz, @Nullable PsiElement scope, boolean isSuperClassAccepted) {
PsiElement place = scope;
while (place != null && place != clazz && !(place instanceof PsiFile && place.isPhysical())) {
if (place instanceof PsiClass) {
if (isSuperClassAccepted) {
- if (InheritanceUtil.isInheritorOrSelf((PsiClass)place, clazz, true)) return true;
+ if (InheritanceUtil.isInheritorOrSelf((PsiClass)place, clazz, true)) return (PsiClass)place;
}
else {
- if (clazz.getManager().areElementsEquivalent(place, clazz)) return true;
+ if (clazz.getManager().areElementsEquivalent(place, clazz)) return (PsiClass)place;
}
}
- if (place instanceof PsiModifierListOwner && ((PsiModifierListOwner)place).hasModifierProperty(PsiModifier.STATIC)) return false;
+ if (place instanceof PsiModifierListOwner && ((PsiModifierListOwner)place).hasModifierProperty(PsiModifier.STATIC)) return null;
place = place.getContext();
}
- if (clazz instanceof GroovyScriptClass) return place == clazz.getContainingFile();
- return place == clazz;
+ if (clazz instanceof GroovyScriptClass && place == clazz.getContainingFile() || place == clazz) {
+ return clazz;
+ }
+ return null;
}
@@ -824,19 +819,16 @@
return false;
}
- public static GroovyResolveResult[] getConstructorCandidates(GroovyPsiElement place,
- GroovyResolveResult[] classCandidates,
+ @NotNull
+ public static GroovyResolveResult[] getConstructorCandidates(@NotNull PsiElement place,
+ @NotNull GroovyResolveResult classCandidate,
@Nullable PsiType[] argTypes) {
- for (GroovyResolveResult classResult : classCandidates) {
- final PsiElement element = classResult.getElement();
- if (element instanceof PsiClass) {
- PsiClass clazz = (PsiClass)element;
- PsiSubstitutor substitutor = classResult.getSubstitutor();
- return ResolveUtil.getAllClassConstructors(clazz, place, substitutor, argTypes);
- }
- }
+ final PsiElement element = classCandidate.getElement();
+ if (!(element instanceof PsiClass)) return GroovyResolveResult.EMPTY_ARRAY;
- return GroovyResolveResult.EMPTY_ARRAY;
+ PsiClass clazz = (PsiClass)element;
+ PsiSubstitutor substitutor = classCandidate.getSubstitutor();
+ return ResolveUtil.getAllClassConstructors(clazz, substitutor, argTypes, place);
}
public static boolean isAccessedForReading(GrExpression expr) {
@@ -894,7 +886,7 @@
final GroovyResolveResult grResult = resolveResult instanceof GroovyResolveResult
? (GroovyResolveResult)resolveResult
: new GroovyResolveResultImpl(psiClass, context, null, substitutor, true, true);
- return getConstructorCandidates(context, new GroovyResolveResult[]{grResult}, argTypes);
+ return getConstructorCandidates(context, grResult, argTypes);
}
@Nullable
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/StaticChecker.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/StaticChecker.java
index fc831c0..6bbf00f 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/StaticChecker.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/StaticChecker.java
@@ -43,6 +43,8 @@
if (!(place instanceof GrReferenceExpression)) return true;
+ if (member instanceof PsiClass && PsiTreeUtil.isAncestor(member, place, false)) return true;
+
GrExpression qualifier = ((GrReferenceExpression)place).getQualifierExpression();
final PsiClass containingClass = getContainingClass((PsiMember)member);
if (qualifier != null) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/GroovyStringLiteralManipulator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/GroovyStringLiteralManipulator.java
index 67d9757..218929a 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/GroovyStringLiteralManipulator.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/GroovyStringLiteralManipulator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -21,40 +21,46 @@
import com.intellij.psi.AbstractElementManipulator;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral;
-import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.literals.GrLiteralImpl;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteralContainer;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrStringContent;
import org.jetbrains.plugins.groovy.lang.psi.util.GrStringUtil;
-public class GroovyStringLiteralManipulator extends AbstractElementManipulator<GrLiteral> {
+public class GroovyStringLiteralManipulator extends AbstractElementManipulator<GrLiteralContainer> {
private static final Logger LOG = Logger.getInstance(GroovyStringLiteralManipulator.class);
- public GrLiteralImpl handleContentChange(GrLiteral expr, TextRange range, String newContent) throws IncorrectOperationException {
+ @Override
+ public GrLiteralContainer handleContentChange(GrLiteralContainer expr, TextRange range, String newContent) throws IncorrectOperationException {
if (!(expr.getValue() instanceof String)) {
- throw new IncorrectOperationException("cannot handle content change, expr.getValue()=" + expr.getValue());
+// throw new IncorrectOperationException("cannot handle content change, expr.getValue()=" + expr.getValue());
}
- LOG.assertTrue(expr instanceof GrLiteralImpl);
+ final String oldText = expr instanceof GrLiteral ? expr.getText() : expr.getParent().getText();
+ final String startQuote = GrStringUtil.getStartQuote(oldText);
- String oldText = expr.getText();
- final String quote = GrStringUtil.getStartQuote(oldText);
-
- if (StringUtil.startsWithChar(quote, '\'')) {
- newContent = GrStringUtil.escapeSymbolsForString(newContent, !quote.equals("'''"), true);
+ if (StringUtil.startsWithChar(startQuote, '\'')) {
+ newContent = GrStringUtil.escapeSymbolsForString(newContent, !startQuote.equals("'''"), true);
}
- else if (StringUtil.startsWithChar(quote, '\"')) {
- newContent = GrStringUtil.escapeSymbolsForGString(newContent, !quote.equals("\"\"\""), true);
+ else if (StringUtil.startsWithChar(startQuote, '\"')) {
+ newContent = GrStringUtil.escapeSymbolsForGString(newContent, !startQuote.equals("\"\"\""), true);
}
- else if ("/".equals(quote)) {
+ else if ("/".equals(startQuote)) {
newContent = GrStringUtil.escapeSymbolsForSlashyStrings(newContent);
}
- else if ("$/".equals(quote)) {
+ else if ("$/".equals(startQuote)) {
newContent = GrStringUtil.escapeSymbolsForDollarSlashyStrings(newContent);
}
- String newText = oldText.substring(0, range.getStartOffset()) + newContent + oldText.substring(range.getEndOffset());
- return ((GrLiteralImpl)expr).updateText(newText);
+ String newText = expr instanceof GrLiteral
+ ? oldText.substring(0, range.getStartOffset()) + newContent + oldText.substring(range.getEndOffset())
+ : newContent;
+ return expr.updateText(newText);
}
- public TextRange getRangeInElement(final GrLiteral element) {
+ @Override
+ public TextRange getRangeInElement(final GrLiteralContainer element) {
+ if (element instanceof GrStringContent) {
+ return TextRange.from(0, element.getTextLength());
+ }
final String text = element.getText();
if (!(element.getValue() instanceof String)) {
return super.getRangeInElement(element);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/NonCodeMembersContributor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/NonCodeMembersContributor.java
index 3adc991..163bee4 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/NonCodeMembersContributor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/NonCodeMembersContributor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -76,9 +76,9 @@
}
public static boolean runContributors(@NotNull final PsiType qualifierType,
- PsiScopeProcessor processor,
- final PsiElement place,
- final ResolveState state) {
+ @NotNull PsiScopeProcessor processor,
+ @NotNull final PsiElement place,
+ @NotNull final ResolveState state) {
MyDelegatingScopeProcessor delegatingProcessor = new MyDelegatingScopeProcessor(processor);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/ResolveUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/ResolveUtil.java
index d8ef7e4..b78d2c8 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/ResolveUtil.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/ResolveUtil.java
@@ -284,8 +284,8 @@
if (!psiClass.processDeclarations(processor, state, null, place)) return false;
}
}
- if (!processNonCodeMembers(type, nonCodeProcessor, place, state)) return false;
if (!processCategoryMembers(place, nonCodeProcessor, state)) return false;
+ if (!processNonCodeMembers(type, nonCodeProcessor, place, state)) return false;
return true;
}
@@ -649,7 +649,10 @@
return variants;
}
- public static GroovyResolveResult[] getAllClassConstructors(PsiClass psiClass, GroovyPsiElement place, PsiSubstitutor substitutor, @Nullable PsiType[] argTypes) {
+ public static GroovyResolveResult[] getAllClassConstructors(@NotNull PsiClass psiClass,
+ @NotNull PsiSubstitutor substitutor,
+ @Nullable PsiType[] argTypes,
+ @NotNull PsiElement place) {
final MethodResolverProcessor processor = new MethodResolverProcessor(psiClass.getName(), place, true, null, argTypes, PsiType.EMPTY_ARRAY);
ResolveState state = ResolveState.initial().put(PsiSubstitutor.KEY, substitutor);
for (PsiMethod constructor : psiClass.getConstructors()) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/MethodResolverProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/MethodResolverProcessor.java
index 666a367..5e76077 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/MethodResolverProcessor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/MethodResolverProcessor.java
@@ -65,7 +65,7 @@
private final boolean myTypedContext;
public MethodResolverProcessor(@Nullable String name,
- @NotNull GroovyPsiElement place,
+ @NotNull PsiElement place,
boolean isConstructor,
@Nullable PsiType thisType,
@Nullable PsiType[] argumentTypes,
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/overrideImplement/GroovyOverrideImplementUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/overrideImplement/GroovyOverrideImplementUtil.java
index 666ddb5..84b0765 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/overrideImplement/GroovyOverrideImplementUtil.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/overrideImplement/GroovyOverrideImplementUtil.java
@@ -36,6 +36,7 @@
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement;
import org.jetbrains.plugins.groovy.refactoring.GroovyChangeContextUtil;
+import org.jetbrains.plugins.groovy.refactoring.GroovyNamesUtil;
import org.jetbrains.plugins.groovy.refactoring.convertToJava.ModifierListGenerator;
import java.io.IOException;
@@ -179,6 +180,9 @@
}
final String paramName = parameter.getName();
if (paramName != null) {
+ if (GroovyNamesUtil.isKeyword(paramName)) {
+ buffer.append('_');
+ }
buffer.append(paramName);
}
else if (parameter instanceof PsiCompiledElement) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyImportOptimizerRefactoringHelper.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyImportOptimizerRefactoringHelper.java
index 71785b5..6165556 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyImportOptimizerRefactoringHelper.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyImportOptimizerRefactoringHelper.java
@@ -25,7 +25,6 @@
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.refactoring.RefactoringHelper;
import com.intellij.usageView.UsageInfo;
@@ -48,12 +47,9 @@
Set<GroovyFile> files = new HashSet<GroovyFile>();
for (UsageInfo usage : usages) {
if (usage.isNonCodeUsage) continue;
- final PsiElement element = usage.getElement();
- if (element != null) {
- final PsiFile file = element.getContainingFile();
- if (file instanceof GroovyFile && file.isValid()) {
- files.add((GroovyFile)file);
- }
+ PsiFile file = usage.getFile();
+ if (file instanceof GroovyFile && file.isValid()) {
+ files.add((GroovyFile)file);
}
}
return files;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyNamesUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyNamesUtil.java
index 93912e2..ddbfb62 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyNamesUtil.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyNamesUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -19,10 +19,13 @@
import com.intellij.lexer.Lexer;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.psi.tree.IElementType;
import com.intellij.util.Function;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.lang.lexer.GroovyLexer;
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
+import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
import java.util.ArrayList;
@@ -96,4 +99,11 @@
}
}, "-");
}
+
+ public static boolean isKeyword(@NotNull String name) {
+ final GroovyLexer lexer = new GroovyLexer();
+ lexer.start(name);
+ final IElementType type = lexer.getTokenType();
+ return TokenSets.KEYWORDS.contains(type);
+ }
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyRefactoringSupportProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyRefactoringSupportProvider.java
index 4f61d4a..1e0b74d 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyRefactoringSupportProvider.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyRefactoringSupportProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -18,12 +18,22 @@
import com.intellij.lang.refactoring.RefactoringSupportProvider;
import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiFile;
+import com.intellij.psi.search.LocalSearchScope;
+import com.intellij.psi.search.PsiSearchHelper;
+import com.intellij.psi.search.SearchScope;
+import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.refactoring.RefactoringActionHandler;
import com.intellij.refactoring.changeSignature.ChangeSignatureHandler;
import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.groovy.lang.psi.GrReferenceElement;
+import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrLabeledStatement;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMember;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
+import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement;
import org.jetbrains.plugins.groovy.refactoring.changeSignature.GrChangeSignatureHandler;
import org.jetbrains.plugins.groovy.refactoring.extract.method.GroovyExtractMethodHandler;
import org.jetbrains.plugins.groovy.refactoring.introduce.constant.GrIntroduceConstantHandler;
@@ -63,8 +73,38 @@
}
@Override
- public boolean isInplaceRenameAvailable(PsiElement element, PsiElement context) {
- return false;
+ public boolean isInplaceRenameAvailable(PsiElement elementToRename, PsiElement nameSuggestionContext) {
+ //local vars & params renames GrVariableInplaceRenameHandler
+
+ if (nameSuggestionContext != null && nameSuggestionContext.getContainingFile() != elementToRename.getContainingFile()) return false;
+ if (!(elementToRename instanceof GrLabeledStatement)) {
+ return false;
+ }
+ SearchScope useScope = PsiSearchHelper.SERVICE.getInstance(elementToRename.getProject()).getUseScope(elementToRename);
+ if (!(useScope instanceof LocalSearchScope)) return false;
+ PsiElement[] scopeElements = ((LocalSearchScope)useScope).getScope();
+ if (scopeElements.length > 1) {
+ return false;
+ }
+
+ PsiFile containingFile = elementToRename.getContainingFile();
+ return PsiTreeUtil.isAncestor(containingFile, scopeElements[0], false);
+
+ }
+
+ @Override
+ public boolean isMemberInplaceRenameAvailable(PsiElement element, PsiElement context) {
+ PsiElement parent = context.getParent();
+
+ //don't try to inplace rename aliased imported references
+ if (parent instanceof GrReferenceElement) {
+ GroovyResolveResult result = ((GrReferenceElement)parent).advancedResolve();
+ PsiElement fileResolveContext = result.getCurrentFileResolveContext();
+ if (fileResolveContext instanceof GrImportStatement && ((GrImportStatement)fileResolveContext).isAliasedImport()) {
+ return false;
+ }
+ }
+ return element instanceof GrMember;
}
@Override
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/changeSignature/GrChangeSignatureUsageProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/changeSignature/GrChangeSignatureUsageProcessor.java
index 126c07f..fb70da6 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/changeSignature/GrChangeSignatureUsageProcessor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/changeSignature/GrChangeSignatureUsageProcessor.java
@@ -270,7 +270,6 @@
Set<GrParameter> toRemove = new HashSet<GrParameter>(oldParameters.length);
ContainerUtil.addAll(toRemove, oldParameters);
- GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(method.getProject());
GrParameter anchor = null;
final GrDocComment docComment = method.getDocComment();
final GrDocTag[] tags = docComment == null ? null : docComment.getTags();
@@ -278,15 +277,6 @@
for (JavaParameterInfo newParameter : newParameters) {
- PsiType type;
- if (newParameter instanceof GrParameterInfo && ((GrParameterInfo)newParameter).hasNoType()) {
- type = null;
- }
- else {
- type = substitutor.substitute(newParameter.createType(context, method.getManager()));
- }
-
-
//if old parameter name differs from base method parameter name we don't change it
final String newName;
final int oldIndex = newParameter.getOldIndex();
@@ -303,25 +293,32 @@
newName = newParameter.getName();
}
- if (docComment != null) {
- if (oldIndex >= 0) {
- final GrParameter oldParameter = oldParameters[oldIndex];
- final String oldName = oldParameter.getName();
- for (GrDocTag tag : tags) {
- if ("@param".equals(tag.getName())) {
- final GrDocParameterReference parameterReference = tag.getDocParameterReference();
- if (parameterReference != null && oldName.equals(parameterReference.getText())) {
- parameterReference.handleElementRename(newName);
- }
+ final GrParameter oldParameter = oldIndex >= 0 ? oldParameters[oldIndex] : null;
+
+ if (docComment != null && oldParameter != null) {
+ final String oldName = oldParameter.getName();
+ for (GrDocTag tag : tags) {
+ if ("@param".equals(tag.getName())) {
+ final GrDocParameterReference parameterReference = tag.getDocParameterReference();
+ if (parameterReference != null && oldName.equals(parameterReference.getText())) {
+ parameterReference.handleElementRename(newName);
}
}
}
}
- GrParameter grParameter = factory.createParameter(newName, type == null ? null : type.getCanonicalText(),
- getInitializer(newParameter), parameterList);
-
-
+ GrParameter grParameter = createNewParameter(substitutor, context, parameterList, newParameter, newName);
+ if (oldParameter != null) {
+ grParameter.getModifierList().replace(oldParameter.getModifierList());
+ }
+
+ if ("def".equals(newParameter.getTypeText())) {
+ grParameter.getModifierList().setModifierProperty(GrModifier.DEF, true);
+ }
+ else if (StringUtil.isEmpty(newParameter.getTypeText())) {
+ grParameter.getModifierList().setModifierProperty(GrModifier.DEF, false);
+ }
+
anchor = (GrParameter)parameterList.addAfter(grParameter, anchor);
}
@@ -347,6 +344,21 @@
return true;
}
+ private static GrParameter createNewParameter(@NotNull PsiSubstitutor substitutor,
+ @NotNull PsiMethod context,
+ @NotNull GrParameterList parameterList,
+ @NotNull JavaParameterInfo newParameter,
+ @NotNull String newName) {
+ GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(parameterList.getProject());
+ String typeText = newParameter.getTypeText();
+ if (newParameter instanceof GrParameterInfo && (typeText.isEmpty() || "def".equals(typeText))) {
+ return factory.createParameter(newName, null, getInitializer(newParameter), parameterList);
+ }
+
+ PsiType type = substitutor.substitute(newParameter.createType(context, parameterList.getManager()));
+ return factory.createParameter(newName, type == null ? null : type.getCanonicalText(), getInitializer(newParameter), parameterList);
+ }
+
private static PsiSubstitutor calculateSubstitutor(PsiMethod derivedMethod, PsiMethod baseMethod) {
PsiSubstitutor substitutor;
if (derivedMethod.getManager().areElementsEquivalent(derivedMethod, baseMethod)) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/changeSignature/GrMethodDescriptor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/changeSignature/GrMethodDescriptor.java
index d570cc0..7d49053 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/changeSignature/GrMethodDescriptor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/changeSignature/GrMethodDescriptor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -18,7 +18,6 @@
import com.intellij.psi.PsiClass;
import com.intellij.refactoring.changeSignature.MethodDescriptor;
import com.intellij.util.VisibilityUtil;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement;
@@ -47,9 +46,7 @@
final GrParameter[] parameters = myMethod.getParameters();
for (int i = 0; i < parameters.length; i++) {
GrParameter parameter = parameters[i];
- GrExpression initializer = parameter.getInitializerGroovy();
- String initializerText = initializer != null ? initializer.getText() : null;
- GrParameterInfo info = new GrParameterInfo(parameter.getName(), "", initializerText, parameter.getType(), i, false);
+ GrParameterInfo info = new GrParameterInfo(parameter, i);
result.add(info);
}
return result;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/changeSignature/GrParameterInfo.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/changeSignature/GrParameterInfo.java
index d279e5b..87775e8 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/changeSignature/GrParameterInfo.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/changeSignature/GrParameterInfo.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -22,6 +22,7 @@
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifier;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
@@ -43,6 +44,9 @@
if (type != null) {
myTypeWrapper = CanonicalTypes.createTypeWrapper(type);
}
+ else if (parameter.hasModifierProperty(GrModifier.DEF)) {
+ myTypeWrapper = CanonicalTypes.createTypeWrapper(JavaPsiFacade.getElementFactory(parameter.getProject()).createTypeFromText("def", null));
+ }
else {
myTypeWrapper = null;
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ExpressionGenerator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ExpressionGenerator.java
index 7ee9475..657f558 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ExpressionGenerator.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ExpressionGenerator.java
@@ -432,7 +432,7 @@
public void visitAssignmentExpression(final GrAssignmentExpression expression) {
final GrExpression lValue = expression.getLValue();
final GrExpression rValue = expression.getRValue();
- final IElementType token = expression.getOperationToken();
+ final IElementType token = expression.getOperationTokenType();
PsiElement realLValue = PsiUtil.skipParentheses(lValue, false);
if (realLValue instanceof GrReferenceExpression && rValue != null) {
@@ -502,7 +502,7 @@
final GroovyResolveResult resolveResult = PsiImplUtil.extractUniqueResult(expression.multiResolve(false));
final PsiElement resolved = resolveResult.getElement();
- if (resolved instanceof PsiMethod && !shouldNotReplaceOperatorWithMethod(lValue.getType(), rValue, expression.getOperationToken())) {
+ if (resolved instanceof PsiMethod && !shouldNotReplaceOperatorWithMethod(lValue.getType(), rValue, expression.getOperationTokenType())) {
lValue.accept(this);
builder.append(" = ");
@@ -523,7 +523,7 @@
});
}
else {
- writeSimpleBinaryExpression(expression.getOpToken(), lValue, rValue);
+ writeSimpleBinaryExpression(expression.getOperationToken(), lValue, rValue);
}
}
}
@@ -561,7 +561,7 @@
if (rValue == null) return null;
GrExpression lValue = expression.getLValue();
- IElementType opToken = expression.getOperationToken();
+ IElementType opToken = expression.getOperationTokenType();
if (opToken == mASSIGN) return rValue;
Pair<String, IElementType> pair = getBinaryOperatorType(opToken);
LOG.assertTrue(pair != null);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/GenerationUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/GenerationUtil.java
index 2446b3a..0c38554 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/GenerationUtil.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/GenerationUtil.java
@@ -315,7 +315,9 @@
while (i < parameters.length) {
PsiParameter parameter = parameters[i];
if (parameter == null) continue;
- if (parameter instanceof PsiCompiledElement) parameter = (PsiParameter)((PsiCompiledElement)parameter).getMirror();
+ if (parameter instanceof PsiCompiledElement) {
+ parameter = (PsiParameter)((PsiCompiledElement)parameter).getMirror();
+ }
if (i > 0) text.append(", "); //append ','
if (!classNameProvider.forStubs()) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/InitialInfo.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/InitialInfo.java
index ce29074..e50e6d5 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/InitialInfo.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/InitialInfo.java
@@ -25,7 +25,6 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrCodeBlock;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrReturnStatement;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
import org.jetbrains.plugins.groovy.lang.psi.dataFlow.reachingDefs.VariableInfo;
@@ -103,10 +102,7 @@
}
}
else if (ExtractUtil.isSingleExpression(statements)) {
- final GrStatement single = statements[0];
- if (!(single.getParent() instanceof GrCodeBlock)) {
- outputType = ((GrExpression)single).getType();
- }
+ outputType = ((GrExpression)statements[0]).getType();
}
else if (hasReturnValue) {
assert returnStatements.size() > 0;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/closure/ExtractClosureFromClosureProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/closure/ExtractClosureFromClosureProcessor.java
index 999fafd..9ed4c94 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/closure/ExtractClosureFromClosureProcessor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/closure/ExtractClosureFromClosureProcessor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -18,7 +18,6 @@
import com.intellij.openapi.util.Ref;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiReference;
-import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.searches.ReferencesSearch;
import com.intellij.refactoring.IntroduceParameterRefactoring;
import com.intellij.refactoring.introduceParameter.ExternalUsageInfo;
@@ -79,7 +78,7 @@
final GrVariable var = (GrVariable)myHelper.getToSearchFor();
if (var != null) {
final List<UsageInfo> result = new ArrayList<UsageInfo>();
- for (PsiReference ref : ReferencesSearch.search(var, GlobalSearchScope.allScope(myHelper.getProject()), true)) {
+ for (PsiReference ref : ReferencesSearch.search(var)) {
final PsiElement element = ref.getElement();
if (element.getLanguage() != GroovyFileType.GROOVY_LANGUAGE) {
result.add(new OtherLanguageUsageInfo(ref));
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/inline/GroovyInlineLocalProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/inline/GroovyInlineLocalProcessor.java
index 6ed6859..b0173f0 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/inline/GroovyInlineLocalProcessor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/inline/GroovyInlineLocalProcessor.java
@@ -23,7 +23,7 @@
import com.intellij.psi.search.searches.ReferencesSearch;
import com.intellij.refactoring.BaseRefactoringProcessor;
import com.intellij.refactoring.RefactoringBundle;
-import com.intellij.refactoring.util.RefactoringUtil;
+import com.intellij.refactoring.util.CommonRefactoringUtil;
import com.intellij.usageView.BaseUsageViewDescriptor;
import com.intellij.usageView.UsageInfo;
import com.intellij.usageView.UsageViewDescriptor;
@@ -192,7 +192,7 @@
@Override
protected void performRefactoring(UsageInfo[] usages) {
- RefactoringUtil.sortDepthFirstRightLeftOrder(usages);
+ CommonRefactoringUtil.sortDepthFirstRightLeftOrder(usages);
for (UsageInfo usage : usages) {
GrVariableInliner.inlineReference(usage, myLocal, mySettings.getInitializer());
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GrIntroduceClosureParameterProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GrIntroduceClosureParameterProcessor.java
index 94ff10a..babc957 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GrIntroduceClosureParameterProcessor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GrIntroduceClosureParameterProcessor.java
@@ -178,7 +178,7 @@
if (!mySettings.generateDelegate() && toSearchFor != null) {
Collection<PsiReference> refs;
if (toSearchFor instanceof GrField) {
- refs = ReferencesSearch.search(toSearchFor, toSearchFor.getResolveScope(), true).findAll();
+ refs = ReferencesSearch.search(toSearchFor, toSearchFor.getResolveScope()).findAll();
final GrAccessorMethod[] getters = ((GrField)toSearchFor).getGetters();
for (GrAccessorMethod getter : getters) {
refs.addAll(MethodReferencesSearch.search(getter, getter.getResolveScope(), true).findAll());
@@ -188,7 +188,7 @@
refs = findUsagesForLocal(toReplaceIn, ((GrVariable)toSearchFor));
}
else {
- refs = ReferencesSearch.search(toSearchFor, toSearchFor.getResolveScope(), true).findAll();
+ refs = ReferencesSearch.search(toSearchFor, toSearchFor.getResolveScope()).findAll();
}
for (PsiReference ref1 : refs) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/rename/PropertyRenameHandler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/rename/PropertyRenameHandler.java
index dc9635b..553f121 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/rename/PropertyRenameHandler.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/rename/PropertyRenameHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -77,13 +77,19 @@
final Pair<List<? extends PsiElement>, String> pair = askToRenameProperty((PsiMember)element);
final List<? extends PsiElement> result = pair.getFirst();
if (result.size() == 0) return;
- if (result.size() == 1) {
- PsiElementRenameHandler.invoke(result.get(0), project, result.get(0), editor);
- return;
- }
- final String propertyName = pair.getSecond();
- PsiElementRenameHandler.invoke(new PropertyForRename(result, propertyName, element.getManager()), project, element, editor);
+ PsiElement propertyToRename = getPropertyToRename(element, result, pair.getSecond());
+
+ PsiElementRenameHandler.invoke(propertyToRename, project, element, editor);
+ }
+
+ private static PsiElement getPropertyToRename(PsiElement element, List<? extends PsiElement> result, String propertyName) {
+ if (result.size() == 1) {
+ return result.get(0);
+ }
+ else /*if (result.size() > 1)*/ {
+ return new PropertyForRename(result, propertyName, element.getManager());
+ }
}
@Override
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/rename/RenameGrFieldProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/rename/RenameGrFieldProcessor.java
index 7426e0b..8ec7ce6 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/rename/RenameGrFieldProcessor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/rename/RenameGrFieldProcessor.java
@@ -77,7 +77,7 @@
for (GrAccessorMethod getter : getters) {
refs.addAll(RenameAliasedUsagesUtil.filterAliasedRefs(MethodReferencesSearch.search(getter, projectScope, true).findAll(), getter));
}
- refs.addAll(RenameAliasedUsagesUtil.filterAliasedRefs(ReferencesSearch.search(field, projectScope, true).findAll(), field));
+ refs.addAll(RenameAliasedUsagesUtil.filterAliasedRefs(ReferencesSearch.search(field, projectScope, false).findAll(), field));
return refs;
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/ui/GrTypeComboBox.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/ui/GrTypeComboBox.java
index 5caf427..52a3d91 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/ui/GrTypeComboBox.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/ui/GrTypeComboBox.java
@@ -99,6 +99,9 @@
}
if (type != null && type.equalsToText(GroovyCommonClassNames.JAVA_MATH_BIG_DECIMAL)) {
+ //suggest double as the second item after original BigDecimal
+ addItem(new PsiTypeItem(type));
+ types.remove(GroovyCommonClassNames.JAVA_MATH_BIG_DECIMAL);
addItem(new PsiTypeItem(PsiType.DOUBLE));
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/ui/MethodOrClosureScopeChooser.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/ui/MethodOrClosureScopeChooser.java
index 2eeef0b..abd9431 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/ui/MethodOrClosureScopeChooser.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/ui/MethodOrClosureScopeChooser.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -200,7 +200,7 @@
if (parent instanceof GrVariable) return (GrVariable)parent;
if (parent instanceof GrAssignmentExpression &&
((GrAssignmentExpression)parent).getRValue() == owner &&
- ((GrAssignmentExpression)parent).getOperationToken() == GroovyTokenTypes.mASSIGN) {
+ ((GrAssignmentExpression)parent).getOperationTokenType() == GroovyTokenTypes.mASSIGN) {
final GrExpression lValue = ((GrAssignmentExpression)parent).getLValue();
if (lValue instanceof GrReferenceExpression) {
final PsiElement resolved = ((GrReferenceExpression)lValue).resolve();
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/structure/GroovyStructureViewFactory.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/structure/GroovyStructureViewFactory.java
index 08723b3..f1ccc7b 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/structure/GroovyStructureViewFactory.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/structure/GroovyStructureViewFactory.java
@@ -27,20 +27,24 @@
import com.intellij.ide.structureView.impl.java.JavaInheritedMembersNodeProvider;
import com.intellij.ide.util.treeView.smartTree.NodeProvider;
import com.intellij.lang.PsiStructureViewFactory;
+import com.intellij.openapi.editor.Editor;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase;
import java.util.Arrays;
import java.util.Collection;
public class GroovyStructureViewFactory implements PsiStructureViewFactory {
+ @Override
public StructureViewBuilder getStructureViewBuilder(final PsiFile psiFile) {
return new TreeBasedStructureViewBuilder() {
+ @Override
@NotNull
- public StructureViewModel createStructureViewModel() {
- return new JavaFileTreeModel((GroovyFileBase)psiFile) {
+ public StructureViewModel createStructureViewModel(@Nullable Editor editor) {
+ return new JavaFileTreeModel((GroovyFileBase)psiFile, editor) {
@NotNull
@Override
public Collection<NodeProvider> getNodeProviders() {
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyAutoPopupTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyAutoPopupTest.groovy
index 2f3437f..163be05 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyAutoPopupTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyAutoPopupTest.groovy
@@ -283,7 +283,9 @@
void foo(File... files) { }
foo(new <caret>)
'''
- type 'File('
+ type 'File'
+ myFixture.assertPreferredCompletionItems 0, 'File', 'File', 'FileInputStream'
+ type '('
assert myFixture.editor.document.text.contains('new File()')
}
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/dsl/GroovyDslTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/dsl/GroovyDslTest.groovy
index 3b759b2..eca21e1 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/dsl/GroovyDslTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/dsl/GroovyDslTest.groovy
@@ -14,6 +14,7 @@
* limitations under the License.
*/
package org.jetbrains.plugins.groovy.dsl
+
import com.intellij.codeInsight.documentation.DocumentationManager
import com.intellij.openapi.module.Module
import com.intellij.openapi.roots.ContentEntry
@@ -32,15 +33,23 @@
* @author peter
*/
public class GroovyDslTest extends LightCodeInsightFixtureTestCase {
- static def descriptor = new DefaultLightProjectDescriptor() {
- @Override def void configureModule(Module module, ModifiableRootModel model, ContentEntry contentEntry) {
+ private static descriptor = new DefaultLightProjectDescriptor() {
+ @Override
+ void configureModule(Module module, ModifiableRootModel model, ContentEntry contentEntry) {
PsiTestUtil.addLibrary(module, model, "GROOVY", TestUtils.getMockGroovyLibraryHome(), TestUtils.GROOVY_JAR);
}
}
+ @NotNull
+ @Override
+ protected LightProjectDescriptor getProjectDescriptor() {
+ descriptor
+ }
+
+
@Override
protected String getBasePath() {
- TestUtils.getTestDataPath() + "groovy/dsl"
+ TestUtils.testDataPath + "groovy/dsl"
}
private def doCustomTest(String s) {
@@ -153,11 +162,6 @@
myFixture.testCompletionTyping(getTestName(false) + ".groovy", '\n', getTestName(false) + "_after.groovy")
}
- @NotNull
- @Override protected LightProjectDescriptor getProjectDescriptor() {
- return descriptor;
- }
-
public void testCategoryWhenMethodRenamed() {
PsiClass category = myFixture.addClass("""
public class MyCategory {
@@ -295,4 +299,18 @@
assertNotNull(myFixture.getReferenceAtCaretPosition().resolve())
}
+
+ void testEnumConstructor() {
+ myFixture.configureByText('a.groovy', '''\
+enum Myenum {
+ a<caret>b(1, 2, 4)
+}
+''')
+
+ addGdsl('''
+contribute(currentType("Myenum")) {
+ constructor params:[foo:Integer, bar:Integer, goo:Integer]
+}''')
+ assertNotNull(myFixture.getReferenceAtCaretPosition().resolve())
+ }
}
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/inspections/GrFinalVariableAccessTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/inspections/GrFinalVariableAccessTest.groovy
index c75f741..564a794 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/inspections/GrFinalVariableAccessTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/inspections/GrFinalVariableAccessTest.groovy
@@ -485,4 +485,27 @@
}''')
}
+ void 'test Field And Parameter With The Same Name'() {
+ testHighlighting('''\
+class Aaa {
+ final int foo
+ final int bar
+
+ Aaa(int foo, int p) {
+ this.foo = foo // this assignment is erroneously reported as invalid
+ this.bar = p // this one is not reported
+ }
+}
+''')
+ }
+
+ void testEnumConstants() {
+ testHighlighting('''\
+enum E {
+ abc, cde
+
+ final int <warning descr="Variable 'x' might not have been initialized">x</warning>
+}
+''')
+ }
}
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/actions/generate/GroovyGenerateMembersTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/actions/generate/GroovyGenerateMembersTest.groovy
index ddd7f88..5a81b3d 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/actions/generate/GroovyGenerateMembersTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/actions/generate/GroovyGenerateMembersTest.groovy
@@ -223,7 +223,7 @@
class Test {
def foo
- void setFoo(def foo) {
+ void setFoo(foo) {
this.foo = foo
}
}'''
@@ -262,7 +262,7 @@
class Test {
static foo
- static void setFoo(def foo) {
+ static void setFoo(foo) {
Test.foo = foo
}
}'''
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/EnterActionTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/EnterActionTest.groovy
index eec5276..205feed 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/EnterActionTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/EnterActionTest.groovy
@@ -14,13 +14,11 @@
* limitations under the License.
*/
-package org.jetbrains.plugins.groovy.lang.formatter;
-
+package org.jetbrains.plugins.groovy.lang.formatter
import org.jetbrains.plugins.groovy.GroovyFileType
import org.jetbrains.plugins.groovy.codeStyle.GroovyCodeStyleSettings
import org.jetbrains.plugins.groovy.util.TestUtils
-
/**
* @author ilyas
*/
@@ -350,6 +348,9 @@
}
void testIndentAfterLabelColon() {
+ groovySettings.indentOptions.LABEL_INDENT_SIZE = 2
+ groovySettings.indentOptions.INDENT_SIZE = 2
+ groovyCustomSettings.INDENT_LABEL_BLOCKS = true
doTest('''
class A extends spock.lang.Specification {
def 'test'() {
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/FormatterTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/FormatterTest.groovy
index a7ec28a..ba19392 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/FormatterTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/FormatterTest.groovy
@@ -112,9 +112,9 @@
public void testAnnotationOnSeparateLine() throws Throwable { doTest(); }
public void testAlignMultipleVariables() throws Throwable { doTest(); }
- public void testSpockTable() throws Throwable {myFixture.addClass('package spock.lang; public class Specification{}'); doTest(); }
- public void testSpockTableComments() throws Throwable {myFixture.addClass('package spock.lang; public class Specification{}'); doTest(); }
- public void testSpockTableWithStringComment() throws Throwable {myFixture.addClass('package spock.lang; public class Specification{}'); doTest(); }
+ //public void testSpockTable() throws Throwable {myFixture.addClass('package spock.lang; public class Specification{}'); doTest(); }
+ //public void testSpockTableComments() throws Throwable {myFixture.addClass('package spock.lang; public class Specification{}'); doTest(); }
+ //public void testSpockTableWithStringComment() throws Throwable {myFixture.addClass('package spock.lang; public class Specification{}'); doTest(); }
public void testElseIfs() throws Throwable {
groovySettings.SPECIAL_ELSE_IF_TREATMENT = false;
@@ -712,24 +712,36 @@
}
void testLabelsInBasicMode() {
+ groovySettings.indentOptions.INDENT_SIZE = 4
+ groovySettings.indentOptions.LABEL_INDENT_SIZE = -2
groovyCustomSettings.INDENT_LABEL_BLOCKS = false
checkFormatting('''\
-abc:foo()
-bar()
+def bar() {
+ abc:
+ foo()
+ bar()
+}
''', '''\
-abc: foo()
-bar()
+def bar() {
+ abc:
+ foo()
+ bar()
+}
''')
}
void testLabels() {
checkFormatting('''\
+def foo() {
abc:foo()
bar()
+}
''', '''\
-abc: foo()
-bar()
+def foo() {
+ abc: foo()
+ bar()
+}
''')
}
@@ -745,6 +757,9 @@
''')
}
+ void testInKeyword() {
+ checkFormatting('foo in bar', 'foo in bar')
+ }
private void doGeeseTest() {
GroovyCodeStyleSettings customSettings = myTempSettings.getCustomSettings(GroovyCodeStyleSettings.class);
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GrAssignabilityTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GrAssignabilityTest.groovy
index 1678a75..d17efb3 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GrAssignabilityTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GrAssignabilityTest.groovy
@@ -15,6 +15,7 @@
*/
package org.jetbrains.plugins.groovy.lang.highlighting
+import com.intellij.codeInsight.intention.IntentionAction
import com.intellij.codeInspection.InspectionProfileEntry
import org.jetbrains.plugins.groovy.codeInspection.assignment.GroovyAssignabilityCheckInspection
import org.jetbrains.plugins.groovy.codeInspection.bugs.GroovyConstructorNamedArgumentsInspection
@@ -693,4 +694,84 @@
def <T extends PsiElement & I> T foo5(Class<T> x = Foo ) {}
''')
}
+
+ void testFixVariableType() {
+ testHighlighting('''\
+int <warning>x<caret>x</warning> = 'abc'
+''')
+
+
+ final IntentionAction intention = myFixture.findSingleIntention('Change variable')
+ myFixture.launchAction(intention)
+ myFixture.checkResult('''\
+String xx = 'abc'
+''')
+
+ }
+
+ void testFixVariableType2() {
+ testHighlighting('''\
+int xx = 5
+
+<warning>x<caret>x</warning> = 'abc'
+''')
+
+ final IntentionAction intention = myFixture.findSingleIntention('Change variable')
+ myFixture.launchAction(intention)
+ myFixture.checkResult('''\
+String xx = 5
+
+xx = 'abc'
+''')
+
+ }
+
+
+ void testInnerClassConstructor0() {
+ testHighlighting('''\
+class A {
+ class Inner {
+ def Inner() {}
+ }
+
+ def foo() {
+ new Inner() //correct
+ }
+
+ static def bar() {
+ new <error>Inner</error>() //semi-correct
+ new Inner(new A()) //correct
+ }
+}
+
+new A.Inner() //semi-correct
+new A.Inner(new A()) //correct
+''')
+ }
+
+ void testInnerClassConstructor1() {
+ testHighlighting('''\
+class A {
+ class Inner {
+ def Inner(A a) {}
+ }
+
+ def foo() {
+ new Inner(new A()) //correct
+ new Inner<warning>()</warning>
+ new Inner<warning>(new A(), new A())</warning>
+ }
+
+ static def bar() {
+ new Inner(new A(), new A()) //correct
+ new Inner<warning>(new A())</warning> //incorrect: first arg is recognized as an enclosing instance arg
+ }
+}
+
+new A.Inner<warning>()</warning> //incorrect
+new A.Inner<warning>(new A())</warning> //incorrect: first arg is recognized as an enclosing instance arg
+new A.Inner(new A(), new A()) //correct
+''')
+ }
+
}
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GroovyHighlightingTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GroovyHighlightingTest.groovy
index 0331e2e..4be88bf 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GroovyHighlightingTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GroovyHighlightingTest.groovy
@@ -788,8 +788,8 @@
class B {}
}
-A.B foo = new <error descr="Cannot reference non-static symbol 'A.B' from static context">A.B</error>()
-''')
+A.B foo = new A.<warning descr="Cannot reference non-static symbol 'A.B' from static context">B</warning>()
+''', GrUnresolvedAccessInspection)
}
void testDuplicatedVar0() {
@@ -1426,4 +1426,153 @@
}
''')
}
+
+ void testFinalParameter() {
+ testHighlighting('''\
+def foo0(final i) {
+ <error descr="Cannot assign a value to final parameter 'i'">i</error> = 5
+ print i
+}
+
+def foo1(i) {
+ i = 5
+ print i
+}
+
+def foo2(final i = 4) {
+ <error descr="Cannot assign a value to final parameter 'i'">i</error> = 5
+ print i
+}
+
+def foo3(final i) {
+ print i
+}
+''')
+ }
+
+ void testNonStaticInnerClass1() {
+ testHighlighting('''\
+class MyController {
+ static def list() {
+ def myInnerClass = new MyCommand.<error descr="Cannot reference non-static symbol 'MyCommand.MyInnerClass' from static context">MyInnerClass</error>()
+ print myInnerClass
+ }
+}
+
+class MyCommand {
+ class MyInnerClass {
+ }
+}
+''', GrUnresolvedAccessInspection)
+ }
+
+ void testNonStaticInnerClass2() {
+ testHighlighting('''\
+class MyController {
+ def list() {
+ def myInnerClass = new MyCommand.<warning descr="Cannot reference non-static symbol 'MyCommand.MyInnerClass' from static context">MyInnerClass</warning>()
+ print myInnerClass
+ }
+}
+
+class MyCommand {
+ class MyInnerClass {
+ }
+}
+''', GrUnresolvedAccessInspection)
+ }
+
+ void testNonStaticInnerClass3() {
+ myFixture.configureByText('_.groovy', '''\
+class MyController {
+ static def list() {
+ def myInnerClass = new MyCommand.<error descr="Cannot reference non-static symbol 'MyCommand.MyInnerClass' from static context">MyInnerClass</error>()
+ print myInnerClass
+ }
+}
+
+class MyCommand {
+ class MyInnerClass {
+ }
+}
+''')
+
+ myFixture.enableInspections(GrUnresolvedAccessInspection)
+
+ GrUnresolvedAccessInspection.getInstance(myFixture.file, myFixture.project).myHighlightInnerClasses = false
+ myFixture.testHighlighting(true, false, true)
+ }
+
+ void testNonStaticInnerClass4() {
+ myFixture.configureByText('_.groovy', '''\
+class MyController {
+ def list() {
+ def myInnerClass = new MyCommand.MyInnerClass()
+ print myInnerClass
+ }
+}
+
+class MyCommand {
+ class MyInnerClass {
+ }
+}
+''')
+
+ myFixture.enableInspections(GrUnresolvedAccessInspection)
+
+ GrUnresolvedAccessInspection.getInstance(myFixture.file, myFixture.project).myHighlightInnerClasses = false
+ myFixture.testHighlighting(true, false, true)
+ }
+
+ void testInnerClassWithStaticMethod() {
+ testHighlighting('''\
+class A {
+ class B {
+ static foo() {}
+
+ static bar() {
+ B.foo() //correct
+ }
+ }
+
+ static foo() {
+ new <error descr="Cannot reference non-static symbol 'A.B' from static context">B</error>()
+ }
+}
+''')
+ }
+
+ void testUnresolvedPropertyWhenGetPropertyDeclared() {
+ myFixture.enableInspections(GrUnresolvedAccessInspection)
+ myFixture.configureByText('_.groovy', '''\
+class DelegatesToTest {
+ void ideSupport() {
+ define {
+ a //delegatesTo provides getProperty from DslDelegate
+ }
+ }
+
+ private static void define(@DelegatesTo(DslDelegate) Closure dsl) {
+ }
+}
+
+class DslDelegate {
+ def getProperty(String name) {
+ {->print 1}
+ }
+
+
+ def ab() {
+ print a //getPropertyDeclared
+ <warning descr="Cannot resolve symbol 'a'">a</warning>() //unresolved
+ }
+}
+
+print new DslDelegate().foo //resolved
+print new DslDelegate().<warning descr="Cannot resolve symbol 'foo'">foo</warning>() //unresolved
+''')
+
+ GrUnresolvedAccessInspection.getInstance(myFixture.file, myFixture.project).myHighlightIfGroovyObjectOverridden = false
+ myFixture.testHighlighting(true, false, true)
+ }
}
\ No newline at end of file
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/parser/AnnotationsParsingTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/parser/AnnotationsParsingTest.groovy
index d0fbe70..c9a968f 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/parser/AnnotationsParsingTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/parser/AnnotationsParsingTest.groovy
@@ -34,4 +34,5 @@
public void testDefAttribute() {doTest()}
public void testLineFeedAfterRef() {doTest()}
public void testKeywordsAttributes() {doTest()}
+ public void testMess() { doTest() }
}
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolveMethodTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolveMethodTest.groovy
index 4cc96dc..8a15559 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolveMethodTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolveMethodTest.groovy
@@ -1593,4 +1593,58 @@
}
''', PsiMethod)
}
+
+ void testPreferCategoryMethods() {
+ def resolved = resolveByText('''
+class TimeCategory {
+ public static TimeDuration minus(final Date lhs, final Date rhs) {
+ return new TimeDuration()
+ }
+}
+
+class TimeDuration {}
+
+void bug() {
+ use (TimeCategory) {
+ def duration = new Date() - new Date()
+ print durat<caret>ion
+ }
+}
+''', GrVariable)
+
+ assertEquals("TimeDuration", resolved.typeGroovy.canonicalText)
+ }
+
+ void testPreferCategoryMethods2() {
+ def resolved = resolveByText('''
+class TimeCategory {
+ public static TimeDuration minus(final Date lhs, final Date rhs) {
+ return new TimeDuration((int) days, hours, minutes, seconds, (int) milliseconds);
+ }
+}
+
+class TimeDuration {}
+
+void bug() {
+ use (TimeCategory) {
+ def duration = new Date().minus(new Date())
+ print durat<caret>ion
+ }
+}
+''', GrVariable)
+
+ assertEquals("TimeDuration", resolved.typeGroovy.canonicalText)
+ }
+
+
+ void testNegatedIf() {
+ resolveByText('''\
+def foo(x) {
+ if (!(x instanceof String)) return
+
+ x.subst<caret>ring(1)
+}
+''', PsiMethod)
+
+ }
}
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/extract/method/ExtractMethodTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/extract/method/ExtractMethodTest.groovy
index a1a3335..cf167e0 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/extract/method/ExtractMethodTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/extract/method/ExtractMethodTest.groovy
@@ -182,4 +182,20 @@
}
''')
}
+
+ void testSingleExpressionAsReturnValue() {
+ doTest('''\
+int foo() {
+ <begin>1<end>
+}
+''', '''\
+int foo() {
+ testMethod()
+}
+
+private int testMethod() {
+ return 1
+}
+''')
+ }
}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/groovy/controlFlow/varInString.test b/plugins/groovy/testdata/groovy/controlFlow/varInString.test
index 70ab7dc..0a7fbd8 100644
--- a/plugins/groovy/testdata/groovy/controlFlow/varInString.test
+++ b/plugins/groovy/testdata/groovy/controlFlow/varInString.test
@@ -6,7 +6,7 @@
3(4,6) Condition Relational expression
4(5) instanceof: i in String
5(10) Negating goto instruction, condition=3Relational expression
-6(7,10) instanceof: i in String
+6(7) instanceof: i in String
7(8) READ i
8(9) WRITE i
9(10) element: Assignment expression MAYBE_RETURN
diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/argsUsedOnlyInAnonymousClass.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/argsUsedOnlyInAnonymousClass.test
index 0857daf..64a3ac5 100644
--- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/argsUsedOnlyInAnonymousClass.test
+++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/argsUsedOnlyInAnonymousClass.test
@@ -10,8 +10,8 @@
testMethod(b, c)
}
-private testMethod(b, c) {
- [].each(new Closure(this, this) {
+private ArrayList testMethod(b, c) {
+ return [].each(new Closure(this, this) {
void call() {
b.plus(c)
}
diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/argsUsedOnlyInClosure.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/argsUsedOnlyInClosure.test
index 7ff5598..76d9bc1 100644
--- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/argsUsedOnlyInClosure.test
+++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/argsUsedOnlyInClosure.test
@@ -8,8 +8,8 @@
testMethod(b, c)
}
-private testMethod(b, c) {
- [].each {
+private ArrayList testMethod(b, c) {
+ return [].each {
b.plus(c)
}
}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/closureIt.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/closureIt.test
index d612cce..3300933 100644
--- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/closureIt.test
+++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/closureIt.test
@@ -6,6 +6,6 @@
testMethod()
}
-private testMethod() {
- [].collect { it }
+private List testMethod() {
+ return [].collect { it }
}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/noContextConflicts.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/noContextConflicts.test
index 3175295..23964f5 100644
--- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/noContextConflicts.test
+++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/noContextConflicts.test
@@ -19,7 +19,7 @@
testMethod()
}
- private testMethod() {
+ private void testMethod() {
use(StringCategory) {
println "TeSt".lower()
}
diff --git a/plugins/groovy/testdata/groovy/refactoring/rename/closureIt.test b/plugins/groovy/testdata/groovy/refactoring/rename/closureIt.test
index 9069e1c..6dcd40b 100644
--- a/plugins/groovy/testdata/groovy/refactoring/rename/closureIt.test
+++ b/plugins/groovy/testdata/groovy/refactoring/rename/closureIt.test
@@ -2,6 +2,6 @@
<caret>it
}
-----
-def c = { def newName ->
+def c = { newName ->
newName
}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/highlighting/IncorrectEscaping.groovy b/plugins/groovy/testdata/highlighting/IncorrectEscaping.groovy
index bab3ad3..963d417 100644
--- a/plugins/groovy/testdata/highlighting/IncorrectEscaping.groovy
+++ b/plugins/groovy/testdata/highlighting/IncorrectEscaping.groovy
@@ -3,14 +3,14 @@
print <error descr="Illegal escape character in string literal">"\u000d"</error>
print <error descr="Illegal escape character in string literal">'\y'</error>
ptint <error descr="Illegal escape character in string literal">"\n\a\t"</error>
-print <error descr="Illegal escape character in string literal">"\n\a${x}\t"</error>
+print "<error descr="Illegal escape character in string literal">\n\a</error>${x}\t"
print "\n${x}\t"
print "\n${x}\"<EOLError descr="String end expected"></EOLError>
print "\n\"<EOLError descr="String end expected"></EOLError>
print '''\n'''
print <error descr="Illegal escape character in string literal">'''\y'''</error>
-print <error descr="Illegal escape character in string literal">"""\n\a${x}\t"""</error>
-ptint <error descr="Illegal escape character in string literal">"""""\n\a\t"""</error>
+print """<error descr="Illegal escape character in string literal">\n\a</error>${x}\t"""
+ptint """<error descr="Illegal escape character in string literal">""\n\a\t</error>"""
print """\n${x}\t"""
print "dfg\$fg"
print 'fg\$fg'
diff --git a/plugins/groovy/testdata/highlighting/NativeMapAssignability.groovy b/plugins/groovy/testdata/highlighting/NativeMapAssignability.groovy
index 194dfd1..1077a1e 100644
--- a/plugins/groovy/testdata/highlighting/NativeMapAssignability.groovy
+++ b/plugins/groovy/testdata/highlighting/NativeMapAssignability.groovy
@@ -2,4 +2,4 @@
foo(a:[b:'c'])
foo<warning descr="'foo' in 'NativeMapAssignability' cannot be applied to '(['a':java.lang.String])'">(a:'b')</warning>
-foo<warning descr="'foo' in 'NativeMapAssignability' cannot be applied to '(['a':java.util.Map<java.lang.Integer, java.lang.Integer>])'">(a:[(2):4])</warning>
\ No newline at end of file
+foo(a:[(2):4])
\ No newline at end of file
diff --git a/plugins/groovy/testdata/intentions/createParameterForField/FromConstructor_after.groovy b/plugins/groovy/testdata/intentions/createParameterForField/FromConstructor_after.groovy
index 31895d6..434027a 100644
--- a/plugins/groovy/testdata/intentions/createParameterForField/FromConstructor_after.groovy
+++ b/plugins/groovy/testdata/intentions/createParameterForField/FromConstructor_after.groovy
@@ -1,6 +1,6 @@
class Foo {
def foo
- def Foo(<caret>def foo) {
+ def Foo(<caret>foo) {
this.foo = foo
}
diff --git a/plugins/groovy/testdata/intentions/createParameterForField/FromField_after.groovy b/plugins/groovy/testdata/intentions/createParameterForField/FromField_after.groovy
index b6c76c8..371e509 100644
--- a/plugins/groovy/testdata/intentions/createParameterForField/FromField_after.groovy
+++ b/plugins/groovy/testdata/intentions/createParameterForField/FromField_after.groovy
@@ -1,7 +1,7 @@
class Foo {
def fo<caret>o
- def Foo(def foo) {
+ def Foo(foo) {
this.foo = foo
}
diff --git a/plugins/groovy/testdata/parsing/groovy/annotations/mess.test b/plugins/groovy/testdata/parsing/groovy/annotations/mess.test
new file mode 100644
index 0000000..7029eb4
--- /dev/null
+++ b/plugins/groovy/testdata/parsing/groovy/annotations/mess.test
@@ -0,0 +1,52 @@
+@A(x = '5', 'foo', , x=, , 5)
+def x
+-----
+Groovy script
+ Variable definitions
+ Modifiers
+ Annotation
+ PsiElement(@)('@')
+ Reference element
+ PsiElement(identifier)('A')
+ Annotation arguments
+ PsiElement(()('(')
+ Annotation member value pair
+ PsiElement(identifier)('x')
+ PsiWhiteSpace(' ')
+ PsiElement(=)('=')
+ PsiWhiteSpace(' ')
+ Literal
+ PsiElement(string)(''5'')
+ PsiElement(,)(',')
+ PsiWhiteSpace(' ')
+ Annotation member value pair
+ Literal
+ PsiElement(string)(''foo'')
+ PsiElement(,)(',')
+ PsiWhiteSpace(' ')
+ Annotation member value pair
+ PsiErrorElement:Annotation attribute expected
+ <empty list>
+ PsiElement(,)(',')
+ PsiWhiteSpace(' ')
+ Annotation member value pair
+ PsiElement(identifier)('x')
+ PsiElement(=)('=')
+ PsiErrorElement:Annotation member value initializer expected
+ <empty list>
+ PsiElement(,)(',')
+ PsiWhiteSpace(' ')
+ Annotation member value pair
+ PsiErrorElement:Annotation attribute expected
+ <empty list>
+ PsiElement(,)(',')
+ PsiWhiteSpace(' ')
+ Annotation member value pair
+ Literal
+ PsiElement(Integer)('5')
+ PsiElement())(')')
+ PsiElement(new line)('\n')
+ PsiElement(def)('def')
+ PsiWhiteSpace(' ')
+ Variable
+ PsiElement(identifier)('x')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/gravy-1653-2.test b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/gravy-1653-2.test
index 85e7c6f..e60aeeb 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/gravy-1653-2.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/gravy-1653-2.test
@@ -3,10 +3,12 @@
Groovy script
Compound regular expression
PsiElement(regex begin)('/')
- PsiElement(regex content)('aaaa ')
+ GrStringContentImpl(GString content element)
+ PsiElement(regex content)('aaaa ')
GString injection
PsiElement($)('$')
Reference expression
PsiElement(identifier)('str')
- PsiElement(regex content)('... bbb')
+ GrStringContentImpl(GString content element)
+ PsiElement(regex content)('... bbb')
PsiElement(regex end)('/')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/grvy-1653.test b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/grvy-1653.test
index 42bf51f..be0cc26 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/grvy-1653.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/grvy-1653.test
@@ -3,10 +3,12 @@
Groovy script
Compound Gstring
PsiElement(Gstring begin)('"')
- PsiElement(Gstring content)('aaaa ')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('aaaa ')
GString injection
PsiElement($)('$')
Reference expression
PsiElement(identifier)('str')
- PsiElement(Gstring content)('... bbb')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('... bbb')
PsiElement(Gstring end)('"')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/gstr3.test b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/gstr3.test
index 7a0ddec..331c83e 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/gstr3.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/gstr3.test
@@ -8,6 +8,7 @@
Command arguments
Compound Gstring
PsiElement(Gstring begin)('"""')
- PsiElement(Gstring content)(' preved " " 42')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)(' preved " " 42')
PsiErrorElement:String end expected
<empty list>
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/standTrooper.test b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/standTrooper.test
index afc99da..d84527f 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/standTrooper.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/standTrooper.test
@@ -21,21 +21,25 @@
PsiWhiteSpace(' ')
Compound Gstring
PsiElement(Gstring begin)('"""')
- PsiElement(Gstring content)('DELIMITER ')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('DELIMITER ')
GString injection
PsiElement($)('$')
PsiErrorElement:Identifier or code block expected
PsiElement($)('$')
- PsiElement(Gstring content)('\n\nDROP PROCEDURE IF EXISTS `gearloop`.`sp_CustomProductProfile_ins_upd`')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('\n\nDROP PROCEDURE IF EXISTS `gearloop`.`sp_CustomProductProfile_ins_upd`')
GString injection
PsiElement($)('$')
PsiErrorElement:Identifier or code block expected
PsiElement($)('$')
- PsiElement(Gstring content)('\n\nCREATE PROCEDURE `gearloop`.`sp_CustomProductProfile_ins_upd`()\n BEGIN\n\n END')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('\n\nCREATE PROCEDURE `gearloop`.`sp_CustomProductProfile_ins_upd`()\n BEGIN\n\n END')
GString injection
PsiElement($)('$')
PsiErrorElement:Identifier or code block expected
PsiElement($)('$')
- PsiElement(Gstring content)('\n\nDELIMITER ;')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('\n\nDELIMITER ;')
PsiElement(Gstring end)('"""')
PsiElement(;)(';')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str1.test b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str1.test
index 5174c90..2762d2c 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str1.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str1.test
@@ -3,7 +3,8 @@
Groovy script
Compound Gstring
PsiElement(Gstring begin)('"')
- PsiElement(Gstring content)('aaa ')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('aaa ')
GString injection
PsiElement($)('$')
Reference expression
@@ -14,7 +15,8 @@
PsiElement(identifier)('b')
PsiElement(.)('.')
PsiElement(identifier)('c')
- PsiElement(Gstring content)(' bbb ')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)(' bbb ')
GString injection
PsiElement($)('$')
Reference expression
@@ -25,5 +27,6 @@
PsiElement(identifier)('d')
PsiElement(.)('.')
PsiElement(identifier)('e')
- PsiElement(Gstring content)(' fff')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)(' fff')
PsiElement(Gstring end)('"')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str2.test b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str2.test
index 2acb08d..e4d7617 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str2.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str2.test
@@ -5,7 +5,8 @@
Groovy script
Compound Gstring
PsiElement(Gstring begin)('"""')
- PsiElement(Gstring content)('aaa ')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('aaa ')
GString injection
PsiElement($)('$')
Reference expression
@@ -16,7 +17,8 @@
PsiElement(identifier)('b')
PsiElement(.)('.')
PsiElement(identifier)('c')
- PsiElement(Gstring content)('\nbbb\n')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('\nbbb\n')
GString injection
PsiElement($)('$')
Reference expression
@@ -27,5 +29,6 @@
PsiElement(identifier)('d')
PsiElement(.)('.')
PsiElement(identifier)('e')
- PsiElement(Gstring content)(' fff')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)(' fff')
PsiElement(Gstring end)('"""')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str3.test b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str3.test
index ebb706d..56c66c0 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str3.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str3.test
@@ -3,10 +3,12 @@
Groovy script
Compound Gstring
PsiElement(Gstring begin)('"')
- PsiElement(Gstring content)('My ')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('My ')
GString injection
PsiElement($)('$')
Reference expression
PsiElement(identifier)('str')
- PsiElement(Gstring content)('. ing')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('. ing')
PsiElement(Gstring end)('"')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str4.test b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str4.test
index 1f99b01..3e74c13 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str4.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str4.test
@@ -5,12 +5,14 @@
Groovy script
Compound Gstring
PsiElement(Gstring begin)('"""')
- PsiElement(Gstring content)('My ')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('My ')
GString injection
PsiElement($)('$')
Reference expression
PsiElement(identifier)('string')
- PsiElement(Gstring content)('.'do' sometihng\n')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('.'do' sometihng\n')
PsiElement(Gstring end)('"""')
PsiElement(new line)('\n')
Additive expression
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str5.test b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str5.test
index 9df1ff5..a6d8a03 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str5.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str5.test
@@ -5,10 +5,12 @@
Groovy script
Compound Gstring
PsiElement(Gstring begin)('"""')
- PsiElement(Gstring content)('My\n')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('My\n')
GString injection
PsiElement($)('$')
Reference expression
PsiElement(identifier)('a')
- PsiElement(Gstring content)('.\nb.c string ')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('.\nb.c string ')
PsiElement(Gstring end)('"""')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str6.test b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str6.test
index e477a64..895c6cb 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str6.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str6.test
@@ -3,15 +3,18 @@
Groovy script
Compound Gstring
PsiElement(Gstring begin)('"')
- PsiElement(Gstring content)('My ')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('My ')
GString injection
PsiElement($)('$')
Reference expression
PsiElement(identifier)('aaa')
- PsiElement(Gstring content)(' your ')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)(' your ')
GString injection
PsiElement($)('$')
Reference expression
PsiElement(identifier)('bbb')
- PsiElement(Gstring content)(' string')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)(' string')
PsiElement(Gstring end)('"')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str7.test b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str7.test
index a78e190..0b391b7 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str7.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str7.test
@@ -7,5 +7,6 @@
PsiElement($)('$')
Reference expression
PsiElement(identifier)('Preved')
- PsiElement(Gstring content)(', medved!')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)(', medved!')
PsiElement(Gstring end)('"')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str8.test b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str8.test
index 549b852..5ab631c 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str8.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str8.test
@@ -4,7 +4,8 @@
Groovy script
Compound Gstring
PsiElement(Gstring begin)('"')
- PsiElement(Gstring content)('My ')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('My ')
GString injection
PsiElement($)('$')
Reference expression
@@ -13,12 +14,14 @@
PsiElement($)('$')
Reference expression
PsiElement(identifier)('ing')
- PsiElement(Gstring content)(' nax')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)(' nax')
PsiElement(Gstring end)('"')
PsiElement(new line)('\n')
Compound Gstring
PsiElement(Gstring begin)('"')
- PsiElement(Gstring content)('My ')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('My ')
GString injection
PsiElement($)('$')
Closable block
@@ -32,5 +35,6 @@
PsiElement($)('$')
Reference expression
PsiElement(identifier)('ing')
- PsiElement(Gstring content)(' nax')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)(' nax')
PsiElement(Gstring end)('"')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str_error3.test b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str_error3.test
index da3586c..66ac3f0 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str_error3.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str_error3.test
@@ -1,8 +1,9 @@
-"""""
-------
+"""""
+-----
Groovy script
Compound Gstring
PsiElement(Gstring begin)('"""')
- PsiElement(Gstring content)('"" ')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('""')
PsiErrorElement:String end expected
<empty list>
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str_error4.test b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str_error4.test
index 53fab59..9442e58 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str_error4.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str_error4.test
@@ -3,6 +3,7 @@
Groovy script
Compound Gstring
PsiElement(Gstring begin)('"""')
- PsiElement(Gstring content)('"')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('"')
PsiErrorElement:String end expected
- <empty list>
+ <empty list>
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str_error5.test b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str_error5.test
index fb11269..fa1b16f 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str_error5.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str_error5.test
@@ -3,6 +3,7 @@
Groovy script
Compound Gstring
PsiElement(Gstring begin)('"""')
- PsiElement(Gstring content)('abc\')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('abc\')
PsiErrorElement:String end expected
<empty list>
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str_error6.test b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str_error6.test
index 46c93ba..cd45df3 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str_error6.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str_error6.test
@@ -3,6 +3,7 @@
Groovy script
Compound Gstring
PsiElement(Gstring begin)('"""')
- PsiElement(Gstring content)(' abc \"""')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)(' abc \"""')
PsiErrorElement:String end expected
<empty list>
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str_error7.test b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str_error7.test
index bc55697..40af8de 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str_error7.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str_error7.test
@@ -3,6 +3,7 @@
Groovy script
Compound Gstring
PsiElement(Gstring begin)('"""')
- PsiElement(Gstring content)('a\')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('a\')
PsiErrorElement:String end expected
<empty list>
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str_error8.test b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str_error8.test
index 3106735..b7cf419 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str_error8.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/str_error8.test
@@ -3,6 +3,7 @@
Groovy script
Compound Gstring
PsiElement(Gstring begin)('"')
- PsiElement(Gstring content)('\')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('\')
PsiErrorElement:String end expected
<empty list>
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/triple/quote_and_slash.test b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/triple/quote_and_slash.test
index 1aef4d2..09e20db 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/triple/quote_and_slash.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/triple/quote_and_slash.test
@@ -3,7 +3,8 @@
Groovy script
Compound Gstring
PsiElement(Gstring begin)('"""')
- PsiElement(Gstring content)('"\\')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('"\\')
GString injection
PsiElement($)('$')
Closable block
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/triple/triple1.test b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/triple/triple1.test
index 931e394..142aa9a 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/triple/triple1.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/triple/triple1.test
@@ -3,10 +3,12 @@
Groovy script
Compound Gstring
PsiElement(Gstring begin)('"""')
- PsiElement(Gstring content)('preved "')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('preved "')
GString injection
PsiElement($)('$')
Reference expression
PsiElement(identifier)('ident')
- PsiElement(Gstring content)(' medved')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)(' medved')
PsiElement(Gstring end)('"""')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/triple/triple2.test b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/triple/triple2.test
index da1ecf7..5e68d4a 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/triple/triple2.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/triple/triple2.test
@@ -3,10 +3,12 @@
Groovy script
Compound Gstring
PsiElement(Gstring begin)('"""')
- PsiElement(Gstring content)('preved ""')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('preved ""')
GString injection
PsiElement($)('$')
Reference expression
PsiElement(identifier)('ident')
- PsiElement(Gstring content)(' medved')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)(' medved')
PsiElement(Gstring end)('"""')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/triple/triple3.test b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/triple/triple3.test
index 8be8c32..74ce06e 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/triple/triple3.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/triple/triple3.test
@@ -3,10 +3,12 @@
Groovy script
Compound Gstring
PsiElement(Gstring begin)('"""')
- PsiElement(Gstring content)('preved \"')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('preved \"')
GString injection
PsiElement($)('$')
Reference expression
PsiElement(identifier)('ident')
- PsiElement(Gstring content)(' medved')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)(' medved')
PsiElement(Gstring end)('"""')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/ugly_lexer.test b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/ugly_lexer.test
index 3b32579..46d1197 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/gstring/ugly_lexer.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/gstring/ugly_lexer.test
@@ -10,7 +10,8 @@
PsiWhiteSpace(' ')
Compound Gstring
PsiElement(Gstring begin)('"')
- PsiElement(Gstring content)('abcdef ')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('abcdef ')
GString injection
PsiElement($)('$')
Closable block
@@ -20,7 +21,8 @@
Literal
PsiElement(Integer)('42')
PsiElement(})('}')
- PsiElement(Gstring content)('\dfsd')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('\dfsd')
PsiErrorElement:String end expected
<empty list>
PsiElement(new line)('\n')
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/path/path4.test b/plugins/groovy/testdata/parsing/groovy/expressions/path/path4.test
index 3308bea..907d03a 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/path/path4.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/path/path4.test
@@ -15,10 +15,12 @@
PsiElement(*.)('*.')
Compound Gstring
PsiElement(Gstring begin)('"')
- PsiElement(Gstring content)('My ')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('My ')
GString injection
PsiElement($)('$')
PsiErrorElement:Identifier or code block expected
PsiElement(import)('import')
- PsiElement(Gstring content)('.bugaga aga')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('.bugaga aga')
PsiElement(Gstring end)('"')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/path/path5.test b/plugins/groovy/testdata/parsing/groovy/expressions/path/path5.test
index aea5cdd..ec4aaae 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/path/path5.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/path/path5.test
@@ -1,5 +1,5 @@
a.b.
-c*."My $import.bugaga aga
+c*."My $import.bugaga aga
-----
Groovy script
Property selection
@@ -15,11 +15,13 @@
PsiElement(*.)('*.')
Compound Gstring
PsiElement(Gstring begin)('"')
- PsiElement(Gstring content)('My ')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('My ')
GString injection
PsiElement($)('$')
PsiErrorElement:Identifier or code block expected
PsiElement(import)('import')
- PsiElement(Gstring content)('.bugaga aga ')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('.bugaga aga')
PsiErrorElement:String end expected
<empty list>
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/path/regexp.test b/plugins/groovy/testdata/parsing/groovy/expressions/path/regexp.test
index 39825cd..36e1029 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/path/regexp.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/path/regexp.test
@@ -36,7 +36,8 @@
PsiElement(.)('.')
Compound regular expression
PsiElement($/ regex begin)('$/')
- PsiElement($/ regex content)('df')
+ GrStringContentImpl(GString content element)
+ PsiElement($/ regex content)('df')
GString injection
PsiElement($)('$')
Reference expression
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/regex/dollarSlashy.test b/plugins/groovy/testdata/parsing/groovy/expressions/regex/dollarSlashy.test
index 39d6d43..76c3d7c 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/regex/dollarSlashy.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/regex/dollarSlashy.test
@@ -20,12 +20,14 @@
PsiWhiteSpace(' ')
Compound regular expression
PsiElement($/ regex begin)('$/')
- PsiElement($/ regex content)('\n Hello ')
+ GrStringContentImpl(GString content element)
+ PsiElement($/ regex content)('\n Hello ')
GString injection
PsiElement($)('$')
Reference expression
PsiElement(identifier)('name')
- PsiElement($/ regex content)(',\n today we're ')
+ GrStringContentImpl(GString content element)
+ PsiElement($/ regex content)(',\n today we're ')
GString injection
PsiElement($)('$')
Closable block
@@ -35,5 +37,6 @@
Reference expression
PsiElement(identifier)('date')
PsiElement(})('}')
- PsiElement($/ regex content)('\n $ dollar-sign\n $$ dollar-sign\n \ backslash\n / slash\n $/ slash\n')
+ GrStringContentImpl(GString content element)
+ PsiElement($/ regex content)('\n $ dollar-sign\n $$ dollar-sign\n \ backslash\n / slash\n $/ slash\n')
PsiElement($/ regex end)('/$')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/regex/dollarSlashy2.test b/plugins/groovy/testdata/parsing/groovy/expressions/regex/dollarSlashy2.test
index 0817ef5..9f97862 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/regex/dollarSlashy2.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/regex/dollarSlashy2.test
@@ -19,12 +19,14 @@
PsiWhiteSpace(' ')
Compound regular expression
PsiElement($/ regex begin)('$/')
- PsiElement($/ regex content)('\n Hello ')
+ GrStringContentImpl(GString content element)
+ PsiElement($/ regex content)('\n Hello ')
GString injection
PsiElement($)('$')
Reference expression
PsiElement(identifier)('name')
- PsiElement($/ regex content)(',\n today we're ')
+ GrStringContentImpl(GString content element)
+ PsiElement($/ regex content)(',\n today we're ')
GString injection
PsiElement($)('$')
Closable block
@@ -34,5 +36,6 @@
Reference expression
PsiElement(identifier)('date')
PsiElement(})('}')
- PsiElement($/ regex content)('\n $ dollar-sign\n $$ dollar-sign\n \ backslash\n / slash\n $/ slash')
+ GrStringContentImpl(GString content element)
+ PsiElement($/ regex content)('\n $ dollar-sign\n $$ dollar-sign\n \ backslash\n / slash\n $/ slash')
PsiElement($/ regex end)('/$')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/regex/dollarSlashyCode.test b/plugins/groovy/testdata/parsing/groovy/expressions/regex/dollarSlashyCode.test
index 444051f..d269062 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/regex/dollarSlashyCode.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/regex/dollarSlashyCode.test
@@ -18,10 +18,12 @@
PsiWhiteSpace(' ')
Compound regular expression
PsiElement($/ regex begin)('$/')
- PsiElement($/ regex content)('\n def normal = '\b\t\n\r'\n def slashy = /\b\t\n\r/\n assert '')
+ GrStringContentImpl(GString content element)
+ PsiElement($/ regex content)('\n def normal = '\b\t\n\r'\n def slashy = /\b\t\n\r/\n assert '')
GString injection
PsiElement($)('$')
Reference expression
PsiElement(identifier)('alphabet')
- PsiElement($/ regex content)(''.size() == 26\n assert normal.size() == 4\n assert slashy.size() == 8\n')
+ GrStringContentImpl(GString content element)
+ PsiElement($/ regex content)(''.size() == 26\n assert normal.size() == 4\n assert slashy.size() == 8\n')
PsiElement($/ regex end)('/$')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/regex/dollarSlashyCodeUnfinished.test b/plugins/groovy/testdata/parsing/groovy/expressions/regex/dollarSlashyCodeUnfinished.test
index 5ad34de..132eb1d 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/regex/dollarSlashyCodeUnfinished.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/regex/dollarSlashyCodeUnfinished.test
@@ -17,11 +17,13 @@
PsiWhiteSpace(' ')
Compound regular expression
PsiElement($/ regex begin)('$/')
- PsiElement($/ regex content)('\n def normal = '\b\t\n\r'\n def slashy = /\b\t\n\r/\n assert '')
+ GrStringContentImpl(GString content element)
+ PsiElement($/ regex content)('\n def normal = '\b\t\n\r'\n def slashy = /\b\t\n\r/\n assert '')
GString injection
PsiElement($)('$')
Reference expression
PsiElement(identifier)('alphabet')
- PsiElement($/ regex content)(''.size() == 26\n assert normal.size() == 4\n assert slashy.size() == 8')
+ GrStringContentImpl(GString content element)
+ PsiElement($/ regex content)(''.size() == 26\n assert normal.size() == 4\n assert slashy.size() == 8')
PsiErrorElement:Dollar slash ending expected
<empty list>
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/regex/dollarSlashyDouble.test b/plugins/groovy/testdata/parsing/groovy/expressions/regex/dollarSlashyDouble.test
index 2d9420c..83ce574 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/regex/dollarSlashyDouble.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/regex/dollarSlashyDouble.test
@@ -12,7 +12,8 @@
PsiWhiteSpace(' ')
Compound regular expression
PsiElement($/ regex begin)('$/')
- PsiElement($/ regex content)(' ')
+ GrStringContentImpl(GString content element)
+ PsiElement($/ regex content)(' ')
GString injection
PsiElement($)('$')
Closable block
@@ -25,7 +26,8 @@
PsiElement($/ regex content)(' a ')
PsiElement($/ regex end)('/$')
PsiElement(})('}')
- PsiElement($/ regex content)(' ')
+ GrStringContentImpl(GString content element)
+ PsiElement($/ regex content)(' ')
GString injection
PsiElement($)('$')
Closable block
@@ -38,5 +40,6 @@
PsiElement($/ regex content)(' b ')
PsiElement($/ regex end)('/$')
PsiElement(})('}')
- PsiElement($/ regex content)(' ')
+ GrStringContentImpl(GString content element)
+ PsiElement($/ regex content)(' ')
PsiElement($/ regex end)('/$')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/regex/dollarSlashyTriple.test b/plugins/groovy/testdata/parsing/groovy/expressions/regex/dollarSlashyTriple.test
index 7ead057..5debb90 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/regex/dollarSlashyTriple.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/regex/dollarSlashyTriple.test
@@ -12,7 +12,8 @@
PsiWhiteSpace(' ')
Compound regular expression
PsiElement($/ regex begin)('$/')
- PsiElement($/ regex content)(' ')
+ GrStringContentImpl(GString content element)
+ PsiElement($/ regex content)(' ')
GString injection
PsiElement($)('$')
Closable block
@@ -25,7 +26,8 @@
PsiElement($/ regex content)(' a ')
PsiElement($/ regex end)('/$')
PsiElement(})('}')
- PsiElement($/ regex content)(' ')
+ GrStringContentImpl(GString content element)
+ PsiElement($/ regex content)(' ')
GString injection
PsiElement($)('$')
Closable block
@@ -34,12 +36,14 @@
<empty list>
Compound regular expression
PsiElement($/ regex begin)('$/')
- PsiElement($/ regex content)(' ')
+ GrStringContentImpl(GString content element)
+ PsiElement($/ regex content)(' ')
GString injection
PsiElement($)('$')
Reference expression
PsiElement(identifier)('b')
- PsiElement($/ regex content)(' ')
+ GrStringContentImpl(GString content element)
+ PsiElement($/ regex content)(' ')
GString injection
PsiElement($)('$')
Closable block
@@ -52,8 +56,10 @@
PsiElement($/ regex content)(' c ')
PsiElement($/ regex end)('/$')
PsiElement(})('}')
- PsiElement($/ regex content)(' ')
+ GrStringContentImpl(GString content element)
+ PsiElement($/ regex content)(' ')
PsiElement($/ regex end)('/$')
PsiElement(})('}')
- PsiElement($/ regex content)(' ')
+ GrStringContentImpl(GString content element)
+ PsiElement($/ regex content)(' ')
PsiElement($/ regex end)('/$')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/regex/dollarSlashyUnfinished.test b/plugins/groovy/testdata/parsing/groovy/expressions/regex/dollarSlashyUnfinished.test
index c31a966..135b497 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/regex/dollarSlashyUnfinished.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/regex/dollarSlashyUnfinished.test
@@ -20,12 +20,14 @@
PsiWhiteSpace(' ')
Compound regular expression
PsiElement($/ regex begin)('$/')
- PsiElement($/ regex content)('\n Hello ')
+ GrStringContentImpl(GString content element)
+ PsiElement($/ regex content)('\n Hello ')
GString injection
PsiElement($)('$')
Reference expression
PsiElement(identifier)('name')
- PsiElement($/ regex content)(',\n today we're ')
+ GrStringContentImpl(GString content element)
+ PsiElement($/ regex content)(',\n today we're ')
GString injection
PsiElement($)('$')
Closable block
@@ -35,6 +37,7 @@
Reference expression
PsiElement(identifier)('date')
PsiElement(})('}')
- PsiElement($/ regex content)('\n $ dollar-sign\n $$ dollar-sign\n \ backslash\n / slash\n $/ slash\n/')
+ GrStringContentImpl(GString content element)
+ PsiElement($/ regex content)('\n $ dollar-sign\n $$ dollar-sign\n \ backslash\n / slash\n $/ slash\n/')
PsiErrorElement:Dollar slash ending expected
<empty list>
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/regex/dollarSlashyXml.test b/plugins/groovy/testdata/parsing/groovy/expressions/regex/dollarSlashyXml.test
index 5d058c2..d1b4e9b 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/regex/dollarSlashyXml.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/regex/dollarSlashyXml.test
@@ -16,10 +16,12 @@
PsiWhiteSpace(' ')
Compound regular expression
PsiElement($/ regex begin)('$/')
- PsiElement($/ regex content)('\n <xml>\n ')
+ GrStringContentImpl(GString content element)
+ PsiElement($/ regex content)('\n <xml>\n ')
GString injection
PsiElement($)('$')
Reference expression
PsiElement(identifier)('tic')
- PsiElement($/ regex content)('\tac\n </xml>\n')
+ GrStringContentImpl(GString content element)
+ PsiElement($/ regex content)('\tac\n </xml>\n')
PsiElement($/ regex end)('/$')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex10.test b/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex10.test
index 3178dea..d064705 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex10.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex10.test
@@ -9,7 +9,8 @@
PsiWhiteSpace(' ')
Compound regular expression
PsiElement(regex begin)('/')
- PsiElement(regex content)('abc \')
+ GrStringContentImpl(GString content element)
+ PsiElement(regex content)('abc \')
GString injection
PsiElement($)('$')
Closable block
@@ -22,7 +23,8 @@
PsiWhiteSpace(' ')
Compound Gstring
PsiElement(Gstring begin)('"')
- PsiElement(Gstring content)('def ')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('def ')
GString injection
PsiElement($)('$')
Closable block
@@ -38,12 +40,14 @@
PsiElement(})('}')
PsiElement(Gstring end)('"')
PsiElement(})('}')
- PsiElement(regex content)(' fgh')
+ GrStringContentImpl(GString content element)
+ PsiElement(regex content)(' fgh')
GString injection
PsiElement($)('$')
Reference expression
PsiElement(identifier)('st')
- PsiElement(regex content)(' ')
+ GrStringContentImpl(GString content element)
+ PsiElement(regex content)(' ')
GString injection
PsiElement($)('$')
Closable block
@@ -65,5 +69,6 @@
PsiElement(Integer)('5')
PsiElement())(')')
PsiElement(})('}')
- PsiElement(regex content)(' ')
+ GrStringContentImpl(GString content element)
+ PsiElement(regex content)(' ')
PsiElement(regex end)('/')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex14.test b/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex14.test
index f3cd6cc..9c11d88 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex14.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex14.test
@@ -12,7 +12,8 @@
PsiWhiteSpace(' ')
Compound regular expression
PsiElement(regex begin)('/')
- PsiElement(regex content)('asd ')
+ GrStringContentImpl(GString content element)
+ PsiElement(regex content)('asd ')
GString injection
PsiElement($)('$')
Closable block
@@ -25,6 +26,7 @@
PsiElement(regex content)('bugaga')
PsiElement(regex end)('/')
PsiElement(})('}')
- PsiElement(regex content)(' asd')
+ GrStringContentImpl(GString content element)
+ PsiElement(regex content)(' asd')
PsiElement(regex end)('/')
PsiElement())(')')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex16.test b/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex16.test
index f48806c..b05b726 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex16.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex16.test
@@ -1,9 +1,11 @@
/$
-----
Groovy script
- Literal
- GroovyASTPsiElementImpl(regex literal)
- PsiElement(regex begin)('/')
+ Compound regular expression
+ PsiElement(regex begin)('/')
+ GString injection
PsiElement($)('$')
- PsiErrorElement:Regex ending expected
- <empty list>
\ No newline at end of file
+ PsiErrorElement:Identifier or code block expected
+ <empty list>
+ PsiErrorElement:Regex ending expected
+ <empty list>
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex19.test b/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex19.test
index a26b41d..6a2eebf 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex19.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex19.test
@@ -3,7 +3,8 @@
Groovy script
Compound regular expression
PsiElement(regex begin)('/')
- PsiElement(regex content)('$')
+ GrStringContentImpl(GString content element)
+ PsiElement(regex content)('$')
GString injection
PsiElement($)('$')
Closable block
@@ -13,10 +14,12 @@
Literal
PsiElement(Integer)('5')
PsiElement(})('}')
- PsiElement(regex content)('$$$')
+ GrStringContentImpl(GString content element)
+ PsiElement(regex content)('$$$')
GString injection
PsiElement($)('$')
Reference expression
PsiElement(identifier)('ref')
- PsiElement(regex content)('$$$')
+ GrStringContentImpl(GString content element)
+ PsiElement(regex content)('$$$')
PsiElement(regex end)('/')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex20.test b/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex20.test
index bf293d8..e275546 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex20.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex20.test
@@ -9,7 +9,8 @@
PsiElement(()('(')
Compound regular expression
PsiElement(regex begin)('/')
- PsiElement(regex content)('a\')
+ GrStringContentImpl(GString content element)
+ PsiElement(regex content)('a\')
GString injection
PsiElement($)('$')
Closable block
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex7.test b/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex7.test
index 9141d84..bc1567b 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex7.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex7.test
@@ -8,7 +8,8 @@
PsiElement(.)('.')
Compound regular expression
PsiElement(regex begin)('/')
- PsiElement(regex content)('foo')
+ GrStringContentImpl(GString content element)
+ PsiElement(regex content)('foo')
GString injection
PsiElement($)('$')
Closable block
@@ -18,7 +19,8 @@
Reference expression
PsiElement(identifier)('st')
PsiElement(})('}')
- PsiElement(regex content)('d')
+ GrStringContentImpl(GString content element)
+ PsiElement(regex content)('d')
PsiElement(regex end)('/')
Arguments
PsiElement(()('(')
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex8.test b/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex8.test
index c53a01e..92c95df 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex8.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex8.test
@@ -9,7 +9,8 @@
PsiWhiteSpace(' ')
Compound regular expression
PsiElement(regex begin)('/')
- PsiElement(regex content)('abc ')
+ GrStringContentImpl(GString content element)
+ PsiElement(regex content)('abc ')
GString injection
PsiElement($)('$')
Closable block
@@ -23,7 +24,8 @@
Command arguments
Compound Gstring
PsiElement(Gstring begin)('"')
- PsiElement(Gstring content)('def ')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('def ')
GString injection
PsiElement($)('$')
Closable block
@@ -39,12 +41,14 @@
PsiElement(})('}')
PsiElement(Gstring end)('"')
PsiElement(})('}')
- PsiElement(regex content)(' fgh')
+ GrStringContentImpl(GString content element)
+ PsiElement(regex content)(' fgh')
GString injection
PsiElement($)('$')
Reference expression
PsiElement(identifier)('st')
- PsiElement(regex content)(' ')
+ GrStringContentImpl(GString content element)
+ PsiElement(regex content)(' ')
GString injection
PsiElement($)('$')
Closable block
@@ -66,5 +70,6 @@
PsiElement(Integer)('5')
PsiElement())(')')
PsiElement(})('}')
- PsiElement(regex content)(' ')
+ GrStringContentImpl(GString content element)
+ PsiElement(regex content)(' ')
PsiElement(regex end)('/')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex9.test b/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex9.test
index 524b555..94e1bb1 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex9.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex9.test
@@ -10,7 +10,8 @@
PsiWhiteSpace(' ')
Compound regular expression
PsiElement(regex begin)('/')
- PsiElement(regex content)('abc ')
+ GrStringContentImpl(GString content element)
+ PsiElement(regex content)('abc ')
GString injection
PsiElement($)('$')
Closable block
@@ -24,7 +25,8 @@
Command arguments
Compound Gstring
PsiElement(Gstring begin)('"')
- PsiElement(Gstring content)('def ')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('def ')
GString injection
PsiElement($)('$')
Closable block
@@ -40,12 +42,14 @@
PsiElement(})('}')
PsiElement(Gstring end)('"')
PsiElement(})('}')
- PsiElement(regex content)(' fgh')
+ GrStringContentImpl(GString content element)
+ PsiElement(regex content)(' fgh')
GString injection
PsiElement($)('$')
Reference expression
PsiElement(identifier)('st')
- PsiElement(regex content)(' ')
+ GrStringContentImpl(GString content element)
+ PsiElement(regex content)(' ')
GString injection
PsiElement($)('$')
Closable block
@@ -67,6 +71,7 @@
PsiElement(Integer)('5')
PsiElement())(')')
PsiElement(})('}')
- PsiElement(regex content)('\ni = 5')
+ GrStringContentImpl(GString content element)
+ PsiElement(regex content)('\ni = 5')
PsiErrorElement:Regex ending expected
<empty list>
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/special/map5.test b/plugins/groovy/testdata/parsing/groovy/expressions/special/map5.test
index 691380c..4846811 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/special/map5.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/special/map5.test
@@ -1,5 +1,5 @@
["$st aga":1, "$st nee"]
-------
+-----
Groovy script
Generalized list
PsiElement([)('[')
@@ -11,7 +11,8 @@
PsiElement($)('$')
Reference expression
PsiElement(identifier)('st')
- PsiElement(Gstring content)(' aga')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)(' aga')
PsiElement(Gstring end)('"')
PsiElement(:)(':')
Literal
@@ -24,6 +25,7 @@
PsiElement($)('$')
Reference expression
PsiElement(identifier)('st')
- PsiElement(Gstring content)(' nee')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)(' nee')
PsiElement(Gstring end)('"')
PsiElement(])(']')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/blocks/clos1.test b/plugins/groovy/testdata/parsing/groovy/statements/blocks/clos1.test
index 3c007bb..d83e23a 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/blocks/clos1.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/blocks/clos1.test
@@ -3,7 +3,8 @@
Groovy script
Compound Gstring
PsiElement(Gstring begin)('"')
- PsiElement(Gstring content)('Pre ')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('Pre ')
GString injection
PsiElement($)('$')
Closable block
@@ -33,5 +34,6 @@
Literal
PsiElement(Integer)('3')
PsiElement(})('}')
- PsiElement(Gstring content)(' ved')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)(' ved')
PsiElement(Gstring end)('"')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/blocks/clos2.test b/plugins/groovy/testdata/parsing/groovy/statements/blocks/clos2.test
index b61db57..368a8b2 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/blocks/clos2.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/blocks/clos2.test
@@ -6,7 +6,8 @@
Groovy script
Compound Gstring
PsiElement(Gstring begin)('"""')
- PsiElement(Gstring content)('Pre ')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('Pre ')
GString injection
PsiElement($)('$')
Closable block
@@ -35,5 +36,6 @@
Literal
PsiElement(Integer)('3')
PsiElement(})('}')
- PsiElement(Gstring content)('\n ved')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('\n ved')
PsiElement(Gstring end)('"""')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/blocks/clos3.test b/plugins/groovy/testdata/parsing/groovy/statements/blocks/clos3.test
index b21fd1c..35bc831 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/blocks/clos3.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/blocks/clos3.test
@@ -6,7 +6,8 @@
Groovy script
Compound Gstring
PsiElement(Gstring begin)('"""')
- PsiElement(Gstring content)('Pre ')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('Pre ')
GString injection
PsiElement($)('$')
Closable block
@@ -30,7 +31,8 @@
Command arguments
Compound Gstring
PsiElement(Gstring begin)('"')
- PsiElement(Gstring content)('bugaga')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('bugaga')
PsiErrorElement:String end expected
<empty list>
PsiElement(new line)('\n ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/blocks/clos4.test b/plugins/groovy/testdata/parsing/groovy/statements/blocks/clos4.test
index 039881e..a06614c 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/blocks/clos4.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/blocks/clos4.test
@@ -3,7 +3,8 @@
Groovy script
Compound Gstring
PsiElement(Gstring begin)('"')
- PsiElement(Gstring content)('Pre ')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('Pre ')
GString injection
PsiElement($)('$')
Closable block
@@ -32,5 +33,6 @@
PsiWhiteSpace(' ')
PsiElement(Integer)('3')
PsiElement(})('}')
- PsiElement(Gstring content)(' ved')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)(' ved')
PsiElement(Gstring end)('"')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/blocks/clos5.test b/plugins/groovy/testdata/parsing/groovy/statements/blocks/clos5.test
index daba752..2ad1b84 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/blocks/clos5.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/blocks/clos5.test
@@ -11,7 +11,8 @@
Command arguments
Compound Gstring
PsiElement(Gstring begin)('"""')
- PsiElement(Gstring content)('Pre')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('Pre')
GString injection
PsiElement($)('$')
Closable block
@@ -55,5 +56,6 @@
Literal
PsiElement(string)(''ved'')
PsiElement(})('}')
- PsiElement(Gstring content)('!')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)('!')
PsiElement(Gstring end)('"""')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/king_regex/king2.test b/plugins/groovy/testdata/parsing/groovy/statements/king_regex/king2.test
index daef5ab..2313589 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/king_regex/king2.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/king_regex/king2.test
@@ -3,10 +3,12 @@
Groovy script
Compound regular expression
PsiElement(regex begin)('/')
- PsiElement(regex content)('abcde $2 ')
+ GrStringContentImpl(GString content element)
+ PsiElement(regex content)('abcde $2 ')
GString injection
PsiElement($)('$')
Reference expression
PsiElement(identifier)('ident')
- PsiElement(regex content)(' asd')
+ GrStringContentImpl(GString content element)
+ PsiElement(regex content)(' asd')
PsiElement(regex end)('/')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/king_regex/king3.test b/plugins/groovy/testdata/parsing/groovy/statements/king_regex/king3.test
index 221f834..98b0df2 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/king_regex/king3.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/king_regex/king3.test
@@ -3,15 +3,18 @@
Groovy script
Compound regular expression
PsiElement(regex begin)('/')
- PsiElement(regex content)('abcde $2$$ ')
+ GrStringContentImpl(GString content element)
+ PsiElement(regex content)('abcde $2$$ ')
GString injection
PsiElement($)('$')
Reference expression
PsiElement(identifier)('ident')
- PsiElement(regex content)(' $$ ')
+ GrStringContentImpl(GString content element)
+ PsiElement(regex content)(' $$ ')
GString injection
PsiElement($)('$')
Reference expression
PsiElement(identifier)('ident2')
- PsiElement(regex content)(' asd')
+ GrStringContentImpl(GString content element)
+ PsiElement(regex content)(' asd')
PsiElement(regex end)('/')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/king_regex/king4.test b/plugins/groovy/testdata/parsing/groovy/statements/king_regex/king4.test
index bc8bad4..867ff2a 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/king_regex/king4.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/king_regex/king4.test
@@ -3,7 +3,8 @@
Groovy script
Compound regular expression
PsiElement(regex begin)('/')
- PsiElement(regex content)('abcde $2$$ ')
+ GrStringContentImpl(GString content element)
+ PsiElement(regex content)('abcde $2$$ ')
GString injection
PsiElement($)('$')
Closable block
@@ -12,18 +13,22 @@
<empty list>
Compound regular expression
PsiElement(regex begin)('/')
- PsiElement(regex content)('asdc $$ asdd ')
+ GrStringContentImpl(GString content element)
+ PsiElement(regex content)('asdc $$ asdd ')
GString injection
PsiElement($)('$')
Reference expression
PsiElement(identifier)('ident3')
- PsiElement(regex content)(' 123')
+ GrStringContentImpl(GString content element)
+ PsiElement(regex content)(' 123')
PsiElement(regex end)('/')
PsiElement(})('}')
- PsiElement(regex content)(' $$ ')
+ GrStringContentImpl(GString content element)
+ PsiElement(regex content)(' $$ ')
GString injection
PsiElement($)('$')
Reference expression
PsiElement(identifier)('ident2')
- PsiElement(regex content)(' asd')
+ GrStringContentImpl(GString content element)
+ PsiElement(regex content)(' asd')
PsiElement(regex end)('/')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/refactoring/changeSignature/ChangeJavaDoc_after.groovy b/plugins/groovy/testdata/refactoring/changeSignature/ChangeJavaDoc_after.groovy
index 9b13832..7afa358 100644
--- a/plugins/groovy/testdata/refactoring/changeSignature/ChangeJavaDoc_after.groovy
+++ b/plugins/groovy/testdata/refactoring/changeSignature/ChangeJavaDoc_after.groovy
@@ -4,6 +4,6 @@
* @return
*/
-def foo(def newName, def b) {
+def foo(newName, b) {
print newName + b
}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/refactoring/changeSignature/DefaultInitializerInJava_after.groovy b/plugins/groovy/testdata/refactoring/changeSignature/DefaultInitializerInJava_after.groovy
index 1af7c4e..0acb44a 100644
--- a/plugins/groovy/testdata/refactoring/changeSignature/DefaultInitializerInJava_after.groovy
+++ b/plugins/groovy/testdata/refactoring/changeSignature/DefaultInitializerInJava_after.groovy
@@ -14,5 +14,5 @@
* limitations under the License.
*/
class GClass {
- public void test(def p = 1) {}
+ public void test(p = 1) {}
}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/refactoring/changeSignature/LineFeedInCommandArgs_after.groovy b/plugins/groovy/testdata/refactoring/changeSignature/LineFeedInCommandArgs_after.groovy
index 0032f49..2bfae53 100644
--- a/plugins/groovy/testdata/refactoring/changeSignature/LineFeedInCommandArgs_after.groovy
+++ b/plugins/groovy/testdata/refactoring/changeSignature/LineFeedInCommandArgs_after.groovy
@@ -1,4 +1,4 @@
-def foo(def b) {
+def foo(b) {
print b
}
diff --git a/plugins/groovy/testdata/refactoring/introduceParameterInClosure/DontReplaceWithGetter_after.groovy b/plugins/groovy/testdata/refactoring/introduceParameterInClosure/DontReplaceWithGetter_after.groovy
index 331e16e..e008717 100644
--- a/plugins/groovy/testdata/refactoring/introduceParameterInClosure/DontReplaceWithGetter_after.groovy
+++ b/plugins/groovy/testdata/refactoring/introduceParameterInClosure/DontReplaceWithGetter_after.groovy
@@ -3,7 +3,7 @@
def getFoo(){foo}
- def bar = { final def anObject ->
+ def bar = { final anObject ->
print anObject
}
}
diff --git a/plugins/groovy/testdata/refactoring/introduceParameterInClosure/Field_after.groovy b/plugins/groovy/testdata/refactoring/introduceParameterInClosure/Field_after.groovy
index cd4b87c..7513c1f 100644
--- a/plugins/groovy/testdata/refactoring/introduceParameterInClosure/Field_after.groovy
+++ b/plugins/groovy/testdata/refactoring/introduceParameterInClosure/Field_after.groovy
@@ -1,6 +1,6 @@
class X {
def a
- public foo = { int x, final def anObject ->
+ public foo = { int x, final anObject ->
print x
print anObject
}
diff --git a/plugins/groovy/testdata/refactoring/introduceParameterInClosure/ReplaceGetterCall_after.groovy b/plugins/groovy/testdata/refactoring/introduceParameterInClosure/ReplaceGetterCall_after.groovy
index 6eda3ff..b7d7635 100644
--- a/plugins/groovy/testdata/refactoring/introduceParameterInClosure/ReplaceGetterCall_after.groovy
+++ b/plugins/groovy/testdata/refactoring/introduceParameterInClosure/ReplaceGetterCall_after.groovy
@@ -1,7 +1,7 @@
class X {
def foo
- def bar = { final def anObject ->
+ def bar = { final anObject ->
print anObject
}
}
diff --git a/plugins/groovy/testdata/refactoring/introduceParameterInClosure/ReplaceWithGetter_after.groovy b/plugins/groovy/testdata/refactoring/introduceParameterInClosure/ReplaceWithGetter_after.groovy
index cdbd4a1..b47f65d 100644
--- a/plugins/groovy/testdata/refactoring/introduceParameterInClosure/ReplaceWithGetter_after.groovy
+++ b/plugins/groovy/testdata/refactoring/introduceParameterInClosure/ReplaceWithGetter_after.groovy
@@ -1,7 +1,7 @@
class X {
def foo
- def bar = { final def anObject ->
+ def bar = { final anObject ->
print anObject
}
}
diff --git a/plugins/groovy/testdata/reparse/MultilineToNormalString.txt b/plugins/groovy/testdata/reparse/MultilineToNormalString.txt
index 23cf5f3..1307994 100644
--- a/plugins/groovy/testdata/reparse/MultilineToNormalString.txt
+++ b/plugins/groovy/testdata/reparse/MultilineToNormalString.txt
@@ -40,7 +40,8 @@
<empty list>
Compound Gstring
PsiElement(Gstring begin)('"')
- PsiElement(Gstring content)(')')
+ GrStringContentImpl(GString content element)
+ PsiElement(Gstring content)(')')
PsiErrorElement:String end expected
<empty list>
PsiElement(new line)('\n ')
diff --git a/plugins/hg4idea/src/META-INF/plugin.xml b/plugins/hg4idea/src/META-INF/plugin.xml
index 92efe81..7f1fccb 100644
--- a/plugins/hg4idea/src/META-INF/plugin.xml
+++ b/plugins/hg4idea/src/META-INF/plugin.xml
@@ -28,6 +28,9 @@
<interface-class>org.zmlx.hg4idea.HgRepositoryWatcher</interface-class>
<implementation-class>org.zmlx.hg4idea.HgRepositoryWatcher</implementation-class>
</component>
+ <component>
+ <implementation-class>org.zmlx.hg4idea.repo.HgRepositoryManager</implementation-class>
+ </component>
</project-components>
<actions>
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/HgPusher.java b/plugins/hg4idea/src/org/zmlx/hg4idea/HgPusher.java
index 1ddff9b..16f4ee3 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/HgPusher.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/HgPusher.java
@@ -26,7 +26,6 @@
import org.jetbrains.annotations.Nullable;
import org.zmlx.hg4idea.action.HgCommandResultNotifier;
import org.zmlx.hg4idea.command.HgPushCommand;
-import org.zmlx.hg4idea.command.HgShowConfigCommand;
import org.zmlx.hg4idea.command.HgTagBranch;
import org.zmlx.hg4idea.command.HgTagBranchCommand;
import org.zmlx.hg4idea.execution.HgCommandResult;
@@ -91,11 +90,6 @@
});
}
- public static String getDefaultPushPath(@NotNull Project project, @NotNull VirtualFile repo) {
- final HgShowConfigCommand configCommand = new HgShowConfigCommand(project);
- return configCommand.getDefaultPushPath(repo);
- }
-
@NotNull
public static List<HgTagBranch> getBranches(@NotNull Project project, @NotNull VirtualFile root) {
HgCommandResult branchesResult = new HgTagBranchCommand(project, root).collectBranches();
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgAbstractGlobalAction.java b/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgAbstractGlobalAction.java
index 930cae3..c8ab2c5 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgAbstractGlobalAction.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgAbstractGlobalAction.java
@@ -20,6 +20,7 @@
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
import com.intellij.openapi.vfs.VirtualFile;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.zmlx.hg4idea.HgVcs;
import org.zmlx.hg4idea.util.HgUtil;
@@ -62,9 +63,13 @@
protected abstract void execute(Project project, Collection<VirtualFile> repositories, @Nullable VirtualFile selectedRepo);
- public static void handleException(Project project, Exception e) {
+ public static void handleException(@Nullable Project project, @NotNull Exception e) {
+ handleException(project, "Error", e);
+ }
+
+ public static void handleException(@Nullable Project project, @NotNull String title, @NotNull Exception e) {
LOG.info(e);
- new HgCommandResultNotifier(project).notifyError(null, "Error", e.getMessage());
+ new HgCommandResultNotifier(project).notifyError(null, title, e.getMessage());
}
protected void markDirtyAndHandleErrors(Project project, VirtualFile repository) {
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgBranchPopup.java b/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgBranchPopup.java
index 87ba6f4..72603e2 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgBranchPopup.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgBranchPopup.java
@@ -33,6 +33,7 @@
import org.zmlx.hg4idea.util.HgUtil;
import javax.swing.*;
+import java.util.List;
/**
* <p>
@@ -93,20 +94,24 @@
private ActionGroup createActions() {
DefaultActionGroup popupGroup = new DefaultActionGroup(null, false);
-
fillPopupWithCurrentRepositoryActions(popupGroup, createRepositoriesActions());
-
popupGroup.addSeparator();
return popupGroup;
}
+ @Nullable
private DefaultActionGroup createRepositoriesActions() {
+ List<VirtualFile> repositories = HgUtil.getHgRepositories(myProject);
+ if (repositories.size() == 1) {
+ return null; // if project has only one repository all branches, bookmarks and actions should be inline and no repository group needed
+ }
DefaultActionGroup popupGroup = new DefaultActionGroup(null, false);
popupGroup.addSeparator("Repositories");
- for (VirtualFile repository : HgUtil.getHgRepositories(myProject)) {
- HgRepository repo = HgRepositoryImpl.getFullInstance(repository, myProject, myProject);
- popupGroup.add(new RootAction<HgRepository>(repo, null,
+ boolean isMultiRepoConfig = repositories.size() > 1;
+ for (VirtualFile repository : repositories) {
+ HgRepository repo = HgRepositoryImpl.getInstance(repository, myProject, myProject);
+ popupGroup.add(new RootAction<HgRepository>(repo, isMultiRepoConfig ? myCurrentRepository : null,
new HgBranchPopupActions(repo.getProject(), repo).createActions(null),
HgUtil.getDisplayableBranchText(repo),
repo.getCurrentBranch()));
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgBranchPopupActions.java b/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgBranchPopupActions.java
index 79c3ca3..3a981ac 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgBranchPopupActions.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgBranchPopupActions.java
@@ -15,6 +15,7 @@
*/
package org.zmlx.hg4idea.action;
+import com.intellij.dvcs.DvcsUtil;
import com.intellij.dvcs.ui.NewBranchAction;
import com.intellij.openapi.actionSystem.ActionGroup;
import com.intellij.openapi.actionSystem.AnAction;
@@ -24,10 +25,13 @@
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.update.UpdatedFiles;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.util.PlatformIcons;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.zmlx.hg4idea.HgRevisionNumber;
import org.zmlx.hg4idea.HgVcs;
+import org.zmlx.hg4idea.command.HgBookmarkCreateCommand;
import org.zmlx.hg4idea.command.HgBranchCreateCommand;
import org.zmlx.hg4idea.command.HgMergeCommand;
import org.zmlx.hg4idea.command.HgUpdateCommand;
@@ -37,6 +41,7 @@
import org.zmlx.hg4idea.provider.update.HgConflictResolver;
import org.zmlx.hg4idea.provider.update.HgHeadMerger;
import org.zmlx.hg4idea.repo.HgRepository;
+import org.zmlx.hg4idea.ui.HgBookmarkDialog;
import org.zmlx.hg4idea.util.HgErrorUtil;
import org.zmlx.hg4idea.util.HgUtil;
@@ -59,12 +64,25 @@
ActionGroup createActions(@Nullable DefaultActionGroup toInsert) {
DefaultActionGroup popupGroup = new DefaultActionGroup(null, false);
- popupGroup.addAction(new HgNewBranchAction(myProject, Collections.singletonList(myRepository)));
+ popupGroup.addAction(new HgNewBranchAction(myProject, Collections.singletonList(myRepository), myRepository.getRoot()));
+ popupGroup.addAction(new HgNewBookmarkAction(myProject, Collections.singletonList(myRepository), myRepository.getRoot()));
if (toInsert != null) {
popupGroup.addAll(toInsert);
}
+ popupGroup.addSeparator("Bookmarks");
+ List<String> bookmarks = new ArrayList<String>(myRepository.getBookmarks());
+ String currentBookmark = myRepository.getCurrentBookmark();
+ Collections.sort(bookmarks);
+ for (String bookmark : bookmarks) {
+ AnAction bookmarkAction = new BranchActions(myProject, bookmark, myRepository);
+ if (bookmark.equals(currentBookmark)) {
+ bookmarkAction.getTemplatePresentation().setIcon(PlatformIcons.CHECK_ICON);
+ }
+ popupGroup.add(bookmarkAction);
+ }
+
popupGroup.addSeparator("Branches");
List<String> branches = new ArrayList<String>(myRepository.getBranches());
Collections.sort(branches);
@@ -76,30 +94,81 @@
return popupGroup;
}
- public static class HgNewBranchAction extends NewBranchAction<HgRepository> {
+ private static class HgNewBranchAction extends NewBranchAction<HgRepository> {
+ @NotNull final VirtualFile myPreselectedRepo;
- HgNewBranchAction(@NotNull Project project, @NotNull List<HgRepository> repositories) {
+ HgNewBranchAction(@NotNull Project project, @NotNull List<HgRepository> repositories, @NotNull VirtualFile preselectedRepo) {
super(project, repositories);
+ myPreselectedRepo = preselectedRepo;
}
@Override
public void actionPerformed(AnActionEvent e) {
final String name = HgUtil.getNewBranchNameFromUser(myProject, "Create New Branch");
-
+ if (name == null) {
+ return;
+ }
try {
- new HgBranchCreateCommand(myProject, HgUtil.getRootForSelectedFile(myProject), name).execute(new HgCommandResultHandler() {
+ new HgBranchCreateCommand(myProject, myPreselectedRepo, name).execute(new HgCommandResultHandler() {
@Override
public void process(@Nullable HgCommandResult result) {
myProject.getMessageBus().syncPublisher(HgVcs.BRANCH_TOPIC).update(myProject, null);
if (HgErrorUtil.hasErrorsInCommandExecution(result)) {
new HgCommandResultNotifier(myProject)
- .notifyError(result, "Creation failed", "Branch creation [" + name + "] failed");
+ .notifyError(result, "Creation failed", "Branch creation [" + name + "] failed");
}
}
});
}
catch (HgCommandException exception) {
- HgAbstractGlobalAction.handleException(myProject, exception);
+ HgAbstractGlobalAction.handleException(myProject, "Can't create new branch: ", exception);
+ }
+ }
+ }
+
+ private static class HgNewBookmarkAction extends DumbAwareAction {
+ protected final List<HgRepository> myRepositories;
+ protected Project myProject;
+ @NotNull final VirtualFile myPreselectedRepo;
+
+ HgNewBookmarkAction(@NotNull Project project, @NotNull List<HgRepository> repositories, @NotNull VirtualFile preselectedRepo) {
+ super("New Bookmark", "Create new bookmark", null);
+ myProject = project;
+ myRepositories = repositories;
+ myPreselectedRepo = preselectedRepo;
+ }
+
+ @Override
+ public void update(AnActionEvent e) {
+ if (DvcsUtil.anyRepositoryIsFresh(myRepositories)) {
+ e.getPresentation().setEnabled(false);
+ e.getPresentation().setDescription("Bookmark creation is not possible before the first commit.");
+ }
+ }
+
+ @Override
+ public void actionPerformed(AnActionEvent e) {
+
+ final HgBookmarkDialog bookmarkDialog = new HgBookmarkDialog(myProject);
+ bookmarkDialog.show();
+ if (bookmarkDialog.isOK()) {
+ try {
+ final String name = bookmarkDialog.getName();
+ new HgBookmarkCreateCommand(myProject, myPreselectedRepo, name,
+ bookmarkDialog.isActive()).execute(new HgCommandResultHandler() {
+ @Override
+ public void process(@Nullable HgCommandResult result) {
+ myProject.getMessageBus().syncPublisher(HgVcs.BRANCH_TOPIC).update(myProject, null);
+ if (HgErrorUtil.hasErrorsInCommandExecution(result)) {
+ new HgCommandResultNotifier(myProject)
+ .notifyError(result, "Creation failed", "Bookmark creation [" + name + "] failed");
+ }
+ }
+ });
+ }
+ catch (HgCommandException exception) {
+ HgAbstractGlobalAction.handleException(myProject, exception);
+ }
}
}
}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgBranchesAction.java b/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgBranchesAction.java
index 0debdab..be0fc88 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgBranchesAction.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgBranchesAction.java
@@ -34,12 +34,12 @@
protected void execute(Project project, Collection<VirtualFile> repositories, @Nullable VirtualFile selectedRepo) {
HgRepository repository;
if (selectedRepo != null) {
- repository = HgRepositoryImpl.getFullInstance(selectedRepo, project, project);
+ repository = HgRepositoryImpl.getInstance(selectedRepo, project, project);
}
else {
VirtualFile selectedRoot = HgUtil.getRootForSelectedFile(project);
if (selectedRoot != null) {
- repository = HgRepositoryImpl.getFullInstance(selectedRoot, project, project);
+ repository = HgRepositoryImpl.getInstance(selectedRoot, project, project);
}
else {
return;
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgAnnotateCommand.java b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgAnnotateCommand.java
index 879c6f0..d15f4a5 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgAnnotateCommand.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgAnnotateCommand.java
@@ -12,8 +12,10 @@
// limitations under the License.
package org.zmlx.hg4idea.command;
+import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.history.VcsFileRevision;
+import com.intellij.util.text.DateFormatUtil;
import org.jetbrains.annotations.NotNull;
import org.zmlx.hg4idea.HgFile;
import org.zmlx.hg4idea.HgRevisionNumber;
@@ -21,6 +23,8 @@
import org.zmlx.hg4idea.execution.HgCommandResult;
import org.zmlx.hg4idea.provider.annotate.HgAnnotationLine;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -29,8 +33,9 @@
public class HgAnnotateCommand {
+ private static final Logger LOG = Logger.getInstance(HgAnnotateCommand.class);
private static final Pattern LINE_PATTERN = Pattern.compile(
- "\\s*(.+)\\s+([0-9]+)\\s+([0-9a-fA-F]+)\\s+([0-9]{4}-[0-9]{2}-[0-9]{2}):\\s*([0-9]+):\\s(.*)"
+ "\\s*(.+)\\s+([0-9]+)\\s+([0-9a-fA-F]+)\\s+([a-zA-Z]{3}\\s+[a-zA-Z]{3}\\s+[0-9]{2}\\s+.*[0-9]{4}.+):\\s*([0-9]+):\\s(.*)"
);
private static final int USER_GROUP = 1;
@@ -48,7 +53,7 @@
public List<HgAnnotationLine> execute(@NotNull HgFile hgFile, VcsFileRevision revision) {
final List<String> arguments = new ArrayList<String>();
- arguments.add("-cqnudl");
+ arguments.add("-cvnudl");
if (revision != null) {
arguments.add("-r");
HgRevisionNumber revisionNumber = (HgRevisionNumber)revision.getRevisionNumber();
@@ -72,7 +77,15 @@
if (matcher.matches()) {
String user = matcher.group(USER_GROUP);
HgRevisionNumber rev = HgRevisionNumber.getInstance(matcher.group(REVISION_GROUP), matcher.group(CHANGESET_GROUP));
- String date = matcher.group(DATE_GROUP);
+ String dateGroup = matcher.group(DATE_GROUP).trim();
+ SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss yyyy");
+ String date = "";
+ try {
+ date = DateFormatUtil.formatPrettyDate(dateFormat.parse(dateGroup));
+ }
+ catch (ParseException e) {
+ LOG.error("Couldn't parse annotation date ", e);
+ }
Integer lineNumber = Integer.valueOf(matcher.group(LINE_NUMBER_GROUP));
String content = matcher.group(CONTENT_GROUP);
HgAnnotationLine annotationLine = new HgAnnotationLine(
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgBookmarkCreateCommand.java b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgBookmarkCreateCommand.java
new file mode 100644
index 0000000..89442ef
--- /dev/null
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgBookmarkCreateCommand.java
@@ -0,0 +1,45 @@
+package org.zmlx.hg4idea.command;
+
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.openapi.vfs.VirtualFile;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.zmlx.hg4idea.execution.HgCommandException;
+import org.zmlx.hg4idea.execution.HgCommandExecutor;
+import org.zmlx.hg4idea.execution.HgCommandResultHandler;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Nadya Zabrodina
+ */
+public class HgBookmarkCreateCommand {
+ @NotNull private final Project myProject;
+ @NotNull private final VirtualFile myRepo;
+ @Nullable private final String myBookmarkName;
+ private final boolean isActive;
+
+ public HgBookmarkCreateCommand(@NotNull Project project,
+ @NotNull VirtualFile repo,
+ @Nullable String bookmarkName,
+ boolean active) {
+ myProject = project;
+ myRepo = repo;
+ myBookmarkName = bookmarkName;
+ isActive = active;
+ }
+
+ public void execute(@Nullable HgCommandResultHandler resultHandler) throws HgCommandException {
+ if (StringUtil.isEmptyOrSpaces(myBookmarkName)) {
+ throw new HgCommandException("bookmark name is empty");
+ }
+ List<String> arguments = new ArrayList<String>();
+ arguments.add(myBookmarkName);
+ if (!isActive) {
+ arguments.add("--inactive");
+ }
+ new HgCommandExecutor(myProject).execute(myRepo, "bookmark", arguments, resultHandler);
+ }
+}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgOutgoingCommand.java b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgOutgoingCommand.java
index cc045d2..64f1550 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgOutgoingCommand.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgOutgoingCommand.java
@@ -14,6 +14,8 @@
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
+import org.jetbrains.annotations.Nullable;
+import org.zmlx.hg4idea.util.HgUtil;
public class HgOutgoingCommand extends HgRemoteChangesetsCommand {
@@ -21,8 +23,8 @@
super(project, "outgoing");
}
- protected String getRepositoryUrl(VirtualFile repo) {
- return new HgShowConfigCommand(project).getDefaultPushPath(repo);
+ @Nullable
+ protected String getRepositoryUrl(VirtualFile root) {
+ return HgUtil.getRepositoryDefaultPushPath(project, root);
}
-
}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgRemoteChangesetsCommand.java b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgRemoteChangesetsCommand.java
index 118d23a..9767be4 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgRemoteChangesetsCommand.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgRemoteChangesetsCommand.java
@@ -22,12 +22,14 @@
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import org.zmlx.hg4idea.HgProjectSettings;
import org.zmlx.hg4idea.HgVcs;
import org.zmlx.hg4idea.action.HgCommandResultNotifier;
import org.zmlx.hg4idea.execution.HgCommandExecutor;
import org.zmlx.hg4idea.execution.HgCommandResult;
import org.zmlx.hg4idea.util.HgErrorUtil;
+import org.zmlx.hg4idea.util.HgUtil;
import javax.swing.event.HyperlinkEvent;
import java.util.List;
@@ -54,8 +56,9 @@
return true;
}
- protected String getRepositoryUrl(VirtualFile repo) {
- return new HgShowConfigCommand(project).getDefaultPath(repo);
+ @Nullable
+ protected String getRepositoryUrl(VirtualFile root) {
+ return HgUtil.getRepositoryDefaultPath(project, root);
}
@Override
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgShowConfigCommand.java b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgShowConfigCommand.java
index 06ac78b..aefca77 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgShowConfigCommand.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgShowConfigCommand.java
@@ -15,6 +15,8 @@
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import org.zmlx.hg4idea.execution.HgCommandExecutor;
import org.zmlx.hg4idea.execution.HgCommandResult;
@@ -25,26 +27,14 @@
public class HgShowConfigCommand {
- private final Project project;
+ @NotNull private final Project project;
- public HgShowConfigCommand(Project project) {
+ public HgShowConfigCommand(@NotNull Project project) {
this.project = project;
}
- public String getDefaultPath(VirtualFile repo) {
- return execute(repo).get("paths.default");
- }
-
- public String getDefaultPushPath(VirtualFile repo) {
- final Map<String, String> map = execute(repo);
- String path = map.get("paths.default-push");
- if (path == null) {
- path = map.get("paths.default");
- }
- return path;
- }
-
- public Map<String, String> execute(VirtualFile repo) {
+ @NotNull
+ public Map<String, Map<String, String>> execute(@Nullable VirtualFile repo) {
if (repo == null) {
return Collections.emptyMap();
}
@@ -57,14 +47,28 @@
return Collections.emptyMap();
}
- Map<String, String> options = new HashMap<String, String>();
+ Map<String, Map<String, String>> configMap = new HashMap<String, Map<String, String>>();
for (String line : result.getOutputLines()) {
List<String> option = StringUtil.split(line, "=", true, false);
if (option.size() == 2) {
- options.put(option.get(0).trim(), option.get(1).trim());
+ String sectionAndName = option.get(0).trim();
+ String value = option.get(1).trim();
+ int dotIndex = sectionAndName.indexOf('.');
+
+ if (dotIndex > 0) {
+ String sectionName = sectionAndName.substring(0, dotIndex);
+ String optionName = sectionAndName.substring(dotIndex + 1, sectionAndName.length());
+ if (configMap.containsKey(sectionName)) {
+ configMap.get(sectionName).put(optionName, value);
+ }
+ else {
+ HashMap<String, String> sectionMap = new HashMap<String, String>();
+ sectionMap.put(optionName, value);
+ configMap.put(sectionName, sectionMap);
+ }
+ }
}
}
- return options;
+ return configMap;
}
-
}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/HgHistoryProvider.java b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/HgHistoryProvider.java
index aff7041..bd21e74 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/HgHistoryProvider.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/HgHistoryProvider.java
@@ -112,7 +112,10 @@
int limit = vcsConfiguration.LIMIT_HISTORY ? vcsConfiguration.MAXIMUM_HISTORY_ROWS : -1;
final HgLogCommand logCommand = new HgLogCommand(project);
- logCommand.setFollowCopies(!filePath.isDirectory());
+ //workaround: --follow options doesn't work with largefiles extension;
+ //see http://selenic.com/pipermail/mercurial-devel/2013-May/051209.html
+ logCommand
+ .setFollowCopies(!filePath.isDirectory() && HgUtil.getConfig(project, vcsRoot, "extensions", "largefiles") == null);
logCommand.setIncludeRemoved(true);
try {
return logCommand.execute(new HgFile(vcsRoot, filePath), limit, false);
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/HgQuickListProvider.java b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/HgQuickListProvider.java
index 94b9601..5c8e6e7 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/HgQuickListProvider.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/HgQuickListProvider.java
@@ -44,6 +44,7 @@
actions.add(new Separator(activeVcs.getDisplayName()));
actions.add(new Separator());
+ add("hg4idea.branches", manager, actions);
add("hg4idea.pull", manager, actions);
add("hg4idea.push", manager, actions);
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/annotate/HgAnnotation.java b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/annotate/HgAnnotation.java
index fafe7ff..a3c79cf 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/annotate/HgAnnotation.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/annotate/HgAnnotation.java
@@ -41,7 +41,7 @@
private static final Logger LOG = Logger.getInstance(HgAnnotation.class.getName());
- enum FIELD {
+ public enum FIELD {
USER, REVISION, DATE, LINE, CONTENT
}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/update/HgRegularUpdater.java b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/update/HgRegularUpdater.java
index e44b388..6cf3bca 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/update/HgRegularUpdater.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/update/HgRegularUpdater.java
@@ -26,6 +26,7 @@
import org.zmlx.hg4idea.command.*;
import org.zmlx.hg4idea.execution.HgCommandException;
import org.zmlx.hg4idea.execution.HgCommandResult;
+import org.zmlx.hg4idea.util.HgUtil;
import java.util.ArrayList;
import java.util.List;
@@ -36,13 +37,13 @@
public class HgRegularUpdater implements HgUpdater {
private final Project project;
- @NotNull private final VirtualFile repository;
+ @NotNull private final VirtualFile repoRoot;
@NotNull private final UpdateConfiguration updateConfiguration;
private static final Logger LOG = Logger.getInstance(HgRegularUpdater.class);
public HgRegularUpdater(Project project, @NotNull VirtualFile repository, @NotNull UpdateConfiguration configuration) {
this.project = project;
- this.repository = repository;
+ this.repoRoot = repository;
this.updateConfiguration = configuration;
}
@@ -64,20 +65,19 @@
public boolean update(final UpdatedFiles updatedFiles, ProgressIndicator indicator, List<VcsException> warnings)
throws VcsException {
- indicator.setText(HgVcsMessages.message("hg4idea.progress.updating", repository.getPath()));
+ indicator.setText(HgVcsMessages.message("hg4idea.progress.updating", repoRoot.getPath()));
- HgShowConfigCommand configCommand = new HgShowConfigCommand(project);
- String defaultPath = configCommand.getDefaultPath(repository);
+ String defaultPath = HgUtil.getRepositoryDefaultPath(project, repoRoot);
if (StringUtil.isEmptyOrSpaces(defaultPath)) {
- throw new VcsException(HgVcsMessages.message("hg4idea.warning.no-default-update-path", repository.getPath()));
+ throw new VcsException(HgVcsMessages.message("hg4idea.warning.no-default-update-path", repoRoot.getPath()));
}
- List<HgRevisionNumber> branchHeadsBeforePull = new HgHeadsCommand(project, repository).execute();
+ List<HgRevisionNumber> branchHeadsBeforePull = new HgHeadsCommand(project, repoRoot).execute();
if (branchHeadsBeforePull.size() > 1) {
- reportWarning(warnings, HgVcsMessages.message("hg4idea.update.warning.multipleHeadsBeforeUpdate", repository.getPath()));
+ reportWarning(warnings, HgVcsMessages.message("hg4idea.update.warning.multipleHeadsBeforeUpdate", repoRoot.getPath()));
}
//TODO perhaps report a warning in this case ?
@@ -89,7 +89,7 @@
// }
if (shouldPull()) {
- boolean pullResult = pull(repository, indicator);
+ boolean pullResult = pull(repoRoot, indicator);
if (!pullResult) {
return false;
}
@@ -97,14 +97,14 @@
if (shouldUpdate()) {
- List<HgRevisionNumber> parentsBeforeUpdate = new HgWorkingCopyRevisionsCommand(project).parents(repository);
+ List<HgRevisionNumber> parentsBeforeUpdate = new HgWorkingCopyRevisionsCommand(project).parents(repoRoot);
if (parentsBeforeUpdate.size() > 1) {
- throw new VcsException(HgVcsMessages.message("hg4idea.update.error.uncommittedMerge", repository.getPath()));
+ throw new VcsException(HgVcsMessages.message("hg4idea.update.error.uncommittedMerge", repoRoot.getPath()));
}
indicator.setText2(HgVcsMessages.message("hg4idea.progress.countingHeads"));
- List<HgRevisionNumber> branchHeadsAfterPull = new HgHeadsCommand(project, repository).execute();
+ List<HgRevisionNumber> branchHeadsAfterPull = new HgHeadsCommand(project, repoRoot).execute();
List<HgRevisionNumber> pulledBranchHeads = determinePulledBranchHeads(branchHeadsBeforePull, branchHeadsAfterPull);
List<HgRevisionNumber> remainingOriginalBranchHeads = determingRemainingOriginalBranchHeads(branchHeadsBeforePull, branchHeadsAfterPull);
@@ -113,14 +113,14 @@
abortOnMultiplePulledHeads(pulledBranchHeads);
abortOnMultipleLocalHeads(remainingOriginalBranchHeads);
- HgCommandResult mergeResult = doMerge(updatedFiles, indicator, warnings, pulledBranchHeads.get(0));
+ HgCommandResult mergeResult = doMerge(updatedFiles, indicator, pulledBranchHeads.get(0));
if (shouldCommitAfterMerge()) {
commitOrWarnAboutConflicts(warnings, mergeResult);
}
} else {
//in case of multiple heads the update will report the appropriate error
- update(repository, indicator, updatedFiles, warnings);
+ update(repoRoot, indicator, updatedFiles, warnings);
}
//any kind of update could have resulted in merges and merge conflicts, so run the resolver
@@ -129,7 +129,8 @@
return true;
}
- private List<HgRevisionNumber> determingRemainingOriginalBranchHeads(List<HgRevisionNumber> branchHeadsBeforePull, List<HgRevisionNumber> branchHeadsAfterPull) {
+ private static List<HgRevisionNumber> determingRemainingOriginalBranchHeads(List<HgRevisionNumber> branchHeadsBeforePull,
+ List<HgRevisionNumber> branchHeadsAfterPull) {
List<HgRevisionNumber> originalBranchHeadsRemaining = new ArrayList<HgRevisionNumber>();
for (HgRevisionNumber headAfterPull : branchHeadsAfterPull) {
if (branchHeadsBeforePull.contains(headAfterPull)) {
@@ -139,7 +140,8 @@
return originalBranchHeadsRemaining;
}
- private List<HgRevisionNumber> determinePulledBranchHeads(List<HgRevisionNumber> branchHeadsBeforePull, List<HgRevisionNumber> branchHeadsAfterPull) {
+ private static List<HgRevisionNumber> determinePulledBranchHeads(List<HgRevisionNumber> branchHeadsBeforePull,
+ List<HgRevisionNumber> branchHeadsAfterPull) {
List<HgRevisionNumber> pulledBranchHeads = new ArrayList<HgRevisionNumber>(branchHeadsAfterPull);
pulledBranchHeads.removeAll(branchHeadsBeforePull);
return pulledBranchHeads;
@@ -147,20 +149,21 @@
private void abortOnMultipleLocalHeads(List<HgRevisionNumber> originalBranchHeadsRemaining) throws VcsException {
if (originalBranchHeadsRemaining.size() != 1) {
- throw new VcsException(HgVcsMessages.message("hg4idea.update.error.merge.multipleLocalHeads", repository.getPath()));
+ throw new VcsException(HgVcsMessages.message("hg4idea.update.error.merge.multipleLocalHeads", repoRoot.getPath()));
}
}
private void abortOnMultiplePulledHeads(List<HgRevisionNumber> newBranchHeadsAfterPull) throws VcsException {
if (newBranchHeadsAfterPull.size() != 1) {
- throw new VcsException(HgVcsMessages.message("hg4idea.update.error.merge.multipleRemoteHeads", newBranchHeadsAfterPull.size(), repository.getPath()));
+ throw new VcsException(HgVcsMessages.message("hg4idea.update.error.merge.multipleRemoteHeads", newBranchHeadsAfterPull.size(),
+ repoRoot.getPath()));
}
}
private void updateToPulledHead(VirtualFile repo, UpdatedFiles updatedFiles, HgRevisionNumber newHead, ProgressIndicator indicator) {
indicator.setText2(HgVcsMessages.message("hg4idea.update.progress.updating.to.pulled.head"));
HgRevisionNumber parentBeforeUpdate = new HgWorkingCopyRevisionsCommand(project).firstParent(repo);
- HgUpdateCommand updateCommand = new HgUpdateCommand(project, repository);
+ HgUpdateCommand updateCommand = new HgUpdateCommand(project, repoRoot);
updateCommand.setRevision(newHead.getChangeset());
updateCommand.setClean(true);
updateCommand.execute();
@@ -171,12 +174,12 @@
private @Nullable HgRevisionNumber findCommonParent(HgRevisionNumber newHead, HgRevisionNumber parentBeforeUpdate) {
// hg log -r 0:source --prune dest --limit 1
- final List<HgRevisionNumber> pulledRevisions = new HgMergePreviewCommand(project, newHead, parentBeforeUpdate, 1).execute(repository);
+ final List<HgRevisionNumber> pulledRevisions = new HgMergePreviewCommand(project, newHead, parentBeforeUpdate, 1).execute(repoRoot);
if (pulledRevisions == null || pulledRevisions.isEmpty()) {
return null;
}
HgRevisionNumber pulledRevision = pulledRevisions.get(0);
- final List<HgRevisionNumber> parentRevisions = new HgWorkingCopyRevisionsCommand(project).getRevisions(repository, "parent", null, pulledRevision, true);
+ final List<HgRevisionNumber> parentRevisions = new HgWorkingCopyRevisionsCommand(project).getRevisions(repoRoot, "parent", null, pulledRevision, true);
if (parentRevisions.isEmpty()) {
return null;
}
@@ -186,45 +189,46 @@
private void commitOrWarnAboutConflicts(List<VcsException> exceptions, HgCommandResult mergeResult) throws VcsException {
if (mergeResult.getExitValue() == 0) { //operation successful and no conflicts
try {
- new HgCommitCommand(project, repository, "Automated merge").execute();
+ new HgCommitCommand(project, repoRoot, "Automated merge").execute();
} catch (HgCommandException e) {
throw new VcsException(e);
}
} else {
- reportWarning(exceptions, HgVcsMessages.message("hg4idea.update.warning.merge.conflicts", repository.getPath()));
+ reportWarning(exceptions, HgVcsMessages.message("hg4idea.update.warning.merge.conflicts", repoRoot.getPath()));
}
}
- private HgCommandResult doMerge(UpdatedFiles updatedFiles, ProgressIndicator indicator, List<VcsException> exceptions, HgRevisionNumber headToMerge) throws VcsException {
+ private HgCommandResult doMerge(UpdatedFiles updatedFiles,
+ ProgressIndicator indicator,
+ HgRevisionNumber headToMerge) throws VcsException {
indicator.setText2(HgVcsMessages.message("hg4idea.update.progress.merging"));
- HgMergeCommand mergeCommand = new HgMergeCommand(project, repository);
+ HgMergeCommand mergeCommand = new HgMergeCommand(project, repoRoot);
//do not explicitly set the revision, that way mercurial itself checks that there are exactly
//two heads in this branch
// mergeCommand.setRevision(headToMerge.getRevision());
- HgCommandResult mergeResult = new HgHeadMerger(project, mergeCommand).merge(repository, updatedFiles, headToMerge);
- return mergeResult;
+ return new HgHeadMerger(project, mergeCommand).merge(repoRoot, updatedFiles, headToMerge);
}
private void abortOnLocalChanges() throws VcsException {
if (getLocalChanges().size() != 0) {
- throw new VcsException(HgVcsMessages.message("hg4idea.update.error.localchanges", repository.getPath()));
+ throw new VcsException(HgVcsMessages.message("hg4idea.update.error.localchanges", repoRoot.getPath()));
}
}
private void resolvePossibleConflicts(final UpdatedFiles updatedFiles) {
- new HgConflictResolver(project, updatedFiles).resolve(repository);
+ new HgConflictResolver(project, updatedFiles).resolve(repoRoot);
}
private Set<HgChange> getLocalChanges() {
HgStatusCommand statusCommand = new HgStatusCommand.Builder(true).unknown(false).ignored(false).build(project);
- return statusCommand.execute(repository);
+ return statusCommand.execute(repoRoot);
}
private boolean pull(VirtualFile repo, ProgressIndicator indicator)
throws VcsException {
indicator.setText2(HgVcsMessages.message("hg4idea.progress.pull.with.update"));
HgPullCommand hgPullCommand = new HgPullCommand(project, repo);
- final String defaultPath = new HgShowConfigCommand(project).getDefaultPath(repo);
+ final String defaultPath = HgUtil.getRepositoryDefaultPath(project, repo);
hgPullCommand.setSource(defaultPath);
hgPullCommand.setUpdate(false);
hgPullCommand.setRebase(false);
@@ -244,13 +248,13 @@
addUpdatedFiles(repo, updatedFiles, parentBeforeUpdate, parentAfterUpdate);
}
- private void handlePossibleWarning(List<VcsException> exceptions, String possibleWarning) {
+ private static void handlePossibleWarning(List<VcsException> exceptions, String possibleWarning) {
if (!StringUtil.isEmptyOrSpaces(possibleWarning)) {
reportWarning(exceptions, possibleWarning);
}
}
- private void reportWarning(List<VcsException> exceptions, String warningMessage) {
+ private static void reportWarning(List<VcsException> exceptions, String warningMessage) {
@SuppressWarnings({"ThrowableInstanceNeverThrown"})
VcsException warningException = new VcsException(warningMessage);
warningException.setIsWarning(true);
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgConfig.java b/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgConfig.java
new file mode 100644
index 0000000..9396d6b
--- /dev/null
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgConfig.java
@@ -0,0 +1,57 @@
+package org.zmlx.hg4idea.repo;
+
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.openapi.vfs.VirtualFile;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.zmlx.hg4idea.command.HgShowConfigCommand;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+
+/**
+ * @author Nadya Zabrodina
+ */
+public class HgConfig {
+
+ @NotNull private final Map<String, Map<String, String>> myConfigMap;
+
+ public static HgConfig getInstance(Project project, VirtualFile root) {
+ return new HgConfig(project, root);
+ }
+
+ private HgConfig(@NotNull Project project, @NotNull VirtualFile repo) {
+ // todo: may be should change showconfigCommand to parse hgrc file
+ // but default values for extension and repository root are not included in hgrc, so perform showconfig is better
+ // in windows configuration Mercurial.ini file may be used instead of hgrc
+ myConfigMap = new HgShowConfigCommand(project).execute(repo);
+ }
+
+ @Nullable
+ public String getDefaultPath() {
+ return getNamedConfig("paths", "default");
+ }
+
+ @Nullable
+ public String getDefaultPushPath() {
+ String path = getNamedConfig("paths", "default-push");
+ return path != null ? path : getNamedConfig("paths", "default");
+ }
+
+ @Nullable
+ public String getNamedConfig(@NotNull String sectionName, @Nullable String configName) {
+ if (StringUtil.isEmptyOrSpaces(sectionName) || StringUtil.isEmptyOrSpaces(configName)) {
+ return null;
+ }
+ Map<String, String> sectionValues = myConfigMap.get(sectionName);
+ return sectionValues != null ? sectionValues.get(configName) : null;
+ }
+
+ @NotNull
+ public Collection<String> getPaths() {
+ Map<String, String> pathOptions = myConfigMap.get("paths");
+ return pathOptions != null ? pathOptions.values() : Collections.<String>emptyList();
+ }
+}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgRepository.java b/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgRepository.java
index c250b50..3c9ea67 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgRepository.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgRepository.java
@@ -19,6 +19,7 @@
import com.intellij.dvcs.repo.Repository;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.util.Collection;
@@ -38,4 +39,15 @@
@NotNull
Collection<String> getBranches();
+
+ @NotNull
+ Collection<String> getBookmarks();
+
+ @Nullable
+ String getCurrentBookmark();
+
+ @NotNull
+ HgConfig getRepositoryConfig();
+
+ void updateConfig();
}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgRepositoryFiles.java b/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgRepositoryFiles.java
index fdddaba..16cc5e2 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgRepositoryFiles.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgRepositoryFiles.java
@@ -35,12 +35,18 @@
public static final String BRANCHEADSDIR = "cache";
public static final String MERGE = "merge";
public static final String BRANCH = "branch";
+ public static final String BOOKMARKS = "bookmarks";
+ public static final String CURRENT_BOOKMARK = "bookmarks.current";
+ public static final String CONFIG_HGRC = "hgrc";
@NotNull private final String myBranchHeadsPath;
@NotNull private final String myBranchHeadsDirPath;
@NotNull private final String myMergePath;
@NotNull private final String myBranchPath;
+ @NotNull private final String myBookmarksPath;
+ @NotNull private final String myCurrentBookmarkPath;
+ @NotNull private final String myConfigHgrcPath;
@NotNull
public static HgRepositoryFiles getInstance(@NotNull VirtualFile hgDir) {
@@ -52,6 +58,9 @@
myBranchHeadsDirPath = hgDir.getPath() + slash(BRANCHEADSDIR);
myBranchPath = hgDir.getPath() + slash(BRANCH);
myMergePath = hgDir.getPath() + slash(MERGE);
+ myBookmarksPath = hgDir.getPath() + slash(BOOKMARKS);
+ myCurrentBookmarkPath = hgDir.getPath() + slash(CURRENT_BOOKMARK);
+ myConfigHgrcPath = hgDir.getPath() + slash(CONFIG_HGRC);
}
@NotNull
@@ -72,7 +81,6 @@
return myBranchHeadsDirPath;
}
-
public boolean isbranchHeadsFile(String filePath) {
return filePath.startsWith(myBranchHeadsPath);
}
@@ -84,4 +92,16 @@
public boolean isMergeFile(String filePath) {
return filePath.startsWith(myMergePath);
}
+
+ public boolean isBookmarksFile(String filePath) {
+ return filePath.equals(myBookmarksPath);
+ }
+
+ public boolean isCurrentBookmarksFile(String filePath) {
+ return filePath.equals(myCurrentBookmarkPath);
+ }
+
+ public boolean isConfigHgrcFile(String filePath) {
+ return filePath.equals(myConfigHgrcPath);
+ }
}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgRepositoryImpl.java b/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgRepositoryImpl.java
index 0220cb9..97c4836 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgRepositoryImpl.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgRepositoryImpl.java
@@ -23,6 +23,7 @@
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import org.zmlx.hg4idea.HgVcs;
import org.zmlx.hg4idea.util.HgUtil;
@@ -40,12 +41,15 @@
@NotNull private final VirtualFile myHgDir;
@NotNull private volatile String myCurrentBranch = DEFAULT_BRANCH;
+ @Nullable private volatile String myCurrentBookmark = null;
@NotNull private volatile Collection<String> myBranches = Collections.emptySet();
+ @NotNull private volatile Collection<String> myBookmarks = Collections.emptySet();
+ @NotNull private volatile HgConfig myConfig;
private boolean myIsFresh = true;
@SuppressWarnings("ConstantConditions")
- protected HgRepositoryImpl(@NotNull VirtualFile rootDir, @NotNull Project project,
+ private HgRepositoryImpl(@NotNull VirtualFile rootDir, @NotNull Project project,
@NotNull Disposable parentDisposable) {
super(project, rootDir, parentDisposable);
myHgDir = rootDir.findChild(HgUtil.DOT_HG);
@@ -53,12 +57,13 @@
myState = State.NORMAL;
myCurrentRevision = null;
myReader = new HgRepositoryReader(VfsUtilCore.virtualToIoFile(myHgDir));
+ myConfig = HgConfig.getInstance(project, rootDir);
update();
}
@NotNull
- public static HgRepository getFullInstance(@NotNull VirtualFile root, @NotNull Project project,
- @NotNull Disposable parentDisposable) {
+ public static HgRepository getInstance(@NotNull VirtualFile root, @NotNull Project project,
+ @NotNull Disposable parentDisposable) {
HgRepositoryImpl repository = new HgRepositoryImpl(root, project, parentDisposable);
repository.setupUpdater();
return repository;
@@ -88,6 +93,23 @@
return myBranches;
}
+ @NotNull
+ @Override
+ public Collection<String> getBookmarks() {
+ return myBookmarks;
+ }
+
+ @Nullable
+ @Override
+ public String getCurrentBookmark() {
+ return myCurrentBookmark;
+ }
+
+ @NotNull
+ @Override
+ public HgConfig getRepositoryConfig() {
+ return myConfig;
+ }
@Override
public boolean isFresh() {
@@ -102,6 +124,7 @@
}
}
+ @NotNull
@Override
public String toLogString() {
return String.format("HgRepository{myCurrentBranch=%s, myCurrentRevision='%s', myState=%s, myRootDir=%s}",
@@ -109,12 +132,18 @@
}
private void readRepository() {
- myIsFresh = myIsFresh && myReader.checkIsFresh(); //if repository not fresh - it will be not fresh all time
+ myIsFresh = myIsFresh && myReader.checkIsFresh(); //if repository not fresh - it will be not fresh all time
if (!isFresh()) {
myState = myReader.readState();
myCurrentRevision = myReader.readCurrentRevision();
myCurrentBranch = myReader.readCurrentBranch();
myBranches = myReader.readBranches();
+ myBookmarks = myReader.readBookmarks();
+ myCurrentBookmark = myReader.readCurrentBookmark();
}
}
+
+ public void updateConfig(){
+ myConfig = HgConfig.getInstance(getProject(),getRoot());
+ }
}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgRepositoryManager.java b/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgRepositoryManager.java
new file mode 100644
index 0000000..3be9436
--- /dev/null
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgRepositoryManager.java
@@ -0,0 +1,27 @@
+package org.zmlx.hg4idea.repo;
+
+import com.intellij.dvcs.repo.AbstractRepositoryManager;
+import com.intellij.dvcs.repo.RepositoryManager;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.vcs.ProjectLevelVcsManager;
+import com.intellij.openapi.vfs.VirtualFile;
+import org.jetbrains.annotations.NotNull;
+import org.zmlx.hg4idea.HgVcs;
+import org.zmlx.hg4idea.util.HgUtil;
+
+/**
+ * @author Nadya Zabrodina
+ */
+public class HgRepositoryManager extends AbstractRepositoryManager<HgRepository> implements RepositoryManager<HgRepository> {
+
+ public HgRepositoryManager(@NotNull Project project,
+ @NotNull ProjectLevelVcsManager vcsManager) {
+ super(project, vcsManager, HgVcs.getInstance(project), HgUtil.DOT_HG);
+ }
+
+ @NotNull
+ @Override
+ protected HgRepository createRepository(@NotNull VirtualFile root) {
+ return HgRepositoryImpl.getInstance(root, myProject, this);
+ }
+}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgRepositoryReader.java b/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgRepositoryReader.java
index 0659e39..f1a27c8 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgRepositoryReader.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgRepositoryReader.java
@@ -37,11 +37,13 @@
*/
public class HgRepositoryReader {
- private static Pattern BRANCH_PATTERN = Pattern.compile("\\s*(.+)\\s+(.+)");
+ private static Pattern HASH_NAME = Pattern.compile("\\s*(.+)\\s+(.+)");
@NotNull private final File myHgDir; // .hg
@NotNull private final File myBranchHeadsFile; // .hg/cache/branchheads (does not exist before first commit)
@NotNull private final File myCurrentBranch; // .hg/branch
+ @NotNull private final File myBookmarksFile; //.hg/bookmarks
+ @NotNull private final File myCurrentBookmark; //.hg/bookmarks.current
public HgRepositoryReader(@NotNull File hgDir) {
myHgDir = hgDir;
@@ -50,6 +52,8 @@
//before 2.5 only branchheads exist
myBranchHeadsFile = branchesFile.exists() ? branchesFile : new File(new File(myHgDir, "cache"), "branchheads");
myCurrentBranch = new File(myHgDir, "branch");
+ myBookmarksFile = new File(myHgDir, "bookmarks");
+ myCurrentBookmark = new File(myHgDir, "bookmarks.current");
}
/**
@@ -62,7 +66,7 @@
if (checkIsFresh()) return null;
String[] branchesWithHeads = RepositoryUtil.tryLoadFile(myBranchHeadsFile).split("\n");
String head = branchesWithHeads[0];
- Matcher matcher = BRANCH_PATTERN.matcher(head);
+ Matcher matcher = HASH_NAME.matcher(head);
if (matcher.matches()) {
return (matcher.group(1));
}
@@ -84,7 +88,7 @@
String[] branchesWithHeads = RepositoryUtil.tryLoadFile(myBranchHeadsFile).split("\n");
// first one - is a head revision: head hash + head number;
for (int i = 1; i < branchesWithHeads.length; ++i) {
- Matcher matcher = BRANCH_PATTERN.matcher(branchesWithHeads[i]);
+ Matcher matcher = HASH_NAME.matcher(branchesWithHeads[i]);
if (matcher.matches()) {
branches.add(matcher.group(2));
}
@@ -109,4 +113,26 @@
public boolean branchExist() {
return myCurrentBranch.exists();
}
+
+ @NotNull
+ public Collection<String> readBookmarks() {
+ // .hg/bookmarks contains hash + name, f.e. 25e44c95b2612e3cdf29a704dabf82c77066cb67 A_BookMark
+ Set<String> bookmarks = new HashSet<String>();
+ if (!myBookmarksFile.exists()) {
+ return bookmarks;
+ }
+ String[] bookmarksWithHeads = RepositoryUtil.tryLoadFile(myBookmarksFile).split("\n");
+ for (String str : bookmarksWithHeads) {
+ Matcher matcher = HASH_NAME.matcher(str);
+ if (matcher.matches()) {
+ bookmarks.add(matcher.group(2));
+ }
+ }
+ return bookmarks;
+ }
+
+ @Nullable
+ public String readCurrentBookmark() {
+ return myCurrentBookmark.exists() ? RepositoryUtil.tryLoadFile(myCurrentBookmark) : null;
+ }
}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgRepositoryUpdater.java b/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgRepositoryUpdater.java
index 22983e1..2344253 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgRepositoryUpdater.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgRepositoryUpdater.java
@@ -23,6 +23,7 @@
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.openapi.vfs.newvfs.BulkFileListener;
import com.intellij.openapi.vfs.newvfs.events.VFileEvent;
+import com.intellij.util.Consumer;
import com.intellij.util.concurrency.QueueProcessor;
import com.intellij.util.messages.MessageBusConnection;
import com.intellij.vcsUtil.VcsUtil;
@@ -43,18 +44,24 @@
@NotNull private final Object DUMMY_UPDATE_OBJECT = new Object();
@Nullable private final VirtualFile myBranchHeadsDir;
@Nullable private final LocalFileSystem.WatchRequest myWatchRequest;
+ @NotNull private final QueueProcessor<Object> myUpdateConfigQueue;
- HgRepositoryUpdater(@NotNull HgRepository repository) {
+ HgRepositoryUpdater(@NotNull final HgRepository repository) {
VirtualFile hgDir = repository.getHgDir();
myWatchRequest = LocalFileSystem.getInstance().addRootToWatch(hgDir.getPath(), true);
myRepositoryFiles = HgRepositoryFiles.getInstance(hgDir);
RepositoryUtil.visitVcsDirVfs(hgDir, HgRepositoryFiles.getSubDirRelativePaths());
myBranchHeadsDir = VcsUtil.getVirtualFile(myRepositoryFiles.getBranchHeadsDirPath());
-
Project project = repository.getProject();
myUpdateQueue = new QueueProcessor<Object>(new RepositoryUtil.Updater(repository), project.getDisposed());
+ myUpdateConfigQueue = new QueueProcessor<Object>(new Consumer<Object>() {
+ @Override
+ public void consume(Object dummy) {
+ repository.updateConfig();
+ }
+ }, project.getDisposed());
if (!project.isDisposed()) {
myMessageBusConnection = project.getMessageBus().connect();
myMessageBusConnection.subscribe(VirtualFileManager.VFS_CHANGES, this);
@@ -64,7 +71,6 @@
}
}
-
@Override
public void dispose() {
if (myWatchRequest != null) {
@@ -86,6 +92,9 @@
boolean branchHeadsChanged = false;
boolean branchFileChanged = false;
boolean mergeFileChanged = false;
+ boolean bookmarksFileChanged = false;
+ boolean currentBookmarkFileChanged = false;
+ boolean configHgrcChanged = false;
for (VFileEvent event : events) {
String filePath = event.getPath();
if (filePath == null) {
@@ -101,12 +110,23 @@
else if (myRepositoryFiles.isMergeFile(filePath)) {
mergeFileChanged = true;
}
+ else if (myRepositoryFiles.isBookmarksFile(filePath)) {
+ bookmarksFileChanged = true;
+ }
+ else if (myRepositoryFiles.isCurrentBookmarksFile(filePath)) {
+ currentBookmarkFileChanged = true;
+ }
+
+ else if (myRepositoryFiles.isConfigHgrcFile(filePath)) {
+ configHgrcChanged = true;
+ }
}
-
- if (branchHeadsChanged || branchFileChanged || mergeFileChanged) {
+ if (branchHeadsChanged || branchFileChanged || mergeFileChanged || bookmarksFileChanged || currentBookmarkFileChanged) {
myUpdateQueue.add(DUMMY_UPDATE_OBJECT);
}
+ if (configHgrcChanged) {
+ myUpdateConfigQueue.add(Void.TYPE);
+ }
}
-
}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/status/ui/HgCurrentBranchStatusUpdater.java b/plugins/hg4idea/src/org/zmlx/hg4idea/status/ui/HgCurrentBranchStatusUpdater.java
index 120fde1..d0a49aa 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/status/ui/HgCurrentBranchStatusUpdater.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/status/ui/HgCurrentBranchStatusUpdater.java
@@ -22,6 +22,7 @@
import com.intellij.util.messages.MessageBusConnection;
import com.intellij.util.ui.UIUtil;
import com.intellij.vcsUtil.VcsUtil;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.zmlx.hg4idea.HgRevisionNumber;
import org.zmlx.hg4idea.HgUpdater;
@@ -41,7 +42,6 @@
private MessageBusConnection busConnection;
-
public HgCurrentBranchStatusUpdater(HgVcs vcs, HgCurrentBranchStatus currentBranchStatus) {
this.vcs = vcs;
this.currentBranchStatus = currentBranchStatus;
@@ -96,22 +96,18 @@
}
}
-
- private void handleUpdate(Project project, @Nullable String branch, List<HgRevisionNumber> parents) {
-
+ private void handleUpdate(@NotNull Project project, @Nullable String branch, @NotNull List<HgRevisionNumber> parents) {
currentBranchStatus.updateFor(branch, parents);
-
- project.getMessageBus().syncPublisher(HgVcs.STATUS_TOPIC).update(project, null);
+ if (!project.isDisposed()) {
+ project.getMessageBus().syncPublisher(HgVcs.STATUS_TOPIC).update(project, null);
+ }
}
-
public void activate() {
-
busConnection = vcs.getProject().getMessageBus().connect();
busConnection.subscribe(HgVcs.BRANCH_TOPIC, this);
}
-
public void deactivate() {
busConnection.disconnect();
}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/status/ui/HgStatusWidget.java b/plugins/hg4idea/src/org/zmlx/hg4idea/status/ui/HgStatusWidget.java
index 547ccc0..dad66a0 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/status/ui/HgStatusWidget.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/status/ui/HgStatusWidget.java
@@ -102,7 +102,7 @@
}
VirtualFile root = HgUtil.getRootForSelectedFile(project);
if (root != null) {
- return HgBranchPopup.getInstance(project, HgRepositoryImpl.getFullInstance(root, project, project)).asListPopup();
+ return HgBranchPopup.getInstance(project, HgRepositoryImpl.getInstance(root, project, project)).asListPopup();
}
return null;
}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgBookmarkDialog.java b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgBookmarkDialog.java
new file mode 100644
index 0000000..6c471f1
--- /dev/null
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgBookmarkDialog.java
@@ -0,0 +1,96 @@
+package org.zmlx.hg4idea.ui;
+
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.DialogWrapper;
+import com.intellij.openapi.ui.ValidationInfo;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.ui.components.JBCheckBox;
+import com.intellij.ui.components.JBLabel;
+import com.intellij.ui.components.JBTextField;
+import com.intellij.util.ui.GridBag;
+import com.intellij.util.ui.UIUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+import java.awt.*;
+
+import static com.intellij.util.ui.UIUtil.DEFAULT_HGAP;
+import static com.intellij.util.ui.UIUtil.DEFAULT_VGAP;
+
+/**
+ * @author Nadya Zabrodina
+ */
+public class HgBookmarkDialog extends DialogWrapper {
+ @NotNull private JBTextField myBookmarkName;
+ @NotNull private JBCheckBox myActiveCheckbox;
+
+ public HgBookmarkDialog(@Nullable Project project) {
+ super(project, false);
+ setTitle("Create Bookmark");
+ setResizable(false);
+ init();
+ }
+
+ @Override
+ @Nullable
+ protected String getHelpId() {
+ return "reference.mercurial.create.bookmark";
+ }
+
+ @Override
+ @NotNull
+ public JComponent getPreferredFocusedComponent() {
+ return myBookmarkName;
+ }
+
+ @Override
+ @NotNull
+ protected String getDimensionServiceKey() {
+ return HgBookmarkDialog.class.getName();
+ }
+
+ @Override
+ @NotNull
+ protected JComponent createCenterPanel() {
+
+ JPanel contentPanel = new JPanel(new GridBagLayout());
+ GridBag g = new GridBag()
+ .setDefaultInsets(new Insets(0, 0, DEFAULT_VGAP, DEFAULT_HGAP))
+ .setDefaultAnchor(GridBagConstraints.LINE_START)
+ .setDefaultFill(GridBagConstraints.HORIZONTAL);
+
+ JLabel icon = new JLabel(UIUtil.getQuestionIcon(), SwingConstants.LEFT);
+ myBookmarkName = new JBTextField(13);
+
+ JBLabel bookmarkLabel = new JBLabel("Bookmark name:");
+ bookmarkLabel.setLabelFor(myBookmarkName);
+
+ myActiveCheckbox = new JBCheckBox("Inactive", false);
+
+ contentPanel.add(icon, g.nextLine().next().coverColumn(3).pady(DEFAULT_HGAP));
+ contentPanel.add(bookmarkLabel, g.next().fillCellNone().insets(new Insets(0, 6, DEFAULT_VGAP, DEFAULT_HGAP)));
+ contentPanel.add(myBookmarkName, g.next().coverLine().setDefaultWeightX(1));
+ contentPanel.add(myActiveCheckbox, g.nextLine().next().next().coverLine(2));
+ return contentPanel;
+ }
+
+ public boolean isActive() {
+ return !myActiveCheckbox.isSelected();
+ }
+
+ @Nullable
+ public String getName() {
+ return myBookmarkName.getText();
+ }
+
+ @Override
+ @Nullable
+ protected ValidationInfo doValidate() {
+ String message = "You have to specify bookmark name.";
+ if (StringUtil.isEmptyOrSpaces(getName())) {
+ return new ValidationInfo(message, myBookmarkName);
+ }
+ return null;
+ }
+}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgPullDialog.java b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgPullDialog.java
index 8d1f2b0..6705058 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgPullDialog.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgPullDialog.java
@@ -24,7 +24,6 @@
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.Nullable;
import org.zmlx.hg4idea.HgRememberedInputs;
-import org.zmlx.hg4idea.command.HgShowConfigCommand;
import org.zmlx.hg4idea.util.HgUtil;
import javax.swing.*;
@@ -67,6 +66,13 @@
});
}
+ private void addPathsFromHgrc(VirtualFile repo) {
+ Collection<String> paths = HgUtil.getRepositoryPaths(project, repo);
+ for (String path : paths) {
+ myRepositoryURL.prependItem(path);
+ }
+ }
+
public void rememberSettings() {
final HgRememberedInputs rememberedInputs = HgRememberedInputs.getInstance(project);
rememberedInputs.addRepositoryUrl(HgUtil.removePasswordIfNeeded(getSource()));
@@ -100,13 +106,13 @@
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
@Override
public void run() {
- VirtualFile repo = hgRepositorySelector.getRepository();
- HgShowConfigCommand configCommand = new HgShowConfigCommand(project);
- final String defaultPath = configCommand.getDefaultPath(repo);
+ final VirtualFile repo = hgRepositorySelector.getRepository();
+ final String defaultPath = HgUtil.getRepositoryDefaultPath(project,repo);
if (!StringUtil.isEmptyOrSpaces(defaultPath)) {
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
+ addPathsFromHgrc(repo);
myRepositoryURL.setText(HgUtil.removePasswordIfNeeded(defaultPath));
myCurrentRepositoryUrl = defaultPath;
}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgPushDialog.java b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgPushDialog.java
index a76c787..d9974b2 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgPushDialog.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgPushDialog.java
@@ -93,6 +93,13 @@
});
}
+ private void addPathsFromHgrc(VirtualFile repo) {
+ Collection<String> paths = HgUtil.getRepositoryPaths(myProject, repo);
+ for (String path : paths) {
+ myRepositoryURL.prependItem(path);
+ }
+ }
+
public VirtualFile getRepository() {
return hgRepositorySelectorComponent.getRepository();
}
@@ -133,11 +140,12 @@
@Override
public void run() {
final VirtualFile repo = hgRepositorySelectorComponent.getRepository();
- final String defaultPath = HgPusher.getDefaultPushPath(myProject, repo);
+ final String defaultPath = HgUtil.getRepositoryDefaultPushPath(myProject, repo);
final List<HgTagBranch> branches = HgPusher.getBranches(myProject, repo);
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
+ addPathsFromHgrc(repo);
if (defaultPath != null) {
updateRepositoryUrlText(HgUtil.removePasswordIfNeeded(defaultPath));
myCurrentRepositoryUrl = defaultPath;
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgUtil.java b/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgUtil.java
index 0f355b2..7f85944 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgUtil.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgUtil.java
@@ -13,6 +13,7 @@
package org.zmlx.hg4idea.util;
import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
@@ -44,6 +45,7 @@
import org.zmlx.hg4idea.command.HgWorkingCopyRevisionsCommand;
import org.zmlx.hg4idea.provider.HgChangeProvider;
import org.zmlx.hg4idea.repo.HgRepository;
+import org.zmlx.hg4idea.repo.HgRepositoryManager;
import java.awt.*;
import java.io.*;
@@ -548,4 +550,41 @@
}
return branchText + repository.getCurrentBranch();
}
+
+ @NotNull
+ public static HgRepositoryManager getRepositoryManager(@NotNull Project project) {
+ return ServiceManager.getService(project, HgRepositoryManager.class);
+ }
+
+ @Nullable
+ public static String getRepositoryDefaultPath(@NotNull Project project, @NotNull VirtualFile root) {
+ HgRepository hgRepository = getRepositoryManager(project).getRepositoryForRoot(root);
+ assert hgRepository != null : "Repository can't be null for root " + root.getName();
+ return hgRepository.getRepositoryConfig().getDefaultPath();
+ }
+
+ @Nullable
+ public static String getRepositoryDefaultPushPath(@NotNull Project project, @NotNull VirtualFile root) {
+ HgRepository hgRepository = getRepositoryManager(project).getRepositoryForRoot(root);
+ assert hgRepository != null : "Repository can't be null for root " + root.getName();
+ return hgRepository.getRepositoryConfig().getDefaultPushPath();
+ }
+
+ @Nullable
+ public static String getConfig(@NotNull Project project,
+ @NotNull VirtualFile root,
+ @NotNull String section,
+ @Nullable String configName) {
+ HgRepository hgRepository = getRepositoryManager(project).getRepositoryForRoot(root);
+ assert hgRepository != null : "Repository can't be null for root " + root.getName();
+ return hgRepository.getRepositoryConfig().getNamedConfig(section, configName);
+ }
+
+ @NotNull
+ public static Collection<String> getRepositoryPaths(@NotNull Project project,
+ @NotNull VirtualFile root) {
+ HgRepository hgRepository = getRepositoryManager(project).getRepositoryForRoot(root);
+ assert hgRepository != null : "Repository can't be null for root " + root.getName();
+ return hgRepository.getRepositoryConfig().getPaths();
+ }
}
diff --git a/plugins/hg4idea/testData/repo/dot_hg/bookmarks b/plugins/hg4idea/testData/repo/dot_hg/bookmarks
new file mode 100644
index 0000000..782ad98
--- /dev/null
+++ b/plugins/hg4idea/testData/repo/dot_hg/bookmarks
@@ -0,0 +1,3 @@
+25e44c95b2612e3cdf29a704dabf82c77066cb67 A_BookMark
+c4e6b94abdf018515b2300698e3eb9b441d53619 B_BookMark
+25e44c95b2612e3cdf29a704dabf82c77066cb67 C_BookMark
diff --git a/plugins/hg4idea/testData/repo/dot_hg/bookmarks.current b/plugins/hg4idea/testData/repo/dot_hg/bookmarks.current
new file mode 100644
index 0000000..7ca946f
--- /dev/null
+++ b/plugins/hg4idea/testData/repo/dot_hg/bookmarks.current
@@ -0,0 +1 @@
+B_BookMark
\ No newline at end of file
diff --git a/plugins/hg4idea/testSrc/hg4idea/test/HgPlatformTest.java b/plugins/hg4idea/testSrc/hg4idea/test/HgPlatformTest.java
index d4f34b8..8caa695 100644
--- a/plugins/hg4idea/testSrc/hg4idea/test/HgPlatformTest.java
+++ b/plugins/hg4idea/testSrc/hg4idea/test/HgPlatformTest.java
@@ -24,7 +24,10 @@
import com.intellij.testFramework.fixtures.IdeaProjectTestFixture;
import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import org.zmlx.hg4idea.HgVcs;
+import org.zmlx.hg4idea.repo.HgRepository;
+import org.zmlx.hg4idea.util.HgUtil;
import java.io.File;
import java.io.IOException;
@@ -89,22 +92,30 @@
super.tearDown();
}
- private static void setUpHgrc(@NotNull VirtualFile repositoryRoot) {
+ private static void setUpHgrc(@NotNull VirtualFile repositoryRoot) throws IOException {
cd(".hg");
File pluginRoot = new File(PluginPathManager.getPluginHomePath("hg4idea"));
String pathToHgrc = "testData\\repo\\dot_hg";
File hgrcFile = new File(new File(pluginRoot, FileUtil.toSystemIndependentName(pathToHgrc)), "hgrc");
File hgrc = new File(new File(repositoryRoot.getPath(), ".hg"), "hgrc");
- try {
- FileUtil.appendToFile(hgrc, FileUtil.loadFile(hgrcFile));
- }
- catch (IOException e) {
- e.printStackTrace();
- fail("Can not update hgrc file.");
- }
+ FileUtil.appendToFile(hgrc, FileUtil.loadFile(hgrcFile));
assertTrue(hgrc.exists());
}
+ protected static void appendToHgrc(@NotNull VirtualFile repositoryRoot, @NotNull String text) throws IOException {
+ cd(".hg");
+ File hgrc = new File(new File(repositoryRoot.getPath(), ".hg"), "hgrc");
+ FileUtil.appendToFile(hgrc, text);
+ assertTrue(hgrc.exists());
+ }
+
+
+ protected static void updateRepoConfig(@NotNull Project project, @Nullable VirtualFile repo) {
+ HgRepository hgRepository = HgUtil.getRepositoryManager(project).getRepositoryForRoot(repo);
+ assertNotNull(hgRepository);
+ hgRepository.updateConfig();
+ }
+
protected void createRepository(VirtualFile root) {
initRepo(root.getPath());
}
diff --git a/plugins/hg4idea/testSrc/hg4idea/test/annotation/HgAnnotationTest.java b/plugins/hg4idea/testSrc/hg4idea/test/annotation/HgAnnotationTest.java
new file mode 100644
index 0000000..bd30492
--- /dev/null
+++ b/plugins/hg4idea/testSrc/hg4idea/test/annotation/HgAnnotationTest.java
@@ -0,0 +1,56 @@
+package hg4idea.test.annotation;
+
+import com.intellij.openapi.vcs.VcsException;
+import com.intellij.openapi.vfs.VfsUtilCore;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.util.text.DateFormatUtil;
+import hg4idea.test.HgPlatformTest;
+import org.zmlx.hg4idea.HgFile;
+import org.zmlx.hg4idea.command.HgAnnotateCommand;
+import org.zmlx.hg4idea.provider.annotate.HgAnnotation;
+import org.zmlx.hg4idea.provider.annotate.HgAnnotationLine;
+
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+import static com.intellij.dvcs.test.Executor.cd;
+import static com.intellij.dvcs.test.Executor.echo;
+import static hg4idea.test.HgExecutor.hg;
+
+/**
+ * @author Nadya Zabrodina
+ */
+public class HgAnnotationTest extends HgPlatformTest {
+ String firstCreatedFile = "file.txt";
+ static final String author1 = "a.bacaba@jetbrains.com";
+ static final String author2 = "bacaba.a";
+ static final String defaultAuthor = "John Doe <John.Doe@example.com>";
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ cd(myRepository);
+ echo(firstCreatedFile, "a\n");
+ hg("commit -m modify");
+ echo(firstCreatedFile, "b\n");
+ hg("commit -m modify1 -u " + author1);
+ echo(firstCreatedFile, "c\n");
+ hg("commit -m modify2 -u " + author2);
+ }
+
+ public void testAnnotationWithVerboseOption() throws VcsException {
+ final VirtualFile file = myRepository.findFileByRelativePath(firstCreatedFile);
+ assert file != null;
+ List<String> users = Arrays.asList(defaultAuthor, author1, author2);
+ final HgFile hgFile = new HgFile(myRepository, VfsUtilCore.virtualToIoFile(file));
+ final String date = DateFormatUtil.formatPrettyDate(new Date());
+ List<HgAnnotationLine> annotationLines =
+ new HgAnnotateCommand(myProject).execute(hgFile, null);
+ for (int i = 0; i < annotationLines.size(); ++i) {
+ HgAnnotationLine line = annotationLines.get(i);
+ assertEquals(users.get(i), line.get(HgAnnotation.FIELD.USER));
+ assertEquals(date, line.get(HgAnnotation.FIELD.DATE));
+ }
+ }
+}
diff --git a/plugins/hg4idea/testSrc/hg4idea/test/config/HgConfigTest.java b/plugins/hg4idea/testSrc/hg4idea/test/config/HgConfigTest.java
new file mode 100644
index 0000000..07d6c82
--- /dev/null
+++ b/plugins/hg4idea/testSrc/hg4idea/test/config/HgConfigTest.java
@@ -0,0 +1,79 @@
+package hg4idea.test.config;
+
+import com.intellij.dvcs.test.TestRepositoryUtil;
+import com.intellij.openapi.util.io.FileUtil;
+import hg4idea.test.HgPlatformTest;
+import org.zmlx.hg4idea.util.HgUtil;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collection;
+
+import static com.intellij.dvcs.test.Executor.cd;
+
+/**
+ * @author Nadya Zabrodina
+ */
+public class HgConfigTest extends HgPlatformTest {
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ prepareSecondRepository();
+ }
+
+ public void testDefaultPathInClonedRepo() {
+ cd(myChildRepo);
+ final String defaultPath = HgUtil.getRepositoryDefaultPath(myProject, myChildRepo);
+ assertNotNull(defaultPath);
+ assertEquals(myRepository.getPath(),
+ FileUtil.toSystemIndependentName(defaultPath));
+ }
+
+ public void testPushPathInClonedRepo() throws IOException {
+ cd(myChildRepo);
+ String pushPath = "somePath";
+ appendToHgrc(myChildRepo, "\n[paths]\n" +
+ "default-push=" + pushPath);
+ updateRepoConfig(myProject, myChildRepo);
+ final String defaultPushPath = HgUtil.getRepositoryDefaultPushPath(myProject, myChildRepo);
+ assertNotNull(defaultPushPath);
+ assertEquals(FileUtil.toSystemIndependentName(myChildRepo.getPath() + "/" + pushPath),
+ FileUtil.toSystemIndependentName(defaultPushPath));
+ }
+
+ public void testPushPathWithoutAppropriateConfig() {
+ cd(myChildRepo);
+ final String defaultPushPath = HgUtil.getRepositoryDefaultPushPath(myProject, myChildRepo);
+ assertNotNull(defaultPushPath);
+ assertEquals(myRepository.getPath(),
+ FileUtil.toSystemIndependentName(defaultPushPath));
+ }
+
+ public void testMultiPathConfig() throws IOException {
+ cd(myChildRepo);
+ final String path1 = "https://bitbucket.org/nadushnik/hgtestrepo";
+ final String path2 = "https://bitbucket.org/nadushnik/javarepo";
+ final String path3 = "https://bitbucket.org/nadushnik/hgTestRepo2";
+ appendToHgrc(myChildRepo, "\n[paths]" +
+ "\npath1=" + path1 +
+ "\npath2=" + path2 +
+ "\npath3=" + path3);
+ updateRepoConfig(myProject, myChildRepo);
+ final Collection<String> paths = HgUtil.getRepositoryPaths(myProject, myChildRepo);
+ final Collection<String> expectedPaths = Arrays.asList(myRepository.getPath(), path1, path2, path3);
+ TestRepositoryUtil.assertEqualCollections(expectedPaths,
+ paths);
+ }
+
+ public void testLargeExtensionInClonedRepo() throws IOException {
+ cd(myChildRepo);
+ File hgrc = new File(new File(myChildRepo.getPath(), ".hg"), "hgrc");
+ assert hgrc.exists();
+ FileUtil.appendToFile(hgrc, "\n[extensions]\n" +
+ "largefiles =");
+ updateRepoConfig(myProject, myChildRepo);
+ assertNotNull(HgUtil.getConfig(myProject, myChildRepo, "extensions", "largefiles"));
+ }
+}
diff --git a/plugins/hg4idea/testSrc/hg4idea/test/merge/HgMergeProviderTest.java b/plugins/hg4idea/testSrc/hg4idea/test/merge/HgMergeProviderTest.java
index e407280..35e65e9 100644
--- a/plugins/hg4idea/testSrc/hg4idea/test/merge/HgMergeProviderTest.java
+++ b/plugins/hg4idea/testSrc/hg4idea/test/merge/HgMergeProviderTest.java
@@ -152,10 +152,10 @@
//Add a file with the same name, but different content in child repository, don't commit.
cd(myChildRepo);
touch(bFile, "local");
+ myChildRepo.refresh(false, true);
hg("add " + bFile);
updateProject();
-
verifyMergeData(myChildRepo.findChild(bFile), "", "local", "server");
}
@@ -172,11 +172,13 @@
hg("add " + aFile);
hg("commit -m 'create file' ");
hg("update");
+ myRepository.refresh(false, true);
final VirtualFile parentFile = myRepository.findChild(aFile);
assertNotNull("Can't find " + aFile + " in parent repo!", parentFile);
cd(myChildRepo);
hg("pull");
hg("update");
+ myChildRepo.refresh(false, true);
final VirtualFile childFile = myChildRepo.findChild(aFile);
return Pair.create(parentFile, childFile);
}
@@ -192,5 +194,4 @@
private static void assertEquals(String s, byte[] bytes) {
Assert.assertEquals(s, new String(bytes));
}
-
}
diff --git a/plugins/hg4idea/testSrc/hg4idea/test/repo/HgRealRepositoryReaderTest.java b/plugins/hg4idea/testSrc/hg4idea/test/repo/HgRealRepositoryReaderTest.java
index 7089ca4..1f76f13 100644
--- a/plugins/hg4idea/testSrc/hg4idea/test/repo/HgRealRepositoryReaderTest.java
+++ b/plugins/hg4idea/testSrc/hg4idea/test/repo/HgRealRepositoryReaderTest.java
@@ -60,12 +60,23 @@
TestRepositoryUtil.assertEqualCollections(myRepositoryReader.readBranches(), Arrays.asList("default", "branchA", "branchB"));
}
+ public void testCurrentBookmark() {
+ hg("update B_BookMark");
+ assertEquals(myRepositoryReader.readCurrentBookmark(), "B_BookMark");
+ }
+
+ public void testBookmarks() {
+ TestRepositoryUtil.assertEqualCollections(myRepositoryReader.readBookmarks(), Arrays.asList("A_BookMark", "B_BookMark", "C_BookMark"));
+ }
+
private void createBranches() {
cd(myRepository);
+ hg("bookmark A_BookMark");
String aFile = "A.txt";
touch(aFile, "base");
hg("add " + aFile);
hg("commit -m 'create file'");
+ hg("bookmark B_BookMark");
hg("branch branchA");
echo(aFile, " modify with a");
hg("commit -m 'create branchA'");
@@ -73,6 +84,7 @@
hg("branch branchB");
echo(aFile, " modify with b");
hg("commit -m 'modify file in branchB'");
+ hg("bookmark C_BookMark");
hg("up branchA");
}
}
diff --git a/plugins/hg4idea/testSrc/hg4idea/test/repo/HgRepositoryReaderTest.java b/plugins/hg4idea/testSrc/hg4idea/test/repo/HgRepositoryReaderTest.java
index 9bc1a21..2a80515 100644
--- a/plugins/hg4idea/testSrc/hg4idea/test/repo/HgRepositoryReaderTest.java
+++ b/plugins/hg4idea/testSrc/hg4idea/test/repo/HgRepositoryReaderTest.java
@@ -35,6 +35,7 @@
@NotNull private HgRepositoryReader myRepositoryReader;
@NotNull private File myHgDir;
@NotNull private Collection<String> myBranches;
+ @NotNull private Collection<String> myBookmarks;
@Override
public void setUp() throws Exception {
@@ -48,11 +49,16 @@
File cacheDir = new File(testHgDir, "cache");
File testBranchFile = new File(testHgDir, "branch");
+ File testBookmarkFile = new File(testHgDir, "bookmarks");
+ File testCurrentBookmarkFile = new File(testHgDir, "bookmarks.current");
FileUtil.copyDir(cacheDir, new File(myHgDir, "cache"));
FileUtil.copy(testBranchFile, new File(myHgDir, "branch"));
+ FileUtil.copy(testBookmarkFile, new File(myHgDir, "bookmarks"));
+ FileUtil.copy(testCurrentBookmarkFile, new File(myHgDir, "bookmarks.current"));
myRepositoryReader = new HgRepositoryReader(myHgDir);
myBranches = readBranches();
+ myBookmarks = readBookmarks();
}
public void testHEAD() {
@@ -69,6 +75,11 @@
TestRepositoryUtil.assertEqualCollections(branches, myBranches);
}
+ public void testBookmarks() {
+ Collection<String> bookmarks = myRepositoryReader.readBookmarks();
+ TestRepositoryUtil.assertEqualCollections(bookmarks, myBookmarks);
+ }
+
@NotNull
private Collection<String> readBranches() throws IOException {
Collection<String> branches = new HashSet<String>();
@@ -81,4 +92,22 @@
}
return branches;
}
+
+
+ public void testCurrentBookmark() {
+ assertEquals(myRepositoryReader.readCurrentBookmark(), "B_BookMark");
+ }
+
+ @NotNull
+ private Collection<String> readBookmarks() throws IOException {
+ Collection<String> bookmarks = new HashSet<String>();
+ File bookmarksFile = new File(myHgDir, "bookmarks");
+ String[] bookmarksWithHashes = FileUtil.loadFile(bookmarksFile).split("\n");
+ for (String str : bookmarksWithHashes) {
+ String[] refAndName = str.trim().split(" ");
+ assertEquals(2, refAndName.length);
+ bookmarks.add(refAndName[1]);
+ }
+ return bookmarks;
+ }
}
diff --git a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgDiffProviderTest.java b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgDiffProviderTest.java
index 80644dc..de286d0 100644
--- a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgDiffProviderTest.java
+++ b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgDiffProviderTest.java
@@ -67,8 +67,6 @@
refreshVfs();
- //ChangeListManager.getInstance(myProject).ensureUpToDate(false);
-
HgDiffProvider diffProvider = new HgDiffProvider(myProject);
HgRevisionNumber currentRevision = (HgRevisionNumber)diffProvider.getCurrentRevision(myWorkingCopyDir.findChild(AFILE));
diff --git a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgUpdateTest.java b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgUpdateTest.java
index 4c00183..8ab8cd3 100644
--- a/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgUpdateTest.java
+++ b/plugins/hg4idea/testSrc/org/zmlx/hg4idea/test/HgUpdateTest.java
@@ -25,6 +25,7 @@
import org.zmlx.hg4idea.HgRevisionNumber;
import org.zmlx.hg4idea.command.*;
import org.zmlx.hg4idea.provider.update.HgRegularUpdater;
+import org.zmlx.hg4idea.util.HgUtil;
import java.io.File;
import java.io.IOException;
@@ -58,7 +59,7 @@
//do a simple pull without an update
HgPullCommand pull = new HgPullCommand(myProject, projectRepoVirtualFile);
- pull.setSource(new HgShowConfigCommand(myProject).getDefaultPath(projectRepoVirtualFile));
+ pull.setSource(HgUtil.getRepositoryDefaultPath(myProject, projectRepoVirtualFile));
pull.setUpdate(false);
pull.execute();
diff --git a/plugins/java-i18n/src/com/intellij/codeInspection/i18n/I18nizeConcatenationQuickFix.java b/plugins/java-i18n/src/com/intellij/codeInspection/i18n/I18nizeConcatenationQuickFix.java
index 7775d94..65cf7e5 100644
--- a/plugins/java-i18n/src/com/intellij/codeInspection/i18n/I18nizeConcatenationQuickFix.java
+++ b/plugins/java-i18n/src/com/intellij/codeInspection/i18n/I18nizeConcatenationQuickFix.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -16,13 +16,13 @@
package com.intellij.codeInspection.i18n;
import com.intellij.codeInsight.CodeInsightBundle;
-import com.intellij.codeInsight.intention.impl.ConcatenationToMessageFormatAction;
import com.intellij.lang.properties.psi.I18nizedTextGenerator;
import com.intellij.lang.properties.psi.PropertiesFile;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
+import com.intellij.psi.util.PsiConcatenationUtil;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NonNls;
@@ -88,7 +88,7 @@
StringBuilder formatString = new StringBuilder();
final List<PsiExpression> args = new ArrayList<PsiExpression>();
try {
- ConcatenationToMessageFormatAction.buildMessageFormatString(concatenation, formatString, args);
+ PsiConcatenationUtil.buildFormatString(concatenation, formatString, args, false);
}
catch (IncorrectOperationException e) {
LOG.error(e);
diff --git a/plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/GenerateGetterSetterTest.java b/plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/GenerateGetterSetterTest.java
index 2761011..e95087b 100644
--- a/plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/GenerateGetterSetterTest.java
+++ b/plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/GenerateGetterSetterTest.java
@@ -30,6 +30,10 @@
doTest();
}
+ public void testStringNumber() throws Exception {
+ doTest();
+ }
+
@Override
protected void setUpModule() {
super.setUpModule();
diff --git a/plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/RefactoringFieldTest.java b/plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/RefactoringFieldTest.java
new file mode 100644
index 0000000..5ac15b3
--- /dev/null
+++ b/plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/RefactoringFieldTest.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2000-2012 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 org.jetbrains.plugins.javaFX;
+
+import com.intellij.codeInsight.TargetElementUtilBase;
+import com.intellij.openapi.application.PluginPathManager;
+import com.intellij.psi.PsiElement;
+import com.intellij.refactoring.rename.RenameProcessor;
+import com.intellij.refactoring.safeDelete.SafeDeleteHandler;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.plugins.javaFX.fxml.AbstractJavaFXTestCase;
+
+public class RefactoringFieldTest extends AbstractJavaFXTestCase {
+
+ public void testPropertyRename() throws Exception {
+ myFixture.configureByFile(getTestName(false) + ".java");
+ performRename("newName");
+ myFixture.checkResultByFile(getTestName(false) + "_after.java");
+ }
+
+ public void testPropertyDelete() throws Exception {
+ myFixture.configureByFile(getTestName(false) + ".java");
+ performDelete();
+ myFixture.checkResultByFile(getTestName(false) + "_after.java");
+ }
+
+ protected void performRename(String newName) {
+ PsiElement element = TargetElementUtilBase.findTargetElement(myFixture.getEditor(), TargetElementUtilBase
+ .ELEMENT_NAME_ACCEPTED | TargetElementUtilBase.REFERENCED_ELEMENT_ACCEPTED);
+
+ new RenameProcessor(getProject(), element, newName, false, false).run();
+ }
+
+ private void performDelete() {
+ final PsiElement psiElement = TargetElementUtilBase
+ .findTargetElement(myFixture.getEditor(), TargetElementUtilBase.ELEMENT_NAME_ACCEPTED | TargetElementUtilBase.REFERENCED_ELEMENT_ACCEPTED);
+ assertNotNull("No element found in text:\n" + myFixture.getFile().getText(), psiElement);
+ SafeDeleteHandler.invoke(getProject(), new PsiElement[]{psiElement}, true);
+ }
+
+ @NotNull
+ @Override
+ protected String getTestDataPath() {
+ return PluginPathManager.getPluginHomePath("javaFX") + "/testData/fieldRefactoring/";
+ }
+}
diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/codeInsight/JavaFxGetterSetterPrototypeProvider.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/codeInsight/JavaFxGetterSetterPrototypeProvider.java
index 2c3ae17..8ed3fd8 100644
--- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/codeInsight/JavaFxGetterSetterPrototypeProvider.java
+++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/codeInsight/JavaFxGetterSetterPrototypeProvider.java
@@ -82,6 +82,28 @@
}
@Override
+ public PsiMethod[] findGetters(PsiClass psiClass, String propertyName) {
+ final String getterName = suggestGetterName(propertyName);
+ final PsiMethod specificGetter = psiClass
+ .findMethodBySignature(JavaPsiFacade.getElementFactory(psiClass.getProject()).createMethod(getterName, PsiType.VOID), false);
+ if (specificGetter != null) {
+ final PsiMethod getter = PropertyUtil.findPropertyGetter(psiClass, propertyName, false, false);
+ return getter == null ? new PsiMethod[] {specificGetter} : new PsiMethod[] {getter, specificGetter};
+ }
+ return super.findGetters(psiClass, propertyName);
+ }
+
+ @Override
+ public String suggestGetterName(String propertyName) {
+ return propertyName + "Property";
+ }
+
+ @Override
+ public boolean isSimpleGetter(PsiMethod method, String oldPropertyName) {
+ return method.getName().equals(suggestGetterName(oldPropertyName));
+ }
+
+ @Override
public boolean isReadOnly(PsiField field) {
return !InheritanceUtil.isInheritor(field.getType(), JavaFxCommonClassNames.JAVAFX_BEANS_VALUE_WRITABLE_VALUE);
}
diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/JavaFxPsiUtil.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/JavaFxPsiUtil.java
index 544379c..f680469 100644
--- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/JavaFxPsiUtil.java
+++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/JavaFxPsiUtil.java
@@ -518,7 +518,7 @@
final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(fieldType);
final PsiClass fieldClass = resolveResult.getElement();
if (fieldClass == null) return fieldType;
- return CachedValuesManager.getManager(project).getCachedValue(fieldClass, new CachedValueProvider<PsiType>() {
+ return CachedValuesManager.getManager(project).getCachedValue(field, new CachedValueProvider<PsiType>() {
@Nullable
@Override
public Result<PsiType> compute() {
diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/codeInsight/inspections/JavaFxUnresolvedFxIdReferenceInspection.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/codeInsight/inspections/JavaFxUnresolvedFxIdReferenceInspection.java
index 2cac819..391db81 100644
--- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/codeInsight/inspections/JavaFxUnresolvedFxIdReferenceInspection.java
+++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/codeInsight/inspections/JavaFxUnresolvedFxIdReferenceInspection.java
@@ -141,7 +141,7 @@
field = CreateFieldFromUsageHelper.insertField(targetClass, field, psiElement);
final PsiClassType fieldType = factory.createType(checkContext(reference.getXmlAttributeValue()));
- final ExpectedTypeInfo[] types = {new ExpectedTypeInfoImpl(fieldType, ExpectedTypeInfo.TYPE_OR_SUBTYPE, 0, fieldType, TailType.NONE)};
+ final ExpectedTypeInfo[] types = {new ExpectedTypeInfoImpl(fieldType, ExpectedTypeInfo.TYPE_OR_SUBTYPE, fieldType, TailType.NONE)};
CreateFieldFromUsageFix.createFieldFromUsageTemplate(targetClass, project, types, field, false, psiElement);
}
}
diff --git a/plugins/javaFX/testData/fieldRefactoring/PropertyDelete.java b/plugins/javaFX/testData/fieldRefactoring/PropertyDelete.java
new file mode 100644
index 0000000..1839234
--- /dev/null
+++ b/plugins/javaFX/testData/fieldRefactoring/PropertyDelete.java
@@ -0,0 +1,18 @@
+import javafx.beans.property.IntegerProperty;
+import javafx.beans.property.SimpleIntegerProperty;
+
+class Test {
+ private IntegerProperty c<caret>ount = new SimpleIntegerProperty(this, "count");
+
+ public int getCount() {
+ return count.get();
+ }
+
+ public IntegerProperty countProperty() {
+ return count;
+ }
+
+ public void setCount(int count) {
+ this.count.set(count);
+ }
+}
\ No newline at end of file
diff --git a/plugins/javaFX/testData/fieldRefactoring/PropertyDelete_after.java b/plugins/javaFX/testData/fieldRefactoring/PropertyDelete_after.java
new file mode 100644
index 0000000..973bbc3
--- /dev/null
+++ b/plugins/javaFX/testData/fieldRefactoring/PropertyDelete_after.java
@@ -0,0 +1,6 @@
+import javafx.beans.property.IntegerProperty;
+import javafx.beans.property.SimpleIntegerProperty;
+
+class Test {
+
+}
\ No newline at end of file
diff --git a/plugins/javaFX/testData/fieldRefactoring/PropertyRename.java b/plugins/javaFX/testData/fieldRefactoring/PropertyRename.java
new file mode 100644
index 0000000..1839234
--- /dev/null
+++ b/plugins/javaFX/testData/fieldRefactoring/PropertyRename.java
@@ -0,0 +1,18 @@
+import javafx.beans.property.IntegerProperty;
+import javafx.beans.property.SimpleIntegerProperty;
+
+class Test {
+ private IntegerProperty c<caret>ount = new SimpleIntegerProperty(this, "count");
+
+ public int getCount() {
+ return count.get();
+ }
+
+ public IntegerProperty countProperty() {
+ return count;
+ }
+
+ public void setCount(int count) {
+ this.count.set(count);
+ }
+}
\ No newline at end of file
diff --git a/plugins/javaFX/testData/fieldRefactoring/PropertyRename_after.java b/plugins/javaFX/testData/fieldRefactoring/PropertyRename_after.java
new file mode 100644
index 0000000..a9ef9cd
--- /dev/null
+++ b/plugins/javaFX/testData/fieldRefactoring/PropertyRename_after.java
@@ -0,0 +1,18 @@
+import javafx.beans.property.IntegerProperty;
+import javafx.beans.property.SimpleIntegerProperty;
+
+class Test {
+ private IntegerProperty newName = new SimpleIntegerProperty(this, "count");
+
+ public int getNewName() {
+ return newName.get();
+ }
+
+ public IntegerProperty newNameProperty() {
+ return newName;
+ }
+
+ public void setNewName(int newName) {
+ this.newName.set(newName);
+ }
+}
\ No newline at end of file
diff --git a/plugins/javaFX/testData/generateGetterSetter/afterStringNumber.java b/plugins/javaFX/testData/generateGetterSetter/afterStringNumber.java
new file mode 100644
index 0000000..9f43a6a
--- /dev/null
+++ b/plugins/javaFX/testData/generateGetterSetter/afterStringNumber.java
@@ -0,0 +1,32 @@
+import javafx.beans.property.ObjectProperty;
+import javafx.beans.property.SimpleObjectProperty;
+
+public class BugTest {
+
+ private ObjectProperty<String> name = new SimpleObjectProperty<>();
+ private ObjectProperty<Number> value = new SimpleObjectProperty<>();
+
+ public String getName() {
+ return name.get();
+ }
+
+ public ObjectProperty<String> nameProperty() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name.set(name);
+ }
+
+ public Number getValue() {
+ return value.get();
+ }
+
+ public ObjectProperty<Number> valueProperty() {
+ return value;
+ }
+
+ public void setValue(Number value) {
+ this.value.set(value);
+ }
+}
\ No newline at end of file
diff --git a/plugins/javaFX/testData/generateGetterSetter/beforeStringNumber.java b/plugins/javaFX/testData/generateGetterSetter/beforeStringNumber.java
new file mode 100644
index 0000000..d489014
--- /dev/null
+++ b/plugins/javaFX/testData/generateGetterSetter/beforeStringNumber.java
@@ -0,0 +1,10 @@
+import javafx.beans.property.ObjectProperty;
+import javafx.beans.property.SimpleObjectProperty;
+
+public class BugTest {
+
+ private ObjectProperty<String> name = new SimpleObjectProperty<>();
+ private ObjectProperty<Number> value = new SimpleObjectProperty<>();
+
+ <caret>
+}
\ No newline at end of file
diff --git a/plugins/junit/src/com/intellij/execution/junit/TestDirectory.java b/plugins/junit/src/com/intellij/execution/junit/TestDirectory.java
index 7a09cd0..77403df 100644
--- a/plugins/junit/src/com/intellij/execution/junit/TestDirectory.java
+++ b/plugins/junit/src/com/intellij/execution/junit/TestDirectory.java
@@ -28,10 +28,7 @@
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.psi.JavaDirectoryService;
-import com.intellij.psi.PsiDirectory;
-import com.intellij.psi.PsiManager;
-import com.intellij.psi.PsiPackage;
+import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.GlobalSearchScopes;
@@ -118,4 +115,21 @@
}
return aPackage;
}
+
+ @Override
+ public boolean isConfiguredByElement(JUnitConfiguration configuration,
+ PsiClass testClass,
+ PsiMethod testMethod,
+ PsiPackage testPackage) {
+ if (JUnitConfiguration.TEST_DIRECTORY.equals(configuration.getPersistentData().TEST_OBJECT) && testPackage != null) {
+ final PsiDirectory[] directories = testPackage.getDirectories(configuration.getConfigurationModule().getSearchScope());
+ final String dirName = configuration.getPersistentData().getDirName();
+ if (dirName != null) {
+ for (PsiDirectory directory : directories) {
+ if (dirName.equals(directory.getVirtualFile().getPath())) return true;
+ }
+ }
+ }
+ return false;
+ }
}
diff --git a/plugins/junit/src/com/intellij/execution/junit/TestObject.java b/plugins/junit/src/com/intellij/execution/junit/TestObject.java
index 127e817..84937d5 100644
--- a/plugins/junit/src/com/intellij/execution/junit/TestObject.java
+++ b/plugins/junit/src/com/intellij/execution/junit/TestObject.java
@@ -27,6 +27,7 @@
import com.intellij.execution.junit2.ui.JUnitTreeConsoleView;
import com.intellij.execution.junit2.ui.TestsPacketsReceiver;
import com.intellij.execution.junit2.ui.actions.RerunFailedTestsAction;
+import com.intellij.execution.junit2.ui.model.CompletionEvent;
import com.intellij.execution.junit2.ui.model.JUnitRunningModel;
import com.intellij.execution.junit2.ui.model.RootTestInfo;
import com.intellij.execution.junit2.ui.properties.JUnitConsoleProperties;
@@ -47,16 +48,16 @@
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.module.Module;
+import com.intellij.openapi.module.ModuleManager;
+import com.intellij.openapi.module.ModuleUtil;
+import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.projectRoots.JavaSdkType;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.projectRoots.ex.JavaSdkUtil;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.roots.ProjectRootManager;
-import com.intellij.openapi.util.Comparing;
-import com.intellij.openapi.util.Disposer;
-import com.intellij.openapi.util.Getter;
-import com.intellij.openapi.util.Key;
+import com.intellij.openapi.util.*;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.psi.PsiClass;
@@ -70,14 +71,12 @@
import com.intellij.util.PathUtil;
import jetbrains.buildServer.messages.serviceMessages.ServiceMessageTypes;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.jps.model.serialization.PathMacroUtil;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
+import java.util.*;
public abstract class TestObject implements JavaCommandLine {
protected static final Logger LOG = Logger.getInstance("#com.intellij.execution.junit.TestObject");
@@ -90,6 +89,7 @@
protected final JUnitConfiguration myConfiguration;
private final ExecutionEnvironment myEnvironment;
protected File myTempFile = null;
+ protected File myWorkingDirsFile = null;
public File myListenersFile;
public static TestObject fromString(final String id,
@@ -404,7 +404,15 @@
}
protected void notifyByBalloon(JUnitRunningModel model, boolean started, JUnitConsoleProperties consoleProperties) {
- TestsUIUtil.notifyByBalloon(myProject, started, model != null ? model.getRoot() : null, consoleProperties);
+ String comment;
+ if (model != null) {
+ final CompletionEvent done = model.getProgress().getDone();
+ comment = done != null ? done.getComment() : null;
+ }
+ else {
+ comment = null;
+ }
+ TestsUIUtil.notifyByBalloon(myProject, started, model != null ? model.getRoot() : null, consoleProperties, comment);
}
protected JUnitProcessHandler createHandler(Executor executor) throws ExecutionException {
@@ -412,10 +420,22 @@
return JUnitProcessHandler.runCommandLine(CommandLineBuilder.createFromJavaParameters(myJavaParameters, myProject, true));
}
+ private boolean forkPerModule() {
+ final String workingDirectory = myConfiguration.getWorkingDirectory();
+ return JUnitConfiguration.TEST_PACKAGE.equals(myConfiguration.getPersistentData().TEST_OBJECT) &&
+ myConfiguration.getPersistentData().getScope() != TestSearchScope.SINGLE_MODULE &&
+ ("$" + PathMacroUtil.MODULE_DIR_MACRO_NAME + "$").equals(workingDirectory);
+ }
+
private void appendForkInfo(Executor executor) throws ExecutionException {
final String forkMode = myConfiguration.getForkMode();
if (Comparing.strEqual(forkMode, "none")) {
- return;
+ final String workingDirectory = myConfiguration.getWorkingDirectory();
+ if (!JUnitConfiguration.TEST_PACKAGE.equals(myConfiguration.getPersistentData().TEST_OBJECT) ||
+ myConfiguration.getPersistentData().getScope() == TestSearchScope.SINGLE_MODULE ||
+ !("$" + PathMacroUtil.MODULE_DIR_MACRO_NAME + "$").equals(workingDirectory)) {
+ return;
+ }
}
if (getRunnerSettings().getData() != null) {
@@ -461,6 +481,7 @@
myJavaParameters.getProgramParametersList().add("@" + myTempFile.getAbsolutePath());
}
+ final Map<String, List<String>> perModule = forkPerModule() ? new TreeMap<String, List<String>>() : null;
final PrintWriter writer = new PrintWriter(myTempFile, "UTF-8");
try {
writer.println(packageName);
@@ -471,9 +492,30 @@
LOG.error("invalid element " + element);
return;
}
- testNames.add(name);
+
+ if (perModule != null && element instanceof PsiElement) {
+ final Module module = ModuleUtilCore.findModuleForPsiElement((PsiElement)element);
+ if (module != null) {
+ final String moduleDir = PathMacroUtil.getModuleDir(module.getModuleFilePath());
+ List<String> list = perModule.get(moduleDir);
+ if (list == null) {
+ list = new ArrayList<String>();
+ perModule.put(moduleDir, list);
+ }
+ list.add(name);
+ }
+ } else {
+ testNames.add(name);
+ }
}
- Collections.sort(testNames); //sort tests in FQN order
+ if (perModule != null) {
+ for (List<String> perModuleClasses : perModule.values()) {
+ Collections.sort(perModuleClasses);
+ testNames.addAll(perModuleClasses);
+ }
+ } else {
+ Collections.sort(testNames); //sort tests in FQN order
+ }
for (String testName : testNames) {
writer.println(testName);
}
@@ -481,6 +523,23 @@
finally {
writer.close();
}
+
+ if (perModule != null && perModule.size() > 1) {
+ final PrintWriter wWriter = new PrintWriter(myWorkingDirsFile, "UTF-8");
+ try {
+ wWriter.println(packageName);
+ for (String workingDir : perModule.keySet()) {
+ wWriter.println(workingDir);
+ final List<String> classNames = perModule.get(workingDir);
+ wWriter.println(classNames.size());
+ for (String className : classNames) {
+ wWriter.println(className);
+ }
+ }
+ } finally {
+ wWriter.close();
+ }
+ }
}
catch (IOException e) {
LOG.error(e);
diff --git a/plugins/junit/src/com/intellij/execution/junit/TestPackage.java b/plugins/junit/src/com/intellij/execution/junit/TestPackage.java
index 9ace14a..d157cab 100644
--- a/plugins/junit/src/com/intellij/execution/junit/TestPackage.java
+++ b/plugins/junit/src/com/intellij/execution/junit/TestPackage.java
@@ -165,6 +165,15 @@
}
try {
+ myWorkingDirsFile = FileUtil.createTempFile("idea_working_dirs_junit", ".tmp");
+ myWorkingDirsFile.deleteOnExit();
+ myJavaParameters.getProgramParametersList().add("@w@" + myWorkingDirsFile.getAbsolutePath());
+ }
+ catch (IOException e) {
+ LOG.error(e);
+ }
+
+ try {
myServerSocket = new ServerSocket(0, 0, InetAddress.getByName("127.0.0.1"));
myJavaParameters.getProgramParametersList().add("-socket" + myServerSocket.getLocalPort());
}
diff --git a/plugins/junit/src/com/intellij/execution/junit/TestsPattern.java b/plugins/junit/src/com/intellij/execution/junit/TestsPattern.java
index 51c2fb0..802f513 100644
--- a/plugins/junit/src/com/intellij/execution/junit/TestsPattern.java
+++ b/plugins/junit/src/com/intellij/execution/junit/TestsPattern.java
@@ -40,6 +40,7 @@
import com.intellij.psi.PsiPackage;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.refactoring.listeners.RefactoringElementListener;
+import com.intellij.refactoring.listeners.RefactoringElementListenerComposite;
import com.intellij.util.Function;
import com.intellij.util.FunctionUtil;
import org.jetbrains.annotations.NotNull;
@@ -47,6 +48,7 @@
import java.io.IOException;
import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.Set;
public class TestsPattern extends TestPackage {
@@ -72,12 +74,8 @@
final Project project = myConfiguration.getProject();
final Set<String> classNames = new HashSet<String>();
for (String className : data.getPatterns()) {
- final PsiClass psiClass = JavaExecutionUtil.findMainClass(project,
- className.contains(",")
- ? className.substring(0, className.indexOf(','))
- : className,
- GlobalSearchScope.allScope(project));
- if (psiClass != null && JUnitUtil.isTestClass(psiClass)) {
+ final PsiClass psiClass = getTestClass(project, className);
+ if (psiClass != null&& JUnitUtil.isTestClass(psiClass)) {
classNames.add(className);
}
}
@@ -119,6 +117,13 @@
return super.findTests();
}
+ private static PsiClass getTestClass(Project project, String className) {
+ return JavaExecutionUtil.findMainClass(project,
+ (className.contains(",")
+ ? className.substring(0, className.indexOf(','))
+ : className).trim(), GlobalSearchScope.allScope(project));
+ }
+
protected void configureClasspath() throws CantRunException {
final String jreHome = myConfiguration.isAlternativeJrePathEnabled() ? myConfiguration.getAlternativeJrePath() : null;
@@ -144,7 +149,48 @@
@Nullable
@Override
public RefactoringElementListener getListener(PsiElement element, JUnitConfiguration configuration) {
- return null;
+ final RefactoringElementListenerComposite composite = new RefactoringElementListenerComposite();
+ final JUnitConfiguration.Data data = configuration.getPersistentData();
+ final Set<String> patterns = data.getPatterns();
+ for (final String pattern : patterns) {
+ final PsiClass testClass = getTestClass(configuration.getProject(), pattern.trim());
+ if (testClass != null && testClass.equals(element)) {
+ final RefactoringElementListener listeners =
+ RefactoringListeners.getListeners(testClass, new RefactoringListeners.Accessor<PsiClass>() {
+ private String myOldName = testClass.getQualifiedName();
+ @Override
+ public void setName(String qualifiedName) {
+ final Set<String> replaced = new LinkedHashSet<String>();
+ for (String currentPattern : patterns) {
+ if (myOldName.equals(currentPattern)) {
+ replaced.add(qualifiedName);
+ myOldName = qualifiedName;
+ } else {
+ replaced.add(currentPattern);
+ }
+ }
+ patterns.clear();
+ patterns.addAll(replaced);
+ }
+
+ @Override
+ public PsiClass getPsiElement() {
+ return testClass;
+ }
+
+ @Override
+ public void setPsiElement(PsiClass psiElement) {
+ if (psiElement == testClass) {
+ setName(psiElement.getQualifiedName());
+ }
+ }
+ });
+ if (listeners != null) {
+ composite.addListener(listeners);
+ }
+ }
+ }
+ return composite;
}
@Override
diff --git a/plugins/junit/src/com/intellij/execution/junit2/ui/JUnitStatusLine.java b/plugins/junit/src/com/intellij/execution/junit2/ui/JUnitStatusLine.java
index a3a1a07..88a474c 100644
--- a/plugins/junit/src/com/intellij/execution/junit2/ui/JUnitStatusLine.java
+++ b/plugins/junit/src/com/intellij/execution/junit2/ui/JUnitStatusLine.java
@@ -135,6 +135,7 @@
if (!event.isRunning()) {
final CompletionEvent completionEvent = (CompletionEvent) event;
myStateInfo.setDone(completionEvent);
+ myProgress.setDone(completionEvent);
if (completionEvent.isTerminated() && !myProgress.hasDefects()) {
myProgressBar.setColor(ColorProgressBar.YELLOW);
}
diff --git a/plugins/junit/src/com/intellij/execution/junit2/ui/TestProgress.java b/plugins/junit/src/com/intellij/execution/junit2/ui/TestProgress.java
index 1117c26..62c5337 100644
--- a/plugins/junit/src/com/intellij/execution/junit2/ui/TestProgress.java
+++ b/plugins/junit/src/com/intellij/execution/junit2/ui/TestProgress.java
@@ -20,6 +20,7 @@
import com.intellij.execution.junit2.events.NewChildEvent;
import com.intellij.execution.junit2.events.StateChangedEvent;
import com.intellij.execution.junit2.events.TestEvent;
+import com.intellij.execution.junit2.ui.model.CompletionEvent;
import com.intellij.execution.junit2.ui.model.JUnitAdapter;
import com.intellij.execution.junit2.ui.model.JUnitRunningModel;
import com.intellij.execution.testframework.AbstractTestProxy;
@@ -45,6 +46,7 @@
return test.shouldRun();
}
};
+ private CompletionEvent myDone;
public TestProgress() {
super(0, 0, 0, 0);
@@ -83,6 +85,14 @@
fireStateChanged();
}
+ public CompletionEvent getDone() {
+ return myDone;
+ }
+
+ public void setDone(CompletionEvent done) {
+ myDone = done;
+ }
+
private class MyJUnitListener extends JUnitAdapter {
public void onTestChanged(final TestEvent event) {
if (event instanceof StateChangedEvent)
diff --git a/plugins/junit/src/com/intellij/execution/junit2/ui/model/CompletionEvent.java b/plugins/junit/src/com/intellij/execution/junit2/ui/model/CompletionEvent.java
index dedd974..8a0b297 100644
--- a/plugins/junit/src/com/intellij/execution/junit2/ui/model/CompletionEvent.java
+++ b/plugins/junit/src/com/intellij/execution/junit2/ui/model/CompletionEvent.java
@@ -23,7 +23,7 @@
public CompletionEvent(final boolean normalExit, final long time) {
super(normalExit ? TerminatedType.DONE: TerminatedType.TERNINATED,
- time >= 0 ? Formatters.printTime(time) : "");
+ time >= 0 ? "in " + Formatters.printTime(time) : "");
myNormalExit = normalExit;
}
diff --git a/plugins/junit_rt/src/com/intellij/junit3/JUnit3IdeaTestRunner.java b/plugins/junit_rt/src/com/intellij/junit3/JUnit3IdeaTestRunner.java
index 26562ca..1f027db 100644
--- a/plugins/junit_rt/src/com/intellij/junit3/JUnit3IdeaTestRunner.java
+++ b/plugins/junit_rt/src/com/intellij/junit3/JUnit3IdeaTestRunner.java
@@ -86,6 +86,10 @@
return myRegistry;
}
+ public String getTestClassName(Object child) {
+ return child instanceof TestSuite ? ((TestSuite)child).getName() : child.getClass().getName();
+ }
+
public String getStartDescription(Object child) {
final Test test = (Test)child;
if (test instanceof TestCase) {
@@ -126,15 +130,13 @@
}
public TestResult doRun(Test suite, boolean wait) { //todo
- if (mySendTree) {
- try {
- TreeSender.sendTree(this, suite);
- }
- catch (Exception e) {
- //noinspection HardCodedStringLiteral
- System.err.println("Internal Error occured.");
- e.printStackTrace(System.err);
- }
+ try {
+ TreeSender.sendTree(this, suite, mySendTree);
+ }
+ catch (Exception e) {
+ //noinspection HardCodedStringLiteral
+ System.err.println("Internal Error occured.");
+ e.printStackTrace(System.err);
}
return super.doRun(suite, wait);
}
diff --git a/plugins/junit_rt/src/com/intellij/junit4/JUnit4IdeaTestRunner.java b/plugins/junit_rt/src/com/intellij/junit4/JUnit4IdeaTestRunner.java
index 810ece9..42f6767 100644
--- a/plugins/junit_rt/src/com/intellij/junit4/JUnit4IdeaTestRunner.java
+++ b/plugins/junit_rt/src/com/intellij/junit4/JUnit4IdeaTestRunner.java
@@ -47,7 +47,7 @@
else if (request instanceof FilterRequest) {
description = getFilteredDescription(request, description);
}
- if (sendTree) TreeSender.sendTree(this, description);
+ TreeSender.sendTree(this, description, sendTree);
}
catch (Exception e) {
//noinspection HardCodedStringLiteral
@@ -175,6 +175,10 @@
return myRegistry;
}
+ public String getTestClassName(Object child) {
+ return ((Description)child).getClassName();
+ }
+
public String getStartDescription(Object child) {
final Description description = (Description)child;
final String methodName = description.getMethodName();
diff --git a/plugins/junit_rt/src/com/intellij/junit4/JUnit4TestRunnerUtil.java b/plugins/junit_rt/src/com/intellij/junit4/JUnit4TestRunnerUtil.java
index bcbd62b..b560569 100644
--- a/plugins/junit_rt/src/com/intellij/junit4/JUnit4TestRunnerUtil.java
+++ b/plugins/junit_rt/src/com/intellij/junit4/JUnit4TestRunnerUtil.java
@@ -120,8 +120,8 @@
if (clazzAnnotation == null) { //do not override external runners
try {
final Method method = clazz.getMethod(methodName, null);
- if (method != null && notForked && method.getAnnotation(Ignore.class) != null) { //override ignored case only
- final Request classRequest = createIgnoreIgnoredClassRequest(clazz);
+ if (method != null && notForked && (method.getAnnotation(Ignore.class) != null || clazz.getAnnotation(Ignore.class) != null)) { //override ignored case only
+ final Request classRequest = createIgnoreIgnoredClassRequest(clazz, true);
final Filter ignoredTestFilter = Filter.matchMethodDescription(Description.createTestDescription(clazz, methodName));
return classRequest.filterWith(new Filter() {
public boolean shouldRun(Description description) {
@@ -167,7 +167,7 @@
final Class clazz = (Class)result.get(0);
try {
if (clazz.getAnnotation(Ignore.class) != null) { //override ignored case only
- return createIgnoreIgnoredClassRequest(clazz);
+ return createIgnoreIgnoredClassRequest(clazz, false);
}
}
catch (ClassNotFoundException e) {
@@ -178,12 +178,12 @@
return Request.classes(getArrayOfClasses(result));
}
- private static Request createIgnoreIgnoredClassRequest(final Class clazz) throws ClassNotFoundException {
+ private static Request createIgnoreIgnoredClassRequest(final Class clazz, final boolean recursively) throws ClassNotFoundException {
Class.forName("org.junit.runners.BlockJUnit4ClassRunner"); //ignore IgnoreIgnored for junit4.4 and <
return new ClassRequest(clazz) {
public Runner getRunner() {
try {
- return new IgnoreIgnoredTestJUnit4ClassRunner(clazz);
+ return new IgnoreIgnoredTestJUnit4ClassRunner(clazz, recursively);
}
catch (Exception ignored) {
//return super runner
@@ -245,11 +245,18 @@
private static class IgnoreIgnoredTestJUnit4ClassRunner extends BlockJUnit4ClassRunner {
- public IgnoreIgnoredTestJUnit4ClassRunner(Class clazz) throws Exception {
+ private final boolean myRecursively;
+
+ public IgnoreIgnoredTestJUnit4ClassRunner(Class clazz, boolean recursively) throws Exception {
super(clazz);
+ myRecursively = recursively;
}
protected void runChild(FrameworkMethod method, RunNotifier notifier) {
+ if (!myRecursively){
+ super.runChild(method, notifier);
+ return;
+ }
final Description description = describeChild(method);
final EachTestNotifier eachNotifier = new EachTestNotifier(notifier, description);
eachNotifier.fireTestStarted();
diff --git a/plugins/junit_rt/src/com/intellij/rt/execution/junit/IdeaTestRunner.java b/plugins/junit_rt/src/com/intellij/rt/execution/junit/IdeaTestRunner.java
index 49e94d1..cd1cbb9 100644
--- a/plugins/junit_rt/src/com/intellij/rt/execution/junit/IdeaTestRunner.java
+++ b/plugins/junit_rt/src/com/intellij/rt/execution/junit/IdeaTestRunner.java
@@ -36,4 +36,6 @@
String getStartDescription(Object child);
OutputObjectRegistry getRegistry();
+
+ String getTestClassName(Object child);
}
\ No newline at end of file
diff --git a/plugins/junit_rt/src/com/intellij/rt/execution/junit/JUnitForkedStarter.java b/plugins/junit_rt/src/com/intellij/rt/execution/junit/JUnitForkedStarter.java
index 957c65e..3f3276a 100644
--- a/plugins/junit_rt/src/com/intellij/rt/execution/junit/JUnitForkedStarter.java
+++ b/plugins/junit_rt/src/com/intellij/rt/execution/junit/JUnitForkedStarter.java
@@ -19,6 +19,7 @@
import java.io.*;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
/**
@@ -26,7 +27,8 @@
* @since 6.04.2011
*/
public class JUnitForkedStarter {
- private JUnitForkedStarter() { }
+ private JUnitForkedStarter() {
+ }
public static void main(String[] args) throws Exception {
final String testOutputPath = args[0];
@@ -64,7 +66,8 @@
}
}
- static int startForkedVMs(String[] args,
+ static int startForkedVMs(String workingDirsPath,
+ String[] args,
boolean isJUnit4,
List listeners,
SegmentedOutputStream out,
@@ -88,19 +91,94 @@
final Object description = testRunner.getTestToStart(args);
if (description == null) return -1;
- TreeSender.sendTree(testRunner, description);
+ TreeSender.sendTree(testRunner, description, true);
long time = System.currentTimeMillis();
- final List children = testRunner.getChildTests(description);
- final boolean forkTillMethod = forkMode.equalsIgnoreCase("method");
- int result = processChildren(isJUnit4, listeners, out, err, parameters, testRunner, children, 0, forkTillMethod);
+ int result = 0;
+ if (workingDirsPath == null || new File(workingDirsPath).length() == 0) {
+ final List children = testRunner.getChildTests(description);
+ final boolean forkTillMethod = forkMode.equalsIgnoreCase("method");
+ result = processChildren(isJUnit4, listeners, out, err, parameters, testRunner, children, 0, forkTillMethod, null);
+ } else {
+ final BufferedReader perDirReader = new BufferedReader(new FileReader(workingDirsPath));
+ try {
+ final String packageName = perDirReader.readLine();
+ String workingDir;
+ while ((workingDir = perDirReader.readLine()) != null) {
+ try {
+ File tempFile = File.createTempFile("idea_junit", ".tmp");
+ tempFile.deleteOnExit();
+
+ final FileOutputStream writer = new FileOutputStream(tempFile);
+
+ List classNames = new ArrayList();
+ try {
+ final int classNamesSize = Integer.parseInt(perDirReader.readLine());
+ writer.write((packageName + ", working directory: \'" + workingDir + "\'\n").getBytes("UTF-8")); //instead of package name
+ for (int i = 0; i < classNamesSize; i++) {
+ String className = perDirReader.readLine();
+ if (className == null) {
+ System.err.println("Class name is expected. Working dir: " + workingDir);
+ return -1;
+ }
+ classNames.add(className);
+ writer.write((className + "\n").getBytes("UTF-8"));
+ }
+ }
+ finally {
+ writer.close();
+ }
+
+ final Object rootDescriptor = findByClassName(testRunner, (String)classNames.get(0), description);
+ final int childResult;
+ final File dir = new File(workingDir);
+ if (forkMode.equals("none")) {
+ childResult =
+ runChild(isJUnit4, listeners, out, err, parameters, "@" + tempFile.getAbsolutePath(), dir,
+ String.valueOf(testRunner.getRegistry().getKnownObject(rootDescriptor) - 1));
+ } else {
+ final List children = new ArrayList(testRunner.getChildTests(description));
+ for (Iterator iterator = children.iterator(); iterator.hasNext(); ) {
+ if (!classNames.contains(testRunner.getTestClassName(iterator.next()))) {
+ iterator.remove();
+ }
+ }
+ final boolean forkTillMethod = forkMode.equalsIgnoreCase("method");
+ childResult = processChildren(isJUnit4, listeners, out, err, parameters, testRunner, children, result, forkTillMethod, dir);
+ }
+ result = Math.min(childResult, result);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ finally {
+ perDirReader.close();
+ }
+ }
time = System.currentTimeMillis() - time;
new TimeSender(testRunner.getRegistry()).printHeader(time);
return result;
}
+ private static Object findByClassName(IdeaTestRunner testRunner, String className, Object rootDescription) {
+ final List children = testRunner.getChildTests(rootDescription);
+ for (int i = 0; i < children.size(); i++) {
+ Object child = children.get(i);
+ if (className.equals(testRunner.getTestClassName(child))) {
+ return child;
+ }
+ }
+ for (int i = 0; i < children.size(); i++) {
+ final Object byName = findByClassName(testRunner, className, children.get(i));
+ if (byName != null) return byName;
+ }
+ return null;
+ }
+
private static int processChildren(boolean isJUnit4,
List listeners,
SegmentedOutputStream out,
@@ -109,39 +187,47 @@
IdeaTestRunner testRunner,
List children,
int result,
- boolean forkTillMethod) throws IOException, InterruptedException {
+ boolean forkTillMethod, File workingDir) throws IOException, InterruptedException {
for (int i = 0, argsLength = children.size(); i < argsLength; i++) {
final Object child = children.get(i);
final List childTests = testRunner.getChildTests(child);
- final int childResult = childTests.isEmpty() || !forkTillMethod
- ? runChild(child, isJUnit4, listeners, out, err, parameters, testRunner, forkTillMethod)
- : processChildren(isJUnit4, listeners, out, err, parameters, testRunner, childTests, result, forkTillMethod);
+ final int childResult;
+ if (childTests.isEmpty() || !forkTillMethod) {
+ final int startIndex = testRunner.getRegistry().getKnownObject(child);
+ childResult =
+ runChild(isJUnit4, listeners, out, err, parameters, testRunner.getStartDescription(child), workingDir,
+ String.valueOf(startIndex));
+ }
+ else {
+ childResult =
+ processChildren(isJUnit4, listeners, out, err, parameters, testRunner, childTests, result, forkTillMethod, workingDir);
+ }
result = Math.min(childResult, result);
}
return result;
}
- private static int runChild(Object child,
- boolean isJUnit4,
+ private static int runChild(boolean isJUnit4,
List listeners,
SegmentedOutputStream out,
SegmentedOutputStream err,
List parameters,
- IdeaTestRunner testRunner,
- boolean forkTillMethod) throws IOException, InterruptedException {
+ String description,
+ File workingDir,
+ String startIndex) throws IOException, InterruptedException {
//noinspection SSBasedInspection
final File tempFile = File.createTempFile("fork", "test");
final String testOutputPath = tempFile.getAbsolutePath();
- final int knownObject = testRunner.getRegistry().getKnownObject(child);
final ProcessBuilder builder = new ProcessBuilder();
builder.add(parameters);
builder.add(JUnitForkedStarter.class.getName());
builder.add(testOutputPath);
- builder.add(String.valueOf(knownObject + (forkTillMethod ? 0 : 1)));
+ builder.add(startIndex);
builder.add(String.valueOf(isJUnit4));
- builder.add(testRunner.getStartDescription(child));
+ builder.add(description);
builder.add(listeners);
+ builder.setWorkingDir(workingDir);
final Process exec = builder.createProcess();
final int result = exec.waitFor();
diff --git a/plugins/junit_rt/src/com/intellij/rt/execution/junit/JUnitStarter.java b/plugins/junit_rt/src/com/intellij/rt/execution/junit/JUnitStarter.java
index 2097d54..d0a3a0e 100644
--- a/plugins/junit_rt/src/com/intellij/rt/execution/junit/JUnitStarter.java
+++ b/plugins/junit_rt/src/com/intellij/rt/execution/junit/JUnitStarter.java
@@ -36,6 +36,7 @@
private static final String SOCKET = "-socket";
private static String ourForkMode;
private static String ourCommandFileName;
+ private static String ourWorkingDirs;
public static boolean SM_RUNNER = System.getProperty("idea.junit.sm_runner") != null;
public static void main(String[] args) throws IOException {
@@ -77,7 +78,10 @@
isJunit4 = false;
}
else {
- if (arg.startsWith("@@@")) {
+ if (arg.startsWith("@w@")) {
+ ourWorkingDirs = arg.substring(3);
+ continue;
+ } else if (arg.startsWith("@@@")) {
final int pos = arg.indexOf(',');
ourForkMode = arg.substring(3, pos);
ourCommandFileName = arg.substring(pos + 1);
@@ -189,7 +193,9 @@
System.setOut(new PrintStream(out));
System.setErr(new PrintStream(err));
if (ourCommandFileName != null) {
- return JUnitForkedStarter.startForkedVMs(args, isJUnit4, listeners, out, err, ourForkMode, ourCommandFileName);
+ if (!"none".equals(ourForkMode) || new File(ourWorkingDirs).length() > 0) {
+ return JUnitForkedStarter.startForkedVMs(ourWorkingDirs, args, isJUnit4, listeners, out, err, ourForkMode, ourCommandFileName);
+ }
}
IdeaTestRunner testRunner = (IdeaTestRunner)getAgentClass(isJUnit4).newInstance();
testRunner.setStreams(out, err, 0);
diff --git a/plugins/junit_rt/src/com/intellij/rt/execution/junit/ProcessBuilder.java b/plugins/junit_rt/src/com/intellij/rt/execution/junit/ProcessBuilder.java
index 0f008da..f0c0b2a 100644
--- a/plugins/junit_rt/src/com/intellij/rt/execution/junit/ProcessBuilder.java
+++ b/plugins/junit_rt/src/com/intellij/rt/execution/junit/ProcessBuilder.java
@@ -15,6 +15,7 @@
*/
package com.intellij.rt.execution.junit;
+import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -28,6 +29,7 @@
private static final String WIN_SHELL_SPECIALS = "&<>()@^|";
private final List myParameters = new ArrayList();
+ private File myWorkingDir = null;
public void add(final String parameter) {
myParameters.add(parameter);
@@ -39,6 +41,10 @@
}
}
+ public void setWorkingDir(File workingDir) {
+ myWorkingDir = workingDir;
+ }
+
// please keep an implementation in sync with [util] CommandLineUtil.toCommandLine()
public Process createProcess() throws IOException {
if (myParameters.size() < 1) {
@@ -79,7 +85,7 @@
commandLine[i] = parameter;
}
- return Runtime.getRuntime().exec(commandLine);
+ return Runtime.getRuntime().exec(commandLine, null, myWorkingDir);
}
private static boolean containsAnyChar(String value, String chars) {
diff --git a/plugins/junit_rt/src/com/intellij/rt/execution/junit/TreeSender.java b/plugins/junit_rt/src/com/intellij/rt/execution/junit/TreeSender.java
index df805ee..f64d237 100644
--- a/plugins/junit_rt/src/com/intellij/rt/execution/junit/TreeSender.java
+++ b/plugins/junit_rt/src/com/intellij/rt/execution/junit/TreeSender.java
@@ -25,16 +25,18 @@
private TreeSender() {
}
- public static void sendTree(IdeaTestRunner runner, Object suite) {
+ public static void sendTree(IdeaTestRunner runner, Object suite, boolean sendTree) {
Packet packet = runner.getRegistry().createPacket();
packet.addString(PoolOfDelimiters.TREE_PREFIX);
Set objects = new HashSet();
sendNode(runner, suite, packet, objects);
- for (Iterator iterator = objects.iterator(); iterator.hasNext();) {
- ((Packet)iterator.next()).send();
+ if (sendTree) {
+ for (Iterator iterator = objects.iterator(); iterator.hasNext();) {
+ ((Packet)iterator.next()).send();
+ }
+ packet.addString("\n");
+ packet.send();
}
- packet.addString("\n");
- packet.send();
}
private static void sendNode(IdeaTestRunner runner, Object test, Packet packet, Collection objectPackets) {
diff --git a/plugins/maven/maven-server-api/src/org/jetbrains/idea/maven/server/MavenServerSettings.java b/plugins/maven/maven-server-api/src/org/jetbrains/idea/maven/server/MavenServerSettings.java
index 0038eff..6fcacb9 100644
--- a/plugins/maven/maven-server-api/src/org/jetbrains/idea/maven/server/MavenServerSettings.java
+++ b/plugins/maven/maven-server-api/src/org/jetbrains/idea/maven/server/MavenServerSettings.java
@@ -37,6 +37,17 @@
@NotNull private UpdatePolicy myPluginUpdatePolicy = UpdatePolicy.DO_NOT_UPDATE;
@NotNull private UpdatePolicy mySnapshotUpdatePolicy = UpdatePolicy.ALWAYS_UPDATE;
+ private String projectJdk;
+
+ @Nullable
+ public String getProjectJdk() {
+ return projectJdk;
+ }
+
+ public void setProjectJdk(@Nullable String projectJdk) {
+ this.projectJdk = projectJdk;
+ }
+
public int getLoggingLevel() {
return myLoggingLevel;
}
diff --git a/plugins/maven/maven3-server-impl/src/org/jetbrains/idea/maven/server/Maven3ServerEmbedderImpl.java b/plugins/maven/maven3-server-impl/src/org/jetbrains/idea/maven/server/Maven3ServerEmbedderImpl.java
index d0dbbb8..ffb419c 100644
--- a/plugins/maven/maven3-server-impl/src/org/jetbrains/idea/maven/server/Maven3ServerEmbedderImpl.java
+++ b/plugins/maven/maven3-server-impl/src/org/jetbrains/idea/maven/server/Maven3ServerEmbedderImpl.java
@@ -164,6 +164,10 @@
mySystemProperties = FieldAccessor.<Properties>get(cliRequestClass, cliRequest, "systemProperties");
+ if (settings.getProjectJdk() != null) {
+ mySystemProperties.setProperty("java.home", settings.getProjectJdk());
+ }
+
myMavenSettings = buildSettings(FieldAccessor.<SettingsBuilder>get(MavenCli.class, cli, "settingsBuilder"),
settings,
mySystemProperties,
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/DependencyConflictId.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/DependencyConflictId.java
new file mode 100644
index 0000000..75a2bd9
--- /dev/null
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/DependencyConflictId.java
@@ -0,0 +1,95 @@
+package org.jetbrains.idea.maven.dom;
+
+import com.intellij.openapi.util.text.StringUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.idea.maven.dom.model.MavenDomDependency;
+import org.jetbrains.idea.maven.model.MavenArtifact;
+
+/**
+ * See org.apache.maven.artifact.Artifact#getDependencyConflictId()
+ *
+ * @author Sergey Evdokimov
+ */
+public class DependencyConflictId {
+ private final String groupId;
+ private final String artifactId;
+ private final String type;
+ private final String classifier;
+
+ public DependencyConflictId(@NotNull String groupId, @NotNull String artifactId, @Nullable String type, @Nullable String classifier) {
+ this.groupId = groupId;
+ this.artifactId = artifactId;
+ this.type = StringUtil.isEmpty(type) ? "jar" : type;
+ this.classifier = classifier;
+ }
+
+ @Nullable
+ public static DependencyConflictId create(@NotNull MavenDomDependency dep) {
+ String groupId = dep.getGroupId().getStringValue();
+ if (StringUtil.isEmpty(groupId)) return null;
+
+ String artifactId = dep.getArtifactId().getStringValue();
+ if (StringUtil.isEmpty(artifactId)) return null;
+
+ //noinspection ConstantConditions
+ return new DependencyConflictId(groupId, artifactId, dep.getType().getStringValue(), dep.getClassifier().getStringValue());
+ }
+
+ @Nullable
+ public static DependencyConflictId create(@NotNull MavenArtifact dep) {
+ return create(dep.getGroupId(), dep.getArtifactId(), dep.getType(), dep.getClassifier());
+ }
+
+ @Nullable
+ public static DependencyConflictId create(String groupId, String artifactId, String type, String classifier) {
+ if (StringUtil.isEmpty(groupId)) return null;
+ if (StringUtil.isEmpty(artifactId)) return null;
+
+ return new DependencyConflictId(groupId, artifactId, type, classifier);
+ }
+
+ @NotNull
+ public String getGroupId() {
+ return groupId;
+ }
+
+ @NotNull
+ public String getArtifactId() {
+ return artifactId;
+ }
+
+ @NotNull
+ public String getType() {
+ return type;
+ }
+
+ @Nullable
+ public String getClassifier() {
+ return classifier;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof DependencyConflictId)) return false;
+
+ DependencyConflictId id = (DependencyConflictId)o;
+
+ if (!artifactId.equals(id.artifactId)) return false;
+ if (classifier != null ? !classifier.equals(id.classifier) : id.classifier != null) return false;
+ if (!groupId.equals(id.groupId)) return false;
+ if (!type.equals(id.type)) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = groupId.hashCode();
+ result = 31 * result + artifactId.hashCode();
+ result = 31 * result + type.hashCode();
+ result = 31 * result + (classifier != null ? classifier.hashCode() : 0);
+ return result;
+ }
+}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenDomProjectProcessorUtils.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenDomProjectProcessorUtils.java
index 246897a..c585131 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenDomProjectProcessorUtils.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenDomProjectProcessorUtils.java
@@ -16,6 +16,7 @@
package org.jetbrains.idea.maven.dom;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
@@ -24,6 +25,7 @@
import com.intellij.psi.xml.XmlTag;
import com.intellij.util.Function;
import com.intellij.util.Processor;
+import com.intellij.util.SmartList;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.hash.HashSet;
import com.intellij.util.xml.DomUtil;
@@ -164,10 +166,9 @@
public static Set<MavenDomDependency> searchDependencyUsages(@NotNull final MavenDomDependency dependency) {
final MavenDomProjectModel model = dependency.getParentOfType(MavenDomProjectModel.class, false);
if (model != null) {
- final String artifactId = dependency.getArtifactId().getStringValue();
- final String groupId = dependency.getGroupId().getStringValue();
- if (artifactId != null && groupId != null) {
- return searchDependencyUsages(model, groupId, artifactId, Collections.singleton(dependency));
+ DependencyConflictId dependencyId = DependencyConflictId.create(dependency);
+ if (dependencyId != null) {
+ return searchDependencyUsages(model, dependencyId, Collections.singleton(dependency));
}
}
return Collections.emptySet();
@@ -175,19 +176,8 @@
@NotNull
public static Set<MavenDomDependency> searchDependencyUsages(@NotNull final MavenDomProjectModel model,
- @NotNull final String groupId,
- @NotNull final String artifactId) {
- return searchDependencyUsages(model, groupId, artifactId, Collections.<MavenDomDependency>emptySet());
- }
-
- @NotNull
- public static Set<MavenDomDependency> searchDependencyUsages(@NotNull final MavenDomProjectModel model,
- @Nullable final String groupId,
- @Nullable final String artifactId,
+ @NotNull final DependencyConflictId dependencyId,
@NotNull final Set<MavenDomDependency> excludes) {
-
- if (groupId == null || artifactId == null) return Collections.emptySet();
-
Project project = model.getManager().getProject();
final Set<MavenDomDependency> usages = new HashSet<MavenDomDependency>();
Processor<MavenDomProjectModel> collectProcessor = new Processor<MavenDomProjectModel>() {
@@ -195,8 +185,8 @@
if (!model.equals(mavenDomProjectModel)) {
for (MavenDomDependency domDependency : mavenDomProjectModel.getDependencies().getDependencies()) {
if (excludes.contains(domDependency)) continue;
- if (artifactId.equals(domDependency.getArtifactId().getStringValue()) &&
- groupId.equals(domDependency.getGroupId().getStringValue())) {
+
+ if (dependencyId.equals(DependencyConflictId.create(domDependency))) {
usages.add(domDependency);
}
}
@@ -282,22 +272,6 @@
}
}
- @NotNull
- public static Set<MavenDomDependency> collectManagingDependencies(@NotNull MavenDomProjectModel model) {
- final Set<MavenDomDependency> dependencies = new HashSet<MavenDomDependency>();
-
- Processor<MavenDomDependencies> collectProcessor = new Processor<MavenDomDependencies>() {
- public boolean process(MavenDomDependencies mavenDomDependencies) {
- dependencies.addAll(mavenDomDependencies.getDependencies());
- return false;
- }
- };
-
- processDependenciesInDependencyManagement(model, collectProcessor, model.getManager().getProject());
-
- return dependencies;
- }
-
@Nullable
public static MavenDomDependency searchManagingDependency(@NotNull final MavenDomDependency dependency) {
return searchManagingDependency(dependency, dependency.getManager().getProject());
@@ -305,50 +279,29 @@
@Nullable
public static MavenDomDependency searchManagingDependency(@NotNull final MavenDomDependency dependency, @NotNull final Project project) {
- final String artifactId = dependency.getArtifactId().getStringValue();
- final String groupId = dependency.getGroupId().getStringValue();
- if (artifactId == null || groupId == null) return null;
+ final DependencyConflictId depId = DependencyConflictId.create(dependency);
+ if (depId == null) return null;
final MavenDomProjectModel model = dependency.getParentOfType(MavenDomProjectModel.class, false);
if (model == null) return null;
- SearchProcessor<MavenDomDependency, MavenDomDependencies> processor = new SearchProcessor<MavenDomDependency, MavenDomDependencies>() {
+ final Ref<MavenDomDependency> res = new Ref<MavenDomDependency>();
+
+ Processor<MavenDomDependency> processor = new Processor<MavenDomDependency>() {
@Override
- protected MavenDomDependency find(MavenDomDependencies mavenDomDependencies) {
- for (MavenDomDependency domDependency : mavenDomDependencies.getDependencies()) {
- if (artifactId.equals(domDependency.getArtifactId().getStringValue()) &&
- groupId.equals(domDependency.getGroupId().getStringValue())) {
- return domDependency;
- }
-
- if ("import".equals(domDependency.getScope().getRawText())) {
- GenericDomValue<String> version = domDependency.getVersion();
- if (version.getXmlElement() != null) {
- GenericDomValueReference reference = new GenericDomValueReference(version);
- PsiElement resolve = reference.resolve();
-
- if (resolve instanceof XmlFile) {
- MavenDomProjectModel dependModel = MavenDomUtil.getMavenDomModel((PsiFile)resolve, MavenDomProjectModel.class);
- if (dependModel != null) {
- for (MavenDomDependency dep : dependModel.getDependencyManagement().getDependencies().getDependencies()) {
- if (artifactId.equals(dep.getArtifactId().getStringValue()) &&
- groupId.equals(dep.getGroupId().getStringValue())) {
- return domDependency;
- }
- }
- }
- }
- }
- }
+ public boolean process(MavenDomDependency dependency) {
+ if (depId.equals(DependencyConflictId.create(dependency))) {
+ res.set(dependency);
+ return true;
}
- return null;
+ return false;
}
};
processDependenciesInDependencyManagement(model, processor, project);
- return processor.myResult;
+ return res.get();
}
@Nullable
@@ -388,16 +341,57 @@
public static boolean processDependenciesInDependencyManagement(@NotNull MavenDomProjectModel projectDom,
- @NotNull final Processor<MavenDomDependencies> processor,
+ @NotNull final Processor<MavenDomDependency> processor,
@NotNull final Project project) {
+ Processor<MavenDomDependencies> managedDependenciesListProcessor = new Processor<MavenDomDependencies>() {
+ @Override
+ public boolean process(MavenDomDependencies dependencies) {
+ SmartList<MavenDomDependency> importDependencies = null;
+
+ for (MavenDomDependency domDependency : dependencies.getDependencies()) {
+ if ("import".equals(domDependency.getScope().getRawText())) {
+ if (importDependencies == null) {
+ importDependencies = new SmartList<MavenDomDependency>();
+ }
+
+ importDependencies.add(domDependency);
+ }
+ else {
+ if (processor.process(domDependency)) return true;
+ }
+ }
+
+ if (importDependencies != null) {
+ for (MavenDomDependency domDependency : importDependencies) {
+ GenericDomValue<String> version = domDependency.getVersion();
+ if (version.getXmlElement() != null) {
+ GenericDomValueReference reference = new GenericDomValueReference(version);
+ PsiElement resolve = reference.resolve();
+
+ if (resolve instanceof XmlFile) {
+ MavenDomProjectModel dependModel = MavenDomUtil.getMavenDomModel((PsiFile)resolve, MavenDomProjectModel.class);
+ if (dependModel != null) {
+ for (MavenDomDependency dep : dependModel.getDependencyManagement().getDependencies().getDependencies()) {
+ if (processor.process(dep)) return true;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return false;
+ }
+ };
+
Function<MavenDomProjectModelBase, MavenDomDependencies> domFunction = new Function<MavenDomProjectModelBase, MavenDomDependencies>() {
public MavenDomDependencies fun(MavenDomProjectModelBase mavenDomProfile) {
return mavenDomProfile.getDependencyManagement().getDependencies();
}
};
- return process(projectDom, processor, project, domFunction, domFunction);
+ return process(projectDom, managedDependenciesListProcessor, project, domFunction, domFunction);
}
public static boolean processDependencies(@NotNull MavenDomProjectModel projectDom,
@@ -592,6 +586,4 @@
return myResult;
}
}
-
-
}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenPropertyResolver.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenPropertyResolver.java
index 514c243..652aa7a 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenPropertyResolver.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenPropertyResolver.java
@@ -16,8 +16,6 @@
package org.jetbrains.idea.maven.dom;
import com.intellij.openapi.module.Module;
-import com.intellij.openapi.projectRoots.Sdk;
-import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.xml.XmlElement;
import com.intellij.psi.xml.XmlTag;
@@ -36,7 +34,10 @@
import org.jetbrains.jps.maven.compiler.MavenEscapeWindowsCharacterUtils;
import java.io.IOException;
-import java.util.*;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -236,18 +237,16 @@
}
if ("java.home".equals(propName)) {
- Module module = projectsManager.findModule(mavenProject);
- if (module != null) {
- Sdk sdk = ModuleRootManager.getInstance(module).getSdk();
- if (sdk != null) {
- VirtualFile homeDirectory = sdk.getHomeDirectory();
- if (homeDirectory != null) {
- VirtualFile jreDir = homeDirectory.findChild("jre");
- if (jreDir != null) {
- return jreDir.getPath();
- }
- }
- }
+ String jreDir = MavenUtil.getModuleJreHome(projectsManager, mavenProject);
+ if (jreDir != null) {
+ return jreDir;
+ }
+ }
+
+ if ("java.version".equals(propName)) {
+ String javaVersion = MavenUtil.getModuleJavaVersion(projectsManager, mavenProject);
+ if (javaVersion != null) {
+ return javaVersion;
}
}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesArtifactIdConverter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesArtifactIdConverter.java
index 92caff0..b2ba34d 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesArtifactIdConverter.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesArtifactIdConverter.java
@@ -18,7 +18,9 @@
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.xml.ConvertContext;
import org.jetbrains.idea.maven.indices.MavenProjectIndicesManager;
+import org.jetbrains.idea.maven.model.MavenArtifact;
import org.jetbrains.idea.maven.model.MavenId;
+import org.jetbrains.idea.maven.project.MavenProject;
import java.util.Collections;
import java.util.Set;
@@ -27,7 +29,21 @@
@Override
protected boolean doIsValid(MavenId id, MavenProjectIndicesManager manager, ConvertContext context) {
if (StringUtil.isEmpty(id.getGroupId()) || StringUtil.isEmpty(id.getArtifactId())) return false;
- return manager.hasArtifactId(id.getGroupId(), id.getArtifactId());
+ if (manager.hasArtifactId(id.getGroupId(), id.getArtifactId())) {
+ return true;
+ }
+
+ // Check if artifact was found on importing.
+ MavenProject mavenProject = findMavenProject(context);
+ if (mavenProject != null) {
+ for (MavenArtifact artifact : mavenProject.findDependencies(id.getGroupId(), id.getArtifactId())) {
+ if (artifact.isResolved()) {
+ return true;
+ }
+ }
+ }
+
+ return false;
}
@Override
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesConverter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesConverter.java
index 0b365be..ed98ef1 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesConverter.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesConverter.java
@@ -33,12 +33,15 @@
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.jetbrains.idea.maven.dom.DependencyConflictId;
import org.jetbrains.idea.maven.dom.MavenDomBundle;
import org.jetbrains.idea.maven.dom.MavenDomProjectProcessorUtils;
import org.jetbrains.idea.maven.dom.MavenDomUtil;
import org.jetbrains.idea.maven.dom.model.*;
import org.jetbrains.idea.maven.indices.MavenProjectIndicesManager;
+import org.jetbrains.idea.maven.model.MavenArtifact;
import org.jetbrains.idea.maven.model.MavenId;
+import org.jetbrains.idea.maven.model.MavenPlugin;
import org.jetbrains.idea.maven.project.MavenProject;
import org.jetbrains.idea.maven.project.MavenProjectsManager;
import org.jetbrains.idea.maven.utils.MavenArtifactUtil;
@@ -52,7 +55,7 @@
if (s == null) return null;
MavenId id = MavenArtifactCoordinatesHelper.getId(context);
- MavenProjectIndicesManager manager = MavenProjectIndicesManager.getInstance(getProject(context));
+ MavenProjectIndicesManager manager = MavenProjectIndicesManager.getInstance(context.getProject());
return selectStrategy(context).isValid(id, manager, context) ? s : null;
}
@@ -65,7 +68,7 @@
@NotNull
public Collection<String> getVariants(ConvertContext context) {
- MavenProjectIndicesManager manager = MavenProjectIndicesManager.getInstance(getProject(context));
+ MavenProjectIndicesManager manager = MavenProjectIndicesManager.getInstance(context.getProject());
MavenId id = MavenArtifactCoordinatesHelper.getId(context);
MavenDomShortArtifactCoordinates coordinates = MavenArtifactCoordinatesHelper.getCoordinates(context);
@@ -77,17 +80,12 @@
@Override
public PsiElement resolve(String o, ConvertContext context) {
- Project p = getProject(context);
MavenId id = MavenArtifactCoordinatesHelper.getId(context);
- PsiFile result = selectStrategy(context).resolve(p, id, context);
+ PsiFile result = selectStrategy(context).resolve(id, context);
return result != null ? result : super.resolve(o, context);
}
- private static Project getProject(ConvertContext context) {
- return context.getFile().getProject();
- }
-
@Override
public String getErrorMessage(@Nullable String s, ConvertContext context) {
return selectStrategy(context).getContextName() + " '''" + MavenArtifactCoordinatesHelper.getId(context) + "''' not found";
@@ -120,6 +118,15 @@
return false;
}
+ @Nullable
+ protected MavenProject findMavenProject(ConvertContext context) {
+ PsiFile psiFile = context.getFile().getOriginalFile();
+ VirtualFile file = psiFile.getVirtualFile();
+ if (file == null) return null;
+
+ return MavenProjectsManager.getInstance(psiFile.getProject()).findProject(file);
+ }
+
private ConverterStrategy selectStrategy(ConvertContext context) {
if (MavenDomUtil.getImmediateParent(context, MavenDomProjectModel.class) != null) {
return new ProjectStrategy();
@@ -179,9 +186,9 @@
return doGetVariants(id, manager);
}
- public PsiFile resolve(Project project, MavenId id, ConvertContext context) {
- MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(project);
- PsiManager psiManager = PsiManager.getInstance(project);
+ public PsiFile resolve(MavenId id, ConvertContext context) {
+ PsiManager psiManager = context.getPsiManager();
+ MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(psiManager.getProject());
PsiFile result = resolveBySpecifiedPath();
if (result != null) return result;
@@ -212,7 +219,7 @@
return psiManager.findFile(virtualFile);
}
- protected File makeLocalRepositoryFile(MavenId id, File localRepository) {
+ private File makeLocalRepositoryFile(MavenId id, File localRepository) {
String relPath = (StringUtil.notNullize(id.getGroupId(), "null")).replace(".", "/");
relPath += "/" + id.getArtifactId();
@@ -225,7 +232,7 @@
private class ProjectStrategy extends ConverterStrategy {
@Override
- public PsiFile resolve(Project project, MavenId id, ConvertContext context) {
+ public PsiFile resolve(MavenId id, ConvertContext context) {
return null;
}
@@ -266,28 +273,39 @@
}
@Override
- public PsiFile resolve(Project project, MavenId id, ConvertContext context) {
- if (id.getVersion() == null && id.getGroupId() != null && id.getArtifactId() != null) {
- DomElement parent = context.getInvocationElement().getParent();
- if (parent instanceof MavenDomDependency) {
- MavenDomDependency managedDependency = MavenDomProjectProcessorUtils.searchManagingDependency((MavenDomDependency)parent);
- if (managedDependency != null && !"import".equals(managedDependency.getScope().getStringValue())) {
- final GenericDomValue<String> managedDependencyArtifactId = managedDependency.getArtifactId();
- PsiElement res = RecursionManager.doPreventingRecursion(managedDependencyArtifactId, false, new Computable<PsiElement>() {
- @Override
- public PsiElement compute() {
- return new GenericDomValueReference(managedDependencyArtifactId).resolve();
- }
- });
+ public PsiFile resolve(MavenId id, ConvertContext context) {
+ PsiFile res = super.resolve(id, context);
+ if (res != null) return res;
- if (res instanceof PsiFile) {
- return (PsiFile)res;
- }
- }
+ DomElement parent = context.getInvocationElement().getParent();
+ if (!(parent instanceof MavenDomDependency)) return null;
+
+ DependencyConflictId dependencyId = DependencyConflictId.create((MavenDomDependency)parent);
+ if (dependencyId == null) return null;
+
+ MavenProject mavenProject = findMavenProject(context);
+ if (mavenProject != null) {
+ MavenArtifact artifact = mavenProject.getDependencyArtifactIndex().findArtifacts(dependencyId);
+ if (artifact != null && artifact.isResolved()) {
+ return super.resolve(new MavenId(id.getGroupId(), id.getArtifactId(), artifact.getVersion()), context);
}
}
- return super.resolve(project, id, context);
+ if (id.getVersion() == null) {
+ MavenDomDependency managedDependency = MavenDomProjectProcessorUtils.searchManagingDependency((MavenDomDependency)parent);
+ if (managedDependency != null) {
+ final GenericDomValue<String> managedDependencyArtifactId = managedDependency.getArtifactId();
+ return RecursionManager.doPreventingRecursion(managedDependencyArtifactId, false, new Computable<PsiFile>() {
+ @Override
+ public PsiFile compute() {
+ PsiElement res = new GenericDomValueReference(managedDependencyArtifactId).resolve();
+ return res instanceof PsiFile ? (PsiFile)res : null;
+ }
+ });
+ }
+ }
+
+ return null;
}
@Override
@@ -313,7 +331,7 @@
private class ExclusionStrategy extends ConverterStrategy {
@Override
- public PsiFile resolve(Project project, MavenId id, ConvertContext context) {
+ public PsiFile resolve(MavenId id, ConvertContext context) {
return null;
}
@@ -369,8 +387,33 @@
}
@Override
- protected File makeLocalRepositoryFile(MavenId id, File localRepository) {
- return MavenArtifactUtil.getArtifactFile(localRepository, id.getGroupId(), id.getArtifactId(), id.getVersion(), "pom");
+ public PsiFile resolve(MavenId id, ConvertContext context) {
+ PsiFile res = super.resolve(id, context);
+ if (res != null) return res;
+
+ // Try to resolve to imported plugin
+ MavenProject mavenProject = findMavenProject(context);
+ if (mavenProject != null) {
+ for (MavenPlugin plugin : mavenProject.getPlugins()) {
+ if (MavenArtifactUtil.isPluginIdEquals(id.getGroupId(), id.getArtifactId(), plugin.getGroupId(), plugin.getArtifactId())) {
+ return super.resolve(plugin.getMavenId(), context);
+ }
+ }
+ }
+
+ // Try to resolve to plugin with latest version
+ PsiManager psiManager = context.getPsiManager();
+ MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(psiManager.getProject());
+
+ File artifactFile = MavenArtifactUtil
+ .getArtifactFile(projectsManager.getLocalRepository(), id.getGroupId(), id.getArtifactId(), id.getVersion(), "pom");
+
+ VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByIoFile(artifactFile);
+ if (virtualFile != null) {
+ return psiManager.findFile(virtualFile);
+ }
+
+ return null;
}
}
}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesGroupIdConverter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesGroupIdConverter.java
index 2a3b3d4..d441cde 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesGroupIdConverter.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesGroupIdConverter.java
@@ -4,7 +4,9 @@
import com.intellij.util.containers.hash.HashSet;
import com.intellij.util.xml.ConvertContext;
import org.jetbrains.idea.maven.indices.MavenProjectIndicesManager;
+import org.jetbrains.idea.maven.model.MavenArtifact;
import org.jetbrains.idea.maven.model.MavenId;
+import org.jetbrains.idea.maven.project.MavenProject;
import java.util.Collection;
import java.util.Set;
@@ -13,7 +15,21 @@
@Override
protected boolean doIsValid(MavenId id, MavenProjectIndicesManager manager, ConvertContext context) {
if (StringUtil.isEmpty(id.getGroupId())) return false;
- return manager.hasGroupId(id.getGroupId());
+
+ boolean res = manager.hasGroupId(id.getGroupId());
+ if (res) return true;
+
+ // Check if artifact was found on importing.
+ MavenProject mavenProject = findMavenProject(context);
+ if (mavenProject != null) {
+ for (MavenArtifact artifact : mavenProject.findDependencies(id.getGroupId(), id.getArtifactId())) {
+ if (artifact.isResolved()) {
+ return true;
+ }
+ }
+ }
+
+ return res;
}
@Override
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenDependencyTypeConverter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenDependencyTypeConverter.java
index 932a9a7..b4cb4a6 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenDependencyTypeConverter.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenDependencyTypeConverter.java
@@ -17,10 +17,14 @@
import com.intellij.util.xml.ConvertContext;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.idea.maven.model.MavenConstants;
import org.jetbrains.idea.maven.project.MavenProject;
+import org.jetbrains.idea.maven.project.MavenProjectsManager;
import org.jetbrains.idea.maven.project.SupportedRequestType;
import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.Set;
public class MavenDependencyTypeConverter extends MavenProjectConstantListConverter {
public MavenDependencyTypeConverter() {
@@ -29,6 +33,14 @@
@Override
protected Collection<String> getValues(@NotNull ConvertContext context, @NotNull MavenProject project) {
- return project.getSupportedDependencyTypes(SupportedRequestType.FOR_COMPLETION);
+ Set<String> res = new LinkedHashSet<String>();
+
+ res.addAll(MavenProjectsManager.getInstance(context.getProject()).getImportingSettings().getDependencyTypesAsSet());
+
+ res.add(MavenConstants.TYPE_POM);
+
+ res.addAll(project.getDependencyTypesFromImporters(SupportedRequestType.FOR_COMPLETION));
+
+ return res;
}
}
\ No newline at end of file
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/generate/GenerateManagedDependencyAction.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/generate/GenerateManagedDependencyAction.java
index b46b604..4909a48 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/generate/GenerateManagedDependencyAction.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/generate/GenerateManagedDependencyAction.java
@@ -21,17 +21,20 @@
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.Processor;
+import com.intellij.util.containers.hash.HashMap;
import com.intellij.util.containers.hash.HashSet;
import com.intellij.util.xml.ui.actions.generate.GenerateDomElementAction;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.idea.maven.dom.DependencyConflictId;
import org.jetbrains.idea.maven.dom.MavenDomBundle;
import org.jetbrains.idea.maven.dom.MavenDomProjectProcessorUtils;
import org.jetbrains.idea.maven.dom.MavenDomUtil;
-import org.jetbrains.idea.maven.dom.model.MavenDomDependencies;
import org.jetbrains.idea.maven.dom.model.MavenDomDependency;
import org.jetbrains.idea.maven.dom.model.MavenDomProjectModel;
+import java.util.Collection;
import java.util.List;
+import java.util.Map;
import java.util.Set;
public class GenerateManagedDependencyAction extends GenerateDomElementAction {
@@ -51,7 +54,7 @@
@Override
protected MavenDomDependency doGenerate(@NotNull final MavenDomProjectModel mavenModel, final Editor editor) {
- Set<MavenDomDependency> managingDependencies = collectManagingDependencies(mavenModel);
+ Collection<MavenDomDependency> managingDependencies = collectManagingDependencies(mavenModel);
final List<MavenDomDependency> dependenciesToOverride =
GenerateDependencyUtil.chooseDependencies(managingDependencies, mavenModel.getManager().getProject());
@@ -86,22 +89,23 @@
}
@NotNull
- public static Set<MavenDomDependency> collectManagingDependencies(@NotNull final MavenDomProjectModel model) {
- final Set<MavenDomDependency> dependencies = new HashSet<MavenDomDependency>();
+ public static Collection<MavenDomDependency> collectManagingDependencies(@NotNull final MavenDomProjectModel model) {
+ final Map<DependencyConflictId, MavenDomDependency> dependencies = new HashMap<DependencyConflictId, MavenDomDependency>();
- final List<MavenDomDependency> existingDependencies = model.getDependencies().getDependencies();
+ final Set<DependencyConflictId> existingDependencies = new HashSet<DependencyConflictId>();
+ for (MavenDomDependency dependency : model.getDependencies().getDependencies()) {
+ DependencyConflictId id = DependencyConflictId.create(dependency);
+ if (id != null) {
+ existingDependencies.add(id);
+ }
+ }
- Processor<MavenDomDependencies> collectProcessor = new Processor<MavenDomDependencies>() {
- public boolean process(MavenDomDependencies mavenDomDependencies) {
- if (!model.equals(mavenDomDependencies.getParentOfType(MavenDomProjectModel.class, true))) {
- for (MavenDomDependency dependency : mavenDomDependencies.getDependencies()) {
- String groupId = dependency.getGroupId().getStringValue();
- String artifactId = dependency.getArtifactId().getStringValue();
- if (StringUtil.isEmptyOrSpaces(groupId) || StringUtil.isEmptyOrSpaces(artifactId)) continue;
-
- if (!isDependencyExist(groupId, artifactId, existingDependencies)) {
- dependencies.add(dependency);
- }
+ Processor<MavenDomDependency> collectProcessor = new Processor<MavenDomDependency>() {
+ public boolean process(MavenDomDependency dependency) {
+ if (!model.equals(dependency.getParentOfType(MavenDomProjectModel.class, true))) {
+ DependencyConflictId id = DependencyConflictId.create(dependency);
+ if (id != null && !existingDependencies.contains(id) && !dependencies.containsKey(id)) {
+ dependencies.put(id, dependency);
}
}
return false;
@@ -110,16 +114,6 @@
MavenDomProjectProcessorUtils.processDependenciesInDependencyManagement(model, collectProcessor, model.getManager().getProject());
- return dependencies;
- }
-
- private static boolean isDependencyExist(String groupId, String artifactId, List<MavenDomDependency> existingDependencies) {
- for (MavenDomDependency existingDependency : existingDependencies) {
- if (groupId.equals(existingDependency.getGroupId().getStringValue()) ||
- artifactId.equals(existingDependency.getArtifactId().getStringValue())) {
- return true;
- }
- }
- return false;
+ return dependencies.values();
}
}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/model/completion/MavenVersionCompletionContributor.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/model/completion/MavenVersionCompletionContributor.java
index 10bcb78..9c88846 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/model/completion/MavenVersionCompletionContributor.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/model/completion/MavenVersionCompletionContributor.java
@@ -15,6 +15,7 @@
*/
package org.jetbrains.idea.maven.dom.model.completion;
+import com.google.common.collect.Sets;
import com.intellij.codeInsight.completion.*;
import com.intellij.codeInsight.completion.impl.NegatingComparable;
import com.intellij.codeInsight.lookup.LookupElement;
@@ -33,7 +34,9 @@
import org.jetbrains.idea.maven.dom.MavenVersionComparable;
import org.jetbrains.idea.maven.dom.converters.MavenArtifactCoordinatesVersionConverter;
import org.jetbrains.idea.maven.dom.model.MavenDomArtifactCoordinates;
+import org.jetbrains.idea.maven.dom.model.MavenDomPlugin;
import org.jetbrains.idea.maven.indices.MavenProjectIndicesManager;
+import org.jetbrains.idea.maven.utils.MavenArtifactUtil;
import java.util.Set;
@@ -72,22 +75,36 @@
String groupId = coordinates.getGroupId().getStringValue();
String artifactId = coordinates.getArtifactId().getStringValue();
- if (!StringUtil.isEmptyOrSpaces(groupId) && !StringUtil.isEmptyOrSpaces(artifactId)) {
- Set<String> versions = MavenProjectIndicesManager.getInstance(project).getVersions(groupId, artifactId);
+ if (StringUtil.isEmptyOrSpaces(artifactId)) return;
- CompletionResultSet newResultSet = result.withRelevanceSorter(CompletionService.getCompletionService().emptySorter().weigh(
- new LookupElementWeigher("mavenVersionWeigher") {
- @Nullable
- @Override
- public Comparable weigh(@NotNull LookupElement element) {
- return new NegatingComparable(new MavenVersionComparable(element.getLookupString()));
- }
- }));
+ CompletionResultSet newResultSet = result.withRelevanceSorter(CompletionService.getCompletionService().emptySorter().weigh(
+ new LookupElementWeigher("mavenVersionWeigher") {
+ @Nullable
+ @Override
+ public Comparable weigh(@NotNull LookupElement element) {
+ return new NegatingComparable(new MavenVersionComparable(element.getLookupString()));
+ }
+ }));
- for (String version : versions) {
- newResultSet.addElement(LookupElementBuilder.create(version));
+ MavenProjectIndicesManager indicesManager = MavenProjectIndicesManager.getInstance(project);
+
+ Set<String> versions;
+
+ if (StringUtil.isEmptyOrSpaces(groupId)) {
+ if (!(coordinates instanceof MavenDomPlugin)) return;
+
+ versions = indicesManager.getVersions(MavenArtifactUtil.DEFAULT_GROUPS[0], artifactId);
+ for (int i = 0; i < MavenArtifactUtil.DEFAULT_GROUPS.length; i++) {
+ versions = Sets.union(versions, indicesManager.getVersions(MavenArtifactUtil.DEFAULT_GROUPS[i], artifactId));
}
}
+ else {
+ versions = indicesManager.getVersions(groupId, artifactId);
+ }
+
+ for (String version : versions) {
+ newResultSet.addElement(LookupElementBuilder.create(version));
+ }
}
}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/refactorings/extract/ExtractManagedDependenciesAction.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/refactorings/extract/ExtractManagedDependenciesAction.java
index dcfa5c2..7312dbf 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/refactorings/extract/ExtractManagedDependenciesAction.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/refactorings/extract/ExtractManagedDependenciesAction.java
@@ -34,6 +34,7 @@
import com.intellij.util.xml.DomUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.jetbrains.idea.maven.dom.DependencyConflictId;
import org.jetbrains.idea.maven.dom.MavenDomProjectProcessorUtils;
import org.jetbrains.idea.maven.dom.MavenDomUtil;
import org.jetbrains.idea.maven.dom.model.MavenDomDependency;
@@ -83,14 +84,14 @@
MavenDomDependency.class);
if (dependency == null || isManagedDependency(dependency)) return null;
- Set<MavenDomProjectModel> parents = getParentProjects(file.getProject(), file);
+ Set<MavenDomProjectModel> parents = getParentProjects(file);
if (parents.isEmpty()) return null;
return Pair.create(dependency, parents);
}
@NotNull
- private static Set<MavenDomProjectModel> getParentProjects(@NotNull Project project, @NotNull PsiFile file) {
+ private static Set<MavenDomProjectModel> getParentProjects(@NotNull PsiFile file) {
final MavenDomProjectModel model = MavenDomUtil.getMavenDomModel(file, MavenDomProjectModel.class);
if (model == null) return Collections.emptySet();
@@ -134,13 +135,11 @@
if (typeValue != null) {
addedDependency.getType().setStringValue(typeValue);
- dependency.getType().undefine();
}
String classifier = dependency.getClassifier().getStringValue();
if (classifier != null) {
addedDependency.getClassifier().setStringValue(classifier);
- dependency.getClassifier().undefine();
}
String systemPath = dependency.getSystemPath().getStringValue();
@@ -219,10 +218,10 @@
return new Function<MavenDomProjectModel, Set<MavenDomDependency>>() {
public Set<MavenDomDependency> fun(MavenDomProjectModel model) {
- String groupId = dependency.getGroupId().getStringValue();
- String artifactId = dependency.getArtifactId().getStringValue();
+ DependencyConflictId dependencyId = DependencyConflictId.create(dependency);
+ if (dependencyId == null) return Collections.emptySet();
- return MavenDomProjectProcessorUtils.searchDependencyUsages(model, groupId, artifactId, Collections.singleton(dependency));
+ return MavenDomProjectProcessorUtils.searchDependencyUsages(model, dependencyId, Collections.singleton(dependency));
}
};
}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/references/MavenPropertyPsiReference.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/references/MavenPropertyPsiReference.java
index a11cad1..55db2bf 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/references/MavenPropertyPsiReference.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/references/MavenPropertyPsiReference.java
@@ -20,9 +20,6 @@
import com.intellij.lang.properties.IProperty;
import com.intellij.lang.properties.PropertiesLanguage;
import com.intellij.lang.properties.psi.PropertiesFile;
-import com.intellij.openapi.module.Module;
-import com.intellij.openapi.projectRoots.Sdk;
-import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.pom.Navigatable;
@@ -190,7 +187,14 @@
}
if ("java.home".equals(myText)) {
- PsiElement element = resolveToJavaHome(mavenProject);
+ PsiElement element = resolveToCustomSystemProperty("java.home", MavenUtil.getModuleJreHome(myProjectsManager, mavenProject));
+ if (element != null) {
+ return element;
+ }
+ }
+
+ if ("java.version".equals(myText)) {
+ PsiElement element = resolveToCustomSystemProperty("java.version", MavenUtil.getModuleJavaVersion(myProjectsManager, mavenProject));
if (element != null) {
return element;
}
@@ -236,21 +240,11 @@
}
@Nullable
- private PsiElement resolveToJavaHome(@NotNull MavenProject mavenProject) {
- Module module = myProjectsManager.findModule(mavenProject);
- if (module == null) return null;
-
- Sdk sdk = ModuleRootManager.getInstance(module).getSdk();
- if (sdk == null) return null;
-
- VirtualFile homeDirectory = sdk.getHomeDirectory();
- if (homeDirectory == null) return null;
-
- VirtualFile jreDir = homeDirectory.findChild("jre");
- if (jreDir == null) return null;
+ private PsiElement resolveToCustomSystemProperty(@NotNull String propertyName, @Nullable String propertyValue) {
+ if (propertyValue == null) return null;
PsiFile propFile = PsiFileFactory.getInstance(myProject).createFileFromText("SystemProperties.properties", PropertiesLanguage.INSTANCE,
- "java.home=" + jreDir.getPath());
+ propertyName + '=' + propertyValue);
return ((PropertiesFile)propFile).getProperties().get(0).getPsiElement();
}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/references/MavenPropertyPsiReferenceProvider.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/references/MavenPropertyPsiReferenceProvider.java
index 53ce16a..1108d8b 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/references/MavenPropertyPsiReferenceProvider.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/references/MavenPropertyPsiReferenceProvider.java
@@ -24,14 +24,11 @@
import com.intellij.psi.PsiReferenceProvider;
import com.intellij.psi.xml.XmlTag;
import com.intellij.util.ProcessingContext;
-import com.intellij.util.xml.DomElement;
-import com.intellij.util.xml.DomManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.maven.dom.MavenDomUtil;
-import org.jetbrains.idea.maven.dom.MavenPluginDomUtil;
import org.jetbrains.idea.maven.dom.MavenPropertyResolver;
-import org.jetbrains.idea.maven.dom.model.MavenDomConfiguration;
+import org.jetbrains.idea.maven.plugins.api.MavenPluginParamInfo;
import org.jetbrains.idea.maven.project.MavenProject;
import org.jetbrains.idea.maven.project.MavenProjectsManager;
@@ -50,18 +47,9 @@
private static boolean isElementCanContainReference(PsiElement element) {
if (element instanceof XmlTag) {
- if ("delimiter".equals(((XmlTag)element).getName())) {
- XmlTag delimitersTag = ((XmlTag)element).getParentTag();
- if (delimitersTag != null && "delimiters".equals(delimitersTag.getName())) {
- XmlTag configurationTag = delimitersTag.getParentTag();
- if (configurationTag != null && "configuration".equals(configurationTag.getName())) {
- DomElement configurationDom = DomManager.getDomManager(configurationTag.getProject()).getDomElement(configurationTag);
- if (configurationDom != null && configurationDom instanceof MavenDomConfiguration) {
- if (MavenPluginDomUtil.isPlugin((MavenDomConfiguration)configurationDom, "org.apache.maven.plugins", "maven-resources-plugin")) {
- return false;
- }
- }
- }
+ for (MavenPluginParamInfo.ParamInfo info : MavenPluginParamInfo.getParamInfoList((XmlTag)element)) {
+ if (Boolean.TRUE.equals(info.getParam().disableReferences)) {
+ return false;
}
}
}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenEditGoalDialog.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenEditGoalDialog.java
index 5bb135c..635e1da 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenEditGoalDialog.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenEditGoalDialog.java
@@ -19,10 +19,7 @@
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.fileTypes.PlainTextFileType;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.ui.ComboBox;
-import com.intellij.openapi.ui.DialogWrapper;
-import com.intellij.openapi.ui.FixedSizeButton;
-import com.intellij.openapi.ui.TextFieldWithBrowseButton;
+import com.intellij.openapi.ui.*;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.EditorComboBoxEditor;
import com.intellij.ui.EditorComboBoxRenderer;
@@ -117,6 +114,16 @@
});
}
+ @Nullable
+ @Override
+ protected ValidationInfo doValidate() {
+ if (workDirectoryField.getText().trim().isEmpty()) {
+ return new ValidationInfo("Working directory is empty", workDirectoryField);
+ }
+
+ return null;
+ }
+
@NotNull
public String getGoals() {
if (goalsComboBox != null) {
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenExecuteGoalDialog.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenExecuteGoalDialog.java
index dc238ba..997101b 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenExecuteGoalDialog.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenExecuteGoalDialog.java
@@ -20,7 +20,6 @@
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
-import java.awt.event.ActionEvent;
import java.util.Collection;
/**
@@ -37,14 +36,8 @@
@NotNull
@Override
protected Action getOKAction() {
- return new DialogWrapperAction("&Execute") {
- {
- putValue(DEFAULT_ACTION, Boolean.TRUE);
- }
- @Override
- protected void doAction(ActionEvent e) {
- doOKAction();
- }
- };
+ Action action = super.getOKAction();
+ action.putValue(Action.NAME, "&Execute");
+ return action;
}
}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenExternalParameters.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenExternalParameters.java
index 3b1881f..5873bcc 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenExternalParameters.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenExternalParameters.java
@@ -502,7 +502,7 @@
stringBuilder.append(",");
}
if (!entry.getValue()) {
- stringBuilder.append("-");
+ stringBuilder.append("!");
}
stringBuilder.append(entry.getKey());
}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunConfiguration.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunConfiguration.java
index 796f9b5..70daae8 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunConfiguration.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunConfiguration.java
@@ -15,10 +15,8 @@
*/
package org.jetbrains.idea.maven.execution;
-import com.intellij.execution.DefaultExecutionResult;
-import com.intellij.execution.ExecutionException;
-import com.intellij.execution.ExecutionResult;
-import com.intellij.execution.Executor;
+import com.intellij.diagnostic.logging.LogConfigurationPanel;
+import com.intellij.execution.*;
import com.intellij.execution.configurations.*;
import com.intellij.execution.process.OSProcessHandler;
import com.intellij.execution.process.ProcessAdapter;
@@ -27,6 +25,7 @@
import com.intellij.execution.runners.ProgramRunner;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.options.SettingsEditor;
+import com.intellij.openapi.options.SettingsEditorGroup;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.InvalidDataException;
@@ -36,9 +35,7 @@
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import org.jetbrains.idea.maven.project.MavenConsoleImpl;
-import org.jetbrains.idea.maven.project.MavenGeneralSettings;
-import org.jetbrains.idea.maven.project.MavenProjectsManager;
+import org.jetbrains.idea.maven.project.*;
public class MavenRunConfiguration extends RunConfigurationBase implements LocatableConfiguration, ModuleRunProfile {
private MavenSettings mySettings;
@@ -57,7 +54,14 @@
@Override
public SettingsEditor<? extends RunConfiguration> getConfigurationEditor() {
- return new MavenRunConfigurationSettings(getProject());
+ SettingsEditorGroup<MavenRunConfiguration> group = new SettingsEditorGroup<MavenRunConfiguration>();
+
+ group.addEditor(RunnerBundle.message("maven.runner.parameters.title"), new MavenRunnerParametersSettingEditor(getProject()));
+
+ group.addEditor(ProjectBundle.message("maven.tab.general"), new MavenGeneralSettingsEditor(getProject()));
+ group.addEditor(RunnerBundle.message("maven.tab.runner"), new MavenRunnerSettingsEditor(getProject()));
+ group.addEditor(ExecutionBundle.message("logs.tab.title"), new LogConfigurationPanel<MavenRunConfiguration>());
+ return group;
}
public JavaParameters createJavaParameters(@Nullable Project project) throws ExecutionException {
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunConfigurationSettings.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunConfigurationSettings.java
deleted file mode 100644
index d33b771..0000000
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunConfigurationSettings.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2000-2009 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 org.jetbrains.idea.maven.execution;
-
-import com.intellij.openapi.options.Configurable;
-import com.intellij.openapi.options.ConfigurationException;
-import com.intellij.openapi.options.SettingsEditor;
-import com.intellij.openapi.project.Project;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.jetbrains.idea.maven.project.MavenGeneralConfigurableWithUseProjectSettings;
-import org.jetbrains.idea.maven.project.MavenGeneralSettings;
-
-import javax.swing.*;
-
-/**
- * @author Vladislav.Kaznacheev
- */
-public class MavenRunConfigurationSettings extends SettingsEditor<MavenRunConfiguration> {
- private MavenRunConfiguration configuration;
- Configurable myCompositeConfigurable;
-
- public MavenRunConfigurationSettings(@NotNull final Project p) {
- myCompositeConfigurable = new CompositeConfigurable(
- new MavenRunnerParametersConfigurable(p) {
- protected MavenRunnerParameters getParameters() {
- return configuration.getRunnerParameters();
- }
- }, new MavenGeneralConfigurableWithUseProjectSettings(p) {
- protected MavenGeneralSettings getState() {
- return configuration.getGeneralSettings();
- }
-
- @Override
- public void setState(@Nullable MavenGeneralSettings state) {
- configuration.setGeneralSettings(state);
- }
- }, new MavenRunnerConfigurableWithUseProjectSettings(p) {
- protected MavenRunnerSettings getState() {
- return configuration.getRunnerSettings();
- }
-
- @Override
- public void setState(@Nullable MavenRunnerSettings state) {
- configuration.setRunnerSettings(state);
- }
- });
- }
-
- protected void resetEditorFrom(MavenRunConfiguration configuration) {
- this.configuration = configuration;
- myCompositeConfigurable.reset();
- }
-
- protected void applyEditorTo(MavenRunConfiguration configuration) throws ConfigurationException {
- this.configuration = configuration;
- myCompositeConfigurable.apply();
- }
-
- @NotNull
- protected JComponent createEditor() {
- return myCompositeConfigurable.createComponent();
- }
-
- protected void disposeEditor() {
- myCompositeConfigurable.disposeUIResources();
- }
-}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunConfigurationType.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunConfigurationType.java
index e61305e..6dd8743 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunConfigurationType.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunConfigurationType.java
@@ -59,7 +59,7 @@
MavenRunConfigurationType() {
myFactory = new ConfigurationFactory(this) {
public RunConfiguration createTemplateConfiguration(Project project) {
- throw new UnsupportedOperationException();
+ return new MavenRunConfiguration(project, this, "");
}
public RunConfiguration createTemplateConfiguration(Project project, RunManager runManager) {
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerConfigurable.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerConfigurable.java
index dc1d969..d001bd4 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerConfigurable.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerConfigurable.java
@@ -1,150 +1,26 @@
-/* ==========================================================================
- * Copyright 2006 Mevenide Team
- *
- * 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 org.jetbrains.idea.maven.execution;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.options.SearchableConfigurable;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.projectRoots.JavaSdk;
-import com.intellij.openapi.projectRoots.ProjectJdkTable;
-import com.intellij.openapi.projectRoots.Sdk;
-import com.intellij.openapi.roots.ProjectRootManager;
-import com.intellij.ui.IdeBorderFactory;
-import com.intellij.ui.RawCommandLineEditor;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import org.jetbrains.idea.maven.project.MavenProject;
-import org.jetbrains.idea.maven.project.MavenProjectsManager;
-import org.jetbrains.idea.maven.utils.ComboBoxUtil;
-import javax.swing.*;
-import java.awt.*;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Properties;
-
-public abstract class MavenRunnerConfigurable implements SearchableConfigurable, Configurable.NoScroll {
- protected final Project myProject;
- private final boolean myRunConfigurationMode;
-
- private JCheckBox myRunInBackgroundCheckbox;
- private RawCommandLineEditor myVMParametersEditor;
- private JComboBox myJdkCombo;
- private final DefaultComboBoxModel myJdkComboModel = new DefaultComboBoxModel();
- private JCheckBox mySkipTestsCheckBox;
- private MavenPropertiesPanel myPropertiesPanel;
-
- private Map<String, String> myProperties;
+/**
+ * @author Sergey Evdokimov
+ */
+public abstract class MavenRunnerConfigurable extends MavenRunnerPanel implements SearchableConfigurable, Configurable.NoScroll {
public MavenRunnerConfigurable(@NotNull Project p, boolean isRunConfiguration) {
- myProject = p;
- myRunConfigurationMode = isRunConfiguration;
+ super(p, isRunConfiguration);
}
@Nullable
protected abstract MavenRunnerSettings getState();
- public JComponent createComponent() {
- JPanel panel = new JPanel(new GridBagLayout());
-
- GridBagConstraints c = new GridBagConstraints();
- c.fill = GridBagConstraints.HORIZONTAL;
- c.anchor = GridBagConstraints.WEST;
- c.insets.bottom = 5;
-
- myRunInBackgroundCheckbox = new JCheckBox("Run in background");
- myRunInBackgroundCheckbox.setMnemonic('b');
- if (!myRunConfigurationMode) {
- c.gridx = 0;
- c.gridy++;
- c.weightx = 1;
- c.gridwidth = GridBagConstraints.REMAINDER;
-
- panel.add(myRunInBackgroundCheckbox, c);
- }
- c.gridwidth = 1;
-
- JLabel labelVMParameters = new JLabel("VM Options:");
- labelVMParameters.setDisplayedMnemonic('v');
- labelVMParameters.setLabelFor(myVMParametersEditor = new RawCommandLineEditor());
- myVMParametersEditor.setDialogCaption(labelVMParameters.getText());
-
- c.gridx = 0;
- c.gridy++;
- c.weightx = 0;
- panel.add(labelVMParameters, c);
-
- c.gridx = 1;
- c.weightx = 1;
- c.insets.left = 10;
- panel.add(myVMParametersEditor, c);
- c.insets.left = 0;
-
- JLabel jdkLabel = new JLabel("JRE:");
- jdkLabel.setDisplayedMnemonic('j');
- jdkLabel.setLabelFor(myJdkCombo = new JComboBox());
- c.gridx = 0;
- c.gridy++;
- c.weightx = 0;
- panel.add(jdkLabel, c);
- c.gridx = 1;
- c.weightx = 1;
- c.fill = GridBagConstraints.NONE;
- c.insets.left = 10;
- panel.add(myJdkCombo, c);
- c.insets.left = 0;
- c.fill = GridBagConstraints.HORIZONTAL;
-
- JPanel propertiesPanel = new JPanel(new BorderLayout());
- propertiesPanel.setBorder(IdeBorderFactory.createTitledBorder("Properties", false));
-
- propertiesPanel.add(mySkipTestsCheckBox = new JCheckBox("Skip tests"), BorderLayout.NORTH);
- mySkipTestsCheckBox.setMnemonic('t');
-
- collectProperties();
- propertiesPanel.add(myPropertiesPanel = new MavenPropertiesPanel(myProperties), BorderLayout.CENTER);
- myPropertiesPanel.getEmptyText().setText("No properties defined");
-
- c.gridx = 0;
- c.gridy++;
- c.weightx = c.weighty = 1;
- c.gridwidth = c.gridheight = GridBagConstraints.REMAINDER;
- c.fill = GridBagConstraints.BOTH;
- panel.add(propertiesPanel, c);
-
- return panel;
- }
-
- private void collectProperties() {
- MavenProjectsManager s = MavenProjectsManager.getInstance(myProject);
- Map<String, String> result = new LinkedHashMap<String, String>();
-
- for (MavenProject each : s.getProjects()) {
- Properties properties = each.getProperties();
- result.putAll((Map)properties);
- }
-
- myProperties = result;
- }
-
public boolean isModified() {
MavenRunnerSettings s = new MavenRunnerSettings();
setData(s);
@@ -183,59 +59,4 @@
public void disposeUIResources() {
}
-
- void getData(MavenRunnerSettings data) {
- myRunInBackgroundCheckbox.setSelected(data.isRunMavenInBackground());
- myVMParametersEditor.setText(data.getVmOptions());
- mySkipTestsCheckBox.setSelected(data.isSkipTests());
-
- Map<String, String> jdkMap = collectJdkNamesAndDescriptions();
- if (!jdkMap.containsKey(data.getJreName())) {
- jdkMap.put(data.getJreName(), data.getJreName());
- }
-
- myJdkComboModel.removeAllElements();
- for (Map.Entry<String, String> entry : jdkMap.entrySet()) {
- ComboBoxUtil.addToModel(myJdkComboModel, entry.getKey(), entry.getValue());
- }
- myJdkCombo.setModel(myJdkComboModel);
- ComboBoxUtil.select(myJdkComboModel, data.getJreName());
-
- myPropertiesPanel.setDataFromMap(data.getMavenProperties());
- }
-
- private Map<String, String> collectJdkNamesAndDescriptions() {
- Map<String, String> result = new LinkedHashMap<String, String>();
-
- for (Sdk projectJdk : ProjectJdkTable.getInstance().getSdksOfType(JavaSdk.getInstance())) {
- String name = projectJdk.getName();
- result.put(name, name);
- }
-
- result.put(MavenRunnerSettings.USE_INTERNAL_JAVA, RunnerBundle.message("maven.java.internal"));
-
- String projectJdkTitle;
-
- String projectJdk = ProjectRootManager.getInstance(myProject).getProjectSdkName();
- if (projectJdk == null) {
- projectJdkTitle = "Use Project JDK (not defined yet)";
- }
- else {
- projectJdkTitle = "Use Project JDK (" + projectJdk + ')';
- }
-
- result.put(MavenRunnerSettings.USE_PROJECT_JDK, projectJdkTitle);
- result.put(MavenRunnerSettings.USE_JAVA_HOME, RunnerBundle.message("maven.java.home.env"));
-
- return result;
- }
-
- void setData(MavenRunnerSettings data) {
- data.setRunMavenInBackground(myRunInBackgroundCheckbox.isSelected());
- data.setVmOptions(myVMParametersEditor.getText().trim());
- data.setSkipTests(mySkipTestsCheckBox.isSelected());
- data.setJreName(ComboBoxUtil.getSelectedString(myJdkComboModel));
-
- data.setMavenProperties(myPropertiesPanel.getDataAsMap());
- }
}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerConfigurableWithUseProjectSettings.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerConfigurableWithUseProjectSettings.java
deleted file mode 100644
index b6a636b..0000000
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerConfigurableWithUseProjectSettings.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright 2000-2012 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 org.jetbrains.idea.maven.execution;
-
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Pair;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.jetbrains.idea.maven.project.MavenDisablePanelCheckbox;
-
-import javax.swing.*;
-import java.awt.*;
-
-/**
- * @author Sergey Evdokimov
- */
-public abstract class MavenRunnerConfigurableWithUseProjectSettings extends MavenRunnerConfigurable {
-
- private JCheckBox myUseProjectSettings;
-
- public MavenRunnerConfigurableWithUseProjectSettings(@NotNull Project project) {
- super(project, true);
- }
-
- public abstract void setState(@Nullable MavenRunnerSettings state);
-
- @Override
- public boolean isModified() {
- if (myUseProjectSettings.isSelected()) {
- return getState() != null;
- }
- else {
- return getState() == null || super.isModified();
- }
- }
-
- @Override
- public void apply() {
- if (myUseProjectSettings.isSelected()) {
- setState(null);
- }
- else {
- MavenRunnerSettings state = getState();
- if (state != null) {
- setData(state);
- }
- else {
- MavenRunnerSettings settings = MavenRunner.getInstance(myProject).getSettings().clone();
- setData(settings);
- setState(settings);
- }
- }
- }
-
- @Override
- public void reset() {
- MavenRunnerSettings state = getState();
- myUseProjectSettings.setSelected(state == null);
-
- if (state == null) {
- MavenRunnerSettings settings = MavenRunner.getInstance(myProject).getSettings();
- getData(settings);
- }
- else {
- getData(state);
- }
- }
-
- @Override
- public JComponent createComponent() {
- Pair<JPanel,JCheckBox> pair = MavenDisablePanelCheckbox.createPanel(super.createComponent(), "Use project settings");
-
- myUseProjectSettings = pair.second;
- return pair.first;
- }
-
-
-}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerPanel.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerPanel.java
new file mode 100644
index 0000000..5043a8e
--- /dev/null
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerPanel.java
@@ -0,0 +1,197 @@
+/* ==========================================================================
+ * Copyright 2006 Mevenide Team
+ *
+ * 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 org.jetbrains.idea.maven.execution;
+
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.projectRoots.JavaSdk;
+import com.intellij.openapi.projectRoots.ProjectJdkTable;
+import com.intellij.openapi.projectRoots.Sdk;
+import com.intellij.openapi.roots.ProjectRootManager;
+import com.intellij.ui.IdeBorderFactory;
+import com.intellij.ui.RawCommandLineEditor;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.idea.maven.project.MavenProject;
+import org.jetbrains.idea.maven.project.MavenProjectsManager;
+import org.jetbrains.idea.maven.utils.ComboBoxUtil;
+
+import javax.swing.*;
+import java.awt.*;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Properties;
+
+public class MavenRunnerPanel {
+ protected final Project myProject;
+ private final boolean myRunConfigurationMode;
+
+ private JCheckBox myRunInBackgroundCheckbox;
+ private RawCommandLineEditor myVMParametersEditor;
+ private JComboBox myJdkCombo;
+ private final DefaultComboBoxModel myJdkComboModel = new DefaultComboBoxModel();
+ private JCheckBox mySkipTestsCheckBox;
+ private MavenPropertiesPanel myPropertiesPanel;
+
+ private Map<String, String> myProperties;
+
+ public MavenRunnerPanel(@NotNull Project p, boolean isRunConfiguration) {
+ myProject = p;
+ myRunConfigurationMode = isRunConfiguration;
+ }
+
+ public JComponent createComponent() {
+ JPanel panel = new JPanel(new GridBagLayout());
+
+ GridBagConstraints c = new GridBagConstraints();
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.anchor = GridBagConstraints.WEST;
+ c.insets.bottom = 5;
+
+ myRunInBackgroundCheckbox = new JCheckBox("Run in background");
+ myRunInBackgroundCheckbox.setMnemonic('b');
+ if (!myRunConfigurationMode) {
+ c.gridx = 0;
+ c.gridy++;
+ c.weightx = 1;
+ c.gridwidth = GridBagConstraints.REMAINDER;
+
+ panel.add(myRunInBackgroundCheckbox, c);
+ }
+ c.gridwidth = 1;
+
+ JLabel labelVMParameters = new JLabel("VM Options:");
+ labelVMParameters.setDisplayedMnemonic('v');
+ labelVMParameters.setLabelFor(myVMParametersEditor = new RawCommandLineEditor());
+ myVMParametersEditor.setDialogCaption(labelVMParameters.getText());
+
+ c.gridx = 0;
+ c.gridy++;
+ c.weightx = 0;
+ panel.add(labelVMParameters, c);
+
+ c.gridx = 1;
+ c.weightx = 1;
+ c.insets.left = 10;
+ panel.add(myVMParametersEditor, c);
+ c.insets.left = 0;
+
+ JLabel jdkLabel = new JLabel("JRE:");
+ jdkLabel.setDisplayedMnemonic('j');
+ jdkLabel.setLabelFor(myJdkCombo = new JComboBox());
+ c.gridx = 0;
+ c.gridy++;
+ c.weightx = 0;
+ panel.add(jdkLabel, c);
+ c.gridx = 1;
+ c.weightx = 1;
+ c.fill = GridBagConstraints.NONE;
+ c.insets.left = 10;
+ panel.add(myJdkCombo, c);
+ c.insets.left = 0;
+ c.fill = GridBagConstraints.HORIZONTAL;
+
+ JPanel propertiesPanel = new JPanel(new BorderLayout());
+ propertiesPanel.setBorder(IdeBorderFactory.createTitledBorder("Properties", false));
+
+ propertiesPanel.add(mySkipTestsCheckBox = new JCheckBox("Skip tests"), BorderLayout.NORTH);
+ mySkipTestsCheckBox.setMnemonic('t');
+
+ collectProperties();
+ propertiesPanel.add(myPropertiesPanel = new MavenPropertiesPanel(myProperties), BorderLayout.CENTER);
+ myPropertiesPanel.getEmptyText().setText("No properties defined");
+
+ c.gridx = 0;
+ c.gridy++;
+ c.weightx = c.weighty = 1;
+ c.gridwidth = c.gridheight = GridBagConstraints.REMAINDER;
+ c.fill = GridBagConstraints.BOTH;
+ panel.add(propertiesPanel, c);
+
+ return panel;
+ }
+
+ private void collectProperties() {
+ MavenProjectsManager s = MavenProjectsManager.getInstance(myProject);
+ Map<String, String> result = new LinkedHashMap<String, String>();
+
+ for (MavenProject each : s.getProjects()) {
+ Properties properties = each.getProperties();
+ result.putAll((Map)properties);
+ }
+
+ myProperties = result;
+ }
+
+ protected void getData(MavenRunnerSettings data) {
+ myRunInBackgroundCheckbox.setSelected(data.isRunMavenInBackground());
+ myVMParametersEditor.setText(data.getVmOptions());
+ mySkipTestsCheckBox.setSelected(data.isSkipTests());
+
+ Map<String, String> jdkMap = collectJdkNamesAndDescriptions();
+ if (!jdkMap.containsKey(data.getJreName())) {
+ jdkMap.put(data.getJreName(), data.getJreName());
+ }
+
+ myJdkComboModel.removeAllElements();
+ for (Map.Entry<String, String> entry : jdkMap.entrySet()) {
+ ComboBoxUtil.addToModel(myJdkComboModel, entry.getKey(), entry.getValue());
+ }
+ myJdkCombo.setModel(myJdkComboModel);
+ ComboBoxUtil.select(myJdkComboModel, data.getJreName());
+
+ myPropertiesPanel.setDataFromMap(data.getMavenProperties());
+ }
+
+ private Map<String, String> collectJdkNamesAndDescriptions() {
+ Map<String, String> result = new LinkedHashMap<String, String>();
+
+ for (Sdk projectJdk : ProjectJdkTable.getInstance().getSdksOfType(JavaSdk.getInstance())) {
+ String name = projectJdk.getName();
+ result.put(name, name);
+ }
+
+ result.put(MavenRunnerSettings.USE_INTERNAL_JAVA, RunnerBundle.message("maven.java.internal"));
+
+ String projectJdkTitle;
+
+ String projectJdk = ProjectRootManager.getInstance(myProject).getProjectSdkName();
+ if (projectJdk == null) {
+ projectJdkTitle = "Use Project JDK (not defined yet)";
+ }
+ else {
+ projectJdkTitle = "Use Project JDK (" + projectJdk + ')';
+ }
+
+ result.put(MavenRunnerSettings.USE_PROJECT_JDK, projectJdkTitle);
+ result.put(MavenRunnerSettings.USE_JAVA_HOME, RunnerBundle.message("maven.java.home.env"));
+
+ return result;
+ }
+
+ protected void setData(MavenRunnerSettings data) {
+ data.setRunMavenInBackground(myRunInBackgroundCheckbox.isSelected());
+ data.setVmOptions(myVMParametersEditor.getText().trim());
+ data.setSkipTests(mySkipTestsCheckBox.isSelected());
+ data.setJreName(ComboBoxUtil.getSelectedString(myJdkComboModel));
+
+ data.setMavenProperties(myPropertiesPanel.getDataAsMap());
+ }
+
+ public Project getProject() {
+ return myProject;
+ }
+}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerParametersConfigurable.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerParametersConfigurable.java
index 2611106..c8d9382 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerParametersConfigurable.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerParametersConfigurable.java
@@ -1,117 +1,19 @@
-/*
- * Copyright 2000-2009 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 org.jetbrains.idea.maven.execution;
-import com.intellij.codeInsight.completion.CompletionResultSet;
-import com.intellij.codeInsight.lookup.LookupElementBuilder;
-import com.intellij.execution.configurations.ParametersList;
-import com.intellij.icons.AllIcons;
-import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.ui.FixedSizeButton;
-import com.intellij.openapi.ui.LabeledComponent;
-import com.intellij.openapi.ui.TextFieldWithBrowseButton;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.ui.EditorTextField;
-import com.intellij.ui.PanelWithAnchor;
-import com.intellij.ui.components.JBLabel;
-import com.intellij.util.TextFieldCompletionProvider;
-import com.intellij.util.execution.ParametersListUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import org.jetbrains.idea.maven.model.MavenConstants;
-import org.jetbrains.idea.maven.project.MavenProjectsManager;
-import org.jetbrains.idea.maven.utils.Strings;
-
-import javax.swing.*;
-import java.util.LinkedHashMap;
-import java.util.Map;
/**
- * @author Vladislav.Kaznacheev
+ * @author Sergey Evdokimov
*/
-public abstract class MavenRunnerParametersConfigurable implements Configurable, PanelWithAnchor {
- private JPanel panel;
- protected LabeledComponent<TextFieldWithBrowseButton> workingDirComponent;
- protected LabeledComponent<EditorTextField> goalsComponent;
- private LabeledComponent<EditorTextField> profilesComponent;
- private JBLabel myFakeLabel;
- private JCheckBox myResolveToWorkspaceCheckBox;
- private FixedSizeButton showProjectTreeButton;
- private JComponent anchor;
+public abstract class MavenRunnerParametersConfigurable extends MavenRunnerParametersPanel implements Configurable {
- public MavenRunnerParametersConfigurable(@NotNull final Project project) {
- workingDirComponent.getComponent().addBrowseFolderListener(
- RunnerBundle.message("maven.select.maven.project.file"), "", project,
- new FileChooserDescriptor(false, true, false, false, false, false) {
- @Override
- public boolean isFileSelectable(VirtualFile file) {
- if (!super.isFileSelectable(file)) return false;
- return file.findChild(MavenConstants.POM_XML) != null;
- }
- });
-
- if (!project.isDefault()) {
- TextFieldCompletionProvider profilesCompletionProvider = new TextFieldCompletionProvider(true) {
- @Override
- protected final void addCompletionVariants(@NotNull String text, int offset, @NotNull String prefix, @NotNull CompletionResultSet result) {
- MavenProjectsManager manager = MavenProjectsManager.getInstance(project);
- for (String profile : manager.getAvailableProfiles()) {
- result.addElement(LookupElementBuilder.create(profile));
- }
- }
-
- @NotNull
- @Override
- protected String getPrefix(@NotNull String currentTextPrefix) {
- String prefix = super.getPrefix(currentTextPrefix);
- if (prefix.startsWith("-") || prefix.startsWith("!")) {
- prefix = prefix.substring(1);
- }
- return prefix;
- }
- };
-
- profilesComponent.setComponent(profilesCompletionProvider.createEditor(project));
-
- goalsComponent.setComponent(new MavenArgumentsCompletionProvider(project).createEditor(project));
- }
-
- showProjectTreeButton.setIcon(AllIcons.Actions.Module);
-
- MavenSelectProjectPopup.attachToWorkingDirectoryField(MavenProjectsManager.getInstance(project),
- workingDirComponent.getComponent().getTextField(),
- showProjectTreeButton,
- goalsComponent.getComponent());
-
- setAnchor(profilesComponent.getLabel());
- }
-
- public JComponent createComponent() {
- return panel;
- }
-
- public void disposeUIResources() {
- }
-
- public String getDisplayName() {
- return RunnerBundle.message("maven.runner.parameters.title");
+ public MavenRunnerParametersConfigurable(@NotNull Project project) {
+ super(project);
}
@Nullable
@@ -134,60 +36,6 @@
getData(getParameters());
}
- private void setData(final MavenRunnerParameters data) {
- data.setWorkingDirPath(workingDirComponent.getComponent().getText());
- data.setGoals(ParametersListUtil.parse(goalsComponent.getComponent().getText()));
- data.setResolveToWorkspace(myResolveToWorkspaceCheckBox.isSelected());
-
- Map<String, Boolean> profilesMap = new LinkedHashMap<String, Boolean>();
-
- for (String profile : Strings.tokenize(profilesComponent.getComponent().getText(), " ,;")) {
- Boolean isEnabled = true;
- if (profile.startsWith("-") || profile.startsWith("!")) {
- profile = profile.substring(1);
- if (profile.isEmpty()) continue;
-
- isEnabled = false;
- }
-
- profilesMap.put(profile, isEnabled);
- }
- data.setProfilesMap(profilesMap);
- }
-
- private void getData(final MavenRunnerParameters data) {
- workingDirComponent.getComponent().setText(data.getWorkingDirPath());
- goalsComponent.getComponent().setText(ParametersList.join(data.getGoals()));
- myResolveToWorkspaceCheckBox.setSelected(data.isResolveToWorkspace());
-
- StringBuilder sb = new StringBuilder();
- for (Map.Entry<String, Boolean> entry : data.getProfilesMap().entrySet()) {
- if (sb.length() != 0) {
- sb.append(" ");
- }
- if (!entry.getValue()) {
- sb.append("-");
- }
-
- sb.append(entry.getKey());
- }
-
- profilesComponent.getComponent().setText(sb.toString());
- }
-
protected abstract MavenRunnerParameters getParameters();
- @Override
- public JComponent getAnchor() {
- return anchor;
- }
-
- @Override
- public void setAnchor(JComponent anchor) {
- this.anchor = anchor;
- workingDirComponent.setAnchor(anchor);
- goalsComponent.setAnchor(anchor);
- profilesComponent.setAnchor(anchor);
- myFakeLabel.setAnchor(anchor);
- }
}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerParametersConfigurable.form b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerParametersPanel.form
similarity index 99%
rename from plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerParametersConfigurable.form
rename to plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerParametersPanel.form
index c17e596..1b420f3 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerParametersConfigurable.form
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerParametersPanel.form
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.idea.maven.execution.MavenRunnerParametersConfigurable">
+<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.idea.maven.execution.MavenRunnerParametersPanel">
<grid id="27dc6" binding="panel" layout-manager="GridLayoutManager" row-count="5" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerParametersPanel.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerParametersPanel.java
new file mode 100644
index 0000000..99f61d6
--- /dev/null
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerParametersPanel.java
@@ -0,0 +1,177 @@
+/*
+ * Copyright 2000-2009 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 org.jetbrains.idea.maven.execution;
+
+import com.intellij.codeInsight.completion.CompletionResultSet;
+import com.intellij.codeInsight.lookup.LookupElementBuilder;
+import com.intellij.execution.configurations.ParametersList;
+import com.intellij.icons.AllIcons;
+import com.intellij.openapi.fileChooser.FileChooserDescriptor;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.FixedSizeButton;
+import com.intellij.openapi.ui.LabeledComponent;
+import com.intellij.openapi.ui.TextFieldWithBrowseButton;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.ui.EditorTextField;
+import com.intellij.ui.PanelWithAnchor;
+import com.intellij.ui.components.JBLabel;
+import com.intellij.util.TextFieldCompletionProvider;
+import com.intellij.util.execution.ParametersListUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.idea.maven.execution.cmd.ParametersListLexer;
+import org.jetbrains.idea.maven.model.MavenConstants;
+import org.jetbrains.idea.maven.project.MavenProjectsManager;
+
+import javax.swing.*;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Vladislav.Kaznacheev
+ */
+public class MavenRunnerParametersPanel implements PanelWithAnchor {
+ private JPanel panel;
+ protected LabeledComponent<TextFieldWithBrowseButton> workingDirComponent;
+ protected LabeledComponent<EditorTextField> goalsComponent;
+ private LabeledComponent<EditorTextField> profilesComponent;
+ private JBLabel myFakeLabel;
+ private JCheckBox myResolveToWorkspaceCheckBox;
+ private FixedSizeButton showProjectTreeButton;
+ private JComponent anchor;
+
+ public MavenRunnerParametersPanel(@NotNull final Project project) {
+ workingDirComponent.getComponent().addBrowseFolderListener(
+ RunnerBundle.message("maven.select.maven.project.file"), "", project,
+ new FileChooserDescriptor(false, true, false, false, false, false) {
+ @Override
+ public boolean isFileSelectable(VirtualFile file) {
+ if (!super.isFileSelectable(file)) return false;
+ return file.findChild(MavenConstants.POM_XML) != null;
+ }
+ });
+
+ if (!project.isDefault()) {
+ TextFieldCompletionProvider profilesCompletionProvider = new TextFieldCompletionProvider(true) {
+ @Override
+ protected final void addCompletionVariants(@NotNull String text, int offset, @NotNull String prefix, @NotNull CompletionResultSet result) {
+ MavenProjectsManager manager = MavenProjectsManager.getInstance(project);
+ for (String profile : manager.getAvailableProfiles()) {
+ result.addElement(LookupElementBuilder.create(ParametersListUtil.join(profile)));
+ }
+ }
+
+ @NotNull
+ @Override
+ protected String getPrefix(@NotNull String currentTextPrefix) {
+ ParametersListLexer lexer = new ParametersListLexer(currentTextPrefix);
+ while (lexer.nextToken()) {
+ if (lexer.getTokenEnd() == currentTextPrefix.length()) {
+ String prefix = lexer.getCurrentToken();
+ if (prefix.startsWith("-") || prefix.startsWith("!")) {
+ prefix = prefix.substring(1);
+ }
+ return prefix;
+ }
+ }
+
+ return "";
+ }
+ };
+
+ profilesComponent.setComponent(profilesCompletionProvider.createEditor(project));
+
+ goalsComponent.setComponent(new MavenArgumentsCompletionProvider(project).createEditor(project));
+ }
+
+ showProjectTreeButton.setIcon(AllIcons.Actions.Module);
+
+ MavenSelectProjectPopup.attachToWorkingDirectoryField(MavenProjectsManager.getInstance(project),
+ workingDirComponent.getComponent().getTextField(),
+ showProjectTreeButton,
+ goalsComponent.getComponent());
+
+ setAnchor(profilesComponent.getLabel());
+ }
+
+ public JComponent createComponent() {
+ return panel;
+ }
+
+ public void disposeUIResources() {
+ }
+
+ public String getDisplayName() {
+ return RunnerBundle.message("maven.runner.parameters.title");
+ }
+
+ protected void setData(final MavenRunnerParameters data) {
+ data.setWorkingDirPath(workingDirComponent.getComponent().getText());
+ data.setGoals(ParametersListUtil.parse(goalsComponent.getComponent().getText()));
+ data.setResolveToWorkspace(myResolveToWorkspaceCheckBox.isSelected());
+
+ Map<String, Boolean> profilesMap = new LinkedHashMap<String, Boolean>();
+
+ List<String> profiles = ParametersListUtil.parse(profilesComponent.getComponent().getText());
+
+ for (String profile : profiles) {
+ Boolean isEnabled = true;
+ if (profile.startsWith("-") || profile.startsWith("!")) {
+ profile = profile.substring(1);
+ if (profile.isEmpty()) continue;
+
+ isEnabled = false;
+ }
+
+ profilesMap.put(profile, isEnabled);
+ }
+ data.setProfilesMap(profilesMap);
+ }
+
+ protected void getData(final MavenRunnerParameters data) {
+ workingDirComponent.getComponent().setText(data.getWorkingDirPath());
+ goalsComponent.getComponent().setText(ParametersList.join(data.getGoals()));
+ myResolveToWorkspaceCheckBox.setSelected(data.isResolveToWorkspace());
+
+ ParametersList parametersList = new ParametersList();
+
+ for (Map.Entry<String, Boolean> entry : data.getProfilesMap().entrySet()) {
+ String profileName = entry.getKey();
+
+ if (!entry.getValue()) {
+ profileName = '-' + profileName;
+ }
+
+ parametersList.add(profileName);
+ }
+
+ profilesComponent.getComponent().setText(parametersList.getParametersString());
+ }
+
+ @Override
+ public JComponent getAnchor() {
+ return anchor;
+ }
+
+ @Override
+ public void setAnchor(JComponent anchor) {
+ this.anchor = anchor;
+ workingDirComponent.setAnchor(anchor);
+ goalsComponent.setAnchor(anchor);
+ profilesComponent.setAnchor(anchor);
+ myFakeLabel.setAnchor(anchor);
+ }
+}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerParametersSettingEditor.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerParametersSettingEditor.java
new file mode 100644
index 0000000..5e0c59d
--- /dev/null
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerParametersSettingEditor.java
@@ -0,0 +1,41 @@
+package org.jetbrains.idea.maven.execution;
+
+import com.intellij.openapi.options.ConfigurationException;
+import com.intellij.openapi.options.SettingsEditor;
+import com.intellij.openapi.project.Project;
+import org.jetbrains.annotations.NotNull;
+
+import javax.swing.*;
+
+/**
+ * @author Sergey Evdokimov
+ */
+public class MavenRunnerParametersSettingEditor extends SettingsEditor<MavenRunConfiguration> {
+
+ private final MavenRunnerParametersPanel myPanel;
+
+ public MavenRunnerParametersSettingEditor(@NotNull Project project) {
+ myPanel = new MavenRunnerParametersPanel(project);
+ }
+
+ @Override
+ protected void resetEditorFrom(MavenRunConfiguration runConfiguration) {
+ myPanel.getData(runConfiguration.getRunnerParameters());
+ }
+
+ @Override
+ protected void applyEditorTo(MavenRunConfiguration runConfiguration) throws ConfigurationException {
+ myPanel.setData(runConfiguration.getRunnerParameters());
+ }
+
+ @NotNull
+ @Override
+ protected JComponent createEditor() {
+ return myPanel.createComponent();
+ }
+
+ @Override
+ protected void disposeEditor() {
+ myPanel.disposeUIResources();
+ }
+}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerSettingsEditor.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerSettingsEditor.java
new file mode 100644
index 0000000..87d9dea
--- /dev/null
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerSettingsEditor.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2000-2012 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 org.jetbrains.idea.maven.execution;
+
+import com.intellij.openapi.options.ConfigurationException;
+import com.intellij.openapi.options.SettingsEditor;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Pair;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.idea.maven.project.MavenDisablePanelCheckbox;
+
+import javax.swing.*;
+
+/**
+ * @author Sergey Evdokimov
+ */
+public class MavenRunnerSettingsEditor extends SettingsEditor<MavenRunConfiguration> {
+
+ private final MavenRunnerPanel myPanel;
+
+ private JCheckBox myUseProjectSettings;
+
+ public MavenRunnerSettingsEditor(@NotNull Project project) {
+ myPanel = new MavenRunnerPanel(project, true);
+ }
+
+ @Override
+ protected void resetEditorFrom(MavenRunConfiguration runConfiguration) {
+ myUseProjectSettings.setSelected(runConfiguration.getRunnerSettings() == null);
+
+ if (runConfiguration.getRunnerSettings() == null) {
+ MavenRunnerSettings settings = MavenRunner.getInstance(myPanel.getProject()).getSettings();
+ myPanel.getData(settings);
+ }
+ else {
+ myPanel.getData(runConfiguration.getRunnerSettings());
+ }
+ }
+
+ @Override
+ protected void applyEditorTo(MavenRunConfiguration runConfiguration) throws ConfigurationException {
+ if (myUseProjectSettings.isSelected()) {
+ runConfiguration.setRunnerSettings(null);
+ }
+ else {
+ if (runConfiguration.getRunnerSettings() != null) {
+ myPanel.setData(runConfiguration.getRunnerSettings());
+ }
+ else {
+ MavenRunnerSettings settings = MavenRunner.getInstance(myPanel.getProject()).getSettings().clone();
+ myPanel.setData(settings);
+ runConfiguration.setRunnerSettings(settings);
+ }
+ }
+ }
+
+ @NotNull
+ @Override
+ protected JComponent createEditor() {
+ Pair<JPanel,JCheckBox> pair = MavenDisablePanelCheckbox.createPanel(myPanel.createComponent(), "Use project settings");
+
+ myUseProjectSettings = pair.second;
+ return pair.first;
+ }
+
+ @Override
+ protected void disposeEditor() {
+
+ }
+}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenSelectProjectPopup.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenSelectProjectPopup.java
index 0d42f4a..124fe9f 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenSelectProjectPopup.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenSelectProjectPopup.java
@@ -75,8 +75,10 @@
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_DOWN) {
- e.consume();
- showModulesButton.doClick();
+ if (!e.isConsumed()) { // May be consumed by path completion.
+ e.consume();
+ showModulesButton.doClick();
+ }
}
}
});
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenModuleImporter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenModuleImporter.java
index 1140cbc..90f6743 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenModuleImporter.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenModuleImporter.java
@@ -15,6 +15,8 @@
*/
package org.jetbrains.idea.maven.importing;
+import com.intellij.openapi.application.AccessToken;
+import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleType;
import com.intellij.openapi.roots.*;
@@ -25,6 +27,7 @@
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.pom.java.LanguageLevel;
+import gnu.trove.THashSet;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -146,8 +149,26 @@
}
private void configDependencies() {
+ THashSet<String> dependencyTypesFromSettings = new THashSet<String>();
+
+ AccessToken accessToken = ReadAction.start();
+ try {
+ if (myModule.getProject().isDisposed()) return;
+
+ dependencyTypesFromSettings.addAll(MavenProjectsManager.getInstance(myModule.getProject()).getImportingSettings().getDependencyTypesAsSet());
+ }
+ finally {
+ accessToken.finish();
+ }
+
+
for (MavenArtifact artifact : myMavenProject.getDependencies()) {
- if (!myMavenProject.isSupportedDependency(artifact, SupportedRequestType.FOR_IMPORT)) continue;
+ String dependencyType = artifact.getType();
+
+ if (!dependencyTypesFromSettings.contains(dependencyType)
+ && !myMavenProject.getDependencyTypesFromImporters(SupportedRequestType.FOR_IMPORT).contains(dependencyType)) {
+ continue;
+ }
DependencyScope scope = selectScope(artifact.getScope());
@@ -155,7 +176,7 @@
if (depProject != null && !myMavenTree.isIgnored(depProject)) {
if (depProject == myMavenProject) continue;
- boolean isTestJar = MavenConstants.TYPE_TEST_JAR.equals(artifact.getType()) || "tests".equals(artifact.getClassifier());
+ boolean isTestJar = MavenConstants.TYPE_TEST_JAR.equals(dependencyType) || "tests".equals(artifact.getClassifier());
myRootModelAdapter.addModuleDependency(myMavenProjectToModuleName.get(depProject), scope, isTestJar);
Element buildHelperCfg = depProject.getPluginGoalConfiguration("org.codehaus.mojo", "build-helper-maven-plugin", "attach-artifact");
@@ -171,7 +192,7 @@
artifact.getArtifactId(),
artifact.getVersion(),
artifact.getBaseVersion(),
- artifact.getType(),
+ dependencyType,
artifact.getClassifier(),
artifact.getScope(),
artifact.isOptional(),
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenRootModelAdapter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenRootModelAdapter.java
index a21d560..b0c6b64 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenRootModelAdapter.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenRootModelAdapter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -163,7 +163,7 @@
}
public static boolean isEqualOrAncestor(String ancestor, String child) {
- return ancestor.equals(child) || StringUtil.startsWithConcatenationOf(child, ancestor, "/");
+ return ancestor.equals(child) || StringUtil.startsWithConcatenation(child, ancestor, "/");
}
private boolean exists(String path) {
@@ -352,7 +352,7 @@
urlExists = true;
continue;
}
- if (clearAll || isRepositoryUrl(artifact, url)) {
+ if (clearAll || (isRepositoryUrl(artifact, url) && !url.startsWith(newUrl))) {
library.removeRoot(url, type);
}
}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/configurers/MavenAnnotationProcessorConfigurer.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/configurers/MavenAnnotationProcessorConfigurer.java
index f160457..e5bfaa7 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/configurers/MavenAnnotationProcessorConfigurer.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/configurers/MavenAnnotationProcessorConfigurer.java
@@ -158,7 +158,7 @@
}
@Nullable
- private String getRelativeAnnotationProcessorDirectory(MavenProject mavenProject, boolean isTest) {
+ private static String getRelativeAnnotationProcessorDirectory(MavenProject mavenProject, boolean isTest) {
String annotationProcessorDirectory = mavenProject.getAnnotationProcessorDirectory(isTest);
File annotationProcessorDirectoryFile = new File(annotationProcessorDirectory);
if (!annotationProcessorDirectoryFile.isAbsolute()) {
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenArtifactSearchPanel.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenArtifactSearchPanel.java
index e1d78d1..1eb0cd3 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenArtifactSearchPanel.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenArtifactSearchPanel.java
@@ -97,14 +97,16 @@
add(pane, BorderLayout.CENTER);
mySearchField.getDocument().addDocumentListener(new DocumentAdapter() {
+ @Override
protected void textChanged(DocumentEvent e) {
scheduleSearch();
}
});
myResultList.addTreeSelectionListener(new TreeSelectionListener() {
+ @Override
public void valueChanged(TreeSelectionEvent e) {
- if (myAlarm.getActiveRequestCount() > 0) return;
+ if (!myAlarm.isEmpty()) return;
boolean hasSelection = !myResultList.isSelectionEmpty();
myListener.canSelectStateChanged(MavenArtifactSearchPanel.this, hasSelection);
@@ -146,6 +148,7 @@
myAlarm.cancelAllRequests();
myAlarm.addRequest(new Runnable() {
+ @Override
public void run() {
try {
doSearch(text);
@@ -163,6 +166,7 @@
final TreeModel model = new MyTreeModel(result);
SwingUtilities.invokeLater(new Runnable() {
+ @Override
public void run() {
if (!myDialog.isVisible()) return;
@@ -200,14 +204,17 @@
myItems = items;
}
+ @Override
public Object getRoot() {
return myItems;
}
+ @Override
public Object getChild(Object parent, int index) {
return getList(parent).get(index);
}
+ @Override
public int getChildCount(Object parent) {
List list = getList(parent);
assert list != null : parent;
@@ -220,20 +227,25 @@
return null;
}
+ @Override
public boolean isLeaf(Object node) {
return node != myItems && (getList(node) == null || getChildCount(node) < 2);
}
+ @Override
public int getIndexOfChild(Object parent, Object child) {
return getList(parent).indexOf(child);
}
+ @Override
public void valueForPathChanged(TreePath path, Object newValue) {
}
+ @Override
public void addTreeModelListener(TreeModelListener l) {
}
+ @Override
public void removeTreeModelListener(TreeModelListener l) {
}
}
@@ -296,6 +308,7 @@
});
}
+ @Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row,
boolean hasFocus) {
myLeftComponent.clear();
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/MavenNavigationUtil.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/MavenNavigationUtil.java
index 38cc7fd..e30c6e7 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/MavenNavigationUtil.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/MavenNavigationUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -46,8 +46,7 @@
public class MavenNavigationUtil {
private static final String ARTIFACT_ID = "artifactId";
- private MavenNavigationUtil() {
- }
+ private MavenNavigationUtil() { }
@Nullable
public static Navigatable createNavigatableForPom(final Project project, final VirtualFile file) {
@@ -82,7 +81,7 @@
MavenDomProjectModel projectModel = MavenDomUtil.getMavenDomProjectModel(project, file);
if (projectModel == null) return;
- MavenDomDependency dependency = findDependency(projectModel, artifact);
+ MavenDomDependency dependency = findDependency(projectModel, artifact.getGroupId(), artifact.getArtifactId());
if (dependency == null) return;
XmlTag artifactId = dependency.getArtifactId().getXmlTag();
@@ -91,41 +90,6 @@
navigate(project, artifactId.getContainingFile().getVirtualFile(), artifactId.getTextOffset() + artifactId.getName().length() + 2, requestFocus);
}
};
- //final File pom = MavenArtifactUtil.getArtifactFile(myProjectsManager.getLocalRepository(), artifact.getMavenId());
- //final VirtualFile vPom;
- //if (pom.exists()) {
- //vPom = LocalFileSystem.getInstance().findFileByIoFile(pom);
- //} else {
- // final MavenProject mp = myProjectsManager.findProject(artifact);
- // vPom = mp == null ? null : mp.getFile();
- //}
- //if (vPom != null) {
- // return new Navigatable.Adapter() {
- // public void navigate(boolean requestFocus) {
- // int offset = 0;
- // try {
- // int index = new String(vPom.contentsToByteArray()).indexOf("<artifactId>" + artifact.getArtifactId() + "</artifactId>");
- // if (index != -1) {
- // offset += index + 12;
- // }
- // }
- // catch (IOException e) {//
- // }
- // new OpenFileDescriptor(project, vPom, offset).navigate(requestFocus);
- // }
- // };
- //}
- //
- //final Module m = myProjectsManager.findModule(mavenProject);
- //if (m == null) return null;
- //final OrderEntry e = MavenRootModelAdapter.findLibraryEntry(m, artifact);
- //if (e == null) return null;
- //return new Navigatable.Adapter() {
- // public void navigate(boolean requestFocus) {
- // ProjectSettingsService.getInstance(project).openProjectLibrarySettings(new NamedLibraryElement(m, e));
- // }
- //};
-
}
@Nullable
@@ -135,14 +99,14 @@
}
@Nullable
- public static MavenDomDependency findDependency(@NotNull MavenDomProjectModel projectDom, @NotNull final MavenArtifact artifact) {
+ public static MavenDomDependency findDependency(@NotNull MavenDomProjectModel projectDom, final String groupId, final String artifactId) {
MavenDomProjectProcessorUtils.SearchProcessor<MavenDomDependency, MavenDomDependencies> processor = new MavenDomProjectProcessorUtils.SearchProcessor<MavenDomDependency, MavenDomDependencies>() {
@Nullable
@Override
protected MavenDomDependency find(MavenDomDependencies element) {
for (MavenDomDependency dependency : element.getDependencies()) {
- if (Comparing.equal(artifact.getGroupId(), dependency.getGroupId().getStringValue())
- && Comparing.equal(artifact.getArtifactId(), dependency.getArtifactId().getStringValue())) {
+ if (Comparing.equal(groupId, dependency.getGroupId().getStringValue()) &&
+ Comparing.equal(artifactId, dependency.getArtifactId().getStringValue())) {
return dependency;
}
}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/MavenProjectsNavigator.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/MavenProjectsNavigator.java
index 461ecba..34922db 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/MavenProjectsNavigator.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/MavenProjectsNavigator.java
@@ -159,6 +159,7 @@
if (isUnitTestMode()) return;
MavenUtil.runWhenInitialized(myProject, new DumbAwareRunnable() {
public void run() {
+ if (myProject.isDisposed()) return;
initToolWindow();
}
});
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/actions/MavenExecuteGoalAction.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/actions/MavenExecuteGoalAction.java
index 01186a5..55dd3e3 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/actions/MavenExecuteGoalAction.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/actions/MavenExecuteGoalAction.java
@@ -16,8 +16,13 @@
package org.jetbrains.idea.maven.navigator.actions;
import com.intellij.execution.configurations.ParametersList;
+import com.intellij.notification.Notification;
+import com.intellij.notification.NotificationListener;
+import com.intellij.notification.NotificationType;
+import com.intellij.notification.Notifications;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
+import com.intellij.openapi.options.ShowSettingsUtil;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
@@ -25,8 +30,10 @@
import org.jetbrains.idea.maven.project.MavenGeneralSettings;
import org.jetbrains.idea.maven.project.MavenProject;
import org.jetbrains.idea.maven.project.MavenProjectsManager;
+import org.jetbrains.idea.maven.utils.MavenSettings;
import org.jetbrains.idea.maven.utils.MavenUtil;
+import javax.swing.event.HyperlinkEvent;
import java.io.File;
import java.util.Arrays;
import java.util.LinkedHashMap;
@@ -37,8 +44,8 @@
*/
public class MavenExecuteGoalAction extends DumbAwareAction {
@Override
- public void actionPerformed(AnActionEvent e) {
- Project project = e.getRequiredData(PlatformDataKeys.PROJECT);
+ public void actionPerformed(final AnActionEvent e) {
+ final Project project = e.getRequiredData(PlatformDataKeys.PROJECT);
ExecuteMavenGoalHistoryService historyService = ExecuteMavenGoalHistoryService.getInstance(project);
@@ -77,8 +84,21 @@
File mavenHome = MavenUtil.resolveMavenHomeDirectory(projectsManager.getGeneralSettings().getMavenHome());
if (mavenHome == null) {
- // todo handle
- throw new RuntimeException();
+ Notification notification = new Notification(MavenUtil.MAVEN_NOTIFICATION_GROUP,
+ "Failed to execute goal",
+ RunnerBundle.message("external.maven.home.no.default.with.fix"), NotificationType.ERROR,
+ new NotificationListener() {
+ @Override
+ public void hyperlinkUpdate(@NotNull Notification notification,
+ @NotNull HyperlinkEvent event) {
+ if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
+ ShowSettingsUtil.getInstance().showSettingsDialog(project, MavenSettings.DISPLAY_NAME);
+ }
+ }
+ });
+
+ Notifications.Bus.notify(notification, project);
+ return;
}
MavenRunnerParameters parameters = new MavenRunnerParameters(true, workDirectory, Arrays.asList(ParametersList.parse(goals)), null);
@@ -99,17 +119,4 @@
return rootProjects.get(0).getDirectory();
}
-
- @Override
- public void update(AnActionEvent e) {
- Project project = e.getData(PlatformDataKeys.PROJECT);
-
- boolean hasMaven = false;
-
- if (project != null) {
- hasMaven = MavenProjectsManager.getInstance(project).hasProjects();
- }
-
- e.getPresentation().setVisible(hasMaven);
- }
}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/plugins/api/MavenPluginConfigurationLanguageInjector.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/plugins/api/MavenPluginConfigurationLanguageInjector.java
index bf8e6ad..262cfed 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/plugins/api/MavenPluginConfigurationLanguageInjector.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/plugins/api/MavenPluginConfigurationLanguageInjector.java
@@ -21,9 +21,7 @@
import com.intellij.psi.LanguageInjector;
import com.intellij.psi.PsiLanguageInjectionHost;
import com.intellij.psi.xml.XmlText;
-import com.intellij.util.PairProcessor;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.idea.maven.dom.model.MavenDomConfiguration;
/**
* @author Sergey Evdokimov
@@ -38,24 +36,21 @@
if (!MavenPluginParamInfo.isSimpleText(xmlText)) return;
- MavenPluginParamInfo.processParamInfo(xmlText, new PairProcessor<MavenPluginParamInfo.ParamInfo, MavenDomConfiguration>() {
- @Override
- public boolean process(MavenPluginParamInfo.ParamInfo info, MavenDomConfiguration configuration) {
- Language language = info.getLanguage();
+ MavenPluginParamInfo.ParamInfoList infoList = MavenPluginParamInfo.getParamInfoList(xmlText);
+ for (MavenPluginParamInfo.ParamInfo info : infoList) {
+ Language language = info.getLanguage();
- if (language == null) {
- MavenParamLanguageProvider provider = info.getLanguageProvider();
- if (provider != null) {
- language = provider.getLanguage(xmlText, configuration);
- }
+ if (language == null) {
+ MavenParamLanguageProvider provider = info.getLanguageProvider();
+ if (provider != null) {
+ language = provider.getLanguage(xmlText, infoList.getDomCfg());
}
-
- if (language != null) {
- injectionPlacesRegistrar.addPlace(language, TextRange.from(0, host.getTextLength()), info.getLanguageInjectionPrefix(), info.getLanguageInjectionSuffix());
- return false;
- }
- return true;
}
- });
+
+ if (language != null) {
+ injectionPlacesRegistrar.addPlace(language, TextRange.from(0, host.getTextLength()), info.getLanguageInjectionPrefix(), info.getLanguageInjectionSuffix());
+ return;
+ }
+ }
}
}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/plugins/api/MavenPluginDescriptor.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/plugins/api/MavenPluginDescriptor.java
index 8350dc4..c066328 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/plugins/api/MavenPluginDescriptor.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/plugins/api/MavenPluginDescriptor.java
@@ -73,6 +73,12 @@
public Boolean soft;
/**
+ * Disallow to add standard maven references to parameter like <delimiter>$$</delimiter>, see MavenPropertyPsiReferenceProvider
+ */
+ @Attribute("disableReferences")
+ public Boolean disableReferences;
+
+ /**
* Language to inject.
*/
@Attribute("language")
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/plugins/api/MavenPluginParamInfo.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/plugins/api/MavenPluginParamInfo.java
index a613e4d..a987c94 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/plugins/api/MavenPluginParamInfo.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/plugins/api/MavenPluginParamInfo.java
@@ -10,17 +10,15 @@
import com.intellij.psi.xml.XmlTag;
import com.intellij.psi.xml.XmlText;
import com.intellij.psi.xml.XmlTokenType;
-import com.intellij.util.PairProcessor;
import com.intellij.util.ProcessingContext;
+import com.intellij.util.SmartList;
import com.intellij.util.xml.DomElement;
import com.intellij.util.xml.DomManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.maven.dom.model.*;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.StringTokenizer;
+import java.util.*;
/**
* @author Sergey Evdokimov
@@ -98,20 +96,24 @@
return true;
}
- public static void processParamInfo(@NotNull XmlText paramValue, @NotNull PairProcessor<ParamInfo, MavenDomConfiguration> processor) {
- XmlTag paramTag = paramValue.getParentTag();
- if (paramTag == null) return;
+ public static ParamInfoList getParamInfoList(@NotNull XmlText paramValue) {
+ XmlTag tag = paramValue.getParentTag();
+ if (tag == null) return ParamInfoList.EMPTY;
+ return getParamInfoList(tag);
+ }
+
+ public static ParamInfoList getParamInfoList(@NotNull XmlTag paramTag) {
XmlTag configurationTag = paramTag;
DomElement domElement;
Map m = getMap().get(paramTag.getName());
while (true) {
- if (m == null) return;
+ if (m == null) return ParamInfoList.EMPTY;
configurationTag = configurationTag.getParentTag();
- if (configurationTag == null) return;
+ if (configurationTag == null) return ParamInfoList.EMPTY;
String tagName = configurationTag.getName();
if ("configuration".equals(tagName)) {
@@ -120,7 +122,7 @@
break;
}
- if (domElement != null) return;
+ if (domElement != null) return ParamInfoList.EMPTY;
}
m = (Map)m.get(tagName);
@@ -131,7 +133,7 @@
MavenDomConfiguration domCfg = (MavenDomConfiguration)domElement;
MavenDomPlugin domPlugin = domCfg.getParentOfType(MavenDomPlugin.class, true);
- if (domPlugin == null) return;
+ if (domPlugin == null) return ParamInfoList.EMPTY;
String pluginGroupId = domPlugin.getGroupId().getStringValue();
String pluginArtifactId = domPlugin.getArtifactId().getStringValue();
@@ -148,22 +150,62 @@
goalsMap = pluginsMap.get(Pair.create(pluginGroupId, pluginArtifactId));
}
- if (goalsMap == null) return;
+ if (goalsMap == null) return ParamInfoList.EMPTY;
DomElement parent = domCfg.getParent();
if (parent instanceof MavenDomPluginExecution) {
+ SmartList<ParamInfo> infos = null;
+
MavenDomGoals goals = ((MavenDomPluginExecution)parent).getGoals();
for (MavenDomGoal goal : goals.getGoals()) {
ParamInfo info = goalsMap.get(goal.getStringValue());
if (info != null) {
- if (!processor.process(info, domCfg)) return;
+ if (infos == null) {
+ infos = new SmartList<ParamInfo>();
+ }
+
+ infos.add(info);
}
}
+
+ if (infos != null) {
+ ParamInfo defaultInfo = goalsMap.get(null);
+ if (defaultInfo != null) {
+ infos.add(defaultInfo);
+ }
+
+ return new ParamInfoList(domCfg, infos);
+ }
}
ParamInfo defaultInfo = goalsMap.get(null);
if (defaultInfo != null) {
- if (!processor.process(defaultInfo, domCfg)) return;
+ return new ParamInfoList(domCfg, Collections.singletonList(defaultInfo));
+ }
+
+ return ParamInfoList.EMPTY;
+ }
+
+ public static class ParamInfoList implements Iterable<ParamInfo> {
+
+ private static final ParamInfoList EMPTY = new ParamInfoList(null, Collections.<ParamInfo>emptyList());
+
+ private final MavenDomConfiguration domCfg;
+
+ private final List<ParamInfo> paramInfos;
+
+ ParamInfoList(MavenDomConfiguration domCfg, @NotNull List<ParamInfo> paramInfos) {
+ this.domCfg = domCfg;
+ this.paramInfos = paramInfos;
+ }
+
+ public MavenDomConfiguration getDomCfg() {
+ return domCfg;
+ }
+
+ @Override
+ public Iterator<ParamInfo> iterator() {
+ return paramInfos.iterator();
}
}
@@ -216,6 +258,10 @@
return myLanguageProvider;
}
+ public MavenPluginDescriptor.Param getParam() {
+ return myParam;
+ }
+
public String getLanguageInjectionPrefix() {
return myParam.languageInjectionPrefix;
}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/plugins/api/MavenPluginParamReferenceContributor.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/plugins/api/MavenPluginParamReferenceContributor.java
index 6263d99..298bc9f 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/plugins/api/MavenPluginParamReferenceContributor.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/plugins/api/MavenPluginParamReferenceContributor.java
@@ -20,10 +20,8 @@
import com.intellij.psi.*;
import com.intellij.psi.xml.XmlText;
import com.intellij.psi.xml.XmlTokenType;
-import com.intellij.util.PairProcessor;
import com.intellij.util.ProcessingContext;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.idea.maven.dom.model.MavenDomConfiguration;
import static org.jetbrains.idea.maven.plugins.api.MavenPluginParamInfo.ParamInfo;
@@ -50,29 +48,14 @@
if (!MavenPluginParamInfo.isSimpleText(xmlText)) return PsiReference.EMPTY_ARRAY;
- class MyProcessor implements PairProcessor<ParamInfo, MavenDomConfiguration> {
- PsiReference[] result;
-
- @Override
- public boolean process(ParamInfo info, MavenDomConfiguration domCfg) {
- MavenParamReferenceProvider providerInstance = info.getProviderInstance();
- if (providerInstance != null) {
- result = providerInstance.getReferencesByElement(xmlText, domCfg, context);
- return false;
- }
-
- return true;
+ MavenPluginParamInfo.ParamInfoList paramInfos = MavenPluginParamInfo.getParamInfoList(xmlText);
+ for (ParamInfo info : paramInfos) {
+ MavenParamReferenceProvider providerInstance = info.getProviderInstance();
+ if (providerInstance != null) {
+ return providerInstance.getReferencesByElement(xmlText, paramInfos.getDomCfg(), context);
}
}
- MyProcessor processor = new MyProcessor();
-
- MavenPluginParamInfo.processParamInfo(xmlText, processor);
-
- if (processor.result != null) {
- return processor.result;
- }
-
return PsiReference.EMPTY_ARRAY;
}
}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/plugins/groovy/MavenGroovyPomScriptMemberContributor.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/plugins/groovy/MavenGroovyPomScriptMemberContributor.java
new file mode 100644
index 0000000..0fce635
--- /dev/null
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/plugins/groovy/MavenGroovyPomScriptMemberContributor.java
@@ -0,0 +1,46 @@
+package org.jetbrains.idea.maven.plugins.groovy;
+
+import com.intellij.psi.*;
+import com.intellij.psi.scope.PsiScopeProcessor;
+import com.intellij.psi.xml.XmlFile;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.groovy.lang.resolve.NonCodeMembersContributor;
+import org.jetbrains.plugins.groovy.util.dynamicMembers.DynamicMemberUtils;
+
+/**
+ * @author Sergey Evdokimov
+ */
+public class MavenGroovyPomScriptMemberContributor extends NonCodeMembersContributor {
+
+ private static final String CLASS_SOURCE = "class PomElements {\n" +
+ " org.apache.maven.project.MavenProject project;\n" +
+ " org.apache.maven.project.MavenProject pom;\n" +
+ " org.apache.maven.execution.MavenSession session;\n" +
+ " org.apache.maven.settings.Settings settings;\n" +
+ " org.slf4j.Logger log;\n" +
+ " groovy.util.AntBuilder ant;\n" +
+ " public void fail() {}" +
+ "}";
+
+ @Nullable
+ @Override
+ protected String getParentClassName() {
+ return "GroovyMavenPomClassIdea";
+ }
+
+ @Override
+ public void processDynamicElements(@NotNull PsiType qualifierType,
+ PsiClass aClass,
+ PsiScopeProcessor processor,
+ PsiElement place,
+ ResolveState state) {
+ PsiElement pomElement = aClass.getContainingFile().getContext();
+ if (pomElement == null) return;
+
+ PsiFile pomFile = pomElement.getContainingFile();
+ if (!(pomFile instanceof XmlFile)) return;
+
+ DynamicMemberUtils.process(processor, false, place, CLASS_SOURCE);
+ }
+}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/AbstractMavenConsoleFilter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/AbstractMavenConsoleFilter.java
new file mode 100644
index 0000000..430c169
--- /dev/null
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/AbstractMavenConsoleFilter.java
@@ -0,0 +1,74 @@
+package org.jetbrains.idea.maven.project;
+
+import com.intellij.execution.filters.Filter;
+import com.intellij.execution.filters.OpenFileHyperlinkInfo;
+import com.intellij.openapi.editor.colors.CodeInsightColors;
+import com.intellij.openapi.editor.colors.EditorColorsManager;
+import com.intellij.openapi.editor.markup.EffectType;
+import com.intellij.openapi.editor.markup.TextAttributes;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.SystemInfo;
+import com.intellij.openapi.vfs.LocalFileSystem;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.ui.JBColor;
+import org.jetbrains.annotations.Nullable;
+
+import java.awt.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author Sergey Evdokimov
+ */
+public abstract class AbstractMavenConsoleFilter implements Filter {
+
+ private final Pattern myPattern;
+
+ private final Project myProject;
+
+ public AbstractMavenConsoleFilter(Project project, Pattern pattern) {
+ myProject = project;
+ myPattern = pattern;
+ }
+
+ protected abstract boolean lightCheck(String line);
+
+ @Nullable
+ @Override
+ public Result applyFilter(String line, int entireLength) {
+ if (!lightCheck(line)) return null;
+
+ Matcher matcher = myPattern.matcher(line);
+ if (!matcher.matches()) return null;
+
+ String path = matcher.group(1);
+
+ VirtualFile file = LocalFileSystem.getInstance().findFileByPath(path);
+ if (file == null) {
+ if (SystemInfo.isWindows && path.matches("/[A-Z]:/.+")) {
+ file = LocalFileSystem.getInstance().findFileByPath(path.substring(1));
+ }
+ if (file == null) return null;
+ }
+
+ int lineNumber = Integer.parseInt(matcher.group(2)) - 1;
+ if (lineNumber < 0) {
+ lineNumber = -1;
+ }
+
+ TextAttributes attr = createCompilationErrorAttr();
+
+ return new Result(entireLength - line.length() + matcher.start(1), entireLength - line.length() + matcher.end(1),
+ new OpenFileHyperlinkInfo(myProject, file, lineNumber), attr);
+ }
+
+ private static TextAttributes createCompilationErrorAttr() {
+ TextAttributes attr = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(CodeInsightColors.HYPERLINK_ATTRIBUTES).clone();
+ attr.setForegroundColor(JBColor.RED);
+ attr.setEffectColor(JBColor.RED);
+ attr.setEffectType(EffectType.LINE_UNDERSCORE);
+ attr.setFontType(Font.PLAIN);
+ return attr;
+ }
+
+}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenArtifactDownloader.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenArtifactDownloader.java
index c0bdf9b..092af62 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenArtifactDownloader.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenArtifactDownloader.java
@@ -15,11 +15,15 @@
*/
package org.jetbrains.idea.maven.project;
+import com.intellij.openapi.application.AccessToken;
import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ReadAction;
+import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.vfs.LocalFileSystem;
import gnu.trove.THashMap;
import gnu.trove.THashSet;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.maven.importing.MavenExtraArtifactType;
import org.jetbrains.idea.maven.model.*;
@@ -38,33 +42,38 @@
new ThreadPoolExecutor(5, Integer.MAX_VALUE, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new ThreadFactory() {
AtomicInteger num = new AtomicInteger();
+ @NotNull
@Override
- public Thread newThread(Runnable r) {
+ public Thread newThread(@NotNull Runnable r) {
return new Thread(r, "Maven Artifact Downloader " + num.getAndIncrement());
}
});
+ private final Project myProject;
private final MavenProjectsTree myProjectsTree;
private final Collection<MavenProject> myMavenProjects;
private final Collection<MavenArtifact> myArtifacts;
private final MavenProgressIndicator myProgress;
private final MavenEmbedderWrapper myEmbedder;
- public static DownloadResult download(MavenProjectsTree projectsTree,
+ public static DownloadResult download(@NotNull Project project,
+ MavenProjectsTree projectsTree,
Collection<MavenProject> mavenProjects,
@Nullable Collection<MavenArtifact> artifacts,
boolean downloadSources,
boolean downloadDocs,
MavenEmbedderWrapper embedder,
MavenProgressIndicator p) throws MavenProcessCanceledException {
- return new MavenArtifactDownloader(projectsTree, mavenProjects, artifacts, embedder, p).download(downloadSources, downloadDocs);
+ return new MavenArtifactDownloader(project, projectsTree, mavenProjects, artifacts, embedder, p).download(downloadSources, downloadDocs);
}
- private MavenArtifactDownloader(MavenProjectsTree projectsTree,
+ private MavenArtifactDownloader(@NotNull Project project,
+ MavenProjectsTree projectsTree,
Collection<MavenProject> mavenProjects,
Collection<MavenArtifact> artifacts,
MavenEmbedderWrapper embedder,
MavenProgressIndicator p) {
+ myProject = project;
myProjectsTree = projectsTree;
myMavenProjects = mavenProjects;
myArtifacts = artifacts == null ? null : new THashSet<MavenArtifact>(artifacts);
@@ -104,6 +113,18 @@
private Map<MavenId, DownloadData> collectArtifactsToDownload(List<MavenExtraArtifactType> types) {
Map<MavenId, DownloadData> result = new THashMap<MavenId, DownloadData>();
+ THashSet<String> dependencyTypesFromSettings = new THashSet<String>();
+
+ AccessToken accessToken = ReadAction.start();
+ try {
+ if (myProject.isDisposed()) return result;
+
+ dependencyTypesFromSettings.addAll(MavenProjectsManager.getInstance(myProject).getImportingSettings().getDependencyTypesAsSet());
+ }
+ finally {
+ accessToken.finish();
+ }
+
for (MavenProject eachProject : myMavenProjects) {
List<MavenRemoteRepository> repositories = eachProject.getRemoteRepositories();
@@ -112,7 +133,13 @@
if (MavenConstants.SCOPE_SYSTEM.equalsIgnoreCase(eachDependency.getScope())) continue;
if (myProjectsTree.findProject(eachDependency.getMavenId()) != null) continue;
- if (!eachProject.isSupportedDependency(eachDependency, SupportedRequestType.FOR_IMPORT)) continue;
+
+ String dependencyType = eachDependency.getType();
+
+ if (!dependencyTypesFromSettings.contains(dependencyType)
+ && !eachProject.getDependencyTypesFromImporters(SupportedRequestType.FOR_IMPORT).contains(dependencyType)) {
+ continue;
+ }
MavenId id = eachDependency.getMavenId();
DownloadData data = result.get(id);
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenArtifactIndex.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenArtifactIndex.java
new file mode 100644
index 0000000..b7ade4d
--- /dev/null
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenArtifactIndex.java
@@ -0,0 +1,110 @@
+package org.jetbrains.idea.maven.project;
+
+import com.intellij.openapi.util.Comparing;
+import com.intellij.util.SmartList;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.idea.maven.dom.DependencyConflictId;
+import org.jetbrains.idea.maven.model.MavenArtifact;
+import org.jetbrains.idea.maven.model.MavenId;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Sergey Evdokimov
+ */
+public class MavenArtifactIndex {
+
+ private static final MavenArtifactIndex EMPTY_INDEX = new MavenArtifactIndex(Collections.<String, Map<String, List<MavenArtifact>>>emptyMap());
+
+ private final Map<String, Map<String, List<MavenArtifact>>> myData;
+
+ private MavenArtifactIndex(Map<String, Map<String, List<MavenArtifact>>> data) {
+ myData = data;
+ }
+
+ public Map<String, Map<String, List<MavenArtifact>>> getData() {
+ return myData;
+ }
+
+ @NotNull
+ public List<MavenArtifact> findArtifacts(@Nullable String groupId, @Nullable String artifactId) {
+ Map<String, List<MavenArtifact>> groupMap = myData.get(groupId);
+ if (groupMap == null) return Collections.emptyList();
+
+ List<MavenArtifact> res = groupMap.get(artifactId);
+ return res == null ? Collections.<MavenArtifact>emptyList() : res;
+ }
+
+ @NotNull
+ public List<MavenArtifact> findArtifacts(@Nullable MavenId mavenId) {
+ if (mavenId == null) return Collections.emptyList();
+
+ return findArtifacts(mavenId.getGroupId(), mavenId.getArtifactId(), mavenId.getVersion());
+ }
+
+ @Nullable
+ public MavenArtifact findArtifacts(@NotNull DependencyConflictId id) {
+ for (MavenArtifact artifact : findArtifacts(id.getGroupId(), id.getArtifactId())) {
+ if (id.equals(DependencyConflictId.create(artifact))) {
+ return artifact;
+ }
+ }
+
+ return null;
+ }
+
+ @NotNull
+ public List<MavenArtifact> findArtifacts(@Nullable String groupId, @Nullable String artifactId, @Nullable String version) {
+ Map<String, List<MavenArtifact>> groupMap = myData.get(groupId);
+ if (groupMap == null) return Collections.emptyList();
+
+ List<MavenArtifact> artifacts = groupMap.get(artifactId);
+ if (artifacts == null) return Collections.emptyList();
+
+ List<MavenArtifact> res = new SmartList<MavenArtifact>();
+ for (MavenArtifact artifact : artifacts) {
+ if (Comparing.equal(version, artifact.getVersion())) {
+ res.add(artifact);
+ }
+ }
+
+ return res;
+ }
+
+
+
+ public static MavenArtifactIndex build(@NotNull List<MavenArtifact> dependencies) {
+ if (dependencies.isEmpty()) return EMPTY_INDEX;
+
+ Map<String, Map<String, List<MavenArtifact>>> map = new HashMap<String, Map<String, List<MavenArtifact>>>();
+
+ for (MavenArtifact dep : dependencies) {
+ String groupId = dep.getGroupId();
+ if (groupId == null) continue;
+
+ String artifactId = dep.getArtifactId();
+ if (artifactId == null) continue;
+
+ Map<String, List<MavenArtifact>> groupMap = map.get(groupId);
+ if (groupMap == null) {
+ groupMap = new HashMap<String, List<MavenArtifact>>();
+ map.put(groupId, groupMap);
+ }
+
+ List<MavenArtifact> artifactList = groupMap.get(artifactId);
+ if (artifactList == null) {
+ artifactList = new SmartList<MavenArtifact>();
+ groupMap.put(artifactId, artifactList);
+ }
+
+ artifactList.add(dep);
+ }
+
+ return new MavenArtifactIndex(map);
+ }
+
+}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenConsoleImpl.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenConsoleImpl.java
index af638f2..09c9c6c 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenConsoleImpl.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenConsoleImpl.java
@@ -105,6 +105,7 @@
});
builder.addFilter(new MavenGroovyConsoleFilter(project));
+ builder.addFilter(new MavenScalaConsoleFilter(project));
return builder;
}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenEnvironmentForm.form b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenEnvironmentForm.form
index 545f60c..2b578f3 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenEnvironmentForm.form
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenEnvironmentForm.form
@@ -69,7 +69,7 @@
</component>
<component id="4becc" class="com.intellij.ui.components.JBLabel">
<constraints>
- <grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="4" anchor="9" fill="0" indent="1" use-parent-layout="false"/>
+ <grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="4" anchor="9" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<componentStyle value="SMALL"/>
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenGeneralConfigurable.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenGeneralConfigurable.java
index 9c6c522..1ba8dc1 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenGeneralConfigurable.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenGeneralConfigurable.java
@@ -1,118 +1,17 @@
-/* ==========================================================================
- * Copyright 2006 Mevenide Team
- *
- * 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 org.jetbrains.idea.maven.project;
import com.intellij.openapi.options.SearchableConfigurable;
-import com.intellij.openapi.util.Pair;
-import com.intellij.ui.PanelWithAnchor;
-import com.intellij.ui.components.JBLabel;
-import com.intellij.util.Function;
-import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import org.jetbrains.idea.maven.execution.MavenExecutionOptions;
-import org.jetbrains.idea.maven.utils.ComboBoxUtil;
-
-import javax.swing.*;
-import java.util.Arrays;
/**
- * @author Ralf Quebbemann (ralfq@codehaus.org)
+ * @author Sergey Evdokimov
*/
-public abstract class MavenGeneralConfigurable implements SearchableConfigurable, PanelWithAnchor {
- private JCheckBox checkboxWorkOffline;
- private JPanel panel;
- private JComboBox outputLevelCombo;
- private JCheckBox checkboxProduceExceptionErrorMessages;
- private JComboBox checksumPolicyCombo;
- private JComboBox failPolicyCombo;
- private JComboBox pluginUpdatePolicyCombo;
- private JCheckBox checkboxUsePluginRegistry;
- private JCheckBox checkboxRecursive;
- private MavenEnvironmentForm mavenPathsForm;
- private JBLabel myMultiprojectBuildFailPolicyLabel;
- private JCheckBox alwaysUpdateSnapshotsCheckBox;
- private final DefaultComboBoxModel outputLevelComboModel = new DefaultComboBoxModel();
- private final DefaultComboBoxModel checksumPolicyComboModel = new DefaultComboBoxModel();
- private final DefaultComboBoxModel failPolicyComboModel = new DefaultComboBoxModel();
- private final DefaultComboBoxModel pluginUpdatePolicyComboModel = new DefaultComboBoxModel();
- private JComponent anchor;
+public abstract class MavenGeneralConfigurable extends MavenGeneralPanel implements SearchableConfigurable {
protected abstract MavenGeneralSettings getState();
- protected MavenGeneralConfigurable() {
- fillOutputLevelCombobox();
- fillChecksumPolicyCombobox();
- fillFailureBehaviorCombobox();
- fillPluginUpdatePolicyCombobox();
-
- setAnchor(myMultiprojectBuildFailPolicyLabel);
- }
-
- private void fillOutputLevelCombobox() {
- ComboBoxUtil.setModel(outputLevelCombo, outputLevelComboModel,
- Arrays.asList(MavenExecutionOptions.LoggingLevel.values()),
- new Function<MavenExecutionOptions.LoggingLevel, Pair<String, ?>>() {
- public Pair<String, MavenExecutionOptions.LoggingLevel> fun(MavenExecutionOptions.LoggingLevel each) {
- return Pair.create(each.getDisplayString(), each);
- }
- });
- }
-
- private void fillFailureBehaviorCombobox() {
- ComboBoxUtil.setModel(failPolicyCombo, failPolicyComboModel,
- Arrays.asList(MavenExecutionOptions.FailureMode.values()),
- new Function<MavenExecutionOptions.FailureMode, Pair<String, ?>>() {
- public Pair<String, MavenExecutionOptions.FailureMode> fun(MavenExecutionOptions.FailureMode each) {
- return Pair.create(each.getDisplayString(), each);
- }
- });
- }
-
- private void fillChecksumPolicyCombobox() {
- ComboBoxUtil.setModel(checksumPolicyCombo, checksumPolicyComboModel,
- Arrays.asList(MavenExecutionOptions.ChecksumPolicy.values()),
- new Function<MavenExecutionOptions.ChecksumPolicy, Pair<String, ?>>() {
- public Pair<String, MavenExecutionOptions.ChecksumPolicy> fun(MavenExecutionOptions.ChecksumPolicy each) {
- return Pair.create(each.getDisplayString(), each);
- }
- });
- }
-
- private void fillPluginUpdatePolicyCombobox() {
- ComboBoxUtil.setModel(pluginUpdatePolicyCombo, pluginUpdatePolicyComboModel,
- Arrays.asList(MavenExecutionOptions.PluginUpdatePolicy.values()),
- new Function<MavenExecutionOptions.PluginUpdatePolicy, Pair<String, ?>>() {
- public Pair<String, MavenExecutionOptions.PluginUpdatePolicy> fun(MavenExecutionOptions.PluginUpdatePolicy each) {
- return Pair.create(each.getDisplayString(), each);
- }
- });
- }
-
- public JComponent createComponent() {
- mavenPathsForm.createComponent(); // have to initialize all listeners
- return panel;
- }
-
- public void disposeUIResources() {
- }
-
public boolean isModified() {
MavenGeneralSettings formData = new MavenGeneralSettings();
setData(formData);
@@ -127,46 +26,6 @@
getData(getState());
}
- protected void setData(MavenGeneralSettings data) {
- data.beginUpdate();
-
- data.setWorkOffline(checkboxWorkOffline.isSelected());
- mavenPathsForm.setData(data);
-
- data.setPrintErrorStackTraces(checkboxProduceExceptionErrorMessages.isSelected());
- data.setUsePluginRegistry(checkboxUsePluginRegistry.isSelected());
- data.setNonRecursive(!checkboxRecursive.isSelected());
-
- data.setOutputLevel((MavenExecutionOptions.LoggingLevel)ComboBoxUtil.getSelectedValue(outputLevelComboModel));
- data.setChecksumPolicy((MavenExecutionOptions.ChecksumPolicy)ComboBoxUtil.getSelectedValue(checksumPolicyComboModel));
- data.setFailureBehavior((MavenExecutionOptions.FailureMode)ComboBoxUtil.getSelectedValue(failPolicyComboModel));
- data.setPluginUpdatePolicy((MavenExecutionOptions.PluginUpdatePolicy)ComboBoxUtil.getSelectedValue(pluginUpdatePolicyComboModel));
- data.setAlwaysUpdateSnapshots(alwaysUpdateSnapshotsCheckBox.isSelected());
-
- data.endUpdate();
- }
-
- protected void getData(MavenGeneralSettings data) {
- checkboxWorkOffline.setSelected(data.isWorkOffline());
-
- mavenPathsForm.getData(data);
-
- checkboxProduceExceptionErrorMessages.setSelected(data.isPrintErrorStackTraces());
- checkboxUsePluginRegistry.setSelected(data.isUsePluginRegistry());
- checkboxRecursive.setSelected(!data.isNonRecursive());
- alwaysUpdateSnapshotsCheckBox.setSelected(data.isAlwaysUpdateSnapshots());
-
- ComboBoxUtil.select(outputLevelComboModel, data.getOutputLevel());
- ComboBoxUtil.select(checksumPolicyComboModel, data.getChecksumPolicy());
- ComboBoxUtil.select(failPolicyComboModel, data.getFailureBehavior());
- ComboBoxUtil.select(pluginUpdatePolicyComboModel, data.getPluginUpdatePolicy());
- }
-
- @Nls
- public String getDisplayName() {
- return ProjectBundle.message("maven.tab.general");
- }
-
@Nullable
@NonNls
public String getHelpTopic() {
@@ -182,15 +41,4 @@
return null;
}
- @Override
- public JComponent getAnchor() {
- return anchor;
- }
-
- @Override
- public void setAnchor(JComponent anchor) {
- this.anchor = anchor;
- myMultiprojectBuildFailPolicyLabel.setAnchor(anchor);
- mavenPathsForm.setAnchor(anchor);
- }
}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenGeneralConfigurableWithUseProjectSettings.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenGeneralConfigurableWithUseProjectSettings.java
deleted file mode 100644
index 8daaf1e..0000000
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenGeneralConfigurableWithUseProjectSettings.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright 2000-2012 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 org.jetbrains.idea.maven.project;
-
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Pair;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import javax.swing.*;
-import java.awt.*;
-
-/**
- * @author Sergey Evdokimov
- */
-public abstract class MavenGeneralConfigurableWithUseProjectSettings extends MavenGeneralConfigurable {
-
- private JCheckBox myUseProjectSettings;
-
- private final Project myProject;
-
- protected MavenGeneralConfigurableWithUseProjectSettings(@NotNull Project project) {
- myProject = project;
- }
-
- public abstract void setState(@Nullable MavenGeneralSettings state);
-
- @Override
- public boolean isModified() {
- if (myUseProjectSettings.isSelected()) {
- return getState() != null;
- }
- else {
- return getState() == null || super.isModified();
- }
- }
-
- @Override
- public void apply() {
- if (myUseProjectSettings.isSelected()) {
- setState(null);
- }
- else {
- MavenGeneralSettings state = getState();
- if (state != null) {
- setData(state);
- }
- else {
- MavenGeneralSettings settings = MavenProjectsManager.getInstance(myProject).getGeneralSettings().clone();
- setData(settings);
- setState(settings);
- }
- }
- }
-
- @Override
- public void reset() {
- MavenGeneralSettings state = getState();
- myUseProjectSettings.setSelected(state == null);
-
- if (state == null) {
- MavenGeneralSettings settings = MavenProjectsManager.getInstance(myProject).getGeneralSettings();
- getData(settings);
- }
- else {
- getData(state);
- }
- }
-
- @Override
- public JComponent createComponent() {
- Pair<JPanel,JCheckBox> pair = MavenDisablePanelCheckbox.createPanel(super.createComponent(), "Use project settings");
-
- myUseProjectSettings = pair.second;
- return pair.first;
- }
-}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenGeneralConfigurable.form b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenGeneralPanel.form
similarity index 98%
rename from plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenGeneralConfigurable.form
rename to plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenGeneralPanel.form
index c416803..30e57e5 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenGeneralConfigurable.form
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenGeneralPanel.form
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.idea.maven.project.MavenGeneralConfigurable">
+<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.idea.maven.project.MavenGeneralPanel">
<grid id="27dc6" binding="panel" layout-manager="GridLayoutManager" row-count="11" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenGeneralPanel.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenGeneralPanel.java
new file mode 100644
index 0000000..fbd6848
--- /dev/null
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenGeneralPanel.java
@@ -0,0 +1,161 @@
+/* ==========================================================================
+ * Copyright 2006 Mevenide Team
+ *
+ * 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 org.jetbrains.idea.maven.project;
+
+import com.intellij.openapi.util.Pair;
+import com.intellij.ui.PanelWithAnchor;
+import com.intellij.ui.components.JBLabel;
+import com.intellij.util.Function;
+import org.jetbrains.annotations.Nls;
+import org.jetbrains.idea.maven.execution.MavenExecutionOptions;
+import org.jetbrains.idea.maven.utils.ComboBoxUtil;
+
+import javax.swing.*;
+import java.util.Arrays;
+
+/**
+ * @author Ralf Quebbemann (ralfq@codehaus.org)
+ */
+public class MavenGeneralPanel implements PanelWithAnchor {
+ private JCheckBox checkboxWorkOffline;
+ private JPanel panel;
+ private JComboBox outputLevelCombo;
+ private JCheckBox checkboxProduceExceptionErrorMessages;
+ private JComboBox checksumPolicyCombo;
+ private JComboBox failPolicyCombo;
+ private JComboBox pluginUpdatePolicyCombo;
+ private JCheckBox checkboxUsePluginRegistry;
+ private JCheckBox checkboxRecursive;
+ private MavenEnvironmentForm mavenPathsForm;
+ private JBLabel myMultiprojectBuildFailPolicyLabel;
+ private JCheckBox alwaysUpdateSnapshotsCheckBox;
+ private final DefaultComboBoxModel outputLevelComboModel = new DefaultComboBoxModel();
+ private final DefaultComboBoxModel checksumPolicyComboModel = new DefaultComboBoxModel();
+ private final DefaultComboBoxModel failPolicyComboModel = new DefaultComboBoxModel();
+ private final DefaultComboBoxModel pluginUpdatePolicyComboModel = new DefaultComboBoxModel();
+ private JComponent anchor;
+
+ public MavenGeneralPanel() {
+ fillOutputLevelCombobox();
+ fillChecksumPolicyCombobox();
+ fillFailureBehaviorCombobox();
+ fillPluginUpdatePolicyCombobox();
+
+ setAnchor(myMultiprojectBuildFailPolicyLabel);
+ }
+
+ private void fillOutputLevelCombobox() {
+ ComboBoxUtil.setModel(outputLevelCombo, outputLevelComboModel,
+ Arrays.asList(MavenExecutionOptions.LoggingLevel.values()),
+ new Function<MavenExecutionOptions.LoggingLevel, Pair<String, ?>>() {
+ public Pair<String, MavenExecutionOptions.LoggingLevel> fun(MavenExecutionOptions.LoggingLevel each) {
+ return Pair.create(each.getDisplayString(), each);
+ }
+ });
+ }
+
+ private void fillFailureBehaviorCombobox() {
+ ComboBoxUtil.setModel(failPolicyCombo, failPolicyComboModel,
+ Arrays.asList(MavenExecutionOptions.FailureMode.values()),
+ new Function<MavenExecutionOptions.FailureMode, Pair<String, ?>>() {
+ public Pair<String, MavenExecutionOptions.FailureMode> fun(MavenExecutionOptions.FailureMode each) {
+ return Pair.create(each.getDisplayString(), each);
+ }
+ });
+ }
+
+ private void fillChecksumPolicyCombobox() {
+ ComboBoxUtil.setModel(checksumPolicyCombo, checksumPolicyComboModel,
+ Arrays.asList(MavenExecutionOptions.ChecksumPolicy.values()),
+ new Function<MavenExecutionOptions.ChecksumPolicy, Pair<String, ?>>() {
+ public Pair<String, MavenExecutionOptions.ChecksumPolicy> fun(MavenExecutionOptions.ChecksumPolicy each) {
+ return Pair.create(each.getDisplayString(), each);
+ }
+ });
+ }
+
+ private void fillPluginUpdatePolicyCombobox() {
+ ComboBoxUtil.setModel(pluginUpdatePolicyCombo, pluginUpdatePolicyComboModel,
+ Arrays.asList(MavenExecutionOptions.PluginUpdatePolicy.values()),
+ new Function<MavenExecutionOptions.PluginUpdatePolicy, Pair<String, ?>>() {
+ public Pair<String, MavenExecutionOptions.PluginUpdatePolicy> fun(MavenExecutionOptions.PluginUpdatePolicy each) {
+ return Pair.create(each.getDisplayString(), each);
+ }
+ });
+ }
+
+ public JComponent createComponent() {
+ mavenPathsForm.createComponent(); // have to initialize all listeners
+ return panel;
+ }
+
+ public void disposeUIResources() {
+ }
+
+ protected void setData(MavenGeneralSettings data) {
+ data.beginUpdate();
+
+ data.setWorkOffline(checkboxWorkOffline.isSelected());
+ mavenPathsForm.setData(data);
+
+ data.setPrintErrorStackTraces(checkboxProduceExceptionErrorMessages.isSelected());
+ data.setUsePluginRegistry(checkboxUsePluginRegistry.isSelected());
+ data.setNonRecursive(!checkboxRecursive.isSelected());
+
+ data.setOutputLevel((MavenExecutionOptions.LoggingLevel)ComboBoxUtil.getSelectedValue(outputLevelComboModel));
+ data.setChecksumPolicy((MavenExecutionOptions.ChecksumPolicy)ComboBoxUtil.getSelectedValue(checksumPolicyComboModel));
+ data.setFailureBehavior((MavenExecutionOptions.FailureMode)ComboBoxUtil.getSelectedValue(failPolicyComboModel));
+ data.setPluginUpdatePolicy((MavenExecutionOptions.PluginUpdatePolicy)ComboBoxUtil.getSelectedValue(pluginUpdatePolicyComboModel));
+ data.setAlwaysUpdateSnapshots(alwaysUpdateSnapshotsCheckBox.isSelected());
+
+ data.endUpdate();
+ }
+
+ protected void getData(MavenGeneralSettings data) {
+ checkboxWorkOffline.setSelected(data.isWorkOffline());
+
+ mavenPathsForm.getData(data);
+
+ checkboxProduceExceptionErrorMessages.setSelected(data.isPrintErrorStackTraces());
+ checkboxUsePluginRegistry.setSelected(data.isUsePluginRegistry());
+ checkboxRecursive.setSelected(!data.isNonRecursive());
+ alwaysUpdateSnapshotsCheckBox.setSelected(data.isAlwaysUpdateSnapshots());
+
+ ComboBoxUtil.select(outputLevelComboModel, data.getOutputLevel());
+ ComboBoxUtil.select(checksumPolicyComboModel, data.getChecksumPolicy());
+ ComboBoxUtil.select(failPolicyComboModel, data.getFailureBehavior());
+ ComboBoxUtil.select(pluginUpdatePolicyComboModel, data.getPluginUpdatePolicy());
+ }
+
+ @Nls
+ public String getDisplayName() {
+ return ProjectBundle.message("maven.tab.general");
+ }
+
+ @Override
+ public JComponent getAnchor() {
+ return anchor;
+ }
+
+ @Override
+ public void setAnchor(JComponent anchor) {
+ this.anchor = anchor;
+ myMultiprojectBuildFailPolicyLabel.setAnchor(anchor);
+ mavenPathsForm.setAnchor(anchor);
+ }
+}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenGeneralSettingsEditor.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenGeneralSettingsEditor.java
new file mode 100644
index 0000000..69a4e50
--- /dev/null
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenGeneralSettingsEditor.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2000-2012 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 org.jetbrains.idea.maven.project;
+
+import com.intellij.openapi.options.ConfigurationException;
+import com.intellij.openapi.options.SettingsEditor;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Pair;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.idea.maven.execution.MavenRunConfiguration;
+
+import javax.swing.*;
+
+/**
+ * @author Sergey Evdokimov
+ */
+public class MavenGeneralSettingsEditor extends SettingsEditor<MavenRunConfiguration> {
+
+ private final MavenGeneralPanel myPanel;
+
+ private JCheckBox myUseProjectSettings;
+
+ private final Project myProject;
+
+ public MavenGeneralSettingsEditor(@NotNull Project project) {
+ myProject = project;
+ myPanel = new MavenGeneralPanel();
+ }
+
+ @Override
+ protected void resetEditorFrom(MavenRunConfiguration s) {
+ myUseProjectSettings.setSelected(s.getGeneralSettings() == null);
+
+ if (s.getGeneralSettings() == null) {
+ MavenGeneralSettings settings = MavenProjectsManager.getInstance(myProject).getGeneralSettings();
+ myPanel.getData(settings);
+ }
+ else {
+ myPanel.getData(s.getGeneralSettings());
+ }
+ }
+
+ @Override
+ protected void applyEditorTo(MavenRunConfiguration s) throws ConfigurationException {
+ if (myUseProjectSettings.isSelected()) {
+ s.setGeneralSettings(null);
+ }
+ else {
+ MavenGeneralSettings state = s.getGeneralSettings();
+ if (state != null) {
+ myPanel.setData(state);
+ }
+ else {
+ MavenGeneralSettings settings = MavenProjectsManager.getInstance(myProject).getGeneralSettings().clone();
+ myPanel.setData(settings);
+ s.setGeneralSettings(settings);
+ }
+ }
+ }
+
+ @NotNull
+ @Override
+ protected JComponent createEditor() {
+ Pair<JPanel,JCheckBox> pair = MavenDisablePanelCheckbox.createPanel(myPanel.createComponent(), "Use project settings");
+
+ myUseProjectSettings = pair.second;
+ return pair.first;
+ }
+
+ @Override
+ protected void disposeEditor() {
+ myPanel.disposeUIResources();
+ }
+
+ public Project getProject() {
+ return myProject;
+ }
+}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenGroovyConsoleFilter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenGroovyConsoleFilter.java
index ae3003d..598b3d5 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenGroovyConsoleFilter.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenGroovyConsoleFilter.java
@@ -15,76 +15,26 @@
*/
package org.jetbrains.idea.maven.project;
-import com.intellij.execution.filters.Filter;
-import com.intellij.execution.filters.OpenFileHyperlinkInfo;
-import com.intellij.openapi.editor.colors.CodeInsightColors;
-import com.intellij.openapi.editor.colors.EditorColorsManager;
-import com.intellij.openapi.editor.markup.EffectType;
-import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.SystemInfo;
-import com.intellij.openapi.vfs.LocalFileSystem;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.ui.JBColor;
-import org.jetbrains.annotations.Nullable;
-import java.awt.*;
-import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @author Sergey Evdokimov
*/
-public class MavenGroovyConsoleFilter implements Filter {
+public class MavenGroovyConsoleFilter extends AbstractMavenConsoleFilter {
+ // Example of gmaven error line:
+ // [ERROR] /home/user/ideaProjects/simpleMaven/src/main/groovy/com/A.groovy: 17: [Static type checking] - Cannot assign value of type java.lang.String to variable of type int
private static final Pattern PATTERN = Pattern.compile("\\[ERROR\\] (\\S.+\\.groovy): (-?\\d{1,5}): .+", Pattern.DOTALL);
- private final Project myProject;
-
public MavenGroovyConsoleFilter(Project project) {
- myProject = project;
+ super(project, PATTERN);
}
- @Nullable
@Override
- public Result applyFilter(String line, int entireLength) {
-
- // Example of gmaven error line:
- // [ERROR] /home/user/ideaProjects/simpleMaven/src/main/groovy/com/A.groovy: 17: [Static type checking] - Cannot assign value of type java.lang.String to variable of type int
-
- if (!line.startsWith("[ERROR] ") || !line.contains(".groovy: ")) return null;
-
- Matcher matcher = PATTERN.matcher(line);
- if (!matcher.matches()) return null;
-
- String path = matcher.group(1);
-
- VirtualFile file = LocalFileSystem.getInstance().findFileByPath(path);
- if (file == null) {
- if (SystemInfo.isWindows && path.matches("/[A-Z]:/.+")) {
- file = LocalFileSystem.getInstance().findFileByPath(path.substring(1));
- }
- if (file == null) return null;
- }
-
- int lineNumber = Integer.parseInt(matcher.group(2)) - 1;
- if (lineNumber < 0) {
- lineNumber = -1;
- }
-
- TextAttributes attr = createCompilationErrorAttr();
-
- return new Result(entireLength - line.length() + matcher.start(1), entireLength - line.length() + matcher.end(1),
- new OpenFileHyperlinkInfo(myProject, file, lineNumber), attr);
- }
-
- private static TextAttributes createCompilationErrorAttr() {
- TextAttributes attr = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(CodeInsightColors.HYPERLINK_ATTRIBUTES).clone();
- attr.setForegroundColor(JBColor.RED);
- attr.setEffectColor(JBColor.RED);
- attr.setEffectType(EffectType.LINE_UNDERSCORE);
- attr.setFontType(Font.PLAIN);
- return attr;
+ protected boolean lightCheck(String line) {
+ return line.startsWith("[ERROR] ") && line.contains(".groovy: ");
}
}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenImportingSettings.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenImportingSettings.java
index 12f7ade..c24b117 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenImportingSettings.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenImportingSettings.java
@@ -15,11 +15,14 @@
*/
package org.jetbrains.idea.maven.project;
+import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.xmlb.annotations.Property;
import org.jetbrains.annotations.NotNull;
+import java.util.LinkedHashSet;
import java.util.List;
+import java.util.Set;
public class MavenImportingSettings implements Cloneable {
private static final String PROCESS_RESOURCES_PHASE = "process-resources";
@@ -50,6 +53,9 @@
private GeneratedSourcesFolder generatedSourcesFolder = GeneratedSourcesFolder.AUTODETECT;
+ private String dependencyTypes = "jar, test-jar, maven-plugin, ejb, ejb-client, jboss-har, jboss-sar, war, ear, bundle";
+ private Set<String> myDependencyTypesAsSet;
+
private List<Listener> myListeners = ContainerUtil.createLockFreeCopyOnWriteList();
public enum GeneratedSourcesFolder {
@@ -91,6 +97,30 @@
fireAutoImportChanged();
}
+ @NotNull
+ public String getDependencyTypes() {
+ return dependencyTypes;
+ }
+
+ public void setDependencyTypes(@NotNull String dependencyTypes) {
+ this.dependencyTypes = dependencyTypes;
+ myDependencyTypesAsSet = null;
+ }
+
+ @NotNull
+ public Set<String> getDependencyTypesAsSet() {
+ if (myDependencyTypesAsSet == null) {
+ Set<String> res = new LinkedHashSet<String>();
+
+ for (String type : StringUtil.tokenize(dependencyTypes, " \n\r\t,;")) {
+ res.add(type);
+ }
+
+ myDependencyTypesAsSet = res;
+ }
+ return myDependencyTypesAsSet;
+ }
+
public boolean isCreateModuleGroups() {
return createModuleGroups;
}
@@ -179,6 +209,7 @@
if (createModuleGroups != that.createModuleGroups) return false;
if (createModulesForAggregators != that.createModulesForAggregators) return false;
if (importAutomatically != that.importAutomatically) return false;
+ if (!dependencyTypes.equals(that.dependencyTypes)) return false;
if (downloadDocsAutomatically != that.downloadDocsAutomatically) return false;
if (downloadSourcesAutomatically != that.downloadSourcesAutomatically) return false;
if (lookForNested != that.lookForNested) return false;
@@ -220,6 +251,7 @@
result = 31 * result + (updateFoldersOnImportPhase != null ? updateFoldersOnImportPhase.hashCode() : 0);
result = 31 * result + dedicatedModuleDir.hashCode();
result = 31 * result + generatedSourcesFolder.hashCode();
+ result = 31 * result + dependencyTypes.hashCode();
return result;
}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenImportingSettingsForm.form b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenImportingSettingsForm.form
index 48408f7..1be375b 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenImportingSettingsForm.form
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenImportingSettingsForm.form
@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.idea.maven.project.MavenImportingSettingsForm">
- <grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="17" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+ <grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="19" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
- <xy x="20" y="20" width="536" height="565"/>
+ <xy x="20" y="20" width="769" height="577"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="b48ca" class="javax.swing.JCheckBox" binding="myCreateModulesForAggregators">
<constraints>
- <grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+ <grid row="5" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Create $FULLNAME$ &modules for aggregator projects (with 'pom' packaging)"/>
@@ -18,7 +18,7 @@
</component>
<component id="2b9b5" class="javax.swing.JCheckBox" binding="myCreateGroupsCheckBox" default-binding="true">
<constraints>
- <grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+ <grid row="6" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Create module &groups for multi-module Maven projects"/>
@@ -26,7 +26,7 @@
</component>
<component id="d7aa1" class="javax.swing.JCheckBox" binding="mySearchRecursivelyCheckBox">
<constraints>
- <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+ <grid row="0" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="&Search for projects recursively"/>
@@ -34,7 +34,7 @@
</component>
<component id="1b499" class="javax.swing.JCheckBox" binding="myUseMavenOutputCheckBox">
<constraints>
- <grid row="9" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+ <grid row="9" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Use Maven &output directories"/>
@@ -43,7 +43,7 @@
</component>
<component id="22b1c" class="com.intellij.ui.components.JBLabel">
<constraints>
- <grid row="13" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="3" use-parent-layout="false"/>
+ <grid row="13" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="3" use-parent-layout="false"/>
</constraints>
<properties>
<componentStyle value="SMALL"/>
@@ -53,7 +53,7 @@
</component>
<component id="323ff" class="javax.swing.JCheckBox" binding="myImportAutomaticallyBox">
<constraints>
- <grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+ <grid row="4" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Import Maven projects &automatically"/>
@@ -63,7 +63,7 @@
<grid id="49dc8" layout-manager="GridLayoutManager" row-count="1" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="10" left="0" bottom="0" right="0"/>
<constraints>
- <grid row="14" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
+ <grid row="14" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<focusable value="true"/>
@@ -103,7 +103,7 @@
</grid>
<component id="6d280" class="javax.swing.JCheckBox" binding="myKeepSourceFoldersCheckBox">
<constraints>
- <grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+ <grid row="7" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Keep source and test &folders on reimport"/>
@@ -112,7 +112,7 @@
<grid id="d7645" binding="myAdditionalSettingsPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="15" left="0" bottom="0" right="0"/>
<constraints>
- <grid row="15" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="8" fill="2" indent="0" use-parent-layout="false"/>
+ <grid row="17" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="8" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
@@ -120,13 +120,13 @@
</grid>
<hspacer id="d45a7">
<constraints>
- <grid row="14" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
+ <grid row="14" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<grid id="eca06" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
- <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
+ <grid row="2" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
@@ -157,7 +157,7 @@
<grid id="7fb78" binding="mySeparateModulesDirPanel" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="10" right="0"/>
<constraints>
- <grid row="3" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
+ <grid row="3" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
@@ -180,13 +180,13 @@
</grid>
<vspacer id="5d738">
<constraints>
- <grid row="16" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
+ <grid row="18" column="0" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<grid id="34bc4" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
- <grid row="12" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
+ <grid row="12" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
@@ -215,14 +215,14 @@
</grid>
<vspacer id="aa40b">
<constraints>
- <grid row="11" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
+ <grid row="11" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
<preferred-size width="-1" height="10"/>
</grid>
</constraints>
</vspacer>
<vspacer id="6351f">
<constraints>
- <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
+ <grid row="1" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
<preferred-size width="-1" height="10"/>
</grid>
</constraints>
@@ -230,7 +230,7 @@
<grid id="f9c12" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
- <grid row="10" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
+ <grid row="10" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
@@ -258,13 +258,45 @@
</grid>
<component id="af108" class="javax.swing.JCheckBox" binding="myExcludeTargetFolderCheckBox">
<constraints>
- <grid row="8" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+ <grid row="8" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Exclude build directory (%PROJECT_ROOT%/target)"/>
<toolTipText value="If you select this options folder /target will be excluded from project during reimport. Compiler output (/target/classes and /target/test-classes) will be excluded anyway"/>
</properties>
</component>
+ <component id="2e377" class="javax.swing.JLabel">
+ <constraints>
+ <grid row="15" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+ </constraints>
+ <properties>
+ <labelFor value="83bca"/>
+ <text value="Dependency types:"/>
+ <toolTipText resource-bundle="ProjectBundle" key="maven.import.dependency.type.description"/>
+ </properties>
+ </component>
+ <component id="83bca" class="javax.swing.JTextField" binding="myDependencyTypes">
+ <constraints>
+ <grid row="15" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
+ <preferred-size width="60" height="-1"/>
+ </grid>
+ </constraints>
+ <properties>
+ <columns value="0"/>
+ <toolTipText resource-bundle="ProjectBundle" key="maven.import.dependency.type.description"/>
+ </properties>
+ </component>
+ <component id="d634c" class="com.intellij.ui.components.JBLabel">
+ <constraints>
+ <grid row="16" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="9" fill="0" indent="0" use-parent-layout="false"/>
+ </constraints>
+ <properties>
+ <componentStyle value="SMALL"/>
+ <fontColor value="BRIGHTER"/>
+ <labelFor value="83bca"/>
+ <text resource-bundle="ProjectBundle" key="maven.import.dependency.type.description"/>
+ </properties>
+ </component>
</children>
</grid>
<buttonGroups>
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenImportingSettingsForm.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenImportingSettingsForm.java
index da4dc0a..ea7e0f7 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenImportingSettingsForm.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenImportingSettingsForm.java
@@ -15,15 +15,15 @@
*/
package org.jetbrains.idea.maven.project;
-import com.intellij.openapi.updateSettings.impl.LabelTextReplacingUtil;
-import com.intellij.ui.ListCellRendererWrapper;
import com.intellij.ide.util.projectWizard.WizardContext;
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
+import com.intellij.openapi.updateSettings.impl.LabelTextReplacingUtil;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.projectImport.ProjectFormatPanel;
import com.intellij.ui.EnumComboBoxModel;
+import com.intellij.ui.ListCellRendererWrapper;
import javax.swing.*;
import java.awt.event.ActionEvent;
@@ -53,6 +53,7 @@
private JPanel mySeparateModulesDirPanel;
private JComboBox myGeneratedSourcesComboBox;
private JCheckBox myExcludeTargetFolderCheckBox;
+ private JTextField myDependencyTypes;
public MavenImportingSettingsForm(boolean isImportStep, boolean isCreatingNewProject) {
mySearchRecursivelyCheckBox.setVisible(isImportStep);
@@ -123,6 +124,8 @@
data.setDownloadSourcesAutomatically(myDownloadSourcesCheckBox.isSelected());
data.setDownloadDocsAutomatically(myDownloadDocsCheckBox.isSelected());
+
+ data.setDependencyTypes(myDependencyTypes.getText());
}
public void setData(MavenImportingSettings data) {
@@ -145,6 +148,8 @@
myDownloadSourcesCheckBox.setSelected(data.isDownloadSourcesAutomatically());
myDownloadDocsCheckBox.setSelected(data.isDownloadDocsAutomatically());
+ myDependencyTypes.setText(data.getDependencyTypes());
+
updateControls();
}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProject.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProject.java
index 8561b2b..6c1778f 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProject.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProject.java
@@ -28,7 +28,6 @@
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.util.SmartList;
import com.intellij.util.containers.ContainerUtil;
import gnu.trove.THashSet;
import org.jdom.Element;
@@ -47,6 +46,9 @@
import java.util.concurrent.ConcurrentHashMap;
public class MavenProject {
+
+ private static final Key<MavenArtifactIndex> DEPENDENCIES_CACHE_KEY = Key.create("MavenProject.DEPENDENCIES_CACHE_KEY");
+
@NotNull private final VirtualFile myFile;
@NotNull private volatile State myState = new State();
@@ -482,65 +484,52 @@
return res;
}
- //private String getCompilerArgument() {
- // return MavenJDOMUtil.findChildValueByPath(getCompilerConfig(), "compilerArgument");
- //}
- //
- //private String getCompilerArguments(){
- // StringBuilder compilerArguments = new StringBuilder();
- // Element compilerArgumentsElement = MavenJDOMUtil.findChildByPath(getCompilerConfig(), "compilerArguments");
- // if(compilerArgumentsElement != null){
- // List compilerArgumentsElements = compilerArgumentsElement.getChildren();
- // for(Object compilerArgumentsElementKey: compilerArgumentsElements){
- // String key = ((Element)compilerArgumentsElementKey).getName();
- // String value = ((Element)compilerArgumentsElementKey).getValue();
- // compilerArguments.append(prepareKeyValue(key)).append(" ").append(prepareValueContent(value));
- // }
- // }
- // return compilerArguments.toString();
- //}
- //
- //private static String prepareValueContent(String value) {
- // return (value == null || value.length() == 0)? "" : value + " ";
- //}
- //
- //private static String prepareKeyValue(final String key) {
- // return (key.startsWith( "-A" ))? key.substring(2) : key;
- //}
-
@Nullable
public List<String> getDeclaredAnnotationProcessors() {
Element compilerConfig = getCompilerConfig();
- if (compilerConfig == null) return null;
+ if (compilerConfig != null) {
+ Element processors = compilerConfig.getChild("annotationProcessors");
+ if (processors != null) {
+ List<String> res = new ArrayList<String>();
- Element processors = compilerConfig.getChild("annotationProcessors");
- if (processors == null) return null;
+ for (Element element : processors.getChildren("annotationProcessor")){
+ String processorClassName = element.getTextTrim();
+ if (!processorClassName.isEmpty()) {
+ res.add(processorClassName);
+ }
+ }
- List<String> res = new ArrayList<String>();
-
- for (Element element : (List<Element>)processors.getChildren("annotationProcessor")){
- String processorClassName = element.getTextTrim();
- if (!processorClassName.isEmpty()) {
- res.add(processorClassName);
+ return res;
}
}
- return res;
+ MavenPlugin bscMavenPlugin = findPlugin("org.bsc.maven", "maven-processor-plugin");
+ if (bscMavenPlugin != null) {
+ Element cfg = bscMavenPlugin.getGoalConfiguration("process");
+ if (cfg == null) {
+ cfg = bscMavenPlugin.getConfigurationElement();
+ }
+
+ if (cfg != null) {
+ Element processors = cfg.getChild("processors");
+ if (processors != null) {
+ List<String> res = new ArrayList<String>();
+
+ for (Element element : processors.getChildren("processor")){
+ String processorClassName = element.getTextTrim();
+ if (!processorClassName.isEmpty()) {
+ res.add(processorClassName);
+ }
+ }
+
+ return res;
+ }
+ }
+ }
+
+ return null;
}
- //private String getArgumentsForAnnotationProcessor(){
- // return getCompilerArguments() + formatCompilerArgument(getCompilerArgument()) ;
- //}
-
- //private static String formatCompilerArgument(String compilerArgument){
- // String[] splitArguments = compilerArgument.split("\\s+");
- // List<String> formattedArguments = new ArrayList<String>();
- // for(String splitArgument: splitArguments){
- // formattedArguments.add((splitArgument.startsWith( "-A" ))? splitArgument.substring(2) : splitArgument);
- // }
- // return StringUtil.join(formattedArguments, " ");
- //}
-
@NotNull
public String getOutputDirectory() {
return myState.myOutputDirectory;
@@ -789,10 +778,6 @@
return myState.myDependencyTree;
}
- public boolean isSupportedDependency(@NotNull MavenArtifact artifact, @NotNull SupportedRequestType type) {
- return getSupportedDependencyTypes(type).contains(artifact.getType());
- }
-
@NotNull
public Set<String> getSupportedPackagings() {
Set<String> result = ContainerUtil.newHashSet(MavenConstants.TYPE_POM,
@@ -804,20 +789,14 @@
return result;
}
- @NotNull
- public Set<String> getSupportedDependencyTypes(@NotNull SupportedRequestType type) {
- Set<String> result = ContainerUtil.newTroveSet(MavenConstants.TYPE_JAR,
- MavenConstants.TYPE_TEST_JAR,
- "maven-plugin",
- "ejb", "ejb-client", "jboss-har", "jboss-sar", "war", "ear", "bundle");
- if (type == SupportedRequestType.FOR_COMPLETION) {
- result.add(MavenConstants.TYPE_POM);
- }
+ public Set<String> getDependencyTypesFromImporters(@NotNull SupportedRequestType type) {
+ THashSet<String> res = new THashSet<String>();
for (MavenImporter each : getSuitableImporters()) {
- each.getSupportedDependencyTypes(result, type);
+ each.getSupportedDependencyTypes(res, type);
}
- return result;
+
+ return res;
}
@NotNull
@@ -838,6 +817,8 @@
List<MavenArtifact> dependenciesCopy = new ArrayList<MavenArtifact>(state.myDependencies);
dependenciesCopy.add(dependency);
state.myDependencies = dependenciesCopy;
+
+ state.myCache.clear();
}
@NotNull
@@ -846,22 +827,12 @@
}
public List<MavenArtifact> findDependencies(@NotNull MavenId id) {
- List<MavenArtifact> result = new SmartList<MavenArtifact>();
- for (MavenArtifact each : getDependencies()) {
- if (id.equals(each.getGroupId(), each.getArtifactId(), each.getVersion())) result.add(each);
- }
- return result;
+ return getDependencyArtifactIndex().findArtifacts(id);
}
@NotNull
public List<MavenArtifact> findDependencies(@Nullable String groupId, @Nullable String artifactId) {
- List<MavenArtifact> result = new SmartList<MavenArtifact>();
- for (MavenArtifact each : getDependencies()) {
- if (Comparing.equal(artifactId, each.getArtifactId()) && Comparing.equal(groupId, each.getGroupId())) {
- result.add(each);
- }
- }
- return result;
+ return getDependencyArtifactIndex().findArtifacts(groupId, artifactId);
}
public boolean hasUnresolvedArtifacts() {
@@ -1011,6 +982,16 @@
return Pair.create(type.getDefaultClassifier(), type.getDefaultExtension());
}
+ public MavenArtifactIndex getDependencyArtifactIndex() {
+ MavenArtifactIndex res = getCachedValue(DEPENDENCIES_CACHE_KEY);
+ if (res == null) {
+ res = MavenArtifactIndex.build(getDependencies());
+ res = putCachedValue(DEPENDENCIES_CACHE_KEY, res);
+ }
+
+ return res;
+ }
+
@Nullable
public <V> V getCachedValue(Key<V> key) {
//noinspection unchecked
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectDependencyIndexer.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectDependencyIndexer.java
new file mode 100644
index 0000000..4461cfe
--- /dev/null
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectDependencyIndexer.java
@@ -0,0 +1,12 @@
+package org.jetbrains.idea.maven.project;
+
+/**
+ * @author Sergey Evdokimov
+ */
+public class MavenProjectDependencyIndexer {
+
+
+
+
+
+}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsManager.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsManager.java
index 0d5cf0f..0034268 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsManager.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsManager.java
@@ -16,7 +16,6 @@
package org.jetbrains.idea.maven.project;
import com.intellij.compiler.CompilerWorkspaceConfiguration;
-import com.intellij.compiler.server.BuildManager;
import com.intellij.ide.startup.StartupManagerEx;
import com.intellij.openapi.application.AccessToken;
import com.intellij.openapi.application.ApplicationManager;
@@ -30,7 +29,6 @@
import com.intellij.openapi.project.DumbAwareRunnable;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ModuleRootManager;
-import com.intellij.openapi.roots.ProjectFileIndex;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.util.*;
import com.intellij.openapi.util.io.FileUtil;
@@ -41,15 +39,11 @@
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.UIUtil;
import com.intellij.util.ui.update.Update;
-import com.intellij.util.xmlb.XmlSerializer;
import gnu.trove.THashMap;
import gnu.trove.THashSet;
-import org.jdom.Document;
-import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
-import org.jetbrains.idea.maven.dom.references.MavenFilteredPropertyPsiReferenceProvider;
import org.jetbrains.idea.maven.importing.MavenDefaultModifiableModelsProvider;
import org.jetbrains.idea.maven.importing.MavenFoldersImporter;
import org.jetbrains.idea.maven.importing.MavenModifiableModelsProvider;
@@ -57,12 +51,9 @@
import org.jetbrains.idea.maven.model.*;
import org.jetbrains.idea.maven.server.NativeMavenProjectHolder;
import org.jetbrains.idea.maven.utils.*;
-import org.jetbrains.jps.maven.model.impl.MavenIdBean;
-import org.jetbrains.jps.maven.model.impl.MavenModuleResourceConfiguration;
-import org.jetbrains.jps.maven.model.impl.MavenProjectConfiguration;
-import org.jetbrains.jps.maven.model.impl.ResourceRootConfiguration;
-import java.io.*;
+import java.io.File;
+import java.io.IOException;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -177,7 +168,7 @@
try {
if (!CompilerWorkspaceConfiguration.getInstance(myProject).useOutOfProcessBuild()) return true;
- generateBuildConfiguration(context.isRebuild());
+ new MavenResourceCompilerConfigurationGenerator(myProject, myProjectsTree).generateBuildConfiguration(context.isRebuild());
}
finally {
token.finish();
@@ -1041,160 +1032,6 @@
return projectImporter.getCreatedModules();
}
- public void generateBuildConfiguration(boolean force) {
- if (!isMavenizedProject()) {
- return;
- }
- final BuildManager buildManager = BuildManager.getInstance();
- final File projectSystemDir = buildManager.getProjectSystemDirectory(myProject);
- if (projectSystemDir == null) {
- return;
- }
-
- final File mavenConfigFile = new File(projectSystemDir, MavenProjectConfiguration.CONFIGURATION_FILE_RELATIVE_PATH);
-
- ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
-
- final int crc = myProjectsTree.getFilterConfigCrc(fileIndex);
-
- final File crcFile = new File(mavenConfigFile.getParent(), "configuration.crc");
-
- if (!force) {
- try {
- DataInputStream crcInput = new DataInputStream(new FileInputStream(crcFile));
- try {
- if (crcInput.readInt() == crc) return; // Project had not change since last config generation.
- }
- finally {
- crcInput.close();
- }
- }
- catch (IOException ignored) {
- // // Config file is not generated.
- }
- }
-
- MavenProjectConfiguration projectConfig = new MavenProjectConfiguration();
-
- for (MavenProject mavenProject : getProjects()) {
- VirtualFile pomXml = mavenProject.getFile();
-
- Module module = fileIndex.getModuleForFile(pomXml);
- if (module == null) continue;
-
- if (mavenProject.getDirectoryFile() != fileIndex.getContentRootForFile(pomXml)) continue;
-
- MavenModuleResourceConfiguration resourceConfig = new MavenModuleResourceConfiguration();
-
- MavenId projectId = mavenProject.getMavenId();
- resourceConfig.id = new MavenIdBean(projectId.getGroupId(), projectId.getArtifactId(), projectId.getVersion());
-
- MavenId parentId = mavenProject.getParentId();
- if (parentId != null) {
- resourceConfig.parentId = new MavenIdBean(parentId.getGroupId(), parentId.getArtifactId(), parentId.getVersion());
- }
- resourceConfig.directory = FileUtil.toSystemIndependentName(mavenProject.getDirectory());
- resourceConfig.delimitersPattern = MavenFilteredPropertyPsiReferenceProvider.getDelimitersPattern(mavenProject).pattern();
- for (Map.Entry<String, String> entry : mavenProject.getModelMap().entrySet()) {
- String key = entry.getKey();
- String value = entry.getValue();
- if (value != null) {
- resourceConfig.modelMap.put(key, value);
- }
- }
- addResources(resourceConfig.resources, mavenProject.getResources());
- addResources(resourceConfig.testResources, mavenProject.getTestResources());
- resourceConfig.filteringExclusions.addAll(MavenProjectsTree.getFilterExclusions(mavenProject));
- final Properties properties = getFilteringProperties(mavenProject);
- for (Map.Entry<Object, Object> propEntry : properties.entrySet()) {
- resourceConfig.properties.put((String)propEntry.getKey(), (String)propEntry.getValue());
- }
-
- Element pluginConfiguration = mavenProject.getPluginConfiguration("org.apache.maven.plugins", "maven-resources-plugin");
- resourceConfig.escapeString = MavenJDOMUtil.findChildValueByPath(pluginConfiguration, "escapeString", "\\");
- String escapeWindowsPaths = MavenJDOMUtil.findChildValueByPath(pluginConfiguration, "escapeWindowsPaths");
- if (escapeWindowsPaths != null) {
- resourceConfig.escapeWindowsPaths = Boolean.parseBoolean(escapeWindowsPaths);
- }
-
- projectConfig.moduleConfigurations.put(module.getName(), resourceConfig);
- }
-
- final Document document = new Document(new Element("maven-project-configuration"));
- XmlSerializer.serializeInto(projectConfig, document.getRootElement());
- buildManager.runCommand(new Runnable() {
- @Override
- public void run() {
- buildManager.clearState(myProject);
- FileUtil.createIfDoesntExist(mavenConfigFile);
- try {
- JDOMUtil.writeDocument(document, mavenConfigFile, "\n");
-
- DataOutputStream crcOutput = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(crcFile)));
- try {
- crcOutput.writeInt(crc);
- }
- finally {
- crcOutput.close();
- }
- }
- catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- });
- }
-
- private static void addResources(final List<ResourceRootConfiguration> container, Collection<MavenResource> resources) {
- for (MavenResource resource : resources) {
- final String dir = resource.getDirectory();
- if (dir == null) {
- continue;
- }
-
- final ResourceRootConfiguration props = new ResourceRootConfiguration();
- props.directory = FileUtil.toSystemIndependentName(dir);
-
- final String target = resource.getTargetPath();
- props.targetPath = target != null ? FileUtil.toSystemIndependentName(target) : null;
-
- props.isFiltered = resource.isFiltered();
- props.includes.clear();
- for (String include : resource.getIncludes()) {
- props.includes.add(include.trim());
- }
- props.excludes.clear();
- for (String exclude : resource.getExcludes()) {
- props.excludes.add(exclude.trim());
- }
- container.add(props);
- }
- }
-
- private static Properties getFilteringProperties(MavenProject mavenProject) {
- final Properties properties = new Properties();
-
- for (String each : mavenProject.getFilters()) {
- try {
- FileInputStream in = new FileInputStream(each);
- try {
- properties.load(in);
- }
- finally {
- in.close();
- }
- }
- catch (IOException ignored) {
- }
- }
-
- properties.putAll(mavenProject.getProperties());
-
- properties.put("settings.localRepository", mavenProject.getLocalRepository().getAbsolutePath());
-
- return properties;
- }
-
private Map<VirtualFile, Module> getFileToModuleMapping(MavenModelsProvider modelsProvider) {
Map<VirtualFile, Module> result = new THashMap<VirtualFile, Module>();
for (Module each : modelsProvider.getModules()) {
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsManagerWatcher.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsManagerWatcher.java
index 465a72c..4a46293 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsManagerWatcher.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsManagerWatcher.java
@@ -42,6 +42,7 @@
import com.intellij.openapi.vfs.pointers.VirtualFilePointerManager;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.util.PathUtil;
+import com.intellij.util.containers.ConcurrentWeakHashMap;
import com.intellij.util.messages.MessageBusConnection;
import com.intellij.util.ui.update.Update;
import gnu.trove.THashSet;
@@ -53,9 +54,13 @@
import org.jetbrains.idea.maven.utils.MavenUtil;
import java.io.File;
+import java.io.IOException;
import java.util.*;
public class MavenProjectsManagerWatcher {
+
+ private static final Key<ConcurrentWeakHashMap<Project, Integer>> CRC_WITHOUT_SPACES = Key.create("MavenProjectsManagerWatcher.CRC_WITHOUT_SPACES");
+
public static final Key<Boolean> FORCE_IMPORT_AND_RESOLVE_ON_REFRESH =
Key.create(MavenProjectsManagerWatcher.class + "FORCE_IMPORT_AND_RESOLVE_ON_REFRESH");
@@ -325,10 +330,8 @@
}
private boolean isProfilesFile(String path) {
- String suffix = "/" + MavenConstants.PROFILES_XML;
- if (!path.endsWith(suffix)) return false;
- int pos = path.lastIndexOf(suffix);
- return myProjectsTree.isPotentialProject(path.substring(0, pos) + "/" + MavenConstants.POM_XML);
+ if (!path.endsWith("/" + MavenConstants.PROFILES_XML)) return false;
+ return myProjectsTree.isPotentialProject(path.substring(0, path.length() - MavenConstants.PROFILES_XML.length()) + MavenConstants.POM_XML);
}
private boolean isSettingsFile(String path) {
@@ -358,16 +361,16 @@
}
@Override
- protected void updateFile(VirtualFile file) {
- doUpdateFile(file, false);
+ protected void updateFile(VirtualFile file, VFileEvent event) {
+ doUpdateFile(file, event, false);
}
@Override
- protected void deleteFile(VirtualFile file) {
- doUpdateFile(file, true);
+ protected void deleteFile(VirtualFile file, VFileEvent event) {
+ doUpdateFile(file, event, true);
}
- private void doUpdateFile(VirtualFile file, boolean remove) {
+ private void doUpdateFile(VirtualFile file, VFileEvent event, boolean remove) {
initLists();
if (isSettingsFile(file)) {
@@ -381,7 +384,9 @@
VirtualFile pom = getPomFileProfilesFile(file);
if (pom != null) {
- filesToUpdate.add(pom);
+ if (remove || xmlFileWasChanged(pom, event)) {
+ filesToUpdate.add(pom);
+ }
return;
}
@@ -389,7 +394,37 @@
filesToRemove.add(file);
}
else {
- filesToUpdate.add(file);
+ if (xmlFileWasChanged(file, event)) {
+ filesToUpdate.add(file);
+ }
+ }
+ }
+
+ private boolean xmlFileWasChanged(VirtualFile xmlFile, VFileEvent event) {
+ if (!xmlFile.isValid() || !(event instanceof VFileContentChangeEvent)) return true;
+
+ ConcurrentWeakHashMap<Project, Integer> map = xmlFile.getUserData(CRC_WITHOUT_SPACES);
+ if (map == null) {
+ map = xmlFile.putUserDataIfAbsent(CRC_WITHOUT_SPACES, new ConcurrentWeakHashMap<Project, Integer>());
+ }
+
+ Integer crc = map.get(myProject);
+ Integer newCrc;
+
+ try {
+ newCrc = MavenUtil.crcWithoutSpaces(xmlFile);
+ }
+ catch (IOException ignored) {
+ return true;
+ }
+
+ if (newCrc == -1 // XML is invalid
+ || newCrc.equals(crc)) {
+ return false;
+ }
+ else {
+ map.put(myProject, newCrc);
+ return true;
}
}
@@ -444,9 +479,9 @@
private static abstract class MyFileChangeListenerBase implements BulkFileListener {
protected abstract boolean isRelevant(String path);
- protected abstract void updateFile(VirtualFile file);
+ protected abstract void updateFile(VirtualFile file, VFileEvent event);
- protected abstract void deleteFile(VirtualFile file);
+ protected abstract void deleteFile(VirtualFile file, VFileEvent event);
protected abstract void apply();
@@ -454,31 +489,31 @@
public void before(@NotNull List<? extends VFileEvent> events) {
for (VFileEvent each : events) {
if (each instanceof VFileDeleteEvent) {
- deleteRecursively(each.getFile());
+ deleteRecursively(each.getFile(), each);
}
else {
if (!isRelevant(each.getPath())) continue;
if (each instanceof VFilePropertyChangeEvent) {
if (isRenamed(each)) {
- deleteRecursively(each.getFile());
+ deleteRecursively(each.getFile(), each);
}
}
else if (each instanceof VFileMoveEvent) {
VFileMoveEvent moveEvent = (VFileMoveEvent)each;
String newPath = moveEvent.getNewParent().getPath() + "/" + moveEvent.getFile().getName();
if (!isRelevant(newPath)) {
- deleteRecursively(moveEvent.getFile());
+ deleteRecursively(moveEvent.getFile(), each);
}
}
}
}
}
- private void deleteRecursively(VirtualFile f) {
+ private void deleteRecursively(VirtualFile f, final VFileEvent event) {
VfsUtilCore.visitChildrenRecursively(f, new VirtualFileVisitor() {
@Override
public boolean visitFile(@NotNull VirtualFile f) {
- if (isRelevant(f.getPath())) deleteFile(f);
+ if (isRelevant(f.getPath())) deleteFile(f, event);
return true;
}
@@ -499,26 +534,26 @@
VFileCreateEvent createEvent = (VFileCreateEvent)each;
VirtualFile newChild = createEvent.getParent().findChild(createEvent.getChildName());
if (newChild != null) {
- updateFile(newChild);
+ updateFile(newChild, each);
}
}
else if (each instanceof VFileCopyEvent) {
VFileCopyEvent copyEvent = (VFileCopyEvent)each;
VirtualFile newChild = copyEvent.getNewParent().findChild(copyEvent.getNewChildName());
if (newChild != null) {
- updateFile(newChild);
+ updateFile(newChild, each);
}
}
else if (each instanceof VFileContentChangeEvent) {
- updateFile(each.getFile());
+ updateFile(each.getFile(), each);
}
else if (each instanceof VFilePropertyChangeEvent) {
if (isRenamed(each)) {
- updateFile(each.getFile());
+ updateFile(each.getFile(), each);
}
}
else if (each instanceof VFileMoveEvent) {
- updateFile(each.getFile());
+ updateFile(each.getFile(), each);
}
}
apply();
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsProcessorArtifactsDownloadingTask.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsProcessorArtifactsDownloadingTask.java
index ddf7b46..0e3c079 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsProcessorArtifactsDownloadingTask.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsProcessorArtifactsDownloadingTask.java
@@ -53,7 +53,7 @@
public void perform(final Project project, MavenEmbeddersManager embeddersManager, MavenConsole console, MavenProgressIndicator indicator)
throws MavenProcessCanceledException {
MavenArtifactDownloader.DownloadResult result =
- myTree.downloadSourcesAndJavadocs(myProjects, myArtifacts, myDownloadSources, myDownloadDocs, embeddersManager, console, indicator);
+ myTree.downloadSourcesAndJavadocs(project, myProjects, myArtifacts, myDownloadSources, myDownloadDocs, embeddersManager, console, indicator);
if (myCallbackResult != null) myCallbackResult.setDone(result);
// todo: hack to update all file pointers.
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsTree.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsTree.java
index 8af9573..3a39929 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsTree.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsTree.java
@@ -26,7 +26,6 @@
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.util.Function;
import com.intellij.util.containers.ArrayListSet;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.Stack;
@@ -92,14 +91,10 @@
try {
try {
if (!STORAGE_VERSION.equals(in.readUTF())) return null;
- result.myManagedFilesPaths = readList(in);
- result.myIgnoredFilesPaths = readList(in);
- result.myIgnoredFilesPatterns = readList(in);
- result.myExplicitProfiles = readCollection(in, new Function<Integer, Set<String>>() {
- public Set<String> fun(Integer integer) {
- return new THashSet<String>();
- }
- });
+ result.myManagedFilesPaths = readCollection(in, new ArrayList<String>());
+ result.myIgnoredFilesPaths = readCollection(in, new ArrayList<String>());
+ result.myIgnoredFilesPatterns = readCollection(in, new ArrayList<String>());
+ result.myExplicitProfiles = readCollection(in, new THashSet<String>());
result.myRootProjects.addAll(readProjectsRecursively(in, result));
}
catch (IOException e) {
@@ -117,23 +112,21 @@
return result;
}
- private static List<String> readList(DataInputStream in) throws IOException {
- return readCollection(in, new Function<Integer, List<String>>() {
- public List<String> fun(Integer integer) {
- return new ArrayList<String>(integer);
- }
- });
- }
-
- private static <T extends Collection<String>> T readCollection(DataInputStream in, Function<Integer, T> factory) throws IOException {
+ private static <T extends Collection<String>> T readCollection(DataInputStream in, T result) throws IOException {
int count = in.readInt();
- T result = factory.fun(count);
while (count-- > 0) {
result.add(in.readUTF());
}
return result;
}
+ private static void writeCollection(DataOutputStream out, Collection<String> list) throws IOException {
+ out.writeInt(list.size());
+ for (String each : list) {
+ out.writeUTF(each);
+ }
+ }
+
private static List<MavenProject> readProjectsRecursively(DataInputStream in,
MavenProjectsTree tree) throws IOException {
int count = in.readInt();
@@ -180,13 +173,6 @@
}
}
- private static void writeCollection(DataOutputStream out, Collection<String> list) throws IOException {
- out.writeInt(list.size());
- for (String each : list) {
- out.writeUTF(each);
- }
- }
-
private void writeProjectsRecursively(DataOutputStream out, List<MavenProject> list) throws IOException {
out.writeInt(list.size());
for (MavenProject each : list) {
@@ -380,25 +366,25 @@
}
public Collection<String> getAvailableProfiles() {
- return getAvailableAndActiveProfiles(true, false).first;
- }
+ Collection<String> res = new THashSet<String>();
- private Pair<Collection<String>, Collection<String>> getAvailableAndActiveProfiles(boolean includeAvailable, boolean includeActive) {
- Collection<String> available = includeAvailable ? new THashSet<String>() : null;
- Collection<String> active = includeActive ? new THashSet<String>() : null;
for (MavenProject each : getProjects()) {
- if (available != null) available.addAll(each.getProfilesIds());
- if (active != null) active.addAll(each.getActivatedProfilesIds());
+ res.addAll(each.getProfilesIds());
}
- return Pair.create(available, active);
+
+ return res;
}
public Collection<Pair<String, MavenProfileKind>> getProfilesWithStates() {
Collection<Pair<String, MavenProfileKind>> result = new ArrayListSet<Pair<String, MavenProfileKind>>();
- Pair<Collection<String>, Collection<String>> profiles = getAvailableAndActiveProfiles(true, true);
- Collection<String> available = profiles.first;
- Collection<String> active = profiles.second;
+ Collection<String> available = new THashSet<String>();
+ Collection<String> active = new THashSet<String>();
+ for (MavenProject each : getProjects()) {
+ available.addAll(each.getProfilesIds());
+ active.addAll(each.getActivatedProfilesIds());
+ }
+
Collection<String> explicitProfiles = getExplicitProfiles();
for (String each : available) {
@@ -1243,7 +1229,8 @@
});
}
- public MavenArtifactDownloader.DownloadResult downloadSourcesAndJavadocs(@NotNull Collection<MavenProject> projects,
+ public MavenArtifactDownloader.DownloadResult downloadSourcesAndJavadocs(@NotNull Project project,
+ @NotNull Collection<MavenProject> projects,
@Nullable Collection<MavenArtifact> artifacts,
boolean downloadSources,
boolean downloadDocs,
@@ -1256,7 +1243,7 @@
try {
MavenArtifactDownloader.DownloadResult result =
- MavenArtifactDownloader.download(this, projects, artifacts, downloadSources, downloadDocs, embedder, process);
+ MavenArtifactDownloader.download(project, this, projects, artifacts, downloadSources, downloadDocs, embedder, process);
for (MavenProject each : projects) {
fireArtifactsDownloaded(each);
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenResourceCompilerConfigurationGenerator.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenResourceCompilerConfigurationGenerator.java
new file mode 100644
index 0000000..12fb1d3
--- /dev/null
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenResourceCompilerConfigurationGenerator.java
@@ -0,0 +1,299 @@
+package org.jetbrains.idea.maven.project;
+
+import com.intellij.compiler.CompilerConfiguration;
+import com.intellij.compiler.CompilerConfigurationImpl;
+import com.intellij.compiler.server.BuildManager;
+import com.intellij.openapi.module.Module;
+import com.intellij.openapi.module.ModuleManager;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.roots.*;
+import com.intellij.openapi.util.JDOMUtil;
+import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.openapi.vfs.LocalFileSystem;
+import com.intellij.openapi.vfs.VfsUtil;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.util.containers.ContainerUtil;
+import com.intellij.util.xmlb.XmlSerializer;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jetbrains.idea.maven.dom.references.MavenFilteredPropertyPsiReferenceProvider;
+import org.jetbrains.idea.maven.model.MavenId;
+import org.jetbrains.idea.maven.model.MavenResource;
+import org.jetbrains.idea.maven.utils.MavenJDOMUtil;
+import org.jetbrains.idea.maven.utils.MavenUtil;
+import org.jetbrains.jps.maven.model.impl.MavenIdBean;
+import org.jetbrains.jps.maven.model.impl.MavenModuleResourceConfiguration;
+import org.jetbrains.jps.maven.model.impl.MavenProjectConfiguration;
+import org.jetbrains.jps.maven.model.impl.ResourceRootConfiguration;
+
+import java.io.*;
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author Sergey Evdokimov
+ */
+public class MavenResourceCompilerConfigurationGenerator {
+
+ private static final Pattern SIMPLE_NEGATIVE_PATTERN = Pattern.compile("!\\?(\\*\\.\\w+)");
+
+ private final Project myProject;
+
+ private final MavenProjectsManager myMavenProjectsManager;
+
+ private final MavenProjectsTree myProjectsTree;
+
+ public MavenResourceCompilerConfigurationGenerator(Project project, MavenProjectsTree projectsTree) {
+ myProject = project;
+ myMavenProjectsManager = MavenProjectsManager.getInstance(project);
+ myProjectsTree = projectsTree;
+ }
+
+ public void generateBuildConfiguration(boolean force) {
+ if (!myMavenProjectsManager.isMavenizedProject()) {
+ return;
+ }
+
+ final BuildManager buildManager = BuildManager.getInstance();
+ final File projectSystemDir = buildManager.getProjectSystemDirectory(myProject);
+ if (projectSystemDir == null) {
+ return;
+ }
+
+ final File mavenConfigFile = new File(projectSystemDir, MavenProjectConfiguration.CONFIGURATION_FILE_RELATIVE_PATH);
+
+ ProjectRootManager projectRootManager = ProjectRootManager.getInstance(myProject);
+
+ ProjectFileIndex fileIndex = projectRootManager.getFileIndex();
+
+ final int crc = myProjectsTree.getFilterConfigCrc(fileIndex) + (int)projectRootManager.getModificationCount();
+
+ final File crcFile = new File(mavenConfigFile.getParent(), "configuration.crc");
+
+ if (!force) {
+ try {
+ DataInputStream crcInput = new DataInputStream(new FileInputStream(crcFile));
+ try {
+ if (crcInput.readInt() == crc) return; // Project had not change since last config generation.
+ }
+ finally {
+ crcInput.close();
+ }
+ }
+ catch (IOException ignored) {
+ // // Config file is not generated.
+ }
+ }
+
+ MavenProjectConfiguration projectConfig = new MavenProjectConfiguration();
+
+ for (MavenProject mavenProject : myMavenProjectsManager.getProjects()) {
+ VirtualFile pomXml = mavenProject.getFile();
+
+ Module module = fileIndex.getModuleForFile(pomXml);
+ if (module == null) continue;
+
+ if (mavenProject.getDirectoryFile() != fileIndex.getContentRootForFile(pomXml)) continue;
+
+ MavenModuleResourceConfiguration resourceConfig = new MavenModuleResourceConfiguration();
+
+ MavenId projectId = mavenProject.getMavenId();
+ resourceConfig.id = new MavenIdBean(projectId.getGroupId(), projectId.getArtifactId(), projectId.getVersion());
+
+ MavenId parentId = mavenProject.getParentId();
+ if (parentId != null) {
+ resourceConfig.parentId = new MavenIdBean(parentId.getGroupId(), parentId.getArtifactId(), parentId.getVersion());
+ }
+ resourceConfig.directory = FileUtil.toSystemIndependentName(mavenProject.getDirectory());
+ resourceConfig.delimitersPattern = MavenFilteredPropertyPsiReferenceProvider.getDelimitersPattern(mavenProject).pattern();
+ for (Map.Entry<String, String> entry : mavenProject.getModelMap().entrySet()) {
+ String key = entry.getKey();
+ String value = entry.getValue();
+ if (value != null) {
+ resourceConfig.modelMap.put(key, value);
+ }
+ }
+ addResources(resourceConfig.resources, mavenProject.getResources());
+ addResources(resourceConfig.testResources, mavenProject.getTestResources());
+ resourceConfig.filteringExclusions.addAll(MavenProjectsTree.getFilterExclusions(mavenProject));
+
+ final Properties properties = getFilteringProperties(mavenProject);
+ for (Map.Entry<Object, Object> propEntry : properties.entrySet()) {
+ resourceConfig.properties.put((String)propEntry.getKey(), (String)propEntry.getValue());
+ }
+
+ Element pluginConfiguration = mavenProject.getPluginConfiguration("org.apache.maven.plugins", "maven-resources-plugin");
+ resourceConfig.escapeString = MavenJDOMUtil.findChildValueByPath(pluginConfiguration, "escapeString", "\\");
+ String escapeWindowsPaths = MavenJDOMUtil.findChildValueByPath(pluginConfiguration, "escapeWindowsPaths");
+ if (escapeWindowsPaths != null) {
+ resourceConfig.escapeWindowsPaths = Boolean.parseBoolean(escapeWindowsPaths);
+ }
+
+ projectConfig.moduleConfigurations.put(module.getName(), resourceConfig);
+ }
+
+ addNonMavenResources(projectConfig);
+
+ final Document document = new Document(new Element("maven-project-configuration"));
+ XmlSerializer.serializeInto(projectConfig, document.getRootElement());
+ buildManager.runCommand(new Runnable() {
+ @Override
+ public void run() {
+ buildManager.clearState(myProject);
+ FileUtil.createIfDoesntExist(mavenConfigFile);
+ try {
+ JDOMUtil.writeDocument(document, mavenConfigFile, "\n");
+
+ DataOutputStream crcOutput = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(crcFile)));
+ try {
+ crcOutput.writeInt(crc);
+ }
+ finally {
+ crcOutput.close();
+ }
+ }
+ catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ });
+ }
+
+ private Properties getFilteringProperties(MavenProject mavenProject) {
+ final Properties properties = new Properties();
+
+ for (String each : mavenProject.getFilters()) {
+ try {
+ FileInputStream in = new FileInputStream(each);
+ try {
+ properties.load(in);
+ }
+ finally {
+ in.close();
+ }
+ }
+ catch (IOException ignored) {
+ }
+ }
+
+ properties.putAll(mavenProject.getProperties());
+
+ properties.put("settings.localRepository", mavenProject.getLocalRepository().getAbsolutePath());
+
+ String jreDir = MavenUtil.getModuleJreHome(myMavenProjectsManager, mavenProject);
+ if (jreDir != null) {
+ properties.put("java.home", jreDir);
+ }
+
+ String javaVersion = MavenUtil.getModuleJavaVersion(myMavenProjectsManager, mavenProject);
+ if (javaVersion != null) {
+ properties.put("java.version", javaVersion);
+ }
+
+ return properties;
+ }
+
+ private static void addResources(final List<ResourceRootConfiguration> container, Collection<MavenResource> resources) {
+ for (MavenResource resource : resources) {
+ final String dir = resource.getDirectory();
+ if (dir == null) {
+ continue;
+ }
+
+ final ResourceRootConfiguration props = new ResourceRootConfiguration();
+ props.directory = FileUtil.toSystemIndependentName(dir);
+
+ final String target = resource.getTargetPath();
+ props.targetPath = target != null ? FileUtil.toSystemIndependentName(target) : null;
+
+ props.isFiltered = resource.isFiltered();
+ props.includes.clear();
+ for (String include : resource.getIncludes()) {
+ props.includes.add(include.trim());
+ }
+ props.excludes.clear();
+ for (String exclude : resource.getExcludes()) {
+ props.excludes.add(exclude.trim());
+ }
+ container.add(props);
+ }
+ }
+
+ private void addNonMavenResources(MavenProjectConfiguration projectCfg) {
+ Set<VirtualFile> processedRoots = new HashSet<VirtualFile>();
+
+ for (MavenProject project : myMavenProjectsManager.getProjects()) {
+ for (String dir : ContainerUtil.concat(project.getSources(), project.getTestSources())) {
+ VirtualFile file = LocalFileSystem.getInstance().findFileByPath(dir);
+ if (file != null) {
+ processedRoots.add(file);
+ }
+ }
+
+ for (MavenResource resource : ContainerUtil.concat(project.getResources(), project.getTestResources())) {
+ VirtualFile file = LocalFileSystem.getInstance().findFileByPath(resource.getDirectory());
+ if (file != null) {
+ processedRoots.add(file);
+ }
+ }
+ }
+
+ CompilerConfiguration compilerConfiguration = CompilerConfiguration.getInstance(myProject);
+
+ for (Module module : ModuleManager.getInstance(myProject).getModules()) {
+ if (!myMavenProjectsManager.isMavenizedModule(module)) continue;
+
+ for (ContentEntry contentEntry : ModuleRootManager.getInstance(module).getContentEntries()) {
+ for (SourceFolder folder : contentEntry.getSourceFolders()) {
+ VirtualFile file = folder.getFile();
+ if (file == null) continue;
+
+ if (!compilerConfiguration.isExcludedFromCompilation(file) && !isUnderRoots(processedRoots, file)) {
+ MavenModuleResourceConfiguration configuration = projectCfg.moduleConfigurations.get(module.getName());
+ if (configuration == null) continue;
+
+ List<ResourceRootConfiguration> resourcesList = folder.isTestSource() ? configuration.testResources : configuration.resources;
+
+ final ResourceRootConfiguration cfg = new ResourceRootConfiguration();
+ cfg.directory = FileUtil.toSystemIndependentName(FileUtil.toSystemIndependentName(file.getPath()));
+
+ CompilerModuleExtension compilerModuleExtension = CompilerModuleExtension.getInstance(module);
+ if (compilerModuleExtension == null) continue;
+
+
+ String compilerOutputUrl = folder.isTestSource()
+ ? compilerModuleExtension.getCompilerOutputUrlForTests()
+ : compilerModuleExtension.getCompilerOutputUrl();
+
+ cfg.targetPath = VfsUtil.urlToPath(compilerOutputUrl);
+
+ convertIdeaExcludesToMavenExcludes(cfg, (CompilerConfigurationImpl)compilerConfiguration);
+
+ resourcesList.add(cfg);
+ }
+ }
+ }
+ }
+ }
+
+ private static void convertIdeaExcludesToMavenExcludes(ResourceRootConfiguration cfg, CompilerConfigurationImpl compilerConfiguration) {
+ for (String pattern : compilerConfiguration.getResourceFilePatterns()) {
+ Matcher matcher = SIMPLE_NEGATIVE_PATTERN.matcher(pattern);
+ if (matcher.matches()) {
+ cfg.excludes.add("**/" + matcher.group(1));
+ }
+ }
+ }
+
+ private static boolean isUnderRoots(Set<VirtualFile> roots, VirtualFile file) {
+ for (VirtualFile f = file; f != null; f = f.getParent()) {
+ if (roots.contains(file)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenScalaConsoleFilter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenScalaConsoleFilter.java
new file mode 100644
index 0000000..abfa6cc
--- /dev/null
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenScalaConsoleFilter.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2000-2012 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 org.jetbrains.idea.maven.project;
+
+import com.intellij.openapi.project.Project;
+
+import java.util.regex.Pattern;
+
+/**
+ * @author Sergey Evdokimov
+ */
+public class MavenScalaConsoleFilter extends AbstractMavenConsoleFilter {
+
+ private static final Pattern PATTERN = Pattern.compile("\\[ERROR\\] (\\S.+\\.scala): ?(-?\\d{1,5}): .+", Pattern.DOTALL);
+
+ public MavenScalaConsoleFilter(Project project) {
+ super(project, PATTERN);
+ }
+
+ @Override
+ protected boolean lightCheck(String line) {
+ return line.startsWith("[ERROR] ") && line.contains(".scala:");
+ }
+}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/server/MavenServerManager.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/server/MavenServerManager.java
index fd3ce1d..863594f 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/server/MavenServerManager.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/server/MavenServerManager.java
@@ -32,6 +32,7 @@
import com.intellij.openapi.projectRoots.JdkUtil;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.projectRoots.SimpleJavaSdkType;
+import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.util.ShutDownTracker;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.util.Alarm;
@@ -54,7 +55,6 @@
import org.jetbrains.idea.maven.utils.MavenUtil;
import java.io.File;
-import java.nio.charset.Charset;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.ArrayList;
@@ -336,6 +336,9 @@
settings = settings.clone();
settings.setOffline(false);
}
+
+ settings.setProjectJdk(MavenUtil.getSdkPath(ProjectRootManager.getInstance(project).getProjectSdk()));
+
return MavenServerManager.this.getOrCreateWrappee().createEmbedder(settings);
}
};
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenArtifactUtil.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenArtifactUtil.java
index cba0ef4..3ae3060 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenArtifactUtil.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenArtifactUtil.java
@@ -15,6 +15,7 @@
*/
package org.jetbrains.idea.maven.utils;
+import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import gnu.trove.THashMap;
@@ -70,6 +71,33 @@
return getArtifactFile(localRepository, id.getGroupId(), id.getArtifactId(), id.getVersion(), "pom");
}
+ public static boolean isPluginIdEquals(@Nullable String groupId1, @Nullable String artifactId1,
+ @Nullable String groupId2, @Nullable String artifactId2) {
+ if (artifactId1 == null) return false;
+
+ if (!artifactId1.equals(artifactId2)) return false;
+
+ if (groupId1 != null) {
+ for (String group : DEFAULT_GROUPS) {
+ if (groupId1.equals(group)) {
+ groupId1 = null;
+ break;
+ }
+ }
+ }
+
+ if (groupId2 != null) {
+ for (String group : DEFAULT_GROUPS) {
+ if (groupId2.equals(group)) {
+ groupId2 = null;
+ break;
+ }
+ }
+ }
+
+ return Comparing.equal(groupId1, groupId2);
+ }
+
@NotNull
public static File getArtifactFile(File localRepository, String groupId, String artifactId, String version, String type) {
File dir = null;
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java
index fd63fcf..ad22709 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java
@@ -32,12 +32,15 @@
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
+import com.intellij.openapi.module.Module;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.projectRoots.Sdk;
+import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.startup.StartupManager;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Pair;
@@ -63,9 +66,17 @@
import org.jetbrains.idea.maven.project.MavenProjectsManager;
import org.jetbrains.idea.maven.server.MavenServerManager;
import org.jetbrains.idea.maven.server.MavenServerUtil;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.helpers.DefaultHandler;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
import java.io.File;
import java.io.IOException;
+import java.io.InputStream;
import java.net.URL;
import java.util.*;
import java.util.concurrent.ExecutionException;
@@ -73,6 +84,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
+import java.util.zip.CRC32;
public class MavenUtil {
public static final String MAVEN_NOTIFICATION_GROUP = "Maven";
@@ -747,4 +759,151 @@
public interface MavenTaskHandler {
void waitFor();
}
+
+ public static int crcWithoutSpaces(@NotNull InputStream in) throws IOException {
+ try {
+ final CRC32 crc = new CRC32();
+
+ SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
+
+ parser.parse(in, new DefaultHandler(){
+
+ boolean textContentOccur = false;
+ int spacesCrc;
+
+ private void putString(@Nullable String string) {
+ if (string == null) return;
+
+ for (int i = 0, end = string.length(); i < end; i++) {
+ crc.update(string.charAt(i));
+ }
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
+ textContentOccur = false;
+
+ crc.update(1);
+ putString(qName);
+
+ for (int i = 0; i < attributes.getLength(); i++) {
+ putString(attributes.getQName(i));
+ putString(attributes.getValue(i));
+ }
+ }
+
+ @Override
+ public void endElement(String uri, String localName, String qName) throws SAXException {
+ textContentOccur = false;
+
+ crc.update(2);
+ putString(qName);
+ }
+
+ private void processTextOrSpaces(char[] ch, int start, int length) {
+ for (int i = start, end = start + length; i < end; i++) {
+ char a = ch[i];
+
+ if (Character.isWhitespace(a)) {
+ if (textContentOccur) {
+ spacesCrc = spacesCrc * 31 + a;
+ }
+ }
+ else {
+ if (textContentOccur && spacesCrc != 0) {
+ crc.update(spacesCrc);
+ crc.update(spacesCrc >> 8);
+ }
+
+ crc.update(a);
+
+ textContentOccur = true;
+ spacesCrc = 0;
+ }
+ }
+ }
+
+ @Override
+ public void characters(char[] ch, int start, int length) throws SAXException {
+ processTextOrSpaces(ch, start, length);
+ }
+
+ @Override
+ public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
+ processTextOrSpaces(ch, start, length);
+ }
+
+ @Override
+ public void processingInstruction(String target, String data) throws SAXException {
+ putString(target);
+ putString(data);
+ }
+
+ @Override
+ public void skippedEntity(String name) throws SAXException {
+ putString(name);
+ }
+
+ @Override
+ public void error(SAXParseException e) throws SAXException {
+ crc.update(100);
+ }
+ });
+
+ return (int)crc.getValue();
+ }
+ catch (ParserConfigurationException e) {
+ throw new RuntimeException(e);
+ }
+ catch (SAXException e) {
+ return -1;
+ }
+ }
+
+ public static int crcWithoutSpaces(@NotNull VirtualFile xmlFile) throws IOException {
+ InputStream inputStream = xmlFile.getInputStream();
+ try {
+ return crcWithoutSpaces(inputStream);
+ }
+ finally {
+ inputStream.close();
+ }
+ }
+
+ public static String getSdkPath(@Nullable Sdk sdk) {
+ if (sdk == null) return null;
+
+ VirtualFile homeDirectory = sdk.getHomeDirectory();
+ if (homeDirectory == null) return null;
+
+ if (!"jre".equals(homeDirectory.getName())) {
+ VirtualFile jreDir = homeDirectory.findChild("jre");
+ if (jreDir != null) {
+ homeDirectory = jreDir;
+ }
+ }
+
+ return homeDirectory.getPath();
+ }
+
+ @Nullable
+ public static String getModuleJreHome(@NotNull MavenProjectsManager mavenProjectsManager, @NotNull MavenProject mavenProject) {
+ return getSdkPath(getModuleJdk(mavenProjectsManager, mavenProject));
+ }
+
+ @Nullable
+ public static String getModuleJavaVersion(@NotNull MavenProjectsManager mavenProjectsManager, @NotNull MavenProject mavenProject) {
+ Sdk sdk = getModuleJdk(mavenProjectsManager, mavenProject);
+ if (sdk == null) return null;
+
+ return sdk.getVersionString();
+ }
+
+ @Nullable
+ public static Sdk getModuleJdk(@NotNull MavenProjectsManager mavenProjectsManager, @NotNull MavenProject mavenProject) {
+ Module module = mavenProjectsManager.findModule(mavenProject);
+ if (module == null) return null;
+
+ return ModuleRootManager.getInstance(module).getSdk();
+ }
}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenActionUtil.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenActionUtil.java
index 13a347f..4658fd4 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenActionUtil.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenActionUtil.java
@@ -82,7 +82,9 @@
}
public static boolean isMavenProjectFile(VirtualFile file) {
- return file != null && !file.isDirectory() && MavenConstants.POM_XML.equals(file.getName());
+ return file != null && !file.isDirectory()
+ && MavenConstants.POM_XML.equals(file.getName())
+ && file.isInLocalFileSystem();
}
public static List<MavenProject> getMavenProjects(DataContext context) {
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/SelectProfilesStep.form b/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/SelectProfilesStep.form
index dac764d..6f73eb9 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/SelectProfilesStep.form
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/SelectProfilesStep.form
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.idea.maven.wizards.SelectProfilesStep">
- <grid id="27dc6" binding="panel" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+ <grid id="27dc6" binding="panel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="8" left="8" bottom="8" right="8"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
@@ -14,11 +14,6 @@
</constraints>
<properties/>
</component>
- <vspacer id="dd0c8">
- <constraints>
- <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
- </constraints>
- </vspacer>
<component id="beb4e" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
diff --git a/plugins/maven/src/main/resources/META-INF/groovy-support.xml b/plugins/maven/src/main/resources/META-INF/groovy-support.xml
index 696cf9c..11a96b0 100644
--- a/plugins/maven/src/main/resources/META-INF/groovy-support.xml
+++ b/plugins/maven/src/main/resources/META-INF/groovy-support.xml
@@ -2,15 +2,19 @@
<extensions defaultExtensionNs="org.jetbrains.idea.maven">
<importer implementation="org.jetbrains.idea.maven.importing.Groovy_1_0_Importer"/>
<importer implementation="org.jetbrains.idea.maven.importing.Groovy_1_1_plus_Importer"/>
- </extensions>
- <extensions defaultExtensionNs="org.jetbrains.idea.maven">
<pluginDescriptor mavenId="org.codehaus.groovy.maven:gmaven-plugin">
- <param name="source" languageProvider="org.jetbrains.idea.maven.plugins.groovy.MavenGroovyLanguageProvider"/>
+ <param name="source" languageProvider="org.jetbrains.idea.maven.plugins.groovy.MavenGroovyLanguageProvider"
+ languageInjectionPrefix="class GroovyMavenPomClassIdea {{" languageInjectionSuffix="}}"/>
</pluginDescriptor>
<pluginDescriptor mavenId="org.codehaus.gmaven:gmaven-plugin">
- <param name="source" languageProvider="org.jetbrains.idea.maven.plugins.groovy.MavenGroovyLanguageProvider"/>
+ <param name="source" languageProvider="org.jetbrains.idea.maven.plugins.groovy.MavenGroovyLanguageProvider"
+ languageInjectionPrefix="class GroovyMavenPomClassIdea {{" languageInjectionSuffix="}}"/>
</pluginDescriptor>
</extensions>
+
+ <extensions defaultExtensionNs="org.intellij.groovy">
+ <membersContributor implementation="org.jetbrains.idea.maven.plugins.groovy.MavenGroovyPomScriptMemberContributor"/>
+ </extensions>
</idea-plugin>
\ No newline at end of file
diff --git a/plugins/maven/src/main/resources/META-INF/plugin.xml b/plugins/maven/src/main/resources/META-INF/plugin.xml
index 50954e2..416ecdc 100644
--- a/plugins/maven/src/main/resources/META-INF/plugin.xml
+++ b/plugins/maven/src/main/resources/META-INF/plugin.xml
@@ -184,6 +184,8 @@
<param name="outputDirectory" refProvider="org.jetbrains.idea.maven.plugins.api.common.MavenCommonParamReferenceProviders$DirPath"/>
<param name="filters/filter" refProvider="org.jetbrains.idea.maven.plugins.api.common.MavenCommonParamReferenceProviders$FilePath"/>
<param name="resourceEncoding" refProvider="org.jetbrains.idea.maven.plugins.api.common.MavenCommonParamReferenceProviders$Encoding"/>
+
+ <param name="outputFileNameMapping" disableReferences="true"/>
</pluginDescriptor>
<pluginDescriptor mavenId="org.apache.maven.plugins:maven-acr-plugin">
@@ -230,6 +232,11 @@
<param name="javaScriptBuildnumberCallback" language="JavaScript" languageInjectionPrefix="function() {return a + " languageInjectionSuffix="}" />
</pluginDescriptor>
+ <pluginDescriptor mavenId="org.codehaus.mojo:buildnumber-maven-plugin">
+ <property name="buildNumber"/>
+ <property name="timestamp"/>
+ </pluginDescriptor>
+
<pluginDescriptor mavenId="org.codehaus.mojo:sql-maven-plugin">
<param name="sqlCommand" language="SQL"/>
</pluginDescriptor>
@@ -243,6 +250,8 @@
<pluginDescriptor mavenId="org.apache.maven.plugins:maven-resources-plugin">
<param name="encoding" refProvider="org.jetbrains.idea.maven.plugins.api.common.MavenCommonParamReferenceProviders$Encoding"/>
+
+ <param name="delimiters/delimiter" disableReferences="true"/>
</pluginDescriptor>
</extensions>
diff --git a/plugins/maven/src/main/resources/ProjectBundle.properties b/plugins/maven/src/main/resources/ProjectBundle.properties
index 4277e11..af2bf52 100644
--- a/plugins/maven/src/main/resources/ProjectBundle.properties
+++ b/plugins/maven/src/main/resources/ProjectBundle.properties
@@ -36,6 +36,7 @@
maven.import.environment.settings=&Environment settings...
maven.import.environment.settings.title=Maven environment
maven.import.title.module.dir=Select directory for IDEA module files (*.iml)
+maven.import.dependency.type.description=Comma separated list of dependency types that should be imported
maven.import.incompatible.modules=<html>\
The following {0,choice,1#module has|2#modules have} incorrect type and {0,choice,1#needs|2#need} to be recreated:<br><br>{1}<br><br>\
diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenImportingTestCase.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenImportingTestCase.java
index 8a4f802..c75a604 100644
--- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenImportingTestCase.java
+++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenImportingTestCase.java
@@ -50,10 +50,7 @@
import org.jetbrains.annotations.NonNls;
import org.jetbrains.idea.maven.execution.*;
import org.jetbrains.idea.maven.model.MavenArtifact;
-import org.jetbrains.idea.maven.project.MavenArtifactDownloader;
-import org.jetbrains.idea.maven.project.MavenProject;
-import org.jetbrains.idea.maven.project.MavenProjectsManager;
-import org.jetbrains.idea.maven.project.MavenProjectsTree;
+import org.jetbrains.idea.maven.project.*;
import javax.swing.*;
import java.io.File;
@@ -531,7 +528,8 @@
modules.add(getModule(each));
}
if (useJps()) {
- MavenProjectsManager.getInstance(myProject).generateBuildConfiguration(false);
+ new MavenResourceCompilerConfigurationGenerator(myProject, MavenProjectsManager.getInstance(myProject).getProjectsTreeForTests())
+ .generateBuildConfiguration(false);
}
}
});
diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/AnnotationProcessorImportingTest.groovy b/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/AnnotationProcessorImportingTest.groovy
index 097b891..56664ce 100644
--- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/AnnotationProcessorImportingTest.groovy
+++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/AnnotationProcessorImportingTest.groovy
@@ -291,5 +291,42 @@
assert profile.getGeneratedSourcesDirectoryName(true).replace('\\', '/').endsWith("target/metamodelTest")
}
+ public void testProcessorsViaBscMavenPlugin() {
+ importProject("""
+<groupId>test</groupId>
+<artifactId>project</artifactId>
+<version>1</version>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.bsc.maven</groupId>
+ <artifactId>maven-processor-plugin</artifactId>
+
+ <executions>
+ <execution>
+ <id>process-entities</id>
+ <goals>
+ <goal>process</goal>
+ </goals>
+ <phase>generate-sources</phase>
+
+ <configuration>
+ <processors>
+ <processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
+ <processor>com.test.SourceCodeGeneratingAnnotationProcessor2</processor>
+ </processors>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+""")
+
+ def compilerConfiguration = ((CompilerConfigurationImpl)CompilerConfiguration.getInstance(myProject))
+
+ assert compilerConfiguration.findModuleProcessorProfile(MavenAnnotationProcessorConfigurer.PROFILE_PREFIX + 'project').getProcessors() ==
+ new HashSet<String>(["com.test.SourceCodeGeneratingAnnotationProcessor2", "com.mysema.query.apt.jpa.JPAAnnotationProcessor"])
+ }
}
diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ResourceCopyingTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ResourceCopyingTest.java
index bd3a718..93cad46 100644
--- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ResourceCopyingTest.java
+++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ResourceCopyingTest.java
@@ -17,13 +17,15 @@
import com.intellij.compiler.CompilerConfiguration;
import com.intellij.compiler.CompilerConfigurationImpl;
-import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.AccessToken;
+import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.command.WriteCommandAction;
+import com.intellij.openapi.compiler.options.ExcludeEntryDescription;
+import com.intellij.openapi.module.Module;
+import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.testFramework.PsiTestUtil;
import org.jetbrains.idea.maven.MavenImportingTestCase;
-import org.jetbrains.idea.maven.importing.MavenDefaultModifiableModelsProvider;
-import org.jetbrains.idea.maven.importing.MavenRootModelAdapter;
import java.io.File;
@@ -426,38 +428,6 @@
assertCopied("target/classes/file.properties");
}
- public void testWorkCorrectlyIfFoldersMarkedAsSource() throws Exception {
- createProjectSubFile("src/main/resources/file.properties");
- createProjectSubFile("src/main/resources/file.txt");
- createProjectSubFile("src/main/resources/file.xxx");
- createProjectSubFile("src/main/ideaRes/file2.xxx");
-
- importProject("<groupId>test</groupId>" +
- "<artifactId>project</artifactId>" +
- "<version>1</version>");
-
- ApplicationManager.getApplication().runWriteAction(new Runnable() {
- public void run() {
- MavenRootModelAdapter adapter = new MavenRootModelAdapter(myProjectsTree.findProject(myProjectPom),
- getModule("project"),
- new MavenDefaultModifiableModelsProvider(myProject));
- adapter.addSourceFolder(myProjectRoot.findFileByRelativePath("src/main/resources").getPath(), false);
- adapter.addSourceFolder(myProjectRoot.findFileByRelativePath("src/main/ideaRes").getPath(), false);
- adapter.getRootModel().commit();
- }
- });
-
-
- assertSources("project", "src/main/resources", "src/main/ideaRes");
-
- compileModules("project");
-
- assertCopied("target/classes/file.properties");
- assertCopied("target/classes/file.txt");
- assertCopied("target/classes/file.xxx");
- assertNotCopied("target/classes/file2.xxx");
- }
-
public void testDoNotDeleteFilesFromOtherModulesOutput() throws Exception {
createProjectSubFile("m1/resources/file.xxx");
createProjectSubFile("m2/resources/file.yyy");
@@ -576,14 +546,16 @@
}
private void setModulesOutput(final VirtualFile output, final String... moduleNames) {
- ApplicationManager.getApplication().runWriteAction(new Runnable() {
- public void run() {
- for (String each : moduleNames) {
- PsiTestUtil.setCompilerOutputPath(getModule(each), output.getUrl(), false);
- PsiTestUtil.setCompilerOutputPath(getModule(each), output.getUrl(), true);
- }
+ AccessToken accessToken = WriteAction.start();
+ try {
+ for (String each : moduleNames) {
+ PsiTestUtil.setCompilerOutputPath(getModule(each), output.getUrl(), false);
+ PsiTestUtil.setCompilerOutputPath(getModule(each), output.getUrl(), true);
}
- });
+ }
+ finally {
+ accessToken.finish();
+ }
}
public void testWebResources() throws Exception {
@@ -675,6 +647,47 @@
"</build>");
}
+ public void testCopingNonMavenResources() throws Exception {
+ if (ignore()) return;
+
+ createProjectSubFile("src/resources/a.txt", "a");
+
+ VirtualFile configDir = createProjectSubDir("src/config");
+ createProjectSubFile("src/config/b.txt", "b");
+ createProjectSubFile("src/config/JavaClass.java", "class JavaClass {}");
+ createProjectSubFile("src/config/xxx.xxx", "xxx"); // *.xxx is excluded from resource coping, see setUpInWriteAction()
+
+ final VirtualFile excludedDir = createProjectSubDir("src/excluded");
+ createProjectSubFile("src/excluded/c.txt", "c");
+
+ importProject("<groupId>test</groupId>" +
+ "<artifactId>project</artifactId>" +
+ "<version>1</version>");
+
+ Module module = ModuleManager.getInstance(myProject).findModuleByName("project");
+ PsiTestUtil.addSourceRoot(module, configDir);
+ PsiTestUtil.addSourceRoot(module, excludedDir);
+
+ new WriteCommandAction.Simple(myProject) {
+ @Override
+ protected void run() throws Throwable {
+ CompilerConfiguration.getInstance(myProject).getExcludedEntriesConfiguration()
+ .addExcludeEntryDescription(new ExcludeEntryDescription(excludedDir, true, false, getTestRootDisposable()));
+
+ setModulesOutput(myProjectRoot.createChildDirectory(this, "output"), "project", "m1", "m2");
+ }
+ }.execute().throwException();
+
+ compileModules("project");
+
+ assertCopied("output/a.txt");
+ assertCopied("output/b.txt");
+
+ assertNotCopied("output/JavaClass.java");
+ assertNotCopied("output/xxx.xxx");
+ assertNotCopied("output/c.txt");
+ }
+
private void assertCopied(String path) {
if (useJps()) {
assertTrue(new File(myProjectPom.getParent().getPath(), path).exists());
diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ResourceFilteringTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ResourceFilteringTest.java
index a9f00d9..4c2c781 100644
--- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ResourceFilteringTest.java
+++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ResourceFilteringTest.java
@@ -15,16 +15,12 @@
*/
package org.jetbrains.idea.maven.compiler;
-import com.intellij.openapi.application.Result;
-import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.fileTypes.FileTypeManager;
import com.intellij.openapi.fileTypes.FileTypes;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.idea.maven.MavenImportingTestCase;
-import org.jetbrains.idea.maven.importing.MavenDefaultModifiableModelsProvider;
-import org.jetbrains.idea.maven.importing.MavenRootModelAdapter;
import java.io.File;
import java.io.IOException;
@@ -306,50 +302,6 @@
assertResult("target/classes/file2.properties", "value=project");
}
- public void testWorkCorrectlyIfFoldersMarkedAsSource() throws Exception {
- createProjectSubFile("src/main/resources/file1.properties", "value=${project.artifactId}");
- createProjectSubFile("src/main/ideaRes/file2.properties", "value=${project.artifactId}");
-
- importProject("<groupId>test</groupId>" +
- "<artifactId>project</artifactId>" +
- "<version>1</version>" +
-
- "<build>" +
- " <resources>" +
- " <resource>" +
- " <directory>src/main/resources</directory>" +
- " <filtering>true</filtering>" +
- " </resource>" +
- " </resources>" +
- "</build>");
-
- new WriteAction() {
- protected void run(Result result) throws Throwable {
- MavenRootModelAdapter adapter = new MavenRootModelAdapter(myProjectsTree.findProject(myProjectPom),
- getModule("project"),
- new MavenDefaultModifiableModelsProvider(myProject));
- adapter.addSourceFolder(myProjectRoot.findFileByRelativePath("src/main/resources").getPath(), false);
- adapter.addSourceFolder(myProjectRoot.findFileByRelativePath("src/main/ideaRes").getPath(), false);
- adapter.getRootModel().commit();
- }
- }.execute();
-
- assertSources("project", "src/main/resources", "src/main/ideaRes");
-
- compileModules("project");
-
- assertResult("target/classes/file1.properties", "value=project");
- if (useJps()) {
- // in jps only maven resource builder works for mavenized modules, so the file should not be copied at all
- File file = new File(myProjectPom.getParent().getPath(), "target/classes/file2.properties");
- assertFalse("The file should not be copied " + file.getPath(), file.exists());
- }
- else {
- assertResult("target/classes/file2.properties", "value=${project.artifactId}");
- }
- }
-
-
public void testEscapingWindowsChars() throws Exception {
createProjectSubFile("resources/file.txt", "value=${foo}\n" +
"value2=@foo@\n" +
diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencyCompletionAndResolutionTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencyCompletionAndResolutionTest.java
index 23307e4..6185881 100644
--- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencyCompletionAndResolutionTest.java
+++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencyCompletionAndResolutionTest.java
@@ -24,11 +24,14 @@
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
import com.intellij.psi.formatter.xml.XmlCodeStyleSettings;
+import com.intellij.util.PathUtil;
import com.intellij.util.Producer;
+import org.jetbrains.idea.maven.MavenCustomRepositoryHelper;
import org.jetbrains.idea.maven.dom.intentions.ChooseFileIntentionAction;
import org.jetbrains.idea.maven.dom.model.MavenDomDependency;
import org.jetbrains.idea.maven.dom.model.MavenDomProjectModel;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -441,6 +444,93 @@
assertResolved(myProjectPom, findPsiFile(f));
}
+ public void testResolveSystemManagedDependency() throws Exception {
+ String someJarPath = PathUtil.getJarPathForClass(ArrayList.class).replace('\\', '/');
+
+ importProject("<groupId>test</groupId>" +
+ "<artifactId>project</artifactId>" +
+ "<version>1</version>" +
+
+ "<dependencyManagement>" +
+ " <dependencies>" +
+ " <dependency>" +
+ " <groupId>direct-system-dependency</groupId>" +
+ " <artifactId>direct-system-dependency</artifactId>" +
+ " <version>1.0</version>" +
+ " <scope>system</scope>" +
+ " <systemPath>" + someJarPath + "</systemPath>" +
+ " </dependency>" +
+ " </dependencies>" +
+ "</dependencyManagement>" +
+
+ "<dependencies>" +
+ " <dependency>" +
+ " <groupId>direct-system-dependency</groupId>" +
+ " <artifactId>direct-system-dependency</artifactId>" +
+ " </dependency>" +
+ "</dependencies>");
+
+ createProjectPom("<groupId>test</groupId>" +
+ "<artifactId>project</artifactId>" +
+ "<version>1</version>" +
+
+ "<dependencyManagement>" +
+ " <dependencies>" +
+ " <dependency>" +
+ " <groupId>direct-system-dependency</groupId>" +
+ " <artifactId>direct-system-dependency</artifactId>" +
+ " <version>1.0</version>" +
+ " <scope>system</scope>" +
+ " <systemPath>" + someJarPath + "</systemPath>" +
+ " </dependency>" +
+ " </dependencies>" +
+ "</dependencyManagement>" +
+
+ "<dependencies>" +
+ " <dependency>" +
+ " <groupId>direct-system-dependency</groupId>" +
+ " <artifactId>direct-system-dependency</artifactId>" +
+ " </dependency>" +
+ "</dependencies>");
+
+ checkHighlighting(myProjectPom, true, false, true);
+ }
+
+ public void testResolveLATESTDependency() throws Exception {
+ MavenCustomRepositoryHelper helper = new MavenCustomRepositoryHelper(myDir, "local1");
+ String repoPath = helper.getTestDataPath("local1");
+ setRepositoryPath(repoPath);
+
+ importProject("<groupId>test</groupId>" +
+ "<artifactId>project</artifactId>" +
+ "<version>1</version>" +
+
+ "<dependencies>" +
+ " <dependency>" +
+ " <groupId>junit</groupId>" +
+ " <artifactId>junit</artifactId>" +
+ " <version>[1,4.0]</version>" +
+ " </dependency>" +
+ "</dependencies>");
+
+ createProjectPom("<groupId>test</groupId>" +
+ "<artifactId>project</artifactId>" +
+ "<version>1</version>" +
+
+ "<dependencies>" +
+ " <dependency>" +
+ " <groupId>junit</groupId>" +
+ " <artifactId>junit<caret></artifactId>" +
+ " <version>[1,4.0]</version>" +
+ " </dependency>" +
+ "</dependencies>");
+
+ String filePath = myIndicesFixture.getRepositoryHelper().getTestDataPath("local1/junit/junit/4.0/junit-4.0.pom");
+ VirtualFile f = LocalFileSystem.getInstance().refreshAndFindFileByPath(filePath);
+
+ assertResolved(myProjectPom, findPsiFile(f));
+ }
+
public void testResolutionIsTypeBased() throws Exception {
createProjectPom("<groupId>test</groupId>" +
"<artifactId>project</artifactId>" +
diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPluginCompletionAndResolutionTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPluginCompletionAndResolutionTest.java
index abf3f3d..a7d10fe 100644
--- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPluginCompletionAndResolutionTest.java
+++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPluginCompletionAndResolutionTest.java
@@ -78,6 +78,24 @@
assertCompletionVariants(myProjectPom, "maven-compiler-plugin", "maven-war-plugin", "maven-surefire-plugin", "maven-eclipse-plugin");
}
+ public void testVersionCompletion() throws Exception {
+ createProjectPom("<groupId>test</groupId>" +
+ "<artifactId>project</artifactId>" +
+ "<version>1</version>" +
+
+ "<build>" +
+ " <plugins>" +
+ " <plugin>" +
+ " <groupId>org.apache.maven.plugins</groupId>" +
+ " <artifactId>maven-compiler-plugin</artifactId>" +
+ " <version><caret></version>" +
+ " </plugin>" +
+ " </plugins>" +
+ "</build>");
+
+ assertCompletionVariants(myProjectPom, "2.0.2");
+ }
+
@Bombed(year = 2013, month = Calendar.APRIL, day = 25, user = "sergey.evdokimov")
public void testArtifactWithoutGroupCompletion() throws Exception {
createProjectPom("<groupId>test</groupId>" +
@@ -100,6 +118,23 @@
"maven-eclipse-plugin");
}
+ public void testVersionWithoutGroupCompletion() throws Exception {
+ createProjectPom("<groupId>test</groupId>" +
+ "<artifactId>project</artifactId>" +
+ "<version>1</version>" +
+
+ "<build>" +
+ " <plugins>" +
+ " <plugin>" +
+ " <artifactId>maven-compiler-plugin</artifactId>" +
+ " <version><caret></version>" +
+ " </plugin>" +
+ " </plugins>" +
+ "</build>");
+
+ assertCompletionVariants(myProjectPom, "2.0.2");
+ }
+
public void testResolvingPlugins() throws Exception {
createProjectPom("<groupId>test</groupId>" +
"<artifactId>project</artifactId>" +
diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenRunConfigurationTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenRunConfigurationTest.java
index de2c2ad..e30c306 100644
--- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenRunConfigurationTest.java
+++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenRunConfigurationTest.java
@@ -16,6 +16,7 @@
package org.jetbrains.idea.maven.execution;
import com.google.common.collect.ImmutableMap;
+import com.intellij.openapi.options.ConfigurationException;
import com.intellij.testFramework.IdeaTestCase;
import com.intellij.util.xmlb.XmlSerializer;
import org.jdom.Element;
@@ -28,7 +29,13 @@
MavenRunConfiguration.MavenSettings s = new MavenRunConfiguration.MavenSettings(myProject);
s.myRunnerParameters.setWorkingDirPath("some path");
s.myRunnerParameters.setGoals(Arrays.asList("clean", "validate"));
- s.myRunnerParameters.setProfilesMap(ImmutableMap.of("prof1", true, "prof2", true, "prof3", false, "aaa", true));
+ s.myRunnerParameters.setProfilesMap(ImmutableMap.<String, Boolean>builder()
+ .put("prof1", true)
+ .put("prof2", true)
+ .put("prof3", false)
+ .put("aaa", true)
+ .put("tomcat (local)", false)
+ .put("tomcat (local) ", true).build());
s.myGeneralSettings = new MavenGeneralSettings();
s.myGeneralSettings.setChecksumPolicy(MavenExecutionOptions.ChecksumPolicy.WARN);
@@ -50,4 +57,30 @@
assertEquals(s.myGeneralSettings, loaded.myGeneralSettings);
assertEquals(s.myRunnerSettings, loaded.myRunnerSettings);
}
+
+ public void testMavenParametersEditing() throws ConfigurationException {
+ ImmutableMap<String, Boolean> profilesMap = ImmutableMap.<String, Boolean>builder()
+ .put("prof1", true)
+ .put("prof2", true)
+ .put("prof3", false)
+ .put("aaa", true)
+ .put("tomcat (local)", false)
+ .put("tomcat (local) ", true).build();
+
+ final MavenRunnerParameters params = new MavenRunnerParameters();
+ params.setProfilesMap(profilesMap);
+
+ MavenRunnerParametersConfigurable cfg = new MavenRunnerParametersConfigurable(getProject()) {
+ @Override
+ protected MavenRunnerParameters getParameters() {
+ return params;
+ }
+ };
+
+ cfg.reset();
+
+ cfg.apply();
+
+ assertEquals(profilesMap, cfg.getParameters().getProfilesMap());
+ }
}
diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/DependenciesImportingTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/DependenciesImportingTest.java
index b52069c..428f978 100644
--- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/DependenciesImportingTest.java
+++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/DependenciesImportingTest.java
@@ -19,7 +19,10 @@
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.module.Module;
-import com.intellij.openapi.roots.*;
+import com.intellij.openapi.roots.DependencyScope;
+import com.intellij.openapi.roots.JavadocOrderRootType;
+import com.intellij.openapi.roots.ModuleRootModificationUtil;
+import com.intellij.openapi.roots.OrderRootType;
import com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable;
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.roots.libraries.LibraryTable;
@@ -32,7 +35,6 @@
import org.jetbrains.idea.maven.project.MavenProject;
import java.io.File;
-import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -1599,19 +1601,25 @@
addLibraryRoot("Maven: junit:junit:4.0", OrderRootType.CLASSES, "file://foo.classes");
addLibraryRoot("Maven: junit:junit:4.0", OrderRootType.SOURCES, "file://foo.sources");
addLibraryRoot("Maven: junit:junit:4.0", JavadocOrderRootType.getInstance(), "file://foo.javadoc");
+ addLibraryRoot("Maven: junit:junit:4.0", OrderRootType.SOURCES, "jar://" + getRepositoryPath() + "/junit/junit/4.0/junit-4.0-sources.jar!/aaa");
+ addLibraryRoot("Maven: junit:junit:4.0", JavadocOrderRootType.getInstance(), "jar://" + getRepositoryPath() + "/junit/junit/4.0/junit-4.0-javadoc.jar!/bbb");
assertModuleLibDep("project", "Maven: junit:junit:4.0",
Arrays.asList("jar://" + getRepositoryPath() + "/junit/junit/4.0/junit-4.0.jar!/", "file://foo.classes"),
- Arrays.asList("jar://" + getRepositoryPath() + "/junit/junit/4.0/junit-4.0-sources.jar!/", "file://foo.sources"),
- Arrays.asList("jar://" + getRepositoryPath() + "/junit/junit/4.0/junit-4.0-javadoc.jar!/", "file://foo.javadoc"));
+ Arrays.asList("jar://" + getRepositoryPath() + "/junit/junit/4.0/junit-4.0-sources.jar!/",
+ "file://foo.sources",
+ "jar://" + getRepositoryPath() + "/junit/junit/4.0/junit-4.0-sources.jar!/aaa"),
+ Arrays.asList("jar://" + getRepositoryPath() + "/junit/junit/4.0/junit-4.0-javadoc.jar!/",
+ "file://foo.javadoc",
+ "jar://" + getRepositoryPath() + "/junit/junit/4.0/junit-4.0-javadoc.jar!/bbb"));
scheduleResolveAll();
resolveDependenciesAndImport();
assertModuleLibDep("project", "Maven: junit:junit:4.0",
Arrays.asList("jar://" + getRepositoryPath() + "/junit/junit/4.0/junit-4.0.jar!/", "file://foo.classes"),
- Arrays.asList("jar://" + getRepositoryPath() + "/junit/junit/4.0/junit-4.0-sources.jar!/", "file://foo.sources"),
- Arrays.asList("jar://" + getRepositoryPath() + "/junit/junit/4.0/junit-4.0-javadoc.jar!/", "file://foo.javadoc"));
+ Arrays.asList("jar://" + getRepositoryPath() + "/junit/junit/4.0/junit-4.0-sources.jar!/", "file://foo.sources", "jar://" + getRepositoryPath() + "/junit/junit/4.0/junit-4.0-sources.jar!/aaa"),
+ Arrays.asList("jar://" + getRepositoryPath() + "/junit/junit/4.0/junit-4.0-javadoc.jar!/", "file://foo.javadoc", "jar://" + getRepositoryPath() + "/junit/junit/4.0/junit-4.0-javadoc.jar!/bbb"));
}
public void testDifferentSystemDependenciesWithSameId() throws Exception {
diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/MavenXmlCrcTest.groovy b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/MavenXmlCrcTest.groovy
new file mode 100644
index 0000000..9cd0083
--- /dev/null
+++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/MavenXmlCrcTest.groovy
@@ -0,0 +1,188 @@
+package org.jetbrains.idea.maven.importing
+
+import junit.framework.TestCase
+import org.intellij.lang.annotations.Language
+import org.jetbrains.idea.maven.utils.MavenUtil
+
+/**
+ * @author Sergey Evdokimov
+ */
+class MavenXmlCrcTest extends TestCase {
+
+ public void testCrc() {
+ same("""
+<project a="a" b="b">
+</project>
+""", """
+<project a="a"
+ b="b" >
+</project>
+""");
+
+ same("""
+<project>
+ <build><a>value</a></build>
+</project>
+""", """
+<project>
+ <build>
+ <a>value</a>
+ </build>
+</project>
+""")
+
+ same("""
+<project></project>
+""", """
+<project>
+ <!-- comment -->
+</project>
+"""
+ );
+
+ different("""
+<project>
+ <a>foo</a>
+</project>
+""", """
+<project>
+ <a>foo</a> text
+</project>
+""")
+
+ different("""
+<project>
+ <a>foo</a>
+</project>
+""", """
+<project>
+ <b>foo</b>
+</project>
+""")
+
+ same("""
+<project>
+ <a>foo</a>
+</project>
+""", """
+<project>
+ <a><!-- comment -->foo<!-- comment --></a>
+</project>
+""")
+
+ same("""
+<project>
+ <a>foo</a>
+</project>
+""", """
+<project>
+ <a>
+ <!-- comment -->foo<!-- comment -->
+ </a>
+</project>
+""")
+
+ same("""
+<project>
+ <a>foo</a>
+</project>
+""", """
+<project>
+ <a>fo<!-- comment -->o</a>
+</project>
+""")
+
+ same("""
+<project>
+ ab <a/>cd
+</project>
+""", """
+<project>
+ ab <a/> <!-- c --> cd
+</project>
+""")
+
+ different("""
+<project>
+ <a>foo bar</a>
+</project>
+""", """
+<project>
+ <a>foo bar</a>
+</project>
+""")
+
+ different("""
+<project>
+ <a>foo bar</a>
+</project>
+""", """
+<project>
+ <a>foo\tbar</a>
+</project>
+""")
+
+ different("""
+<project>
+ <a>111</a>
+</project>
+""", """
+<project>
+ <a>222</a>
+</project>
+""")
+
+ different("""
+<project>
+</project>
+""", """
+< project>
+</project>
+""")
+
+ // All invalid xmls are same
+ same("""
+""", """
+<project>
+ <sss>
+</project>
+""")
+ }
+
+ public void testInvalidXml() {
+ assert crc("""
+< project>
+</project>
+""") == -1
+
+ assert crc("""
+<project>
+""") == -1
+
+ assert crc("""
+<project>
+ <sss>
+</project>
+""") == -1
+ }
+
+ private static int crc(String text) {
+ return MavenUtil.crcWithoutSpaces(new ByteArrayInputStream(text.bytes))
+ }
+
+ private static void same(@Language("XML") String xml1, @Language("XML") String xml2) {
+ int crc1 = crc(xml1);
+ int crc2 = crc(xml2);
+
+ assert crc1 == crc2;
+ }
+
+ private static void different(@Language("XML") String xml1, @Language("XML") String xml2) {
+ int crc1 = crc(xml1);
+ int crc2 = crc(xml2);
+
+ assert crc1 != crc2;
+ }
+
+
+}
diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/plugins/groovy/MavenGroovyInjectionTest.groovy b/plugins/maven/src/test/java/org/jetbrains/idea/maven/plugins/groovy/MavenGroovyInjectionTest.groovy
index acc7e4b..4f0502d 100644
--- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/plugins/groovy/MavenGroovyInjectionTest.groovy
+++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/plugins/groovy/MavenGroovyInjectionTest.groovy
@@ -16,6 +16,7 @@
package org.jetbrains.idea.maven.plugins.groovy
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable
/**
* @author Sergey Evdokimov
@@ -115,4 +116,43 @@
assert lookups.containsAll(["String", "StringBuffer", "StringBuilder"])
}
+ public void testInjectionVariables() {
+ myFixture.configureByText("pom.xml", """
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>simpleMaven</groupId>
+ <artifactId>simpleMaven</artifactId>
+ <version>1.0</version>
+
+ <packaging>jar</packaging>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.gmaven</groupId>
+ <artifactId>gmaven-plugin</artifactId>
+ <version>1.3</version>
+ <configuration>
+ <!-- http://groovy.codehaus.org/The+groovydoc+Ant+task -->
+ <source>
+ println project<caret>
+ </source>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
+""")
+
+ def element = myFixture.getElementAtCaret()
+
+ assert element instanceof GrVariable
+ assert element.getDeclaredType().getPresentableText() == "MavenProject"
+ }
+
}
diff --git a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java
index 04b4c00..9b8d41c 100644
--- a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java
+++ b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java
@@ -442,7 +442,7 @@
public void run() {
if (!isValid()) return;
// there is pending update which is going to change prop file anyway
- if (myUpdatePsiAlarm.getActiveRequestCount() != 0) {
+ if (!myUpdatePsiAlarm.isEmpty()) {
myUpdateEditorAlarm.cancelAllRequests();
myUpdateEditorAlarm.addRequest(this, 200);
return;
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/CheckJavaHL.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/CheckJavaHL.java
index 3c4f16f..7729902 100644
--- a/plugins/svn4idea/src/org/jetbrains/idea/svn/CheckJavaHL.java
+++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/CheckJavaHL.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -16,7 +16,6 @@
package org.jetbrains.idea.svn;
import com.intellij.notification.Notification;
-import com.intellij.notification.NotificationDisplayType;
import com.intellij.notification.NotificationType;
import com.intellij.notification.Notifications;
import com.intellij.openapi.project.Project;
@@ -89,7 +88,7 @@
if (! ourIsPresent) {
Notifications.Bus.notify(new Notification(SvnVcs.getInstance(project).getDisplayName(), "Subversion: JavaHL problem",
ourProblemDescription + " Acceleration is not available.",
- NotificationType.ERROR), NotificationDisplayType.STICKY_BALLOON, project);
+ NotificationType.ERROR), project);
}
}
}
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnBundle.properties b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnBundle.properties
index 45fe521..d3c0fc1 100644
--- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnBundle.properties
+++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnBundle.properties
@@ -83,7 +83,7 @@
# GNOME keyring dialog
gnome.keyring.prompt.nameless=Please provide GNOME Keyring password
-gnome.keyring.prompt.named=Please provide '{0}' GNOME Keyring password
+gnome.keyring.prompt.named=Please provide ''{0}'' GNOME Keyring password
#Repository Browser
dialog.title.browser.copy.or.move=Copy or Move
@@ -212,14 +212,7 @@
radio.configure.create.auto.17format=1.&7 format
label.configure.change.label=Change working copy ''{0}'' format to:
-radio.configure.change.none=1.&3 format
-radio.configure.change.auto=1.&4 format
-radio.configure.change.auto.15format=1.&5 format
-radio.configure.change.auto.16format=1.&6 format
-radio.configure.change.auto.17format=1.&7 format
-label.where.svn.format.settings.text=To change above setting later, visit '{0} | Version Control'
-label.where.svn.format.can.be.changed.text=''Version Control | Subversion | {0}''
dialog.upgrade.wcopy.format.title=Subversion Working Copy Format
label.working.copy.root.outside.text=Working copy root is outside the directory specified in Project Settings.\nThe whole working copy will be converted.
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangeProvider.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangeProvider.java
index 3d83736..dc8cbb1 100644
--- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangeProvider.java
+++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangeProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -237,7 +237,7 @@
continue;
}
final String childURL = childUrl.toDecodedString();
- if (StringUtil.startsWithConcatenationOf(childURL, copyFromURL, "/")) {
+ if (StringUtil.startsWithConcatenation(childURL, copyFromURL, "/")) {
String relativePath = childURL.substring(copyFromURL.length());
File newPath = new File(copiedFile.getFilePath().getIOFile(), relativePath);
FilePath newFilePath = myFactory.createFilePathOn(newPath);
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java
index 4120dad..748fc86 100644
--- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java
+++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java
@@ -461,14 +461,14 @@
if (SystemInfo.isWindows) {
if (!SVNJNAUtil.isJNAPresent()) {
Notifications.Bus.notify(new Notification(getDisplayName(), "Subversion plugin: no JNA",
- "A problem with JNA initialization for svnkit library. Encryption is not available.",
- NotificationType.WARNING),
- NotificationDisplayType.BALLOON, myProject);
+ "A problem with JNA initialization for SVNKit library. Encryption is not available.",
+ NotificationType.WARNING), myProject);
}
else if (!SVNJNAUtil.isWinCryptEnabled()) {
Notifications.Bus.notify(new Notification(getDisplayName(), "Subversion plugin: no encryption",
- "A problem with encryption module (Crypt32.dll) initialization for svnkit library. Encryption is not available.",
- NotificationType.WARNING), NotificationDisplayType.BALLOON, myProject);
+ "A problem with encryption module (Crypt32.dll) initialization for SVNKit library. " +
+ "Encryption is not available.",
+ NotificationType.WARNING), myProject);
}
}
diff --git a/plugins/terminal/lib/jediterm-pty-0.04.jar b/plugins/terminal/lib/jediterm-pty-0.04.jar
deleted file mode 100644
index 59ec12c..0000000
--- a/plugins/terminal/lib/jediterm-pty-0.04.jar
+++ /dev/null
Binary files differ
diff --git a/plugins/terminal/lib/jediterm-pty-0.05.jar b/plugins/terminal/lib/jediterm-pty-0.05.jar
new file mode 100644
index 0000000..7767509
--- /dev/null
+++ b/plugins/terminal/lib/jediterm-pty-0.05.jar
Binary files differ
diff --git a/plugins/terminal/src/org/jetbrains/plugins/terminal/AbstractTerminalRunner.java b/plugins/terminal/src/org/jetbrains/plugins/terminal/AbstractTerminalRunner.java
index cc1d6c8..d5ff763 100644
--- a/plugins/terminal/src/org/jetbrains/plugins/terminal/AbstractTerminalRunner.java
+++ b/plugins/terminal/src/org/jetbrains/plugins/terminal/AbstractTerminalRunner.java
@@ -18,7 +18,7 @@
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowManager;
import com.intellij.util.ui.UIUtil;
-import com.jediterm.emulator.TtyConnector;
+import com.jediterm.terminal.TtyConnector;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -44,9 +44,16 @@
try {
doRun();
}
- catch (Exception e) {
+ catch (final Exception e) {
LOG.warn("Error running terminal", e);
- Messages.showErrorDialog(AbstractTerminalRunner.this.getProject(), getTitle(), e.getMessage());
+
+ UIUtil.invokeLaterIfNeeded(new Runnable() {
+
+ @Override
+ public void run() {
+ Messages.showErrorDialog(AbstractTerminalRunner.this.getProject(), e.getMessage(), getTitle());
+ }
+ });
}
}
});
diff --git a/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminal.java b/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminal.java
index f605ffb..8a633ed 100644
--- a/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminal.java
+++ b/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminal.java
@@ -8,11 +8,10 @@
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.ui.components.JBScrollBar;
import com.intellij.util.containers.HashMap;
-import com.jediterm.emulator.display.BackBuffer;
-import com.jediterm.emulator.display.LinesBuffer;
-import com.jediterm.emulator.display.StyleState;
-import com.jediterm.emulator.ui.SwingJediTerminal;
-import com.jediterm.emulator.ui.SwingTerminalPanel;
+import com.jediterm.terminal.display.BackBuffer;
+import com.jediterm.terminal.display.StyleState;
+import com.jediterm.terminal.ui.SwingJediTerminal;
+import com.jediterm.terminal.ui.SwingTerminalPanel;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -27,8 +26,8 @@
}
@Override
- protected SwingTerminalPanel createTerminalPanel(StyleState styleState, BackBuffer backBuffer, LinesBuffer scrollBuffer) {
- return new JBTerminalPanel(backBuffer, scrollBuffer, styleState, getColorScheme());
+ protected SwingTerminalPanel createTerminalPanel(StyleState styleState, BackBuffer backBuffer) {
+ return new JBTerminalPanel(backBuffer, styleState, getColorScheme());
}
public EditorColorsScheme getColorScheme() {
diff --git a/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalPanel.java b/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalPanel.java
index ebb5dee..7693623 100644
--- a/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalPanel.java
+++ b/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalPanel.java
@@ -25,11 +25,10 @@
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.ide.CopyPasteManager;
import com.intellij.util.ui.GraphicsUtil;
-import com.jediterm.emulator.TextStyle;
-import com.jediterm.emulator.display.BackBuffer;
-import com.jediterm.emulator.display.LinesBuffer;
-import com.jediterm.emulator.display.StyleState;
-import com.jediterm.emulator.ui.SwingTerminalPanel;
+import com.jediterm.terminal.TextStyle;
+import com.jediterm.terminal.display.BackBuffer;
+import com.jediterm.terminal.display.StyleState;
+import com.jediterm.terminal.ui.SwingTerminalPanel;
import java.awt.*;
import java.awt.datatransfer.DataFlavor;
@@ -41,8 +40,8 @@
public class JBTerminalPanel extends SwingTerminalPanel {
private final EditorColorsScheme myColorScheme;
- public JBTerminalPanel(BackBuffer backBuffer, LinesBuffer scrollBuffer, StyleState styleState, EditorColorsScheme scheme) {
- super(backBuffer, scrollBuffer, styleState);
+ public JBTerminalPanel(BackBuffer backBuffer, StyleState styleState, EditorColorsScheme scheme) {
+ super(backBuffer, styleState);
myColorScheme = scheme;
styleState.setDefaultStyle(new TextStyle(myColorScheme.getDefaultForeground(), myColorScheme.getDefaultBackground()));
diff --git a/plugins/terminal/src/org/jetbrains/plugins/terminal/LocalTerminalDirectRunner.java b/plugins/terminal/src/org/jetbrains/plugins/terminal/LocalTerminalDirectRunner.java
index f633024..7a4626b 100644
--- a/plugins/terminal/src/org/jetbrains/plugins/terminal/LocalTerminalDirectRunner.java
+++ b/plugins/terminal/src/org/jetbrains/plugins/terminal/LocalTerminalDirectRunner.java
@@ -7,9 +7,9 @@
import com.intellij.openapi.project.Project;
import com.intellij.util.Consumer;
import com.intellij.util.containers.HashMap;
-import com.jediterm.emulator.TtyConnector;
import com.jediterm.pty.PtyProcess;
import com.jediterm.pty.PtyProcessTtyConnector;
+import com.jediterm.terminal.TtyConnector;
import org.jetbrains.annotations.Nullable;
import java.io.OutputStream;
@@ -24,19 +24,19 @@
public class LocalTerminalDirectRunner extends AbstractTerminalRunner<PtyProcess> {
private final Charset myDefaultCharset;
- private final String myCommand;
+ private final String[] myCommand;
- public LocalTerminalDirectRunner(Project project, Charset charset, String command) {
+ public LocalTerminalDirectRunner(Project project, String[] command) {
super(project);
- myDefaultCharset = charset;
+ myDefaultCharset = Charset.forName("UTF-8");
myCommand = command;
}
@Override
protected PtyProcess createProcess() throws ExecutionException {
Map<String, String> envs = new HashMap<String, String>(System.getenv());
- envs.put("TERM", "vt100");
- return new PtyProcess(myCommand, new String[]{myCommand}, envs);
+ envs.put("TERM", "xterm");
+ return new PtyProcess(myCommand[0], myCommand, envs);
}
@Override
diff --git a/plugins/terminal/src/org/jetbrains/plugins/terminal/OpenLocalTerminalAction.java b/plugins/terminal/src/org/jetbrains/plugins/terminal/OpenLocalTerminalAction.java
index ac03550..a4aa3af 100644
--- a/plugins/terminal/src/org/jetbrains/plugins/terminal/OpenLocalTerminalAction.java
+++ b/plugins/terminal/src/org/jetbrains/plugins/terminal/OpenLocalTerminalAction.java
@@ -8,8 +8,6 @@
import com.intellij.openapi.util.SystemInfo;
import icons.TerminalIcons;
-import java.nio.charset.Charset;
-
/**
* @author traff
*/
@@ -31,12 +29,12 @@
public void runLocalTerminal(AnActionEvent event) {
final Project project = event.getData(PlatformDataKeys.PROJECT);
- setupRemoteCredentialsAndRunTerminal(project);
+ runLocalTerminal(project);
}
- public static void setupRemoteCredentialsAndRunTerminal(final Project project) {
- String terminalCommand = SystemInfo.isMac ? "/bin/tcsh" : "/bin/bash";
+ public static void runLocalTerminal(final Project project) {
+ String[] terminalCommand = SystemInfo.isMac ? new String[]{"/bin/bash", "--login"} : new String[]{"/bin/bash"};
- new LocalTerminalDirectRunner(project, Charset.defaultCharset(), terminalCommand).run();
+ new LocalTerminalDirectRunner(project, terminalCommand).run();
}
}
diff --git a/plugins/terminal/terminal.iml b/plugins/terminal/terminal.iml
index d3d1e76..41e2aa0 100644
--- a/plugins/terminal/terminal.iml
+++ b/plugins/terminal/terminal.iml
@@ -42,7 +42,7 @@
<orderEntry type="module-library">
<library name="jediterm-pty">
<CLASSES>
- <root url="jar://$MODULE_DIR$/lib/jediterm-pty-0.04.jar!/" />
+ <root url="jar://$MODULE_DIR$/lib/jediterm-pty-0.05.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
diff --git a/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGRunnableState.java b/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGRunnableState.java
index d64507e..d33ccaa 100644
--- a/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGRunnableState.java
+++ b/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGRunnableState.java
@@ -161,25 +161,8 @@
final TestConsoleProperties consoleProperties = console.getProperties();
if (consoleProperties == null) return;
- final String testRunDebugId = consoleProperties.isDebug() ? ToolWindowId.DEBUG : ToolWindowId.RUN;
final TestNGResults resultsView = console.getResultsView();
- final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
- if (!Comparing.strEqual(toolWindowManager.getActiveToolWindowId(), testRunDebugId)) {
- final MessageType type = resultsView == null || resultsView.getStatus() == MessageHelper.SKIPPED_TEST
- ? MessageType.WARNING
- : (resultsView.getStatus() == MessageHelper.FAILED_TEST
- ? MessageType.ERROR
- : MessageType.INFO);
- final String message;
- if (resultsView == null) {
- message = myStarted ? "Tests were interrupted" : "Tests were not started";
- }
- else {
- message = resultsView.getStatusLine();
- }
- toolWindowManager.notifyByBalloon(testRunDebugId, type, message, null, null);
- TestsUIUtil.NOTIFICATION_GROUP.createNotification(message, type).notify(project);
- }
+ TestsUIUtil.notifyByBalloon(project, myStarted, console.getResultsView().getRoot(), consoleProperties, "in " + resultsView.getTime());
}
};
SwingUtilities.invokeLater(notificationRunnable);
diff --git a/plugins/testng/src/com/theoryinpractice/testng/ui/TestNGResults.java b/plugins/testng/src/com/theoryinpractice/testng/ui/TestNGResults.java
index 617d403..509eeec 100644
--- a/plugins/testng/src/com/theoryinpractice/testng/ui/TestNGResults.java
+++ b/plugins/testng/src/com/theoryinpractice/testng/ui/TestNGResults.java
@@ -209,6 +209,11 @@
}
return sb.toString();
}
+
+ public String getTime() {
+ final long time = end - start;
+ return time == 0 ? "0.0 s" : NumberFormat.getInstance().format((double)time / 1000.0) + " s";
+ }
public TestProxy testStarted(TestResultMessage result) {
return testStarted(result, true);
@@ -322,6 +327,7 @@
}
myStatusLine.setFraction((double)count / total);
updateStatusLine();
+ TestsUIUtil.showIconProgress(project, count, total, failed.size());
}
private TestProxy getPackageClassNodeFor(final TestResultMessage result) {
@@ -451,6 +457,7 @@
public void dispose() {
super.dispose();
tree.getSelectionModel().removeTreeSelectionListener(openSourceListener);
+ TestsUIUtil.clearIconProgress(project);
}
public TestProxy getFailedToStart() {
diff --git a/plugins/ui-designer-core/src/com/intellij/designer/clipboard/SimpleTransferable.java b/plugins/ui-designer-core/src/com/intellij/designer/clipboard/SimpleTransferable.java
index 72e0c00..378e338 100644
--- a/plugins/ui-designer-core/src/com/intellij/designer/clipboard/SimpleTransferable.java
+++ b/plugins/ui-designer-core/src/com/intellij/designer/clipboard/SimpleTransferable.java
@@ -21,7 +21,6 @@
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
-import java.awt.dnd.InvalidDnDOperationException;
import java.io.IOException;
/**
@@ -80,16 +79,9 @@
try {
for (DataFlavor dataFlavor : transferable.getTransferDataFlavors()) {
if (transferable.isDataFlavorSupported(dataFlavor)) {
- try {
- Object transferData = transferable.getTransferData(dataFlavor);
- if (transferData != null && dataClass.isInstance(transferData)) {
- return (T)transferData;
- }
- } catch (InvalidDnDOperationException e) {
- // Ignore; even though transferable reported that it supports this flavor,
- // some transferables will throw a "no protocol: unsupported type" exception
- // here, for example if you try to drag an OSX text file into the layout
- // editor
+ Object transferData = transferable.getTransferData(dataFlavor);
+ if (dataClass.isInstance(transferData)) {
+ return (T)transferData;
}
}
}
diff --git a/plugins/ui-designer-core/src/com/intellij/designer/designSurface/DesignerEditorPanel.java b/plugins/ui-designer-core/src/com/intellij/designer/designSurface/DesignerEditorPanel.java
index 36b5f82..16e0a71 100644
--- a/plugins/ui-designer-core/src/com/intellij/designer/designSurface/DesignerEditorPanel.java
+++ b/plugins/ui-designer-core/src/com/intellij/designer/designSurface/DesignerEditorPanel.java
@@ -1329,4 +1329,4 @@
return super.get(key);
}
}
-}
+}
\ No newline at end of file
diff --git a/plugins/ui-designer-core/src/com/intellij/designer/propertyTable/renderers/AbstractResourceRenderer.java b/plugins/ui-designer-core/src/com/intellij/designer/propertyTable/renderers/AbstractResourceRenderer.java
index 68a9cd8..f630380 100644
--- a/plugins/ui-designer-core/src/com/intellij/designer/propertyTable/renderers/AbstractResourceRenderer.java
+++ b/plugins/ui-designer-core/src/com/intellij/designer/propertyTable/renderers/AbstractResourceRenderer.java
@@ -21,7 +21,6 @@
import com.intellij.designer.propertyTable.PropertyRenderer;
import com.intellij.designer.propertyTable.PropertyTable;
import com.intellij.ui.SimpleColoredComponent;
-import com.intellij.util.ui.EmptyIcon;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -62,52 +61,4 @@
public void updateUI() {
SwingUtilities.updateComponentTreeUI(myColoredComponent);
}
-
- protected final static class ColorIcon extends EmptyIcon {
- private final int myColorSize;
- private Color myColor;
- private boolean myShowRedLine;
-
- private ColorIcon(int size, int colorSize) {
- super(size, size);
- myColorSize = colorSize;
- }
-
- public void setColor(Color color) {
- myColor = color;
- }
-
- public void showRedLine(boolean value) {
- myShowRedLine = value;
- }
-
- @Override
- public void paintIcon(Component component, Graphics g, final int left, final int top) {
- int iconWidth = getIconWidth();
- int iconHeight = getIconHeight();
-
- SimpleColoredComponent coloredComponent = (SimpleColoredComponent)component;
- g.setColor(component.getBackground());
- g.fillRect(left - coloredComponent.getIpad().left, 0,
- iconWidth + coloredComponent.getIpad().left + coloredComponent.getIconTextGap(), component.getHeight());
-
- int x = left + (iconWidth - myColorSize) / 2;
- int y = top + (iconHeight - myColorSize) / 2;
-
- g.setColor(myColor);
- g.fillRect(x, y, myColorSize, myColorSize);
-
- if (myShowRedLine) {
- Graphics2D g2d = (Graphics2D)g;
- Object hint = g2d.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- g.setColor(Color.red);
- g.drawLine(x, y + myColorSize, x + myColorSize, y);
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, hint);
- }
-
- g.setColor(Color.BLACK);
- g.drawRect(x, y, myColorSize, myColorSize);
- }
- }
}
\ No newline at end of file
diff --git a/plugins/ui-designer-core/src/com/intellij/designer/propertyTable/renderers/ColorIcon.java b/plugins/ui-designer-core/src/com/intellij/designer/propertyTable/renderers/ColorIcon.java
new file mode 100644
index 0000000..8e64e9c
--- /dev/null
+++ b/plugins/ui-designer-core/src/com/intellij/designer/propertyTable/renderers/ColorIcon.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2000-2013 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.designer.propertyTable.renderers;
+
+import com.intellij.ui.SimpleColoredComponent;
+import com.intellij.util.ui.EmptyIcon;
+
+import java.awt.*;
+
+/**
+ * @author Alexander Lobas
+ */
+public final class ColorIcon extends EmptyIcon {
+ private final int myColorSize;
+ private Color myColor;
+ private boolean myShowRedLine;
+
+ public ColorIcon(int size, int colorSize) {
+ super(size, size);
+ myColorSize = colorSize;
+ }
+
+ public Color getColor() {
+ return myShowRedLine ? null : myColor;
+ }
+
+ public void setColor(Color color) {
+ myColor = color;
+ }
+
+ public void showRedLine(boolean value) {
+ myShowRedLine = value;
+ }
+
+ @Override
+ public void paintIcon(Component component, Graphics g, final int left, final int top) {
+ int iconWidth = getIconWidth();
+ int iconHeight = getIconHeight();
+
+ if (component instanceof SimpleColoredComponent) {
+ SimpleColoredComponent coloredComponent = (SimpleColoredComponent)component;
+ g.setColor(component.getBackground());
+ g.fillRect(left - coloredComponent.getIpad().left, 0,
+ iconWidth + coloredComponent.getIpad().left + coloredComponent.getIconTextGap(), component.getHeight());
+ }
+
+ int x = left + (iconWidth - myColorSize) / 2;
+ int y = top + (iconHeight - myColorSize) / 2;
+
+ g.setColor(myColor);
+ g.fillRect(x, y, myColorSize, myColorSize);
+
+ if (myShowRedLine) {
+ Graphics2D g2d = (Graphics2D)g;
+ Object hint = g2d.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ g.setColor(Color.red);
+ g.drawLine(x, y + myColorSize, x + myColorSize, y);
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, hint);
+ }
+
+ g.setColor(Color.BLACK);
+ g.drawRect(x, y, myColorSize, myColorSize);
+ }
+}
\ No newline at end of file
diff --git a/plugins/ui-designer-core/testSources/com/intellij/designer/model/RadComponentTest.java b/plugins/ui-designer-core/testSources/com/intellij/designer/model/RadComponentTest.java
deleted file mode 100644
index db4c5bc..0000000
--- a/plugins/ui-designer-core/testSources/com/intellij/designer/model/RadComponentTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright 2000-2013 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.designer.model;
-
-import junit.framework.TestCase;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-public class RadComponentTest extends TestCase {
- public void testGroupSiblings() {
- Map<RadComponent,List<RadComponent>> map;
-
- // Test empty
- assertNotNull(RadComponent.groupSiblings(Collections.<TestComponent>emptyList()));
-
- // Test single
- TestComponent single = new TestComponent("single");
- map = RadComponent.groupSiblings(Collections.<TestComponent>singletonList(single));
- assertNotNull(map);
- assertEquals(1, map.size());
- assertSame(single, map.get(null).iterator().next());
- assertSame(null, map.keySet().iterator().next());
- assertSame(single, map.values().iterator().next().iterator().next());
-
- // Test multiple
- TestComponent parent1 = new TestComponent("single");
- TestComponent parent2 = new TestComponent("parent2");
- TestComponent child1 = new TestComponent("child1");
- TestComponent child2 = new TestComponent("child2");
- child1.setParent(parent1);
- child2.setParent(parent1);
- TestComponent child3 = new TestComponent("child3");
- TestComponent child4 = new TestComponent("child4");
- TestComponent child5 = new TestComponent("child5");
- child3.setParent(parent2);
- child4.setParent(parent2);
- child5.setParent(parent2);
- TestComponent grandChild1 = new TestComponent("grandChild1");
- grandChild1.setParent(child1);
- TestComponent child6 = new TestComponent("child6");
-
- // Should partition into:
- // null: child6
- // parent1: child1, child2
- // parent2: child3, child4, child5
- // child1: grandChild1
- map = RadComponent.groupSiblings(Arrays.asList(child1, child2, child3, child4, child5, child6, grandChild1));
- assertNotNull(map);
- assertEquals(4, map.size());
- assertEquals(Arrays.<RadComponent>asList(child6), map.get(null));
- assertEquals(Arrays.<RadComponent>asList(child1, child2), map.get(parent1));
- assertEquals(Arrays.<RadComponent>asList(child3, child4, child5), map.get(parent2));
- assertEquals(Arrays.<RadComponent>asList(grandChild1), map.get(child1));
- }
-
- private static class TestComponent extends RadVisualComponent { // Because RadVisualComponent is abstract
- private final String myName;
- private TestComponent(String name) {
- myName = name;
- }
-
- @Override
- public String toString() {
- return myName;
- }
- }
-}
diff --git a/plugins/ui-designer-core/testSources/com/intellij/designer/model/RadVisualComponentTest.java b/plugins/ui-designer-core/testSources/com/intellij/designer/model/RadVisualComponentTest.java
deleted file mode 100644
index fbd0ce2..0000000
--- a/plugins/ui-designer-core/testSources/com/intellij/designer/model/RadVisualComponentTest.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * 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.designer.model;
-
-import com.intellij.designer.designSurface.ScalableComponent;
-import junit.framework.TestCase;
-
-import javax.swing.*;
-import java.awt.*;
-import java.util.Collections;
-
-public class RadVisualComponentTest extends TestCase {
- public void testGetBounds() {
- TestComponent testComponent = new TestComponent();
- assertNull(testComponent.getParent());
- assertEquals(Collections.<RadComponent>emptyList(), testComponent.getChildren());
-
- testComponent.setBounds(1, 2, 3, 4);
- assertEquals(new Rectangle(1,2, 3,4), testComponent.getBounds());
-
- MyRoot nativeComponent = new MyRoot(3.0);
- testComponent.setNativeComponent(nativeComponent);
- assertEquals(new Rectangle(1, 2, 3, 4), testComponent.getBounds());
- }
-
- public void testGetBoundsConversion() {
- TestComponent testComponent = new TestComponent();
-
- MyRoot nativeComponent = new MyRoot(2.0);
- JPanel panel = new JPanel();
- panel.add(nativeComponent);
- nativeComponent.setLocation(15, 20);
- JPanel other = new JPanel();
- panel.add(other);
- other.setLocation(5, 5);
-
- testComponent.setNativeComponent(nativeComponent);
- testComponent.setBounds(100, 110, 300, 400);
-
- // No conversion for model coordinates
- assertEquals(new Rectangle(100, 110, 300, 400), testComponent.getBounds());
- // No conversion when querying for the model view itself
- assertEquals(new Rectangle(100, 110, 300, 400), testComponent.getBounds(nativeComponent));
- // When converting to the parent, should scale by above scale factor (2), then shift by view location relative to panel (15,20)
- assertEquals(new Rectangle(100 * 2 + 15, 110 * 2 + 20, 300 * 2, 400 * 2), testComponent.getBounds(panel));
- // When converting to another child, first shift to parent, then down to other child (5,5)
- assertEquals(new Rectangle(100 * 2 + 15 - 5, 110 * 2 + 20 - 5, 300 * 2, 400 * 2), testComponent.getBounds(other));
- }
-
- public void testModelRectangleConversion() {
- TestComponent testComponent = new TestComponent();
-
- MyRoot nativeComponent = new MyRoot(2.0);
- JPanel panel = new JPanel();
- panel.add(nativeComponent);
- nativeComponent.setLocation(15, 20);
- JPanel other = new JPanel();
- panel.add(other);
- other.setLocation(5, 5);
-
- testComponent.setNativeComponent(nativeComponent);
-
- // No conversion when querying for the model view itself
- assertEquals(new Rectangle(100, 110, 300, 400), testComponent.fromModel(nativeComponent, new Rectangle(100, 110, 300, 400)));
-
- // When converting to the parent, should scale by above scale factor (2), then shift by view location relative to panel (15,20)
- assertEquals(new Rectangle(100 * 2 + 15, 110 * 2 + 20, 300 * 2, 400 * 2),
- testComponent.fromModel(panel, new Rectangle(100, 110, 300, 400)));
- // When converting to another child, first shift to parent, then down to other child (5,5)
- assertEquals(new Rectangle(100 * 2 + 15 - 5, 110 * 2 + 20 - 5, 300 * 2, 400 * 2),
- testComponent.fromModel(other, new Rectangle(100, 110, 300, 400)));
-
- // Compute reverse direction of the above rectangles
-
- assertEquals(new Rectangle(100, 110, 300, 400), testComponent.toModel(nativeComponent, new Rectangle(100, 110, 300, 400)));
- assertEquals(new Rectangle(100, 110, 300, 400),
- testComponent.toModel(panel, new Rectangle(100 * 2 + 15, 110 * 2 + 20, 300 * 2, 400 * 2)));
- assertEquals(new Rectangle(100, 110, 300, 400),
- testComponent.toModel(other, new Rectangle(100 * 2 + 15 - 5, 110 * 2 + 20 - 5, 300 * 2, 400 * 2)));
- }
-
- public void testModelPointConversion() {
- TestComponent testComponent = new TestComponent();
-
- MyRoot nativeComponent = new MyRoot(2.0);
- JPanel panel = new JPanel();
- panel.add(nativeComponent);
- nativeComponent.setLocation(15, 20);
- JPanel other = new JPanel();
- panel.add(other);
- other.setLocation(5, 5);
-
- testComponent.setNativeComponent(nativeComponent);
-
- // No conversion when querying for the model view itself
- assertEquals(new Point(100, 110), testComponent.fromModel(nativeComponent, new Point(100, 110)));
-
- // When converting to the parent, should scale by above scale factor (2), then shift by view location relative to panel (15,20)
- assertEquals(new Point(100 * 2 + 15, 110 * 2 + 20), testComponent.fromModel(panel, new Point(100, 110)));
- // When converting to another child, first shift to parent, then down to other child (5,5)
- assertEquals(new Point(100 * 2 + 15 - 5, 110 * 2 + 20 - 5), testComponent.fromModel(other, new Point(100, 110)));
-
- // Compute reverse direction of the above Points
-
- assertEquals(new Point(100, 110), testComponent.toModel(nativeComponent, new Point(100, 110)));
- assertEquals(new Point(100, 110), testComponent.toModel(panel, new Point(100 * 2 + 15, 110 * 2 + 20)));
- assertEquals(new Point(100, 110), testComponent.toModel(other, new Point(100 * 2 + 15 - 5, 110 * 2 + 20 - 5)));
- }
-
- public void testModelSizeConversion() {
- TestComponent testComponent = new TestComponent();
-
- MyRoot nativeComponent = new MyRoot(2.0);
- JPanel panel = new JPanel();
- panel.add(nativeComponent);
- nativeComponent.setLocation(15, 20);
- JPanel other = new JPanel();
- panel.add(other);
- other.setLocation(5, 5);
-
- testComponent.setNativeComponent(nativeComponent);
-
- // No conversion when querying for the model view itself
- assertEquals(new Dimension(300, 400), testComponent.fromModel(nativeComponent, new Dimension(300, 400)));
-
- // When converting to the parent, should scale by above scale factor (2), then shift by view location relative to panel (15,20)
- assertEquals(new Dimension(300 * 2, 400 * 2), testComponent.fromModel(panel, new Dimension(300, 400)));
- // When converting to another child, first shift to parent, then down to other child (5,5)
- assertEquals(new Dimension(300 * 2, 400 * 2), testComponent.fromModel(other, new Dimension(300, 400)));
-
- // Compute reverse direction of the above Dimensions
-
- assertEquals(new Dimension(300, 400), testComponent.toModel(nativeComponent, new Dimension(300, 400)));
- assertEquals(new Dimension(300, 400), testComponent.toModel(panel, new Dimension(300 * 2, 400 * 2)));
- assertEquals(new Dimension(300, 400), testComponent.toModel(other, new Dimension(300 * 2, 400 * 2)));
- }
-
- private static class TestComponent extends RadVisualComponent { // Because RadVisualComponent is abstract
- }
-
- private static class MyRoot extends JComponent implements ScalableComponent {
- private double myScale;
-
- private MyRoot(double scale) {
- myScale = scale;
- }
-
- @Override
- public double getScale() {
- return myScale;
- }
- }
-}
diff --git a/plugins/ui-designer-core/ui-designer-core.iml b/plugins/ui-designer-core/ui-designer-core.iml
index f05517e..a4fc33f 100644
--- a/plugins/ui-designer-core/ui-designer-core.iml
+++ b/plugins/ui-designer-core/ui-designer-core.iml
@@ -4,7 +4,6 @@
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
- <sourceFolder url="file://$MODULE_DIR$/testSources" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/impl/XsltDocumentationProvider.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/impl/XsltDocumentationProvider.java
index 9305819..87dcffc 100644
--- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/impl/XsltDocumentationProvider.java
+++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/impl/XsltDocumentationProvider.java
@@ -199,7 +199,7 @@
final String prefix = tag.getNamespacePrefix();
if (prefix.length() == 0) {
return new DocElement(mgr, psiElement, "element", (String)object);
- } else if (StringUtil.startsWithConcatenationOf(((String)object), prefix, ":")) {
+ } else if (StringUtil.startsWithConcatenation(((String)object), prefix, ":")) {
return new DocElement(mgr, psiElement, "element", ((String)object).substring(prefix.length() + 1));
}
}
diff --git a/plugins/xpath/xpath-view/src/META-INF/plugin.xml b/plugins/xpath/xpath-view/src/META-INF/plugin.xml
index ea18a40..4164b02 100644
--- a/plugins/xpath/xpath-view/src/META-INF/plugin.xml
+++ b/plugins/xpath/xpath-view/src/META-INF/plugin.xml
@@ -214,9 +214,9 @@
</action>
<!-- Toolbar -->
- <reference id="XPathView.Actions.Evaluate">
- <add-to-group group-id="MainToolBar" anchor="before" relative-to-action="HelpTopics" />
- </reference>
+ <!--<reference id="XPathView.Actions.Evaluate">-->
+ <!--<add-to-group group-id="MainToolBar" anchor="before" relative-to-action="HelpTopics" />-->
+ <!--</reference>-->
<group id="XPathView.MainMenu.Search">
<separator />
diff --git a/resources-en/src/tips/Welcome.html b/resources-en/src/tips/Welcome.html
index 2f8692b..7301e94 100644
--- a/resources-en/src/tips/Welcome.html
+++ b/resources-en/src/tips/Welcome.html
@@ -4,7 +4,7 @@
</head>
<body>
<h1>
- Welcome to <span class="product">&productName;</span> <span class="version">&majorVersion;.&minorVersion;</span></h1>
+ Welcome to <span class="product">&productName;</span> <span class="version">&majorVersion;</span></h1>
<p>
You can quickly get familiar with the main features of the IDE by reading these tips. You may try out
the features described in the tips while this dialog stays open on the screen. If you close the dialog,
diff --git a/resources/resources.iml b/resources/resources.iml
index 1f8b3f2..b4aa76b 100644
--- a/resources/resources.iml
+++ b/resources/resources.iml
@@ -12,6 +12,9 @@
<orderEntry type="module" module-name="images" exported="" />
<orderEntry type="module" module-name="community-resources" exported="" />
<orderEntry type="module" module-name="util" />
+ <orderEntry type="module" module-name="InspectionGadgetsAnalysis" />
+ <orderEntry type="module" module-name="IntentionPowerPackPlugin" />
+ <orderEntry type="module" module-name="remote-servers-impl" exported="" scope="RUNTIME" />
</component>
<component name="copyright">
<Base>
diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml
index 41f591a..7b46397 100644
--- a/resources/src/META-INF/IdeaPlugin.xml
+++ b/resources/src/META-INF/IdeaPlugin.xml
@@ -8,6 +8,8 @@
<xi:include href="/idea/JavaActions.xml" xpointer="xpointer(/component/*)"/>
<xi:include href="/META-INF/ExternalSystemExtensions.xml" xpointer="xpointer(/idea-plugin/extensions/*)"/>
<xi:include href="/componentSets/Debugger.xml" xpointer="xpointer(/components/*)"/>
+ <xi:include href="/META-INF/IntentionPowerPack.xml" xpointer="xpointer(/idea-plugin/*)"/>
+ <xi:include href="/META-INF/InspectionGadgets.xml" xpointer="xpointer(/idea-plugin/*)"/>
<application-components>
<component>
@@ -314,7 +316,7 @@
order="last, before default"/>
<completion.contributor language="JAVA" implementationClass="com.intellij.codeInsight.completion.JavaDocCompletionContributor" id="javadoc"
- order="last, before javaLegacy"/>
+ order="last, before javaLegacy, before wordCompletion"/>
<completion.contributor language="JAVA" implementationClass="com.intellij.codeInsight.completion.NullSmartCompletionContributor" id="smartNull"
order="last, before javaSmart"/>
@@ -462,7 +464,7 @@
<externalProjectDataService implementation="com.intellij.externalSystem.JavaProjectDataService"/>
- <specialTool shortName="UnusedDeclaration" displayName="Unused declaration" groupBundle="messages.InspectionsBundle"
+ <globalInspection shortName="UnusedDeclaration" displayName="Unused declaration" groupBundle="messages.InspectionsBundle"
groupKey="group.names.declaration.redundancy" enabledByDefault="true" level="WARNING"
implementationClass="com.intellij.codeInspection.deadCode.UnusedDeclarationInspection"/>
<globalInspection shortName="UnusedLibrary" bundle="messages.InspectionsBundle" key="unused.library.display.name"
diff --git a/resources/src/idea/RichPlatformPlugin.xml b/resources/src/idea/RichPlatformPlugin.xml
index a2c79d7..dcb2acd 100644
--- a/resources/src/idea/RichPlatformPlugin.xml
+++ b/resources/src/idea/RichPlatformPlugin.xml
@@ -385,6 +385,7 @@
</extensions>
<xi:include href="/META-INF/xdebugger.xml" xpointer="xpointer(/idea-plugin/*)"/>
+ <xi:include href="/META-INF/RemoteServers.xml" xpointer="xpointer(/idea-plugin/*)"/>
<xi:include href="/META-INF/XmlPlugin.xml" xpointer="xpointer(/idea-plugin/*)"/>
<xi:include href="/META-INF/RegExpPlugin.xml" xpointer="xpointer(/idea-plugin/*)"/>
diff --git a/spellchecker/src/com/intellij/spellchecker/jetbrains.dic b/spellchecker/src/com/intellij/spellchecker/jetbrains.dic
index 106b8f3..9ff4426 100644
--- a/spellchecker/src/com/intellij/spellchecker/jetbrains.dic
+++ b/spellchecker/src/com/intellij/spellchecker/jetbrains.dic
@@ -207,6 +207,7 @@
kotlin
labeler
labelers
+lcov
ldap
libxml
lifecycle
@@ -479,6 +480,7 @@
underwave
undoable
undofile
+unescaped
unhandled
uninstall
unpivot
diff --git a/spellchecker/src/com/intellij/spellchecker/ui/SpellCheckingEditorCustomization.java b/spellchecker/src/com/intellij/spellchecker/ui/SpellCheckingEditorCustomization.java
index d3ffcb5..31c0462 100644
--- a/spellchecker/src/com/intellij/spellchecker/ui/SpellCheckingEditorCustomization.java
+++ b/spellchecker/src/com/intellij/spellchecker/ui/SpellCheckingEditorCustomization.java
@@ -16,6 +16,7 @@
package com.intellij.spellchecker.ui;
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
+import com.intellij.codeInsight.daemon.HighlightDisplayKey;
import com.intellij.codeInsight.intention.IntentionManager;
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.codeInspection.ex.InspectionProfileImpl;
@@ -24,17 +25,15 @@
import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiDocumentManager;
-import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.spellchecker.inspections.SpellCheckingInspection;
import com.intellij.ui.SimpleEditorCustomization;
import com.intellij.util.Function;
import com.intellij.util.containers.WeakHashMap;
-import gnu.trove.THashSet;
-import gnu.trove.TObjectHashingStrategy;
import org.jetbrains.annotations.NotNull;
-import java.util.*;
+import java.util.HashMap;
+import java.util.Map;
/**
* Allows to enforce editors to use/don't use spell checking ignoring user-defined spelling inspection settings.
@@ -49,7 +48,7 @@
public static final SpellCheckingEditorCustomization ENABLED = new SpellCheckingEditorCustomization(true);
public static final SpellCheckingEditorCustomization DISABLED = new SpellCheckingEditorCustomization(false);
- private static final Set<LocalInspectionToolWrapper> SPELL_CHECK_TOOLS = new HashSet<LocalInspectionToolWrapper>();
+ private static final Map<String, LocalInspectionToolWrapper> SPELL_CHECK_TOOLS = new HashMap<String, LocalInspectionToolWrapper>();
private static final boolean READY = init();
@NotNull
@@ -70,7 +69,7 @@
for (Class<LocalInspectionTool> inspectionClass : inspectionClasses) {
try {
LocalInspectionTool tool = inspectionClass.newInstance();
- SPELL_CHECK_TOOLS.add(new LocalInspectionToolWrapper(tool));
+ SPELL_CHECK_TOOLS.put(tool.getShortName(), new LocalInspectionToolWrapper(tool));
}
catch (Throwable e) {
return false;
@@ -152,29 +151,9 @@
myDelegate = delegate;
}
- @NotNull
@Override
- public List<LocalInspectionToolWrapper> getHighlightingLocalInspectionTools(PsiElement element) {
- Set<LocalInspectionToolWrapper> result = new THashSet<LocalInspectionToolWrapper>(myDelegate.getHighlightingLocalInspectionTools(element), new TObjectHashingStrategy<LocalInspectionToolWrapper>() {
- @Override
- public int computeHashCode(LocalInspectionToolWrapper object) {
- return object.getShortName().hashCode();
- }
-
- @Override
- public boolean equals(LocalInspectionToolWrapper o1, LocalInspectionToolWrapper o2) {
- return o1.getShortName().equals(o2.getShortName());
- }
- });
-
- if (myUseSpellCheck) {
- result.removeAll(SPELL_CHECK_TOOLS);
- result.addAll(SPELL_CHECK_TOOLS);
- }
- else {
- result.removeAll(SPELL_CHECK_TOOLS);
- }
- return new ArrayList<LocalInspectionToolWrapper>(result);
+ public boolean isToolEnabled(HighlightDisplayKey key) {
+ return myDelegate.isToolEnabled(key) && SPELL_CHECK_TOOLS.containsKey(key.toString()) && myUseSpellCheck;
}
public void setUseSpellCheck(boolean useSpellCheck) {
diff --git a/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementAnnotationsManagerImpl.java b/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementAnnotationsManagerImpl.java
index fc673ec..19c4f06 100644
--- a/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementAnnotationsManagerImpl.java
+++ b/xml/dom-impl/src/com/intellij/util/xml/highlighting/DomElementAnnotationsManagerImpl.java
@@ -21,7 +21,7 @@
import com.intellij.codeInspection.InspectionProfile;
import com.intellij.codeInspection.InspectionProfileEntry;
import com.intellij.codeInspection.ProblemDescriptor;
-import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
+import com.intellij.codeInspection.ex.InspectionToolWrapper;
import com.intellij.lang.annotation.HighlightSeverity;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.diagnostic.Logger;
@@ -62,21 +62,25 @@
private final EventDispatcher<DomHighlightingListener> myDispatcher = EventDispatcher.create(DomHighlightingListener.class);
private static final DomElementsProblemsHolder EMPTY_PROBLEMS_HOLDER = new DomElementsProblemsHolder() {
+ @Override
@NotNull
public List<DomElementProblemDescriptor> getProblems(DomElement domElement) {
return Collections.emptyList();
}
+ @Override
public List<DomElementProblemDescriptor> getProblems(final DomElement domElement, boolean includeXmlProblems) {
return Collections.emptyList();
}
+ @Override
public List<DomElementProblemDescriptor> getProblems(final DomElement domElement,
final boolean includeXmlProblems,
final boolean withChildren) {
return Collections.emptyList();
}
+ @Override
public List<DomElementProblemDescriptor> getProblems(DomElement domElement,
final boolean includeXmlProblems,
final boolean withChildren,
@@ -84,18 +88,22 @@
return Collections.emptyList();
}
+ @Override
public List<DomElementProblemDescriptor> getProblems(DomElement domElement, final boolean withChildren, HighlightSeverity minSeverity) {
return Collections.emptyList();
}
+ @Override
public List<DomElementProblemDescriptor> getAllProblems() {
return Collections.emptyList();
}
+ @Override
public List<DomElementProblemDescriptor> getAllProblems(@NotNull DomElementsInspection inspection) {
return Collections.emptyList();
}
+ @Override
public boolean isInspectionCompleted(@NotNull final DomElementsInspection inspectionClass) {
return false;
}
@@ -108,15 +116,18 @@
public DomElementAnnotationsManagerImpl(Project project) {
myProject = project;
myModificationTracker = new ModificationTracker() {
+ @Override
public long getModificationCount() {
return myModificationCount;
}
};
final ProfileChangeAdapter profileChangeAdapter = new ProfileChangeAdapter() {
+ @Override
public void profileActivated(@NotNull Profile oldProfile, Profile profile) {
dropAnnotationsCache();
}
+ @Override
public void profileChanged(Profile profile) {
dropAnnotationsCache();
}
@@ -125,12 +136,14 @@
final InspectionProfileManager inspectionProfileManager = InspectionProfileManager.getInstance();
inspectionProfileManager.addProfileChangeListener(profileChangeAdapter, project);
Disposer.register(project, new Disposable() {
+ @Override
public void dispose() {
inspectionProfileManager.removeProfileChangeListener(profileChangeAdapter);
}
});
}
+ @Override
public void dropAnnotationsCache() {
myModificationCount++;
}
@@ -156,6 +169,7 @@
holder = new DomElementsProblemsHolderImpl(element);
rootTag.putUserData(DOM_PROBLEM_HOLDER_KEY, holder);
final CachedValue<Boolean> cachedValue = CachedValuesManager.getManager(myProject).createCachedValue(new CachedValueProvider<Boolean>() {
+ @Override
public Result<Boolean> compute() {
return new Result<Boolean>(Boolean.FALSE, element, PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myModificationTracker, ProjectRootManager.getInstance(myProject));
}
@@ -183,6 +197,7 @@
return cachedValue == null || !cachedValue.hasUpToDateValue();
}
+ @Override
@NotNull
public DomElementsProblemsHolder getProblemHolder(DomElement element) {
if (element == null || !element.isValid()) return EMPTY_PROBLEMS_HOLDER;
@@ -200,6 +215,7 @@
}
}
+ @Override
@NotNull
public DomElementsProblemsHolder getCachedProblemHolder(DomElement element) {
return getProblemHolder(element);
@@ -212,10 +228,12 @@
}
}
+ @Override
public List<ProblemDescriptor> createProblemDescriptors(final InspectionManager manager, DomElementProblemDescriptor problemDescriptor) {
return ContainerUtil.createMaybeSingletonList(DomElementsHighlightingUtil.createProblemDescriptors(manager, problemDescriptor));
}
+ @Override
public boolean isHighlightingFinished(final DomElement[] domElements) {
for (final DomElement domElement : domElements) {
if (getHighlightStatus(domElement) != DomHighlightStatus.INSPECTIONS_FINISHED) {
@@ -225,14 +243,17 @@
return true;
}
+ @Override
public void addHighlightingListener(DomHighlightingListener listener, Disposable parentDisposable) {
myDispatcher.addListener(listener, parentDisposable);
}
+ @Override
public DomHighlightingHelper getHighlightingHelper() {
return DomHighlightingHelperImpl.INSTANCE;
}
+ @Override
@NotNull
public <T extends DomElement> List<DomElementProblemDescriptor> checkFileElement(@NotNull final DomFileElement<T> domFileElement,
@NotNull final DomElementsInspection<T> inspection,
@@ -251,9 +272,9 @@
Class rootType = fileElement.getRootElementClass();
final InspectionProfile profile = getInspectionProfile(fileElement);
final List<DomElementsInspection> inspections = new SmartList<DomElementsInspection>();
- for (final InspectionProfileEntry profileEntry : profile.getInspectionTools(fileElement.getFile())) {
- if (!enabledOnly || profile.isToolEnabled(HighlightDisplayKey.find(profileEntry.getShortName()), fileElement.getFile())) {
- ContainerUtil.addIfNotNull(getSuitableInspection(profileEntry, rootType), inspections);
+ for (final InspectionToolWrapper toolWrapper : profile.getInspectionTools(fileElement.getFile())) {
+ if (!enabledOnly || profile.isToolEnabled(HighlightDisplayKey.find(toolWrapper.getShortName()), fileElement.getFile())) {
+ ContainerUtil.addIfNotNull(getSuitableInspection(toolWrapper.getTool(), rootType), inspections);
}
}
return inspections;
@@ -265,10 +286,6 @@
@Nullable
private static DomElementsInspection getSuitableInspection(InspectionProfileEntry entry, Class rootType) {
- if (entry instanceof LocalInspectionToolWrapper) {
- return getSuitableInspection(((LocalInspectionToolWrapper)entry).getTool(), rootType);
- }
-
if (entry instanceof DomElementsInspection) {
if (((DomElementsInspection)entry).getDomClasses().contains(rootType)) {
return (DomElementsInspection) entry;
diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/DomServiceImpl.java b/xml/dom-impl/src/com/intellij/util/xml/impl/DomServiceImpl.java
index de28721..ce5bb54 100644
--- a/xml/dom-impl/src/com/intellij/util/xml/impl/DomServiceImpl.java
+++ b/xml/dom-impl/src/com/intellij/util/xml/impl/DomServiceImpl.java
@@ -75,7 +75,7 @@
return computeHeaderByPsi(file);
}
- if (!XmlUtil.isStubBuilding(file) && file.getFileType() == XmlFileType.INSTANCE) {
+ if (!XmlUtil.isStubBuilding() && file.getFileType() == XmlFileType.INSTANCE) {
VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile instanceof VirtualFileWithId) {
ObjectStubTree tree = StubTreeLoader.getInstance().readFromVFile(file.getProject(), virtualFile);
@@ -90,7 +90,7 @@
if (!file.isValid()) return XmlFileHeader.EMPTY;
- if (XmlUtil.isStubBuilding(file) && file.getFileType() == XmlFileType.INSTANCE) {
+ if (XmlUtil.isStubBuilding() && file.getFileType() == XmlFileType.INSTANCE) {
FileContent fileContent = file.getUserData(DomStubBuilder.CONTENT_FOR_DOM_STUBS);
if (fileContent != null) {
//noinspection IOResourceOpenedButNotSafelyClosed
diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/FileDescriptionCachedValueProvider.java b/xml/dom-impl/src/com/intellij/util/xml/impl/FileDescriptionCachedValueProvider.java
index 2edfb9a..a9adbfe 100644
--- a/xml/dom-impl/src/com/intellij/util/xml/impl/FileDescriptionCachedValueProvider.java
+++ b/xml/dom-impl/src/com/intellij/util/xml/impl/FileDescriptionCachedValueProvider.java
@@ -117,7 +117,7 @@
FileStub stub = null;
if (description.hasStubs() && file instanceof VirtualFileWithId && !isFileParsed()) {
ApplicationManager.getApplication().assertReadAccessAllowed();
- if (!XmlUtil.isStubBuilding(myXmlFile)) {
+ if (!XmlUtil.isStubBuilding()) {
ObjectStubTree stubTree = StubTreeLoader.getInstance().readOrBuild(myXmlFile.getProject(), file, myXmlFile);
if (stubTree != null) {
stub = (FileStub)stubTree.getRoot();
diff --git a/xml/dom-impl/src/com/intellij/util/xml/structure/DomStructureViewBuilder.java b/xml/dom-impl/src/com/intellij/util/xml/structure/DomStructureViewBuilder.java
index 94ccf53..a8fb409 100644
--- a/xml/dom-impl/src/com/intellij/util/xml/structure/DomStructureViewBuilder.java
+++ b/xml/dom-impl/src/com/intellij/util/xml/structure/DomStructureViewBuilder.java
@@ -21,18 +21,21 @@
import com.intellij.ide.structureView.TreeBasedStructureViewBuilder;
import com.intellij.ide.structureView.newStructureView.StructureViewComponent;
import com.intellij.ide.util.treeView.AbstractTreeNode;
+import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.fileEditor.FileEditor;
+import com.intellij.openapi.fileEditor.TextEditor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.AsyncResult;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.xml.XmlElement;
-import com.intellij.psi.xml.XmlTag;
import com.intellij.psi.xml.XmlFile;
+import com.intellij.psi.xml.XmlTag;
import com.intellij.util.Function;
import com.intellij.util.xml.DomElement;
import com.intellij.util.xml.DomManager;
import com.intellij.util.xml.DomService;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
public class DomStructureViewBuilder extends TreeBasedStructureViewBuilder {
private final Function<DomElement, DomService.StructureViewMode> myDescriptor;
@@ -43,18 +46,22 @@
myDescriptor = descriptor;
}
+ @Override
@NotNull
- public StructureViewModel createStructureViewModel() {
- return new DomStructureViewTreeModel(myFile, myDescriptor);
+ public StructureViewModel createStructureViewModel(@Nullable Editor editor) {
+ return new DomStructureViewTreeModel(myFile, myDescriptor, editor);
}
+ @Override
public boolean isRootNodeShown() {
return true;
}
+ @Override
@NotNull
public StructureView createStructureView(final FileEditor fileEditor, final Project project) {
- return new StructureViewComponent(fileEditor, createStructureViewModel(), project) {
+ return new StructureViewComponent(fileEditor, createStructureViewModel(fileEditor instanceof TextEditor ? ((TextEditor)fileEditor).getEditor() : null), project) {
+ @Override
public AsyncResult<AbstractTreeNode> expandPathToElement(final Object element) {
if (element instanceof XmlElement) {
final XmlElement xmlElement = (XmlElement)element;
diff --git a/xml/dom-impl/src/com/intellij/util/xml/structure/DomStructureViewTreeModel.java b/xml/dom-impl/src/com/intellij/util/xml/structure/DomStructureViewTreeModel.java
index 41139a2..bb5b01b 100644
--- a/xml/dom-impl/src/com/intellij/util/xml/structure/DomStructureViewTreeModel.java
+++ b/xml/dom-impl/src/com/intellij/util/xml/structure/DomStructureViewTreeModel.java
@@ -21,11 +21,13 @@
import com.intellij.ide.structureView.impl.xml.XmlStructureViewTreeModel;
import com.intellij.ide.util.treeView.smartTree.Sorter;
import com.intellij.openapi.Disposable;
+import com.intellij.openapi.editor.Editor;
import com.intellij.psi.PsiFile;
import com.intellij.psi.xml.XmlFile;
import com.intellij.util.Function;
import com.intellij.util.xml.*;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
/**
* @author Gregory.Shrago
@@ -35,17 +37,21 @@
private final DomElementNavigationProvider myNavigationProvider;
private final Function<DomElement, DomService.StructureViewMode> myDescriptor;
- public DomStructureViewTreeModel(final XmlFile file, final Function<DomElement, DomService.StructureViewMode> descriptor) {
- this(file, DomElementsNavigationManager.getManager(file.getProject()).getDomElementsNavigateProvider(DomElementsNavigationManager.DEFAULT_PROVIDER_NAME), descriptor);
+ public DomStructureViewTreeModel(final XmlFile file, final Function<DomElement, DomService.StructureViewMode> descriptor, @Nullable Editor editor) {
+ this(file, DomElementsNavigationManager.getManager(file.getProject()).getDomElementsNavigateProvider(DomElementsNavigationManager.DEFAULT_PROVIDER_NAME), descriptor, editor);
}
- public DomStructureViewTreeModel(final XmlFile file, final DomElementNavigationProvider navigationProvider, final Function<DomElement, DomService.StructureViewMode> descriptor) {
- super(file);
+ public DomStructureViewTreeModel(final XmlFile file,
+ final DomElementNavigationProvider navigationProvider,
+ final Function<DomElement, DomService.StructureViewMode> descriptor,
+ @Nullable Editor editor) {
+ super(file, editor);
myFile = file;
myNavigationProvider = navigationProvider;
myDescriptor = descriptor;
}
+ @Override
@NotNull
public StructureViewTreeElement getRoot() {
final DomFileElement<DomElement> fileElement = DomManager.getDomManager(myFile.getProject()).getFileElement(myFile, DomElement.class);
@@ -58,11 +64,13 @@
return myNavigationProvider;
}
+ @Override
@NotNull
public Sorter[] getSorters() {
return new Sorter[]{Sorter.ALPHA_SORTER};
}
+ @Override
protected PsiFile getPsiFile() {
return myFile;
}
diff --git a/xml/dom-impl/src/com/intellij/util/xml/stubs/builder/DomStubBuilder.java b/xml/dom-impl/src/com/intellij/util/xml/stubs/builder/DomStubBuilder.java
index cb57547..3d960e5 100644
--- a/xml/dom-impl/src/com/intellij/util/xml/stubs/builder/DomStubBuilder.java
+++ b/xml/dom-impl/src/com/intellij/util/xml/stubs/builder/DomStubBuilder.java
@@ -54,13 +54,12 @@
Project project = fileContent.getProject();
PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
if (!(psiFile instanceof XmlFile)) return null;
- psiFile.putUserData(CONTENT_FOR_DOM_STUBS, fileContent);
XmlFile xmlFile = (XmlFile)psiFile;
- DomManager manager = DomManager.getDomManager(project);
try {
- xmlFile.putUserData(XmlUtil.BUILDING_DOM_STUBS, Boolean.TRUE);
- DomFileElement<? extends DomElement> fileElement = manager.getFileElement(xmlFile);
+ XmlUtil.BUILDING_DOM_STUBS.set(Boolean.TRUE);
+ psiFile.putUserData(CONTENT_FOR_DOM_STUBS, fileContent);
+ DomFileElement<? extends DomElement> fileElement = DomManager.getDomManager(project).getFileElement(xmlFile);
if (fileElement == null || !fileElement.getFileDescription().hasStubs()) return null;
XmlFileHeader header = DomService.getInstance().getXmlFileHeader(xmlFile);
@@ -73,7 +72,7 @@
return fileStub;
}
finally {
- xmlFile.putUserData(XmlUtil.BUILDING_DOM_STUBS, null);
+ XmlUtil.BUILDING_DOM_STUBS.set(Boolean.FALSE);
psiFile.putUserData(CONTENT_FOR_DOM_STUBS, null);
}
}
diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/CommitablePanelUserActivityListener.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/CommitablePanelUserActivityListener.java
index 82ca2b9..d34619d 100644
--- a/xml/dom-openapi/src/com/intellij/util/xml/ui/CommitablePanelUserActivityListener.java
+++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/CommitablePanelUserActivityListener.java
@@ -16,13 +16,13 @@
package com.intellij.util.xml.ui;
-import com.intellij.ui.UserActivityListener;
-import com.intellij.util.Alarm;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.components.ServiceManager;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.ProgressIndicator;
+import com.intellij.openapi.progress.ProgressManager;
+import com.intellij.openapi.project.Project;
+import com.intellij.ui.UserActivityListener;
+import com.intellij.util.Alarm;
/**
* User: Sergey.Vasiliev
@@ -82,7 +82,7 @@
}
public final boolean isWaiting() {
- return myAlarm.getActiveRequestCount() > 0;
+ return !myAlarm.isEmpty();
}
public final void cancelAllRequests() {
diff --git a/xml/dom-tests/tests/com/intellij/util/xml/DomHighlightingLiteTest.java b/xml/dom-tests/tests/com/intellij/util/xml/DomHighlightingLiteTest.java
index 623b116..e96d2e4 100644
--- a/xml/dom-tests/tests/com/intellij/util/xml/DomHighlightingLiteTest.java
+++ b/xml/dom-tests/tests/com/intellij/util/xml/DomHighlightingLiteTest.java
@@ -21,7 +21,7 @@
import com.intellij.codeInspection.InspectionToolProvider;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ex.InspectionToolRegistrar;
-import com.intellij.ide.ui.search.SearchableOptionsRegistrar;
+import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
import com.intellij.lang.annotation.Annotation;
import com.intellij.mock.MockInspectionProfile;
import com.intellij.profile.codeInspection.InspectionProfileManager;
@@ -53,7 +53,7 @@
protected void setUp() throws Exception {
super.setUp();
- final InspectionToolRegistrar registrar = new InspectionToolRegistrar(SearchableOptionsRegistrar.getInstance());
+ final InspectionToolRegistrar registrar = new InspectionToolRegistrar();
registrar.registerTools(new InspectionToolProvider[0]);
final InspectionProfileManager inspectionProfileManager = new InspectionProfileManagerImpl(registrar, new MockSchemesManagerFactory());
myInspectionProfile = new MockInspectionProfile();
@@ -177,7 +177,7 @@
public void testNoMockInspection() throws Throwable {
myElement.setFileDescription(new MyNonHighlightingDomFileDescription());
- myInspectionProfile.setInspectionTools(new MyDomElementsInspection());
+ myInspectionProfile.setInspectionTools(new LocalInspectionToolWrapper(new MyDomElementsInspection()));
assertNull(myAnnotationsManager.getMockInspection(myElement));
}
@@ -238,7 +238,7 @@
}
};
HighlightDisplayKey.register(inspection.getShortName());
- myInspectionProfile.setInspectionTools(inspection);
+ myInspectionProfile.setInspectionTools(new LocalInspectionToolWrapper(inspection));
myAnnotationsManager.appendProblems(myElement, createHolder(), MockAnnotatingDomInspection.class);
assertEquals(DomHighlightStatus.ANNOTATORS_FINISHED, myAnnotationsManager.getHighlightStatus(myElement));
@@ -263,8 +263,9 @@
}
};
HighlightDisplayKey.register(inspection.getShortName());
- myInspectionProfile.setInspectionTools(inspection);
- myInspectionProfile.setEnabled(inspection, false);
+ LocalInspectionToolWrapper toolWrapper = new LocalInspectionToolWrapper(inspection);
+ myInspectionProfile.setInspectionTools(toolWrapper);
+ myInspectionProfile.setEnabled(toolWrapper, false);
myAnnotationsManager.appendProblems(myElement, createHolder(), MockAnnotatingDomInspection.class);
assertEquals(DomHighlightStatus.INSPECTIONS_FINISHED, myAnnotationsManager.getHighlightStatus(myElement));
diff --git a/xml/impl/resources/com/intellij/codeInsight/completion/TagNameReferenceCompletionProvider.java b/xml/impl/resources/com/intellij/codeInsight/completion/TagNameReferenceCompletionProvider.java
index fa2f160..45220b0 100644
--- a/xml/impl/resources/com/intellij/codeInsight/completion/TagNameReferenceCompletionProvider.java
+++ b/xml/impl/resources/com/intellij/codeInsight/completion/TagNameReferenceCompletionProvider.java
@@ -23,9 +23,11 @@
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiReference;
+import com.intellij.psi.impl.source.xml.SchemaPrefixReference;
import com.intellij.psi.impl.source.xml.TagNameReference;
import com.intellij.psi.xml.XmlTag;
import com.intellij.util.Consumer;
+import com.intellij.util.PairConsumer;
import com.intellij.util.ProcessingContext;
import com.intellij.xml.XmlTagNameProvider;
import org.jetbrains.annotations.NotNull;
@@ -48,12 +50,21 @@
@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
ProcessingContext context,
- @NotNull CompletionResultSet result) {
- PsiReference reference = parameters.getPosition().getContainingFile().findReferenceAt(parameters.getOffset());
- if (reference instanceof TagNameReference) {
- TagNameReference tagNameReference = (TagNameReference)reference;
- collectCompletionVariants(tagNameReference, result);
- }
+ @NotNull final CompletionResultSet result) {
+ LegacyCompletionContributor.processReferences(parameters, result, new PairConsumer<PsiReference, CompletionResultSet>() {
+ @Override
+ public void consume(PsiReference reference, CompletionResultSet set) {
+ if (reference instanceof TagNameReference) {
+ collectCompletionVariants((TagNameReference)reference, set);
+ }
+ else if (reference instanceof SchemaPrefixReference) {
+ TagNameReference tagNameReference = ((SchemaPrefixReference)reference).getTagNameReference();
+ if (tagNameReference != null && !tagNameReference.isStartTagFlag()) {
+ set.consume(createClosingTagLookupElement((XmlTag)tagNameReference.getElement(), true, tagNameReference.getNameElement()));
+ }
+ }
+ }
+ });
}
public static void collectCompletionVariants(TagNameReference tagNameReference,
diff --git a/xml/impl/resources/liveTemplates/zen_html.xml b/xml/impl/resources/liveTemplates/zen_html.xml
index 0f77507..58009a6 100644
--- a/xml/impl/resources/liveTemplates/zen_html.xml
+++ b/xml/impl/resources/liveTemplates/zen_html.xml
@@ -62,7 +62,7 @@
</context>
</template>
<template description="" name="!" toReformat="true" toShortenFQNames="true"
- value="<!doctype html> <html lang="$ENV_LOCALE$"> <head> <meta charset="UTF-8"> <title>$TITLE$</title> </head> <body> $END$ </body> </html>">
+ value="<!doctype html> <html lang="$ENV_LOCALE$"> <head> <meta charset="UTF-8"> <title>$TITLE$</title> </head> <body> $END$ </body> </html>">
<variable alwaysStopAt="true" defaultValue=""en"" expression="" name="ENV_LOCALE"/>
<variable alwaysStopAt="true" defaultValue=""Document"" expression="" name="TITLE"/>
<context>
@@ -1032,21 +1032,21 @@
</context>
</template>
<template description="" name="doc" toReformat="true" toShortenFQNames="true"
- value="<html> <head> <meta charset="UTF-8"> <title>$TITLE$</title> </head> <body> $END$ </body> </html>">
+ value="<html> <head> <meta charset="UTF-8"> <title>$TITLE$</title> </head> <body> $END$ </body> </html>">
<variable alwaysStopAt="true" defaultValue=""Document"" expression="" name="TITLE"/>
<context>
<option name="HTML_TEXT" value="true"/>
</context>
</template>
<template description="" name="doc4" toReformat="true" toShortenFQNames="true"
- value="<html> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>$TITLE$</title> </head> <body> $END$ </body> </html>">
+ value="<html> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>$TITLE$</title> </head> <body> $END$ </body> </html>">
<variable alwaysStopAt="true" defaultValue=""Document"" expression="" name="TITLE"/>
<context>
<option name="HTML_TEXT" value="true"/>
</context>
</template>
<template description="" name="html:4t" toReformat="true" toShortenFQNames="true"
- value="<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="$ENV_LANG$"> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>$TITLE$</title> </head> <body> $END$ </body> </html>">
+ value="<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="$ENV_LANG$"> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>$TITLE$</title> </head> <body> $END$ </body> </html>">
<variable alwaysStopAt="true" defaultValue=""en"" expression="" name="ENV_LANG"/>
<variable alwaysStopAt="true" defaultValue=""Document"" expression="" name="TITLE"/>
<context>
@@ -1054,7 +1054,7 @@
</context>
</template>
<template description="" name="html:4s" toReformat="true" toShortenFQNames="true"
- value="<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="$ENV_LANG$"> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>$TITLE$</title> </head> <body> $END$ </body> </html>">
+ value="<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="$ENV_LANG$"> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>$TITLE$</title> </head> <body> $END$ </body> </html>">
<variable alwaysStopAt="true" defaultValue=""en"" expression="" name="ENV_LANG"/>
<variable alwaysStopAt="true" defaultValue=""Document"" expression="" name="TITLE"/>
<context>
@@ -1062,7 +1062,7 @@
</context>
</template>
<template description="" name="html:xt" toReformat="true" toShortenFQNames="true"
- value="<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="$ENV_LANG$"> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>$TITLE$</title> </head> <body> $END$ </body> </html>">
+ value="<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="$ENV_LANG$"> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>$TITLE$</title> </head> <body> $END$ </body> </html>">
<variable alwaysStopAt="true" defaultValue=""en"" expression="" name="ENV_LANG"/>
<variable alwaysStopAt="true" defaultValue=""Document"" expression="" name="TITLE"/>
<context>
@@ -1070,7 +1070,7 @@
</context>
</template>
<template description="" name="html:xs" toReformat="true" toShortenFQNames="true"
- value="<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="$ENV_LANG$"> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>$TITLE$</title> </head> <body> $END$ </body> </html>">
+ value="<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="$ENV_LANG$"> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>$TITLE$</title> </head> <body> $END$ </body> </html>">
<variable alwaysStopAt="true" defaultValue=""en"" expression="" name="ENV_LANG"/>
<variable alwaysStopAt="true" defaultValue=""Document"" expression="" name="TITLE"/>
<context>
@@ -1078,7 +1078,7 @@
</context>
</template>
<template description="" name="html:xxs" toReformat="true" toShortenFQNames="true"
- value="<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="$ENV_LANG$"> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>$TITLE$</title> </head> <body> $END$ </body> </html>">
+ value="<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="$ENV_LANG$"> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>$TITLE$</title> </head> <body> $END$ </body> </html>">
<variable alwaysStopAt="true" defaultValue=""en"" expression="" name="ENV_LANG"/>
<variable alwaysStopAt="true" defaultValue=""Document"" expression="" name="TITLE"/>
<context>
@@ -1086,30 +1086,30 @@
</context>
</template>
<template description="" name="html:5" toReformat="true" toShortenFQNames="true"
- value="<!doctype html> <html lang="$ENV_LOCALE$"> <head> <meta charset="UTF-8"> <title>$TITLE$</title> </head> <body> $END$ </body> </html>">
+ value="<!doctype html> <html lang="$ENV_LOCALE$"> <head> <meta charset="UTF-8"> <title>$TITLE$</title> </head> <body> $END$ </body> </html>">
<variable alwaysStopAt="true" defaultValue=""en"" expression="" name="ENV_LOCALE"/>
<variable alwaysStopAt="true" defaultValue=""Document"" expression="" name="TITLE"/>
<context>
<option name="HTML_TEXT" value="true"/>
</context>
</template>
- <template description="" name="ol+" toReformat="true" toShortenFQNames="true" value="<ol> <li>$END$</li> </ol>">
+ <template description="" name="ol+" toReformat="true" toShortenFQNames="true" value="<ol> <li>$END$</li> </ol>">
<context>
<option name="HTML_TEXT" value="true"/>
</context>
</template>
- <template description="" name="ul+" toReformat="true" toShortenFQNames="true" value="<ul> <li>$END$</li> </ul>">
+ <template description="" name="ul+" toReformat="true" toShortenFQNames="true" value="<ul> <li>$END$</li> </ul>">
<context>
<option name="HTML_TEXT" value="true"/>
</context>
</template>
- <template description="" name="dl+" toReformat="true" toShortenFQNames="true" value="<dl> <dt>$VAR0$</dt> <dd>$END$</dd> </dl>">
+ <template description="" name="dl+" toReformat="true" toShortenFQNames="true" value="<dl> <dt>$VAR0$</dt> <dd>$END$</dd> </dl>">
<variable alwaysStopAt="true" defaultValue="""" expression="" name="VAR0"/>
<context>
<option name="HTML_TEXT" value="true"/>
</context>
</template>
- <template description="" name="map+" toReformat="true" toShortenFQNames="true" value="<map name="$VAR0$"> <area shape="$VAR1$" coords="$VAR2$" href="$VAR3$" alt="$VAR4$"/>$END$ </map>">
+ <template description="" name="map+" toReformat="true" toShortenFQNames="true" value="<map name="$VAR0$"> <area shape="$VAR1$" coords="$VAR2$" href="$VAR3$" alt="$VAR4$"/>$END$ </map>">
<variable alwaysStopAt="true" defaultValue="""" expression="" name="VAR0"/>
<variable alwaysStopAt="true" defaultValue="""" expression="" name="VAR1"/>
<variable alwaysStopAt="true" defaultValue="""" expression="" name="VAR2"/>
@@ -1119,27 +1119,27 @@
<option name="HTML_TEXT" value="true"/>
</context>
</template>
- <template description="" name="table+" toReformat="true" toShortenFQNames="true" value="<table> <tr> <td>$END$</td> </tr> </table>">
+ <template description="" name="table+" toReformat="true" toShortenFQNames="true" value="<table> <tr> <td>$END$</td> </tr> </table>">
<context>
<option name="HTML_TEXT" value="true"/>
</context>
</template>
- <template description="" name="colgroup+" toReformat="true" toShortenFQNames="true" value="<colgroup> <col/> </colgroup>">
+ <template description="" name="colgroup+" toReformat="true" toShortenFQNames="true" value="<colgroup> <col/> </colgroup>">
<context>
<option name="HTML_TEXT" value="true"/>
</context>
</template>
- <template description="" name="colg+" toReformat="true" toShortenFQNames="true" value="<colgroup> <col/> </colgroup>">
+ <template description="" name="colg+" toReformat="true" toShortenFQNames="true" value="<colgroup> <col/> </colgroup>">
<context>
<option name="HTML_TEXT" value="true"/>
</context>
</template>
- <template description="" name="tr+" toReformat="true" toShortenFQNames="true" value="<tr> <td>$END$</td> </tr>">
+ <template description="" name="tr+" toReformat="true" toShortenFQNames="true" value="<tr> <td>$END$</td> </tr>">
<context>
<option name="HTML_TEXT" value="true"/>
</context>
</template>
- <template description="" name="select+" toReformat="true" toShortenFQNames="true" value="<select name="$VAR0$" id="$VAR1$"> <option value="$VAR2$">$END$</option> </select>">
+ <template description="" name="select+" toReformat="true" toShortenFQNames="true" value="<select name="$VAR0$" id="$VAR1$"> <option value="$VAR2$">$END$</option> </select>">
<variable alwaysStopAt="true" defaultValue="""" expression="" name="VAR0"/>
<variable alwaysStopAt="true" defaultValue="""" expression="" name="VAR1"/>
<variable alwaysStopAt="true" defaultValue="""" expression="" name="VAR2"/>
@@ -1147,13 +1147,13 @@
<option name="HTML_TEXT" value="true"/>
</context>
</template>
- <template description="" name="optgroup+" toReformat="true" toShortenFQNames="true" value="<optgroup> <option value="$VAR0$">$END$</option> </optgroup>">
+ <template description="" name="optgroup+" toReformat="true" toShortenFQNames="true" value="<optgroup> <option value="$VAR0$">$END$</option> </optgroup>">
<variable alwaysStopAt="true" defaultValue="""" expression="" name="VAR0"/>
<context>
<option name="HTML_TEXT" value="true"/>
</context>
</template>
- <template description="" name="optg+" toReformat="true" toShortenFQNames="true" value="<optgroup> <option value="$VAR0$">$END$</option> </optgroup>">
+ <template description="" name="optg+" toReformat="true" toShortenFQNames="true" value="<optgroup> <option value="$VAR0$">$END$</option> </optgroup>">
<variable alwaysStopAt="true" defaultValue="""" expression="" name="VAR0"/>
<context>
<option name="HTML_TEXT" value="true"/>
diff --git a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java
index d39630b..0509068 100644
--- a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java
+++ b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java
@@ -685,12 +685,12 @@
}
@Override
- public void addMessage(PsiElement context, String message, ErrorType type) {
+ public void addMessage(PsiElement context, String message, @NotNull ErrorType type) {
addMessageWithFixes(context, message, type);
}
@Override
- public void addMessageWithFixes(final PsiElement context, final String message, final ErrorType type, final IntentionAction... fixes) {
+ public void addMessageWithFixes(final PsiElement context, final String message, @NotNull final ErrorType type, final IntentionAction... fixes) {
if (message != null && !message.isEmpty()) {
final PsiFile containingFile = context.getContainingFile();
final HighlightInfoType defaultInfoType = type == ErrorType.ERROR ? HighlightInfoType.ERROR : type == ErrorType.WARNING ? HighlightInfoType.WARNING : HighlightInfoType.WEAK_WARNING;
diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java
index b945ca3..a57464b 100644
--- a/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java
+++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java
@@ -65,7 +65,7 @@
}
@Nullable
- private static ZenCodingNode parse(@NotNull String text,
+ public static ZenCodingNode parse(@NotNull String text,
@NotNull CustomTemplateCallback callback,
@NotNull ZenCodingGenerator generator, @Nullable String surroundedText) {
List<ZenCodingToken> tokens = new EmmetLexer().lex(text);
@@ -154,12 +154,14 @@
}
- private static void expand(String key,
+ public static void expand(String key,
@NotNull CustomTemplateCallback callback,
String surroundedText,
@NotNull ZenCodingGenerator defaultGenerator) {
ZenCodingNode node = parse(key, callback, defaultGenerator, surroundedText);
- assert node != null;
+ if (node == null) {
+ return;
+ }
if (surroundedText == null) {
if (node instanceof TemplateNode) {
if (key.equals(((TemplateNode)node).getTemplateToken().getKey()) &&
diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/tokens/TemplateToken.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/tokens/TemplateToken.java
index 25a4c5b..c64946d 100644
--- a/xml/impl/src/com/intellij/codeInsight/template/emmet/tokens/TemplateToken.java
+++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/tokens/TemplateToken.java
@@ -17,7 +17,6 @@
import com.intellij.codeInsight.template.CustomTemplateCallback;
import com.intellij.codeInsight.template.impl.TemplateImpl;
-import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.undo.UndoConstants;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.util.Pair;
@@ -25,7 +24,6 @@
import com.intellij.psi.PsiFileFactory;
import com.intellij.psi.XmlElementFactory;
import com.intellij.psi.xml.XmlAttribute;
-import com.intellij.psi.xml.XmlDocument;
import com.intellij.psi.xml.XmlFile;
import com.intellij.psi.xml.XmlTag;
import com.intellij.util.ArrayUtil;
@@ -76,22 +74,12 @@
public boolean setTemplate(TemplateImpl template, CustomTemplateCallback callback) {
myTemplate = template;
- final XmlFile xmlFile = parseXmlFileInTemplate(template.getString(), callback, true);
+ final XmlFile xmlFile = parseXmlFileInTemplate(template, callback, getAttribute2Value());
setFile(xmlFile);
- XmlDocument document = xmlFile.getDocument();
- final XmlTag tag = document != null ? document.getRootTag() : null;
+ final XmlTag tag = xmlFile.getRootTag();
if (getAttribute2Value().size() > 0 && tag == null) {
return false;
}
- if (tag != null) {
- if (!containsAttrsVar(template) && getAttribute2Value().size() > 0) {
- ApplicationManager.getApplication().runWriteAction(new Runnable() {
- public void run() {
- addMissingAttributes(tag, getAttribute2Value());
- }
- });
- }
- }
return true;
}
@@ -107,9 +95,22 @@
}
@NotNull
- private static XmlFile parseXmlFileInTemplate(String templateString, CustomTemplateCallback callback, boolean createPhysicalFile) {
- XmlFile xmlFile = (XmlFile)PsiFileFactory.getInstance(callback.getProject())
- .createFileFromText("dummy.xml", StdFileTypes.XML, templateString, LocalTimeCounter.currentTime(), createPhysicalFile);
+ private static XmlFile parseXmlFileInTemplate(TemplateImpl template,
+ CustomTemplateCallback callback,
+ List<Pair<String, String>> attributes) {
+ XmlTag dummyRootTag = null;
+ String templateString = template.getString();
+ final PsiFileFactory psiFileFactory = PsiFileFactory.getInstance(callback.getProject());
+ if (!containsAttrsVar(template)) {
+ XmlFile dummyFile = (XmlFile)psiFileFactory.createFileFromText("dummy.xml", StdFileTypes.XML, templateString);
+ dummyRootTag = dummyFile.getRootTag();
+ if (dummyRootTag != null) {
+ addMissingAttributes(dummyRootTag, attributes);
+ }
+ }
+
+ templateString = dummyRootTag != null ? dummyRootTag.getContainingFile().getText() : templateString;
+ XmlFile xmlFile = (XmlFile)psiFileFactory.createFileFromText("dummy.xml", StdFileTypes.XML, templateString, LocalTimeCounter.currentTime(), true);
VirtualFile vFile = xmlFile.getVirtualFile();
if (vFile != null) {
vFile.putUserData(UndoConstants.DONT_RECORD_UNDO, Boolean.TRUE);
diff --git a/xml/impl/src/com/intellij/ide/browsers/OpenFileInBrowserAction.java b/xml/impl/src/com/intellij/ide/browsers/OpenFileInBrowserAction.java
index 130fd1f..969e7f8 100644
--- a/xml/impl/src/com/intellij/ide/browsers/OpenFileInBrowserAction.java
+++ b/xml/impl/src/com/intellij/ide/browsers/OpenFileInBrowserAction.java
@@ -25,6 +25,7 @@
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Pair;
import com.intellij.psi.PsiFile;
+import com.intellij.testFramework.LightVirtualFile;
import com.intellij.xml.XmlBundle;
import com.intellij.xml.util.HtmlUtil;
@@ -39,48 +40,59 @@
final PsiFile file = LangDataKeys.PSI_FILE.getData(dataContext);
final Presentation presentation = e.getPresentation();
- if (file != null && file.getVirtualFile() != null) {
- presentation.setVisible(true);
+ if (file == null || file.getVirtualFile() == null) {
+ presentation.setVisible(false);
+ presentation.setEnabled(false);
+ return;
+ }
- Pair<WebBrowserUrlProvider, Url> browserUrlProvider = WebBrowserServiceImpl.getProvider(file);
- final boolean isHtmlFile = HtmlUtil.isHtmlFile(file);
- presentation.setEnabled(browserUrlProvider != null || isHtmlFile);
-
- String text = getTemplatePresentation().getText();
- String description = getTemplatePresentation().getDescription();
-
- if (browserUrlProvider != null) {
- final String customText = browserUrlProvider.first.getOpenInBrowserActionText(file);
- if (customText != null) {
- text = customText;
- }
- final String customDescription = browserUrlProvider.first.getOpenInBrowserActionDescription(file);
- if (customDescription != null) {
- description = customDescription;
- }
- if (isHtmlFile) {
- description += " (hold Shift to open URL of local file)";
- }
+ Pair<WebBrowserUrlProvider, Url> browserUrlProvider = WebBrowserServiceImpl.getProvider(file);
+ final boolean isHtmlFile = HtmlUtil.isHtmlFile(file);
+ if (browserUrlProvider == null) {
+ if (file.getVirtualFile() instanceof LightVirtualFile) {
+ presentation.setVisible(false);
+ presentation.setEnabled(false);
+ return;
}
-
- presentation.setText(text);
- presentation.setDescription(description);
-
- GeneralSettings settings = GeneralSettings.getInstance();
- if (!settings.isUseDefaultBrowser()) {
- BrowsersConfiguration.BrowserFamily family = BrowsersConfiguration.getInstance().findFamilyByPath(settings.getBrowserPath());
- if (family != null) {
- presentation.setIcon(family.getIcon());
- }
- }
-
- if (ActionPlaces.isPopupPlace(e.getPlace())) {
- presentation.setVisible(presentation.isEnabled());
+ else {
+ presentation.setEnabled(isHtmlFile);
}
}
else {
- presentation.setVisible(false);
- presentation.setEnabled(false);
+ presentation.setEnabled(true);
+ }
+ presentation.setVisible(true);
+
+ String text = getTemplatePresentation().getText();
+ String description = getTemplatePresentation().getDescription();
+
+ if (browserUrlProvider != null) {
+ final String customText = browserUrlProvider.first.getOpenInBrowserActionText(file);
+ if (customText != null) {
+ text = customText;
+ }
+ final String customDescription = browserUrlProvider.first.getOpenInBrowserActionDescription(file);
+ if (customDescription != null) {
+ description = customDescription;
+ }
+ if (isHtmlFile) {
+ description += " (hold Shift to open URL of local file)";
+ }
+ }
+
+ presentation.setText(text);
+ presentation.setDescription(description);
+
+ GeneralSettings settings = GeneralSettings.getInstance();
+ if (!settings.isUseDefaultBrowser()) {
+ BrowsersConfiguration.BrowserFamily family = BrowsersConfiguration.getInstance().findFamilyByPath(settings.getBrowserPath());
+ if (family != null) {
+ presentation.setIcon(family.getIcon());
+ }
+ }
+
+ if (ActionPlaces.isPopupPlace(e.getPlace())) {
+ presentation.setVisible(presentation.isEnabled());
}
}
diff --git a/xml/impl/src/com/intellij/ide/browsers/OpenUrlHyperlinkInfo.java b/xml/impl/src/com/intellij/ide/browsers/OpenUrlHyperlinkInfo.java
index fe8fe06..79ce4a5 100644
--- a/xml/impl/src/com/intellij/ide/browsers/OpenUrlHyperlinkInfo.java
+++ b/xml/impl/src/com/intellij/ide/browsers/OpenUrlHyperlinkInfo.java
@@ -24,6 +24,7 @@
import com.intellij.openapi.ide.CopyPasteManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Condition;
+import com.intellij.openapi.util.Conditions;
import com.intellij.util.PlatformIcons;
import org.jetbrains.annotations.NotNull;
@@ -34,11 +35,11 @@
* @author nik
*/
public class OpenUrlHyperlinkInfo implements HyperlinkWithPopupMenuInfo {
- private String myUrl;
+ private final String myUrl;
private final Condition<BrowsersConfiguration.BrowserFamily> mySuitableBrowsers;
public OpenUrlHyperlinkInfo(@NotNull String url) {
- this(url, Condition.TRUE);
+ this(url, Conditions.<BrowsersConfiguration.BrowserFamily>alwaysTrue());
}
public OpenUrlHyperlinkInfo(@NotNull String url, @NotNull Condition<BrowsersConfiguration.BrowserFamily> suitableBrowsers) {
diff --git a/xml/impl/src/com/intellij/ide/browsers/UrlImpl.java b/xml/impl/src/com/intellij/ide/browsers/UrlImpl.java
index c89c6c5..05fa403 100644
--- a/xml/impl/src/com/intellij/ide/browsers/UrlImpl.java
+++ b/xml/impl/src/com/intellij/ide/browsers/UrlImpl.java
@@ -13,6 +13,7 @@
public final class UrlImpl implements Url {
private String raw;
+
private final String scheme;
private final String authority;
@@ -21,6 +22,8 @@
private final String parameters;
+ private String externalFormWithoutParameters;
+
public UrlImpl(@Nullable String raw, @NotNull String scheme, @Nullable String authority, @Nullable String path, @Nullable String parameters) {
this.raw = raw;
this.scheme = scheme;
@@ -85,28 +88,41 @@
@Override
@NotNull
public String toExternalForm(boolean skipQueryAndFragment) {
- if (raw != null && (parameters == null || !skipQueryAndFragment)) {
- return raw;
+ if (parameters == null || !skipQueryAndFragment) {
+ if (raw != null) {
+ return raw;
+ }
+ }
+ else if (externalFormWithoutParameters != null) {
+ return externalFormWithoutParameters;
}
+ String result;
try {
String externalPath = path;
boolean inLocalFileSystem = isInLocalFileSystem();
if (inLocalFileSystem && SystemInfo.isWindows && externalPath.charAt(0) != '/') {
externalPath = '/' + externalPath;
}
- String result = new URI(scheme, inLocalFileSystem ? "" : authority, externalPath, null, null).toASCIIString();
- if (!skipQueryAndFragment) {
- if (parameters != null) {
- result += parameters;
- }
- raw = result;
- }
- return result;
+ result = new URI(scheme, inLocalFileSystem ? "" : authority, externalPath, null, null).toASCIIString();
}
catch (URISyntaxException e) {
throw new RuntimeException(e);
}
+
+ if (skipQueryAndFragment) {
+ externalFormWithoutParameters = result;
+ if (parameters == null) {
+ raw = externalFormWithoutParameters;
+ }
+ }
+ else {
+ if (parameters != null) {
+ result += parameters;
+ }
+ raw = result;
+ }
+ return result;
}
@NotNull
diff --git a/xml/impl/src/com/intellij/ide/browsers/Urls.java b/xml/impl/src/com/intellij/ide/browsers/Urls.java
index f6aa46e..a7e1306 100644
--- a/xml/impl/src/com/intellij/ide/browsers/Urls.java
+++ b/xml/impl/src/com/intellij/ide/browsers/Urls.java
@@ -2,6 +2,7 @@
import com.google.common.base.CharMatcher;
import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.StandardFileSystems;
import com.intellij.openapi.vfs.VfsUtil;
@@ -40,15 +41,32 @@
}
@Nullable
- private static Url parseUrl(String url, boolean urlAsRaw) {
- Matcher matcher = URI_PATTERN.matcher(url);
+ private static Url parseUrl(@NotNull String url, boolean urlAsRaw) {
+ String urlToParse;
+ if (url.startsWith("jar:file://")) {
+ urlToParse = url.substring("jar:".length());
+ }
+ else {
+ urlToParse = url;
+ }
+
+ Matcher matcher = URI_PATTERN.matcher(urlToParse);
if (!matcher.matches()) {
LOG.warn("Cannot parse url " + url);
return null;
}
String scheme = matcher.group(1);
+ if (urlToParse != url) {
+ scheme = "jar:" + scheme;
+ }
+
String authority = StringUtil.nullize(matcher.group(2));
+
String path = StringUtil.nullize(matcher.group(3));
+ if (path != null) {
+ path = FileUtil.toCanonicalUriPath(path);
+ }
+
String parameters = matcher.group(4);
if (authority != null && StandardFileSystems.FILE_PROTOCOL.equals(scheme)) {
path = path == null ? authority : (authority + path);
diff --git a/xml/impl/src/com/intellij/ide/browsers/impl/WebBrowserServiceImpl.java b/xml/impl/src/com/intellij/ide/browsers/impl/WebBrowserServiceImpl.java
index bb477c2..bee53af 100644
--- a/xml/impl/src/com/intellij/ide/browsers/impl/WebBrowserServiceImpl.java
+++ b/xml/impl/src/com/intellij/ide/browsers/impl/WebBrowserServiceImpl.java
@@ -26,6 +26,7 @@
import com.intellij.openapi.vfs.impl.http.HttpVirtualFile;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
+import com.intellij.testFramework.LightVirtualFile;
import com.intellij.xml.util.HtmlUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -36,9 +37,10 @@
public class WebBrowserServiceImpl extends WebBrowserService {
@Override
public boolean canOpenInBrowser(@NotNull PsiElement psiElement) {
- final PsiFile psiFile = psiElement instanceof PsiFile ? (PsiFile)psiElement : psiElement.getContainingFile();
- return psiFile != null && psiFile.getVirtualFile() != null &&
- (HtmlUtil.isHtmlFile(psiFile) || getProvider(psiElement) != null);
+ PsiFile psiFile = psiElement instanceof PsiFile ? (PsiFile)psiElement : psiElement.getContainingFile();
+ VirtualFile virtualFile = psiFile == null ? null : psiFile.getVirtualFile();
+ return virtualFile != null &&
+ ((HtmlUtil.isHtmlFile(psiFile) && !(virtualFile instanceof LightVirtualFile)) || getProvider(psiElement, psiFile) != null);
}
@Override
@@ -76,7 +78,7 @@
}
}
}
- return Urls.newFromVirtualFile(virtualFile);
+ return virtualFile instanceof LightVirtualFile ? null : Urls.newFromVirtualFile(virtualFile);
}
@Override
@@ -93,10 +95,10 @@
@Nullable
public static Pair<WebBrowserUrlProvider, Url> getProvider(@Nullable PsiElement element) {
PsiFile psiFile = element == null ? null : element.getContainingFile();
- if (psiFile == null) {
- return null;
- }
+ return psiFile == null ? null : getProvider(element, psiFile);
+ }
+ private static Pair<WebBrowserUrlProvider, Url> getProvider(PsiElement element, PsiFile psiFile) {
Ref<Url> result = Ref.create();
List<WebBrowserUrlProvider> allProviders = Arrays.asList(WebBrowserUrlProvider.EP_NAME.getExtensions());
for (WebBrowserUrlProvider urlProvider : DumbService.getInstance(element.getProject()).filterByDumbAwareness(allProviders)) {
diff --git a/xml/impl/src/com/intellij/ide/structureView/impl/xml/XmlStructureViewTreeModel.java b/xml/impl/src/com/intellij/ide/structureView/impl/xml/XmlStructureViewTreeModel.java
index 71212d1..19408e7 100644
--- a/xml/impl/src/com/intellij/ide/structureView/impl/xml/XmlStructureViewTreeModel.java
+++ b/xml/impl/src/com/intellij/ide/structureView/impl/xml/XmlStructureViewTreeModel.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -21,48 +21,51 @@
import com.intellij.ide.structureView.TextEditorBasedStructureViewModel;
import com.intellij.ide.util.treeView.smartTree.Sorter;
import com.intellij.lang.dtd.DTDLanguage;
+import com.intellij.openapi.editor.Editor;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.xml.*;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
-import java.util.Collection;
-
-public class XmlStructureViewTreeModel extends TextEditorBasedStructureViewModel{
+public class XmlStructureViewTreeModel extends TextEditorBasedStructureViewModel {
private final XmlFile myFile;
private static final Class[] myClasses = new Class[]{XmlTag.class, XmlFile.class, XmlEntityDecl.class, XmlElementDecl.class, XmlAttlistDecl.class, XmlConditionalSection.class};
private static final Sorter[] mySorters = {Sorter.ALPHA_SORTER};
- public XmlStructureViewTreeModel(XmlFile file) {
- super(file);
+ public XmlStructureViewTreeModel(XmlFile file, @Nullable Editor editor) {
+ super(editor, file);
myFile = file;
}
+ @Override
@NotNull
public StructureViewTreeElement getRoot() {
if (myFile.getLanguage() == DTDLanguage.INSTANCE) return new DtdFileTreeElement(myFile);
return new XmlFileTreeElement(myFile);
}
+ @Override
public boolean shouldEnterElement(final Object element) {
return element instanceof XmlTag && ((XmlTag)element).getSubTags().length > 0;
}
+ @Override
protected PsiFile getPsiFile() {
return myFile;
}
+ @Override
@NotNull
protected Class[] getSuitableClasses() {
return myClasses;
}
+ @Override
public Object getCurrentEditorElement() {
final Object editorElement = super.getCurrentEditorElement();
if (editorElement instanceof XmlTag) {
- final Collection<StructureViewExtension> structureViewExtensions =
- StructureViewFactoryEx.getInstanceEx(myFile.getProject()).getAllExtensions(XmlTag.class);
- for(StructureViewExtension extension:structureViewExtensions) {
+ for (StructureViewExtension extension : StructureViewFactoryEx.getInstanceEx(myFile.getProject()).getAllExtensions(XmlTag.class)) {
final Object element = extension.getCurrentEditorElement(getEditor(), (PsiElement)editorElement);
if (element != null) return element;
}
@@ -70,8 +73,9 @@
return editorElement;
}
+ @Override
@NotNull
public Sorter[] getSorters() {
return mySorters;
}
-}
+}
\ No newline at end of file
diff --git a/xml/impl/src/com/intellij/ide/structureView/impl/xml/XmlTagTreeElement.java b/xml/impl/src/com/intellij/ide/structureView/impl/xml/XmlTagTreeElement.java
index a2ecfd7..ee75742 100644
--- a/xml/impl/src/com/intellij/ide/structureView/impl/xml/XmlTagTreeElement.java
+++ b/xml/impl/src/com/intellij/ide/structureView/impl/xml/XmlTagTreeElement.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -15,6 +15,7 @@
*/
package com.intellij.ide.structureView.impl.xml;
+import com.intellij.ide.IdeBundle;
import com.intellij.ide.structureView.StructureViewTreeElement;
import com.intellij.psi.xml.XmlAttribute;
import com.intellij.psi.xml.XmlTag;
@@ -32,33 +33,38 @@
super(tag);
}
+ @Override
@NotNull
public Collection<StructureViewTreeElement> getChildrenBase() {
return getStructureViewTreeElements(getElement().getSubTags());
}
+ @Override
public String getPresentableText() {
final XmlTag element = getElement();
- if (element == null) return "*invalid*";
+ if (element == null) {
+ return IdeBundle.message("node.structureview.invalid");
+ }
String id = element.getAttributeValue(ID_ATTR_NAME);
- if (id == null) id = element.getAttributeValue(NAME_ATTR_NAME);
- id = toCanonicalForm(id);
-
- if (id != null) return id + ":" + element.getLocalName();
- return element.getName();
- }
-
- public String getLocationString() {
- final StringBuffer buffer = new StringBuffer();
- final XmlTag element = getElement();
- final XmlAttribute[] attributes = element.getAttributes();
-
- String id = element.getAttributeValue(ID_ATTR_NAME);
- String usedAttrName = null;
-
if (id == null) {
id = element.getAttributeValue(NAME_ATTR_NAME);
- if (id != null) usedAttrName = NAME_ATTR_NAME;
+ }
+ id = toCanonicalForm(id);
+ return id != null ? id + ':' + element.getLocalName() : element.getName();
+ }
+
+ @Override
+ public String getLocationString() {
+ final StringBuilder buffer = new StringBuilder();
+ final XmlTag element = getElement();
+ assert element != null;
+ String id = element.getAttributeValue(ID_ATTR_NAME);
+ String usedAttrName = null;
+ if (id == null) {
+ id = element.getAttributeValue(NAME_ATTR_NAME);
+ if (id != null) {
+ usedAttrName = NAME_ATTR_NAME;
+ }
}
else {
usedAttrName = ID_ATTR_NAME;
@@ -66,24 +72,18 @@
id = toCanonicalForm(id);
- for (XmlAttribute attribute : attributes) {
+ for (XmlAttribute attribute : element.getAttributes()) {
if (buffer.length() != 0) {
- buffer.append(" ");
+ buffer.append(' ');
}
final String name = attribute.getName();
- if (usedAttrName != null &&
- id != null &&
- usedAttrName.equals(name)
- ) {
+ if (usedAttrName != null && id != null && usedAttrName.equals(name)) {
continue; // we output this name in name
}
buffer.append(name);
- buffer.append("=");
- buffer.append("\"");
- buffer.append(attribute.getValue());
- buffer.append("\"");
+ buffer.append('=').append('"').append(attribute.getValue()).append('"');
}
return buffer.toString();
}
@@ -92,8 +92,10 @@
public static String toCanonicalForm(@Nullable String id) {
if (id != null) {
id = id.trim();
- if (id.length() == 0) id = null;
+ if (id.isEmpty()) {
+ return null;
+ }
}
return id;
}
-}
+}
\ No newline at end of file
diff --git a/xml/impl/src/com/intellij/ide/util/treeView/XmlDoctypeNodeDescriptor.java b/xml/impl/src/com/intellij/ide/util/treeView/XmlDoctypeNodeDescriptor.java
index ea771e3..a6255af 100644
--- a/xml/impl/src/com/intellij/ide/util/treeView/XmlDoctypeNodeDescriptor.java
+++ b/xml/impl/src/com/intellij/ide/util/treeView/XmlDoctypeNodeDescriptor.java
@@ -17,12 +17,13 @@
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
+import org.jetbrains.annotations.NotNull;
/**
* @author Mike
*/
public class XmlDoctypeNodeDescriptor extends SmartElementDescriptor {
- public XmlDoctypeNodeDescriptor(Project project, NodeDescriptor parentDescriptor, PsiElement element) {
+ public XmlDoctypeNodeDescriptor(@NotNull Project project, NodeDescriptor parentDescriptor, PsiElement element) {
super(project, parentDescriptor, element);
//noinspection HardCodedStringLiteral
myName = "DOCTYPE";
diff --git a/xml/impl/src/com/intellij/javaee/ExternalResourceManagerImpl.java b/xml/impl/src/com/intellij/javaee/ExternalResourceManagerImpl.java
index cd97d26..8606e11 100644
--- a/xml/impl/src/com/intellij/javaee/ExternalResourceManagerImpl.java
+++ b/xml/impl/src/com/intellij/javaee/ExternalResourceManagerImpl.java
@@ -16,570 +16,28 @@
package com.intellij.javaee;
import com.intellij.application.options.PathMacrosImpl;
-import com.intellij.application.options.ReplacePathToMacroMap;
-import com.intellij.openapi.Disposable;
-import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.components.*;
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.extensions.Extensions;
-import com.intellij.openapi.fileTypes.FileType;
+import com.intellij.openapi.components.ServiceManager;
+import com.intellij.openapi.components.State;
+import com.intellij.openapi.components.Storage;
+import com.intellij.openapi.components.StoragePathMacros;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.*;
-import com.intellij.openapi.util.io.FileUtil;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.psi.PsiFile;
-import com.intellij.psi.xml.XmlFile;
-import com.intellij.util.ArrayUtil;
-import com.intellij.util.containers.ContainerUtil;
-import com.intellij.util.containers.HashMap;
-import com.intellij.xml.Html5SchemaProvider;
-import com.intellij.xml.XmlSchemaProvider;
-import com.intellij.xml.util.XmlUtil;
-import org.jdom.Element;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.jetbrains.annotations.TestOnly;
-
-import java.io.File;
-import java.net.URL;
-import java.util.*;
+import com.intellij.openapi.util.JDOMExternalizable;
+import com.intellij.openapi.util.NotNullLazyKey;
/**
* @author mike
*/
@State(name = "ExternalResourceManagerImpl",
storages = {@Storage( file = StoragePathMacros.APP_CONFIG + "/other.xml")})
-public class ExternalResourceManagerImpl extends ExternalResourceManagerEx implements JDOMExternalizable {
- static final Logger LOG = Logger.getInstance("#com.intellij.j2ee.openapi.impl.ExternalResourceManagerImpl");
-
- @NonNls public static final String J2EE_1_3 = "http://java.sun.com/dtd/";
- @NonNls public static final String J2EE_1_2 = "http://java.sun.com/j2ee/dtds/";
- @NonNls public static final String J2EE_NS = "http://java.sun.com/xml/ns/j2ee/";
- @NonNls public static final String JAVAEE_NS = "http://java.sun.com/xml/ns/javaee/";
- private static final String CATALOG_PROPERTIES_ELEMENT = "CATALOG_PROPERTIES";
-
-
- private final Map<String, Map<String, String>> myResources = new HashMap<String, Map<String, String>>();
- private final Set<String> myResourceLocations = new HashSet<String>();
-
- private final Set<String> myIgnoredResources = new HashSet<String>();
-
- private final AtomicNotNullLazyValue<Map<String, Map<String, Resource>>> myStdResources = new AtomicNotNullLazyValue<Map<String, Map<String, Resource>>>() {
-
- @NotNull
- @Override
- protected Map<String, Map<String, Resource>> compute() {
- return computeStdResources();
- }
- };
-
- private String myDefaultHtmlDoctype = HTML5_DOCTYPE_ELEMENT;
-
- private String myCatalogPropertiesFile;
- private XMLCatalogManager myCatalogManager;
- private static final String HTML5_DOCTYPE_ELEMENT = "HTML5";
-
- protected Map<String, Map<String, Resource>> computeStdResources() {
- ResourceRegistrarImpl registrar = new ResourceRegistrarImpl();
- for (StandardResourceProvider provider : Extensions.getExtensions(StandardResourceProvider.EP_NAME)) {
- provider.registerResources(registrar);
- }
- StandardResourceEP[] extensions = Extensions.getExtensions(StandardResourceEP.EP_NAME);
- for (StandardResourceEP extension : extensions) {
- registrar.addStdResource(extension.url, extension.version, extension.resourcePath, null, extension.getLoaderForClass());
- }
-
- myIgnoredResources.addAll(registrar.getIgnored());
- return registrar.getResources();
- }
-
- private final List<ExternalResourceListener> myListeners = ContainerUtil.createLockFreeCopyOnWriteList();
- private long myModificationCount = 0;
- private final PathMacrosImpl myPathMacros;
- @NonNls private static final String RESOURCE_ELEMENT = "resource";
- @NonNls private static final String URL_ATTR = "url";
- @NonNls private static final String LOCATION_ATTR = "location";
- @NonNls private static final String IGNORED_RESOURCE_ELEMENT = "ignored-resource";
- @NonNls private static final String HTML_DEFAULT_DOCTYPE_ELEMENT = "default-html-doctype";
- private static final String DEFAULT_VERSION = null;
-
+public class ExternalResourceManagerImpl extends ExternalResourceManagerExImpl implements JDOMExternalizable {
public ExternalResourceManagerImpl(PathMacrosImpl pathMacros) {
- myPathMacros = pathMacros;
+ super(pathMacros);
}
- public boolean isStandardResource(VirtualFile file) {
- VirtualFile parent = file.getParent();
- return parent != null && parent.getName().equals("standardSchemas");
- }
-
- @Override
- public boolean isUserResource(VirtualFile file) {
- return myResourceLocations.contains(file.getUrl());
- }
-
- @Nullable
- static <T> Map<String, T> getMap(@NotNull final Map<String, Map<String, T>> resources,
- @Nullable final String version,
- final boolean create) {
- Map<String, T> map = resources.get(version);
- if (map == null) {
- if (create) {
- map = ContainerUtil.newHashMap();
- resources.put(version, map);
- }
- else if (version == null || !version.equals(DEFAULT_VERSION)) {
- map = resources.get(DEFAULT_VERSION);
- }
- }
-
- return map;
- }
-
- public String getResourceLocation(String url) {
- return getResourceLocation(url, DEFAULT_VERSION);
- }
-
- public String getResourceLocation(@NonNls String url, String version) {
- String result = getUserResource(url, version);
- if (result == null) {
- XMLCatalogManager manager = getCatalogManager();
- if (manager != null) {
- result = manager.resolve(url);
- }
- }
- if (result == null) {
- result = getStdResource(url, version);
- }
- if (result == null) {
- result = url;
- }
- return result;
- }
-
- @Override
- @Nullable
- public String getUserResource(Project project, String url, String version) {
- String resource = getProjectResources(project).getUserResource(url, version);
- return resource == null ? getUserResource(url, version) : resource;
- }
-
- @Override
- @Nullable
- public String getStdResource(String url, String version) {
- Map<String, Resource> map = getMap(myStdResources.getValue(), version, false);
- if (map != null) {
- Resource resource = map.get(url);
- return resource == null ? null : resource.getResourceUrl();
- }
- else {
- return null;
- }
- }
-
- @Nullable
- private String getUserResource(String url, String version) {
- Map<String, String> map = getMap(myResources, version, false);
- return map != null ? map.get(url) : null;
- }
-
- public String getResourceLocation(@NonNls String url, @NotNull Project project) {
- String location = getProjectResources(project).getResourceLocation(url);
- return location == null || location.equals(url) ? getResourceLocation(url) : location;
- }
-
- public String getResourceLocation(@NonNls String url, String version, @NotNull Project project) {
- String location = getProjectResources(project).getResourceLocation(url, version);
- return location == null || location.equals(url) ? getResourceLocation(url, version) : location;
- }
-
- @Nullable
- public PsiFile getResourceLocation(@NotNull @NonNls final String url, @NotNull final PsiFile baseFile, final String version) {
- final XmlFile schema = XmlSchemaProvider.findSchema(url, baseFile);
- if (schema != null) {
- return schema;
- }
- final String location = getResourceLocation(url, version, baseFile.getProject());
- return XmlUtil.findXmlFile(baseFile, location);
- }
-
- public String[] getResourceUrls(FileType fileType, final boolean includeStandard) {
- return getResourceUrls(fileType, DEFAULT_VERSION, includeStandard);
- }
-
- public String[] getResourceUrls(@Nullable final FileType fileType, @NonNls final String version, final boolean includeStandard) {
- final List<String> result = new LinkedList<String>();
- addResourcesFromMap(result, version, myResources);
-
- if (includeStandard) {
- addResourcesFromMap(result, version, myStdResources.getValue());
- }
-
- return ArrayUtil.toStringArray(result);
- }
-
- private static <T> void addResourcesFromMap(final List<String> result,
- String version,
- Map<String, Map<String, T>> resourcesMap) {
- Map<String, T> resources = getMap(resourcesMap, version, false);
- if (resources == null) return;
- result.addAll(resources.keySet());
- }
-
- @TestOnly
- public static void addTestResource(final String url, final String location, Disposable parentDisposable) {
- final ExternalResourceManagerImpl instance = (ExternalResourceManagerImpl)getInstance();
- ApplicationManager.getApplication().runWriteAction(new Runnable() {
- public void run() {
- instance.addResource(url, location);
- }
- });
- Disposer.register(parentDisposable, new Disposable() {
- @Override
- public void dispose() {
- ApplicationManager.getApplication().runWriteAction(new Runnable() {
- public void run() {
- instance.removeResource(url);
- }
- });
- }
- });
- }
- public void addResource(String url, String location) {
- addResource(url, DEFAULT_VERSION, location);
- }
-
- public void addResource(@NonNls String url, @NonNls String version, @NonNls String location) {
- ApplicationManager.getApplication().assertWriteAccessAllowed();
- addSilently(url, version, location);
- fireExternalResourceChanged();
- }
-
- private void addSilently(String url, String version, String location) {
- final Map<String, String> map = getMap(myResources, version, true);
- assert map != null;
- map.put(url, location);
- myResourceLocations.add(location);
- myModificationCount++;
- }
-
- public void removeResource(String url) {
- removeResource(url, DEFAULT_VERSION);
- }
-
- public void removeResource(String url, String version) {
- ApplicationManager.getApplication().assertWriteAccessAllowed();
- Map<String, String> map = getMap(myResources, version, false);
- if (map != null) {
- String location = map.remove(url);
- if (location != null) {
- myResourceLocations.remove(location);
- }
- myModificationCount++;
- fireExternalResourceChanged();
- }
- }
-
- @Override
- public void removeResource(String url, @NotNull Project project) {
- getProjectResources(project).removeResource(url);
- }
-
- @Override
- public void addResource(@NonNls String url, @NonNls String location, @NotNull Project project) {
- getProjectResources(project).addResource(url, location);
- }
-
- public String[] getAvailableUrls() {
- Set<String> urls = new HashSet<String>();
- for (Map<String, String> map : myResources.values()) {
- urls.addAll(map.keySet());
- }
- return ArrayUtil.toStringArray(urls);
- }
-
- @Override
- public String[] getAvailableUrls(Project project) {
- return getProjectResources(project).getAvailableUrls();
- }
-
- public void clearAllResources() {
- myResources.clear();
- myIgnoredResources.clear();
- }
-
- public void clearAllResources(Project project) {
- ApplicationManager.getApplication().assertWriteAccessAllowed();
- clearAllResources();
- getProjectResources(project).clearAllResources();
- myModificationCount++;
- fireExternalResourceChanged();
- }
-
- public void addIgnoredResource(String url) {
- ApplicationManager.getApplication().assertWriteAccessAllowed();
- addIgnoredSilently(url);
- fireExternalResourceChanged();
- }
-
- private void addIgnoredSilently(String url) {
- myIgnoredResources.add(url);
- myModificationCount++;
- }
-
- public void removeIgnoredResource(String url) {
- ApplicationManager.getApplication().assertWriteAccessAllowed();
- if (myIgnoredResources.remove(url)) {
- myModificationCount++;
- fireExternalResourceChanged();
- }
- }
-
- public boolean isIgnoredResource(String url) {
- myStdResources.getValue(); // ensure ignored resources are loaded
- return myIgnoredResources.contains(url) || isImplicitNamespaceDescriptor(url);
- }
-
- private static boolean isImplicitNamespaceDescriptor(String url) {
- for (ImplicitNamespaceDescriptorProvider namespaceDescriptorProvider : Extensions
- .getExtensions(ImplicitNamespaceDescriptorProvider.EP_NAME)) {
- if (namespaceDescriptorProvider.getNamespaceDescriptor(null, url, null) != null) return true;
- }
- return false;
- }
-
- public String[] getIgnoredResources() {
- myStdResources.getValue(); // ensure ignored resources are loaded
- return ArrayUtil.toStringArray(myIgnoredResources);
- }
-
- public long getModificationCount() {
- return myModificationCount;
- }
-
- @Override
- public long getModificationCount(@NotNull Project project) {
- return getProjectResources(project).getModificationCount();
- }
-
- public void readExternal(Element element) throws InvalidDataException {
- final ExpandMacroToPathMap macroExpands = new ExpandMacroToPathMap();
- myPathMacros.addMacroExpands(macroExpands);
- macroExpands.substitute(element, SystemInfo.isFileSystemCaseSensitive);
-
- myModificationCount++;
- for (final Object o1 : element.getChildren(RESOURCE_ELEMENT)) {
- Element e = (Element)o1;
- addSilently(e.getAttributeValue(URL_ATTR), DEFAULT_VERSION, e.getAttributeValue(LOCATION_ATTR).replace('/', File.separatorChar));
- }
-
- for (final Object o : element.getChildren(IGNORED_RESOURCE_ELEMENT)) {
- Element e = (Element)o;
- addIgnoredSilently(e.getAttributeValue(URL_ATTR));
- }
-
- Element child = element.getChild(HTML_DEFAULT_DOCTYPE_ELEMENT);
- if (child != null) {
- String text = child.getText();
- if (FileUtil.toSystemIndependentName(text).endsWith(".jar!/resources/html5-schema/html5.rnc")) {
- text = HTML5_DOCTYPE_ELEMENT;
- }
- myDefaultHtmlDoctype = text;
- }
- Element catalogElement = element.getChild(CATALOG_PROPERTIES_ELEMENT);
- if (catalogElement != null) {
- myCatalogPropertiesFile = catalogElement.getTextTrim();
- }
- }
-
- public void writeExternal(Element element) throws WriteExternalException {
- final String[] urls = getAvailableUrls();
- for (String url : urls) {
- if (url == null) continue;
- String location = getResourceLocation(url);
- if (location == null) continue;
- final Element e = new Element(RESOURCE_ELEMENT);
-
- e.setAttribute(URL_ATTR, url);
- e.setAttribute(LOCATION_ATTR, location.replace(File.separatorChar, '/'));
- element.addContent(e);
- }
-
- final String[] ignoredResources = getIgnoredResources();
- for (String ignoredResource : ignoredResources) {
- final Element e = new Element(IGNORED_RESOURCE_ELEMENT);
-
- e.setAttribute(URL_ATTR, ignoredResource);
- element.addContent(e);
- }
-
- if (myDefaultHtmlDoctype != null && !HTML5_DOCTYPE_ELEMENT.equals(myDefaultHtmlDoctype)) {
- final Element e = new Element(HTML_DEFAULT_DOCTYPE_ELEMENT);
- e.setText(myDefaultHtmlDoctype);
- element.addContent(e);
- }
- if (myCatalogPropertiesFile != null) {
- Element properties = new Element(CATALOG_PROPERTIES_ELEMENT);
- properties.setText(myCatalogPropertiesFile);
- element.addContent(properties);
- }
- final ReplacePathToMacroMap macroReplacements = new ReplacePathToMacroMap();
- PathMacrosImpl.getInstanceEx().addMacroReplacements(macroReplacements);
- macroReplacements.substitute(element, SystemInfo.isFileSystemCaseSensitive);
- }
-
- public void addExternalResourceListener(ExternalResourceListener listener) {
- myListeners.add(listener);
- }
-
- public void removeExternalResourceListener(ExternalResourceListener listener) {
- myListeners.remove(listener);
- }
-
- private void fireExternalResourceChanged() {
- for (ExternalResourceListener listener : myListeners) {
- listener.externalResourceChanged();
- }
- }
-
- Collection<Map<String, Resource>> getStandardResources() {
- return myStdResources.getValue().values();
- }
-
-
private static final NotNullLazyKey<ProjectResources, Project> INSTANCE_CACHE = ServiceManager.createLazyKey(ProjectResources.class);
- private static ExternalResourceManagerImpl getProjectResources(Project project) {
+ @Override
+ protected ExternalResourceManagerExImpl getProjectResources(Project project) {
return INSTANCE_CACHE.getValue(project);
}
-
- @Override
- @NotNull
- public String getDefaultHtmlDoctype(@NotNull Project project) {
- final String doctype = getProjectResources(project).myDefaultHtmlDoctype;
- if (XmlUtil.XHTML_URI.equals(doctype)) {
- return XmlUtil.XHTML4_SCHEMA_LOCATION;
- }
- else if (HTML5_DOCTYPE_ELEMENT.equals(doctype)) {
- return Html5SchemaProvider.getHtml5SchemaLocation();
- }
- else {
- return doctype;
- }
- }
-
- @Override
- public void setDefaultHtmlDoctype(@NotNull String defaultHtmlDoctype, @NotNull Project project) {
- getProjectResources(project).setDefaultHtmlDoctype(defaultHtmlDoctype);
- }
-
- @Override
- public String getCatalogPropertiesFile() {
- return myCatalogPropertiesFile;
- }
-
- @Override
- public void setCatalogPropertiesFile(String filePath) {
- myCatalogManager = null;
- myCatalogPropertiesFile = filePath;
- myModificationCount++;
- }
-
- @Nullable
- private XMLCatalogManager getCatalogManager() {
- if (myCatalogManager == null && myCatalogPropertiesFile != null) {
- myCatalogManager = new XMLCatalogManager(myCatalogPropertiesFile);
- }
- return myCatalogManager;
- }
-
- private void setDefaultHtmlDoctype(String defaultHtmlDoctype) {
- myModificationCount++;
-
- if (Html5SchemaProvider.getHtml5SchemaLocation().equals(defaultHtmlDoctype)) {
- myDefaultHtmlDoctype = HTML5_DOCTYPE_ELEMENT;
- }
- else {
- myDefaultHtmlDoctype = defaultHtmlDoctype;
- }
- fireExternalResourceChanged();
- }
-
- @TestOnly
- public static void registerResourceTemporarily(final String url, final String location, Disposable disposable) {
- ApplicationManager.getApplication().runWriteAction(new Runnable() {
- public void run() {
- getInstance().addResource(url, location);
- }
- });
-
- Disposer.register(disposable, new Disposable() {
- @Override
- public void dispose() {
- ApplicationManager.getApplication().runWriteAction(new Runnable() {
- public void run() {
- getInstance().removeResource(url);
- }
- });
- }
- });
- }
-
- static class Resource {
- String file;
- ClassLoader classLoader;
- Class clazz;
-
- @Nullable
- String getResourceUrl() {
-
- if (classLoader == null && clazz == null) return file;
-
- final URL resource = clazz == null ? classLoader.getResource(file) : clazz.getResource(file);
- classLoader = null;
- clazz = null;
- if (resource == null) {
- String message = "Cannot find standard resource. filename:" + file + " class=" + classLoader;
- if (ApplicationManager.getApplication().isUnitTestMode()) {
- LOG.error(message);
- }
- else {
- LOG.warn(message);
- }
-
- return null;
- }
-
- String path = FileUtil.unquote(resource.toString());
- // this is done by FileUtil for windows
- path = path.replace('\\','/');
- file = path;
- return path;
- }
-
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- Resource resource = (Resource)o;
-
- if (classLoader != resource.classLoader) return false;
- if (clazz != resource.clazz) return false;
- if (file != null ? !file.equals(resource.file) : resource.file != null) return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- return file.hashCode();
- }
-
- @Override
- public String toString() {
- return file + " for " + classLoader;
- }
- }
}
diff --git a/xml/impl/src/com/intellij/lang/dtd/DtdStructureViewBuilderFactory.java b/xml/impl/src/com/intellij/lang/dtd/DtdStructureViewBuilderFactory.java
index f88cafe..fcccefe 100644
--- a/xml/impl/src/com/intellij/lang/dtd/DtdStructureViewBuilderFactory.java
+++ b/xml/impl/src/com/intellij/lang/dtd/DtdStructureViewBuilderFactory.java
@@ -24,17 +24,21 @@
import com.intellij.ide.structureView.TreeBasedStructureViewBuilder;
import com.intellij.ide.structureView.impl.xml.XmlStructureViewTreeModel;
import com.intellij.lang.PsiStructureViewFactory;
+import com.intellij.openapi.editor.Editor;
import com.intellij.psi.PsiFile;
import com.intellij.psi.xml.XmlFile;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
public class DtdStructureViewBuilderFactory implements PsiStructureViewFactory {
+ @Override
@NotNull
public StructureViewBuilder getStructureViewBuilder(final PsiFile psiFile) {
return new TreeBasedStructureViewBuilder() {
+ @Override
@NotNull
- public StructureViewModel createStructureViewModel() {
- return new XmlStructureViewTreeModel((XmlFile)psiFile);
+ public StructureViewModel createStructureViewModel(@Nullable Editor editor) {
+ return new XmlStructureViewTreeModel((XmlFile)psiFile, editor);
}
};
}
diff --git a/xml/impl/src/com/intellij/lang/html/structureView/Html5SectionTreeElement.java b/xml/impl/src/com/intellij/lang/html/structureView/Html5SectionTreeElement.java
index d300737..f18222f 100644
--- a/xml/impl/src/com/intellij/lang/html/structureView/Html5SectionTreeElement.java
+++ b/xml/impl/src/com/intellij/lang/html/structureView/Html5SectionTreeElement.java
@@ -37,11 +37,14 @@
myHeader = header;
}
+ @Override
@NotNull
public Collection<StructureViewTreeElement> getChildrenBase() {
return myChildrenComputable.compute();
}
+ @Nullable
+ @Override
public String getPresentableText() {
if (myHeader != null) {
return HtmlTagTreeElement.normalizeSpacesAndShortenIfLong(myHeader);
@@ -51,6 +54,7 @@
return tag == null ? null : HtmlTagTreeElement.normalizeSpacesAndShortenIfLong(tag.getValue().getTrimmedText());
}
+ @Override
public String getLocationString() {
final XmlTag tag = getElement();
if (tag == null) return null;
@@ -58,6 +62,7 @@
return HtmlTagTreeElement.getTagPresentation(tag);
}
+ @Override
public boolean isSearchInLocationString() {
return true;
}
diff --git a/xml/impl/src/com/intellij/lang/html/structureView/Html5SectionsNodeProvider.java b/xml/impl/src/com/intellij/lang/html/structureView/Html5SectionsNodeProvider.java
index a1cbc35..dd3341d 100644
--- a/xml/impl/src/com/intellij/lang/html/structureView/Html5SectionsNodeProvider.java
+++ b/xml/impl/src/com/intellij/lang/html/structureView/Html5SectionsNodeProvider.java
@@ -41,29 +41,35 @@
public static final String ACTION_ID = "HTML5_OUTLINE_MODE";
public static final String HTML5_OUTLINE_PROVIDER_PROPERTY = "html5.sections.node.provider";
+ @Override
@NotNull
public String getName() {
return ACTION_ID;
}
+ @Override
@NotNull
public ActionPresentation getPresentation() {
return new ActionPresentationData(XmlBundle.message("html5.outline.mode"), null, AllIcons.Xml.Html5);
}
+ @Override
public String getCheckBoxText() {
return XmlBundle.message("html5.outline.mode");
}
+ @Override
public Shortcut[] getShortcut() {
return KeymapManager.getInstance().getActiveKeymap().getShortcuts("FileStructurePopup");
}
+ @Override
@NotNull
public String getPropertyName() {
return HTML5_OUTLINE_PROVIDER_PROPERTY;
}
+ @Override
public Collection<Html5SectionTreeElement> provideNodes(final TreeElement node) {
if (!(node instanceof HtmlFileTreeElement)) return Collections.emptyList();
diff --git a/xml/impl/src/com/intellij/lang/html/structureView/HtmlFileTreeElement.java b/xml/impl/src/com/intellij/lang/html/structureView/HtmlFileTreeElement.java
index e819405..39d5d6b 100644
--- a/xml/impl/src/com/intellij/lang/html/structureView/HtmlFileTreeElement.java
+++ b/xml/impl/src/com/intellij/lang/html/structureView/HtmlFileTreeElement.java
@@ -31,7 +31,6 @@
import java.util.*;
class HtmlFileTreeElement extends PsiTreeElementBase<XmlFile> {
-
private final boolean myInStructureViewPopup;
public HtmlFileTreeElement(final boolean inStructureViewPopup, final XmlFile xmlFile) {
@@ -39,6 +38,7 @@
myInStructureViewPopup = inStructureViewPopup;
}
+ @Override
@NotNull
public Collection<StructureViewTreeElement> getChildrenBase() {
if (isHtml5SectionsMode()) {
@@ -71,11 +71,9 @@
}
else {
final Collection<StructureViewTreeElement> result = new ArrayList<StructureViewTreeElement>();
-
for (XmlTag tag : rootTags) {
result.add(new HtmlTagTreeElement(tag));
}
-
return result;
}
}
@@ -97,8 +95,9 @@
return false;
}
+ @Override
@Nullable
public String getPresentableText() {
return toString(); // root element is not visible
}
-}
+}
\ No newline at end of file
diff --git a/xml/impl/src/com/intellij/lang/html/structureView/HtmlStructureViewBuilderProvider.java b/xml/impl/src/com/intellij/lang/html/structureView/HtmlStructureViewBuilderProvider.java
index 3243fe7..9a8741d 100644
--- a/xml/impl/src/com/intellij/lang/html/structureView/HtmlStructureViewBuilderProvider.java
+++ b/xml/impl/src/com/intellij/lang/html/structureView/HtmlStructureViewBuilderProvider.java
@@ -20,24 +20,28 @@
import com.intellij.ide.structureView.StructureViewModel;
import com.intellij.ide.structureView.TreeBasedStructureViewBuilder;
import com.intellij.ide.structureView.xml.XmlStructureViewBuilderProvider;
+import com.intellij.openapi.editor.Editor;
import com.intellij.psi.xml.XmlFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class HtmlStructureViewBuilderProvider implements XmlStructureViewBuilderProvider {
+ @Override
@Nullable
public StructureViewBuilder createStructureViewBuilder(@NotNull final XmlFile file) {
if (file.getViewProvider().getVirtualFile().getFileType() != HtmlFileType.INSTANCE) return null;
return new TreeBasedStructureViewBuilder() {
+ @Override
public boolean isRootNodeShown() {
return false;
}
+ @Override
@NotNull
- public StructureViewModel createStructureViewModel() {
- return new HtmlStructureViewTreeModel(file);
+ public StructureViewModel createStructureViewModel(@Nullable Editor editor) {
+ return new HtmlStructureViewTreeModel(file, editor);
}
};
}
-}
+}
\ No newline at end of file
diff --git a/xml/impl/src/com/intellij/lang/html/structureView/HtmlStructureViewTreeModel.java b/xml/impl/src/com/intellij/lang/html/structureView/HtmlStructureViewTreeModel.java
index 230a89a..f2bc5c1 100644
--- a/xml/impl/src/com/intellij/lang/html/structureView/HtmlStructureViewTreeModel.java
+++ b/xml/impl/src/com/intellij/lang/html/structureView/HtmlStructureViewTreeModel.java
@@ -20,9 +20,11 @@
import com.intellij.ide.structureView.impl.xml.XmlStructureViewTreeModel;
import com.intellij.ide.util.treeView.smartTree.NodeProvider;
import com.intellij.ide.util.treeView.smartTree.Sorter;
+import com.intellij.openapi.editor.Editor;
import com.intellij.psi.xml.XmlFile;
import com.intellij.ui.PlaceHolder;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
import java.util.Collection;
@@ -33,29 +35,35 @@
private String myStructureViewPlace;
- public HtmlStructureViewTreeModel(final XmlFile file) {
- super(file);
+ public HtmlStructureViewTreeModel(final XmlFile file, @Nullable Editor editor) {
+ super(file, editor);
+
myNodeProviders = Arrays.<NodeProvider>asList(new Html5SectionsNodeProvider());
}
+ @Override
public void setPlace(final String place) {
myStructureViewPlace = place;
}
+ @Override
public String getPlace() {
return myStructureViewPlace;
}
+ @Override
@NotNull
public Sorter[] getSorters() {
return Sorter.EMPTY_ARRAY;
}
+ @Override
@NotNull
public Collection<NodeProvider> getNodeProviders() {
return myNodeProviders;
}
+ @Override
@NotNull
public StructureViewTreeElement getRoot() {
return new HtmlFileTreeElement(ViewStructureAction.isInStructureViewPopup(this), (XmlFile)getPsiFile());
diff --git a/xml/impl/src/com/intellij/lang/html/structureView/HtmlTagTreeElement.java b/xml/impl/src/com/intellij/lang/html/structureView/HtmlTagTreeElement.java
index b55e9e5..bf9c08a 100644
--- a/xml/impl/src/com/intellij/lang/html/structureView/HtmlTagTreeElement.java
+++ b/xml/impl/src/com/intellij/lang/html/structureView/HtmlTagTreeElement.java
@@ -25,6 +25,7 @@
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.util.Collection;
import java.util.Collections;
@@ -37,80 +38,107 @@
super(tag);
}
+ @Override
@NotNull
public Collection<StructureViewTreeElement> getChildrenBase() {
final XmlTag tag = getElement();
if (tag == null || !tag.isValid()) return Collections.emptyList();
return ContainerUtil.map2List(tag.getSubTags(), new Function<XmlTag, StructureViewTreeElement>() {
+ @Override
public StructureViewTreeElement fun(final XmlTag subTag) {
return new HtmlTagTreeElement(subTag);
}
});
}
+ @Override
public String getPresentableText() {
final XmlTag tag = getElement();
- if (tag == null) return IdeBundle.message("node.structureview.invalid");
-
+ if (tag == null) {
+ return IdeBundle.message("node.structureview.invalid");
+ }
return getTagPresentation(tag);
}
+ @Nullable
+ @Override
public String getLocationString() {
final XmlTag tag = getElement();
- if (tag == null) return null;
+ if (tag == null) {
+ return null;
+ }
- final String text = normalizeSpacesAndShortenIfLong(tag.getValue().getTrimmedText());
- return text.isEmpty() ? null : text;
+ if (tag.getName().equalsIgnoreCase("img") || tag.getName().equalsIgnoreCase("script")) {
+ String src = tag.getAttributeValue("src");
+ if (StringUtil.isEmpty(src)) {
+ return null;
+ }
+ else {
+ assert src != null;
+ return StringUtil.shortenPathWithEllipsis(src, MAX_TEXT_LENGTH, true);
+ }
+ }
+ else {
+ return StringUtil.nullize(normalizeSpacesAndShortenIfLong(tag.getValue().getTrimmedText()));
+ }
}
+ @Override
public boolean isSearchInLocationString() {
return true;
}
public static String getTagPresentation(final @NotNull XmlTag tag) {
- final String id = XmlTagTreeElement.toCanonicalForm(tag.getAttributeValue("id"));
+ StringBuilder builder = new StringBuilder(tag.getLocalName());
- final String classValue = tag.getAttributeValue("class");
- final List<String> classValues = classValue != null ? StringUtil.split(classValue, " ") : Collections.<String>emptyList();
-
- final StringBuilder text = new StringBuilder(tag.getLocalName());
-
+ String id = XmlTagTreeElement.toCanonicalForm(tag.getAttributeValue("id"));
if (id != null) {
- text.append("#").append(id);
+ builder.append('#').append(id);
}
+ String classValue = tag.getAttributeValue("class");
+ List<String> classValues = classValue == null ? Collections.<String>emptyList() : StringUtil.split(classValue, " ");
if (!classValues.isEmpty()) {
- text.append('.').append(StringUtil.join(classValues, "."));
+ builder.append('.');
+ StringUtil.join(classValues, ".", builder);
}
- return text.toString();
+ return builder.toString();
}
- @NotNull
+ @Nullable
public static String normalizeSpacesAndShortenIfLong(final @NotNull String text) {
- return shortenTextIfLong(normalizeSpaces(text));
+ StringBuilder builder = normalizeSpaces(text);
+ return builder == null ? null : shortenTextIfLong(builder);
}
- private static String normalizeSpaces(final String text) {
- final StringBuilder buf = new StringBuilder();
+ @Nullable
+ private static StringBuilder normalizeSpaces(@NotNull String text) {
+ if (text.isEmpty()) {
+ return null;
+ }
- for (char ch : text.toCharArray()) {
- if (ch <= ' ' || Character.isSpaceChar(ch)) {
+ final StringBuilder buf = new StringBuilder(text.length());
+ for (int i = 0, length = text.length(); i < length; i++) {
+ char c = text.charAt(i);
+ if (c <= ' ' || Character.isSpaceChar(c)) {
if (buf.length() == 0 || buf.charAt(buf.length() - 1) != ' ') {
buf.append(' ');
}
}
else {
- buf.append(ch);
+ buf.append(c);
}
}
-
- return buf.toString();
+ return buf;
}
- private static String shortenTextIfLong(final String text) {
- if (text.length() <= MAX_TEXT_LENGTH) return text;
+ @Nullable
+ private static String shortenTextIfLong(@NotNull StringBuilder text) {
+ if (text.length() <= MAX_TEXT_LENGTH) {
+ return text.toString();
+ }
int index;
for (index = MAX_TEXT_LENGTH; index > MAX_TEXT_LENGTH - 20; index--) {
@@ -119,14 +147,16 @@
}
}
- final int endIndex = Character.isLetter(index) ? MAX_TEXT_LENGTH : index;
- return text.substring(0, endIndex) + "...";
+ text.setLength(Character.isLetter(index) ? MAX_TEXT_LENGTH : index);
+ return text.append("\u2026").toString();
}
+ @Override
public String getLocationPrefix() {
return " ";
}
+ @Override
public String getLocationSuffix() {
return "";
}
diff --git a/xml/impl/src/com/intellij/lang/xml/XMLExternalAnnotator.java b/xml/impl/src/com/intellij/lang/xml/XMLExternalAnnotator.java
index 1e2041c..c77bebd 100644
--- a/xml/impl/src/com/intellij/lang/xml/XMLExternalAnnotator.java
+++ b/xml/impl/src/com/intellij/lang/xml/XMLExternalAnnotator.java
@@ -29,6 +29,7 @@
import com.intellij.psi.xml.XmlToken;
import com.intellij.xml.XmlNSDescriptor;
import com.intellij.xml.util.XmlTagUtil;
+import org.jetbrains.annotations.NotNull;
/**
* @author ven
@@ -70,11 +71,11 @@
}
@Override
- public void addMessage(PsiElement context, String message, ErrorType type) {
+ public void addMessage(PsiElement context, String message, @NotNull ErrorType type) {
addMessageWithFixes(context, message, type);
}
- public void addMessageWithFixes(final PsiElement context, final String message, final ErrorType type, final IntentionAction... fixes) {
+ public void addMessageWithFixes(final PsiElement context, final String message, @NotNull final ErrorType type, final IntentionAction... fixes) {
if (message != null && message.length() > 0) {
if (context instanceof XmlTag) {
addMessagesForTag((XmlTag)context, message, type, fixes);
diff --git a/xml/impl/src/com/intellij/lang/xml/XmlStructureViewBuilderFactory.java b/xml/impl/src/com/intellij/lang/xml/XmlStructureViewBuilderFactory.java
index 2282b17..ba27214 100644
--- a/xml/impl/src/com/intellij/lang/xml/XmlStructureViewBuilderFactory.java
+++ b/xml/impl/src/com/intellij/lang/xml/XmlStructureViewBuilderFactory.java
@@ -27,6 +27,7 @@
import com.intellij.lang.Language;
import com.intellij.lang.LanguageStructureViewBuilder;
import com.intellij.lang.PsiStructureViewFactory;
+import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.psi.PsiFile;
import com.intellij.psi.xml.XmlFile;
@@ -34,6 +35,7 @@
import org.jetbrains.annotations.Nullable;
public class XmlStructureViewBuilderFactory implements PsiStructureViewFactory {
+ @Override
@Nullable
public StructureViewBuilder getStructureViewBuilder(final PsiFile psiFile) {
if (!(psiFile instanceof XmlFile)) {
@@ -52,9 +54,10 @@
}
return new TreeBasedStructureViewBuilder() {
+ @Override
@NotNull
- public StructureViewModel createStructureViewModel() {
- return new XmlStructureViewTreeModel((XmlFile)psiFile);
+ public StructureViewModel createStructureViewModel(@Nullable Editor editor) {
+ return new XmlStructureViewTreeModel((XmlFile)psiFile, editor);
}
};
}
diff --git a/xml/impl/src/com/intellij/xml/arrangement/XmlArrangementVisitor.java b/xml/impl/src/com/intellij/xml/arrangement/XmlArrangementVisitor.java
index 907ca91..7f118e8 100644
--- a/xml/impl/src/com/intellij/xml/arrangement/XmlArrangementVisitor.java
+++ b/xml/impl/src/com/intellij/xml/arrangement/XmlArrangementVisitor.java
@@ -44,15 +44,14 @@
@Override
public void visitXmlTag(XmlTag tag) {
final XmlElementArrangementEntry entry = createNewEntry(
- tag.getTextRange(), XML_TAG, null, true);
+ tag.getTextRange(), XML_TAG, null, null, true);
processEntry(entry, tag);
}
@Override
public void visitXmlAttribute(XmlAttribute attribute) {
- final String name = attribute.isNamespaceDeclaration() ? "" : attribute.getName();
final XmlElementArrangementEntry entry = createNewEntry(
- attribute.getTextRange(), XML_ATTRIBUTE, name, true);
+ attribute.getTextRange(), XML_ATTRIBUTE, attribute.getName(), attribute.getNamespace(), true);
processEntry(entry, null);
}
@@ -73,13 +72,14 @@
private XmlElementArrangementEntry createNewEntry(@NotNull TextRange range,
@NotNull ArrangementSettingsToken type,
@Nullable String name,
+ @Nullable String namespace,
boolean canBeMatched) {
if (!isWithinBounds(range)) {
return null;
}
final DefaultArrangementEntry current = getCurrent();
final XmlElementArrangementEntry entry = new XmlElementArrangementEntry(
- current, range, type, name, canBeMatched);
+ current, range, type, name, namespace, canBeMatched);
if (current == null) {
myInfo.addEntry(entry);
diff --git a/xml/impl/src/com/intellij/xml/arrangement/XmlElementArrangementEntry.java b/xml/impl/src/com/intellij/xml/arrangement/XmlElementArrangementEntry.java
index 164465d..c6099fb 100644
--- a/xml/impl/src/com/intellij/xml/arrangement/XmlElementArrangementEntry.java
+++ b/xml/impl/src/com/intellij/xml/arrangement/XmlElementArrangementEntry.java
@@ -1,10 +1,7 @@
package com.intellij.xml.arrangement;
import com.intellij.openapi.util.TextRange;
-import com.intellij.psi.codeStyle.arrangement.ArrangementEntry;
-import com.intellij.psi.codeStyle.arrangement.DefaultArrangementEntry;
-import com.intellij.psi.codeStyle.arrangement.NameAwareArrangementEntry;
-import com.intellij.psi.codeStyle.arrangement.TypeAwareArrangementEntry;
+import com.intellij.psi.codeStyle.arrangement.*;
import com.intellij.psi.codeStyle.arrangement.std.ArrangementSettingsToken;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -16,19 +13,22 @@
* @author Eugene.Kudelevsky
*/
public class XmlElementArrangementEntry extends DefaultArrangementEntry
- implements TypeAwareArrangementEntry, NameAwareArrangementEntry {
+ implements TypeAwareArrangementEntry, NameAwareArrangementEntry, NamespaceAwareArrangementEntry {
private final ArrangementSettingsToken myType;
private final String myName;
+ private final String myNamespace;
public XmlElementArrangementEntry(@Nullable ArrangementEntry parent,
@NotNull TextRange range,
@NotNull ArrangementSettingsToken type,
@Nullable String name,
+ @Nullable String namespace,
boolean canBeMatched)
{
super(parent, range.getStartOffset(), range.getEndOffset(), canBeMatched);
myName = name;
+ myNamespace = namespace;
myType = type;
}
@@ -38,6 +38,12 @@
return myName;
}
+ @Nullable
+ @Override
+ public String getNamespace() {
+ return myNamespace;
+ }
+
@NotNull
@Override
public Set<ArrangementSettingsToken> getTypes() {
diff --git a/xml/impl/src/com/intellij/xml/arrangement/XmlRearranger.java b/xml/impl/src/com/intellij/xml/arrangement/XmlRearranger.java
index add2e0d..9e20743 100644
--- a/xml/impl/src/com/intellij/xml/arrangement/XmlRearranger.java
+++ b/xml/impl/src/com/intellij/xml/arrangement/XmlRearranger.java
@@ -6,10 +6,13 @@
import com.intellij.psi.PsiElement;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import com.intellij.psi.codeStyle.arrangement.ArrangementSettings;
+import com.intellij.psi.codeStyle.arrangement.ArrangementUtil;
import com.intellij.psi.codeStyle.arrangement.Rearranger;
import com.intellij.psi.codeStyle.arrangement.group.ArrangementGroupingRule;
import com.intellij.psi.codeStyle.arrangement.match.ArrangementEntryMatcher;
+import com.intellij.psi.codeStyle.arrangement.match.StdArrangementEntryMatcher;
import com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule;
+import com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition;
import com.intellij.psi.codeStyle.arrangement.model.ArrangementMatchCondition;
import com.intellij.psi.codeStyle.arrangement.std.*;
import com.intellij.util.containers.ContainerUtilRt;
@@ -34,8 +37,24 @@
private static final Set<ArrangementSettingsToken> SUPPORTED_TYPES = ContainerUtilRt.newLinkedHashSet(XML_TAG, XML_ATTRIBUTE);
private static final List<StdArrangementMatchRule> DEFAULT_MATCH_RULES = new ArrayList<StdArrangementMatchRule>();
- private static final StdArrangementSettings DEFAULT_SETTINGS = new StdRulePriorityAwareSettings(
- Collections.<ArrangementGroupingRule>emptyList(), DEFAULT_MATCH_RULES);
+ private static final StdArrangementSettings DEFAULT_SETTINGS;
+
+ static {
+ DEFAULT_MATCH_RULES.add(new StdArrangementMatchRule(new StdArrangementEntryMatcher(
+ new ArrangementAtomMatchCondition(StdArrangementTokens.Regexp.NAME, "xmlns:.*"))));
+ DEFAULT_SETTINGS = new StdRulePriorityAwareSettings(
+ Collections.<ArrangementGroupingRule>emptyList(), DEFAULT_MATCH_RULES);
+ }
+
+ @NotNull
+ public static StdArrangementMatchRule attrArrangementRule(@NotNull String nameFilter,
+ @NotNull String namespaceFilter,
+ @NotNull ArrangementSettingsToken orderType) {
+ return new StdArrangementMatchRule(new StdArrangementEntryMatcher(ArrangementUtil.combine(
+ new ArrangementAtomMatchCondition(StdArrangementTokens.Regexp.NAME, nameFilter),
+ new ArrangementAtomMatchCondition(StdArrangementTokens.Regexp.XML_NAMESPACE, namespaceFilter)
+ )), orderType);
+ }
@Nullable
@Override
diff --git a/xml/impl/src/com/intellij/xml/breadcrumbs/BreadcrumbsXmlWrapper.java b/xml/impl/src/com/intellij/xml/breadcrumbs/BreadcrumbsXmlWrapper.java
index 56b9b06..cd62adf 100644
--- a/xml/impl/src/com/intellij/xml/breadcrumbs/BreadcrumbsXmlWrapper.java
+++ b/xml/impl/src/com/intellij/xml/breadcrumbs/BreadcrumbsXmlWrapper.java
@@ -16,6 +16,8 @@
package com.intellij.xml.breadcrumbs;
import com.intellij.application.options.editor.WebEditorOptions;
+import com.intellij.ide.ui.UISettings;
+import com.intellij.ide.ui.UISettingsListener;
import com.intellij.lang.Language;
import com.intellij.lang.xml.XMLLanguage;
import com.intellij.openapi.Disposable;
@@ -84,17 +86,20 @@
final FileStatusManager manager = FileStatusManager.getInstance(project);
manager.addFileStatusListener(new FileStatusListener() {
public void fileStatusesChanged() {
- if (myComponent != null && myEditor != null) {
- final Font editorFont = myEditor.getColorsScheme().getFont(EditorFontType.PLAIN);
- myComponent.setFont(editorFont.deriveFont(Font.PLAIN, editorFont.getSize2D()));
- updateCrumbs(myEditor.getCaretModel().getLogicalPosition());
- }
+ updateCrumbs();
}
public void fileStatusChanged(@NotNull final VirtualFile virtualFile) {
}
}, this);
+ UISettings.getInstance().addUISettingsListener(new UISettingsListener() {
+ @Override
+ public void uiSettingsChanged(UISettings source) {
+ updateCrumbs();
+ }
+ }, this);
+
myInfoProvider = findInfoProvider(findViewProvider(myFile, myProject));
@@ -183,6 +188,14 @@
myWrapperPanel.add(myComponent, BorderLayout.CENTER);
}
+ private void updateCrumbs() {
+ if (myComponent != null && myEditor != null) {
+ final Font editorFont = myEditor.getColorsScheme().getFont(EditorFontType.PLAIN);
+ myComponent.setFont(editorFont.deriveFont(Font.PLAIN, editorFont.getSize2D()));
+ updateCrumbs(myEditor.getCaretModel().getLogicalPosition());
+ }
+ }
+
public void queueUpdate(Editor editor) {
myQueue.cancelAllUpdates();
myQueue.queue(new MyUpdate(this, editor));
diff --git a/xml/impl/src/com/intellij/xml/impl/schema/SchemaDefinitionsSearch.java b/xml/impl/src/com/intellij/xml/impl/schema/SchemaDefinitionsSearch.java
index fe3a323..6811ca9 100644
--- a/xml/impl/src/com/intellij/xml/impl/schema/SchemaDefinitionsSearch.java
+++ b/xml/impl/src/com/intellij/xml/impl/schema/SchemaDefinitionsSearch.java
@@ -63,13 +63,18 @@
});
if (infos != null && ! infos.isEmpty()) {
- XmlFile file = XmlUtil.getContainingFile(xml);
+ final XmlFile file = XmlUtil.getContainingFile(xml);
final Project project = file.getProject();
final Module module = ModuleUtil.findModuleForPsiElement(queryParameters);
//if (module == null) return false;
final VirtualFile vf = file.getVirtualFile();
- String thisNs = XmlNamespaceIndex.getNamespace(vf, project, file);
+ String thisNs = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
+ @Override
+ public String compute() {
+ return XmlNamespaceIndex.getNamespace(vf, project, file);
+ }
+ });
thisNs = thisNs == null ? getDefaultNs(file) : thisNs;
// so thisNs can be null
if (thisNs == null) return false;
diff --git a/xml/impl/src/com/intellij/xml/util/XmlPrefixReferenceProvider.java b/xml/impl/src/com/intellij/xml/util/XmlPrefixReferenceProvider.java
index 38fbf27..f1b8294 100644
--- a/xml/impl/src/com/intellij/xml/util/XmlPrefixReferenceProvider.java
+++ b/xml/impl/src/com/intellij/xml/util/XmlPrefixReferenceProvider.java
@@ -37,7 +37,7 @@
int i = value.indexOf(':');
if (i > 0) {
return new PsiReference[] {
- new SchemaPrefixReference(attributeValue, TextRange.from(1, i), value.substring(0, i))
+ new SchemaPrefixReference(attributeValue, TextRange.from(1, i), value.substring(0, i), null)
};
}
}
diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/RngDocumentationProvider.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/RngDocumentationProvider.java
index f3025ce..de71f0d 100644
--- a/xml/relaxng/src/org/intellij/plugins/relaxNG/RngDocumentationProvider.java
+++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/RngDocumentationProvider.java
@@ -17,15 +17,18 @@
package org.intellij.plugins.relaxNG;
import com.intellij.lang.documentation.DocumentationProvider;
+import com.intellij.openapi.diagnostic.Logger;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiManager;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.xml.XmlAttribute;
import com.intellij.psi.xml.XmlElement;
import com.intellij.psi.xml.XmlTag;
+import com.intellij.util.containers.ContainerUtil;
import com.intellij.xml.XmlAttributeDescriptor;
import com.intellij.xml.XmlElementDescriptor;
import com.intellij.xml.util.XmlStringUtil;
+import gnu.trove.THashSet;
import org.intellij.plugins.relaxNG.model.descriptors.CompositeDescriptor;
import org.intellij.plugins.relaxNG.model.descriptors.RngElementDescriptor;
import org.intellij.plugins.relaxNG.model.descriptors.RngXmlAttributeDescriptor;
@@ -42,12 +45,18 @@
* Date: 19.11.2007
*/
public class RngDocumentationProvider implements DocumentationProvider {
+ private static final Logger LOG = Logger.getInstance(RngDocumentationProvider.class);
+
@NonNls
private static final String COMPATIBILITY_ANNOTATIONS_1_0 = "http://relaxng.org/ns/compatibility/annotations/1.0";
@Nullable
- public String generateDoc(PsiElement element, PsiElement originalElement) {
+ public String generateDoc(PsiElement element, @Nullable PsiElement originalElement) {
final XmlElement c = PsiTreeUtil.getParentOfType(originalElement, XmlTag.class, XmlAttribute.class);
+ if (c != null && c.getManager() == null) {
+ LOG.warn("Invalid context element passed to generateDoc()", new Throwable("<stack trace>"));
+ return null;
+ }
if (c instanceof XmlTag) {
final XmlTag xmlElement = (XmlTag)c;
final XmlElementDescriptor descriptor = xmlElement.getDescriptor();
@@ -55,9 +64,10 @@
final StringBuilder sb = new StringBuilder();
final CompositeDescriptor d = (CompositeDescriptor)descriptor;
final DElementPattern[] patterns = d.getElementPatterns();
+ final THashSet<PsiElement> elements = ContainerUtil.newIdentityTroveSet();
for (DElementPattern pattern : patterns) {
final PsiElement psiElement = d.getDeclaration(pattern.getLocation());
- if (psiElement instanceof XmlTag) {
+ if (psiElement instanceof XmlTag && elements.add(psiElement)) {
if (sb.length() > 0) {
sb.append("<hr>");
}
@@ -78,13 +88,13 @@
if (descriptor instanceof RngXmlAttributeDescriptor) {
final RngXmlAttributeDescriptor d = (RngXmlAttributeDescriptor)descriptor;
final StringBuilder sb = new StringBuilder();
- final Collection<PsiElement> declaration = d.getDeclarations();
+ final Collection<PsiElement> declaration = ContainerUtil.newIdentityTroveSet(d.getDeclarations());
for (PsiElement psiElement : declaration) {
if (psiElement instanceof XmlTag) {
if (sb.length() > 0) {
sb.append("<hr>");
}
- sb.append(getDocumentationFromTag((XmlTag)element, d.getName(), "Attribute"));
+ sb.append(getDocumentationFromTag((XmlTag)psiElement, d.getName(), "Attribute"));
}
}
}
diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncElementType.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncElementType.java
index a40fa6e..1909092 100644
--- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncElementType.java
+++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncElementType.java
@@ -16,14 +16,7 @@
package org.intellij.plugins.relaxNG.compact;
-import com.intellij.lang.ASTNode;
import com.intellij.psi.tree.IElementType;
-import com.intellij.util.NotNullFunction;
-import org.intellij.plugins.relaxNG.compact.psi.RncElement;
-import org.jetbrains.annotations.NotNull;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Modifier;
public class RncElementType extends IElementType {
public RncElementType(String name) {
@@ -31,25 +24,4 @@
}
}
-class RncElementTypeEx<C extends RncElement> extends RncElementType implements NotNullFunction<ASTNode, C> {
- private final Constructor<? extends C> myConstructor;
- RncElementTypeEx(String name, Class<? extends C> clazz) {
- super(name);
- assert !clazz.isInterface() && !Modifier.isAbstract(clazz.getModifiers());
- try {
- myConstructor = clazz.getConstructor(ASTNode.class);
- } catch (NoSuchMethodException e) {
- throw new Error(e);
- }
- }
-
- @NotNull
- public final C fun(ASTNode node) {
- try {
- return myConstructor.newInstance(node);
- } catch (Exception e) {
- throw new Error(e);
- }
- }
-}
diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncElementTypeEx.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncElementTypeEx.java
new file mode 100644
index 0000000..76274c5
--- /dev/null
+++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/RncElementTypeEx.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2000-2013 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 org.intellij.plugins.relaxNG.compact;
+
+import com.intellij.lang.ASTNode;
+import com.intellij.util.NotNullFunction;
+import org.intellij.plugins.relaxNG.compact.psi.RncElement;
+import org.jetbrains.annotations.NotNull;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Modifier;
+
+/**
+ * @author nik
+ */
+class RncElementTypeEx<C extends RncElement> extends RncElementType implements NotNullFunction<ASTNode, C> {
+ private final Constructor<? extends C> myConstructor;
+
+ RncElementTypeEx(String name, Class<? extends C> clazz) {
+ super(name);
+ assert !clazz.isInterface() && !Modifier.isAbstract(clazz.getModifiers());
+ try {
+ myConstructor = clazz.getConstructor(ASTNode.class);
+ } catch (NoSuchMethodException e) {
+ throw new Error(e);
+ }
+ }
+
+ @NotNull
+ public final C fun(ASTNode node) {
+ try {
+ return myConstructor.newInstance(node);
+ } catch (Exception e) {
+ throw new Error(e);
+ }
+ }
+}
diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/lexer/CompactSyntaxLexerAdapter.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/lexer/CompactSyntaxLexerAdapter.java
index 7ae13da..f16484d 100644
--- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/lexer/CompactSyntaxLexerAdapter.java
+++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/lexer/CompactSyntaxLexerAdapter.java
@@ -199,7 +199,7 @@
return new CompactSyntaxTokenManager(new SimpleCharStream(preprocessor, 1, 1), initialState);
} catch (NoSuchMethodError e) {
final Class<CompactSyntaxTokenManager> managerClass = CompactSyntaxTokenManager.class;
- LOG.error("Unsupported version of RNGOM in classpath", e,
+ LOG.error("Unsupported version of RNGOM in classpath. Please check your IDEA and JDK installation.", e,
"Actual parameter types: " + Arrays.toString(managerClass.getConstructors()[0].getParameterTypes()),
"Location of " + managerClass.getName() + ": " + getSourceLocation(managerClass),
"Location of " + CharStream.class.getName() + ": " + getSourceLocation(CharStream.class));
@@ -215,7 +215,9 @@
return location.toExternalForm();
}
}
- final URL resource = clazz.getClassLoader().getResource(clazz.getName().replace('.', '/') + ".class");
+ final String name = clazz.getName().replace('.', '/') + ".class";
+ final ClassLoader loader = clazz.getClassLoader();
+ final URL resource = loader != null ? loader.getResource(name) : ClassLoader.getSystemResource(name);
return resource != null ? resource.toExternalForm() : "<unknown>";
}
diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/RngElementDescriptor.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/RngElementDescriptor.java
index 054460f..0bf6be4 100644
--- a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/RngElementDescriptor.java
+++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/descriptors/RngElementDescriptor.java
@@ -215,8 +215,9 @@
}
public PsiElement getDeclaration() {
- if (myDeclaration != null) {
- final PsiElement element = myDeclaration.getElement();
+ final SmartPsiElementPointer<? extends PsiElement> declaration = myDeclaration;
+ if (declaration != null) {
+ final PsiElement element = declaration.getElement();
if (element != null && element.isValid()) {
return element;
}
@@ -225,7 +226,6 @@
final PsiElement decl = myNsDescriptor.getDeclaration();
if (decl == null/* || !decl.isValid()*/) {
myDeclaration = null;
- System.out.println("decl is null");
return null;
}
@@ -244,7 +244,7 @@
return getDeclarationImpl(element, location);
}
- private PsiElement getDeclarationImpl(PsiElement decl, Locator location) {
+ private static PsiElement getDeclarationImpl(PsiElement decl, Locator location) {
final VirtualFile virtualFile = RngSchemaValidator.findVirtualFile(location.getSystemId());
if (virtualFile == null) {
return decl;
@@ -262,6 +262,9 @@
final Document document = PsiDocumentManager.getInstance(project).getDocument(file);
assert document != null;
+ if (line <= 0 || document.getLineCount() < line - 1) {
+ return decl;
+ }
final int startOffset = document.getLineStartOffset(line - 1);
final PsiElement at;
@@ -271,7 +274,8 @@
}
at = file.findElementAt(startOffset + column - 2);
} else {
- at = PsiTreeUtil.nextLeaf(file.findElementAt(startOffset));
+ PsiElement element = file.findElementAt(startOffset);
+ at = element != null ? PsiTreeUtil.nextLeaf(element) : null;
}
return PsiTreeUtil.getParentOfType(at, XmlTag.class);
diff --git a/xml/tests/src/com/intellij/codeInsight/XmlEventsTest.java b/xml/tests/src/com/intellij/codeInsight/XmlEventsTest.java
index 5ccbdba..457a949 100644
--- a/xml/tests/src/com/intellij/codeInsight/XmlEventsTest.java
+++ b/xml/tests/src/com/intellij/codeInsight/XmlEventsTest.java
@@ -15,16 +15,12 @@
import com.intellij.pom.event.PomModelEvent;
import com.intellij.pom.event.PomModelListener;
import com.intellij.pom.xml.XmlAspect;
-import com.intellij.psi.PsiDocumentManager;
-import com.intellij.psi.PsiFile;
-import com.intellij.psi.XmlElementFactory;
+import com.intellij.psi.*;
import com.intellij.psi.impl.source.PsiFileImpl;
-import com.intellij.psi.xml.XmlAttribute;
-import com.intellij.psi.xml.XmlFile;
-import com.intellij.psi.xml.XmlTag;
-import com.intellij.psi.xml.XmlText;
+import com.intellij.psi.xml.*;
import com.intellij.testFramework.LightCodeInsightTestCase;
import com.intellij.testFramework.PlatformTestUtil;
+import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.FileNotFoundException;
@@ -235,4 +231,64 @@
text = StringUtil.convertLineSeparators(text);
return text;
}
+
+ public void testDocumentChange() throws Exception {
+ final String xml = "" +
+ "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
+ "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" +
+ " android:layout_height=\"fill_parent\">\n" +
+ " <include layout=\"@layout/colorstrip\" />\n" +
+ "\n" +
+ "\n" +
+ " <LinearLayout\n" +
+ " android:id=\"@+id/noteArea\"\n" +
+ " android:layout_width=\"fill_parent\"\n" +
+ " android:layout_height=\"wrap_content\"\n" +
+ " android:layout_weight=\"1\"\n" +
+ " android:layout_margin=\"5dip\">\n" +
+ " </LinearLayout>\n" +
+ "\n" +
+ "</LinearLayout>\n";
+ PsiFile file = createFile("file.xml", xml);
+ assertTrue(file instanceof XmlFile);
+ XmlDocument xmlDocument = ((XmlFile)file).getDocument();
+ assertNotNull(xmlDocument);
+ final XmlTag tagFromText = xmlDocument.getRootTag();
+ assertNotNull(tagFromText);
+ final PsiFileImpl containingFile = (PsiFileImpl)tagFromText.getContainingFile();
+ final PsiDocumentManager documentManager = PsiDocumentManager.getInstance(getProject());
+ final Document document = documentManager.getDocument(containingFile);
+ assertNotNull(document);
+
+ final TestListener listener = new TestListener();
+ PsiManager.getInstance(getProject()).addPsiTreeChangeListener(listener);
+
+ CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() {
+ @Override
+ public void run() {
+ ApplicationManager.getApplication().runWriteAction(new Runnable() {
+ @Override
+ public void run() {
+ int positionToInsert = xml.indexOf(" <LinearLayout\n" +
+ " android:id=\"@+id/noteArea\"\n");
+ assertFalse(positionToInsert == -1);
+ String stringToInsert = "<Button android:id=\"@+id/newid\" />\n";
+ document.insertString(positionToInsert, stringToInsert);
+ documentManager.commitDocument(document);
+ }
+ });
+ }
+ }, "", null);
+
+ PsiManager.getInstance(getProject()).removePsiTreeChangeListener(listener);
+ }
+
+ private static class TestListener extends PsiTreeChangeAdapter {
+ @Override
+ public void childReplaced(@NotNull PsiTreeChangeEvent event) {
+ if (event.getNewChild() != null) {
+ assertNotSame("Received identical before and after children in childReplaced;", event.getOldChild(), event.getNewChild());
+ }
+ }
+ }
}
diff --git a/xml/tests/src/com/intellij/xml/arrangement/XmlRearrangerTest.groovy b/xml/tests/src/com/intellij/xml/arrangement/XmlRearrangerTest.groovy
index 15c3649..a9c9d33 100644
--- a/xml/tests/src/com/intellij/xml/arrangement/XmlRearrangerTest.groovy
+++ b/xml/tests/src/com/intellij/xml/arrangement/XmlRearrangerTest.groovy
@@ -2,9 +2,13 @@
import com.intellij.ide.highlighter.XmlFileType
import com.intellij.lang.xml.XMLLanguage
import com.intellij.psi.codeStyle.arrangement.AbstractRearrangerTest
+import com.intellij.psi.codeStyle.arrangement.match.StdArrangementEntryMatcher
+import com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule
+import com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchCondition
+import com.intellij.psi.codeStyle.arrangement.std.StdArrangementTokens
+import org.jetbrains.annotations.NotNull
import static com.intellij.psi.codeStyle.arrangement.std.StdArrangementTokens.Order.BY_NAME
-
/**
* @author Eugene.Kudelevsky
*/
@@ -17,7 +21,7 @@
void testAttributeSorting1() {
doTest(
initial: '''<root xmlns:ns="http://ns.com" attr2="value2" attr1="value1" attr3="value3"/>''',
- expected: '''<root xmlns:ns="http://ns.com" attr1="value1" attr2="value2" attr3="value3"/>''',
+ expected: '''<root attr1="value1" attr2="value2" attr3="value3" xmlns:ns="http://ns.com"/>''',
rules: [ruleWithOrder(BY_NAME, nameRule(".*"))]
)
}
@@ -25,7 +29,7 @@
void testAttributeSorting2() {
doTest(
initial: '''<root attr3="value3" attr2="value2" attr1="value1" xmlns:ns="http://ns.com"/>''',
- expected: '''<root xmlns:ns="http://ns.com" attr1="value1" attr2="value2" attr3="value3"/>''',
+ expected: '''<root attr1="value1" attr2="value2" attr3="value3" xmlns:ns="http://ns.com"/>''',
rules: [ruleWithOrder(BY_NAME, nameRule(".*"))]
)
}
@@ -48,7 +52,139 @@
</tag1>
</root>
''',
- rules: [ruleWithOrder(BY_NAME, nameRule(".*"))]
+ rules: [ruleWithOrder(BY_NAME, nameRule("xmlns:.*")), ruleWithOrder(BY_NAME, nameRule(".*"))]
)
}
+
+ public void testAttributeSorting4() throws Exception {
+ doTest(
+ initial: '''<root attr3="value3" attr2="value2" attr1="value1" xmlns:ns="http://ns.com"/>''',
+ expected: '''<root xmlns:ns="http://ns.com" attr1="value1" attr2="value2" attr3="value3"/>''',
+ rules: [ruleWithOrder(BY_NAME, nameRule("xmlns:.*")), ruleWithOrder(BY_NAME, nameRule(".*"))]
+ )
+ }
+
+ public void testAttributeSortingByNamespace1() throws Exception {
+ doTest(
+ initial: '''\
+<root attr1="value1" ns1:attr2="value2" xmlns:ns1="http://ns1.com" xmlns:ns2="http://ns2.com" ns1:attr1="value1">
+ <tag1 ns2:attr2="value2" attr2="value2" attr1="value1" ns2:attr1="value1" ns1:attr2="value2" ns1:attr1="value1">
+ </tag1>
+</root>
+''',
+ expected: '''\
+<root xmlns:ns1="http://ns1.com" xmlns:ns2="http://ns2.com" attr1="value1" ns1:attr1="value1" ns1:attr2="value2">
+ <tag1 attr1="value1" attr2="value2" ns1:attr1="value1" ns1:attr2="value2" ns2:attr1="value1" ns2:attr2="value2">
+ </tag1>
+</root>
+''',
+ rules: [ruleWithOrder(BY_NAME, nameRule("xmlns:.*")), ruleWithOrder(BY_NAME, namespaceRule(".*"))]
+ )
+ }
+
+ public void testAttributeSortingByNamespace2() throws Exception {
+ doTest(
+ initial: '''\
+<root attr1="value1" ns1:attr2="value2" xmlns:ns1="http://ns1.com" xmlns:ns2="http://ns2.com" ns1:attr1="value1">
+ <tag1 ns2:attr2="value2" attr2="value2" attr1="value1" ns2:attr1="value1" ns1:attr2="value2" ns1:attr1="value1">
+ </tag1>
+</root>
+''',
+ expected: '''\
+<root xmlns:ns1="http://ns1.com" xmlns:ns2="http://ns2.com" ns1:attr1="value1" ns1:attr2="value2" attr1="value1">
+ <tag1 ns1:attr1="value1" ns1:attr2="value2" ns2:attr1="value1" ns2:attr2="value2" attr2="value2" attr1="value1">
+ </tag1>
+</root>
+''',
+ rules: [ruleWithOrder(BY_NAME, nameRule("xmlns:.*")), ruleWithOrder(BY_NAME, namespaceRule("http://ns.*"))]
+ )
+ }
+
+ public void testAttributeSortingByNamespace3() throws Exception {
+ doTest(
+ initial: '''\
+<root attr1="value1" ns1:attr2="value2" xmlns:ns1="http://ns1.com" xmlns:ns2="http://ns2.com" ns1:attr1="value1">
+ <tag1 ns2:attr2="value2" attr2="value2" attr1="value1" ns2:attr1="value1" ns1:attr2="value2" ns1:attr1="value1">
+ </tag1>
+</root>
+''',
+ expected: '''\
+<root xmlns:ns1="http://ns1.com" xmlns:ns2="http://ns2.com" ns1:attr1="value1" ns1:attr2="value2" attr1="value1">
+ <tag1 ns1:attr1="value1" ns1:attr2="value2" ns2:attr1="value1" ns2:attr2="value2" attr1="value1" attr2="value2">
+ </tag1>
+</root>
+''',
+ rules: [ruleWithOrder(BY_NAME, nameRule("xmlns:.*")), ruleWithOrder(BY_NAME, namespaceRule("http://ns.*")),
+ ruleWithOrder(BY_NAME, nameRule(".*"))]
+ )
+ }
+
+ public void testAttributeSortingByNamespace4() throws Exception {
+ doTest(
+ initial: '''\
+<root attr1="value1" ns1:attr2="value2" xmlns:ns1="http://ns1.com" xmlns:ns2="http://ns2.com" ns1:attr1="value1">
+ <tag1 ns2:attr2="value2" attr2="value2" attr1="value1" ns2:attr1="value1" ns1:attr2="value2" ns1:attr1="value1">
+ </tag1>
+</root>
+''',
+ expected: '''\
+<root xmlns:ns1="http://ns1.com" xmlns:ns2="http://ns2.com" attr1="value1" ns1:attr1="value1" ns1:attr2="value2">
+ <tag1 ns2:attr1="value1" ns2:attr2="value2" attr1="value1" attr2="value2" ns1:attr1="value1" ns1:attr2="value2">
+ </tag1>
+</root>
+''',
+ rules: [ruleWithOrder(BY_NAME, nameRule("xmlns:.*")), ruleWithOrder(BY_NAME, namespaceRule("http://ns2.com")),
+ ruleWithOrder(BY_NAME, nameRule(".*"))]
+ )
+ }
+
+ public void testAttributeSortingByNamespace5() throws Exception {
+ doTest(
+ initial: '''\
+<root attr1="value1" ns1:attr2="value2" xmlns:ns1="http://ns1.com" xmlns:ns2="http://ns2.com" ns1:attr1="value1">
+ <tag1 ns2:attr2="value2" attr2="value2" attr1="value1" ns2:attr1="value1" ns1:attr2="value2" ns1:attr1="value1">
+ </tag1>
+</root>
+''',
+ expected: '''\
+<root xmlns:ns1="http://ns1.com" xmlns:ns2="http://ns2.com" ns1:attr1="value1" ns1:attr2="value2" attr1="value1">
+ <tag1 ns2:attr1="value1" ns2:attr2="value2" ns1:attr1="value1" ns1:attr2="value2" attr2="value2" attr1="value1">
+ </tag1>
+</root>
+''',
+ rules: [ruleWithOrder(BY_NAME, nameRule("xmlns:.*")), ruleWithOrder(BY_NAME, namespaceRule("http://ns2.com")),
+ ruleWithOrder(BY_NAME, namespaceRule("http://ns1.com"))]
+ )
+ }
+
+ public void testAttributeSortingByNamespace6() throws Exception {
+ doTest(
+ initial: '''\
+<root attr1="value1" ns1:attr2="value2" xmlns:ns1="http://ns1.com" xmlns:ns2="http://ns2.com" ns1:attr1="value1">
+ <tag1 ns2:attr2="value2" attr2="value2" attr1="value1" ns2:attr1="value1" ns1:attr2="value2" ns1:attr1="value1">
+ </tag1>
+</root>
+''',
+ expected: '''\
+<root xmlns:ns1="http://ns1.com" xmlns:ns2="http://ns2.com" ns1:attr2="value2" attr1="value1" ns1:attr1="value1">
+ <tag1 ns1:attr2="value2" ns2:attr2="value2" attr1="value1" attr2="value2" ns1:attr1="value1" ns2:attr1="value1">
+ </tag1>
+</root>
+''',
+ rules: [ruleWithOrder(BY_NAME, nameRule("xmlns:.*")), ruleWithOrder(BY_NAME, compositeRule(".*:attr2", "http://ns.*")),
+ ruleWithOrder(BY_NAME, nameRule(".*"))]
+ )
+ }
+
+ @NotNull
+ private static StdArrangementMatchRule namespaceRule(@NotNull String filter) {
+ return new StdArrangementMatchRule(new StdArrangementEntryMatcher(
+ new ArrangementAtomMatchCondition(StdArrangementTokens.Regexp.XML_NAMESPACE, filter)))
+ }
+
+ @NotNull
+ protected static StdArrangementMatchRule compositeRule(@NotNull String nameFilter, @NotNull String namespaceFilter) {
+ return rule(new ArrangementAtomMatchCondition(StdArrangementTokens.Regexp.NAME, nameFilter),
+ new ArrangementAtomMatchCondition(StdArrangementTokens.Regexp.XML_NAMESPACE, namespaceFilter));
+ }
}
diff --git a/xml/tests/src/com/intellij/xml/structureView/HtmlFileStructureTest.java b/xml/tests/src/com/intellij/xml/structureView/HtmlFileStructureTest.java
index e822249..77aab44 100644
--- a/xml/tests/src/com/intellij/xml/structureView/HtmlFileStructureTest.java
+++ b/xml/tests/src/com/intellij/xml/structureView/HtmlFileStructureTest.java
@@ -6,15 +6,16 @@
import com.intellij.testFramework.FileStructureTestBase;
public class HtmlFileStructureTest extends FileStructureTestBase {
-
private boolean myHtml5OutlineModeDefault;
+ @Override
public void setUp() throws Exception {
super.setUp();
myHtml5OutlineModeDefault = PropertiesComponent.getInstance().getBoolean(getHtml5OutlineModePropertyName(), false);
setHtml5OutlineMode(true);
}
+ @Override
public void tearDown() throws Exception {
PropertiesComponent.getInstance().setValue(getHtml5OutlineModePropertyName(), String.valueOf(myHtml5OutlineModeDefault));
super.tearDown();
@@ -24,14 +25,17 @@
return FileStructurePopup.getPropertyName(Html5SectionsNodeProvider.HTML5_OUTLINE_PROVIDER_PROPERTY);
}
+ @Override
protected String getFileExtension() {
return "html";
}
+ @Override
protected String getBasePath() {
return "/xml/tests/testData/structureView/";
}
+ @Override
protected boolean isCommunity() {
return true;
}
@@ -46,4 +50,4 @@
public void testNoSectioningRoot() throws Exception {checkTree();}
public void testImplicitSections() throws Exception {checkTree();}
public void testMultipleRootTags() throws Exception {checkTree();}
-}
+}
\ No newline at end of file
diff --git a/xml/tests/testData/structureView/ImplicitSections.tree b/xml/tests/testData/structureView/ImplicitSections.tree
index 9903463..8ae4cdc 100644
--- a/xml/tests/testData/structureView/ImplicitSections.tree
+++ b/xml/tests/testData/structureView/ImplicitSections.tree
@@ -18,7 +18,7 @@
g2
-body2
body3
- -
- -
+ -null
+ -null
hhh2
hhh1
\ No newline at end of file
diff --git a/xml/tests/testData/structureView/Simple.tree b/xml/tests/testData/structureView/Simple.tree
index 4f8e03e..3d9a21b 100644
--- a/xml/tests/testData/structureView/Simple.tree
+++ b/xml/tests/testData/structureView/Simple.tree
@@ -1,2 +1,2 @@
-HtmlFile:Simple.html
- []
\ No newline at end of file
+ [null]
\ No newline at end of file
diff --git a/xml/openapi/src/com/intellij/javaee/ResourceRegistrar.java b/xml/xml-psi-api/src/com/intellij/javaee/ResourceRegistrar.java
similarity index 100%
rename from xml/openapi/src/com/intellij/javaee/ResourceRegistrar.java
rename to xml/xml-psi-api/src/com/intellij/javaee/ResourceRegistrar.java
diff --git a/xml/openapi/src/com/intellij/javaee/StandardResourceEP.java b/xml/xml-psi-api/src/com/intellij/javaee/StandardResourceEP.java
similarity index 100%
rename from xml/openapi/src/com/intellij/javaee/StandardResourceEP.java
rename to xml/xml-psi-api/src/com/intellij/javaee/StandardResourceEP.java
diff --git a/xml/openapi/src/com/intellij/javaee/StandardResourceProvider.java b/xml/xml-psi-api/src/com/intellij/javaee/StandardResourceProvider.java
similarity index 100%
rename from xml/openapi/src/com/intellij/javaee/StandardResourceProvider.java
rename to xml/xml-psi-api/src/com/intellij/javaee/StandardResourceProvider.java
diff --git a/xml/xml-psi-impl/src/com/intellij/javaee/ExternalResourceManagerExImpl.java b/xml/xml-psi-impl/src/com/intellij/javaee/ExternalResourceManagerExImpl.java
new file mode 100644
index 0000000..4d58a55
--- /dev/null
+++ b/xml/xml-psi-impl/src/com/intellij/javaee/ExternalResourceManagerExImpl.java
@@ -0,0 +1,563 @@
+package com.intellij.javaee;
+
+import com.intellij.application.options.PathMacrosImpl;
+import com.intellij.application.options.ReplacePathToMacroMap;
+import com.intellij.openapi.Disposable;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.components.ExpandMacroToPathMap;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.extensions.Extensions;
+import com.intellij.openapi.fileTypes.FileType;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.*;
+import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.psi.PsiFile;
+import com.intellij.psi.xml.XmlFile;
+import com.intellij.util.ArrayUtil;
+import com.intellij.util.containers.ContainerUtil;
+import com.intellij.util.containers.HashMap;
+import com.intellij.xml.Html5SchemaProvider;
+import com.intellij.xml.XmlSchemaProvider;
+import com.intellij.xml.util.XmlUtil;
+import org.jdom.Element;
+import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.TestOnly;
+
+import java.io.File;
+import java.net.URL;
+import java.util.*;
+
+public class ExternalResourceManagerExImpl extends ExternalResourceManagerEx {
+ static final Logger LOG = Logger.getInstance("#com.intellij.j2ee.openapi.impl.ExternalResourceManagerImpl");
+
+ @NonNls public static final String J2EE_1_3 = "http://java.sun.com/dtd/";
+ @NonNls public static final String J2EE_1_2 = "http://java.sun.com/j2ee/dtds/";
+ @NonNls public static final String J2EE_NS = "http://java.sun.com/xml/ns/j2ee/";
+ @NonNls public static final String JAVAEE_NS = "http://java.sun.com/xml/ns/javaee/";
+ private static final String CATALOG_PROPERTIES_ELEMENT = "CATALOG_PROPERTIES";
+
+
+ private final Map<String, Map<String, String>> myResources = new HashMap<String, Map<String, String>>();
+ private final Set<String> myResourceLocations = new HashSet<String>();
+
+ private final Set<String> myIgnoredResources = new HashSet<String>();
+
+ private final AtomicNotNullLazyValue<Map<String, Map<String, Resource>>> myStdResources = new AtomicNotNullLazyValue<Map<String, Map<String, Resource>>>() {
+
+ @NotNull
+ @Override
+ protected Map<String, Map<String, Resource>> compute() {
+ return computeStdResources();
+ }
+ };
+
+ private String myDefaultHtmlDoctype = HTML5_DOCTYPE_ELEMENT;
+
+ private String myCatalogPropertiesFile;
+ private XMLCatalogManager myCatalogManager;
+ private static final String HTML5_DOCTYPE_ELEMENT = "HTML5";
+
+ protected Map<String, Map<String, Resource>> computeStdResources() {
+ ResourceRegistrarImpl registrar = new ResourceRegistrarImpl();
+ for (StandardResourceProvider provider : Extensions.getExtensions(StandardResourceProvider.EP_NAME)) {
+ provider.registerResources(registrar);
+ }
+ StandardResourceEP[] extensions = Extensions.getExtensions(StandardResourceEP.EP_NAME);
+ for (StandardResourceEP extension : extensions) {
+ registrar.addStdResource(extension.url, extension.version, extension.resourcePath, null, extension.getLoaderForClass());
+ }
+
+ myIgnoredResources.addAll(registrar.getIgnored());
+ return registrar.getResources();
+ }
+
+ private final List<ExternalResourceListener> myListeners = ContainerUtil.createLockFreeCopyOnWriteList();
+ private long myModificationCount = 0;
+ private final PathMacrosImpl myPathMacros;
+ @NonNls private static final String RESOURCE_ELEMENT = "resource";
+ @NonNls private static final String URL_ATTR = "url";
+ @NonNls private static final String LOCATION_ATTR = "location";
+ @NonNls private static final String IGNORED_RESOURCE_ELEMENT = "ignored-resource";
+ @NonNls private static final String HTML_DEFAULT_DOCTYPE_ELEMENT = "default-html-doctype";
+ private static final String DEFAULT_VERSION = null;
+
+ public ExternalResourceManagerExImpl(PathMacrosImpl pathMacros) {
+ myPathMacros = pathMacros;
+ }
+
+ public boolean isStandardResource(VirtualFile file) {
+ VirtualFile parent = file.getParent();
+ return parent != null && parent.getName().equals("standardSchemas");
+ }
+
+ @Override
+ public boolean isUserResource(VirtualFile file) {
+ return myResourceLocations.contains(file.getUrl());
+ }
+
+ @Nullable
+ static <T> Map<String, T> getMap(@NotNull final Map<String, Map<String, T>> resources,
+ @Nullable final String version,
+ final boolean create) {
+ Map<String, T> map = resources.get(version);
+ if (map == null) {
+ if (create) {
+ map = ContainerUtil.newHashMap();
+ resources.put(version, map);
+ }
+ else if (version == null || !version.equals(DEFAULT_VERSION)) {
+ map = resources.get(DEFAULT_VERSION);
+ }
+ }
+
+ return map;
+ }
+
+ public String getResourceLocation(String url) {
+ return getResourceLocation(url, DEFAULT_VERSION);
+ }
+
+ public String getResourceLocation(@NonNls String url, String version) {
+ String result = getUserResource(url, version);
+ if (result == null) {
+ XMLCatalogManager manager = getCatalogManager();
+ if (manager != null) {
+ result = manager.resolve(url);
+ }
+ }
+ if (result == null) {
+ result = getStdResource(url, version);
+ }
+ if (result == null) {
+ result = url;
+ }
+ return result;
+ }
+
+ @Override
+ @Nullable
+ public String getUserResource(Project project, String url, String version) {
+ String resource = getProjectResources(project).getUserResource(url, version);
+ return resource == null ? getUserResource(url, version) : resource;
+ }
+
+ @Override
+ @Nullable
+ public String getStdResource(String url, String version) {
+ Map<String, Resource> map = getMap(myStdResources.getValue(), version, false);
+ if (map != null) {
+ Resource resource = map.get(url);
+ return resource == null ? null : resource.getResourceUrl();
+ }
+ else {
+ return null;
+ }
+ }
+
+ @Nullable
+ private String getUserResource(String url, String version) {
+ Map<String, String> map = getMap(myResources, version, false);
+ return map != null ? map.get(url) : null;
+ }
+
+ public String getResourceLocation(@NonNls String url, @NotNull Project project) {
+ String location = getProjectResources(project).getResourceLocation(url);
+ return location == null || location.equals(url) ? getResourceLocation(url) : location;
+ }
+
+ public String getResourceLocation(@NonNls String url, String version, @NotNull Project project) {
+ String location = getProjectResources(project).getResourceLocation(url, version);
+ return location == null || location.equals(url) ? getResourceLocation(url, version) : location;
+ }
+
+ @Nullable
+ public PsiFile getResourceLocation(@NotNull @NonNls final String url, @NotNull final PsiFile baseFile, final String version) {
+ final XmlFile schema = XmlSchemaProvider.findSchema(url, baseFile);
+ if (schema != null) {
+ return schema;
+ }
+ final String location = getResourceLocation(url, version, baseFile.getProject());
+ return XmlUtil.findXmlFile(baseFile, location);
+ }
+
+ public String[] getResourceUrls(FileType fileType, final boolean includeStandard) {
+ return getResourceUrls(fileType, DEFAULT_VERSION, includeStandard);
+ }
+
+ public String[] getResourceUrls(@Nullable final FileType fileType, @NonNls final String version, final boolean includeStandard) {
+ final List<String> result = new LinkedList<String>();
+ addResourcesFromMap(result, version, myResources);
+
+ if (includeStandard) {
+ addResourcesFromMap(result, version, myStdResources.getValue());
+ }
+
+ return ArrayUtil.toStringArray(result);
+ }
+
+ private static <T> void addResourcesFromMap(final List<String> result,
+ String version,
+ Map<String, Map<String, T>> resourcesMap) {
+ Map<String, T> resources = getMap(resourcesMap, version, false);
+ if (resources == null) return;
+ result.addAll(resources.keySet());
+ }
+
+ @TestOnly
+ public static void addTestResource(final String url, final String location, Disposable parentDisposable) {
+ final ExternalResourceManagerExImpl instance = (ExternalResourceManagerExImpl)getInstance();
+ ApplicationManager.getApplication().runWriteAction(new Runnable() {
+ public void run() {
+ instance.addResource(url, location);
+ }
+ });
+ Disposer.register(parentDisposable, new Disposable() {
+ @Override
+ public void dispose() {
+ ApplicationManager.getApplication().runWriteAction(new Runnable() {
+ public void run() {
+ instance.removeResource(url);
+ }
+ });
+ }
+ });
+ }
+ public void addResource(String url, String location) {
+ addResource(url, DEFAULT_VERSION, location);
+ }
+
+ public void addResource(@NonNls String url, @NonNls String version, @NonNls String location) {
+ ApplicationManager.getApplication().assertWriteAccessAllowed();
+ addSilently(url, version, location);
+ fireExternalResourceChanged();
+ }
+
+ private void addSilently(String url, String version, String location) {
+ final Map<String, String> map = getMap(myResources, version, true);
+ assert map != null;
+ map.put(url, location);
+ myResourceLocations.add(location);
+ myModificationCount++;
+ }
+
+ public void removeResource(String url) {
+ removeResource(url, DEFAULT_VERSION);
+ }
+
+ public void removeResource(String url, String version) {
+ ApplicationManager.getApplication().assertWriteAccessAllowed();
+ Map<String, String> map = getMap(myResources, version, false);
+ if (map != null) {
+ String location = map.remove(url);
+ if (location != null) {
+ myResourceLocations.remove(location);
+ }
+ myModificationCount++;
+ fireExternalResourceChanged();
+ }
+ }
+
+ @Override
+ public void removeResource(String url, @NotNull Project project) {
+ getProjectResources(project).removeResource(url);
+ }
+
+ @Override
+ public void addResource(@NonNls String url, @NonNls String location, @NotNull Project project) {
+ getProjectResources(project).addResource(url, location);
+ }
+
+ public String[] getAvailableUrls() {
+ Set<String> urls = new HashSet<String>();
+ for (Map<String, String> map : myResources.values()) {
+ urls.addAll(map.keySet());
+ }
+ return ArrayUtil.toStringArray(urls);
+ }
+
+ @Override
+ public String[] getAvailableUrls(Project project) {
+ return getProjectResources(project).getAvailableUrls();
+ }
+
+ public void clearAllResources() {
+ myResources.clear();
+ myIgnoredResources.clear();
+ }
+
+ public void clearAllResources(Project project) {
+ ApplicationManager.getApplication().assertWriteAccessAllowed();
+ clearAllResources();
+ getProjectResources(project).clearAllResources();
+ myModificationCount++;
+ fireExternalResourceChanged();
+ }
+
+ public void addIgnoredResource(String url) {
+ ApplicationManager.getApplication().assertWriteAccessAllowed();
+ addIgnoredSilently(url);
+ fireExternalResourceChanged();
+ }
+
+ private void addIgnoredSilently(String url) {
+ myIgnoredResources.add(url);
+ myModificationCount++;
+ }
+
+ public void removeIgnoredResource(String url) {
+ ApplicationManager.getApplication().assertWriteAccessAllowed();
+ if (myIgnoredResources.remove(url)) {
+ myModificationCount++;
+ fireExternalResourceChanged();
+ }
+ }
+
+ public boolean isIgnoredResource(String url) {
+ myStdResources.getValue(); // ensure ignored resources are loaded
+ return myIgnoredResources.contains(url) || isImplicitNamespaceDescriptor(url);
+ }
+
+ private static boolean isImplicitNamespaceDescriptor(String url) {
+ for (ImplicitNamespaceDescriptorProvider namespaceDescriptorProvider : Extensions
+ .getExtensions(ImplicitNamespaceDescriptorProvider.EP_NAME)) {
+ if (namespaceDescriptorProvider.getNamespaceDescriptor(null, url, null) != null) return true;
+ }
+ return false;
+ }
+
+ public String[] getIgnoredResources() {
+ myStdResources.getValue(); // ensure ignored resources are loaded
+ return ArrayUtil.toStringArray(myIgnoredResources);
+ }
+
+ public long getModificationCount() {
+ return myModificationCount;
+ }
+
+ @Override
+ public long getModificationCount(@NotNull Project project) {
+ return getProjectResources(project).getModificationCount();
+ }
+
+ public void readExternal(Element element) throws InvalidDataException {
+ final ExpandMacroToPathMap macroExpands = new ExpandMacroToPathMap();
+ myPathMacros.addMacroExpands(macroExpands);
+ macroExpands.substitute(element, SystemInfo.isFileSystemCaseSensitive);
+
+ myModificationCount++;
+ for (final Object o1 : element.getChildren(RESOURCE_ELEMENT)) {
+ Element e = (Element)o1;
+ addSilently(e.getAttributeValue(URL_ATTR), DEFAULT_VERSION, e.getAttributeValue(LOCATION_ATTR).replace('/', File.separatorChar));
+ }
+
+ for (final Object o : element.getChildren(IGNORED_RESOURCE_ELEMENT)) {
+ Element e = (Element)o;
+ addIgnoredSilently(e.getAttributeValue(URL_ATTR));
+ }
+
+ Element child = element.getChild(HTML_DEFAULT_DOCTYPE_ELEMENT);
+ if (child != null) {
+ String text = child.getText();
+ if (FileUtil.toSystemIndependentName(text).endsWith(".jar!/resources/html5-schema/html5.rnc")) {
+ text = HTML5_DOCTYPE_ELEMENT;
+ }
+ myDefaultHtmlDoctype = text;
+ }
+ Element catalogElement = element.getChild(CATALOG_PROPERTIES_ELEMENT);
+ if (catalogElement != null) {
+ myCatalogPropertiesFile = catalogElement.getTextTrim();
+ }
+ }
+
+ public void writeExternal(Element element) throws WriteExternalException {
+ final String[] urls = getAvailableUrls();
+ for (String url : urls) {
+ if (url == null) continue;
+ String location = getResourceLocation(url);
+ if (location == null) continue;
+ final Element e = new Element(RESOURCE_ELEMENT);
+
+ e.setAttribute(URL_ATTR, url);
+ e.setAttribute(LOCATION_ATTR, location.replace(File.separatorChar, '/'));
+ element.addContent(e);
+ }
+
+ final String[] ignoredResources = getIgnoredResources();
+ for (String ignoredResource : ignoredResources) {
+ final Element e = new Element(IGNORED_RESOURCE_ELEMENT);
+
+ e.setAttribute(URL_ATTR, ignoredResource);
+ element.addContent(e);
+ }
+
+ if (myDefaultHtmlDoctype != null && !HTML5_DOCTYPE_ELEMENT.equals(myDefaultHtmlDoctype)) {
+ final Element e = new Element(HTML_DEFAULT_DOCTYPE_ELEMENT);
+ e.setText(myDefaultHtmlDoctype);
+ element.addContent(e);
+ }
+ if (myCatalogPropertiesFile != null) {
+ Element properties = new Element(CATALOG_PROPERTIES_ELEMENT);
+ properties.setText(myCatalogPropertiesFile);
+ element.addContent(properties);
+ }
+ final ReplacePathToMacroMap macroReplacements = new ReplacePathToMacroMap();
+ PathMacrosImpl.getInstanceEx().addMacroReplacements(macroReplacements);
+ macroReplacements.substitute(element, SystemInfo.isFileSystemCaseSensitive);
+ }
+
+ public void addExternalResourceListener(ExternalResourceListener listener) {
+ myListeners.add(listener);
+ }
+
+ public void removeExternalResourceListener(ExternalResourceListener listener) {
+ myListeners.remove(listener);
+ }
+
+ private void fireExternalResourceChanged() {
+ for (ExternalResourceListener listener : myListeners) {
+ listener.externalResourceChanged();
+ }
+ }
+
+ Collection<Map<String, Resource>> getStandardResources() {
+ return myStdResources.getValue().values();
+ }
+
+
+ protected ExternalResourceManagerExImpl getProjectResources(Project project) {
+ return this;
+ }
+
+ @Override
+ @NotNull
+ public String getDefaultHtmlDoctype(@NotNull Project project) {
+ final String doctype = getProjectResources(project).myDefaultHtmlDoctype;
+ if (XmlUtil.XHTML_URI.equals(doctype)) {
+ return XmlUtil.XHTML4_SCHEMA_LOCATION;
+ }
+ else if (HTML5_DOCTYPE_ELEMENT.equals(doctype)) {
+ return Html5SchemaProvider.getHtml5SchemaLocation();
+ }
+ else {
+ return doctype;
+ }
+ }
+
+ @Override
+ public void setDefaultHtmlDoctype(@NotNull String defaultHtmlDoctype, @NotNull Project project) {
+ getProjectResources(project).setDefaultHtmlDoctype(defaultHtmlDoctype);
+ }
+
+ @Override
+ public String getCatalogPropertiesFile() {
+ return myCatalogPropertiesFile;
+ }
+
+ @Override
+ public void setCatalogPropertiesFile(String filePath) {
+ myCatalogManager = null;
+ myCatalogPropertiesFile = filePath;
+ myModificationCount++;
+ }
+
+ @Nullable
+ private XMLCatalogManager getCatalogManager() {
+ if (myCatalogManager == null && myCatalogPropertiesFile != null) {
+ myCatalogManager = new XMLCatalogManager(myCatalogPropertiesFile);
+ }
+ return myCatalogManager;
+ }
+
+ private void setDefaultHtmlDoctype(String defaultHtmlDoctype) {
+ myModificationCount++;
+
+ if (Html5SchemaProvider.getHtml5SchemaLocation().equals(defaultHtmlDoctype)) {
+ myDefaultHtmlDoctype = HTML5_DOCTYPE_ELEMENT;
+ }
+ else {
+ myDefaultHtmlDoctype = defaultHtmlDoctype;
+ }
+ fireExternalResourceChanged();
+ }
+
+ @TestOnly
+ public static void registerResourceTemporarily(final String url, final String location, Disposable disposable) {
+ ApplicationManager.getApplication().runWriteAction(new Runnable() {
+ public void run() {
+ getInstance().addResource(url, location);
+ }
+ });
+
+ Disposer.register(disposable, new Disposable() {
+ @Override
+ public void dispose() {
+ ApplicationManager.getApplication().runWriteAction(new Runnable() {
+ public void run() {
+ getInstance().removeResource(url);
+ }
+ });
+ }
+ });
+ }
+
+ static class Resource {
+ String file;
+ ClassLoader classLoader;
+ Class clazz;
+
+ @Nullable
+ String getResourceUrl() {
+
+ if (classLoader == null && clazz == null) return file;
+
+ final URL resource = clazz == null ? classLoader.getResource(file) : clazz.getResource(file);
+ classLoader = null;
+ clazz = null;
+ if (resource == null) {
+ String message = "Cannot find standard resource. filename:" + file + " class=" + classLoader;
+ if (ApplicationManager.getApplication().isUnitTestMode()) {
+ LOG.error(message);
+ }
+ else {
+ LOG.warn(message);
+ }
+
+ return null;
+ }
+
+ String path = FileUtil.unquote(resource.toString());
+ // this is done by FileUtil for windows
+ path = path.replace('\\','/');
+ file = path;
+ return path;
+ }
+
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ Resource resource = (Resource)o;
+
+ if (classLoader != resource.classLoader) return false;
+ if (clazz != resource.clazz) return false;
+ if (file != null ? !file.equals(resource.file) : resource.file != null) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return file.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return file + " for " + classLoader;
+ }
+ }
+}
diff --git a/xml/impl/src/com/intellij/javaee/InternalResourceProvider.java b/xml/xml-psi-impl/src/com/intellij/javaee/InternalResourceProvider.java
similarity index 100%
rename from xml/impl/src/com/intellij/javaee/InternalResourceProvider.java
rename to xml/xml-psi-impl/src/com/intellij/javaee/InternalResourceProvider.java
diff --git a/xml/impl/src/com/intellij/javaee/ResourceRegistrarImpl.java b/xml/xml-psi-impl/src/com/intellij/javaee/ResourceRegistrarImpl.java
similarity index 84%
rename from xml/impl/src/com/intellij/javaee/ResourceRegistrarImpl.java
rename to xml/xml-psi-impl/src/com/intellij/javaee/ResourceRegistrarImpl.java
index 10bb852..b3dcdcf 100644
--- a/xml/impl/src/com/intellij/javaee/ResourceRegistrarImpl.java
+++ b/xml/xml-psi-impl/src/com/intellij/javaee/ResourceRegistrarImpl.java
@@ -29,7 +29,7 @@
*/
public class ResourceRegistrarImpl implements ResourceRegistrar {
- private final Map<String, Map<String, ExternalResourceManagerImpl.Resource>> myResources = new HashMap<String, Map<String, ExternalResourceManagerImpl.Resource>>();
+ private final Map<String, Map<String, ExternalResourceManagerExImpl.Resource>> myResources = new HashMap<String, Map<String, ExternalResourceManagerExImpl.Resource>>();
private final List<String> myIgnored = new ArrayList<String>();
public void addStdResource(@NonNls String resource, @NonNls String fileName) {
@@ -41,9 +41,9 @@
}
public void addStdResource(@NonNls String resource, @NonNls String version, @NonNls String fileName, @Nullable Class klass, @Nullable ClassLoader classLoader) {
- final Map<String, ExternalResourceManagerImpl.Resource> map = ExternalResourceManagerImpl.getMap(myResources, version, true);
+ final Map<String, ExternalResourceManagerExImpl.Resource> map = ExternalResourceManagerExImpl.getMap(myResources, version, true);
assert map != null;
- ExternalResourceManagerImpl.Resource res = new ExternalResourceManagerImpl.Resource();
+ ExternalResourceManagerExImpl.Resource res = new ExternalResourceManagerExImpl.Resource();
res.file = fileName;
res.classLoader = classLoader;
res.clazz = klass;
@@ -74,7 +74,7 @@
addStdResource(resource, version, ExternalResourceManagerEx.STANDARD_SCHEMAS + fileName, clazz);
}
- public Map<String, Map<String, ExternalResourceManagerImpl.Resource>> getResources() {
+ public Map<String, Map<String, ExternalResourceManagerExImpl.Resource>> getResources() {
return myResources;
}
diff --git a/xml/impl/src/com/intellij/javaee/XMLCatalogManager.java b/xml/xml-psi-impl/src/com/intellij/javaee/XMLCatalogManager.java
similarity index 100%
rename from xml/impl/src/com/intellij/javaee/XMLCatalogManager.java
rename to xml/xml-psi-impl/src/com/intellij/javaee/XMLCatalogManager.java
diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/HtmlFileImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/HtmlFileImpl.java
index 4154cfe..90ca560 100644
--- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/HtmlFileImpl.java
+++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/HtmlFileImpl.java
@@ -34,6 +34,7 @@
return "HtmlFile:" + getName();
}
+ @Override
public XmlDocument getDocument() {
CompositeElement treeElement = calcTreeElement();
diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/SchemaReferencesProvider.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/SchemaReferencesProvider.java
index 8578453..8862ac8 100644
--- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/SchemaReferencesProvider.java
+++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/SchemaReferencesProvider.java
@@ -568,7 +568,7 @@
final XmlAttributeValue attributeValue = (XmlAttributeValue)element;
final String prefix = XmlUtil.findPrefixByQualifiedName(attributeValue.getValue());
if (prefix.length() > 0) {
- return new SchemaPrefixReference(attributeValue, TextRange.from(1, prefix.length()), prefix);
+ return new SchemaPrefixReference(attributeValue, TextRange.from(1, prefix.length()), prefix, null);
}
}
return null;
diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/SchemaPrefixReference.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/SchemaPrefixReference.java
index f8a4833..2c963a9 100644
--- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/SchemaPrefixReference.java
+++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/SchemaPrefixReference.java
@@ -37,16 +37,20 @@
private final SchemaPrefix myPrefix;
private final String myName;
+ @Nullable
+ private final TagNameReference myTagNameReference;
/**
*
* @param element XmlAttribute || XmlAttributeValue
* @param range
* @param name
+ * @param reference
*/
- public SchemaPrefixReference(XmlElement element, TextRange range, String name) {
+ public SchemaPrefixReference(XmlElement element, TextRange range, String name, TagNameReference reference) {
super(element, range);
myName = name;
+ myTagNameReference = reference;
if (myElement instanceof XmlAttribute && (((XmlAttribute)myElement).isNamespaceDeclaration())) {
myPrefix = new SchemaPrefix((XmlAttribute)myElement, getRangeInElement(), myName);
}
@@ -108,4 +112,9 @@
public boolean isPrefixReference() {
return true;
}
+
+ @Nullable
+ public TagNameReference getTagNameReference() {
+ return myTagNameReference;
+ }
}
diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeImpl.java
index a7aff78..8923767 100644
--- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeImpl.java
+++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeImpl.java
@@ -325,13 +325,13 @@
final String prefix = XmlUtil.findPrefixByQualifiedName(getName());
final TextRange range =
prefix.length() == 0 ? TextRange.from(getName().length(), 0) : TextRange.from(prefix.length() + 1, localName.length());
- refs[0] = new SchemaPrefixReference(this, range, localName);
+ refs[0] = new SchemaPrefixReference(this, range, localName, null);
}
else {
final String prefix = getNamespacePrefix();
if (prefix.length() > 0 && getLocalName().length() > 0) {
refs = new PsiReference[referencesFromProviders.length + 2];
- refs[0] = new SchemaPrefixReference(this, TextRange.from(0, prefix.length()), prefix);
+ refs[0] = new SchemaPrefixReference(this, TextRange.from(0, prefix.length()), prefix, null);
refs[1] = new XmlAttributeReference(this);
}
else {
diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlFileImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlFileImpl.java
index c85085f..780eee7 100644
--- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlFileImpl.java
+++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlFileImpl.java
@@ -42,6 +42,7 @@
super(elementType, elementType, viewProvider);
}
+ @Override
public XmlDocument getDocument() {
PsiElement child = getFirstChild();
while (child != null) {
@@ -58,11 +59,13 @@
return document == null ? null : document.getRootTag();
}
+ @Override
public boolean processElements(PsiElementProcessor processor, PsiElement place){
final XmlDocument document = getDocument();
return document == null || document.processElements(processor, place);
}
+ @Override
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof XmlElementVisitor) {
((XmlElementVisitor)visitor).visitXmlFile(this);
@@ -77,6 +80,7 @@
}
private FileType myType = null;
+ @Override
@NotNull
public FileType getFileType() {
if (myType == null) {
@@ -102,12 +106,14 @@
return getLanguage() == XHTMLLanguage.INSTANCE || getLanguage() == HTMLLanguage.INSTANCE;
}
+ @Override
public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, @NotNull PsiElement place) {
return super.processDeclarations(processor, state, lastParent, place) &&
(!isWebFileType() || ScriptSupportUtil.processDeclarations(this, processor, state, lastParent, place));
}
+ @Override
public GlobalSearchScope getFileResolveScope() {
return ProjectScope.getAllScope(getProject());
}
diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlTagImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlTagImpl.java
index 30496bc..81645bd 100644
--- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlTagImpl.java
+++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlTagImpl.java
@@ -180,7 +180,8 @@
}
private SchemaPrefixReference createPrefixReference(ASTNode startTagName, String prefix, TagNameReference tagRef) {
- return new SchemaPrefixReference(this, TextRange.from(startTagName.getStartOffset() - getStartOffset(), prefix.length()), prefix);
+ return new SchemaPrefixReference(this, TextRange.from(startTagName.getStartOffset() - getStartOffset(), prefix.length()), prefix,
+ tagRef);
}
@Override
diff --git a/xml/xml-psi-impl/src/com/intellij/xml/XmlCoreEnvironment.java b/xml/xml-psi-impl/src/com/intellij/xml/XmlCoreEnvironment.java
index d844267..cdf33c3 100644
--- a/xml/xml-psi-impl/src/com/intellij/xml/XmlCoreEnvironment.java
+++ b/xml/xml-psi-impl/src/com/intellij/xml/XmlCoreEnvironment.java
@@ -7,10 +7,7 @@
import com.intellij.ide.highlighter.HtmlFileType;
import com.intellij.ide.highlighter.XHtmlFileType;
import com.intellij.ide.highlighter.XmlFileType;
-import com.intellij.javaee.CoreExternalResourceManager;
-import com.intellij.javaee.ExternalResourceManager;
-import com.intellij.javaee.ExternalResourceManagerEx;
-import com.intellij.javaee.ImplicitNamespaceDescriptorProvider;
+import com.intellij.javaee.*;
import com.intellij.lang.LanguageASTFactory;
import com.intellij.lang.LanguageParserDefinitions;
import com.intellij.lang.dtd.DTDLanguage;
@@ -70,9 +67,12 @@
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), XmlAttributeDescriptorsProvider.EP_NAME, XmlAttributeDescriptorsProvider.class);
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), XmlExtension.EP_NAME, XmlExtension.class);
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), HtmlEmbeddedTokenTypesProvider.EXTENSION_POINT_NAME, HtmlEmbeddedTokenTypesProvider.class);
+ CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), StandardResourceProvider.EP_NAME, StandardResourceProvider.class);
+ CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), StandardResourceEP.EP_NAME, StandardResourceEP.class);
appEnvironment.addExtension(MetaDataContributor.EP_NAME, new XmlApplicationComponent());
appEnvironment.addExtension(FileBasedIndexExtension.EXTENSION_POINT_NAME, new XmlNamespaceIndex());
+ appEnvironment.addExtension(StandardResourceProvider.EP_NAME, new InternalResourceProvider());
appEnvironment.registerApplicationService(ExternalResourceManager.class, createExternalResourceManager());
}
diff --git a/xml/xml-psi-impl/src/com/intellij/xml/impl/ExternalDocumentValidator.java b/xml/xml-psi-impl/src/com/intellij/xml/impl/ExternalDocumentValidator.java
index 4ea997f..32f592d 100644
--- a/xml/xml-psi-impl/src/com/intellij/xml/impl/ExternalDocumentValidator.java
+++ b/xml/xml-psi-impl/src/com/intellij/xml/impl/ExternalDocumentValidator.java
@@ -18,7 +18,7 @@
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
import com.intellij.codeInsight.daemon.Validator;
import com.intellij.codeInspection.InspectionProfile;
-import com.intellij.codeInspection.InspectionProfileEntry;
+import com.intellij.codeInspection.ex.InspectionToolWrapper;
import com.intellij.ide.highlighter.XHtmlFileType;
import com.intellij.ide.highlighter.XmlFileType;
import com.intellij.lang.Language;
@@ -45,6 +45,7 @@
import com.intellij.xml.util.XmlResourceResolver;
import com.intellij.xml.util.XmlUtil;
import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
import org.xml.sax.SAXParseException;
import java.lang.ref.WeakReference;
@@ -112,6 +113,7 @@
final List<ValidationInfo> results = new LinkedList<ValidationInfo>();
myHost = new Validator.ValidationHost() {
+ @Override
public void addMessage(PsiElement context, String message, int type) {
final ValidationInfo o = new ValidationInfo();
@@ -121,19 +123,23 @@
o.type = type;
}
- public void addMessage(final PsiElement context, final String message, final ErrorType type) {
+ @Override
+ public void addMessage(final PsiElement context, final String message, @NotNull final ErrorType type) {
addMessage(context, message, type.ordinal());
}
};
myHandler.setErrorReporter(new ErrorReporter(myHandler) {
+ @Override
public boolean isStopOnUndeclaredResource() {
return true;
}
+ @Override
public void processError(final SAXParseException e, final ValidateXmlActionHandler.ProblemType warning) {
try {
ApplicationManager.getApplication().runReadAction(new Runnable() {
+ @Override
public void run() {
if (e.getPublicId() != null) {
return;
@@ -341,7 +347,7 @@
if (containingFile.getViewProvider() instanceof TemplateLanguageFileViewProvider) {
return;
}
-
+
final FileType fileType = containingFile.getViewProvider().getVirtualFile().getFileType();
if (fileType != XmlFileType.INSTANCE && fileType != XHtmlFileType.INSTANCE) {
return;
@@ -360,7 +366,7 @@
final Project project = document.getProject();
final InspectionProfile profile = InspectionProjectProfileManager.getInstance(project).getInspectionProfile();
- final InspectionProfileEntry toolWrapper =
+ final InspectionToolWrapper toolWrapper =
profile.getInspectionTool(INSPECTION_SHORT_NAME, containingFile);
if (toolWrapper == null) return;
diff --git a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlNSDescriptorImpl.java b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlNSDescriptorImpl.java
index 1c704a0..1575367 100644
--- a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlNSDescriptorImpl.java
+++ b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlNSDescriptorImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -396,7 +396,7 @@
if (namespace.length() > 0) {
return checkSchemaNamespace(namespace);
}
- return StringUtil.startsWithConcatenationOf(context.getName(), XSD_PREFIX, ":");
+ return StringUtil.startsWithConcatenation(context.getName(), XSD_PREFIX, ":");
}
static @NotNull XmlNSDescriptorImpl getNSDescriptorToSearchIn(XmlTag rootTag, final String name, XmlNSDescriptorImpl defaultNSDescriptor) {
diff --git a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlSchemaTagsProcessor.java b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlSchemaTagsProcessor.java
index 3a703c1..b884ced 100644
--- a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlSchemaTagsProcessor.java
+++ b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlSchemaTagsProcessor.java
@@ -16,6 +16,7 @@
package com.intellij.xml.impl.schema;
import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiReference;
import com.intellij.psi.xml.XmlAttribute;
import com.intellij.psi.xml.XmlAttributeValue;
import com.intellij.psi.xml.XmlTag;
@@ -124,7 +125,9 @@
if (ref != null) {
XmlAttributeValue value = ref.getValueElement();
if (value != null) {
- return value.getReferences()[0].resolve();
+ PsiReference[] references = value.getReferences();
+ if (references.length > 0)
+ return references[0].resolve();
}
}
return null;
diff --git a/xml/xml-psi-impl/src/com/intellij/xml/index/XmlNamespaceIndex.java b/xml/xml-psi-impl/src/com/intellij/xml/index/XmlNamespaceIndex.java
index efb006b..4806b87 100644
--- a/xml/xml-psi-impl/src/com/intellij/xml/index/XmlNamespaceIndex.java
+++ b/xml/xml-psi-impl/src/com/intellij/xml/index/XmlNamespaceIndex.java
@@ -46,7 +46,7 @@
@Nullable
public static String getNamespace(@NotNull VirtualFile file, final Project project, PsiFile context) {
- if (DumbService.isDumb(project) || (context != null && XmlUtil.isStubBuilding(context))) {
+ if (DumbService.isDumb(project) || (context != null && XmlUtil.isStubBuilding())) {
try {
return XsdNamespaceBuilder.computeNamespace(file.getInputStream());
}
@@ -170,7 +170,7 @@
@Nullable final String version,
@NotNull PsiFile file) {
- if (DumbService.isDumb(file.getProject()) || XmlUtil.isStubBuilding(file)) return null;
+ if (DumbService.isDumb(file.getProject()) || XmlUtil.isStubBuilding()) return null;
IndexedRelevantResource<String,XsdNamespaceBuilder> resource =
guessSchema(namespace, tagName, version, ModuleUtilCore.findModuleForPsiElement(file));
@@ -189,7 +189,7 @@
if (!dtdUri.endsWith(".dtd") ||
DumbService.isDumb(baseFile.getProject()) ||
- XmlUtil.isStubBuilding(baseFile)) return null;
+ XmlUtil.isStubBuilding()) return null;
String dtdFileName = new File(dtdUri).getName();
List<IndexedRelevantResource<String, XsdNamespaceBuilder>>
diff --git a/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlUtil.java b/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlUtil.java
index e502a5e..d72f932 100644
--- a/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlUtil.java
+++ b/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlUtil.java
@@ -119,7 +119,7 @@
"body", "object", "applet", "ins", "del", "dd", "li", "button", "th", "td", "iframe", "comment", "nobr"
};
- // flow elements are block or inline, so they shuld not close <p> for example
+ // flow elements are block or inline, so they should not close <p> for example
@NonNls private static final String[] POSSIBLY_INLINE_TAGS =
{"a", "abbr", "acronym", "applet", "b", "basefont", "bdo", "big", "br", "button",
"cite", "code", "del", "dfn", "em", "font", "i", "iframe", "img", "input", "ins",
diff --git a/xml/xml-psi-impl/src/com/intellij/xml/util/XmlUtil.java b/xml/xml-psi-impl/src/com/intellij/xml/util/XmlUtil.java
index 09fa8ad..ee38a7e 100644
--- a/xml/xml-psi-impl/src/com/intellij/xml/util/XmlUtil.java
+++ b/xml/xml-psi-impl/src/com/intellij/xml/util/XmlUtil.java
@@ -168,7 +168,12 @@
@NonNls public static final String WSDL_SCHEMA_URI = "http://schemas.xmlsoap.org/wsdl/";
public static final String XHTML4_SCHEMA_LOCATION;
- public final static Key<Boolean> BUILDING_DOM_STUBS = Key.create("building dom stubs...");
+ public final static ThreadLocal<Boolean> BUILDING_DOM_STUBS = new ThreadLocal<Boolean>() {
+ @Override
+ protected Boolean initialValue() {
+ return Boolean.FALSE;
+ }
+ };
@NonNls private static final String FILE = "file:";
@NonNls private static final String CLASSPATH = "classpath:/";
@NonNls private static final String URN = "urn:";
@@ -626,8 +631,8 @@
return tagName.subSequence(pos + 1, tagName.length());
}
- public static boolean isStubBuilding(PsiFile file) {
- return Boolean.TRUE.equals(file.getUserData(BUILDING_DOM_STUBS));
+ public static boolean isStubBuilding() {
+ return BUILDING_DOM_STUBS.get();
}
/**
@@ -735,9 +740,13 @@
if (file != null) {
for (XmlFileNSInfoProvider provider : nsProviders) {
- if (provider.overrideNamespaceFromDocType(file)) {
- overrideNamespaceFromDocType = true;
- break;
+ try {
+ if (provider.overrideNamespaceFromDocType(file)) {
+ overrideNamespaceFromDocType = true;
+ break;
+ }
+ }
+ catch (AbstractMethodError ignored) {
}
}
}
diff --git a/xml/xml-psi-impl/xml-psi-impl.iml b/xml/xml-psi-impl/xml-psi-impl.iml
index b12b84d..ea9932a 100644
--- a/xml/xml-psi-impl/xml-psi-impl.iml
+++ b/xml/xml-psi-impl/xml-psi-impl.iml
@@ -15,6 +15,7 @@
<orderEntry type="module" module-name="projectModel-impl" />
<orderEntry type="module" module-name="indexing-impl" />
<orderEntry type="library" name="Xerces" level="project" />
+ <orderEntry type="library" name="XmlBeans" level="project" />
</component>
</module>