diff options
author | Tor Norbye <tnorbye@google.com> | 2013-08-29 10:40:28 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2013-08-29 10:40:35 -0700 |
commit | 932259520ebaedeb2ccf4b7594bad50c700963d7 (patch) | |
tree | 2b52334b8a019d9652625b1432deac11a7c4b31e /java | |
parent | e47d04f1f804b9e725b768725da436af6788f19b (diff) | |
download | idea-932259520ebaedeb2ccf4b7594bad50c700963d7.tar.gz |
Snapshot 1c7917945d4706cdbb32b599f81abd05c0251e32 from idea/132.27 branch of git://git.jetbrains.org/idea/community.git
1c79179: 2013-08-29 Yann Cébron - DevKit: smart EP "implementation" highlighting/completion
f3a83bc: 2013-08-29 Roman Shevchenko - IDEA-112827 (NPE in error reporter)
464a45b: 2013-08-29 Anna Kozlova - move pin button to the right side of popup (IDEA-112435)
1635be8: 2013-08-29 Yann Cébron - Dom EPs: add some <with> tags
6bcac42: 2013-08-29 Roman Shevchenko - IDEA-112824 (suppress SVN logging for normal use)
16d0ba4: 2013-08-29 Anna Kozlova - NPE
285509c4c: 2013-08-28 Max Medvedev - IDEA-111110 Groovy: Introduce Field Refactoring doesn't suggest to choose destination class
5415af1: 2013-08-28 Yann Cébron - Merge remote-tracking branch 'origin/master'
8462f3b: 2013-08-28 Dmitry Jemerov - cleanup
2ad6100: 2013-08-28 Yann Cébron - Merge remote-tracking branch 'origin/master'
9de8bfc: 2013-08-28 Dmitry Jemerov - Merge branch 'master' of git://github.com/niktrop/intellij-community into pull92
6315415: 2013-08-28 Dmitry Jemerov - cleanup
7281b73: 2013-08-28 Dmitry Jemerov - Merge branch 'cjfm3' of git://github.com/max-kammerer/intellij-community into pull87
6e31350: 2013-08-28 Dmitry Jemerov - fix couple of issues with https://github.com/JetBrains/intellij-community/pull/94
3695aa0: 2013-08-28 Dmitry Jemerov - Merge branch 'master' of git://github.com/asedunov/intellij-community into pull94
ce2c15f: 2013-08-28 Yann Cébron - fix javadoc @see link
6794ead: 2013-08-28 Anna Kozlova - skip adverts when server doesn't accept provided info
851da00: 2013-08-28 Anna Kozlova - skip advs in tests and headless mode
cddbc28: 2013-08-28 Anna Kozlova - EA-48802 - assert: JavaFileManagerBase.findClass
1eafaae: 2013-08-28 Anna Kozlova - EA-49147 - NPE: UnusedDeclarationInspection.isReadObjectMethod
f1a2040: 2013-08-28 Anna Kozlova - EA-49155 - NPE: JavaChangeSignatureDialog.doCalculateSignature
2684709: 2013-08-28 Dmitry Jemerov - MalformedFormatStringInspectionTest fixed
ce8088e: 2013-08-28 Evgeny Gerashchenko - Removed extra checking for duplicate annotations in one file. It is performed when reading file anyway.
9d4c7ca: 2013-08-28 Dmitry Trofimov - Merge remote-tracking branch 'origin/master'
2fd8641: 2013-08-28 Eugene Kudelevsky - add possibility to setup lookup element for XML attribute values; IDEA-102167 layout_* attributes should go first
3b065b1: 2013-08-28 Dmitry Trofimov - Merge remote-tracking branch 'origin/master'
d8d9168: 2013-08-28 Dmitry Trofimov - Libs update.
28a95a6: 2013-08-28 Alexey Kudravtsev - compilation
d4a0d69: 2013-08-28 Alexey Kudravtsev - notnull
f9f8006: 2013-08-28 Alexey Kudravtsev - moved to appropriate package
4d058f8: 2013-08-28 Alexey Kudravtsev - cleanup
111301a: 2013-08-28 Alexey Kudravtsev - extra method
01e59b0: 2013-08-28 Alexey Kudravtsev - doc
da966ae: 2013-08-28 Alexey Kudravtsev - cleanup
7503616: 2013-08-28 Alexey Kudravtsev - add method to javaversionservice
7d6de4f: 2013-08-28 Alexey Kudravtsev - notnull
dee081f: 2013-08-27 Alexey Kudravtsev - statistics
dd327c0: 2013-08-28 Dmitry Trofimov - Focus fixes.
7231931: 2013-08-28 Vladimir Krivosheev - WEB-8988 Return "open in browser" in context menu
2102255: 2013-08-28 Roman Shevchenko - app: install-over range extended for next EAPs
ddad3bb: 2013-08-28 Dmitry Avdeev - IDEA-112728 Can't create new task from tasks menu in toolbar: no need to fix lost typing for Go To Task
a8160c2: 2013-08-28 Dmitry Avdeev - typo
7328cbd: 2013-08-28 Dmitry Avdeev - cleanup
abbdb5a: 2013-08-28 Dmitry Avdeev - cleanup
a5c8503: 2013-08-28 Dmitry Avdeev - do not allow empty task name
e8daf37: 2013-08-28 Dmitry Avdeev - simplified
dff28d3: 2013-08-28 Dmitry Avdeev - simplified
38513a8: 2013-08-28 Dmitry Avdeev - cleanup
c09dd55: 2013-08-28 Vladimir Krivosheev - VariablesGroup — avoid array copy
8f3c91f: 2013-08-28 Roman Shevchenko - java: correct character escaping in decompiler
9a19e30: 2013-08-28 Dmitry Trofimov - Fixed hiding and activating of the terminal (PY-10669).
df672ba: 2013-08-28 Dmitry Trofimov - Terminal system settings refactored.
4653b54: 2013-08-28 Anna Kozlova - unknown features equality fixed
2896270: 2013-08-28 Anna Kozlova - ensure read access
ccff3af: 2013-08-28 Anna Kozlova - suggest to download plugins by unknown run configurations
9c8a3d2: 2013-08-28 Konstantin Bulenkov - include os.arch and jdk build number in about
861984c: 2013-08-28 Denis Fokin - IDEA-108265. We should not do anything if an empty array is passed.
a6b3441: 2013-08-28 Sergey Simonchik - EA-49063 - AIOOBE: ScriptRunnerUtil$ScriptOutput.onTextAvailable
845ee5c: 2013-08-28 Vladimir Krivosheev - value nullability
36121a2: 2013-08-28 Konstantin Kolosovsky - Merge branch 'svn1_8_new'
1515b70: 2013-08-28 Mikhail Golubev - Merge remote-tracking branch 'origin/master'
33d684e0: 2013-08-28 Mikhail Golubev - IDEA-110012 Not all Redmine Issues Available on "Open Task" (Limited to 100?)
39899b1: 2013-08-28 Bas Leijdekkers - IDEA-112782 (Change signature dialog shows unexpected 'cannot resolve symbol' message)
e469928: 2013-08-28 Anna Kozlova - accept test config methods in non-test classes (IDEA-112537)
b53abed: 2013-08-27 Anna Kozlova - fix typo
3074f49: 2013-08-28 Dmitry Avdeev - IDEA-112781 Open YouTrack task: Create changelist doesn't work with SVN ?
43c8897: 2013-08-27 Dmitry Avdeev - cleanup
ff6217a: 2013-08-28 Kirill Likhodedov - Annotate overriding methods
8e2d0e1: 2013-08-28 Roman Shevchenko - terminal: platform's Guava should be good enough for the plugin
2055780: 2013-08-27 Roman Shevchenko - EA-49123 (do not load extensions from static initializer)
116dc30: 2013-08-27 Roman Shevchenko - EA-49235 (check proxy port)
2b4f96f: 2013-08-27 Roman Shevchenko - EA-49235 (code readability)
ed03bca: 2013-08-27 Roman Shevchenko - EA-49142 (NPE, cleanup)
e6053d0: 2013-08-27 Roman Shevchenko - EA-49102 (face user with printing errors)
a748474: 2013-08-28 Vladimir Krivosheev - 4.1.0. update netty (now it is not patched build, https://github.com/netty/netty/pull/1762)
3c60901: 2013-08-28 Konstantin Bulenkov - better selection for mixed languages
20decc3: 2013-08-28 Konstantin Bulenkov - fix selection for files with multiple languages
878ad26: 2013-08-27 Max Medvedev - IDEA-111100 Groovy: Introduce Variable/Parameter Refactorings don't suggest to replace occurrences if applied to expressions inside code blocks
8a60662: 2013-08-27 Max Medvedev - IDEA-110981 Groovy: "Split into declaration and assignment" intention leaves unnecessary "=" if applied to closures
77912c1: 2013-08-27 Max Medvedev - IDEA-111101 Groovy: In-Place Introduce Field: Alt+I mnemonic doesn't work in the refactoring preview
088f68e: 2013-08-27 Max Medvedev - IDEA-111027 Groovy: In-Place Introduce Variable: PIEAE at GrInplaceIntroducer.<init> on introducing a variable within one-line method/closure
a2210a4: 2013-08-27 Aleksei Sedunov - Extract inheritor candidate check into separate InheritanceChecker interface
f40be5e: 2013-08-27 Alexander Zolotov - Filter moduleAwareConfigurables by module
cf7704f: 2013-08-26 Alexander Zolotov - WEB-6452 SASS suggests functions at the top, instead of property values
165ccf7: 2013-08-27 Konstantin Kolosovsky - IDEA-94942 Fixed diff, annotate errors in history view after rename/move
7b6396a: 2013-08-27 Dmitry Jemerov - branch number 132
e176d25: 2013-08-27 Sergey Evdokimov - IDEA-112754 Maven import: NCDFE for org/jetbrains/plugins/groovy/util/ClassInstanceCache
43c49f6: 2013-08-27 Sergey Evdokimov - IDEA-112754 Maven import: NCDFE for org/jetbrains/plugins/groovy/util/ClassInstanceCache
377dd45: 2013-08-27 Konstantin Bulenkov - fix memory leak
203fb69: 2013-08-27 Sergey Simonchik - WEB-9011 Karma plugin ignored tests
3b896f2: 2013-08-27 Sergey Evdokimov - Make project unignored when new module is created by ignored project
9ae29c6: 2013-08-27 Sergey Evdokimov - Remove maven project from project tree when user deletes module. +review CR-IC-2084
0f0f39e: 2013-08-27 Vladimir Krivosheev - cleanup, Overrides
3dddec4: 2013-08-27 Vladimir Krivosheev - cleanup
a2fff55: 2013-08-27 Aleksey Pivovarov - Github: Add API function for loading Commit Comments
9bd1660: 2013-08-27 Aleksey Pivovarov - fix IndexOutOfBoundsException on inserting empty collection to empty model
46b8998: 2013-08-27 Nadya Zabrodina - exception during annotate copied file fixed
66640b2: 2013-08-27 Dmitry Trofimov - Merge remote-tracking branch 'origin/master'
c597bcc: 2013-08-27 Sergey Evdokimov - Remove maven project from project tree when user deletes module. +review CR-IC-2084
33e932a: 2013-08-27 Dmitry Trofimov - Merge remote-tracking branch 'origin/master'
7cc9cca: 2013-08-27 Vladislav.Soroka - IDEA-79466 gradle support should generate web module configuration
42e649d: 2013-08-27 Dmitry Jemerov - better names for couple of new classes added to API
5c70eaf: 2013-08-27 Dmitry Trofimov - Merge remote-tracking branch 'origin/master'
2e0f1fa: 2013-08-27 Dmitry Trofimov - Update lib.
dcc2c4b: 2013-08-27 Dmitry Trofimov - Override isRetina.
05b716b: 2013-08-27 nik - processing dependencies in JPS: @NotNull annotations and javadoc added
6314b6e: 2013-08-27 Dmitry Trofimov - Fixed for Retina.
9d1886c: 2013-08-27 Dmitry Avdeev - navigatable xsd documentation
0f389c5: 2013-08-27 Vladimir Krivosheev - hide internal class XValuePresenterAdapter
a0386eb: 2013-08-27 Mikhail Golubev - Merge remote-tracking branch 'origin/master'
53248dc: 2013-08-27 Vladimir Krivosheev - fix createPresenter
d0355b3: 2013-08-27 Sergey Evdokimov - Remove maven project from project tree when user deletes module. +review CR-IC @Anton.Makeev
fb48f62: 2013-08-27 Sergey Evdokimov - Optimization of MavenProjectsTree.isManagedFile()
6b123aa: 2013-08-27 nik - JPS dependencies enumerator: convenient method added
d4579e1: 2013-08-27 Dmitry Avdeev - UrlPsiReference promoted
3b1feea: 2013-08-27 Dmitry Avdeev - cleanup
ee18443: 2013-08-27 Dmitry Avdeev - cleanup
ca2484e: 2013-08-27 Dmitry Avdeev - cleanup
c9e045b: 2013-08-27 Vladimir Krivosheev - 1) methods "void setPresentation(@NonNls String name, @Nullable Icon icon, @NonNls @Nullable String type, @NonNls @NotNull String separator, @NonNls @NotNull String value, boolean hasChildren);" and "void setPresentation(@NonNls String name, @Nullable Icon icon, @NonNls @Nullable String type, @NonNls @NotNull String value, boolean hasChildren);"
b38d58a: 2013-08-27 Konstantin Kolosovsky - IDEA-94942 Fixed treating svn client warnings as errors
8cab12c: 2013-08-27 Dmitry Jemerov - separate UI and non-UI parts of MalformedFormatStringInspection
93e3fa6: 2013-08-20 Jason Holmes - Custom "Malformed format string" inspection
b9f6fde: 2013-08-27 nik - actions to mark/unmark roots in Project View refactored to support custom root types
0455e46: 2013-08-27 Aleksey Pivovarov - Github: remove useless listener
7f40613: 2013-08-27 Aleksey Pivovarov - Github: reset User on token change
c8a5402: 2013-08-27 Aleksey Pivovarov - Github: change layout
89769be: 2013-08-27 Aleksey Pivovarov - Github: add test
0d8ab04: 2013-08-27 Aleksey Pivovarov - Github: comment
cba103c: 2013-08-27 Dmitry Trofimov - Merge remote-tracking branch 'origin/master'
d6ca049: 2013-08-27 Anna Kozlova - allow autoPopup after custom symbols (IDEA-112571)
a70c338: 2013-08-27 Konstantin Bulenkov - IDEA-110846 File Structure pop-up doesn't work properly for template languages
4896775: 2013-08-27 Konstantin Bulenkov - recent files duplicates
05835fa: 2013-08-27 Fedor Korotkov - WEB-6328 Add support for HTML5 <main> element
2407d7b: 2013-08-27 Anna Kozlova - allow to call getValue without readAction as it was before
29cb25d: 2013-08-27 Dmitry Avdeev - fixing the leak
7d3932a: 2013-08-27 Dmitry Avdeev - IDEA-112708 Static classes in JSP class block are considered an error
f6dbce2: 2013-08-26 Mikhail Golubev - IDEA-112605 Task management: can't add Generic server: NoClassDefFoundError: XPathFileType
82c1dc1: 2013-08-27 Konstantin Kolosovsky - Merge branch 'svn1_8_new'
08d46f1: 2013-08-27 Alexey Kudravtsev - highlightVisitor moves and cleanup
e0fec9d: 2013-08-27 Alexey Kudravtsev - Merge remote-tracking branch 'origin/master'
e9b1dfc: 2013-08-27 Anna Kozlova - dumb smart lambda completion (IDEA-112553)
6da30a4: 2013-08-26 Alexey Kudravtsev - calculate column/offset: optimisation of the no-tabs case
c0990c4: 2013-08-26 Alexey Kudravtsev - race conditions?
135e250: 2013-08-26 Alexey Kudravtsev - notnull, cleanup
75b28ba: 2013-08-26 Alexey Kudravtsev - file was not rehighlighted on some changes
5647d35: 2013-08-26 Sergey Evdokimov - Make myManagedFilesPaths a Set to avoid duplication.
680dd76: 2013-08-27 Aleksey Pivovarov - Github: fix memory leak on Exception in setUp();
e3092b7: 2013-08-27 Dmitry Avdeev - IDEA-112611 Task management: DVCS: closing a task fails: "Cannot delete the branch master"
d12d4fe: 2013-08-27 Anna Kozlova - logging for EA-49099 - PIEAE: PsiAnchor$StubIndexReference.getStartOffset
3cc53fe: 2013-08-27 Anna Kozlova - revert changes in api
10fbef9: 2013-08-27 Roman Shevchenko - Test data updated
a5455ba: 2013-08-27 Dmitry Trofimov - Merge remote-tracking branch 'origin/master'
8ed3ae8: 2013-08-27 Dmitry Trofimov - Updated lib.
e6df583: 2013-08-27 Dmitry Trofimov - Added guava lib to terminal.
1853090: 2013-08-27 Dmitry Trofimov - Draw image Retina support.
a7ebcaf: 2013-08-27 Dmitry Trofimov - Open session action moved to constructor.
5176bfa: 2013-08-26 Sergey Evdokimov - Fix maven tests
291f740: 2013-08-26 Vladimir Krivosheev - we must check if any port free too
18d4be6: 2013-08-26 Vassiliy Kudryashov - IDEA-70769 Settings panel: increase speed of scrollbars
0c76aca: 2013-08-26 Vassiliy Kudryashov - IDEA-112524 Working directory for default rake tasks is changed to $MODULE_DIR$ after project's reopening
e2b7f6b: 2013-08-26 Konstantin Bulenkov - pattern dependent delay
1916142: 2013-08-26 Vladimir Krivosheev - cleanup
3da9dcd: 2013-08-26 Vladimir Krivosheev - done: custom binary request handler
e02eba9: 2013-08-26 Aleksey Pivovarov - Github: do not produce dozens of notifications
8e41d59: 2013-08-26 Aleksey Pivovarov - Simplify
78c800d: 2013-08-26 Aleksey Pivovarov - Github: respect 'max' parameter
3afb19f: 2013-08-26 Maxim.Mossienko - proper versioning of stub index when persistent enumerator version changes
c853e9e: 2013-08-26 Eugene Kudelevsky - IDEA-112376 add "importFilter" extension point to force using FQN when importing class
31281a9: 2013-08-26 Kirill Likhodedov - [git] Don't write empty lines to LOG.debug.
493b9fb: 2013-08-26 Dmitry Trofimov - Merge remote-tracking branch 'origin/master'
60384ba: 2013-08-26 Dmitry Trofimov - Enable Run local terminal action for Windows.
bfa8e61: 2013-08-26 Dmitry Jemerov - stupid typo fixed
04a76c3: 2013-08-26 Anna Kozlova - IDEA-112555 Bad code is green with method references on instance
8f5139d: 2013-08-26 Denis Fokin - IDEA-108265. Now user is asked whether the project should be opened in a new frame.
da958ab: 2013-08-26 Natalia Ukhorskaya - Decompile chars, bytes and shorts correctly
8008709: 2013-08-26 Roman Shevchenko - java: incorrect annotation decoding fixed
9f07ea5: 2013-08-26 Roman Shevchenko - logging
e07c905: 2013-08-26 Dmitry Trofimov - Merge remote-tracking branch 'origin/master'
e81832d: 2013-08-26 Dmitry Trofimov - This update fixes pty on windows.
e36607b: 2013-08-26 Konstantin Bulenkov - new renderer
9ea47a5: 2013-08-26 nik - source roots editors: obtain icons for content tree from extension
d52dfb8: 2013-08-26 nik - constants moved
710d3ba: 2013-08-26 niktrop - Code style fixed
aa8832d: 2013-08-26 Sergey Simonchik - code style: two subsequent ifs merged to reduce inner indent
ed88487: 2013-08-26 Konstantin Kolosovsky - IDEA-94942 Provide detailed error messages to user instead of general ones
e0df7a3: 2013-08-26 Vassiliy Kudryashov - IDEA-112524 Working directory for default rake tasks is changed to $MODULE_DIR$ after project's reopening
e60a55b: 2013-08-26 nik - source roots editors refactored: root type specific UI moved to extension
928ea20: 2013-08-26 Mikhail Golubev - Merge remote-tracking branch 'origin/master'
70d526d: 2013-08-26 Anna Kozlova - guardedBy itself support (IDEA-112565)
2e23cb8: 2013-08-26 Anna Kozlova - restore bytecode viewer for java classes
89dffc9: 2013-08-26 Anna Kozlova - cal property name: accept without any other checks non-letter prefixes (IDEA-112585)
bab044f: 2013-08-26 Vladimir Krivosheev - restore Alarm.cancelRequest
dd817dc: 2013-08-26 Sergey Simonchik - simplification
7046dc4: 2013-08-26 niktrop - Some refactoring for reusing GenerateEquals UI in scala plugin
44e4219: 2013-08-26 Sergey Evdokimov - IDEA-112529 Maven: code completion could work in file path value with property references
867be29: 2013-08-26 Denis Fokin - Jumplist libraries changes. This is a release version of dll with eliminated MSVCRT dependencies.
7b0029d: 2013-08-26 Anton Makeev - CIDR: language tests in windows +review CR-OC @micha
9bef3a2: 2013-08-26 Konstantin Kolosovsky - IDEA-94942 Updated cleanup behavior after previous command failed
8447776: 2013-08-26 Mikhail Golubev - Remove SelectorBasedResponseHandler#getSelectorFileType, delegate to #getResponseType instead. Add missing @NotNull annotation, update doc comments.
d7ecb44: 2013-08-26 Anna Kozlova - treat classes with before/after methods as test classes for bad declared exceptions (IDEA-112537)
4be2bcf: 2013-08-26 Anna Kozlova - restore suggestion to remove 'abstract' when method has body
c57c308: 2013-08-26 Anna Kozlova - local can be final inside lambda body (IDEA-112630)
b8170a6: 2013-08-26 Vladimir Krivosheev - isValuesCustomSorted, add or not SortValuesAction (alphabetically sort) TODO: this action should be moved to "Variables" as gear action
b56b744: 2013-08-26 Mikhail Golubev - Merge remote-tracking branch 'origin/master'
ba7e194: 2013-08-23 Mikhail Golubev - Migrate Assembla to new GenericRepository
dd0885d: 2013-08-23 Mikhail Golubev - Refactor TemplateVariable
aa94a3c: 2013-08-23 Mikhail Golubev - Add several tests of date parsing
0e7e61e: 2013-08-23 Mikhail Golubev - Reflective PsiElements creation in JqlParserDefinition
a5f3011: 2013-08-26 Konstantin Kolosovsky - IDEA-94942 Short refactoring (removed duplication)
01cd38b: 2013-08-26 Sergey Simonchik - unnecessary line removed
7c34a2a: 2013-08-26 Dmitry Avdeev - IDEA-60895 No completion for enumerated and boolean values of xml tags
8b83a30: 2013-08-26 Vladislav.Soroka - gradle: cosmetic UI fix
8ee6a76: 2013-08-26 Roman Shevchenko - Convenient debug logging
cde5373: 2013-08-26 Dmitry Avdeev - IDEA-60895 No completion for enumerated and boolean values of xml tags
75d9b47: 2013-08-24 Max Medvedev - IDEA-112621 Groovy: Remove explicit type declaration intention
d1c29fb: 2013-08-23 Max Medvedev - separate visit methods for all types of classes, enums, interfaces, annotation types, and anonymous classes
5eca3d0: 2013-08-23 Max Medvedev - Byte code viewer shows byte code for groovy scripts
c96d27f: 2013-08-23 Max Medvedev - Convert anonymous class to closure: don't insert 'as Runnable' if groovy version is at least 2.2
7e993a0: 2013-08-23 Max Medvedev - IDEA-112560 process only applicable mixins to a ref
c33dc4a: 2013-08-26 Roman Shevchenko - platform: unified loading of system libraries (done right)
d492a6f: 2013-08-25 Roman Shevchenko - logging
2f2b546: 2013-08-25 Roman Shevchenko - IDEA-112462 (allow plugins to extend lib search path)
2a39bf2: 2013-08-25 Maxim.Mossienko - restart lexer from 0 offset when searching from start
a0858dbf: 2013-08-25 Maxim.Mossienko - 20% more compact compiler caches (-50M for IDEA project)
5ce3373: 2013-08-25 Maxim.Mossienko - IDEA-111918 Find: comments / string literals only: just 1 entry is found in each comment or literal
68ffc65: 2013-08-25 Maxim.Mossienko - faster contol + shift + N / control + N by default
eb67af1: 2013-08-24 Vassiliy Kudryashov - IDEA-107413 Cannot drag'n'drop more than one item in Changes View
d5ed7b5: 2013-08-24 nik - store properties of source folder in JPS element
b3dd357: 2013-08-24 nik - typo
5b8b1ff: 2013-08-24 Kirill Likhodedov - Merge remote-tracking branch 'origin/master'
0dd284a: 2013-08-24 Kirill Likhodedov - Better assertion error in the DefaultLogger
3146c0b: 2013-08-23 Bas Leijdekkers - foreach can also initialize field
6356a11: 2013-08-23 Konstantin Bulenkov - completely refacrored
6ad3452: 2013-08-23 Anna Kozlova - show conflict on invert boolean and method references (IDEA-112572)
4726276: 2013-08-23 Anna Kozlova - extract method from lambda body: accept parameters of parent method (IDEA-112570)
16a5e32: 2013-08-23 Gregory.Shrago - EditorEx: permanent header API
edc3497: 2013-08-23 Konstantin Kolosovsky - IDEA-94942 Content retrieval from svn refactored to ClientFactory model
0f40312: 2013-08-23 Mikhail Golubev - Change JqlQuery methods, JqlTerminalClause should extend JqlClause
c335f2b: 2013-08-23 Mikhail Golubev - IDEA-111811 Task management: JIRA: JQL: code completion suggests nothing after closing parenthesis
6e6972a: 2013-08-23 Konstantin Kolosovsky - IDEA-94942 Annotate action
e9d5412: 2013-08-23 Mikhail Golubev - Update description of NATIVE_SEARCH feature in TaskRepository
3c948a8: 2013-08-22 Konstantin Kolosovsky - IDEA-94942 Code cleanup - unused parameters removed
64706df: 2013-08-22 Konstantin Kolosovsky - IDEA-112184
0e41cad: 2013-08-22 Konstantin Kolosovsky - IDEA-94942 Simple property client to fix SvnMergeProvider.isBinary implementation
8091bb0: 2013-08-22 Konstantin Kolosovsky - IDEA-94942 Implemented file conflicts resolving Updated "svn info" result parsing
040f405: 2013-08-21 Konstantin Kolosovsky - IDEA-94942 SvnBindClient - unsupported methods removed
cef0440: 2013-08-21 Konstantin Kolosovsky - IDEA-94942 "bindSvn" module classes moved to "svn4idea" SvnBindClient unsupported methods will be removed in next commit (to track change like "rename" instead of "delete" + "add" to preserve history)
6c36a93: 2013-08-20 Konstantin Kolosovsky - IDEA-112184 Added logging to detect authentication issues
928c01e: 2013-08-07 Konstantin Kolosovsky - IDEA-94942 - Basic svn 1.8 test support
d880599: 2013-08-20 Konstantin Kolosovsky - IDEA-94942 Small text fixes Ignoring tests for old/not used functionality
71384c1: 2013-08-19 Konstantin Kolosovsky - IDEA-94942 Copy and move actions
a5f7e7c: 2013-08-19 Konstantin Kolosovsky - IDEA-94942 Delete action
e197c08: 2013-08-19 Konstantin Kolosovsky - IDEA-94942 Fixed authentication for svn protocol
c28c127: 2013-08-19 Konstantin Kolosovsky - IDEA-94942 Short add, revert commands refactoring
e06a346: 2013-08-19 Konstantin Kolosovsky - IDEA-94942 Revert action Fixed status command for single file Fixed status result parsing for normal (non-modified versioned) file
0f66f9d: 2013-08-19 Konstantin Kolosovsky - IDEA-94942 Logging and comments for some commands
c928fe5: 2013-08-16 Konstantin Kolosovsky - IDEA-94942 Force command line client usage if working copy of svn 1.8 format detected
d6e4e38: 2013-08-16 Konstantin Kolosovsky - IDEA-94942 Fixed "add" action output parsing for binary files
1236be5: 2013-08-15 Konstantin Kolosovsky - IDEA-94942 Small refactoring and fixes after review
e05b576: 2013-08-15 Konstantin Kolosovsky - IDEA-94942 "Add" action for files and directories
ccf6085: 2013-08-15 Konstantin Kolosovsky - IDEA-94942 "Subversion" -> "Show History" for files and folders
aba7390: 2013-08-14 Konstantin Kolosovsky - IDEA-94942 Add command refactored
555d597: 2013-08-14 Konstantin Kolosovsky - IDEA-94942 Fixing status, info commands to use correct arguments
b083f31: 2013-08-14 Konstantin Kolosovsky - IDEA-94942 Diff provider (without revision properties) Small command refactoring
f657dc8: 2013-08-13 Konstantin Kolosovsky - IDEA-94942 Authentication updates Authentication for remote status command Result parsing for remote info command 2 way SSL support (could be issues with ordinary password entering after 2 way SSL)
2785122: 2013-07-29 Konstantin Kolosovsky - IDEA-94942 initial svn 1.8 support with already existing command line functionality
857bfd5: 2013-08-12 max-kammerer - Update CoreJavaFileManagerTest.java
13539bc: 2013-08-09 Mikhael Bogdanov - CoreJavaFileManager.findClass: properly resolve $ in inner class names
Change-Id: Ica3d3d647183983bcd88ce2fb3450deb86343cdb
Diffstat (limited to 'java')
128 files changed, 1405 insertions, 580 deletions
diff --git a/java/compiler/impl/src/com/intellij/compiler/options/CompilerOptionsManager.java b/java/compiler/impl/src/com/intellij/compiler/options/CompilerOptionsFilter.java index ed2973adcb49..49ad3108ec64 100644 --- a/java/compiler/impl/src/com/intellij/compiler/options/CompilerOptionsManager.java +++ b/java/compiler/impl/src/com/intellij/compiler/options/CompilerOptionsFilter.java @@ -29,9 +29,9 @@ import org.jetbrains.annotations.NotNull; * @author Denis Zhdanov * @since 7/18/13 12:40 PM */ -public interface CompilerOptionsManager { +public interface CompilerOptionsFilter { - ExtensionPointName<CompilerOptionsManager> EP_NAME = ExtensionPointName.create("com.intellij.compiler.optionsManager"); + ExtensionPointName<CompilerOptionsFilter> EP_NAME = ExtensionPointName.create("com.intellij.compiler.optionsManager"); enum Setting { RESOURCE_PATTERNS, CLEAR_OUTPUT_DIR_ON_REBUILD, ADD_NOT_NULL_ASSERTIONS, AUTO_SHOW_FIRST_ERROR_IN_EDITOR, diff --git a/java/compiler/impl/src/com/intellij/compiler/options/CompilerUIConfigurable.java b/java/compiler/impl/src/com/intellij/compiler/options/CompilerUIConfigurable.java index 57eb6994f5a3..38769dcec587 100644 --- a/java/compiler/impl/src/com/intellij/compiler/options/CompilerUIConfigurable.java +++ b/java/compiler/impl/src/com/intellij/compiler/options/CompilerUIConfigurable.java @@ -40,7 +40,7 @@ import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.*; -import static com.intellij.compiler.options.CompilerOptionsManager.*; +import static com.intellij.compiler.options.CompilerOptionsFilter.*; public class CompilerUIConfigurable implements SearchableConfigurable, Configurable.NoScroll { private static final Logger LOG = Logger.getInstance("#com.intellij.compiler.options.CompilerUIConfigurable"); @@ -110,9 +110,9 @@ public class CompilerUIConfigurable implements SearchableConfigurable, Configura } private void tweakControls(@NotNull Project project) { - CompilerOptionsManager[] managers = CompilerOptionsManager.EP_NAME.getExtensions(); + CompilerOptionsFilter[] managers = CompilerOptionsFilter.EP_NAME.getExtensions(); boolean showExternalBuildSetting = true; - for (CompilerOptionsManager manager : managers) { + for (CompilerOptionsFilter manager : managers) { showExternalBuildSetting = manager.isAvailable(Setting.EXTERNAL_BUILD, project); if (!showExternalBuildSetting) { myDisabledSettings.add(Setting.EXTERNAL_BUILD); @@ -126,7 +126,7 @@ public class CompilerUIConfigurable implements SearchableConfigurable, Configura myDisabledSettings.add(setting); } else { - for (CompilerOptionsManager manager : managers) { + for (CompilerOptionsFilter manager : managers) { if (!manager.isAvailable(setting, project)) { myDisabledSettings.add(setting); break; diff --git a/java/execution/impl/src/com/intellij/execution/application/ApplicationConfiguration.java b/java/execution/impl/src/com/intellij/execution/application/ApplicationConfiguration.java index a15f2de7d5fa..f98100026007 100644 --- a/java/execution/impl/src/com/intellij/execution/application/ApplicationConfiguration.java +++ b/java/execution/impl/src/com/intellij/execution/application/ApplicationConfiguration.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. @@ -111,7 +111,7 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration<JavaRunCo if (MAIN_CLASS_NAME == null) { return null; } - return JavaExecutionUtil.getPresentableClassName(MAIN_CLASS_NAME, getConfigurationModule()); + return JavaExecutionUtil.getPresentableClassName(MAIN_CLASS_NAME); } @Override diff --git a/java/execution/openapi/src/com/intellij/execution/JavaExecutionUtil.java b/java/execution/openapi/src/com/intellij/execution/JavaExecutionUtil.java index 95a2c2d46e8b..0e0615769b79 100644 --- a/java/execution/openapi/src/com/intellij/execution/JavaExecutionUtil.java +++ b/java/execution/openapi/src/com/intellij/execution/JavaExecutionUtil.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. @@ -141,12 +141,17 @@ public class JavaExecutionUtil { } @Nullable + public static String getPresentableClassName(final String rtClassName) { + return getPresentableClassName(rtClassName, null); + } + + /** + * {@link JavaExecutionUtil#getPresentableClassName(java.lang.String)} + */ + @Deprecated + @Nullable public static String getPresentableClassName(final String rtClassName, final JavaRunConfigurationModule configurationModule) { if (StringUtil.isEmpty(rtClassName)) return null; - final PsiClass psiClass = configurationModule.findClass(rtClassName); - if (psiClass != null) { - return psiClass.getName(); - } final int lastDot = rtClassName.lastIndexOf('.'); if (lastDot == -1 || lastDot == rtClassName.length() - 1) { return rtClassName; diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/JavaContentEntriesEditor.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/JavaContentEntriesEditor.java index 2ed1ac7db662..2c6d8d8fb7ff 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/JavaContentEntriesEditor.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/JavaContentEntriesEditor.java @@ -30,6 +30,7 @@ import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.concurrency.SwingWorker; +import org.jetbrains.jps.model.java.JavaSourceRootType; import javax.swing.*; import java.awt.*; @@ -41,12 +42,12 @@ import java.util.Map; public class JavaContentEntriesEditor extends CommonContentEntriesEditor { public JavaContentEntriesEditor(String moduleName, ModuleConfigurationState state) { - super(moduleName, state, true, true); + super(moduleName, state, JavaSourceRootType.SOURCE, JavaSourceRootType.TEST_SOURCE); } @Override protected ContentEntryEditor createContentEntryEditor(final String contentEntryUrl) { - return new JavaContentEntryEditor(contentEntryUrl) { + return new JavaContentEntryEditor(contentEntryUrl, getEditHandlers()) { @Override protected ModifiableRootModel getModel() { return JavaContentEntriesEditor.this.getModel(); @@ -55,11 +56,6 @@ public class JavaContentEntriesEditor extends CommonContentEntriesEditor { } @Override - protected ContentEntryTreeEditor createContentEntryTreeEditor(Project project) { - return new ContentEntryTreeEditor(project, true, true); - } - - @Override protected List<ContentEntry> addContentEntries(VirtualFile[] files) { List<ContentEntry> contentEntries = super.addContentEntries(files); if (!contentEntries.isEmpty()) { diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/JavaContentEntryEditor.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/JavaContentEntryEditor.java index 41b8c8d057ec..7d3c535fcd9b 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/JavaContentEntryEditor.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/JavaContentEntryEditor.java @@ -18,28 +18,38 @@ package com.intellij.openapi.roots.ui.configuration; import com.intellij.openapi.roots.CompilerModuleExtension; import com.intellij.openapi.roots.ContentEntry; import com.intellij.openapi.roots.ExcludeFolder; +import com.intellij.openapi.roots.SourceFolder; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.*; +import java.util.List; + public abstract class JavaContentEntryEditor extends ContentEntryEditor { private final CompilerModuleExtension myCompilerExtension; - public JavaContentEntryEditor(final String contentEntryUrl) { - super(contentEntryUrl, true, true); + public JavaContentEntryEditor(final String contentEntryUrl, List<ModuleSourceRootEditHandler<?>> moduleSourceRootEditHandlers) { + super(contentEntryUrl, moduleSourceRootEditHandlers); myCompilerExtension = getModel().getModuleExtension(CompilerModuleExtension.class); } @Override protected ContentRootPanel createContentRootPane() { - return new JavaContentRootPanel(this) { + return new ContentRootPanel(this, getEditHandlers()) { @Nullable @Override protected ContentEntry getContentEntry() { return JavaContentEntryEditor.this.getContentEntry(); } + + @Nullable + @Override + protected JComponent createRootPropertiesEditor(ModuleSourceRootEditHandler<?> editor, SourceFolder folder) { + return editor.createPropertiesEditor(folder, this, myCallback); + } }; } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/JavaContentRootPanel.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/JavaContentRootPanel.java deleted file mode 100644 index d0af3a1c4694..000000000000 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/JavaContentRootPanel.java +++ /dev/null @@ -1,65 +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.openapi.roots.ui.configuration; - -import com.intellij.icons.AllIcons; -import com.intellij.openapi.project.ProjectBundle; -import com.intellij.openapi.roots.ContentFolder; -import com.intellij.openapi.roots.SourceFolder; -import com.intellij.openapi.ui.Messages; -import com.intellij.ui.roots.IconActionComponent; -import org.jetbrains.annotations.Nullable; - -import javax.swing.*; -import java.awt.*; - -public abstract class JavaContentRootPanel extends ContentRootPanel { - - public JavaContentRootPanel(ActionCallback callback) { - super(callback, true, true); - } - - @Override - @Nullable - protected JComponent createAdditionalComponent(ContentFolder folder) { - if (folder instanceof SourceFolder) { - return createAddPrefixComponent((SourceFolder)folder); - } - return null; - } - - private JComponent createAddPrefixComponent(final SourceFolder folder) { - final IconActionComponent iconComponent = new IconActionComponent(AllIcons.Modules.SetPackagePrefix, - AllIcons.Modules.SetPackagePrefixRollover, - ProjectBundle.message("module.paths.package.prefix.tooltip"), new Runnable() { - @Override - public void run() { - final String message = ProjectBundle.message("module.paths.package.prefix.prompt", - toRelativeDisplayPath(folder.getUrl(), getContentEntry().getUrl() + ":")); - final String prefix = Messages.showInputDialog(JavaContentRootPanel.this, message, - ProjectBundle.message("module.paths.package.prefix.title"), Messages.getQuestionIcon(), folder.getPackagePrefix(), null); - if (prefix != null) { - myCallback.setPackagePrefix(folder, prefix); - } - } - }); - final JPanel panel = new JPanel(new BorderLayout()); - panel.setOpaque(false); - panel.add(iconComponent, BorderLayout.CENTER); - panel.add(Box.createHorizontalStrut(3), BorderLayout.EAST); - return panel; - } -} diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectStructureConfigurable.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectStructureConfigurable.java index 9c6343a59ba7..af34e4092d32 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectStructureConfigurable.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectStructureConfigurable.java @@ -223,8 +223,8 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se addArtifactsConfig(); } - ProjectStructureConfigurableAdder[] adders = ProjectStructureConfigurableAdder.EP_NAME.getExtensions(); - for (ProjectStructureConfigurableAdder adder : adders) { + ProjectStructureConfigurableContributor[] adders = ProjectStructureConfigurableContributor.EP_NAME.getExtensions(); + for (ProjectStructureConfigurableContributor adder : adders) { for (Configurable configurable : adder.getExtraProjectConfigurables(myProject, myContext)) { addConfigurable(configurable, true); } @@ -234,7 +234,7 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se addJdkListConfig(); addGlobalLibrariesConfig(); - for (ProjectStructureConfigurableAdder adder : adders) { + for (ProjectStructureConfigurableContributor adder : adders) { for (Configurable configurable : adder.getExtraPlatformConfigurables(myProject, myContext)) { addConfigurable(configurable, true); } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectStructureConfigurableAdder.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectStructureConfigurableContributor.java index 4a79ada53eb5..ad688063c369 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectStructureConfigurableAdder.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectStructureConfigurableContributor.java @@ -24,8 +24,8 @@ import org.jetbrains.annotations.NotNull; import java.util.Collections; import java.util.List; -public abstract class ProjectStructureConfigurableAdder { - public static final ExtensionPointName<ProjectStructureConfigurableAdder> EP_NAME = ExtensionPointName.create("com.intellij.projectStructureConfigurableAdder"); +public abstract class ProjectStructureConfigurableContributor { + public static final ExtensionPointName<ProjectStructureConfigurableContributor> EP_NAME = ExtensionPointName.create("com.intellij.projectStructureConfigurableAdder"); @NotNull public List<? extends Configurable> getExtraProjectConfigurables(@NotNull Project project, @NotNull StructureConfigurableContext context) { diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/concurrencyAnnotations/JCiPUtil.java b/java/java-analysis-impl/src/com/intellij/codeInspection/concurrencyAnnotations/JCiPUtil.java index daf675a519de..02a5c5714b6b 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/concurrencyAnnotations/JCiPUtil.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/concurrencyAnnotations/JCiPUtil.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. @@ -18,6 +18,7 @@ package com.intellij.codeInspection.concurrencyAnnotations; import com.intellij.codeInsight.AnnotationUtil; import com.intellij.psi.*; import com.intellij.psi.javadoc.PsiDocTag; +import com.intellij.psi.util.PsiTreeUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -103,7 +104,12 @@ public class JCiPUtil { final PsiAnnotationMemberValue psiAnnotationMemberValue = pair.getValue(); if (psiAnnotationMemberValue != null) { final String value = psiAnnotationMemberValue.getText(); - return value.substring(1, value.length() - 1).trim(); + final String trim = value.substring(1, value.length() - 1).trim(); + if (trim.equals("itself")) { + final PsiMember member = PsiTreeUtil.getParentOfType(annotation, PsiMember.class); + if (member != null) return member.getName(); + } + return trim; } } } diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java b/java/java-analysis-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java index 9c8cc96ca336..df96d140ed3d 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.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. @@ -263,7 +263,7 @@ public class UnusedDeclarationInspection extends GlobalInspectionTool { } } - private static boolean isExternalizableNoParameterConstructor(PsiMethod method, RefClass refClass) { + private static boolean isExternalizableNoParameterConstructor(@NotNull PsiMethod method, RefClass refClass) { if (!method.isConstructor()) return false; if (!method.hasModifierProperty(PsiModifier.PUBLIC)) return false; final PsiParameterList parameterList = method.getParameterList(); @@ -272,7 +272,7 @@ public class UnusedDeclarationInspection extends GlobalInspectionTool { return aClass == null || isExternalizable(aClass, refClass); } - private static boolean isSerializationImplicitlyUsedField(PsiField field) { + private static boolean isSerializationImplicitlyUsedField(@NotNull PsiField field) { @NonNls final String name = field.getName(); if (!HighlightUtilBase.SERIAL_VERSION_UID_FIELD_NAME.equals(name) && !"serialPersistentFields".equals(name)) return false; if (!field.hasModifierProperty(PsiModifier.STATIC)) return false; @@ -280,7 +280,7 @@ public class UnusedDeclarationInspection extends GlobalInspectionTool { return aClass == null || isSerializable(aClass, null); } - private static boolean isWriteObjectMethod(PsiMethod method, RefClass refClass) { + private static boolean isWriteObjectMethod(@NotNull PsiMethod method, RefClass refClass) { @NonNls final String name = method.getName(); if (!"writeObject".equals(name)) return false; PsiParameter[] parameters = method.getParameterList().getParameters(); @@ -291,7 +291,7 @@ public class UnusedDeclarationInspection extends GlobalInspectionTool { return !(aClass != null && !isSerializable(aClass, refClass)); } - private static boolean isReadObjectMethod(PsiMethod method, RefClass refClass) { + private static boolean isReadObjectMethod(@NotNull PsiMethod method, RefClass refClass) { @NonNls final String name = method.getName(); if (!"readObject".equals(name)) return false; PsiParameter[] parameters = method.getParameterList().getParameters(); @@ -302,7 +302,7 @@ public class UnusedDeclarationInspection extends GlobalInspectionTool { return !(aClass != null && !isSerializable(aClass, refClass)); } - private static boolean isWriteReplaceMethod(PsiMethod method, RefClass refClass) { + private static boolean isWriteReplaceMethod(@NotNull PsiMethod method, RefClass refClass) { @NonNls final String name = method.getName(); if (!"writeReplace".equals(name)) return false; PsiParameter[] parameters = method.getParameterList().getParameters(); @@ -313,7 +313,7 @@ public class UnusedDeclarationInspection extends GlobalInspectionTool { return !(aClass != null && !isSerializable(aClass, refClass)); } - private static boolean isReadResolveMethod(PsiMethod method, RefClass refClass) { + private static boolean isReadResolveMethod(@NotNull PsiMethod method, RefClass refClass) { @NonNls final String name = method.getName(); if (!"readResolve".equals(name)) return false; PsiParameter[] parameters = method.getParameterList().getParameters(); @@ -329,7 +329,7 @@ public class UnusedDeclarationInspection extends GlobalInspectionTool { return serializableClass != null && isSerializable(aClass, refClass, serializableClass); } - private static boolean isExternalizable(PsiClass aClass, RefClass refClass) { + private static boolean isExternalizable(@NotNull PsiClass aClass, RefClass refClass) { final GlobalSearchScope scope = aClass.getResolveScope(); final PsiClass externalizableClass = JavaPsiFacade.getInstance(aClass.getProject()).findClass("java.io.Externalizable", scope); return externalizableClass != null && isSerializable(aClass, refClass, externalizableClass); @@ -537,7 +537,7 @@ public class UnusedDeclarationInspection extends GlobalInspectionTool { public void visitField(@NotNull final RefField refField) { myProcessedSuspicious.add(refField); PsiField psiField = refField.getElement(); - if (isSerializationImplicitlyUsedField(psiField)) { + if (psiField != null && isSerializationImplicitlyUsedField(psiField)) { getEntryPointsManager().addEntryPoint(refField, false); } else { @@ -560,7 +560,7 @@ public class UnusedDeclarationInspection extends GlobalInspectionTool { } else { PsiMethod psiMethod = (PsiMethod)refMethod.getElement(); - if (isSerializablePatternMethod(psiMethod, refMethod.getOwnerClass())) { + if (psiMethod != null && isSerializablePatternMethod(psiMethod, refMethod.getOwnerClass())) { getEntryPointsManager().addEntryPoint(refMethod, false); } else if (!refMethod.isExternalOverride() && !PsiModifier.PRIVATE.equals(refMethod.getAccessModifier())) { @@ -614,7 +614,7 @@ public class UnusedDeclarationInspection extends GlobalInspectionTool { return true; } - private static boolean isSerializablePatternMethod(PsiMethod psiMethod, RefClass refClass) { + private static boolean isSerializablePatternMethod(@NotNull PsiMethod psiMethod, RefClass refClass) { return isReadObjectMethod(psiMethod, refClass) || isWriteObjectMethod(psiMethod, refClass) || isReadResolveMethod(psiMethod, refClass) || isWriteReplaceMethod(psiMethod, refClass) || isExternalizableNoParameterConstructor(psiMethod, refClass); } diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/localCanBeFinal/LocalCanBeFinal.java b/java/java-analysis-impl/src/com/intellij/codeInspection/localCanBeFinal/LocalCanBeFinal.java index 112aee0814de..e508a77b11b6 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/localCanBeFinal/LocalCanBeFinal.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/localCanBeFinal/LocalCanBeFinal.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,7 +77,7 @@ public class LocalCanBeFinal extends BaseJavaBatchLocalInspectionTool { } @Nullable - private List<ProblemDescriptor> checkCodeBlock(final PsiCodeBlock body, InspectionManager manager, boolean onTheFly) { + private List<ProblemDescriptor> checkCodeBlock(final PsiCodeBlock body, final InspectionManager manager, final boolean onTheFly) { if (body == null) return null; final ControlFlow flow; try { @@ -120,9 +120,17 @@ public class LocalCanBeFinal extends BaseJavaBatchLocalInspectionTool { final List<PsiVariable> writtenVariables = new ArrayList<PsiVariable>(ControlFlowUtil.getWrittenVariables(flow, start, end, false)); + final List<ProblemDescriptor> problems = new ArrayList<ProblemDescriptor>(); final HashSet<PsiVariable> ssaVarsSet = new HashSet<PsiVariable>(); body.accept(new JavaRecursiveElementWalkingVisitor() { @Override public void visitCodeBlock(PsiCodeBlock block) { + if (block.getParent() instanceof PsiLambdaExpression && block != body) { + final List<ProblemDescriptor> descriptors = checkCodeBlock(block, manager, onTheFly); + if (descriptors != null) { + problems.addAll(descriptors); + } + return; + } super.visitCodeBlock(block); PsiElement anchor = block; if (block.getParent() instanceof PsiSwitchStatement) { @@ -177,7 +185,7 @@ public class LocalCanBeFinal extends BaseJavaBatchLocalInspectionTool { } }); - ArrayList<PsiVariable> result = new ArrayList<PsiVariable>(ssaVarsSet); + final ArrayList<PsiVariable> result = new ArrayList<PsiVariable>(ssaVarsSet); if (body.getParent() instanceof PsiMethod) { PsiMethod method = (PsiMethod)body.getParent(); @@ -215,7 +223,7 @@ public class LocalCanBeFinal extends BaseJavaBatchLocalInspectionTool { iterator.remove(); } } - List<ProblemDescriptor> problems = new ArrayList<ProblemDescriptor>(result.size()); + for (PsiVariable variable : result) { final PsiIdentifier nameIdenitier = variable.getNameIdentifier(); PsiElement problemElement = nameIdenitier != null ? nameIdenitier : variable; diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/wrongPackageStatement/WrongPackageStatementInspectionBase.java b/java/java-analysis-impl/src/com/intellij/codeInspection/wrongPackageStatement/WrongPackageStatementInspectionBase.java index 8efcc458c2d3..3d458873c312 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/wrongPackageStatement/WrongPackageStatementInspectionBase.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/wrongPackageStatement/WrongPackageStatementInspectionBase.java @@ -21,7 +21,7 @@ import com.intellij.codeInspection.*; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.util.Comparing; import com.intellij.psi.*; -import com.intellij.psi.util.PsiUtilCore; +import com.intellij.psi.util.FileTypeUtils; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -40,7 +40,7 @@ public class WrongPackageStatementInspectionBase extends BaseJavaBatchLocalInspe // does not work in tests since CodeInsightTestCase copies file into temporary location if (ApplicationManager.getApplication().isUnitTestMode()) return null; if (file instanceof PsiJavaFile) { - if (isInJsp(file)) return null; + if (FileTypeUtils.isInServerPageFile(file)) return null; PsiJavaFile javaFile = (PsiJavaFile)file; PsiDirectory directory = javaFile.getContainingDirectory(); @@ -86,10 +86,6 @@ public class WrongPackageStatementInspectionBase extends BaseJavaBatchLocalInspe return null; } - private static boolean isInJsp(PsiFile file) { - return PsiUtilCore.getTemplateLanguageFile(file) instanceof ServerPageFile; - } - protected void addMoveToPackageFix(PsiFile file, String packName, List<LocalQuickFix> availableFixes) { } diff --git a/java/java-impl/src/com/intellij/analysis/JavaAnalysisScope.java b/java/java-impl/src/com/intellij/analysis/JavaAnalysisScope.java index 6899c7a1cf3d..1c49c3be174e 100644 --- a/java/java-impl/src/com/intellij/analysis/JavaAnalysisScope.java +++ b/java/java-impl/src/com/intellij/analysis/JavaAnalysisScope.java @@ -31,7 +31,7 @@ import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.search.PackageScope; import com.intellij.psi.search.SearchScope; import com.intellij.util.containers.ContainerUtil; -import com.siyeh.ig.psiutils.FileTypeUtils; +import com.intellij.psi.util.FileTypeUtils; import org.jetbrains.annotations.NotNull; import java.util.HashSet; diff --git a/java/java-impl/src/com/intellij/codeInsight/CodeInsightUtil.java b/java/java-impl/src/com/intellij/codeInsight/CodeInsightUtil.java index fe002f62dbc4..9f2b486164ce 100644 --- a/java/java-impl/src/com/intellij/codeInsight/CodeInsightUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/CodeInsightUtil.java @@ -43,7 +43,7 @@ import com.intellij.util.Consumer; import com.intellij.util.FilteredQuery; import com.intellij.util.Processor; import com.intellij.util.Query; -import com.siyeh.ig.psiutils.FileTypeUtils; +import com.intellij.psi.util.FileTypeUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionContributor.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionContributor.java index 3ce6050837b7..26b9fdb52086 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionContributor.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionContributor.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. @@ -589,6 +589,11 @@ public class JavaCompletionContributor extends CompletionContributor { return LangBundle.message("completion.no.suggestions") + suffix; } + @Override + public boolean invokeAutoPopup(@NotNull PsiElement position, char typeChar) { + return typeChar == ':' && JavaTokenType.COLON == position.getNode().getElementType(); + } + private static boolean shouldSuggestSmartCompletion(final PsiElement element) { if (shouldSuggestClassNameCompletion(element)) return false; 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 9710f7550c99..ac752ed54ac1 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaSmartCompletionContributor.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaSmartCompletionContributor.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. @@ -20,6 +20,7 @@ import com.intellij.codeInsight.completion.scope.JavaCompletionProcessor; import com.intellij.codeInsight.lookup.*; import com.intellij.openapi.util.Key; import com.intellij.patterns.ElementPattern; +import com.intellij.patterns.ElementPatternCondition; import com.intellij.patterns.PsiElementPattern; import com.intellij.patterns.PsiJavaPatterns; import com.intellij.psi.*; @@ -28,6 +29,7 @@ import com.intellij.psi.filters.ElementFilter; import com.intellij.psi.filters.GeneratorFilter; import com.intellij.psi.filters.OrFilter; import com.intellij.psi.filters.getters.*; +import com.intellij.psi.filters.position.FilterPattern; import com.intellij.psi.filters.types.AssignableFromFilter; import com.intellij.psi.filters.types.AssignableGroupFilter; import com.intellij.psi.filters.types.AssignableToFilter; @@ -92,6 +94,21 @@ public class JavaSmartCompletionContributor extends CompletionContributor { psiElement().withText(")").withParent(PsiTypeCastExpression.class))); static final PsiElementPattern.Capture<PsiElement> IN_TYPE_ARGS = psiElement().inside(psiElement(PsiReferenceParameterList.class)); + static final PsiElementPattern.Capture<PsiElement> LAMBDA = psiElement().and(new FilterPattern(new ElementFilter() { + @Override + public boolean isAcceptable(Object element, @Nullable PsiElement context) { + if (context == null) return false; + final PsiElement originalElement = context.getOriginalElement(); + if (originalElement == null) return false; + final PsiElement rulezzRef = originalElement.getParent(); + return LambdaUtil.isValidLambdaContext(rulezzRef.getParent()); + } + + @Override + public boolean isClassAcceptable(Class hintClass) { + return true; + } + })); @Nullable private static ElementFilter getReferenceFilter(PsiElement element) { @@ -313,6 +330,8 @@ public class JavaSmartCompletionContributor extends CompletionContributor { } } }); + + extend(CompletionType.SMART, LAMBDA, new LambdaCompletionProvider()); } private static void addExpectedTypeMembers(CompletionParameters params, diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/LambdaCompletionProvider.java b/java/java-impl/src/com/intellij/codeInsight/completion/LambdaCompletionProvider.java new file mode 100644 index 000000000000..eca5453c20f8 --- /dev/null +++ b/java/java-impl/src/com/intellij/codeInsight/completion/LambdaCompletionProvider.java @@ -0,0 +1,67 @@ +/* + * 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.completion; + +import com.intellij.codeInsight.ExpectedTypeInfo; +import com.intellij.codeInsight.lookup.AutoCompletionPolicy; +import com.intellij.codeInsight.lookup.LookupElement; +import com.intellij.codeInsight.lookup.LookupElementBuilder; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.editor.EditorModificationUtil; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.psi.*; +import com.intellij.psi.util.PsiUtil; +import com.intellij.util.Function; +import com.intellij.util.ProcessingContext; +import org.jetbrains.annotations.NotNull; + +/** + * User: anna + */ +public class LambdaCompletionProvider extends CompletionProvider<CompletionParameters> { + @Override + protected void addCompletions(@NotNull CompletionParameters parameters, + ProcessingContext context, + @NotNull CompletionResultSet result) { + if (!PsiUtil.isLanguageLevel8OrHigher(parameters.getOriginalFile())) return; + final ExpectedTypeInfo[] expectedTypes = JavaSmartCompletionContributor.getExpectedTypes(parameters); + for (ExpectedTypeInfo expectedType : expectedTypes) { + final PsiType defaultType = expectedType.getDefaultType(); + if (LambdaHighlightingUtil.checkInterfaceFunctional(defaultType) == null) { + final PsiMethod method = LambdaUtil.getFunctionalInterfaceMethod(defaultType); + if (method != null) { + final PsiParameter[] params = method.getParameterList().getParameters(); + final String paramsString = "(" + StringUtil.join(params, new Function<PsiParameter, String>() { + @Override + public String fun(PsiParameter parameter) { + return parameter.getName(); + } + }, ",") + ")"; + final LookupElementBuilder builder = + LookupElementBuilder.create(paramsString).withPresentableText(paramsString + " -> {}").withInsertHandler(new InsertHandler<LookupElement>() { + @Override + public void handleInsert(InsertionContext context, LookupElement item) { + final Editor editor = context.getEditor(); + EditorModificationUtil.insertStringAtCaret(editor, " -> "); + PsiDocumentManager.getInstance(context.getProject()).commitDocument(editor.getDocument()); + } + }); + result.addElement(builder.withAutoCompletionPolicy(AutoCompletionPolicy.NEVER_AUTOCOMPLETE)); + } + } + } + } +} diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightControlFlowUtil.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightControlFlowUtil.java index c32a30c0d985..7cc7879c2206 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightControlFlowUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightControlFlowUtil.java @@ -32,7 +32,7 @@ import com.intellij.psi.tree.IElementType; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtil; import com.intellij.util.Processor; -import com.siyeh.ig.psiutils.FileTypeUtils; +import com.intellij.psi.util.FileTypeUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; 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 612d4704ec10..3266e9685dc2 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 @@ -915,7 +915,7 @@ public class HighlightMethodUtil { if (!hasNoBody) { QuickFixAction.registerQuickFixAction(info, new DeleteMethodBodyFix(method)); } - if (method.hasModifierProperty(PsiModifier.ABSTRACT) && isInterface) { + if (method.hasModifierProperty(PsiModifier.ABSTRACT) && !isInterface) { QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createModifierListFix(method, PsiModifier.ABSTRACT, false, false)); } for (IntentionAction intentionAction : additionalFixes) { 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 5657a40f9d34..a3fb8928efef 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 @@ -61,7 +61,7 @@ import com.intellij.util.IncorrectOperationException; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.UIUtil; import com.intellij.xml.util.XmlStringUtil; -import com.siyeh.ig.psiutils.FileTypeUtils; +import com.intellij.psi.util.FileTypeUtils; import gnu.trove.THashMap; import org.intellij.lang.annotations.Language; import org.jetbrains.annotations.NonNls; @@ -808,7 +808,8 @@ public class HighlightUtil extends HighlightUtilBase { } else if (PsiModifier.STATIC.equals(modifier) || PsiModifier.PRIVATE.equals(modifier) || PsiModifier.PROTECTED.equals(modifier) || PsiModifier.PACKAGE_LOCAL.equals(modifier)) { - isAllowed = modifierOwnerParent instanceof PsiClass && ((PsiClass)modifierOwnerParent).getQualifiedName() != null; + isAllowed = modifierOwnerParent instanceof PsiClass && + ((PsiClass)modifierOwnerParent).getQualifiedName() != null || FileTypeUtils.isInServerPageFile(modifierOwnerParent); } if (aClass.isEnum()) { 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 5c9e198b578b..40e2eaab4697 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 @@ -29,7 +29,7 @@ import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.IndexNotReadyException; import com.intellij.openapi.project.Project; import com.intellij.openapi.projectRoots.JavaSdkVersion; -import com.intellij.openapi.projectRoots.JavaSdkVersionUtil; +import com.intellij.openapi.projectRoots.JavaVersionService; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.TextRange; import com.intellij.pom.java.LanguageLevel; @@ -147,7 +147,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh boolean success = true; try { myLanguageLevel = PsiUtil.getLanguageLevel(file); - myJavaSdkVersion = ObjectUtils.notNull(JavaSdkVersionUtil.getJavaSdkVersion(file), JavaSdkVersion.fromLanguageLevel(myLanguageLevel)); + myJavaSdkVersion = ObjectUtils.notNull(JavaVersionService.getInstance().getJavaSdkVersion(file), JavaSdkVersion.fromLanguageLevel(myLanguageLevel)); if (updateWholeFile) { Project project = file.getProject(); DaemonCodeAnalyzer daemonCodeAnalyzer = DaemonCodeAnalyzer.getInstance(project); diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddNewArrayExpressionFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddNewArrayExpressionFix.java index 13921e963c0d..d564d3a34ac9 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddNewArrayExpressionFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddNewArrayExpressionFix.java @@ -32,7 +32,7 @@ import org.jetbrains.annotations.NotNull; public class AddNewArrayExpressionFix implements IntentionAction { private final PsiArrayInitializerExpression myInitializer; - public AddNewArrayExpressionFix(PsiArrayInitializerExpression initializer) { + public AddNewArrayExpressionFix(@NotNull PsiArrayInitializerExpression initializer) { myInitializer = initializer; } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeCastFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeCastFix.java index 67952e11727d..b9c5d21bcd5e 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeCastFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeCastFix.java @@ -40,7 +40,7 @@ import org.jetbrains.annotations.Nullable; public class AddTypeCastFix extends LocalQuickFixAndIntentionActionOnPsiElement { private final PsiType myType; - public AddTypeCastFix(PsiType type, PsiExpression expression) { + public AddTypeCastFix(@NotNull PsiType type, @NotNull PsiExpression expression) { super(expression); myType = type; } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeToAppendFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeToAppendFix.java index 0683af7a2f5d..513cb7895ecf 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeToAppendFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeToAppendFix.java @@ -36,7 +36,7 @@ public class ChangeToAppendFix implements IntentionAction { private final PsiType myLhsType; private final PsiAssignmentExpression myAssignmentExpression; - public ChangeToAppendFix(IElementType eqOpSign, PsiType lType, PsiAssignmentExpression assignmentExpression) { + public ChangeToAppendFix(@NotNull IElementType eqOpSign, @NotNull PsiType lType, @NotNull PsiAssignmentExpression assignmentExpression) { myTokenType = eqOpSign; myLhsType = lType; myAssignmentExpression = assignmentExpression; diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ConvertSwitchToIfIntention.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ConvertSwitchToIfIntention.java index a996525546e6..dab9a3bb6208 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ConvertSwitchToIfIntention.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ConvertSwitchToIfIntention.java @@ -40,7 +40,7 @@ import java.util.Set; public class ConvertSwitchToIfIntention implements IntentionAction { private final PsiSwitchStatement mySwitchExpression; - public ConvertSwitchToIfIntention(PsiSwitchStatement switchStatement) { + public ConvertSwitchToIfIntention(@NotNull PsiSwitchStatement switchStatement) { mySwitchExpression = switchStatement; } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFieldFromUsageFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFieldFromUsageFix.java index 139a605ae60d..939b8b6f8a13 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFieldFromUsageFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFieldFromUsageFix.java @@ -32,8 +32,7 @@ import org.jetbrains.annotations.NotNull; * @author Mike */ public class CreateFieldFromUsageFix extends CreateVarFromUsageFix { - - public CreateFieldFromUsageFix(PsiReferenceExpression referenceElement) { + public CreateFieldFromUsageFix(@NotNull PsiReferenceExpression referenceElement) { super(referenceElement); } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/DeleteCatchFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/DeleteCatchFix.java index 35d25d864f47..ec6e0c3e23dd 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/DeleteCatchFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/DeleteCatchFix.java @@ -27,7 +27,7 @@ import org.jetbrains.annotations.NotNull; public class DeleteCatchFix implements IntentionAction { private final PsiParameter myCatchParameter; - public DeleteCatchFix(PsiParameter myCatchParameter) { + public DeleteCatchFix(@NotNull PsiParameter myCatchParameter) { this.myCatchParameter = myCatchParameter; } @@ -45,9 +45,7 @@ public class DeleteCatchFix implements IntentionAction { @Override public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { - return myCatchParameter != null - && myCatchParameter.isValid() - && PsiManager.getInstance(project).isInProject(myCatchParameter.getContainingFile()); + return myCatchParameter.isValid() && PsiManager.getInstance(project).isInProject(myCatchParameter.getContainingFile()); } @Override diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/DeleteMultiCatchFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/DeleteMultiCatchFix.java index 41e08d682790..c85e613acf9a 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/DeleteMultiCatchFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/DeleteMultiCatchFix.java @@ -32,7 +32,7 @@ import java.util.List; public class DeleteMultiCatchFix implements IntentionAction { private final PsiTypeElement myTypeElement; - public DeleteMultiCatchFix(final PsiTypeElement typeElement) { + public DeleteMultiCatchFix(@NotNull PsiTypeElement typeElement) { myTypeElement = typeElement; } @@ -50,9 +50,7 @@ public class DeleteMultiCatchFix implements IntentionAction { @Override public boolean isAvailable(@NotNull final Project project, final Editor editor, final PsiFile file) { - return myTypeElement != null && - myTypeElement.isValid() && - PsiManager.getInstance(project).isInProject(myTypeElement.getContainingFile()); + return myTypeElement.isValid() && PsiManager.getInstance(project).isInProject(myTypeElement.getContainingFile()); } @Override diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/GeneralizeCatchFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/GeneralizeCatchFix.java index b0c979092f32..64ad43808b86 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/GeneralizeCatchFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/GeneralizeCatchFix.java @@ -32,7 +32,7 @@ public class GeneralizeCatchFix implements IntentionAction { private PsiTryStatement myTryStatement; private PsiParameter myCatchParameter; - public GeneralizeCatchFix(PsiElement element, PsiClassType unhandledException) { + public GeneralizeCatchFix(@NotNull PsiElement element, @NotNull PsiClassType unhandledException) { myElement = element; myUnhandledException = unhandledException; } @@ -53,9 +53,7 @@ public class GeneralizeCatchFix implements IntentionAction { @Override public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { - if (!(myElement != null - && myElement.isValid() - && myUnhandledException != null + if (!(myElement.isValid() && myUnhandledException.isValid() && myElement.getManager().isInProject(myElement))) return false; // find enclosing try 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 1a2683e39b31..abc31adfaf57 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 @@ -41,12 +41,12 @@ import com.intellij.packageDependencies.DependencyValidationManager; import com.intellij.psi.*; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.search.PsiShortNamesCache; +import com.intellij.psi.util.FileTypeUtils; import com.intellij.psi.util.InheritanceUtil; import com.intellij.psi.util.PsiUtil; import com.intellij.util.Processor; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.HashSet; -import com.siyeh.ig.psiutils.FileTypeUtils; import gnu.trove.THashSet; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/MoveCatchUpFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/MoveCatchUpFix.java index 48fae89acedb..4110c915a0ba 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/MoveCatchUpFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/MoveCatchUpFix.java @@ -35,10 +35,10 @@ public class MoveCatchUpFix implements IntentionAction { private final PsiCatchSection myCatchSection; private final PsiCatchSection myMoveBeforeSection; - public MoveCatchUpFix(PsiCatchSection catchSection, PsiCatchSection moveBeforeSection) { + public MoveCatchUpFix(@NotNull PsiCatchSection catchSection, @NotNull PsiCatchSection moveBeforeSection) { this.myCatchSection = catchSection; - myMoveBeforeSection = moveBeforeSection; - } + myMoveBeforeSection = moveBeforeSection; + } @Override @NotNull @@ -56,10 +56,8 @@ public class MoveCatchUpFix implements IntentionAction { @Override public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { - return myCatchSection != null - && myCatchSection.isValid() + return myCatchSection.isValid() && myCatchSection.getManager().isInProject(myCatchSection) - && myMoveBeforeSection != null && myMoveBeforeSection.isValid() && myCatchSection.getCatchType() != null && PsiUtil.resolveClassInType(myCatchSection.getCatchType()) != null diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/NegationBroadScopeFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/NegationBroadScopeFix.java index dcbdd44ab8ff..b628b9fc5afb 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/NegationBroadScopeFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/NegationBroadScopeFix.java @@ -33,7 +33,7 @@ import org.jetbrains.annotations.NotNull; public class NegationBroadScopeFix implements IntentionAction { private final PsiPrefixExpression myPrefixExpression; - public NegationBroadScopeFix(PsiPrefixExpression prefixExpression) { + public NegationBroadScopeFix(@NotNull PsiPrefixExpression prefixExpression) { myPrefixExpression = prefixExpression; } @@ -70,7 +70,7 @@ public class NegationBroadScopeFix implements IntentionAction { @Override public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { - if (myPrefixExpression == null || !myPrefixExpression.isValid()) return false; + if (!myPrefixExpression.isValid()) return false; PsiElement parent = myPrefixExpression.getParent(); if (parent instanceof PsiInstanceOfExpression && ((PsiInstanceOfExpression)parent).getOperand() == myPrefixExpression) { diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RemoveParameterListFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RemoveParameterListFix.java index 3fdf63939ef0..19f5359475c4 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RemoveParameterListFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RemoveParameterListFix.java @@ -29,7 +29,7 @@ public class RemoveParameterListFix implements IntentionAction { private final PsiMethod myMethod; - public RemoveParameterListFix(PsiMethod method) { + public RemoveParameterListFix(@NotNull PsiMethod method) { myMethod = method; } @@ -47,7 +47,7 @@ public class RemoveParameterListFix implements IntentionAction { @Override public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { - return myMethod != null && myMethod.isValid(); + return myMethod.isValid(); } @Override diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RemoveQualifierFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RemoveQualifierFix.java index 063f1b75c079..35a053e64489 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RemoveQualifierFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RemoveQualifierFix.java @@ -35,7 +35,7 @@ public class RemoveQualifierFix implements IntentionAction { private final PsiReferenceExpression myExpression; private final PsiClass myResolved; - public RemoveQualifierFix(final PsiExpression qualifier, final PsiReferenceExpression expression, final PsiClass resolved) { + public RemoveQualifierFix(@NotNull PsiExpression qualifier, @NotNull PsiReferenceExpression expression, @NotNull PsiClass resolved) { myQualifier = qualifier; myExpression = expression; myResolved = resolved; @@ -56,14 +56,10 @@ public class RemoveQualifierFix implements IntentionAction { @Override public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { return - myQualifier != null - && myQualifier.isValid() + myQualifier.isValid() && myQualifier.getManager().isInProject(myQualifier) - && myExpression != null && myExpression.isValid() - && myResolved != null - && myResolved.isValid() - ; + && myResolved.isValid(); } @Override diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RenameWrongRefFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RenameWrongRefFix.java index 42d42a4c7a30..6dc619d3c935 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RenameWrongRefFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RenameWrongRefFix.java @@ -49,11 +49,11 @@ public class RenameWrongRefFix implements IntentionAction { @NonNls private static final String OTHER_VARIABLE_NAME = "OTHERVAR"; private final boolean myUnresolvedOnly; - public RenameWrongRefFix(PsiReferenceExpression refExpr) { + public RenameWrongRefFix(@NotNull PsiReferenceExpression refExpr) { this(refExpr, false); } - public RenameWrongRefFix(PsiReferenceExpression refExpr, final boolean unresolvedOnly) { + public RenameWrongRefFix(@NotNull PsiReferenceExpression refExpr, final boolean unresolvedOnly) { myRefExpr = refExpr; myUnresolvedOnly = unresolvedOnly; } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ReplaceWithListAccessFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ReplaceWithListAccessFix.java index 59d6f7083efa..7e8161e39598 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ReplaceWithListAccessFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ReplaceWithListAccessFix.java @@ -33,7 +33,7 @@ import org.jetbrains.annotations.Nullable; public class ReplaceWithListAccessFix implements IntentionAction { private final PsiArrayAccessExpression myArrayAccessExpression; - public ReplaceWithListAccessFix(PsiArrayAccessExpression arrayAccessExpression) { + public ReplaceWithListAccessFix(@NotNull PsiArrayAccessExpression arrayAccessExpression) { myArrayAccessExpression = arrayAccessExpression; } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ReuseVariableDeclarationFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ReuseVariableDeclarationFix.java index 78c027532fd1..bc1aafdf3c96 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ReuseVariableDeclarationFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ReuseVariableDeclarationFix.java @@ -36,7 +36,7 @@ import org.jetbrains.annotations.Nullable; public class ReuseVariableDeclarationFix implements IntentionAction { private final PsiLocalVariable myVariable; - public ReuseVariableDeclarationFix(final PsiLocalVariable variable) { + public ReuseVariableDeclarationFix(@NotNull PsiLocalVariable variable) { this.myVariable = variable; } @@ -54,7 +54,7 @@ public class ReuseVariableDeclarationFix implements IntentionAction { @Override public boolean isAvailable(@NotNull final Project project, final Editor editor, final PsiFile file) { - if (myVariable == null || !myVariable.isValid()) { + if (!myVariable.isValid()) { return false; } final PsiVariable previousVariable = findPreviousVariable(); diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ShowModulePropertiesFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ShowModulePropertiesFix.java index 1912230a568b..203612ee1cec 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ShowModulePropertiesFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ShowModulePropertiesFix.java @@ -21,7 +21,6 @@ import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.IdeActions; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.module.Module; -import com.intellij.openapi.module.ModuleUtil; import com.intellij.openapi.module.ModuleUtilCore; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.ui.configuration.ProjectSettingsService; @@ -33,13 +32,9 @@ import org.jetbrains.annotations.NotNull; public class ShowModulePropertiesFix implements IntentionAction { private final String myModuleName; - public ShowModulePropertiesFix(String moduleName) { - myModuleName = moduleName; - } - - public ShowModulePropertiesFix(PsiElement context) { + public ShowModulePropertiesFix(@NotNull PsiElement context) { Module module = ModuleUtilCore.findModuleForPsiElement(context); - myModuleName = module != null ? module.getName() : null; + myModuleName = module == null ? null : module.getName(); } @Override diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/SurroundWithTryCatchFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/SurroundWithTryCatchFix.java index 1e91f9d9ca36..d617c8d67e88 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/SurroundWithTryCatchFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/SurroundWithTryCatchFix.java @@ -40,7 +40,7 @@ public class SurroundWithTryCatchFix implements IntentionAction { private PsiStatement myStatement = null; - public SurroundWithTryCatchFix(PsiElement element) { + public SurroundWithTryCatchFix(@NotNull PsiElement element) { final PsiMethodReferenceExpression methodReferenceExpression = PsiTreeUtil.getParentOfType(element, PsiMethodReferenceExpression.class, false); if (methodReferenceExpression == null) { final PsiLambdaExpression lambdaExpression = PsiTreeUtil.getParentOfType(element, PsiLambdaExpression.class); diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/VariableParameterizedTypeFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/VariableParameterizedTypeFix.java index a8b3b2847865..60ba6789c85a 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/VariableParameterizedTypeFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/VariableParameterizedTypeFix.java @@ -20,7 +20,7 @@ import com.intellij.codeInsight.daemon.impl.analysis.GenericsHighlightUtil; import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil; import com.intellij.openapi.project.DumbService; import com.intellij.openapi.projectRoots.JavaSdkVersion; -import com.intellij.openapi.projectRoots.JavaSdkVersionUtil; +import com.intellij.openapi.projectRoots.JavaVersionService; import com.intellij.psi.*; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.search.PsiShortNamesCache; @@ -40,7 +40,7 @@ public class VariableParameterizedTypeFix { PsiShortNamesCache shortNamesCache = PsiShortNamesCache.getInstance(parameterList.getProject()); PsiClass[] classes = shortNamesCache.getClassesByName(shortName, GlobalSearchScope.allScope(manager.getProject())); PsiElementFactory factory = facade.getElementFactory(); - JavaSdkVersion version = JavaSdkVersionUtil.getJavaSdkVersion(parameterList); + JavaSdkVersion version = JavaVersionService.getInstance().getJavaSdkVersion(parameterList); for (PsiClass aClass : classes) { if (GenericsHighlightUtil.checkReferenceTypeArgumentList(aClass, parameterList, PsiSubstitutor.EMPTY, false, version) == null) { PsiType[] actualTypeParameters = parameterList.getTypeArguments(); diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithIfExpressionSurrounder.java b/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithIfExpressionSurrounder.java index 38fd5a9b62f6..bcfd4d04472e 100644 --- a/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithIfExpressionSurrounder.java +++ b/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithIfExpressionSurrounder.java @@ -24,7 +24,7 @@ import com.intellij.openapi.util.TextRange; import com.intellij.psi.*; import com.intellij.psi.codeStyle.CodeStyleManager; import com.intellij.util.IncorrectOperationException; -import com.siyeh.ig.psiutils.FileTypeUtils; +import com.intellij.psi.util.FileTypeUtils; import org.jetbrains.annotations.NonNls; class JavaWithIfExpressionSurrounder extends JavaExpressionSurrounder{ diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithNullCheckSurrounder.java b/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithNullCheckSurrounder.java index c6a1221eced0..a5e3f4881516 100644 --- a/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithNullCheckSurrounder.java +++ b/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithNullCheckSurrounder.java @@ -24,7 +24,7 @@ import com.intellij.psi.*; import com.intellij.psi.codeStyle.CodeStyleManager; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.util.IncorrectOperationException; -import com.siyeh.ig.psiutils.FileTypeUtils; +import com.intellij.psi.util.FileTypeUtils; import org.jetbrains.annotations.NonNls; class JavaWithNullCheckSurrounder extends JavaExpressionSurrounder{ diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/ui/AbstractGenerateEqualsWizard.java b/java/java-impl/src/com/intellij/codeInsight/generation/ui/AbstractGenerateEqualsWizard.java new file mode 100644 index 000000000000..12e6903d6dac --- /dev/null +++ b/java/java-impl/src/com/intellij/codeInsight/generation/ui/AbstractGenerateEqualsWizard.java @@ -0,0 +1,200 @@ +package com.intellij.codeInsight.generation.ui; + +import com.intellij.codeInsight.CodeInsightBundle; +import com.intellij.ide.wizard.AbstractWizard; +import com.intellij.ide.wizard.Step; +import com.intellij.ide.wizard.StepAdapter; +import com.intellij.openapi.project.Project; +import com.intellij.psi.PsiElement; +import com.intellij.refactoring.classMembers.MemberInfoBase; +import com.intellij.refactoring.ui.AbstractMemberSelectionPanel; +import com.intellij.util.containers.HashMap; + +import javax.swing.*; +import javax.swing.event.TableModelEvent; +import javax.swing.event.TableModelListener; +import java.awt.*; +import java.util.Collection; +import java.util.List; + +/** + * Nikolay.Tropin + * 8/20/13 + */ +public abstract class AbstractGenerateEqualsWizard <C extends PsiElement, M extends PsiElement, I extends MemberInfoBase<M>> + extends AbstractWizard<Step> { + + protected final C myClass; + + protected final AbstractMemberSelectionPanel<M, I> myEqualsPanel; + protected final AbstractMemberSelectionPanel<M, I> myHashCodePanel; + protected final AbstractMemberSelectionPanel<M, I> myNonNullPanel; + protected final HashMap<M, I> myFieldsToHashCode; + protected final HashMap<M, I> myFieldsToNonNull; + + private int myNonNullStepCode; + private int myEqualsStepCode; + private int myHashCodeStepCode; + + protected int getHashCodeStepCode() { + return myHashCodeStepCode; + } + + protected int getEqualsStepCode() { + return myEqualsStepCode; + } + + protected int getNonNullStepCode() { + return myNonNullStepCode; + } + + protected final List<I> myClassFields; + + protected final Builder<C, M, I> myBuilder; + + public static abstract class Builder<C extends PsiElement, M extends PsiElement, I extends MemberInfoBase<M>> { + protected abstract C getPsiClass(); + protected abstract List<I> getClassFields(); + protected abstract HashMap<M, I> getFieldsToHashCode(); + protected abstract HashMap<M, I> getFieldsToNonNull(); + protected abstract AbstractMemberSelectionPanel<M, I> getEqualsPanel(); + protected abstract AbstractMemberSelectionPanel<M, I> getHashCodePanel(); + protected abstract AbstractMemberSelectionPanel<M, I> getNonNullPanel(); + protected abstract void updateHashCodeMemberInfos(Collection<I> equalsMemberInfos); + protected abstract void updateNonNullMemberInfos(Collection<I> equalsMemberInfos); + } + + public AbstractGenerateEqualsWizard(Project project, Builder<C, M, I> builder) { + super(CodeInsightBundle.message("generate.equals.hashcode.wizard.title"), project); + myBuilder = builder; + myClass = builder.getPsiClass(); + myClassFields = builder.getClassFields(); + myFieldsToHashCode = builder.getFieldsToHashCode(); + myFieldsToNonNull = builder.getFieldsToNonNull(); + myEqualsPanel = builder.getEqualsPanel(); + myHashCodePanel = builder.getHashCodePanel(); + myNonNullPanel = builder.getNonNullPanel(); + + addTableListeners(); + addSteps(); + init(); + updateButtons(); + } + + protected void addSteps() { + myEqualsStepCode = addStepForPanel(myEqualsPanel); + myHashCodeStepCode = addStepForPanel(myHashCodePanel); + myNonNullStepCode = addStepForPanel(myNonNullPanel); + } + + protected int addStepForPanel(AbstractMemberSelectionPanel<M, I> panel) { + if (panel != null) { + addStep(new MyStep(panel)); + return getStepCount() - 1; + } else { + return -1; + } + } + + protected void addTableListeners() { + final MyTableModelListener listener = new MyTableModelListener(); + if (myEqualsPanel != null) myEqualsPanel.getTable().getModel().addTableModelListener(listener); + if (myHashCodePanel != null) myHashCodePanel.getTable().getModel().addTableModelListener(listener); + } + + @Override + protected void doNextAction() { + if (getCurrentStep() == getEqualsStepCode() && myEqualsPanel != null) { + equalsFieldsSelected(); + } + else if (getCurrentStep() == getHashCodeStepCode() && myHashCodePanel != null) { + Collection<I> selectedMemberInfos = myEqualsPanel != null ? myEqualsPanel.getTable().getSelectedMemberInfos() + : myHashCodePanel.getTable().getSelectedMemberInfos(); + updateNonNullMemberInfos(selectedMemberInfos); + } + + super.doNextAction(); + updateButtons(); + } + + @Override + protected String getHelpID() { + return "editing.altInsert.equals"; + } + + private void equalsFieldsSelected() { + Collection<I> selectedMemberInfos = myEqualsPanel.getTable().getSelectedMemberInfos(); + updateHashCodeMemberInfos(selectedMemberInfos); + updateNonNullMemberInfos(selectedMemberInfos); + } + + @Override + protected void doOKAction() { + if (myEqualsPanel != null) { + equalsFieldsSelected(); + } + super.doOKAction(); + } + + protected void updateHashCodeMemberInfos(Collection<I> equalsMemberInfos) { + myBuilder.updateHashCodeMemberInfos(equalsMemberInfos); + } + + protected void updateNonNullMemberInfos(Collection<I> equalsMemberInfos) { + myBuilder.updateNonNullMemberInfos(equalsMemberInfos); + } + + @Override + protected boolean canGoNext() { + if (getCurrentStep() == myEqualsStepCode) { + for (I classField : myClassFields) { + if (classField.isChecked()) { + return true; + } + } + return false; + } + + return true; + } + + @Override + public JComponent getPreferredFocusedComponent() { + final Component stepComponent = getCurrentStepComponent(); + if (stepComponent instanceof AbstractMemberSelectionPanel) { + return ((AbstractMemberSelectionPanel)stepComponent).getTable(); + } + else { + return null; + } + } + + private class MyTableModelListener implements TableModelListener { + public void tableChanged(TableModelEvent modelEvent) { + updateButtons(); + } + } + + private static class MyStep extends StepAdapter { + final AbstractMemberSelectionPanel myPanel; + + public MyStep(AbstractMemberSelectionPanel panel) { + myPanel = panel; + } + + @Override + public Icon getIcon() { + return null; + } + + @Override + public JComponent getComponent() { + return myPanel; + } + + @Override + public JComponent getPreferredFocusedComponent() { + return myPanel.getTable(); + } + } +} diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/ui/GenerateEqualsWizard.java b/java/java-impl/src/com/intellij/codeInsight/generation/ui/GenerateEqualsWizard.java index bd7203f83016..d76caeda89c4 100644 --- a/java/java-impl/src/com/intellij/codeInsight/generation/ui/GenerateEqualsWizard.java +++ b/java/java-impl/src/com/intellij/codeInsight/generation/ui/GenerateEqualsWizard.java @@ -18,16 +18,15 @@ package com.intellij.codeInsight.generation.ui; import com.intellij.codeInsight.CodeInsightBundle; import com.intellij.codeInsight.CodeInsightSettings; import com.intellij.codeInsight.generation.GenerateEqualsHelper; -import com.intellij.ide.wizard.AbstractWizard; import com.intellij.ide.wizard.StepAdapter; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.VerticalFlowLayout; import com.intellij.psi.*; +import com.intellij.refactoring.classMembers.AbstractMemberInfoModel; import com.intellij.refactoring.classMembers.MemberInfoBase; -import com.intellij.refactoring.classMembers.MemberInfoChange; -import com.intellij.refactoring.classMembers.MemberInfoModel; import com.intellij.refactoring.classMembers.MemberInfoTooltipManager; +import com.intellij.refactoring.ui.AbstractMemberSelectionPanel; import com.intellij.refactoring.ui.MemberSelectionPanel; import com.intellij.refactoring.util.classMembers.MemberInfo; import com.intellij.ui.NonFocusableCheckBox; @@ -36,108 +35,144 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; -import javax.swing.event.TableModelEvent; -import javax.swing.event.TableModelListener; -import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.*; -import java.util.List; /** * @author dsl */ -public class GenerateEqualsWizard extends AbstractWizard { +public class GenerateEqualsWizard extends AbstractGenerateEqualsWizard<PsiClass, PsiMember, MemberInfo> { private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.generation.ui.GenerateEqualsWizard"); - private final PsiClass myClass; - private final MemberSelectionPanel myEqualsPanel; - private final MemberSelectionPanel myHashCodePanel; - private final HashMap myFieldsToHashCode; - private final MemberSelectionPanel myNonNullPanel; - private final HashMap<PsiElement, MemberInfo> myFieldsToNonNull; - - private final int myTestBoxedStep; - private final int myEqualsStepCode; - private final int myHashcodeStepCode; - - private final List<MemberInfo> myClassFields; private static final MyMemberInfoFilter MEMBER_INFO_FILTER = new MyMemberInfoFilter(); - - public GenerateEqualsWizard(Project project, PsiClass aClass, boolean needEquals, boolean needHashCode) { - super(CodeInsightBundle.message("generate.equals.hashcode.wizard.title"), project); - LOG.assertTrue(needEquals || needHashCode); - myClass = aClass; - - myClassFields = MemberInfo.extractClassMembers(myClass, MEMBER_INFO_FILTER, false); - for (MemberInfo myClassField : myClassFields) { - myClassField.setChecked(true); - } - int testBoxedStep = 0; - if (needEquals) { - myEqualsPanel = - new MemberSelectionPanel(CodeInsightBundle.message("generate.equals.hashcode.equals.fields.chooser.title"), myClassFields, null); - myEqualsPanel.getTable().setMemberInfoModel(new EqualsMemberInfoModel()); - testBoxedStep+=2; - } - else { - myEqualsPanel = null; - } - if (needHashCode) { - final List<MemberInfo> hashCodeMemberInfos; + public static class JavaGenerateEqualsWizardBuilder extends AbstractGenerateEqualsWizard.Builder<PsiClass, PsiMember, MemberInfo> { + private final PsiClass myClass; + + private final MemberSelectionPanel myEqualsPanel; + private final MemberSelectionPanel myHashCodePanel; + private final MemberSelectionPanel myNonNullPanel; + private final HashMap<PsiMember, MemberInfo> myFieldsToHashCode; + private final HashMap<PsiMember, MemberInfo> myFieldsToNonNull; + private final List<MemberInfo> myClassFields; + + private JavaGenerateEqualsWizardBuilder(PsiClass aClass, boolean needEquals, boolean needHashCode) { + LOG.assertTrue(needEquals || needHashCode); + myClass = aClass; + myClassFields = MemberInfo.extractClassMembers(myClass, MEMBER_INFO_FILTER, false); + for (MemberInfo myClassField : myClassFields) { + myClassField.setChecked(true); + } if (needEquals) { - myFieldsToHashCode = createFieldToMemberInfoMap(true); - hashCodeMemberInfos = Collections.emptyList(); + myEqualsPanel = new MemberSelectionPanel(CodeInsightBundle.message("generate.equals.hashcode.equals.fields.chooser.title"), + myClassFields, null); + myEqualsPanel.getTable().setMemberInfoModel(new EqualsMemberInfoModel()); + } + else { + myEqualsPanel = null; + } + if (needHashCode) { + final List<MemberInfo> hashCodeMemberInfos; + if (needEquals) { + myFieldsToHashCode = createFieldToMemberInfoMap(true); + hashCodeMemberInfos = Collections.emptyList(); + } + else { + hashCodeMemberInfos = myClassFields; + myFieldsToHashCode = null; + } + myHashCodePanel = new MemberSelectionPanel(CodeInsightBundle.message("generate.equals.hashcode.hashcode.fields.chooser.title"), hashCodeMemberInfos, null); + myHashCodePanel.getTable().setMemberInfoModel(new HashCodeMemberInfoModel()); + if (needEquals) { + updateHashCodeMemberInfos(myClassFields); + } } else { - hashCodeMemberInfos = myClassFields; + myHashCodePanel = null; myFieldsToHashCode = null; } - myHashCodePanel = new MemberSelectionPanel(CodeInsightBundle.message("generate.equals.hashcode.hashcode.fields.chooser.title"), - hashCodeMemberInfos, null); - myHashCodePanel.getTable().setMemberInfoModel(new HashCodeMemberInfoModel()); - if (needEquals) { - updateHashCodeMemberInfos(myClassFields); + myNonNullPanel = new MemberSelectionPanel(CodeInsightBundle.message("generate.equals.hashcode.non.null.fields.chooser.title"), Collections.<MemberInfo>emptyList(), null); + myFieldsToNonNull = createFieldToMemberInfoMap(false); + for (final Map.Entry<PsiMember, MemberInfo> entry : myFieldsToNonNull.entrySet()) { + entry.getValue().setChecked(entry.getKey().getModifierList().findAnnotation(NotNull.class.getName()) != null); } - testBoxedStep++; } - else { - myHashCodePanel = null; - myFieldsToHashCode = null; + + @Override + protected List<MemberInfo> getClassFields() { + return myClassFields; } - myTestBoxedStep=testBoxedStep; - myNonNullPanel = new MemberSelectionPanel(CodeInsightBundle.message("generate.equals.hashcode.non.null.fields.chooser.title"), - Collections.<MemberInfo>emptyList(), null); - myFieldsToNonNull = createFieldToMemberInfoMap(false); - for (final Map.Entry<PsiElement, MemberInfo> entry : myFieldsToNonNull.entrySet()) { - entry.getValue().setChecked(((PsiField)entry.getKey()).getModifierList().findAnnotation(NotNull.class.getName()) != null); + + @Override + protected HashMap<PsiMember, MemberInfo> getFieldsToHashCode() { + return myFieldsToHashCode; } - final MyTableModelListener listener = new MyTableModelListener(); - if (myEqualsPanel != null) { - myEqualsPanel.getTable().getModel().addTableModelListener(listener); - addStep(new InstanceofOptionStep()); - addStep(new MyStep(myEqualsPanel)); - myEqualsStepCode = 1; + @Override + protected HashMap<PsiMember, MemberInfo> getFieldsToNonNull() { + return myFieldsToNonNull; } - else { - myEqualsStepCode = -1; + + @Override + protected AbstractMemberSelectionPanel<PsiMember, MemberInfo> getEqualsPanel() { + return myEqualsPanel; } - if (myHashCodePanel != null) { - myHashCodePanel.getTable().getModel().addTableModelListener(listener); - addStep(new MyStep(myHashCodePanel)); - myHashcodeStepCode = myEqualsStepCode > 0 ? myEqualsStepCode + 1 : 0; + @Override + protected AbstractMemberSelectionPanel<PsiMember, MemberInfo> getHashCodePanel() { + return myHashCodePanel; } - else { - myHashcodeStepCode = -1; + + @Override + protected AbstractMemberSelectionPanel<PsiMember, MemberInfo> getNonNullPanel() { + return myNonNullPanel; + } + + @Override + protected PsiClass getPsiClass() { + return myClass; } - addStep(new MyStep(myNonNullPanel)); + @Override + protected void updateHashCodeMemberInfos(Collection<MemberInfo> equalsMemberInfos) { + if (myHashCodePanel == null) return; + List<MemberInfo> hashCodeFields = new ArrayList<MemberInfo>(); + + for (MemberInfo equalsMemberInfo : equalsMemberInfos) { + hashCodeFields.add(myFieldsToHashCode.get(equalsMemberInfo.getMember())); + } + + myHashCodePanel.getTable().setMemberInfos(hashCodeFields); + } + + @Override + protected void updateNonNullMemberInfos(Collection<MemberInfo> equalsMemberInfos) { + final ArrayList<MemberInfo> list = new ArrayList<MemberInfo>(); + + for (MemberInfo equalsMemberInfo : equalsMemberInfos) { + PsiField field = (PsiField)equalsMemberInfo.getMember(); + if (!(field.getType() instanceof PsiPrimitiveType)) { + list.add(myFieldsToNonNull.get(equalsMemberInfo.getMember())); + } + } + myNonNullPanel.getTable().setMemberInfos(list); + } - init(); - updateButtons(); + private HashMap<PsiMember, MemberInfo> createFieldToMemberInfoMap(boolean checkedByDefault) { + Collection<MemberInfo> memberInfos = MemberInfo.extractClassMembers(myClass, MEMBER_INFO_FILTER, false); + final HashMap<PsiMember, MemberInfo> result = new HashMap<PsiMember, MemberInfo>(); + for (MemberInfo memberInfo : memberInfos) { + memberInfo.setChecked(checkedByDefault); + result.put(memberInfo.getMember(), memberInfo); + } + return result; + } + + } + + public GenerateEqualsWizard(Project project, PsiClass aClass, boolean needEquals, boolean needHashCode) { + super(project, new JavaGenerateEqualsWizardBuilder(aClass, needEquals, needHashCode)); } public PsiField[] getEqualsFields() { @@ -171,21 +206,6 @@ public class GenerateEqualsWizard extends AbstractWizard { } @Override - protected void doNextAction() { - if (getCurrentStep() == myEqualsStepCode && myEqualsPanel != null) { - equalsFieldsSelected(); - } - else if (getCurrentStep() == myHashcodeStepCode && myHashCodePanel != null) { - Collection<MemberInfo> selectedMemberInfos = myEqualsPanel != null ? myEqualsPanel.getTable().getSelectedMemberInfos() - : myHashCodePanel.getTable().getSelectedMemberInfos(); - updateNonNullMemberInfos(selectedMemberInfos); - } - - super.doNextAction(); - updateButtons(); - } - - @Override protected String getHelpID() { return "editing.altInsert.equals"; } @@ -204,47 +224,14 @@ public class GenerateEqualsWizard extends AbstractWizard { super.doOKAction(); } - private HashMap<PsiElement, MemberInfo> createFieldToMemberInfoMap(boolean checkedByDefault) { - Collection<MemberInfo> memberInfos = MemberInfo.extractClassMembers(myClass, MEMBER_INFO_FILTER, false); - final HashMap<PsiElement, MemberInfo> result = new HashMap<PsiElement, MemberInfo>(); - for (MemberInfo memberInfo : memberInfos) { - memberInfo.setChecked(checkedByDefault); - result.put(memberInfo.getMember(), memberInfo); - } - return result; - } - - private void updateHashCodeMemberInfos(Collection<MemberInfo> equalsMemberInfos) { - if (myHashCodePanel == null) return; - List<MemberInfo> hashCodeFields = new ArrayList<MemberInfo>(); - - for (MemberInfo equalsMemberInfo : equalsMemberInfos) { - hashCodeFields.add((MemberInfo)myFieldsToHashCode.get(equalsMemberInfo.getMember())); - } - - myHashCodePanel.getTable().setMemberInfos(hashCodeFields); - } - - private void updateNonNullMemberInfos(Collection<MemberInfo> equalsMemberInfos) { - final ArrayList<MemberInfo> list = new ArrayList<MemberInfo>(); - - for (MemberInfoBase<PsiMember> equalsMemberInfo : equalsMemberInfos) { - PsiField field = (PsiField)equalsMemberInfo.getMember(); - if (!(field.getType() instanceof PsiPrimitiveType)) { - list.add(myFieldsToNonNull.get(equalsMemberInfo.getMember())); - } - } - myNonNullPanel.getTable().setMemberInfos(list); - } - @Override protected int getNextStep(int step) { - if (step + 1 == myTestBoxedStep) { + if (step + 1 == getNonNullStepCode()) { for (MemberInfo classField : myClassFields) { if (classField.isChecked()) { PsiField field = (PsiField)classField.getMember(); if (!(field.getType() instanceof PsiPrimitiveType)) { - return myTestBoxedStep; + return getNonNullStepCode(); } } } @@ -255,88 +242,11 @@ public class GenerateEqualsWizard extends AbstractWizard { } @Override - protected boolean canGoNext() { - if (getCurrentStep() == myEqualsStepCode) { - for (MemberInfo classField : myClassFields) { - if (classField.isChecked()) { - return true; - } - } - return false; - } - - return true; - } - - @Override - public JComponent getPreferredFocusedComponent() { - final Component stepComponent = getCurrentStepComponent(); - if (stepComponent instanceof MemberSelectionPanel) { - return ((MemberSelectionPanel)stepComponent).getTable(); - } - else { - return null; - } - } - - private class MyTableModelListener implements TableModelListener { - @Override - public void tableChanged(TableModelEvent e) { - updateButtons(); - } - } - - private static class InstanceofOptionStep extends StepAdapter { - private final JComponent myPanel; - - private InstanceofOptionStep() { - final JCheckBox checkbox = new NonFocusableCheckBox(CodeInsightBundle.message("generate.equals.hashcode.accept.sublcasses")); - checkbox.setSelected(CodeInsightSettings.getInstance().USE_INSTANCEOF_ON_EQUALS_PARAMETER); - checkbox.addActionListener(new ActionListener() { - @Override - public void actionPerformed(final ActionEvent e) { - CodeInsightSettings.getInstance().USE_INSTANCEOF_ON_EQUALS_PARAMETER = checkbox.isSelected(); - } - }); - - myPanel = new JPanel(new VerticalFlowLayout()); - myPanel.add(checkbox); - myPanel.add(new JLabel(CodeInsightBundle.message("generate.equals.hashcode.accept.sublcasses.explanation"))); - } - - @Override - public JComponent getComponent() { - return myPanel; - } - - @Override - @Nullable - public Icon getIcon() { - return null; - } - } - - private static class MyStep extends StepAdapter { - final MemberSelectionPanel myPanel; - - public MyStep(MemberSelectionPanel panel) { - myPanel = panel; - } - - @Override - public Icon getIcon() { - return null; - } - - @Override - public JComponent getComponent() { - return myPanel; - } - - @Override - public JComponent getPreferredFocusedComponent() { - return myPanel.getTable(); + protected void addSteps() { + if (myEqualsPanel != null) { + addStep(new InstanceofOptionStep()); } + super.addSteps(); } private static class MyMemberInfoFilter implements MemberInfoBase.Filter<PsiMember> { @@ -346,9 +256,9 @@ public class GenerateEqualsWizard extends AbstractWizard { } } - - private static class EqualsMemberInfoModel implements MemberInfoModel<PsiMember, MemberInfo> { - MemberInfoTooltipManager<PsiMember, MemberInfo> myTooltipManager = new MemberInfoTooltipManager<PsiMember, MemberInfo>(new MemberInfoTooltipManager.TooltipProvider<PsiMember, MemberInfo>() { + private static class EqualsMemberInfoModel extends AbstractMemberInfoModel<PsiMember, MemberInfo> { + MemberInfoTooltipManager<PsiMember, MemberInfo> myTooltipManager = + new MemberInfoTooltipManager<PsiMember, MemberInfo>(new MemberInfoTooltipManager.TooltipProvider<PsiMember, MemberInfo>() { @Override public String getTooltip(MemberInfo memberInfo) { if (checkForProblems(memberInfo) == OK) return null; @@ -372,26 +282,6 @@ public class GenerateEqualsWizard extends AbstractWizard { } @Override - public boolean isCheckedWhenDisabled(MemberInfo member) { - return false; - } - - @Override - public boolean isAbstractEnabled(MemberInfo member) { - return false; - } - - @Override - public boolean isAbstractWhenDisabled(MemberInfo member) { - return false; - } - - @Override - public Boolean isFixedAbstract(MemberInfo member) { - return null; - } - - @Override public int checkForProblems(@NotNull MemberInfo member) { if (!(member.getMember() instanceof PsiField)) return ERROR; final PsiType type = ((PsiField)member.getMember()).getType(); @@ -401,16 +291,12 @@ public class GenerateEqualsWizard extends AbstractWizard { } @Override - public void memberInfoChanged(MemberInfoChange<PsiMember, MemberInfo> event) { - } - - @Override public String getTooltipText(MemberInfo member) { return myTooltipManager.getTooltip(member); } } - private static class HashCodeMemberInfoModel implements MemberInfoModel<PsiMember, MemberInfo> { + private static class HashCodeMemberInfoModel extends AbstractMemberInfoModel<PsiMember, MemberInfo> { private final MemberInfoTooltipManager<PsiMember, MemberInfo> myTooltipManager = new MemberInfoTooltipManager<PsiMember, MemberInfo>(new MemberInfoTooltipManager.TooltipProvider<PsiMember, MemberInfo>() { @Override public String getTooltip(MemberInfo memberInfo) { @@ -429,37 +315,37 @@ public class GenerateEqualsWizard extends AbstractWizard { } @Override - public boolean isCheckedWhenDisabled(MemberInfo member) { - return false; - } - - @Override - public boolean isAbstractEnabled(MemberInfo member) { - return false; + public String getTooltipText(MemberInfo member) { + return myTooltipManager.getTooltip(member); } + } - @Override - public boolean isAbstractWhenDisabled(MemberInfo member) { - return false; - } + private static class InstanceofOptionStep extends StepAdapter { + private final JComponent myPanel; - @Override - public Boolean isFixedAbstract(MemberInfo member) { - return null; - } + private InstanceofOptionStep() { + final JCheckBox checkbox = new NonFocusableCheckBox(CodeInsightBundle.message("generate.equals.hashcode.accept.sublcasses")); + checkbox.setSelected(CodeInsightSettings.getInstance().USE_INSTANCEOF_ON_EQUALS_PARAMETER); + checkbox.addActionListener(new ActionListener() { + public void actionPerformed(@NotNull final ActionEvent M) { + CodeInsightSettings.getInstance().USE_INSTANCEOF_ON_EQUALS_PARAMETER = checkbox.isSelected(); + } + }); - @Override - public int checkForProblems(@NotNull MemberInfo member) { - return OK; + myPanel = new JPanel(new VerticalFlowLayout()); + myPanel.add(checkbox); + myPanel.add(new JLabel(CodeInsightBundle.message("generate.equals.hashcode.accept.sublcasses.explanation"))); } @Override - public void memberInfoChanged(MemberInfoChange<PsiMember, MemberInfo> event) { + public JComponent getComponent() { + return myPanel; } @Override - public String getTooltipText(MemberInfo member) { - return myTooltipManager.getTooltip(member); + @Nullable + public Icon getIcon() { + return null; } } } diff --git a/java/java-impl/src/com/intellij/codeInspection/SuppressManagerImpl.java b/java/java-impl/src/com/intellij/codeInspection/SuppressManagerImpl.java index 18ba50a4675f..c67f925d6c09 100644 --- a/java/java-impl/src/com/intellij/codeInspection/SuppressManagerImpl.java +++ b/java/java-impl/src/com/intellij/codeInspection/SuppressManagerImpl.java @@ -21,7 +21,6 @@ package com.intellij.codeInspection; import com.intellij.codeInsight.daemon.HighlightDisplayKey; -import com.intellij.codeInspection.ex.InspectionManagerEx; import com.intellij.psi.PsiDocCommentOwner; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiModifierListOwner; @@ -45,7 +44,7 @@ public class SuppressManagerImpl extends SuppressManager { return ContainerUtil.map2Array(actions, SuppressIntentionAction.class, new Function<SuppressQuickFix, SuppressIntentionAction>() { @Override public SuppressIntentionAction fun(SuppressQuickFix fix) { - return InspectionManagerEx.convertBatchToSuppressIntentionAction(fix); + return SuppressIntentionActionFromFix.convertBatchToSuppressIntentionAction(fix); } }); } 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 e01c21c99e8e..4dacb84d0469 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 @@ -39,7 +39,7 @@ import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtilBase; import com.intellij.psi.util.PsiUtilCore; import com.intellij.ui.LayeredIcon; -import com.siyeh.ig.psiutils.FileTypeUtils; +import com.intellij.psi.util.FileTypeUtils; import org.jetbrains.annotations.NotNull; import javax.swing.*; diff --git a/java/java-impl/src/com/intellij/openapi/projectRoots/JavaVersionServiceImpl.java b/java/java-impl/src/com/intellij/openapi/projectRoots/JavaVersionServiceImpl.java index 76e9875e42c0..1a3ce4e0cea2 100644 --- a/java/java-impl/src/com/intellij/openapi/projectRoots/JavaVersionServiceImpl.java +++ b/java/java-impl/src/com/intellij/openapi/projectRoots/JavaVersionServiceImpl.java @@ -27,4 +27,9 @@ public class JavaVersionServiceImpl extends JavaVersionService { public boolean isAtLeast(@NotNull PsiElement element, @NotNull JavaSdkVersion version) { return JavaSdkVersionUtil.isAtLeast(element, version); } + + @Override + public JavaSdkVersion getJavaSdkVersion(@NotNull PsiElement element) { + return JavaSdkVersionUtil.getJavaSdkVersion(element); + } } diff --git a/java/java-impl/src/com/intellij/openapi/projectRoots/impl/JavaSdkImpl.java b/java/java-impl/src/com/intellij/openapi/projectRoots/impl/JavaSdkImpl.java index ad59dda1c471..eb3ea75c8024 100644 --- a/java/java-impl/src/com/intellij/openapi/projectRoots/impl/JavaSdkImpl.java +++ b/java/java-impl/src/com/intellij/openapi/projectRoots/impl/JavaSdkImpl.java @@ -109,25 +109,25 @@ public class JavaSdkImpl extends JavaSdk { } @Override - public void saveAdditionalData(SdkAdditionalData additionalData, Element additional) { + public void saveAdditionalData(@NotNull SdkAdditionalData additionalData, @NotNull Element additional) { } @Override @SuppressWarnings({"HardCodedStringLiteral"}) - public String getBinPath(Sdk sdk) { + public String getBinPath(@NotNull Sdk sdk) { return getConvertedHomePath(sdk) + "bin"; } @Override @NonNls - public String getToolsPath(Sdk sdk) { + public String getToolsPath(@NotNull Sdk sdk) { final String versionString = sdk.getVersionString(); final boolean isJdk1_x = versionString != null && (versionString.contains("1.0") || versionString.contains("1.1")); return getConvertedHomePath(sdk) + "lib" + File.separator + (isJdk1_x? "classes.zip" : "tools.jar"); } @Override - public String getVMExecutablePath(Sdk sdk) { + public String getVMExecutablePath(@NotNull Sdk sdk) { /* if ("64".equals(System.getProperty("sun.arch.data.model"))) { return getBinPath(sdk) + File.separator + System.getProperty("os.arch") + File.separator + VM_EXE_NAME; 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 39a8cdc7a516..852c7297de7f 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 @@ -15,6 +15,7 @@ */ package com.intellij.psi.impl.source.codeStyle; +import com.intellij.codeInsight.ImportFilter; import com.intellij.lang.ASTNode; import com.intellij.lang.java.JavaLanguage; import com.intellij.openapi.diagnostic.Logger; @@ -368,6 +369,10 @@ public class ImportHelper{ String className = refClass.getQualifiedName(); if (className == null) return true; + + if (!ImportFilter.shouldImport(className)) { + return false; + } String packageName = getPackageOrClassName(className); String shortName = PsiNameHelper.getShortClassName(className); diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaCodeStyleManagerImpl.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaCodeStyleManagerImpl.java index 2822fcfc81f5..fbf7ec3993af 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaCodeStyleManagerImpl.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaCodeStyleManagerImpl.java @@ -38,7 +38,7 @@ import com.intellij.psi.util.TypeConversionUtil; import com.intellij.util.ArrayUtil; import com.intellij.util.IncorrectOperationException; import com.intellij.util.containers.ContainerUtil; -import com.siyeh.ig.psiutils.FileTypeUtils; +import com.intellij.psi.util.FileTypeUtils; import gnu.trove.THashSet; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -752,7 +752,7 @@ public class JavaCodeStyleManagerImpl extends JavaCodeStyleManager { int pLength = prefix.length(); if (pLength > 0 && name.startsWith(prefix) && name.length() > pLength && // check it's not just a long camel word that happens to begin with the specified prefix - (!Character.isJavaIdentifierPart(prefix.charAt(pLength - 1)) || Character.isUpperCase(name.charAt(pLength)))) { + (!Character.isLetter(prefix.charAt(pLength - 1)) || Character.isUpperCase(name.charAt(pLength)))) { name = name.substring(pLength); doDecapitalize = true; } diff --git a/java/java-impl/src/com/intellij/refactoring/anonymousToInner/AnonymousToInnerHandler.java b/java/java-impl/src/com/intellij/refactoring/anonymousToInner/AnonymousToInnerHandler.java index 346ed4cf1cfd..390ac0e06f41 100644 --- a/java/java-impl/src/com/intellij/refactoring/anonymousToInner/AnonymousToInnerHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/anonymousToInner/AnonymousToInnerHandler.java @@ -37,7 +37,7 @@ import com.intellij.refactoring.RefactoringBundle; import com.intellij.refactoring.util.CommonRefactoringUtil; import com.intellij.refactoring.util.classMembers.ElementNeedsThis; import com.intellij.util.IncorrectOperationException; -import com.siyeh.ig.psiutils.FileTypeUtils; +import com.intellij.psi.util.FileTypeUtils; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; 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 bfbe8b2413e0..df0afa80010d 100644 --- a/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureDialog.java +++ b/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureDialog.java @@ -30,6 +30,7 @@ import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.ui.ValidationInfo; +import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.Ref; @@ -660,12 +661,12 @@ public class JavaChangeSignatureDialog extends ChangeSignatureDialogBase<Paramet final String oldModifier = VisibilityUtil.getVisibilityModifier(modifierList); final String newModifier = getVisibility(); String newModifierStr = VisibilityUtil.getVisibilityString(newModifier); - if (!newModifier.equals(oldModifier)) { + if (!Comparing.equal(newModifier, oldModifier)) { int index = modifiers.indexOf(oldModifier); if (index >= 0) { final StringBuilder buf = new StringBuilder(modifiers); buf.replace(index, - index + oldModifier.length() + ("".equals(newModifierStr) ? 1 : 0), + index + oldModifier.length() + (StringUtil.isEmpty(newModifierStr) ? 1 : 0), newModifierStr); modifiers = buf.toString(); } else { diff --git a/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureHandler.java b/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureHandler.java index 56578039526f..a57b9966b855 100644 --- a/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureHandler.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. @@ -89,7 +89,7 @@ public class JavaChangeSignatureHandler implements ChangeSignatureHandler { final PsiClass containingClass = method.getContainingClass(); final PsiReferenceExpression refExpr = editor != null ? TargetElementUtil.findReferenceExpression(editor) : null; final boolean allowDelegation = containingClass != null && !containingClass.isInterface(); - final DialogWrapper dialog = new JavaChangeSignatureDialog(project, method, allowDelegation, refExpr); + final DialogWrapper dialog = new JavaChangeSignatureDialog(project, method, allowDelegation, refExpr == null ? method : refExpr); dialog.show(); } diff --git a/java/java-impl/src/com/intellij/refactoring/introduceField/BaseExpressionToFieldHandler.java b/java/java-impl/src/com/intellij/refactoring/introduceField/BaseExpressionToFieldHandler.java index 1aac71dfd7ee..be633c477160 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceField/BaseExpressionToFieldHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceField/BaseExpressionToFieldHandler.java @@ -67,7 +67,7 @@ import com.intellij.refactoring.util.RefactoringUtil; import com.intellij.refactoring.util.occurrences.OccurrenceManager; import com.intellij.util.IncorrectOperationException; import com.intellij.util.VisibilityUtil; -import com.siyeh.ig.psiutils.FileTypeUtils; +import com.intellij.psi.util.FileTypeUtils; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/java/java-impl/src/com/intellij/refactoring/introduceField/LocalToFieldHandler.java b/java/java-impl/src/com/intellij/refactoring/introduceField/LocalToFieldHandler.java index 08a6bf64234f..cb027ac73e45 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceField/LocalToFieldHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceField/LocalToFieldHandler.java @@ -38,7 +38,7 @@ import com.intellij.refactoring.util.EnumConstantsUtil; import com.intellij.refactoring.util.RefactoringUtil; import com.intellij.util.IncorrectOperationException; import com.intellij.util.VisibilityUtil; -import com.siyeh.ig.psiutils.FileTypeUtils; +import com.intellij.psi.util.FileTypeUtils; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; diff --git a/java/java-impl/src/com/intellij/refactoring/invertBoolean/InvertBooleanProcessor.java b/java/java-impl/src/com/intellij/refactoring/invertBoolean/InvertBooleanProcessor.java index b859be9299ac..0b84dfe31917 100644 --- a/java/java-impl/src/com/intellij/refactoring/invertBoolean/InvertBooleanProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/invertBoolean/InvertBooleanProcessor.java @@ -33,6 +33,7 @@ import com.intellij.util.IncorrectOperationException; import com.intellij.util.Query; import com.intellij.util.containers.HashMap; import com.intellij.util.containers.HashSet; +import com.intellij.util.containers.MultiMap; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -69,6 +70,18 @@ public class InvertBooleanProcessor extends BaseRefactoringProcessor { @Override protected boolean preprocessUsages(Ref<UsageInfo[]> refUsages) { + final MultiMap<PsiElement, String> conflicts = new MultiMap<PsiElement, String>(); + for (UsageInfo info : myToInvert.keySet()) { + final PsiElement element = info.getElement(); + if (element instanceof PsiMethodReferenceExpression) { + conflicts.putValue(element, "Method is used in method reference expression"); + } + } + + if (!conflicts.isEmpty()) { + return showConflicts(conflicts, null); + } + if (myRenameProcessor.preprocessUsages(refUsages)) { prepareSuccessful(); return true; diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/JavaMoveDirectoryWithClassesHelper.java b/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/JavaMoveDirectoryWithClassesHelper.java index 930eafc5cf6b..41e0a2bef057 100644 --- a/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/JavaMoveDirectoryWithClassesHelper.java +++ b/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/JavaMoveDirectoryWithClassesHelper.java @@ -10,7 +10,7 @@ import com.intellij.refactoring.util.RefactoringConflictsUtil; import com.intellij.usageView.UsageInfo; import com.intellij.util.Function; import com.intellij.util.containers.MultiMap; -import com.siyeh.ig.psiutils.FileTypeUtils; +import com.intellij.psi.util.FileTypeUtils; import java.util.*; diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesUtil.java b/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesUtil.java index 5f3471f63ab8..c2cd0afaf958 100644 --- a/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesUtil.java +++ b/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesUtil.java @@ -38,7 +38,7 @@ import com.intellij.refactoring.util.TextOccurrencesUtil; import com.intellij.usageView.UsageInfo; import com.intellij.util.IncorrectOperationException; import com.intellij.util.containers.HashMap; -import com.siyeh.ig.psiutils.FileTypeUtils; +import com.intellij.psi.util.FileTypeUtils; import org.jetbrains.annotations.Nullable; import java.io.File; 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 3134f39ecf18..258c263e01dd 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 @@ -29,7 +29,7 @@ import com.intellij.refactoring.move.moveFilesOrDirectories.MoveFileHandler; import com.intellij.refactoring.util.MoveRenameUsageInfo; import com.intellij.usageView.UsageInfo; import com.intellij.util.IncorrectOperationException; -import com.siyeh.ig.psiutils.FileTypeUtils; +import com.intellij.psi.util.FileTypeUtils; import java.util.ArrayList; import java.util.Collections; diff --git a/java/java-impl/src/com/intellij/refactoring/rename/JavaVetoRenameCondition.java b/java/java-impl/src/com/intellij/refactoring/rename/JavaVetoRenameCondition.java index 72231dc2f50c..0f290cf16871 100644 --- a/java/java-impl/src/com/intellij/refactoring/rename/JavaVetoRenameCondition.java +++ b/java/java-impl/src/com/intellij/refactoring/rename/JavaVetoRenameCondition.java @@ -20,7 +20,7 @@ import com.intellij.openapi.util.Condition; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiJavaFile; -import com.siyeh.ig.psiutils.FileTypeUtils; +import com.intellij.psi.util.FileTypeUtils; public class JavaVetoRenameCondition implements Condition<PsiElement> { @Override diff --git a/java/java-impl/src/com/intellij/refactoring/ui/AbstractMemberSelectionPanel.java b/java/java-impl/src/com/intellij/refactoring/ui/AbstractMemberSelectionPanel.java new file mode 100644 index 000000000000..0e9397ad40f2 --- /dev/null +++ b/java/java-impl/src/com/intellij/refactoring/ui/AbstractMemberSelectionPanel.java @@ -0,0 +1,14 @@ +package com.intellij.refactoring.ui; + +import com.intellij.psi.PsiElement; +import com.intellij.refactoring.classMembers.MemberInfoBase; + +import javax.swing.*; + +/** + * Nikolay.Tropin + * 8/20/13 + */ +public abstract class AbstractMemberSelectionPanel<T extends PsiElement, M extends MemberInfoBase<T>> extends JPanel { + public abstract AbstractMemberSelectionTable<T, M> getTable(); +} diff --git a/java/java-impl/src/com/intellij/refactoring/ui/MemberSelectionPanel.java b/java/java-impl/src/com/intellij/refactoring/ui/MemberSelectionPanel.java index 05dd6f805634..c503a86e9c39 100644 --- a/java/java-impl/src/com/intellij/refactoring/ui/MemberSelectionPanel.java +++ b/java/java-impl/src/com/intellij/refactoring/ui/MemberSelectionPanel.java @@ -24,18 +24,16 @@ */ package com.intellij.refactoring.ui; +import com.intellij.psi.PsiMember; import com.intellij.refactoring.util.classMembers.MemberInfo; import com.intellij.ui.ScrollPaneFactory; import com.intellij.ui.SeparatorFactory; -import com.intellij.ui.TableUtil; import javax.swing.*; import java.awt.*; -import java.awt.event.FocusAdapter; -import java.awt.event.FocusEvent; import java.util.List; -public class MemberSelectionPanel extends JPanel { +public class MemberSelectionPanel extends AbstractMemberSelectionPanel<PsiMember, MemberInfo> { private final MemberSelectionTable myTable; /** diff --git a/java/java-impl/src/com/intellij/usages/impl/rules/ClassGroupingRule.java b/java/java-impl/src/com/intellij/usages/impl/rules/ClassGroupingRule.java index add3fe2b4106..e8af76be4fd6 100644 --- a/java/java-impl/src/com/intellij/usages/impl/rules/ClassGroupingRule.java +++ b/java/java-impl/src/com/intellij/usages/impl/rules/ClassGroupingRule.java @@ -32,7 +32,7 @@ import com.intellij.usages.UsageGroup; import com.intellij.usages.UsageView; import com.intellij.usages.rules.PsiElementUsage; import com.intellij.usages.rules.UsageGroupingRule; -import com.siyeh.ig.psiutils.FileTypeUtils; +import com.intellij.psi.util.FileTypeUtils; import org.jetbrains.annotations.NotNull; import javax.swing.*; diff --git a/java/java-indexing-api/src/com/intellij/psi/search/searches/ClassInheritorsSearch.java b/java/java-indexing-api/src/com/intellij/psi/search/searches/ClassInheritorsSearch.java index 233bb4251508..be4c4f81eb8a 100644 --- a/java/java-indexing-api/src/com/intellij/psi/search/searches/ClassInheritorsSearch.java +++ b/java/java-indexing-api/src/com/intellij/psi/search/searches/ClassInheritorsSearch.java @@ -83,6 +83,17 @@ public class ClassInheritorsSearch extends ExtensibleQueryFactory<PsiClass, Clas }); } + public interface InheritanceChecker { + boolean checkInheritance(@NotNull PsiClass subClass, @NotNull PsiClass parentClass); + + InheritanceChecker DEFAULT = new InheritanceChecker() { + @Override + public boolean checkInheritance(@NotNull PsiClass subClass, @NotNull PsiClass parentClass) { + return subClass.isInheritor(parentClass, false); + } + }; + } + public static class SearchParameters { private final PsiClass myClass; private final SearchScope myScope; @@ -90,6 +101,7 @@ public class ClassInheritorsSearch extends ExtensibleQueryFactory<PsiClass, Clas private final boolean myCheckInheritance; private final boolean myIncludeAnonymous; private final Condition<String> myNameCondition; + private final InheritanceChecker myInheritanceChecker; public SearchParameters(@NotNull final PsiClass aClass, @NotNull SearchScope scope, final boolean checkDeep, final boolean checkInheritance, boolean includeAnonymous) { this(aClass, scope, checkDeep, checkInheritance, includeAnonymous, Condition.TRUE); @@ -97,12 +109,18 @@ public class ClassInheritorsSearch extends ExtensibleQueryFactory<PsiClass, Clas public SearchParameters(@NotNull final PsiClass aClass, @NotNull SearchScope scope, final boolean checkDeep, final boolean checkInheritance, boolean includeAnonymous, @NotNull final Condition<String> nameCondition) { + this(aClass, scope, checkDeep, checkInheritance, includeAnonymous, nameCondition, InheritanceChecker.DEFAULT); + } + + public SearchParameters(@NotNull final PsiClass aClass, @NotNull SearchScope scope, final boolean checkDeep, final boolean checkInheritance, + boolean includeAnonymous, @NotNull final Condition<String> nameCondition, @NotNull InheritanceChecker inheritanceChecker) { myClass = aClass; myScope = scope; myCheckDeep = checkDeep; myCheckInheritance = checkInheritance; myIncludeAnonymous = includeAnonymous; myNameCondition = nameCondition; + myInheritanceChecker = inheritanceChecker; } @NotNull @@ -204,7 +222,7 @@ public class ClassInheritorsSearch extends ExtensibleQueryFactory<PsiClass, Clas public void run() { fqn[0] = candidate.getQualifiedName(); if (parameters.isCheckInheritance() || parameters.isCheckDeep() && !(candidate instanceof PsiAnonymousClass)) { - if (!candidate.isInheritor(currentBase.get(), false)) { + if (!parameters.myInheritanceChecker.checkInheritance(candidate, currentBase.get())) { result.set(true); return; } diff --git a/java/java-psi-api/src/com/intellij/codeInsight/ImportFilter.java b/java/java-psi-api/src/com/intellij/codeInsight/ImportFilter.java new file mode 100644 index 000000000000..4863b8217dc8 --- /dev/null +++ b/java/java-psi-api/src/com/intellij/codeInsight/ImportFilter.java @@ -0,0 +1,22 @@ +package com.intellij.codeInsight; + +import com.intellij.openapi.extensions.ExtensionPointName; +import org.jetbrains.annotations.NotNull; + +/** + * @author Eugene.Kudelevsky + */ +public abstract class ImportFilter { + public static final ExtensionPointName<ImportFilter> EP_NAME = new ExtensionPointName<ImportFilter>("com.intellij.importFilter"); + + public abstract boolean shouldUseFullyQualifiedName(@NotNull String classQualifiedName); + + public static boolean shouldImport(@NotNull String classQualifiedName) { + for (ImportFilter filter : EP_NAME.getExtensions()) { + if (filter.shouldUseFullyQualifiedName(classQualifiedName)) { + return false; + } + } + return true; + } +} diff --git a/java/java-psi-api/src/com/intellij/codeInsight/TestFrameworks.java b/java/java-psi-api/src/com/intellij/codeInsight/TestFrameworks.java index 9f7e02457f4a..248aad72fb51 100644 --- a/java/java-psi-api/src/com/intellij/codeInsight/TestFrameworks.java +++ b/java/java-psi-api/src/com/intellij/codeInsight/TestFrameworks.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. @@ -35,4 +35,13 @@ public abstract class TestFrameworks { @Nullable public abstract PsiMethod findSetUpMethod(PsiClass psiClass); + + @Nullable + public abstract PsiMethod findTearDownMethod(PsiClass psiClass); + + protected abstract boolean hasConfigMethods(PsiClass psiClass); + + public boolean isTestOrConfig(PsiClass psiClass) { + return isTestClass(psiClass) || hasConfigMethods(psiClass); + } } diff --git a/java/java-psi-api/src/com/intellij/openapi/projectRoots/JavaVersionService.java b/java/java-psi-api/src/com/intellij/openapi/projectRoots/JavaVersionService.java index 9e8338ed3797..5108c592c6ac 100644 --- a/java/java-psi-api/src/com/intellij/openapi/projectRoots/JavaVersionService.java +++ b/java/java-psi-api/src/com/intellij/openapi/projectRoots/JavaVersionService.java @@ -32,4 +32,8 @@ public class JavaVersionService { public boolean isAtLeast(@NotNull PsiElement element, @NotNull JavaSdkVersion version) { return PsiUtil.getLanguageLevel(element).isAtLeast(version.getMaxLanguageLevel()); } + + public JavaSdkVersion getJavaSdkVersion(@NotNull PsiElement element) { + return JavaSdkVersion.fromLanguageLevel(PsiUtil.getLanguageLevel(element)); + } }
\ No newline at end of file diff --git a/java/java-psi-api/src/com/intellij/psi/LambdaUtil.java b/java/java-psi-api/src/com/intellij/psi/LambdaUtil.java index 2bfe47080530..b0a014949f75 100644 --- a/java/java-psi-api/src/com/intellij/psi/LambdaUtil.java +++ b/java/java-psi-api/src/com/intellij/psi/LambdaUtil.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. @@ -93,7 +93,7 @@ public class LambdaUtil { return initialSubst; } - public static boolean isValidLambdaContext(PsiElement context) { + public static boolean isValidLambdaContext(@Nullable PsiElement context) { return context instanceof PsiTypeCastExpression || context instanceof PsiAssignmentExpression || context instanceof PsiVariable || diff --git a/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceUtil.java b/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceUtil.java index 17117c4965ff..a2a75bc3a787 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceUtil.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceUtil.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. @@ -107,6 +107,15 @@ public class PsiMethodReferenceUtil { } return new QualifierResolveResult(containingClass, substitutor, false); } + + public static boolean isStaticallyReferenced(@NotNull PsiMethodReferenceExpression methodReferenceExpression) { + final PsiExpression qualifierExpression = methodReferenceExpression.getQualifierExpression(); + if (qualifierExpression != null) { + return qualifierExpression instanceof PsiReferenceExpression && + ((PsiReferenceExpression)qualifierExpression).resolve() instanceof PsiClass; + } + return true; + } public static boolean isAcceptable(@Nullable final PsiMethodReferenceExpression methodReferenceExpression, PsiType left) { if (methodReferenceExpression == null) return false; diff --git a/java/java-psi-api/src/com/intellij/psi/util/FileTypeUtils.java b/java/java-psi-api/src/com/intellij/psi/util/FileTypeUtils.java new file mode 100644 index 000000000000..0080248397ce --- /dev/null +++ b/java/java-psi-api/src/com/intellij/psi/util/FileTypeUtils.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 com.intellij.psi.util; + +import com.intellij.psi.PsiElement; +import com.intellij.psi.ServerPageFile; + +public class FileTypeUtils { + public static boolean isInServerPageFile(PsiElement file) { + return PsiUtilCore.getTemplateLanguageFile(file) instanceof ServerPageFile; + } +} 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 3504ef8dfb3c..e3e2511a08d1 100644 --- a/java/java-psi-impl/src/com/intellij/codeInsight/BaseExternalAnnotationsManager.java +++ b/java/java-psi-impl/src/com/intellij/codeInsight/BaseExternalAnnotationsManager.java @@ -19,7 +19,6 @@ import com.intellij.lang.PsiBuilder; import com.intellij.lang.java.parser.JavaParser; import com.intellij.lang.java.parser.JavaParserUtil; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.LowMemoryWatcher; import com.intellij.openapi.util.Pair; @@ -251,9 +250,9 @@ public abstract class BaseExternalAnnotationsManager extends ExternalAnnotations MostlySingularMultiMap<String, AnnotationData> fileData = getDataFromFile(file); - addAnnotations(result, externalName, file, fileData); + ContainerUtil.addAll(result, fileData.get(externalName)); if (oldExternalName != null && !externalName.equals(oldExternalName)) { - addAnnotations(result, oldExternalName, file, fileData); + ContainerUtil.addAll(result, fileData.get(oldExternalName)); } } if (result.isEmpty()) { @@ -263,24 +262,6 @@ public abstract class BaseExternalAnnotationsManager extends ExternalAnnotations return result; } - private void addAnnotations(@NotNull List<AnnotationData> result, - @NotNull String externalName, - @NotNull PsiFile file, - @NotNull MostlySingularMultiMap<String, AnnotationData> fileData) { - Iterable<AnnotationData> data = fileData.get(externalName); - for (AnnotationData ad : data) { - if (result.contains(ad)) { - // there can be compatible annotations in different files - if (Comparing.equal(ad.virtualFile, file.getVirtualFile())) { - duplicateError(file, externalName, "Duplicate signature"); - } - } - else { - result.add(ad); - } - } - } - @Override @Nullable public List<PsiFile> findExternalAnnotationsFiles(@NotNull PsiModifierListOwner listOwner) { @@ -414,13 +395,11 @@ public abstract class BaseExternalAnnotationsManager extends ExternalAnnotations private static class AnnotationData { @NotNull private final String annotationClassFqName; @NotNull private final String annotationParameters; - private final VirtualFile virtualFile; private volatile PsiAnnotation annotation; - private AnnotationData(@NotNull String annotationClassFqName, @NotNull String annotationParameters, VirtualFile virtualFile) { + private AnnotationData(@NotNull String annotationClassFqName, @NotNull String annotationParameters) { this.annotationClassFqName = annotationClassFqName; this.annotationParameters = annotationParameters; - this.virtualFile = virtualFile; } @NotNull @@ -514,7 +493,7 @@ public abstract class BaseExternalAnnotationsManager extends ExternalAnnotations duplicateError(file, externalName, "Duplicate annotation '" + annotationFQN + "' "); } } - AnnotationData annData = internAnnotationData(new AnnotationData(annotationFQN, argumentsString, file.getVirtualFile())); + AnnotationData annData = internAnnotationData(new AnnotationData(annotationFQN, argumentsString)); data.add(externalName, annData); annotationFQN = null; arguments = null; diff --git a/java/java-psi-impl/src/com/intellij/codeInsight/TestFrameworksImpl.java b/java/java-psi-impl/src/com/intellij/codeInsight/TestFrameworksImpl.java index 08c7cd23d8dc..7671eae0c97a 100644 --- a/java/java-psi-impl/src/com/intellij/codeInsight/TestFrameworksImpl.java +++ b/java/java-psi-impl/src/com/intellij/codeInsight/TestFrameworksImpl.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. @@ -76,4 +76,28 @@ public class TestFrameworksImpl extends TestFrameworks { } return null; } + + @Override + @Nullable + public PsiMethod findTearDownMethod(final PsiClass psiClass) { + final TestFramework[] testFrameworks = Extensions.getExtensions(TestFramework.EXTENSION_NAME); + for (TestFramework framework : testFrameworks) { + if (framework.isTestClass(psiClass)) { + final PsiMethod setUpMethod = (PsiMethod)framework.findTearDownMethod(psiClass); + if (setUpMethod != null) { + return setUpMethod; + } + } + } + return null; + } + + @Override + protected boolean hasConfigMethods(PsiClass psiClass) { + final TestFramework[] testFrameworks = Extensions.getExtensions(TestFramework.EXTENSION_NAME); + for (TestFramework framework : testFrameworks) { + if (framework.findSetUpMethod(psiClass) != null || framework.findTearDownMethod(psiClass) != null) return true; + } + return false; + } }
\ No newline at end of file diff --git a/java/java-psi-impl/src/com/intellij/core/CoreJavaFileManager.java b/java/java-psi-impl/src/com/intellij/core/CoreJavaFileManager.java index 1df60969e17e..dd3904097351 100644 --- a/java/java-psi-impl/src/com/intellij/core/CoreJavaFileManager.java +++ b/java/java-psi-impl/src/com/intellij/core/CoreJavaFileManager.java @@ -26,10 +26,7 @@ import com.intellij.psi.search.GlobalSearchScope; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; +import java.util.*; /** * @author yole @@ -138,36 +135,48 @@ public class CoreJavaFileManager implements JavaFileManager { if (classes.length == 1) { PsiClass curClass = classes[0]; - if (bucks > 0) { - int newComponentStart = 0; - int lookupStart = 0; + if (bucks > 0) { + Stack<ClassAndOffsets> currentPath = new Stack<ClassAndOffsets>(); + currentPath.add(new ClassAndOffsets(curClass, 0, 0)); + currentPath.add(currentPath.peek()); - while (lookupStart <= className.length()) { - int b = className.indexOf("$", lookupStart); - b = b < 0 ? className.length(): b; + while (currentPath.size() > 1) { + ClassAndOffsets classAndOffset = currentPath.pop(); + int newComponentStart = classAndOffset.componentStart; + int lookupStart = classAndOffset.lookupStart; + curClass = currentPath.peek().clazz; //owner class - String component = className.substring(newComponentStart, b); - PsiClass inner = curClass.findInnerClassByName(component, false); + while (lookupStart <= className.length()) { + int bucksIndex = className.indexOf("$", lookupStart); + bucksIndex = bucksIndex < 0 ? className.length(): bucksIndex; - lookupStart = b + 1; - if (inner == null) { - continue; - } + String component = className.substring(newComponentStart, bucksIndex); + PsiClass inner = curClass.findInnerClassByName(component, false); - newComponentStart = lookupStart; - curClass = inner; - } + lookupStart = bucksIndex + 1; + if (inner == null) { + continue; + } + + currentPath.add(new ClassAndOffsets(inner, newComponentStart, lookupStart)); + + newComponentStart = lookupStart; + curClass = inner; + } + + if (lookupStart == newComponentStart) { + return curClass; + } + } - if (lookupStart != newComponentStart) { return null; + + } else { + return curClass; } } - - - return curClass; } } - } return null; } @@ -196,4 +205,17 @@ public class CoreJavaFileManager implements JavaFileManager { public void addToClasspath(VirtualFile root) { myClasspath.add(root); } + + private static class ClassAndOffsets { + + final PsiClass clazz; + final int componentStart; + final int lookupStart; + + ClassAndOffsets(PsiClass clazz, int componentStart, int lookupStart) { + this.clazz = clazz; + this.componentStart = componentStart; + this.lookupStart = lookupStart; + } + } } diff --git a/java/java-psi-impl/src/com/intellij/psi/controlFlow/LocalsControlFlowPolicy.java b/java/java-psi-impl/src/com/intellij/psi/controlFlow/LocalsControlFlowPolicy.java index 333ed4c45312..b5c0f8ef40a9 100644 --- a/java/java-psi-impl/src/com/intellij/psi/controlFlow/LocalsControlFlowPolicy.java +++ b/java/java-psi-impl/src/com/intellij/psi/controlFlow/LocalsControlFlowPolicy.java @@ -47,7 +47,7 @@ public class LocalsControlFlowPolicy implements ControlFlowPolicy { } if (codeFragment == null) return null; if (myCodeFragment.getContainingFile() == codeFragment.getContainingFile() && // in order for jsp includes to work - !myCodeFragment.equals(codeFragment)) { + !myCodeFragment.equals(codeFragment) && !(myCodeFragment.getParent() instanceof PsiLambdaExpression)) { return null; } return (PsiVariable)refElement; 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 0100ccc5e325..03a14f45d623 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 @@ -31,14 +31,20 @@ public class ClsAnnotationParameterListImpl extends ClsElementImpl implements Ps public ClsAnnotationParameterListImpl(@NotNull PsiAnnotation parent, @NotNull PsiNameValuePair[] psiAttributes) { myParent = parent; myAttributes = new ClsNameValuePairImpl[psiAttributes.length]; - for (int i = 0; i < myAttributes.length; i++) { + for (int i = 0; i < psiAttributes.length; i++) { String name = psiAttributes[i].getName(); + PsiAnnotationMemberValue value = psiAttributes[i].getValue(); if (value == null) { String anno = parent instanceof ClsAnnotationImpl ? ((ClsAnnotationImpl)parent).getStub().getText() : parent.getText(); - Logger.getInstance(getClass()).error("name=" + name + " anno=[" + anno + "]"); + Logger.getInstance(getClass()).error("name=" + name + " anno=[" + anno + "] file=" + parent.getContainingFile()); value = new ClsLiteralExpressionImpl(this, "null", PsiType.NULL, null); } + + if (psiAttributes.length == 1 && "value".equals(name)) { + name = null; // cosmetics - omit default attribute name + } + myAttributes[i] = new ClsNameValuePairImpl(this, name, value); } } diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/StubBuildingVisitor.java b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/StubBuildingVisitor.java index 8e79478dd2d6..7324f7bbcb4b 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/StubBuildingVisitor.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/StubBuildingVisitor.java @@ -17,9 +17,7 @@ package com.intellij.psi.impl.compiled; import com.intellij.openapi.util.text.StringUtil; import com.intellij.pom.java.LanguageLevel; -import com.intellij.psi.CommonClassNames; -import com.intellij.psi.PsiNameHelper; -import com.intellij.psi.PsiReferenceList; +import com.intellij.psi.*; import com.intellij.psi.impl.cache.ModifierFlags; import com.intellij.psi.impl.cache.TypeInfo; import com.intellij.psi.impl.java.stubs.*; @@ -340,7 +338,7 @@ public class StubBuildingVisitor<T> extends ClassVisitor { byte flags = PsiFieldStubImpl.packFlags((access & Opcodes.ACC_ENUM) != 0, (access & Opcodes.ACC_DEPRECATED) != 0, false); TypeInfo type = fieldType(desc, signature); - String initializer = constToString(value, "boolean".equals(type.text.getString()), false); + String initializer = constToString(value, type.text.getString(), false); PsiFieldStub stub = new PsiFieldStubImpl(myResult, name, type, initializer, flags); PsiModifierListStub modList = new PsiModifierListStubImpl(stub, packFieldFlags(access)); return new AnnotationCollectingVisitor(modList); @@ -537,7 +535,7 @@ public class StubBuildingVisitor<T> extends ClassVisitor { @Override public void visit(final String name, final Object value) { valuePairPrefix(name); - myBuilder.append(constToString(value, false, true)); + myBuilder.append(constToString(value, null, true)); } @Override @@ -556,7 +554,7 @@ public class StubBuildingVisitor<T> extends ClassVisitor { myBuilder.append(','); } - if (name != null && !"value".equals(name)) { + if (name != null) { myBuilder.append(name).append('='); } } @@ -697,18 +695,34 @@ public class StubBuildingVisitor<T> extends ClassVisitor { } @Nullable - private static String constToString(@Nullable Object value, boolean isBoolean, boolean anno) { + private static String constToString(@Nullable Object value, @Nullable String type, boolean anno) { if (value == null) return null; - if (value instanceof String) return "\"" + StringUtil.escapeStringCharacters((String)value) + "\""; - if (value instanceof Boolean) return value.toString(); - if (value instanceof Long) return value.toString() + "L"; + if (value instanceof String) { + return "\"" + StringUtil.escapeStringCharacters((String)value) + "\""; + } + + if (value instanceof Boolean || value instanceof Short || value instanceof Byte) { + return value.toString(); + } + + if (value instanceof Character) { + return "'" + StringUtil.escapeCharCharacters(value.toString()) + "'"; + } + + if (value instanceof Long) { + return value.toString() + "L"; + } if (value instanceof Integer) { - if (isBoolean) { + if ("boolean".equals(type)) { if (value.equals(0)) return "false"; if (value.equals(1)) return "true"; } + if ("char".equals(type)) { + char ch = (char)((Integer)value).intValue(); + return "'" + StringUtil.escapeCharCharacters(String.valueOf(ch)) + "'"; + } return value.toString(); } diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodReferenceExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodReferenceExpressionImpl.java index 4c799c689d42..25ff273f5947 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodReferenceExpressionImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodReferenceExpressionImpl.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. @@ -427,7 +427,9 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase boolean hasReceiver = false; final PsiType[] parameterTypes = mySignature.getParameterTypes(); - if (parameterTypes.length > 0 && PsiMethodReferenceUtil.isReceiverType(parameterTypes[0], myContainingClass, mySubstitutor)) { + if (parameterTypes.length > 0 && + PsiMethodReferenceUtil.isReceiverType(parameterTypes[0], myContainingClass, mySubstitutor) && + PsiMethodReferenceUtil.isStaticallyReferenced(PsiMethodReferenceExpressionImpl.this)) { hasReceiver = true; } diff --git a/java/java-tests/testData/codeInsight/completion/smartType/InLambdaPosition-out.java b/java/java-tests/testData/codeInsight/completion/smartType/InLambdaPosition-out.java new file mode 100644 index 000000000000..8b6864c5e474 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/smartType/InLambdaPosition-out.java @@ -0,0 +1,3 @@ +class Test { + Runnable r = () -> <caret> +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/smartType/InLambdaPosition.java b/java/java-tests/testData/codeInsight/completion/smartType/InLambdaPosition.java new file mode 100644 index 000000000000..8bda0afcc1d6 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/smartType/InLambdaPosition.java @@ -0,0 +1,3 @@ +class Test { + Runnable r = <caret> +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ExprReceiver.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ExprReceiver.java new file mode 100644 index 000000000000..f3bc8d4b8a6c --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ExprReceiver.java @@ -0,0 +1,15 @@ +class ThreadExample { + interface Function<T, R> { + + R apply(T t); + } + { + A a = new A(); + <error descr="Incompatible types. Found: '<method reference>', required: 'ThreadExample.Function<? super ThreadExample.A,? extends java.lang.String>'">Function<? super A,? extends String> foo = a::foo;</error> + } + + static class A { + public String foo() { return "a"; } + } +} + diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/modifier/after37.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/modifier/after37.java new file mode 100644 index 000000000000..97dcfd58b281 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/modifier/after37.java @@ -0,0 +1,8 @@ +// "Make 'a' not abstract" "true" +import java.io.*; + +abstract class A { + void a<caret>() { + } +} + diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/modifier/before37.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/modifier/before37.java new file mode 100644 index 000000000000..6be31221292f --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/modifier/before37.java @@ -0,0 +1,8 @@ +// "Make 'a' not abstract" "true" +import java.io.*; + +abstract class A { + abstract void a<caret>() { + } +} + diff --git a/java/java-tests/testData/codeInsight/generateConstructor/afterFieldPrefixCoincidence1.java b/java/java-tests/testData/codeInsight/generateConstructor/afterFieldPrefixCoincidence1.java new file mode 100644 index 000000000000..29be0de779ed --- /dev/null +++ b/java/java-tests/testData/codeInsight/generateConstructor/afterFieldPrefixCoincidence1.java @@ -0,0 +1,7 @@ +class Test { + private int _foo; + + Test(int foo) { + _foo = foo; + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/generateConstructor/beforeFieldPrefixCoincidence1.java b/java/java-tests/testData/codeInsight/generateConstructor/beforeFieldPrefixCoincidence1.java new file mode 100644 index 000000000000..8acd4dc129fd --- /dev/null +++ b/java/java-tests/testData/codeInsight/generateConstructor/beforeFieldPrefixCoincidence1.java @@ -0,0 +1,4 @@ +class Test { + private int _foo; + <caret> +}
\ No newline at end of file diff --git a/java/java-tests/testData/inspection/guarded/itself.java b/java/java-tests/testData/inspection/guarded/itself.java new file mode 100644 index 000000000000..35b784585086 --- /dev/null +++ b/java/java-tests/testData/inspection/guarded/itself.java @@ -0,0 +1,19 @@ +import net.jcip.annotations.GuardedBy; + +import java.lang.String; + +class A { + + @GuardedBy("itself") + private String _foo; + + public String getFoo() { + synchronized (_foo) { + return _foo; + } + } + + public void setFoo(String foo) { + <warning descr="Access to field '_foo' outside of declared guards">_foo</warning> = foo; + } +}
\ No newline at end of file diff --git a/java/java-tests/testData/inspection/localCanBeFinal/LambdaBody/expected.xml b/java/java-tests/testData/inspection/localCanBeFinal/LambdaBody/expected.xml new file mode 100644 index 000000000000..1da1935ad438 --- /dev/null +++ b/java/java-tests/testData/inspection/localCanBeFinal/LambdaBody/expected.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<problems> + <problem> + <file>Junk.java</file> + <line>4</line> + <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Local variable or parameter can be final</problem_class> + <description>Variable <code>i</code> can have <code>final</code> modifier</description> + </problem> + <problem> + <file>Junk.java</file> + <line>3</line> + <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Local variable or parameter can be final</problem_class> + <description>Variable <code>r</code> can have <code>final</code> modifier</description> + </problem> +</problems> + diff --git a/java/java-tests/testData/inspection/localCanBeFinal/LambdaBody/src/Junk.java b/java/java-tests/testData/inspection/localCanBeFinal/LambdaBody/src/Junk.java new file mode 100644 index 000000000000..f89a1e2f4786 --- /dev/null +++ b/java/java-tests/testData/inspection/localCanBeFinal/LambdaBody/src/Junk.java @@ -0,0 +1,10 @@ +public final class Junk { + public void sillyMethod() { + Runnable r = () -> { + int i = 0; + System.out.println(i); + }; + } +} + + diff --git a/java/java-tests/testData/psi/cls/mirror/Annotations.txt b/java/java-tests/testData/psi/cls/mirror/Annotations.txt index 9bbe384da735..58f2792d88f3 100644 --- a/java/java-tests/testData/psi/cls/mirror/Annotations.txt +++ b/java/java-tests/testData/psi/cls/mirror/Annotations.txt @@ -25,6 +25,9 @@ abstract class Annotations { @pkg.Annotations.A4(ids = {42, 84}) abstract void m4b(); + @pkg.Annotations.A5(b = true, value = java.lang.Integer.class) + abstract void m5(); + static @interface IndeterminateAnno { float f1() default -1.0f / 0.0; @@ -39,6 +42,12 @@ abstract class Annotations { double d3() default 1.0 / 0.0; } + static @interface A5 { + boolean b() default false; + + java.lang.Class<? extends java.lang.Number> value() default java.lang.Integer.class; + } + static @interface A4 { int[] ids() default {}; } diff --git a/java/java-tests/testData/psi/cls/mirror/Booleans.txt b/java/java-tests/testData/psi/cls/mirror/Booleans.txt deleted file mode 100644 index 8def7d921ba3..000000000000 --- a/java/java-tests/testData/psi/cls/mirror/Booleans.txt +++ /dev/null @@ -1,18 +0,0 @@ - - // IntelliJ API Decompiler stub source generated from a class file - // Implementation of methods is not available - -package pkg; - -class Booleans { - public static final boolean TRUE = true; - public static final boolean FALSE = false; - - Booleans() { /* compiled code */ } - - @pkg.BooleanAnno(true) - public static boolean TRUE() { /* compiled code */ } - - @pkg.BooleanAnno(false) - public static boolean FALSE() { /* compiled code */ } -}
\ No newline at end of file diff --git a/java/java-tests/testData/psi/cls/mirror/Primitives.txt b/java/java-tests/testData/psi/cls/mirror/Primitives.txt new file mode 100644 index 000000000000..4eb6750d0451 --- /dev/null +++ b/java/java-tests/testData/psi/cls/mirror/Primitives.txt @@ -0,0 +1,30 @@ + + // IntelliJ API Decompiler stub source generated from a class file + // Implementation of methods is not available + +package pkg; + +class Primitives { + public static final boolean TRUE = true; + public static final boolean FALSE = false; + public static final byte BYTE = 1; + public static final char CHAR = '\''; + public static final short SHORT = 42; + public static final int INT = 42; + public static final long LONG = 42L; + + Primitives() { /* compiled code */ } + + @pkg.BooleanAnno(true) + public static boolean TRUE() { /* compiled code */ } + + @pkg.BooleanAnno(false) + public static boolean FALSE() { /* compiled code */ } + + @pkg.ByteAnno(1) + @pkg.CharAnno('\\') + @pkg.ShortAnno(42) + @pkg.IntAnno(42) + @pkg.LongAnno(42L) + public static void m() { /* compiled code */ } +}
\ No newline at end of file diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A1.class b/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A1.class Binary files differindex 61209608ab7e..00c4747c6521 100644 --- a/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A1.class +++ b/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A1.class diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A2.class b/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A2.class Binary files differindex 8d94afe68543..96bda0c34281 100644 --- a/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A2.class +++ b/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A2.class diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A3.class b/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A3.class Binary files differindex 630cfd964d18..c23cb7cbb8b3 100644 --- a/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A3.class +++ b/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A3.class diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A4.class b/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A4.class Binary files differindex 040a84c05353..e00c95b04881 100644 --- a/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A4.class +++ b/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A4.class diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A5.class b/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A5.class Binary files differnew file mode 100644 index 000000000000..b85d9d0abc49 --- /dev/null +++ b/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$A5.class diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$IndeterminateAnno.class b/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$IndeterminateAnno.class Binary files differindex d77b499c1f59..101bbd26c396 100644 --- a/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$IndeterminateAnno.class +++ b/java/java-tests/testData/psi/cls/mirror/pkg/Annotations$IndeterminateAnno.class diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/Annotations.class b/java/java-tests/testData/psi/cls/mirror/pkg/Annotations.class Binary files differindex 03f1f52f42b8..a5293f04639b 100644 --- a/java/java-tests/testData/psi/cls/mirror/pkg/Annotations.class +++ b/java/java-tests/testData/psi/cls/mirror/pkg/Annotations.class diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/BooleanAnno.class b/java/java-tests/testData/psi/cls/mirror/pkg/BooleanAnno.class Binary files differindex 64ba86fc5932..118a4c4df8ca 100644 --- a/java/java-tests/testData/psi/cls/mirror/pkg/BooleanAnno.class +++ b/java/java-tests/testData/psi/cls/mirror/pkg/BooleanAnno.class diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/Booleans.class b/java/java-tests/testData/psi/cls/mirror/pkg/Booleans.class Binary files differdeleted file mode 100644 index 1a71ca06f3c4..000000000000 --- a/java/java-tests/testData/psi/cls/mirror/pkg/Booleans.class +++ /dev/null diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/ByteAnno.class b/java/java-tests/testData/psi/cls/mirror/pkg/ByteAnno.class Binary files differnew file mode 100644 index 000000000000..6250428694f7 --- /dev/null +++ b/java/java-tests/testData/psi/cls/mirror/pkg/ByteAnno.class diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/CharAnno.class b/java/java-tests/testData/psi/cls/mirror/pkg/CharAnno.class Binary files differnew file mode 100644 index 000000000000..17e8b6729b29 --- /dev/null +++ b/java/java-tests/testData/psi/cls/mirror/pkg/CharAnno.class diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/IntAnno.class b/java/java-tests/testData/psi/cls/mirror/pkg/IntAnno.class Binary files differnew file mode 100644 index 000000000000..e3e7eed220b0 --- /dev/null +++ b/java/java-tests/testData/psi/cls/mirror/pkg/IntAnno.class diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/LongAnno.class b/java/java-tests/testData/psi/cls/mirror/pkg/LongAnno.class Binary files differnew file mode 100644 index 000000000000..63147056a558 --- /dev/null +++ b/java/java-tests/testData/psi/cls/mirror/pkg/LongAnno.class diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/Primitives.class b/java/java-tests/testData/psi/cls/mirror/pkg/Primitives.class Binary files differnew file mode 100644 index 000000000000..1e2d9f0a17ff --- /dev/null +++ b/java/java-tests/testData/psi/cls/mirror/pkg/Primitives.class diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/ShortAnno.class b/java/java-tests/testData/psi/cls/mirror/pkg/ShortAnno.class Binary files differnew file mode 100644 index 000000000000..e5583b1cca2e --- /dev/null +++ b/java/java-tests/testData/psi/cls/mirror/pkg/ShortAnno.class diff --git a/java/java-tests/testData/psi/cls/mirror/src/pkg/Annotations.java b/java/java-tests/testData/psi/cls/mirror/src/pkg/Annotations.java index 5aeda680f6dd..dafd4dce2770 100644 --- a/java/java-tests/testData/psi/cls/mirror/src/pkg/Annotations.java +++ b/java/java-tests/testData/psi/cls/mirror/src/pkg/Annotations.java @@ -16,6 +16,11 @@ abstract class Annotations { int[] ids() default { }; } + @interface A5 { + boolean b() default false; + Class<? extends Number> value() default Integer.class; + } + @A1 abstract void m1(); @A2() abstract void m2a(); @@ -26,6 +31,8 @@ abstract class Annotations { @A4 abstract void m4a(); @A4(ids = {42, 84}) abstract void m4b(); + @A5(b = true, value = Integer.class) abstract void m5(); + @interface IndeterminateAnno { float f1() default Float.NEGATIVE_INFINITY; float f2() default Float.NaN; diff --git a/java/java-tests/testData/psi/cls/mirror/src/pkg/Booleans.java b/java/java-tests/testData/psi/cls/mirror/src/pkg/Booleans.java deleted file mode 100644 index 495e1ace68a3..000000000000 --- a/java/java-tests/testData/psi/cls/mirror/src/pkg/Booleans.java +++ /dev/null @@ -1,13 +0,0 @@ -package pkg; - -class Booleans { - public static final boolean TRUE = true; - public static final boolean FALSE = false; - - @BooleanAnno(true) public static boolean TRUE() { return TRUE; } - @BooleanAnno(false) public static boolean FALSE() { return FALSE; } -} - -@interface BooleanAnno { - boolean value(); -}
\ No newline at end of file diff --git a/java/java-tests/testData/psi/cls/mirror/src/pkg/Primitives.java b/java/java-tests/testData/psi/cls/mirror/src/pkg/Primitives.java new file mode 100644 index 000000000000..4ffcf4ae3634 --- /dev/null +++ b/java/java-tests/testData/psi/cls/mirror/src/pkg/Primitives.java @@ -0,0 +1,42 @@ +package pkg; + +class Primitives { + public static final boolean TRUE = true; + public static final boolean FALSE = false; + + @BooleanAnno(true) public static boolean TRUE() { return TRUE; } + @BooleanAnno(false) public static boolean FALSE() { return FALSE; } + + public static final byte BYTE = 1; + public static final char CHAR = '\''; + public static final short SHORT = 42; + public static final int INT = 42; + public static final long LONG = 42L; + + @ByteAnno(1) @CharAnno('\\') @ShortAnno(42) @IntAnno(42) @LongAnno(42L) + public static void m() { } +} + +@interface BooleanAnno { + boolean value(); +} + +@interface ByteAnno { + byte value(); +} + +@interface CharAnno { + char value(); +} + +@interface ShortAnno { + short value(); +} + +@interface IntAnno { + int value(); +} + +@interface LongAnno { + long value(); +} diff --git a/java/java-tests/testData/psi/cls/stubBuilder/Nullable.txt b/java/java-tests/testData/psi/cls/stubBuilder/Nullable.txt index 277fe1497cf9..5f492a770b1b 100644 --- a/java/java-tests/testData/psi/cls/stubBuilder/Nullable.txt +++ b/java/java-tests/testData/psi/cls/stubBuilder/Nullable.txt @@ -2,8 +2,8 @@ PsiJavaFileStub [org.jetbrains.annotations] PsiClassStub[interface annotation name=Nullable fqn=org.jetbrains.annotations.Nullable] PsiModifierListStub[mask=1025] PsiAnnotationStub[@java.lang.annotation.Documented] - PsiAnnotationStub[@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS)] - PsiAnnotationStub[@java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD,java.lang.annotation.ElementType.FIELD,java.lang.annotation.ElementType.PARAMETER,java.lang.annotation.ElementType.LOCAL_VARIABLE})] + PsiAnnotationStub[@java.lang.annotation.Retention(value=java.lang.annotation.RetentionPolicy.CLASS)] + PsiAnnotationStub[@java.lang.annotation.Target(value={java.lang.annotation.ElementType.METHOD,java.lang.annotation.ElementType.FIELD,java.lang.annotation.ElementType.PARAMETER,java.lang.annotation.ElementType.LOCAL_VARIABLE})] PsiTypeParameterListStub PsiRefListStub[EXTENDS_LIST:] PsiRefListStub[IMPLEMENTS_LIST:] diff --git a/java/java-tests/testData/refactoring/extractMethod/FromLambdaBody1.java b/java/java-tests/testData/refactoring/extractMethod/FromLambdaBody1.java new file mode 100644 index 000000000000..fcb14a849657 --- /dev/null +++ b/java/java-tests/testData/refactoring/extractMethod/FromLambdaBody1.java @@ -0,0 +1,22 @@ +/* + * 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. + */ +class Test { + public void foo(int ii) { + Runnable r = () -> { + <selection>System.out.println(ii);</selection> + }; + } +} diff --git a/java/java-tests/testData/refactoring/extractMethod/FromLambdaBody1_after.java b/java/java-tests/testData/refactoring/extractMethod/FromLambdaBody1_after.java new file mode 100644 index 000000000000..6debfdee24db --- /dev/null +++ b/java/java-tests/testData/refactoring/extractMethod/FromLambdaBody1_after.java @@ -0,0 +1,26 @@ +/* + * 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. + */ +class Test { + public void foo(int ii) { + Runnable r = () -> { + newMethod(ii); + }; + } + + private void newMethod(int ii) { + System.out.println(ii); + } +} diff --git a/java/java-tests/testData/refactoring/invertBoolean/methodRefs.java b/java/java-tests/testData/refactoring/invertBoolean/methodRefs.java new file mode 100644 index 000000000000..b7477fc316ef --- /dev/null +++ b/java/java-tests/testData/refactoring/invertBoolean/methodRefs.java @@ -0,0 +1,14 @@ +abstract class A{ + static boolean isB<caret>ool() { + return false; + } + + + interface I { + boolean b(); + } + + { + I i = A::isBool; + } +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/GenerateConstructorTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/GenerateConstructorTest.java index 3fb5b7c848f4..5ef9e70a8093 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/GenerateConstructorTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/GenerateConstructorTest.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. @@ -55,6 +55,11 @@ public class GenerateConstructorTest extends LightCodeInsightTestCase { doTest(); } + public void testFieldPrefixCoincidence1() throws Exception { + CodeStyleSettingsManager.getInstance(getProject()).getCurrentSettings().FIELD_NAME_PREFIX = "_"; + doTest(); + } + private void doTest() throws Exception { doTest(false); } 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 669070815bce..d626cbaf6080 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy @@ -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. @@ -83,6 +83,20 @@ class JavaAutoPopupTest extends CompletionAutoPopupTestCase { assert lookup.focused } + public void testAfterDblColon() { + myFixture.configureByText("a.java", """ + class Foo { + void foo() { + Runnable::<caret> + } + } + """) + type('r') + def les = myFixture.lookupElementStrings + assert 'run' in les + assert lookup.focused + } + def assertContains(String... items) { myFixture.assertPreferredCompletionItems(0, items) } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType18CompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType18CompletionTest.java index f8ea1ba949bc..c386bd3c0f7a 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType18CompletionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType18CompletionTest.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. @@ -66,6 +66,10 @@ public class SmartType18CompletionTest extends LightFixtureCompletionTestCase { doTest(); } + public void testInLambdaPosition() throws Exception { + doTest(); + } + private void doTest() { configureByFile("/" + getTestName(false) + ".java"); assertNotNull(myItems); diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MethodRefHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MethodRefHighlightingTest.java index 064b2c39c6bc..a1016d7332cf 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MethodRefHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MethodRefHighlightingTest.java @@ -78,6 +78,7 @@ public class MethodRefHighlightingTest extends LightDaemonAnalyzerTestCase { public void testAbstractMethod() { doTest(); } public void testMethodRefAcceptance() { doTest(); } public void testVarargsMethodRef() { doTest(); } + public void testExprReceiver() { doTest(); } public void testTypeParameterWithExtendsList() throws Exception { doTest(); diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/FieldAccessedNotGuardedInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/FieldAccessedNotGuardedInspectionTest.java new file mode 100644 index 000000000000..88fd4ce21e21 --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/codeInspection/FieldAccessedNotGuardedInspectionTest.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 com.intellij.codeInspection; + +import com.intellij.JavaTestUtil; +import com.intellij.codeInspection.concurrencyAnnotations.FieldAccessNotGuardedInspection; +import com.intellij.openapi.application.PluginPathManager; +import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; +import org.jetbrains.annotations.NotNull; + +public class FieldAccessedNotGuardedInspectionTest extends LightCodeInsightFixtureTestCase { + public void testItself() throws Exception { + myFixture.addClass("package net.jcip.annotations;\n" + + "@java.lang.annotation.Target({java.lang.annotation.ElementType.FIELD, java.lang.annotation.ElementType.METHOD})\n" + + "@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)\n" + + "public @interface GuardedBy {\n" + + " java.lang.String value();\n" + + "}"); + myFixture.testHighlighting(true, false, false, getTestName(true) + ".java"); + } + + + @Override + protected void setUp() throws Exception { + super.setUp(); + myFixture.enableInspections(new FieldAccessNotGuardedInspection()); + } + + @NotNull + @Override + protected String getTestDataPath() { + return JavaTestUtil.getJavaTestDataPath() + "/inspection/guarded"; + } +} diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/LocalCanBeFinalTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/LocalCanBeFinalTest.java index c8e5ecf6fa1c..7dfa608fc142 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/LocalCanBeFinalTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/LocalCanBeFinalTest.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 com.intellij.codeInspection; import com.intellij.JavaTestUtil; @@ -102,4 +117,10 @@ public class LocalCanBeFinalTest extends InspectionTestCase { myTool.REPORT_VARIABLES = true; doTest(); } + + public void testLambdaBody() throws Exception { + myTool.REPORT_PARAMETERS = true; + myTool.REPORT_VARIABLES = true; + doTest(); + } } diff --git a/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java b/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java index 65092f24eb99..e579fbb49ca4 100644 --- a/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java +++ b/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java @@ -32,6 +32,7 @@ import com.intellij.psi.*; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.search.LocalSearchScope; import com.intellij.testFramework.IdeaTestUtil; +import com.intellij.testFramework.LightVirtualFile; import com.intellij.testFramework.PlatformTestUtil; import com.intellij.testFramework.PsiTestUtil; import com.intellij.testFramework.fixtures.TempDirTestFixture; @@ -434,5 +435,116 @@ public class FindManagerTest extends DaemonAnalyzerTestCase { } } + public void testFindInCommentsAndLiterals() throws Exception{ + FindManager findManager = FindManager.getInstance(myProject); + + FindModel findModel = new FindModel(); + findModel.setStringToFind("done"); + findModel.setWholeWordsOnly(false); + findModel.setFromCursor(false); + findModel.setGlobal(true); + findModel.setMultipleFiles(false); + findModel.setProjectScope(true); + + String text = "\"done done done\" /* done done done */"; + + runFindInCommentsAndLiterals(findManager, findModel, text); + + findModel.setRegularExpressions(true); + runFindInCommentsAndLiterals(findManager, findModel, text); + } + + private static void runFindInCommentsAndLiterals(FindManager findManager, FindModel findModel, String text) { + runFindInCommentsAndLiterals(findManager, findModel, text, "java"); + } + + private static void runFindInCommentsAndLiterals(FindManager findManager, + FindModel findModel, + String text, + String ext) { + findModel.setInStringLiteralsOnly(true); + findModel.setInCommentsOnly(false); + runFindForwardAndBackward(findManager, findModel, text, ext); + + findModel.setInStringLiteralsOnly(false); + findModel.setInCommentsOnly(true); + runFindForwardAndBackward(findManager, findModel, text, ext); + } + + private static void runFindForwardAndBackward(FindManager findManager, FindModel findModel, String text) { + runFindForwardAndBackward(findManager, findModel, text, "java"); + } + + private static void runFindForwardAndBackward(FindManager findManager, FindModel findModel, String text, String ext) { + findModel.setForward(true); + LightVirtualFile file = new LightVirtualFile("A."+ext, text); + int prevousOffset; + + FindResult findResult = findManager.findString(text, 0, findModel, file); + assertTrue(findResult.isStringFound()); + prevousOffset = findResult.getStartOffset(); + + findResult = findManager.findString(text, findResult.getEndOffset(), findModel, file); + assertTrue(findResult.isStringFound()); + assertTrue(findResult.getStartOffset() > prevousOffset); + prevousOffset = findResult.getStartOffset(); + + findResult = findManager.findString(text, findResult.getEndOffset(), findModel, file); + assertTrue(findResult.isStringFound()); + assertTrue(findResult.getStartOffset() > prevousOffset); + + findModel.setForward(false); + + findResult = findManager.findString(text, text.length(), findModel, file); + assertTrue(findResult.isStringFound()); + prevousOffset = findResult.getStartOffset(); + + findResult = findManager.findString(text, prevousOffset, findModel, file); + assertTrue(findResult.isStringFound()); + assertTrue(prevousOffset > findResult.getStartOffset() ); + + prevousOffset = findResult.getStartOffset(); + + findResult = findManager.findString(text, prevousOffset, findModel, file); + assertTrue(findResult.isStringFound()); + assertTrue(prevousOffset > findResult.getStartOffset() ); + } + + public void testFindInJavaDocs() throws Exception{ + FindManager findManager = FindManager.getInstance(myProject); + + FindModel findModel = new FindModel(); + findModel.setStringToFind("done"); + findModel.setWholeWordsOnly(false); + findModel.setFromCursor(false); + findModel.setGlobal(true); + findModel.setMultipleFiles(false); + findModel.setProjectScope(true); + + String text = "/** done done done */"; + findModel.setInCommentsOnly(true); + runFindForwardAndBackward(findManager, findModel, text); + + findModel.setRegularExpressions(true); + runFindForwardAndBackward(findManager, findModel, text); + } + + public void testFindInUserFileType() throws Exception{ + FindManager findManager = FindManager.getInstance(myProject); + + FindModel findModel = new FindModel(); + findModel.setStringToFind("done"); + findModel.setWholeWordsOnly(false); + findModel.setFromCursor(false); + findModel.setGlobal(true); + findModel.setMultipleFiles(false); + findModel.setProjectScope(true); + + String text = "\"done done\"; 'done'; // done\n" + + "/* done\n" + + "done */"; + + runFindInCommentsAndLiterals(findManager, findModel, text, "cs"); + } } diff --git a/java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java b/java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java index 0217607f1793..a7deee87bada 100644 --- a/java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java @@ -40,7 +40,7 @@ public class ClsMirrorBuildingTest extends LightIdeaTestCase { public void testMethodReceiver() { doTest(); } public void testPackageInfo() { doTest("package-info"); } public void testEA40568() { doTest(); } - public void testBooleans() { doTest(); } + public void testPrimitives() { doTest(); } public void testClassRefs() { doTest(); } public void testEA46236() { doTest("ValuedEnum"); } diff --git a/java/java-tests/testSrc/com/intellij/psi/CoreJavaFileManagerTest.java b/java/java-tests/testSrc/com/intellij/psi/CoreJavaFileManagerTest.java index 1cd630ccc2db..5c12affa5e72 100644 --- a/java/java-tests/testSrc/com/intellij/psi/CoreJavaFileManagerTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/CoreJavaFileManagerTest.java @@ -22,26 +22,35 @@ import com.intellij.psi.search.GlobalSearchScope; import com.intellij.testFramework.PsiTestCase; import com.intellij.testFramework.PsiTestUtil; +import java.util.LinkedList; +import java.util.Queue; + public class CoreJavaFileManagerTest extends PsiTestCase { - public void testNotNullInnerClass() throws Exception { + private VirtualFile prepareClasses(String clazzName, String clazzData) throws Exception { VirtualFile root = PsiTestUtil.createTestProjectStructure(myProject, myModule, myFilesToDelete); VirtualFile pkg = root.createChildDirectory(this, "foo"); PsiDirectory dir = myPsiManager.findDirectory(pkg); assertNotNull(dir); + dir.add(PsiFileFactory.getInstance(getProject()).createFileFromText(clazzName + ".java", JavaFileType.INSTANCE, clazzData)); + return root; + } + + public void testNotNullInnerClass() throws Exception { String text = "package foo;\n\n" + "public class Nested {\n" + "public class InnerGeneral {}\n" + - "public class Inner$ {}\n" + + "public class Inner$ {" + + "}\n" + "\n" + "public Inner$ inner() {\n" + " return new Inner$();\n" + "}\n" + "\n" + "}"; - PsiElement created = dir.add(PsiFileFactory.getInstance(getProject()).createFileFromText("Nested.java", JavaFileType.INSTANCE, text)); + VirtualFile root = prepareClasses("Nested", text); GlobalSearchScope scope = GlobalSearchScope.allScope(getProject()); CoreJavaFileManager manager = new CoreJavaFileManager(myPsiManager); manager.addToClasspath(root); @@ -65,4 +74,90 @@ public class CoreJavaFileManagerTest extends PsiTestCase { assertNull(clazzInner$Wrong3); } + + public void testNotNullInnerClass2() throws Exception { + String text = "package foo;\n\n" + + "public class Nested {\n" + + + "public class Inner {" + + " public class XInner{}" + + " public class XInner${}" + + "}\n" + + "public class Inner$ {" + + " public class XInner{}" + + " public class XInner${}" + + "}\n" + + "\n" + + "}"; + + VirtualFile root = prepareClasses("Nested", text); + GlobalSearchScope scope = GlobalSearchScope.allScope(getProject()); + CoreJavaFileManager manager = new CoreJavaFileManager(myPsiManager); + manager.addToClasspath(root); + + PsiClass clazzInner = manager.findClass("foo.Nested.Inner", scope); + assertNotNull(clazzInner); + + PsiClass clazzXInner = manager.findClass("foo.Nested.Inner.XInner", scope); + assertNotNull(clazzXInner); + + PsiClass clazzXInner$ = manager.findClass("foo.Nested.Inner.XInner$", scope); + assertNotNull(clazzXInner$); + + PsiClass clazz$XInner = manager.findClass("foo.Nested.Inner$.XInner", scope); + assertNotNull(clazz$XInner); + + PsiClass clazz$XInner$ = manager.findClass("foo.Nested.Inner$.XInner$", scope); + assertNotNull(clazz$XInner$); + } + + + public void testNotNullInnerClass3() throws Exception { + String text = "package foo;\n\n" + + "public class NestedX {\n" + + + "public class XX {" + + " public class XXX{" + + " public class XXXX{ }" + + " public class XXXX${ }" + + " }" + + " public class XXX${" + + " public class XXXX{ }" + + " public class XXXX${ }" + + " }" + + "}\n" + + "public class XX$ {" + + " public class XXX{" + + " public class XXXX{ }" + + " public class XXXX${ }" + + " }" + + " public class XXX${" + + " public class XXXX{ }" + + " public class XXXX${ }" + + " }" + + "}\n" + + "\n" + + "}"; + + VirtualFile root = prepareClasses("NestedX", text); + GlobalSearchScope scope = GlobalSearchScope.allScope(getProject()); + CoreJavaFileManager manager = new CoreJavaFileManager(myPsiManager); + manager.addToClasspath(root); + + Queue<String> queue = new LinkedList<String>(); + queue.add("foo.NestedX"); + + while(!queue.isEmpty()) { + String head = queue.remove(); + PsiClass clazzInner = manager.findClass(head, scope); + assertNotNull(head, clazzInner); + String lastSegment = head.substring(head.lastIndexOf('.')); + String xs = lastSegment.substring(lastSegment.indexOf("X")).replace("$", ""); + if (xs.length() < 4) { + queue.add(head + "." + xs + "X"); + queue.add(head + "." + xs + "X$"); + } + } + } + } diff --git a/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodTest.java b/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodTest.java index b56646516390..07002255014a 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodTest.java @@ -547,6 +547,10 @@ public class ExtractMethodTest extends LightCodeInsightTestCase { doTest(); } + public void testFromLambdaBody1() throws Exception { + doTest(); + } + public void testOneLineLambda() throws Exception { doTest(); } diff --git a/java/java-tests/testSrc/com/intellij/refactoring/InvertBooleanTest.java b/java/java-tests/testSrc/com/intellij/refactoring/InvertBooleanTest.java index 236ac1a82ee5..175577041eb9 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/InvertBooleanTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/InvertBooleanTest.java @@ -30,6 +30,15 @@ public class InvertBooleanTest extends LightRefactoringTestCase { public void testInnerClasses() throws Exception {doTest();} public void testAnonymousClasses() throws Exception {doTest();} + public void testMethodRefs() throws Exception { + try { + doTest(); + fail("Conflict expected."); + } + catch (BaseRefactoringProcessor.ConflictsInTestsException e) { + assertEquals("Method is used in method reference expression", e.getMessage()); + } + } private void doTest() throws Exception { configureByFile(TEST_ROOT + getTestName(true) + ".java"); diff --git a/java/java-tests/testSrc/com/intellij/roots/ManagingContentRootsTest.java b/java/java-tests/testSrc/com/intellij/roots/ManagingContentRootsTest.java index b0ed71e38192..d6468e316429 100644 --- a/java/java-tests/testSrc/com/intellij/roots/ManagingContentRootsTest.java +++ b/java/java-tests/testSrc/com/intellij/roots/ManagingContentRootsTest.java @@ -83,7 +83,7 @@ public class ManagingContentRootsTest extends IdeaTestCase { assertEquals(root, findContentEntry(url).getFile()); } - public void testGettingMofifiableModelCorrectlySetsRootModelForContentEntries() throws Exception { + public void testGettingModifiableModelCorrectlySetsRootModelForContentEntries() { ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { diff --git a/java/openapi/src/com/intellij/codeInsight/intention/QuickFixFactory.java b/java/openapi/src/com/intellij/codeInsight/intention/QuickFixFactory.java index 5dca4c34e034..b422156ba792 100644 --- a/java/openapi/src/com/intellij/codeInsight/intention/QuickFixFactory.java +++ b/java/openapi/src/com/intellij/codeInsight/intention/QuickFixFactory.java @@ -31,38 +31,53 @@ public abstract class QuickFixFactory { return ServiceManager.getService(QuickFixFactory.class); } + @NotNull public abstract LocalQuickFixAndIntentionActionOnPsiElement createModifierListFix(@NotNull PsiModifierList modifierList, @PsiModifier.ModifierConstant @NotNull String modifier, boolean shouldHave, final boolean showContainingClass); + @NotNull public abstract LocalQuickFixAndIntentionActionOnPsiElement createModifierListFix(@NotNull PsiModifierListOwner owner, @PsiModifier.ModifierConstant @NotNull String modifier, boolean shouldHave, final boolean showContainingClass); + @NotNull public abstract LocalQuickFixAndIntentionActionOnPsiElement createMethodReturnFix(@NotNull PsiMethod method, @NotNull PsiType toReturn, boolean fixWholeHierarchy); - + @NotNull public abstract LocalQuickFixAndIntentionActionOnPsiElement createAddMethodFix(@NotNull PsiMethod method, @NotNull PsiClass toClass); - public abstract LocalQuickFixAndIntentionActionOnPsiElement createAddMethodFix(@NotNull String methodText, @NotNull PsiClass toClass, String... exceptions); + @NotNull + public abstract LocalQuickFixAndIntentionActionOnPsiElement createAddMethodFix(@NotNull String methodText, @NotNull PsiClass toClass, @NotNull String... exceptions); /** * @param psiElement psiClass or enum constant without class initializer */ + @NotNull public abstract LocalQuickFixAndIntentionActionOnPsiElement createImplementMethodsFix(@NotNull PsiElement psiElement); + @NotNull public abstract LocalQuickFixAndIntentionActionOnPsiElement createImplementMethodsFix(@NotNull PsiClass psiElement); + @NotNull public abstract LocalQuickFixOnPsiElement createMethodThrowsFix(@NotNull PsiMethod method, @NotNull PsiClassType exceptionClass, boolean shouldThrow, boolean showContainingClass); + @NotNull public abstract LocalQuickFixAndIntentionActionOnPsiElement createAddDefaultConstructorFix(@NotNull PsiClass aClass); @Nullable - public abstract LocalQuickFixAndIntentionActionOnPsiElement createAddConstructorFix(@NotNull PsiClass aClass, @PsiModifier.ModifierConstant String modifier); + public abstract LocalQuickFixAndIntentionActionOnPsiElement createAddConstructorFix(@NotNull PsiClass aClass, @PsiModifier.ModifierConstant @NotNull String modifier); + @NotNull public abstract LocalQuickFixAndIntentionActionOnPsiElement createMethodParameterTypeFix(@NotNull PsiMethod method, int index, @NotNull PsiType newType, boolean fixWholeHierarchy); + @NotNull public abstract LocalQuickFixAndIntentionActionOnPsiElement createMakeClassInterfaceFix(@NotNull PsiClass aClass); + @NotNull public abstract LocalQuickFixAndIntentionActionOnPsiElement createMakeClassInterfaceFix(@NotNull PsiClass aClass, final boolean makeInterface); + @NotNull public abstract LocalQuickFixAndIntentionActionOnPsiElement createExtendsListFix(@NotNull PsiClass aClass, @NotNull PsiClassType typeToExtendFrom, boolean toAdd); + @NotNull public abstract LocalQuickFixAndIntentionActionOnPsiElement createRemoveUnusedParameterFix(@NotNull PsiParameter parameter); + @NotNull public abstract IntentionAction createRemoveUnusedVariableFix(@NotNull PsiVariable variable); @Nullable public abstract IntentionAction createCreateClassOrPackageFix(@NotNull PsiElement context, @NotNull String qualifiedName, final boolean createClass, final String superClass); @Nullable public abstract IntentionAction createCreateClassOrInterfaceFix(@NotNull PsiElement context, @NotNull String qualifiedName, final boolean createClass, final String superClass); - public abstract IntentionAction createCreateFieldOrPropertyFix(final PsiClass aClass, final String name, final PsiType type, final PropertyMemberType targetMember, final PsiAnnotation... annotations); + @NotNull + public abstract IntentionAction createCreateFieldOrPropertyFix(@NotNull PsiClass aClass, @NotNull String name, @NotNull PsiType type, @NotNull PropertyMemberType targetMember, @NotNull PsiAnnotation... annotations); } diff --git a/java/openapi/src/com/intellij/openapi/projectRoots/JavaSdk.java b/java/openapi/src/com/intellij/openapi/projectRoots/JavaSdk.java index 88a5c55c1c2a..51ae01f5c1b9 100644 --- a/java/openapi/src/com/intellij/openapi/projectRoots/JavaSdk.java +++ b/java/openapi/src/com/intellij/openapi/projectRoots/JavaSdk.java @@ -25,7 +25,7 @@ import org.jetbrains.annotations.Nullable; import java.io.File; public abstract class JavaSdk extends SdkType implements JavaSdkType, ApplicationComponent { - public JavaSdk(@NonNls String name) { + public JavaSdk(@NotNull @NonNls String name) { super(name); } diff --git a/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java b/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java index cfd68e9eeac2..03ec96844a5c 100644 --- a/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java +++ b/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java @@ -139,11 +139,11 @@ public abstract class CodeInsightTestCase extends PsiTestCase { return configureByFile(vFile, projectFile); } - protected PsiFile configureByText(final FileType fileType, @NonNls final String text) throws Exception { + protected PsiFile configureByText(@NotNull FileType fileType, @NonNls final String text) throws Exception { return configureByText(fileType, text, null); } - protected PsiFile configureByText(final FileType fileType, @NonNls final String text, @Nullable String _extension) throws Exception { + protected PsiFile configureByText(@NotNull final FileType fileType, @NonNls final String text, @Nullable String _extension) throws Exception { final String extension = _extension == null ? fileType.getDefaultExtension():_extension; File dir = createTempDirectory(); |