Snapshot 34f078c3452e79ba209d28a551962857e0970e5d from idea/134.1342 of git://git.jetbrains.org/idea/community.git
34f078c: WEB-11147 NPM: Upgrade is disabled for package that was selected before it's version was fetched
caa3d13: Slim. Parser skipps leading comments and line breaks
7b58b81: IDEA-121215 (Java 1.8: "Interface may be annotated with @FunctionalInterface" inspection should not report @interfaces)
4f97ffe: don't reuse progress indicator in ctrl+mouse handler (EA-53958)
95a36c3: IDEA-121294 Toggling breakpoint with a mouse causes unfolding of a section
583c5a7: IDEA-121301 Setting a breakpoint after navigation to a folded method
245f457: cache jar root path
56ca4df: drop memory usage indicator old style
c049454: improve error reporting
72bac20: IDEA-109979 The ability to set breakpoints in the breakpoints edit window
f400bdc: CR-IC-4385 move util method to util
f6ff78b: notnull
847aa41: cleanup
5bd112a: Marking following plugins as broken NodeJS 134.1276 Php 133.982 Ruby 6.0.0.20140207 Karma 134.1163 JSTestDriver 134.1163
aea523f: Cleanup (deprecated code; formatting)
7d90896: Cleanup (missing delegation)
f9371d5: Cleanup (loop invariant; duplicated code)
38269aa: Cleanup (formatting)
7d3368b: java: PsiType documentation corrected
f288bdc: Cleanup (pointless null check; formatting)
d173a3e: IDEA-46403 Breakpoint on an empty line
e0e750e: don't queue breakpoint ui update if nothing changed reuse old CustomizedBreakpointPresentation
0ba4d7e: Gradle description
547cce7: Merge remote-tracking branch 'origin/master'
dff66d2: add JDK statistics
a90591f: Merge branch 'python-fixes'
ae1e6ca: Better error recovery for lines with single 'class' or 'def' keywords and normal functions defined below
10c8b99: support UI state for toggleable selected actions
b1dd00f: icon wrapper for selected toggleable actions' icons
8b4df90: re-think and make it usable in PoppedIcon
83f082f: dispose created marker for good
a39c3b7: Better error recovery for blocks with missing ':' and non-empty bodies
9b8a6cc: Fixed unmached parentheses in test data
9186334: a test for IDEA-116706 Unselect word at caret doesn't work reversing through lambdarized anonymous class
2cb92f2: fix isEnabledCondition
c47a26d: cleanup
60316b6: spelling
4a50ed6: use SmartList
788e5a0: cleanup
628b30a: cleanup
2efcf47: suppress warning
876a793: new test
3f8471c: @Nullable
18f2aee: optimize resolve. In some cases resolve() works faster than resolveGenerics (for example in LiteralClassType) and does not need to infer type parameters which can are needed only after some checks
3f460bc: language level is not @NotNull
37fcda8: simplify code
76d9c82: typo
d85d9f7: lazy inference of closure parameters' types some renames and cleanups
7874795: Disable fullscreen for the sheet parent
88a57a0: Merge remote-tracking branch 'origin/master'
7788a2f: PY-12173 Extract Superclass: warn about conflicting names
0fb4704: diff: fix EditSource action description on toolbar
feaf1fa: fix double icon in available plugins table
c332536: move Sort Installed First to context menu
5ad1016: move Sort by Status to context menu
09bd5b3: Fixed error recovery after empty blocks with no indent
2956e56: PY-12179 Pull up: do not show dialog when there is nothing to pull up
17a06dc: EA-54364 - CCE: SuppressionAnnotationInspectionBase$SuppressionAnnotationVisitor.visitAnnotation
6033fa8: provide type parameter based type with site substitutor to be accepted during type arguments check
2f69c1e: notnull
a575173: moved to community
b8d01ff: CR-IC-4490 Make EnforcedPlainTextFileTypeManager use only project configurations (fixes IDEA-120941)
84279e1: warn only on method parameters
cc9d5bb: IDEA-70465 Multi selection + making it working with live templates
792ea73: WEB-9670 'Surround with Emmet' doesn't work with block selection
1270d02: Live templates and multicaret: stop template at the first variable or end marker
14837f9: Enable multicaret for live templates
6fcc639: IDEA-121193 Don't show 'Class already exists' error if there are two groovy classes with the same qualified name in different modules
6e2687a: CR-IC-4514 @NotNull
2f8c679: cleanup
d4e0fec: Merge remote-tracking branch 'origin/master'
dd8e7fe: Merge branch 'svn_18_3'
78a3523: restored platform prefix autodetection to fix sql tests
5057388: svn: Fixed NPE in SvnConfiguration - initialize inner state to default value
1c5b685: IDEA-95011 diff: better handling of FilesTooBigForDiffException in merge dialog
c599d55: IDEA-121140 Format spock DSL in script body
841e5c6: isRetina fix for headless mode reviewed by kb
685e871: Merge branch 'disable-strings-no-effect'
be10b84: Disable 'Statement has no effect' for all string literals (PY-12194)
ca00903: use embedded tokes for templates instead of injections #WEB-11115 fixed
b671182: Platform: disabled image interpolation on resize in the viewer (IDEA-98635)
f48afb5: Merge remote-tracking branch 'origin/master'
151071e: EA-54197 - IAE: HgTagBranchCommand.collectNames
6a669b7: avoid stripping whitespaces on caret lines on document save (IDEA-80056)
28437d6: diff: fix typo
a10b616: Merge remote-tracking branch 'origin/master'
ea29fa7: Fix incorrect foremost window detection (IDEA-121261).
6e9ac43: Merge branch 'svn_18_3'
9b637e5: for loop -> forEach call chain inspection
e967a04: redundant lambda param types: take site subst into account
994eb2c: junit: do not treat config methods as tests (IDEA-121162)
470d4d0: PY-12213 When moving, members should be sorted according to their dependencies
8f75528: enable new DSM legend for retina & darcula
581f3c4: svn: Refactored SvnConfiguration - settings persistence implemented using PersistentStateComponent<State> class (and not using general PersistentStateComponent<Element> class)
1424a3a: svn: Refactored SvnConfiguration - removed SvnSupportOptions class (logic moved to SvnConfiguration itself)
8d03b3a: Merge remote-tracking branch 'origin/master'
7eb7546: DB props: reuse F4 as part of DataSourceElement.navigate() and drop 'Enter' shortcut
d22be0b: make CaretModelImpl.setCaretsAndSelection() implementation follow contract of interface method (IDEA-80056)
d1752c1: introduce IdeResourcesTestCase: Ultimate & DBE versions
c6d8ea2: Merge remote-tracking branch 'origin/master'
1f69774: NPE fix
5fa2055: Merge branch 'python-live-templates'
76d43e8: WEB-9926 remove 0xhh postfix (property name)
e9c49a1: Added Python live templates for '__main__', 'for' loops, comprehensions, properties (PY-2378)
5e2bf99: IDEA-121202 Step Into doesn't step into a lambda
1be8e04: IDEA-121057 Multiple Carets: Alt-N works in "whole word" mode if the whole word is initially selected
cbbae06: cleanup bean code
b865331: Merge remote-tracking branch 'origin/master'
94b34e9: Merge remote-tracking branch 'origin/master'
6e82d2d: Message header wraps long strings now
e4bb391: IDEA-121227 latest IJ mac builds: Cannot load JVM bundle in case of Java 1.7
138f7f8: Icons improvement
e200179: moved template language setting to the integrated tools
29068e1: png optimization
1686207: Merge branch 'svn_18_3'
a2619760: new debug helpers
7e75d80: Mnemonics
ff028dd: IDEA-103473 Correctly handle paths different only by case on case insensitive file system during commit - use just paths or specialized api for comparison
1ae54aa: IDEA-121099 Ctrl + Shift + Arrows doesn't work with multiple cursors
a578b4a: svn: Use idea home directory as working directory for "move" operation when move paths differ only by case for case insensitive file systems
6aefd30: Resources/Template roots -> Project structure
b8abb8f: add @NotNull to CompletionData.objectToLookupItem
75fdf53: don't choke on non-physical classes in resolve (EA-53892 - IAE: ResolveScopeManagerImpl$.compare)
1d44099: EA-54072 - assert: StubBasedPsiElementBase.getNode
38f2c99: EA-54221 - AIOOBE: ImmutableText.charAt
a717fce: EA-54222 - NPE: TemplateState.setCurrentVariableNumber
0ecb335: IDEA-118988 completion could add 'value=' in annotation
30a899f: add an explanatory comment to com.intellij.ide.macro.EditorMacro.getColumnNumber
e3fde06: use StubIndex.processElements where possible
a91570c: CR-IC-4499: deprecate StubIndex.process, satisfy Maxim's sense of beauty
393b67f: tests repaired
968404a: Merge remote-tracking branch 'origin/master'
6ded813: new inference: most specifics, varargs case
89aefc8: new inference: non-wildcard parameterization
8d60b8d: drop secondary carets when entering/exiting column selection mode (IDEA-80056)
bda5184: Merge remote-tracking branch 'origin/master'
9d41bae: Animator instead of Swing Timer
cddde85: make multi-caret selection with keyboard in column mode work more like old block selection (IDEA-80056)
5601899: Slim formatter started
0826b4a: fix can't read message for IDEA-121207
87ef851: IDEA-121182 Plain text autodetection isn't rerun on file content change
bbd2363: notnull
8248670: notnull
ca9faaa: notnull
1490fb8: moved back to analysis
d2bd356: moved to editor-ui
0b53dbe: IDEA-121220 Focus remains on Document tabs instead of Editor area when tabs switching
34a5343: cleanup
760c3b6: jps plugins to use 1.6 language and bytecode target level
e699813: NodeJS 134.1163 isn't compatible with EAP
e58ef02: Make EditorToggleColumnMode action work with multiple carets like previously with block selection (IDEA-80056)
eb39a65: ensure API backward compatibility
4d26c0a: platform: system notifications reworked
8b2e547: force 1.6 language level for jps-builders
ea1e764: Merge remote-tracking branch 'origin/master'
1b50ea2: lambda -> anonym: disable in unexpected context where cast won't help (IDEA-120165)
f4e209c: lambda -> anonym: additionally process method calls as they may clash with resulted class methods (IDEA-120469)
a745e5a: Merge remote-tracking branch 'origin/master'
b178187: continue gutter layout (don't process all console lines to compute max width)
e521e77: IDEA-111990 Don't close about on blur
82110ac: 1-to-1 mapping between Caret instances for injected and main editors (IDEA-80056)
c074bd2: 1-to-1 mapping between Caret instances for injected and main editors (IDEA-80056)
ff01b5b: get rid of duplicated code in editor fixtures (IDEA-80056)
70aaf37: external build: renamed system property to avoid clashes with user-defined properties for Maven resource filtering (ZD-22524)
78fcfe8: Platform: GenericKeymapManager for IDEs other than IDEA
7589de1: IDEA-2870
64721a2: methods usage index uses mappings
da6e3d8: leave shift + F11 only for bookmarks in JBuilder keymap
ef553f6: IDEA-96651 "Alphabetical order for tabs is ON" warning
e796dc6: make myPressPointScreen accessible in processDragFinish
f130fdc: Merge remote-tracking branch 'origin/master'
ce2d2ec: IDEA-91530 Tab highlighting error when sorted alphabetically
43fdfb2: Spellchecker : IDEA-120568 add gzip (cherry picked from commit 9204f00)
24fbf80: anonym -> lambda: check initializer inside constructor for final fields (IDEA-120698)
44dde64: anonym -> lambda: do not suggest when forward references are detected (IDEA-120699)
b716f47: more consistent highlight "type#selector"
7a9bf2a: reject 1.7 varargs hack as 1.8 reject the code again even with target 1.7
2df995f: More extensibility for CoreProjectEnvironment
b4eba39: move xml descriptors to the module available from Upsource
aa61e88: EA-54181 - NPE: NullableStuffInspectionBase.checkNullableStuffForMethod
f64f1ef: do not suggest broken plugins
7a70428: lambda: accept ellipsis parameter when array expected (IDEA-117124)
d7d0eec: extract method with new inference
351b9b1: tests left on 1.7 for now
8f7ff5b: wrap with command
e0ce9de: testdata
f1b256f: forbid lambda in conditional inside cast context
232f8bd: new inference: strict subtyping: skip raw types
828cb5a: new inference: erase return type if unchecked conversion was performed
01b095b: check myDisposed in read action too
e29d48f: EA-53239 - UOE: VirtualFileImpl.getChildren
9d2947e: IDEA-121192 Fix query construction and update test
92ac042: RemoteSdkCredentials retrieval extracted from RemoteSdkAdditionalData.
17b78eb: show "native" description for node objects
84aa4e8: we must use case-sensitive natural compare — constants must be first, but our naturalCompare is "buggy", so, we perform manual sort before call platform function
5ef006c: WEB-9926 don't auto expand library scope, we must use case-sensitive natural compare — constants must be first
5ac875b: Correct API version is initialized next time JIRA repository is read from settings
4be43ba: WEB-10887 TypeScript: unexpected error occured when Import clause with immediate export
a8c7d79: compact view for installed plugins
a216ae3: DBE: manage data sources action
cd5c3c9: check there are at least 2 tabs are open for move operations
479f584: move to right and move to down actions
0120c91: Generify to support move to right and move to down actions
1cc06ea: text will be assigned automatically
e167ddf: github: fix tests
5a6339b: github: assert -> warning
4edfd8e: remove possible deadlock on network operation in EDT
3d789e3: temporary fix for completion issue (IDEA-80056, EA-54248)
c598b17: @TestOnly
a23a0a6: diff: do not forget about start offset
e17305a: diff: optimise reindexer
0c614ba: IDEA-121031 Plugin Manager: "Update plugin" button does nothing
f32b77f: use install icon and fg/bg on update button
48921af: console gutter component should use setAdditionalColumnsCount now (we use editor area) rename outdated historyAnnotation
32209cb: fix About dialog font on Windows
68e033e: IDEA-121138 Tab completion does not work in autopopup
1c21d1d: Platform: empty text accessor for NewErrorTreeViewPanel
8d25634: DBE: customize editor empty-text ad
a96ee36: fix case in test data file name
5239b11: add help id
e5fe842: better font sizes for Windows and Linux
621a2b3: Git Update tree stays black after switching to Darcula
9d167d2: IDEA-120787 MySQL Comment with Block Comment inside block comment should uncomment; affected for all SelfManagingCommenters
46061a0: introduced REFORMAT_BLOCK_ON_RBRACE property
2d4efe7: project structure dialog: hide library types irrelevant to the current project from 'Global Libraries' -> 'Add' action
9b71864: project structure dialog: hide irrelevant to current module libraries (e.g. JavaScript libraries in Java module) in 'Add Library to dependencies' chooser
1ca73f4: final
3f3e013: simplify ctor
63ec0ea: Merge remote-tracking branch 'origin/master'
17bc69d: added application root to the SDK search path on window (Education Edition attempt)
e26dc5b: IDEA-120157 Reformat code ignores keep dependent methods together order
9173579: new DSM legend
26ff86f: typo
06933eb: IDEA-117902 Commit message wrapping behaves strangely
adaef15: rearrange checkbox in reformat files dialog moved before "only VCS changed text"
e52b01a7: an API to avoid CCEs when doing StubIndex.process
d55d2bb: rename physical->eventSystemEnabled to reduce confusion when constructing FileViewProvider
f786d1e: IDEA-120066 Auto indent on closing curly brace
7f105db: Compilation fix
57ebb86: Cleanup (interface adapter)
3686918: Merge remote-tracking branch 'origin/master'
41624fb: merged
0f39a4c: method refs: restore error on invalid array creation
07de151: AIOOBE
b587af7: exact method refs most specific: void compatibility
527e1de: runSingleTest(Runnable) extracted for parameterized tests
7544243: platform project open processor starts to work as last one, to avoid its interception with SBT / Gradle / Maven / etc (IDEA-121111 )
e37b853: avoid invalid regions
ca5b739: check disposed in read action (EA-53960 - assert: ComponentManagerImpl.getPicoContainer)
307a9b9: github: assertion relaxed for tests
19a1516: Cleanup (pointless exceptions dropped; test reformatted)
dd456d2: Cleanup (typos)
bdf35bd: Cleanup (unneeded cast)
7f5ae7e: Cleanup (formatting)
b877311: Cleanup (unneeded test case inheritance)
d128928: Cleanup (configuration tests correctly generified and annotated)
d9dcac5: Cleanup (typos)
6cc57f8: EA-54183 (CCE: BooleanConstructorInspection$BooleanConstructorFix.doFix)
cf00d70: delete old inference strategy for java 8
96af56c: AIOOBE
2f80e7d: new inference: reject partial computation
72c51dc: configurable oneLineInput
7130e5e: cleanup
c2a4f0d: IDEA-80056 Column selection mode improvement
a5c59c2: github: fix 'open in browser' url
4d7c38f: recover from EA-53754 - IOOBE: CharSequenceSubSequence.<init> (BlockSupportImpl) not only in internal mode
26a4855: hide psiFileFactory
fdee766: IDEA-117332 Change signature refactoring should warn about @Contract conflict
cc56534: IDEA-118094 smart completion in annotation: allow exclude
a3548b0: Fix for focus traversal.
825f767: NPE fix in FormatterTagHandler.getFormatterTag()
ac15549: structure view extracted
9739a4d: javadoc
68c3a40: nullable
53b173e: cleanup
1e7bbca: moved to xml-analysis
7693bbc: cleanup
75ca104: notnull
cad71fe: notnull
e65df65: cleanup
b53845b: notnull
e5df149: moved to core
b4d9fc6: notnull
aa5bc16: moved to core
8e38503: notnull
9a997d1: moved to editor-ui
a816b5d: moved to editor-ui
b1818fc: moved to editor-ui
64b597f: notnull
72e86eb: notnull
a4b1105: cleanup
3c9e26a: removed dependency on FileEditorManager
5f12f65: moved to editor
001957a: moved to core
9f26603: moved to editor-ui
bc83d33: moved to core
745381b: NotNull
4ef4bad: moved to core
ca75131: NPE
4715a42: add file validation on show execution point
09954a9: nodejs doesn't report actual locations after set breakpoint
f97c3ae: nullability
78ef38e: cleanup
6033db3: eliminate WebBrowserBase
0ea4a4b: IDEA-80056 Column selection mode improvement
99dab77: IDEA-80056 Column selection mode improvement
65fc838: Merge remote-tracking branch 'origin/master'
3abd020: fixed NPE
33a6a8c: EA-54164 - assert: FileManagerImpl.findFile
a97592b: Search for unique names that don't clash with anything in mock SDK
569a8ba: Reset module name index in mock SDK setup for reproducible test results
62db067: Merge branch 'python-fixes'
a7e01b8: Don't suggest Python live templates after '.' in qualified names
948ad3e: new inference: ensure type parameters are not modified during ground type evaluation
6a38fba: new inference: avoid current type calculation during conflict resolution for target type detection (IDEA-121052)
edf1d19: don't load modules from disabled plugins
019aa0a: unused field
83a5ada: IDEA-117643 use a correct file for searching for binding variables. Complete binding variables in debugger's watch editor
45c7715: duplicated code
7b9be7e: IDEA-117643 don't add parameters for binding variables. Just try to infer them as they are.
aeb3292: IDEA-119691 Groovy: References to outer class properties should be resolved to accessors if they exist. Fields are prefferable only inside its containing class (not inside inner classes of the outer class)
c41376f: CPP build
add0457: Merge branch 'goto-module'
5897600: Changed the visual representation of PyFileImpl to be more Python module-like (PY-6923)
bdac622: Added Python modules to 'Navigate to class' and 'Navigate to symbol' results (PY-6923)
6c401b1: Added Python module names index (PY-6923)
751a087: EA-46543 (diagnostic)
a91b1d0: Merge remote-tracking branch 'origin/master'
31ea501: grab focus in show all action from interpreter combobox
f6be520: remove association if vEnv associated with different project was selected
6df7c8d: Move GroovyImporter back to org.jetbrains.idea.maven.importing , bacause it used from some plugins.
69b7118: WebBrowserManager API post review
e051d7a: looks like there are a lot of clients assuming default JTable scrollable viewport size (450x400)
8111501: diff: fix action name
8c6f416: IDEA-121050 diff: fix typo
644139e: IDEA-120993 diff: fix diff range calculation in case of newline at the beginning of file
41921f7: diff: rename action
6be4951: diff: add generics
7458f32: github: add assertion
04d6c56: diff: do not fail completely on by-word comparison of two extremely big lines
997c1b2: diff: ask to show content of equal files
74153c9: diff: @Nullable
b285dea: diff: do not call read action to access to local read-only document
7058ea2: IDEA-80056 Column selection mode improvement
fe84447: IDEA-80056 Column selection mode improvement
24763b6: IDEA-121074 Make JIRA remote API version undefined only on actual URL change
964fcf5: java 8: final and default/static in interfaces
d2c3b4b: more specific inference: do not compare functional types if both methods were generic
e42ff74: testdata for IDEA-120992
217a1fd: new inference: address anonymous classes (IDEA-121063)
0f023fa: testdata for IDEA-121055
6900ca8: IDEA-121077 Fix JQL query construction in JIRA connector
d2513fa: java: wrong method used
9fd2a22: groovy: not-so-fast performance test excluded from the suite
6c6ac37: java: ability to skip slow tests
f2ed5a6: Cleanup (platform tests moved to platform)
9c85eb9: Cleanup (dead code; readability; typos; annotations)
0799e8b: Cleanup (common class extracted)
815bba3: pass project to psi file factory
00f817a: LanguageConsoleImpl is not intended to be extended
0b90dc8: add todo note
2c034c0: implement ConsoleJavaScriptInspectionFilter
a38c63c: new inference: isAcceptable for method reference
a4deb4d: new inference: isAcceptable for lambda
de7f053: new inference: do not accept varargs when array is passed there
9fc4b68: new inference: take into account site substitutors during additional constraints gathering
6a5b57d: dispose previous root model when changing to a new one without events
751ec20: save one volatile read on each charAt in editor
5349f1e: language console: revert "disable DaemonCodeAnalyzer "
db3a3d6: Fixed incorrect YesNoCancel behaviour, html in message is handled properly now, size of text in the message is taken into account, esc works properly, better message width and height calculation based on the text area and number of buttons in the message.
c582c37: fix offset calculation remove incorrect call — it is right gutter responsibility
406255c: update notifications about not installed pip/setuptools
fb25259: js repl: setOneLineMode true (will be or not moved as platform default after discussion)
3996201: disable DaemonCodeAnalyzer for console editor — the same as EditorTextField does +review
74f1397: fixing compiler storage data integrity for certain cases when classes are moved between modules
9491e6d: IDEA-120625 Save file as template
1a50247: IDEA-116706 Unselect word at caret doesn't work reversing through lambdarized anonymous class
374e421: IDEA-76185 Macro: $SelectionStartColumn$ and $SelectionEndColumn$ external tools macros count tabs as expanded spaces
4e1ae10: PathMacroMap: add clarifying comments about by-reference string comparison
3510a84: setAdditionalLinesCount = 1
0d4ce76: don't set setRightMarginShown twice — ConsoleViewUtil is enough
a51adfb: LanguageConsoleImpl is not intended to be extended
b792a8c: cleanup
bcaeaeb: cleanup
bbae05d: deprecate createActions — LanguageConsoleImpl is not intended to be extended (actually, it is not used in our code, but we keep method to ensure backward compatibility)
752e268: cleanup
0dbe448: add isEmptyCommandExecutionAllowed, by default true
ec8a5d2: IDEA-80056 Column selection mode improvement
83550bf: Merge remote-tracking branch 'origin/master'
f85aa38: IDEA-120866 Improve usability of 'Uninstall old version(s)' step
ffd542c: CR-IC-4381#c22616
62acb09: Show error message when disable broken plugin.
5a79c28: CR-IC-4381#CFR-71852
90e7243: CR-IC-4381#CFR-71852
a5f7dd7: accidentally committed — revert
3437a1e: optimize imports on project: exception fixed, removed unused method invocation
638f8f1: don't setup delegating color scheme twice — ConsoleViewUtil is enough +review
d785cf6: @NotNull
55e67f6: don't execute empty command
5febcfe: isEmptyOrSpaces accepts CharSequence +review
2610e6c: cleanup
5a83918: deprecate setTextToEditor
975ad62: overrides
c76c841: Merge branch 'master' of git.labs.intellij.net:idea/community
8bd736a: show all in project interpreter combobox regardless virtualenv association
4518cf9: Merge remote-tracking branch 'origin/master'
ce073a75: PY-12196 Members moving refactoring should handle dependencies
b353744: IDEA-120038 - Redesing Git cloud frameworks UI - upload SSH key from account
dbe4736: WEB-11067 Karma Plugin broken because of missing intellijCli Node module
3fb9b1a: fix layout (IDEA-121036)
61bac55: Add "JSTestDriver Plugin" plugin to brokenPlugins.txt
9583062: Postfix completion: do not show 'enable template in autopopup' checkbox if show.template.in.completion.list is enabled
e896024: Postfix completion: apply throw template on Throwable only
79e95dc: Postfix completion: do not apply null, notnull and instanceof template on primitive types
4ddf754: Postfix completion: extract condition constant
1ae8c8c: notnull/nullable
f124013: NPE fix
dc27b12: Add SBT plugin to brokenPlugins.txt
406ebb4: Do not store virtual files in map that is never cleared for IDEA-120732 (Throwable at com.intellij.cvsSupport2.actions.IgnoreFileAction$1.run)
0cfd079: make final
68a8f15: fix CR-PY-5915
5d124b0: fix method isn|'t implemented: com.intellij.execution.console.ProcessBackedConsoleExecuteActionHandler com.intellij.execution.runners.AbstractConsoleRunnerWithHistory#createConsoleExecuteActionHandler() (in Pythonid:3.1.1.134.1462)
52ac45a: deprecate finishExecution()
ce1c1a4: don't expose createConsoleExecAction
c524fb2: cleanup
3ab1740: Merge remote-tracking branch 'origin/master'
cd937d1: better class naming
709bbc0: better class naming
c6ad195: Merge branch 'python-fixes'
4a5c63e: add MarkupModelListener.Adapter
ff1625e: cleanup
8af73b7: Don't resolve to file-level '__metaclass__' in PyClass.getMetaClassExpression() (PY-12127)
abd4c25: IDEA-80056 Column selection mode improvement
14d837e: IDEA-120526 Groovy: Inline super.call()
7065641: IDEA-120979 Static method call in instance context
970da58: fix contracts
4fdbc8c: IDEA-120885: complete 'as' keyword in appropriate place
8342f32: fix JsDebugConfigurationConverterTest
993f8c1: Test fix; cleanup (formatting)
987d9d4: IDEA-120931 Threads tree in "Debugger" pane displays incorrect thread name
9db0214: IDEA-120994 Debugger: tooltip on multiline string value - no need to escape quote characters
ef685df: test fixed
cd39c84: remote templates
3582560: Merge remote-tracking branch 'origin/master'
7de9df1: fixes according code review
59b76f6: suppressed for tests
6a696ee: create project from template: radio button replaced with checkbox
9e8ad70: IDEA-80056 Column selection mode improvement
c1073f8: CR-IC-4035
aa2ed97: Add jira to build in community
b11d66e: new inference: method refs: do not include containing class type params in inference
bac3191: new inferencve: do not apply substitution twice for additional constraints
2a16fd1: new inference: lambda functional type detection
3093e7e: testdata fixed
97b25c1: BaseProgramRunner must be internal
68eb92a: EA-54083 (diagnostic)
0bff0b9: ProcessBackedExecutionEnabledCondition must not be public (and originally was not intended, but we keep backward compatibility)
1b0e049: cleanup
16ae520: ConsoleExecuteActionHandler renamed to ProcessBackedConsoleExecuteActionHandler, keep backward compatibility
b7f131a: ConsoleExecuteActionHandler renamed to ProcessBackedConsoleExecuteActionHandler
415bd34: ConsoleExecuteActionHandler renamed to ProcessBackedConsoleExecuteActionHandler
78a6a8b: remove ruby variant of ConsoleExecuteAction — platform implementation is enough simplification — ConsoleExecuteActionHandler could be also as Condition (we must rename this class to ProcessBackedConsoleExecuteActionHandler — todo)
0912938: cleanup
dec28d2: revert unfinished changes
9495ef2: IDEA-119396 (be picky about unfinished annotated new array expressions)
ead0734: Cleanup (test moved to platform)
3f5ed3f: IDEA-120952
0850b33: Merge remote-tracking branch 'origin/master'
3e4618e: Modify test to attempt to set required initial state, if it's wrong
c068d8e: Fix build due to moved jira module.
eda25d0: Add missing module to layout.gant
9781b1d: IDEA-119819 (Cannot suppress warnings for inspection "Unnecessary unicode escape sequence")
f1f14d5: use setRightMarginShown instead of nullify color +review
8d11adf: overrides
718ee80: IDEA-80056 Column selection mode improvement
62ec1ba: js repl: editor ask us to paint line 4-6, but we should draw line for line 3 (startLine - 1) also, otherwise it will be not rendered fix layout
30e3163: Taking into account Oracle bug 8019291 it is better do not set this property for this transient window than see strange decorations on the transient window.
c814d70: do not embed js into "on" prefixed unknown attributes
3886bc2: Set location of splash screen basing on the current screen device.
f56d570: CR-IC-4445 show whole table by default if it's inside scrollpane
821a6c3: js repl: fix layout
76637d3: LicenseDialog: tuning. LoadingDecorator: rollback
eb161bf: Merge remote-tracking branch 'origin/master'
0c27db7: removed over logging, not informative messages from updater logger.
6abf38a: IDEA-80056 Column selection mode improvement
ed0dc5c: Merge remote-tracking branch 'origin/master'
fbafcac: fixed PY-12186 Project interpreter: not able to select element in appeared settings menu
22da9d4: Updating file properties -> Initializing file system cache (IDEA-115130)
567602b: IDEA-120976 'Complete' work is mentioned 3 times in a simple sentence
4392d23: reverted
089d059: updater: patch applier made tolerant to missing log dir parameter
1305416: zebra-mode enabled
e024d71: WEB-11069 unexpected vertical scrollbar in Bower integration; Review CR-WS-326
d1af527: IDEA-83657 Can't find text in files under .idea
1d9e5df: walk non-indexed files when searching for whole words (IDEA-120648)
09450b1: make go to declaration shortcut also work on console hyperlinks (IDEA-120911)
bfdc9c9: js repl: draw line separators using range marker highlighter
e66c805: EditorEx returns MarkupModelEx (the same as DocumentEx) +review
8efac81: nullability, consistent parameter name
a94a51e: IDEA-120054: Maven: war: non-filtered resource is not copied to output
99ca505: restore clicking on console hyperlinks
f3e9a1e: IDEA-112815 (IDEA does not ignore directories specified in .cvsignore)
85db4a5: use balloon instead of error dialog
713c3d9: cache large leaf element text strings
2f36f24: enable show.live.templates.in.completion by default
16dab5a: IDEA-120911 follow link by keyboard
396d5ec: advance bomb
d0e3130: add jira to tasks plugin
96c8508: remove excessive templates
cbee5a3: clarification
44b16d0: Cleanup (manifest inspections .html files)
54bfa05: new inference: lift also unknown vars (IDEA-117530)
88d220f: new inference: cleanup from eliminateWildcards
e104084: new inference: cleanup checkFunctionalType
1563225: new inference: cleanup from eliminateWildcards
c0f1310: new inference: accept null = Object constraint
1b0e87f: java 8: allow to cast to intersection types
d22feaa: meaningful toString
bd681be: new inference: 18.5.2 adjustments
6103980: bound promotion for super wildcard (? super A (bound extends A) == A)
a91c7f7: bound promotion for super wildcard (? super A (bound extends A) == A)
f3bbc7a: new inference: cleanup
15740a3: new inference: cls copy replacement
4ba1e5f: NPE
1a5e473: AIOOBE
c5d0b16: new inference: debug
555b8b3: new inference: 2 phase resolution
19ba9d8: new inference: resolve
694432f: new inference: capture conversions in return types initial; variable dependencies
758fa4a: rearrange on multiple files continues if no rearranger found for one of them
3e8ca79: IDEA-34877 (CVS: check whether the new-added file name exists in .cvsignore and don't prompt to add it) & IDEA-120736 (CVS: don't prompt to add new-created files ignored using IgnoredFiles list)
10a58c5: Cleanup (extra write action)
1c8930c: Cleanup (double commit)
4f1c289: License Dialog: windows tuning. cleanup
a77da47: LicenseDialog: JetProfile assets choice & proceed
c83ed1d: Merge branch 'svn_18_3'
a472d35: svn: Optimized IdeaCommitHandler - track deleted files only if required (corresponding parameter is set)
045a753: Display conflicts if destination class already has some member
31c7494: let's start async cache update for EAP
342cf54: Merge branch 'svn_18_3'
fbf5d55: js repl: in/out markers done
cf9ace3: svn: Do not check repository protocol (just working copy format) when determining which implementation (SVNKit or command line) should be used for commit operation
ff65c9f: platform: safe project model modification
93b33a3: svn: Refactored SvnCheckinEnvironment - utilize IdeaCommitHandler as event handler for SVNKit commit flow
45cf910: move prepareExecuteAction to LanguageConsoleImpl instance
06062ed: Retina support + no dialog resize (just image clip)
65531b1: fix test data
894d4bb: remove duplicated code — DocumentUtil.writeInRunUndoTransparentAction
effd774: svn: Refactored SvnCheckinEnvironment - use common client factory model for file status detection
c725668: Make BaseRepositoryImpl initialize HTTP client lazily on network settings updates
4af031a: svn: Refactored SvnCheckinEnvironment - not null, code simplifications, methods extracted, warnings fixes
81e72d4: + gruntfile
343a277: revert IDEA-120811
3e991eb: deprecate addCurrentToHistory, cleanup
b22e89b: continue LanguageConsoleBuilder.registerExecuteAction — don't force client to know low-level details, cleanup NewSshConsole
3936b51: add LanguageConsoleBuilder.registerExecuteAction — This API doesn't look good, but it is much better than force client to know low-level details
50318ce: IDEA-120906 NPE at com.intellij.ide.util.projectWizard.SdkSettingsStep.<init>
4524244: Slightly update message in "Option" tab of YouTrack repository editor
cdfd4d0: IDEA-116229 (Invalid Warning: Contents of array 'longs' are written to, but never read)
17dcc98: IDEA-120799 (Quick-fix for "Unnecessary parentheses" changes expression semantics)
0ced324: IDEA-120904 Debugger UI: watch variable text field is shown when debug tool window is hidden
5ed18af: Merge remote-tracking branch 'origin/master'
7d1d9c8: fixed PY-12185 Project interpreter: strange combobox size in settings
7039d82: store 'export to html' settings in workspace.xml instead of shared misc.xml (IDEA-96348)
a3a8fa7: Merge remote-tracking branch 'origin/master'
817df93: Merge remote-tracking branch 'origin/master'
5c95f86: another fix for PY-12186 Project interpreter: not able to select element in appeared settings menu
0c1316c: Merge remote-tracking branch 'origin/master'
ee07119: show word variants in custom file type completion autopopup
f5e8ce0: PathMacroMap: add clarifying comments about by-reference string comparison
f1ac105: use common ExceptionUtil
89e9ca0: do not loose type args on ratianalize static calls (IDEA-120767)
c7b78f7: IDEA-120784 "Class is public should be declared in a file named <Classname>.java" for inner interface
65642d9: IDEA-118305 github: try to fix GH:E specific bug
ada3f52: Merge remote-tracking branch 'origin/master'
3a9eef6: speed search
071a9d5: cleanup
2108e56: fix for PY-12186 Project interpreter: not able to select element in appeared settings menu
11069dc1: Merge remote-tracking branch 'origin/master'
6ec4b86: fixed PY-12184 Project Interpreter: Throwable at com.intellij.openapi.vfs.newvfs.RefreshQueueImpl.execute
08f79dc: diff: do not try to create empty LineFragment
f0eed8c: IDEA-80056 Column selection mode improvement
eec124a: IDEA-80056 Column selection mode improvement
81adc91: IDEA-120834 Same-class methods should be preferred over static imports
1ae2a82: IDEA-118234 Groovy 2.3: type inference of SAM-closure parameters
d0507fc: IDEA-120595 Restore compatibility with JIRA < 4.2. Return support of JIRA SOAP API. Move all JIRA related classes to dedicated module
0fcb597: Add tests for CertificatesManager. Disable them for now, because SNI related patch in httpclient works only on Oracle JRE 1.7+
3355e94: Update Apache HttpClient to 4.3.2 due to fix of HTTPCLIENT-1119
b2d5f76: svn: Refactored AbstractUpdateIntegrateCrawler - remove unnecessary SVNUpdateClient creation
e266021: svn: Refactored GatheringChangelistBuilder - make inherit EmptyChangelistBuilder, renames, optimizations
f042e76: svn: Refactored GatheringChangelistBuilder - use common client factory model to get svn properties (instead of direct SVNWCClient usage)
300839e: svn: Refactored GatheringChangelistBuilder - code simplifications, notnull, removed unused code
17b7bfa: svn: Make SvnKitBrowseClient not pass to handler separate entry for root folder (at which list() method was executed) - to have consistent behaviour for both CmdBrowseClient and SvnKitBrowseClient
c4e1a04f: svn: Implemented correct element name and relative path calculation for CmdBrowseClient
4d8ae08: svn: Refactored SvnChangeList - use common client factory model (instead of direct SVNLogClient usage)
05913e6: svn: Refactored SvnUtil.createUrl - make it throw SvnBindException (instead of SVNException)
8a44f01: svn: Refactored SvnChangeList - SVNRepository usages replaced with "svn info" command
a66c80b: svn: Refactored SvnChangeList - method extractions, code simplifications
56ca50d: svn: Ensure repository relative path is used in SvnChangeList logic (logic was broken and full path was returned after changes in commit 42c824)
58f70a1: svn: Refactored RemoteRevisionsNumberCache - code simplifications, warnings fixes
24e95a4: svn: Refactored SvnCommandLineInfoClient - code simplifications, warnings fixes
87bcdbd: svn: Refactored SvnChangeList - removed duplication, simplified code flow
Change-Id: I25aae09c68ce6c702066c108dae46d17c32e2709
diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ClassFilesIndexFeaturesHolder.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ClassFilesIndexFeaturesHolder.java
index eee027c..a860efe 100644
--- a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ClassFilesIndexFeaturesHolder.java
+++ b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ClassFilesIndexFeaturesHolder.java
@@ -79,16 +79,15 @@
return state == FeatureState.AVAILABLE;
}
- public synchronized void visitEnabledConfigures(final Processor<ClassFilesIndexConfigure> availableConfiguresVisitor,
- final Processor<ClassFilesIndexConfigure> notAvailableConfiguresVisitor) {
+ public synchronized void visitConfigures(final ConfigureVisitor visitor) {
for (final ClassFilesIndexConfigure configure : myEnabledIndexReaders.keySet()) {
- availableConfiguresVisitor.process(configure);
+ visitor.visit(configure, true);
}
for (final ClassFilesIndexFeature feature : ClassFilesIndexFeature.values()) {
if (feature.isEnabled() && !myEnabledFeatures.containsKey(feature)) {
for (final ClassFilesIndexConfigure configure : feature.getRequiredIndicesConfigures()) {
if (!myEnabledIndexReaders.containsKey(configure)) {
- notAvailableConfiguresVisitor.process(configure);
+ visitor.visit(configure, false);
}
}
}
@@ -176,4 +175,4 @@
AVAILABLE,
NOT_AVAILABLE
}
-}
+}
\ No newline at end of file
diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ClassFilesIndexReaderBase.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ClassFilesIndexReaderBase.java
index 8f6a7eb..cc1d2ba 100644
--- a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ClassFilesIndexReaderBase.java
+++ b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ClassFilesIndexReaderBase.java
@@ -23,8 +23,10 @@
import com.intellij.util.io.KeyDescriptor;
import com.intellij.util.io.PersistentHashMap;
import org.jetbrains.annotations.Nullable;
-import org.jetbrains.jps.classFilesIndex.indexer.api.ClassFilesIndexStorage;
+import org.jetbrains.jps.builders.java.dependencyView.Mappings;
import org.jetbrains.jps.classFilesIndex.indexer.api.IndexState;
+import org.jetbrains.jps.classFilesIndex.indexer.api.storage.ClassFilesIndexStorageBase;
+import org.jetbrains.jps.incremental.storage.BuildDataManager;
import java.io.File;
import java.io.IOException;
@@ -34,16 +36,19 @@
*/
public abstract class ClassFilesIndexReaderBase<K, V> {
+ public static final String VERSION_FILE_NAME = "version";
+
private final static Logger LOG = Logger.getInstance(ClassFilesIndexReaderBase.class);
@Nullable
- protected final ClassFilesIndexStorage<K, V> myIndex;
-
+ protected final ClassFilesIndexStorageReader<K, V> myIndex;
+ @Nullable
+ protected final Mappings myMappings;
public static boolean checkIndexAndRecreateIfNeed(final Project project, final int currentVersion, final String canonicalIndexName) {
final File projectBuildSystemDirectory = BuildManager.getInstance().getProjectSystemDirectory(project);
assert projectBuildSystemDirectory != null;
- final File versionFile = new File(ClassFilesIndexStorage.getIndexDir(canonicalIndexName, projectBuildSystemDirectory), "version");
- final File indexDir = ClassFilesIndexStorage.getIndexDir(canonicalIndexName, projectBuildSystemDirectory);
+ final File versionFile = new File(ClassFilesIndexStorageBase.getIndexDir(canonicalIndexName, projectBuildSystemDirectory), VERSION_FILE_NAME);
+ final File indexDir = ClassFilesIndexStorageBase.getIndexDir(canonicalIndexName, projectBuildSystemDirectory);
if (versionFile.exists() &&
!versionDiffers(projectBuildSystemDirectory, canonicalIndexName, currentVersion) &&
IndexState.load(indexDir) == IndexState.EXIST) {
@@ -62,27 +67,35 @@
final int indexVersion,
final Project project) {
if (checkIndexAndRecreateIfNeed(project, indexVersion, canonicalIndexName)) {
- ClassFilesIndexStorage<K, V> index = null;
+ ClassFilesIndexStorageReader<K, V> index = null;
IOException exception = null;
final File projectBuildSystemDirectory = BuildManager.getInstance().getProjectSystemDirectory(project);
- final File indexDir = ClassFilesIndexStorage.getIndexDir(canonicalIndexName, projectBuildSystemDirectory);
+ final File indexDir = ClassFilesIndexStorageBase.getIndexDir(canonicalIndexName, projectBuildSystemDirectory);
try {
- index = new ClassFilesIndexStorage<K, V>(indexDir, keyDescriptor, valueExternalizer);
+ index = new ClassFilesIndexStorageReader<K, V>(indexDir, keyDescriptor, valueExternalizer);
}
catch (final IOException e) {
exception = e;
- PersistentHashMap.deleteFilesStartingWith(ClassFilesIndexStorage.getIndexFile(indexDir));
+ PersistentHashMap.deleteFilesStartingWith(ClassFilesIndexStorageBase.getIndexFile(indexDir));
}
if (exception != null) {
recreateIndex(canonicalIndexName, indexVersion, projectBuildSystemDirectory, indexDir);
myIndex = null;
+ myMappings = null;
}
else {
myIndex = index;
+ try {
+ myMappings = new Mappings(BuildDataManager.getMappingsRoot(projectBuildSystemDirectory),false);
+ }
+ catch (final IOException e) {
+ throw new RuntimeException(e);
+ }
}
}
else {
myIndex = null;
+ myMappings = null;
}
}
@@ -94,8 +107,8 @@
FileUtil.delete(indexDir);
}
try {
- FileUtil.writeToFile(new File(ClassFilesIndexStorage.getIndexDir(canonicalIndexName, projectBuildSystemDirectory), "version"), String.valueOf(
- indexVersion));
+ FileUtil.writeToFile(new File(ClassFilesIndexStorageBase.getIndexDir(canonicalIndexName, projectBuildSystemDirectory), VERSION_FILE_NAME),
+ String.valueOf(indexVersion));
}
catch (final IOException e) {
throw new RuntimeException(e);
@@ -130,7 +143,7 @@
}
private static File getVersionFile(final File projectBuildSystemDirectory, final String canonicalIndexName) {
- return new File(ClassFilesIndexStorage.getIndexDir(canonicalIndexName, projectBuildSystemDirectory), "version");
+ return new File(ClassFilesIndexStorageBase.getIndexDir(canonicalIndexName, projectBuildSystemDirectory), VERSION_FILE_NAME);
}
private static boolean versionDiffers(final File projectBuildSystemDirectory, final String canonicalIndexName, final int currentVersion) {
diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ClassFilesIndexStorageReader.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ClassFilesIndexStorageReader.java
new file mode 100644
index 0000000..6f0d9ab
--- /dev/null
+++ b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ClassFilesIndexStorageReader.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2000-2014 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.compiler.classFilesIndex.api.index;
+
+import com.intellij.util.io.DataExternalizer;
+import com.intellij.util.io.KeyDescriptor;
+import org.jetbrains.jps.classFilesIndex.indexer.api.storage.ClassFilesIndexStorageBase;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+
+/**
+ * @author Dmitry Batkovich
+ */
+public class ClassFilesIndexStorageReader<K, V> extends ClassFilesIndexStorageBase<K, V> {
+ public ClassFilesIndexStorageReader(final File indexDir,
+ final KeyDescriptor<K> keyDescriptor,
+ final DataExternalizer<V> valueExternalizer) throws IOException {
+ super(indexDir, keyDescriptor, valueExternalizer);
+ }
+
+ public Collection<V> getData(final K key) {
+ return myCache.get(key).getValues();
+ }
+}
diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ClassFilesIndexerBuilderParametersProvider.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ClassFilesIndexerBuilderParametersProvider.java
index eba69fd..91f84bb 100644
--- a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ClassFilesIndexerBuilderParametersProvider.java
+++ b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ClassFilesIndexerBuilderParametersProvider.java
@@ -39,31 +39,18 @@
@Override
public List<String> getVMArguments() {
final List<String> args = new ArrayList<String>();
- myIndicesHolder.visitEnabledConfigures(
- new Processor<ClassFilesIndexConfigure>() {
+ myIndicesHolder.visitConfigures(new ConfigureVisitor() {
@Override
- public boolean process(final ClassFilesIndexConfigure availableConfigure) {
- final String className = availableConfigure.getIndexerBuilderClass().getCanonicalName();
+ public void visit(ClassFilesIndexConfigure<?, ?> configure, boolean isAvailable) {
+ final String className = configure.getIndexerBuilderClass().getCanonicalName();
args.add(className);
- return true;
- }
- }, new Processor<ClassFilesIndexConfigure>() {
- @Override
- public boolean process(final ClassFilesIndexConfigure notAvailableConfigure) {
- final String className = notAvailableConfigure.getIndexerBuilderClass().getCanonicalName();
- args.add(className);
- notAvailableConfigure.prepareToIndexing(myIndicesHolder.getProject());
- return true;
+ if (!isAvailable) {
+ configure.prepareToIndexing(myIndicesHolder.getProject());
}
}
- );
- if (args.size() != 0) {
- final String serializedArgs = StringUtil.join(args, ";");
- return Collections.singletonList("-D" + ClassFilesIndicesBuilder.PROPERTY_NAME + "=" + serializedArgs);
- }
- else {
- return Collections.emptyList();
- }
+ });
+ return args.size() != 0
+ ? Collections.singletonList("-D" + ClassFilesIndicesBuilder.PROPERTY_NAME + "=" + StringUtil.join(args, ";"))
+ : Collections.<String>emptyList();
}
-
}
diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/AccessLevelProvider.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ConfigureVisitor.java
similarity index 68%
copy from java/java-impl/src/com/intellij/ide/structureView/impl/java/AccessLevelProvider.java
copy to java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ConfigureVisitor.java
index 1f153aa..1a4f838 100644
--- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/AccessLevelProvider.java
+++ b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/api/index/ConfigureVisitor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,9 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.intellij.ide.structureView.impl.java;
+package com.intellij.compiler.classFilesIndex.api.index;
-public interface AccessLevelProvider {
- int getAccessLevel();
- int getSubLevel();
+/**
+ * @author Dmitry Batkovich
+ */
+public interface ConfigureVisitor {
+
+ void visit(ClassFilesIndexConfigure<?, ?> configure, boolean isAvailable);
+
}
diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/CachedRelevantStaticMethodSearcher.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/CachedRelevantStaticMethodSearcher.java
index da119b1..81089c7 100644
--- a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/CachedRelevantStaticMethodSearcher.java
+++ b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/CachedRelevantStaticMethodSearcher.java
@@ -25,7 +25,7 @@
import com.intellij.util.SmartList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import org.jetbrains.jps.classFilesIndex.indexer.impl.MethodIncompleteSignature;
+import com.intellij.compiler.classFilesIndex.impl.MethodIncompleteSignature;
import java.util.*;
@@ -35,24 +35,18 @@
public class CachedRelevantStaticMethodSearcher {
private final HashMap<MethodIncompleteSignature, PsiMethod> myCachedResolveResults = new HashMap<MethodIncompleteSignature, PsiMethod>();
private final MethodsUsageIndexReader myIndexReader;
- private final JavaPsiFacade myJavaPsiFacade;
- private final GlobalSearchScope myAllScope;
- private final GlobalSearchScope myResolveScope;
+ private final ChainCompletionContext myCompletionContext;
- public CachedRelevantStaticMethodSearcher(final Project project, final GlobalSearchScope resolveScope) {
- myIndexReader = MethodsUsageIndexReader.getInstance(project);
- myJavaPsiFacade = JavaPsiFacade.getInstance(project);
- myAllScope = GlobalSearchScope.allScope(project);
- myResolveScope = resolveScope;
+ public CachedRelevantStaticMethodSearcher(final ChainCompletionContext completionContext) {
+ myIndexReader = MethodsUsageIndexReader.getInstance(completionContext.getProject());
+ myCompletionContext = completionContext;
}
@NotNull
- public List<ContextRelevantStaticMethod> getRelevantStaticMethods(final String resultQualifiedClassName,
- final int minOccurrence,
- final ChainCompletionContext completionContext) {
+ public List<ContextRelevantStaticMethod> getRelevantStaticMethods(final String resultQualifiedClassName, final int minOccurrence) {
if (resultQualifiedClassName == null ||
ChainCompletionStringUtil.isPrimitiveOrArrayOfPrimitives(resultQualifiedClassName) ||
- completionContext.getTarget().equals(resultQualifiedClassName)) {
+ myCompletionContext.getTarget().getClassQName().equals(resultQualifiedClassName)) {
return Collections.emptyList();
}
final TreeSet<UsageIndexValue> indexValues = myIndexReader.getMethods(resultQualifiedClassName);
@@ -66,9 +60,9 @@
method = myCachedResolveResults.get(methodInvocation);
}
else {
- final PsiMethod[] methods = completionContext.resolveNotDeprecated(methodInvocation);
+ final PsiMethod[] methods = myCompletionContext.resolveNotDeprecated(methodInvocation);
method = MethodChainsSearchUtil
- .getMethodWithMinNotPrimitiveParameters(methods, Collections.singleton(completionContext.getTarget().getClassQName()));
+ .getMethodWithMinNotPrimitiveParameters(methods, Collections.singleton(myCompletionContext.getTarget().getClassQName()));
myCachedResolveResults.put(methodInvocation, method);
if (method == null) {
return Collections.emptyList();
@@ -78,9 +72,9 @@
return Collections.emptyList();
}
if (method.hasModifierProperty(PsiModifier.PUBLIC)) {
- if (isMethodValid(method, completionContext, resultQualifiedClassName)) {
+ if (isMethodValid(method, myCompletionContext, resultQualifiedClassName)) {
occurrences += indexValue.getOccurrences();
- if (myResolveScope.contains(method.getContainingFile().getVirtualFile())) {
+ if (myCompletionContext.getResolveScope().contains(method.getContainingFile().getVirtualFile())) {
relevantMethods.add(new ContextRelevantStaticMethod(method, null));
}
if (occurrences >= minOccurrence) {
@@ -109,7 +103,7 @@
if (method == null) return false;
for (final PsiParameter parameter : method.getParameterList().getParameters()) {
final PsiType type = parameter.getType();
- final String shortClassName = typeAsString(type);
+ final String shortClassName = typeAsShortString(type);
if (targetTypeShortName.equals(shortClassName)) return false;
if (!ChainCompletionStringUtil.isShortNamePrimitiveOrArrayOfPrimitives(shortClassName) &&
!completionContext.contains(type.getCanonicalText())) {
@@ -119,18 +113,17 @@
return true;
}
-
@Nullable
- public static String typeAsString(final PsiType type) {
+ public static String typeAsShortString(final PsiType type) {
if (type instanceof PsiClassType)
return ((PsiClassType) type).getClassName();
else if (type instanceof PsiPrimitiveType)
return type.getCanonicalText();
else if (type instanceof PsiArrayType) {
- final String componentTypeAsString = typeAsString(((PsiArrayType) type).getComponentType());
+ final String componentTypeAsString = typeAsShortString(((PsiArrayType)type).getComponentType());
if (componentTypeAsString == null) return null;
return String.format("%s[]", componentTypeAsString);
}
return null;
}
-}
+}
\ No newline at end of file
diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/ChainCompletionStringUtil.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/ChainCompletionStringUtil.java
index 8a2c1d1..1931c2b 100644
--- a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/ChainCompletionStringUtil.java
+++ b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/ChainCompletionStringUtil.java
@@ -31,16 +31,12 @@
public final class ChainCompletionStringUtil {
private ChainCompletionStringUtil() {}
- public static boolean isPrimitiveOrArray(final @Nullable String typeQName) {
- return typeQName != null && (typeQName.endsWith("[]") || PRIMITIVES_NAMES.contains(typeQName));
- }
-
/**
* CAUTION: isPrimitiveOrArrayOfPrimitives("java.lang.String") == true,
* isPrimitiveOrArrayOfPrimitives("java.lang.Object") == true
* isPrimitiveOrArrayOfPrimitives("java.lang.Class") == true
*/
- public static boolean isPrimitiveOrArrayOfPrimitives(final String typeQName) {
+ public static boolean isPrimitiveOrArrayOfPrimitives(final @Nullable String typeQName) {
if (typeQName == null) {
return false;
}
@@ -63,6 +59,7 @@
}
private static final Set<String> PRIMITIVES_NAMES = new HashSet<String>();
+ private static final Set<String> PRIMITIVES_SHORT_NAMES = new HashSet<String>();
static {
fillPrimitivesNames(PsiType.BOOLEAN);
@@ -74,36 +71,22 @@
fillPrimitivesNames(PsiType.CHAR);
fillPrimitivesNames(PsiType.BYTE);
fillPrimitivesNames(PsiType.VOID);
- PRIMITIVES_NAMES.add(CommonClassNames.JAVA_LANG_STRING);
- PRIMITIVES_NAMES.add(CommonClassNames.JAVA_LANG_OBJECT);
- PRIMITIVES_NAMES.add(CommonClassNames.JAVA_LANG_CLASS);
+
+ fillNonPrimitiveNames(CommonClassNames.JAVA_LANG_STRING);
+ fillNonPrimitiveNames(CommonClassNames.JAVA_LANG_OBJECT);
+ fillNonPrimitiveNames(CommonClassNames.JAVA_LANG_CLASS);
+ }
+
+ private static void fillNonPrimitiveNames(final String typeAsString) {
+ PRIMITIVES_NAMES.add(typeAsString);
+ PRIMITIVES_SHORT_NAMES.add(StringUtilRt.getShortName(typeAsString));
}
private static void fillPrimitivesNames(final PsiPrimitiveType type) {
PRIMITIVES_NAMES.add(type.getBoxedTypeName());
PRIMITIVES_NAMES.add(type.getCanonicalText());
- }
- private static final Set<String> PRIMITIVES_SHORT_NAMES = new HashSet<String>();
-
- static {
- fillPrimitivesShortNames(PsiType.BOOLEAN);
- fillPrimitivesShortNames(PsiType.INT);
- fillPrimitivesShortNames(PsiType.LONG);
- fillPrimitivesShortNames(PsiType.DOUBLE);
- fillPrimitivesShortNames(PsiType.FLOAT);
- fillPrimitivesShortNames(PsiType.SHORT);
- fillPrimitivesShortNames(PsiType.CHAR);
- fillPrimitivesShortNames(PsiType.BYTE);
- fillPrimitivesShortNames(PsiType.VOID);
- PRIMITIVES_SHORT_NAMES.add(StringUtilRt.getShortName(CommonClassNames.JAVA_LANG_STRING));
- PRIMITIVES_SHORT_NAMES.add(StringUtilRt.getShortName(CommonClassNames.JAVA_LANG_OBJECT));
- PRIMITIVES_SHORT_NAMES.add(StringUtilRt.getShortName(CommonClassNames.JAVA_LANG_CLASS));
- }
-
- private static void fillPrimitivesShortNames(final PsiPrimitiveType type) {
PRIMITIVES_SHORT_NAMES.add(StringUtilRt.getShortName(type.getBoxedTypeName()));
PRIMITIVES_SHORT_NAMES.add(type.getCanonicalText());
}
-
}
diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/ChainRelevance.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/ChainRelevance.java
index c3e9e0a..9b8d3dc 100644
--- a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/ChainRelevance.java
+++ b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/ChainRelevance.java
@@ -49,11 +49,6 @@
}
@TestOnly
- public boolean hasCallingVariableInContext() {
- return myHasCallingVariableInContext;
- }
-
- @TestOnly
public int getChainSize() {
return myChainSize;
}
@@ -73,11 +68,6 @@
return myNotMatchedStringVars;
}
- @TestOnly
- public boolean isFirstMethodStatic() {
- return myFirstMethodStatic;
- }
-
@Override
public int compareTo(@NotNull final ChainRelevance that) {
if (myHasCallingVariableInContext && !that.myHasCallingVariableInContext) {
diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/ChainsSearcher.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/ChainsSearcher.java
index c040e96..f58d9ef 100644
--- a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/ChainsSearcher.java
+++ b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/ChainsSearcher.java
@@ -27,8 +27,7 @@
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import org.jetbrains.jps.classFilesIndex.indexer.impl.MethodIncompleteSignature;
-import org.jetbrains.jps.incremental.storage.BuildDataManager;
+import com.intellij.compiler.classFilesIndex.impl.MethodIncompleteSignature;
import java.util.*;
@@ -42,17 +41,14 @@
private static final Logger LOG = Logger.getInstance(ChainsSearcher.class);
private static final double NEXT_METHOD_IN_CHAIN_RATIO = 1.5;
+ @NotNull
public static List<MethodsChain> search(final int pathMaximalLength,
final TargetType targetType,
final Set<String> contextQNames,
final int maxResultSize,
final ChainCompletionContext context,
final MethodsUsageIndexReader methodsUsageIndexReader) {
- final SearchInitializer initializer =
- createInitializer(targetType,
- context.getExcludedQNames(),
- methodsUsageIndexReader,
- context);
+ final SearchInitializer initializer = createInitializer(targetType, context.getExcludedQNames(), methodsUsageIndexReader, context);
if (initializer == null) {
return Collections.emptyList();
}
@@ -70,7 +66,7 @@
final Set<String> excludedParamsTypesQNames,
final MethodsUsageIndexReader methodsUsageIndexReader,
final ChainCompletionContext context) {
- final TreeSet<UsageIndexValue> methods = methodsUsageIndexReader.getMethods(target.getClassQName());
+ final SortedSet<UsageIndexValue> methods = methodsUsageIndexReader.getMethods(target.getClassQName());
return new SearchInitializer(methods, target.getClassQName(), excludedParamsTypesQNames, context);
}
@@ -82,7 +78,7 @@
final int maxResultSize,
final String targetQName,
final ChainCompletionContext context) {
- final Set<String> allExcludedNames = MethodChainsSearchUtil.unionToHashSet(context.getExcludedQNames(), targetQName);
+ final Set<String> allExcludedNames = MethodChainsSearchUtil.joinToHashSet(context.getExcludedQNames(), targetQName);
final SearchInitializer.InitResult initResult = initializer.init(Collections.<String>emptySet());
final Map<MethodIncompleteSignature, MethodsChain> knownDistance = initResult.getChains();
@@ -91,23 +87,21 @@
final LinkedList<WeightAware<Pair<MethodIncompleteSignature, MethodsChain>>> q =
new LinkedList<WeightAware<Pair<MethodIncompleteSignature, MethodsChain>>>(ContainerUtil.map(allInitialVertexes,
- new Function<WeightAware<MethodIncompleteSignature>, WeightAware<Pair<MethodIncompleteSignature, MethodsChain>>>() {
- @Override
- public WeightAware<Pair<MethodIncompleteSignature, MethodsChain>> fun(
- final WeightAware<MethodIncompleteSignature> methodIncompleteSignatureWeightAware) {
- final MethodIncompleteSignature underlying = methodIncompleteSignatureWeightAware.getUnderlying();
- return new WeightAware<Pair<MethodIncompleteSignature, MethodsChain>>(
- new Pair<MethodIncompleteSignature, MethodsChain>(
- underlying,
- new MethodsChain(context.resolveNotDeprecated(underlying),
- methodIncompleteSignatureWeightAware.getWeight(),
- underlying.getOwner()
- )
- ),
- methodIncompleteSignatureWeightAware.getWeight()
- );
- }
- }
+ new Function<WeightAware<MethodIncompleteSignature>, WeightAware<Pair<MethodIncompleteSignature, MethodsChain>>>() {
+ @Override
+ public WeightAware<Pair<MethodIncompleteSignature, MethodsChain>> fun(
+ final WeightAware<MethodIncompleteSignature> methodIncompleteSignatureWeightAware) {
+ final MethodIncompleteSignature underlying = methodIncompleteSignatureWeightAware.getUnderlying();
+ return new WeightAware<Pair<MethodIncompleteSignature, MethodsChain>>(
+ new Pair<MethodIncompleteSignature, MethodsChain>(
+ underlying,
+ new MethodsChain(context.resolveNotDeprecated(underlying),
+ methodIncompleteSignatureWeightAware.getWeight(),
+ underlying.getOwner())),
+ methodIncompleteSignatureWeightAware.getWeight()
+ );
+ }
+ }
));
int maxWeight = 0;
diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/MethodChainsSearchUtil.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/MethodChainsSearchUtil.java
index 08dbe04..e8c9b31 100644
--- a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/MethodChainsSearchUtil.java
+++ b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/MethodChainsSearchUtil.java
@@ -83,7 +83,7 @@
return false;
}
- public static <T> HashSet<T> unionToHashSet(final Collection<T> collection, final T... items) {
+ public static <T> HashSet<T> joinToHashSet(final Collection<T> collection, final T... items) {
final HashSet<T> result = new HashSet<T>();
result.addAll(collection);
Collections.addAll(result, items);
diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/MethodsChainLookupRangingHelper.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/MethodsChainLookupRangingHelper.java
index 00a0dcd..fe5af0c 100644
--- a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/MethodsChainLookupRangingHelper.java
+++ b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/MethodsChainLookupRangingHelper.java
@@ -48,9 +48,10 @@
public static List<LookupElement> chainsToWeightableLookupElements(final List<MethodsChain> chains,
final ChainCompletionContext context) {
+ final CachedRelevantStaticMethodSearcher staticMethodSearcher = new CachedRelevantStaticMethodSearcher(context);
final List<LookupElement> lookupElements = new ArrayList<LookupElement>(chains.size());
for (final MethodsChain chain : chains) {
- final LookupElement lookupElement = chainToWeightableLookupElement(chain, context);
+ final LookupElement lookupElement = chainToWeightableLookupElement(chain, context, staticMethodSearcher);
if (lookupElement != null) {
lookupElements.add(lookupElement);
}
@@ -60,7 +61,9 @@
@SuppressWarnings("ConstantConditions")
@Nullable
- private static LookupElement chainToWeightableLookupElement(final MethodsChain chain, final ChainCompletionContext context) {
+ private static LookupElement chainToWeightableLookupElement(final MethodsChain chain,
+ final ChainCompletionContext context,
+ final CachedRelevantStaticMethodSearcher staticMethodSearcher) {
final int chainSize = chain.size();
assert chainSize != 0;
final int lastMethodWeight = chain.getChainWeight();
@@ -93,7 +96,8 @@
qualifierClass = null;
}
- final MethodProcResult procResult = processMethod(method, qualifierClass, context, lastMethodWeight, isHead, nullableNotNullManager);
+ final MethodProcResult procResult = processMethod(method, qualifierClass, isHead, lastMethodWeight, context, staticMethodSearcher,
+ nullableNotNullManager);
if (procResult == null) {
return null;
}
@@ -125,9 +129,10 @@
@Nullable
private static MethodProcResult processMethod(@NotNull final PsiMethod method,
@Nullable final PsiClass qualifierClass,
- final ChainCompletionContext context,
- final int weight,
final boolean isHeadMethod,
+ final int weight,
+ final ChainCompletionContext context,
+ final CachedRelevantStaticMethodSearcher staticMethodSearcher,
final NullableNotNullManager nullableNotNullManager) {
int unreachableParametersCount = 0;
int notMatchedStringVars = 0;
@@ -172,7 +177,7 @@
continue;
}
final ContextRelevantStaticMethod contextRelevantStaticMethod =
- ContainerUtil.getFirstItem(context.getRelevantStaticMethods(typeQName, weight), null);
+ ContainerUtil.getFirstItem(staticMethodSearcher.getRelevantStaticMethods(typeQName, weight), null);
if (contextRelevantStaticMethod != null) {
//
// In most cases it is not really relevant
diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/SearchInitializer.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/SearchInitializer.java
index 89becb4..16b770a 100644
--- a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/SearchInitializer.java
+++ b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/SearchInitializer.java
@@ -19,7 +19,7 @@
import com.intellij.compiler.classFilesIndex.impl.UsageIndexValue;
import com.intellij.openapi.util.Pair;
import com.intellij.psi.PsiMethod;
-import org.jetbrains.jps.classFilesIndex.indexer.impl.MethodIncompleteSignature;
+import com.intellij.compiler.classFilesIndex.impl.MethodIncompleteSignature;
import java.util.*;
@@ -39,10 +39,11 @@
myContext = context;
final int size = indexValues.size();
myChains = new LinkedHashMap<MethodIncompleteSignature, Pair<MethodsChain, Integer>>(size);
- add(indexValues, MethodChainsSearchUtil.unionToHashSet(excludedParamsTypesQNames, targetQName));
+ add(indexValues, MethodChainsSearchUtil.joinToHashSet(excludedParamsTypesQNames, targetQName));
}
- private void add(final Collection<UsageIndexValue> indexValues, final Set<String> excludedParamsTypesQNames) {
+ private void add(final Collection<UsageIndexValue> indexValues,
+ final Set<String> excludedParamsTypesQNames) {
int bestOccurrences = -1;
for (final UsageIndexValue indexValue : indexValues) {
if (add(indexValue, excludedParamsTypesQNames)) {
diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/completion/MethodsChainsCompletionContributor.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/completion/MethodsChainsCompletionContributor.java
index 85ee710..5a85396 100644
--- a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/completion/MethodsChainsCompletionContributor.java
+++ b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/completion/MethodsChainsCompletionContributor.java
@@ -23,6 +23,7 @@
import java.util.*;
+import static com.intellij.compiler.classFilesIndex.chainsSearch.completion.CompletionContributorPatternUtil.*;
import static com.intellij.patterns.PsiJavaPatterns.or;
/**
@@ -49,8 +50,7 @@
@SuppressWarnings("unchecked")
public MethodsChainsCompletionContributor() {
- final ElementPattern<PsiElement> pattern =
- or(CompletionContributorPatternUtil.patternForMethodParameter(), CompletionContributorPatternUtil.patternForVariableAssignment());
+ final ElementPattern<PsiElement> pattern = or(patternForMethodParameter(), patternForVariableAssignment());
extend(COMPLETION_TYPE, pattern, new CompletionProvider<CompletionParameters>() {
@Override
protected void addCompletions(final @NotNull CompletionParameters parameters,
@@ -107,8 +107,12 @@
final Processor<TargetType> consumer = new Processor<TargetType>() {
@Override
public boolean process(final TargetType targetType) {
- for (final MethodsChain chain : searchChains(targetType, contextRelevantTypes, MAX_SEARCH_RESULT_SIZE, MAX_CHAIN_SIZE,
- completionContext, methodsUsageIndexReader)) {
+ for (final MethodsChain chain : searchChains(targetType,
+ contextRelevantTypes,
+ MAX_SEARCH_RESULT_SIZE,
+ MAX_CHAIN_SIZE,
+ completionContext,
+ methodsUsageIndexReader)) {
boolean insert = true;
for (final MethodsChain baseChain : searchResult) {
final MethodsChain.CompareResult r = MethodsChain.compare(baseChain, chain, completionContext.getPsiManager());
diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/context/ChainCompletionContext.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/context/ChainCompletionContext.java
index 7d25398..bc3a6a0 100644
--- a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/context/ChainCompletionContext.java
+++ b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/context/ChainCompletionContext.java
@@ -21,11 +21,10 @@
import com.intellij.openapi.util.UserDataHolder;
import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
-import com.intellij.util.containers.FactoryMap;
import com.intellij.util.containers.MultiMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import org.jetbrains.jps.classFilesIndex.indexer.impl.MethodIncompleteSignature;
+import com.intellij.compiler.classFilesIndex.impl.MethodIncompleteSignature;
import java.util.*;
@@ -33,33 +32,26 @@
* @author Dmitry Batkovich
*/
public class ChainCompletionContext {
- private final NotNullLazyValue<String> myContextMethodName = new NotNullLazyValue<String>() {
- @NotNull
- @Override
- protected String compute() {
- return myContextMethod.getName();
- }
- };
- private final PsiMethod myContextMethod;
private final TargetType myTarget;
private final Set<String> myContainingClassQNames;
private final MultiMap<String, PsiVariable> myContextVars;
private final MultiMap<String, PsiMethod> myContainingClassGetters;
private final MultiMap<String, ContextRelevantVariableGetter> myContextVarsGetters;
private final Map<String, PsiVariable> myStringVars;
- private final CachedRelevantStaticMethodSearcher myStaticMethodSearcher;
private final Set<String> myExcludedQNames;
private final GlobalSearchScope myResolveScope;
private final Project myProject;
private final PsiManager myPsiManager;
- private final FactoryMap<MethodIncompleteSignature, PsiMethod[]> myNotDeprecatedMethodsResolver;
+ private final MethodIncompleteSignatureResolver myNotDeprecatedMethodsResolver;
private final NotNullLazyValue<Set<String>> contextTypesQNames = new NotNullLazyValue<Set<String>>() {
@SuppressWarnings("unchecked")
@NotNull
@Override
protected Set<String> compute() {
- return unionToHashSet(myContainingClassQNames, myContextVars.keySet(), myContainingClassGetters.keySet(),
+ return unionToHashSet(myContainingClassQNames,
+ myContextVars.keySet(),
+ myContainingClassGetters.keySet(),
myContextVarsGetters.keySet());
}
};
@@ -68,8 +60,7 @@
return myExcludedQNames;
}
- ChainCompletionContext(final PsiMethod contextMethod,
- final TargetType target,
+ ChainCompletionContext(final TargetType target,
final Set<String> containingClassQNames,
final MultiMap<String, PsiVariable> contextVars,
final MultiMap<String, PsiMethod> containingClassGetters,
@@ -78,7 +69,6 @@
final Set<String> excludedQNames,
final Project project,
final GlobalSearchScope resolveScope) {
- myContextMethod = contextMethod;
myTarget = target;
myContainingClassQNames = containingClassQNames;
myContextVars = contextVars;
@@ -89,16 +79,7 @@
myResolveScope = resolveScope;
myProject = project;
myPsiManager = PsiManager.getInstance(project);
- myNotDeprecatedMethodsResolver = MethodIncompleteSignatureResolver.create(JavaPsiFacade.getInstance(project), resolveScope);
- myStaticMethodSearcher = new CachedRelevantStaticMethodSearcher(project, resolveScope);
- }
-
- public PsiMethod getContextMethod() {
- return myContextMethod;
- }
-
- public String getContextMethodName() {
- return myContextMethodName.getValue();
+ myNotDeprecatedMethodsResolver = new MethodIncompleteSignatureResolver(JavaPsiFacade.getInstance(project), resolveScope);
}
public TargetType getTarget() {
@@ -130,10 +111,6 @@
return myContainingClassGetters.get(typeQName);
}
- public Collection<ContextRelevantStaticMethod> getRelevantStaticMethods(final String typeQName, final int weight) {
- return myStaticMethodSearcher.getRelevantStaticMethods(typeQName, weight, this);
- }
-
public Collection<ContextRelevantVariableGetter> getRelevantVariablesGetters(final String typeQName) {
return myContextVarsGetters.get(typeQName);
}
@@ -182,4 +159,4 @@
}
return res;
}
-}
+}
\ No newline at end of file
diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/context/ContextRelevantStaticMethod.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/context/ContextRelevantStaticMethod.java
index a10bf35..8e1a447 100644
--- a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/context/ContextRelevantStaticMethod.java
+++ b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/context/ContextRelevantStaticMethod.java
@@ -43,7 +43,7 @@
@Override
public boolean execute(final int pos, final PsiVariable var) {
ContextRelevantStaticMethod.this.parameters.put(pos, new VariableSubLookupElement(var));
- return false;
+ return true;
}
});
}
diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/context/ContextUtil.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/context/ContextUtil.java
index 7b79ef7..7816c16 100644
--- a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/context/ContextUtil.java
+++ b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/context/ContextUtil.java
@@ -119,7 +119,7 @@
}
}
- return create(method, target, contextVars, contextMethods, containingClassQNames, containingElement.getProject(),
+ return create(target, contextVars, contextMethods, containingClassQNames, containingElement.getProject(),
containingElement.getResolveScope(), excludedQNames);
}
@@ -174,8 +174,7 @@
}
@Nullable
- private static ChainCompletionContext create(final PsiMethod contextMethod,
- final TargetType target,
+ private static ChainCompletionContext create(final TargetType target,
final List<PsiVariable> contextVars,
final List<PsiMethod> contextMethods,
final Set<String> containingClassQNames,
@@ -233,7 +232,7 @@
classQNameToVariable.putValue(qName, var);
}
}
- return new ChainCompletionContext(contextMethod, target, containingClassQNames, classQNameToVariable, containingClassGetters,
+ return new ChainCompletionContext(target, containingClassQNames, classQNameToVariable, containingClassGetters,
contextVarsGetters, stringVars, excludedQNames, project, resolveScope);
}
diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/context/MethodIncompleteSignatureResolver.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/context/MethodIncompleteSignatureResolver.java
index 5a9c257..f6353f3 100644
--- a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/context/MethodIncompleteSignatureResolver.java
+++ b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/context/MethodIncompleteSignatureResolver.java
@@ -18,22 +18,21 @@
import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.util.containers.FactoryMap;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import org.jetbrains.jps.classFilesIndex.indexer.impl.MethodIncompleteSignature;
+import com.intellij.compiler.classFilesIndex.impl.MethodIncompleteSignature;
+import org.jetbrains.jps.classFilesIndex.AsmUtil;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
+import java.util.*;
/**
* @author Dmitry Batkovich
*/
final class MethodIncompleteSignatureResolver {
- private MethodIncompleteSignatureResolver() {}
+ private final Map<MethodIncompleteSignature, PsiMethod[]> myResolvedCache;
- public static FactoryMap<MethodIncompleteSignature, PsiMethod[]> create(final JavaPsiFacade javaPsiFacade, final GlobalSearchScope scope) {
- return new FactoryMap<MethodIncompleteSignature, PsiMethod[]>() {
+ public MethodIncompleteSignatureResolver(final JavaPsiFacade javaPsiFacade, final GlobalSearchScope scope) {
+ myResolvedCache = new FactoryMap<MethodIncompleteSignature, PsiMethod[]>() {
@Nullable
@Override
protected PsiMethod[] create(final MethodIncompleteSignature signature) {
@@ -42,13 +41,18 @@
};
}
+ @NotNull
+ public PsiMethod[] get(final MethodIncompleteSignature signature) {
+ return myResolvedCache.get(signature);
+ }
+
private static PsiMethod[] resolveNotDeprecated(final MethodIncompleteSignature signature,
- final JavaPsiFacade javaPsiFacade,
- final GlobalSearchScope scope) {
+ final JavaPsiFacade javaPsiFacade,
+ final GlobalSearchScope scope) {
if (MethodIncompleteSignature.CONSTRUCTOR_METHOD_NAME.equals(signature.getName())) {
return PsiMethod.EMPTY_ARRAY;
}
- final PsiClass aClass = javaPsiFacade.findClass(signature.getOwner(), scope);
+ final PsiClass aClass = javaPsiFacade.findClass(AsmUtil.getQualifiedClassName(signature.getOwner()), scope);
if (aClass == null) {
return PsiMethod.EMPTY_ARRAY;
}
@@ -70,7 +74,8 @@
if (qualifiedName.equals(signature.getReturnType())) {
filtered.add(method);
}
- } else if (returnType.equalsToText(signature.getReturnType())) {
+ }
+ else if (returnType.equalsToText(signature.getReturnType())) {
filtered.add(method);
}
}
@@ -86,4 +91,4 @@
}
return filtered.toArray(new PsiMethod[filtered.size()]);
}
-}
+}
\ No newline at end of file
diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/context/TargetType.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/context/TargetType.java
index 2d983f1..6c6897a 100644
--- a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/context/TargetType.java
+++ b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/chainsSearch/context/TargetType.java
@@ -18,6 +18,7 @@
import com.intellij.psi.*;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.Nullable;
+import org.jetbrains.asm4.Type;
import java.util.Collections;
import java.util.List;
diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/impl/MethodIncompleteSignature.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/impl/MethodIncompleteSignature.java
new file mode 100644
index 0000000..6022139
--- /dev/null
+++ b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/impl/MethodIncompleteSignature.java
@@ -0,0 +1,102 @@
+/*
+ * 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.compiler.classFilesIndex.impl;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.jps.builders.java.dependencyView.Mappings;
+import org.jetbrains.jps.classFilesIndex.AsmUtil;
+import org.jetbrains.jps.classFilesIndex.indexer.impl.EnumeratedMethodIncompleteSignature;
+
+import java.util.Comparator;
+
+/**
+ * @author Dmitry Batkovich
+ */
+public class MethodIncompleteSignature {
+ public static final String CONSTRUCTOR_METHOD_NAME = "<init>";
+
+ @NotNull
+ private final String myOwner;
+ @NotNull
+ private final String myReturnType;
+ @NotNull
+ private final String myName;
+ private final boolean myStatic;
+
+ private MethodIncompleteSignature(@NotNull final String owner, @NotNull final String returnType, @NotNull final String name, final boolean aStatic) {
+ myOwner = owner;
+ myReturnType = returnType;
+ myName = name;
+ myStatic = aStatic;
+ }
+
+ public static MethodIncompleteSignature denumerated(final EnumeratedMethodIncompleteSignature sign, final String returnType, final Mappings mappings) {
+ return new MethodIncompleteSignature(AsmUtil.getQualifiedClassName(mappings.valueOf(sign.getOwner())), returnType, mappings.valueOf(sign.getName()), sign.isStatic());
+ }
+
+ @NotNull
+ public String getOwner() {
+ return myOwner;
+ }
+
+ @NotNull
+ public String getName() {
+ return myName;
+ }
+
+ @NotNull
+ public String getReturnType() {
+ return myReturnType;
+ }
+
+ public boolean isStatic() {
+ return myStatic;
+ }
+
+ @Override
+ public String toString() {
+ return "MethodIncompleteSignature{" +
+ "myOwner='" + myOwner + '\'' +
+ ", myReturnType='" + myReturnType + '\'' +
+ ", myName='" + myName + '\'' +
+ ", myStatic=" + myStatic +
+ '}';
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o) return true;
+ if (o == null || !(o instanceof MethodIncompleteSignature)) return false;
+
+ final MethodIncompleteSignature that = (MethodIncompleteSignature)o;
+
+ if (myStatic != that.myStatic) return false;
+ if (!myName.equals(that.myName)) return false;
+ if (!myOwner.equals(that.myOwner)) return false;
+ if (!myReturnType.equals(that.myReturnType)) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = myOwner.hashCode();
+ result = 31 * result + myReturnType.hashCode();
+ result = 31 * result + myName.hashCode();
+ result = 31 * result + (myStatic ? 1 : 0);
+ return result;
+ }
+}
\ No newline at end of file
diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/impl/MethodsUsageIndexConfigure.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/impl/MethodsUsageIndexConfigure.java
index e64dd1b..b442ef6 100644
--- a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/impl/MethodsUsageIndexConfigure.java
+++ b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/impl/MethodsUsageIndexConfigure.java
@@ -20,14 +20,14 @@
import com.intellij.openapi.project.Project;
import gnu.trove.TObjectIntHashMap;
import org.jetbrains.jps.classFilesIndex.indexer.api.ClassFileIndexerFactory;
-import org.jetbrains.jps.classFilesIndex.indexer.impl.MethodIncompleteSignature;
+import org.jetbrains.jps.classFilesIndex.indexer.impl.EnumeratedMethodIncompleteSignature;
import org.jetbrains.jps.classFilesIndex.indexer.impl.MethodsUsageIndexerFactory;
import org.jetbrains.jps.classFilesIndex.indexer.impl.MethodsUsageIndexer;
/**
* @author Dmitry Batkovich
*/
-public class MethodsUsageIndexConfigure extends ClassFilesIndexConfigure<String, TObjectIntHashMap<MethodIncompleteSignature>> {
+public class MethodsUsageIndexConfigure extends ClassFilesIndexConfigure<Integer, TObjectIntHashMap<EnumeratedMethodIncompleteSignature>> {
public static final MethodsUsageIndexConfigure INSTANCE = new MethodsUsageIndexConfigure();
@@ -38,7 +38,7 @@
@Override
public int getIndexVersion() {
- return 0;
+ return 1;
}
@Override
@@ -47,7 +47,7 @@
}
@Override
- public ClassFilesIndexReaderBase<String, TObjectIntHashMap<MethodIncompleteSignature>> createIndexReader(final Project project) {
+ public ClassFilesIndexReaderBase<Integer, TObjectIntHashMap<EnumeratedMethodIncompleteSignature>> createIndexReader(final Project project) {
return new MethodsUsageIndexReader(project, getIndexCanonicalName(), getIndexVersion());
}
}
diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/impl/MethodsUsageIndexReader.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/impl/MethodsUsageIndexReader.java
index 3b3adcd..0ad37ea 100644
--- a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/impl/MethodsUsageIndexReader.java
+++ b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/impl/MethodsUsageIndexReader.java
@@ -18,12 +18,13 @@
import com.intellij.compiler.classFilesIndex.api.index.ClassFilesIndexFeaturesHolder;
import com.intellij.compiler.classFilesIndex.api.index.ClassFilesIndexReaderBase;
import com.intellij.openapi.project.Project;
+import com.intellij.util.io.EnumeratorIntegerDescriptor;
import com.intellij.util.io.EnumeratorStringDescriptor;
import gnu.trove.TObjectIntHashMap;
import gnu.trove.TObjectIntProcedure;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.classFilesIndex.TObjectIntHashMapExternalizer;
-import org.jetbrains.jps.classFilesIndex.indexer.impl.MethodIncompleteSignature;
+import org.jetbrains.jps.classFilesIndex.indexer.impl.EnumeratedMethodIncompleteSignature;
import java.util.Collection;
import java.util.TreeSet;
@@ -32,7 +33,7 @@
/**
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
*/
-public class MethodsUsageIndexReader extends ClassFilesIndexReaderBase<String, TObjectIntHashMap<MethodIncompleteSignature>> {
+public class MethodsUsageIndexReader extends ClassFilesIndexReaderBase<Integer, TObjectIntHashMap<EnumeratedMethodIncompleteSignature>> {
public static MethodsUsageIndexReader getInstance(final Project project) {
final MethodsUsageIndexReader instance =
@@ -45,23 +46,25 @@
public MethodsUsageIndexReader(final Project project, final String canonicalIndexName, final int version) {
//noinspection ConstantConditions
- super(new EnumeratorStringDescriptor(),
- new TObjectIntHashMapExternalizer<MethodIncompleteSignature>(MethodIncompleteSignature.createDataExternalizer()),
+ super(EnumeratorIntegerDescriptor.INSTANCE,
+ new TObjectIntHashMapExternalizer<EnumeratedMethodIncompleteSignature>(EnumeratedMethodIncompleteSignature.createDataExternalizer()),
canonicalIndexName, version, project);
}
@NotNull
public TreeSet<UsageIndexValue> getMethods(final String key) {
assert myIndex != null;
- final Collection<TObjectIntHashMap<MethodIncompleteSignature>> unReducedValues = myIndex.getData(key);
+ assert myMappings != null;
+ final Collection<TObjectIntHashMap<EnumeratedMethodIncompleteSignature>> unReducedValues = myIndex.getData(myMappings.getName(key.replace('.', '/')));
final TObjectIntHashMap<MethodIncompleteSignature> rawValues = new TObjectIntHashMap<MethodIncompleteSignature>();
- for (final TObjectIntHashMap<MethodIncompleteSignature> unReducedValue : unReducedValues) {
- unReducedValue.forEachEntry(new TObjectIntProcedure<MethodIncompleteSignature>() {
+ for (final TObjectIntHashMap<EnumeratedMethodIncompleteSignature> unReducedValue : unReducedValues) {
+ unReducedValue.forEachEntry(new TObjectIntProcedure<EnumeratedMethodIncompleteSignature>() {
@Override
- public boolean execute(final MethodIncompleteSignature sign, final int occurrences) {
- if (!rawValues.adjustValue(sign, occurrences)) {
- rawValues.put(sign, occurrences);
+ public boolean execute(final EnumeratedMethodIncompleteSignature sign, final int occurrences) {
+ final MethodIncompleteSignature denumerated = MethodIncompleteSignature.denumerated(sign, key, myMappings);
+ if (!rawValues.adjustValue(denumerated, occurrences)) {
+ rawValues.put(denumerated, occurrences);
}
return true;
}
@@ -71,8 +74,8 @@
final TreeSet<UsageIndexValue> values = new TreeSet<UsageIndexValue>();
rawValues.forEachEntry(new TObjectIntProcedure<MethodIncompleteSignature>() {
@Override
- public boolean execute(MethodIncompleteSignature sign, int occurrences) {
- values.add(new UsageIndexValue(sign.toExternalRepresentation(), occurrences));
+ public boolean execute(final MethodIncompleteSignature sign, final int occurrences) {
+ values.add(new UsageIndexValue(sign, occurrences));
return true;
}
});
diff --git a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/impl/UsageIndexValue.java b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/impl/UsageIndexValue.java
index e04f64e..a2be6b4 100644
--- a/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/impl/UsageIndexValue.java
+++ b/java/compiler/impl/src/com/intellij/compiler/classFilesIndex/impl/UsageIndexValue.java
@@ -16,7 +16,8 @@
package com.intellij.compiler.classFilesIndex.impl;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.jps.classFilesIndex.indexer.impl.MethodIncompleteSignature;
+
+import java.util.Comparator;
/**
* @author Dmitry Batkovich
@@ -57,8 +58,26 @@
@Override
public int compareTo(@NotNull final UsageIndexValue that) {
- final int sub = -myOccurrences + that.myOccurrences;
+ int sub = -myOccurrences + that.myOccurrences;
if (sub != 0) return sub;
- return MethodIncompleteSignature.COMPARATOR.compare(myMethodIncompleteSignature, that.myMethodIncompleteSignature);
+ sub = myMethodIncompleteSignature.getOwner().compareTo(that.myMethodIncompleteSignature.getOwner());
+ if (sub != 0) {
+ return sub;
+ }
+ sub = myMethodIncompleteSignature.getName().compareTo(that.myMethodIncompleteSignature.getName());
+ if (sub != 0) {
+ return sub;
+ }
+ sub = myMethodIncompleteSignature.getReturnType().compareTo(that.myMethodIncompleteSignature.getReturnType());
+ if (sub != 0) {
+ return sub;
+ }
+ if (myMethodIncompleteSignature.isStatic() && !that.myMethodIncompleteSignature.isStatic()) {
+ return 1;
+ }
+ if (that.myMethodIncompleteSignature.isStatic() && !myMethodIncompleteSignature.isStatic()) {
+ return -1;
+ }
+ return 0;
}
}
diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/TranslatingCompilerFilesMonitor.java b/java/compiler/impl/src/com/intellij/compiler/impl/TranslatingCompilerFilesMonitor.java
index 88f3521..a20c697 100644
--- a/java/compiler/impl/src/com/intellij/compiler/impl/TranslatingCompilerFilesMonitor.java
+++ b/java/compiler/impl/src/com/intellij/compiler/impl/TranslatingCompilerFilesMonitor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -1413,7 +1413,7 @@
}
private class MyVfsListener extends VirtualFileAdapter {
- public void propertyChanged(final VirtualFilePropertyEvent event) {
+ public void propertyChanged(@NotNull final VirtualFilePropertyEvent event) {
if (VirtualFile.PROP_NAME.equals(event.getPropertyName())) {
final VirtualFile eventFile = event.getFile();
final VirtualFile parent = event.getParent();
@@ -1459,23 +1459,23 @@
}
}
- public void contentsChanged(final VirtualFileEvent event) {
+ public void contentsChanged(@NotNull final VirtualFileEvent event) {
markDirtyIfSource(event.getFile(), false);
}
- public void fileCreated(final VirtualFileEvent event) {
+ public void fileCreated(@NotNull final VirtualFileEvent event) {
processNewFile(event.getFile(), true);
}
- public void fileCopied(final VirtualFileCopyEvent event) {
+ public void fileCopied(@NotNull final VirtualFileCopyEvent event) {
processNewFile(event.getFile(), true);
}
- public void fileMoved(VirtualFileMoveEvent event) {
+ public void fileMoved(@NotNull VirtualFileMoveEvent event) {
processNewFile(event.getFile(), true);
}
- public void beforeFileDeletion(final VirtualFileEvent event) {
+ public void beforeFileDeletion(@NotNull final VirtualFileEvent event) {
if (myWatchedProjectsCount == 0) return;
final VirtualFile eventFile = event.getFile();
if ((LOG.isDebugEnabled() && eventFile.isDirectory()) || ourDebugMode) {
@@ -1573,7 +1573,7 @@
notifyFilesDeleted(pathsToMark);
}
- public void beforeFileMovement(final VirtualFileMoveEvent event) {
+ public void beforeFileMovement(@NotNull final VirtualFileMoveEvent event) {
markDirtyIfSource(event.getFile(), true);
}
diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactVirtualFileListener.java b/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactVirtualFileListener.java
index 641bae7..4f020ab 100644
--- a/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactVirtualFileListener.java
+++ b/java/compiler/impl/src/com/intellij/packaging/impl/artifacts/ArtifactVirtualFileListener.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -71,7 +71,7 @@
@Override
- public void fileMoved(VirtualFileMoveEvent event) {
+ public void fileMoved(@NotNull VirtualFileMoveEvent event) {
final String oldPath = event.getOldParent().getPath() + "/" + event.getFileName();
filePathChanged(oldPath, event.getNewParent().getPath() + "/" + event.getFileName());
}
@@ -98,7 +98,7 @@
}
@Override
- public void propertyChanged(VirtualFilePropertyEvent event) {
+ public void propertyChanged(@NotNull VirtualFilePropertyEvent event) {
if (VirtualFile.PROP_NAME.equals(event.getPropertyName())) {
final VirtualFile parent = event.getParent();
if (parent != null) {
diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/PlaceInDocument.java b/java/debugger/impl/src/com/intellij/debugger/actions/PlaceInDocument.java
index 808f226..611e393 100644
--- a/java/debugger/impl/src/com/intellij/debugger/actions/PlaceInDocument.java
+++ b/java/debugger/impl/src/com/intellij/debugger/actions/PlaceInDocument.java
@@ -22,7 +22,20 @@
* Date: Oct 7, 2003
* Time: 3:12:54 PM
*/
-interface PlaceInDocument {
- public Document getDocument();
- public int getOffset();
+class PlaceInDocument {
+ private final Document myDocument;
+ private final int myOffset;
+
+ PlaceInDocument(Document document, int offset) {
+ myDocument = document;
+ myOffset = offset;
+ }
+
+ public Document getDocument() {
+ return myDocument;
+ }
+
+ public int getOffset() {
+ return myOffset;
+ }
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/ToggleLineBreakpointActionHandler.java b/java/debugger/impl/src/com/intellij/debugger/actions/ToggleLineBreakpointActionHandler.java
index 4e33a34..650e7c3 100644
--- a/java/debugger/impl/src/com/intellij/debugger/actions/ToggleLineBreakpointActionHandler.java
+++ b/java/debugger/impl/src/com/intellij/debugger/actions/ToggleLineBreakpointActionHandler.java
@@ -26,13 +26,14 @@
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.editor.FoldRegion;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.psi.PsiDocumentManager;
-import com.intellij.psi.PsiFile;
-import com.intellij.psi.PsiManager;
+import com.intellij.psi.*;
+import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.xdebugger.impl.actions.DebuggerActionHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -71,10 +72,14 @@
return;
}
- ExpandRegionAction.expandRegionAtCaret(project, event.getData(CommonDataKeys.EDITOR));
+ Editor editor = event.getData(CommonDataKeys.EDITOR);
+ ExpandRegionAction.expandRegionAtCaret(project, editor);
Document document = place.getDocument();
int line = document.getLineNumber(place.getOffset());
+ if (editor != null && editor.getCaretModel().getVisualPosition().line != line) {
+ editor.getCaretModel().moveToOffset(place.getOffset());
+ }
DebuggerManagerEx debugManager = DebuggerManagerEx.getInstanceEx(project);
if (debugManager == null) {
@@ -100,28 +105,59 @@
}
}
+ private static boolean containsOnlyDeclarations(int line, Document document, PsiFile file) {
+ int lineStart = document.getLineStartOffset(line);
+ int lineEnd = document.getLineEndOffset(line);
+ PsiElement start = file.findElementAt(lineStart);
+ PsiElement end = file.findElementAt(lineEnd - 1);
+ if (start == null || end == null) return false;
+
+ PsiElement commonParent = PsiTreeUtil.findCommonParent(start, end);
+ for (PsiElement element : PsiTreeUtil.findChildrenOfAnyType(commonParent, PsiStatement.class, PsiExpression.class)) {
+ if (new TextRange(lineStart, lineEnd).contains(element.getTextRange().getStartOffset())) {
+ return false;
+ }
+ }
+ return true;
+ }
+
@Nullable
private static PlaceInDocument getPlace(@NotNull final Project project, AnActionEvent event) {
Editor editor = event.getData(CommonDataKeys.EDITOR);
if(editor == null) {
editor = FileEditorManager.getInstance(project).getSelectedTextEditor();
}
- if (editor != null) {
- final Document document = editor.getDocument();
- PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(document);
- if (file != null) {
- final Editor editor1 = editor;
- return new PlaceInDocument() {
- public Document getDocument() {
- return document;
- }
-
- public int getOffset() {
- return editor1.getCaretModel().getOffset();
- }
- };
- }
+ if (editor == null) {
+ return null;
}
- return null;
+
+ final Document document = editor.getDocument();
+ PsiDocumentManager.getInstance(project).commitDocument(document);
+ PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(document);
+ if (file == null) {
+ return null;
+ }
+
+ // if several lines are merged into one visual line (using folding), try to find the most appropriate of those lines
+ int visualLine = editor.getCaretModel().getVisualPosition().getLine();
+ int visibleOffset = editor.getCaretModel().getOffset();
+ while (editor.offsetToVisualPosition(visibleOffset).line == visualLine) {
+ int line = document.getLineNumber(visibleOffset);
+ if (!containsOnlyDeclarations(line, document, file)) {
+ return new PlaceInDocument(document, visibleOffset);
+ }
+ int lineEndOffset = document.getLineEndOffset(line);
+ FoldRegion region = editor.getFoldingModel().getCollapsedRegionAtOffset(lineEndOffset);
+ if (region != null) {
+ int foldEnd = region.getEndOffset();
+ if (foldEnd > lineEndOffset) {
+ visibleOffset = foldEnd;
+ continue;
+ }
+ }
+ visibleOffset = lineEndOffset + 1;
+ }
+
+ return new PlaceInDocument(document, editor.getCaretModel().getOffset());
}
}
\ No newline at end of file
diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/ToggleMethodBreakpointAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/ToggleMethodBreakpointAction.java
index 25ee5bf..79cb5c8 100644
--- a/java/debugger/impl/src/com/intellij/debugger/actions/ToggleMethodBreakpointAction.java
+++ b/java/debugger/impl/src/com/intellij/debugger/actions/ToggleMethodBreakpointAction.java
@@ -122,21 +122,7 @@
}
}
- if(method != null) {
- final PsiElement method1 = method;
- final Document document1 = document;
-
- return new PlaceInDocument() {
- public Document getDocument() {
- return document1;
- }
-
- public int getOffset() {
- return method1.getTextOffset();
- }
- };
- }
- return null;
+ return method != null ? new PlaceInDocument(document, method.getTextOffset()) : null;
}
@Nullable
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/LambdaMethodFilter.java b/java/debugger/impl/src/com/intellij/debugger/engine/LambdaMethodFilter.java
index b1aade4..c51326b 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/LambdaMethodFilter.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/LambdaMethodFilter.java
@@ -31,7 +31,7 @@
* Date: 10/26/13
*/
public class LambdaMethodFilter implements BreakpointStepMethodFilter{
- private static final String LAMBDA_METHOD_PREFIX = "lambda$";
+ public static final String LAMBDA_METHOD_PREFIX = "lambda$";
private final int myLambdaOrdinal;
@Nullable
private final SourcePosition myFirstStatementPosition;
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/RequestHint.java b/java/debugger/impl/src/com/intellij/debugger/engine/RequestHint.java
index 06aac88..7a18427 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/RequestHint.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/RequestHint.java
@@ -188,7 +188,10 @@
final Method method = location.method();
if (method != null) {
if (myVirtualMachineProxy.canGetSyntheticAttribute()? method.isSynthetic() : method.name().indexOf('$') >= 0) {
- return myDepth;
+ // step into lambda methods
+ if (!method.name().startsWith(LambdaMethodFilter.LAMBDA_METHOD_PREFIX)) {
+ return myDepth;
+ }
}
}
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/jdi/ThreadReferenceProxyImpl.java b/java/debugger/impl/src/com/intellij/debugger/jdi/ThreadReferenceProxyImpl.java
index 38140c6..594e7a2 100644
--- a/java/debugger/impl/src/com/intellij/debugger/jdi/ThreadReferenceProxyImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/jdi/ThreadReferenceProxyImpl.java
@@ -129,6 +129,7 @@
protected void clearCaches() {
DebuggerManagerThreadImpl.assertIsManagerThread();
+ myName = null;
myFrames = null;
myFrameCount = -1;
super.clearCaches();
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerSessionTab.java b/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerSessionTab.java
index 95024cd..0ffc89c 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerSessionTab.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerSessionTab.java
@@ -32,7 +32,6 @@
import com.intellij.debugger.ui.impl.WatchDebuggerTree;
import com.intellij.debugger.ui.impl.watch.*;
import com.intellij.execution.DefaultExecutionResult;
-import com.intellij.execution.ExecutionException;
import com.intellij.execution.ExecutionManager;
import com.intellij.execution.ExecutionResult;
import com.intellij.execution.configurations.RunProfile;
@@ -81,13 +80,13 @@
private final MyDebuggerStateManager myStateManager = new MyDebuggerStateManager();
private final FramesPanel myFramesPanel;
- private DebugUIEnvironment myDebugUIEnvironment;
+ private final DebugUIEnvironment myDebugUIEnvironment;
private final ThreadsPanel myThreadsPanel;
private static final String THREAD_DUMP_CONTENT_PREFIX = "Dump";
public DebuggerSessionTab(final Project project, final String sessionName, @NotNull final DebugUIEnvironment environment,
- @NotNull DebuggerSession debuggerSession) throws ExecutionException {
+ @NotNull DebuggerSession debuggerSession) {
super(project, "JavaDebugger", sessionName, debuggerSession.getSearchScope());
myDebuggerSession = debuggerSession;
myDebugUIEnvironment = environment;
@@ -264,8 +263,8 @@
final DefaultActionGroup consoleActions = new DefaultActionGroup();
if (myConsole instanceof ConsoleView) {
AnAction[] actions = ((ConsoleView)myConsole).createConsoleActions();
- for (AnAction goaction : actions) {
- consoleActions.add(goaction);
+ for (AnAction goAction : actions) {
+ consoleActions.add(goAction);
}
}
console.setActions(consoleActions, ActionPlaces.DEBUGGER_TOOLBAR, myConsole.getPreferredFocusableComponent());
@@ -429,7 +428,7 @@
@Nullable
@Override
protected RunProfile getRunProfile() {
- return myDebugUIEnvironment != null ? myDebugUIEnvironment.getRunProfile() : null;
+ return myDebugUIEnvironment.getRunProfile();
}
private void attractFramesOnPause(final int event) {
@@ -461,9 +460,8 @@
consoleView.allowHeavyFilters();
final ThreadDumpPanel panel = new ThreadDumpPanel(project, consoleView, toolbarActions, threads);
- final Icon icon = null;
final String id = createThreadDumpContentId();
- final Content content = myUi.createContent(id, panel, id, icon, null);
+ final Content content = myUi.createContent(id, panel, id, null, null);
content.setCloseable(true);
content.setDescription("Thread Dump");
myUi.addContent(content);
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointManager.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointManager.java
index 1923092..1bcbf3e 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointManager.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointManager.java
@@ -196,7 +196,7 @@
offset = editor.getDocument().getLineStartOffset(line);
}
- ExpandRegionAction.expandRegionAtCaret(myProject, editor);
+ ExpandRegionAction.expandRegionAtOffset(myProject, editor, offset);
Breakpoint breakpoint = findBreakpoint(document, offset, null);
if (breakpoint == null) {
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/DebuggerTreeBase.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/DebuggerTreeBase.java
index f515f94..dd25e3f 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/DebuggerTreeBase.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/DebuggerTreeBase.java
@@ -295,6 +295,9 @@
else if (c == 'n') {
buf.append('\n');
}
+ else if (c == '\"') {
+ buf.append('\"');
+ }
else {
buf.append('\\');
buf.append(c);
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/DebuggerTreePanel.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/DebuggerTreePanel.java
index 9caf776..25cc972 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/DebuggerTreePanel.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/DebuggerTreePanel.java
@@ -49,6 +49,7 @@
myTree = createTreeView();
final PopupHandler popupHandler = new PopupHandler() {
+ @Override
public void invokePopup(Component comp, int x, int y) {
ActionPopupMenu popupMenu = createPopupMenu();
if (popupMenu != null) {
@@ -59,12 +60,14 @@
myTree.addMouseListener(popupHandler);
setFocusTraversalPolicy(new IdeFocusTraversalPolicy() {
+ @Override
public Component getDefaultComponentImpl(Container focusCycleRoot) {
return myTree;
}
});
registerDisposable(new Disposable() {
+ @Override
public void dispose() {
myTree.removeMouseListener(popupHandler);
}
@@ -78,9 +81,11 @@
protected abstract DebuggerTree createTreeView();
+ @Override
protected void rebuild(int event) {
myRebuildAlarm.cancelAllRequests();
myRebuildAlarm.addRequest(new Runnable() {
+ @Override
public void run() {
try {
final DebuggerContextImpl context = getContext();
@@ -95,6 +100,7 @@
}, 100, ModalityState.NON_MODAL);
}
+ @Override
public void dispose() {
Disposer.dispose(myRebuildAlarm);
try {
@@ -121,13 +127,15 @@
myTree.removeAllChildren();
}
+ @Override
public Object getData(String dataId) {
- if (DebuggerTreePanel.DATA_KEY.is(dataId)) {
+ if (DATA_KEY.is(dataId)) {
return this;
}
return null;
}
+ @Override
public void requestFocus() {
getTree().requestFocus();
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/ThreadsPanel.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/ThreadsPanel.java
index bbcbff7..de2d8b3 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/ThreadsPanel.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/ThreadsPanel.java
@@ -54,6 +54,7 @@
registerDisposable(disposable);
getThreadsTree().addKeyListener(new KeyAdapter() {
+ @Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER && getThreadsTree().getSelectionCount() == 1) {
DebuggerTreeNodeImpl node = (DebuggerTreeNodeImpl)getThreadsTree().getLastSelectedPathComponent();
@@ -68,6 +69,7 @@
});
add(ScrollPaneFactory.createScrollPane(getThreadsTree()), BorderLayout.CENTER);
stateManager.addListener(new DebuggerContextListener() {
+ @Override
public void changeEvent(DebuggerContextImpl newContext, int event) {
if (DebuggerSession.EVENT_ATTACHED == event || DebuggerSession.EVENT_RESUME == event) {
startLabelsUpdate();
@@ -86,6 +88,7 @@
private void startLabelsUpdate() {
myUpdateLabelsAlarm.cancelAllRequests();
myUpdateLabelsAlarm.addRequest(new Runnable() {
+ @Override
public void run() {
boolean updateScheduled = false;
try {
@@ -96,6 +99,7 @@
final DebugProcessImpl process = getContext().getDebugProcess();
if (process != null) {
process.getManagerThread().invoke(new DebuggerCommandImpl() {
+ @Override
protected void action() throws Exception {
try {
updateNodeLabels(root);
@@ -104,6 +108,7 @@
reschedule();
}
}
+ @Override
protected void commandCancelled() {
reschedule();
}
@@ -141,6 +146,7 @@
for (int idx = 0; idx < childCount; idx++) {
final DebuggerTreeNodeImpl child = (DebuggerTreeNodeImpl)from.getChildAt(idx);
child.getDescriptor().updateRepresentation(null, new DescriptorLabelListener() {
+ @Override
public void labelChanged() {
child.labelChanged();
}
@@ -149,15 +155,18 @@
}
}
+ @Override
protected DebuggerTree createTreeView() {
return new ThreadsDebuggerTree(getProject());
}
+ @Override
protected ActionPopupMenu createPopupMenu() {
DefaultActionGroup group = (DefaultActionGroup)ActionManager.getInstance().getAction(DebuggerActions.THREADS_PANEL_POPUP);
return ActionManager.getInstance().createActionPopupMenu(DebuggerActions.THREADS_PANEL_POPUP, group);
}
+ @Override
public Object getData(String dataId) {
if (PlatformDataKeys.HELP_ID.is(dataId)) {
return HELP_ID;
diff --git a/java/execution/impl/src/com/intellij/execution/junit/JUnitUtil.java b/java/execution/impl/src/com/intellij/execution/junit/JUnitUtil.java
index e4de6db..d7c34ea 100644
--- a/java/execution/impl/src/com/intellij/execution/junit/JUnitUtil.java
+++ b/java/execution/impl/src/com/intellij/execution/junit/JUnitUtil.java
@@ -34,6 +34,7 @@
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
@@ -52,6 +53,9 @@
public static final String PARAMETRIZED_PARAMETERS_ANNOTATION_NAME = "org.junit.runners.Parameterized.Parameters";
private static final String AFTER_CLASS_ANNOTATION_NAME = "org.junit.AfterClass";
private static final String BEFORE_CLASS_ANNOTATION_NAME = "org.junit.BeforeClass";
+ private static final Collection<String> CONFIGURATIONS_ANNOTATION_NAME = Collections.unmodifiableList(
+ Arrays.asList(DATA_POINT, AFTER_ANNOTATION_NAME, BEFORE_ANNOTATION_NAME, AFTER_CLASS_ANNOTATION_NAME, BEFORE_CLASS_ANNOTATION_NAME));
+
public static final String PARAMETERIZED_CLASS_NAME = "org.junit.runners.Parameterized";
public static boolean isSuiteMethod(@NotNull PsiMethod psiMethod) {
@@ -78,7 +82,7 @@
if (psiMethod.isConstructor()) return false;
if (!psiMethod.hasModifierProperty(PsiModifier.PUBLIC)) return false;
if (psiMethod.hasModifierProperty(PsiModifier.ABSTRACT)) return false;
- if (AnnotationUtil.isAnnotated(psiMethod, DATA_POINT, false)) return false;
+ if (AnnotationUtil.isAnnotated(psiMethod, CONFIGURATIONS_ANNOTATION_NAME, false)) return false;
if (AnnotationUtil.isAnnotated(aClass, RUN_WITH, true)) return true;
if (psiMethod.getParameterList().getParametersCount() > 0) return false;
if (psiMethod.hasModifierProperty(PsiModifier.STATIC) && SUITE_METHOD_NAME.equals(psiMethod.getName())) return false;
diff --git a/java/idea-ui/src/com/intellij/ide/projectWizard/ChooseTemplateStep.form b/java/idea-ui/src/com/intellij/ide/projectWizard/ChooseTemplateStep.form
index 10c9cc5..c171b88 100644
--- a/java/idea-ui/src/com/intellij/ide/projectWizard/ChooseTemplateStep.form
+++ b/java/idea-ui/src/com/intellij/ide/projectWizard/ChooseTemplateStep.form
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.ide.projectWizard.ChooseTemplateStep">
- <grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+ <grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
@@ -8,33 +8,24 @@
<properties/>
<border type="none"/>
<children>
- <component id="13f52" class="com.intellij.ui.components.JBRadioButton" binding="myEmptyProjectButton">
- <constraints>
- <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
- </constraints>
- <properties>
- <selected value="true"/>
- <text value="Create &empty project"/>
- </properties>
- </component>
<hspacer id="35cc7">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
- <component id="2c81b" class="com.intellij.ui.components.JBRadioButton" binding="myFromTemplateButton">
+ <nested-form id="2fbda" form-file="com/intellij/ide/projectWizard/ProjectTemplateList.form" binding="myTemplateList">
<constraints>
- <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+ <grid row="1" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
+ </constraints>
+ </nested-form>
+ <component id="fb5d8" class="com.intellij.ui.components.JBCheckBox" binding="myCreateFromTemplateCheckBox">
+ <constraints>
+ <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Create project from &template"/>
</properties>
</component>
- <nested-form id="2fbda" form-file="com/intellij/ide/projectWizard/ProjectTemplateList.form" binding="myTemplateList">
- <constraints>
- <grid row="2" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
- </constraints>
- </nested-form>
</children>
</grid>
<buttonGroups>
diff --git a/java/idea-ui/src/com/intellij/ide/projectWizard/ChooseTemplateStep.java b/java/idea-ui/src/com/intellij/ide/projectWizard/ChooseTemplateStep.java
index db2b79e..65a1ffd 100644
--- a/java/idea-ui/src/com/intellij/ide/projectWizard/ChooseTemplateStep.java
+++ b/java/idea-ui/src/com/intellij/ide/projectWizard/ChooseTemplateStep.java
@@ -18,7 +18,8 @@
import com.intellij.ide.util.projectWizard.ModuleWizardStep;
import com.intellij.ide.util.projectWizard.WizardContext;
import com.intellij.platform.ProjectTemplate;
-import com.intellij.ui.components.JBRadioButton;
+import com.intellij.ui.components.JBCheckBox;
+import org.jetbrains.annotations.TestOnly;
import javax.swing.*;
import java.awt.event.ActionEvent;
@@ -34,26 +35,22 @@
private final ProjectTypeStep myProjectTypeStep;
private JPanel myPanel;
- private JBRadioButton myEmptyProjectButton;
- private JBRadioButton myFromTemplateButton;
private ProjectTemplateList myTemplateList;
+ private JBCheckBox myCreateFromTemplateCheckBox;
public ChooseTemplateStep(WizardContext wizardContext, ProjectTypeStep projectTypeStep) {
myWizardContext = wizardContext;
myProjectTypeStep = projectTypeStep;
- ActionListener listener = new ActionListener() {
+ myCreateFromTemplateCheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
- updateSelection();
+ myTemplateList.setEnabled(myCreateFromTemplateCheckBox.isSelected());
+ if (myCreateFromTemplateCheckBox.isSelected()) {
+ myTemplateList.getList().requestFocus();
+ }
}
- };
- myEmptyProjectButton.addActionListener(listener);
- myFromTemplateButton.addActionListener(listener);
- updateSelection();
- }
-
- private void updateSelection() {
- myTemplateList.setEnabled(myFromTemplateButton.isSelected());
+ });
+ myTemplateList.setEnabled(false);
}
@Override
@@ -73,8 +70,19 @@
@Override
public void updateDataModel() {
- if (myFromTemplateButton.isSelected()) {
+ if (myCreateFromTemplateCheckBox.isSelected()) {
myWizardContext.setProjectTemplate(myTemplateList.getSelectedTemplate());
}
}
+
+ public ProjectTemplateList getTemplateList() {
+ return myTemplateList;
+ }
+
+ @TestOnly
+ public boolean setSelectedTemplate(String name) {
+ myCreateFromTemplateCheckBox.setSelected(true);
+ return myTemplateList.setSelectedTemplate(name);
+ }
+
}
diff --git a/java/idea-ui/src/com/intellij/ide/projectWizard/NewProjectWizard.java b/java/idea-ui/src/com/intellij/ide/projectWizard/NewProjectWizard.java
index 12007df..e7e172c 100644
--- a/java/idea-ui/src/com/intellij/ide/projectWizard/NewProjectWizard.java
+++ b/java/idea-ui/src/com/intellij/ide/projectWizard/NewProjectWizard.java
@@ -47,11 +47,15 @@
myWizardContext.setNewWizard(true);
ProjectTypeStep projectTypeStep = new ProjectTypeStep(myWizardContext, this, modulesProvider);
mySequence.addCommonStep(projectTypeStep);
- mySequence.addCommonStep(new ChooseTemplateStep(myWizardContext, projectTypeStep));
+ ChooseTemplateStep chooseTemplateStep = new ChooseTemplateStep(myWizardContext, projectTypeStep);
+ mySequence.addCommonStep(chooseTemplateStep);
mySequence.addCommonFinishingStep(new ProjectSettingsStep(myWizardContext), null);
for (ModuleWizardStep step : mySequence.getAllSteps()) {
addStep(step);
}
+ if (myWizardContext.isCreatingNewProject()) {
+ projectTypeStep.loadRemoteTemplates(chooseTemplateStep);
+ }
super.init();
}
diff --git a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTemplateList.java b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTemplateList.java
index 51e4294..3c6d456 100644
--- a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTemplateList.java
+++ b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTemplateList.java
@@ -31,6 +31,7 @@
import com.intellij.ui.popup.list.GroupedItemsListRenderer;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.TestOnly;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
@@ -177,10 +178,19 @@
});
}
+ public JBList getList() {
+ return myList;
+ }
+
public void addListSelectionListener(ListSelectionListener listener) {
myList.addListSelectionListener(listener);
}
+ public void setPaintBusy(boolean b) {
+ myList.setPaintBusy(b);
+ }
+
+ @TestOnly
public boolean setSelectedTemplate(String name) {
ListModel model1 = myList.getModel();
for (int j = 0; j < model1.getSize(); j++) {
@@ -192,8 +202,4 @@
return false;
}
-
- public void setPaintBusy(boolean b) {
- myList.setPaintBusy(b);
- }
}
diff --git a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.java b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.java
index cde7955..2c8ac12 100644
--- a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.java
+++ b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.java
@@ -54,9 +54,7 @@
import com.intellij.platform.templates.BuilderBasedTemplate;
import com.intellij.platform.templates.LocalArchivedTemplate;
import com.intellij.platform.templates.RemoteTemplatesFactory;
-import com.intellij.ui.CollectionListModel;
-import com.intellij.ui.ColoredListCellRenderer;
-import com.intellij.ui.IdeBorderFactory;
+import com.intellij.ui.*;
import com.intellij.ui.SingleSelectionModel;
import com.intellij.ui.components.JBList;
import com.intellij.util.Function;
@@ -116,7 +114,6 @@
};
private final Map<String, ModuleWizardStep> myCustomSteps = new HashMap<String, ModuleWizardStep>();
private final MultiMap<TemplatesGroup,ProjectTemplate> myTemplatesMap;
- private boolean myRemoteTemplatesLoaded;
private String myCurrentCard;
public ProjectTypeStep(WizardContext context, NewProjectWizard wizard, ModulesProvider modulesProvider) {
@@ -150,6 +147,12 @@
append(value.getName());
}
});
+ new ListSpeedSearch(myProjectTypeList) {
+ @Override
+ protected String getElementText(Object element) {
+ return ((TemplatesGroup)element).getName();
+ }
+ };
myModulesProvider = modulesProvider;
Project project = context.getProject();
@@ -240,7 +243,7 @@
else {
TemplatesGroup group = new TemplatesGroup(builder);
groupMap.put(group.getName(), group);
- myTemplatesMap.put(group, new ArrayList<ProjectTemplate>(Collections.singletonList(template)));
+ myTemplatesMap.put(group, new ArrayList<ProjectTemplate>());
}
}
@@ -258,15 +261,6 @@
}
}
- // remove empty groups
- //for (Iterator<Map.Entry<TemplatesGroup, Collection<ProjectTemplate>>> iterator = myTemplatesMap.entrySet().iterator();
- // iterator.hasNext(); ) {
- // Map.Entry<TemplatesGroup, Collection<ProjectTemplate>> entry = iterator.next();
- // if (entry.getValue().isEmpty()) {
- // iterator.remove();
- // }
- //}
-
List<TemplatesGroup> groups = new ArrayList<TemplatesGroup>(myTemplatesMap.keySet());
// sorting by module type popularity
@@ -381,9 +375,11 @@
return ContainerUtil.intersects(Arrays.asList(roles), acceptable);
}
-
private void setTemplatesList(TemplatesGroup group, Collection<ProjectTemplate> templates, boolean preserveSelection) {
- ArrayList<ProjectTemplate> list = new ArrayList<ProjectTemplate>(templates);
+ List<ProjectTemplate> list = new ArrayList<ProjectTemplate>(templates);
+ if (group.getModuleBuilder() != null) {
+ list.add(0, new BuilderBasedTemplate(group.getModuleBuilder()));
+ }
if (group.getParentGroup() == null) {
for (TemplatesGroup templatesGroup : myTemplatesMap.keySet()) {
if (group.getName().equals(templatesGroup.getParentGroup())) {
@@ -463,13 +459,6 @@
}
@Override
- public void updateStep() {
- if (myContext.isCreatingNewProject() && !myRemoteTemplatesLoaded) {
- loadRemoteTemplates();
- }
- }
-
- @Override
public boolean validate() throws ConfigurationException {
ModuleWizardStep step = getCustomStep();
return step != null ? step.validate() : super.validate();
@@ -522,12 +511,13 @@
return map;
}
- private void loadRemoteTemplates() {
+ void loadRemoteTemplates(final ChooseTemplateStep chooseTemplateStep) {
ProgressManager.getInstance().run(new Task.Backgroundable(myContext.getProject(), "Loading Templates") {
@Override
public void run(@NotNull ProgressIndicator indicator) {
try {
myTemplatesList.setPaintBusy(true);
+ chooseTemplateStep.getTemplateList().setPaintBusy(true);
RemoteTemplatesFactory factory = new RemoteTemplatesFactory();
String[] groups = factory.getGroups();
for (String group : groups) {
@@ -548,12 +538,13 @@
if (group == null) return;
Collection<ProjectTemplate> templates = myTemplatesMap.get(group);
setTemplatesList(group, templates, true);
+ chooseTemplateStep.updateStep();
}
});
}
finally {
myTemplatesList.setPaintBusy(false);
- myRemoteTemplatesLoaded = true;
+ chooseTemplateStep.getTemplateList().setPaintBusy(false);
}
}
});
diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectNameWithTypeStep.form b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectNameWithTypeStep.form
deleted file mode 100644
index 2df2467..0000000
--- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectNameWithTypeStep.form
+++ /dev/null
@@ -1,167 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.ide.util.newProjectWizard.ProjectNameWithTypeStep">
- <grid id="807b" binding="myModulePanel" layout-manager="GridBagLayout">
- <constraints>
- <xy x="20" y="20" width="416" height="453"/>
- </constraints>
- <properties/>
- <border type="none"/>
- <children>
- <grid id="27dc6" binding="myInternalPanel" layout-manager="GridBagLayout">
- <constraints>
- <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
- <gridbag weightx="1.0" weighty="1.0"/>
- </constraints>
- <properties>
- <maximumSize width="250" height="150"/>
- <preferredSize width="250" height="150"/>
- </properties>
- <clientProperties>
- <BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"/>
- </clientProperties>
- <border type="none"/>
- <children>
- <scrollpane id="d8de8" class="com.intellij.ui.components.JBScrollPane" binding="myModuleTypeScrollPane">
- <constraints>
- <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
- <gridbag top="0" left="0" bottom="0" right="5" weightx="0.1" weighty="1.0"/>
- </constraints>
- <properties>
- <horizontalScrollBarPolicy value="31"/>
- <preferredSize width="125" height="128"/>
- </properties>
- <border type="none"/>
- <children>
- <component id="c263e" class="com.intellij.ui.components.JBList" binding="myTypesList">
- <constraints/>
- <properties/>
- </component>
- </children>
- </scrollpane>
- <component id="fb71" class="javax.swing.JLabel" binding="myModuleTypeLabel">
- <constraints>
- <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
- <gridbag top="10" left="0" bottom="2" right="0" weightx="0.0" weighty="0.0"/>
- </constraints>
- <properties>
- <text resource-bundle="messages/ProjectBundle" key="project.new.wizard.select.type.label"/>
- </properties>
- </component>
- <component id="9073d" class="javax.swing.JLabel" binding="myDescriptionLabel">
- <constraints>
- <grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
- <gridbag top="10" left="0" bottom="2" right="0" weightx="0.0" weighty="0.0"/>
- </constraints>
- <properties>
- <text resource-bundle="messages/ProjectBundle" key="project.new.wizard.description.title"/>
- </properties>
- </component>
- <scrollpane id="6260" class="com.intellij.ui.components.JBScrollPane" binding="myDescriptionScrollPane">
- <constraints>
- <grid row="2" column="1" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
- <gridbag weightx="0.8" weighty="0.0"/>
- </constraints>
- <properties>
- <horizontalScrollBarPolicy value="30"/>
- <preferredSize width="28" height="20"/>
- </properties>
- <border type="none"/>
- <children>
- <component id="6e12" class="javax.swing.JEditorPane" binding="myModuleDescriptionPane">
- <constraints/>
- <properties/>
- </component>
- </children>
- </scrollpane>
- <grid id="8a2b7" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
- <margin top="0" left="0" bottom="0" right="0"/>
- <constraints>
- <grid row="0" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
- <gridbag weightx="1.0" weighty="0.0"/>
- </constraints>
- <properties/>
- <border type="none"/>
- <children>
- <component id="e6ad1" class="javax.swing.JTextField" binding="myModuleName">
- <constraints>
- <grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
- <preferred-size width="150" height="-1"/>
- </grid>
- </constraints>
- <properties/>
- </component>
- <component id="1f996" class="javax.swing.JLabel">
- <constraints>
- <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
- </constraints>
- <properties>
- <labelFor value="e6ad1"/>
- <text resource-bundle="messages/ProjectBundle" key="project.new.wizard.module.name.title"/>
- </properties>
- </component>
- <component id="4af6e" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myModuleContentRoot">
- <constraints>
- <grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
- </constraints>
- <properties/>
- </component>
- <component id="c4851" class="javax.swing.JLabel">
- <constraints>
- <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
- </constraints>
- <properties>
- <labelFor value="4af6e"/>
- <text resource-bundle="messages/ProjectBundle" key="project.new.wizard.module.root.title"/>
- </properties>
- </component>
- <component id="83a50" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myModuleFileLocation">
- <constraints>
- <grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
- </constraints>
- <properties>
- <preferredSize width="280" height="20"/>
- </properties>
- </component>
- <component id="a4319" class="javax.swing.JLabel">
- <constraints>
- <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
- </constraints>
- <properties>
- <labelFor value="83a50"/>
- <text resource-bundle="messages/ProjectBundle" key="project.new.wizard.module.file.title"/>
- </properties>
- </component>
- </children>
- </grid>
- </children>
- </grid>
- <grid id="fa640" binding="myHeader" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
- <margin top="0" left="0" bottom="0" right="0"/>
- <constraints>
- <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
- <gridbag weightx="0.0" weighty="0.0"/>
- </constraints>
- <properties>
- <visible value="true"/>
- </properties>
- <border type="none"/>
- <children>
- <component id="63a74" class="javax.swing.JCheckBox" binding="myCreateModuleCb">
- <constraints>
- <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
- </constraints>
- <properties>
- <text value="&Create module"/>
- </properties>
- </component>
- <component id="d48cf" class="javax.swing.JSeparator">
- <constraints>
- <grid row="0" column="1" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
- </constraints>
- <properties/>
- </component>
- </children>
- </grid>
- </children>
- </grid>
-</form>
diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectNameWithTypeStep.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectNameWithTypeStep.java
deleted file mode 100644
index baf7b4c..0000000
--- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectNameWithTypeStep.java
+++ /dev/null
@@ -1,491 +0,0 @@
-/*
- * Copyright 2000-2013 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.ide.util.newProjectWizard;
-
-import com.intellij.ide.BrowserUtil;
-import com.intellij.ide.IdeBundle;
-import com.intellij.ide.highlighter.ModuleFileType;
-import com.intellij.ide.util.BrowseFilesListener;
-import com.intellij.ide.util.newProjectWizard.modes.CreateFromTemplateMode;
-import com.intellij.ide.util.newProjectWizard.modes.WizardMode;
-import com.intellij.ide.util.projectWizard.ModuleBuilder;
-import com.intellij.ide.util.projectWizard.ProjectWizardUtil;
-import com.intellij.ide.util.projectWizard.WizardContext;
-import com.intellij.openapi.actionSystem.AnAction;
-import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.openapi.actionSystem.CustomShortcutSet;
-import com.intellij.openapi.module.Module;
-import com.intellij.openapi.module.ModuleManager;
-import com.intellij.openapi.options.ConfigurationException;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.project.ProjectBundle;
-import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable;
-import com.intellij.openapi.ui.Messages;
-import com.intellij.openapi.ui.TextFieldWithBrowseButton;
-import com.intellij.openapi.util.Comparing;
-import com.intellij.openapi.util.SystemInfo;
-import com.intellij.openapi.util.io.FileUtil;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.ui.DocumentAdapter;
-import com.intellij.ui.DoubleClickListener;
-import com.intellij.ui.HyperlinkAdapter;
-import com.intellij.ui.components.JBScrollPane;
-import com.intellij.util.IJSwingUtilities;
-import com.intellij.util.ui.UIUtil;
-
-import javax.swing.*;
-import javax.swing.event.*;
-import java.awt.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.KeyEvent;
-import java.awt.event.MouseEvent;
-import java.io.File;
-import java.util.List;
-
-public class ProjectNameWithTypeStep extends ProjectNameStep {
- private JEditorPane myModuleDescriptionPane;
- private JList myTypesList;
- protected JCheckBox myCreateModuleCb;
- private JPanel myModulePanel;
- private JPanel myInternalPanel;
- private JTextField myModuleName;
- private TextFieldWithBrowseButton myModuleContentRoot;
- private TextFieldWithBrowseButton myModuleFileLocation;
- private JPanel myHeader;
-
- private JLabel myModuleTypeLabel;
- private JLabel myDescriptionLabel;
- private JBScrollPane myModuleTypeScrollPane;
- private JBScrollPane myDescriptionScrollPane;
-
- private boolean myModuleNameChangedByUser = false;
- private boolean myModuleNameDocListenerEnabled = true;
-
- private boolean myContentRootChangedByUser = false;
- private boolean myContentRootDocListenerEnabled = true;
-
- private boolean myImlLocationChangedByUser = false;
- private boolean myImlLocationDocListenerEnabled = true;
- private final StepSequence mySequence;
-
-
- public ProjectNameWithTypeStep(final WizardContext wizardContext, StepSequence sequence, final WizardMode mode) {
- super(wizardContext, mode);
- mySequence = sequence;
- myAdditionalContentPanel.add(myModulePanel,
- new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1, 1, GridBagConstraints.NORTHWEST,
- GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
- myHeader.setVisible(myWizardContext.isCreatingNewProject() && !isCreateFromTemplateMode());
- myCreateModuleCb.addActionListener(new ActionListener() {
- public void actionPerformed(final ActionEvent e) {
- UIUtil.setEnabled(myInternalPanel, myCreateModuleCb.isSelected(), true);
- fireStateChanged();
- }
- });
- myCreateModuleCb.setSelected(true);
- if (!myWizardContext.isCreatingNewProject()){
- myInternalPanel.setBorder(null);
- }
- myModuleDescriptionPane.setContentType(UIUtil.HTML_MIME);
- myModuleDescriptionPane.addHyperlinkListener(new HyperlinkAdapter() {
- @Override
- protected void hyperlinkActivated(HyperlinkEvent e) {
- try {
- BrowserUtil.browse(e.getURL());
- }
- catch (IllegalThreadStateException ex) {
- // it's not a problem
- }
- }
- });
- myModuleDescriptionPane.setEditable(false);
-
- final DefaultListModel defaultListModel = new DefaultListModel();
- for (ModuleBuilder builder : ModuleBuilder.getAllBuilders()) {
- defaultListModel.addElement(builder);
- }
- myTypesList.setModel(defaultListModel);
- myTypesList.setSelectionModel(new PermanentSingleSelectionModel());
- myTypesList.setCellRenderer(new DefaultListCellRenderer(){
- public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) {
- final Component rendererComponent = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
- final ModuleBuilder builder = (ModuleBuilder)value;
- setIcon(builder.getBigIcon());
- setDisabledIcon(builder.getBigIcon());
- setText(builder.getPresentableName());
- return rendererComponent;
- }
- });
- myTypesList.addListSelectionListener(new ListSelectionListener() {
- @SuppressWarnings({"HardCodedStringLiteral"})
- public void valueChanged(ListSelectionEvent e) {
- if (e.getValueIsAdjusting()) {
- return;
- }
-
- final ModuleBuilder typeSelected = (ModuleBuilder)myTypesList.getSelectedValue();
-
- final StringBuilder sb = new StringBuilder("<html><body><font face=\"Verdana\" ");
- sb.append(SystemInfo.isMac ? "" : "size=\"-1\"").append('>');
- sb.append(typeSelected.getDescription()).append("</font></body></html>");
-
- myModuleDescriptionPane.setText(sb.toString());
-
- boolean focusOwner = myTypesList.isFocusOwner();
- fireStateChanged();
- if (focusOwner) {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- myTypesList.requestFocusInWindow();
- }
- });
- }
- }
- });
- myTypesList.setSelectedIndex(0);
- new DoubleClickListener() {
- @Override
- protected boolean onDoubleClick(MouseEvent e) {
- myWizardContext.requestNextStep();
- return true;
- }
- }.installOn(myTypesList);
-
- final Dimension preferredSize = calcTypeListPreferredSize(ModuleBuilder.getAllBuilders());
- final JBScrollPane pane = IJSwingUtilities.findParentOfType(myTypesList, JBScrollPane.class);
- pane.setPreferredSize(preferredSize);
- pane.setMinimumSize(preferredSize);
-
- myNamePathComponent.getNameComponent().getDocument().addDocumentListener(new DocumentAdapter() {
- protected void textChanged(final DocumentEvent e) {
- if (!myModuleNameChangedByUser) {
- setModuleName(myNamePathComponent.getNameValue());
- }
- }
- });
-
- myModuleContentRoot.addBrowseFolderListener(ProjectBundle.message("project.new.wizard.module.content.root.chooser.title"), ProjectBundle.message("project.new.wizard.module.content.root.chooser.description"),
- myWizardContext.getProject(), BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR);
-
- myNamePathComponent.getPathComponent().getDocument().addDocumentListener(new DocumentAdapter() {
- protected void textChanged(final DocumentEvent e) {
- if (!myContentRootChangedByUser) {
- setModuleContentRoot(myNamePathComponent.getPath());
- }
- }
- });
- myModuleName.getDocument().addDocumentListener(new DocumentAdapter() {
- protected void textChanged(final DocumentEvent e) {
- if (myModuleNameDocListenerEnabled) {
- myModuleNameChangedByUser = true;
- }
- String path = getDefaultBaseDir(wizardContext);
- final String moduleName = getModuleName();
- if (path.length() > 0 && !Comparing.strEqual(moduleName, myNamePathComponent.getNameValue())) {
- path += "/" + moduleName;
- }
- if (!myContentRootChangedByUser) {
- final boolean f = myModuleNameChangedByUser;
- myModuleNameChangedByUser = true;
- setModuleContentRoot(path);
- myModuleNameChangedByUser = f;
- }
- if (!myImlLocationChangedByUser) {
- setImlFileLocation(path);
- }
- }
- });
- myModuleContentRoot.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
- protected void textChanged(final DocumentEvent e) {
- if (myContentRootDocListenerEnabled) {
- myContentRootChangedByUser = true;
- }
- if (!myImlLocationChangedByUser) {
- setImlFileLocation(myModuleContentRoot.getText());
- }
- if (!myModuleNameChangedByUser) {
- final String path = FileUtil.toSystemIndependentName(myModuleContentRoot.getText());
- final int idx = path.lastIndexOf("/");
-
- boolean f = myContentRootChangedByUser;
- myContentRootChangedByUser = true;
-
- boolean i = myImlLocationChangedByUser;
- myImlLocationChangedByUser = true;
-
- setModuleName(idx >= 0 ? path.substring(idx + 1) : "");
-
- myContentRootChangedByUser = f;
- myImlLocationChangedByUser = i;
- }
- }
- });
-
- myModuleFileLocation.addBrowseFolderListener(ProjectBundle.message("project.new.wizard.module.file.chooser.title"), ProjectBundle.message("project.new.wizard.module.file.description"),
- myWizardContext.getProject(), BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR);
- myModuleFileLocation.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
- protected void textChanged(final DocumentEvent e) {
- if (myImlLocationDocListenerEnabled) {
- myImlLocationChangedByUser = true;
- }
- }
- });
- myNamePathComponent.getPathComponent().getDocument().addDocumentListener(new DocumentAdapter() {
- protected void textChanged(final DocumentEvent e) {
- if (!myImlLocationChangedByUser) {
- setImlFileLocation(myNamePathComponent.getPath());
- }
- }
- });
- if (wizardContext.isCreatingNewProject()) {
- setModuleName(myNamePathComponent.getNameValue());
- setModuleContentRoot(myNamePathComponent.getPath());
- setImlFileLocation(myNamePathComponent.getPath());
- } else {
- final Project project = wizardContext.getProject();
- assert project != null;
- VirtualFile baseDir = project.getBaseDir();
- if (baseDir != null) { //e.g. was deleted
- final String baseDirPath = baseDir.getPath();
- String moduleName = ProjectWizardUtil.findNonExistingFileName(baseDirPath, "untitled", "");
- String contentRoot = baseDirPath + "/" + moduleName;
- if (!Comparing.strEqual(project.getName(), wizardContext.getProjectName()) && !wizardContext.isCreatingNewProject() && wizardContext.getProjectName() != null) {
- moduleName = ProjectWizardUtil.findNonExistingFileName(wizardContext.getProjectFileDirectory(), wizardContext.getProjectName(), "");
- contentRoot = wizardContext.getProjectFileDirectory();
- }
- setModuleName(moduleName);
- setModuleContentRoot(contentRoot);
- setImlFileLocation(contentRoot);
- myModuleName.select(0, moduleName.length());
- }
- }
-
-
- if (isCreateFromTemplateMode()) {
- replaceModuleTypeOptions(new JPanel());
- }
- else {
- final AnAction arrow = new AnAction() {
- @Override
- public void actionPerformed(AnActionEvent e) {
- if (e.getInputEvent() instanceof KeyEvent) {
- final int code = ((KeyEvent)e.getInputEvent()).getKeyCode();
- if (!myCreateModuleCb.isSelected()) return;
- int i = myTypesList.getSelectedIndex();
- if (code == KeyEvent.VK_DOWN) {
- if (++i == myTypesList.getModel().getSize()) return;
- }
- else if (code == KeyEvent.VK_UP) {
- if (--i == -1) return;
- }
- myTypesList.setSelectedIndex(i);
- }
- }
- };
- CustomShortcutSet shortcutSet = new CustomShortcutSet(KeyEvent.VK_UP, KeyEvent.VK_DOWN);
- arrow.registerCustomShortcutSet(shortcutSet, myNamePathComponent.getNameComponent());
- arrow.registerCustomShortcutSet(shortcutSet, myModuleName);
- }
- }
-
- private boolean isCreateFromTemplateMode() {
- return myMode instanceof CreateFromTemplateMode;
- }
-
- private Dimension calcTypeListPreferredSize(final List<ModuleBuilder> allModuleTypes) {
- int width = 0;
- int height = 0;
- final FontMetrics fontMetrics = myTypesList.getFontMetrics(myTypesList.getFont());
- final int fontHeight = fontMetrics.getMaxAscent() + fontMetrics.getMaxDescent();
- for (final ModuleBuilder type : allModuleTypes) {
- final Icon icon = type.getBigIcon();
- final int iconHeight = icon != null ? icon.getIconHeight() : 0;
- final int iconWidth = icon != null ? icon.getIconWidth() : 0;
- height += Math.max(iconHeight, fontHeight) + 6;
- width = Math.max(width, iconWidth + fontMetrics.stringWidth(type.getPresentableName()) + 10);
- }
- return new Dimension(width, height);
- }
-
- private String getDefaultBaseDir(WizardContext wizardContext) {
- if (wizardContext.isCreatingNewProject()) {
- return myNamePathComponent.getPath();
- } else {
- final Project project = wizardContext.getProject();
- assert project != null;
- final VirtualFile baseDir = project.getBaseDir();
- if (baseDir != null) {
- return baseDir.getPath();
- }
- return "";
- }
- }
-
- @Override
- public boolean isStepVisible() {
- return true;
- }
-
- public JComponent getPreferredFocusedComponent() {
- return myWizardContext.isCreatingNewProject() ? super.getPreferredFocusedComponent() : myModuleName;
- }
-
- private void setImlFileLocation(final String path) {
- myImlLocationDocListenerEnabled = false;
- myModuleFileLocation.setText(FileUtil.toSystemDependentName(path));
- myImlLocationDocListenerEnabled = true;
- }
-
- private void setModuleContentRoot(final String path) {
- myContentRootDocListenerEnabled = false;
- myModuleContentRoot.setText(FileUtil.toSystemDependentName(path));
- myContentRootDocListenerEnabled = true;
- }
-
- private void setModuleName(String moduleName) {
- myModuleNameDocListenerEnabled = false;
- myModuleName.setText(moduleName);
- myModuleNameDocListenerEnabled = true;
- }
-
- public void updateStep() {
- super.updateStep();
- if (!isCreateFromTemplateMode()) {
- if (myCreateModuleCb.isSelected()) {
- mySequence.setType(getSelectedBuilderId());
- } else {
- mySequence.setType(null);
- }
- }
- }
-
- public void updateDataModel() {
-
- if (!isCreateFromTemplateMode()) {
- mySequence.setType(myCreateModuleCb.isSelected() ? getSelectedBuilderId() : null);
- }
- super.updateDataModel();
-
- if (!isCreateFromTemplateMode() && myCreateModuleCb.isSelected()) {
- final ModuleBuilder builder = (ModuleBuilder)myMode.getModuleBuilder();
- assert builder != null;
- final String moduleName = getModuleName();
- builder.setName(moduleName);
- builder.setModuleFilePath(
- FileUtil.toSystemIndependentName(myModuleFileLocation.getText()) + "/" + moduleName + ModuleFileType.DOT_DEFAULT_EXTENSION);
- builder.setContentEntryPath(FileUtil.toSystemIndependentName(myModuleContentRoot.getText()));
- }
- }
-
- protected String getSelectedBuilderId() {
- return ((ModuleBuilder)myTypesList.getSelectedValue()).getBuilderId();
- }
-
- public boolean validate() throws ConfigurationException {
- if (myCreateModuleCb.isSelected() || !myWizardContext.isCreatingNewProject()) {
- if (validateModulePaths()) return false;
- }
- if (!myWizardContext.isCreatingNewProject()) {
- validateExistingModuleName();
- }
- return !myWizardContext.isCreatingNewProject() || super.validate();
- }
-
- private void validateExistingModuleName() throws ConfigurationException {
- final String moduleName = getModuleName();
- final Module module;
- final ProjectStructureConfigurable fromConfigurable = ProjectStructureConfigurable.getInstance(myWizardContext.getProject());
- if (fromConfigurable != null) {
- module = fromConfigurable.getModulesConfig().getModule(moduleName);
- }
- else {
- module = ModuleManager.getInstance(myWizardContext.getProject()).findModuleByName(moduleName);
- }
- if (module != null) {
- throw new ConfigurationException("Module \'" + moduleName + "\' already exist in project. Please, specify another name.");
- }
- }
-
- private boolean validateModulePaths() throws ConfigurationException {
- final String moduleName = getModuleName();
- final String moduleFileDirectory = myModuleFileLocation.getText();
- if (moduleFileDirectory.length() == 0) {
- throw new ConfigurationException("Enter module file location");
- }
- if (moduleName.length() == 0) {
- throw new ConfigurationException("Enter a module name");
- }
-
- if (!ProjectWizardUtil.createDirectoryIfNotExists(IdeBundle.message("directory.module.file"), moduleFileDirectory,
- myImlLocationChangedByUser)) {
- return true;
- }
- if (!ProjectWizardUtil.createDirectoryIfNotExists(IdeBundle.message("directory.module.content.root"), myModuleContentRoot.getText(),
- myContentRootChangedByUser)) {
- return true;
- }
-
- File moduleFile = new File(moduleFileDirectory, moduleName + ModuleFileType.DOT_DEFAULT_EXTENSION);
- if (moduleFile.exists()) {
- int answer = Messages.showYesNoDialog(IdeBundle.message("prompt.overwrite.project.file", moduleFile.getAbsolutePath(),
- IdeBundle.message("project.new.wizard.module.identification")),
- IdeBundle.message("title.file.already.exists"), Messages.getQuestionIcon());
- if (answer != Messages.YES) {
- return true;
- }
- }
- return false;
- }
-
- private static class PermanentSingleSelectionModel extends DefaultListSelectionModel {
- public PermanentSingleSelectionModel() {
- super.setSelectionMode(SINGLE_SELECTION);
- }
-
- public final void setSelectionMode(int selectionMode) {
- }
-
- public final void removeSelectionInterval(int index0, int index1) {
- }
- }
-
- public String getHelpId() {
- return "reference.dialogs.new.project.fromScratch";
- }
-
- protected String getModuleName() {
- return myModuleName.getText().trim();
- }
-
- protected void addModuleNameListener(final DocumentListener listener) {
- myModuleName.getDocument().addDocumentListener(listener);
- }
-
- protected void replaceModuleTypeOptions(final Component component) {
- myModuleTypeLabel.setVisible(false);
- myDescriptionLabel.setVisible(false);
- myModuleTypeScrollPane.setVisible(false);
- myDescriptionScrollPane.setVisible(false);
- myInternalPanel.add(component, new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
- new Insets(10, 0, 0, 0), 0, 0));
- }
-
- @Override
- public String getName() {
- return "Name and Type";
- }
-}
diff --git a/java/idea-ui/src/com/intellij/ide/util/projectWizard/SdkSettingsStep.java b/java/idea-ui/src/com/intellij/ide/util/projectWizard/SdkSettingsStep.java
index 4e42026..9acbbd5 100644
--- a/java/idea-ui/src/com/intellij/ide/util/projectWizard/SdkSettingsStep.java
+++ b/java/idea-ui/src/com/intellij/ide/util/projectWizard/SdkSettingsStep.java
@@ -17,8 +17,12 @@
import com.intellij.CommonBundle;
import com.intellij.ide.IdeBundle;
+import com.intellij.ide.util.PropertiesComponent;
+import com.intellij.openapi.module.ModuleType;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.project.ProjectManager;
+import com.intellij.openapi.projectRoots.ProjectJdkTable;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.projectRoots.SdkTypeId;
import com.intellij.openapi.roots.ProjectRootManager;
@@ -31,6 +35,8 @@
import javax.swing.*;
import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
/**
* @author Dmitry Avdeev
@@ -47,7 +53,9 @@
@NotNull Condition<SdkTypeId> sdkFilter) {
this(settingsStep.getContext(), moduleBuilder, sdkFilter);
- settingsStep.addSettingsField(getSdkFieldLabel(settingsStep.getContext().getProject()), myJdkPanel);
+ if (!isEmpty()) {
+ settingsStep.addSettingsField(getSdkFieldLabel(settingsStep.getContext().getProject()), myJdkPanel);
+ }
}
public SdkSettingsStep(WizardContext context,
@@ -60,12 +68,60 @@
Project project = myWizardContext.getProject();
myModel.reset(project);
- myJdkComboBox = JdkComboBox.createSdkComboBox(moduleBuilder, sdkFilter, project, myModel);
+ myJdkComboBox = new JdkComboBox(myModel, sdkFilter);
myJdkPanel = new JPanel(new BorderLayout(4, 0));
+
+ final PropertiesComponent component = project == null ? PropertiesComponent.getInstance() : PropertiesComponent.getInstance(project);
+ ModuleType moduleType = moduleBuilder.getModuleType();
+ final String selectedJdkProperty = "jdk.selected." + (moduleType == null ? "" : moduleType.getId());
+ myJdkComboBox.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ Sdk jdk = myJdkComboBox.getSelectedJdk();
+ if (jdk != null) {
+ component.setValue(selectedJdkProperty, jdk.getName());
+ }
+ }
+ });
+
+ if (project != null) {
+ Sdk sdk = ProjectRootManager.getInstance(project).getProjectSdk();
+ if (sdk != null && moduleBuilder.isSuitableSdkType(sdk.getSdkType())) {
+ // use project SDK
+ return;
+ }
+ }
+ else {
+ // set default project SDK
+ Project defaultProject = ProjectManager.getInstance().getDefaultProject();
+ Sdk sdk = ProjectRootManager.getInstance(defaultProject).getProjectSdk();
+ if (sdk != null && sdkFilter.value(sdk.getSdkType())) {
+ myJdkComboBox.setSelectedJdk(sdk);
+ }
+ }
+
+ String value = component.getValue(selectedJdkProperty);
+ if (value != null) {
+ Sdk jdk = ProjectJdkTable.getInstance().findJdk(value);
+ if (jdk != null) {
+ myJdkComboBox.setSelectedJdk(jdk);
+ }
+ }
+
+ JButton button = new JButton("Ne\u001Bw...");
+ myJdkComboBox.setSetupButton(button, project, myModel,
+ project == null ? new JdkComboBox.NoneJdkComboBoxItem() : new JdkComboBox.ProjectJdkComboBoxItem(),
+ null,
+ false);
+
myJdkPanel.add(myJdkComboBox);
myJdkPanel.add(myJdkComboBox.getSetUpButton(), BorderLayout.EAST);
}
+ public boolean isEmpty() {
+ return myJdkPanel.getComponentCount() == 0;
+ }
+
@NotNull
protected String getSdkFieldLabel(@Nullable Project project) {
return (project == null ? "Project" : "Module") + " \u001BSDK:";
diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/JdkComboBox.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/JdkComboBox.java
index 8a8a554..43344ae 100644
--- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/JdkComboBox.java
+++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/JdkComboBox.java
@@ -16,19 +16,13 @@
package com.intellij.openapi.roots.ui.configuration;
import com.intellij.ide.DataManager;
-import com.intellij.ide.util.PropertiesComponent;
-import com.intellij.ide.util.projectWizard.ModuleBuilder;
import com.intellij.ide.util.projectWizard.ProjectJdkListRenderer;
import com.intellij.openapi.actionSystem.*;
-import com.intellij.openapi.module.ModuleType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectBundle;
-import com.intellij.openapi.project.ProjectManager;
-import com.intellij.openapi.projectRoots.ProjectJdkTable;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.projectRoots.SdkType;
import com.intellij.openapi.projectRoots.SdkTypeId;
-import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.roots.ui.configuration.projectRoot.JdkListConfigurable;
import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel;
import com.intellij.openapi.ui.ComboBoxWithWidePopup;
@@ -92,7 +86,7 @@
else if (value instanceof ProjectJdkComboBoxItem) {
final Sdk jdk = jdkModel.getProjectSdk();
if (jdk != null) {
- setIcon(((SdkType) jdk.getSdkType()).getIcon());
+ setIcon(((SdkType)jdk.getSdkType()).getIcon());
append(ProjectBundle.message("project.roots.project.jdk.inherited"), SimpleTextAttributes.REGULAR_ATTRIBUTES);
append(" (" + jdk.getName() + ")", SimpleTextAttributes.GRAYED_ATTRIBUTES);
}
@@ -110,57 +104,6 @@
});
}
- public static JdkComboBox createSdkComboBox(ModuleBuilder moduleBuilder,
- Condition<SdkTypeId> sdkFilter,
- Project project,
- ProjectSdksModel model) {
- final JdkComboBox comboBox = new JdkComboBox(model, sdkFilter);
-
- final PropertiesComponent component = project == null ? PropertiesComponent.getInstance() : PropertiesComponent.getInstance(project);
- ModuleType moduleType = moduleBuilder.getModuleType();
- final String selectedJdkProperty = "jdk.selected." + (moduleType == null ? "" : moduleType.getId());
- comboBox.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- Sdk jdk = comboBox.getSelectedJdk();
- if (jdk != null) {
- component.setValue(selectedJdkProperty, jdk.getName());
- }
- }
- });
-
- if (project != null) {
- Sdk sdk = ProjectRootManager.getInstance(project).getProjectSdk();
- if (sdk != null && moduleBuilder.isSuitableSdkType(sdk.getSdkType())) {
- // use project SDK
- return null;
- }
- }
- else {
- // set default project SDK
- Project defaultProject = ProjectManager.getInstance().getDefaultProject();
- Sdk sdk = ProjectRootManager.getInstance(defaultProject).getProjectSdk();
- if (sdk != null && sdkFilter.value(sdk.getSdkType())) {
- comboBox.setSelectedJdk(sdk);
- }
- }
-
- String value = component.getValue(selectedJdkProperty);
- if (value != null) {
- Sdk jdk = ProjectJdkTable.getInstance().findJdk(value);
- if (jdk != null) {
- comboBox.setSelectedJdk(jdk);
- }
- }
-
- JButton button = new JButton("Ne\u001Bw...");
- comboBox.setSetupButton(button, project, model,
- project == null ? new NoneJdkComboBoxItem() : new ProjectJdkComboBoxItem(),
- null,
- false);
- return comboBox;
- }
-
@Override
public Dimension getPreferredSize() {
final Rectangle rec = ScreenUtil.getScreenRectangle(0, 0);
diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/AddLibraryDependencyAction.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/AddLibraryDependencyAction.java
index f280814..a671153 100644
--- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/AddLibraryDependencyAction.java
+++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/classpath/AddLibraryDependencyAction.java
@@ -15,6 +15,7 @@
*/
package com.intellij.openapi.roots.ui.configuration.classpath;
+import com.intellij.facet.impl.ProjectFacetsConfigurator;
import com.intellij.openapi.project.ProjectBundle;
import com.intellij.openapi.roots.*;
import com.intellij.openapi.roots.libraries.Library;
@@ -72,7 +73,7 @@
}
private boolean hasLibraries() {
- final Predicate<Library> condition = LibraryEditingUtil.getNotAddedLibrariesCondition(myClasspathPanel.getRootModel());
+ final Predicate<Library> condition = getNotAddedSuitableLibrariesCondition();
for (LibraryTable table : ChooseLibrariesFromTablesDialog.getLibraryTables(myClasspathPanel.getProject(), true)) {
final LibrariesModifiableModel model = myContext.myLevel2Providers.get(table.getTableLevel());
if (model != null) {
@@ -86,6 +87,11 @@
return false;
}
+ private Predicate<Library> getNotAddedSuitableLibrariesCondition() {
+ ProjectFacetsConfigurator facetsConfigurator = myContext.getModulesConfigurator().getFacetsConfigurator();
+ return LibraryEditingUtil.getNotAddedSuitableLibrariesCondition(myClasspathPanel.getRootModel(), facetsConfigurator);
+ }
+
@Override
@Nullable
protected ClasspathTableItem<?> createTableItem(final Library item) {
@@ -125,9 +131,8 @@
@Override
@NotNull
public List<Library> chooseElements() {
- final Predicate<Library> condition = LibraryEditingUtil.getNotAddedLibrariesCondition(myClasspathPanel.getRootModel());
ProjectStructureChooseLibrariesDialog dialog = new ProjectStructureChooseLibrariesDialog(myClasspathPanel, myContext,
- condition);
+ getNotAddedSuitableLibrariesCondition());
dialog.show();
return dialog.getSelectedLibraries();
}
diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/LibraryEditingUtil.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/LibraryEditingUtil.java
index 2c5374a..5be63aa 100644
--- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/LibraryEditingUtil.java
+++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/LibraryEditingUtil.java
@@ -28,6 +28,7 @@
import com.intellij.openapi.roots.impl.libraries.LibraryImpl;
import com.intellij.openapi.roots.impl.libraries.LibraryTableImplUtil;
import com.intellij.openapi.roots.libraries.*;
+import com.intellij.openapi.roots.ui.configuration.FacetsProvider;
import com.intellij.openapi.roots.ui.configuration.classpath.ClasspathPanel;
import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesModifiableModel;
import com.intellij.openapi.roots.ui.configuration.projectRoot.ModuleStructureConfigurable;
@@ -81,7 +82,7 @@
return candidateName;
}
- public static Predicate<Library> getNotAddedLibrariesCondition(final ModuleRootModel rootModel) {
+ public static Predicate<Library> getNotAddedSuitableLibrariesCondition(final ModuleRootModel rootModel, final FacetsProvider facetsProvider) {
final OrderEntry[] orderEntries = rootModel.getOrderEntries();
final Set<Library> result = new HashSet<Library>(orderEntries.length);
for (OrderEntry orderEntry : orderEntries) {
@@ -101,6 +102,13 @@
final Library source = ((LibraryImpl)library).getSource();
if (source != null && result.contains(source)) return false;
}
+ PersistentLibraryKind<?> kind = ((LibraryEx)library).getKind();
+ if (kind != null) {
+ LibraryType type = LibraryType.findByKind(kind);
+ if (type != null && !type.isSuitableModule(rootModel.getModule(), facetsProvider)) {
+ return false;
+ }
+ }
return true;
}
};
@@ -200,7 +208,7 @@
if (library != null) {
final ModuleRootModel rootModel = rootConfigurable.getContext().getModulesConfigurator().getRootModel(module);
- if (!getNotAddedLibrariesCondition(rootModel).apply(library)) {
+ if (!getNotAddedSuitableLibrariesCondition(rootModel, rootConfigurable.getFacetConfigurator()).apply(library)) {
continue;
}
}
diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/CreateNewLibraryAction.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/CreateNewLibraryAction.java
index ff1b722..42861a4 100644
--- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/CreateNewLibraryAction.java
+++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/CreateNewLibraryAction.java
@@ -116,7 +116,7 @@
public static AnAction[] createActionOrGroup(@NotNull String text, @NotNull BaseLibrariesConfigurable librariesConfigurable, final @NotNull Project project) {
final LibraryType<?>[] extensions = LibraryType.EP_NAME.getExtensions();
List<LibraryType<?>> suitableTypes = new ArrayList<LibraryType<?>>();
- if (librariesConfigurable instanceof ProjectLibrariesConfigurable) {
+ if (librariesConfigurable instanceof ProjectLibrariesConfigurable || !project.isDefault()) {
final ModuleStructureConfigurable configurable = ModuleStructureConfigurable.getInstance(project);
for (LibraryType<?> extension : extensions) {
if (!LibraryEditingUtil.getSuitableModules(configurable, extension.getKind(), null).isEmpty()) {
diff --git a/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java b/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java
index f62333c..dd30f52 100644
--- a/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java
+++ b/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java
@@ -55,8 +55,6 @@
public class RemoteTemplatesFactory extends ProjectTemplatesFactory {
private static final String URL = "http://download.jetbrains.com/idea/project_templates/";
- public static final String SAMPLES_GALLERY = "Samples Gallery";
- private static final Namespace NAMESPACE = Namespace.getNamespace("http://www.jetbrains.com/projectTemplates");
public static final String INPUT_FIELD = "input-field";
public static final String TEMPLATE = "template";
@@ -113,20 +111,12 @@
@SuppressWarnings("unchecked")
public static MultiMap<String, ArchivedProjectTemplate> createFromText(String text) throws IOException, JDOMException {
- Element rootElement = JDOMUtil.loadDocument(text).getRootElement();
- List<Element> groups = rootElement.getChildren("group", NAMESPACE);
MultiMap<String, ArchivedProjectTemplate> map = new MultiMap<String, ArchivedProjectTemplate>();
- if (groups.isEmpty()) { // sample gallery by default
- map.put(SAMPLES_GALLERY, createGroupTemplates(rootElement, Namespace.NO_NAMESPACE));
+ Element rootElement = JDOMUtil.loadDocument(text).getRootElement();
+ List<ArchivedProjectTemplate> templates = createGroupTemplates(rootElement, Namespace.NO_NAMESPACE);
+ for (ArchivedProjectTemplate template : templates) {
+ map.putValue(template.getCategory(), template);
}
- else {
- for (Element group : groups) {
- if (checkRequiredPlugins(group, NAMESPACE)) {
- map.put(group.getChildText("name", NAMESPACE), createGroupTemplates(group, NAMESPACE));
- }
- }
- }
-
return map;
}
diff --git a/java/idea-ui/src/com/intellij/util/descriptors/impl/ConfigFileContainerImpl.java b/java/idea-ui/src/com/intellij/util/descriptors/impl/ConfigFileContainerImpl.java
index 1a394ba..231e61a 100644
--- a/java/idea-ui/src/com/intellij/util/descriptors/impl/ConfigFileContainerImpl.java
+++ b/java/idea-ui/src/com/intellij/util/descriptors/impl/ConfigFileContainerImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@
import com.intellij.openapi.vfs.*;
import com.intellij.util.EventDispatcher;
import com.intellij.util.descriptors.*;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
@@ -49,11 +50,11 @@
myMetaDataProvider = descriptorMetaDataProvider;
myProject = project;
VirtualFileManager.getInstance().addVirtualFileListener(new VirtualFileAdapter() {
- public void propertyChanged(final VirtualFilePropertyEvent event) {
+ public void propertyChanged(@NotNull final VirtualFilePropertyEvent event) {
fileChanged(event.getFile());
}
- public void fileMoved(final VirtualFileMoveEvent event) {
+ public void fileMoved(@NotNull final VirtualFileMoveEvent event) {
fileChanged(event.getFile());
}
}, this);
diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java
index 163ca42..a7de8c0 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java
@@ -30,7 +30,6 @@
import com.intellij.codeInsight.daemon.impl.quickfix.QuickFixAction;
import com.intellij.codeInsight.intention.QuickFixFactory;
import com.intellij.ide.highlighter.JavaFileType;
-import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.openapi.project.Project;
@@ -229,37 +228,34 @@
@Nullable
static HighlightInfo checkPublicClassInRightFile(PsiClass aClass) {
- // most test case classes are located in wrong files
- if (ApplicationManager.getApplication().isUnitTestMode()) return null;
-
PsiFile containingFile = aClass.getContainingFile();
if (aClass.getParent() != containingFile || !aClass.hasModifierProperty(PsiModifier.PUBLIC) || !(containingFile instanceof PsiJavaFile)) return null;
PsiJavaFile file = (PsiJavaFile)containingFile;
VirtualFile virtualFile = file.getVirtualFile();
- HighlightInfo errorResult = null;
- if (virtualFile != null && !aClass.getName().equals(virtualFile.getNameWithoutExtension())) {
- String message = JavaErrorMessages.message("public.class.should.be.named.after.file", aClass.getName());
- TextRange range = HighlightNamesUtil.getClassDeclarationTextRange(aClass);
- errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).
- range(aClass, range.getStartOffset(), range.getEndOffset()).
- descriptionAndTooltip(message).create();
- PsiModifierList psiModifierList = aClass.getModifierList();
- QuickFixAction.registerQuickFixAction(errorResult,
- QUICK_FIX_FACTORY.createModifierListFix(psiModifierList, PsiModifier.PUBLIC, false, false));
- PsiClass[] classes = file.getClasses();
- if (classes.length > 1) {
- QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createMoveClassToSeparateFileFix(aClass));
- }
- for (PsiClass otherClass : classes) {
- if (!otherClass.getManager().areElementsEquivalent(otherClass, aClass) &&
- otherClass.hasModifierProperty(PsiModifier.PUBLIC) &&
- otherClass.getName().equals(virtualFile.getNameWithoutExtension())) {
- return errorResult;
- }
- }
- QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createRenameFileFix(aClass.getName() + JavaFileType.DOT_DEFAULT_EXTENSION));
- QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createRenameElementFix(aClass));
+ if (virtualFile == null || aClass.getName().equals(virtualFile.getNameWithoutExtension())) {
+ return null;
}
+ String message = JavaErrorMessages.message("public.class.should.be.named.after.file", aClass.getName());
+ TextRange range = HighlightNamesUtil.getClassDeclarationTextRange(aClass);
+ HighlightInfo errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).
+ range(aClass, range.getStartOffset(), range.getEndOffset()).
+ descriptionAndTooltip(message).create();
+ PsiModifierList psiModifierList = aClass.getModifierList();
+ QuickFixAction.registerQuickFixAction(errorResult,
+ QUICK_FIX_FACTORY.createModifierListFix(psiModifierList, PsiModifier.PUBLIC, false, false));
+ PsiClass[] classes = file.getClasses();
+ if (classes.length > 1) {
+ QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createMoveClassToSeparateFileFix(aClass));
+ }
+ for (PsiClass otherClass : classes) {
+ if (!otherClass.getManager().areElementsEquivalent(otherClass, aClass) &&
+ otherClass.hasModifierProperty(PsiModifier.PUBLIC) &&
+ otherClass.getName().equals(virtualFile.getNameWithoutExtension())) {
+ return errorResult;
+ }
+ }
+ QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createRenameFileFix(aClass.getName() + JavaFileType.DOT_DEFAULT_EXTENSION));
+ QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createRenameElementFix(aClass));
return errorResult;
}
@@ -291,7 +287,7 @@
}
@Nullable
- private static HighlightInfo checkStaticFieldDeclarationInInnerClass(PsiKeyword keyword) {
+ private static HighlightInfo checkStaticFieldDeclarationInInnerClass(@NotNull PsiKeyword keyword) {
if (getEnclosingStaticClass(keyword, PsiField.class) == null) {
return null;
}
@@ -343,7 +339,7 @@
return result;
}
- private static PsiElement getEnclosingStaticClass(PsiKeyword keyword, Class<?> parentClass) {
+ private static PsiElement getEnclosingStaticClass(@NotNull PsiKeyword keyword, @NotNull Class<?> parentClass) {
return new PsiMatcherImpl(keyword)
.dot(PsiMatchers.hasText(PsiModifier.STATIC))
.parent(PsiMatchers.hasClass(PsiModifierList.class))
diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightControlFlowUtil.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightControlFlowUtil.java
index 35f9416..0315904 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightControlFlowUtil.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightControlFlowUtil.java
@@ -675,7 +675,7 @@
return null;
}
- private static boolean isEffectivelyFinal(PsiVariable variable, PsiElement scope, PsiJavaCodeReferenceElement context) {
+ public static boolean isEffectivelyFinal(PsiVariable variable, PsiElement scope, PsiJavaCodeReferenceElement context) {
boolean effectivelyFinal;
if (variable instanceof PsiParameter) {
effectivelyFinal = notAccessedForWriting(variable, new LocalSearchScope(((PsiParameter)variable).getDeclarationScope()));
diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java
index 7c4e8fa..5492bb5 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java
@@ -118,8 +118,8 @@
ourMethodIncompatibleModifiers.put(PsiModifier.PRIVATE, ContainerUtil.newTroveSet(PsiModifier.PACKAGE_LOCAL, PsiModifier.PUBLIC, PsiModifier.PROTECTED));
ourMethodIncompatibleModifiers.put(PsiModifier.PUBLIC, ContainerUtil.newTroveSet(PsiModifier.PACKAGE_LOCAL, PsiModifier.PRIVATE, PsiModifier.PROTECTED));
ourMethodIncompatibleModifiers.put(PsiModifier.PROTECTED, ContainerUtil.newTroveSet(PsiModifier.PACKAGE_LOCAL, PsiModifier.PUBLIC, PsiModifier.PRIVATE));
- ourMethodIncompatibleModifiers.put(PsiModifier.STATIC, ContainerUtil.newTroveSet(PsiModifier.ABSTRACT, PsiModifier.DEFAULT));
- ourMethodIncompatibleModifiers.put(PsiModifier.DEFAULT, ContainerUtil.newTroveSet(PsiModifier.ABSTRACT, PsiModifier.STATIC));
+ ourMethodIncompatibleModifiers.put(PsiModifier.STATIC, ContainerUtil.newTroveSet(PsiModifier.ABSTRACT, PsiModifier.DEFAULT, PsiModifier.FINAL));
+ ourMethodIncompatibleModifiers.put(PsiModifier.DEFAULT, ContainerUtil.newTroveSet(PsiModifier.ABSTRACT, PsiModifier.STATIC, PsiModifier.FINAL));
ourMethodIncompatibleModifiers.put(PsiModifier.SYNCHRONIZED, ContainerUtil.newTroveSet(PsiModifier.ABSTRACT));
ourMethodIncompatibleModifiers.put(PsiModifier.STRICTFP, ContainerUtil.newTroveSet(PsiModifier.ABSTRACT));
ourMethodIncompatibleModifiers.put(PsiModifier.FINAL, ContainerUtil.newTroveSet(PsiModifier.ABSTRACT));
@@ -165,6 +165,15 @@
continue;
}
}
+ if (modifier.equals(PsiModifier.STATIC) && incompatible.equals(PsiModifier.FINAL)) {
+ final PsiElement parent = modifierList.getParent();
+ if (parent instanceof PsiMethod) {
+ final PsiClass containingClass = ((PsiMethod)parent).getContainingClass();
+ if (containingClass == null || !containingClass.isInterface()) {
+ continue;
+ }
+ }
+ }
if (modifierList.hasModifierProperty(incompatible)) {
return incompatible;
}
@@ -2571,9 +2580,9 @@
}
@Nullable
- static HighlightInfo checkPackageAndClassConflict(@NotNull PsiJavaCodeReferenceElement ref) {
+ static HighlightInfo checkPackageAndClassConflict(@NotNull PsiJavaCodeReferenceElement ref, @NotNull PsiFile containingFile) {
if (ref.isQualified() && isInsidePackageStatement(ref)) {
- VirtualFile file = ref.getContainingFile().getVirtualFile();
+ VirtualFile file = containingFile.getVirtualFile();
if (file != null) {
Module module = ProjectFileIndex.SERVICE.getInstance(ref.getProject()).getModuleForFile(file);
if (module != null) {
diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java
index bf9f3e0..4e9d79f 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java
@@ -1108,7 +1108,7 @@
}
}
- if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkPackageAndClassConflict(ref));
+ if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkPackageAndClassConflict(ref, myFile));
return result;
}
diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/JavaHighlightUtil.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/JavaHighlightUtil.java
index 864798f..722ec35 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/JavaHighlightUtil.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/JavaHighlightUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,6 +15,7 @@
*/
package com.intellij.codeInsight.daemon.impl.analysis;
+import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.intellij.psi.util.*;
import org.jetbrains.annotations.NonNls;
@@ -26,8 +27,8 @@
public class JavaHighlightUtil {
public static boolean isSerializable(@NotNull PsiClass aClass) {
- PsiManager manager = aClass.getManager();
- PsiClass serializableClass = JavaPsiFacade.getInstance(manager.getProject()).findClass("java.io.Serializable", aClass.getResolveScope());
+ Project project = aClass.getManager().getProject();
+ PsiClass serializableClass = JavaPsiFacade.getInstance(project).findClass("java.io.Serializable", aClass.getResolveScope());
return serializableClass != null && aClass.isInheritor(serializableClass, true);
}
@@ -70,18 +71,13 @@
@NotNull
public static String formatType(@Nullable PsiType type) {
- if (type == null) return PsiKeyword.NULL;
- String text = type.getInternalCanonicalText();
- return text == null ? PsiKeyword.NULL : text;
+ return type == null ? PsiKeyword.NULL : type.getInternalCanonicalText();
}
@Nullable
- private static PsiType getArrayInitializerType(@NotNull final PsiArrayInitializerExpression element) {
- final PsiType typeCheckResult = sameType(element.getInitializers());
- if (typeCheckResult != null) {
- return typeCheckResult.createArrayType();
- }
- return null;
+ private static PsiType getArrayInitializerType(@NotNull PsiArrayInitializerExpression element) {
+ PsiType typeCheckResult = sameType(element.getInitializers());
+ return typeCheckResult != null ? typeCheckResult.createArrayType() : null;
}
@Nullable
diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/AnonymousCanBeLambdaInspection.java b/java/java-analysis-impl/src/com/intellij/codeInspection/AnonymousCanBeLambdaInspection.java
index 93e4951..ed34940 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInspection/AnonymousCanBeLambdaInspection.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/AnonymousCanBeLambdaInspection.java
@@ -17,6 +17,7 @@
import com.intellij.codeInsight.ChangeContextUtil;
import com.intellij.codeInsight.daemon.GroupNames;
+import com.intellij.codeInsight.daemon.impl.analysis.HighlightControlFlowUtil;
import com.intellij.codeInsight.intention.HighPriorityAction;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
@@ -25,14 +26,18 @@
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.*;
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
+import com.intellij.psi.controlFlow.AnalysisCanceledException;
+import com.intellij.psi.controlFlow.ControlFlow;
+import com.intellij.psi.controlFlow.ControlFlowUtil;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
import com.intellij.util.Function;
-import com.intellij.util.containers.HashSet;
+import com.intellij.util.containers.ContainerUtilRt;
import com.intellij.util.containers.hash.LinkedHashMap;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
+import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@@ -77,77 +82,24 @@
super.visitAnonymousClass(aClass);
if (PsiUtil.getLanguageLevel(aClass).isAtLeast(LanguageLevel.JDK_1_8)) {
final PsiClassType baseClassType = aClass.getBaseClassType();
- final String functionalInterfaceErrorMessage = LambdaHighlightingUtil.checkInterfaceFunctional(baseClassType);
- if (functionalInterfaceErrorMessage == null) {
- final PsiMethod[] methods = aClass.getMethods();
- if (methods.length == 1 && aClass.getFields().length == 0) {
- final PsiCodeBlock body = methods[0].getBody();
- if (body != null) {
- final boolean [] bodyContainsForbiddenRefs = new boolean[1];
- final Set<PsiLocalVariable> locals = new HashSet<PsiLocalVariable>();
- body.accept(new JavaRecursiveElementWalkingVisitor() {
- @Override
- public void visitMethodCallExpression(PsiMethodCallExpression methodCallExpression) {
- if (bodyContainsForbiddenRefs[0]) return;
- super.visitMethodCallExpression(methodCallExpression);
- final PsiMethod psiMethod = methodCallExpression.resolveMethod();
- if (psiMethod == methods[0] ||
- psiMethod != null &&
- !methodCallExpression.getMethodExpression().isQualified() &&
- "getClass".equals(psiMethod.getName()) &&
- psiMethod.getParameterList().getParametersCount() == 0) {
- bodyContainsForbiddenRefs[0] = true;
+ if (LambdaUtil.isFunctionalType(baseClassType)) {
+ final PsiElement lambdaContext = aClass.getParent().getParent();
+ if (LambdaUtil.isValidLambdaContext(lambdaContext) || !(lambdaContext instanceof PsiExpressionStatement)) {
+ final PsiMethod[] methods = aClass.getMethods();
+ if (methods.length == 1 && aClass.getFields().length == 0) {
+ final PsiCodeBlock body = methods[0].getBody();
+ if (body != null) {
+ final ForbiddenRefsChecker checker = new ForbiddenRefsChecker(methods[0], aClass);
+ body.accept(checker);
+ if (!checker.hasForbiddenRefs()) {
+ PsiResolveHelper helper = PsiResolveHelper.SERVICE.getInstance(body.getProject());
+ for (PsiLocalVariable local : checker.getLocals()) {
+ final String localName = local.getName();
+ if (localName != null && helper.resolveReferencedVariable(localName, aClass) != null) return;
}
+ holder.registerProblem(aClass.getBaseClassReference(), "Anonymous #ref #loc can be replaced with lambda",
+ ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new ReplaceWithLambdaFix());
}
-
- @Override
- public void visitThisExpression(PsiThisExpression expression) {
- if (bodyContainsForbiddenRefs[0]) return;
- if (expression.getQualifier() == null) {
- bodyContainsForbiddenRefs[0] = true;
- }
- }
-
- @Override
- public void visitSuperExpression(PsiSuperExpression expression) {
- if (bodyContainsForbiddenRefs[0]) return;
- if (expression.getQualifier() == null) {
- bodyContainsForbiddenRefs[0] = true;
- }
- }
-
- @Override
- public void visitLocalVariable(PsiLocalVariable variable) {
- if (bodyContainsForbiddenRefs[0]) return;
- super.visitLocalVariable(variable);
- locals.add(variable);
- }
-
- @Override
- public void visitReferenceExpression(PsiReferenceExpression expression) {
- if (bodyContainsForbiddenRefs[0]) return;
- super.visitReferenceExpression(expression);
- if (!(expression.getParent() instanceof PsiMethodCallExpression)) {
- final PsiField field = PsiTreeUtil.getParentOfType(expression, PsiField.class);
- if (field != null) {
- final PsiElement resolved = expression.resolve();
- if (resolved instanceof PsiField &&
- !((PsiField)resolved).hasInitializer() &&
- ((PsiField)resolved).getContainingClass() == field.getContainingClass()) {
- bodyContainsForbiddenRefs[0] = true;
- }
- }
- }
- }
- });
- if (!bodyContainsForbiddenRefs[0]) {
- PsiResolveHelper helper = PsiResolveHelper.SERVICE.getInstance(body.getProject());
- for (PsiLocalVariable local : locals) {
- final String localName = local.getName();
- if (localName != null && helper.resolveReferencedVariable(localName, aClass) != null) return;
- }
- holder.registerProblem(aClass.getBaseClassReference(), "Anonymous #ref #loc can be replaced with lambda",
- ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new ReplaceWithLambdaFix());
}
}
}
@@ -288,9 +240,7 @@
}
private static boolean isInferred(PsiLambdaExpression lambdaExpression, PsiType interfaceType) {
- return interfaceType == null || !LambdaUtil.isLambdaFullyInferred(lambdaExpression, interfaceType) || LambdaHighlightingUtil
- .checkInterfaceFunctional(
- interfaceType) != null;
+ return interfaceType == null || !LambdaUtil.isLambdaFullyInferred(lambdaExpression, interfaceType) || !LambdaUtil.isFunctionalType(interfaceType);
}
private static String composeLambdaText(PsiMethod method, final boolean appendType) {
@@ -330,4 +280,110 @@
return parameterType + parameterName;
}
}
+
+ private static class ForbiddenRefsChecker extends JavaRecursiveElementWalkingVisitor {
+ private boolean myBodyContainsForbiddenRefs;
+ private final Set<PsiLocalVariable> myLocals = ContainerUtilRt.newHashSet(5);
+
+ private final PsiMethod myMethod;
+ private final PsiAnonymousClass myAnonymClass;
+
+ public ForbiddenRefsChecker(PsiMethod method,
+ PsiAnonymousClass aClass) {
+ myMethod = method;
+ myAnonymClass = aClass;
+ }
+
+ @Override
+ public void visitMethodCallExpression(PsiMethodCallExpression methodCallExpression) {
+ if (myBodyContainsForbiddenRefs) return;
+
+ super.visitMethodCallExpression(methodCallExpression);
+ final PsiMethod psiMethod = methodCallExpression.resolveMethod();
+ if (psiMethod == myMethod ||
+ psiMethod != null &&
+ !methodCallExpression.getMethodExpression().isQualified() &&
+ "getClass".equals(psiMethod.getName()) &&
+ psiMethod.getParameterList().getParametersCount() == 0) {
+ myBodyContainsForbiddenRefs = true;
+ }
+ }
+
+ @Override
+ public void visitThisExpression(PsiThisExpression expression) {
+ if (myBodyContainsForbiddenRefs) return;
+
+ if (expression.getQualifier() == null) {
+ myBodyContainsForbiddenRefs = true;
+ }
+ }
+
+ @Override
+ public void visitSuperExpression(PsiSuperExpression expression) {
+ if (myBodyContainsForbiddenRefs) return;
+
+ if (expression.getQualifier() == null) {
+ myBodyContainsForbiddenRefs = true;
+ }
+ }
+
+ @Override
+ public void visitLocalVariable(PsiLocalVariable variable) {
+ if (myBodyContainsForbiddenRefs) return;
+
+ super.visitLocalVariable(variable);
+ myLocals.add(variable);
+ }
+
+ @Override
+ public void visitReferenceExpression(PsiReferenceExpression expression) {
+ if (myBodyContainsForbiddenRefs) return;
+
+ super.visitReferenceExpression(expression);
+ if (!(expression.getParent() instanceof PsiMethodCallExpression)) {
+ final PsiField field = PsiTreeUtil.getParentOfType(expression, PsiField.class);
+ if (field != null) {
+ final PsiElement resolved = expression.resolve();
+ if (resolved instanceof PsiField && ((PsiField)resolved).getContainingClass() == field.getContainingClass()) {
+ final PsiExpression initializer = ((PsiField)resolved).getInitializer();
+ if (initializer == null ||
+ initializer.getTextOffset() > myAnonymClass.getTextOffset() && !((PsiField)resolved).hasModifierProperty(PsiModifier.STATIC)) {
+ myBodyContainsForbiddenRefs = true;
+ }
+ }
+ } else {
+ final PsiMethod method = PsiTreeUtil.getParentOfType(myAnonymClass, PsiMethod.class);
+ if (method != null && method.isConstructor()) {
+ final PsiElement resolved = expression.resolve();
+ if (resolved instanceof PsiField &&
+ ((PsiField)resolved).hasModifierProperty(PsiModifier.FINAL) &&
+ ((PsiField)resolved).getContainingClass() == method.getContainingClass()) {
+ try {
+ final PsiCodeBlock constructorBody = method.getBody();
+ if (constructorBody != null) {
+ final ControlFlow flow = HighlightControlFlowUtil.getControlFlowNoConstantEvaluate(constructorBody);
+ final int startOffset = flow.getStartOffset(myAnonymClass);
+ final Collection<PsiVariable> writtenVariables = ControlFlowUtil.getWrittenVariables(flow, 0, startOffset, false);
+ if (!writtenVariables.contains(resolved)) {
+ myBodyContainsForbiddenRefs = true;
+ }
+ }
+ }
+ catch (AnalysisCanceledException e) {
+ myBodyContainsForbiddenRefs = true;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public boolean hasForbiddenRefs() {
+ return myBodyContainsForbiddenRefs;
+ }
+
+ public Set<PsiLocalVariable> getLocals() {
+ return myLocals;
+ }
+ }
}
diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/AnonymousCanBeMethodReferenceInspection.java b/java/java-analysis-impl/src/com/intellij/codeInspection/AnonymousCanBeMethodReferenceInspection.java
index 558c3c0..6ad6d22 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInspection/AnonymousCanBeMethodReferenceInspection.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/AnonymousCanBeMethodReferenceInspection.java
@@ -67,8 +67,7 @@
super.visitAnonymousClass(aClass);
if (PsiUtil.getLanguageLevel(aClass).isAtLeast(LanguageLevel.JDK_1_8)) {
final PsiClassType baseClassType = aClass.getBaseClassType();
- final String functionalInterfaceErrorMessage = LambdaHighlightingUtil.checkInterfaceFunctional(baseClassType);
- if (functionalInterfaceErrorMessage == null) {
+ if (LambdaUtil.isFunctionalType(baseClassType)) {
final PsiMethod[] methods = aClass.getMethods();
if (methods.length == 1 && aClass.getFields().length == 0) {
final PsiCodeBlock body = methods[0].getBody();
diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/StreamApiMigrationInspection.java b/java/java-analysis-impl/src/com/intellij/codeInspection/StreamApiMigrationInspection.java
new file mode 100644
index 0000000..8101d16
--- /dev/null
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/StreamApiMigrationInspection.java
@@ -0,0 +1,206 @@
+/*
+ * Copyright 2000-2014 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.codeInsight.daemon.GroupNames;
+import com.intellij.codeInsight.daemon.impl.analysis.HighlightControlFlowUtil;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.project.Project;
+import com.intellij.pom.java.LanguageLevel;
+import com.intellij.psi.*;
+import com.intellij.psi.controlFlow.*;
+import com.intellij.psi.util.InheritanceUtil;
+import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.psi.util.PsiUtil;
+import com.intellij.util.containers.IntArrayList;
+import org.jetbrains.annotations.Nls;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Collection;
+
+/**
+ * User: anna
+ */
+public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTool {
+ private static final Logger LOG = Logger.getInstance("#" + StreamApiMigrationInspection.class.getName());
+
+ @Nls
+ @NotNull
+ @Override
+ public String getGroupDisplayName() {
+ return GroupNames.LANGUAGE_LEVEL_SPECIFIC_GROUP_NAME;
+ }
+
+ @Nls
+ @NotNull
+ @Override
+ public String getDisplayName() {
+ return "foreach loop can be collapsed with stream api";
+ }
+
+ @Override
+ public boolean isEnabledByDefault() {
+ return true;
+ }
+
+ @NotNull
+ @Override
+ public String getShortName() {
+ return "Convert2streamapi";
+ }
+
+ @NotNull
+ @Override
+ public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
+ return new JavaElementVisitor() {
+ @Override
+ public void visitForeachStatement(PsiForeachStatement statement) {
+ super.visitForeachStatement(statement);
+ if (PsiUtil.getLanguageLevel(statement).isAtLeast(LanguageLevel.JDK_1_8)) {
+ final PsiExpression iteratedValue = statement.getIteratedValue();
+ final PsiStatement body = statement.getBody();
+ if (iteratedValue != null && body != null) {
+ final PsiType iteratedValueType = iteratedValue.getType();
+ if (InheritanceUtil.isInheritor(iteratedValueType, CommonClassNames.JAVA_LANG_ITERABLE)) {
+ final PsiClass iteratorClass = PsiUtil.resolveClassInType(iteratedValueType);
+ LOG.assertTrue(iteratorClass != null);
+ try {
+ final ControlFlow controlFlow = ControlFlowFactory.getInstance(holder.getProject())
+ .getControlFlow(body, LocalsOrMyInstanceFieldsControlFlowPolicy.getInstance());
+ int startOffset = controlFlow.getStartOffset(body);
+ int endOffset = controlFlow.getEndOffset(body);
+ final Collection<PsiStatement> exitPoints = ControlFlowUtil
+ .findExitPointsAndStatements(controlFlow, startOffset, endOffset, new IntArrayList(), PsiContinueStatement.class,
+ PsiBreakStatement.class, PsiReturnStatement.class, PsiThrowStatement.class);
+ if (exitPoints.isEmpty()) {
+
+ final boolean[] effectivelyFinal = new boolean[] {true};
+ body.accept(new JavaRecursiveElementWalkingVisitor() {
+ @Override
+ public void visitElement(PsiElement element) {
+ if (!effectivelyFinal[0]) return;
+ super.visitElement(element);
+ }
+
+ @Override
+ public void visitReferenceExpression(PsiReferenceExpression expression) {
+ if (!effectivelyFinal[0]) return;
+ super.visitReferenceExpression(expression);
+ final PsiElement resolve = expression.resolve();
+ if (resolve instanceof PsiVariable && !(resolve instanceof PsiField)) {
+ effectivelyFinal[0] = HighlightControlFlowUtil.isEffectivelyFinal((PsiVariable)resolve, body, expression);
+ }
+ }
+ });
+
+ if (effectivelyFinal[0] && !isTrivial(body, statement.getIterationParameter(), iteratedValueType)) {
+ holder.registerProblem(iteratedValue, "Can be replaced with foreach call",
+ ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new ReplaceWithForeachCallFix());
+ }
+ }
+ }
+ catch (AnalysisCanceledException ignored) {
+ }
+ }
+ }
+ }
+ }
+ };
+ }
+
+ private static boolean isTrivial(PsiStatement body, PsiParameter parameter, PsiType iteratedValueType) {
+ final PsiIfStatement ifStatement = extractIfStatement(body);
+ //stream
+ if (ifStatement != null && ifStatement.getElseBranch() == null && ifStatement.getThenBranch() != null &&
+ InheritanceUtil.isInheritor(iteratedValueType, CommonClassNames.JAVA_UTIL_COLLECTION)) {
+ return false;
+ }
+ //method reference
+ return LambdaCanBeMethodReferenceInspection.canBeMethodReferenceProblem(body instanceof PsiBlockStatement ? ((PsiBlockStatement)body).getCodeBlock() : body, new PsiParameter[] {parameter}, null) == null;
+ }
+
+ private static class ReplaceWithForeachCallFix implements LocalQuickFix {
+ @NotNull
+ @Override
+ public String getName() {
+ return getFamilyName();
+ }
+
+ @NotNull
+ @Override
+ public String getFamilyName() {
+ return "Replace with forEach";
+ }
+
+ @Override
+ public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
+ final PsiForeachStatement foreachStatement = PsiTreeUtil.getParentOfType(descriptor.getPsiElement(), PsiForeachStatement.class);
+ if (foreachStatement != null) {
+ PsiStatement body = foreachStatement.getBody();
+ final PsiExpression iteratedValue = foreachStatement.getIteratedValue();
+ if (body != null && iteratedValue != null) {
+ final PsiParameter parameter = foreachStatement.getIterationParameter();
+ final PsiIfStatement ifStmt = extractIfStatement(body);
+
+ String foreEachText = body.getText();
+ String iterated = iteratedValue.getText();
+ if (ifStmt != null && ifStmt.getElseBranch() == null) {
+ final PsiExpression condition = ifStmt.getCondition();
+ if (condition != null) {
+ final PsiStatement thenBranch = ifStmt.getThenBranch();
+ if (thenBranch != null && InheritanceUtil.isInheritor(iteratedValue.getType(), CommonClassNames.JAVA_UTIL_COLLECTION)) {
+ body = thenBranch;
+ foreEachText = thenBranch.getText();
+ iterated += ".stream().filter(" + parameter.getName() + " -> " + condition.getText() +")";
+ }
+ }
+ }
+
+ final PsiParameter[] parameters = {parameter};
+ final PsiCallExpression expression = LambdaCanBeMethodReferenceInspection.canBeMethodReferenceProblem(body instanceof PsiBlockStatement ? ((PsiBlockStatement)body).getCodeBlock() : body, parameters, null);
+ final String methodReferenceText = LambdaCanBeMethodReferenceInspection.createMethodReferenceText(expression, null, parameters);
+ final String lambdaText = parameter.getName() + " -> " + foreEachText;
+ final String codeBlock8 = methodReferenceText != null ? methodReferenceText : lambdaText;
+ PsiExpressionStatement callStatement = (PsiExpressionStatement)JavaPsiFacade.getElementFactory(project).createStatementFromText(iterated + ".forEach(" + codeBlock8 + ");", foreachStatement);
+
+ callStatement = (PsiExpressionStatement)foreachStatement.replace(callStatement);
+ final PsiExpressionList argumentList = ((PsiCallExpression)callStatement.getExpression()).getArgumentList();
+ LOG.assertTrue(argumentList != null, callStatement.getText());
+ final PsiExpression[] expressions = argumentList.getExpressions();
+ LOG.assertTrue(expressions.length == 1);
+
+ if (expressions[0] instanceof PsiLambdaExpression && ((PsiLambdaExpression)expressions[0]).getFunctionalInterfaceType() == null ||
+ expressions[0] instanceof PsiMethodReferenceExpression && ((PsiMethodReferenceExpression)expressions[0]).getFunctionalInterfaceType() == null) {
+ callStatement = (PsiExpressionStatement)callStatement.replace(JavaPsiFacade.getElementFactory(project).createStatementFromText(iterated + ".forEach((" + parameter.getText() + ") -> " + foreEachText + ");", callStatement));
+ }
+ }
+ }
+ }
+ }
+
+ public static PsiIfStatement extractIfStatement(PsiStatement body) {
+ PsiIfStatement ifStmt = null;
+ if (body instanceof PsiIfStatement) {
+ ifStmt = (PsiIfStatement)body;
+ } else if (body instanceof PsiBlockStatement) {
+ final PsiStatement[] statements = ((PsiBlockStatement)body).getCodeBlock().getStatements();
+ if (statements.length == 1 && statements[0] instanceof PsiIfStatement) {
+ ifStmt = (PsiIfStatement)statements[0];
+ }
+ }
+ return ifStmt;
+ }
+}
diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/nullable/NullableStuffInspectionBase.java b/java/java-analysis-impl/src/com/intellij/codeInspection/nullable/NullableStuffInspectionBase.java
index 0edaee4..38f8d46 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInspection/nullable/NullableStuffInspectionBase.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/nullable/NullableStuffInspectionBase.java
@@ -395,7 +395,7 @@
parameters[i].getNameIdentifier(); //be sure that corresponding tree element available
PsiAnnotation annotation = AnnotationUtil.findAnnotation(parameters[i], nullableManager.getNotNulls());
PsiElement psiElement = annotation;
- if (!annotation.isPhysical()) {
+ if (annotation == null || !annotation.isPhysical()) {
psiElement = parameters[i].getNameIdentifier();
if (psiElement == null) continue;
}
diff --git a/java/java-psi-api/src/com/intellij/psi/util/EnclosingLoopMatcherExpression.java b/java/java-analysis-impl/src/com/intellij/psi/util/EnclosingLoopMatcherExpression.java
similarity index 96%
rename from java/java-psi-api/src/com/intellij/psi/util/EnclosingLoopMatcherExpression.java
rename to java/java-analysis-impl/src/com/intellij/psi/util/EnclosingLoopMatcherExpression.java
index c1c70ce..b2f913d 100644
--- a/java/java-psi-api/src/com/intellij/psi/util/EnclosingLoopMatcherExpression.java
+++ b/java/java-analysis-impl/src/com/intellij/psi/util/EnclosingLoopMatcherExpression.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/java/java-psi-api/src/com/intellij/psi/util/EnclosingLoopOrSwitchMatcherExpression.java b/java/java-analysis-impl/src/com/intellij/psi/util/EnclosingLoopOrSwitchMatcherExpression.java
similarity index 96%
rename from java/java-psi-api/src/com/intellij/psi/util/EnclosingLoopOrSwitchMatcherExpression.java
rename to java/java-analysis-impl/src/com/intellij/psi/util/EnclosingLoopOrSwitchMatcherExpression.java
index c4d722b..52419c9 100644
--- a/java/java-psi-api/src/com/intellij/psi/util/EnclosingLoopOrSwitchMatcherExpression.java
+++ b/java/java-analysis-impl/src/com/intellij/psi/util/EnclosingLoopOrSwitchMatcherExpression.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/java/java-psi-api/src/com/intellij/psi/util/JavaMatchers.java b/java/java-analysis-impl/src/com/intellij/psi/util/JavaMatchers.java
similarity index 97%
rename from java/java-psi-api/src/com/intellij/psi/util/JavaMatchers.java
rename to java/java-analysis-impl/src/com/intellij/psi/util/JavaMatchers.java
index 4378141..9b1efff 100644
--- a/java/java-psi-api/src/com/intellij/psi/util/JavaMatchers.java
+++ b/java/java-analysis-impl/src/com/intellij/psi/util/JavaMatchers.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/java/java-analysis-impl/src/com/intellij/psi/util/PsiMatcher.java b/java/java-analysis-impl/src/com/intellij/psi/util/PsiMatcher.java
new file mode 100644
index 0000000..d86698b
--- /dev/null
+++ b/java/java-analysis-impl/src/com/intellij/psi/util/PsiMatcher.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2000-2014 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;
+
+public interface PsiMatcher {
+ PsiMatcher parent(PsiMatcherExpression e);
+ PsiMatcher firstChild(PsiMatcherExpression e);
+ PsiMatcher ancestor(PsiMatcherExpression e);
+ PsiMatcher descendant(PsiMatcherExpression e);
+ PsiMatcher dot(PsiMatcherExpression e);
+
+ PsiElement getElement();
+}
diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/AccessLevelProvider.java b/java/java-analysis-impl/src/com/intellij/psi/util/PsiMatcherExpression.java
similarity index 74%
copy from java/java-impl/src/com/intellij/ide/structureView/impl/java/AccessLevelProvider.java
copy to java/java-analysis-impl/src/com/intellij/psi/util/PsiMatcherExpression.java
index 1f153aa..0a49c24 100644
--- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/AccessLevelProvider.java
+++ b/java/java-analysis-impl/src/com/intellij/psi/util/PsiMatcherExpression.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,9 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.intellij.ide.structureView.impl.java;
+package com.intellij.psi.util;
-public interface AccessLevelProvider {
- int getAccessLevel();
- int getSubLevel();
+import com.intellij.psi.PsiElement;
+
+public interface PsiMatcherExpression {
+ Boolean match(PsiElement element);
}
diff --git a/java/java-analysis-impl/src/com/intellij/psi/util/PsiMatcherImpl.java b/java/java-analysis-impl/src/com/intellij/psi/util/PsiMatcherImpl.java
new file mode 100644
index 0000000..6c62daa
--- /dev/null
+++ b/java/java-analysis-impl/src/com/intellij/psi/util/PsiMatcherImpl.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2000-2014 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;
+
+public class PsiMatcherImpl implements PsiMatcher {
+ private PsiElement myElement;
+
+ public PsiMatcherImpl(PsiElement element) {
+ myElement = element;
+ }
+
+ @Override
+ public PsiMatcher parent(PsiMatcherExpression e) {
+ myElement = myElement.getParent();
+ if (myElement == null || e != null && e.match(myElement) != Boolean.TRUE) return NullPsiMatcherImpl.INSTANCE;
+ return this;
+ }
+
+ @Override
+ public PsiMatcher firstChild(PsiMatcherExpression e) {
+ final PsiElement[] children = myElement.getChildren();
+ for (PsiElement child : children) {
+ myElement = child;
+ if (e == null || e.match(myElement) == Boolean.TRUE) {
+ return this;
+ }
+ }
+ return NullPsiMatcherImpl.INSTANCE;
+ }
+
+ @Override
+ public PsiMatcher ancestor(PsiMatcherExpression e) {
+ while (myElement != null) {
+ Boolean res = e == null ? Boolean.TRUE : e.match(myElement);
+ if (res == Boolean.TRUE) break;
+ if (res == null) return NullPsiMatcherImpl.INSTANCE;
+ myElement = myElement.getParent();
+ }
+ if (myElement == null) return NullPsiMatcherImpl.INSTANCE;
+ return this;
+ }
+
+ @Override
+ public PsiMatcher descendant(PsiMatcherExpression e) {
+ final PsiElement[] children = myElement.getChildren();
+ for (PsiElement child : children) {
+ myElement = child;
+ final Boolean res = e == null ? Boolean.TRUE : e.match(myElement);
+ if (res == Boolean.TRUE) {
+ return this;
+ }
+ else if (res == Boolean.FALSE) {
+ final PsiMatcher grandChild = descendant(e);
+ if (grandChild != NullPsiMatcherImpl.INSTANCE) return grandChild;
+ }
+ }
+ return NullPsiMatcherImpl.INSTANCE;
+ }
+
+ @Override
+ public PsiMatcher dot(PsiMatcherExpression e) {
+ return e == null || e.match(myElement) == Boolean.TRUE ? this : NullPsiMatcherImpl.INSTANCE;
+ }
+
+
+ @Override
+ public PsiElement getElement() {
+ return myElement;
+ }
+
+ private static class NullPsiMatcherImpl implements PsiMatcher {
+ @Override
+ public PsiMatcher parent(PsiMatcherExpression e) {
+ return this;
+ }
+
+ @Override
+ public PsiMatcher firstChild(PsiMatcherExpression e) {
+ return this;
+ }
+
+ @Override
+ public PsiMatcher ancestor(PsiMatcherExpression e) {
+ return this;
+ }
+
+ @Override
+ public PsiMatcher descendant(PsiMatcherExpression e) {
+ return this;
+ }
+
+ @Override
+ public PsiMatcher dot(PsiMatcherExpression e) {
+ return this;
+ }
+
+ @Override
+ public PsiElement getElement() {
+ return null;
+ }
+
+ private static final NullPsiMatcherImpl INSTANCE = new NullPsiMatcherImpl();
+ }
+}
diff --git a/java/java-analysis-impl/src/com/intellij/psi/util/PsiMatchers.java b/java/java-analysis-impl/src/com/intellij/psi/util/PsiMatchers.java
new file mode 100644
index 0000000..4d97d99
--- /dev/null
+++ b/java/java-analysis-impl/src/com/intellij/psi/util/PsiMatchers.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @author max
+ */
+package com.intellij.psi.util;
+
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiNamedElement;
+import com.intellij.util.ArrayUtil;
+import org.jetbrains.annotations.NotNull;
+
+public class PsiMatchers {
+
+ private PsiMatchers() {
+ }
+
+ @NotNull
+ public static PsiMatcherExpression hasName(@NotNull final String name) {
+ return new PsiMatcherExpression() {
+ @Override
+ public Boolean match(PsiElement element) {
+ if (element instanceof PsiNamedElement && name.equals(((PsiNamedElement) element).getName())) return Boolean.TRUE;
+ return Boolean.FALSE;
+ }
+ };
+ }
+
+ @NotNull
+ public static PsiMatcherExpression hasText(@NotNull final String text) {
+ return new PsiMatcherExpression() {
+ @Override
+ public Boolean match(PsiElement element) {
+ if (element.getTextLength() != text.length()) return Boolean.FALSE;
+ return text.equals(element.getText());
+ }
+ };
+ }
+
+ @NotNull
+ public static PsiMatcherExpression hasText(@NotNull final String... texts) {
+ return new PsiMatcherExpression() {
+ @Override
+ public Boolean match(PsiElement element) {
+ String text = element.getText();
+ return ArrayUtil.find(texts, text) != -1;
+ }
+ };
+ }
+
+ @NotNull
+ public static PsiMatcherExpression hasClass(@NotNull final Class<?> aClass) {
+ return new PsiMatcherExpression() {
+ @Override
+ public Boolean match(PsiElement element) {
+ if (aClass.isAssignableFrom(element.getClass())) return Boolean.TRUE;
+ return Boolean.FALSE;
+ }
+ };
+ }
+
+ @NotNull
+ public static PsiMatcherExpression hasClass(@NotNull final Class... classes) {
+ return new PsiMatcherExpression() {
+ @Override
+ public Boolean match(PsiElement element) {
+ for (Class<?> aClass : classes) {
+ if (aClass.isAssignableFrom(element.getClass())) return Boolean.TRUE;
+ }
+ return Boolean.FALSE;
+ }
+ };
+ }
+}
diff --git a/java/java-impl/java-impl.iml b/java/java-impl/java-impl.iml
index 0e65b92..688a8d3 100644
--- a/java/java-impl/java-impl.iml
+++ b/java/java-impl/java-impl.iml
@@ -52,6 +52,7 @@
<orderEntry type="library" name="Xerces" level="project" />
<orderEntry type="library" name="Velocity" level="project" />
<orderEntry type="module" module-name="testFramework-java" scope="TEST" />
+ <orderEntry type="module" module-name="java-structure-view" exported="" />
</component>
<component name="copyright">
<Base>
diff --git a/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java b/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java
index 394d42a..8680943 100644
--- a/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java
+++ b/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -777,27 +777,27 @@
}
@Override
- public void contentsChanged(VirtualFileEvent event) {
+ public void contentsChanged(@NotNull VirtualFileEvent event) {
processEvent(event);
}
@Override
- public void fileCreated(VirtualFileEvent event) {
+ public void fileCreated(@NotNull VirtualFileEvent event) {
processEvent(event);
}
@Override
- public void fileDeleted(VirtualFileEvent event) {
+ public void fileDeleted(@NotNull VirtualFileEvent event) {
processEvent(event);
}
@Override
- public void fileMoved(VirtualFileMoveEvent event) {
+ public void fileMoved(@NotNull VirtualFileMoveEvent event) {
processEvent(event);
}
@Override
- public void fileCopied(VirtualFileCopyEvent event) {
+ public void fileCopied(@NotNull VirtualFileCopyEvent event) {
processEvent(event);
}
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/ExcludeFromCompletionLookupActionProvider.java b/java/java-impl/src/com/intellij/codeInsight/completion/ExcludeFromCompletionLookupActionProvider.java
index bc00fa2..ec7c5c5 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/ExcludeFromCompletionLookupActionProvider.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/ExcludeFromCompletionLookupActionProvider.java
@@ -32,7 +32,11 @@
public class ExcludeFromCompletionLookupActionProvider implements LookupActionProvider {
@Override
public void fillActions(LookupElement element, Lookup lookup, Consumer<LookupElementAction> consumer) {
- final Object o = element.getObject();
+ Object o = element.getObject();
+ if (o instanceof PsiClassObjectAccessExpression) {
+ o = PsiUtil.resolveClassInType(((PsiClassObjectAccessExpression)o).getOperand().getType());
+ }
+
if (o instanceof PsiClass) {
PsiClass clazz = (PsiClass)o;
addExcludes(consumer, clazz, clazz.getQualifiedName());
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 b17afb7..d645290 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionContributor.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionContributor.java
@@ -465,8 +465,10 @@
if (!(method instanceof PsiAnnotationMethod)) continue;
final String attrName = method.getName();
- for (PsiNameValuePair apair : existingPairs) {
- if (Comparing.equal(apair.getName(), attrName)) continue methods;
+ for (PsiNameValuePair existingAttr : existingPairs) {
+ if (PsiTreeUtil.isAncestor(existingAttr, insertedElement, false)) break;
+ if (Comparing.equal(existingAttr.getName(), attrName) ||
+ PsiAnnotation.DEFAULT_REFERENCED_METHOD_NAME.equals(attrName) && existingAttr.getName() == null) continue methods;
}
LookupElementBuilder element = LookupElementBuilder.createWithIcon(method).withInsertHandler(new InsertHandler<LookupElement>() {
@Override
@@ -474,6 +476,15 @@
final Editor editor = context.getEditor();
TailType.EQ.processTail(editor, editor.getCaretModel().getOffset());
context.setAddCompletionChar(false);
+
+ context.commitDocument();
+ PsiAnnotationParameterList paramList =
+ PsiTreeUtil.findElementOfClassAtOffset(context.getFile(), context.getStartOffset(), PsiAnnotationParameterList.class, false);
+ if (paramList != null && paramList.getAttributes().length > 0 && paramList.getAttributes()[0].getName() == null) {
+ int valueOffset = paramList.getAttributes()[0].getTextRange().getStartOffset();
+ context.getDocument().insertString(valueOffset, PsiAnnotation.DEFAULT_REFERENCED_METHOD_NAME);
+ TailType.EQ.processTail(editor, valueOffset + PsiAnnotation.DEFAULT_REFERENCED_METHOD_NAME.length());
+ }
}
});
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/LambdaCompletionProvider.java b/java/java-impl/src/com/intellij/codeInsight/completion/LambdaCompletionProvider.java
index 8073d1b..386c8a2 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/LambdaCompletionProvider.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/LambdaCompletionProvider.java
@@ -40,7 +40,7 @@
final ExpectedTypeInfo[] expectedTypes = JavaSmartCompletionContributor.getExpectedTypes(parameters);
for (ExpectedTypeInfo expectedType : expectedTypes) {
final PsiType defaultType = expectedType.getDefaultType();
- if (LambdaHighlightingUtil.checkInterfaceFunctional(defaultType) == null) {
+ if (LambdaUtil.isFunctionalType(defaultType)) {
final PsiMethod method = LambdaUtil.getFunctionalInterfaceMethod(defaultType);
if (method != null) {
final PsiParameter[] params = method.getParameterList().getParameters();
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/MethodReferenceCompletionProvider.java b/java/java-impl/src/com/intellij/codeInsight/completion/MethodReferenceCompletionProvider.java
index dbd2fc8..f060567 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/MethodReferenceCompletionProvider.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/MethodReferenceCompletionProvider.java
@@ -19,9 +19,8 @@
import com.intellij.codeInsight.ExpectedTypeInfoImpl;
import com.intellij.codeInsight.TailType;
import com.intellij.codeInsight.lookup.LookupElement;
-import com.intellij.codeInsight.lookup.LookupElementBuilder;
-import com.intellij.psi.*;
-import com.intellij.psi.filters.ElementFilter;
+import com.intellij.psi.LambdaUtil;
+import com.intellij.psi.PsiType;
import com.intellij.psi.util.PsiUtil;
import com.intellij.util.Consumer;
import com.intellij.util.ProcessingContext;
@@ -36,7 +35,7 @@
final ExpectedTypeInfo[] expectedTypes = JavaSmartCompletionContributor.getExpectedTypes(parameters);
for (ExpectedTypeInfo expectedType : expectedTypes) {
final PsiType defaultType = expectedType.getDefaultType();
- if (LambdaHighlightingUtil.checkInterfaceFunctional(defaultType) == null) {
+ if (LambdaUtil.isFunctionalType(defaultType)) {
final PsiType returnType = LambdaUtil.getFunctionalInterfaceReturnType(defaultType);
if (returnType != null) {
final ExpectedTypeInfoImpl typeInfo =
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/TypeArgumentCompletionProvider.java b/java/java-impl/src/com/intellij/codeInsight/completion/TypeArgumentCompletionProvider.java
index 3f97212..dcc9c31 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/TypeArgumentCompletionProvider.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/TypeArgumentCompletionProvider.java
@@ -24,6 +24,7 @@
import com.intellij.codeInsight.lookup.LookupElementPresentation;
import com.intellij.codeInsight.lookup.PsiTypeLookupItem;
import com.intellij.codeInsight.lookup.TailTypeDecorator;
+import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
@@ -47,6 +48,7 @@
* @author peter
*/
class TypeArgumentCompletionProvider extends CompletionProvider<CompletionParameters> {
+ private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.completion.TypeArgumentCompletionProvider");
private final boolean mySmart;
@Nullable private final InheritorsHolder myInheritors;
@@ -244,7 +246,12 @@
public void handleInsert(InsertionContext context) {
context.getDocument().deleteString(context.getStartOffset(), context.getTailOffset());
for (int i = 0; i < myTypeItems.size(); i++) {
- CompletionUtil.emulateInsertion(context, context.getTailOffset(), myTypeItems.get(i));
+ PsiTypeLookupItem typeItem = myTypeItems.get(i);
+ CompletionUtil.emulateInsertion(context, context.getTailOffset(), typeItem);
+ if (context.getTailOffset() < 0) {
+ LOG.error("tail offset spoiled by " + typeItem);
+ return;
+ }
context.setTailOffset(getTail(i == myTypeItems.size() - 1).processTail(context.getEditor(), context.getTailOffset()));
}
context.setAddCompletionChar(false);
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/quickFix/RedundantLambdaParameterTypeIntention.java b/java/java-impl/src/com/intellij/codeInsight/daemon/quickFix/RedundantLambdaParameterTypeIntention.java
index 949ddce..56c8860 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/quickFix/RedundantLambdaParameterTypeIntention.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/quickFix/RedundantLambdaParameterTypeIntention.java
@@ -22,7 +22,9 @@
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.resolve.DefaultParameterTypeInferencePolicy;
+import com.intellij.psi.infos.MethodCandidateInfo;
import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.psi.util.PsiUtil;
import com.intellij.util.Function;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
@@ -57,13 +59,14 @@
if (parameter.getTypeElement() == null) return false;
}
if (parameters.length == 0) return false;
- final PsiType functionalInterfaceType = LambdaUtil.getFunctionalInterfaceType(expression, false);
+ final PsiType functionalInterfaceType = LambdaUtil.getFunctionalInterfaceType(expression, true);
if (functionalInterfaceType != null) {
final PsiElement lambdaParent = expression.getParent();
if (lambdaParent instanceof PsiExpressionList) {
final PsiElement gParent = lambdaParent.getParent();
if (gParent instanceof PsiCallExpression && ((PsiCallExpression)gParent).getTypeArguments().length == 0) {
- final PsiMethod method = ((PsiCallExpression)gParent).resolveMethod();
+ final JavaResolveResult resolveResult = ((PsiCallExpression)gParent).resolveMethodGenerics();
+ final PsiMethod method = (PsiMethod)resolveResult.getElement();
if (method == null) return false;
final int idx = LambdaUtil.getLambdaIdx((PsiExpressionList)lambdaParent, expression);
if (idx < 0) return false;
@@ -79,16 +82,17 @@
}
}, ", ") + ") -> {}", expression);
final PsiSubstitutor substitutor = javaPsiFacade.getResolveHelper()
- .inferTypeArguments(typeParameters, method.getParameterList().getParameters(), arguments, PsiSubstitutor.EMPTY,
+ .inferTypeArguments(typeParameters, method.getParameterList().getParameters(), arguments, ((MethodCandidateInfo)resolveResult).getSiteSubstitutor(),
gParent, DefaultParameterTypeInferencePolicy.INSTANCE);
for (PsiTypeParameter parameter : typeParameters) {
final PsiType psiType = substitutor.substitute(parameter);
- if (psiType == null || LambdaUtil.dependsOnTypeParams(psiType, expression, parameter)) return false;
+ if (psiType == null || dependsOnTypeParams(psiType, expression, parameter)) return false;
}
+ return functionalInterfaceType.isAssignableFrom(substitutor.substitute(method.getParameterList().getParameters()[idx].getType()));
}
}
- else if (!LambdaUtil.isLambdaFullyInferred(expression, functionalInterfaceType)) {
+ if (!LambdaUtil.isLambdaFullyInferred(expression, functionalInterfaceType)) {
return false;
}
return true;
@@ -122,4 +126,11 @@
lambdaExpression.getParameterList().replace(expression.getParameterList());
}
}
+
+ private static boolean dependsOnTypeParams(PsiType type,
+ PsiLambdaExpression expr,
+ PsiTypeParameter param2Check) {
+ return LambdaUtil.depends(type, new LambdaUtil.TypeParamsChecker(expr, PsiUtil
+ .resolveGenericsClassInType(LambdaUtil.getFunctionalInterfaceType(expr, false)).getElement()), param2Check);
+ }
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/config/QuickFixFactoryImpl.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/config/QuickFixFactoryImpl.java
index 147cf33..0bc9f29 100644
--- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/config/QuickFixFactoryImpl.java
+++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/config/QuickFixFactoryImpl.java
@@ -40,7 +40,6 @@
import com.intellij.diagnostic.LogMessageEx;
import com.intellij.lang.annotation.HighlightSeverity;
import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.command.undo.UndoManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
@@ -55,6 +54,7 @@
import com.intellij.psi.util.ClassKind;
import com.intellij.psi.util.PropertyMemberType;
import com.intellij.refactoring.changeSignature.ChangeSignatureGestureDetector;
+import com.intellij.util.DocumentUtil;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.Processor;
import org.jetbrains.annotations.NotNull;
@@ -715,12 +715,7 @@
PsiDocumentManager.getInstance(file.getProject()).commitAllDocuments();
String beforeText = file.getText();
final long oldStamp = editor.getDocument().getModificationStamp();
- CommandProcessor.getInstance().runUndoTransparentAction(new Runnable() {
- @Override
- public void run() {
- ApplicationManager.getApplication().runWriteAction(runnable);
- }
- });
+ DocumentUtil.writeInRunUndoTransparentAction(runnable);
if (oldStamp != editor.getDocument().getModificationStamp()) {
String afterText = file.getText();
if (Comparing.strEqual(beforeText, afterText)) {
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/completion/PostfixTemplatesCompletionProvider.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/completion/PostfixTemplatesCompletionProvider.java
index 386718e..d5e98c4 100644
--- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/completion/PostfixTemplatesCompletionProvider.java
+++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/completion/PostfixTemplatesCompletionProvider.java
@@ -19,10 +19,10 @@
import com.intellij.codeInsight.completion.CompletionProvider;
import com.intellij.codeInsight.completion.CompletionResultSet;
import com.intellij.codeInsight.template.CustomTemplateCallback;
+import com.intellij.codeInsight.template.impl.LiveTemplateCompletionContributor;
import com.intellij.codeInsight.template.postfix.settings.PostfixTemplatesSettings;
import com.intellij.codeInsight.template.postfix.templates.PostfixLiveTemplate;
import com.intellij.codeInsight.template.postfix.templates.PostfixTemplate;
-import com.intellij.openapi.util.registry.Registry;
import com.intellij.patterns.StandardPatterns;
import com.intellij.psi.PsiFile;
import com.intellij.util.ProcessingContext;
@@ -33,7 +33,7 @@
class PostfixTemplatesCompletionProvider extends CompletionProvider<CompletionParameters> {
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) {
- if (!isCompletionEnabled(parameters) || Registry.is("show.live.templates.in.completion")) {
+ if (!isCompletionEnabled(parameters) || LiveTemplateCompletionContributor.shouldShowAllTemplates()) {
/**
* disabled or covered with {@link com.intellij.codeInsight.template.impl.LiveTemplateCompletionContributor}
*/
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/settings/PostfixTemplatesConfigurable.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/settings/PostfixTemplatesConfigurable.java
index 78e0475..b8c6a9d 100644
--- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/settings/PostfixTemplatesConfigurable.java
+++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/settings/PostfixTemplatesConfigurable.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
import com.intellij.application.options.editor.EditorOptionsProvider;
import com.intellij.codeInsight.CodeInsightBundle;
+import com.intellij.codeInsight.template.impl.LiveTemplateCompletionContributor;
import com.intellij.codeInsight.template.impl.TemplateSettings;
import com.intellij.codeInsight.template.postfix.templates.PostfixTemplate;
import com.intellij.openapi.options.Configurable;
@@ -83,7 +84,7 @@
@Nullable
@Override
public String getHelpTopic() {
- return null;
+ return getId();
}
@Nls
@@ -155,6 +156,7 @@
private void updateComponents() {
boolean pluginEnabled = myPostfixTemplatesEnabled.isSelected();
+ myCompletionEnabledCheckbox.setVisible(!LiveTemplateCompletionContributor.shouldShowAllTemplates());
myCompletionEnabledCheckbox.setEnabled(pluginEnabled);
myShortcutComboBox.setEnabled(pluginEnabled);
if (myTemplatesListPanel != null) {
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/InstanceofExpressionPostfixTemplate.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/InstanceofExpressionPostfixTemplate.java
index aac8bf9..8c5b58e 100644
--- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/InstanceofExpressionPostfixTemplate.java
+++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/InstanceofExpressionPostfixTemplate.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2000-2014 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.template.postfix.templates;
import com.intellij.codeInsight.guess.GuessManager;
@@ -28,17 +43,17 @@
@Override
public boolean isApplicable(@NotNull PsiElement context, @NotNull Document copyDocument, int newOffset) {
- return getTopmostExpression(context) != null;
+ return PostfixTemplatesUtils.isNotPrimitiveTypeExpression(getTopmostExpression(context));
}
@Override
public void expand(@NotNull PsiElement context, @NotNull Editor editor) {
PsiExpression expression = getTopmostExpression(context);
- if (expression == null) return;
+ if (!PostfixTemplatesUtils.isNotPrimitiveTypeExpression(expression)) return;
surroundExpression(context.getProject(), editor, expression);
}
- private static void surroundExpression(Project project, Editor editor, PsiExpression expr) throws IncorrectOperationException {
+ private static void surroundExpression(@NotNull Project project, @NotNull Editor editor, @NotNull PsiExpression expr) throws IncorrectOperationException {
assert expr.isValid();
PsiType[] types = GuessManager.getInstance(project).guessTypeToCast(expr);
final boolean parenthesesNeeded = expr instanceof PsiPolyadicExpression ||
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/NotExpressionPostfixTemplate.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/NotExpressionPostfixTemplate.java
index 14c723f..9900c0a 100644
--- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/NotExpressionPostfixTemplate.java
+++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/NotExpressionPostfixTemplate.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2000-2014 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.template.postfix.templates;
import com.intellij.codeInsight.CodeInsightServicesUtil;
@@ -10,6 +25,13 @@
@Aliases("!")
public class NotExpressionPostfixTemplate extends ExpressionPostfixTemplateWithChooser {
+ private static final Condition<PsiExpression> BOOLEAN_TYPE_CONDITION = new Condition<PsiExpression>() {
+ @Override
+ public boolean value(PsiExpression expression) {
+ return PostfixTemplatesUtils.isBoolean(expression.getType());
+ }
+ };
+
public NotExpressionPostfixTemplate() {
super("not", "Negates boolean expression", "!expr");
}
@@ -22,11 +44,6 @@
@NotNull
@Override
protected Condition<PsiExpression> getTypeCondition() {
- return new Condition<PsiExpression>() {
- @Override
- public boolean value(PsiExpression expression) {
- return PostfixTemplatesUtils.isBoolean(expression.getType());
- }
- };
+ return BOOLEAN_TYPE_CONDITION;
}
}
\ No newline at end of file
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/NullCheckPostfixTemplate.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/NullCheckPostfixTemplate.java
index 77126b8..6a9b676 100644
--- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/NullCheckPostfixTemplate.java
+++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/NullCheckPostfixTemplate.java
@@ -39,13 +39,13 @@
@Override
public boolean isApplicable(@NotNull PsiElement context, @NotNull Document copyDocument, int newOffset) {
- return getTopmostExpression(context) != null;
+ return PostfixTemplatesUtils.isNotPrimitiveTypeExpression(getTopmostExpression(context));
}
@Override
public void expand(@NotNull PsiElement context, @NotNull Editor editor) {
PsiExpression expr = getTopmostExpression(context);
- if (expr == null) return;
+ if (!PostfixTemplatesUtils.isNotPrimitiveTypeExpression(expr)) return;
Project project = expr.getProject();
PsiElementFactory factory = JavaPsiFacade.getInstance(project).getElementFactory();
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ThrowExceptionPostfixTemplate.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ThrowExceptionPostfixTemplate.java
index 7c2017f..b1bb654 100644
--- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ThrowExceptionPostfixTemplate.java
+++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ThrowExceptionPostfixTemplate.java
@@ -19,6 +19,7 @@
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiExpression;
import org.jetbrains.annotations.NotNull;
public class ThrowExceptionPostfixTemplate extends PostfixTemplate {
@@ -28,7 +29,8 @@
@Override
public boolean isApplicable(@NotNull PsiElement context, @NotNull Document copyDocument, int newOffset) {
- return getTopmostExpression(context) != null;
+ PsiExpression expression = getTopmostExpression(context);
+ return expression != null && PostfixTemplatesUtils.isThrowable(expression.getType());
}
@Override
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/util/PostfixTemplatesUtils.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/util/PostfixTemplatesUtils.java
index 923dfdc..09cf4fb 100644
--- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/util/PostfixTemplatesUtils.java
+++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/util/PostfixTemplatesUtils.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -47,11 +47,21 @@
}
@Contract("null -> false")
+ public static boolean isNotPrimitiveTypeExpression(@Nullable PsiExpression expression) {
+ return expression != null && !(expression.getType() instanceof PsiPrimitiveType);
+ }
+
+ @Contract("null -> false")
public static boolean isIterable(@Nullable PsiType type) {
return type != null && InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_LANG_ITERABLE);
}
@Contract("null -> false")
+ public static boolean isThrowable(@Nullable PsiType type) {
+ return type != null && InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_LANG_THROWABLE);
+ }
+
+ @Contract("null -> false")
public static boolean isArray(@Nullable PsiType type) {
return type != null && type instanceof PsiArrayType;
}
diff --git a/java/java-impl/src/com/intellij/ide/projectView/impl/ClassesTreeStructureProvider.java b/java/java-impl/src/com/intellij/ide/projectView/impl/ClassesTreeStructureProvider.java
index 518fb06..7e05157 100644
--- a/java/java-impl/src/com/intellij/ide/projectView/impl/ClassesTreeStructureProvider.java
+++ b/java/java-impl/src/com/intellij/ide/projectView/impl/ClassesTreeStructureProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.java.JavaModuleSourceRootTypes;
@@ -42,8 +43,9 @@
myProject = project;
}
+ @NotNull
@Override
- public Collection<AbstractTreeNode> modify(AbstractTreeNode parent, Collection<AbstractTreeNode> children, ViewSettings settings) {
+ public Collection<AbstractTreeNode> modify(@NotNull AbstractTreeNode parent, @NotNull Collection<AbstractTreeNode> children, ViewSettings settings) {
ArrayList<AbstractTreeNode> result = new ArrayList<AbstractTreeNode>();
for (final AbstractTreeNode child : children) {
Object o = child.getValue();
diff --git a/java/java-impl/src/com/intellij/ide/projectView/impl/nodes/PackageElement.java b/java/java-impl/src/com/intellij/ide/projectView/impl/nodes/PackageElement.java
index 3e92bda..ee64a31 100644
--- a/java/java-impl/src/com/intellij/ide/projectView/impl/nodes/PackageElement.java
+++ b/java/java-impl/src/com/intellij/ide/projectView/impl/nodes/PackageElement.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -58,6 +58,7 @@
return myElement;
}
+ @NotNull
@Override
public Collection<VirtualFile> getRoots() {
Set<VirtualFile> roots= new HashSet<VirtualFile>();
diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/StructureNodeRenderer.java b/java/java-impl/src/com/intellij/ide/structureView/impl/StructureNodeRenderer.java
index b264b48..0ed2b58 100644
--- a/java/java-impl/src/com/intellij/ide/structureView/impl/StructureNodeRenderer.java
+++ b/java/java-impl/src/com/intellij/ide/structureView/impl/StructureNodeRenderer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,13 +26,15 @@
import com.intellij.psi.PsiMember;
import com.intellij.ui.ColoredTreeCellRenderer;
import com.intellij.ui.SimpleTextAttributes;
+import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeNode;
public class StructureNodeRenderer extends ColoredTreeCellRenderer {
- public void customizeCellRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
+ @Override
+ public void customizeCellRenderer(@NotNull JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
forNodeDescriptorInTree(value, expanded).customize(this);
}
diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/InheritedMembersFilter.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/InheritedMembersFilter.java
deleted file mode 100644
index b176cc0..0000000
--- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/InheritedMembersFilter.java
+++ /dev/null
@@ -1,62 +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.ide.structureView.impl.java;
-
-import com.intellij.icons.AllIcons;
-import com.intellij.ide.IdeBundle;
-import com.intellij.ide.util.FileStructureFilter;
-import com.intellij.ide.util.treeView.smartTree.ActionPresentation;
-import com.intellij.ide.util.treeView.smartTree.ActionPresentationData;
-import com.intellij.ide.util.treeView.smartTree.TreeElement;
-import com.intellij.openapi.actionSystem.Shortcut;
-import com.intellij.openapi.keymap.KeymapManager;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-
-public class InheritedMembersFilter implements FileStructureFilter {
- @NonNls public static final String ID = "SHOW_INHERITED";
-
- public boolean isVisible(TreeElement treeNode) {
- if (treeNode instanceof JavaClassTreeElementBase) {
- return !((JavaClassTreeElementBase)treeNode).isInherited();
- }
- else {
- return true;
- }
- }
-
- @NotNull
- public ActionPresentation getPresentation() {
- return new ActionPresentationData(IdeBundle.message("action.structureview.show.inherited"), null, AllIcons.Hierarchy.Supertypes);
- }
-
- @NotNull
- public String getName() {
- return ID;
- }
-
- public boolean isReverted() {
- return true;
- }
-
- public String getCheckBoxText() {
- return IdeBundle.message("file.structure.toggle.show.inherited");
- }
-
- public Shortcut[] getShortcut() {
- return KeymapManager.getInstance().getActiveKeymap().getShortcuts("FileStructurePopup");
- }
-}
diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaAnonymousMembersFilter.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaAnonymousMembersFilter.java
deleted file mode 100644
index fc91ca5..0000000
--- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaAnonymousMembersFilter.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2000-2011 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.ide.structureView.impl.java;
-
-import com.intellij.ide.util.FileStructureFilter;
-import com.intellij.ide.util.treeView.smartTree.ActionPresentation;
-import com.intellij.ide.util.treeView.smartTree.ActionPresentationData;
-import com.intellij.ide.util.treeView.smartTree.TreeElement;
-import com.intellij.openapi.actionSystem.Shortcut;
-import com.intellij.util.PlatformIcons;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * @author Konstantin Bulenkov
- */
-public class JavaAnonymousMembersFilter implements FileStructureFilter {
-
- private static final String ID = "SHOW_ANONYMOUS";
-
- @Override
- public String getCheckBoxText() {
- return "Show Anonymous Classes";
- }
-
- @Override
- public Shortcut[] getShortcut() {
- return new Shortcut[0];
- }
-
- @Override
- public boolean isVisible(TreeElement treeNode) {
- return !(treeNode instanceof JavaAnonymousClassTreeElement);
- }
-
- @Override
- public boolean isReverted() {
- return true;
- }
-
- @NotNull
- @Override
- public ActionPresentation getPresentation() {
- return new ActionPresentationData(getCheckBoxText(), null, PlatformIcons.ANONYMOUS_CLASS_ICON);
- }
-
- @NotNull
- @Override
- public String getName() {
- return ID;
- }
-}
diff --git a/java/java-impl/src/com/intellij/ide/util/treeView/SourceComparator.java b/java/java-impl/src/com/intellij/ide/util/treeView/SourceComparator.java
index 3b9e17b..7456bdc 100644
--- a/java/java-impl/src/com/intellij/ide/util/treeView/SourceComparator.java
+++ b/java/java-impl/src/com/intellij/ide/util/treeView/SourceComparator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,6 +28,7 @@
private SourceComparator() {
}
+ @Override
public int compare(NodeDescriptor nodeDescriptor1, NodeDescriptor nodeDescriptor2) {
int weight1 = getWeight(nodeDescriptor1);
int weight2 = getWeight(nodeDescriptor2);
diff --git a/java/java-impl/src/com/intellij/lang/java/JavaAnonymousClassesProvider.java b/java/java-impl/src/com/intellij/lang/java/JavaAnonymousClassesProvider.java
index 0d01c1b..5e5fa49 100644
--- a/java/java-impl/src/com/intellij/lang/java/JavaAnonymousClassesProvider.java
+++ b/java/java-impl/src/com/intellij/lang/java/JavaAnonymousClassesProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
import com.intellij.navigation.AnonymousElementProvider;
import com.intellij.psi.*;
+import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
@@ -25,8 +26,9 @@
* @author Konstantin Bulenkov
*/
public class JavaAnonymousClassesProvider implements AnonymousElementProvider {
+ @NotNull
@Override
- public PsiElement[] getAnonymousElements(PsiElement parent) {
+ public PsiElement[] getAnonymousElements(@NotNull PsiElement parent) {
if (suite(parent)) {
if (parent instanceof PsiCompiledElement) {
parent = parent.getNavigationElement();
diff --git a/java/java-impl/src/com/intellij/psi/codeStyle/arrangement/JavaRearranger.java b/java/java-impl/src/com/intellij/psi/codeStyle/arrangement/JavaRearranger.java
index 7e3f95a..369c5b2 100644
--- a/java/java-impl/src/com/intellij/psi/codeStyle/arrangement/JavaRearranger.java
+++ b/java/java-impl/src/com/intellij/psi/codeStyle/arrangement/JavaRearranger.java
@@ -180,12 +180,14 @@
private static void setupBreadthFirstDependency(@NotNull ArrangementEntryDependencyInfo info) {
Deque<ArrangementEntryDependencyInfo> toProcess = new ArrayDeque<ArrangementEntryDependencyInfo>();
toProcess.add(info);
+ JavaElementArrangementEntry prev = info.getAnchorEntry();
while (!toProcess.isEmpty()) {
ArrangementEntryDependencyInfo current = toProcess.removeFirst();
for (ArrangementEntryDependencyInfo dependencyInfo : current.getDependentEntriesInfos()) {
JavaElementArrangementEntry dependencyMethod = dependencyInfo.getAnchorEntry();
if (dependencyMethod.getDependencies() == null) {
- dependencyMethod.addDependency(current.getAnchorEntry());
+ dependencyMethod.addDependency(prev);
+ prev = dependencyMethod;
}
toProcess.addLast(dependencyInfo);
}
diff --git a/java/java-impl/src/com/intellij/psi/impl/file/JavaUpdateAddedFileProcessor.java b/java/java-impl/src/com/intellij/psi/impl/file/JavaUpdateAddedFileProcessor.java
index 82dbc6d..17b5a64 100644
--- a/java/java-impl/src/com/intellij/psi/impl/file/JavaUpdateAddedFileProcessor.java
+++ b/java/java-impl/src/com/intellij/psi/impl/file/JavaUpdateAddedFileProcessor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
import com.intellij.psi.*;
import com.intellij.psi.templateLanguages.TemplateLanguageFileViewProvider;
import com.intellij.util.IncorrectOperationException;
+import org.jetbrains.annotations.NotNull;
/**
* @author Maxim.Mossienko
@@ -26,7 +27,7 @@
*/
public class JavaUpdateAddedFileProcessor extends UpdateAddedFileProcessor {
@Override
- public boolean canProcessElement(final PsiFile file) {
+ public boolean canProcessElement(@NotNull final PsiFile file) {
return file instanceof PsiClassOwner;
}
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 10d4584..7749d95 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
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,10 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-/*
- * @author max
- */
package com.intellij.psi.impl.source.codeStyle;
import com.intellij.lang.ASTNode;
@@ -47,6 +43,9 @@
import java.beans.Introspector;
import java.util.*;
+/**
+ * @author max
+ */
public class JavaCodeStyleManagerImpl extends JavaCodeStyleManager {
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.codeStyle.JavaCodeStyleManagerImpl");
@@ -87,8 +86,7 @@
}
@Override
- public void shortenClassReferences(@NotNull PsiElement element, int startOffset, int endOffset)
- throws IncorrectOperationException {
+ public void shortenClassReferences(@NotNull PsiElement element, int startOffset, int endOffset) throws IncorrectOperationException {
CheckUtil.checkWritable(element);
if (SourceTreeToPsiMap.hasTreeElement(element)) {
final ReferenceAdjuster adjuster = ReferenceAdjuster.Extension.getReferenceAdjuster(element.getLanguage());
@@ -164,7 +162,7 @@
ContainerUtil.addAll(redundant, imports);
redundant.removeAll(allImports);
for (PsiImportStatementBase importStatement : imports) {
- if (importStatement instanceof JspxImportStatement && ((JspxImportStatement)importStatement).isForeignFileImport()) {
+ if (importStatement instanceof JspxImportStatement && importStatement.isForeignFileImport()) {
redundant.remove(importStatement);
}
}
@@ -481,7 +479,7 @@
if (fromLiterals != null) {
ContainerUtil.addAll(names, fromLiterals);
}
-
+
ContainerUtil.addAll(names, suggestVariableNameByExpressionOnly(expr, variableKind, correctKeywords, false).names);
ContainerUtil.addAll(names, suggestVariableNameByExpressionPlace(expr, variableKind, correctKeywords).names);
diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaReferenceAdjuster.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaReferenceAdjuster.java
index c069767..db020ad 100644
--- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaReferenceAdjuster.java
+++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaReferenceAdjuster.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -37,7 +37,7 @@
public class JavaReferenceAdjuster implements ReferenceAdjuster {
@Override
- public ASTNode process(ASTNode element, boolean addImports, boolean incompleteCode, boolean useFqInJavadoc, boolean useFqInCode) {
+ public ASTNode process(@NotNull ASTNode element, boolean addImports, boolean incompleteCode, boolean useFqInJavadoc, boolean useFqInCode) {
IElementType elementType = element.getElementType();
if ((elementType == JavaElementType.JAVA_CODE_REFERENCE || elementType == JavaElementType.REFERENCE_EXPRESSION) && !isAnnotated(element)) {
IElementType parentType = element.getTreeParent().getElementType();
@@ -124,7 +124,7 @@
}
@Override
- public ASTNode process(ASTNode element, boolean addImports, boolean incompleteCode, Project project) {
+ public ASTNode process(@NotNull ASTNode element, boolean addImports, boolean incompleteCode, Project project) {
final CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(project);
return process(element, addImports, incompleteCode, settings.USE_FQ_CLASS_NAMES_IN_JAVADOC, settings.USE_FQ_CLASS_NAMES);
}
@@ -155,7 +155,7 @@
}
@Override
- public void processRange(ASTNode element, int startOffset, int endOffset, boolean useFqInJavadoc, boolean useFqInCode) {
+ public void processRange(@NotNull ASTNode element, int startOffset, int endOffset, boolean useFqInJavadoc, boolean useFqInCode) {
List<ASTNode> array = new ArrayList<ASTNode>();
addReferencesInRange(array, element, startOffset, endOffset);
for (ASTNode ref : array) {
@@ -166,7 +166,7 @@
}
@Override
- public void processRange(ASTNode element, int startOffset, int endOffset, Project project) {
+ public void processRange(@NotNull ASTNode element, int startOffset, int endOffset, Project project) {
final CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(project);
processRange(element, startOffset, endOffset, settings.USE_FQ_CLASS_NAMES_IN_JAVADOC, settings.USE_FQ_CLASS_NAMES);
}
@@ -206,6 +206,7 @@
}
}
+ @NotNull
private static ASTNode makeShortReference(@NotNull CompositeElement reference, @NotNull PsiClass refClass, boolean addImports) {
@NotNull final PsiJavaCodeReferenceElement psiReference = (PsiJavaCodeReferenceElement)reference.getPsi();
final PsiQualifiedReferenceElement reference1 = getClassReferenceToShorten(refClass, addImports, psiReference);
diff --git a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/PsiDocTagValueManipulator.java b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/PsiDocTagValueManipulator.java
index 9a2a479..34c1d9d 100644
--- a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/PsiDocTagValueManipulator.java
+++ b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/PsiDocTagValueManipulator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@
import com.intellij.psi.PsiElement;
import com.intellij.psi.javadoc.PsiDocTag;
import com.intellij.util.IncorrectOperationException;
+import org.jetbrains.annotations.NotNull;
/**
* @author Gregory.Shrago
@@ -29,7 +30,7 @@
public class PsiDocTagValueManipulator extends AbstractElementManipulator<PsiDocTag> {
@Override
- public PsiDocTag handleContentChange(PsiDocTag tag, TextRange range, String newContent) throws IncorrectOperationException {
+ public PsiDocTag handleContentChange(@NotNull PsiDocTag tag, @NotNull TextRange range, String newContent) throws IncorrectOperationException {
final StringBuilder replacement = new StringBuilder( tag.getText() );
replacement.replace(
@@ -40,8 +41,9 @@
return (PsiDocTag)tag.replace(JavaPsiFacade.getInstance(tag.getProject()).getElementFactory().createDocTagFromText(replacement.toString()));
}
+ @NotNull
@Override
- public TextRange getRangeInElement(final PsiDocTag tag) {
+ public TextRange getRangeInElement(@NotNull final PsiDocTag tag) {
final PsiElement[] elements = tag.getDataElements();
if (elements.length == 0) {
final PsiElement name = tag.getNameElement();
diff --git a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/StringLiteralManipulator.java b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/StringLiteralManipulator.java
index 3e4abfc..9d9b1f1 100644
--- a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/StringLiteralManipulator.java
+++ b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/StringLiteralManipulator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,13 +19,14 @@
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
import com.intellij.util.IncorrectOperationException;
+import org.jetbrains.annotations.NotNull;
/**
* @author ven
*/
public class StringLiteralManipulator extends AbstractElementManipulator<PsiLiteralExpression> {
@Override
- public PsiLiteralExpression handleContentChange(PsiLiteralExpression expr, TextRange range, String newContent) throws IncorrectOperationException {
+ public PsiLiteralExpression handleContentChange(@NotNull PsiLiteralExpression expr, @NotNull TextRange range, String newContent) throws IncorrectOperationException {
String oldText = expr.getText();
if (oldText.startsWith("\"")) {
newContent = StringUtil.escapeStringCharacters(newContent);
@@ -42,8 +43,9 @@
return (PsiLiteralExpression)expr.replace(newExpr);
}
+ @NotNull
@Override
- public TextRange getRangeInElement(final PsiLiteralExpression element) {
+ public TextRange getRangeInElement(@NotNull final PsiLiteralExpression element) {
return getValueRange(element);
}
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 2548fbf..f86b78d 100644
--- a/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureDialog.java
+++ b/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureDialog.java
@@ -19,7 +19,7 @@
import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CustomShortcutSet;
-import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.colors.EditorFontType;
@@ -556,7 +556,7 @@
}
if (item.parameter.oldParameterIndex < 0) {
- item.parameter.defaultValue = ApplicationManager.getApplication().runWriteAction(new Computable<String>() {
+ item.parameter.defaultValue = WriteCommandAction.runWriteCommandAction(myProject, new Computable<String>() {
@Override
public String compute() {
return JavaCodeStyleManager.getInstance(myProject).qualifyClassReferences(item.defaultValueCodeFragment).getText();
diff --git a/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureUsageProcessor.java b/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureUsageProcessor.java
index e8bb45c..83de0ed 100644
--- a/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureUsageProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureUsageProcessor.java
@@ -17,6 +17,7 @@
import com.intellij.codeInsight.ExceptionUtil;
import com.intellij.codeInsight.daemon.impl.analysis.JavaHighlightUtil;
+import com.intellij.codeInspection.dataFlow.ControlFlowAnalyzer;
import com.intellij.lang.StdLanguages;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
@@ -884,7 +885,7 @@
private static class ConflictSearcher {
private final JavaChangeInfo myChangeInfo;
- private ConflictSearcher(JavaChangeInfo changeInfo) {
+ private ConflictSearcher(@NotNull JavaChangeInfo changeInfo) {
this.myChangeInfo = changeInfo;
}
@@ -901,6 +902,8 @@
LOG.error(e);
}
}
+
+ checkContract(conflictDescriptions, myChangeInfo.getMethod());
for (UsageInfo usageInfo : usagesSet) {
final PsiElement element = usageInfo.getElement();
@@ -914,6 +917,8 @@
conflictDescriptions.putValue(baseMethod, "Implicit last parameter should not be deleted");
}
}
+
+ checkContract(conflictDescriptions, method);
} else if (element instanceof PsiMethodReferenceExpression) {
conflictDescriptions.putValue(element, "Changed method is used in method reference");
}
@@ -922,6 +927,12 @@
return conflictDescriptions;
}
+ private static void checkContract(MultiMap<PsiElement, String> conflictDescriptions, PsiMethod method) {
+ if (ControlFlowAnalyzer.findContractAnnotation(method) != null) {
+ conflictDescriptions.putValue(method, "@Contract annotation will have to be changed manually");
+ }
+ }
+
private boolean needToChangeCalls() {
return myChangeInfo.isNameChanged() || myChangeInfo.isParameterSetOrOrderChanged() || myChangeInfo.isExceptionSetOrOrderChanged();
}
@@ -964,9 +975,6 @@
private void addMethodConflicts(MultiMap<PsiElement, String> conflicts) {
String newMethodName = myChangeInfo.getNewName();
- if (!(myChangeInfo instanceof JavaChangeInfo)) {
- return;
- }
try {
PsiMethod prototype;
final PsiMethod method = myChangeInfo.getMethod();
diff --git a/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectProcessor.java b/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectProcessor.java
index 8d449cf..e423210 100644
--- a/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectProcessor.java
@@ -36,7 +36,6 @@
import com.intellij.psi.codeStyle.VariableKind;
import com.intellij.psi.controlFlow.ControlFlowUtil;
import com.intellij.psi.impl.source.PsiImmediateClassType;
-import com.intellij.psi.impl.source.resolve.DefaultParameterTypeInferencePolicy;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.searches.ReferencesSearch;
import com.intellij.psi.util.PropertyUtil;
@@ -469,12 +468,9 @@
final PsiTypeParameter[] methodTypeParameters = getMethod().getTypeParameters();
if (methodTypeParameters.length > 0) {
List<String> typeSignature = new ArrayList<String>();
- final PsiResolveHelper resolveHelper = JavaPsiFacade.getInstance(getMethod().getProject()).getResolveHelper();
+ final PsiSubstitutor substitutor = methodCallExpression.resolveMethodGenerics().getSubstitutor();
for (final PsiTypeParameter typeParameter : methodTypeParameters) {
- final PsiType type = resolveHelper.inferTypeForMethodTypeParameter(typeParameter, getMethod().getParameterList().getParameters(),
- methodCallExpression.getArgumentList().getExpressions(),
- PsiSubstitutor.EMPTY, methodCallExpression,
- DefaultParameterTypeInferencePolicy.INSTANCE);
+ final PsiType type = substitutor.substitute(typeParameter);
if (type == null || PsiType.NULL.equals(type)) {
return "";
}
diff --git a/java/java-indexing-impl/src/com/intellij/psi/impl/PsiShortNamesCacheImpl.java b/java/java-indexing-impl/src/com/intellij/psi/impl/PsiShortNamesCacheImpl.java
index e80e487..e189e9c 100644
--- a/java/java-indexing-impl/src/com/intellij/psi/impl/PsiShortNamesCacheImpl.java
+++ b/java/java-indexing-impl/src/com/intellij/psi/impl/PsiShortNamesCacheImpl.java
@@ -147,8 +147,9 @@
@NotNull
public PsiMethod[] getMethodsByNameIfNotMoreThan(@NonNls @NotNull final String name, @NotNull final GlobalSearchScope scope, final int maxCount) {
final List<PsiMethod> methods = new SmartList<PsiMethod>();
- StubIndex.getInstance().process(JavaStubIndexKeys.METHODS, name, myManager.getProject(), scope, new CommonProcessors.CollectProcessor<PsiMethod>(methods){
- @Override
+ StubIndex.getInstance().processElements(JavaStubIndexKeys.METHODS, name, myManager.getProject(), scope, PsiMethod.class, new
+ CommonProcessors.CollectProcessor < PsiMethod > (methods){
+ @Override
public boolean process(PsiMethod method) {
return methods.size() != maxCount && super.process(method);
}
@@ -163,7 +164,7 @@
public boolean processMethodsWithName(@NonNls @NotNull String name,
@NotNull GlobalSearchScope scope,
@NotNull Processor<PsiMethod> processor) {
- return StubIndex.getInstance().process(JavaStubIndexKeys.METHODS, name, myManager.getProject(), scope, processor);
+ return StubIndex.getInstance().processElements(JavaStubIndexKeys.METHODS, name, myManager.getProject(), scope, PsiMethod.class, processor);
}
@Override
@@ -181,8 +182,9 @@
@NotNull
public PsiField[] getFieldsByNameIfNotMoreThan(@NotNull String name, @NotNull final GlobalSearchScope scope, final int maxCount) {
final List<PsiField> methods = new SmartList<PsiField>();
- StubIndex.getInstance().process(JavaStubIndexKeys.FIELDS, name, myManager.getProject(), scope, new CommonProcessors.CollectProcessor<PsiField>(methods){
- @Override
+ StubIndex.getInstance().processElements(JavaStubIndexKeys.FIELDS, name, myManager.getProject(), scope, PsiField.class, new
+ CommonProcessors.CollectProcessor < PsiField > (methods){
+ @Override
public boolean process(PsiField method) {
return methods.size() != maxCount && super.process(method);
}
@@ -220,7 +222,8 @@
@NotNull Processor<? super PsiField> processor,
@NotNull GlobalSearchScope scope,
@Nullable IdFilter filter) {
- return StubIndex.getInstance().process(JavaStubIndexKeys.FIELDS, name, myManager.getProject(), new JavaSourceFilterScope(scope), filter, processor);
+ return StubIndex.getInstance().processElements(JavaStubIndexKeys.FIELDS, name, myManager.getProject(), new JavaSourceFilterScope(scope),
+ filter, PsiField.class, processor);
}
@Override
@@ -228,7 +231,8 @@
@NotNull Processor<? super PsiMethod> processor,
@NotNull GlobalSearchScope scope,
@Nullable IdFilter filter) {
- return StubIndex.getInstance().process(JavaStubIndexKeys.METHODS, name, myManager.getProject(), new JavaSourceFilterScope(scope), filter, processor);
+ return StubIndex.getInstance().processElements(JavaStubIndexKeys.METHODS, name, myManager.getProject(),
+ new JavaSourceFilterScope(scope), filter, PsiMethod.class, processor);
}
@Override
@@ -236,7 +240,8 @@
@NotNull Processor<? super PsiClass> processor,
@NotNull GlobalSearchScope scope,
@Nullable IdFilter filter) {
- return StubIndex.getInstance().process(JavaStubIndexKeys.CLASS_SHORT_NAMES, name, myManager.getProject(), new JavaSourceFilterScope(scope), filter, processor);
+ return StubIndex.getInstance().processElements(JavaStubIndexKeys.CLASS_SHORT_NAMES, name, myManager.getProject(),
+ new JavaSourceFilterScope(scope), filter, PsiClass.class, processor);
}
private <T extends PsiMember> List<T> filterMembers(Collection<T> members, final GlobalSearchScope scope) {
diff --git a/java/java-indexing-impl/src/com/intellij/psi/impl/search/AllClassesSearchExecutor.java b/java/java-indexing-impl/src/com/intellij/psi/impl/search/AllClassesSearchExecutor.java
index f33ff1e..09b60c1 100644
--- a/java/java-indexing-impl/src/com/intellij/psi/impl/search/AllClassesSearchExecutor.java
+++ b/java/java-indexing-impl/src/com/intellij/psi/impl/search/AllClassesSearchExecutor.java
@@ -107,10 +107,10 @@
return true;
}
- private static boolean processScopeRootForAllClasses(@NotNull PsiElement scopeRoot, @NotNull final Processor<PsiClass> processor) {
+ private static boolean processScopeRootForAllClasses(@NotNull final PsiElement scopeRoot, @NotNull final Processor<PsiClass> processor) {
final boolean[] stopped = {false};
- JavaElementVisitor visitor = scopeRoot instanceof PsiCompiledElement ? new JavaRecursiveElementVisitor() {
+ final JavaElementVisitor visitor = scopeRoot instanceof PsiCompiledElement ? new JavaRecursiveElementVisitor() {
@Override
public void visitElement(PsiElement element) {
if (!stopped[0]) {
@@ -137,7 +137,12 @@
super.visitClass(aClass);
}
};
- scopeRoot.accept(visitor);
+ ApplicationManager.getApplication().runReadAction(new Runnable() {
+ @Override
+ public void run() {
+ scopeRoot.accept(visitor);
+ }
+ });
return !stopped[0];
}
diff --git a/java/java-psi-api/src/com/intellij/psi/LambdaHighlightingUtil.java b/java/java-psi-api/src/com/intellij/psi/LambdaHighlightingUtil.java
index 86137d0..178001b 100644
--- a/java/java-psi-api/src/com/intellij/psi/LambdaHighlightingUtil.java
+++ b/java/java-psi-api/src/com/intellij/psi/LambdaHighlightingUtil.java
@@ -101,7 +101,7 @@
if (checkInterfaceFunctional(type) == null) return null;
}
}
- final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(GenericsUtil.eliminateWildcards(functionalInterfaceType));
+ final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(functionalInterfaceType);
final PsiClass aClass = resolveResult.getElement();
if (aClass != null) {
if (aClass instanceof PsiTypeParameter) return null; //should be logged as cyclic inference
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 11ba3f2..15b3208 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-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,6 @@
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Pair;
import com.intellij.pom.java.LanguageLevel;
-import com.intellij.psi.codeStyle.JavaCodeStyleManager;
import com.intellij.psi.infos.MethodCandidateInfo;
import com.intellij.psi.util.*;
import org.jetbrains.annotations.NonNls;
@@ -116,7 +115,7 @@
context instanceof PsiExpressionList ||
context instanceof PsiParenthesizedExpression ||
context instanceof PsiArrayInitializerExpression ||
- context instanceof PsiConditionalExpression;
+ context instanceof PsiConditionalExpression && PsiTreeUtil.getParentOfType(context, PsiTypeCastExpression.class) == null;
}
public static boolean isLambdaFullyInferred(PsiLambdaExpression expression, PsiType functionalInterfaceType) {
@@ -128,89 +127,6 @@
return true;
}
- private static boolean checkRawAcceptable(PsiLambdaExpression expression, PsiType functionalInterfaceType) {
- PsiElement parent = expression.getParent();
- while (parent instanceof PsiParenthesizedExpression) {
- parent = parent.getParent();
- }
- if (parent instanceof PsiExpressionList) {
- final PsiElement gParent = parent.getParent();
- if (gParent instanceof PsiMethodCallExpression) {
- final PsiExpression qualifierExpression = ((PsiMethodCallExpression)gParent).getMethodExpression().getQualifierExpression();
- final PsiType type = qualifierExpression != null ? qualifierExpression.getType() : null;
- if (type instanceof PsiClassType && ((PsiClassType)type).isRaw()) {
- return true;
- }
- final PsiMethod method = ((PsiMethodCallExpression)gParent).resolveMethod();
- if (method != null) {
- int lambdaIdx = getLambdaIdx((PsiExpressionList)parent, expression);
- final PsiParameter[] parameters = method.getParameterList().getParameters();
- final PsiType normalizedType = getNormalizedType(parameters[adjustLambdaIdx(lambdaIdx, method, parameters)]);
- if (normalizedType instanceof PsiClassType && ((PsiClassType)normalizedType).isRaw()) return true;
- }
- }
- if (functionalInterfaceType instanceof PsiClassType && ((PsiClassType)functionalInterfaceType).isRaw()){
- return false;
- }
- }
- return true;
- }
-
- public static boolean isAcceptable(PsiLambdaExpression lambdaExpression, final PsiType leftType, boolean checkReturnType) {
- if (leftType instanceof PsiIntersectionType) {
- for (PsiType conjunctType : ((PsiIntersectionType)leftType).getConjuncts()) {
- if (isAcceptable(lambdaExpression, conjunctType, checkReturnType)) return true;
- }
- return false;
- }
- final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(GenericsUtil.eliminateWildcards(leftType));
- final PsiClass psiClass = resolveResult.getElement();
- if (psiClass instanceof PsiAnonymousClass) {
- return isAcceptable(lambdaExpression, ((PsiAnonymousClass)psiClass).getBaseClassType(), checkReturnType);
- }
- final MethodSignature methodSignature = getFunction(psiClass);
- if (methodSignature == null) return false;
- final PsiParameter[] lambdaParameters = lambdaExpression.getParameterList().getParameters();
- final PsiType[] parameterTypes = methodSignature.getParameterTypes();
- if (lambdaParameters.length != parameterTypes.length) return false;
- for (int lambdaParamIdx = 0, length = lambdaParameters.length; lambdaParamIdx < length; lambdaParamIdx++) {
- PsiParameter parameter = lambdaParameters[lambdaParamIdx];
- final PsiTypeElement typeElement = parameter.getTypeElement();
- if (typeElement != null) {
- final PsiType lambdaFormalType = typeElement.getType();
- final PsiType methodParameterType = parameterTypes[lambdaParamIdx];
- if (lambdaFormalType instanceof PsiPrimitiveType) {
- if (methodParameterType instanceof PsiPrimitiveType) return methodParameterType.equals(lambdaFormalType);
- return false;
- }
-
- if (!TypeConversionUtil.erasure(lambdaFormalType)
- .isAssignableFrom(TypeConversionUtil.erasure(GenericsUtil.eliminateWildcards(
- resolveResult.getSubstitutor().substitute(methodSignature.getSubstitutor().substitute(methodParameterType)))))) {
- return false;
- }
- }
- }
- if (checkReturnType) {
- final String uniqueVarName =
- JavaCodeStyleManager.getInstance(lambdaExpression.getProject()).suggestUniqueVariableName("l", lambdaExpression, true);
- String canonicalText = leftType.getCanonicalText();
- if (leftType instanceof PsiEllipsisType) {
- canonicalText = ((PsiEllipsisType)leftType).toArrayType().getCanonicalText();
- }
- final PsiStatement assignmentFromText = JavaPsiFacade.getElementFactory(lambdaExpression.getProject())
- .createStatementFromText(canonicalText + " " + uniqueVarName + " = " + lambdaExpression.getText(), lambdaExpression);
- final PsiLocalVariable localVariable = (PsiLocalVariable)((PsiDeclarationStatement)assignmentFromText).getDeclaredElements()[0];
- LOG.assertTrue(psiClass != null);
- PsiType methodReturnType = getReturnType(psiClass, methodSignature);
- if (methodReturnType != null) {
- methodReturnType = resolveResult.getSubstitutor().substitute(methodSignature.getSubstitutor().substitute(methodReturnType));
- return LambdaHighlightingUtil.checkReturnTypeCompatible((PsiLambdaExpression)localVariable.getInitializer(), methodReturnType) == null;
- }
- }
- return true;
- }
-
@Nullable
static MethodSignature getFunction(PsiClass psiClass) {
if (psiClass == null) return null;
@@ -269,7 +185,7 @@
if (psiClass instanceof PsiAnonymousClass) {
psiClass = PsiUtil.resolveClassInType(((PsiAnonymousClass)psiClass).getBaseClassType());
}
- if (psiClass != null && psiClass.isInterface()) {
+ if (psiClass != null && psiClass.isInterface() && !psiClass.isAnnotationType()) {
final List<MethodSignature> methods = new ArrayList<MethodSignature>();
final Collection<HierarchicalMethodSignature> visibleSignatures = psiClass.getVisibleSignatures();
for (HierarchicalMethodSignature signature : visibleSignatures) {
@@ -324,12 +240,6 @@
}
public static boolean dependsOnTypeParams(PsiType type,
- PsiLambdaExpression expr,
- PsiTypeParameter param2Check) {
- return depends(type, new TypeParamsChecker(expr), param2Check);
- }
-
- public static boolean dependsOnTypeParams(PsiType type,
PsiType functionalInterfaceType,
PsiElement lambdaExpression,
PsiTypeParameter... param2Check) {
@@ -337,13 +247,7 @@
PsiUtil.resolveClassInType(functionalInterfaceType)), param2Check);
}
- public static boolean dependsOnTypeParams(PsiType type,
- PsiClass aClass,
- PsiMethod aMethod) {
- return depends(type, new TypeParamsChecker(aMethod, aClass));
- }
-
- static boolean depends(PsiType type, TypeParamsChecker visitor, PsiTypeParameter... param2Check) {
+ public static boolean depends(PsiType type, TypeParamsChecker visitor, PsiTypeParameter... param2Check) {
if (!visitor.startedInference()) return false;
final Boolean accept = type.accept(visitor);
if (param2Check.length > 0) {
@@ -352,79 +256,8 @@
return accept != null && accept.booleanValue();
}
- public static boolean isFreeFromTypeInferenceArgs(final PsiParameter[] methodParameters,
- final PsiLambdaExpression lambdaExpression,
- final PsiExpression expression,
- final PsiSubstitutor subst,
- final PsiType functionalInterfaceType,
- final PsiTypeParameter typeParam) {
- if (expression instanceof PsiCallExpression && ((PsiCallExpression)expression).getTypeArguments().length > 0) return true;
- if (expression instanceof PsiNewExpression) {
- final PsiJavaCodeReferenceElement classReference = ((PsiNewExpression)expression).getClassOrAnonymousClassReference();
- if (classReference != null) {
- final PsiReferenceParameterList parameterList = classReference.getParameterList();
- if (parameterList != null) {
- final PsiTypeElement[] typeParameterElements = parameterList.getTypeParameterElements();
- if (typeParameterElements.length > 0) {
- if (!(typeParameterElements[0].getType() instanceof PsiDiamondType)) {
- return true;
- }
- }
- }
- }
- }
- final PsiParameter[] lambdaParams = lambdaExpression.getParameterList().getParameters();
- if (lambdaParams.length != methodParameters.length) return false;
- final boolean[] independent = {true};
- final PsiMethod interfaceMethod = getFunctionalInterfaceMethod(functionalInterfaceType);
- if (interfaceMethod == null) return false;
- final TypeParamsChecker paramsChecker = new TypeParamsChecker(lambdaExpression);
- for (PsiParameter parameter : interfaceMethod.getParameterList().getParameters()) {
- subst.substitute(parameter.getType()).accept(paramsChecker);
- }
- paramsChecker.myUsedTypeParams.add(typeParam);
-
- expression.accept(new JavaRecursiveElementWalkingVisitor() {
- @Override
- public void visitConditionalExpression(PsiConditionalExpression expression) {
- final PsiExpression thenExpression = expression.getThenExpression();
- if (thenExpression != null) {
- thenExpression.accept(this);
- }
- final PsiExpression elseExpression = expression.getElseExpression();
- if (elseExpression != null) {
- elseExpression.accept(this);
- }
- }
-
- @Override
- public void visitReferenceExpression(PsiReferenceExpression expression) {
- super.visitReferenceExpression(expression);
- int usedParamIdx = -1;
- for (int i = 0; i < lambdaParams.length; i++) {
- PsiParameter param = lambdaParams[i];
- if (expression.isReferenceTo(param)) {
- usedParamIdx = i;
- break;
- }
- }
-
- if (usedParamIdx > -1 && dependsOnTypeParams(subst.substitute(methodParameters[usedParamIdx].getType()), functionalInterfaceType,
- lambdaExpression, paramsChecker.myUsedTypeParams.toArray(new PsiTypeParameter[paramsChecker.myUsedTypeParams.size()]))) {
- independent[0] = false;
- }
- }
- });
- return independent[0];
- }
-
@Nullable
public static PsiType getFunctionalInterfaceType(PsiElement expression, final boolean tryToSubstitute) {
- return getFunctionalInterfaceType(expression, tryToSubstitute, -1);
- }
-
- @Nullable
- public static PsiType getFunctionalInterfaceType(PsiElement expression, final boolean tryToSubstitute, int paramIdx) {
PsiElement parent = expression.getParent();
PsiElement element = expression;
while (parent instanceof PsiParenthesizedExpression || parent instanceof PsiConditionalExpression) {
@@ -460,14 +293,6 @@
final int lambdaIdx = getLambdaIdx(expressionList, expression);
if (lambdaIdx > -1) {
- PsiType cachedType = null;
- final Pair<PsiMethod, PsiSubstitutor> method = MethodCandidateInfo.getCurrentMethod(parent);
- if (method != null) {
- final PsiParameter[] parameters = method.first.getParameterList().getParameters();
- cachedType = lambdaIdx < parameters.length ? method.second.substitute(getNormalizedType(parameters[adjustLambdaIdx(lambdaIdx, method.first, parameters)])) : null;
- if (!tryToSubstitute) return cachedType;
- }
-
PsiElement gParent = expressionList.getParent();
if (gParent instanceof PsiAnonymousClass) {
@@ -483,22 +308,6 @@
final int finalLambdaIdx = adjustLambdaIdx(lambdaIdx, (PsiMethod)resolve, parameters);
if (finalLambdaIdx < parameters.length) {
if (!tryToSubstitute) return getNormalizedType(parameters[finalLambdaIdx]);
- if (cachedType != null) {
- final PsiMethod interfaceMethod = getFunctionalInterfaceMethod(cachedType);
- if (interfaceMethod != null) {
- final PsiClassType.ClassResolveResult cachedResult = PsiUtil.resolveGenericsClassInType(cachedType);
- if (paramIdx == -1) {
- if (!dependsOnTypeParams(cachedType, cachedType, expression) && !dependsOnTypeParams(getFunctionalInterfaceReturnType(cachedType), cachedType, expression)) {
- return cachedType;
- }
- }
- else {
- if (!dependsOnTypeParams(cachedResult.getSubstitutor().substitute(interfaceMethod.getParameterList().getParameters()[paramIdx].getType()), cachedType, expression)) {
- return cachedType;
- }
- }
- }
- }
return PsiResolveHelper.ourGuard.doPreventingRecursion(expression, true, new Computable<PsiType>() {
@Override
public PsiType compute() {
@@ -551,53 +360,6 @@
return type;
}
- public static PsiType getLambdaParameterType(PsiParameter param) {
- final PsiElement paramParent = param.getParent();
- if (paramParent instanceof PsiParameterList) {
- final int parameterIndex = ((PsiParameterList)paramParent).getParameterIndex(param);
- if (parameterIndex > -1) {
- final PsiLambdaExpression lambdaExpression = PsiTreeUtil.getParentOfType(param, PsiLambdaExpression.class);
- if (lambdaExpression != null) {
-
- PsiType type = getFunctionalInterfaceType(lambdaExpression, true, parameterIndex);
- if (type == null) {
- type = getFunctionalInterfaceType(lambdaExpression, false);
- }
- if (type instanceof PsiIntersectionType) {
- final PsiType[] conjuncts = ((PsiIntersectionType)type).getConjuncts();
- for (PsiType conjunct : conjuncts) {
- final PsiType lambdaParameterFromType = getLambdaParameterFromType(parameterIndex, lambdaExpression, conjunct);
- if (lambdaParameterFromType != null) return lambdaParameterFromType;
- }
- } else {
- final PsiType lambdaParameterFromType = getLambdaParameterFromType(parameterIndex, lambdaExpression, type);
- if (lambdaParameterFromType != null) {
- return lambdaParameterFromType;
- }
- }
- }
- }
- }
- return new PsiLambdaParameterType(param);
- }
-
- private static PsiType getLambdaParameterFromType(int parameterIndex, PsiLambdaExpression lambdaExpression, PsiType conjunct) {
- final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(conjunct);
- if (resolveResult != null) {
- final PsiMethod method = getFunctionalInterfaceMethod(conjunct);
- if (method != null) {
- final PsiParameter[] parameters = method.getParameterList().getParameters();
- if (parameterIndex < parameters.length) {
- final PsiType psiType = getSubstitutor(method, resolveResult).substitute(parameters[parameterIndex].getType());
- if (!dependsOnTypeParams(psiType, conjunct, lambdaExpression)) {
- return GenericsUtil.eliminateWildcards(psiType);
- }
- }
- }
- }
- return null;
- }
-
public static boolean notInferredType(PsiType typeByExpression) {
return typeByExpression instanceof PsiMethodReferenceType || typeByExpression instanceof PsiLambdaExpressionType || typeByExpression instanceof PsiLambdaParameterType;
}
@@ -668,19 +430,10 @@
return true;
}
- static class TypeParamsChecker extends PsiTypeVisitor<Boolean> {
+ public static class TypeParamsChecker extends PsiTypeVisitor<Boolean> {
private PsiMethod myMethod;
private final PsiClass myClass;
- private final Set<PsiTypeParameter> myUsedTypeParams = new HashSet<PsiTypeParameter>();
-
- private TypeParamsChecker(PsiMethod method, PsiClass aClass) {
- myMethod = method;
- myClass = aClass;
- }
-
- public TypeParamsChecker(PsiElement expression) {
- this(expression, PsiUtil.resolveGenericsClassInType(getFunctionalInterfaceType(expression, false)).getElement());
- }
+ public final Set<PsiTypeParameter> myUsedTypeParams = new HashSet<PsiTypeParameter>();
public TypeParamsChecker(PsiElement expression, PsiClass aClass) {
myClass = aClass;
diff --git a/java/java-psi-api/src/com/intellij/psi/PsiCapturedWildcardType.java b/java/java-psi-api/src/com/intellij/psi/PsiCapturedWildcardType.java
index 9fe82b3..6de8d02 100644
--- a/java/java-psi-api/src/com/intellij/psi/PsiCapturedWildcardType.java
+++ b/java/java-psi-api/src/com/intellij/psi/PsiCapturedWildcardType.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,8 +15,10 @@
*/
package com.intellij.psi;
+import com.intellij.openapi.util.Comparing;
import com.intellij.psi.search.GlobalSearchScope;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
/**
* @author ven
@@ -24,27 +26,48 @@
public class PsiCapturedWildcardType extends PsiType {
@NotNull private final PsiWildcardType myExistential;
@NotNull private final PsiElement myContext;
-
- public boolean equals(final Object o) {
- if (!(o instanceof PsiCapturedWildcardType)) return false;
- final PsiCapturedWildcardType captured = (PsiCapturedWildcardType)o;
- return myContext.equals(captured.myContext) &&
- myExistential.equals(captured.myExistential);
- }
-
- public int hashCode() {
- return myExistential.hashCode() + 31 * myContext.hashCode();
- }
-
- private PsiCapturedWildcardType(@NotNull PsiWildcardType existential, @NotNull PsiElement context) {
- super(PsiAnnotation.EMPTY_ARRAY);//todo
- myExistential = existential;
- myContext = context;
- }
+ @Nullable private final PsiTypeParameter myParameter;
@NotNull
public static PsiCapturedWildcardType create(@NotNull PsiWildcardType existential, @NotNull PsiElement context) {
- return new PsiCapturedWildcardType(existential, context);
+ return create(existential, context, null);
+ }
+
+ @NotNull
+ public static PsiCapturedWildcardType create(@NotNull PsiWildcardType existential,
+ @NotNull PsiElement context,
+ @Nullable PsiTypeParameter parameter) {
+ return new PsiCapturedWildcardType(existential, context, parameter);
+ }
+
+ private PsiCapturedWildcardType(@NotNull PsiWildcardType existential, @NotNull PsiElement context, @Nullable PsiTypeParameter parameter) {
+ super(PsiAnnotation.EMPTY_ARRAY);
+ myExistential = existential;
+ myContext = context;
+ myParameter = parameter;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (!(o instanceof PsiCapturedWildcardType)) {
+ return false;
+ }
+
+ final PsiCapturedWildcardType captured = (PsiCapturedWildcardType)o;
+ if (!myContext.equals(captured.myContext) || !myExistential.equals(captured.myExistential)) {
+ return false;
+ }
+
+ if (myContext instanceof PsiReferenceExpression && !Comparing.equal(myParameter, captured.myParameter)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return myExistential.hashCode() + 31 * myContext.hashCode();
}
@NotNull
@@ -62,7 +85,6 @@
@NotNull
@Override
public String getInternalCanonicalText() {
- //noinspection HardCodedStringLiteral
return "capture<" + myExistential.getInternalCanonicalText() + '>';
}
@@ -81,6 +103,7 @@
return visitor.visitCapturedWildcardType(this);
}
+ @NotNull
@Override
public GlobalSearchScope getResolveScope() {
return myExistential.getResolveScope();
@@ -101,10 +124,11 @@
if (myExistential.isExtends()) {
return bound;
}
+ else if (bound instanceof PsiCapturedWildcardType) {
+ return PsiWildcardType.createSuper(myContext.getManager(), ((PsiCapturedWildcardType)bound).getUpperBound());
+ }
else {
- return bound instanceof PsiCapturedWildcardType
- ? PsiWildcardType.createSuper(myContext.getManager(), ((PsiCapturedWildcardType)bound).getUpperBound())
- : PsiType.getJavaLangObject(myContext.getManager(), getResolveScope());
+ return PsiType.getJavaLangObject(myContext.getManager(), getResolveScope());
}
}
diff --git a/java/java-psi-api/src/com/intellij/psi/PsiDiamondType.java b/java/java-psi-api/src/com/intellij/psi/PsiDiamondType.java
index 84e8162..e72f63f 100644
--- a/java/java-psi-api/src/com/intellij/psi/PsiDiamondType.java
+++ b/java/java-psi-api/src/com/intellij/psi/PsiDiamondType.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
*/
package com.intellij.psi;
-import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.RecursionGuard;
import com.intellij.openapi.util.RecursionManager;
import org.jetbrains.annotations.NotNull;
@@ -74,24 +73,17 @@
private final List<PsiType> myInferredTypes = new ArrayList<PsiType>();
private String myErrorMessage;
-
private String myNewExpressionPresentableText;
- private Project myProject;
- public DiamondInferenceResult() {
- }
+ public DiamondInferenceResult() { }
- public DiamondInferenceResult(String expressionPresentableText, Project project) {
+ public DiamondInferenceResult(String expressionPresentableText) {
myNewExpressionPresentableText = expressionPresentableText;
- myProject = project;
}
@NotNull
public PsiType[] getTypes() {
- if (myErrorMessage != null) {
- return PsiType.EMPTY_ARRAY;
- }
- return myInferredTypes.toArray(createArray(myInferredTypes.size()));
+ return myErrorMessage == null ? myInferredTypes.toArray(createArray(myInferredTypes.size())) : PsiType.EMPTY_ARRAY;
}
/**
@@ -113,48 +105,12 @@
if (myErrorMessage != null) return;
if (psiType == null) {
myErrorMessage = "Cannot infer type arguments for " + myNewExpressionPresentableText;
- } /*else if (!isValid(psiType)) {
- myErrorMessage = "Cannot infer type arguments for " +
- myNewExpressionPresentableText + " because type " + psiType.getPresentableText() + " inferred is not allowed in current context";
- }*/ else {
+ }
+ else {
myInferredTypes.add(psiType);
}
}
- private static Boolean isValid(PsiType type) {
- return type.accept(new PsiTypeVisitor<Boolean>() {
- @Override
- public Boolean visitType(PsiType type) {
- return !(type instanceof PsiIntersectionType);
- }
-
- @Override
- public Boolean visitCapturedWildcardType(PsiCapturedWildcardType capturedWildcardType) {
- return false;
- }
-
- @Override
- public Boolean visitWildcardType(PsiWildcardType wildcardType) {
- final PsiType bound = wildcardType.getBound();
- if (bound != null) {
- if (bound instanceof PsiIntersectionType) return false;
- return bound.accept(this);
- }
- return true;
- }
-
- @Override
- public Boolean visitClassType(PsiClassType classType) {
- for (PsiType psiType : classType.getParameters()) {
- if (!psiType.accept(this)) {
- return false;
- }
- }
- return true;
- }
- });
- }
-
@Override
public boolean equals(Object o) {
if (this == o) return true;
diff --git a/java/java-psi-api/src/com/intellij/psi/PsiLambdaExpression.java b/java/java-psi-api/src/com/intellij/psi/PsiLambdaExpression.java
index 5f15c50..e8e3dea 100644
--- a/java/java-psi-api/src/com/intellij/psi/PsiLambdaExpression.java
+++ b/java/java-psi-api/src/com/intellij/psi/PsiLambdaExpression.java
@@ -53,4 +53,6 @@
* @return true when lambda declares parameter types explicitly
*/
boolean hasFormalParameterTypes();
+
+ boolean isAcceptable(PsiType leftType, boolean checkReturnType);
}
diff --git a/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceExpression.java b/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceExpression.java
index 01a11a6..1f927d5 100644
--- a/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceExpression.java
+++ b/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceExpression.java
@@ -64,4 +64,9 @@
* @return true if reference is of form ClassType::new
*/
boolean isConstructor();
+
+ /**
+ * Potentially compatible, and if exact - congruent
+ */
+ boolean isAcceptable(PsiType left);
}
diff --git a/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceType.java b/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceType.java
index 437bdc9..08fa9d3 100644
--- a/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceType.java
+++ b/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceType.java
@@ -23,6 +23,7 @@
* A type which represents a function denoted by a method reference.
*/
public class PsiMethodReferenceType extends PsiType {
+ @NotNull
private final PsiMethodReferenceExpression myReference;
public PsiMethodReferenceType(@NotNull final PsiMethodReferenceExpression reference) {
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 28cf4de..133d170 100644
--- a/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceUtil.java
+++ b/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceUtil.java
@@ -16,15 +16,10 @@
package com.intellij.psi;
import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.project.Project;
-import com.intellij.pom.java.LanguageLevel;
-import com.intellij.psi.infos.MethodCandidateInfo;
import com.intellij.psi.util.*;
-import com.intellij.util.Function;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import java.util.HashMap;
import java.util.Map;
/**
@@ -45,7 +40,6 @@
}
public static String checkReturnType(PsiMethodReferenceExpression expression, JavaResolveResult result, PsiType functionalInterfaceType) {
- final QualifierResolveResult qualifierResolveResult = getQualifierResolveResult(expression);
final PsiElement resolve = result.getElement();
if (resolve instanceof PsiMethod) {
PsiSubstitutor subst = result.getSubstitutor();
@@ -61,8 +55,7 @@
PsiType methodReturnType = subst.substitute(returnType);
if (interfaceReturnType != null && interfaceReturnType != PsiType.VOID) {
if (methodReturnType == null) {
- methodReturnType =
- JavaPsiFacade.getElementFactory(expression.getProject()).createType(((PsiMethod)resolve).getContainingClass(), subst);
+ methodReturnType = JavaPsiFacade.getElementFactory(expression.getProject()).createType(((PsiMethod)resolve).getContainingClass(), subst);
}
if (!TypeConversionUtil.isAssignable(interfaceReturnType, methodReturnType, false)) {
return "Bad return type in method reference: cannot convert " + methodReturnType.getCanonicalText() + " to " + interfaceReturnType.getCanonicalText();
@@ -159,101 +152,7 @@
return true;
}
- public static boolean isAcceptable(@Nullable final PsiMethodReferenceExpression methodReferenceExpression, PsiType left) {
- if (methodReferenceExpression == null) return false;
- final PsiElement argsList = PsiTreeUtil.getParentOfType(methodReferenceExpression, PsiExpressionList.class);
- if (MethodCandidateInfo.ourOverloadGuard.currentStack().contains(argsList)) {
- if (!methodReferenceExpression.isPotentiallyCompatible(left)) {
- return false;
- }
- if (!methodReferenceExpression.isExact()) {
- return true;
- }
- }
- if (left instanceof PsiIntersectionType) {
- for (PsiType conjunct : ((PsiIntersectionType)left).getConjuncts()) {
- if (isAcceptable(methodReferenceExpression, conjunct)) return true;
- }
- return false;
- }
- Map<PsiMethodReferenceExpression, PsiType> map = ourRefs.get();
- if (map == null) {
- map = new HashMap<PsiMethodReferenceExpression, PsiType>();
- ourRefs.set(map);
- }
-
- final JavaResolveResult result;
- try {
- if (map.put(methodReferenceExpression, left) != null) {
- return false;
- }
- result = methodReferenceExpression.advancedResolve(false);
- }
- finally {
- map.remove(methodReferenceExpression);
- }
-
- final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(left);
- final PsiMethod method = LambdaUtil.getFunctionalInterfaceMethod(resolveResult);
- if (method != null) {
- final QualifierResolveResult qualifierResolveResult = getQualifierResolveResult(methodReferenceExpression);
- final PsiElement resolve = result.getElement();
- if (resolve instanceof PsiMethod) {
- final MethodSignature signature1 = method.getSignature(LambdaUtil.getSubstitutor(method, resolveResult));
- PsiSubstitutor subst = result.getSubstitutor();
- final MethodSignature signature2 = ((PsiMethod)resolve).getSignature(subst);
-
- if (methodReferenceExpression.isExact()) {
- final PsiType interfaceReturnType = LambdaUtil.getFunctionalInterfaceReturnType(left);
-
- PsiType returnType = PsiTypesUtil.patchMethodGetClassReturnType(methodReferenceExpression, methodReferenceExpression,
- (PsiMethod)resolve, null,
- PsiUtil.getLanguageLevel(methodReferenceExpression));
- if (returnType == null) {
- returnType = ((PsiMethod)resolve).getReturnType();
- }
- PsiType methodReturnType = subst.substitute(returnType);
- if (interfaceReturnType != null && interfaceReturnType != PsiType.VOID) {
- if (methodReturnType == null) {
- methodReturnType = JavaPsiFacade.getElementFactory(methodReferenceExpression.getProject()).createType(((PsiMethod)resolve).getContainingClass(), subst);
- }
- if (!TypeConversionUtil.isAssignable(interfaceReturnType, methodReturnType, false)) return false;
- }
- }
- if (areAcceptable(signature1, signature2, qualifierResolveResult.getContainingClass(), qualifierResolveResult.getSubstitutor(), ((PsiMethod)resolve).isVarArgs())) return true;
- } else if (resolve instanceof PsiClass) {
- final PsiType interfaceReturnType = LambdaUtil.getFunctionalInterfaceReturnType(left);
- if (interfaceReturnType != null) {
- if (interfaceReturnType == PsiType.VOID) return true;
- final PsiParameter[] parameters = method.getParameterList().getParameters();
- if (resolve == JavaPsiFacade.getElementFactory(resolve.getProject()).getArrayClass(PsiUtil.getLanguageLevel(resolve))) {
- if (!arrayCompatibleSignature(parameters, new Function<PsiParameter[], PsiType>() {
- @Override
- public PsiType fun(PsiParameter[] parameters) {
- return resolveResult.getSubstitutor().substitute(parameters[0].getType());
- }
- })) return false;
- final PsiTypeParameter[] typeParameters = ((PsiClass)resolve).getTypeParameters();
- if (typeParameters.length == 1) {
- final PsiType arrayComponentType = result.getSubstitutor().substitute(typeParameters[0]);
- return arrayComponentType != null && TypeConversionUtil.isAssignable(interfaceReturnType, arrayComponentType.createArrayType(), true);
- }
- return false;
- }
- final PsiClassType classType = JavaPsiFacade.getElementFactory(methodReferenceExpression.getProject()).createType((PsiClass)resolve, result.getSubstitutor());
- if (TypeConversionUtil.isAssignable(interfaceReturnType, classType, !((PsiClass)resolve).hasTypeParameters())) {
- if (parameters.length == 0) return true;
- if (parameters.length == 1) {
- if (isReceiverType(resolveResult.getSubstitutor().substitute(parameters[0].getType()), qualifierResolveResult.getContainingClass(), qualifierResolveResult.getSubstitutor())) return true;
- }
- }
- }
- }
- }
- return false;
- }
-
- private static boolean isReceiverType(@Nullable PsiClass aClass, @Nullable PsiClass containingClass) {
+ public static boolean isReceiverType(@Nullable PsiClass aClass, @Nullable PsiClass containingClass) {
return InheritanceUtil.isInheritorOrSelf(aClass, containingClass, true);
}
@@ -300,78 +199,6 @@
return false;
}
- public static boolean areAcceptable(MethodSignature signature1,
- MethodSignature signature2,
- PsiClass psiClass,
- PsiSubstitutor psiSubstitutor,
- boolean isVarargs) {
- int offset = 0;
- final PsiType[] signatureParameterTypes1 = signature1.getParameterTypes();
- final PsiType[] signatureParameterTypes2 = signature2.getParameterTypes();
- if (signatureParameterTypes1.length != signatureParameterTypes2.length) {
- if (signatureParameterTypes1.length == signatureParameterTypes2.length + 1) {
- if (isReceiverType(signatureParameterTypes1[0], psiClass, psiSubstitutor)) {
- offset++;
- }
- else if (!isVarargs){
- return false;
- }
- }
- else if (!isVarargs) {
- return false;
- }
- } else if (isVarargs) {
- if (isReceiverType(signatureParameterTypes1[0], psiClass, psiSubstitutor)) {
- offset++;
- }
- }
-
- final int min = Math.min(signatureParameterTypes2.length, signatureParameterTypes1.length - offset);
- for (int i = 0; i < min; i++) {
- final PsiType type1 = GenericsUtil.eliminateWildcards(psiSubstitutor.substitute(signatureParameterTypes1[offset + i]));
- if (isVarargs && i == min - 1) {
- if (!(signatureParameterTypes2[i] instanceof PsiArrayType)) {
- return false;
- }
- if (!TypeConversionUtil.isAssignable(((PsiArrayType)signatureParameterTypes2[i]).getComponentType(), type1) &&
- !TypeConversionUtil.isAssignable(signatureParameterTypes2[i], type1)) {
- return false;
- }
- }
- else {
- if (!TypeConversionUtil.isAssignable(signatureParameterTypes2[i], type1)) {
- return false;
- }
- }
- }
- return true;
- }
-
-
- public static boolean onArrayType(PsiClass containingClass, MethodSignature signature) {
- if (arrayCompatibleSignature(signature.getParameterTypes(), new Function<PsiType[], PsiType>() {
- @Override
- public PsiType fun(PsiType[] types) {
- return types[0];
- }
- })) {
- if (containingClass != null) {
- final Project project = containingClass.getProject();
- final LanguageLevel level = PsiUtil.getLanguageLevel(containingClass);
- return containingClass == JavaPsiFacade.getElementFactory(project).getArrayClass(level);
- }
- }
- return false;
- }
-
- private static <T> boolean arrayCompatibleSignature(T[] paramTypes, Function<T[], PsiType> fun) {
- if (paramTypes.length == 1) {
- final PsiType paramType = fun.fun(paramTypes);
- if (paramType != null && TypeConversionUtil.isAssignable(PsiType.INT, paramType)) return true;
- }
- return false;
- }
-
private static PsiType getExpandedType(PsiType type, @NotNull PsiElement typeElement) {
if (type instanceof PsiArrayType) {
type = JavaPsiFacade.getElementFactory(typeElement.getProject())
diff --git a/java/java-psi-api/src/com/intellij/psi/PsiPrimitiveType.java b/java/java-psi-api/src/com/intellij/psi/PsiPrimitiveType.java
index 6797e84..dd6b0d4 100644
--- a/java/java-psi-api/src/com/intellij/psi/PsiPrimitiveType.java
+++ b/java/java-psi-api/src/com/intellij/psi/PsiPrimitiveType.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,18 +31,11 @@
* Represents primitive types of Java language.
*/
public class PsiPrimitiveType extends PsiType {
+ private static final Map<String, PsiPrimitiveType> ourQNameToUnboxed = new THashMap<String, PsiPrimitiveType>();
+ private static final Map<PsiPrimitiveType, String> ourUnboxedToQName = new THashMap<PsiPrimitiveType, String>();
+
private final String myName;
- public PsiPrimitiveType(@NonNls @NotNull String name, PsiAnnotation[] annotations) {
- super(annotations);
- myName = name;
- }
-
- @NonNls
- private static final Map<String, PsiPrimitiveType> ourQNameToUnboxed = new THashMap<String, PsiPrimitiveType>();
- @NonNls
- private static final Map<PsiPrimitiveType, String> ourUnboxedToQName = new THashMap<PsiPrimitiveType, String>();
- //registering ctor
PsiPrimitiveType(@NonNls @NotNull String name, @NonNls String boxedName) {
this(name, PsiAnnotation.EMPTY_ARRAY);
if (boxedName != null) {
@@ -51,6 +44,11 @@
}
}
+ public PsiPrimitiveType(@NonNls @NotNull String name, @NotNull PsiAnnotation[] annotations) {
+ super(annotations);
+ myName = name;
+ }
+
@NotNull
@Override
public String getPresentableText() {
diff --git a/java/java-psi-api/src/com/intellij/psi/PsiType.java b/java/java-psi-api/src/com/intellij/psi/PsiType.java
index 3b95be0..cfbf026 100644
--- a/java/java-psi-api/src/com/intellij/psi/PsiType.java
+++ b/java/java-psi-api/src/com/intellij/psi/PsiType.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -73,21 +73,22 @@
}
/**
- * @return text of the type that can be presented to a user (non-qualified references, with annotations).
+ * Returns text of the type that can be presented to a user (references normally non-qualified).
*/
@NonNls
@NotNull
public abstract String getPresentableText();
/**
- * @return text of the type (fully-qualified references, no annotations).
+ * Returns canonical representation of the type (all references fully-qualified).
*/
@NonNls
@NotNull
public abstract String getCanonicalText();
/**
- * @return text of the type (fully-qualified references, with annotations).
+ * Return canonical text of the type with some internal details added for presentational purposes. Use with care.
+ * todo[r.sh] merge with getPresentableText()
*/
@NonNls
@NotNull
diff --git a/java/java-psi-api/src/com/intellij/psi/codeStyle/ReferenceAdjuster.java b/java/java-psi-api/src/com/intellij/psi/codeStyle/ReferenceAdjuster.java
index 8be4e1d..ff1656f 100644
--- a/java/java-psi-api/src/com/intellij/psi/codeStyle/ReferenceAdjuster.java
+++ b/java/java-psi-api/src/com/intellij/psi/codeStyle/ReferenceAdjuster.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,16 +19,17 @@
import com.intellij.lang.Language;
import com.intellij.lang.LanguageExtension;
import com.intellij.openapi.project.Project;
+import org.jetbrains.annotations.NotNull;
/**
* @author Max Medvedev
*/
public interface ReferenceAdjuster {
- ASTNode process(ASTNode element, boolean addImports, boolean incompleteCode, boolean useFqInJavadoc, boolean useFqInCode);
- ASTNode process(ASTNode element, boolean addImports, boolean incompleteCode, Project project);
+ ASTNode process(@NotNull ASTNode element, boolean addImports, boolean incompleteCode, boolean useFqInJavadoc, boolean useFqInCode);
+ ASTNode process(@NotNull ASTNode element, boolean addImports, boolean incompleteCode, Project project);
- void processRange(ASTNode element, int startOffset, int endOffset, boolean useFqInJavadoc, boolean useFqInCode);
- void processRange(ASTNode element, int startOffset, int endOffset, Project project);
+ void processRange(@NotNull ASTNode element, int startOffset, int endOffset, boolean useFqInJavadoc, boolean useFqInCode);
+ void processRange(@NotNull ASTNode element, int startOffset, int endOffset, Project project);
class Extension extends LanguageExtension<ReferenceAdjuster> {
private static final Extension INSTANCE = new Extension();
@@ -37,7 +38,7 @@
super("com.intellij.codeStyle.ReferenceAdjuster");
}
- public static ReferenceAdjuster getReferenceAdjuster(Language language) {
+ public static ReferenceAdjuster getReferenceAdjuster(@NotNull Language language) {
return INSTANCE.forLanguage(language);
}
}
diff --git a/java/java-psi-api/src/com/intellij/psi/impl/source/resolve/ParameterTypeInferencePolicy.java b/java/java-psi-api/src/com/intellij/psi/impl/source/resolve/ParameterTypeInferencePolicy.java
index 75b3df3..e597cdb 100644
--- a/java/java-psi-api/src/com/intellij/psi/impl/source/resolve/ParameterTypeInferencePolicy.java
+++ b/java/java-psi-api/src/com/intellij/psi/impl/source/resolve/ParameterTypeInferencePolicy.java
@@ -38,6 +38,7 @@
/**
* @return true when Object bounds would be rejected in the hope that outer call could provide more information. Should be used for java 1.8 only
*/
+ @Deprecated
public boolean allowPostponeInference() {
return false;
}
diff --git a/java/java-psi-api/src/com/intellij/psi/infos/MethodCandidateInfo.java b/java/java-psi-api/src/com/intellij/psi/infos/MethodCandidateInfo.java
index 9b9174b..2afc76a 100644
--- a/java/java-psi-api/src/com/intellij/psi/infos/MethodCandidateInfo.java
+++ b/java/java-psi-api/src/com/intellij/psi/infos/MethodCandidateInfo.java
@@ -206,18 +206,22 @@
return inferTypeArguments(policy, arguments, true);
}
else {
- PsiSubstitutor incompleteSubstitutor = super.getSubstitutor();
- PsiMethod method = getElement();
- if (method != null) {
- PsiTypeParameter[] typeParams = method.getTypeParameters();
- for (int i = 0; i < myTypeArguments.length && i < typeParams.length; i++) {
- incompleteSubstitutor = incompleteSubstitutor.put(typeParams[i], myTypeArguments[i]);
- }
- }
- return incompleteSubstitutor;
+ return typeArgumentsSubstitutor();
}
}
+ public PsiSubstitutor typeArgumentsSubstitutor() {
+ PsiSubstitutor incompleteSubstitutor = super.getSubstitutor();
+ PsiMethod method = getElement();
+ if (method != null) {
+ PsiTypeParameter[] typeParams = method.getTypeParameters();
+ for (int i = 0; i < myTypeArguments.length && i < typeParams.length; i++) {
+ incompleteSubstitutor = incompleteSubstitutor.put(typeParams[i], myTypeArguments[i]);
+ }
+ }
+ return incompleteSubstitutor;
+ }
+
@NotNull
public PsiSubstitutor inferTypeArguments(@NotNull ParameterTypeInferencePolicy policy,
@NotNull PsiExpression[] arguments,
diff --git a/java/java-psi-api/src/com/intellij/psi/util/InheritanceUtil.java b/java/java-psi-api/src/com/intellij/psi/util/InheritanceUtil.java
index 304d6fa..fa1c6c9 100644
--- a/java/java-psi-api/src/com/intellij/psi/util/InheritanceUtil.java
+++ b/java/java-psi-api/src/com/intellij/psi/util/InheritanceUtil.java
@@ -62,7 +62,7 @@
return true;
}
- @Contract("null, _ -> fail")
+ @Contract("null, _ -> false")
public static boolean isInheritor(@Nullable PsiType type, @NotNull @NonNls final String baseClassName) {
if (type instanceof PsiClassType) {
return isInheritor(((PsiClassType)type).resolve(), baseClassName);
@@ -71,12 +71,12 @@
return false;
}
- @Contract("null, _ -> fail")
+ @Contract("null, _ -> false")
public static boolean isInheritor(@Nullable PsiClass psiClass, @NotNull final String baseClassName) {
return isInheritor(psiClass, false, baseClassName);
}
- @Contract("null, _, _ -> fail")
+ @Contract("null, _, _ -> false")
public static boolean isInheritor(@Nullable PsiClass psiClass, final boolean strict, @NotNull final String baseClassName) {
if (psiClass == null) {
return false;
diff --git a/java/java-psi-api/src/com/intellij/psi/util/PsiUtil.java b/java/java-psi-api/src/com/intellij/psi/util/PsiUtil.java
index 262a4bb..32a9879 100644
--- a/java/java-psi-api/src/com/intellij/psi/util/PsiUtil.java
+++ b/java/java-psi-api/src/com/intellij/psi/util/PsiUtil.java
@@ -687,7 +687,7 @@
final PsiType substituted = substitutor.substitute(typeParameter);
if (substituted instanceof PsiWildcardType) {
if (substitutionMap == null) substitutionMap = new HashMap<PsiTypeParameter, PsiType>(substitutor.getSubstitutionMap());
- substitutionMap.put(typeParameter, PsiCapturedWildcardType.create((PsiWildcardType)substituted, context));
+ substitutionMap.put(typeParameter, PsiCapturedWildcardType.create((PsiWildcardType)substituted, context, typeParameter));
}
}
@@ -1065,11 +1065,11 @@
return className + "." + member.getName();
}
- static boolean checkSameExpression(PsiExpression templateExpr, final PsiExpression expression) {
+ static boolean checkSameExpression(PsiElement templateExpr, final PsiExpression expression) {
return templateExpr.equals(skipParenthesizedExprDown(expression));
}
- public static boolean isCondition(PsiExpression expr, PsiElement parent) {
+ public static boolean isCondition(PsiElement expr, PsiElement parent) {
if (parent instanceof PsiIfStatement) {
if (checkSameExpression(expr, ((PsiIfStatement)parent).getCondition())) {
return true;
diff --git a/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java b/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java
index 385e3a6..2bf734b 100644
--- a/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java
+++ b/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java
@@ -105,6 +105,12 @@
final int toTypeRank = getTypeRank(toType);
if (!toIsPrimitive) {
if (fromTypeRank == toTypeRank) return true;
+ if (toType instanceof PsiIntersectionType) {
+ for (PsiType type : ((PsiIntersectionType)toType).getConjuncts()) {
+ if (!areTypesConvertible(fromType, type)) return false;
+ }
+ return true;
+ }
// JLS 5.5: A value of a primitive type can be cast to a reference type by boxing conversion(see 5.1.7)
if (!(toType instanceof PsiClassType)) return false;
PsiClass toClass = ((PsiClassType)toType).resolve();
@@ -700,7 +706,7 @@
final PsiType lType = ((PsiMethodReferenceType)left).getExpression().getFunctionalInterfaceType();
return Comparing.equal(rType, lType);
}
- return PsiMethodReferenceUtil.isAcceptable(methodReferenceExpression, left);
+ return methodReferenceExpression.isAcceptable(left);
}
if (right instanceof PsiLambdaExpressionType) {
final PsiLambdaExpression rLambdaExpression = ((PsiLambdaExpressionType)right).getExpression();
@@ -710,7 +716,7 @@
final PsiType lType = lLambdaExpression.getFunctionalInterfaceType();
return Comparing.equal(rType, lType);
}
- return !(left instanceof PsiArrayType) && LambdaUtil.isAcceptable(rLambdaExpression, left, false);
+ return !(left instanceof PsiArrayType) && rLambdaExpression.isAcceptable(left, false);
}
if (left instanceof PsiIntersectionType) {
diff --git a/java/java-psi-impl/src/com/intellij/core/JavaCoreApplicationEnvironment.java b/java/java-psi-impl/src/com/intellij/core/JavaCoreApplicationEnvironment.java
index cfe57a3..8e7fcdb 100644
--- a/java/java-psi-impl/src/com/intellij/core/JavaCoreApplicationEnvironment.java
+++ b/java/java-psi-impl/src/com/intellij/core/JavaCoreApplicationEnvironment.java
@@ -44,12 +44,13 @@
import com.intellij.psi.impl.source.tree.PlainTextASTFactory;
import com.intellij.psi.presentation.java.*;
import com.intellij.psi.stubs.BinaryFileStubBuilders;
+import org.jetbrains.annotations.NotNull;
/**
* @author yole
*/
public class JavaCoreApplicationEnvironment extends CoreApplicationEnvironment {
- public JavaCoreApplicationEnvironment(Disposable parentDisposable) {
+ public JavaCoreApplicationEnvironment(@NotNull Disposable parentDisposable) {
super(parentDisposable);
registerFileType(JavaClassFileType.INSTANCE, "class");
diff --git a/java/java-psi-impl/src/com/intellij/lang/java/parser/ExpressionParser.java b/java/java-psi-impl/src/com/intellij/lang/java/parser/ExpressionParser.java
index a8a2ff5..38b8545 100644
--- a/java/java-psi-impl/src/com/intellij/lang/java/parser/ExpressionParser.java
+++ b/java/java-psi-impl/src/com/intellij/lang/java/parser/ExpressionParser.java
@@ -28,7 +28,9 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import static com.intellij.lang.PsiBuilderUtil.drop;
import static com.intellij.lang.PsiBuilderUtil.expect;
+import static com.intellij.lang.PsiBuilderUtil.rollbackTo;
import static com.intellij.lang.java.parser.JavaParserUtil.*;
public class ExpressionParser {
@@ -342,7 +344,7 @@
if (dotTokenType == JavaTokenType.CLASS_KEYWORD && exprType(expr) == JavaElementType.REFERENCE_EXPRESSION) {
if (breakPoint == BreakPoint.P1 && builder.getCurrentOffset() == breakOffset) {
error(builder, JavaErrorMessages.message("expected.identifier"));
- PsiBuilderUtil.drop(startMarker, dotPos);
+ drop(startMarker, dotPos);
return expr;
}
@@ -701,9 +703,7 @@
PsiBuilder.Marker anno = myParser.getDeclarationParser().parseAnnotations(builder);
IElementType tokenType = builder.getTokenType();
if (tokenType == JavaTokenType.IDENTIFIER) {
- if (anno != null) {
- anno.rollbackTo();
- }
+ rollbackTo(anno);
refOrType = myParser.getReferenceParser().parseJavaCodeReference(builder, true, true, true, true);
if (refOrType == null) {
error(builder, JavaErrorMessages.message("expected.identifier"));
@@ -732,9 +732,10 @@
return newExpr;
}
- myParser.getDeclarationParser().parseAnnotations(builder);
+ anno = myParser.getDeclarationParser().parseAnnotations(builder);
if (builder.getTokenType() != JavaTokenType.LBRACKET) {
+ rollbackTo(anno);
error(builder, refOrType == null ? JavaErrorMessages.message("expected.lbracket") : JavaErrorMessages.message("expected.lparen.or.lbracket"));
newExpr.done(JavaElementType.NEW_EXPRESSION);
return newExpr;
@@ -743,9 +744,12 @@
int bracketCount = 0;
int dimCount = 0;
while (true) {
- myParser.getDeclarationParser().parseAnnotations(builder);
+ anno = myParser.getDeclarationParser().parseAnnotations(builder);
- if (builder.getTokenType() != JavaTokenType.LBRACKET) break;
+ if (builder.getTokenType() != JavaTokenType.LBRACKET) {
+ rollbackTo(anno);
+ break;
+ }
builder.advanceLexer();
if (bracketCount == dimCount) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/ClassFileViewProvider.java b/java/java-psi-impl/src/com/intellij/psi/ClassFileViewProvider.java
index bdcc3f1..ef89a6c 100644
--- a/java/java-psi-impl/src/com/intellij/psi/ClassFileViewProvider.java
+++ b/java/java-psi-impl/src/com/intellij/psi/ClassFileViewProvider.java
@@ -31,8 +31,8 @@
super(manager, file);
}
- public ClassFileViewProvider(@NotNull final PsiManager manager, @NotNull final VirtualFile virtualFile, final boolean physical) {
- super(manager, virtualFile, physical);
+ public ClassFileViewProvider(@NotNull final PsiManager manager, @NotNull final VirtualFile virtualFile, final boolean eventSystemEnabled) {
+ super(manager, virtualFile, eventSystemEnabled);
}
@Override
diff --git a/java/java-psi-impl/src/com/intellij/psi/ClassFileViewProviderFactory.java b/java/java-psi-impl/src/com/intellij/psi/ClassFileViewProviderFactory.java
index d9b7711..de870b9 100644
--- a/java/java-psi-impl/src/com/intellij/psi/ClassFileViewProviderFactory.java
+++ b/java/java-psi-impl/src/com/intellij/psi/ClassFileViewProviderFactory.java
@@ -29,20 +29,20 @@
*/
public class ClassFileViewProviderFactory implements FileViewProviderFactory {
@Override
- public FileViewProvider createFileViewProvider(@NotNull VirtualFile file, Language language, @NotNull PsiManager manager, boolean physical) {
+ public FileViewProvider createFileViewProvider(@NotNull VirtualFile file, Language language, @NotNull PsiManager manager, boolean eventSystemEnabled) {
ClassFileDecompilers.Decompiler decompiler = ClassFileDecompilers.find(file);
if (decompiler instanceof Full) {
- return ((Full)decompiler).createFileViewProvider(file, manager, physical);
+ return ((Full)decompiler).createFileViewProvider(file, manager, eventSystemEnabled);
}
for (ContentBasedFileSubstitutor processor : Extensions.getExtensions(ContentBasedFileSubstitutor.EP_NAME)) {
Language lang = processor.obtainLanguageForFile(file);
if (lang != null) {
FileViewProviderFactory factory = LanguageFileViewProviders.INSTANCE.forLanguage(language);
- return factory.createFileViewProvider(file, language, manager, physical);
+ return factory.createFileViewProvider(file, language, manager, eventSystemEnabled);
}
}
- return new ClassFileViewProvider(manager, file, physical);
+ return new ClassFileViewProvider(manager, file, eventSystemEnabled);
}
}
\ No newline at end of file
diff --git a/java/java-psi-impl/src/com/intellij/psi/PsiDiamondTypeImpl.java b/java/java-psi-impl/src/com/intellij/psi/PsiDiamondTypeImpl.java
index 2da9534..e7ebfca 100644
--- a/java/java-psi-impl/src/com/intellij/psi/PsiDiamondTypeImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/PsiDiamondTypeImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,13 +38,14 @@
import java.util.Set;
/**
- * User: anna
- * Date: Jul 30, 2010
+ * @author anna
+ * @since Jul 30, 2010
*/
public class PsiDiamondTypeImpl extends PsiDiamondType {
+ private static final Logger LOG = Logger.getInstance("#" + PsiDiamondTypeImpl.class.getName());
+
private final PsiManager myManager;
private final PsiTypeElement myTypeElement;
- private static final Logger LOG = Logger.getInstance("#" + PsiDiamondTypeImpl.class.getName());
public PsiDiamondTypeImpl(PsiManager manager, PsiTypeElement psiTypeElement) {
super(PsiAnnotation.EMPTY_ARRAY);
@@ -77,7 +78,7 @@
@Override
public boolean equalsToText(@NotNull @NonNls String text) {
- return text != null && text.isEmpty();
+ return text.isEmpty();
}
@Override
@@ -85,6 +86,7 @@
return visitor.visitDiamondType(this);
}
+ @NotNull
@Override
public GlobalSearchScope getResolveScope() {
return GlobalSearchScope.allScope(myManager.getProject());
@@ -145,7 +147,7 @@
return null;
}
staticFactoryRef.set(staticFactory);
-
+
return inferTypeParametersForStaticFactory(staticFactory, newExpression, context);
}
});
@@ -161,8 +163,7 @@
final PsiTypeParameter[] classParameters = psiClass.getTypeParameters();
final PsiJavaCodeReferenceElement classOrAnonymousClassReference = newExpression.getClassOrAnonymousClassReference();
LOG.assertTrue(classOrAnonymousClassReference != null);
- final DiamondInferenceResult
- result = new DiamondInferenceResult(classOrAnonymousClassReference.getReferenceName() + "<>", newExpression.getProject());
+ final DiamondInferenceResult result = new DiamondInferenceResult(classOrAnonymousClassReference.getReferenceName() + "<>");
for (PsiTypeParameter parameter : parameters) {
for (PsiTypeParameter classParameter : classParameters) {
if (Comparing.strEqual(classParameter.getName(), parameter.getName())) {
@@ -246,7 +247,7 @@
} else if (reference != null && qualifier == null && containingClass.getContainingClass() != null) {
qualifiedName = null;
}
-
+
buf.append(qualifiedName != null ? qualifiedName : containingClass.getName());
final PsiTypeParameter[] parameters = containingClass.getTypeParameters();
buf.append("<");
@@ -341,8 +342,8 @@
public Boolean visitClassType(PsiClassType classType) {
for (PsiType psiType : classType.getParameters()) {
if (psiType != null) {
- final Boolean typaParamFound = psiType.accept(this);
- if (typaParamFound != null && typaParamFound) return true;
+ final Boolean typeParamFound = psiType.accept(this);
+ if (typeParamFound != null && typeParamFound) return true;
}
}
final PsiClass aClass = PsiUtil.resolveClassInType(classType);
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiElementFactoryImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiElementFactoryImpl.java
index 8aedad8..b427f91 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiElementFactoryImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiElementFactoryImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -165,7 +165,7 @@
final PsiClassType.ClassResolveResult resolveResult = type.resolveGenerics();
final PsiClass refClass = resolveResult.getElement();
assert refClass != null : type;
- return new LightClassReference(myManager, type.getInternalCanonicalText(), refClass, resolveResult.getSubstitutor());
+ return new LightClassReference(myManager, type.getCanonicalText(), refClass, resolveResult.getSubstitutor());
}
@NotNull
@@ -543,7 +543,7 @@
@NotNull
@Override
public PsiKeyword createKeyword(@NotNull final String text) throws IncorrectOperationException {
- if (!JavaPsiFacade.getInstance(myManager.getProject()).getNameHelper().isKeyword(text)) {
+ if (!PsiNameHelper.getInstance(myManager.getProject()).isKeyword(text)) {
throw new IncorrectOperationException("\"" + text + "\" is not a keyword.");
}
return new LightKeyword(myManager, text);
@@ -579,7 +579,7 @@
if (packageName.isEmpty()) {
throw new IncorrectOperationException("Cannot create import statement for default package.");
}
- if (!JavaPsiFacade.getInstance(myManager.getProject()).getNameHelper().isQualifiedName(packageName)) {
+ if (!PsiNameHelper.getInstance(myManager.getProject()).isQualifiedName(packageName)) {
throw new IncorrectOperationException("Incorrect package name: \"" + packageName + "\".");
}
@@ -590,30 +590,38 @@
@NotNull
@Override
- public PsiDeclarationStatement createVariableDeclarationStatement(@NotNull final String name,
- @NotNull final PsiType type,
- final PsiExpression initializer) throws IncorrectOperationException {
- if (!JavaPsiFacade.getInstance(myManager.getProject()).getNameHelper().isIdentifier(name)) {
+ public PsiDeclarationStatement createVariableDeclarationStatement(@NotNull String name,
+ @NotNull PsiType type,
+ @Nullable PsiExpression initializer) throws IncorrectOperationException {
+ if (!isIdentifier(name)) {
throw new IncorrectOperationException("\"" + name + "\" is not an identifier.");
}
if (PsiType.NULL.equals(type)) {
throw new IncorrectOperationException("Cannot create variable with type \"null\".");
}
- @NonNls final String text = "X " + name + (initializer != null ? " = x" : "") + ";";
+ String text = "X " + name + (initializer != null ? " = x" : "") + ";";
+ PsiDeclarationStatement statement = (PsiDeclarationStatement)createStatementFromText(text, null);
- final PsiDeclarationStatement statement = (PsiDeclarationStatement)createStatementFromText(text, null);
- final PsiVariable variable = (PsiVariable)statement.getDeclaredElements()[0];
+ PsiVariable variable = (PsiVariable)statement.getDeclaredElements()[0];
replace(variable.getTypeElement(), createTypeElement(type), text);
- PsiUtil.setModifierProperty(variable, PsiModifier.FINAL,
- JavaCodeStyleSettingsFacade.getInstance(myManager.getProject()).isGenerateFinalLocals());
+
+ boolean generateFinalLocals = JavaCodeStyleSettingsFacade.getInstance(myManager.getProject()).isGenerateFinalLocals();
+ PsiUtil.setModifierProperty(variable, PsiModifier.FINAL, generateFinalLocals);
+
if (initializer != null) {
replace(variable.getInitializer(), initializer, text);
}
+
GeneratedMarkerVisitor.markGenerated(statement);
return statement;
}
+ private static void replace(@Nullable PsiElement original, @NotNull PsiElement replacement, @NotNull String message) {
+ assert original != null : message;
+ original.replace(replacement);
+ }
+
@NotNull
@Override
public PsiDocTag createParamTag(@NotNull final String parameterName, @NonNls final String description) throws IncorrectOperationException {
@@ -718,11 +726,6 @@
return statements[0];
}
- private static void replace(final PsiElement original, final PsiElement replacement, final String message) {
- assert original != null : message;
- original.replace(replacement);
- }
-
private static final JavaParserUtil.ParserWrapper CATCH_SECTION = new JavaParserUtil.ParserWrapper() {
@Override
public void parse(final PsiBuilder builder) {
@@ -782,6 +785,6 @@
}
private boolean isIdentifier(@NotNull String name) {
- return JavaPsiFacade.getInstance(myManager.getProject()).getNameHelper().isIdentifier(name);
+ return PsiNameHelper.getInstance(myManager.getProject()).isIdentifier(name);
}
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiSubstitutorImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiSubstitutorImpl.java
index 723f509..57390de 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiSubstitutorImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiSubstitutorImpl.java
@@ -389,11 +389,21 @@
}
}
}
+ } else if (substituted instanceof PsiWildcardType && ((PsiWildcardType)substituted).isSuper()) {
+ final PsiType erasure = TypeConversionUtil.erasure(((PsiWildcardType)substituted).getBound());
+ if (erasure != null) {
+ final PsiType[] boundTypes = typeParameter.getExtendsListTypes();
+ for (PsiType boundType : boundTypes) {
+ if (TypeConversionUtil.isAssignable(boundType, erasure) || TypeConversionUtil.isAssignable(erasure, boundType)) {
+ return boundType;
+ }
+ }
+ }
}
if (captureContext != null) {
substituted = oldSubstituted instanceof PsiCapturedWildcardType && substituted == ((PsiCapturedWildcardType)oldSubstituted).getWildcard()
- ? oldSubstituted : PsiCapturedWildcardType.create((PsiWildcardType)substituted, captureContext);
+ ? oldSubstituted : PsiCapturedWildcardType.create((PsiWildcardType)substituted, captureContext, typeParameter);
}
return substituted;
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsTypeParameterImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsTypeParameterImpl.java
index cf6e159..259d93a 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsTypeParameterImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsTypeParameterImpl.java
@@ -307,7 +307,7 @@
@NonNls
public String toString() {
- return "PsiTypeParameter";
+ return "PsiTypeParameter:" + getName();
}
@Override
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/file/PsiPackageImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/file/PsiPackageImpl.java
index bab137c..56cb356 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/file/PsiPackageImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/file/PsiPackageImpl.java
@@ -232,7 +232,11 @@
Arrays.sort(array, new Comparator<PsiClass>() {
@Override
public int compare(PsiClass o1, PsiClass o2) {
- return scope.compare(o2.getContainingFile().getVirtualFile(), o1.getContainingFile().getVirtualFile());
+ VirtualFile file1 = o1.getContainingFile().getVirtualFile();
+ VirtualFile file2 = o2.getContainingFile().getVirtualFile();
+ if (file1 == null) return file2 == null ? 0 : -1;
+ if (file2 == null) return 1;
+ return scope.compare(file2, file1);
}
});
return array;
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiParameterImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiParameterImpl.java
index 287fba0..ae08b6d 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiParameterImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiParameterImpl.java
@@ -32,6 +32,7 @@
import com.intellij.psi.search.SearchScope;
import com.intellij.psi.stubs.IStubElementType;
import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.psi.util.PsiUtil;
import com.intellij.reference.SoftReference;
import com.intellij.ui.RowIcon;
import com.intellij.util.IncorrectOperationException;
@@ -59,6 +60,53 @@
super(node);
}
+ public static PsiType getLambdaParameterType(PsiParameter param) {
+ final PsiElement paramParent = param.getParent();
+ if (paramParent instanceof PsiParameterList) {
+ final int parameterIndex = ((PsiParameterList)paramParent).getParameterIndex(param);
+ if (parameterIndex > -1) {
+ final PsiLambdaExpression lambdaExpression = PsiTreeUtil.getParentOfType(param, PsiLambdaExpression.class);
+ if (lambdaExpression != null) {
+
+ PsiType type = LambdaUtil.getFunctionalInterfaceType(lambdaExpression, true);
+ if (type == null) {
+ type = LambdaUtil.getFunctionalInterfaceType(lambdaExpression, false);
+ }
+ if (type instanceof PsiIntersectionType) {
+ final PsiType[] conjuncts = ((PsiIntersectionType)type).getConjuncts();
+ for (PsiType conjunct : conjuncts) {
+ final PsiType lambdaParameterFromType = getLambdaParameterFromType(parameterIndex, lambdaExpression, conjunct);
+ if (lambdaParameterFromType != null) return lambdaParameterFromType;
+ }
+ } else {
+ final PsiType lambdaParameterFromType = getLambdaParameterFromType(parameterIndex, lambdaExpression, type);
+ if (lambdaParameterFromType != null) {
+ return lambdaParameterFromType;
+ }
+ }
+ }
+ }
+ }
+ return new PsiLambdaParameterType(param);
+ }
+
+ private static PsiType getLambdaParameterFromType(int parameterIndex, PsiLambdaExpression lambdaExpression, PsiType conjunct) {
+ final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(conjunct);
+ if (resolveResult != null) {
+ final PsiMethod method = LambdaUtil.getFunctionalInterfaceMethod(conjunct);
+ if (method != null) {
+ final PsiParameter[] parameters = method.getParameterList().getParameters();
+ if (parameterIndex < parameters.length) {
+ final PsiType psiType = LambdaUtil.getSubstitutor(method, resolveResult).substitute(parameters[parameterIndex].getType());
+ if (!LambdaUtil.dependsOnTypeParams(psiType, conjunct, lambdaExpression)) {
+ return GenericsUtil.eliminateWildcards(psiType);
+ }
+ }
+ }
+ }
+ return null;
+ }
+
@Override
public void subtreeChanged() {
super.subtreeChanged();
@@ -138,7 +186,7 @@
PsiTypeElement typeElement = getTypeElement();
if (typeElement == null) {
assert isLambdaParameter() : this;
- return LambdaUtil.getLambdaParameterType(this);
+ return getLambdaParameterType(this);
}
else {
return JavaSharedImplUtil.getType(typeElement, getParameterIdentifier());
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/GraphInferencePolicy.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/GraphInferencePolicy.java
deleted file mode 100644
index b6a0baa..0000000
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/GraphInferencePolicy.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright 2000-2013 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.psi.impl.source.resolve;
-
-import com.intellij.psi.*;
-import com.intellij.psi.scope.MethodProcessorSetupFailedException;
-import com.intellij.psi.scope.processor.MethodCandidatesProcessor;
-import com.intellij.psi.scope.util.PsiScopesUtil;
-import com.intellij.psi.util.PsiUtil;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.*;
-
-/**
-* User: anna
-* Date: 2/14/13
-*/
-public class GraphInferencePolicy extends ProcessCandidateParameterTypeInferencePolicy {
- private static final ThreadLocal<Map<PsiExpression, Map<JavaResolveResult, PsiSubstitutor>>> ourResults = new ThreadLocal<Map<PsiExpression, Map<JavaResolveResult, PsiSubstitutor>>>() {
- @Override
- protected Map<PsiExpression, Map<JavaResolveResult, PsiSubstitutor>> initialValue() {
- return new WeakHashMap<PsiExpression, Map<JavaResolveResult, PsiSubstitutor>>();
- }
- };
-
- @Override
- protected List<PsiExpression> getExpressions(PsiExpression[] expressions, int i) {
- final List<PsiExpression> list = Arrays.asList(expressions);
- list.set(i, null);
- return list;
- }
-
- @Override
- protected PsiSubstitutor getSubstitutor(PsiCallExpression contextCall, PsiExpression[] expressions, int i, JavaResolveResult result) {
- Map<JavaResolveResult, PsiSubstitutor> map = ourResults.get().get(contextCall);
- if (map != null) {
- final PsiSubstitutor substitutor = map.get(result);
- if (substitutor != PsiSubstitutor.UNKNOWN && substitutor != null && substitutor.isValid()) return substitutor;
- }
- final PsiSubstitutor substitutor = super.getSubstitutor(contextCall, expressions, i, result);
- if (map != null) {
- map.put(result, substitutor);
- }
- return substitutor;
- }
-
- @NotNull
- @Override
- protected JavaResolveResult[] getResults(@NotNull PsiCallExpression contextCall, final int exprIdx)
- throws MethodProcessorSetupFailedException {
- Map<JavaResolveResult, PsiSubstitutor> map = ourResults.get().get(contextCall);
- if (map != null) {
- final Set<JavaResolveResult> results = map.keySet();
- return results.toArray(new JavaResolveResult[results.size()]);
- }
-
- PsiFile containingFile = contextCall.getContainingFile();
- final MethodCandidatesProcessor processor = new MethodCandidatesProcessor(contextCall, containingFile) {
- @Override
- protected PsiType[] getExpressionTypes(PsiExpressionList argumentList) {
- if (argumentList != null) {
- final PsiExpression[] expressions = argumentList.getExpressions();
- final PsiType[] types = PsiType.createArray(expressions.length);
- for (int i = 0; i < expressions.length; i++) {
- if (i != exprIdx) {
- types[i] = expressions[i].getType();
- }
- else {
- types[i] = PsiType.NULL;
- }
- }
- return types;
- }
- else {
- return null;
- }
- }
- };
- PsiScopesUtil.setupAndRunProcessor(processor, contextCall, false);
- final JavaResolveResult[] results = processor.getResult();
-
- map = new WeakHashMap<JavaResolveResult, PsiSubstitutor>();
- ourResults.get().put(contextCall, map);
- for (JavaResolveResult result : results) {
- map.put(result, PsiSubstitutor.UNKNOWN);
- }
- return results;
- }
-
- public static void forget(PsiElement parent) {
- if (parent instanceof PsiExpression) {
- PsiElement gParent = PsiUtil.skipParenthesizedExprUp(parent.getParent());
- if (gParent instanceof PsiExpressionList) {
- final PsiElement ggParent = gParent.getParent();
- if (ggParent instanceof PsiCallExpression) {
- ourResults.get().remove(ggParent);
- }
- }
- }
- }
-}
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiOldInferenceHelper.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiOldInferenceHelper.java
index bb75e07..2fbfc60 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiOldInferenceHelper.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiOldInferenceHelper.java
@@ -15,29 +15,22 @@
*/
package com.intellij.psi.impl.source.resolve;
-import com.intellij.codeInsight.ExceptionUtil;
import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.project.Project;
import com.intellij.openapi.projectRoots.JavaSdkVersion;
import com.intellij.openapi.projectRoots.JavaVersionService;
-import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.RecursionGuard;
-import com.intellij.openapi.util.registry.Registry;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.*;
-import com.intellij.psi.infos.MethodCandidateInfo;
import com.intellij.psi.search.GlobalSearchScope;
-import com.intellij.psi.util.*;
+import com.intellij.psi.util.PsiTypesUtil;
+import com.intellij.psi.util.PsiUtil;
+import com.intellij.psi.util.TypeConversionUtil;
import com.intellij.util.ArrayUtil;
-import com.intellij.util.containers.HashMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import java.util.List;
-import java.util.Map;
-
/**
* User: anna
*/
@@ -50,7 +43,7 @@
myManager = manager;
}
- private Pair<PsiType, ConstraintType> inferTypeForMethodTypeParameterInner(@NotNull PsiTypeParameter typeParameter,
+ private Pair<PsiType, ConstraintType> inferTypeForMethodTypeParameterInner(@NotNull PsiTypeParameter typeParameter,
@NotNull PsiParameter[] parameters,
@NotNull PsiExpression[] arguments,
@NotNull PsiSubstitutor partialSubstitutor,
@@ -98,10 +91,6 @@
PsiType lowerBound = PsiType.NULL;
PsiType upperBound = PsiType.NULL;
if (paramTypes.length > 0) {
- sortLambdaExpressionsLast(paramTypes, argTypes);
- boolean rawType = false;
- boolean nullPassed = false;
- boolean lambdaRaw = false;
for (int j = 0; j < argTypes.length; j++) {
PsiType argumentType = argTypes[j];
if (argumentType == null) continue;
@@ -109,8 +98,6 @@
PsiType parameterType = paramTypes[j];
if (parameterType == null) break;
- rawType |= parameterType instanceof PsiClassType && ((PsiClassType)parameterType).isRaw();
- nullPassed |= argumentType == PsiType.NULL;
if (parameterType instanceof PsiEllipsisType) {
parameterType = ((PsiEllipsisType)parameterType).getComponentType();
@@ -119,26 +106,8 @@
}
}
final Pair<PsiType,ConstraintType> currentSubstitution;
- if (argumentType instanceof PsiLambdaExpressionType) {
- currentSubstitution = inferSubstitutionFromLambda(typeParameter, (PsiLambdaExpressionType)argumentType, lowerBound, partialSubstitutor);
- if (rawType) {
- if (currentSubstitution == FAILED_INFERENCE || currentSubstitution == null && lowerBound == PsiType.NULL) return RAW_INFERENCE;
- }
- if (nullPassed && currentSubstitution == null) return RAW_INFERENCE;
- if (currentSubstitution != null && currentSubstitution.first == null) {
- lambdaRaw = true;
- }
- if (currentSubstitution == null && lambdaRaw) {
- return new Pair<PsiType, ConstraintType>(PsiType.getJavaLangObject(myManager, typeParameter.getResolveScope()), ConstraintType.EQUALS);
- }
- } else if (argumentType instanceof PsiMethodReferenceType) {
- final PsiMethodReferenceExpression referenceExpression = ((PsiMethodReferenceType)argumentType).getExpression();
- currentSubstitution = inferConstraintFromFunctionalInterfaceMethod(typeParameter, referenceExpression, partialSubstitutor.substitute(parameterType), partialSubstitutor, policy);
- }
- else {
- currentSubstitution = getSubstitutionForTypeParameterConstraint(typeParameter, parameterType,
- argumentType, true, PsiUtil.getLanguageLevel(typeParameter));
- }
+ currentSubstitution = getSubstitutionForTypeParameterConstraint(typeParameter, parameterType,
+ argumentType, true, PsiUtil.getLanguageLevel(typeParameter));
if (currentSubstitution == null) continue;
if (currentSubstitution == FAILED_INFERENCE) {
return getFailedInferenceConstraint(typeParameter);
@@ -210,23 +179,6 @@
return null;
}
- private static void sortLambdaExpressionsLast(@NotNull PsiType[] paramTypes, @NotNull PsiType[] argTypes) {
- for (int i = 0; i < argTypes.length; i++) {
- PsiType argType = argTypes[i];
- if ((argType instanceof PsiLambdaExpressionType || argType instanceof PsiMethodReferenceType) && i < argTypes.length - 1) {
- int k = i + 1;
- while((argTypes[k] instanceof PsiLambdaExpressionType || argTypes[k] instanceof PsiMethodReferenceType) && k < argTypes.length - 1) {
- k++;
- }
- if (!(argTypes[k] instanceof PsiLambdaExpressionType || argTypes[k] instanceof PsiMethodReferenceType)) {
- ArrayUtil.swap(paramTypes, i, k);
- ArrayUtil.swap(argTypes, i, k);
- i = k;
- }
- }
- }
- }
-
private static Pair<PsiType, ConstraintType> getFailedInferenceConstraint(@NotNull PsiTypeParameter typeParameter) {
return new Pair<PsiType, ConstraintType>(JavaPsiFacade.getInstance(typeParameter.getProject()).getElementFactory().createType(typeParameter), ConstraintType.EQUALS);
}
@@ -321,41 +273,36 @@
}
}
- try {
- for (int i = 0; i < typeParameters.length; i++) {
- PsiTypeParameter typeParameter = typeParameters[i];
- PsiType substitution = substitutions[i];
- if (substitution != null) continue;
+ for (int i = 0; i < typeParameters.length; i++) {
+ PsiTypeParameter typeParameter = typeParameters[i];
+ PsiType substitution = substitutions[i];
+ if (substitution != null) continue;
- Pair<PsiType, ConstraintType> constraint = constraints[i];
- if (constraint == null) {
- constraint = inferMethodTypeParameterFromParent(typeParameter, partialSubstitutor, parent, policy);
- }
- else if (constraint.getSecond() == ConstraintType.SUBTYPE) {
- Pair<PsiType, ConstraintType> otherConstraint =
- inferMethodTypeParameterFromParent(typeParameter, partialSubstitutor, parent, policy);
- if (otherConstraint != null) {
- if (otherConstraint.getSecond() == ConstraintType.EQUALS || otherConstraint.getSecond() == ConstraintType.SUPERTYPE) {
- constraint = otherConstraint;
- }
+ Pair<PsiType, ConstraintType> constraint = constraints[i];
+ if (constraint == null) {
+ constraint = inferMethodTypeParameterFromParent(typeParameter, partialSubstitutor, parent, policy);
+ }
+ else if (constraint.getSecond() == ConstraintType.SUBTYPE) {
+ Pair<PsiType, ConstraintType> otherConstraint =
+ inferMethodTypeParameterFromParent(typeParameter, partialSubstitutor, parent, policy);
+ if (otherConstraint != null) {
+ if (otherConstraint.getSecond() == ConstraintType.EQUALS || otherConstraint.getSecond() == ConstraintType.SUPERTYPE) {
+ constraint = otherConstraint;
}
}
-
- if (constraint != null) {
- substitution = constraint.getFirst();
- }
-
- if (substitution == null) {
- PsiElementFactory factory = JavaPsiFacade.getInstance(myManager.getProject()).getElementFactory();
- return factory.createRawSubstitutor(partialSubstitutor, typeParameters);
- }
- if (substitution != PsiType.NULL) {
- partialSubstitutor = partialSubstitutor.put(typeParameter, substitution);
- }
}
- }
- finally {
- GraphInferencePolicy.forget(parent);
+
+ if (constraint != null) {
+ substitution = constraint.getFirst();
+ }
+
+ if (substitution == null) {
+ PsiElementFactory factory = JavaPsiFacade.getInstance(myManager.getProject()).getElementFactory();
+ return factory.createRawSubstitutor(partialSubstitutor, typeParameters);
+ }
+ if (substitution != PsiType.NULL) {
+ partialSubstitutor = partialSubstitutor.put(typeParameter, substitution);
+ }
}
return partialSubstitutor;
}
@@ -544,222 +491,6 @@
return getSubstitutionForTypeParameterInner(param, arg, patternType, ConstraintType.SUPERTYPE, 0);
}
- @Nullable
- private Pair<PsiType, ConstraintType> inferSubstitutionFromLambda(PsiTypeParameter typeParam,
- PsiLambdaExpressionType arg,
- PsiType lowerBound,
- PsiSubstitutor partialSubstitutor) {
- final PsiLambdaExpression lambdaExpression = arg.getExpression();
- if (PsiUtil.getLanguageLevel(lambdaExpression).isAtLeast(LanguageLevel.JDK_1_8)) {
- final PsiElement parent = PsiUtil.skipParenthesizedExprUp(lambdaExpression.getParent());
- if (parent instanceof PsiExpressionList) {
- final PsiExpressionList expressionList = (PsiExpressionList)parent;
- final Map<PsiElement, Pair<PsiMethod, PsiSubstitutor>> methodMap = MethodCandidateInfo.CURRENT_CANDIDATE.get();
- final Pair<PsiMethod, PsiSubstitutor> pair = methodMap != null ? methodMap.get(expressionList) : null;
- if (pair != null) {
- final int i = LambdaUtil.getLambdaIdx(expressionList, lambdaExpression);
- if (i < 0) return null;
- final PsiParameter[] parameters = pair.first.getParameterList().getParameters();
- if (parameters.length <= i) return null;
- final PsiSubstitutor combinedSubst = pair.second.putAll(partialSubstitutor);
- methodMap.put(expressionList, Pair.create(pair.first, combinedSubst));
- return inferConstraintFromFunctionalInterfaceMethod(typeParam, lambdaExpression, combinedSubst.substitute(parameters[i].getType()), lowerBound);
- }
- }
- else {
- return inferConstraintFromFunctionalInterfaceMethod(typeParam, lambdaExpression,
- partialSubstitutor.substitute(lambdaExpression.getFunctionalInterfaceType()), lowerBound);
- }
- }
- return null;
- }
-
- @Nullable
- private Pair<PsiType, ConstraintType> inferConstraintFromFunctionalInterfaceMethod(final PsiTypeParameter typeParam,
- final PsiMethodReferenceExpression methodReferenceExpression,
- final PsiType functionalInterfaceType,
- final PsiSubstitutor partialSubstitutor,
- final ParameterTypeInferencePolicy policy) {
- final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(functionalInterfaceType);
- final PsiMethod functionalInterfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(resolveResult);
- if (functionalInterfaceMethod != null) {
- final PsiSubstitutor subst = LambdaUtil.getSubstitutor(functionalInterfaceMethod, resolveResult);
- final PsiParameter[] methodParameters = functionalInterfaceMethod.getParameterList().getParameters();
- PsiType[] methodParamTypes = PsiType.createArray(methodParameters.length);
- for (int i = 0; i < methodParameters.length; i++) {
- methodParamTypes[i] = GenericsUtil.eliminateWildcards(subst.substitute(methodParameters[i].getType()));
- }
-
- if (methodParamsDependOn(typeParam, methodReferenceExpression, functionalInterfaceType, methodParameters, subst)) {
- return null;
- }
-
- final PsiType[] args = PsiType.createArray(methodParameters.length);
- Map<PsiMethodReferenceExpression,PsiType> map = PsiMethodReferenceUtil.ourRefs.get();
- if (map == null) {
- map = new HashMap<PsiMethodReferenceExpression, PsiType>();
- PsiMethodReferenceUtil.ourRefs.set(map);
- }
- final PsiType added = map.put(methodReferenceExpression, functionalInterfaceType);
- final JavaResolveResult methReferenceResolveResult;
- try {
- methReferenceResolveResult = methodReferenceExpression.advancedResolve(false);
- }
- finally {
- if (added == null) {
- map.remove(methodReferenceExpression);
- }
- }
- final PsiElement resolved = methReferenceResolveResult.getElement();
- if (resolved instanceof PsiMethod) {
- final PsiMethod method = (PsiMethod)resolved;
- final PsiParameter[] parameters = method.getParameterList().getParameters();
- boolean hasReceiver = false;
- if (methodParamTypes.length == parameters.length + 1) {
- if (!PsiMethodReferenceUtil
- .isReceiverType(methodParamTypes[0], method.getContainingClass(), methReferenceResolveResult.getSubstitutor())) return null;
- hasReceiver = true;
- } else if (parameters.length != methodParameters.length) {
- return null;
- }
- for (int i = 0; i < parameters.length; i++) {
- args[i] = methReferenceResolveResult.getSubstitutor().substitute(subst.substitute(parameters[i].getType()));
- }
-
- final PsiType[] typesToInfer = hasReceiver ? ArrayUtil.remove(methodParamTypes, 0) : methodParamTypes;
- final Pair<PsiType, ConstraintType> constraint = inferTypeForMethodTypeParameterInner(typeParam, typesToInfer, args, subst, null, DefaultParameterTypeInferencePolicy.INSTANCE);
- if (constraint != null){
- return constraint;
- }
- PsiType functionalInterfaceReturnType = functionalInterfaceMethod.getReturnType();
- if (functionalInterfaceReturnType != null && functionalInterfaceReturnType != PsiType.VOID) {
- functionalInterfaceReturnType = GenericsUtil.eliminateWildcards(subst.substitute(functionalInterfaceReturnType));
- final PsiType argType;
- if (method.isConstructor()) {
- argType = JavaPsiFacade.getElementFactory(functionalInterfaceMethod.getProject()).createType(method.getContainingClass(), methReferenceResolveResult.getSubstitutor());
- } else {
- argType = methReferenceResolveResult.getSubstitutor().substitute(subst.substitute(method.getReturnType()));
- }
- final Pair<PsiType, ConstraintType> typeParameterConstraint =
- getSubstitutionForTypeParameterConstraint(typeParam, functionalInterfaceReturnType, argType, true, PsiUtil.getLanguageLevel(functionalInterfaceMethod));
- if (typeParameterConstraint != null && typeParameterConstraint.getSecond() != ConstraintType.EQUALS && method.isConstructor()) {
- final Pair<PsiType, ConstraintType> constraintFromParent =
- inferMethodTypeParameterFromParent(typeParam, partialSubstitutor, methodReferenceExpression.getParent().getParent(), policy);
- if (constraintFromParent != null && constraintFromParent.getSecond() == ConstraintType.EQUALS) return constraintFromParent;
- }
- return typeParameterConstraint;
- }
- }
- }
- return null;
- }
-
- @Nullable
- private Pair<PsiType, ConstraintType> inferConstraintFromFunctionalInterfaceMethod(PsiTypeParameter typeParam,
- final PsiLambdaExpression lambdaExpression,
- final PsiType functionalInterfaceType,
- PsiType lowerBound) {
- final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(functionalInterfaceType);
- final PsiMethod method = LambdaUtil.getFunctionalInterfaceMethod(resolveResult);
- if (method != null) {
- final PsiSubstitutor subst = LambdaUtil.getSubstitutor(method, resolveResult);
- final Pair<PsiType, ConstraintType> constraintFromFormalParams = inferConstraintFromLambdaFormalParams(typeParam, subst, method, lambdaExpression);
- if (constraintFromFormalParams != null) return constraintFromFormalParams;
-
- final PsiParameter[] methodParameters = method.getParameterList().getParameters();
- if (methodParamsDependOn(typeParam, lambdaExpression, functionalInterfaceType, methodParameters, subst)) {
- return null;
- }
-
- final PsiType returnType = subst.substitute(method.getReturnType());
- if (returnType != null && returnType != PsiType.VOID) {
- Pair<PsiType, ConstraintType> constraint = null;
- final List<PsiExpression> expressions = LambdaUtil.getReturnExpressions(lambdaExpression);
- for (final PsiExpression expression : expressions) {
- final boolean independent = lambdaExpression.hasFormalParameterTypes() || LambdaUtil.isFreeFromTypeInferenceArgs(methodParameters, lambdaExpression, expression, subst, functionalInterfaceType, typeParam);
- if (!independent) {
- if (lowerBound != PsiType.NULL) {
- return null;
- }
- continue;
- }
- if (expression instanceof PsiReferenceExpression && ((PsiReferenceExpression)expression).resolve() == null) continue;
- PsiType exprType = PsiResolveHelper.ourGraphGuard.doPreventingRecursion(expression, true, new Computable<PsiType>() {
- @Override
- public PsiType compute() {
- return expression.getType();
- }
- });
- if (exprType instanceof PsiLambdaParameterType) {
- final PsiParameter parameter = ((PsiLambdaParameterType)exprType).getParameter();
- final int parameterIndex = lambdaExpression.getParameterList().getParameterIndex(parameter);
- if (parameterIndex > -1) {
- exprType = subst.substitute(methodParameters[parameterIndex].getType());
- }
- } else if (exprType instanceof PsiLambdaExpressionType) {
- return inferConstraintFromFunctionalInterfaceMethod(typeParam, ((PsiLambdaExpressionType)exprType).getExpression(), returnType,
- lowerBound);
- } else if (exprType == null && independent) {
- return null;
- }
-
- if (exprType == null){
- return FAILED_INFERENCE;
- }
-
- final Pair<PsiType, ConstraintType> returnExprConstraint =
- getSubstitutionForTypeParameterConstraint(typeParam, GenericsUtil.eliminateWildcards(returnType), exprType, true, PsiUtil.getLanguageLevel(method));
- if (returnExprConstraint != null) {
- if (returnExprConstraint == FAILED_INFERENCE) return returnExprConstraint;
- if (constraint != null) {
- final PsiType leastUpperBound = GenericsUtil.getLeastUpperBound(constraint.getFirst(), returnExprConstraint.getFirst(), myManager);
- constraint = new Pair<PsiType, ConstraintType>(leastUpperBound, ConstraintType.SUPERTYPE);
- } else {
- constraint = returnExprConstraint;
- }
- }
- }
- if (constraint != null) return constraint;
- }
- }
- return null;
- }
-
- private static boolean methodParamsDependOn(PsiTypeParameter typeParam, PsiElement psiElement,
- PsiType functionalInterfaceType,
- PsiParameter[] methodParameters,
- PsiSubstitutor subst) {
- for (PsiParameter parameter : methodParameters) {
- if (LambdaUtil.dependsOnTypeParams(subst.substitute(parameter.getType()), functionalInterfaceType, psiElement, typeParam)) {
- return true;
- }
- }
- return false;
- }
-
- @Nullable
- private Pair<PsiType, ConstraintType> inferConstraintFromLambdaFormalParams(PsiTypeParameter typeParam,
- PsiSubstitutor subst,
- PsiMethod method, PsiLambdaExpression lambdaExpression) {
- final PsiParameter[] parameters = lambdaExpression.getParameterList().getParameters();
- if (parameters.length == 0) return null;
- final PsiType[] lambdaArgs = PsiType.createArray(parameters.length);
- for (int i = 0; i < parameters.length; i++) {
- PsiParameter parameter = parameters[i];
- if (parameter.getTypeElement() == null) {
- return null;
- }
- lambdaArgs[i] = parameter.getType();
- }
-
- final PsiParameter[] methodParameters = method.getParameterList().getParameters();
- PsiType[] methodParamTypes = PsiType.createArray(methodParameters.length);
- for (int i = 0; i < methodParameters.length; i++) {
- methodParamTypes[i] = GenericsUtil.eliminateWildcards(subst.substitute(methodParameters[i].getType()));
- }
- return inferTypeForMethodTypeParameterInner(typeParam, methodParamTypes, lambdaArgs, subst, null, DefaultParameterTypeInferencePolicy.INSTANCE);
- }
-
private static PsiType intersectAllExtends(PsiTypeParameter typeParam, PsiType arg) {
if (arg == null) return null;
PsiClassType[] superTypes = typeParam.getSuperTypes();
@@ -979,48 +710,10 @@
PsiType expectedType = PsiTypesUtil.getExpectedTypeByParent(methodCall);
if (expectedType == null) {
- if (parent instanceof PsiReturnStatement) {
- final PsiLambdaExpression lambdaExpression = PsiTreeUtil.getParentOfType(parent, PsiLambdaExpression.class);
- if (lambdaExpression != null) {
- return getFailedInferenceConstraint(typeParameter);
- }
- }
- else if (parent instanceof PsiExpressionList) {
+ if (parent instanceof PsiExpressionList) {
final PsiElement pParent = parent.getParent();
if (pParent instanceof PsiCallExpression && parent.equals(((PsiCallExpression)pParent).getArgumentList())) {
constraint = policy.inferTypeConstraintFromCallContext(methodCall, (PsiExpressionList)parent, (PsiCallExpression)pParent, typeParameter);
- if (constraint == null && PsiUtil.isLanguageLevel8OrHigher(methodCall)) {
- constraint = graphInferenceFromCallContext(methodCall, typeParameter, (PsiCallExpression)pParent);
- if (constraint != null) {
- final PsiType constraintFirst = constraint.getFirst();
- if (constraintFirst == null || constraintFirst.equalsToText(CommonClassNames.JAVA_LANG_OBJECT)) {
- constraint = null;
- }
- }
- }
- }
- } else if (parent instanceof PsiLambdaExpression) {
- expectedType = PsiResolveHelper.ourGraphGuard.doPreventingRecursion(methodCall, true, new Computable<PsiType>() {
- @Override
- public PsiType compute() {
- return LambdaUtil.getFunctionalInterfaceReturnType(((PsiLambdaExpression)parent).getFunctionalInterfaceType());
- }
- });
- if (expectedType == null) {
- return null;
- }
- expectedType = GenericsUtil.eliminateWildcards(expectedType);
- } else if (parent instanceof PsiConditionalExpression) {
- if (PsiUtil.isLanguageLevel8OrHigher(parent)) {
- try {
- final Pair<PsiType, ConstraintType> pair = inferFromConditionalExpression(parent, methodCall, typeParameter, substitutor, policy);
- if (pair != null) {
- return pair;
- }
- }
- finally {
- GraphInferencePolicy.forget(parent);
- }
}
}
}
@@ -1054,33 +747,6 @@
if (constraint == null) {
if (methodCall instanceof PsiCallExpression) {
- final PsiExpressionList argumentList = ((PsiCallExpression)methodCall).getArgumentList();
- if (argumentList != null && PsiUtil.getLanguageLevel(argumentList).isAtLeast(LanguageLevel.JDK_1_8)) {
- for (PsiExpression expression : argumentList.getExpressions()) {
- if (expression instanceof PsiLambdaExpression || expression instanceof PsiMethodReferenceExpression) {
- final PsiType functionalInterfaceType = LambdaUtil.getFunctionalInterfaceType(expression, false);
- if (functionalInterfaceType == null || PsiUtil.resolveClassInType(functionalInterfaceType) == typeParameter){
- return getFailedInferenceConstraint(typeParameter);
- }
- final PsiMethod method = LambdaUtil.getFunctionalInterfaceMethod(functionalInterfaceType);
-
- final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(functionalInterfaceType);
- if (method == null || methodParamsDependOn(typeParameter, expression,
- functionalInterfaceType, method.getParameterList().getParameters(),
- LambdaUtil.getSubstitutor(method, resolveResult))) {
- if (expression instanceof PsiMethodReferenceExpression) {
- return getFailedInferenceConstraint(typeParameter);
- }
- return null;
- }
- final Pair<PsiType, ConstraintType> inferredExceptionTypeConstraint = inferExceptionConstrains(typeParameter, expression, method, resolveResult.getSubstitutor());
- if (inferredExceptionTypeConstraint != null) {
- return inferredExceptionTypeConstraint;
- }
- }
- }
- }
-
PsiType[] superTypes = typeParameter.getSuperTypes();
if (superTypes.length == 0) return null;
final PsiType[] types = PsiType.createArray(superTypes.length);
@@ -1090,7 +756,6 @@
superType = TypeConversionUtil.erasure(superType);
}
if (superType == null) superType = PsiType.getJavaLangObject(myManager, scope);
- if (superType == null) return null;
types[i] = superType;
}
return policy.getInferredTypeWithNoConstraint(myManager, PsiIntersectionType.createIntersection(types));
@@ -1120,113 +785,4 @@
return new Pair<PsiType, ConstraintType>(guess, constraint.getSecond());
}
-
- private static boolean checkSameExpression(PsiExpression templateExpr, final PsiExpression expression) {
- return templateExpr.equals(PsiUtil.skipParenthesizedExprDown(expression));
- }
-
- private static Pair<PsiType, ConstraintType> inferExceptionConstrains(PsiTypeParameter typeParameter,
- PsiExpression expression,
- PsiMethod method,
- PsiSubstitutor substitutor) {
- final PsiClassType[] declaredExceptions = method.getThrowsList().getReferencedTypes();
- for (PsiClassType exception : declaredExceptions) {
- final PsiType substitute = substitutor.substitute(exception);
- if (PsiUtil.resolveClassInType(substitute) == typeParameter) {
- if (expression instanceof PsiLambdaExpression) {
- final PsiElement body = ((PsiLambdaExpression)expression).getBody();
- if (body != null) {
- final List<PsiClassType> unhandledExceptions = ExceptionUtil.getUnhandledExceptions(body);
- if (unhandledExceptions.isEmpty()) {
- return inferUncheckedException(typeParameter, exception, method);
- }
- }
- }
- else if (expression instanceof PsiMethodReferenceExpression) {
- final PsiElement resolve = ((PsiMethodReferenceExpression)expression).resolve();
- if (resolve instanceof PsiMethod) {
- final PsiClassType[] declaredThrowsList = ((PsiMethod)resolve).getThrowsList().getReferencedTypes();
- for (PsiClassType psiClassType : declaredThrowsList) {
- if (!ExceptionUtil.isUncheckedException(psiClassType)) return null;
- }
- return inferUncheckedException(typeParameter, exception, method);
- }
- }
- break;
- }
- }
- return null;
- }
-
- private static Pair<PsiType, ConstraintType> inferUncheckedException(PsiTypeParameter typeParameter,
- PsiClassType exception,
- PsiMethod method) {
- final Project project = typeParameter.getProject();
- final PsiClass runtimeException = JavaPsiFacade.getInstance(project).findClass(CommonClassNames.JAVA_LANG_RUNTIME_EXCEPTION, method.getResolveScope());
- if (runtimeException != null) {
- for (PsiType superType : exception.getSuperTypes()) {
- if (!InheritanceUtil.isInheritorOrSelf(runtimeException, PsiUtil.resolveClassInType(superType), true)) {
- return getFailedInferenceConstraint(typeParameter);
- }
- }
- return Pair.<PsiType, ConstraintType>create(JavaPsiFacade.getElementFactory(project).createType(runtimeException, PsiSubstitutor.EMPTY), ConstraintType.EQUALS);
- }
- return null;
- }
-
- private Pair<PsiType, ConstraintType> inferFromConditionalExpression(@NotNull PsiElement parent,
- @NotNull PsiExpression methodCall,
- @NotNull PsiTypeParameter typeParameter,
- @NotNull PsiSubstitutor substitutor,
- @NotNull ParameterTypeInferencePolicy policy) {
- Pair<PsiType, ConstraintType> pair =
- inferMethodTypeParameterFromParent(PsiUtil.skipParenthesizedExprUp(parent.getParent()), (PsiExpression)parent, typeParameter, substitutor, policy);
- if (pair == null) {
- final PsiExpression thenExpression = ((PsiConditionalExpression)parent).getThenExpression();
- final PsiExpression elseExpression = ((PsiConditionalExpression)parent).getElseExpression();
- final PsiType[] paramTypes = {((PsiMethod)typeParameter.getOwner()).getReturnType()};
- if (methodCall.equals(PsiUtil.skipParenthesizedExprDown(elseExpression)) && thenExpression != null) {
- final PsiType thenType = PsiResolveHelper.ourGraphGuard.doPreventingRecursion(parent, true, new Computable<PsiType>() {
- @Override
- public PsiType compute() {
- return thenExpression.getType();
- }
- });
- if (thenType != null) {
- pair = inferTypeForMethodTypeParameterInner(typeParameter, paramTypes, new PsiType[] {thenType}, substitutor, null, policy);
- }
- } else if (methodCall.equals(PsiUtil.skipParenthesizedExprDown(thenExpression)) && elseExpression != null) {
- final PsiType elseType = PsiResolveHelper.ourGraphGuard.doPreventingRecursion(parent, true, new Computable<PsiType>() {
- @Override
- public PsiType compute() {
- return elseExpression.getType();
- }
- });
- if (elseType != null) {
- pair = inferTypeForMethodTypeParameterInner(typeParameter, paramTypes, new PsiType[] {elseType}, substitutor, null, policy);
- }
- }
- }
- return pair;
- }
-
- private static final ProcessCandidateParameterTypeInferencePolicy GRAPH_INFERENCE_POLICY = new GraphInferencePolicy();
-
- private static Pair<PsiType, ConstraintType> graphInferenceFromCallContext(@NotNull final PsiExpression methodCall,
- @NotNull final PsiTypeParameter typeParameter,
- @NotNull final PsiCallExpression parentCall) {
- if (Registry.is("disable.graph.inference", false)) return null;
- final PsiExpressionList argumentList = parentCall.getArgumentList();
- if (PsiDiamondType.ourDiamondGuard.currentStack().contains(parentCall)) {
- PsiDiamondType.ourDiamondGuard.prohibitResultCaching(parentCall);
- return FAILED_INFERENCE;
- }
- return PsiResolveHelper.ourGraphGuard.doPreventingRecursion(methodCall, true, new Computable<Pair<PsiType, ConstraintType>>() {
- @Override
- public Pair<PsiType, ConstraintType> compute() {
- return GRAPH_INFERENCE_POLICY.inferTypeConstraintFromCallContext(methodCall, argumentList, parentCall, typeParameter);
- }
- });
- }
-
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java
index dcaf548..840d1b4 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java
@@ -17,7 +17,6 @@
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.util.registry.Registry;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.resolve.graphInference.PsiGraphInferenceHelper;
@@ -26,7 +25,8 @@
import com.intellij.psi.scope.processor.MethodCandidatesProcessor;
import com.intellij.psi.scope.processor.MethodResolverProcessor;
import com.intellij.psi.scope.util.PsiScopesUtil;
-import com.intellij.psi.util.*;
+import com.intellij.psi.util.PsiUtil;
+import com.intellij.psi.util.TypeConversionUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -204,10 +204,10 @@
}
public PsiInferenceHelper getInferenceHelper(LanguageLevel languageLevel) {
- if (ApplicationManager.getApplication().isUnitTestMode()) {
- return myTestHelper != null ? myTestHelper : new PsiOldInferenceHelper(myManager);
+ if (ApplicationManager.getApplication().isUnitTestMode() && myTestHelper != null) {
+ return myTestHelper;
}
- if (languageLevel.isAtLeast(LanguageLevel.JDK_1_8) && Registry.is("enable.graph.inference", true)) {
+ if (languageLevel.isAtLeast(LanguageLevel.JDK_1_8)) {
return new PsiGraphInferenceHelper(myManager);
}
return new PsiOldInferenceHelper(myManager);
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/FunctionalInterfaceParameterizationUtil.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/FunctionalInterfaceParameterizationUtil.java
index 1195b74..a52ea73 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/FunctionalInterfaceParameterizationUtil.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/FunctionalInterfaceParameterizationUtil.java
@@ -102,14 +102,12 @@
return null;
}
- session.resolveBounds(false);
+ final PsiSubstitutor substitutor = session.resolveDependencies(session.getInferenceVariables());
final PsiType[] newTypeParameters = new PsiType[parameters.length];
for (int i = 0; i < typeParameters.length; i++) {
PsiTypeParameter typeParameter = typeParameters[i];
- final InferenceVariable variable = session.getInferenceVariable(typeParameter);
- final PsiType instantiation = variable.getInstantiation();
- if (instantiation != PsiType.NULL) {
- newTypeParameters[i] = instantiation;
+ if (substitutor.getSubstitutionMap().containsKey(typeParameter)) {
+ newTypeParameters[i] = substitutor.substitute(typeParameter);
} else {
newTypeParameters[i] = parameters[i];
}
@@ -125,7 +123,11 @@
return parameterization;
}
- return getNonWildcardParameterization(parameterization);
+ if (!psiClassType.isAssignableFrom(parameterization)) {
+ return null;
+ }
+
+ return getNonWildcardParameterization((PsiClassType)psiClassType);
}
return null;
}
@@ -159,6 +161,7 @@
if (psiClass != null) {
final PsiTypeParameter[] typeParameters = psiClass.getTypeParameters();
final PsiType[] parameters = psiClassType.getParameters();
+ final PsiType[] newParameters = new PsiType[parameters.length];
if (parameters.length != typeParameters.length) return null;
@@ -170,19 +173,23 @@
final PsiClassType Bi = extendsListTypes.length > 0 ? extendsListTypes[0]
: PsiType.getJavaLangObject(psiClass.getManager(),
GlobalSearchScope.allScope(psiClass.getProject()));
- if (PsiPolyExpressionUtil.mentionsTypeParameters(Bi, typeParametersSet)) return null;
+ if (PsiPolyExpressionUtil.mentionsTypeParameters(Bi, typeParametersSet)) {
+ return null;
+ }
final PsiType bound = ((PsiWildcardType)paramType).getBound();
if (bound == null) {
- parameters[i] = Bi;
+ newParameters[i] = Bi;
} else if (((PsiWildcardType)paramType).isExtends()){
- parameters[i] = GenericsUtil.getGreatestLowerBound(Bi, GenericsUtil.eliminateWildcards(bound, false));
+ newParameters[i] = GenericsUtil.getGreatestLowerBound(Bi, GenericsUtil.eliminateWildcards(bound, false));
} else {
- parameters[i] = GenericsUtil.eliminateWildcards(bound, false);
+ newParameters[i] = GenericsUtil.eliminateWildcards(bound, false);
}
+ } else {
+ newParameters[i] = paramType;
}
}
- return JavaPsiFacade.getElementFactory(psiClass.getProject()).createType(psiClass, parameters);
+ return JavaPsiFacade.getElementFactory(psiClass.getProject()).createType(psiClass, newParameters);
}
return null;
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceIncorporationPhase.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceIncorporationPhase.java
index 0eaf3d8..cc66681 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceIncorporationPhase.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceIncorporationPhase.java
@@ -26,8 +26,7 @@
import com.intellij.psi.util.TypeConversionUtil;
import com.intellij.util.Processor;
-import java.util.LinkedHashSet;
-import java.util.List;
+import java.util.*;
/**
* User: anna
@@ -35,14 +34,43 @@
public class InferenceIncorporationPhase {
private static final Logger LOG = Logger.getInstance("#" + InferenceIncorporationPhase.class.getName());
private final InferenceSession mySession;
- private PsiClassType myCapture;
+ private List<Pair<PsiTypeParameter[], PsiClassType>> myCaptures = new ArrayList<Pair<PsiTypeParameter[], PsiClassType>>();
public InferenceIncorporationPhase(InferenceSession session) {
mySession = session;
}
- public void setCapture(PsiClassType capture) {
- myCapture = capture;
+ public void addCapture(PsiTypeParameter[] typeParameters, PsiClassType rightType) {
+ myCaptures.add(Pair.create(typeParameters, rightType));
+ }
+
+ public void forgetCaptures(List<InferenceVariable> variables) {
+ for (InferenceVariable variable : variables) {
+ final PsiTypeParameter parameter = variable.getParameter();
+ for (Iterator<Pair<PsiTypeParameter[], PsiClassType>> iterator = myCaptures.iterator(); iterator.hasNext(); ) {
+ Pair<PsiTypeParameter[], PsiClassType> capture = iterator.next();
+ for (PsiTypeParameter typeParameter : capture.first) {
+ if (parameter == typeParameter) {
+ iterator.remove();
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ public boolean hasCaptureConstraints(Iterable<InferenceVariable> variables) {
+ for (InferenceVariable variable : variables) {
+ final PsiTypeParameter parameter = variable.getParameter();
+ for (Pair<PsiTypeParameter[], PsiClassType> capture : myCaptures) {
+ for (PsiTypeParameter typeParameter : capture.first) {
+ if (parameter == typeParameter){
+ return true;
+ }
+ }
+ }
+ }
+ return false;
}
public boolean incorporate() {
@@ -96,12 +124,13 @@
}
}
- if (myCapture != null) {
- final PsiClass gClass = myCapture.resolve();
+ for (Pair<PsiTypeParameter[], PsiClassType> capture : myCaptures) {
+ final PsiClassType right = capture.second;
+ final PsiClass gClass = right.resolve();
LOG.assertTrue(gClass != null);
- final PsiTypeParameter[] parameters = gClass.getTypeParameters();
- PsiType[] typeArgs = myCapture.getParameters();
- LOG.assertTrue(parameters.length == typeArgs.length);
+ final PsiTypeParameter[] parameters = capture.first;
+ PsiType[] typeArgs = right.getParameters();
+ if (parameters.length != typeArgs.length) continue;
for (int i = 0; i < typeArgs.length; i++) {
PsiType aType = typeArgs[i];
if (aType instanceof PsiCapturedWildcardType) {
@@ -236,7 +265,7 @@
boolean result = false;
for (PsiType upperBound : upperBounds) {
final InferenceVariable inferenceVar = mySession.getInferenceVariable(upperBound);
- if (inferenceVar != null) {
+ if (inferenceVar != null && inferenceVariable != inferenceVar) {
for (PsiType lowerBound : lowerBounds) {
result |= inferenceVar.addBound(lowerBound, inferenceBound);
@@ -259,13 +288,9 @@
*/
private void upDown(List<PsiType> eqBounds, List<PsiType> upperBounds) {
for (PsiType upperBound : upperBounds) {
- if (mySession.isProperType(upperBound)) {
- continue;
- }
+ if (upperBound == null) continue;
for (PsiType eqBound : eqBounds) {
- if (mySession.isProperType(eqBound)) {
- continue;
- }
+ if (eqBound == null) continue;
addConstraint(new StrictSubtypingConstraint(upperBound, eqBound));
}
}
@@ -277,14 +302,8 @@
private void eqEq(List<PsiType> eqBounds) {
for (int i = 0; i < eqBounds.size(); i++) {
PsiType sBound= eqBounds.get(i);
- if (mySession.isProperType(sBound)) {
- continue;
- }
for (int j = i + 1; j < eqBounds.size(); j++) {
final PsiType tBound = eqBounds.get(j);
- if (mySession.isProperType(tBound)) {
- continue;
- }
addConstraint(new TypeEqualityConstraint(tBound, sBound));
}
}
@@ -348,4 +367,43 @@
private void addConstraint(ConstraintFormula constraint) {
mySession.addConstraint(constraint);
}
+
+ public void collectCaptureDependencies(InferenceVariable variable, Set<InferenceVariable> dependencies) {
+ final PsiTypeParameter parameter = variable.getParameter();
+ for (Pair<PsiTypeParameter[], PsiClassType> capture : myCaptures) {
+ for (PsiTypeParameter typeParameter : capture.first) {
+ if (typeParameter == parameter) {
+ collectAllVariablesOnBothSides(dependencies, capture);
+ break;
+ }
+ }
+ }
+ }
+
+ protected void collectAllVariablesOnBothSides(Set<InferenceVariable> dependencies, Pair<PsiTypeParameter[], PsiClassType> capture) {
+ mySession.collectDependencies(capture.second, dependencies);
+ for (PsiTypeParameter psiTypeParameter : capture.first) {
+ final InferenceVariable var = mySession.getInferenceVariable(psiTypeParameter);
+ if (var != null) {
+ dependencies.add(var);
+ }
+ }
+ }
+
+ public PsiSubstitutor checkIncorporated(PsiSubstitutor substitutor, Collection<InferenceVariable> variables) {
+ for (InferenceVariable variable : variables) { //todo equals bounds?
+ for (PsiType lowerBound : variable.getBounds(InferenceBound.LOWER)) {
+ lowerBound = substitutor.substitute(lowerBound);
+ if (mySession.isProperType(lowerBound)) {
+ for (PsiType upperBound : variable.getBounds(InferenceBound.UPPER)) {
+ upperBound = substitutor.substitute(upperBound);
+ if (mySession.isProperType(upperBound) && !TypeConversionUtil.isAssignable(upperBound, lowerBound)) {
+ return null;
+ }
+ }
+ }
+ }
+ }
+ return substitutor;
+ }
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java
index 4b74ef2..abde461 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java
@@ -16,16 +16,16 @@
package com.intellij.psi.impl.source.resolve.graphInference;
import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Computable;
+import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.Pair;
import com.intellij.psi.*;
import com.intellij.psi.impl.PsiImplUtil;
-import com.intellij.psi.impl.source.resolve.DefaultParameterTypeInferencePolicy;
-import com.intellij.psi.impl.source.resolve.ParameterTypeInferencePolicy;
import com.intellij.psi.impl.source.resolve.graphInference.constraints.*;
import com.intellij.psi.infos.MethodCandidateInfo;
import com.intellij.psi.scope.MethodProcessorSetupFailedException;
+import com.intellij.psi.scope.PsiConflictResolver;
+import com.intellij.psi.scope.conflictResolvers.JavaMethodsConflictResolver;
import com.intellij.psi.scope.processor.MethodCandidatesProcessor;
import com.intellij.psi.scope.processor.MethodResolverProcessor;
import com.intellij.psi.scope.util.PsiScopesUtil;
@@ -35,6 +35,7 @@
import com.intellij.psi.util.PsiUtil;
import com.intellij.psi.util.TypeConversionUtil;
import com.intellij.util.ArrayUtilRt;
+import com.intellij.util.Function;
import com.intellij.util.Processor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -46,6 +47,9 @@
*/
public class InferenceSession {
private static final Logger LOG = Logger.getInstance("#" + InferenceSession.class.getName());
+ public static final Key<PsiType> LOWER_BOUND = Key.create("LowBound");
+
+ private static final Key<Boolean> ERASED = Key.create("UNCHECKED_CONVERSION");
private final Map<PsiTypeParameter, InferenceVariable> myInferenceVariables = new LinkedHashMap<PsiTypeParameter, InferenceVariable>();
private final List<ConstraintFormula> myConstraints = new ArrayList<ConstraintFormula>();
@@ -173,9 +177,25 @@
private static PsiType getParameterType(PsiParameter[] parameters, PsiExpression[] args, int i, PsiSubstitutor substitutor) {
PsiType parameterType = substitutor.substitute(parameters[i < parameters.length ? i : parameters.length - 1].getType());
if (parameterType instanceof PsiEllipsisType) {
- if (args.length != parameters.length ||
- PsiPolyExpressionUtil.isPolyExpression(args[i]) ||
- args[i] != null && !(args[i].getType() instanceof PsiArrayType)) {
+ final PsiExpression arg = args[i];
+ if (arg instanceof PsiNewExpression) {
+ if (((PsiNewExpression)arg).getArrayDimensions().length == parameterType.getArrayDimensions() || ((PsiNewExpression)arg).getArrayInitializer() != null) {
+ return parameterType;
+ }
+ }
+ if (arg instanceof PsiCallExpression) {
+ final PsiMethod method = ((PsiCallExpression)arg).resolveMethod();
+ if (method != null) {
+ final PsiType returnType = method.getReturnType();
+ if (returnType != null && returnType.getArrayDimensions() == parameterType.getArrayDimensions()) {
+ return parameterType;
+ }
+ }
+ }
+
+ if (args.length != parameters.length ||
+ PsiPolyExpressionUtil.isPolyExpression(arg) ||
+ arg != null && !(arg.getType() instanceof PsiArrayType)) {
parameterType = ((PsiEllipsisType)parameterType).getComponentType();
}
}
@@ -187,83 +207,115 @@
return infer(null, null, null);
}
- @NotNull
- public PsiSubstitutor infer(@Nullable PsiParameter[] parameters,
- @Nullable PsiExpression[] args,
- @Nullable PsiElement parent) {
- return infer(parameters, args, parent, DefaultParameterTypeInferencePolicy.INSTANCE);
- }
-
- @NotNull
- public PsiSubstitutor infer(@Nullable PsiParameter[] parameters,
- @Nullable PsiExpression[] args,
- @Nullable PsiElement parent,
- ParameterTypeInferencePolicy policy) {
- return infer(parameters, args, parent, false, policy);
- }
-
- @NotNull
- public PsiSubstitutor infer(@Nullable PsiParameter[] parameters,
- @Nullable PsiExpression[] args,
- @Nullable PsiElement parent,
- boolean acceptNonPertinentArgs,
- ParameterTypeInferencePolicy policy) {
-
- if (!repeatInferencePhases(parameters == null || !policy.allowPostponeInference())) {
- return prepareSubstitution();
+ private PsiSubstitutor tryToInfer(@Nullable PsiParameter[] parameters,
+ @Nullable PsiExpression[] args,
+ @Nullable PsiCallExpression parent,
+ PsiMethod parentMethod) {
+ if (!repeatInferencePhases(true)) {
+ //inferred result would be checked as candidate won't be applicable
+ return resolveSubset(myInferenceVariables.values(), mySiteSubstitutor, false);
}
- resolveBounds(myInferenceVariables.values(), mySiteSubstitutor, !policy.allowPostponeInference());
-
- final Pair<PsiMethod, PsiCallExpression> pair = getPair(parent);
- if (pair != null) {
- initReturnTypeConstraint(pair.first, (PsiCallExpression)parent);
- for (InferenceVariable inferenceVariable : myInferenceVariables.values()) {
- inferenceVariable.ignoreInstantiation();
- }
+ if (parentMethod != null) {
+ initReturnTypeConstraint(parentMethod, parent);
if (!repeatInferencePhases(true)) {
return prepareSubstitution();
}
- PsiSubstitutor substitutor = resolveBounds(myInferenceVariables.values(), mySiteSubstitutor, !policy.allowPostponeInference());
- LOG.assertTrue(parent != null);
- PsiExpressionList argumentList = ((PsiCallExpression)parent).getArgumentList();
- LOG.assertTrue(argumentList != null);
- MethodCandidateInfo.updateSubstitutor(argumentList, substitutor);
- }
-
- if (parameters != null && args != null && (acceptNonPertinentArgs || pair != null)) {
- final Set<ConstraintFormula> additionalConstraints = new HashSet<ConstraintFormula>();
- if (parameters.length > 0) {
- for (int i = 0; i < args.length; i++) {
- if (args[i] != null) {
- PsiType parameterType = getParameterType(parameters, args, i, mySiteSubstitutor);
- if (pair == null || !isPertinentToApplicability(args[i], pair.first)) {
- additionalConstraints.add(new ExpressionCompatibilityConstraint(args[i], parameterType));
- }
- additionalConstraints.add(new CheckedExceptionCompatibilityConstraint(args[i], parameterType));
- }
+ if (parameters != null && args != null) {
+ final Set<ConstraintFormula> additionalConstraints = new HashSet<ConstraintFormula>();
+ if (parameters.length > 0) {
+ collectAdditionalConstraints(parameters, args, parentMethod, PsiSubstitutor.EMPTY, additionalConstraints);
}
- }
- if (!additionalConstraints.isEmpty()) {
- for (InferenceVariable inferenceVariable : myInferenceVariables.values()) {
- inferenceVariable.ignoreInstantiation();
- }
- if (!proceedWithAdditionalConstraints(additionalConstraints)) {
+ if (!additionalConstraints.isEmpty() && !proceedWithAdditionalConstraints(additionalConstraints)) {
return prepareSubstitution();
}
}
}
- for (InferenceVariable inferenceVariable : myInferenceVariables.values()) {
- inferenceVariable.ignoreInstantiation();
+ return null;
+ }
+
+ private static void collectAdditionalConstraints(PsiParameter[] parameters,
+ PsiExpression[] args,
+ PsiMethod parentMethod,
+ PsiSubstitutor siteSubstitutor,
+ Set<ConstraintFormula> additionalConstraints) {
+ for (int i = 0; i < args.length; i++) {
+ if (args[i] != null) {
+ PsiType parameterType = getParameterType(parameters, args, i, siteSubstitutor);
+ if (!isPertinentToApplicability(args[i], parentMethod)) {
+ additionalConstraints.add(new ExpressionCompatibilityConstraint(args[i], parameterType));
+ }
+ additionalConstraints.add(new CheckedExceptionCompatibilityConstraint(args[i], parameterType));
+ if (args[i] instanceof PsiCallExpression) {
+ //If the expression is a poly class instance creation expression (15.9) or a poly method invocation expression (15.12),
+ //the set contains all constraint formulas that would appear in the set C when determining the poly expression's invocation type.
+ final PsiCallExpression callExpression = (PsiCallExpression)args[i];
+ final PsiExpressionList argumentList = callExpression.getArgumentList();
+ if (argumentList != null) {
+ final JavaResolveResult result = callExpression.resolveMethodGenerics();
+ if (result instanceof MethodCandidateInfo) {
+ final PsiMethod method = ((MethodCandidateInfo)result).getElement();
+ LOG.assertTrue(method != null);
+ final PsiExpression[] newArgs = argumentList.getExpressions();
+ final PsiParameter[] newParams = method.getParameterList().getParameters();
+ if (newParams.length > 0) {
+ collectAdditionalConstraints(newParams, newArgs, method, ((MethodCandidateInfo)result).getSiteSubstitutor(), additionalConstraints);
+ }
+ }
+ }
+ }
+ }
}
- mySiteSubstitutor = resolveBounds(myInferenceVariables.values(), mySiteSubstitutor, !policy.allowPostponeInference());
+ }
+
+ @NotNull
+ public PsiSubstitutor infer(@Nullable PsiParameter[] parameters,
+ @Nullable PsiExpression[] args,
+ @Nullable PsiElement parent) {
+ final Pair<PsiMethod, PsiCallExpression> pair = getPair(parent);
+ return infer(parameters, args, parent, pair != null ? pair.first : null);
+ }
+
+ @NotNull
+ public PsiSubstitutor infer(PsiParameter[] parameters, PsiExpression[] args, PsiElement parent, PsiMethod parentMethod) {
+ final PsiSubstitutor subst = tryToInfer(parameters, args, parent instanceof PsiCallExpression ? ((PsiCallExpression)parent) : null, parentMethod);
+ if (subst != null) {
+ return subst;
+ }
+
+ final PsiSubstitutor substitutor = resolveBounds(myInferenceVariables.values(), mySiteSubstitutor);
+ if (substitutor != null) {
+ if (myContext != null) {
+ myContext.putUserData(ERASED, myErased);
+ }
+ mySiteSubstitutor = substitutor;
+ for (PsiTypeParameter parameter : substitutor.getSubstitutionMap().keySet()) {
+ final InferenceVariable variable = getInferenceVariable(parameter);
+ if (variable != null) {
+ variable.setInstantiation(substitutor.substitute(parameter));
+ }
+ }
+ } else {
+ return resolveSubset(myInferenceVariables.values(), mySiteSubstitutor, false);
+ }
return prepareSubstitution();
}
+ public PsiSubstitutor resolveDependencies(Collection<InferenceVariable> variables) {
+ PsiSubstitutor substitutor = mySiteSubstitutor;
+ for (InferenceVariable variable : variables) {
+ final PsiType equalsBound = getEqualsBound(variable, substitutor);
+ if (equalsBound != PsiType.NULL) {
+ substitutor = substitutor.put(variable.getParameter(), equalsBound);
+ }
+ }
+ return substitutor;
+ }
+
private PsiSubstitutor prepareSubstitution() {
for (InferenceVariable inferenceVariable : myInferenceVariables.values()) {
final PsiTypeParameter typeParameter = inferenceVariable.getParameter();
@@ -321,11 +373,10 @@
returnType = PsiImplUtil.normalizeWildcardTypeByPosition(returnType, context);
PsiType targetType = PsiTypesUtil.getExpectedTypeByParent(context);
if (targetType == null) {
- final PsiType finalReturnType = returnType;
targetType = PsiResolveHelper.ourGraphGuard.doPreventingRecursion(context, false, new Computable<PsiType>() {
@Override
public PsiType compute() {
- return getTargetType(context, finalReturnType);
+ return getTargetType(context);
}
});
}
@@ -346,15 +397,32 @@
public void registerConstraints(PsiType returnType, PsiType targetType) {
final InferenceVariable inferenceVariable = shouldResolveAndInstantiate(returnType, targetType);
if (inferenceVariable != null) {
- resolveBounds(Collections.singletonList(inferenceVariable), mySiteSubstitutor, true);
- myConstraints.add(new TypeCompatibilityConstraint(inferenceVariable.getInstantiation(), returnType));
+ final PsiSubstitutor substitutor = resolveSubset(Collections.singletonList(inferenceVariable), mySiteSubstitutor, true);
+ myConstraints.add(new TypeCompatibilityConstraint(targetType, PsiUtil.captureToplevelWildcards(substitutor.substitute(inferenceVariable.getParameter()), myContext)));
}
else {
- if (targetType instanceof PsiClassType && ((PsiClassType)targetType).isRaw()) {
- setErased();
+ if (FunctionalInterfaceParameterizationUtil.isWildcardParameterized(returnType)) {
+ final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(returnType);
+ final PsiClass psiClass = resolveResult.getElement();
+ if (psiClass != null) {
+ LOG.assertTrue(returnType instanceof PsiClassType);
+ final PsiTypeParameter[] typeParameters = psiClass.getTypeParameters();
+ PsiSubstitutor subst = PsiSubstitutor.EMPTY;
+ final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(psiClass.getProject());
+ PsiTypeParameter[] copy = new PsiTypeParameter[typeParameters.length];
+ for (int i = 0; i < typeParameters.length; i++) {
+ PsiTypeParameter typeParameter = typeParameters[i];
+ copy[i] = elementFactory.createTypeParameterFromText(typeParameter.getName(), null);
+ initBounds(copy[i]);
+ subst = subst.put(typeParameter, elementFactory.createType(copy[i]));
+ }
+ final PsiType substitutedCapture = PsiUtil.captureToplevelWildcards(subst.substitute(returnType), myContext);
+ myIncorporationPhase.addCapture(copy, (PsiClassType)returnType);
+ myConstraints.add(new TypeCompatibilityConstraint(targetType, substitutedCapture));
+ }
+ } else {
+ myConstraints.add(new TypeCompatibilityConstraint(targetType, myErased ? TypeConversionUtil.erasure(returnType) : returnType));
}
- myConstraints.add(new TypeCompatibilityConstraint(myErased ? TypeConversionUtil.erasure(targetType) : GenericsUtil.eliminateWildcards(
- targetType, false), returnType));
}
}
@@ -404,7 +472,7 @@
}
private static boolean hasWildcardParameterization(InferenceVariable inferenceVariable, PsiClassType targetType) {
- if (FunctionalInterfaceParameterizationUtil.isWildcardParameterized(targetType)) {
+ if (!FunctionalInterfaceParameterizationUtil.isWildcardParameterized(targetType)) {
final List<PsiType> bounds = inferenceVariable.getBounds(InferenceBound.LOWER);
final Processor<Pair<PsiType, PsiType>> differentParameterizationProcessor = new Processor<Pair<PsiType, PsiType>>() {
@Override
@@ -427,63 +495,77 @@
return false;
}
- private PsiType getTargetType(final PsiExpression context, PsiType returnType) {
+ private PsiType getTargetType(final PsiExpression context) {
final PsiElement parent = PsiUtil.skipParenthesizedExprUp(context.getParent());
if (parent instanceof PsiExpressionList) {
- final PsiElement gParent = parent.getParent();
+ PsiElement gParent = parent.getParent();
+ if (gParent instanceof PsiAnonymousClass) {
+ gParent = gParent.getParent();
+ }
if (gParent instanceof PsiCallExpression) {
final PsiExpressionList argumentList = ((PsiCallExpression)gParent).getArgumentList();
if (argumentList != null) {
final Pair<PsiMethod, PsiSubstitutor> pair = MethodCandidateInfo.getCurrentMethod(argumentList);
- final JavaResolveResult resolveResult;
- if (pair == null) {
- final MethodCandidatesProcessor processor = new MethodResolverProcessor((PsiCallExpression)gParent, argumentList, context.getContainingFile()) {
- @Override
- protected PsiType[] getExpressionTypes(PsiExpressionList argumentList) {
- if (argumentList != null) {
- final PsiExpression[] expressions = argumentList.getExpressions();
- final int idx = LambdaUtil.getLambdaIdx(argumentList, context);
- final PsiType[] types = PsiType.createArray(expressions.length);
- for (int i = 0; i < expressions.length; i++) {
- if (i != idx) {
- types[i] = expressions[i].getType();
- }
- else {
- types[i] = PsiType.NULL;
- }
- }
- return types;
- }
- else {
- return null;
- }
- }
- };
- try {
- PsiScopesUtil.setupAndRunProcessor(processor, (PsiCallExpression)gParent, false);
+ final PsiFile placeFile = context.getContainingFile();
+ final JavaMethodsConflictResolver conflictResolver = new JavaMethodsConflictResolver(argumentList, PsiUtil.getLanguageLevel(placeFile)){
+ @Override
+ protected PsiType[] getArgumentTypes() {
+ return InferenceSession.getArgumentTypes(argumentList, context);
}
- catch (MethodProcessorSetupFailedException e) {
- return null;
+ };
+ final MethodCandidatesProcessor processor = new MethodResolverProcessor((PsiCallExpression)gParent, placeFile, new PsiConflictResolver[]{conflictResolver}) {
+ @Override
+ protected PsiType[] getExpressionTypes(PsiExpressionList argumentList) {
+ return getArgumentTypes(argumentList, context);
}
- final JavaResolveResult[] results = processor.getResult();
- return results.length == 1 ? getTypeByMethod(context, argumentList, null, results[0], results[0].getElement()) : null;
+ };
+ try {
+ PsiScopesUtil.setupAndRunProcessor(processor, (PsiCallExpression)gParent, false);
}
- return getTypeByMethod(context, argumentList, pair, null, pair.first);
+ catch (MethodProcessorSetupFailedException e) {
+ return null;
+ }
+ final JavaResolveResult[] results = processor.getResult();
+ return results.length == 1 ? getTypeByMethod(context, argumentList, pair, results[0], results[0].getElement()) : null;
}
}
} else if (parent instanceof PsiConditionalExpression) {
PsiType targetType = PsiTypesUtil.getExpectedTypeByParent((PsiExpression)parent);
if (targetType == null) {
- targetType = getTargetType((PsiExpression)parent, returnType);
+ targetType = getTargetType((PsiExpression)parent);
}
return targetType;
}
else if (parent instanceof PsiLambdaExpression) {
+ if (PsiUtil.skipParenthesizedExprUp(parent.getParent()) instanceof PsiExpressionList) {
+ final PsiType typeTypeByParentCall = getTargetType((PsiLambdaExpression)parent);
+ return LambdaUtil.getFunctionalInterfaceReturnType(FunctionalInterfaceParameterizationUtil.getGroundTargetType(typeTypeByParentCall, (PsiLambdaExpression)parent));
+ }
return LambdaUtil.getFunctionalInterfaceReturnType(((PsiLambdaExpression)parent).getFunctionalInterfaceType());
}
return null;
}
+ private static PsiType[] getArgumentTypes(PsiExpressionList argumentList, PsiExpression context) {
+ if (argumentList != null) {
+ final PsiExpression[] expressions = argumentList.getExpressions();
+ final int idx = LambdaUtil.getLambdaIdx(argumentList, context);
+ final PsiType[] types = PsiType.createArray(expressions.length);
+ for (int i = 0; i < expressions.length; i++) {
+ if (i != idx) {
+ types[i] = expressions[i].getType();
+ }
+ else {
+ types[i] = PsiType.NULL;
+ }
+ }
+ return types;
+ }
+ else {
+ return null;
+ }
+ }
+
private PsiType getTypeByMethod(PsiExpression context,
PsiExpressionList argumentList,
Pair<PsiMethod, PsiSubstitutor> pair,
@@ -499,16 +581,23 @@
}
final int i = ArrayUtilRt.find(args, arg);
if (i < 0) return null;
- if (pair != null) {
- return getParameterType(parameters, args, i, pair.second);
+ final PsiCallExpression callExpression = PsiTreeUtil.getParentOfType(argumentList, PsiCallExpression.class);
+ if (callExpression != null && callExpression.getTypeArguments().length > 0) {
+ return getParameterType(parameters, args, i, ((MethodCandidateInfo)result).typeArgumentsSubstitutor());
}
- else {
- args[i] = null;
- final PsiSubstitutor substitutor = ((MethodCandidateInfo)result).inferSubstitutorFromArgs(LiftParameterTypeInferencePolicy.INSTANCE, args);
- final Set<PsiTypeParameter> typeParameters = substitutor.getSubstitutionMap().keySet();
- initBounds(typeParameters.toArray(new PsiTypeParameter[typeParameters.size()]));
- return getParameterType(parameters, args, i, substitutor);
+ final PsiType parameterType = getParameterType(parameters, args, i, pair != null ? pair.second : PsiSubstitutor.EMPTY);
+ args[i] = null;
+ final PsiTypeParameter[] typeParameters = ((PsiMethod)parentMethod).getTypeParameters();
+ final InferenceSession session = new InferenceSession(typeParameters, ((MethodCandidateInfo)result).getSiteSubstitutor(), myManager, argumentList);
+ session.initExpressionConstraints(parameters, args, argumentList, (PsiMethod)parentMethod);
+ if (session.tryToInfer(parameters, args, callExpression, (PsiMethod)parentMethod) != null) {
+ return null;
}
+ final Collection<PsiTypeParameter> params = session.getTypeParams();
+ initBounds(params.toArray(new PsiTypeParameter[params.size()]));
+ liftBounds(session.getInferenceVariables());
+ final PsiSubstitutor substitutor = ((MethodCandidateInfo)result).getSiteSubstitutor();
+ return substitutor.substitute(parameterType);
}
return null;
}
@@ -607,107 +696,10 @@
return true;
}
- protected PsiSubstitutor resolveBounds(boolean acceptInitialUpperBound) {
- return resolveBounds(getInferenceVariables(), mySiteSubstitutor, acceptInitialUpperBound);
- }
-
- private PsiSubstitutor resolveBounds(final Collection<InferenceVariable> inferenceVariables,
- PsiSubstitutor substitutor,
- boolean acceptInitialUpperBound) {
- final List<List<InferenceVariable>> independentVars = InferenceVariablesOrder.resolveOrder(inferenceVariables, this);
- for (List<InferenceVariable> variables : independentVars) {
- for (InferenceVariable inferenceVariable : variables) {
-
- final PsiTypeParameter typeParameter = inferenceVariable.getParameter();
- try {
- if (inferenceVariable.getInstantiation() != PsiType.NULL) continue;
- final List<PsiType> eqBounds = inferenceVariable.getBounds(InferenceBound.EQ);
- final List<PsiType> lowerBounds = inferenceVariable.getBounds(InferenceBound.LOWER);
- final List<PsiType> upperBounds = inferenceVariable.getBounds(InferenceBound.UPPER);
- if (myErased && eqBounds.contains(null) || /*lowerBounds.contains(null) || */upperBounds.contains(null)) {
- inferenceVariable.setInstantiation(null);
- continue;
- }
- PsiType bound = null;
- if (eqBounds.size() > 1) {
- for (Iterator<PsiType> iterator = eqBounds.iterator(); iterator.hasNext(); ) {
- final PsiType unsubstBound = iterator.next();
- PsiType eqBound = substituteNonProperBound(unsubstBound, substitutor);
- if (PsiUtil.resolveClassInType(eqBound) == typeParameter || !(bound instanceof PsiCapturedWildcardType && bound.equals(unsubstBound)) && Comparing.equal(bound, eqBound)) {
- iterator.remove();
- } else if (bound == null) {
- bound = eqBound;
- }
- }
- if (eqBounds.size() > 1) continue;
- }
- bound = eqBounds.isEmpty() ? null : substituteNonProperBound(eqBounds.get(0), substitutor);
- if (bound != null) {
- inferenceVariable.setInstantiation(bound);
- } else {
- PsiType lub = null;
- for (PsiType lowerBound : lowerBounds) {
- lowerBound = substituteNonProperBound(lowerBound, substitutor);
- if (isProperType(lowerBound)) {
- if (lub == null) {
- lub = lowerBound;
- }
- else {
- lub = GenericsUtil.getLeastUpperBound(lub, lowerBound, myManager);
- }
- }
- }
- if (lub != null) {
- inferenceVariable.setInstantiation(lub instanceof PsiCapturedWildcardType ? ((PsiCapturedWildcardType)lub).getWildcard() : lub);
- }
- else {
- boolean inferred = false;
- PsiType glb = null;
- if (inferenceVariable.isThrownBound() && isThrowable(upperBounds)) {
- glb = PsiType.getJavaLangRuntimeException(myManager, GlobalSearchScope.allScope(myManager.getProject()));
- inferred = true;
- } else {
- int boundCandidatesNumber = 0;
- for (PsiType upperBound : upperBounds) {
- PsiType substitutedBound = substituteNonProperBound(upperBound, substitutor);
- if (isProperType(substitutedBound)) {
- boundCandidatesNumber++;
- if (!upperBound.equals(substitutedBound)) {
- inferred = true;
- }
- if (glb == null) {
- glb = substitutedBound;
- }
- else {
- glb = GenericsUtil.getGreatestLowerBound(glb, substitutedBound);
- }
- }
- }
- if (!inferred) {
- inferred = boundCandidatesNumber > typeParameter.getExtendsListTypes().length && (typeParameter.getExtendsListTypes().length > 0 || boundCandidatesNumber > 1);
- }
- }
- if (glb != null && (acceptInitialUpperBound && !isInsideRecursiveCall(typeParameter) || inferred)) {
- inferenceVariable.setInstantiation(glb);
- }
- }
- }
- }
- finally {
- final PsiType instantiation = inferenceVariable.getInstantiation();
- if (instantiation != PsiType.NULL) {
- substitutor = substitutor.put(typeParameter, instantiation);
- }
- }
- }
- }
- return substitutor;
- }
-
- private static boolean isThrowable(List<PsiType> upperBounds) {
+ private boolean isThrowable(List<PsiType> upperBounds) {
boolean commonThrowable = false;
for (PsiType upperBound : upperBounds) {
- if (upperBound.equalsToText(CommonClassNames.JAVA_LANG_OBJECT)) continue;
+ if (upperBound.equalsToText(CommonClassNames.JAVA_LANG_OBJECT) || !isProperType(upperBound)) continue;
if (upperBound.equalsToText(CommonClassNames.JAVA_LANG_EXCEPTION) ||
upperBound.equalsToText(CommonClassNames.JAVA_LANG_THROWABLE)) {
commonThrowable = true;
@@ -722,6 +714,125 @@
return isProperType(bound) ? bound : substitutor.substitute(bound);
}
+ private PsiSubstitutor resolveBounds(final Collection<InferenceVariable> inferenceVariables,
+ PsiSubstitutor substitutor) {
+ final Collection<InferenceVariable> allVars = new ArrayList<InferenceVariable>(inferenceVariables);
+ while (!allVars.isEmpty()) {
+ final List<InferenceVariable> vars = InferenceVariablesOrder.resolveOrder(allVars, this);
+ if (!myIncorporationPhase.hasCaptureConstraints(vars)) {
+ final PsiSubstitutor firstSubstitutor = resolveSubset(vars, substitutor, true);
+ if (firstSubstitutor != null) {
+ substitutor = firstSubstitutor;
+ allVars.removeAll(vars);
+ continue;
+ }
+ }
+
+ final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(getManager().getProject());
+ for (InferenceVariable var : vars) {
+ final PsiTypeParameter parameter = var.getParameter();
+ final PsiTypeParameter copy = elementFactory.createTypeParameterFromText(parameter.getName(), null);
+ final PsiType lub = getLowerBound(var, substitutor);
+ final PsiType glb = getUpperBound(var, substitutor);
+ final InferenceVariable zVariable = new InferenceVariable(copy);
+ zVariable.addBound(glb, InferenceBound.UPPER);
+ if (lub != PsiType.NULL) {
+ if (!TypeConversionUtil.isAssignable(glb, lub)) {
+ return null;
+ }
+ copy.putUserData(LOWER_BOUND, lub);
+ zVariable.addBound(lub, InferenceBound.LOWER);
+ }
+ myInferenceVariables.put(copy, zVariable);
+ }
+ myIncorporationPhase.forgetCaptures(vars);
+ if (!myIncorporationPhase.incorporate()) {
+ return null;
+ }
+ }
+ return substitutor;
+ }
+
+ private PsiType getLowerBound(InferenceVariable var, PsiSubstitutor substitutor) {
+ return composeBound(var, InferenceBound.LOWER, new Function<Pair<PsiType, PsiType>, PsiType>() {
+ @Override
+ public PsiType fun(Pair<PsiType, PsiType> pair) {
+ return GenericsUtil.getLeastUpperBound(pair.first, pair.second, myManager);
+ }
+ }, substitutor);
+ }
+
+ private PsiSubstitutor resolveSubset(Collection<InferenceVariable> vars, PsiSubstitutor substitutor, boolean checkResult) {
+ for (InferenceVariable var : vars) {
+ LOG.assertTrue(var.getInstantiation() == PsiType.NULL);
+ final PsiTypeParameter typeParameter = var.getParameter();
+ final PsiType eqBound = getEqualsBound(var, substitutor);
+ if (eqBound != PsiType.NULL && eqBound instanceof PsiPrimitiveType) continue;
+ final PsiType lub = eqBound != PsiType.NULL && (myErased || eqBound != null) ? eqBound : getLowerBound(var, substitutor);
+ if (lub != PsiType.NULL) {
+ substitutor = substitutor.put(typeParameter, lub);
+ }
+ else if (var.isThrownBound() && isThrowable(var.getBounds(InferenceBound.UPPER))) {
+ final PsiClassType runtimeException = PsiType.getJavaLangRuntimeException(myManager, GlobalSearchScope.allScope(myManager.getProject()));
+ substitutor = substitutor.put(typeParameter, runtimeException);
+ }
+ else {
+ substitutor = substitutor.put(typeParameter, getUpperBound(var, substitutor));
+ }
+ }
+
+ return checkResult ? myIncorporationPhase.checkIncorporated(substitutor, vars) : substitutor;
+ }
+
+ private PsiType getUpperBound(InferenceVariable var, PsiSubstitutor substitutor) {
+ return composeBound(var, InferenceBound.UPPER, new Function<Pair<PsiType, PsiType>, PsiType>() {
+ @Override
+ public PsiType fun(Pair<PsiType, PsiType> pair) {
+ return GenericsUtil.getGreatestLowerBound(pair.first, pair.second);
+ }
+ }, substitutor);
+ }
+
+ public PsiType getEqualsBound(InferenceVariable var, PsiSubstitutor substitutor) {
+ return composeBound(var, InferenceBound.EQ, new Function<Pair<PsiType, PsiType>, PsiType>() {
+ @Override
+ public PsiType fun(Pair<PsiType, PsiType> pair) {
+ return pair.first; //todo check if equals
+ }
+ }, substitutor);
+ }
+
+ private PsiType composeBound(InferenceVariable variable,
+ InferenceBound boundType,
+ Function<Pair<PsiType, PsiType>, PsiType> fun,
+ PsiSubstitutor substitutor) {
+ final List<PsiType> lowerBounds = variable.getBounds(boundType);
+ PsiType lub = PsiType.NULL;
+ for (PsiType lowerBound : lowerBounds) {
+ lowerBound = substituteNonProperBound(lowerBound, substitutor);
+ final HashSet<InferenceVariable> dependencies = new HashSet<InferenceVariable>();
+ collectDependencies(lowerBound, dependencies);
+ if (dependencies.size() == 1 && dependencies.contains(variable) && isInsideRecursiveCall(dependencies)) {
+ lub = JavaPsiFacade.getElementFactory(myManager.getProject()).createType(variable.getParameter());
+ } else if (dependencies.isEmpty() || isInsideRecursiveCall(dependencies)) {
+ if (lub == PsiType.NULL) {
+ lub = lowerBound;
+ }
+ else {
+ lub = fun.fun(Pair.create(lub, lowerBound));
+ }
+ }
+ }
+ return lub;
+ }
+
+ private boolean isInsideRecursiveCall(HashSet<InferenceVariable> dependencies) {
+ for (InferenceVariable dependency : dependencies) {
+ if (!isInsideRecursiveCall(dependency.getParameter())) return false;
+ }
+ return true;
+ }
+
public PsiManager getManager() {
return myManager;
}
@@ -746,11 +857,26 @@
private boolean proceedWithAdditionalConstraints(Set<ConstraintFormula> additionalConstraints) {
while (!additionalConstraints.isEmpty()) {
+ //extract subset of constraints
+ final Set<ConstraintFormula> subset = buildSubset(additionalConstraints);
+
+ //collect all input variables of selection
final Set<InferenceVariable> varsToResolve = new HashSet<InferenceVariable>();
+ for (ConstraintFormula formula : subset) {
+ if (formula instanceof InputOutputConstraintFormula) {
+ final Set<InferenceVariable> inputVariables = ((InputOutputConstraintFormula)formula).getInputVariables(this);
+ if (inputVariables != null) {
+ varsToResolve.addAll(inputVariables);
+ }
+ }
+ }
- final Set<ConstraintFormula> subset = buildSubset(additionalConstraints, varsToResolve);
+ //resolve input variables
+ PsiSubstitutor substitutor = resolveSubset(varsToResolve, mySiteSubstitutor, true);
- PsiSubstitutor substitutor = resolveBounds(varsToResolve, mySiteSubstitutor, true);
+ if (substitutor == null) {
+ return false;
+ }
if (myContext instanceof PsiCallExpression) {
PsiExpressionList argumentList = ((PsiCallExpression)myContext).getArgumentList();
@@ -771,8 +897,7 @@
return true;
}
- private Set<ConstraintFormula> buildSubset(final Set<ConstraintFormula> additionalConstraints,
- final Set<InferenceVariable> varsToResolve) {
+ private Set<ConstraintFormula> buildSubset(final Set<ConstraintFormula> additionalConstraints) {
final Set<ConstraintFormula> subset = new HashSet<ConstraintFormula>();
final Set<InferenceVariable> outputVariables = new HashSet<InferenceVariable>();
@@ -802,10 +927,6 @@
}
if (!dependsOnOutput) {
subset.add(constraint);
- for (InferenceVariable variable : inputVariables) {
- varsToResolve.addAll(variable.getDependencies(this));
- varsToResolve.add(variable);
- }
}
}
else {
@@ -847,12 +968,14 @@
final PsiParameter[] parameters1 = m1.getParameterList().getParameters();
final PsiParameter[] parameters2 = m2.getParameterList().getParameters();
- LOG.assertTrue(parameters1.length == parameters2.length);
+ if (!varargs) {
+ LOG.assertTrue(parameters1.length == parameters2.length);
+ }
final int paramsLength = !varargs ? parameters1.length : parameters1.length - 1;
for (int i = 0; i < paramsLength; i++) {
PsiType sType = siteSubstitutor2.substitute(parameters1[i].getType());
- PsiType tType = siteSubstitutor2.substitute(parameters2[i].getType());
+ PsiType tType = siteSubstitutor2.substitute(getVarargParameterType(varargs, i, parameters2));
if (session.isProperType(sType) && session.isProperType(tType)) {
if (!TypeConversionUtil.isAssignable(tType, sType)) {
return false;
@@ -870,13 +993,22 @@
if (varargs) {
PsiType sType = siteSubstitutor2.substitute(parameters1[paramsLength].getType());
- PsiType tType = siteSubstitutor2.substitute(parameters2[paramsLength].getType());
+ PsiType tType = siteSubstitutor2.substitute(getVarargParameterType(true, paramsLength, parameters2));
session.addConstraint(new StrictSubtypingConstraint(tType, sType));
}
return session.repeatInferencePhases(true);
}
+ public static PsiType getVarargParameterType(boolean varargs, int i, PsiParameter[] parameters2) {
+ if (varargs && i >= parameters2.length - 1) {
+ final PsiType lastParamType = parameters2[parameters2.length - 1].getType();
+ LOG.assertTrue(lastParamType instanceof PsiEllipsisType);
+ return ((PsiEllipsisType)lastParamType).getComponentType();
+ }
+ return parameters2[i].getType();
+ }
+
/**
* 15.12.2.5 Choosing the Most Specific Method
* "a functional interface type S is more specific than a functional interface type T for an expression exp" part
@@ -891,8 +1023,9 @@
PsiType tType,
@Nullable InferenceSession session,
PsiExpression... args) {
- final PsiClassType.ClassResolveResult sResult = PsiUtil.resolveGenericsClassInType(sType);
- final PsiMethod sInterfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(sResult); //todo capture of Si
+ final PsiType capturedSType = sType;//todo capture of Si session != null && sType != null ? PsiUtil.captureToplevelWildcards(sType, session.myContext) : sType;
+ final PsiClassType.ClassResolveResult sResult = PsiUtil.resolveGenericsClassInType(capturedSType);
+ final PsiMethod sInterfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(sResult);
LOG.assertTrue(sInterfaceMethod != null);
final PsiSubstitutor sSubstitutor = LambdaUtil.getSubstitutor(sInterfaceMethod, sResult);
@@ -969,8 +1102,8 @@
if (arg instanceof PsiMethodReferenceExpression && ((PsiMethodReferenceExpression)arg).isExact()) {
final PsiParameter[] sParameters = sInterfaceMethod.getParameterList().getParameters();
final PsiParameter[] tParameters = tInterfaceMethod.getParameterList().getParameters();
- LOG.assertTrue(sParameters.length == tParameters.length);
if (session != null) {
+ LOG.assertTrue(sParameters.length == tParameters.length);
for (int i = 0; i < tParameters.length; i++) {
session.addConstraint(new TypeEqualityConstraint(tSubstitutor.substitute(tParameters[i].getType()),
sSubstitutor.substitute(sParameters[i].getType())));
@@ -986,15 +1119,15 @@
return false;
}
- final boolean sPrimitive = sReturnType instanceof PsiPrimitiveType;
- final boolean tPrimitive = tReturnType instanceof PsiPrimitiveType;
+ final boolean sPrimitive = sReturnType instanceof PsiPrimitiveType && sReturnType != PsiType.VOID;
+ final boolean tPrimitive = tReturnType instanceof PsiPrimitiveType && tReturnType != PsiType.VOID;
if (sPrimitive ^ tPrimitive) {
final PsiMember member = ((PsiMethodReferenceExpression)arg).getPotentiallyApplicableMember();
LOG.assertTrue(member != null);
if (member instanceof PsiMethod) {
final PsiType methodReturnType = ((PsiMethod)member).getReturnType();
- if (sPrimitive && methodReturnType instanceof PsiPrimitiveType ||
+ if (sPrimitive && methodReturnType instanceof PsiPrimitiveType && methodReturnType != PsiType.VOID ||
tPrimitive && methodReturnType instanceof PsiClassType) {
return true;
}
@@ -1054,4 +1187,33 @@
}
return false;
}
+
+ public void collectCaptureDependencies(InferenceVariable inferenceVariable, Set<InferenceVariable> dependencies) {
+ myIncorporationPhase.collectCaptureDependencies(inferenceVariable, dependencies);
+ }
+
+ public boolean hasCapture(InferenceVariable inferenceVariable) {
+ return myIncorporationPhase.hasCaptureConstraints(Arrays.asList(inferenceVariable));
+ }
+
+ public void liftBounds(Collection<InferenceVariable> variables) {
+ for (InferenceVariable variable : variables) {
+ final PsiTypeParameter parameter = variable.getParameter();
+ final InferenceVariable inferenceVariable = getInferenceVariable(parameter);
+ if (inferenceVariable != null) {
+ for (InferenceBound boundType : InferenceBound.values()) {
+ for (PsiType bound : variable.getBounds(boundType)) {
+ inferenceVariable.addBound(bound, boundType);
+ }
+ }
+ } else {
+ myInferenceVariables.put(parameter, variable);
+ }
+ }
+ }
+
+ public static boolean wasUncheckedConversionPerformed(PsiElement call) {
+ final Boolean erased = call.getUserData(ERASED);
+ return erased != null && erased.booleanValue();
+ }
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceVariable.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceVariable.java
index c3ef4b6..bb8db38 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceVariable.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceVariable.java
@@ -15,7 +15,8 @@
*/
package com.intellij.psi.impl.source.resolve.graphInference;
-import com.intellij.psi.*;
+import com.intellij.psi.PsiType;
+import com.intellij.psi.PsiTypeParameter;
import java.util.*;
@@ -42,22 +43,15 @@
public void setInstantiation(PsiType instantiation) {
myInstantiation = instantiation;
}
-
- public void ignoreInstantiation() {
- myInstantiation = PsiType.NULL;
- }
public boolean addBound(PsiType classType, InferenceBound inferenceBound) {
- if (inferenceBound == InferenceBound.EQ && classType instanceof PsiClassType && ((PsiClassType)classType).resolve() == myParameter) {
- return false;
- }
List<PsiType> list = myBounds.get(inferenceBound);
if (list == null) {
list = new ArrayList<PsiType>();
myBounds.put(inferenceBound, list);
}
final int idx = list.indexOf(classType);
- if (idx < 0 || inferenceBound == InferenceBound.EQ && classType instanceof PsiCapturedWildcardType && list.get(idx) != classType) {
+ if (idx < 0) {
list.add(classType);
return true;
}
@@ -76,6 +70,33 @@
session.collectDependencies(bound, dependencies);
}
}
+
+ next:
+ for (InferenceVariable variable : session.getInferenceVariables()) {
+ if (!dependencies.contains(variable) && variable != this) {
+ for (InferenceBound inferenceBound : InferenceBound.values()) {
+ for (PsiType bound : getBounds(inferenceBound)) {
+ Set<InferenceVariable> deps = new HashSet<InferenceVariable>();
+ session.collectDependencies(bound, deps);
+ if (deps.contains(this)) {
+ dependencies.add(variable);
+ continue next;
+ }
+ }
+ }
+ }
+ }
+
+ if (!session.hasCapture(this)) {
+ return dependencies;
+ }
+
+ for (Iterator<InferenceVariable> iterator = dependencies.iterator(); iterator.hasNext(); ) {
+ if (!session.hasCapture(iterator.next())) {
+ iterator.remove();
+ }
+ }
+ session.collectCaptureDependencies(this, dependencies);
return dependencies;
}
@@ -87,16 +108,12 @@
myThrownBound = true;
}
- public InferenceVariable copy() {
- final InferenceVariable variable = new InferenceVariable(myParameter);
- for (InferenceBound bound : InferenceBound.values()) {
- for (PsiType type : getBounds(bound)) {
- variable.addBound(type, bound);
- }
- }
- if (myThrownBound) {
- variable.setThrownBound();
- }
- return variable;
+ public void replaceBounds(InferenceBound boundType, LinkedHashSet<PsiType> bounds) {
+
+ }
+
+ @Override
+ public String toString() {
+ return myParameter.toString();
}
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceVariablesOrder.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceVariablesOrder.java
index cd87df6..1c91b06 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceVariablesOrder.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceVariablesOrder.java
@@ -28,7 +28,7 @@
public class InferenceVariablesOrder {
- public static List<List<InferenceVariable>> resolveOrder(Collection<InferenceVariable> vars, InferenceSession session) {
+ public static List<InferenceVariable> resolveOrder(Collection<InferenceVariable> vars, InferenceSession session) {
Map<InferenceVariable, InferenceGraphNode<InferenceVariable>> nodes =
new LinkedHashMap<InferenceVariable, InferenceGraphNode<InferenceVariable>>();
for (InferenceVariable var : vars) {
@@ -52,7 +52,7 @@
public List<InferenceVariable> fun(InferenceGraphNode<InferenceVariable> node) {
return node.getValue();
}
- });
+ }).iterator().next();
}
public static <T> List<List<InferenceGraphNode<T>>> tarjan(Collection<InferenceGraphNode<T>> nodes) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/LiftParameterTypeInferencePolicy.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/LiftParameterTypeInferencePolicy.java
deleted file mode 100644
index 1ac3a22..0000000
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/LiftParameterTypeInferencePolicy.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2000-2013 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.psi.impl.source.resolve.graphInference;
-
-import com.intellij.psi.impl.source.resolve.DefaultParameterTypeInferencePolicy;
-
-/**
- * User: anna
- * Date: 11/16/13
- */
-public class LiftParameterTypeInferencePolicy extends DefaultParameterTypeInferencePolicy {
- public static final LiftParameterTypeInferencePolicy INSTANCE = new LiftParameterTypeInferencePolicy();
-
- @Override
- public boolean allowPostponeInference() {
- return true;
- }
-}
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/PsiGraphInferenceHelper.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/PsiGraphInferenceHelper.java
index 094ef28..b4c971b 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/PsiGraphInferenceHelper.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/PsiGraphInferenceHelper.java
@@ -40,7 +40,7 @@
@NotNull ParameterTypeInferencePolicy policy) {
final InferenceSession inferenceSession = new InferenceSession(new PsiTypeParameter[]{typeParameter}, partialSubstitutor, myManager, parent);
inferenceSession.initExpressionConstraints(parameters, arguments, parent, null);
- return inferenceSession.infer(parameters, arguments, parent, policy).substitute(typeParameter);
+ return inferenceSession.infer(parameters, arguments, parent).substitute(typeParameter);
}
@NotNull
@@ -55,7 +55,7 @@
if (typeParameters.length == 0) return partialSubstitutor;
final InferenceSession inferenceSession = new InferenceSession(typeParameters, partialSubstitutor, myManager, parent);
inferenceSession.initExpressionConstraints(parameters, arguments, parent, null);
- return inferenceSession.infer(parameters, arguments, parent, policy);
+ return inferenceSession.infer(parameters, arguments, parent);
}
@NotNull
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/ExpressionCompatibilityConstraint.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/ExpressionCompatibilityConstraint.java
index 6caa6bf..30628e3 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/ExpressionCompatibilityConstraint.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/ExpressionCompatibilityConstraint.java
@@ -15,18 +15,16 @@
*/
package com.intellij.psi.impl.source.resolve.graphInference.constraints;
-import com.intellij.openapi.util.Pair;
import com.intellij.psi.*;
-import com.intellij.psi.impl.source.resolve.DefaultParameterTypeInferencePolicy;
import com.intellij.psi.impl.source.resolve.graphInference.InferenceSession;
import com.intellij.psi.impl.source.resolve.graphInference.InferenceVariable;
-import com.intellij.psi.impl.source.resolve.graphInference.LiftParameterTypeInferencePolicy;
import com.intellij.psi.impl.source.resolve.graphInference.PsiPolyExpressionUtil;
import com.intellij.psi.impl.source.tree.java.PsiMethodCallExpressionImpl;
import com.intellij.psi.infos.MethodCandidateInfo;
import com.intellij.psi.util.TypeConversionUtil;
import org.jetbrains.annotations.NotNull;
+import java.util.Collection;
import java.util.List;
import java.util.Set;
@@ -50,7 +48,7 @@
}
final PsiType exprType = myExpression.getType();
- if (exprType != null) {
+ if (exprType != null && exprType != PsiType.NULL) {
constraints.add(new TypeCompatibilityConstraint(myT, exprType));
}
return true;
@@ -79,9 +77,8 @@
if (myExpression instanceof PsiCallExpression) {
final PsiExpressionList argumentList = ((PsiCallExpression)myExpression).getArgumentList();
if (argumentList != null) {
- final Pair<PsiMethod,PsiSubstitutor> pair = MethodCandidateInfo.getCurrentMethod(argumentList);
- final JavaResolveResult resolveResult = pair == null ? ((PsiCallExpression)myExpression).resolveMethodGenerics() : null;
- final PsiMethod method = pair != null ? pair.first : (PsiMethod)resolveResult.getElement();
+ final JavaResolveResult resolveResult = ((PsiCallExpression)myExpression).resolveMethodGenerics();
+ final PsiMethod method = (PsiMethod)resolveResult.getElement();
PsiType returnType = null;
PsiTypeParameter[] typeParams = null;
if (method != null && !method.isConstructor()) {
@@ -106,21 +103,23 @@
session.addCapturedVariable(typeParam);
}
PsiSubstitutor substitutor = PsiSubstitutor.EMPTY;
- if (pair == null) {
- if (method != null) {
- InferenceSession callSession = new InferenceSession(typeParams, ((MethodCandidateInfo)resolveResult).getSiteSubstitutor(), myExpression.getManager(), myExpression);
- final PsiExpression[] args = argumentList.getExpressions();
- final PsiParameter[] parameters = method.getParameterList().getParameters();
- callSession.initExpressionConstraints(parameters, args, myExpression, method);
- substitutor = callSession.infer(parameters, args, myExpression, true, LiftParameterTypeInferencePolicy.INSTANCE);
+ if (method != null) {
+ //typeParams are already included
+ final Collection<PsiTypeParameter> params = session.getTypeParams();
+ InferenceSession callSession = new InferenceSession(params.toArray(new PsiTypeParameter[params.size()]), resolveResult instanceof MethodCandidateInfo ? ((MethodCandidateInfo)resolveResult).getSiteSubstitutor()
+ : PsiSubstitutor.EMPTY, myExpression.getManager(), myExpression);
+ final PsiExpression[] args = argumentList.getExpressions();
+ final PsiParameter[] parameters = method.getParameterList().getParameters();
+ callSession.initExpressionConstraints(parameters, args, myExpression, method);
+ callSession.registerConstraints(returnType, myT);
+ if (callSession.repeatInferencePhases(true)) {
+ session.liftBounds(callSession.getInferenceVariables());
}
- } else {
- substitutor = pair.second;
}
final PsiType capturedReturnType = myExpression instanceof PsiMethodCallExpression
? PsiMethodCallExpressionImpl.captureReturnType((PsiMethodCallExpression)myExpression, method, returnType, substitutor)
: substitutor.substitute(returnType);
- constraints.add(new TypeCompatibilityConstraint(GenericsUtil.eliminateWildcards(myT, false), capturedReturnType));
+ constraints.add(new TypeCompatibilityConstraint(myT, capturedReturnType));
}
}
return true;
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/InputOutputConstraintFormula.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/InputOutputConstraintFormula.java
index e409089..0a49428 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/InputOutputConstraintFormula.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/InputOutputConstraintFormula.java
@@ -49,7 +49,7 @@
if (inferenceVariable != null) {
return Collections.singleton(inferenceVariable);
}
- if (LambdaHighlightingUtil.checkInterfaceFunctional(type) == null) {
+ if (LambdaUtil.isFunctionalType(type)) {
final PsiType functionType =
psiExpression instanceof PsiLambdaExpression
? FunctionalInterfaceParameterizationUtil.getGroundTargetType(type, (PsiLambdaExpression)psiExpression)
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/LambdaExpressionCompatibilityConstraint.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/LambdaExpressionCompatibilityConstraint.java
index 3d923b7..12e7bfe 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/LambdaExpressionCompatibilityConstraint.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/LambdaExpressionCompatibilityConstraint.java
@@ -65,7 +65,7 @@
returnType = substitutor.substitute(returnType);
if (!session.isProperType(returnType)) {
for (PsiExpression returnExpression : returnExpressions) {
- constraints.add(new ExpressionCompatibilityConstraint(returnExpression, GenericsUtil.eliminateWildcards(returnType)));
+ constraints.add(new ExpressionCompatibilityConstraint(returnExpression, returnType));
}
}
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/PsiMethodReferenceCompatibilityConstraint.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/PsiMethodReferenceCompatibilityConstraint.java
index 175f3d6..21480db 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/PsiMethodReferenceCompatibilityConstraint.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/PsiMethodReferenceCompatibilityConstraint.java
@@ -85,11 +85,11 @@
if (targetParameters.length == parameters.length + 1) {
specialCase(session, constraints, substitutor, targetParameters);
for (int i = 1; i < targetParameters.length; i++) {
- constraints.add(new TypeCompatibilityConstraint(psiSubstitutor.substitute(parameters[i - 1].getType()), GenericsUtil.eliminateWildcards(substitutor.substitute(targetParameters[i].getType()))));
+ constraints.add(new TypeCompatibilityConstraint(psiSubstitutor.substitute(parameters[i - 1].getType()), substitutor.substitute(targetParameters[i].getType())));
}
} else if (targetParameters.length == parameters.length) {
for (int i = 0; i < targetParameters.length; i++) {
- constraints.add(new TypeCompatibilityConstraint(psiSubstitutor.substitute(parameters[i].getType()), GenericsUtil.eliminateWildcards(substitutor.substitute(targetParameters[i].getType()))));
+ constraints.add(new TypeCompatibilityConstraint(psiSubstitutor.substitute(parameters[i].getType()), substitutor.substitute(targetParameters[i].getType())));
}
} else {
return false;
@@ -100,13 +100,13 @@
}
if (applicableMethodReturnType != null) {
- constraints.add(new TypeCompatibilityConstraint(GenericsUtil.eliminateWildcards(returnType), psiSubstitutor.substitute(applicableMethodReturnType)));
+ constraints.add(new TypeCompatibilityConstraint(returnType, psiSubstitutor.substitute(applicableMethodReturnType)));
} else if (applicableMember instanceof PsiClass || applicableMember instanceof PsiMethod && ((PsiMethod)applicableMember).isConstructor()) {
final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(applicableMember.getProject());
final PsiClass containingClass = qualifierResolveResult.getContainingClass();
if (containingClass != null) {
final PsiClassType classType = elementFactory.createType(containingClass, psiSubstitutor);
- constraints.add(new TypeCompatibilityConstraint(GenericsUtil.eliminateWildcards(returnType), classType));
+ constraints.add(new TypeCompatibilityConstraint(returnType, classType));
}
}
}
@@ -150,10 +150,13 @@
LOG.assertTrue(referencedMethodReturnType != null, method);
session.initBounds(method.getTypeParameters());
- session.initBounds(containingClass.getTypeParameters());
- if (typeParameters.length == 0 && ((PsiMethod)resolve).getTypeParameters().length > 0) {
+ if (!PsiTreeUtil.isContextAncestor(containingClass, myExpression, false) ||
+ PsiUtil.getEnclosingStaticElement(myExpression, containingClass) != null) {
+ session.initBounds(containingClass.getTypeParameters());
+ }
+ if (typeParameters.length == 0 && method.getTypeParameters().length > 0) {
final PsiClass interfaceClass = classResolveResult.getElement();
LOG.assertTrue(interfaceClass != null);
if (PsiPolyExpressionUtil.mentionsTypeParameters(referencedMethodReturnType,
@@ -176,7 +179,8 @@
}
final PsiParameter[] parameters = method.getParameterList().getParameters();
- if (targetParameters.length == parameters.length + 1 && !method.isVarArgs()) {
+ if (targetParameters.length == parameters.length + 1 && !method.isVarArgs() &&
+ PsiPolyExpressionUtil.mentionsTypeParameters(referencedMethodReturnType, ContainerUtil.newHashSet(containingClass.getTypeParameters()))) { //todo specification bug?
specialCase(session, constraints, substitutor, targetParameters);
}
constraints.add(new TypeCompatibilityConstraint(returnType, psiSubstitutor.substitute(referencedMethodReturnType)));
@@ -214,7 +218,7 @@
final PsiClass qualifierClass = PsiUtil.resolveClassInType(qualifierType);
if (qualifierClass != null) {
session.initBounds(qualifierClass.getTypeParameters());
- constraints.add(new StrictSubtypingConstraint(qualifierType, GenericsUtil.eliminateWildcards(substitutor.substitute(targetParameters[0].getType()))));
+ constraints.add(new StrictSubtypingConstraint(qualifierType, substitutor.substitute(targetParameters[0].getType())));
}
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/StrictSubtypingConstraint.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/StrictSubtypingConstraint.java
index 88accf9..db193dd 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/StrictSubtypingConstraint.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/StrictSubtypingConstraint.java
@@ -19,6 +19,7 @@
import com.intellij.psi.impl.source.resolve.graphInference.InferenceBound;
import com.intellij.psi.impl.source.resolve.graphInference.InferenceSession;
import com.intellij.psi.impl.source.resolve.graphInference.InferenceVariable;
+import com.intellij.psi.util.InheritanceUtil;
import com.intellij.psi.util.TypeConversionUtil;
import java.util.List;
@@ -50,8 +51,8 @@
return TypeConversionUtil.isAssignable(myT, myS);
}
- if (PsiType.NULL.equals(myS) || myS == null) return true;
if (PsiType.NULL.equals(myT) || myT == null) return false;
+ if (PsiType.NULL.equals(myS) || myS == null || myT.equalsToText(CommonClassNames.JAVA_LANG_OBJECT)) return true;
InferenceVariable inferenceVariable = session.getInferenceVariable(myS);
if (inferenceVariable != null) {
@@ -83,13 +84,20 @@
if (myT.equals(conjunct)) return true;
}
}
- //todo ((PsiTypeParameter)C).getLowerBound()
+ final PsiType lowerBound = CClass.getUserData(InferenceSession.LOWER_BOUND);
+ if (lowerBound != null) {
+ constraints.add(new StrictSubtypingConstraint(lowerBound, myS));
+ return true;
+ }
return false;
}
if (!(myS instanceof PsiClassType)) return false;
PsiClassType.ClassResolveResult SResult = ((PsiClassType)myS).resolveGenerics();
PsiClass SClass = SResult.getElement();
+ if (((PsiClassType)myT).isRaw()) {
+ return SClass != null && InheritanceUtil.isInheritorOrSelf(SClass, CClass, true);
+ }
final PsiSubstitutor tSubstitutor = TResult.getSubstitutor();
final PsiSubstitutor sSubstitutor = SClass != null ? TypeConversionUtil.getClassSubstitutor(CClass, SClass, SResult.getSubstitutor()) : null;
if (sSubstitutor != null) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/SubtypingConstraint.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/SubtypingConstraint.java
index f226228..8b7b7fb 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/SubtypingConstraint.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/SubtypingConstraint.java
@@ -20,9 +20,7 @@
import com.intellij.psi.PsiSubstitutor;
import com.intellij.psi.PsiType;
import com.intellij.psi.PsiWildcardType;
-import com.intellij.psi.impl.source.resolve.graphInference.InferenceBound;
import com.intellij.psi.impl.source.resolve.graphInference.InferenceSession;
-import com.intellij.psi.impl.source.resolve.graphInference.InferenceVariable;
import java.util.List;
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/TypeEqualityConstraint.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/TypeEqualityConstraint.java
index 1b5ebfb..7e2443a 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/TypeEqualityConstraint.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/TypeEqualityConstraint.java
@@ -72,6 +72,8 @@
}
if (session.isProperType(myT) && session.isProperType(myS)) {
+ if (myT == null) return myS == null || myS.equalsToText(CommonClassNames.JAVA_LANG_OBJECT);
+ if (myS == null) return myT.equalsToText(CommonClassNames.JAVA_LANG_OBJECT);
return Comparing.equal(myT, myS);
}
InferenceVariable inferenceVariable = session.getInferenceVariable(myS);
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiLambdaExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiLambdaExpressionImpl.java
index 90ca869..d6f9f1b 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiLambdaExpressionImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiLambdaExpressionImpl.java
@@ -17,6 +17,7 @@
import com.intellij.lang.ASTNode;
import com.intellij.psi.*;
+import com.intellij.psi.codeStyle.JavaCodeStyleManager;
import com.intellij.psi.controlFlow.*;
import com.intellij.psi.impl.PsiImplUtil;
import com.intellij.psi.impl.source.resolve.graphInference.FunctionalInterfaceParameterizationUtil;
@@ -25,6 +26,7 @@
import com.intellij.psi.scope.PsiScopeProcessor;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.psi.util.PsiUtil;
import com.intellij.util.containers.IntArrayList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -142,4 +144,65 @@
}
return true;
}
+
+ @Override
+ public boolean isAcceptable(PsiType leftType, boolean checkReturnType) {
+ if (leftType instanceof PsiIntersectionType) {
+ for (PsiType conjunctType : ((PsiIntersectionType)leftType).getConjuncts()) {
+ if (isAcceptable(conjunctType, checkReturnType)) return true;
+ }
+ return false;
+ }
+ leftType = FunctionalInterfaceParameterizationUtil.getGroundTargetType(leftType, this);
+
+ final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(leftType);
+ final PsiClass psiClass = resolveResult.getElement();
+ if (psiClass instanceof PsiAnonymousClass) {
+ return isAcceptable(((PsiAnonymousClass)psiClass).getBaseClassType(), checkReturnType);
+ }
+
+ final PsiMethod interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(resolveResult);
+
+ if (interfaceMethod == null) return false;
+
+ final PsiSubstitutor substitutor = LambdaUtil.getSubstitutor(interfaceMethod, resolveResult);
+
+ assert leftType != null;
+ final PsiParameter[] lambdaParameters = getParameterList().getParameters();
+ final PsiType[] parameterTypes = interfaceMethod.getSignature(substitutor).getParameterTypes();
+ if (lambdaParameters.length != parameterTypes.length) return false;
+
+ for (int lambdaParamIdx = 0, length = lambdaParameters.length; lambdaParamIdx < length; lambdaParamIdx++) {
+ PsiParameter parameter = lambdaParameters[lambdaParamIdx];
+ final PsiTypeElement typeElement = parameter.getTypeElement();
+ if (typeElement != null) {
+ final PsiType lambdaFormalType = toArray(typeElement.getType());
+ final PsiType methodParameterType = toArray(parameterTypes[lambdaParamIdx]);
+ if (!lambdaFormalType.equals(methodParameterType)) {
+ return false;
+ }
+ }
+ }
+
+ if (checkReturnType) {
+ final String uniqueVarName = JavaCodeStyleManager.getInstance(getProject()).suggestUniqueVariableName("l", this, true);
+ final String canonicalText = toArray(leftType).getCanonicalText();
+ final PsiStatement assignmentFromText = JavaPsiFacade.getElementFactory(getProject())
+ .createStatementFromText(canonicalText + " " + uniqueVarName + " = " + getText(), this);
+ final PsiLocalVariable localVariable = (PsiLocalVariable)((PsiDeclarationStatement)assignmentFromText).getDeclaredElements()[0];
+ PsiType methodReturnType = interfaceMethod.getReturnType();
+ if (methodReturnType != null) {
+ return LambdaHighlightingUtil.checkReturnTypeCompatible((PsiLambdaExpression)localVariable.getInitializer(),
+ substitutor.substitute(methodReturnType)) == null;
+ }
+ }
+ return true;
+ }
+
+ private static PsiType toArray(PsiType paramType) {
+ if (paramType instanceof PsiEllipsisType) {
+ return ((PsiEllipsisType)paramType).toArrayType();
+ }
+ return paramType;
+ }
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodCallExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodCallExpressionImpl.java
index 36013c3..dc204b4 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodCallExpressionImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodCallExpressionImpl.java
@@ -24,6 +24,7 @@
import com.intellij.psi.impl.DebugUtil;
import com.intellij.psi.impl.PsiImplUtil;
import com.intellij.psi.impl.source.resolve.JavaResolveCache;
+import com.intellij.psi.impl.source.resolve.graphInference.InferenceSession;
import com.intellij.psi.impl.source.tree.ChildRole;
import com.intellij.psi.impl.source.tree.ElementType;
import com.intellij.psi.impl.source.tree.JavaElementType;
@@ -208,6 +209,12 @@
PsiSubstitutor substitutor) {
PsiType substitutedReturnType = substitutor.substitute(ret);
if (substitutedReturnType == null) return TypeConversionUtil.erasure(ret);
+ if (InferenceSession.wasUncheckedConversionPerformed(call)) {
+ // 18.5.2
+ // if unchecked conversion was necessary, then this substitution provides the parameter types of the invocation type,
+ // while the return type and thrown types are given by the erasure of m's type (without applying θ').
+ return TypeConversionUtil.erasure(substitutedReturnType);
+ }
if (PsiUtil.isRawSubstitutor(method, substitutor)) {
final PsiType returnTypeErasure = TypeConversionUtil.erasure(ret);
if (Comparing.equal(TypeConversionUtil.erasure(substitutedReturnType), returnTypeErasure)) {
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 89ef1e0..fdd02e8 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
@@ -45,6 +45,7 @@
import com.intellij.psi.scope.util.PsiScopesUtil;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.util.*;
+import com.intellij.util.Function;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.SmartList;
import org.jetbrains.annotations.NotNull;
@@ -59,6 +60,26 @@
super(JavaElementType.METHOD_REF_EXPRESSION);
}
+ private static boolean arrayCreationSignature(MethodSignature signature) {
+ if (arrayCompatibleSignature(signature.getParameterTypes(), new Function<PsiType[], PsiType>() {
+ @Override
+ public PsiType fun(PsiType[] types) {
+ return types[0];
+ }
+ })) {
+ return true;
+ }
+ return false;
+ }
+
+ public static <T> boolean arrayCompatibleSignature(T[] paramTypes, Function<T[], PsiType> fun) {
+ if (paramTypes.length == 1) {
+ final PsiType paramType = fun.fun(paramTypes);
+ if (paramType != null && TypeConversionUtil.isAssignable(PsiType.INT, paramType)) return true;
+ }
+ return false;
+ }
+
@Override
public PsiTypeElement getQualifierType() {
final PsiElement qualifier = getQualifier();
@@ -110,9 +131,12 @@
if (parametersCount == interfaceArity - 1 && !isStatic) {
return true;
}
+ if (((PsiMethod)element).isVarArgs()) return true;
} else if (!isStatic) {
return true;
}
+ } else if (element instanceof PsiClass) {
+ return true;
}
}
return false;
@@ -408,9 +432,9 @@
substitutor = session.infer();
}
ClassCandidateInfo candidateInfo = null;
- if ((containingClass.getContainingClass() == null || !isLocatedInStaticContext(containingClass)) &&
- signature.getParameterTypes().length == 0 ||
- PsiMethodReferenceUtil.onArrayType(containingClass, signature)) {
+ final boolean isArray = containingClass == JavaPsiFacade.getElementFactory(getProject()).getArrayClass(PsiUtil.getLanguageLevel(containingClass));
+ if (!isArray && (containingClass.getContainingClass() == null || !isLocatedInStaticContext(containingClass)) && signature.getParameterTypes().length == 0 ||
+ isArray && arrayCreationSignature(signature)) {
candidateInfo = new ClassCandidateInfo(containingClass, substitutor);
}
return candidateInfo == null ? JavaResolveResult.EMPTY_ARRAY : new JavaResolveResult[]{candidateInfo};
@@ -488,9 +512,6 @@
session.addConstraint(new TypeCompatibilityConstraint(getParameterType(parameters, i, varargs), interfaceParamType));
}
}
- else {
- return substitutor;
- }
if (!session.repeatInferencePhases(false)) {
if (method.isVarArgs() && !varargs) {
@@ -698,4 +719,111 @@
}
}
}
+
+ @Override
+ public boolean isAcceptable(PsiType left) {
+ if (left instanceof PsiIntersectionType) {
+ for (PsiType conjunct : ((PsiIntersectionType)left).getConjuncts()) {
+ if (isAcceptable(conjunct)) return true;
+ }
+ return false;
+ }
+
+ left = FunctionalInterfaceParameterizationUtil.getGroundTargetType(left);
+ if (!isPotentiallyCompatible(left)) {
+ return false;
+ }
+
+ final PsiElement argsList = PsiTreeUtil.getParentOfType(this, PsiExpressionList.class);
+ if (MethodCandidateInfo.ourOverloadGuard.currentStack().contains(argsList)) {
+ if (!isExact()) {
+ return true;
+ }
+ }
+
+ // A method reference is congruent with a function type if the following are true:
+ // The function type identifies a single compile-time declaration corresponding to the reference.
+ // One of the following is true:
+ // i)The return type of the function type is void.
+ // ii)The return type of the function type is R;
+ // the result of applying capture conversion (5.1.10) to the return type of the invocation type (15.12.2.6) of the chosen declaration is R',
+ // where R is the target type that may be used to infer R'; neither R nor R' is void; and R' is compatible with R in an assignment context.
+
+ Map<PsiMethodReferenceExpression, PsiType> map = PsiMethodReferenceUtil.ourRefs.get();
+ if (map == null) {
+ map = new HashMap<PsiMethodReferenceExpression, PsiType>();
+ PsiMethodReferenceUtil.ourRefs.set(map);
+ }
+
+ final JavaResolveResult result;
+ try {
+ if (map.put(this, left) != null) {
+ return false;
+ }
+ result = advancedResolve(false);
+ }
+ finally {
+ map.remove(this);
+ }
+
+ final PsiElement resolve = result.getElement();
+ if (resolve == null) {
+ return false;
+ }
+
+ final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(left);
+ final PsiMethod interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(resolveResult);
+ if (interfaceMethod != null) {
+ final PsiType interfaceReturnType = LambdaUtil.getFunctionalInterfaceReturnType(left);
+
+ LOG.assertTrue(interfaceReturnType != null);
+
+ if (interfaceReturnType == PsiType.VOID) {
+ return true;
+ }
+
+ final PsiSubstitutor subst = result.getSubstitutor();
+
+ PsiType methodReturnType = null;
+ PsiClass containingClass = null;
+ if (resolve instanceof PsiMethod) {
+ containingClass = ((PsiMethod)resolve).getContainingClass();
+
+ PsiType returnType = PsiTypesUtil.patchMethodGetClassReturnType(this, this, (PsiMethod)resolve, null, PsiUtil.getLanguageLevel(this));
+
+ if (returnType == null) {
+ returnType = ((PsiMethod)resolve).getReturnType();
+ }
+
+ if (returnType == PsiType.VOID) {
+ return false;
+ }
+
+ methodReturnType = subst.substitute(returnType);
+ }
+ else if (resolve instanceof PsiClass) {
+ if (resolve == JavaPsiFacade.getElementFactory(resolve.getProject()).getArrayClass(PsiUtil.getLanguageLevel(resolve))) {
+ final PsiTypeParameter[] typeParameters = ((PsiClass)resolve).getTypeParameters();
+ if (typeParameters.length == 1) {
+ final PsiType arrayComponentType = subst.substitute(typeParameters[0]);
+ if (arrayComponentType == null) {
+ return false;
+ }
+ methodReturnType = arrayComponentType.createArrayType();
+ }
+ }
+ containingClass = (PsiClass)resolve;
+ }
+
+ if (methodReturnType == null) {
+ if (containingClass == null) {
+ return false;
+ }
+ methodReturnType = JavaPsiFacade.getElementFactory(getProject()).createType(containingClass, subst);
+ }
+
+ return TypeConversionUtil.isAssignable(interfaceReturnType, methodReturnType, false);
+ }
+ return false;
+ }
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/presentation/java/ClassPresentationProvider.java b/java/java-psi-impl/src/com/intellij/psi/presentation/java/ClassPresentationProvider.java
index 12b234d..2c890f4 100644
--- a/java/java-psi-impl/src/com/intellij/psi/presentation/java/ClassPresentationProvider.java
+++ b/java/java-psi-impl/src/com/intellij/psi/presentation/java/ClassPresentationProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiClassOwner;
import com.intellij.psi.PsiFile;
+import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -32,7 +33,7 @@
*/
public class ClassPresentationProvider implements ItemPresentationProvider<PsiClass> {
@Override
- public ItemPresentation getPresentation(final PsiClass psiClass) {
+ public ItemPresentation getPresentation(@NotNull final PsiClass psiClass) {
return new ColoredItemPresentation() {
@Override
public String getPresentableText() {
diff --git a/java/java-psi-impl/src/com/intellij/psi/presentation/java/FieldPresentationProvider.java b/java/java-psi-impl/src/com/intellij/psi/presentation/java/FieldPresentationProvider.java
index 3b3d6ed..6b2ad4f 100644
--- a/java/java-psi-impl/src/com/intellij/psi/presentation/java/FieldPresentationProvider.java
+++ b/java/java-psi-impl/src/com/intellij/psi/presentation/java/FieldPresentationProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 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,13 +18,14 @@
import com.intellij.navigation.ItemPresentation;
import com.intellij.navigation.ItemPresentationProvider;
import com.intellij.psi.PsiField;
+import org.jetbrains.annotations.NotNull;
/**
* @author yole
*/
public class FieldPresentationProvider implements ItemPresentationProvider<PsiField> {
@Override
- public ItemPresentation getPresentation(PsiField item) {
+ public ItemPresentation getPresentation(@NotNull PsiField item) {
return JavaPresentationUtil.getFieldPresentation(item);
}
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/presentation/java/JavaPresentationUtil.java b/java/java-psi-impl/src/com/intellij/psi/presentation/java/JavaPresentationUtil.java
index 69dcc96..9ac376a 100644
--- a/java/java-psi-impl/src/com/intellij/psi/presentation/java/JavaPresentationUtil.java
+++ b/java/java-psi-impl/src/com/intellij/psi/presentation/java/JavaPresentationUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@
import com.intellij.psi.util.PsiFormatUtil;
import com.intellij.psi.util.PsiFormatUtilBase;
import com.intellij.psi.util.PsiTreeUtil;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
@@ -32,7 +33,8 @@
private JavaPresentationUtil() {
}
- public static ColoredItemPresentation getMethodPresentation(final PsiMethod psiMethod) {
+ @NotNull
+ public static ColoredItemPresentation getMethodPresentation(@NotNull final PsiMethod psiMethod) {
return new ColoredItemPresentation() {
@Override
public String getPresentableText() {
@@ -63,7 +65,8 @@
};
}
- public static ItemPresentation getFieldPresentation(final PsiField psiField) {
+ @NotNull
+ public static ItemPresentation getFieldPresentation(@NotNull final PsiField psiField) {
return new ColoredItemPresentation() {
@Override
public String getPresentableText() {
@@ -91,7 +94,7 @@
}
@Nullable
- private static String getJavaSymbolContainerText(final PsiElement element) {
+ private static String getJavaSymbolContainerText(@NotNull final PsiElement element) {
final String result;
PsiElement container = PsiTreeUtil.getParentOfType(element, PsiMember.class, PsiFile.class);
diff --git a/java/java-psi-impl/src/com/intellij/psi/presentation/java/MethodPresentationProvider.java b/java/java-psi-impl/src/com/intellij/psi/presentation/java/MethodPresentationProvider.java
index 91ee8d6..3f57380 100644
--- a/java/java-psi-impl/src/com/intellij/psi/presentation/java/MethodPresentationProvider.java
+++ b/java/java-psi-impl/src/com/intellij/psi/presentation/java/MethodPresentationProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 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,13 +18,14 @@
import com.intellij.navigation.ItemPresentation;
import com.intellij.navigation.ItemPresentationProvider;
import com.intellij.psi.PsiMethod;
+import org.jetbrains.annotations.NotNull;
/**
* @author yole
*/
public class MethodPresentationProvider implements ItemPresentationProvider<PsiMethod> {
@Override
- public ItemPresentation getPresentation(PsiMethod item) {
+ public ItemPresentation getPresentation(@NotNull PsiMethod item) {
return JavaPresentationUtil.getMethodPresentation(item);
}
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/presentation/java/PackagePresentationProvider.java b/java/java-psi-impl/src/com/intellij/psi/presentation/java/PackagePresentationProvider.java
index 62e55c8..5599325 100644
--- a/java/java-psi-impl/src/com/intellij/psi/presentation/java/PackagePresentationProvider.java
+++ b/java/java-psi-impl/src/com/intellij/psi/presentation/java/PackagePresentationProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,12 +21,13 @@
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.psi.PsiPackage;
import com.intellij.util.PlatformIcons;
+import org.jetbrains.annotations.NotNull;
import javax.swing.*;
public class PackagePresentationProvider implements ItemPresentationProvider<PsiPackage> {
@Override
- public ItemPresentation getPresentation(final PsiPackage aPackage) {
+ public ItemPresentation getPresentation(@NotNull final PsiPackage aPackage) {
return new ColoredItemPresentation() {
@Override
public TextAttributesKey getTextAttributesKey() {
diff --git a/java/java-psi-impl/src/com/intellij/psi/presentation/java/VariablePresentationProvider.java b/java/java-psi-impl/src/com/intellij/psi/presentation/java/VariablePresentationProvider.java
index c94ee9f..ddd3161 100644
--- a/java/java-psi-impl/src/com/intellij/psi/presentation/java/VariablePresentationProvider.java
+++ b/java/java-psi-impl/src/com/intellij/psi/presentation/java/VariablePresentationProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@
import com.intellij.navigation.ItemPresentationProvider;
import com.intellij.navigation.NavigationItem;
import com.intellij.psi.PsiVariable;
+import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -27,7 +28,7 @@
*/
public class VariablePresentationProvider<T extends PsiVariable & NavigationItem> implements ItemPresentationProvider<T> {
@Override
- public ItemPresentation getPresentation(final T variable) {
+ public ItemPresentation getPresentation(@NotNull final T variable) {
return new ItemPresentation() {
@Override
public String getPresentableText() {
diff --git a/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java b/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java
index 70dfd67..406abbf 100644
--- a/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java
+++ b/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java
@@ -29,7 +29,6 @@
import com.intellij.psi.scope.PsiConflictResolver;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.util.*;
-import com.intellij.util.ArrayUtilRt;
import com.intellij.util.containers.HashSet;
import gnu.trove.THashMap;
import gnu.trove.THashSet;
@@ -37,7 +36,10 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import java.util.*;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
/**
* Created by IntelliJ IDEA.
@@ -121,8 +123,7 @@
if (methodParameters.length == 0) continue;
final PsiParameter param = i < methodParameters.length ? methodParameters[i] : methodParameters[methodParameters.length - 1];
final PsiType paramType = param.getType();
- if (!LambdaUtil.isAcceptable(lambdaExpression, ((MethodCandidateInfo)conflict).getSubstitutor(false).substitute(paramType),
- lambdaExpression.hasFormalParameterTypes())) {
+ if (!lambdaExpression.isAcceptable(((MethodCandidateInfo)conflict).getSubstitutor(false).substitute(paramType), lambdaExpression.hasFormalParameterTypes())) {
iterator.remove();
}
}
@@ -368,7 +369,7 @@
boolean toFilter = false;
for (CandidateInfo conflict : conflicts) {
ProgressManager.checkCanceled();
- @MethodCandidateInfo.ApplicabilityLevelConstant final int level = preferVarargs((MethodCandidateInfo)conflict);
+ @MethodCandidateInfo.ApplicabilityLevelConstant final int level = ((MethodCandidateInfo)conflict).getPertinentApplicabilityLevel();
if (maxApplicabilityLevel > 0 && maxApplicabilityLevel != level) {
toFilter = true;
}
@@ -381,7 +382,7 @@
for (Iterator<CandidateInfo> iterator = conflicts.iterator(); iterator.hasNext();) {
ProgressManager.checkCanceled();
CandidateInfo info = iterator.next();
- final int level = preferVarargs((MethodCandidateInfo)info);
+ final int level = ((MethodCandidateInfo)info).getPertinentApplicabilityLevel();
if (level < maxApplicabilityLevel) {
iterator.remove();
}
@@ -391,17 +392,6 @@
return maxApplicabilityLevel;
}
- private static int preferVarargs(MethodCandidateInfo info) {
- final int level = info.getPertinentApplicabilityLevel();
- if (level == MethodCandidateInfo.ApplicabilityLevel.FIXED_ARITY) {
- final PsiMethod psiMethod = info.getElement();
- if (psiMethod != null && psiMethod.isVarArgs() && JavaVersionService.getInstance().isAtLeast(psiMethod, JavaSdkVersion.JDK_1_7)) {
- return level + 1;
- }
- }
- return level;
- }
-
private static int getCheckAccessLevel(MethodCandidateInfo method){
boolean visible = method.isAccessible();
return visible ? 1 : 0;
@@ -416,11 +406,15 @@
private PsiType[] getActualParameterTypes() {
if (myActualParameterTypes == null) {
LOG.assertTrue(myArgumentsList instanceof PsiExpressionList, myArgumentsList);
- myActualParameterTypes = ((PsiExpressionList)myArgumentsList).getExpressionTypes();
+ myActualParameterTypes = getArgumentTypes();
}
return myActualParameterTypes;
}
+ protected PsiType[] getArgumentTypes() {
+ return ((PsiExpressionList)myArgumentsList).getExpressionTypes();
+ }
+
private enum Specifics {
FIRST,
SECOND,
@@ -541,7 +535,8 @@
return Specifics.FIRST;
}
}
- if (languageLevel.isAtLeast(LanguageLevel.JDK_1_8) && myArgumentsList instanceof PsiExpressionList) {
+
+ if (languageLevel.isAtLeast(LanguageLevel.JDK_1_8) && myArgumentsList instanceof PsiExpressionList && (typeParameters1.length == 0 || typeParameters2.length == 0)) {
boolean toCompareFunctional = false;
for (int i = 0; i < myActualParameterTypes.length; i++) {
if (types1.length > 0 && LambdaUtil.isFunctionalType(types1[Math.min(i, types1.length - 1)]) &&
@@ -641,7 +636,7 @@
PsiMethod method2,
PsiSubstitutor siteSubstitutor1) {
if (languageLevel.isAtLeast(LanguageLevel.JDK_1_8) && method2 != null && method1.getTypeParameters().length > 0 && myArgumentsList instanceof PsiExpressionList) {
- return InferenceSession.isMoreSpecific(method2, method1, siteSubstitutor1, ((PsiExpressionList)myArgumentsList).getExpressions(), null, varargsPosition);
+ return InferenceSession.isMoreSpecific(method2, method1, siteSubstitutor1, ((PsiExpressionList)myArgumentsList).getExpressions(), myArgumentsList, varargsPosition);
}
final int applicabilityLevel = PsiUtil.getApplicabilityLevel(method1, methodSubstitutor1, types2AtSite, languageLevel, false, varargsPosition);
return applicabilityLevel > MethodCandidateInfo.ApplicabilityLevel.NOT_APPLICABLE;
@@ -651,60 +646,10 @@
final PsiType[] types = PsiType.createArray(types1.length);
for (int i = 0; i < types1.length; i++) {
types[i] = siteSubstitutor1.substitute(types1[i]);
- if (types[i] instanceof PsiClassType) {
- final PsiClass aClass = ((PsiClassType)types[i]).resolve();
- if (aClass instanceof PsiTypeParameter) {
- final List<PsiType> resultBounds = new ArrayList<PsiType>();
- for (PsiType bound : aClass.getExtendsListTypes()) {
- bound = siteSubstitutor1.substitute(bound);
- if (!dependsOnOtherTypeParams(bound, typeParameters1)) {
- resultBounds.add(bound);
- } else {
- resultBounds.clear();
- break;
- }
- }
- if (!resultBounds.isEmpty()) {
- types[i] = PsiIntersectionType.createIntersection(resultBounds);
- }
- }
- }
}
return types;
}
- private static boolean dependsOnOtherTypeParams(PsiType type, final PsiTypeParameter[] params) {
- return type.accept(new PsiTypeVisitor<Boolean>(){
- @Nullable
- @Override
- public Boolean visitClassType(PsiClassType classType) {
- for (PsiType psiType : classType.getParameters()) {
- if (psiType.accept(this)) return true;
- }
- return ArrayUtilRt.find(params, classType.resolve()) > -1;
- }
-
- @Nullable
- @Override
- public Boolean visitArrayType(PsiArrayType arrayType) {
- return arrayType.getComponentType().accept(this);
- }
-
- @Nullable
- @Override
- public Boolean visitWildcardType(PsiWildcardType wildcardType) {
- final PsiType bound = wildcardType.getBound();
- return bound != null && bound.accept(this);
- }
-
- @Nullable
- @Override
- public Boolean visitType(PsiType type) {
- return false;
- }
- });
- }
-
private static PsiSubstitutor calculateMethodSubstitutor(final PsiTypeParameter[] typeParameters,
final PsiMethod method,
final PsiSubstitutor siteSubstitutor,
@@ -722,6 +667,14 @@
type = TypeConversionUtil.erasure(type, substitutor);
}
substitutor = substitutor.put(typeParameter, type);
+ } else {
+ final PsiType type = substitutor.substitute(typeParameter);
+ if (type instanceof PsiClassType) {
+ final PsiClass aClass = ((PsiClassType)type).resolve();
+ if (aClass instanceof PsiTypeParameter) {
+ substitutor = substitutor.put(typeParameter, JavaPsiFacade.getElementFactory(aClass.getProject()).createType(aClass, siteSubstitutor));
+ }
+ }
}
}
return substitutor;
diff --git a/java/java-structure-view/java-structure-view.iml b/java/java-structure-view/java-structure-view.iml
new file mode 100644
index 0000000..036dead
--- /dev/null
+++ b/java/java-structure-view/java-structure-view.iml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
+ <exclude-output />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="module" module-name="structure-view-impl" />
+ <orderEntry type="module" module-name="java-psi-impl" />
+ </component>
+</module>
+
diff --git a/java/java-impl/src/com/intellij/ide/highlighter/JavaClsStructureViewBuilderProvider.java b/java/java-structure-view/src/com/intellij/ide/highlighter/JavaClsStructureViewBuilderProvider.java
similarity index 98%
rename from java/java-impl/src/com/intellij/ide/highlighter/JavaClsStructureViewBuilderProvider.java
rename to java/java-structure-view/src/com/intellij/ide/highlighter/JavaClsStructureViewBuilderProvider.java
index 7361877..0d7e2f0 100644
--- a/java/java-impl/src/com/intellij/ide/highlighter/JavaClsStructureViewBuilderProvider.java
+++ b/java/java-structure-view/src/com/intellij/ide/highlighter/JavaClsStructureViewBuilderProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/AddAllMembersProcessor.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/AddAllMembersProcessor.java
similarity index 96%
rename from java/java-impl/src/com/intellij/ide/structureView/impl/AddAllMembersProcessor.java
rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/AddAllMembersProcessor.java
index 952c929..f692c8f 100644
--- a/java/java-impl/src/com/intellij/ide/structureView/impl/AddAllMembersProcessor.java
+++ b/java/java-structure-view/src/com/intellij/ide/structureView/impl/AddAllMembersProcessor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@
private final PsiClass myPsiClass;
private final Map<MethodSignature,PsiMethod> myMethodsBySignature = new HashMap<MethodSignature, PsiMethod>();
- public AddAllMembersProcessor(Collection<PsiElement> allMembers, PsiClass psiClass) {
+ public AddAllMembersProcessor(@NotNull Collection<PsiElement> allMembers, @NotNull PsiClass psiClass) {
for (PsiElement psiElement : allMembers) {
if (psiElement instanceof PsiMethod) mapMethodBySignature((PsiMethod)psiElement);
}
@@ -42,6 +42,7 @@
myPsiClass = psiClass;
}
+ @Override
public boolean execute(@NotNull PsiElement element, ResolveState state) {
PsiMember member = (PsiMember)element;
if (!isInteresting(element)) return true;
diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/AccessLevelProvider.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/AccessLevelProvider.java
similarity index 94%
rename from java/java-impl/src/com/intellij/ide/structureView/impl/java/AccessLevelProvider.java
rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/java/AccessLevelProvider.java
index 1f153aa..97b5d3e 100644
--- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/AccessLevelProvider.java
+++ b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/AccessLevelProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/AnonymousClassesSorter.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/AnonymousClassesSorter.java
similarity index 93%
rename from java/java-impl/src/com/intellij/ide/structureView/impl/java/AnonymousClassesSorter.java
rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/java/AnonymousClassesSorter.java
index cefb5d9..b18f9af 100644
--- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/AnonymousClassesSorter.java
+++ b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/AnonymousClassesSorter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@
public class AnonymousClassesSorter implements Sorter {
public static Sorter INSTANCE = new AnonymousClassesSorter();
- private Comparator myComparator = new Comparator() {
+ private final Comparator myComparator = new Comparator() {
@Override
public int compare(Object o1, Object o2) {
String s1 = SorterUtil.getStringPresentation(o1);
@@ -43,6 +43,7 @@
}
};
+ @NotNull
@Override
public Comparator getComparator() {
return myComparator;
diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/ClassInitializerTreeElement.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/ClassInitializerTreeElement.java
similarity index 95%
rename from java/java-impl/src/com/intellij/ide/structureView/impl/java/ClassInitializerTreeElement.java
rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/java/ClassInitializerTreeElement.java
index ccf7c6a..4005780 100644
--- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/ClassInitializerTreeElement.java
+++ b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/ClassInitializerTreeElement.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@
super(initializer);
}
+ @Override
public String getPresentableText() {
PsiClassInitializer initializer = getElement();
assert initializer != null;
@@ -38,6 +39,7 @@
return CodeInsightBundle.message("static.class.initializer", isStatic);
}
+ @Override
public String getLocationString() {
PsiClassInitializer initializer = getElement();
assert initializer != null;
@@ -51,16 +53,19 @@
return null;
}
+ @Override
@NotNull
public Collection<StructureViewTreeElement> getChildrenBase() {
return Collections.emptyList();
}
+ @Override
public int getAccessLevel() {
return PsiUtil.ACCESS_LEVEL_PRIVATE;
}
+ @Override
public int getSubLevel() {
return 0;
}
-}
\ No newline at end of file
+}
diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/FieldsFilter.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/FieldsFilter.java
similarity index 94%
rename from java/java-impl/src/com/intellij/ide/structureView/impl/java/FieldsFilter.java
rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/java/FieldsFilter.java
index da430a0..acea371 100644
--- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/FieldsFilter.java
+++ b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/FieldsFilter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -27,20 +27,24 @@
public class FieldsFilter implements Filter{
@NonNls public static final String ID = "SHOW_FIELDS";
+ @Override
public boolean isVisible(TreeElement treeNode) {
return !(treeNode instanceof PsiFieldTreeElement);
}
+ @Override
@NotNull
public ActionPresentation getPresentation() {
return new ActionPresentationData(IdeBundle.message("action.structureview.show.fields"), null, PlatformIcons.FIELD_ICON);
}
+ @Override
@NotNull
public String getName() {
return ID;
}
+ @Override
public boolean isReverted() {
return true;
}
diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaAnonymousClassTreeElement.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/JavaAnonymousClassTreeElement.java
similarity index 95%
rename from java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaAnonymousClassTreeElement.java
rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/java/JavaAnonymousClassTreeElement.java
index 6c3cd1a..2905a6f 100644
--- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaAnonymousClassTreeElement.java
+++ b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/JavaAnonymousClassTreeElement.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -27,7 +27,7 @@
* @author Konstantin Bulenkov
*/
public class JavaAnonymousClassTreeElement extends JavaClassTreeElement {
- public final static JavaAnonymousClassTreeElement[] EMPTY_ARRAY = {};
+ public static final JavaAnonymousClassTreeElement[] EMPTY_ARRAY = {};
private String myName;
private String myBaseName;
diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaAnonymousClassesNodeProvider.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/JavaAnonymousClassesNodeProvider.java
similarity index 80%
rename from java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaAnonymousClassesNodeProvider.java
rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/java/JavaAnonymousClassesNodeProvider.java
index 65bc73d..fbfcaee 100644
--- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaAnonymousClassesNodeProvider.java
+++ b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/JavaAnonymousClassesNodeProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -45,29 +45,34 @@
public static final String ID = "SHOW_ANONYMOUS";
public static final String JAVA_ANONYMOUS_PROPERTY_NAME = "java.anonymous.provider";
+ @NotNull
@Override
- public Collection<JavaAnonymousClassTreeElement> provideNodes(TreeElement node) {
+ public Collection<JavaAnonymousClassTreeElement> provideNodes(@NotNull TreeElement node) {
if (node instanceof PsiMethodTreeElement || node instanceof PsiFieldTreeElement || node instanceof ClassInitializerTreeElement) {
final PsiElement el = ((PsiTreeElementBase)node).getElement();
- for (AnonymousElementProvider provider : Extensions.getExtensions(AnonymousElementProvider.EP_NAME)) {
- final PsiElement[] elements = provider.getAnonymousElements(el);
- if (elements != null && elements.length > 0) {
- List<JavaAnonymousClassTreeElement> result = new ArrayList<JavaAnonymousClassTreeElement>(elements.length);
- for (PsiElement element : elements) {
- result.add(new JavaAnonymousClassTreeElement((PsiAnonymousClass)element, new HashSet<PsiClass>()));
+ if (el != null) {
+ for (AnonymousElementProvider provider : Extensions.getExtensions(AnonymousElementProvider.EP_NAME)) {
+ final PsiElement[] elements = provider.getAnonymousElements(el);
+ if (elements.length > 0) {
+ List<JavaAnonymousClassTreeElement> result = new ArrayList<JavaAnonymousClassTreeElement>(elements.length);
+ for (PsiElement element : elements) {
+ result.add(new JavaAnonymousClassTreeElement((PsiAnonymousClass)element, new HashSet<PsiClass>()));
+ }
+ return result;
}
- return result;
}
}
}
return Collections.emptyList();
}
+ @NotNull
@Override
public String getCheckBoxText() {
return "Show Anonymous Classes";
}
+ @NotNull
@Override
public Shortcut[] getShortcut() {
return new Shortcut[]{KeyboardShortcut.fromString(SystemInfo.isMac ? "meta I" : "control I")};
diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaClassTreeElement.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/JavaClassTreeElement.java
similarity index 97%
rename from java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaClassTreeElement.java
rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/java/JavaClassTreeElement.java
index cbae413..354ccf3 100644
--- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaClassTreeElement.java
+++ b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/JavaClassTreeElement.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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,6 +35,7 @@
myParents.add(cls);
}
+ @Override
@NotNull
public Collection<StructureViewTreeElement> getChildrenBase() {
return getClassChildren();
@@ -89,10 +90,12 @@
return myParents;
}
+ @Override
public String getPresentableText() {
return getElement().getName();
}
+ @Override
public boolean isPublic() {
return getElement().getParent() instanceof PsiFile || super.isPublic();
}
diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaClassTreeElementBase.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/JavaClassTreeElementBase.java
similarity index 98%
rename from java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaClassTreeElementBase.java
rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/java/JavaClassTreeElementBase.java
index 817e170..50cc8c4 100644
--- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaClassTreeElementBase.java
+++ b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/JavaClassTreeElementBase.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -46,6 +46,7 @@
return !(element instanceof PsiModifierListOwner) || ((PsiModifierListOwner)element).hasModifierProperty(PsiModifier.PUBLIC);
}
+ @Override
public int getAccessLevel() {
final PsiModifierList modifierList = ((PsiModifierListOwner)getElement()).getModifierList();
if (modifierList == null) {
@@ -54,6 +55,7 @@
return PsiUtil.getAccessLevel(modifierList);
}
+ @Override
public int getSubLevel() {
return 0;
}
diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaFileTreeElement.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/JavaFileTreeElement.java
similarity index 95%
rename from java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaFileTreeElement.java
rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/java/JavaFileTreeElement.java
index 56a993c..590f102 100644
--- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaFileTreeElement.java
+++ b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/JavaFileTreeElement.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,10 +31,12 @@
super(file);
}
+ @Override
public String getPresentableText() {
return getElement().getName();
}
+ @Override
@NotNull
public Collection<StructureViewTreeElement> getChildrenBase() {
PsiClass[] classes = getElement().getClasses();
@@ -45,4 +47,4 @@
return result;
}
-}
\ No newline at end of file
+}
diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaFileTreeModel.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/JavaFileTreeModel.java
similarity index 83%
rename from java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaFileTreeModel.java
rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/java/JavaFileTreeModel.java
index 962bf5f..a18a4cc 100644
--- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaFileTreeModel.java
+++ b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/JavaFileTreeModel.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,14 +15,10 @@
*/
package com.intellij.ide.structureView.impl.java;
-import com.intellij.ide.actions.ViewStructureAction;
import com.intellij.ide.structureView.StructureViewModel;
import com.intellij.ide.structureView.StructureViewTreeElement;
import com.intellij.ide.structureView.TextEditorBasedStructureViewModel;
-import com.intellij.ide.util.treeView.smartTree.Filter;
-import com.intellij.ide.util.treeView.smartTree.Grouper;
-import com.intellij.ide.util.treeView.smartTree.NodeProvider;
-import com.intellij.ide.util.treeView.smartTree.Sorter;
+import com.intellij.ide.util.treeView.smartTree.*;
import com.intellij.openapi.editor.Editor;
import com.intellij.psi.*;
import com.intellij.ui.PlaceHolder;
@@ -35,19 +31,16 @@
public class JavaFileTreeModel extends TextEditorBasedStructureViewModel implements StructureViewModel.ElementInfoProvider, PlaceHolder<String> {
private static final Collection<NodeProvider> NODE_PROVIDERS = Arrays.<NodeProvider>asList(new JavaInheritedMembersNodeProvider(),
new JavaAnonymousClassesNodeProvider());
- private final PsiClassOwner myFile;
private String myPlace;
public JavaFileTreeModel(@NotNull PsiClassOwner file, @Nullable Editor editor) {
super(editor, file);
- myFile = file;
}
@Override
@NotNull
public Filter[] getFilters() {
- return new Filter[]{new FieldsFilter(),
- new PublicElementsFilter()};
+ return new Filter[]{new FieldsFilter(), new PublicElementsFilter()};
}
@NotNull
@@ -65,7 +58,7 @@
@Override
@NotNull
public StructureViewTreeElement getRoot() {
- return new JavaFileTreeElement(myFile);
+ return new JavaFileTreeElement(getPsiFile());
}
@Override
@@ -77,15 +70,15 @@
@NotNull
public Sorter[] getSorters() {
return new Sorter[] {
- ViewStructureAction.isInStructureViewPopup(this) ? KindSorter.POPUP_INSTANCE : KindSorter.INSTANCE,
+ TreeStructureUtil.isInStructureViewPopup(this) ? KindSorter.POPUP_INSTANCE : KindSorter.INSTANCE,
VisibilitySorter.INSTANCE,
AnonymousClassesSorter.INSTANCE,
Sorter.ALPHA_SORTER};
}
@Override
- protected PsiFile getPsiFile() {
- return myFile;
+ protected PsiClassOwner getPsiFile() {
+ return (PsiClassOwner)super.getPsiFile();
}
@Override
@@ -130,7 +123,7 @@
}
@Override
- public void setPlace(String place) {
+ public void setPlace(@NotNull String place) {
myPlace = place;
}
diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaInheritedMembersNodeProvider.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/JavaInheritedMembersNodeProvider.java
similarity index 93%
rename from java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaInheritedMembersNodeProvider.java
rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/java/JavaInheritedMembersNodeProvider.java
index e8a4cbb..d17f9bb 100644
--- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaInheritedMembersNodeProvider.java
+++ b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/JavaInheritedMembersNodeProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 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.ide.util.treeView.smartTree.TreeElement;
import com.intellij.psi.*;
import com.intellij.util.containers.ContainerUtil;
+import org.jetbrains.annotations.NotNull;
import java.util.*;
@@ -27,8 +28,9 @@
* @author Konstantin Bulenkov
*/
public class JavaInheritedMembersNodeProvider extends InheritedMembersNodeProvider {
+ @NotNull
@Override
- public Collection<TreeElement> provideNodes(TreeElement node) {
+ public Collection<TreeElement> provideNodes(@NotNull TreeElement node) {
if (node instanceof JavaClassTreeElement) {
final PsiClass aClass = ((JavaClassTreeElement)node).getValue();
Collection<PsiElement> inherited = new LinkedHashSet<PsiElement>();
diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/KindSorter.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/KindSorter.java
similarity index 86%
rename from java/java-impl/src/com/intellij/ide/structureView/impl/java/KindSorter.java
rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/java/KindSorter.java
index 18cc597..10d8c60 100644
--- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/KindSorter.java
+++ b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/KindSorter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,14 +24,18 @@
import java.util.Comparator;
public class KindSorter implements Sorter {
- public static final Sorter INSTANCE = new KindSorter();
- public static final Sorter POPUP_INSTANCE = new KindSorter(){{isPopup = true;}};
+ public static final Sorter INSTANCE = new KindSorter(false);
+ public static final Sorter POPUP_INSTANCE = new KindSorter(true);
+ public KindSorter(boolean isPopup) {
+ this.isPopup = isPopup;
+ }
@NonNls public static final String ID = "KIND";
- boolean isPopup = false;
+ private final boolean isPopup;
private final Comparator COMPARATOR = new Comparator() {
+ @Override
public int compare(final Object o1, final Object o2) {
return getWeight(o1) - getWeight(o2);
}
@@ -65,19 +69,24 @@
}
};
+ @Override
+ @NotNull
public Comparator getComparator() {
return COMPARATOR;
}
+ @Override
public boolean isVisible() {
return false;
}
+ @Override
@NotNull
public ActionPresentation getPresentation() {
throw new IllegalStateException();
}
+ @Override
@NotNull
public String getName() {
return ID;
diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/PropertiesGrouper.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/PropertiesGrouper.java
similarity index 92%
rename from java/java-impl/src/com/intellij/ide/structureView/impl/java/PropertiesGrouper.java
rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/java/PropertiesGrouper.java
index b948ac9..e86b733 100644
--- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/PropertiesGrouper.java
+++ b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/PropertiesGrouper.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -32,8 +32,9 @@
public class PropertiesGrouper implements Grouper{
@NonNls public static final String ID = "SHOW_PROPERTIES";
+ @Override
@NotNull
- public Collection<Group> group(final AbstractTreeNode parent, Collection<TreeElement> children) {
+ public Collection<Group> group(@NotNull final AbstractTreeNode parent, @NotNull Collection<TreeElement> children) {
if (parent.getValue() instanceof PropertyGroup) return Collections.emptyList();
Map<Group,Group> result = new THashMap<Group, Group>();
for (TreeElement o : children) {
@@ -60,11 +61,13 @@
return result.values();
}
+ @Override
@NotNull
public ActionPresentation getPresentation() {
return new ActionPresentationData(IdeBundle.message("action.structureview.show.properties"), null, PlatformIcons.PROPERTY_ICON);
}
+ @Override
@NotNull
public String getName() {
return ID;
diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/PropertyGroup.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/PropertyGroup.java
similarity index 97%
rename from java/java-impl/src/com/intellij/ide/structureView/impl/java/PropertyGroup.java
rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/java/PropertyGroup.java
index 90e0c9e..fca6716 100644
--- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/PropertyGroup.java
+++ b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/PropertyGroup.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -90,14 +90,19 @@
return null;
}
+ @Override
+ @NotNull
public Collection<TreeElement> getChildren() {
return myChildren;
}
+ @Override
+ @NotNull
public ItemPresentation getPresentation() {
return this;
}
+ @Override
public Icon getIcon(boolean open) {
if (isStatic()) {
if (getGetter() != null && getSetter() != null) {
@@ -128,10 +133,12 @@
return myIsStatic;
}
+ @Override
public String getLocationString() {
return null;
}
+ @Override
public String getPresentableText() {
return myPropertyName + ": " + myPropertyType.getPresentableText();
}
@@ -174,6 +181,7 @@
return PropertyUtil.suggestGetterName(myPropertyName, myPropertyType);
}
+ @Override
public int getAccessLevel() {
int result = PsiUtil.ACCESS_LEVEL_PRIVATE;
if (getGetter() != null) {
@@ -188,6 +196,7 @@
return result;
}
+ @Override
public int getSubLevel() {
return 0;
}
@@ -235,6 +244,7 @@
return icon;
}
+ @Override
public TextAttributesKey getTextAttributesKey() {
return isDeprecated() ? CodeInsightColors.DEPRECATED_ATTRIBUTES : null;
}
@@ -258,6 +268,7 @@
return this;
}
+ @Override
public int getWeight() {
return 60;
}
diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/PsiFieldTreeElement.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/PsiFieldTreeElement.java
similarity index 95%
rename from java/java-impl/src/com/intellij/ide/structureView/impl/java/PsiFieldTreeElement.java
rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/java/PsiFieldTreeElement.java
index 9317505..48b60e4 100644
--- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/PsiFieldTreeElement.java
+++ b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/PsiFieldTreeElement.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,11 +31,13 @@
super(isInherited,field);
}
+ @Override
@NotNull
public Collection<StructureViewTreeElement> getChildrenBase() {
return Collections.emptyList();
}
+ @Override
public String getPresentableText() {
return StringUtil.replace(PsiFormatUtil.formatVariable(
getElement(),
@@ -48,6 +50,8 @@
return getElement();
}
+ @Override
+ @NotNull
public String getAlphaSortKey() {
final PsiField field = getElement();
if (field != null) {
diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/PsiMethodTreeElement.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/PsiMethodTreeElement.java
similarity index 98%
rename from java/java-impl/src/com/intellij/ide/structureView/impl/java/PsiMethodTreeElement.java
rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/java/PsiMethodTreeElement.java
index 2f186db..c1afbee 100644
--- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/PsiMethodTreeElement.java
+++ b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/PsiMethodTreeElement.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -127,6 +127,7 @@
return getElement();
}
+ @NotNull
@Override
public String getAlphaSortKey() {
final PsiMethod method = getElement();
diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/PublicElementsFilter.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/PublicElementsFilter.java
similarity index 94%
rename from java/java-impl/src/com/intellij/ide/structureView/impl/java/PublicElementsFilter.java
rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/java/PublicElementsFilter.java
index 79ecfac..5fb718f 100644
--- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/PublicElementsFilter.java
+++ b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/PublicElementsFilter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -27,6 +27,7 @@
public class PublicElementsFilter implements Filter{
@NonNls public static final String ID = "SHOW_NON_PUBLIC";
+ @Override
public boolean isVisible(TreeElement treeNode) {
if (treeNode instanceof JavaClassTreeElementBase) {
return ((JavaClassTreeElementBase)treeNode).isPublic();
@@ -36,16 +37,19 @@
}
}
+ @Override
@NotNull
public ActionPresentation getPresentation() {
return new ActionPresentationData(IdeBundle.message("action.structureview.show.non.public"), null, PlatformIcons.PRIVATE_ICON);
}
+ @Override
@NotNull
public String getName() {
return ID;
}
+ @Override
public boolean isReverted() {
return true;
}
diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/SuperTypeGroup.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/SuperTypeGroup.java
similarity index 94%
rename from java/java-impl/src/com/intellij/ide/structureView/impl/java/SuperTypeGroup.java
rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/java/SuperTypeGroup.java
index ee713b8..049ecf2 100644
--- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/SuperTypeGroup.java
+++ b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/SuperTypeGroup.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
import com.intellij.psi.SmartPointerManager;
import com.intellij.psi.SmartPsiElementPointer;
import com.intellij.psi.util.PsiUtil;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
@@ -47,6 +48,8 @@
mySuperClassPointer = SmartPointerManager.getInstance(superClass.getProject()).createSmartPsiElementPointer(superClass);
}
+ @Override
+ @NotNull
public Collection<TreeElement> getChildren() {
return myChildren;
}
@@ -56,10 +59,13 @@
return (PsiClass)mySuperClassPointer.getElement();
}
+ @Override
+ @NotNull
public ItemPresentation getPresentation() {
return this;
}
+ @Override
public Icon getIcon(boolean open) {
switch (myOverrides) {
case IMPLEMENTS:
@@ -73,10 +79,12 @@
return null; // Can't be
}
+ @Override
public String getLocationString() {
return null;
}
+ @Override
public String getPresentableText() {
return toString();
}
@@ -108,12 +116,14 @@
return this;
}
+ @Override
public int getAccessLevel() {
final PsiClass superClass = getSuperClass();
PsiModifierList modifierList = superClass == null ? null : superClass.getModifierList();
return modifierList == null ? PsiUtil.ACCESS_LEVEL_PUBLIC : PsiUtil.getAccessLevel(modifierList);
}
+ @Override
public int getSubLevel() {
return 1;
}
diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/SuperTypesGrouper.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/SuperTypesGrouper.java
similarity index 95%
rename from java/java-impl/src/com/intellij/ide/structureView/impl/java/SuperTypesGrouper.java
rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/java/SuperTypesGrouper.java
index 0f5a758..1e95ac6 100644
--- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/SuperTypesGrouper.java
+++ b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/SuperTypesGrouper.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -37,8 +37,9 @@
public static final Key<WeakReference<PsiMethod>> SUPER_METHOD_KEY = Key.create("StructureTreeBuilder.SUPER_METHOD_KEY");
@NonNls public static final String ID = "SHOW_INTERFACES";
+ @Override
@NotNull
- public Collection<Group> group(final AbstractTreeNode parent, Collection<TreeElement> children) {
+ public Collection<Group> group(@NotNull final AbstractTreeNode parent, @NotNull Collection<TreeElement> children) {
if (isParentGrouped(parent)) return Collections.emptyList();
Map<Group, SuperTypeGroup> groups = new THashMap<Group, SuperTypeGroup>();
@@ -112,12 +113,14 @@
}
+ @Override
@NotNull
public ActionPresentation getPresentation() {
return new ActionPresentationData(IdeBundle.message("action.structureview.group.methods.by.defining.type"), null,
AllIcons.General.ImplementingMethod);
}
+ @Override
@NotNull
public String getName() {
return ID;
diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/VisibilityComparator.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/VisibilityComparator.java
similarity index 85%
rename from java/java-impl/src/com/intellij/ide/structureView/impl/java/VisibilityComparator.java
rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/java/VisibilityComparator.java
index 8320959..73eafed 100644
--- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/VisibilityComparator.java
+++ b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/VisibilityComparator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,8 +15,6 @@
*/
package com.intellij.ide.structureView.impl.java;
-import com.intellij.ide.util.treeView.AlphaComparator;
-import com.intellij.ide.util.treeView.SourceComparator;
import com.intellij.openapi.diagnostic.Logger;
import org.jetbrains.annotations.NotNull;
@@ -25,8 +23,6 @@
public class VisibilityComparator implements Comparator {
private static final Logger LOG = Logger.getInstance("#com.intellij.ide.structureView.impl.java.VisibilityComparator");
private static final int GROUP_ACCESS_SUBLEVEL = 1;
- public static Comparator THEN_SOURCE = new VisibilityComparator(SourceComparator.INSTANCE);
- public static Comparator THEN_ALPHA = new VisibilityComparator(AlphaComparator.INSTANCE);
public static Comparator IMSTANCE = new VisibilityComparator(null);
private final Comparator myNextComparator;
@@ -36,6 +32,7 @@
myNextComparator = comparator;
}
+ @Override
public int compare(@NotNull Object descriptor1, @NotNull Object descriptor2) {
int accessLevel1 = getAccessLevel(descriptor1);
int accessLevel2 = getAccessLevel(descriptor2);
diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/VisibilitySorter.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/VisibilitySorter.java
similarity index 91%
rename from java/java-impl/src/com/intellij/ide/structureView/impl/java/VisibilitySorter.java
rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/java/VisibilitySorter.java
index e5ce331..d509c77 100644
--- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/VisibilitySorter.java
+++ b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/VisibilitySorter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,33 +30,42 @@
public static final Sorter INSTANCE = new VisibilitySorter();
private static final ActionPresentation PRESENTATION = new ActionPresentation() {
+ @Override
+ @NotNull
public String getText() {
return IdeBundle.message("action.structureview.sort.by.visibility");
}
+ @Override
public String getDescription() {
return null;
}
+ @Override
public Icon getIcon() {
return AllIcons.ObjectBrowser.VisibilitySort;
}
};
@NonNls public static final String ID = "VISIBILITY_SORTER";
+ @Override
+ @NotNull
public Comparator getComparator() {
return VisibilityComparator.IMSTANCE;
}
+ @Override
public boolean isVisible() {
return true;
}
+ @Override
@NotNull
public ActionPresentation getPresentation() {
return PRESENTATION;
}
+ @Override
@NotNull
public String getName() {
return ID;
diff --git a/java/java-impl/src/com/intellij/lang/java/JavaStructureViewBuilderFactory.java b/java/java-structure-view/src/com/intellij/lang/java/JavaStructureViewBuilderFactory.java
similarity index 97%
rename from java/java-impl/src/com/intellij/lang/java/JavaStructureViewBuilderFactory.java
rename to java/java-structure-view/src/com/intellij/lang/java/JavaStructureViewBuilderFactory.java
index e8d4eba..857191f 100644
--- a/java/java-impl/src/com/intellij/lang/java/JavaStructureViewBuilderFactory.java
+++ b/java/java-structure-view/src/com/intellij/lang/java/JavaStructureViewBuilderFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/java/java-tests/testData/codeInsight/clsHighlighting/IDEA118733.java b/java/java-tests/testData/codeInsight/clsHighlighting/IDEA118733.java
index 9b2a124..e8237d8 100644
--- a/java/java-tests/testData/codeInsight/clsHighlighting/IDEA118733.java
+++ b/java/java-tests/testData/codeInsight/clsHighlighting/IDEA118733.java
@@ -1,4 +1,4 @@
-public class MyChild {
+public class IDEA118733 {
public void evaluate(Child child) {
Parent<String>.InnerBase i = child.foo();
}
diff --git a/java/java-tests/testData/codeInsight/clsHighlighting/IDEA97887.java b/java/java-tests/testData/codeInsight/clsHighlighting/IDEA97887.java
index 36c97bd..a5bde0b 100644
--- a/java/java-tests/testData/codeInsight/clsHighlighting/IDEA97887.java
+++ b/java/java-tests/testData/codeInsight/clsHighlighting/IDEA97887.java
@@ -1,4 +1,4 @@
-public class MyChild extends Child<String> {
+public class IDEA97887 extends Child<String> {
@Override
public void evaluate(InnerImpl impl) {
String s = impl.t;
diff --git a/java/java-tests/testData/codeInsight/completion/normal/AddExplicitValueInAnnotation.java b/java/java-tests/testData/codeInsight/completion/normal/AddExplicitValueInAnnotation.java
new file mode 100644
index 0000000..88262b4
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/normal/AddExplicitValueInAnnotation.java
@@ -0,0 +1,8 @@
+@interface Anno {
+ String value();
+ String bar();
+ String goo();
+}
+
+@Anno("a", <caret>)
+class Foo {}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/completion/normal/AddExplicitValueInAnnotation_after.java b/java/java-tests/testData/codeInsight/completion/normal/AddExplicitValueInAnnotation_after.java
new file mode 100644
index 0000000..fbfa550
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/normal/AddExplicitValueInAnnotation_after.java
@@ -0,0 +1,8 @@
+@interface Anno {
+ String value();
+ String bar();
+ String goo();
+}
+
+@Anno(value = "a", bar = <caret>)
+class Foo {}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/completion/normal/MulticaretMethodWithParen.java b/java/java-tests/testData/codeInsight/completion/normal/MulticaretMethodWithParen.java
new file mode 100644
index 0000000..a4bddd9
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/normal/MulticaretMethodWithParen.java
@@ -0,0 +1,4 @@
+class Foo {{
+ System.out.ap<caret>
+ System.out.ap<caret>
+}}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/completion/normal/MulticaretMethodWithParen_after.java b/java/java-tests/testData/codeInsight/completion/normal/MulticaretMethodWithParen_after.java
new file mode 100644
index 0000000..46acfad
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/normal/MulticaretMethodWithParen_after.java
@@ -0,0 +1,4 @@
+class Foo {{
+ System.out.append(<caret>)
+ System.out.append(<caret>)
+}}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/completion/normal/MulticaretSingleItemInsertion.java b/java/java-tests/testData/codeInsight/completion/normal/MulticaretSingleItemInsertion.java
new file mode 100644
index 0000000..6c7981f
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/normal/MulticaretSingleItemInsertion.java
@@ -0,0 +1,4 @@
+class Foo {{
+ ret<caret>;
+ ret<caret>;
+}}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/completion/normal/MulticaretSingleItemInsertion_after.java b/java/java-tests/testData/codeInsight/completion/normal/MulticaretSingleItemInsertion_after.java
new file mode 100644
index 0000000..bed450b
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/normal/MulticaretSingleItemInsertion_after.java
@@ -0,0 +1,4 @@
+class Foo {{
+ return<caret>;
+ return<caret>;
+}}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AbstractMethods.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AbstractMethods.java
index 986e6f3..9d1d785 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AbstractMethods.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AbstractMethods.java
@@ -1,5 +1,5 @@
// abstract methods
-public class a {
+class a {
<error descr="Missing method body, or declare abstract">void f();</error>
}
@@ -57,7 +57,7 @@
//------- if only Bottom were in other package, it should have been abstract --------------------------
-public abstract class AbstractTest {
+abstract class AbstractTest {
abstract String getName();
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AccessInner.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AccessInner.java
index 2ab5a66..9bf67fb 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AccessInner.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AccessInner.java
@@ -53,3 +53,6 @@
}
}
}
+class Ax {
+ public interface B {}
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AnonInAnon.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AnonInAnon.java
index 298668e..bd8f829 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AnonInAnon.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AnonInAnon.java
@@ -1,4 +1,4 @@
-public class QQQ {
+class QQQ {
{
new Outer(){
void foo(){
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/CtrCallIsFirst.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/CtrCallIsFirst.java
index 53059fb..49e2bec 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/CtrCallIsFirst.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/CtrCallIsFirst.java
@@ -1,5 +1,5 @@
// call to super must be first
-public class a {
+class a {
a() {}
a(int i) {}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/DefaultPackageClassInStaticImport.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/DefaultPackageClassInStaticImport.java
index afadb37..052b313 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/DefaultPackageClassInStaticImport.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/DefaultPackageClassInStaticImport.java
@@ -1,7 +1,7 @@
import static <error descr="Cannot resolve symbol 'MyConstants'">MyConstants</error>.*;
import <error descr="Cannot resolve symbol 'MyConstants'">MyConstants</error>;
-public class MyClient
+class MyClient
{
private int field = MyConstants.CONSTANT;
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/EnclosingInstance.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/EnclosingInstance.java
index aa64305..c2bc1dc 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/EnclosingInstance.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/EnclosingInstance.java
@@ -24,7 +24,7 @@
class inner {}
}
-public class C1_57 extends inner_holder {
+class C1_57 extends inner_holder {
// inner instance available through inheritance
protected class c extends inner {
private class iii extends inner {}
@@ -88,7 +88,7 @@
}
-public class A42 {
+class A42 {
class B {}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/ExceptionNeverThrown.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/ExceptionNeverThrown.java
index 5158a74..ae86e0d 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/ExceptionNeverThrown.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/ExceptionNeverThrown.java
@@ -61,7 +61,7 @@
}
////////////////////////////////
-public class FooThrow
+class FooThrow
{
final Foo foo = new Foo(); // Can throw FooException
FooThrow() throws Foo {
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/FinalFieldInit.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/FinalFieldInit.java
index 8f09a70..a7450bd 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/FinalFieldInit.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/FinalFieldInit.java
@@ -3,7 +3,7 @@
import java.net.*;
import java.awt.event.*;
-public class a {
+class a {
/**
* javadoc should not be highlighted
*/
@@ -177,7 +177,7 @@
int n2 = k==0 ? (k2=9) : (k2=0);
}
-public class cX {
+class cX {
final int i;
cX() {
this(1);
@@ -208,7 +208,7 @@
}
}
-public class X {
+class X {
final int i;
X() {
try {
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IDEADEV25784.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IDEADEV25784.java
index 99b6bc5..6dddd05 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IDEADEV25784.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IDEADEV25784.java
@@ -1,5 +1,5 @@
-public class X extends Y {}
-public class Y {
+class X extends Y {}
+class Y {
private static int x = 0;
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IgnoreSuperMethodsInMultipleOverridingCheck.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IgnoreSuperMethodsInMultipleOverridingCheck.java
index 943e373..dcc1df7 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IgnoreSuperMethodsInMultipleOverridingCheck.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IgnoreSuperMethodsInMultipleOverridingCheck.java
@@ -10,7 +10,7 @@
}
}
-public class CompileErrorTestExtended extends CompileErrorTest {
+class CompileErrorTestExtended extends CompileErrorTest {
public void foo() throws Exception {
try {
super.foo();
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/InnerClassesShadowing.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/InnerClassesShadowing.java
index 647df2b..8124907 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/InnerClassesShadowing.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/InnerClassesShadowing.java
@@ -1,6 +1,6 @@
import java.io.*;
-public class Main {
+class Main {
static interface A
{
interface B { }
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/MultipleSingleTypeImports.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/MultipleSingleTypeImports.java
index 38147e9..b28021b 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/MultipleSingleTypeImports.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/MultipleSingleTypeImports.java
@@ -4,6 +4,6 @@
<warning descr="Unused import statement">import java.io.IOException;</warning>
-public class c {
+class c {
public IOException m;
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/SingleTypeImportConflicts.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/SingleTypeImportConflicts.java
index 7a7c9df..21013a5 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/SingleTypeImportConflicts.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/SingleTypeImportConflicts.java
@@ -8,4 +8,4 @@
import java.io.IOException;
-public class c {}
+class c {}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/StaticOverride.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/StaticOverride.java
index 2229311..be1914e 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/StaticOverride.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/StaticOverride.java
@@ -2,7 +2,7 @@
import java.io.*;
import java.net.*;
-public class a extends a1 {
+class a extends a1 {
<error descr="Static method 'f()' in 'a' cannot override instance method 'f()' in 'a1'">public static void f()</error> { }
<error descr="Instance method 'f1()' in 'a' cannot override static method 'f1()' in 'a1'">public void f1()</error> { }
}
@@ -75,13 +75,13 @@
// Sun-style inheritance
-public class Sunc {
+class Sunc {
protected void f() {}
}
-public class Suncc extends Sunc {
+class Suncc extends Sunc {
public void f() {}
}
-public interface Suni {
+interface Suni {
public void f();
}
class Sunccc extends Suncc implements Suni {
@@ -103,7 +103,7 @@
class Foo {
protected static void foo(String s) {}
}
-public class Bar extends Foo{
+class Bar extends Foo{
<error descr="'foo(String)' in 'Bar' clashes with 'foo(String)' in 'Foo'; attempting to assign weaker access privileges ('private'); was 'protected'">private</error> static void foo(String s) {}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnhandledExceptionsInSuperclass.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnhandledExceptionsInSuperclass.java
index 721be46..fb12c28 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnhandledExceptionsInSuperclass.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnhandledExceptionsInSuperclass.java
@@ -1,7 +1,7 @@
// unhandled exceptions from superclases/etc
import java.io.*;
import java.net.*;
-public class a {
+class a {
a(int i) {}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/Unused.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/Unused.java
index bcbcd27..6fb038c 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/Unused.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/Unused.java
@@ -1,4 +1,4 @@
-public class a extends Exception {
+class a extends Exception {
private <warning descr="Private constructor 'a(java.lang.String)' is never used">a</warning>(String s) {
super(s);
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnusedNonPrivateMembers.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnusedNonPrivateMembers.java
index 9f3a7b4..6481d94 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnusedNonPrivateMembers.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnusedNonPrivateMembers.java
@@ -1,4 +1,4 @@
-public class <warning descr="Class 'XXX' is never used">XXX</warning> {
+class <warning descr="Class 'XXX' is never used">XXX</warning> {
void <warning descr="Method 'fffff()' is never used">fffff</warning>(){}
public void <warning descr="Method 'asdfaffffff()' is never used">asdfaffffff</warning>(){}
protected void <warning descr="Method 'dasklfjhsad()' is never used">dasklfjhsad</warning>(){}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnusedNonPrivateMembers2.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnusedNonPrivateMembers2.java
index b7ae475..51fd8ee 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnusedNonPrivateMembers2.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnusedNonPrivateMembers2.java
@@ -1,4 +1,4 @@
-public class WithMain {
+class WithMain {
public static void main(String[] args){
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnusedNonPrivateMembersReferencedFromText.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnusedNonPrivateMembersReferencedFromText.java
index 15c0b2a..dc6c96e 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnusedNonPrivateMembersReferencedFromText.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnusedNonPrivateMembersReferencedFromText.java
@@ -1,3 +1,3 @@
-public class <warning descr="Class 'XXX' is never used">XXX</warning> {
+class <warning descr="Class 'XXX' is never used">XXX</warning> {
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/XXX.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/XXX.java
index 0a9a173..7e5a749 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/XXX.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/XXX.java
@@ -1,5 +1,5 @@
import java.io.*;
-public class x {
+class x {
static {int i;}
}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/aClassLoader_hl.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/aClassLoader_hl.java
index c7f959b..de3671e 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/aClassLoader_hl.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/aClassLoader_hl.java
@@ -134,7 +134,7 @@
* @see java.lang.ClassLoader#resolveClass(java.lang.Class)
* @since JDK1.0
*/
-public abstract class ClassLoader {
+abstract class ClassLoader {
private static native void registerNatives();
static {
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/aThinlet_hl.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/aThinlet_hl.java
index 96cc171..30df382 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/aThinlet_hl.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/aThinlet_hl.java
@@ -35,7 +35,7 @@
/**
*
*/
-public class Thinlet extends Container //java
+class Thinlet extends Container //java
implements Runnable, Serializable { //java
//midp public class Thinlet extends Canvas implements CommandListener {
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/publicClassInRightFile/x/X.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/publicClassInRightFile/x/X.java
new file mode 100644
index 0000000..1e82018
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/publicClassInRightFile/x/X.java
@@ -0,0 +1,4 @@
+package x;
+public class X {
+ public interface B {}
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/publicClassInRightFile/x/Y.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/publicClassInRightFile/x/Y.java
new file mode 100644
index 0000000..f5e4929
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/publicClassInRightFile/x/Y.java
@@ -0,0 +1,2 @@
+package x;
+<error descr="Class 'DD' is public, should be declared in a file named 'DD.java'">public class DD</error> {}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/reimportConflictingClasses/x/Usage.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/reimportConflictingClasses/x/Usage.java
index e6e26cf..d6a1f00 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/reimportConflictingClasses/x/Usage.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/reimportConflictingClasses/x/Usage.java
@@ -5,7 +5,7 @@
import x.n.X3;
@Deprecated
-public class Y {
+class Y {
X1 x1;
x.n.Class s;
X2 x2;
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/reimportConflictingClasses/x/Usage_afterOptimize.txt b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/reimportConflictingClasses/x/Usage_afterOptimize.txt
index 15f16b2..348af58 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/reimportConflictingClasses/x/Usage_afterOptimize.txt
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/reimportConflictingClasses/x/Usage_afterOptimize.txt
@@ -5,7 +5,7 @@
import java.lang.Class;
@Deprecated
-public class Y {
+class Y {
X1 x1;
x.n.Class s;
X2 x2;
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting6/RedundantCastInConditionalExpression.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting6/RedundantCastInConditionalExpression.java
index 351526a..ef3fe36 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting6/RedundantCastInConditionalExpression.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting6/RedundantCastInConditionalExpression.java
@@ -1,4 +1,4 @@
-public class Foo {
+class Foo {
public static void main(String[] args) {
final boolean b = false;
final Integer i = (<warning descr="Casting '3' to 'Integer' is redundant">Integer</warning>)3;
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting6/UnhandledExceptionsValueOf.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting6/UnhandledExceptionsValueOf.java
index b1a6060..0ca7ebb 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting6/UnhandledExceptionsValueOf.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting6/UnhandledExceptionsValueOf.java
@@ -7,4 +7,4 @@
}
-public class IllegalArgumentException extends Exception {}
+class IllegalArgumentException extends Exception {}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondPos1.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondPos1.java
index 927df1d..d0cc63a 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondPos1.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondPos1.java
@@ -1,4 +1,4 @@
-public class Pos01<X> {
+class Pos01<X> {
Pos01(X x) {}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondPos2.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondPos2.java
index 0f7a508..28cb2be 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondPos2.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondPos2.java
@@ -1,4 +1,4 @@
-public class Pos02 {
+class Pos02 {
static class Foo<X> {
Foo(X x) {}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondPos3.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondPos3.java
index 7cb0178..0ae30c3 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondPos3.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondPos3.java
@@ -1,4 +1,4 @@
-public class Pos03<U> {
+class Pos03<U> {
class Foo<V> {
Foo(V x) {}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondPos4.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondPos4.java
index 666acb8..2962fa5 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondPos4.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondPos4.java
@@ -1,4 +1,4 @@
-public class Pos4<U> {
+class Pos4<U> {
void test() {
class Foo<V> {
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondPos5.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondPos5.java
index 1f60451..98789a6 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondPos5.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DiamondPos5.java
@@ -1,4 +1,4 @@
-public class Pos05 {
+class Pos05 {
static class Foo<X> {
Foo(X x) {}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DynamicallyAddIgnoredAnnotations.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DynamicallyAddIgnoredAnnotations.java
index 97d405d..7325883 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DynamicallyAddIgnoredAnnotations.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/DynamicallyAddIgnoredAnnotations.java
@@ -1,5 +1,4 @@
-
-public class <warning descr="Class 'WithMain' is never used">WithMain</warning> {
+class <warning descr="Class 'WithMain' is never used">WithMain</warning> {
@MyAnno
public void <warning descr="Method 'myTestMethod()' is never used">myTestMethod</warning>(){}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/IDEA111450.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/IDEA111450.java
index 026403a..9579bf0 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/IDEA111450.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/IDEA111450.java
@@ -1,7 +1,7 @@
import java.lang.Character;
import java.util.List;
-public class Test {
+class Test {
public static void test() {
Character c1 = '1';
Character c2 = '2';
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/IDEA70890.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/IDEA70890.java
index c528329..a397e6e 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/IDEA70890.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/IDEA70890.java
@@ -1,6 +1,6 @@
import java.util.*;
-public class Test {
+class Test {
static <E extends Exception, T> void foo(List<T> l, Class<E> ec) throws E {
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/SuperBound.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/SuperBound.java
index 3ceb429..ade1fcb 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/SuperBound.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/SuperBound.java
@@ -15,7 +15,7 @@
*/
import java.lang.Override;
import java.util.List;
-public class Test
+class Test
{
public interface MyList<N extends Number> extends List<N>
{
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/UncheckedGenericsArrayCreation.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/UncheckedGenericsArrayCreation.java
index 8902887..ce0660b 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/UncheckedGenericsArrayCreation.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/UncheckedGenericsArrayCreation.java
@@ -1,6 +1,6 @@
import java.util.*;
-public class Test {
+class Test {
static <T> List<T> asList(T... tt) {
System.out.println(tt);
return null;
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/UncheckedWarningIDEA21432.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/UncheckedWarningIDEA21432.java
index 7cb66c4..40ab055 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/UncheckedWarningIDEA21432.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/UncheckedWarningIDEA21432.java
@@ -1,7 +1,6 @@
-
import java.util.Map;
-public class MissingWarning {
+class MissingWarning {
static final Map<String, String> VALID_VALUES_BY_KEY = <warning descr="Unchecked generics array creation for varargs parameter">newExceptionOnNullHashMap</warning>(
"Invalid key",
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/UncheckedWarningIDEA99536.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/UncheckedWarningIDEA99536.java
index 7cab4af..cf57f23 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/UncheckedWarningIDEA99536.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/UncheckedWarningIDEA99536.java
@@ -13,7 +13,7 @@
}
-public class Main {
+class Main {
public static void test(Collection<? extends A> <warning descr="Parameter 'c' is never used">c</warning>) {}
public static void main(String[] args) {
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguous/pck/AmbiguousMethodCall.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguous/pck/AmbiguousMethodCall.java
index 2adaecd..b753392 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguous/pck/AmbiguousMethodCall.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguous/pck/AmbiguousMethodCall.java
@@ -13,7 +13,7 @@
static <T> String foo(List<List<T>> x) { return null; }
}
-public class Main {
+class Main {
public static void main(String[] args){
List<List<String>> x = null;
foo(x).toLowerCase();
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousArrayInSubst/pck/AmbiguousMethodCall.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousArrayInSubst/pck/AmbiguousMethodCall.java
index da83342..aca1518 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousArrayInSubst/pck/AmbiguousMethodCall.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousArrayInSubst/pck/AmbiguousMethodCall.java
@@ -13,7 +13,7 @@
static <T> String foo(List<T[]> x) { return null; }
}
-public class Main {
+class Main {
public static void main(String[] args){
List<String[]> x = null;
foo(x).toLowerCase();
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousIDEA67573/pck/AmbiguousMethodCall.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousIDEA67573/pck/AmbiguousMethodCall.java
index b63b6aa..918518e 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousIDEA67573/pck/AmbiguousMethodCall.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousIDEA67573/pck/AmbiguousMethodCall.java
@@ -12,6 +12,6 @@
{
void bar(T x)
{
- x.foo(null);
+ x.foo<error descr="Ambiguous method call: both 'A.foo(String[]...)' and 'B.foo(String[])' match">(null)</error>;
}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousIDEA67832/pck/AmbiguousMethodCall.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousIDEA67832/pck/AmbiguousMethodCall.java
index 45910d1..c031a68 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousIDEA67832/pck/AmbiguousMethodCall.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousIDEA67832/pck/AmbiguousMethodCall.java
@@ -2,7 +2,7 @@
import static pck.D.foo;
import static pck.C.foo;
-public class C {
+class C {
public static <T extends Comparable<S>, S> void foo(T x){}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousIDEA67836/pck/AmbiguousMethodCall.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousIDEA67836/pck/AmbiguousMethodCall.java
index b42af5a..050df61 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousIDEA67836/pck/AmbiguousMethodCall.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousIDEA67836/pck/AmbiguousMethodCall.java
@@ -2,7 +2,7 @@
import static pck.D.foo;
import static pck.C.foo;
-public class C {
+class C {
public static <T> String foo(Comparable<? extends Comparable<T>> x){
return null;
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousIDEA67837/pck/AmbiguousMethodCall.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousIDEA67837/pck/AmbiguousMethodCall.java
index 0fbc5bc..e6cde58 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousIDEA67837/pck/AmbiguousMethodCall.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousIDEA67837/pck/AmbiguousMethodCall.java
@@ -3,7 +3,7 @@
import static pck.D.foo;
import static pck.C.foo;
-public class C {
+class C {
public static <T> void foo(Comparable<? extends Comparable<T>> x){}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousIDEA67841/pck/AmbiguousMethodCall.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousIDEA67841/pck/AmbiguousMethodCall.java
index c79d7c8..d59988b 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousIDEA67841/pck/AmbiguousMethodCall.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousIDEA67841/pck/AmbiguousMethodCall.java
@@ -6,7 +6,7 @@
import static pck.D.foo;
import static pck.C.foo;
-public class C {
+class C {
static <T extends Collection<S>, S> void foo(T x) { }
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousIDEA67864/pck/AmbiguousMethodCall.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousIDEA67864/pck/AmbiguousMethodCall.java
index 8240e7a..7aac847 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousIDEA67864/pck/AmbiguousMethodCall.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousIDEA67864/pck/AmbiguousMethodCall.java
@@ -17,7 +17,7 @@
static <T extends List<?>, S> String foo1(List<T> x) { return null; }
}
-public class Main {
+class Main {
public static void main(String[] args){
List<List<String>> x = null;
foo(x).toCharArray();
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousInferenceOrder/pck/AmbiguousMethodCall.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousInferenceOrder/pck/AmbiguousMethodCall.java
index fc2ebd9..2fe6234 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousInferenceOrder/pck/AmbiguousMethodCall.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousInferenceOrder/pck/AmbiguousMethodCall.java
@@ -17,7 +17,7 @@
class Key<K>{}
-public class C {
+class C {
public <T> void putCopyableUserData(Key<T> key, T value) {
}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousTypeParamExtends/pck/AmbiguousMethodCall.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousTypeParamExtends/pck/AmbiguousMethodCall.java
index 8689693..9ce29dd 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousTypeParamExtends/pck/AmbiguousMethodCall.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousTypeParamExtends/pck/AmbiguousMethodCall.java
@@ -13,7 +13,7 @@
static <T extends List<?>> String foo(List<T> x) { return null; }
}
-public class Main {
+class Main {
public static void main(String[] args){
List<List<String>> x = null;
foo(x).toCharArray();
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousTypeParamNmb/pck/AmbiguousMethodCall.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousTypeParamNmb/pck/AmbiguousMethodCall.java
index db291ad..20ba4ec 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousTypeParamNmb/pck/AmbiguousMethodCall.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousTypeParamNmb/pck/AmbiguousMethodCall.java
@@ -2,7 +2,7 @@
import static pck.C.foo;
import static pck.D.foo;
-public class C {
+class C {
public static void foo(){}
}
class D {
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousTypeParamNmb1/pck/AmbiguousMethodCall.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousTypeParamNmb1/pck/AmbiguousMethodCall.java
index d030dd3..32665b9 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousTypeParamNmb1/pck/AmbiguousMethodCall.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousTypeParamNmb1/pck/AmbiguousMethodCall.java
@@ -2,7 +2,7 @@
import static pck.D.foo;
import static pck.C.foo;
-public class C {
+class C {
public static <T> void foo(Comparable<T> x){}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/annotations/typeAnnotations.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/annotations/typeAnnotations.java
index 4867e10..400a678 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/annotations/typeAnnotations.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/annotations/typeAnnotations.java
@@ -104,7 +104,6 @@
void arrays(String @TA ... docs) {
@TA String @TA [] @TA [] docs1 = new @TA String @TA [2] @TA [2];
@TA int @TA [] ints = new @TA int @TA [2];
- new Boolean @TA [2] <error descr="Annotations are not allowed here">@TA</error>;
}
int @TA [] mixedArrays @TA [] <error descr="Annotations are not allowed here">@TA</error> = new int[0][0];
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/AmbiguousTypeParamVsConcrete.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/AmbiguousTypeParamVsConcrete.java
index 272fb29..58829fd 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/AmbiguousTypeParamVsConcrete.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/AmbiguousTypeParamVsConcrete.java
@@ -1,10 +1,10 @@
-public class CssPropertyValueImpl extends CssTableValueBase<CssPropertyValue, Object> implements CssPropertyValue {
+class CssPropertyValueImpl extends CssTableValueBase<CssPropertyValue, Object> implements CssPropertyValue {
public CssPropertyValueImpl(final Type type) {
super(type);
}
}
-public abstract class CssTableValueBase<V extends CssTableValue, T> implements CssTableValue<V, T> {
+abstract class CssTableValueBase<V extends CssTableValue, T> implements CssTableValue<V, T> {
protected CssTableValueBase(final Type type) {
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/AnnotationsAsPartOfModifierList.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/AnnotationsAsPartOfModifierList.java
index 3fca0c0..3fe5717 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/AnnotationsAsPartOfModifierList.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/AnnotationsAsPartOfModifierList.java
@@ -1,5 +1,5 @@
@Deprecated @SuppressWarnings("")
-<error descr="Class 'Foo' must either be declared abstract or implement abstract method 'run()' in 'Runnable'">public class Foo implements Runnable</error> {
+<error descr="Class 'Foo' must either be declared abstract or implement abstract method 'run()' in 'Runnable'">class Foo implements Runnable</error> {
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/Autoboxing.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/Autoboxing.java
index 8ecc864..3480a63 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/Autoboxing.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/Autoboxing.java
@@ -1,4 +1,4 @@
-public class Autoboxing {
+class Autoboxing {
public boolean compare(short s, Integer i) {
return i == s; //OK, i is unboxed
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/AutoboxingConstructors.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/AutoboxingConstructors.java
index 12c5332..aa73346 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/AutoboxingConstructors.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/AutoboxingConstructors.java
@@ -1,4 +1,4 @@
-public class Test {
+class Test {
public Test(Object a) {
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/AutoboxingMethods.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/AutoboxingMethods.java
index d020997..fdb7ea2 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/AutoboxingMethods.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/AutoboxingMethods.java
@@ -1,4 +1,4 @@
-public class Autoboxing {
+class Autoboxing {
void method(int i) {
System.out.println("i = " + i);
}
@@ -19,7 +19,7 @@
m2(new Integer(10));
}
}
-public class Autoboxing1 {
+class Autoboxing1 {
void method(String s, int i) {
System.out.println("i = " + i);
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/BooleanInferenceFromIfCondition.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/BooleanInferenceFromIfCondition.java
index 44fbeef..f0f12eb 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/BooleanInferenceFromIfCondition.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/BooleanInferenceFromIfCondition.java
@@ -1,4 +1,4 @@
-public class Main {
+class Main {
public <T> T getAttribute() {return null;}
public <T> T getAttribute(T def) {return null;}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/CapturedWildcardAssignments.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/CapturedWildcardAssignments.java
index b750cd2..6c158a3 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/CapturedWildcardAssignments.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/CapturedWildcardAssignments.java
@@ -16,7 +16,7 @@
import java.util.*;
-public class Test {
+class Test {
public static void bar() {
<error descr="Incompatible types. Found: 'java.lang.Class<capture<? extends java.util.Iterator>>', required: 'java.lang.Class<? extends java.util.Iterator<?>>'">Class<? extends Iterator<?>> c = foo();</error>
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/ClassInheritance.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/ClassInheritance.java
index 1a4e80f..7a36edf 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/ClassInheritance.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/ClassInheritance.java
@@ -12,7 +12,7 @@
}
class a extends b<d, c> implements c<d, c<c,c>>, d<b<c<c,c>,d>> {}
-public class b<K,V> implements c<K, c<V,V>> { }
+class b<K,V> implements c<K, c<V,V>> { }
interface c<K,V> extends d<b<V,K>> {}
interface d<K> {}
@@ -28,7 +28,7 @@
////////////////////
-public abstract class ZZZZ<E> {
+abstract class ZZZZ<E> {
public abstract E getElement();
}
abstract class Z<E> extends ZZZZ<E> {}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/ConvertibleTypes.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/ConvertibleTypes.java
index 602e30c..467e5e1 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/ConvertibleTypes.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/ConvertibleTypes.java
@@ -5,7 +5,7 @@
interface YO1 extends YO<String> {}
interface YO2 extends YO<Integer> {}
-public class ConvertibleTest {
+class ConvertibleTest {
YO2 bar (YO1 s) {
return <error descr="Inconvertible types; cannot cast 'YO1' to 'YO2'">(YO2) s</error>;
@@ -19,7 +19,7 @@
class Implementation implements Interface1 {}
-public class InconvertibleTypesTest <E extends Interface2>
+class InconvertibleTypesTest <E extends Interface2>
{
E thing;
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/DisableCastingToNestedWildcards.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/DisableCastingToNestedWildcards.java
index 9c076ab..67bab6d 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/DisableCastingToNestedWildcards.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/DisableCastingToNestedWildcards.java
@@ -1,6 +1,6 @@
import java.util.List;
-public class Test {
+class Test {
interface P {
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/DisableWithinBoundsCheckForSuperWildcards.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/DisableWithinBoundsCheckForSuperWildcards.java
index 703c377..e3a95f9 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/DisableWithinBoundsCheckForSuperWildcards.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/DisableWithinBoundsCheckForSuperWildcards.java
@@ -1,6 +1,6 @@
import java.util.Comparator;
-public class Main2 {
+class Main2 {
static class OfRef<T> {
public OfRef() {
this((Comparator<? super T>) naturalOrder());
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/FlattenIntersectionType.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/FlattenIntersectionType.java
index 4ff85a2..1305737 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/FlattenIntersectionType.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/FlattenIntersectionType.java
@@ -5,7 +5,7 @@
E getEntity();
}
-public class MyTest {
+class MyTest {
<T extends BusinessEntity<T>> T getEntity(EntityId<T> defaultValue) {
return getEntityID(defaultValue).getEntity();
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA103760.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA103760.java
index 93d1143..4159c29 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA103760.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA103760.java
@@ -1,7 +1,7 @@
import java.util.*;
-public class MyList extends ArrayList {}
+class MyList extends ArrayList {}
-public class Test {
+class Test {
public void test() {
List<? super List> list = new ArrayList<List>();
list.add(new MyList());
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA104100.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA104100.java
index cc01b4b..6cb89c7 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA104100.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA104100.java
@@ -1,4 +1,4 @@
-public class TestGenericMap<A extends Comparable<A>, B extends Comparable<B>>
+class TestGenericMap<A extends Comparable<A>, B extends Comparable<B>>
{
public TestGenericMap<B, A> inverse()
{
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA104992.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA104992.java
index 3798c70..94949a8 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA104992.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA104992.java
@@ -9,7 +9,7 @@
<T extends FooObject, I extends FooId<? extends T>> Collection<T> get(Collection<I> keys);
}
-public class Target {
+class Target {
void foo(Bar bar) {
final Set<FooId<?>> keys = null;
final Collection<FooObject> values = bar.get(keys);
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA105695.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA105695.java
index ab28299..75c5523 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA105695.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA105695.java
@@ -1,6 +1,6 @@
import java.util.Map;
-public class Test {
+class Test {
void bar(Prop p) {
Map<? extends String, ? extends String> map = <error descr="Inconvertible types; cannot cast 'Prop' to 'java.util.Map<? extends java.lang.String,? extends java.lang.String>'">(Map<? extends String, ? extends String>)p</error>;
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA106964.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA106964.java
index 8c8603e..7b4fd2b 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA106964.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA106964.java
@@ -1,6 +1,6 @@
import java.io.Serializable;
-public abstract class Test {
+abstract class Test {
abstract <T> T test(Class<T> cls);
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA107782.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA107782.java
index a078c65..d38334e 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA107782.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA107782.java
@@ -1,4 +1,4 @@
-public class Test {
+class Test {
{
final <error descr="Incompatible types. Found: 'java.lang.Object', required: 'MyResult'">MyResult hello = parseXML(new Parser());</error>
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA109875.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA109875.java
index a70b094..89201fa 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA109875.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA109875.java
@@ -1,7 +1,7 @@
import java.util.Collections;
import java.util.Set;
-public class Test<Y> {
+class Test<Y> {
public static <K> Test<K> doTest(K k){
return null;
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA110568.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA110568.java
index ed9eedd..75ac142 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA110568.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA110568.java
@@ -1,6 +1,6 @@
import java.util.Collection;
-public class IncorrectError extends NarrowClass {
+class IncorrectError extends NarrowClass {
public Collection<String> bar() {
return super.doStuff();
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA113225.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA113225.java
index 7b4bbab..675a8be 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA113225.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA113225.java
@@ -1,6 +1,6 @@
import java.io.Serializable;
-public class Test {
+class Test {
public <T extends Serializable> void foo(byte[] data) {
T foo = (T) data;
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA113526.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA113526.java
index 7db1cd8..336087c 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA113526.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA113526.java
@@ -1,6 +1,6 @@
import java.util.List;
-public class MyTest {
+class MyTest {
static void m(List<? extends List> c) {
List<? extends List<?>> d = <warning descr="Unchecked cast: 'java.util.List<capture<? extends java.util.List>>' to 'java.util.List<? extends java.util.List<?>>'">(List<? extends List<?>>)c</warning>;
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA114894.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA114894.java
index 571d0f9..0656e42 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA114894.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA114894.java
@@ -1,7 +1,7 @@
import java.util.Comparator;
import java.util.List;
-public class IdeaBugTest {
+class IdeaBugTest {
public void foo(List<Base> base) {
MyCollection.fun<error descr="'fun(java.util.List<? extends Base>, java.util.Comparator<? super Base>)' in 'MyCollection' cannot be applied to '(java.util.List<Base>, SubComparator)'">(base, new SubComparator())</error>;
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA117827.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA117827.java
index afa7d2a..15638c3 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA117827.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA117827.java
@@ -1,8 +1,7 @@
-
import java.util.Collection;
import java.util.List;
-public class Testsss {
+class Testsss {
public <TA, CA extends Iterable<TA>> void that(Iterable<TA> target) {}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA118527.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA118527.java
index a365bad..2958739 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA118527.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA118527.java
@@ -45,4 +45,35 @@
}
+}
+
+class Test1 {
+ class ResolveResult {
+ }
+
+ class A {
+ }
+
+ class B extends A {
+ }
+
+ abstract class AbstractResolver<K, V> {
+ }
+
+ abstract class Resolver<K> extends AbstractResolver<K, ResolveResult[]> {
+ }
+
+ public <T extends B> ResolveResult[] resolveWithCaching(T ref, Resolver<T> resolver) {
+ return null;
+ }
+
+ public <TRef extends A, TResult> TResult resolveWithCaching(TRef ref, AbstractResolver<TRef, TResult> resolver) {
+ return null;
+ }
+
+ {
+ Resolver<B> resolver = null;
+ B b = null;
+ resolveWithCaching(b, resolver);
+ }
}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA119546.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA119546.java
index 7eeb837..d4ca99d 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA119546.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA119546.java
@@ -1,4 +1,4 @@
-public interface I<K> {
+interface I<K> {
}
abstract class SpringHighlightingTestCase<T extends I>{
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA18425.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA18425.java
index 4308a92..e674ac5 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA18425.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA18425.java
@@ -1,4 +1,4 @@
-public abstract class BiFunction<A,B> {
+abstract class BiFunction<A,B> {
public abstract B apply(A a);
public abstract A unapply(B b);
public BiFunction<B,A> flip() {
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA20573.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA20573.java
index 22bd7a3..934320a 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA20573.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA20573.java
@@ -1,4 +1,4 @@
-public class GoodCodeIsRed {
+class GoodCodeIsRed {
public void test() {
FileIF file = new FileImpl();
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA21602.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA21602.java
index c02ceaa..430eb66 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA21602.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA21602.java
@@ -1,7 +1,7 @@
import java.util.Collection;
import java.util.Collections;
-public class IDEABug {
+class IDEABug {
static class ClassA {
static <T> void sayHello(Collection<? extends T> msg) {}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA21602_7.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA21602_7.java
index 0496f3a..43e47a9 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA21602_7.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA21602_7.java
@@ -1,7 +1,7 @@
import java.util.Collection;
import java.util.Collections;
-public class IDEABug {
+class IDEABug {
static class ClassA {
static <T> void sayHello(Collection<? extends T> msg) {}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA22079.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA22079.java
index f3b25c9..f3edb1c 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA22079.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA22079.java
@@ -1,6 +1,6 @@
import java.util.List;
-public class SubClass extends BaseClass<String> {
+class SubClass extends BaseClass<String> {
public static void main(String[] args) {
new SubClass().method(null);
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA60818.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA60818.java
index 5ed0220..bd6dab8 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA60818.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA60818.java
@@ -1,4 +1,4 @@
-public class IdeaBugTest {
+class IdeaBugTest {
interface A<T> {
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA60836.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA60836.java
index 1902e1b..99fc40f 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA60836.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA60836.java
@@ -1,5 +1,5 @@
import java.util.*;
-public class IdeaGenericsTest {
+class IdeaGenericsTest {
interface Animal<T extends Animal<T>> {
List<T> getFriends();
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA63291.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA63291.java
index 3343db7..f23449d 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA63291.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA63291.java
@@ -1,7 +1,7 @@
import java.util.Comparator;
import java.util.Set;
-public class CastError {
+class CastError {
public void foo(Comparator<? super byte[]> comparator) throws Exception {
MyComparator comparator1 = (MyComparator) comparator;
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA63331.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA63331.java
index eddb94c..bef0287 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA63331.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA63331.java
@@ -7,7 +7,7 @@
B(List<A<?>> list) {}
}
-public class Bug {
+class Bug {
private static B case1(A<?> a) {
return new B(Collections.singletonList(a));
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA65377.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA65377.java
index 1bdf031..9679b0c 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA65377.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA65377.java
@@ -1,4 +1,4 @@
-public class C1<T extends C1<T>>{
+class C1<T extends C1<T>>{
public static class C2<K extends C1<K>> extends C1<K>{}
public static class C3<Z> extends C2<<error descr="No wildcard expected">? extends C3<Z></error>>{}
}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA72912.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA72912.java
index c57bbb5..a04da78 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA72912.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA72912.java
@@ -1,6 +1,6 @@
import java.util.*;
-public class Test<T>
+class Test<T>
{
List<Collection<T>> getList ()
{
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA74899.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA74899.java
index 8723829..8931d87 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA74899.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA74899.java
@@ -1,7 +1,7 @@
import java.util.Collections;
import java.util.Map;
-public class IDEA74899 {
+class IDEA74899 {
void foo() {
Map<String, String> m = Collections.emptyMap();
if (<error descr="Operator '==' cannot be applied to 'java.util.Map<java.lang.String,java.lang.String>', 'java.util.Map<java.lang.Object,java.lang.Object>'">m == Collections.emptyMap()</error>) {
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA76283.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA76283.java
index a221d1b..3f065c4 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA76283.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA76283.java
@@ -1,5 +1,5 @@
import java.util.*;
-public class IDEA76283 {
+class IDEA76283 {
}
interface Parametrized<T extends Number> {
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA80386.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA80386.java
index 3587f4f..79f5879 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA80386.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA80386.java
@@ -1,6 +1,6 @@
import java.util.List;
-public class IDEA80386 {
+class IDEA80386 {
void foo(Class<List> listClass) {
<error descr="Incompatible types. Found: 'java.lang.Class<java.util.List>', required: 'java.lang.Class<? extends java.util.List<?>>'">Class<? extends List<?>> cls = listClass;</error>
Class < ?extends List > cls1 = listClass;
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA88895.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA88895.java
index e3482d7..70a3460 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA88895.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA88895.java
@@ -1,6 +1,6 @@
import java.util.Iterator;
-public class WildcardGenericAndPrivateField {
+class WildcardGenericAndPrivateField {
private Object field;
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEADEV10459.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEADEV10459.java
index fe52659..c8b4470 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEADEV10459.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEADEV10459.java
@@ -3,7 +3,7 @@
import java.util.List;
/** @noinspection UnusedDeclaration*/
-public class GenericsTest98 {
+class GenericsTest98 {
public static void main(String[] args) throws Exception{
List<Movable<? extends Serializable>> list = new ArrayList<Movable<? extends Serializable>> ();
Factory factory = Factory.newInstance();
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEADEV23157.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEADEV23157.java
index c0c2b70..eb3e475 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEADEV23157.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEADEV23157.java
@@ -1,7 +1,7 @@
import java.util.List;
import java.util.Arrays;
-public class ZZZ {
+class ZZZ {
List<Class<?>> f(Class<?>[] exceptionTypes) {
List<Class<?>> nd = Arrays.asList(exceptionTypes);
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IllegalGenericTypeInInstanceof.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IllegalGenericTypeInInstanceof.java
index 52871e8..0ac6ec7 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IllegalGenericTypeInInstanceof.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IllegalGenericTypeInInstanceof.java
@@ -38,7 +38,7 @@
class Node {}
class XBreakpoint<SR>{}
-public class GenericInnerClass<E> {
+class GenericInnerClass<E> {
private void problem( Base base ) {
if ( base instanceof First) {}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/ImplementAnnotation.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/ImplementAnnotation.java
index bbe1e30..8650d6b 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/ImplementAnnotation.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/ImplementAnnotation.java
@@ -1,6 +1,6 @@
import java.lang.annotation.Annotation;
-public @interface Foo {
+@interface Foo {
String id();
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/InferenceWithBounds.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/InferenceWithBounds.java
index bfdb8c5..c7488f3 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/InferenceWithBounds.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/InferenceWithBounds.java
@@ -8,7 +8,7 @@
}
}
//////////////////////////////
-public abstract class ZZZ<K> {
+abstract class ZZZ<K> {
public abstract <T extends String> ZZZ<T> get();
}
class Z2<K> extends ZZZ<K> {
@@ -44,7 +44,7 @@
class B extends A {}
}
//////////////////////////
-public class BadCodeGreen<T, C extends Collection<? extends T>> {
+class BadCodeGreen<T, C extends Collection<? extends T>> {
public BadCodeGreen(C c, T t) {
c.add<error descr="'add(capture<? extends T>)' in 'java.util.Collection' cannot be applied to '(T)'">(t)</error>;
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/InferenceWithSuperBounds.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/InferenceWithSuperBounds.java
index d68f907..f9c1de3 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/InferenceWithSuperBounds.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/InferenceWithSuperBounds.java
@@ -1,4 +1,4 @@
-public class ExampleProblem {
+class ExampleProblem {
<T> void asserting(T t, Simple<T> l){
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/InferenceWithUpperBoundPromotion.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/InferenceWithUpperBoundPromotion.java
index 82a2a68..e114f21 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/InferenceWithUpperBoundPromotion.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/InferenceWithUpperBoundPromotion.java
@@ -1,5 +1,4 @@
-
-public class NestedGenericGoodCodeIsRed {
+class NestedGenericGoodCodeIsRed {
public void main( String[] args ) {
satisfiesAllOf(isPositive(), isEqualTo(10.9));
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/InnerClassRef.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/InnerClassRef.java
index 27efb83..00f443a 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/InnerClassRef.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/InnerClassRef.java
@@ -1,7 +1,7 @@
import java.util.*;
import Node.Details;
-public class Node<E> {
+class Node<E> {
public class Details {
public E data;
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IntersectionTypes.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IntersectionTypes.java
index b201ac5..5706e9f 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IntersectionTypes.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IntersectionTypes.java
@@ -167,7 +167,7 @@
}
///////////////
interface L {}
-public class MaximalType {
+class MaximalType {
public static <T> T getParentOfType(Class<? extends T>... classes) {
classes.hashCode();
return null;
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/OverrideWithMoreSpecificReturn.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/OverrideWithMoreSpecificReturn.java
index c2f6877..926a347 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/OverrideWithMoreSpecificReturn.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/OverrideWithMoreSpecificReturn.java
@@ -11,5 +11,5 @@
}
-public class ExampleSubClass extends ExampleSuperClass implements ExampleInterface {
+class ExampleSubClass extends ExampleSuperClass implements ExampleInterface {
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/OverridingMethods.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/OverridingMethods.java
index 04d2fe2..9968501 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/OverridingMethods.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/OverridingMethods.java
@@ -116,7 +116,7 @@
abstract class HasGenericMethods<T> {
abstract <P> void toArray(P[] p);
}
-public class RawOverridesGenericMethods extends HasGenericMethods{
+class RawOverridesGenericMethods extends HasGenericMethods{
public void toArray(Object[] ps) {
}
}
@@ -160,7 +160,7 @@
interface IU {
public <I> I[] toArray(I[] ts);
}
-public class BarIUBarIU extends BarIU implements IU{
+class BarIUBarIU extends BarIU implements IU{
public <T> T[] toArray(T[] ts) {
return null;
}
@@ -339,7 +339,7 @@
//end of IDEADEV-8393
///////////////////
-public class Prim {
+class Prim {
Object g() {
return null;
}
@@ -366,7 +366,7 @@
//end of IDEADEV-21921
////////////////////////////////////////
-public class Bug2 extends SmartList<Bug2> implements Places {
+class Bug2 extends SmartList<Bug2> implements Places {
}
interface Places extends java.util.List<Bug2> {}
@@ -433,37 +433,37 @@
String toString();
}
///////////////////////IDEADEV-24300 ////////////////////////
-public class ActionContext<A extends ContextAction> {
+class ActionContext<A extends ContextAction> {
}
-public abstract class ContextAction<AC extends ActionContext> {
+abstract class ContextAction<AC extends ActionContext> {
protected abstract void performAction(AC context);
}
-public class OurAction extends TableContextAction<Object> {
+class OurAction extends TableContextAction<Object> {
protected void performAction(TableContext<Object> context) {
}
}
-public class TableContext<TCP> extends ActionContext<TableContextAction<TCP>> {
+class TableContext<TCP> extends ActionContext<TableContextAction<TCP>> {
}
-public abstract class TableContextAction<RO> extends ContextAction<TableContext<RO>> {
+abstract class TableContextAction<RO> extends ContextAction<TableContext<RO>> {
}
///////////////////////////////IDEADEV-23176 /////////////////////
-public interface MyListModel { }
-public interface MyList {
+interface MyListModel { }
+interface MyList {
Object get(int i);
int hashCode();
}
-public interface MutableListModel extends MyListModel, MyList {
+interface MutableListModel extends MyListModel, MyList {
}
-public class ListModelImpl {
+class ListModelImpl {
public Object get(int i) {
return null;
}
}
-public class MutableListModelImpl extends ListModelImpl implements MutableListModel {
+class MutableListModelImpl extends ListModelImpl implements MutableListModel {
}
///////////////////////////////////////////////////////////////
-public class InheritanceBug {
+class InheritanceBug {
interface A {
Object clone();
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/PrivateInnerClassRef.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/PrivateInnerClassRef.java
index ffe0efd..cb6d49b 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/PrivateInnerClassRef.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/PrivateInnerClassRef.java
@@ -1,6 +1,6 @@
import java.util.Comparator;
-public abstract class A implements <error descr="'A.B' has private access in 'A'">Comparator<A.B></error> {
+abstract class A implements <error descr="'A.B' has private access in 'A'">Comparator<A.B></error> {
private static class B {
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/Raw.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/Raw.java
index eb11019..e49f392 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/Raw.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/Raw.java
@@ -159,7 +159,7 @@
/////////////// signatures in non-parameterized class are not erased
-public class C3 {
+class C3 {
public int get(Class<?> c) {
return 0;
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/RawAssignments.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/RawAssignments.java
index bfbe439..b6917ca 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/RawAssignments.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/RawAssignments.java
@@ -11,8 +11,8 @@
foo.getText(prop);
}
}
-public abstract class Hashtable<K,V> implements Map<K,V>, Cloneable {
+abstract class Hashtable<K,V> implements Map<K,V>, Cloneable {
}
-public abstract class Properties extends Hashtable<Object,Object> {
+abstract class Properties extends Hashtable<Object,Object> {
}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/ReferenceTypeParams.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/ReferenceTypeParams.java
index 9b70340..b777718 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/ReferenceTypeParams.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/ReferenceTypeParams.java
@@ -38,10 +38,10 @@
/////// calling super on generic bound class
-public class Generic<T> {
+class Generic<T> {
Generic(T t){}
}
-public class Bound extends Generic<String>{
+class Bound extends Generic<String>{
public Bound(String s) {
super(s);
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/SOE.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/SOE.java
index a5f43e1..d211e94 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/SOE.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/SOE.java
@@ -1,4 +1,4 @@
-public class SOE {
+class SOE {
}
abstract class VersionEntity<V extends Version<V, R>, R extends Ref<V, R>>
implements Version<V, R>{}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/SameErasure.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/SameErasure.java
index 9bb49b2..3240ea2 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/SameErasure.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/SameErasure.java
@@ -14,7 +14,7 @@
void f(Object o) {}
}
-public class Test1 {
+class Test1 {
<error descr="'bug(String)' clashes with 'bug(String)'; both methods have same erasure">public void bug(String s)</error> {
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/StaticImports.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/StaticImports.java
index 047391d..40a6f0d 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/StaticImports.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/StaticImports.java
@@ -1,9 +1,8 @@
-
import static java.util.Arrays.asList;
import static java.util.Arrays.sort;
<warning descr="Unused import statement">import static java.util.Arrays.binarySearch;</warning>
-public class StaticImports {
+class StaticImports {
{
asList(new Object[]{});
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/StaticOverride.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/StaticOverride.java
index a40423e..04d5d71 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/StaticOverride.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/StaticOverride.java
@@ -1,6 +1,6 @@
import java.util.*;
-public class MyClass implements Comparator<String> {
+class MyClass implements Comparator<String> {
<error descr="Static method 'compare(String, String)' in 'MyClass' cannot override instance method 'compare(T, T)' in 'java.util.Comparator'">public static int compare(String a, String b)</error> {
return 42;
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/SuperWildcardWithBoundPromotion.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/SuperWildcardWithBoundPromotion.java
new file mode 100644
index 0000000..cfdc2a5
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/SuperWildcardWithBoundPromotion.java
@@ -0,0 +1,55 @@
+import java.io.Serializable;
+
+interface Parametrized<T extends Number> {}
+
+class Bug1<T extends Serializable>{
+ <I extends Number> Parametrized<I> foo(Parametrized<I> param) {
+ return null;
+ }
+
+ void bug1(Parametrized<? super T> param) {
+ foo(param);
+ }
+
+
+}
+
+class Bug2<T extends Integer>{
+ <I extends Number> Parametrized<I> foo(Parametrized<I> param) {
+ return null;
+ }
+
+ void bug1(Parametrized<? super T> param) {
+ foo(param);
+ }
+
+
+}
+
+class Test {
+ interface Parametrized<T extends Serializable> {}
+
+ class Bug1<T extends Serializable>{
+ <I extends Number> Parametrized<I> foo(Parametrized<I> param) {
+ return null;
+ }
+
+ void bug1(Parametrized<? super T> param) {
+ <error descr="Inferred type 'java.io.Serializable' for type parameter 'I' is not within its bound; should extend 'java.lang.Number'">foo(param)</error>;
+ }
+
+
+ }
+
+ class Bug2<T extends Integer>{
+ <I extends Number> Parametrized<I> foo(Parametrized<I> param) {
+ return null;
+ }
+
+ void bug1(Parametrized<? super T> param) {
+ <error descr="Inferred type 'java.io.Serializable' for type parameter 'I' is not within its bound; should extend 'java.lang.Number'">foo(param)</error>;
+ }
+
+
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeInference.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeInference.java
index f0d2741..d6f1982 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeInference.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeInference.java
@@ -78,7 +78,7 @@
//end of IDEADEV-6738
///////////////////////////////////
-public class Err {
+class Err {
void f() {
Decl[] extensions = getExtensions(Decl.EXTENSION_POINT_NAME);
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeParameterBoundVisibility.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeParameterBoundVisibility.java
index f1ca102..7f7c6dd 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeParameterBoundVisibility.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeParameterBoundVisibility.java
@@ -16,7 +16,7 @@
}
}
-public class Bug {
+class Bug {
// Idea incorrectly analyses this code with JDK 7
public <T extends Bug> void doit(T other) {
// Oops, was legal with JDK 6, no longer legal with JDK 7
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeParameterBoundVisibilityJdk14.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeParameterBoundVisibilityJdk14.java
index df04ee7..327be07 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeParameterBoundVisibilityJdk14.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeParameterBoundVisibilityJdk14.java
@@ -8,7 +8,7 @@
}
}
-public class Bug {
+class Bug {
// Idea incorrectly analyses this code with JDK 7
public <T extends Bug> void doit(T other) {
// Oops, was legal with JDK 6, no longer legal with JDK 7
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeParameterBoundsList.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeParameterBoundsList.java
index 506add0..4afc046 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeParameterBoundsList.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeParameterBoundsList.java
@@ -20,7 +20,7 @@
}
////////////////
-public class TypeParameters {
+class TypeParameters {
class X {}
static <T extends X> void f(Class<T> t){}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeWithinItsWildcardBound.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeWithinItsWildcardBound.java
index 47ecb3b..a7ada78 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeWithinItsWildcardBound.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeWithinItsWildcardBound.java
@@ -1,4 +1,4 @@
-public class WithingBounds {
+class WithingBounds {
interface I {
}
interface I1 {
@@ -311,7 +311,7 @@
A<A<<error descr="Type parameter 'A' is not within its bound; should extend 'A<A>'">A</error>>> a3;
A<? extends A> a4;
- A<<error descr="Type parameter '? super A' is not within its bound; should extend 'A<? super A>'">? super A</error>> a5;
+ A<<error descr="Type parameter '? super A' is not within its bound; should extend 'A<A<T>>'">? super A</error>> a5;
A<<error descr="Type parameter 'A[]' is not within its bound; should extend 'A<A[]>'">A[]</error>> a7;
}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/Variance.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/Variance.java
index 229e01d..131439d 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/Variance.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/Variance.java
@@ -9,7 +9,7 @@
* Time: 8:08:44 PM
* To change this template use File | Settings | File Templates.
*/
-public class VarianceTesting {
+class VarianceTesting {
void method(List<? extends VarianceTesting> l) {
// l.add(new VarianceTesting());
l.add(null);
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/WideningCastToTypeParam.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/WideningCastToTypeParam.java
index 7615d72..5da569e 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/WideningCastToTypeParam.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/WideningCastToTypeParam.java
@@ -9,7 +9,7 @@
class DoubleConverter extends AbstractNumberConverter<Double> {
}
-public class Test {
+class Test {
public static <C> IConverter<C> getConverter(Class<C> type) {
return (IConverter<C>)new DoubleConverter() {
};
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/WildcardCastConversion.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/WildcardCastConversion.java
index f610bac..fb978ed 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/WildcardCastConversion.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/WildcardCastConversion.java
@@ -1,4 +1,4 @@
-public class Test {
+class Test {
interface A {}
interface B {}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/WildcardTypes.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/WildcardTypes.java
index 1c5bd9c..6756d38 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/WildcardTypes.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/WildcardTypes.java
@@ -130,7 +130,7 @@
//end of IDEADEV-5816
interface I33 {}
-public class Q<T extends I33> {
+class Q<T extends I33> {
T t;
<V extends I33> List<V> foo(Q<V> v) {
v.hashCode();
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/WildcardsOnRawTypes.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/WildcardsOnRawTypes.java
index 10099b2..150e45d 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/WildcardsOnRawTypes.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/WildcardsOnRawTypes.java
@@ -1,6 +1,6 @@
import java.util.List;
-public class Main<T> {
+class Main<T> {
Object get(List<DiagramNode<T>> nodes, A a) {
return null;
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/AmbiguousTypeParamVsConcrete.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/AmbiguousTypeParamVsConcrete.java
index 272fb29..58829fd 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/AmbiguousTypeParamVsConcrete.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/AmbiguousTypeParamVsConcrete.java
@@ -1,10 +1,10 @@
-public class CssPropertyValueImpl extends CssTableValueBase<CssPropertyValue, Object> implements CssPropertyValue {
+class CssPropertyValueImpl extends CssTableValueBase<CssPropertyValue, Object> implements CssPropertyValue {
public CssPropertyValueImpl(final Type type) {
super(type);
}
}
-public abstract class CssTableValueBase<V extends CssTableValue, T> implements CssTableValue<V, T> {
+abstract class CssTableValueBase<V extends CssTableValue, T> implements CssTableValue<V, T> {
protected CssTableValueBase(final Type type) {
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/AnnotationsAsPartOfModifierList.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/AnnotationsAsPartOfModifierList.java
index 3fca0c0..3fe5717 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/AnnotationsAsPartOfModifierList.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/AnnotationsAsPartOfModifierList.java
@@ -1,5 +1,5 @@
@Deprecated @SuppressWarnings("")
-<error descr="Class 'Foo' must either be declared abstract or implement abstract method 'run()' in 'Runnable'">public class Foo implements Runnable</error> {
+<error descr="Class 'Foo' must either be declared abstract or implement abstract method 'run()' in 'Runnable'">class Foo implements Runnable</error> {
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/Autoboxing.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/Autoboxing.java
index 3d208b0..5e2a07d 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/Autoboxing.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/Autoboxing.java
@@ -1,4 +1,4 @@
-public class Autoboxing {
+class Autoboxing {
public boolean compare(short s, Integer i) {
return i == s; //OK, i is unboxed
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/AutoboxingConstructors.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/AutoboxingConstructors.java
index 12c5332..aa73346 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/AutoboxingConstructors.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/AutoboxingConstructors.java
@@ -1,4 +1,4 @@
-public class Test {
+class Test {
public Test(Object a) {
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/AutoboxingMethods.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/AutoboxingMethods.java
index d020997..fdb7ea2 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/AutoboxingMethods.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/AutoboxingMethods.java
@@ -1,4 +1,4 @@
-public class Autoboxing {
+class Autoboxing {
void method(int i) {
System.out.println("i = " + i);
}
@@ -19,7 +19,7 @@
m2(new Integer(10));
}
}
-public class Autoboxing1 {
+class Autoboxing1 {
void method(String s, int i) {
System.out.println("i = " + i);
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/BooleanInferenceFromIfCondition.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/BooleanInferenceFromIfCondition.java
index 44fbeef..f0f12eb 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/BooleanInferenceFromIfCondition.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/BooleanInferenceFromIfCondition.java
@@ -1,4 +1,4 @@
-public class Main {
+class Main {
public <T> T getAttribute() {return null;}
public <T> T getAttribute(T def) {return null;}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/CapturedWildcardAssignments.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/CapturedWildcardAssignments.java
index 08761a6..23216cc 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/CapturedWildcardAssignments.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/CapturedWildcardAssignments.java
@@ -16,7 +16,7 @@
import java.util.*;
-public class Test {
+class Test {
public static void bar() {
<error descr="Incompatible types. Found: 'java.lang.Class<capture<? extends java.util.Iterator>>', required: 'java.lang.Class<? extends java.util.Iterator<?>>'">Class<? extends Iterator<?>> c = foo();</error>
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/CastToIntersection.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/CastToIntersection.java
index b1017fc..904e0d6 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/CastToIntersection.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/CastToIntersection.java
@@ -1,6 +1,6 @@
import java.io.Serializable;
-public class FooBar1 {
+class FooBar1 {
{
Object x = null;
Object y = (CharSequence & Serializable) x;
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/CastToIntersectionType.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/CastToIntersectionType.java
new file mode 100644
index 0000000..26f0cc3
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/CastToIntersectionType.java
@@ -0,0 +1,10 @@
+import java.io.Serializable;
+
+class X {
+
+ <T extends Integer & Serializable> void foo(T param) {}
+
+ {
+ foo((Integer & Serializable)0);
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/ClassInheritance.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/ClassInheritance.java
index 1a4e80f..7a36edf 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/ClassInheritance.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/ClassInheritance.java
@@ -12,7 +12,7 @@
}
class a extends b<d, c> implements c<d, c<c,c>>, d<b<c<c,c>,d>> {}
-public class b<K,V> implements c<K, c<V,V>> { }
+class b<K,V> implements c<K, c<V,V>> { }
interface c<K,V> extends d<b<V,K>> {}
interface d<K> {}
@@ -28,7 +28,7 @@
////////////////////
-public abstract class ZZZZ<E> {
+abstract class ZZZZ<E> {
public abstract E getElement();
}
abstract class Z<E> extends ZZZZ<E> {}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/ConvertibleTypes.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/ConvertibleTypes.java
index 572ef4a..8795da2 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/ConvertibleTypes.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/ConvertibleTypes.java
@@ -5,7 +5,7 @@
interface YO1 extends YO<String> {}
interface YO2 extends YO<Integer> {}
-public class ConvertibleTest {
+class ConvertibleTest {
YO2 bar (YO1 s) {
return <error descr="Inconvertible types; cannot cast 'YO1' to 'YO2'">(YO2) s</error>;
@@ -19,7 +19,7 @@
class Implementation implements Interface1 {}
-public class InconvertibleTypesTest <E extends Interface2>
+class InconvertibleTypesTest <E extends Interface2>
{
E thing;
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/DisableCastingToNestedWildcards.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/DisableCastingToNestedWildcards.java
index 9c076ab..67bab6d 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/DisableCastingToNestedWildcards.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/DisableCastingToNestedWildcards.java
@@ -1,6 +1,6 @@
import java.util.List;
-public class Test {
+class Test {
interface P {
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/DisableWithinBoundsCheckForSuperWildcards.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/DisableWithinBoundsCheckForSuperWildcards.java
index 703c377..e3a95f9 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/DisableWithinBoundsCheckForSuperWildcards.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/DisableWithinBoundsCheckForSuperWildcards.java
@@ -1,6 +1,6 @@
import java.util.Comparator;
-public class Main2 {
+class Main2 {
static class OfRef<T> {
public OfRef() {
this((Comparator<? super T>) naturalOrder());
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/FlattenIntersectionType.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/FlattenIntersectionType.java
index 7fa937d..7a09829 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/FlattenIntersectionType.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/FlattenIntersectionType.java
@@ -5,7 +5,7 @@
E getEntity();
}
-public class MyTest {
+class MyTest {
<T extends BusinessEntity<T>> T getEntity(EntityId<T> defaultValue) {
return getEntityID(defaultValue).getEntity();
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA103760.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA103760.java
index e4d05f0..f34702d 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA103760.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA103760.java
@@ -1,7 +1,7 @@
import java.util.*;
-public class MyList extends ArrayList {}
+class MyList extends ArrayList {}
-public class Test {
+class Test {
public void test() {
List<? super List> list = new ArrayList<List>();
list.add(new MyList());
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA104100.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA104100.java
index e854f4a..bff4d5b 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA104100.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA104100.java
@@ -1,4 +1,4 @@
-public class TestGenericMap<A extends Comparable<A>, B extends Comparable<B>>
+class TestGenericMap<A extends Comparable<A>, B extends Comparable<B>>
{
public TestGenericMap<B, A> inverse()
{
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA104992.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA104992.java
index 5e46842..072ca3d 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA104992.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA104992.java
@@ -9,7 +9,7 @@
<T extends FooObject, I extends FooId<? extends T>> Collection<T> get(Collection<I> keys);
}
-public class Target {
+class Target {
void foo(Bar bar) {
final Set<FooId<?>> keys = null;
final Collection<FooObject> values = bar.get(keys);
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA105695.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA105695.java
index 8b1a962..28c1f47 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA105695.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA105695.java
@@ -1,6 +1,6 @@
import java.util.Map;
-public class Test {
+class Test {
void bar(Prop p) {
Map<? extends String, ? extends String> map = <error descr="Inconvertible types; cannot cast 'Prop' to 'java.util.Map<? extends java.lang.String,? extends java.lang.String>'">(Map<? extends String, ? extends String>)p</error>;
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA106964.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA106964.java
index 5745a60..d767e8c 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA106964.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA106964.java
@@ -1,12 +1,12 @@
import java.io.Serializable;
-public abstract class Test {
+abstract class Test {
abstract <T> T test(Class<T> cls);
abstract <T> T test(Serializable type);
private void call(){
- <error descr="Incompatible types. Found: 'java.lang.String[]', required: 'java.lang.String'">String s = test(String[].class);</error>
+ String s = test<error descr="'test(java.lang.Class<T>)' in 'Test' cannot be applied to '(java.lang.Class<java.lang.String[]>)'">(String[].class)</error>;
}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA107782.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA107782.java
index 4beb3ff..a2fcd01 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA107782.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA107782.java
@@ -1,4 +1,4 @@
-public class Test {
+class Test {
{
final MyResult hello = parseXML(new Parser());
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA109875.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA109875.java
index d799ba2..925ecd2 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA109875.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA109875.java
@@ -1,7 +1,7 @@
import java.util.Collections;
import java.util.Set;
-public class Test<Y> {
+class Test<Y> {
public static <K> Test<K> doTest(K k){
return null;
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA110568.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA110568.java
index ed9eedd..75ac142 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA110568.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA110568.java
@@ -1,6 +1,6 @@
import java.util.Collection;
-public class IncorrectError extends NarrowClass {
+class IncorrectError extends NarrowClass {
public Collection<String> bar() {
return super.doStuff();
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA113225.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA113225.java
index 7b4bbab..675a8be 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA113225.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA113225.java
@@ -1,6 +1,6 @@
import java.io.Serializable;
-public class Test {
+class Test {
public <T extends Serializable> void foo(byte[] data) {
T foo = (T) data;
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA18425.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA18425.java
index 7a496b2..e6d2e0c 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA18425.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA18425.java
@@ -1,4 +1,4 @@
-public abstract class BiFunction<A,B> {
+abstract class BiFunction<A,B> {
public abstract B apply(A a);
public abstract A unapply(B b);
public BiFunction<B,A> flip() {
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA20573.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA20573.java
index 22bd7a3..934320a 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA20573.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA20573.java
@@ -1,4 +1,4 @@
-public class GoodCodeIsRed {
+class GoodCodeIsRed {
public void test() {
FileIF file = new FileImpl();
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA21602.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA21602.java
index 217e1fd..647982a 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA21602.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA21602.java
@@ -1,7 +1,7 @@
import java.util.Collection;
import java.util.Collections;
-public class IDEABug {
+class IDEABug {
static class ClassA {
static <T> void sayHello(Collection<? extends T> msg) {}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA21602_7.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA21602_7.java
index 217e1fd..647982a 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA21602_7.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA21602_7.java
@@ -1,7 +1,7 @@
import java.util.Collection;
import java.util.Collections;
-public class IDEABug {
+class IDEABug {
static class ClassA {
static <T> void sayHello(Collection<? extends T> msg) {}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA22079.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA22079.java
index f3b25c9..f3edb1c 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA22079.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA22079.java
@@ -1,6 +1,6 @@
import java.util.List;
-public class SubClass extends BaseClass<String> {
+class SubClass extends BaseClass<String> {
public static void main(String[] args) {
new SubClass().method(null);
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57311.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57311.java
index 1ff6401..a566b5b 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57311.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57311.java
@@ -4,7 +4,7 @@
}
void bar(A<?> x){
- baz<error descr="'baz(A<A<? extends S>>)' in 'A' cannot be applied to '(A<A<capture<?>>>)'">(x.foo())</error>;
+ baz<error descr="'baz(A<A<?>>)' in 'A' cannot be applied to '(A<A<capture<?>>>)'">(x.foo())</error>;
}
<S> void baz(A<A<? extends S>> x){}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57340.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57340.java
index 7bbba7b..f5e4c92 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57340.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57340.java
@@ -9,8 +9,8 @@
void bar(B<?> b, A<?, ?> foo1) {
baz(b.foo());
A<?, ?> foo = b.foo();
- baz<error descr="'baz(A<K,K>)' in 'B' cannot be applied to '(A<capture<?>,capture<?>>)'">(foo)</error>;
- baz<error descr="'baz(A<K,K>)' in 'B' cannot be applied to '(A<capture<?>,capture<?>>)'">(foo1)</error>;
+ baz<error descr="'baz(A<capture<?>,capture<?>>)' in 'B' cannot be applied to '(A<capture<?>,capture<?>>)'">(foo)</error>;
+ baz<error descr="'baz(A<capture<?>,capture<?>>)' in 'B' cannot be applied to '(A<capture<?>,capture<?>>)'">(foo1)</error>;
}
<K> void baz(A<K, K> a) {
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57413.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57413.java
index 699a60d..7236a9b 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57413.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57413.java
@@ -2,6 +2,6 @@
<T extends A<T>> void foo(T x){}
void bar(A<?> x){
- foo<error descr="'foo(T)' in 'A' cannot be applied to '(A<capture<?>>)'">(x)</error>;
+ <error descr="Inferred type 'A<capture<?>>' for type parameter 'T' is not within its bound; should extend 'A<A<capture<?>>>'">foo(x)</error>;
}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57439.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57439.java
index d264fbb..765d20b 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57439.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57439.java
@@ -17,15 +17,15 @@
foo2(sb);
foo2(s);
- foo3<error descr="'foo3(A<A<? extends T>>)' in 'B' cannot be applied to '(B<capture<?>>)'">(b)</error>;
- foo3<error descr="'foo3(A<A<? extends T>>)' in 'B' cannot be applied to '(B<capture<? extends java.lang.String>>)'">(eb)</error>;
- foo3<error descr="'foo3(A<A<? extends T>>)' in 'B' cannot be applied to '(B<capture<? super java.lang.String>>)'">(sb)</error>;
- foo3<error descr="'foo3(A<A<? extends T>>)' in 'B' cannot be applied to '(B<java.lang.String>)'">(s)</error>;
+ foo3<error descr="'foo3(A<A<?>>)' in 'B' cannot be applied to '(B<capture<?>>)'">(b)</error>;
+ foo3<error descr="'foo3(A<A<?>>)' in 'B' cannot be applied to '(B<capture<? extends java.lang.String>>)'">(eb)</error>;
+ foo3<error descr="'foo3(A<A<?>>)' in 'B' cannot be applied to '(B<capture<? super java.lang.String>>)'">(sb)</error>;
+ foo3<error descr="'foo3(A<A<?>>)' in 'B' cannot be applied to '(B<java.lang.String>)'">(s)</error>;
- foo4<error descr="'foo4(A<A<? super T>>)' in 'B' cannot be applied to '(B<capture<?>>)'">(b)</error>;
- foo4<error descr="'foo4(A<A<? super T>>)' in 'B' cannot be applied to '(B<capture<? extends java.lang.String>>)'">(eb)</error>;
- foo4<error descr="'foo4(A<A<? super T>>)' in 'B' cannot be applied to '(B<capture<? super java.lang.String>>)'">(sb)</error>;
- foo4<error descr="'foo4(A<A<? super T>>)' in 'B' cannot be applied to '(B<java.lang.String>)'">(s)</error>;
+ foo4<error descr="'foo4(A<A<? super java.lang.Object>>)' in 'B' cannot be applied to '(B<capture<?>>)'">(b)</error>;
+ foo4<error descr="'foo4(A<A<? super java.lang.Object>>)' in 'B' cannot be applied to '(B<capture<? extends java.lang.String>>)'">(eb)</error>;
+ foo4<error descr="'foo4(A<A<? super java.lang.Object>>)' in 'B' cannot be applied to '(B<capture<? super java.lang.String>>)'">(sb)</error>;
+ foo4<error descr="'foo4(A<A<? super java.lang.Object>>)' in 'B' cannot be applied to '(B<java.lang.String>)'">(s)</error>;
foo5(b);
foo5(eb);
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57494.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57494.java
index 38bafca..c5248da 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57494.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57494.java
@@ -11,6 +11,6 @@
abstract <T> T baz(List<? super T> a);
void bar(List<?> x){
- String o = baz<error descr="'baz(java.util.List<? super T>)' in 'A1' cannot be applied to '(java.util.List<capture<?>>)'">(x)</error>;
+ String o = baz<error descr="'baz(java.util.List<? super java.lang.Object>)' in 'A1' cannot be applied to '(java.util.List<capture<?>>)'">(x)</error>;
}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57495.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57495.java
index 63f8c91..7598ea9 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57495.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57495.java
@@ -4,6 +4,6 @@
abstract <T> T baz(List<? super List<? super T>> a);
void bar(C<?> x){
- baz<error descr="'baz(java.util.List<? super java.util.List<? super T>>)' in 'A' cannot be applied to '(C<capture<?>>)'">(x)</error>;
+ baz<error descr="'baz(java.util.List<? super java.util.List<? super java.lang.Object>>)' in 'A' cannot be applied to '(C<capture<?>>)'">(x)</error>;
}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57533.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57533.java
index 5d1507f..d7ffd7e 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57533.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57533.java
@@ -1,6 +1,6 @@
class C<T extends C<? extends C<? extends T>>>{
void foo(C<?> x){
- bar<error descr="'bar(C<T>)' in 'C' cannot be applied to '(C<capture<?>>)'">(x)</error>;
+ <error descr="Inferred type 'capture<? extends C<? extends C<capture<?>>>>' for type parameter 'T' is not within its bound; should extend 'C<capture<? extends C<? extends C<capture<?>>>>>'">bar(x)</error>;
}
<T extends C<? extends T>> void bar(C<T> x){}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA63291.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA63291.java
index 077eb2d..7dbf956 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA63291.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA63291.java
@@ -1,7 +1,7 @@
import java.util.Comparator;
import java.util.Set;
-public class CastError {
+class CastError {
public void foo(Comparator<? super byte[]> comparator) throws Exception {
MyComparator comparator1 = (MyComparator) comparator;
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA67744.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA67744.java
index 8514e43..e71ede8 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA67744.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA67744.java
@@ -8,8 +8,8 @@
void bar(List<List<?>> x, List<List<List<?>>> y){
foo(x) [0] = "";
- foo1<error descr="'foo1(java.util.List<? extends java.util.List<T>>)' in 'B' cannot be applied to '(java.util.List<java.util.List<?>>)'">(x)</error> [0] = "";
- foo2<error descr="'foo2(java.util.List<java.util.List<? super java.util.List<T>>>)' in 'B' cannot be applied to '(java.util.List<java.util.List<java.util.List<?>>>)'">(y)</error> [0] = "";
+ foo1<error descr="'foo1(java.util.List<? extends java.util.List<java.lang.Object>>)' in 'B' cannot be applied to '(java.util.List<java.util.List<?>>)'">(x)</error> [0] = "";
+ foo2<error descr="'foo2(java.util.List<java.util.List<? super java.util.List<java.lang.Object>>>)' in 'B' cannot be applied to '(java.util.List<java.util.List<java.util.List<?>>>)'">(y)</error> [0] = "";
String s = foo0(x);
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA72912.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA72912.java
index c57bbb5..a04da78 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA72912.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA72912.java
@@ -1,6 +1,6 @@
import java.util.*;
-public class Test<T>
+class Test<T>
{
List<Collection<T>> getList ()
{
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA74899.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA74899.java
index 8723829..8931d87 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA74899.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA74899.java
@@ -1,7 +1,7 @@
import java.util.Collections;
import java.util.Map;
-public class IDEA74899 {
+class IDEA74899 {
void foo() {
Map<String, String> m = Collections.emptyMap();
if (<error descr="Operator '==' cannot be applied to 'java.util.Map<java.lang.String,java.lang.String>', 'java.util.Map<java.lang.Object,java.lang.Object>'">m == Collections.emptyMap()</error>) {
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA76283.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA76283.java
index a221d1b..3f065c4 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA76283.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA76283.java
@@ -1,5 +1,5 @@
import java.util.*;
-public class IDEA76283 {
+class IDEA76283 {
}
interface Parametrized<T extends Number> {
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA80386.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA80386.java
index 3587f4f..79f5879 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA80386.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA80386.java
@@ -1,6 +1,6 @@
import java.util.List;
-public class IDEA80386 {
+class IDEA80386 {
void foo(Class<List> listClass) {
<error descr="Incompatible types. Found: 'java.lang.Class<java.util.List>', required: 'java.lang.Class<? extends java.util.List<?>>'">Class<? extends List<?>> cls = listClass;</error>
Class < ?extends List > cls1 = listClass;
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA88895.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA88895.java
index cf59c1d..ccee8e0 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA88895.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA88895.java
@@ -1,6 +1,6 @@
import java.util.Iterator;
-public class WildcardGenericAndPrivateField {
+class WildcardGenericAndPrivateField {
private Object field;
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEADEV10459.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEADEV10459.java
index f3185c8..839a084 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEADEV10459.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEADEV10459.java
@@ -3,12 +3,12 @@
import java.util.List;
/** @noinspection UnusedDeclaration*/
-public class GenericsTest98 {
+class GenericsTest98 {
public static void main(String[] args) throws Exception{
List<Movable<? extends Serializable>> list = new ArrayList<Movable<? extends Serializable>> ();
Factory factory = Factory.newInstance();
// Doesn't compile, but Idea doesn't complain
- Mover<? extends Serializable> mover = factory.getNew<error descr="'getNew(java.util.List<? extends Movable<T>>)' in 'Factory' cannot be applied to '(java.util.List<Movable<? extends java.io.Serializable>>)'">(list)</error>;
+ Mover<? extends Serializable> mover = factory.getNew<error descr="'getNew(java.util.List<? extends Movable<java.io.Serializable>>)' in 'Factory' cannot be applied to '(java.util.List<Movable<? extends java.io.Serializable>>)'">(list)</error>;
}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEADEV23157.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEADEV23157.java
index eef2542..2cb99769 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEADEV23157.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEADEV23157.java
@@ -1,7 +1,7 @@
import java.util.List;
import java.util.Arrays;
-public class ZZZ {
+class ZZZ {
List<Class<?>> f(Class<?>[] exceptionTypes) {
List<Class<?>> nd = Arrays.asList(exceptionTypes);
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEADEV57343.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEADEV57343.java
index fb7e477..2c4a7fe 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEADEV57343.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEADEV57343.java
@@ -1,6 +1,6 @@
class D<T> {
void foo(D<?> x){
- bar<error descr="'bar(D<? extends T>, D<? super T>)' in 'D' cannot be applied to '(D<capture<?>>, D<capture<?>>)'">(x,x)</error>;
+ bar<error descr="'bar(D<?>, D<? super java.lang.Object>)' in 'D' cannot be applied to '(D<capture<?>>, D<capture<?>>)'">(x,x)</error>;
}
<T> void bar(D<? extends T> x, D<? super T> y){}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IllegalGenericTypeInInstanceof.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IllegalGenericTypeInInstanceof.java
index 52871e8..0ac6ec7 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IllegalGenericTypeInInstanceof.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IllegalGenericTypeInInstanceof.java
@@ -38,7 +38,7 @@
class Node {}
class XBreakpoint<SR>{}
-public class GenericInnerClass<E> {
+class GenericInnerClass<E> {
private void problem( Base base ) {
if ( base instanceof First) {}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/ImplementAnnotation.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/ImplementAnnotation.java
index bbe1e30..8650d6b 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/ImplementAnnotation.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/ImplementAnnotation.java
@@ -1,6 +1,6 @@
import java.lang.annotation.Annotation;
-public @interface Foo {
+@interface Foo {
String id();
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/InferenceWithBounds.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/InferenceWithBounds.java
index 626821e..22d8245 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/InferenceWithBounds.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/InferenceWithBounds.java
@@ -8,7 +8,7 @@
}
}
//////////////////////////////
-public abstract class ZZZ<K> {
+abstract class ZZZ<K> {
public abstract <T extends String> ZZZ<T> get();
}
class Z2<K> extends ZZZ<K> {
@@ -44,7 +44,7 @@
class B extends A {}
}
//////////////////////////
-public class BadCodeGreen<T, C extends Collection<? extends T>> {
+class BadCodeGreen<T, C extends Collection<? extends T>> {
public BadCodeGreen(C c, T t) {
c.add<error descr="'add(capture<? extends T>)' in 'java.util.Collection' cannot be applied to '(T)'">(t)</error>;
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/InferenceWithSuperBounds.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/InferenceWithSuperBounds.java
index d68f907..f9c1de3 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/InferenceWithSuperBounds.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/InferenceWithSuperBounds.java
@@ -1,4 +1,4 @@
-public class ExampleProblem {
+class ExampleProblem {
<T> void asserting(T t, Simple<T> l){
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/InferenceWithUpperBoundPromotion.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/InferenceWithUpperBoundPromotion.java
index 8b2aabe..0350839 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/InferenceWithUpperBoundPromotion.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/InferenceWithUpperBoundPromotion.java
@@ -1,5 +1,4 @@
-
-public class NestedGenericGoodCodeIsRed {
+class NestedGenericGoodCodeIsRed {
public void main( String[] args ) {
satisfiesAllOf(isPositive(), isEqualTo(10.9));
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/InnerClassRef.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/InnerClassRef.java
index f133292..2320bdc 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/InnerClassRef.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/InnerClassRef.java
@@ -1,7 +1,7 @@
import java.util.*;
import Node.Details;
-public class Node<E> {
+class Node<E> {
public class Details {
public E data;
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IntersectionTypes.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IntersectionTypes.java
index 48bb90c..8edfeda 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IntersectionTypes.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IntersectionTypes.java
@@ -167,7 +167,7 @@
}
///////////////
interface L {}
-public class MaximalType {
+class MaximalType {
public static <T> T getParentOfType(Class<? extends T>... classes) {
classes.hashCode();
return null;
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/OverrideWithMoreSpecificReturn.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/OverrideWithMoreSpecificReturn.java
index c2f6877..926a347 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/OverrideWithMoreSpecificReturn.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/OverrideWithMoreSpecificReturn.java
@@ -11,5 +11,5 @@
}
-public class ExampleSubClass extends ExampleSuperClass implements ExampleInterface {
+class ExampleSubClass extends ExampleSuperClass implements ExampleInterface {
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/PrivateInnerClassRef.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/PrivateInnerClassRef.java
index 5647b1d..e086c4f 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/PrivateInnerClassRef.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/PrivateInnerClassRef.java
@@ -1,6 +1,6 @@
import java.util.Comparator;
-public abstract class A implements <error descr="'A.B' has private access in 'A'">Comparator<A.B></error> {
+abstract class A implements <error descr="'A.B' has private access in 'A'">Comparator<A.B></error> {
private static class B {
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/Raw.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/Raw.java
index 25ef682..6b2b1de 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/Raw.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/Raw.java
@@ -159,7 +159,7 @@
/////////////// signatures in non-parameterized class are not erased
-public class C3 {
+class C3 {
public int get(Class<?> c) {
return 0;
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/RawAssignments.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/RawAssignments.java
index bd2af72..8553ab5 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/RawAssignments.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/RawAssignments.java
@@ -11,8 +11,8 @@
foo.getText(prop);
}
}
-public abstract class Hashtable<K,V> implements Map<K,V>, Cloneable {
+abstract class Hashtable<K,V> implements Map<K,V>, Cloneable {
}
-public abstract class Properties extends Hashtable<Object,Object> {
+abstract class Properties extends Hashtable<Object,Object> {
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/ReferenceTypeParams.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/ReferenceTypeParams.java
index 2d64d7c..f848f66 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/ReferenceTypeParams.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/ReferenceTypeParams.java
@@ -38,10 +38,10 @@
/////// calling super on generic bound class
-public class Generic<T> {
+class Generic<T> {
Generic(T t){}
}
-public class Bound extends Generic<String>{
+class Bound extends Generic<String>{
public Bound(String s) {
super(s);
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/SOE.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/SOE.java
index 85aeee7..d73b0e0 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/SOE.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/SOE.java
@@ -1,4 +1,4 @@
-public class SOE {
+class SOE {
}
abstract class VersionEntity<V extends Version<V, R>, R extends Ref<V, R>>
implements Version<V, R>{}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/SameErasure.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/SameErasure.java
index 9bb49b2..3240ea2 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/SameErasure.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/SameErasure.java
@@ -14,7 +14,7 @@
void f(Object o) {}
}
-public class Test1 {
+class Test1 {
<error descr="'bug(String)' clashes with 'bug(String)'; both methods have same erasure">public void bug(String s)</error> {
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/StaticImports.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/StaticImports.java
index 047391d..40a6f0d 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/StaticImports.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/StaticImports.java
@@ -1,9 +1,8 @@
-
import static java.util.Arrays.asList;
import static java.util.Arrays.sort;
<warning descr="Unused import statement">import static java.util.Arrays.binarySearch;</warning>
-public class StaticImports {
+class StaticImports {
{
asList(new Object[]{});
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/StaticOverride.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/StaticOverride.java
index d020968..96ed0f6 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/StaticOverride.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/StaticOverride.java
@@ -1,6 +1,6 @@
import java.util.*;
-public class MyClass implements Comparator<String> {
+class MyClass implements Comparator<String> {
<error descr="Static method 'compare(String, String)' in 'MyClass' cannot override instance method 'compare(T, T)' in 'java.util.Comparator'">public static int compare(String a, String b)</error> {
return 42;
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/TypeInference.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/TypeInference.java
index 0156c75..eac9295 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/TypeInference.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/TypeInference.java
@@ -78,7 +78,7 @@
//end of IDEADEV-6738
///////////////////////////////////
-public class Err {
+class Err {
void f() {
Decl[] extensions = getExtensions(Decl.EXTENSION_POINT_NAME);
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/TypeParameterBoundVisibility.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/TypeParameterBoundVisibility.java
index 68c2337..33884ed 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/TypeParameterBoundVisibility.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/TypeParameterBoundVisibility.java
@@ -16,7 +16,7 @@
}
}
-public class Bug {
+class Bug {
// Idea incorrectly analyses this code with JDK 7
public <T extends Bug> void doit(T other) {
// Oops, was legal with JDK 6, no longer legal with JDK 7
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/TypeParameterBoundsList.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/TypeParameterBoundsList.java
index 506add0..4afc046 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/TypeParameterBoundsList.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/TypeParameterBoundsList.java
@@ -20,7 +20,7 @@
}
////////////////
-public class TypeParameters {
+class TypeParameters {
class X {}
static <T extends X> void f(Class<T> t){}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/TypeWithinItsWildcardBound.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/TypeWithinItsWildcardBound.java
index 47ecb3b..a7ada78 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/TypeWithinItsWildcardBound.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/TypeWithinItsWildcardBound.java
@@ -1,4 +1,4 @@
-public class WithingBounds {
+class WithingBounds {
interface I {
}
interface I1 {
@@ -311,7 +311,7 @@
A<A<<error descr="Type parameter 'A' is not within its bound; should extend 'A<A>'">A</error>>> a3;
A<? extends A> a4;
- A<<error descr="Type parameter '? super A' is not within its bound; should extend 'A<? super A>'">? super A</error>> a5;
+ A<<error descr="Type parameter '? super A' is not within its bound; should extend 'A<A<T>>'">? super A</error>> a5;
A<<error descr="Type parameter 'A[]' is not within its bound; should extend 'A<A[]>'">A[]</error>> a7;
}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/Variance.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/Variance.java
index 67f89f9..7556292 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/Variance.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/Variance.java
@@ -9,7 +9,7 @@
* Time: 8:08:44 PM
* To change this template use File | Settings | File Templates.
*/
-public class VarianceTesting {
+class VarianceTesting {
void method(List<? extends VarianceTesting> l) {
// l.add(new VarianceTesting());
l.add(null);
@@ -87,7 +87,7 @@
}
void foo (Class<? extends Emum<CaptureTest>> clazz) {
- Emum.valueOf<error descr="'valueOf(java.lang.Class<T>, java.lang.String)' in 'CaptureTest.Emum' cannot be applied to '(java.lang.Class<capture<? extends CaptureTest.Emum<CaptureTest>>>, java.lang.String)'">(clazz, "CCC")</error>;
+ <error descr="Inferred type 'capture<? extends CaptureTest.Emum<CaptureTest>>' for type parameter 'T' is not within its bound; should extend 'CaptureTest.Emum<capture<? extends CaptureTest.Emum<CaptureTest>>>'">Emum.valueOf(clazz, "CCC")</error>;
}
}
@@ -152,7 +152,7 @@
}
void bar(List<? extends S2> k) {
- f<error descr="'f(java.util.List<T>, java.util.List<T>)' in 'S2' cannot be applied to '(java.util.List<capture<? extends S2>>, java.util.List<capture<? extends S2>>)'">(k, k)</error>;
+ f<error descr="'f(java.util.List<capture<? extends S2>>, java.util.List<capture<? extends S2>>)' in 'S2' cannot be applied to '(java.util.List<capture<? extends S2>>, java.util.List<capture<? extends S2>>)'">(k, k)</error>;
}
}
@@ -162,7 +162,7 @@
}
void bar(Map<? extends S3, ? extends S3> k) {
- f<error descr="'f(java.util.Map<T,T>)' in 'S3' cannot be applied to '(java.util.Map<capture<? extends S3>,capture<? extends S3>>)'">(k)</error>;
+ f<error descr="'f(java.util.Map<capture<? extends S3>,capture<? extends S3>>)' in 'S3' cannot be applied to '(java.util.Map<capture<? extends S3>,capture<? extends S3>>)'">(k)</error>;
}
}
@@ -182,7 +182,7 @@
multiList.add(intHolder);
multiList.add(doubleHolder);
- swapFirstTwoValues<error descr="'swapFirstTwoValues(java.util.List<TypeBug.ValueHolder<T>>)' in 'TypeBug' cannot be applied to '(java.util.List<TypeBug.ValueHolder<?>>)'">(multiList)</error>; //need to be highlighted
+ swapFirstTwoValues<error descr="'swapFirstTwoValues(java.util.List<TypeBug.ValueHolder<java.lang.Object>>)' in 'TypeBug' cannot be applied to '(java.util.List<TypeBug.ValueHolder<?>>)'">(multiList)</error>; //need to be highlighted
// this line causes a ClassCastException when checked.
Integer value = intHolder.value;
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/WideningCastToTypeParam.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/WideningCastToTypeParam.java
index 7615d72..5da569e 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/WideningCastToTypeParam.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/WideningCastToTypeParam.java
@@ -9,7 +9,7 @@
class DoubleConverter extends AbstractNumberConverter<Double> {
}
-public class Test {
+class Test {
public static <C> IConverter<C> getConverter(Class<C> type) {
return (IConverter<C>)new DoubleConverter() {
};
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/WildcardCastConversion.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/WildcardCastConversion.java
index f610bac..fb978ed 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/WildcardCastConversion.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/WildcardCastConversion.java
@@ -1,4 +1,4 @@
-public class Test {
+class Test {
interface A {}
interface B {}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/WildcardTypes.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/WildcardTypes.java
index d55e641..8686aef 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/WildcardTypes.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/WildcardTypes.java
@@ -130,7 +130,7 @@
//end of IDEADEV-5816
interface I33 {}
-public class Q<T extends I33> {
+class Q<T extends I33> {
T t;
<V extends I33> List<V> foo(Q<V> v) {
v.hashCode();
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/WildcardsBoundsIntersection.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/WildcardsBoundsIntersection.java
index 3fc74e5..cf8ad1c 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/WildcardsBoundsIntersection.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/WildcardsBoundsIntersection.java
@@ -10,6 +10,6 @@
class Main {
public static void main(NodeProperty<NumberExpression, Integer> nval, Node<? extends NodeType> expr) {
- int val = expr.get<error descr="'get(NodeProperty<? super capture<? extends NodeType>,ValueT>)' in 'Node' cannot be applied to '(NodeProperty<NumberExpression,java.lang.Integer>)'">(nval)</error>;
+ int val = expr.get<error descr="'get(NodeProperty<? super capture<? extends NodeType>,java.lang.Object>)' in 'Node' cannot be applied to '(NodeProperty<NumberExpression,java.lang.Integer>)'">(nval)</error>;
}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/WildcardsOnRawTypes.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/WildcardsOnRawTypes.java
index ed1aa05..7017bd4 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/WildcardsOnRawTypes.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/WildcardsOnRawTypes.java
@@ -1,6 +1,6 @@
import java.util.List;
-public class Main<T> {
+class Main<T> {
Object get(List<DiagramNode<T>> nodes, A a) {
return null;
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/highlightSeverity/ErrorLikeUnusedSymbol.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/highlightSeverity/ErrorLikeUnusedSymbol.java
index 80639b6..8e16068 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/highlightSeverity/ErrorLikeUnusedSymbol.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/highlightSeverity/ErrorLikeUnusedSymbol.java
@@ -1,4 +1,4 @@
-public class Test {
+class Test {
public static void main(String[] args) {
int <error descr="Variable 'k' is never used">k</error> = 0;
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/javaDoc/JavadocPeriod1.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/javaDoc/JavadocPeriod1.java
index 96a863e..334dc66 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/javaDoc/JavadocPeriod1.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/javaDoc/JavadocPeriod1.java
@@ -1,6 +1,6 @@
/**
* Do smth @linkplain #link}.
*/
-public class Test {
+class Test {
private void link(){}
}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/javaDoc/JavadocPeriod2.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/javaDoc/JavadocPeriod2.java
index 731e508..58f7010 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/javaDoc/JavadocPeriod2.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/javaDoc/JavadocPeriod2.java
@@ -2,6 +2,6 @@
* Do smth
* @author me.
*/
-public class Test {
+class Test {
}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/javaDoc/UnknownInlineTag.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/javaDoc/UnknownInlineTag.java
index 4d62cd0..2965565 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/javaDoc/UnknownInlineTag.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/javaDoc/UnknownInlineTag.java
@@ -1,7 +1,7 @@
/**
* {<warning>@linked</warning>}
*/
-public class Foo {
+class Foo {
/**
* @param i some param {<warning>@vaaalue</warning> #field}
*/
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/javaDoc/UnknownTags.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/javaDoc/UnknownTags.java
index 3c2e474..4c91f3c 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/javaDoc/UnknownTags.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/javaDoc/UnknownTags.java
@@ -1,7 +1,7 @@
/**
* <warning>@foo</warning>
*/
-public class Foo {
+class Foo {
/**
* <warning>@foo</warning>
*/
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/javaDoc/Vararg.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/javaDoc/Vararg.java
index 5192745..760ea72 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/javaDoc/Vararg.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/javaDoc/Vararg.java
@@ -1,4 +1,4 @@
-public class Test {
+class Test {
/**
* @see Test#test(String, int...)
* @see Test#<error descr="Cannot resolve symbol 'test(String, long...)'">test</error>(String, long...)
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/constraints/EqualityUnboundWildcard.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/constraints/EqualityUnboundWildcard.java
index 650725f..f018273 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/constraints/EqualityUnboundWildcard.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/constraints/EqualityUnboundWildcard.java
@@ -1,4 +1,4 @@
-public class SampleExtendsWildcard {
+class SampleExtendsWildcard {
public void highlightsTheBug(Stream<String> stream) {
stream.flatMap((Block<?> sink, String element) -> {});
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/constraints/LambdaGroundTest.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/constraints/LambdaGroundTest.java
index d5b0dad..d85524e 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/constraints/LambdaGroundTest.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/constraints/LambdaGroundTest.java
@@ -1,6 +1,6 @@
import java.util.List;
-public class Sample {
+class Sample {
interface Fun<A extends List <String>, B> {
B f(A a);
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/constraints/PrimitiveTypesCompatibility.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/constraints/PrimitiveTypesCompatibility.java
index 25d3482..12a2ecc 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/constraints/PrimitiveTypesCompatibility.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/constraints/PrimitiveTypesCompatibility.java
@@ -1,4 +1,4 @@
-public class Sample {
+class Sample {
static <T> T foo(T t) { return null; }
static {
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/constraints/SubtypingExtendsSuper.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/constraints/SubtypingExtendsSuper.java
index 1ced38b..4c0806f 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/constraints/SubtypingExtendsSuper.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/constraints/SubtypingExtendsSuper.java
@@ -2,7 +2,7 @@
import java.util.Collection;
import java.util.List;
-public class Sample {
+class Sample {
static List<String> getList(Function<Object, String> function, ArrayList<? super String> objects) {
return transform(objects, new ArrayList<String>(), function);
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/constraints/TypeCompatibilityUncheckedConversion.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/constraints/TypeCompatibilityUncheckedConversion.java
index e4fa851..376d604 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/constraints/TypeCompatibilityUncheckedConversion.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/constraints/TypeCompatibilityUncheckedConversion.java
@@ -1,4 +1,4 @@
-public class Sample {
+class Sample {
interface G<A> {}
interface G1 extends G {}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/constraints/TypeCompatibilityUncheckedConversionReturnConstraints.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/constraints/TypeCompatibilityUncheckedConversionReturnConstraints.java
index acbc592..564e2f1 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/constraints/TypeCompatibilityUncheckedConversionReturnConstraints.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/constraints/TypeCompatibilityUncheckedConversionReturnConstraints.java
@@ -1,4 +1,4 @@
-public class Sample {
+class Sample {
interface G<A> {}
interface G1 extends G {}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/AfterAbstractPipeline.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/AfterAbstractPipeline.java
index 747b833..5c05bf5 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/AfterAbstractPipeline.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/AfterAbstractPipeline.java
@@ -1,4 +1,4 @@
-public class Test<E_OUT> {
+class Test<E_OUT> {
final <P_IN_WRAP_SINK> Sink<P_IN_WRAP_SINK> wrapSink(Sink<E_OUT> sink) {
return null;
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/ArrayPassedToVarargsMethod.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/ArrayPassedToVarargsMethod.java
new file mode 100644
index 0000000..cfde624
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/ArrayPassedToVarargsMethod.java
@@ -0,0 +1,10 @@
+import java.util.Set;
+
+class FooBar {
+ Set<String> strings = null;
+ {
+ bar(strings.toArray(new String[strings.size()]));
+ }
+
+ void bar(String... a){}
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/ClsCapturedReturnTypes.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/ClsCapturedReturnTypes.java
new file mode 100644
index 0000000..e0cc0f8
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/ClsCapturedReturnTypes.java
@@ -0,0 +1,21 @@
+import java.util.Map;
+import java.util.stream.Collector;
+
+
+class Bug {
+
+
+ {
+ Collector<String, ?, Map<String, Long>> stringTreeMapCollector = groupingBy(counting());
+ }
+
+ public static <T, D, M extends Map<String, D>> Collector<T, ?, M> groupingBy(Collector<? super T, ?, Long> downstream) {
+ return null;
+ }
+
+ public static <Tc> Collector<Tc, ?, Long> counting() {
+ return null;
+ }
+
+
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/DeepCallsChain.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/DeepCallsChain.java
new file mode 100644
index 0000000..566ed14
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/DeepCallsChain.java
@@ -0,0 +1,41 @@
+import java.util.Map;
+
+
+abstract class Test<Tt> {
+
+ public Map<String, Long> getNumberOfInstancesForEachWord() {
+ return collect(groupingBy(counting()));
+ }
+
+ abstract <R> R collect(Collector<? super Tt, R> collector);
+ abstract <Tg, M> Collector<Tg, M> groupingBy(Collector<? super Tg, Long> downstream);
+ abstract <Tc> Collector<Tc, Long> counting();
+
+ interface Collector<T, R> {}
+}
+
+abstract class Test1<Tt> {
+
+ public Map<String, Long> getNumberOfInstancesForEachWord() {
+ return collect(groupingBy(counting()));
+ }
+
+ abstract <R> R collect(Collector<Tt, R> collector);
+ abstract <Tg, M> Collector<Tg, M> groupingBy(Collector<Tg, Long> downstream);
+ abstract <Tc> Collector<Tc, Long> counting();
+
+ interface Collector<T, R> {}
+}
+
+abstract class Test2<Tt> {
+
+ public Map<String, Long> getNumberOfInstancesForEachWord() {
+ return collect(groupingBy(counting()));
+ }
+
+ abstract <R> R collect(Collector<Tt, R> collector);
+ abstract <Tg, M> Collector<Tg, M> groupingBy(Collector<? extends Tg, Long> downstream);
+ abstract <Tc> Collector<Tc, Long> counting();
+
+ interface Collector<T, R> {}
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/ErasedByReturnConstraint.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/ErasedByReturnConstraint.java
index 47940ac..c3a52b5 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/ErasedByReturnConstraint.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/ErasedByReturnConstraint.java
@@ -1,6 +1,6 @@
import java.util.List;
-public class Bug
+class Bug
{
void foo(List<I> futures, I1<Object> callable){
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/GrandParentTypeParams.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/GrandParentTypeParams.java
index 49c3e6b..fdd10fd 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/GrandParentTypeParams.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/GrandParentTypeParams.java
@@ -1,11 +1,10 @@
-
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collector;
import java.util.stream.Stream;
import java.util.*;
-public class X1 {
+class X1 {
void test(Stream<Integer> stream) {
Function<List<Integer>, List<Integer>> unmodifiableList = Collections::unmodifiableList;
stream.collect(collectingAndThen(toList(), unmodifiableList)).remove(0);
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/IDEA104429.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/IDEA104429.java
index bf73abc..145139b 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/IDEA104429.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/IDEA104429.java
@@ -14,7 +14,7 @@
}
-public class Issue1 {
+class Issue1 {
public static void main(String[] args) {
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/IDEA121055.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/IDEA121055.java
new file mode 100644
index 0000000..83b3827
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/IDEA121055.java
@@ -0,0 +1,12 @@
+import java.util.List;
+import java.util.stream.Stream;
+
+import static java.util.stream.Collectors.toList;
+
+class TypeDetectionTest {
+
+ public static void main(String[] args) {
+ List<Number> numbers = Stream.of(1, 2).collect(toList());
+ }
+
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/IDEA98866.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/IDEA98866.java
index 87e8eeb..3524fe9 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/IDEA98866.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/IDEA98866.java
@@ -1,5 +1,5 @@
import java.util.*;
-public class TestInfer
+class TestInfer
{
static <V, T extends V> List<V> singleton(T item)
{
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/InferFromTypeArgs.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/InferFromTypeArgs.java
index 7ee3314..b79446f 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/InferFromTypeArgs.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/InferFromTypeArgs.java
@@ -1,5 +1,5 @@
import java.util.*;
-public class DiamondTest {
+class DiamondTest {
public <U> void foo(ArrayList<U> p) {}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/InferenceFromTypeParamsBounds.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/InferenceFromTypeParamsBounds.java
index 073216a..35e9350 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/InferenceFromTypeParamsBounds.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/InferenceFromTypeParamsBounds.java
@@ -1,6 +1,6 @@
import java.util.Map;
-public class IDEA10166 {
+class IDEA10166 {
interface BiConsumer<T, U> {
void accept(T t, U u);
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/MostSpecificVarargsCase.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/MostSpecificVarargsCase.java
new file mode 100644
index 0000000..8bb2f15
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/MostSpecificVarargsCase.java
@@ -0,0 +1,17 @@
+import java.util.*;
+
+class Specificss {
+ {
+ Set<String> JAR_EXTENSIONS = newTroveSet(new ArrayList<String>(), "jar", "zip", "swc", "ane");
+ }
+
+
+ public static <T> HashSet<T> newTroveSet(T... elements) {
+ return newTroveSet(Arrays.asList(elements));
+ }
+
+ public static <T> HashSet<T> newTroveSet(List<T> strategy, T... elements) {
+ return new HashSet<T>();
+ }
+
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/NestedCalls.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/NestedCalls.java
index 0c91d21..1359f9e 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/NestedCalls.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/NestedCalls.java
@@ -1,5 +1,5 @@
import java.util.*;
-public class Main {
+class Main {
public static <T> T foo() {return null;}
public static <B> List<B> bar(B b) {return null;}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/NestedCalls1.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/NestedCalls1.java
new file mode 100644
index 0000000..4a94295
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/NestedCalls1.java
@@ -0,0 +1,14 @@
+class Main {
+
+ {
+ foo(bar(String.class));
+ }
+
+ <T extends String> T bar(Class<T> cf) {
+ return null;
+ }
+
+ <K extends String> K foo(K vo) {
+ return null;
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/StaticInheritorsAmbiguity.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/StaticInheritorsAmbiguity.java
new file mode 100644
index 0000000..36a8ea8
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/StaticInheritorsAmbiguity.java
@@ -0,0 +1,24 @@
+
+import java.util.Collection;
+import java.util.HashSet;
+
+
+class A {
+ Collection<String> thrownInTryStatement = null;
+ final Collection<String> thrownTypes = ContainerUtil.newHashSet( thrownInTryStatement);
+}
+
+
+class ContainerUtil extends ContainerUtilRt{
+ public static <T> HashSet<T> newHashSet(Iterable<? extends T> iterable) {
+ return null;
+ }
+}
+
+
+class ContainerUtilRt {
+ public static <T> HashSet<T> newHashSet(Iterable<? extends T> iterable) {
+ return null;
+ }
+
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/TargetTypeByAnonymousClass.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/TargetTypeByAnonymousClass.java
new file mode 100644
index 0000000..4293643
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/TargetTypeByAnonymousClass.java
@@ -0,0 +1,16 @@
+import java.util.function.Function;
+
+class TypeDetectionTest {
+
+ public static void main(String[] args) {
+ new Table<String>(Function.identity()) {{}};
+ new Table<String>(Function.identity());
+ new Table<String>(x -> x) {{}};
+
+ }
+
+ public static class Table<T> {
+ public Table(Function<T, T> f) {
+ }
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/TargetTypeByOverloadedMethod.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/TargetTypeByOverloadedMethod.java
index 17d279a..1e5e375 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/TargetTypeByOverloadedMethod.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/TargetTypeByOverloadedMethod.java
@@ -1,7 +1,7 @@
import java.util.List;
import java.util.Set;
-public class Sample {
+class Sample {
interface L<T> {
List<T> foo();
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/TargetTypeByOverloadedMethod2.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/TargetTypeByOverloadedMethod2.java
index 139fcb4..74c7eee 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/TargetTypeByOverloadedMethod2.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/TargetTypeByOverloadedMethod2.java
@@ -2,7 +2,7 @@
import static java.lang.System.out;
-public final class LambdaMain {
+final class LambdaMain {
public static void main(final String... args) {
for (final A<String, X> a : Arrays.<A<String, X>>asList(new A<String, X>() {
@Override
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AcceptRawSubstForLambda.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AcceptRawSubstForLambda.java
index 9f7573f..772152f 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AcceptRawSubstForLambda.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AcceptRawSubstForLambda.java
@@ -1,4 +1,4 @@
-public class CyclicReferenceTest {
+class CyclicReferenceTest {
void test(Match<String, Integer> match) {
Match<String, Integer> matcher = match.or(s -> Optional.empty(), i -> 2);
Match<String, Integer> matcher1 = match.or(s -> s.startsWith("_") ? Optional.of(1) : Optional.empty(), i -> 2);
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguitySpecificReturn.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguitySpecificReturn.java
index 5b9d5d7..5ecd4f5 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguitySpecificReturn.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguitySpecificReturn.java
@@ -1,8 +1,8 @@
class IntStream {
private void foo(IntStream s) {
- s.map<error descr="Ambiguous method call: both 'IntStream.map(IntUnaryOperator)' and 'IntStream.map(ObjIntFunction<Integer>)' match">(i -> 1 << i)</error>;
+ s.map(i -> <error descr="Operator '<<' cannot be applied to 'int', '<lambda parameter>'">1 << i</error>);
s.map<error descr="Ambiguous method call: both 'IntStream.map(IntUnaryOperator)' and 'IntStream.map(ObjIntFunction<Integer>)' match">(i -> 1)</error>;
- s.map<error descr="Ambiguous method call: both 'IntStream.map(IntUnaryOperator)' and 'IntStream.map(ObjIntFunction<Integer>)' match">(i -> i)</error>;
+ s.map<error descr="Ambiguous method call: both 'IntStream.map(IntUnaryOperator)' and 'IntStream.map(ObjIntFunction<T>)' match">(i -> i)</error>;
}
public static void main(String[] args) {
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ConditionalInferenceFromOppositePart.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ConditionalInferenceFromOppositePart.java
index be6dd45..1e23b1a 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ConditionalInferenceFromOppositePart.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ConditionalInferenceFromOppositePart.java
@@ -1,4 +1,4 @@
-public class Main {
+class Main {
interface Function<T, U> {
T fun(U t);
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/FunctionalInterfaceAnnotation2.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/FunctionalInterfaceAnnotation2.java
new file mode 100644
index 0000000..336da59
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/FunctionalInterfaceAnnotation2.java
@@ -0,0 +1,3 @@
+<error descr="Test is not a functional interface">@FunctionalInterface</error>
+@interface Test {
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/InferFromTypeArgs.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/InferFromTypeArgs.java
index d7f797a..842b86a 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/InferFromTypeArgs.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/InferFromTypeArgs.java
@@ -1,5 +1,5 @@
import java.util.*;
-public class BugReportLambdaSquiggles<T> {
+class BugReportLambdaSquiggles<T> {
private T t;
public <V> List<V> flatMap(Mapper<T, List<V>> mapper) {
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/InferenceFromSecondLambda.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/InferenceFromSecondLambda.java
index 03c05c0..837e420 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/InferenceFromSecondLambda.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/InferenceFromSecondLambda.java
@@ -1,5 +1,5 @@
import java.util.*;
-public class Main1 {
+class Main1 {
interface I<T> {
List<T> f();
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/LambdaContext.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/LambdaContext.java
index 4fd368c..a5efd12 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/LambdaContext.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/LambdaContext.java
@@ -23,5 +23,6 @@
class Test1 {
void bar(boolean b){
II ik = b ? (s)-> true : (s)->false;
+ II ik1 = (II)(b ? <error descr="Lambda expression not expected here">(s)-> true</error> : <error descr="Lambda expression not expected here">(s)->false</error>);
}
}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/RawWhenNoParams.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/RawWhenNoParams.java
index 8e6d04d..7e2f4e8 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/RawWhenNoParams.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/RawWhenNoParams.java
@@ -1,4 +1,4 @@
-public class FooBar {
+class FooBar {
private static final class Bar2 {
private Bar2() {
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ReturnTypeCompatibility.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ReturnTypeCompatibility.java
index ab62ca4..0f7aa70 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ReturnTypeCompatibility.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ReturnTypeCompatibility.java
@@ -25,7 +25,7 @@
}
public static void main(String[] args) {
- call<error descr="Ambiguous method call: both 'ReturnTypeIncompatibility.call(I1<Integer>)' and 'ReturnTypeIncompatibility.call(I2<Integer>)' match">(i-> {return i;})</error>;
+ call<error descr="Ambiguous method call: both 'ReturnTypeIncompatibility.call(I1<P>)' and 'ReturnTypeIncompatibility.call(I2<P>)' match">(i-> {return i;})</error>;
}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ReturnValue.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ReturnValue.java
index b0302f0..69e2b78 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ReturnValue.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ReturnValue.java
@@ -36,7 +36,7 @@
if (s.equals("1")) {
return Option.option(1);
} else {
- return Option.option<error descr="'option(java.lang.Integer)' in 'Test1.Option' cannot be applied to '(java.lang.String)'">("2")</error>;
+ return Option.option<error descr="'option(T)' in 'Test1.Option' cannot be applied to '(java.lang.String)'">("2")</error>;
}
};
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/TypeArgsConsistency.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/TypeArgsConsistency.java
index 911f35c..0c79d84 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/TypeArgsConsistency.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/TypeArgsConsistency.java
@@ -12,7 +12,7 @@
I<Integer> i1 = (i, j) -> i + j;
foo((i, j) -> i + j);
I<Integer> i2 = bar((i, j) -> i + j);
- I<Integer> i3 = bar(<error descr="Incompatible return type String in lambda expression">(i, j) -> "" + i + j</error>);
+ I<Integer> i3 = bar(<error descr="Cyclic inference">(i, j) -> "" + i + j</error>);
}
}
@@ -43,7 +43,7 @@
I<Integer> i1 = bar(x -> x);
I1<Integer> i2 = bar1(x -> 1);
I2<String> aI2 = bar2(x -> "");
- I2<Integer> aI28 = bar2( <error descr="Incompatible return type String in lambda expression">x-> ""</error>);
+ I2<Integer> aI28 = bar2( <error descr="Cyclic inference">x-> ""</error>);
I2<Integer> i3 = bar2(x -> x);
I2<Integer> i4 = bar2(x -> foooI());
System.out.println(i4.foo(2));
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/CyclicSubstitutor.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/CyclicSubstitutor.java
index 80d0e5e..9bced30 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/CyclicSubstitutor.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/CyclicSubstitutor.java
@@ -1,4 +1,4 @@
-public interface Iso<T, R> {
+interface Iso<T, R> {
T deply(R r);
default Iso<R, T> inverse() {
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/FinalStaticDefaultMethods.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/FinalStaticDefaultMethods.java
new file mode 100644
index 0000000..69fc7ec
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/FinalStaticDefaultMethods.java
@@ -0,0 +1,4 @@
+interface A {
+ final <error descr="Illegal combination of modifiers: 'static' and 'final'">static</error> void foo() {}
+ final <error descr="Illegal combination of modifiers: 'default' and 'final'">default</error> void foo() {}
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/StaticMethodsInFunctionalInterface.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/StaticMethodsInFunctionalInterface.java
index 702191f..35aa3cb 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/StaticMethodsInFunctionalInterface.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/interfaceMethods/StaticMethodsInFunctionalInterface.java
@@ -1,4 +1,4 @@
-public interface Nat {
+interface Nat {
interface Nil extends Nat {}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/Ambiguity.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/Ambiguity.java
index 3fe1395..c7f2194 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/Ambiguity.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/Ambiguity.java
@@ -154,7 +154,7 @@
}
}
-public class MyTest6 {
+class MyTest6 {
interface I {
void _(Integer i);
}
@@ -169,7 +169,7 @@
}
}
-public class MyTest7 {
+class MyTest7 {
interface I {
void _(Number i);
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/CapturedWildcards.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/CapturedWildcards.java
index 269b075..2fd41e7 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/CapturedWildcards.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/CapturedWildcards.java
@@ -1,4 +1,4 @@
-public class Main {
+class Main {
public static <T> void make(final Consumer<? super T> consumer) {
Sink<T> accept = (Sink<T>) consumer::accept;
Consumer<T> accept1 = (Consumer<T>)consumer::accept;
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ConstructorAssignability.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ConstructorAssignability.java
index cad262f..70c7840 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ConstructorAssignability.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ConstructorAssignability.java
@@ -13,7 +13,7 @@
public void foo() {
reduce(Moo::new);
- reduce(<error descr="Cyclic inference">AMoo::new</error>);
+ <error descr="Inferred type 'Foo<R>.AMoo' for type parameter 'S' is not within its bound; should implement 'Foo.ASink<java.lang.Object,Foo<R>.AMoo>'">reduce(AMoo::new)</error>;
reduce(AAMoo::new);
reduce(AAAMoo::new);
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ConstructorNonAbstractAbstractExpected.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ConstructorNonAbstractAbstractExpected.java
index 86d8bea..ac4c7f6 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ConstructorNonAbstractAbstractExpected.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ConstructorNonAbstractAbstractExpected.java
@@ -1,7 +1,7 @@
import java.util.ArrayList;
import java.util.List;
-public class IDEA99970 {
+class IDEA99970 {
public static <T, C> Collector<T, C> toCollection(Supplier<C> collectionFactory) {
return null;
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ExactReferencesToArrayCreation.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ExactReferencesToArrayCreation.java
index 9a57ad7..f155c9e 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ExactReferencesToArrayCreation.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ExactReferencesToArrayCreation.java
@@ -1,4 +1,4 @@
-public class InspectorTest {
+class InspectorTest {
interface Stream<T> {
<A> A[] toArray(IntFunction<A[]> generator);
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/FunctionalInterfaceMethodIsGeneric.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/FunctionalInterfaceMethodIsGeneric.java
index ed751ea..03c72c7 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/FunctionalInterfaceMethodIsGeneric.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/FunctionalInterfaceMethodIsGeneric.java
@@ -1,4 +1,4 @@
-public class Test {
+class Test {
interface I {
<T> String m();
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific/VoidConflict.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific/VoidConflict.java
new file mode 100644
index 0000000..64e942c
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific/VoidConflict.java
@@ -0,0 +1,46 @@
+class Test {
+
+ interface I { void i_bar(); }
+ interface I1<T> { T i1_bar(); }
+
+ private void m(I i) {System.out.println(i);}
+ private void <warning descr="Private method 'm(Test.I1<java.lang.String>)' is never used">m</warning>(I1<String> i1) {System.out.println(i1);}
+
+ void test() {
+ m(Test::foo);
+ }
+
+ public static int foo() {
+ return 0;
+ }
+}
+
+class Test1 {
+
+ interface I { void i_bar(); }
+ interface I1<T> { T i1_bar(); }
+
+ void m(I i) { System.out.println(i);}
+ void m(I1<String> i1) { System.out.println(i1);}
+
+ void test() {
+ m(Test1::foo);
+ }
+
+ public static String foo() {return "";}
+}
+
+class Test2 {
+
+ interface I { void i_bar(); }
+ interface I1<T> { T i1_bar(); }
+
+ void m(I i) { System.out.println(i);}
+ void m(I1<String> i1) { System.out.println(i1);}
+
+ void test() {
+ m(Test2::foo);
+ }
+
+ public static void foo() {}
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/AdditionalConstraintSubstitution.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/AdditionalConstraintSubstitution.java
index 74240f1..0a958c7 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/AdditionalConstraintSubstitution.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/AdditionalConstraintSubstitution.java
@@ -4,7 +4,7 @@
import java.util.stream.Collector;
import java.util.stream.Stream;
-public class Bug
+class Bug
{
void foo(Stream<Bug> words){
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/AdditionalConstraintsReduceOrder.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/AdditionalConstraintsReduceOrder.java
index 7c76e64..fcdf860 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/AdditionalConstraintsReduceOrder.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/AdditionalConstraintsReduceOrder.java
@@ -2,7 +2,7 @@
import java.util.function.BinaryOperator;
import java.util.function.Function;
-public class FooBar<K> {
+class FooBar<K> {
void foo(List<K > s) {}
<T, U> List<T> bar(BinaryOperator<U> kk, Function<T, U> f){
return null;
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/FunctionalInterfacesCalculation.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/FunctionalInterfacesCalculation.java
new file mode 100644
index 0000000..5e2981f
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/FunctionalInterfacesCalculation.java
@@ -0,0 +1,26 @@
+
+import java.util.Optional;
+import java.util.function.Function;
+
+import static java.util.Optional.of;
+
+class MatchTest {
+
+ {
+ Match<String, Integer> match = match((String s) -> s.equals("1") ? of(1) : null, s -> 1);
+ }
+
+ private <M>Optional<M> bar() {
+ return null;
+ }
+
+ public static <T1, V1, W1> Match<T1, V1> match(Extractor<T1, W1> e, Function<W1, V1> c) {
+ return null;
+ }
+
+ class Match<T, V> {}
+
+ interface Extractor<T, W> {
+ Optional<W> unapply(T t);
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA106670.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA106670.java
index e899b42..0742a19 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA106670.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA106670.java
@@ -34,7 +34,7 @@
}
public void test(I<?> i) {
- bar<error descr="'bar(Test1111.I<? super A>)' in 'Test1111' cannot be applied to '(Test1111.I<capture<?>>)'">(i)</error>;
+ bar<error descr="'bar(Test1111.I<? super java.lang.Object>)' in 'Test1111' cannot be applied to '(Test1111.I<capture<?>>)'">(i)</error>;
}
public static <A> void bar(I<? super A> i) {}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA113573.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA113573.java
index 832dd1e..feba2d2 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA113573.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA113573.java
@@ -1,4 +1,4 @@
-public class Tmp {
+class Tmp {
Integer toInt(Number num) {
return null;
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA117124.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA117124.java
new file mode 100644
index 0000000..c8b29ed
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA117124.java
@@ -0,0 +1,8 @@
+interface Var {
+ void var(int[] ps);
+}
+class Abc {
+ void foo() {
+ Var var = (int... ps) -> {};
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA119535.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA119535.java
new file mode 100644
index 0000000..9c88330
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA119535.java
@@ -0,0 +1,44 @@
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.function.BinaryOperator;
+import java.util.function.Function;
+import java.util.stream.Collector;
+
+class Stuff {
+ public enum Type { A }
+ private final int value;
+ private final Type type;
+ public Stuff(int value, Type type) {
+ this.value = value;
+ this.type = type;
+ }
+ public int getValue() {
+ return value;
+ }
+ public Type getType() {
+ return type;
+ }
+}
+
+class FakeErrors {
+ {
+
+ Collector<Stuff, ?, Map<Stuff.Type, Optional<Stuff>>> collector =
+ groupingBy(Stuff::getType,
+ reducing((d1, d2) -> {
+ boolean b = d1.getValue() > d2.getValue();
+ return d1;
+ }));
+ }
+
+ public static <T> Collector<T, ?, Optional<Stuff>> reducing(BinaryOperator<T> op) {
+ return null;
+ }
+
+ public static <T, K, A, D>
+ Collector<T, ?, Map<K, D>> groupingBy(Function<? super T, ? extends K> classifier,
+ Collector<? super T, A, D> downstream) {
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA120992.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA120992.java
new file mode 100644
index 0000000..33de600
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA120992.java
@@ -0,0 +1,12 @@
+import java.util.Arrays;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+class Test {
+
+ public static void main(String[] args) {
+ Arrays.asList("these", "are", "some", "words").stream()
+ .collect(Collectors.toMap(Function.identity(), (s) -> 1, Integer::sum));
+ }
+
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IncludeConstraintsWhenParentMethodIsDuringCalculation.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IncludeConstraintsWhenParentMethodIsDuringCalculation.java
index a70a70c..84d8d8a 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IncludeConstraintsWhenParentMethodIsDuringCalculation.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IncludeConstraintsWhenParentMethodIsDuringCalculation.java
@@ -9,7 +9,7 @@
<R> SuperFoo<R> foo(I<R> ax) { return null; }
- SuperFoo<String> ls = foo(() -> new Foo<<error descr="Type parameter 'java.lang.String' is not within its bound; should extend 'java.lang.Number'"></error>>());
+ SuperFoo<String> ls = foo(<error descr="Incompatible return type Foo<X> in lambda expression">() -> new Foo<>()</error>);
SuperFoo<Integer> li = foo(() -> new Foo<>());
SuperFoo<?> lw = foo(() -> new Foo<>());
}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/MissedSiteSubstitutorDuringDeepAdditionalConstraintsGathering.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/MissedSiteSubstitutorDuringDeepAdditionalConstraintsGathering.java
new file mode 100644
index 0000000..b28c93d
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/MissedSiteSubstitutorDuringDeepAdditionalConstraintsGathering.java
@@ -0,0 +1,12 @@
+import java.util.concurrent.CompletableFuture;
+
+class CompletableFutureTest {
+
+ void foo(CompletableFuture<String> future3, CompletableFuture<String> future1) throws Exception {
+ onFailure(future1.thenApply(v -> future3));
+ }
+
+ private static <T1> CompletableFuture<T1> onFailure(CompletableFuture<T1> future) {
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/OuterMethodPropagation.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/OuterMethodPropagation.java
index b19ca63..f8c2e75 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/OuterMethodPropagation.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/OuterMethodPropagation.java
@@ -1,4 +1,4 @@
-public class Tmp
+class Tmp
{
interface BiFunction<T, U, R> {
R apply(T t, U u);
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/RecursiveCalls.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/RecursiveCalls.java
index cd946b5..d026996 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/RecursiveCalls.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/RecursiveCalls.java
@@ -6,7 +6,7 @@
{
final I<CRN> f = null;
- Bug.<String>create(fn<error descr="'fn(Bug.I<java.lang.String>)' in 'Bug' cannot be applied to '(Bug.I<CRN>)'">(f)</error>);
+ Bug.<String>create(fn<error descr="'fn(Bug.I<FN>)' in 'Bug' cannot be applied to '(Bug.I<CRN>)'">(f)</error>);
return create(fn(f));
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/TargetTypeConflictResolverShouldNotTryToEvaluateCurrentArgumentType.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/TargetTypeConflictResolverShouldNotTryToEvaluateCurrentArgumentType.java
new file mode 100644
index 0000000..e67cda2
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/TargetTypeConflictResolverShouldNotTryToEvaluateCurrentArgumentType.java
@@ -0,0 +1,16 @@
+import java.util.Comparator;
+import java.util.function.Function;
+import java.util.stream.Stream;
+
+
+class TypeDetectionTest {
+
+ void main(Stream<Integer> of) {
+ of.sorted(comparing(n -> n.doubleValue()));
+ }
+
+ public static <T, U extends Comparable<? super U>> Comparator<T> comparing(Function<? super T, ? extends U> keyExtractor){
+ return null;
+ }
+}
+
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/UseCalculatedSubstitutor.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/UseCalculatedSubstitutor.java
index 72b47c3..6ac3a34 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/UseCalculatedSubstitutor.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/UseCalculatedSubstitutor.java
@@ -8,7 +8,7 @@
void foo(I<? extends String, ? extends List<? extends String>> fip) { }
void test() {
- foo<error descr="'foo(Test.I<? extends java.lang.String,? extends java.util.List<? extends java.lang.String>>)' in 'Test' cannot be applied to '(<lambda expression>)'">((ArrayList<? extends String> p) -> p.get(0))</error>;
+ foo(<error descr="Cannot infer functional interface type">(ArrayList<? extends String> p) -> p.get(0)</error>);
}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/WildcardParameterization.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/WildcardParameterization.java
new file mode 100644
index 0000000..3e7557a
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/WildcardParameterization.java
@@ -0,0 +1,7 @@
+import java.util.function.Function;
+
+class Sample {
+ {
+ Function<? extends String, ? extends Integer> f = (String s) -> s.length();
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/AfterCollectors1.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/AfterCollectors1.java
index 0d73ea1..a5ddf32 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/AfterCollectors1.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/AfterCollectors1.java
@@ -8,7 +8,7 @@
R apply(T t);
}
-public final class Collectors {
+final class Collectors {
public static <T>
Collector<List<T>> toList() {
return null;
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/AfterCollectors2.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/AfterCollectors2.java
index 4e14e99..baf3d88 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/AfterCollectors2.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/AfterCollectors2.java
@@ -17,7 +17,7 @@
interface F<TF> {}
-public final class Collectors {
+final class Collectors {
public static <T>
Collector<List<T>> toList() {
return null;
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/EnsureTypeParametersAreNotModifiedDuringGroundTypeEvaluation.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/EnsureTypeParametersAreNotModifiedDuringGroundTypeEvaluation.java
new file mode 100644
index 0000000..2d8ac7d
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/EnsureTypeParametersAreNotModifiedDuringGroundTypeEvaluation.java
@@ -0,0 +1,17 @@
+import java.util.*;
+import java.util.stream.*;
+
+class Test {
+
+ {
+ Collector<Employee, ?, Map<Department, List<Employee>>> objectMapCollector = Collectors.groupingBy(Employee::getDepartment);
+ }
+
+ private class Employee {
+ public Department getDepartment() {
+ return new Department();
+ }
+ }
+
+ private class Department {}
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/ExcludeContainingClassTypeParamsFromInference.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/ExcludeContainingClassTypeParamsFromInference.java
new file mode 100644
index 0000000..bdc7577
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/ExcludeContainingClassTypeParamsFromInference.java
@@ -0,0 +1,22 @@
+class TestJ8 {
+
+ interface Func<Af, Bf> {
+ Bf f(Af a);
+ }
+
+ class List<A> {
+
+ <Bm> List<Bm> map(Func<A, Bm> f) {
+ return null;
+ }
+
+ <Bb> List<Bb> bind(Func<A, List<Bb>> f) {
+ return null;
+ }
+
+ <B> List<B> apply(final List<Func<A, B>> lf) {
+ return lf.bind(this::map);
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA106522.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA106522.java
index 9de5928..ceeaa54 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA106522.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA106522.java
@@ -1,4 +1,4 @@
-public class Test<A,B> {
+class Test<A,B> {
public static <P,Q> Test<P,Q> left(P p) { return null; }
public static <P,Q> Test<P,Q> right(Q q) { return null; }
public <C> C either(Function<A, C> leftFn, Function<B, C> rightFn){ return null; }
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA112574.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA112574.java
index 91a9f0f..7c717aa 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA112574.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA112574.java
@@ -1,4 +1,4 @@
-public abstract class Tmp<T> {
+abstract class Tmp<T> {
private String concat(Tmp<String> tmp) {
return tmp.collect(StringBuilder::new, StringBuilder::append, StringBuilder::append).toString();
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA113297.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA113297.java
index c20ca59..e036a8c 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA113297.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA113297.java
@@ -1,4 +1,4 @@
-public class Test {
+class Test {
{
addListener(this::editPropertyChanged);
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA113558.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA113558.java
index c67f3e8..f6a94eb 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA113558.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA113558.java
@@ -1,4 +1,4 @@
-public class Tmp
+class Tmp
{
void foo(){}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA117311.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA117311.java
index 0c8cf6c..51947b3 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA117311.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA117311.java
@@ -2,7 +2,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
-public class Box<TBox>
+class Box<TBox>
{
public TBox getValue()
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA120370.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA120370.java
index 652c87e..95330f4 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA120370.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA120370.java
@@ -1,7 +1,7 @@
import java.util.List;
import java.util.concurrent.Callable;
-public class Tmp {
+class Tmp {
static void doo(Runnable action){}
static void doo(Callable<?> action){}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA120376.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA120376.java
index 822402f..a1e91cf 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA120376.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA120376.java
@@ -1,6 +1,6 @@
import java.util.Comparator;
-public class Test<T extends Test<T>> {
+class Test<T extends Test<T>> {
Comparator<Test<?>> bySize = Comparator.comparingInt(Test::size);
public int size() {
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IncorrectArrayCreationSignature.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IncorrectArrayCreationSignature.java
new file mode 100644
index 0000000..1124492
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IncorrectArrayCreationSignature.java
@@ -0,0 +1,11 @@
+class Test {
+ interface I {
+ Object m();
+ }
+
+ void m(I i) {}
+
+ {
+ m<error descr="'m(Test.I)' in 'Test' cannot be applied to '(<method reference>)'">(String[]::new)</error>;
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/LiftMethodReferenceTypeParams.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/LiftMethodReferenceTypeParams.java
index 6fb36d4..ba677e6 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/LiftMethodReferenceTypeParams.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/LiftMethodReferenceTypeParams.java
@@ -15,4 +15,21 @@
}
public static <C> void foo(Function<String, C> fn) { }
-}
\ No newline at end of file
+}
+
+class Test1 {
+
+ interface Function<K> {
+ K _();
+ }
+
+ static {
+ foo(Test1::asList);
+ }
+
+ public static <T> List<T> asList(T... a) {
+ return null;
+ }
+
+ public static <C> void foo(Function<C> fn) { }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/RawTargetType.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/RawTargetType.java
new file mode 100644
index 0000000..880d654
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/RawTargetType.java
@@ -0,0 +1,15 @@
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.function.Supplier;
+
+class Test {
+ interface I<K> {}
+
+ {
+ I i = foo(TreeMap::new);
+ }
+
+ <M extends Map<Integer, Integer>> I<M> foo(Supplier<M> mapFactory) {
+ return null;
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/params/FormalParams.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/params/FormalParams.java
index ad04464..874d72a 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/params/FormalParams.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/params/FormalParams.java
@@ -32,6 +32,6 @@
call((String i)->{ return i;});
call(i->{ return i;});
call(i->"");
- call<error descr="'call(ReturnTypeCompatibility.I1<int>)' in 'ReturnTypeCompatibility' cannot be applied to '(<lambda expression>)'">((int i)->{ return i;})</error>;
+ call(<error descr="Incompatible return type int in lambda expression">(int i)->{ return i;}</error>);
}
}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/afterFinalFieldInitializedBeforeAnonymInConstructor.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/afterFinalFieldInitializedBeforeAnonymInConstructor.java
new file mode 100644
index 0000000..e481f9b
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/afterFinalFieldInitializedBeforeAnonymInConstructor.java
@@ -0,0 +1,15 @@
+// "Replace with lambda" "true"
+class HelloLambda {
+ final int x;
+
+ HelloLambda() {
+ x = 1;
+ Runnable r = () -> {
+ System.out.println(x);
+
+ };
+
+ }
+
+
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/afterForwardStaticFieldReference.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/afterForwardStaticFieldReference.java
new file mode 100644
index 0000000..16ed145
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/afterForwardStaticFieldReference.java
@@ -0,0 +1,7 @@
+// "Replace with lambda" "true"
+class HelloLambda {
+ private final Runnable r = () -> {
+ System.out.println(x);
+ };
+ private static int x = 0;
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeFinalFieldInitializedAfterAnonymInConstructor.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeFinalFieldInitializedAfterAnonymInConstructor.java
new file mode 100644
index 0000000..8660181
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeFinalFieldInitializedAfterAnonymInConstructor.java
@@ -0,0 +1,18 @@
+// "Replace with lambda" "false"
+class HelloLambda {
+ final int x;
+
+ HelloLambda() {
+ Runnable r = new Runn<caret>able() {
+ @Override
+ public void run() {
+ System.out.println(x);
+
+ }
+ };
+ x = 1;
+
+ }
+
+
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeFinalFieldInitializedBeforeAnonymInConstructor.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeFinalFieldInitializedBeforeAnonymInConstructor.java
new file mode 100644
index 0000000..be7fc0d
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeFinalFieldInitializedBeforeAnonymInConstructor.java
@@ -0,0 +1,18 @@
+// "Replace with lambda" "true"
+class HelloLambda {
+ final int x;
+
+ HelloLambda() {
+ x = 1;
+ Runnable r = new Runn<caret>able() {
+ @Override
+ public void run() {
+ System.out.println(x);
+
+ }
+ };
+
+ }
+
+
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeForwardFieldReference.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeForwardFieldReference.java
new file mode 100644
index 0000000..2469fe1
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeForwardFieldReference.java
@@ -0,0 +1,10 @@
+// "Replace with lambda" "false"
+class HelloLambda {
+ private final Runnable r = new Run<caret>nable() {
+ @Override
+ public void run() {
+ System.out.println(x);
+ }
+ };
+ private int x = 0;
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeForwardStaticFieldReference.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeForwardStaticFieldReference.java
new file mode 100644
index 0000000..1afad4b
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeForwardStaticFieldReference.java
@@ -0,0 +1,10 @@
+// "Replace with lambda" "true"
+class HelloLambda {
+ private final Runnable r = new Run<caret>nable() {
+ @Override
+ public void run() {
+ System.out.println(x);
+ }
+ };
+ private static int x = 0;
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeNotAStatement.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeNotAStatement.java
new file mode 100644
index 0000000..6debe4d
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeNotAStatement.java
@@ -0,0 +1,17 @@
+// "Replace with lambda" "false"
+class Test {
+ interface I {
+
+ }
+ interface Bar extends I {
+ int compare(String o1, String o2);
+ }
+ {
+ new Ba<caret>r() {
+ @Override
+ public int compare(String o1, String o2) {
+ return 0;
+ }
+ };
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantLambdaParameterType/afterNoSelfTypeParam.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantLambdaParameterType/afterNoSelfTypeParam.java
new file mode 100644
index 0000000..9547b42
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantLambdaParameterType/afterNoSelfTypeParam.java
@@ -0,0 +1,10 @@
+// "Remove redundant types" "true"
+import java.util.*;
+
+public class Sample {
+ List<String> foo = new ArrayList<>();
+ {
+ foo.forEach(s -> {});
+ }
+}
+
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantLambdaParameterType/beforeNoSelfTypeParam.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantLambdaParameterType/beforeNoSelfTypeParam.java
new file mode 100644
index 0000000..cf550c8
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantLambdaParameterType/beforeNoSelfTypeParam.java
@@ -0,0 +1,10 @@
+// "Remove redundant types" "true"
+import java.util.*;
+
+public class Sample {
+ List<String> foo = new ArrayList<>();
+ {
+ foo.forEach((Str<caret>ing s) -> {});
+ }
+}
+
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterMethodRef.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterMethodRef.java
new file mode 100644
index 0000000..f7d2740
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterMethodRef.java
@@ -0,0 +1,12 @@
+// "Replace with forEach" "true"
+import java.util.ArrayList;
+import java.util.List;
+
+class Sample {
+ List<String> foo = new ArrayList<>();
+ {
+ foo.forEach(this::bar);
+ }
+
+ void bar(String s){}
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterNormal.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterNormal.java
new file mode 100644
index 0000000..ab67b49
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterNormal.java
@@ -0,0 +1,10 @@
+// "Replace with forEach" "true"
+import java.util.ArrayList;
+import java.util.List;
+
+class Sample {
+ List<String> foo = new ArrayList<>();
+ {
+ foo.stream().filter(s -> s != null).forEach(System.out::println);
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeBreakInside.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeBreakInside.java
new file mode 100644
index 0000000..94d571e
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeBreakInside.java
@@ -0,0 +1,15 @@
+// "Replace with forEach" "false"
+import java.util.ArrayList;
+import java.util.List;
+
+class Sample {
+ List<String> foo = new ArrayList<>();
+ {
+ for (String s : fo<caret>o) {
+ if (s == null) {
+ break;
+ }
+ }
+
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeContinueInside.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeContinueInside.java
new file mode 100644
index 0000000..9ff6de7
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeContinueInside.java
@@ -0,0 +1,15 @@
+// "Replace with forEach" "false"
+import java.util.ArrayList;
+import java.util.List;
+
+class Sample {
+ List<String> foo = new ArrayList<>();
+ {
+ for (String s : fo<caret>o) {
+ if (s == null) {
+ continue;
+ }
+ }
+
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeMethodRef.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeMethodRef.java
new file mode 100644
index 0000000..cca5c1e
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeMethodRef.java
@@ -0,0 +1,14 @@
+// "Replace with forEach" "true"
+import java.util.ArrayList;
+import java.util.List;
+
+class Sample {
+ List<String> foo = new ArrayList<>();
+ {
+ for (String s : fo<caret>o) {
+ bar(s)
+ }
+ }
+
+ void bar(String s){}
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeNoFilter.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeNoFilter.java
new file mode 100644
index 0000000..6bf6d9e
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeNoFilter.java
@@ -0,0 +1,11 @@
+// "Replace with forEach" "false"
+class Sample {
+ void foo(It it){
+ for (String s : i<caret>t) {
+ if (s == null) {
+ }
+ }
+ }
+}
+
+abstract class It implements Iterable<String> {}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeNormal.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeNormal.java
new file mode 100644
index 0000000..20a815b
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeNormal.java
@@ -0,0 +1,14 @@
+// "Replace with forEach" "true"
+import java.util.ArrayList;
+import java.util.List;
+
+class Sample {
+ List<String> foo = new ArrayList<>();
+ {
+ for (String s : fo<caret>o) {
+ if (s != null) {
+ System.out.println(s);
+ }
+ }
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeNotEffectivelyFinalVar.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeNotEffectivelyFinalVar.java
new file mode 100644
index 0000000..7e5903f
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeNotEffectivelyFinalVar.java
@@ -0,0 +1,16 @@
+// "Replace with forEach" "false"
+import java.util.ArrayList;
+import java.util.List;
+
+class Sample {
+ List<String> foo = new ArrayList<>();
+ String foo(){
+ boolean b = true;
+ for (String s : f<caret>oo) {
+ if (s == null) {
+ b = false;
+ }
+ }
+ return null;
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeReturnInside.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeReturnInside.java
new file mode 100644
index 0000000..f1279ee
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeReturnInside.java
@@ -0,0 +1,15 @@
+// "Replace with forEach" "false"
+import java.util.ArrayList;
+import java.util.List;
+
+class Sample {
+ List<String> foo = new ArrayList<>();
+ String foo(){
+ for (String s : fo<caret>o) {
+ if (s == null) {
+ return s;
+ }
+ }
+ return null;
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/unusedDecls/LocalClass.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/unusedDecls/LocalClass.java
index 5aea6bf..638186b 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/unusedDecls/LocalClass.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/unusedDecls/LocalClass.java
@@ -1,4 +1,4 @@
-public class Test {
+class Test {
public static void main() {
class Inner1{};
class <warning>Inner2</warning> {};
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/unusedImports/StaticImportingInner.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/unusedImports/StaticImportingInner.java
index b6d384b..3e4c439 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/unusedImports/StaticImportingInner.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/unusedImports/StaticImportingInner.java
@@ -1,6 +1,6 @@
import static package1.c.*;
<warning>import static package1.c.*;</warning>
-public class a {
+class a {
int x = MyInner.a;
}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/slice/backward/CollectionTrack.java b/java/java-tests/testData/codeInsight/slice/backward/CollectionTrack.java
index bead6f4..414dfba 100644
--- a/java/java-tests/testData/codeInsight/slice/backward/CollectionTrack.java
+++ b/java/java-tests/testData/codeInsight/slice/backward/CollectionTrack.java
@@ -2,7 +2,7 @@
import java.util.*;
import org.intellij.lang.annotations.Flow;
-public class ListTack {
+class ListTack {
void f(String <caret>s) {
}
void g(List<String> l) {
diff --git a/java/java-tests/testData/codeInsight/slice/backward/DoubleNulls.java b/java/java-tests/testData/codeInsight/slice/backward/DoubleNulls.java
index c136014..7648436 100644
--- a/java/java-tests/testData/codeInsight/slice/backward/DoubleNulls.java
+++ b/java/java-tests/testData/codeInsight/slice/backward/DoubleNulls.java
@@ -1,4 +1,4 @@
-public class X {
+class X {
String <caret>l;
{
l = null;
diff --git a/java/java-tests/testData/codeInsight/slice/backward/DupSlice.java b/java/java-tests/testData/codeInsight/slice/backward/DupSlice.java
index a983ee6..4e34290 100644
--- a/java/java-tests/testData/codeInsight/slice/backward/DupSlice.java
+++ b/java/java-tests/testData/codeInsight/slice/backward/DupSlice.java
@@ -1,4 +1,4 @@
-public class DupSlice {
+class DupSlice {
int <caret>field;
void multiply(int fp) {
diff --git a/java/java-tests/testData/codeInsight/slice/backward/DuplicateLeaves.java b/java/java-tests/testData/codeInsight/slice/backward/DuplicateLeaves.java
index 18440ec..c52d672 100644
--- a/java/java-tests/testData/codeInsight/slice/backward/DuplicateLeaves.java
+++ b/java/java-tests/testData/codeInsight/slice/backward/DuplicateLeaves.java
@@ -1,4 +1,4 @@
-public class X {
+class X {
String <caret>l;
public X() {
diff --git a/java/java-tests/testData/codeInsight/slice/backward/GenericBoxing.java b/java/java-tests/testData/codeInsight/slice/backward/GenericBoxing.java
index a888944..62c5f2c 100644
--- a/java/java-tests/testData/codeInsight/slice/backward/GenericBoxing.java
+++ b/java/java-tests/testData/codeInsight/slice/backward/GenericBoxing.java
@@ -1,4 +1,4 @@
-public class Boxi {
+class Boxi {
private interface Foo<T> {
T t();
}
diff --git a/java/java-tests/testData/codeInsight/slice/backward/GenericImplement.java b/java/java-tests/testData/codeInsight/slice/backward/GenericImplement.java
index 91d0ee5..1b947ae 100644
--- a/java/java-tests/testData/codeInsight/slice/backward/GenericImplement.java
+++ b/java/java-tests/testData/codeInsight/slice/backward/GenericImplement.java
@@ -1,4 +1,4 @@
-public class X {
+class X {
{
Proc<String> procs = new Proc<String>() {
public void f(String <caret>s) {
diff --git a/java/java-tests/testData/codeInsight/slice/backward/GenericImplement2.java b/java/java-tests/testData/codeInsight/slice/backward/GenericImplement2.java
index 6c3f5f1..33e5f9b 100644
--- a/java/java-tests/testData/codeInsight/slice/backward/GenericImplement2.java
+++ b/java/java-tests/testData/codeInsight/slice/backward/GenericImplement2.java
@@ -1,4 +1,4 @@
-public class X {
+class X {
{
Proc<String> procs = new Proc<String>() {
public void f(String s) {
diff --git a/java/java-tests/testData/codeInsight/slice/backward/GroupByLeavesWithLists.java b/java/java-tests/testData/codeInsight/slice/backward/GroupByLeavesWithLists.java
index b0aa0f6..394b42f 100644
--- a/java/java-tests/testData/codeInsight/slice/backward/GroupByLeavesWithLists.java
+++ b/java/java-tests/testData/codeInsight/slice/backward/GroupByLeavesWithLists.java
@@ -1,7 +1,7 @@
import java.util.ArrayList;
import java.util.List;
-public class ListTack {
+class ListTack {
void f(String s) {
String <caret>p = s;
diff --git a/java/java-tests/testData/codeInsight/slice/backward/InterMethod.java b/java/java-tests/testData/codeInsight/slice/backward/InterMethod.java
index bb2f1cd..ff25747 100644
--- a/java/java-tests/testData/codeInsight/slice/backward/InterMethod.java
+++ b/java/java-tests/testData/codeInsight/slice/backward/InterMethod.java
@@ -1,4 +1,4 @@
-public class WW {
+class WW {
void f(String <flown11111>ddd) {
if (hashCode() == 0)
ddd = <flown11112>"dd";
diff --git a/java/java-tests/testData/codeInsight/slice/backward/ListTrackToArray.java b/java/java-tests/testData/codeInsight/slice/backward/ListTrackToArray.java
index 6fa2dc8..104d891 100644
--- a/java/java-tests/testData/codeInsight/slice/backward/ListTrackToArray.java
+++ b/java/java-tests/testData/codeInsight/slice/backward/ListTrackToArray.java
@@ -3,7 +3,7 @@
import java.util.ArrayList;
import java.util.List;
-public class ListTack {
+class ListTack {
void f(String <caret>s) {
}
void g(List<String> <flown111>l) {
diff --git a/java/java-tests/testData/codeInsight/slice/backward/Nulls.java b/java/java-tests/testData/codeInsight/slice/backward/Nulls.java
index 94738f2..6a72061 100644
--- a/java/java-tests/testData/codeInsight/slice/backward/Nulls.java
+++ b/java/java-tests/testData/codeInsight/slice/backward/Nulls.java
@@ -1,7 +1,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-public class X {
+class X {
private final static String CON = "";
String <caret>l;
private String d;
diff --git a/java/java-tests/testData/codeInsight/slice/backward/OverloadConstructor.java b/java/java-tests/testData/codeInsight/slice/backward/OverloadConstructor.java
index 1e0e90a..64d77c7 100644
--- a/java/java-tests/testData/codeInsight/slice/backward/OverloadConstructor.java
+++ b/java/java-tests/testData/codeInsight/slice/backward/OverloadConstructor.java
@@ -1,6 +1,6 @@
import java.util.*;
-public class Auto {
+class Auto {
public Auto(ArrayList w, Runnable <caret>i) {
this(w, null,null);
}
diff --git a/java/java-tests/testData/codeInsight/slice/backward/Overrides.java b/java/java-tests/testData/codeInsight/slice/backward/Overrides.java
index fce1e2c..35d7aa3 100644
--- a/java/java-tests/testData/codeInsight/slice/backward/Overrides.java
+++ b/java/java-tests/testData/codeInsight/slice/backward/Overrides.java
@@ -1,4 +1,4 @@
-public class OverrideSlice {
+class OverrideSlice {
interface I {
int f(int i);
}
diff --git a/java/java-tests/testData/codeInsight/slice/backward/VarArgs.java b/java/java-tests/testData/codeInsight/slice/backward/VarArgs.java
index 24b3734..cc2e884 100644
--- a/java/java-tests/testData/codeInsight/slice/backward/VarArgs.java
+++ b/java/java-tests/testData/codeInsight/slice/backward/VarArgs.java
@@ -1,4 +1,4 @@
-public class VarArgs {
+class VarArgs {
private void g() {
f<flown111>(<flown1111>1);
f<flown112>(<flown1121>2, <flown1122>3, <flown1123>4);
diff --git a/java/java-tests/testData/codeInsight/slice/forward/InterMethod.java b/java/java-tests/testData/codeInsight/slice/forward/InterMethod.java
index 4d723bc..5d6e4de 100644
--- a/java/java-tests/testData/codeInsight/slice/forward/InterMethod.java
+++ b/java/java-tests/testData/codeInsight/slice/forward/InterMethod.java
@@ -1,4 +1,4 @@
-public class T2 {
+class T2 {
int <caret>fff;
public T2(int i) {
diff --git a/java/java-tests/testData/codeInsight/slice/forward/Simple.java b/java/java-tests/testData/codeInsight/slice/forward/Simple.java
index 1049bec..a3200bb 100644
--- a/java/java-tests/testData/codeInsight/slice/forward/Simple.java
+++ b/java/java-tests/testData/codeInsight/slice/forward/Simple.java
@@ -1,4 +1,4 @@
- public class T2 {
+class T2 {
int <flown111111>fff;
{
diff --git a/java/java-tests/testData/codeInsight/template/postfix/completion/tabCompletionWithTemplatesInAutopopup.java b/java/java-tests/testData/codeInsight/template/postfix/completion/tabCompletionWithTemplatesInAutopopup.java
new file mode 100644
index 0000000..91505af
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/template/postfix/completion/tabCompletionWithTemplatesInAutopopup.java
@@ -0,0 +1,9 @@
+public class Foo {
+ void m() {
+ new MyClass()<caret>
+ }
+
+ private class MyClass {
+ public void parents() {}
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/template/postfix/completion/tabCompletionWithTemplatesInAutopopup_after.java b/java/java-tests/testData/codeInsight/template/postfix/completion/tabCompletionWithTemplatesInAutopopup_after.java
new file mode 100644
index 0000000..37167a3
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/template/postfix/completion/tabCompletionWithTemplatesInAutopopup_after.java
@@ -0,0 +1,9 @@
+public class Foo {
+ void m() {
+ new MyClass().parents();<caret>
+ }
+
+ private class MyClass {
+ public void parents() {}
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/template/postfix/templates/instanceof/primitive.java b/java/java-tests/testData/codeInsight/template/postfix/templates/instanceof/primitive.java
new file mode 100644
index 0000000..2e1d76a
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/template/postfix/templates/instanceof/primitive.java
@@ -0,0 +1,5 @@
+public class Foo {
+ void m(int o) {
+ o.instanceof<caret>
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/template/postfix/templates/instanceof/primitive_after.java b/java/java-tests/testData/codeInsight/template/postfix/templates/instanceof/primitive_after.java
new file mode 100644
index 0000000..29fc33c
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/template/postfix/templates/instanceof/primitive_after.java
@@ -0,0 +1,5 @@
+public class Foo {
+ void m(int o) {
+ o.instanceof <caret>
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/template/postfix/templates/notnull/primitive.java b/java/java-tests/testData/codeInsight/template/postfix/templates/notnull/primitive.java
new file mode 100644
index 0000000..1d9e1ea
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/template/postfix/templates/notnull/primitive.java
@@ -0,0 +1,5 @@
+public class Foo {
+ void m(int o) {
+ o.notnull<caret>
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/template/postfix/templates/notnull/primitive_after.java b/java/java-tests/testData/codeInsight/template/postfix/templates/notnull/primitive_after.java
new file mode 100644
index 0000000..0f3e8ac
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/template/postfix/templates/notnull/primitive_after.java
@@ -0,0 +1,5 @@
+public class Foo {
+ void m(int o) {
+ o.notnull <caret>
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/template/postfix/templates/null/primitive.java b/java/java-tests/testData/codeInsight/template/postfix/templates/null/primitive.java
new file mode 100644
index 0000000..4496cee
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/template/postfix/templates/null/primitive.java
@@ -0,0 +1,5 @@
+public class Foo {
+ void m(int o) {
+ o.null<caret>
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/template/postfix/templates/null/primitive_after.java b/java/java-tests/testData/codeInsight/template/postfix/templates/null/primitive_after.java
new file mode 100644
index 0000000..1084e03
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/template/postfix/templates/null/primitive_after.java
@@ -0,0 +1,5 @@
+public class Foo {
+ void m(int o) {
+ o.null <caret>
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/template/postfix/templates/throw/notThrowable.java b/java/java-tests/testData/codeInsight/template/postfix/templates/throw/notThrowable.java
new file mode 100644
index 0000000..edfbaab
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/template/postfix/templates/throw/notThrowable.java
@@ -0,0 +1,5 @@
+public class Foo {
+ void m(Object o) {
+ o.throw<caret>
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/template/postfix/templates/throw/notThrowable_after.java b/java/java-tests/testData/codeInsight/template/postfix/templates/throw/notThrowable_after.java
new file mode 100644
index 0000000..900e720
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/template/postfix/templates/throw/notThrowable_after.java
@@ -0,0 +1,5 @@
+public class Foo {
+ void m(Object o) {
+ throw o;<caret>
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/template/postfix/templates/throw/simple.java b/java/java-tests/testData/codeInsight/template/postfix/templates/throw/simple.java
index edfbaab..2d183ba 100644
--- a/java/java-tests/testData/codeInsight/template/postfix/templates/throw/simple.java
+++ b/java/java-tests/testData/codeInsight/template/postfix/templates/throw/simple.java
@@ -1,5 +1,7 @@
+import java.lang.RuntimeException;
+
public class Foo {
- void m(Object o) {
- o.throw<caret>
+ void m() {
+ new RuntimeException("error").throw<caret>
}
}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/template/postfix/templates/throw/simple_after.java b/java/java-tests/testData/codeInsight/template/postfix/templates/throw/simple_after.java
index 900e720..a0219e4 100644
--- a/java/java-tests/testData/codeInsight/template/postfix/templates/throw/simple_after.java
+++ b/java/java-tests/testData/codeInsight/template/postfix/templates/throw/simple_after.java
@@ -1,5 +1,7 @@
+import java.lang.RuntimeException;
+
public class Foo {
- void m(Object o) {
- throw o;<caret>
+ void m() {
+ throw new RuntimeException("error");
}
}
\ No newline at end of file
diff --git a/java/java-tests/testData/compileServer/incremental/common/moveClassFromJavaFileToDependentModule.log b/java/java-tests/testData/compileServer/incremental/common/moveClassFromJavaFileToDependentModule.log
new file mode 100644
index 0000000..125f8bf
--- /dev/null
+++ b/java/java-tests/testData/compileServer/incremental/common/moveClassFromJavaFileToDependentModule.log
@@ -0,0 +1,10 @@
+Compiling files:
+moduleA/src/com/ppp/Inner.java
+End of files
+Cleaning output files:
+out/production/moduleB/com/ppp/B.class
+out/production/moduleB/com/ppp/Inner.class
+End of files
+Compiling files:
+moduleB/src/com/ppp/B.java
+End of files
diff --git a/java/java-tests/testData/compileServer/incremental/common/moveClassFromJavaFileToDependentModule/moduleA/src/com/ppp/Inner.java.new b/java/java-tests/testData/compileServer/incremental/common/moveClassFromJavaFileToDependentModule/moduleA/src/com/ppp/Inner.java.new
new file mode 100644
index 0000000..b274897
--- /dev/null
+++ b/java/java-tests/testData/compileServer/incremental/common/moveClassFromJavaFileToDependentModule/moduleA/src/com/ppp/Inner.java.new
@@ -0,0 +1,4 @@
+package com.ppp;
+
+class Inner {
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/compileServer/incremental/common/moveClassFromJavaFileToDependentModule/moduleB/src/com/ppp/B.java b/java/java-tests/testData/compileServer/incremental/common/moveClassFromJavaFileToDependentModule/moduleB/src/com/ppp/B.java
new file mode 100644
index 0000000..d49fc1b
--- /dev/null
+++ b/java/java-tests/testData/compileServer/incremental/common/moveClassFromJavaFileToDependentModule/moduleB/src/com/ppp/B.java
@@ -0,0 +1,8 @@
+package com.ppp;
+
+public class B {
+}
+
+class Inner {
+}
+
diff --git a/java/java-tests/testData/compileServer/incremental/common/moveClassFromJavaFileToDependentModule/moduleB/src/com/ppp/B.java.new b/java/java-tests/testData/compileServer/incremental/common/moveClassFromJavaFileToDependentModule/moduleB/src/com/ppp/B.java.new
new file mode 100644
index 0000000..71be7af
--- /dev/null
+++ b/java/java-tests/testData/compileServer/incremental/common/moveClassFromJavaFileToDependentModule/moduleB/src/com/ppp/B.java.new
@@ -0,0 +1,5 @@
+package com.ppp;
+
+public class B {
+}
+
diff --git a/java/java-tests/testData/compileServer/incremental/common/moveClassToDependentModule.log b/java/java-tests/testData/compileServer/incremental/common/moveClassToDependentModule.log
new file mode 100644
index 0000000..338a087
--- /dev/null
+++ b/java/java-tests/testData/compileServer/incremental/common/moveClassToDependentModule.log
@@ -0,0 +1,6 @@
+Compiling files:
+moduleA/src/com/ppp/Inner.java
+End of files
+Cleaning output files:
+out/production/moduleB/com/ppp/Inner.class
+End of files
diff --git a/java/java-tests/testData/compileServer/incremental/common/moveClassToDependentModule/moduleA/src/com/ppp/Inner.java.new b/java/java-tests/testData/compileServer/incremental/common/moveClassToDependentModule/moduleA/src/com/ppp/Inner.java.new
new file mode 100644
index 0000000..b274897
--- /dev/null
+++ b/java/java-tests/testData/compileServer/incremental/common/moveClassToDependentModule/moduleA/src/com/ppp/Inner.java.new
@@ -0,0 +1,4 @@
+package com.ppp;
+
+class Inner {
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/compileServer/incremental/common/moveClassToDependentModule/moduleB/src/com/ppp/B.java b/java/java-tests/testData/compileServer/incremental/common/moveClassToDependentModule/moduleB/src/com/ppp/B.java
new file mode 100644
index 0000000..71be7af
--- /dev/null
+++ b/java/java-tests/testData/compileServer/incremental/common/moveClassToDependentModule/moduleB/src/com/ppp/B.java
@@ -0,0 +1,5 @@
+package com.ppp;
+
+public class B {
+}
+
diff --git a/java/java-tests/testData/compileServer/incremental/common/moveClassToDependentModule/moduleB/src/com/ppp/Inner.java b/java/java-tests/testData/compileServer/incremental/common/moveClassToDependentModule/moduleB/src/com/ppp/Inner.java
new file mode 100644
index 0000000..5ffa576
--- /dev/null
+++ b/java/java-tests/testData/compileServer/incremental/common/moveClassToDependentModule/moduleB/src/com/ppp/Inner.java
@@ -0,0 +1,5 @@
+package com.ppp;
+
+class Inner {
+}
+
diff --git a/java/java-tests/testData/compileServer/incremental/common/moveClassToDependentModule/moduleB/src/com/ppp/Inner.java.remove b/java/java-tests/testData/compileServer/incremental/common/moveClassToDependentModule/moduleB/src/com/ppp/Inner.java.remove
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/java/java-tests/testData/compileServer/incremental/common/moveClassToDependentModule/moduleB/src/com/ppp/Inner.java.remove
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/AnnReport.java b/java/java-tests/testData/inspection/dataFlow/fixture/AnnReport.java
index 811b41c..082d4da 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/AnnReport.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/AnnReport.java
@@ -1,6 +1,6 @@
import org.jetbrains.annotations.NotNull;
-public class ASD {
+class ASD {
static void foo(Object any) {
boolean a = false;
boolean b = false;
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/AssertFalse.java b/java/java-tests/testData/inspection/dataFlow/fixture/AssertFalse.java
index 3aa73af..e478396 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/AssertFalse.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/AssertFalse.java
@@ -1,4 +1,4 @@
-public class AssertFalse {
+class AssertFalse {
void bar() {
final boolean b = call();
if (Assertions.assertFalse(b)) {
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/AssertIsNotNull.java b/java/java-tests/testData/inspection/dataFlow/fixture/AssertIsNotNull.java
index 5b16eb7..deaf3fd 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/AssertIsNotNull.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/AssertIsNotNull.java
@@ -1,6 +1,6 @@
import java.lang.*;
-public class AssertIsNotNull {
+class AssertIsNotNull {
void bar() {
final Object o = call();
Assertions.assertIsNotNull(o);
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/AssertIsNull.java b/java/java-tests/testData/inspection/dataFlow/fixture/AssertIsNull.java
index 5915277..45d6cdc 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/AssertIsNull.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/AssertIsNull.java
@@ -1,6 +1,6 @@
import java.lang.*;
-public class AssertIsNull {
+class AssertIsNull {
void bar() {
final Object o = call();
Assertions.assertIsNull(o);
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/AssertTrue.java b/java/java-tests/testData/inspection/dataFlow/fixture/AssertTrue.java
index a71e438..870da12 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/AssertTrue.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/AssertTrue.java
@@ -1,4 +1,4 @@
-public class AssertTrue {
+class AssertTrue {
void bar() {
final boolean b = call();
if (Assertions.assertTrue(b)) {
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/AssigningClassLiteralToNullable.java b/java/java-tests/testData/inspection/dataFlow/fixture/AssigningClassLiteralToNullable.java
index 14e44ea..988b551 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/AssigningClassLiteralToNullable.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/AssigningClassLiteralToNullable.java
@@ -1,7 +1,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-public class BrokenAlignment {
+class BrokenAlignment {
public void main(String... args) {
@Nullable Class object = Object.class;
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/AssigningNullableToNotNull.java b/java/java-tests/testData/inspection/dataFlow/fixture/AssigningNullableToNotNull.java
index b932857..762e57e 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/AssigningNullableToNotNull.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/AssigningNullableToNotNull.java
@@ -1,7 +1,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-public class Npe {
+class Npe {
@NotNull Object aField;
@Nullable Object nullable() {
return null;
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/AssigningUnknownToNullable.java b/java/java-tests/testData/inspection/dataFlow/fixture/AssigningUnknownToNullable.java
index b8d1a1e..a1cacc8 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/AssigningUnknownToNullable.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/AssigningUnknownToNullable.java
@@ -1,6 +1,6 @@
import org.jetbrains.annotations.Nullable;
-public class BrokenAlignment {
+class BrokenAlignment {
String unknown(String s) { return s; }
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/BigMethodNotComplex.java b/java/java-tests/testData/inspection/dataFlow/fixture/BigMethodNotComplex.java
index 8a1ff44..99493a9 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/BigMethodNotComplex.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/BigMethodNotComplex.java
@@ -1,4 +1,4 @@
-public abstract class DDD {
+abstract class DDD {
abstract boolean condition();
abstract Object foo();
abstract Object bar();
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/CanBeNullDoesntImplyIsNull.java b/java/java-tests/testData/inspection/dataFlow/fixture/CanBeNullDoesntImplyIsNull.java
index 56f5771..33dd242 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/CanBeNullDoesntImplyIsNull.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/CanBeNullDoesntImplyIsNull.java
@@ -1,6 +1,6 @@
import org.jetbrains.annotations.Nullable;
-public class DDD {
+class DDD {
int test(boolean t) {
if (t && <warning descr="Dereference of 'fff()' may produce 'java.lang.NullPointerException'">fff()</warning>.length == 1) {
return 0;
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/CatchRuntimeException.java b/java/java-tests/testData/inspection/dataFlow/fixture/CatchRuntimeException.java
index 193b3bc..8f65086 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/CatchRuntimeException.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/CatchRuntimeException.java
@@ -1,6 +1,6 @@
import org.jetbrains.annotations.NotNull;
-public class BrokenAlignment {
+class BrokenAlignment {
@NotNull
Object test1() {
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/CatchThrowable.java b/java/java-tests/testData/inspection/dataFlow/fixture/CatchThrowable.java
index b055937..ecb9b26 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/CatchThrowable.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/CatchThrowable.java
@@ -1,4 +1,4 @@
-public class BrokenAlignment {
+class BrokenAlignment {
public static void main(String[] args) {
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/ChainedFinalFieldAccessorsDfa.java b/java/java-tests/testData/inspection/dataFlow/fixture/ChainedFinalFieldAccessorsDfa.java
index 12c6fb1..ca9cf97 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/ChainedFinalFieldAccessorsDfa.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/ChainedFinalFieldAccessorsDfa.java
@@ -2,7 +2,7 @@
import java.lang.String;
-public class BrokenAlignment {
+class BrokenAlignment {
void main(Data data) {
if (data.getText() != null) {
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/ChainedFinalFieldsDfa.java b/java/java-tests/testData/inspection/dataFlow/fixture/ChainedFinalFieldsDfa.java
index 0096d82..8d07f5e 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/ChainedFinalFieldsDfa.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/ChainedFinalFieldsDfa.java
@@ -1,5 +1,5 @@
import org.jetbrains.annotations.Nullable;
-public class BrokenAlignment {
+class BrokenAlignment {
void main(Data data) {
if (data.text != null) {
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/ComparingToNotNullShouldNotAffectNullity.java b/java/java-tests/testData/inspection/dataFlow/fixture/ComparingToNotNullShouldNotAffectNullity.java
index b44b6f8..fed3d1b 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/ComparingToNotNullShouldNotAffectNullity.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/ComparingToNotNullShouldNotAffectNullity.java
@@ -2,7 +2,7 @@
import java.util.Collection;
-public class Bar3 {
+class Bar3 {
@NotNull
Object getObj() {
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/ContinueFlushesLoopVariable.java b/java/java-tests/testData/inspection/dataFlow/fixture/ContinueFlushesLoopVariable.java
index 0328521..f11084a 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/ContinueFlushesLoopVariable.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/ContinueFlushesLoopVariable.java
@@ -6,7 +6,7 @@
import java.sql.SQLException;
import java.util.Map;
-public class Main {
+class Main {
public static String escapeAndUnescapeSymbols(String s, StringBuilder builder) {
boolean escaped = false;
for (int i = 0; i < s.length(); i++) {
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/ContractAnnotation.java b/java/java-tests/testData/inspection/dataFlow/fixture/ContractAnnotation.java
index 3d97047..4890d54 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/ContractAnnotation.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/ContractAnnotation.java
@@ -5,7 +5,7 @@
import java.lang.AssertionError;
import java.lang.IllegalArgumentException;
-public class AssertIsNotNull {
+class AssertIsNotNull {
void bar(String s, String s1) {
if (<warning descr="Condition 's == null && trimIfNotNull(s) != null' is always 'false'">s == null && <warning descr="Condition 'trimIfNotNull(s) != null' is always 'false' when reached">trimIfNotNull(s) != null</warning></warning>) {
throw new AssertionError();
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/ContractInLoopNotTooComplex.java b/java/java-tests/testData/inspection/dataFlow/fixture/ContractInLoopNotTooComplex.java
index 96356dd..14dfd20 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/ContractInLoopNotTooComplex.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/ContractInLoopNotTooComplex.java
@@ -1,6 +1,6 @@
import org.jetbrains.annotations.Contract;
-public class Foo {
+class Foo {
public void main(String[] args) {
for (int i = 0; i < 10; i++) {
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/ContractPreservesUnknownNullability.java b/java/java-tests/testData/inspection/dataFlow/fixture/ContractPreservesUnknownNullability.java
index d829f23..7ef5458 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/ContractPreservesUnknownNullability.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/ContractPreservesUnknownNullability.java
@@ -1,7 +1,7 @@
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
-public class Foo {
+class Foo {
@Contract("null->null")
String foo(String s){
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/ContractSeveralClauses.java b/java/java-tests/testData/inspection/dataFlow/fixture/ContractSeveralClauses.java
index f201cf4..a654b99 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/ContractSeveralClauses.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/ContractSeveralClauses.java
@@ -1,7 +1,7 @@
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.Nullable;
-public class Foo {
+class Foo {
String foo(Object escaper, String s) {
return escapeStr(s, escaper);
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/ContractWithNullable.java b/java/java-tests/testData/inspection/dataFlow/fixture/ContractWithNullable.java
index 47ce7fc..412cf0d 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/ContractWithNullable.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/ContractWithNullable.java
@@ -2,7 +2,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-public class Foo {
+class Foo {
public void main(@NotNull Object nn) {
foo(nn).hashCode();
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/EqualsNotNull.java b/java/java-tests/testData/inspection/dataFlow/fixture/EqualsNotNull.java
index 0459c90..43944c2 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/EqualsNotNull.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/EqualsNotNull.java
@@ -1,7 +1,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-public class Main {
+class Main {
@NotNull
private Object test1(@NotNull Object defVal, @Nullable final Object val) {
return defVal;
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/ExceptionFromFinallyNesting.java b/java/java-tests/testData/inspection/dataFlow/fixture/ExceptionFromFinallyNesting.java
index 8df4297..fe26a88 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/ExceptionFromFinallyNesting.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/ExceptionFromFinallyNesting.java
@@ -2,7 +2,7 @@
import java.io.OutputStream;
import java.net.Socket;
-public class Foo {
+class Foo {
private void run(int port) throws Exception {
Socket socket = new Socket("localhost", port);
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/FieldChangedBetweenSynchronizedBlocks.java b/java/java-tests/testData/inspection/dataFlow/fixture/FieldChangedBetweenSynchronizedBlocks.java
index 63e606b..5da6f51 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/FieldChangedBetweenSynchronizedBlocks.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/FieldChangedBetweenSynchronizedBlocks.java
@@ -1,4 +1,4 @@
-public class Bar {
+class Bar {
private Object field;
private final Object lock = new Object();
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/FinalFieldsDifferentInstances.java b/java/java-tests/testData/inspection/dataFlow/fixture/FinalFieldsDifferentInstances.java
index ef403e7..dbe6509 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/FinalFieldsDifferentInstances.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/FinalFieldsDifferentInstances.java
@@ -1,4 +1,4 @@
-public class BrokenAlignment {
+class BrokenAlignment {
private static boolean dominates(final WatchRequestImpl request, final WatchRequestImpl other) {
if (request.myToWatchRecursively) {
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/FinalFieldsInitializedByAnnotatedParameters.java b/java/java-tests/testData/inspection/dataFlow/fixture/FinalFieldsInitializedByAnnotatedParameters.java
index db7d0b4..ea9ef22 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/FinalFieldsInitializedByAnnotatedParameters.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/FinalFieldsInitializedByAnnotatedParameters.java
@@ -3,7 +3,7 @@
import java.lang.Object;
-public class Doo {
+class Doo {
private final Object myA;
private final Object myB;
private final Object myC;
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/FinalFieldsInitializedNotNull.java b/java/java-tests/testData/inspection/dataFlow/fixture/FinalFieldsInitializedNotNull.java
index c940fea..7760a8f 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/FinalFieldsInitializedNotNull.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/FinalFieldsInitializedNotNull.java
@@ -1,7 +1,7 @@
import java.lang.IllegalArgumentException;
import java.lang.Object;
-public class Doo {
+class Doo {
private final Object myA;
private final Object myB;
private final Object myC;
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/FinalLoopVariableInstanceof.java b/java/java-tests/testData/inspection/dataFlow/fixture/FinalLoopVariableInstanceof.java
index f60cad9..4595420 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/FinalLoopVariableInstanceof.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/FinalLoopVariableInstanceof.java
@@ -1,4 +1,4 @@
-public class Test {
+class Test {
public static void main(Object[] args) throws Exception {
boolean elvisLives = false;
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/FinallyNotComplex.java b/java/java-tests/testData/inspection/dataFlow/fixture/FinallyNotComplex.java
index 3df5e60..2173b2e 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/FinallyNotComplex.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/FinallyNotComplex.java
@@ -1,4 +1,4 @@
-public class Foo {
+class Foo {
Foo getFoo() { return <warning descr="'null' is returned by the method which is not declared as @Nullable">null</warning>; }
void foo() {
try {
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/GeneratedEquals.java b/java/java-tests/testData/inspection/dataFlow/fixture/GeneratedEquals.java
index 225b452..c5d2714 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/GeneratedEquals.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/GeneratedEquals.java
@@ -1,4 +1,4 @@
-public class Bar {
+class Bar {
int foo;
@Override
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/HonorGetterAnnotation.java b/java/java-tests/testData/inspection/dataFlow/fixture/HonorGetterAnnotation.java
index fa72072..047588e 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/HonorGetterAnnotation.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/HonorGetterAnnotation.java
@@ -1,6 +1,6 @@
import org.jetbrains.annotations.Nullable;
-public class Goo {
+class Goo {
Permission permission;
{
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/IsNotNullCheck.java b/java/java-tests/testData/inspection/dataFlow/fixture/IsNotNullCheck.java
index 6acb013..878c4b3 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/IsNotNullCheck.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/IsNotNullCheck.java
@@ -1,4 +1,4 @@
-public class IsNotNullCheck {
+class IsNotNullCheck {
void bar() {
final Value v = call();
if (Value.isNotNull(v)) {
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/IsNullCheck.java b/java/java-tests/testData/inspection/dataFlow/fixture/IsNullCheck.java
index f87e0de..c4737b5 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/IsNullCheck.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/IsNullCheck.java
@@ -1,4 +1,4 @@
-public class IsNullCheck {
+class IsNullCheck {
void bar() {
final Value v = call();
if (Value.isNull(v)) {
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/ManyContinuesNotComplex.java b/java/java-tests/testData/inspection/dataFlow/fixture/ManyContinuesNotComplex.java
index 4cce300..ece86a0 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/ManyContinuesNotComplex.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/ManyContinuesNotComplex.java
@@ -1,4 +1,4 @@
-public class Foo {
+class Foo {
void foo(String[] lines) {
for (String line : lines) {
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/NestedFinally.java b/java/java-tests/testData/inspection/dataFlow/fixture/NestedFinally.java
index d09ec3a..a91dcf6 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/NestedFinally.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/NestedFinally.java
@@ -3,7 +3,7 @@
import java.lang.Throwable;
import java.net.Socket;
-public class Foo {
+class Foo {
void unchecked() {
boolean b = true;
try {
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/NestedTryInWhileNotComplex.java b/java/java-tests/testData/inspection/dataFlow/fixture/NestedTryInWhileNotComplex.java
index ae51350..b092fa9 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/NestedTryInWhileNotComplex.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/NestedTryInWhileNotComplex.java
@@ -1,6 +1,6 @@
import java.io.FileInputStream;
-public class Bar {
+class Bar {
boolean myShouldAccept = true;
public void run() {
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/NullCheckDoesntAffectUncheckedCast.java b/java/java-tests/testData/inspection/dataFlow/fixture/NullCheckDoesntAffectUncheckedCast.java
index 2f85648..520c281 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/NullCheckDoesntAffectUncheckedCast.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/NullCheckDoesntAffectUncheckedCast.java
@@ -1,4 +1,4 @@
-public class DataFlowBug {
+class DataFlowBug {
public int add2(Object left, Object right) {
if (left != null && !(left instanceof String)) {
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/NullableAnonymousMethod.java b/java/java-tests/testData/inspection/dataFlow/fixture/NullableAnonymousMethod.java
index 2d82c8b..6c63ff5 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/NullableAnonymousMethod.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/NullableAnonymousMethod.java
@@ -1,6 +1,6 @@
import org.jetbrains.annotations.Nullable;
-public class Bar {
+class Bar {
void navigateTo() {
Computable c = new Computable() {
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/NullableAnonymousParameter.java b/java/java-tests/testData/inspection/dataFlow/fixture/NullableAnonymousParameter.java
index 86c527e..db7fe28 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/NullableAnonymousParameter.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/NullableAnonymousParameter.java
@@ -1,6 +1,6 @@
import org.jetbrains.annotations.Nullable;
-public class Bar {
+class Bar {
void navigateTo(final@Nullable Object p) {
if (p == null) {
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/NullableField.java b/java/java-tests/testData/inspection/dataFlow/fixture/NullableField.java
index 0a341d3..c0cb53f 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/NullableField.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/NullableField.java
@@ -1,6 +1,6 @@
import org.jetbrains.annotations.Nullable;
-public class DDD {
+class DDD {
@Nullable
String field;
int test() {
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/NullableForeachVariable.java b/java/java-tests/testData/inspection/dataFlow/fixture/NullableForeachVariable.java
index 4fa1c64..027a659 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/NullableForeachVariable.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/NullableForeachVariable.java
@@ -3,7 +3,7 @@
import java.util.ArrayList;
import java.util.List;
-public class Foo {
+class Foo {
void foo1(List<Integer> list) {
for (@Nullable Integer i : list) {
System.out.println(<warning descr="Method invocation 'i.intValue()' may produce 'java.lang.NullPointerException'">i.intValue()</warning>);
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/OptionalThis.java b/java/java-tests/testData/inspection/dataFlow/fixture/OptionalThis.java
index 4e8547d..a7cbd47 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/OptionalThis.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/OptionalThis.java
@@ -1,7 +1,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-public class TestInspection {
+class TestInspection {
private static class StringWrapper {
private String inner = null;
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/PreserveNullableOnUncheckedCast.java b/java/java-tests/testData/inspection/dataFlow/fixture/PreserveNullableOnUncheckedCast.java
index f063d12..7eb316d 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/PreserveNullableOnUncheckedCast.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/PreserveNullableOnUncheckedCast.java
@@ -4,7 +4,7 @@
import java.util.Collection;
import java.util.List;
-public class BrokenAlignment {
+class BrokenAlignment {
void t() {
@NotNull Collection list = new ArrayList();
List<String> strings = (List<String>) list;
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/PrimitiveCastMayChangeValue.java b/java/java-tests/testData/inspection/dataFlow/fixture/PrimitiveCastMayChangeValue.java
index cfe0d0e..e89c688 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/PrimitiveCastMayChangeValue.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/PrimitiveCastMayChangeValue.java
@@ -1,5 +1,4 @@
-
-public class BrokenAlignment {
+class BrokenAlignment {
private static void foo(long value) {
if (value == (byte)value) {
System.out.println("1");
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/ReportConstantReferencesAfterFinalFieldAccess.java b/java/java-tests/testData/inspection/dataFlow/fixture/ReportConstantReferencesAfterFinalFieldAccess.java
index 9957eb7..e7e43f6 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/ReportConstantReferencesAfterFinalFieldAccess.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/ReportConstantReferencesAfterFinalFieldAccess.java
@@ -1,4 +1,4 @@
-public class Foo {
+class Foo {
private final boolean field = hashCode() == 2;
public void main(boolean b) {
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/ReturningNullFromVoidMethod.java b/java/java-tests/testData/inspection/dataFlow/fixture/ReturningNullFromVoidMethod.java
index e544bf1..14c9599 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/ReturningNullFromVoidMethod.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/ReturningNullFromVoidMethod.java
@@ -1,4 +1,4 @@
-public class BrokenAlignment {
+class BrokenAlignment {
Void test() {
return null;
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/SymmetricUncheckedCast.java b/java/java-tests/testData/inspection/dataFlow/fixture/SymmetricUncheckedCast.java
index 8c1087b..da742ea 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/SymmetricUncheckedCast.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/SymmetricUncheckedCast.java
@@ -1,6 +1,6 @@
import java.util.Date;
-public class DataFlowBug {
+class DataFlowBug {
private static boolean isNumberable(Object o) {
return o instanceof Number;
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/SynchronizingOnNullable.java b/java/java-tests/testData/inspection/dataFlow/fixture/SynchronizingOnNullable.java
index 7a83df6..1aa8232 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/SynchronizingOnNullable.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/SynchronizingOnNullable.java
@@ -1,6 +1,6 @@
import org.jetbrains.annotations.Nullable;
-public class BrokenAlignment {
+class BrokenAlignment {
void test(@Nullable Object n) {
synchronized (<warning descr="Dereference of 'n' may produce 'java.lang.NullPointerException'">n</warning>) {
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/TernaryInWhileNotComplex.java b/java/java-tests/testData/inspection/dataFlow/fixture/TernaryInWhileNotComplex.java
index a1b2aff..37e68cc 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/TernaryInWhileNotComplex.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/TernaryInWhileNotComplex.java
@@ -1,6 +1,6 @@
import java.util.List;
-public class Foo {
+class Foo {
public void matchAfterFragment(int patternIndex, int matchLen) {
int star = patternIndex < matchLen ? matchLen : -1;
while (matchLen > 0) {
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/ThrowNull.java b/java/java-tests/testData/inspection/dataFlow/fixture/ThrowNull.java
index e35aa2f..32a83f9 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/ThrowNull.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/ThrowNull.java
@@ -1,4 +1,4 @@
-public class DataFlowBug {
+class DataFlowBug {
public void add2() {
try {
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/TryCatchInForNotComplex.java b/java/java-tests/testData/inspection/dataFlow/fixture/TryCatchInForNotComplex.java
index 9097491..ebaed29 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/TryCatchInForNotComplex.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/TryCatchInForNotComplex.java
@@ -1,4 +1,4 @@
-public class Bar {
+class Bar {
public static void main(String[] args) {
for (String s : args) {
try {
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/TryInAnonymous.java b/java/java-tests/testData/inspection/dataFlow/fixture/TryInAnonymous.java
index f61d5cd..3e79713 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/TryInAnonymous.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/TryInAnonymous.java
@@ -1,4 +1,4 @@
-public class Bar {
+class Bar {
void submit(Runnable r) { }
String[] foos() { return new String[0]; }
diff --git a/java/java-tests/testData/inspection/nullableProblems/Problems.java b/java/java-tests/testData/inspection/nullableProblems/Problems.java
index a34f091..99ca9f9 100644
--- a/java/java-tests/testData/inspection/nullableProblems/Problems.java
+++ b/java/java-tests/testData/inspection/nullableProblems/Problems.java
@@ -9,7 +9,7 @@
}
}
-public class Y extends B {
+class Y extends B {
<warning descr="Cannot annotate with both @Nullable and @NotNull">@NotNull</warning> <warning descr="Cannot annotate with both @Nullable and @NotNull">@Nullable</warning> String s;
public void f(String <warning descr="Not annotated parameter overrides @NotNull parameter">p</warning>){}
diff --git a/java/java-tests/testData/psi/parser-full/declarationParsing/class/Errors4.txt b/java/java-tests/testData/psi/parser-full/declarationParsing/class/Errors4.txt
index f35984d..8380253 100644
--- a/java/java-tests/testData/psi/parser-full/declarationParsing/class/Errors4.txt
+++ b/java/java-tests/testData/psi/parser-full/declarationParsing/class/Errors4.txt
@@ -55,7 +55,6 @@
PsiJavaToken:EQ('=')
PsiWhiteSpace(' ')
PsiNewExpression:new Linked
- @Deprecated
PsiKeyword:new('new')
PsiReferenceParameterList
<empty list>
@@ -64,22 +63,22 @@
PsiIdentifier:Linked('Linked')
PsiReferenceParameterList
<empty list>
- PsiWhiteSpace('\n ')
- PsiAnnotation
- PsiJavaToken:AT('@')
- PsiJavaCodeReferenceElement:Deprecated
- PsiIdentifier:Deprecated('Deprecated')
- PsiReferenceParameterList
- <empty list>
- PsiAnnotationParameterList
- <empty list>
PsiErrorElement:'(' or '[' expected
<empty list>
PsiErrorElement:';' expected
<empty list>
- PsiWhiteSpace(' ')
+ PsiWhiteSpace('\n ')
PsiDeclarationStatement
- PsiTypeElement:List<Object>
+ PsiTypeElement:@Deprecated List<Object>
+ PsiAnnotation
+ PsiJavaToken:AT('@')
+ PsiJavaCodeReferenceElement:Deprecated
+ PsiIdentifier:Deprecated('Deprecated')
+ PsiReferenceParameterList
+ <empty list>
+ PsiAnnotationParameterList
+ <empty list>
+ PsiWhiteSpace(' ')
PsiJavaCodeReferenceElement:List<Object>
PsiIdentifier:List('List')
PsiReferenceParameterList
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/New18.txt b/java/java-tests/testData/psi/parser-partial/expressions/New18.txt
new file mode 100644
index 0000000..b81360a
--- /dev/null
+++ b/java/java-tests/testData/psi/parser-partial/expressions/New18.txt
@@ -0,0 +1,25 @@
+PsiJavaFile:New18.java
+ PsiNewExpression:new int @A [2]
+ PsiKeyword:new('new')
+ PsiReferenceParameterList
+ <empty list>
+ PsiWhiteSpace(' ')
+ PsiKeyword:int('int')
+ PsiWhiteSpace(' ')
+ PsiAnnotation
+ PsiJavaToken:AT('@')
+ PsiJavaCodeReferenceElement:A
+ PsiIdentifier:A('A')
+ PsiReferenceParameterList
+ <empty list>
+ PsiAnnotationParameterList
+ <empty list>
+ PsiWhiteSpace(' ')
+ PsiJavaToken:LBRACKET('[')
+ PsiLiteralExpression:2
+ PsiJavaToken:INTEGER_LITERAL('2')
+ PsiJavaToken:RBRACKET(']')
+ PsiWhiteSpace(' ')
+ PsiErrorElement:Unparsed tokens
+ PsiJavaToken:AT('@')
+ PsiIdentifier:B('B')
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/changeSignature/WarnAboutContract.java b/java/java-tests/testData/refactoring/changeSignature/WarnAboutContract.java
new file mode 100644
index 0000000..f3f573e
--- /dev/null
+++ b/java/java-tests/testData/refactoring/changeSignature/WarnAboutContract.java
@@ -0,0 +1,6 @@
+class A {
+ @org.jetbrains.annotations.Contract("null,_->fail")
+ public int method<caret>(Object i, Object j) {
+ return 0;
+ }
+}
diff --git a/java/java-tests/testData/refactoring/inlineSuperClass/innerclassReference/after/Test.java b/java/java-tests/testData/refactoring/inlineSuperClass/innerClassReference/after/Test.java
similarity index 100%
rename from java/java-tests/testData/refactoring/inlineSuperClass/innerclassReference/after/Test.java
rename to java/java-tests/testData/refactoring/inlineSuperClass/innerClassReference/after/Test.java
diff --git a/java/java-tests/testData/refactoring/inlineSuperClass/innerclassReference/before/Super.java b/java/java-tests/testData/refactoring/inlineSuperClass/innerClassReference/before/Super.java
similarity index 100%
rename from java/java-tests/testData/refactoring/inlineSuperClass/innerclassReference/before/Super.java
rename to java/java-tests/testData/refactoring/inlineSuperClass/innerClassReference/before/Super.java
diff --git a/java/java-tests/testData/refactoring/inlineSuperClass/innerclassReference/before/Test.java b/java/java-tests/testData/refactoring/inlineSuperClass/innerClassReference/before/Test.java
similarity index 100%
rename from java/java-tests/testData/refactoring/inlineSuperClass/innerclassReference/before/Test.java
rename to java/java-tests/testData/refactoring/inlineSuperClass/innerClassReference/before/Test.java
diff --git a/java/java-tests/testData/refactoring/inlineSuperClass/newexpr/after/Test.java b/java/java-tests/testData/refactoring/inlineSuperClass/newExpr/after/Test.java
similarity index 100%
rename from java/java-tests/testData/refactoring/inlineSuperClass/newexpr/after/Test.java
rename to java/java-tests/testData/refactoring/inlineSuperClass/newExpr/after/Test.java
diff --git a/java/java-tests/testData/refactoring/inlineSuperClass/newexpr/after/Usage.java b/java/java-tests/testData/refactoring/inlineSuperClass/newExpr/after/Usage.java
similarity index 100%
rename from java/java-tests/testData/refactoring/inlineSuperClass/newexpr/after/Usage.java
rename to java/java-tests/testData/refactoring/inlineSuperClass/newExpr/after/Usage.java
diff --git a/java/java-tests/testData/refactoring/inlineSuperClass/newexpr/before/Super.java b/java/java-tests/testData/refactoring/inlineSuperClass/newExpr/before/Super.java
similarity index 100%
rename from java/java-tests/testData/refactoring/inlineSuperClass/newexpr/before/Super.java
rename to java/java-tests/testData/refactoring/inlineSuperClass/newExpr/before/Super.java
diff --git a/java/java-tests/testData/refactoring/inlineSuperClass/newexpr/before/Test.java b/java/java-tests/testData/refactoring/inlineSuperClass/newExpr/before/Test.java
similarity index 100%
rename from java/java-tests/testData/refactoring/inlineSuperClass/newexpr/before/Test.java
rename to java/java-tests/testData/refactoring/inlineSuperClass/newExpr/before/Test.java
diff --git a/java/java-tests/testData/refactoring/inlineSuperClass/newexpr/before/Usage.java b/java/java-tests/testData/refactoring/inlineSuperClass/newExpr/before/Usage.java
similarity index 100%
rename from java/java-tests/testData/refactoring/inlineSuperClass/newexpr/before/Usage.java
rename to java/java-tests/testData/refactoring/inlineSuperClass/newExpr/before/Usage.java
diff --git a/java/java-tests/testData/refactoring/introduceVariable/CantCollapsedToDiamond.after.java b/java/java-tests/testData/refactoring/introduceVariable/CantCollapsedToDiamond.after.java
index 8598dc4..d350d8c 100644
--- a/java/java-tests/testData/refactoring/introduceVariable/CantCollapsedToDiamond.after.java
+++ b/java/java-tests/testData/refactoring/introduceVariable/CantCollapsedToDiamond.after.java
@@ -1,6 +1,6 @@
class Test {
void foo() {
- final Foo<Number> a = new Foo<Number>(1);
+ final Foo<Number> a = new Foo<>(1);
}
}
diff --git a/java/java-tests/testData/refactoring/introduceVariable/LambdaExprNotAccepted.after.java b/java/java-tests/testData/refactoring/introduceVariable/LambdaExprNotAccepted.after.java
index e8d7702..a4b5330 100644
--- a/java/java-tests/testData/refactoring/introduceVariable/LambdaExprNotAccepted.after.java
+++ b/java/java-tests/testData/refactoring/introduceVariable/LambdaExprNotAccepted.after.java
@@ -4,7 +4,7 @@
class Foo {
void test() {
- SAM<String> c = (i, j) -> "" + i + j;
+ SAM<X> c = (i, j) -> "" + i + j;
SAM<Integer> s3 = m(c);
}
<X> SAM<X> m(SAM<X> s) { return null; }
diff --git a/java/java-tests/testData/refactoring/introduceVariable/TypeAnnotations.after.java b/java/java-tests/testData/refactoring/introduceVariable/TypeAnnotations.after.java
index 13598a7..965568a 100644
--- a/java/java-tests/testData/refactoring/introduceVariable/TypeAnnotations.after.java
+++ b/java/java-tests/testData/refactoring/introduceVariable/TypeAnnotations.after.java
@@ -1,9 +1,7 @@
import java.lang.annotation.*;
-@Target({ElementType.TYPE_USE/*, ElementType.TYPE*/})
-@interface TA {
-
-}
+@Target({ElementType.TYPE_USE})
+@interface TA { }
class C {
void foo () {
diff --git a/java/java-tests/testData/refactoring/introduceVariable/TypeAnnotations.java b/java/java-tests/testData/refactoring/introduceVariable/TypeAnnotations.java
index bba9d94..7f7db71 100644
--- a/java/java-tests/testData/refactoring/introduceVariable/TypeAnnotations.java
+++ b/java/java-tests/testData/refactoring/introduceVariable/TypeAnnotations.java
@@ -1,9 +1,7 @@
import java.lang.annotation.*;
-@Target({ElementType.TYPE_USE/*, ElementType.TYPE*/})
-@interface TA {
-
-}
+@Target({ElementType.TYPE_USE})
+@interface TA { }
class C {
void foo () {
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/ClsGenericsHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/ClsGenericsHighlightingTest.java
index d9897f5..3cf2a83 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/ClsGenericsHighlightingTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/ClsGenericsHighlightingTest.java
@@ -20,47 +20,29 @@
*/
package com.intellij.codeInsight;
-import com.intellij.codeInsight.intention.AddAnnotationPsiFix;
-import com.intellij.codeInsight.intention.IntentionAction;
-import com.intellij.codeInsight.intention.impl.DeannotateIntentionAction;
-import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.application.Result;
import com.intellij.openapi.application.ex.PathManagerEx;
-import com.intellij.openapi.command.WriteCommandAction;
-import com.intellij.openapi.editor.CaretModel;
-import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.module.Module;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.roots.AnnotationOrderRootType;
import com.intellij.openapi.roots.ModifiableRootModel;
-import com.intellij.openapi.roots.ModuleRootManager;
+import com.intellij.openapi.roots.ModuleRootModificationUtil;
import com.intellij.openapi.roots.OrderRootType;
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.roots.libraries.LibraryTable;
-import com.intellij.openapi.util.Trinity;
-import com.intellij.openapi.util.io.FileUtil;
-import com.intellij.openapi.util.io.StreamUtil;
-import com.intellij.openapi.vfs.*;
-import com.intellij.psi.*;
-import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.openapi.vfs.JarFileSystem;
+import com.intellij.openapi.vfs.LocalFileSystem;
+import com.intellij.openapi.vfs.VfsUtilCore;
+import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.testFramework.IdeaTestCase;
-import com.intellij.testFramework.PsiTestUtil;
import com.intellij.testFramework.UsefulTestCase;
import com.intellij.testFramework.builders.JavaModuleFixtureBuilder;
import com.intellij.testFramework.fixtures.*;
-import com.intellij.util.messages.MessageBusConnection;
-import org.jetbrains.annotations.NonNls;
+import com.intellij.util.Consumer;
import org.jetbrains.annotations.NotNull;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
public class ClsGenericsHighlightingTest extends UsefulTestCase {
private CodeInsightTestFixture myFixture;
private Module myModule;
+ @SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors")
public ClsGenericsHighlightingTest() {
IdeaTestCase.initPlatformPrefix();
}
@@ -68,14 +50,11 @@
@Override
public void setUp() throws Exception {
super.setUp();
- final TestFixtureBuilder<IdeaProjectTestFixture> projectBuilder = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(getName());
-
+ TestFixtureBuilder<IdeaProjectTestFixture> projectBuilder = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(getName());
myFixture = JavaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(projectBuilder.getFixture());
- final String dataPath = PathManagerEx.getTestDataPath() + "/codeInsight/clsHighlighting";
- myFixture.setTestDataPath(dataPath);
- final JavaModuleFixtureBuilder builder = projectBuilder.addModule(JavaModuleFixtureBuilder.class);
+ myFixture.setTestDataPath(PathManagerEx.getTestDataPath() + "/codeInsight/clsHighlighting");
+ JavaModuleFixtureBuilder builder = projectBuilder.addModule(JavaModuleFixtureBuilder.class);
builder.setMockJdkLevel(JavaModuleFixtureBuilder.MockJdkLevel.jdk15);
-
myFixture.setUp();
myModule = builder.getFixture().getModule();
}
@@ -88,41 +67,37 @@
myModule = null;
}
- private void addLibrary(@NotNull final String... libraryPath) {
- ApplicationManager.getApplication().runWriteAction(new Runnable() {
- @Override
- public void run() {
- final ModifiableRootModel model = ModuleRootManager.getInstance(myModule).getModifiableModel();
- final LibraryTable libraryTable = model.getModuleLibraryTable();
- final Library library = libraryTable.createLibrary("test");
-
- final Library.ModifiableModel libraryModel = library.getModifiableModel();
- for (String annotationsDir : libraryPath) {
- final VirtualFile libJarLocal = LocalFileSystem.getInstance().findFileByPath(myFixture.getTestDataPath() + "/libs/" + annotationsDir);
- assertNotNull(libJarLocal);
- final VirtualFile jarRoot = JarFileSystem.getInstance().getJarRootForLocalFile(libJarLocal);
- assertNotNull(jarRoot);
- libraryModel.addRoot(jarRoot , OrderRootType.CLASSES);
- }
- libraryModel.commit();
- final String contentUrl = VfsUtilCore.pathToUrl(myFixture.getTempDirPath());
- model.addContentEntry(contentUrl).addSourceFolder(contentUrl, false);
- model.commit();
- }
- });
- }
-
- public void testIDEA97887() throws Throwable {
- doTest();
- }
-
- public void testIDEA118733() throws Exception {
- doTest();
- }
+ public void testIDEA97887() { doTest(); }
+ public void testIDEA118733() { doTest(); }
private void doTest() {
- addLibrary(getTestName(false) + ".jar");
- myFixture.configureByFile(getTestName(false) + ".java");
+ String name = getTestName(false);
+ addLibrary(name + ".jar");
+ myFixture.configureByFile(name + ".java");
myFixture.checkHighlighting();
}
+
+ private void addLibrary(@NotNull final String... libraryPath) {
+ ModuleRootModificationUtil.updateModel(myModule, new Consumer<ModifiableRootModel>() {
+ @Override
+ public void consume(ModifiableRootModel model) {
+ LibraryTable libraryTable = model.getModuleLibraryTable();
+ Library library = libraryTable.createLibrary("test");
+
+ Library.ModifiableModel libraryModel = library.getModifiableModel();
+ for (String annotationsDir : libraryPath) {
+ String path = myFixture.getTestDataPath() + "/libs/" + annotationsDir;
+ VirtualFile libJarLocal = LocalFileSystem.getInstance().findFileByPath(path);
+ assertNotNull(libJarLocal);
+ VirtualFile jarRoot = JarFileSystem.getInstance().getJarRootForLocalFile(libJarLocal);
+ assertNotNull(jarRoot);
+ libraryModel.addRoot(jarRoot, OrderRootType.CLASSES);
+ }
+ libraryModel.commit();
+
+ String contentUrl = VfsUtilCore.pathToUrl(myFixture.getTempDirPath());
+ model.addContentEntry(contentUrl).addSourceFolder(contentUrl, 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 308d1fb..4e8961d 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-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -53,6 +53,7 @@
import com.intellij.psi.statistics.StatisticsManager
import com.intellij.psi.statistics.impl.StatisticsManagerImpl
import com.intellij.util.containers.ContainerUtil
+import org.jetbrains.annotations.NotNull
import java.awt.event.KeyEvent
/**
@@ -547,7 +548,7 @@
static class LongReplacementOffsetContributor extends CompletionContributor {
@Override
- void duringCompletion(CompletionInitializationContext cxt) {
+ void duringCompletion(@NotNull CompletionInitializationContext cxt) {
Thread.sleep 500
ProgressManager.checkCanceled()
cxt.replacementOffset--;
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/MethodChainsCompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/MethodChainsCompletionTest.java
index 74e46e0..49c1c33 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/MethodChainsCompletionTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/MethodChainsCompletionTest.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2000-2014 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.JavaTestUtil;
@@ -9,6 +24,7 @@
import com.intellij.compiler.classFilesIndex.chainsSearch.completion.lookup.ChainCompletionMethodCallLookupElement;
import com.intellij.compiler.classFilesIndex.chainsSearch.completion.lookup.WeightableChainLookupElement;
import com.intellij.ide.util.PropertiesComponent;
+import com.intellij.testFramework.SkipSlowTestLocally;
import com.intellij.util.SmartList;
import java.util.List;
@@ -16,6 +32,7 @@
/**
* @author Dmitry Batkovich
*/
+@SkipSlowTestLocally
public class MethodChainsCompletionTest extends AbstractCompilerAwareTest {
private final static String TEST_INDEX_FILE_NAME = "TestIndex.java";
private final static String TEST_COMPLETION_FILE_NAME = "TestCompletion.java";
@@ -92,7 +109,7 @@
assertOneElement(doCompletion());
}
- public void testInnerClasses() {
+ public void _testInnerClasses() {
assertAdvisorLookupElementEquals("j.getEntry", 0, 8, 1, 0, assertOneElement(doCompletion()));
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy
index a511209..f07a963 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,6 +28,7 @@
import com.intellij.psi.PsiMethod
import com.intellij.psi.codeStyle.CodeStyleSettingsManager
import com.intellij.psi.codeStyle.CommonCodeStyleSettings
+import com.intellij.testFramework.EditorTestUtil
public class NormalCompletionTest extends LightFixtureCompletionTestCase {
@Override
@@ -755,6 +756,13 @@
assertStringItems("bar", "foo");
}
+ public void testAddExplicitValueInAnnotation() throws Throwable {
+ configureByTestName()
+ assertStringItems("bar", "goo")
+ selectItem(myItems[0])
+ checkResult()
+ }
+
public void testUnnecessaryMethodMerging() throws Throwable {
configureByFile(getTestName(false) + ".java");
assertStringItems("fofoo", "fofoo");
@@ -874,6 +882,16 @@
doAntiTest()
}
+ private void doMultiCaretTest() throws Exception {
+ EditorTestUtil.enableMultipleCarets()
+ try {
+ doTest()
+ }
+ finally {
+ EditorTestUtil.disableMultipleCarets()
+ }
+ }
+
private void doTest() throws Exception {
configure()
checkResult();
@@ -1365,6 +1383,26 @@
}}'''
}
+ public void testMulticaretSingleItemInsertion() {
+ doMultiCaretTest()
+ }
+
+ public void testMulticaretMethodWithParen() {
+ doMultiCaretTest()
+ }
+
+ public void testFinishWithEqualsWhenMultipleCaretsAreEnabled() {
+ EditorTestUtil.enableMultipleCarets()
+ try {
+ configureByFile("SpacesAroundEq.java");
+ type('=');
+ checkResultByFile("SpacesAroundEq_after.java");
+ }
+ finally {
+ EditorTestUtil.disableMultipleCarets()
+ }
+ }
+
public void "test complete lowercase class name"() {
myFixture.addClass("package foo; public class myClass {}")
myFixture.configureByText "a.java", """
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AdvHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AdvHighlightingTest.java
index 89d3792..ca25853 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AdvHighlightingTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AdvHighlightingTest.java
@@ -318,4 +318,10 @@
public void testPackageObscuring() throws Exception {
doTest(BASE_PATH + "/packageObscuring/main/Main.java", BASE_PATH + "/packageObscuring", false, false);
}
+ public void testPublicClassInRightFile() throws Exception {
+ doTest(BASE_PATH + "/publicClassInRightFile/x/X.java", BASE_PATH + "/publicClassInRightFile", false, false);
+ }
+ public void testPublicClassInRightFile2() throws Exception {
+ doTest(BASE_PATH + "/publicClassInRightFile/x/Y.java", BASE_PATH + "/publicClassInRightFile", false, false);
+ }
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AmbiguousMethodCallTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AmbiguousMethodCallTest.java
index 2042e29..f528f8f 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AmbiguousMethodCallTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AmbiguousMethodCallTest.java
@@ -20,6 +20,7 @@
import com.intellij.codeInspection.redundantCast.RedundantCastInspection;
import com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection;
import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection;
+import com.intellij.pom.java.LanguageLevel;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -52,4 +53,9 @@
public void testMultipleInheritance() throws Exception {
doTest(false, false);
}
+
+ @Override
+ protected LanguageLevel getLanguageLevel() {
+ return LanguageLevel.JDK_1_7;
+ }
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java
index 9455c0e..2ed84c6 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java
@@ -338,6 +338,8 @@
public void testIDEA118527() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
public void testIDEA120153() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
+ public void testSuperWildcardWithBoundPromotion() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);}
+
public void testJavaUtilCollections_NoVerify() throws Exception {
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));
assertNotNull(collectionsClass);
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/HighlightStressTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/HighlightStressTest.java
index 101fe0d..c593d04 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/HighlightStressTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/HighlightStressTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -37,6 +37,7 @@
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.PsiShortNamesCache;
import com.intellij.testFramework.PlatformTestUtil;
+import com.intellij.testFramework.SkipSlowTestLocally;
import com.intellij.util.text.CharArrayUtil;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NonNls;
@@ -44,6 +45,7 @@
import java.util.*;
+@SkipSlowTestLocally
public class HighlightStressTest extends LightDaemonAnalyzerTestCase {
@NotNull
@Override
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingPerformanceTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingPerformanceTest.java
index a0d0ffc..6b121b4 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingPerformanceTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingPerformanceTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,12 +28,14 @@
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.impl.source.tree.injected.JavaConcatenationInjectorManager;
import com.intellij.testFramework.PlatformTestUtil;
+import com.intellij.testFramework.SkipSlowTestLocally;
import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl;
import com.intellij.util.ThrowableRunnable;
import java.util.ArrayList;
import java.util.List;
+@SkipSlowTestLocally
public class LightAdvHighlightingPerformanceTest extends LightDaemonAnalyzerTestCase {
private final Disposable my = Disposer.newDisposable();
@Override
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java
index e873a0a..161d864 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java
@@ -25,10 +25,8 @@
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.JavaPsiFacade;
-import com.intellij.psi.PsiClass;
import com.intellij.psi.impl.source.resolve.PsiResolveHelperImpl;
import com.intellij.psi.impl.source.resolve.graphInference.PsiGraphInferenceHelper;
-import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.testFramework.IdeaTestUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -71,13 +69,13 @@
public void testInferenceWithBounds() {
doTest();
}
- public void _testInferenceWithSuperBounds() { //todo waiting for capture bound
+ public void testInferenceWithSuperBounds() {
doTest();
}
public void testInferenceWithUpperBoundPromotion() {
doTest();
}
- public void _testVariance() { //todo waiting for capture bound
+ public void testVariance() {
doTest();
}
public void testForeachTypes() {
@@ -246,7 +244,7 @@
public void testIDEA66311_16() {
doTest();
}
- public void _testIDEA76283() {//todo bounds
+ public void testIDEA76283() {
doTest();
}
public void testIDEA74899() {
@@ -741,6 +739,10 @@
doTest();
}
+ public void testCastToIntersectionType() throws Exception {
+ doTest();
+ }
+
private void doTest() {
doTest(false);
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java
index 8ca146b..1119a0d 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java
@@ -28,7 +28,7 @@
doTest();
}
- public void testNestedCallsSameMethod() throws Exception {
+ public void _testNestedCallsSameMethod() throws Exception {
doTest();
}
@@ -88,7 +88,11 @@
doTest();
}
- public void _testCapturedReturnTypes() throws Exception {//todo waiting for capture incorporation
+ public void testCapturedReturnTypes() throws Exception {
+ doTest();
+ }
+
+ public void testClsCapturedReturnTypes() throws Exception {
doTest();
}
@@ -128,6 +132,34 @@
doTest();
}
+ public void testDeepCallsChain() throws Exception {
+ doTest();
+ }
+
+ public void testArrayPassedToVarargsMethod() throws Exception {
+ doTest();
+ }
+
+ public void testIDEA121055() throws Exception {
+ doTest();
+ }
+
+ public void testTargetTypeByAnonymousClass() throws Exception {
+ doTest();
+ }
+
+ public void testStaticInheritorsAmbiguity() throws Exception {
+ doTest();
+ }
+
+ public void testNestedCalls1() throws Exception {
+ doTest();
+ }
+
+ public void testMostSpecificVarargsCase() throws Exception {
+ doTest();
+ }
+
private void doTest() throws Exception {
doTest(false);
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Interface8MethodsHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Interface8MethodsHighlightingTest.java
index 7e1832a..f43c937 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Interface8MethodsHighlightingTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Interface8MethodsHighlightingTest.java
@@ -33,6 +33,7 @@
public void testStaticMethodCalls() { doTest(false, false); }
public void testDefaultMethodOverrideEquivalentObject() { doTest(false, false); }
public void testStaticMethods() { doTest(false, false); }
+ public void testFinalStaticDefaultMethods() { doTest(false, false); }
public void testDefaultSupersInStaticContext() {
doTest(false, false);
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaHighlightingTest.java
index 93c629a..cf8f43b 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaHighlightingTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaHighlightingTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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,6 +77,7 @@
public void testIntersectionTypeInCast() { doTest(); }
public void testAmbiguitySpecificReturn() { doTest(true); }
public void testFunctionalInterfaceAnnotation() { doTest(); }
+ public void testFunctionalInterfaceAnnotation2() { doTest(); }
public void testAmbiguityReturnValueResolution() { doTest(); }
public void testAmbiguityReturnValueResolution1() { doTest(); }
public void testAmbiguityReturnValueResolution2() { doTest(true); }
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MostSpecificResolutionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MostSpecificResolutionTest.java
new file mode 100644
index 0000000..0cb2f0e
--- /dev/null
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MostSpecificResolutionTest.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.codeInsight.daemon.lambda;
+
+import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
+import com.intellij.codeInspection.LocalInspectionTool;
+import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection;
+import com.intellij.openapi.projectRoots.JavaSdkVersion;
+import com.intellij.openapi.projectRoots.Sdk;
+import com.intellij.testFramework.IdeaTestUtil;
+import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
+
+public class MostSpecificResolutionTest extends LightDaemonAnalyzerTestCase {
+ @NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific";
+
+ @NotNull
+ @Override
+ protected LocalInspectionTool[] configureLocalInspectionTools() {
+ return new LocalInspectionTool[]{
+ new UnusedSymbolLocalInspection(),
+ };
+ }
+
+ public void testVoidConflict() throws Exception {
+ doTest();
+ }
+
+ private void doTest() {
+ doTest(true);
+ }
+
+ private void doTest(boolean warnings) {
+ IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
+ doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false);
+ }
+
+ @Override
+ protected Sdk getProjectJDK() {
+ return IdeaTestUtil.getMockJdk18();
+ }
+}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java
index bfac8d3..89ddef2 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java
@@ -110,6 +110,33 @@
public void testAdditionalConstraintSubstitution() throws Exception {
doTest();
}
+ public void testFunctionalInterfacesCalculation() throws Exception {
+ doTest();
+ }
+
+ public void testMissedSiteSubstitutorDuringDeepAdditionalConstraintsGathering() throws Exception {
+ doTest();
+ }
+
+ public void testIDEA120992() throws Exception {
+ doTest();
+ }
+
+ public void testTargetTypeConflictResolverShouldNotTryToEvaluateCurrentArgumentType() throws Exception {
+ doTest();
+ }
+
+ public void testIDEA119535() throws Exception {
+ doTest();
+ }
+
+ public void testIDEA117124() throws Exception {
+ doTest();
+ }
+
+ public void testWildcardParameterization() throws Exception {
+ doTest();
+ }
private void doTest() {
doTest(false);
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java
index 31b2ec7..e944269 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java
@@ -157,6 +157,22 @@
doTest();
}
+ public void testExcludeContainingClassTypeParamsFromInference() throws Exception {
+ doTest();
+ }
+
+ public void testEnsureTypeParametersAreNotModifiedDuringGroundTypeEvaluation() throws Exception {
+ doTest();
+ }
+
+ public void testIncorrectArrayCreationSignature() throws Exception {
+ doTest();
+ }
+
+ public void testRawTargetType() throws Exception {
+ doTest();
+ }
+
private void doTest() {
doTest(false);
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RedundantLambdaParameterTypeIntentionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RedundantLambdaParameterTypeIntentionTest.java
index e9b9645..4f85962 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RedundantLambdaParameterTypeIntentionTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RedundantLambdaParameterTypeIntentionTest.java
@@ -15,6 +15,9 @@
*/
package com.intellij.codeInsight.daemon.quickFix;
+import com.intellij.openapi.projectRoots.Sdk;
+import com.intellij.testFramework.IdeaTestUtil;
+
public class RedundantLambdaParameterTypeIntentionTest extends LightQuickFixParameterizedTestCase {
public void test() throws Exception { doAllTests(); }
@@ -23,4 +26,8 @@
return "/codeInsight/daemonCodeAnalyzer/quickFix/redundantLambdaParameterType";
}
+ @Override
+ protected Sdk getProjectJDK() {
+ return IdeaTestUtil.getMockJdk18();
+ }
}
\ No newline at end of file
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RemoveRedundantArgumentTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RemoveRedundantArgumentTest.java
index e9b75ea..0642670 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RemoveRedundantArgumentTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RemoveRedundantArgumentTest.java
@@ -1,5 +1,7 @@
package com.intellij.codeInsight.daemon.quickFix;
+import com.intellij.pom.java.LanguageLevel;
+
public class RemoveRedundantArgumentTest extends LightQuickFixParameterizedTestCase {
public void test() throws Exception { doAllTests(); }
@@ -9,4 +11,8 @@
return "/codeInsight/daemonCodeAnalyzer/quickFix/removeRedundantArgument";
}
+ @Override
+ protected LanguageLevel getLanguageLevel() {
+ return LanguageLevel.JDK_1_7;
+ }
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Simplify2DiamondInspectionsTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Simplify2DiamondInspectionsTest.java
index eb3b795..44dcc2e 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Simplify2DiamondInspectionsTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Simplify2DiamondInspectionsTest.java
@@ -17,6 +17,7 @@
import com.intellij.codeInspection.ExplicitTypeCanBeDiamondInspection;
import com.intellij.codeInspection.LocalInspectionTool;
+import com.intellij.pom.java.LanguageLevel;
import org.jetbrains.annotations.NotNull;
@@ -37,4 +38,8 @@
return "/codeInsight/daemonCodeAnalyzer/quickFix/explicit2diamond";
}
+ @Override
+ protected LanguageLevel getLanguageLevel() {
+ return LanguageLevel.JDK_1_7;
+ }
}
\ No newline at end of file
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/StreamApiMigrationInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/StreamApiMigrationInspectionTest.java
new file mode 100644
index 0000000..a112ddf
--- /dev/null
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/StreamApiMigrationInspectionTest.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.codeInsight.daemon.quickFix;
+
+import com.intellij.codeInspection.LocalInspectionTool;
+import com.intellij.codeInspection.StreamApiMigrationInspection;
+import com.intellij.openapi.projectRoots.Sdk;
+import com.intellij.testFramework.IdeaTestUtil;
+import org.jetbrains.annotations.NotNull;
+
+
+public class StreamApiMigrationInspectionTest extends LightQuickFixParameterizedTestCase {
+ @NotNull
+ @Override
+ protected LocalInspectionTool[] configureLocalInspectionTools() {
+ return new LocalInspectionTool[]{
+ new StreamApiMigrationInspection(),
+ };
+ }
+
+ public void test() throws Exception { doAllTests(); }
+
+ @Override
+ protected String getBasePath() {
+ return "/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration";
+ }
+
+ @Override
+ protected Sdk getProjectJDK() {
+ return IdeaTestUtil.getMockJdk18();
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/VariableTypeFromCallTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/VariableTypeFromCallTest.java
index d4f8706..ace3cdf 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/VariableTypeFromCallTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/VariableTypeFromCallTest.java
@@ -16,6 +16,8 @@
package com.intellij.codeInsight.daemon.quickFix;
+import com.intellij.pom.java.LanguageLevel;
+
public class VariableTypeFromCallTest extends LightQuickFixParameterizedTestCase {
public void test() throws Exception { doAllTests(); }
@@ -25,5 +27,9 @@
return "/codeInsight/daemonCodeAnalyzer/quickFix/varTypeFromCall";
}
+ @Override
+ protected LanguageLevel getLanguageLevel() {
+ return LanguageLevel.JDK_1_7;
+ }
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/folding/JavaFoldingTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/folding/JavaFoldingTest.groovy
index 686fc6b..b462263 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/folding/JavaFoldingTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/folding/JavaFoldingTest.groovy
@@ -19,6 +19,7 @@
import com.intellij.codeInsight.folding.impl.CodeFoldingManagerImpl
import com.intellij.codeInsight.folding.impl.JavaCodeFoldingSettingsImpl
import com.intellij.find.FindManager
+import com.intellij.openapi.actionSystem.IdeActions
import com.intellij.openapi.application.ex.PathManagerEx
import com.intellij.openapi.editor.FoldRegion
import com.intellij.openapi.editor.ex.FoldingModelEx
@@ -35,10 +36,10 @@
* @since 1/17/11 1:00 PM
*/
public class JavaFoldingTest extends LightCodeInsightFixtureTestCase {
-
+
def JavaCodeFoldingSettingsImpl myFoldingSettings
def JavaCodeFoldingSettingsImpl myFoldingStateToRestore
-
+
@Override
public void setUp() {
super.setUp()
@@ -65,7 +66,7 @@
class Foo { List a; Map b; }
"""
-
+
assert myFixture.editor.foldingModel.getCollapsedRegionAtOffset(10)
myFixture.type 'import '
@@ -118,25 +119,25 @@
}
}
"""
-
+
configure text
def foldingModel = myFixture.editor.foldingModel as FoldingModelImpl
def closureStartFold = foldingModel.getCollapsedRegionAtOffset(text.indexOf("Runnable"))
assertNotNull closureStartFold
assertFalse closureStartFold.expanded
-
+
assertNotNull closureStartFold.group
def closureFolds = foldingModel.getGroupedRegions(closureStartFold.group)
assertNotNull closureFolds
assertEquals(2, closureFolds.size())
-
+
def closureEndFold = closureFolds.get(1)
assertFalse closureEndFold.expanded
-
+
myFixture.editor.caretModel.moveToOffset(closureEndFold.startOffset + 1)
assertTrue closureStartFold.expanded
assertTrue closureEndFold.expanded
-
+
changeFoldRegions { closureStartFold.expanded = false }
assertTrue closureStartFold.expanded
assertTrue closureEndFold.expanded
@@ -172,7 +173,7 @@
assertNotNull closureFolds
assertEquals(2, closureFolds.size())
}
-
+
public void "test builder style setter"() {
myFoldingSettings.COLLAPSE_ACCESSORS = true
def text = """\
@@ -379,22 +380,22 @@
FindManager.getInstance(project).findNextUsageInEditor(TextEditorProvider.getInstance().getTextEditor(myFixture.editor))
assertEquals('test1', myFixture.editor.selectionModel.selectedText)
}
-
+
public void testCustomFolding() {
myFixture.testFolding("$PathManagerEx.testDataPath/codeInsight/folding/${getTestName(false)}.java");
}
-
+
public void "test move methods"() {
def initialText = '''\
class Test {
void test1() {
}
-
+
void test2() {
}
}
'''
-
+
Closure<FoldRegion> fold = { String methodName ->
def text = myFixture.editor.document.text
def nameIndex = text.indexOf(methodName)
@@ -444,7 +445,7 @@
assertEquals(2, folds[0].startOffset)
assertEquals(6, folds[0].endOffset)
}
-
+
private def configure(String text) {
myFixture.configureByText("a.java", text)
CodeFoldingManagerImpl.getInstance(getProject()).buildInitialFoldings(myFixture.editor);
@@ -458,21 +459,21 @@
int field;
int field2;
int field3;
-
+
int getField()
{
return field;
}
-
+
void setField(int f) {
field = f;
}
-
+
void setField2(int f){field2=f;} // normal method folding here
// normal method folding here
void setField3(int f){
-
+
field2=f;
}
@@ -480,10 +481,10 @@
PsiClass fooClass = JavaPsiFacade.getInstance(project).findClass('Foo', GlobalSearchScope.allScope(project))
def regions = myFixture.editor.foldingModel.allFoldRegions.sort { it.startOffset }
assert regions.size() == 6
-
+
checkAccessorFolding(regions[0], regions[1], fooClass.methods[0])
checkAccessorFolding(regions[2], regions[3], fooClass.methods[1])
-
+
assert regions[4].placeholderText == '{...}'
assert regions[5].placeholderText == '{...}'
}
@@ -504,7 +505,7 @@
int someMethod() {
return 0;
}
-
+
}"""
PsiClass fooClass = JavaPsiFacade.getInstance(project).findClass('Foo', GlobalSearchScope.allScope(project))
def regions = myFixture.editor.foldingModel.allFoldRegions.sort { it.startOffset }
@@ -516,7 +517,7 @@
configure """class Foo {
int someVeryVeryLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongVariable;
- // don't create folding that would exceed the right margin
+ // don't create folding that would exceed the right margin
int getSomeVeryVeryLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongVariable() {
return someVeryVeryLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongVariable;
}
@@ -529,4 +530,18 @@
private def changeFoldRegions(Closure op) {
myFixture.editor.foldingModel.runBatchFoldingOperationDoNotCollapseCaret(op)
}
+
+ public void "test unselect word should go inside folding group"() {
+ configure """class Foo {
+ int field;
+
+ <selection>int getField() {
+ <caret>return field;
+ }</selection>
+
+}"""
+ assertSize 2, myFixture.editor.foldingModel.allFoldRegions
+ myFixture.performEditorAction(IdeActions.ACTION_EDITOR_UNSELECT_WORD_AT_CARET)
+ assert 'return field;' == myFixture.editor.selectionModel.selectedText
+ }
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/template/postfix/completion/TemplatesCompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/template/postfix/completion/TemplatesCompletionTest.java
index 26de5c1..39fd2fb 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/template/postfix/completion/TemplatesCompletionTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/template/postfix/completion/TemplatesCompletionTest.java
@@ -19,30 +19,18 @@
import com.intellij.codeInsight.completion.CompletionAutoPopupTestCase;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.impl.LookupImpl;
+import com.intellij.codeInsight.template.impl.LiveTemplateCompletionContributor;
import com.intellij.codeInsight.template.postfix.settings.PostfixTemplatesSettings;
import com.intellij.codeInsight.template.postfix.templates.*;
-import com.intellij.openapi.util.registry.Registry;
-import com.intellij.openapi.util.registry.RegistryValue;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class TemplatesCompletionTest extends CompletionAutoPopupTestCase {
- private boolean oldRegistryValue;
-
- @Override
- public void setUp() {
- super.setUp();
- RegistryValue registryValue = Registry.get("show.live.templates.in.completion");
- oldRegistryValue = registryValue.asBoolean();
- registryValue.setValue(false);
- }
-
@Override
public void tearDown() throws Exception {
- RegistryValue registryValue = Registry.get("show.live.templates.in.completion");
- registryValue.setValue(oldRegistryValue);
+ LiveTemplateCompletionContributor.ourShowTemplatesInTests = false;
PostfixTemplatesSettings settings = PostfixTemplatesSettings.getInstance();
assertNotNull(settings);
@@ -53,13 +41,13 @@
}
public void testSimpleCompletionList() {
- Registry.get("show.live.templates.in.completion").setValue(true);
+ LiveTemplateCompletionContributor.ourShowTemplatesInTests = true;
doAutoPopupTest("ins", InstanceofExpressionPostfixTemplate.class);
}
public void testAutopopupWithEnabledLiveTemplatesInCompletion() {
- Registry.get("show.live.templates.in.completion").setValue(true);
+ LiveTemplateCompletionContributor.ourShowTemplatesInTests = true;
configureByFile();
type("instanceof");
@@ -155,6 +143,18 @@
type("r");
myFixture.assertPreferredCompletionItems(selectedIndex, ".par", "parents");
}
+
+ public void testTabCompletionWithTemplatesInAutopopup() {
+ LiveTemplateCompletionContributor.ourShowTemplatesInTests = true;
+
+ configureByFile();
+ type(".");
+ myFixture.assertPreferredCompletionItems(0, "parents");
+
+ type("\t");
+ assertNull(getLookup());
+ checkResultByFile();
+ }
@Override
protected String getBasePath() {
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/template/postfix/templates/InstanceofPostfixTemplateTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/template/postfix/templates/InstanceofPostfixTemplateTest.java
index f5e363c..090447d 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/template/postfix/templates/InstanceofPostfixTemplateTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/template/postfix/templates/InstanceofPostfixTemplateTest.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2000-2014 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.template.postfix.templates;
import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
@@ -7,6 +22,7 @@
public class InstanceofPostfixTemplateTest extends PostfixTemplateTestCase {
public void testSingleExpression() { doTest(); }
public void testAlias() { doTest(); }
+ public void testPrimitive() { doTest(); }
public void testSingleExpressionTemplate() {
TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable());
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/template/postfix/templates/NotNullPostfixTemplateTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/template/postfix/templates/NotNullPostfixTemplateTest.java
index ab3b93c..ca08b68 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/template/postfix/templates/NotNullPostfixTemplateTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/template/postfix/templates/NotNullPostfixTemplateTest.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2000-2014 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.template.postfix.templates;
import org.jetbrains.annotations.NotNull;
@@ -11,6 +26,7 @@
protected String getSuffix() { return "notnull"; }
public void testSimple() { doTest(); }
+ public void testPrimitive() { doTest(); }
public void testNn() { doTest(); }
public void testSecondStatement() { doTest(); }
}
\ No newline at end of file
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/template/postfix/templates/NullPostfixTemplateTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/template/postfix/templates/NullPostfixTemplateTest.java
index 7f501b6..9c3fce6 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/template/postfix/templates/NullPostfixTemplateTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/template/postfix/templates/NullPostfixTemplateTest.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2000-2014 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.template.postfix.templates;
import org.jetbrains.annotations.NotNull;
@@ -11,5 +26,6 @@
protected String getSuffix() { return "null"; }
public void testSimple() { doTest(); }
+ public void testPrimitive() { doTest(); }
public void testSecondStatement() { doTest(); }
}
\ No newline at end of file
diff --git a/java/java-tests/testSrc/com/intellij/concurrency/JobUtilTest.java b/java/java-tests/testSrc/com/intellij/concurrency/JobUtilTest.java
deleted file mode 100644
index d0ab59b..0000000
--- a/java/java-tests/testSrc/com/intellij/concurrency/JobUtilTest.java
+++ /dev/null
@@ -1,330 +0,0 @@
-/*
- * Copyright 2000-2014 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.concurrency;
-
-import com.intellij.codeInsight.daemon.impl.DaemonProgressIndicator;
-import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.progress.ProcessCanceledException;
-import com.intellij.openapi.progress.ProgressIndicator;
-import com.intellij.openapi.progress.ProgressManager;
-import com.intellij.openapi.progress.util.AbstractProgressIndicatorBase;
-import com.intellij.openapi.progress.util.ProgressIndicatorBase;
-import com.intellij.testFramework.PlatformTestCase;
-import com.intellij.util.Processor;
-
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
-
-public class JobUtilTest extends PlatformTestCase {
- @Override
- protected boolean isRunInWriteAction() {
- return false;
- }
-
- public void testUnbalancedTaskJobUtilPerformance() {
- List<Integer> things = new ArrayList<Integer>(Collections.<Integer>nCopies(10000, null));
- int sum = 0;
- for (int i = 0; i < things.size(); i++) {
- int v = i < 9950 ? 1 : 1000;
- things.set(i, v);
- sum += things.get(i);
- }
- assertEquals(59950, sum);
-
- long start = System.currentTimeMillis();
- boolean b = JobLauncher.getInstance().invokeConcurrentlyUnderProgress(things, new ProgressIndicatorBase(), false, false, new Processor<Integer>() {
- @Override
- public boolean process(Integer o) {
- busySleep(o);
- return true;
- }
- });
- assertTrue(b);
- long elapsed = System.currentTimeMillis() - start;
- int expected = 2 * (9950 + 50 * 1000) / JobSchedulerImpl.CORES_COUNT;
- String message = "Elapsed: " + elapsed + "; expected: " + expected;
- System.out.println(message);
- assertTrue(message, elapsed < expected);
- }
- private static final AtomicInteger COUNT = new AtomicInteger();
-
- private static int busySleep(int ms) {
- long end = System.currentTimeMillis() + ms;
- while (System.currentTimeMillis() < end);
- return COUNT.incrementAndGet();
- }
-
- public void testJobUtilCorrectlySplitsUpHugeWorkAndFinishes() throws Exception {
- COUNT.set(0);
- int N = 100000;
- List<String> list = Collections.nCopies(N, null);
- final AtomicReference<Exception> exception = new AtomicReference<Exception>();
- final AtomicBoolean finished = new AtomicBoolean();
-
- JobLauncher.getInstance().invokeConcurrentlyUnderProgress(list, null, false, new Processor<String>() {
- @Override
- public boolean process(String name) {
- try {
- if (finished.get()) {
- throw new RuntimeException();
- }
- for (int i = 0; i < 1000; i++) {
- new BigDecimal(i).multiply(new BigDecimal(1));
- }
- busySleep(1);
- if (finished.get()) {
- throw new RuntimeException();
- }
- }
- catch (Exception e) {
- exception.set(e);
- }
- return true;
- }
- });
- finished.set(true);
- Thread.sleep(1000);
- if (exception.get() != null) throw exception.get();
- assertEquals(N, COUNT.get());
- }
-
- public void testJobUtilProcessesAllItems() throws Exception {
- List<String> list = Collections.nCopies(10000, null);
- final AtomicReference<Exception> exception = new AtomicReference<Exception>();
- for (int i=0; i<10; i++) {
- long start = System.currentTimeMillis();
- COUNT.set(0);
- JobLauncher.getInstance().invokeConcurrentlyUnderProgress(list, null, false, new Processor<String>() {
- @Override
- public boolean process(String name) {
- busySleep(1);
- return true;
- }
- });
- if (exception.get() != null) throw exception.get();
- long finish = System.currentTimeMillis();
- System.out.println("Elapsed: "+(finish-start)+"ms");
- assertEquals(list.size(), COUNT.get());
- }
- }
-
- public void testJobUtilRecursive() throws Exception {
- final List<String> list = Collections.nCopies(100, null);
- for (int i=0; i<10; i++) {
- COUNT.set(0);
- long start = System.currentTimeMillis();
- JobLauncher.getInstance().invokeConcurrentlyUnderProgress(list, null, false, new Processor<String>() {
- @Override
- public boolean process(String name) {
- JobLauncher.getInstance().invokeConcurrentlyUnderProgress(list, null, false, new Processor<String>() {
- @Override
- public boolean process(String name) {
- busySleep(1);
- return true;
- }
- });
- return true;
- }
- });
- long finish = System.currentTimeMillis();
- System.out.println("Elapsed: "+(finish-start)+"ms");
- assertEquals(list.size()*list.size(), COUNT.get());
- }
- }
-
- public void testCorrectProgressAndReadAction() throws Throwable {
- checkProgressAndReadAction(Collections.singletonList(null), new DaemonProgressIndicator(), true);
- checkProgressAndReadAction(Collections.singletonList(null), new DaemonProgressIndicator(), false);
- checkProgressAndReadAction(Collections.emptyList(), new DaemonProgressIndicator(), true);
- checkProgressAndReadAction(Collections.emptyList(), new DaemonProgressIndicator(), false);
- checkProgressAndReadAction(Arrays.asList(new Object(), new Object()), new DaemonProgressIndicator(), true);
- checkProgressAndReadAction(Arrays.asList(new Object(), new Object()), new DaemonProgressIndicator(), false);
- checkProgressAndReadAction(Arrays.asList(new Object(), new Object()), null, false);
- }
-
- private static void checkProgressAndReadAction(final List<Object> objects,
- final DaemonProgressIndicator progress,
- final boolean runInReadAction) throws Throwable {
- final AtomicReference<Throwable> exception = new AtomicReference<Throwable>();
- JobLauncher.getInstance().invokeConcurrentlyUnderProgress(objects, progress, runInReadAction, new Processor<Object>() {
- @Override
- public boolean process(Object o) {
- try {
- if (objects.size() <= 1 || JobSchedulerImpl.CORES_COUNT <= JobLauncherImpl.CORES_FORK_THRESHOLD) {
- assertTrue(ApplicationManager.getApplication().isDispatchThread());
- }
- else {
- // generally we know nothing about current thread since FJP can help others task to execute while in current context
- }
- ProgressIndicator actualIndicator = ProgressManager.getInstance().getProgressIndicator();
- if (progress == null) {
- assertNotNull(actualIndicator);
- assertTrue(actualIndicator instanceof AbstractProgressIndicatorBase);
- }
- else {
- assertTrue(actualIndicator instanceof SensitiveProgressWrapper);
- ProgressIndicator original = ((SensitiveProgressWrapper)actualIndicator).getOriginalProgressIndicator();
- assertSame(progress, original);
- }
- // there can be read access even if we didn't ask for it (e.g. when task under read action steals others work)
- assertTrue(!runInReadAction || ApplicationManager.getApplication().isReadAccessAllowed());
- }
- catch (Throwable e) {
- exception.set(e);
- }
- return true;
- }
- });
- if (exception.get() != null) throw exception.get();
- }
-
- public void testExceptionalCompletion() throws Throwable {
- final List<Object> objects = Collections.nCopies(100000000, null);
- COUNT.set(0);
- try {
- JobLauncher.getInstance().invokeConcurrentlyUnderProgress(objects, null, true, new Processor<Object>() {
- @Override
- public boolean process(Object o) {
- if (COUNT.incrementAndGet() == 100000) {
- System.out.println("PCE");
- throw new ProcessCanceledException();
- }
- return true;
- }
- });
- fail("PCE must have been thrown");
- }
- catch (ProcessCanceledException e) {
- // caught OK
- }
- }
- public void testNotNormalCompletion() throws Throwable {
- final List<Object> objects = Collections.nCopies(100000000, null);
- COUNT.set(0);
- try {
- boolean success = JobLauncher.getInstance().invokeConcurrentlyUnderProgress(objects, null, true, new Processor<Object>() {
- @Override
- public boolean process(Object o) {
- if (COUNT.incrementAndGet() == 100000) {
- System.out.println("PCE");
- return false;
- }
- return true;
- }
- });
- assertFalse(success);
- }
- catch (ProcessCanceledException e) {
- }
- }
-
- public void testJobUtilCompletesEvenIfCannotGrabReadAction() throws Throwable {
- final List<Object> objects = Collections.nCopies(1000000, null);
- COUNT.set(0);
- ApplicationManager.getApplication().runWriteAction(new Runnable() {
- @Override
- public void run() {
- boolean success = JobLauncher.getInstance().invokeConcurrentlyUnderProgress(objects, null, true, false, new Processor<Object>() {
- @Override
- public boolean process(Object o) {
- COUNT.incrementAndGet();
- return true;
- }
- });
- assertTrue(success);
- assertEquals(objects.size(), COUNT.get());
- }
- });
- }
-
- public void testJobUtilRecursiveCancel() throws Exception {
- final List<String> list = Collections.nCopies(100, "");
- final List<Integer> ilist = Collections.nCopies(100, 0);
- for (int i=0; i<10; i++) {
- COUNT.set(0);
- long start = System.currentTimeMillis();
- boolean success = false;
- try {
- success = JobLauncher.getInstance().invokeConcurrentlyUnderProgress(list, null, false, new Processor<String>() {
- @Override
- public boolean process(String name) {
- boolean nestedSuccess = JobLauncher.getInstance().invokeConcurrentlyUnderProgress(ilist, null, false, new Processor<Integer>() {
- @Override
- public boolean process(Integer integer) {
- if (busySleep(1) == 1000) {
- System.out.println("PCE");
- throw new RuntimeException("xxx");
- }
- return true;
- }
- });
- //System.out.println("nestedSuccess = " + nestedSuccess);
- return true;
- }
- });
- }
- catch (ProcessCanceledException e) {
- // OK
- }
- catch (RuntimeException e) {
- assertEquals("xxx", e.getMessage());
- }
- long finish = System.currentTimeMillis();
- System.out.println("Elapsed: "+(finish-start)+"ms");
- //assertEquals(list.size()*list.size(), COUNT.get());
- assertFalse(success);
- }
- }
-
- public void testSaturation() throws InterruptedException {
- final CountDownLatch latch = new CountDownLatch(1);
- for (int i=0; i<100; i++) {
- JobLauncher.getInstance().submitToJobThread(0, new Runnable() {
- @Override
- public void run() {
- try {
- latch.await();
- }
- catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
- }
- });
- }
- JobLauncher.getInstance().submitToJobThread(0, new Runnable() {
- @Override
- public void run() {
- latch.countDown();
- }
- });
-
- try {
- boolean scheduled = latch.await(3, TimeUnit.SECONDS);
- assertFalse(scheduled); // pool saturated, no thread can be scheduled
- }
- finally {
- latch.countDown();
- }
- }
-}
diff --git a/java/java-tests/testSrc/com/intellij/execution/BaseConfigurationTestCase.java b/java/java-tests/testSrc/com/intellij/execution/BaseConfigurationTestCase.java
index 2ddd8d1..9092e25 100644
--- a/java/java-tests/testSrc/com/intellij/execution/BaseConfigurationTestCase.java
+++ b/java/java-tests/testSrc/com/intellij/execution/BaseConfigurationTestCase.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.intellij.execution;
import com.intellij.execution.actions.ConfigurationContext;
@@ -5,7 +20,9 @@
import com.intellij.execution.actions.RunConfigurationProducer;
import com.intellij.execution.configurations.RunConfiguration;
import com.intellij.execution.junit.JUnitConfiguration;
-import com.intellij.openapi.actionSystem.DataConstants;
+import com.intellij.execution.junit.JUnitConfigurationProducer;
+import com.intellij.openapi.actionSystem.CommonDataKeys;
+import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ex.PathManagerEx;
import com.intellij.openapi.module.Module;
@@ -25,6 +42,7 @@
import com.intellij.testFramework.MapDataContext;
import com.intellij.testFramework.PsiTestUtil;
import com.intellij.testFramework.TempFiles;
+import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.IOException;
@@ -64,7 +82,7 @@
ModuleRootModificationUtil.addModuleLibrary(module, mockJUnit.getUrl());
ModuleRootModificationUtil.setModuleSdk(module, ModuleRootManager.getInstance(myModule).getSdk());
GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module);
- VirtualFile testCase = mockJUnit.findChild("junit").findChild("framework").findChild("TestCase.java");
+ VirtualFile testCase = mockJUnit.findFileByRelativePath("junit/framework/TestCase.java");
assertNotNull(testCase);
assertTrue(scope.contains(testCase));
Module missingModule = createTempModule();
@@ -139,37 +157,39 @@
return JavaPsiFacade.getInstance(myProject).findClass(qualifiedName, scope);
}
- protected JUnitConfiguration createJUnitConfiguration(final PsiElement psiElement,
- final Class producerClass,
- final MapDataContext dataContext) {
+ protected JUnitConfiguration createJUnitConfiguration(@NotNull PsiElement psiElement,
+ @NotNull Class<? extends JUnitConfigurationProducer> producerClass,
+ @NotNull MapDataContext dataContext) {
ConfigurationContext context = createContext(psiElement, dataContext);
RunConfigurationProducer producer = RunConfigurationProducer.getInstance(producerClass);
assert producer != null;
ConfigurationFromContext fromContext = producer.createConfigurationFromContext(context);
+ assertNotNull(fromContext);
return (JUnitConfiguration)fromContext.getConfiguration();
}
- protected final <T extends RunConfiguration> T createConfiguration(PsiElement psiElement) {
- return (T)createConfiguration(psiElement, new MapDataContext());
+ protected final <T extends RunConfiguration> T createConfiguration(@NotNull PsiElement psiElement) {
+ return createConfiguration(psiElement, new MapDataContext());
}
- protected <T extends RunConfiguration> T createConfiguration(PsiElement psiElement, MapDataContext dataContext) {
+ protected <T extends RunConfiguration> T createConfiguration(@NotNull PsiElement psiElement, @NotNull MapDataContext dataContext) {
ConfigurationContext context = createContext(psiElement, dataContext);
RunnerAndConfigurationSettings settings = context.getConfiguration();
- return settings == null ? null : (T)settings.getConfiguration();
+ @SuppressWarnings("unchecked") T configuration = settings == null ? null : (T)settings.getConfiguration();
+ return configuration;
}
- public ConfigurationContext createContext(PsiElement psiClass) {
+ public ConfigurationContext createContext(@NotNull PsiElement psiClass) {
MapDataContext dataContext = new MapDataContext();
return createContext(psiClass, dataContext);
}
- public ConfigurationContext createContext(PsiElement psiClass, MapDataContext dataContext) {
- dataContext.put(DataConstants.PROJECT, myProject);
- if (dataContext.getData(DataConstants.MODULE) == null) {
- dataContext.put(DataConstants.MODULE, ModuleUtilCore.findModuleForPsiElement(psiClass));
+ public ConfigurationContext createContext(@NotNull PsiElement psiClass, @NotNull MapDataContext dataContext) {
+ dataContext.put(CommonDataKeys.PROJECT, myProject);
+ if (LangDataKeys.MODULE.getData(dataContext) == null) {
+ dataContext.put(LangDataKeys.MODULE, ModuleUtilCore.findModuleForPsiElement(psiClass));
}
- dataContext.put(Location.LOCATION, PsiLocation.fromPsiElement(psiClass));
+ dataContext.put(Location.DATA_KEY, PsiLocation.fromPsiElement(psiClass));
return ConfigurationContext.getFromContext(dataContext);
}
diff --git a/java/java-tests/testSrc/com/intellij/execution/ConfigurationRefactoringsTest.java b/java/java-tests/testSrc/com/intellij/execution/ConfigurationRefactoringsTest.java
index a5d882c..174b9af 100644
--- a/java/java-tests/testSrc/com/intellij/execution/ConfigurationRefactoringsTest.java
+++ b/java/java-tests/testSrc/com/intellij/execution/ConfigurationRefactoringsTest.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.intellij.execution;
import com.intellij.execution.application.ApplicationConfiguration;
@@ -6,6 +21,7 @@
import com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl;
import com.intellij.execution.junit.AllInPackageConfigurationProducer;
import com.intellij.execution.junit.JUnitConfiguration;
+import com.intellij.execution.junit.JUnitConfigurationProducer;
import com.intellij.execution.junit.JUnitConfigurationType;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.command.WriteCommandAction;
@@ -19,6 +35,7 @@
import com.intellij.refactoring.rename.RenameProcessor;
import com.intellij.testFramework.MapDataContext;
import com.intellij.util.containers.HashSet;
+import org.jetbrains.annotations.NotNull;
import java.io.IOException;
@@ -38,6 +55,7 @@
"}";
public void testRenameApplication() throws IOException {
PsiClass psiClass = mySource.createClass("Application", APPLICATION_CODE);
+ assertNotNull(psiClass);
ApplicationConfiguration configuration = createConfiguration(psiClass);
assertNotNull(configuration);
rename(psiClass, "NewName");
@@ -52,6 +70,7 @@
public void testMoveApplication() throws IOException {
PsiClass psiClass = mySource.createClass("Application", APPLICATION_CODE);
+ assertNotNull(psiClass);
ApplicationConfiguration configuration = createConfiguration(psiClass);
move(psiClass, "pkg");
try {
@@ -71,15 +90,16 @@
JUnitConfiguration configuration = createJUnitConfiguration(psiPackage, AllInPackageConfigurationProducer.class, new MapDataContext());
rename(psiPackage, "pkg2");
checkPackage("pkg2", configuration);
- PsiPackage outter = mySource.createPackage("outterPkg");
- move(JavaPsiFacade.getInstance(myProject).findPackage("pkg2"), outter.getQualifiedName());
- checkPackage("outterPkg.pkg2", configuration);
- rename(outter, "outter2");
- checkPackage("outter2.pkg2", configuration);
+ PsiPackage outer = mySource.createPackage("outerPkg");
+ move(JavaPsiFacade.getInstance(myProject).findPackage("pkg2"), outer.getQualifiedName());
+ checkPackage("outerPkg.pkg2", configuration);
+ rename(outer, "outer2");
+ checkPackage("outer2.pkg2", configuration);
}
public void testRenameJUnitContainingPackage() throws IOException {
PsiClass psiClass = mySource.createClass("ATest", TEST_CODE);
+ assertNotNull(psiClass);
JUnitConfiguration configuration = createConfiguration(psiClass);
PsiPackage psiPackage = mySource.createPackage("pkg");
move(psiClass, "pkg");
@@ -95,6 +115,7 @@
public void testRefactorTestMethod() throws IOException {
PsiClass psiClass = mySource.createClass("ATest", TEST_CODE);
+ assertNotNull(psiClass);
PsiMethod testMethod = psiClass.findMethodsByName("test", false)[0];
JUnitConfiguration configuration = createConfiguration(testMethod);
rename(testMethod, "test1");
@@ -110,6 +131,7 @@
PsiClass otherTest = mySource.createClass("ATest", TEST_CODE);
HashSet<PsiMember> members = new HashSet<PsiMember>();
+ assertNotNull(psiClass);
members.add(psiClass.findMethodsByName("test1", false)[0]);
moveMembers(otherTest, members);
psiClass = configuration.getConfigurationModule().findClass(configuration.getPersistentData().getMainClassName());
@@ -117,6 +139,7 @@
checkClassName("ATest", configuration);
assertEquals("ATest.test1", configuration.getName());
+ assertNotNull(psiClass);
PsiMethod otherMethod = psiClass.findMethodsByName("otherMethod", false)[0];
rename(otherMethod, "newName");
checkMethodName("test1", configuration);
@@ -124,11 +147,13 @@
public void testRenameBadTestClass() throws IOException {
PsiClass psiClass = mySource.createClass("NotATest", NOT_A_TEST);
- JUnitConfiguration configuration = new JUnitConfiguration("notATest", myProject, JUnitConfigurationType.getInstance().getConfigurationFactories()[0]);
+ assertNotNull(psiClass);
+ JUnitConfigurationType instance = JUnitConfigurationType.getInstance();
+ assertNotNull(instance);
+ JUnitConfiguration configuration = new JUnitConfiguration("notATest", myProject, instance.getConfigurationFactories()[0]);
configuration.setMainClass(psiClass);
configuration.setModule(configuration.getValidModules().iterator().next());
-
checkConfigurationException("NotATest isn't test class", configuration);
RunManagerEx.getInstanceEx(myProject).setTemporaryConfiguration(new RunnerAndConfigurationSettingsImpl(null, configuration, false));
@@ -144,7 +169,7 @@
assertEquals("test2", data.getMethodName());
}
- private void checkConfigurationException(String expectedExceptionMessage, JUnitConfiguration configuration) {
+ private static void checkConfigurationException(String expectedExceptionMessage, JUnitConfiguration configuration) {
try {
configuration.checkConfiguration();
}
@@ -156,13 +181,18 @@
}
public void testRefactorOtherClass() throws IOException {
- JUnitConfiguration configuration = createConfiguration(mySource.createClass("ATest", TEST_CODE));
- PsiClass psiClass = mySource.createClass("Application", APPLICATION_CODE);
+ PsiClass psiClass = mySource.createClass("ATest", TEST_CODE);
+ assertNotNull(psiClass);
+ JUnitConfiguration configuration = createConfiguration(psiClass);
+
+ psiClass = mySource.createClass("Application", APPLICATION_CODE);
+ assertNotNull(psiClass);
rename(psiClass, "NewName");
checkClassName("ATest", configuration);
mySource.createPackage("pkg");
psiClass = mySource.findClass("NewName");
+ assertNotNull(psiClass);
move(psiClass, "pkg");
checkClassName("ATest", configuration);
}
@@ -170,7 +200,7 @@
private void moveMembers(final PsiClass otherTest, final HashSet<PsiMember> members) {
new WriteCommandAction(myProject) {
@Override
- protected void run(final Result result) throws Throwable {
+ protected void run(@NotNull Result result) throws Throwable {
MockMoveMembersOptions options = new MockMoveMembersOptions(otherTest.getQualifiedName(), members);
new MoveMembersProcessor(myProject, null, options).run();
}
@@ -186,12 +216,13 @@
private void move(final PsiElement psiElement, String packageName) {
VirtualFile pkgFile = mySource.createPackageDir(packageName);
final PsiDirectory toDir = PsiManager.getInstance(myProject).findDirectory(pkgFile);
+ assertNotNull(toDir);
new WriteCommandAction(myProject, psiElement.getContainingFile()) {
@Override
- protected void run(final Result result) throws Throwable {
+ protected void run(@NotNull Result result) throws Throwable {
+ PackageWrapper wrapper = PackageWrapper.create(JavaDirectoryService.getInstance().getPackage(toDir));
new MoveClassesOrPackagesProcessor(myProject, new PsiElement[]{psiElement},
- new SingleSourceRootMoveDestination(
- PackageWrapper.create(JavaDirectoryService.getInstance().getPackage(toDir)), toDir),
+ new SingleSourceRootMoveDestination(wrapper, toDir),
false, false, null).run();
}
}.executeSilently();
@@ -200,11 +231,11 @@
private void rename(final PsiElement psiElement, final String newName) {
new WriteCommandAction(myProject, psiElement.getContainingFile()) {
@Override
- protected void run(final Result result) throws Throwable {
+ protected void run(@NotNull Result result) throws Throwable {
new RenameProcessor(myProject, psiElement, newName, false, false).run();
}
}.executeSilently();
- }
+ }
@Override
protected void setUp() throws Exception {
@@ -218,18 +249,20 @@
protected void tearDown() throws Exception {
mySource.tearDown();
mySource = null;
- super.tearDown(); //To change body of overriden methods use Options | File Templates.
+ super.tearDown();
}
@Override
- protected <T extends RunConfiguration> T createConfiguration(PsiElement psiClass, MapDataContext dataContext) {
- T configuration = (T)super.createConfiguration(psiClass, dataContext);
+ protected <T extends RunConfiguration> T createConfiguration(@NotNull PsiElement psiClass, @NotNull MapDataContext dataContext) {
+ T configuration = super.createConfiguration(psiClass, dataContext);
RunManagerEx.getInstanceEx(myProject).setTemporaryConfiguration(new RunnerAndConfigurationSettingsImpl(null, configuration, false));
return configuration;
}
@Override
- protected JUnitConfiguration createJUnitConfiguration(final PsiElement psiElement, final Class producerClass, final MapDataContext dataContext) {
+ protected JUnitConfiguration createJUnitConfiguration(@NotNull PsiElement psiElement,
+ @NotNull Class<? extends JUnitConfigurationProducer> producerClass,
+ @NotNull MapDataContext dataContext) {
final JUnitConfiguration configuration = super.createJUnitConfiguration(psiElement, producerClass, dataContext);
RunManagerEx.getInstanceEx(myProject).setTemporaryConfiguration(new RunnerAndConfigurationSettingsImpl(null, configuration, false));
return configuration;
diff --git a/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java b/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java
index 1b11603..c2cef13 100644
--- a/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java
+++ b/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java
@@ -22,14 +22,19 @@
import com.intellij.lang.properties.IProperty;
import com.intellij.lang.properties.psi.PropertiesFile;
import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.Result;
import com.intellij.openapi.application.ex.PathManagerEx;
import com.intellij.openapi.command.CommandProcessor;
+import com.intellij.openapi.command.WriteCommandAction;
+import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileTypes.FileTypes;
+import com.intellij.openapi.fileTypes.impl.FileTypeManagerImpl;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.util.ProperTextRange;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
+import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
@@ -279,6 +284,45 @@
assertSize(2, findUsages(findModel));
}
+ public void testWholeWordsInNonIndexedFiles() throws Exception {
+ createFile(myModule, "A.test123", "foo fo foo");
+
+ // don't use createFile here because it creates PsiFile and runs file type autodetection
+ // in real life some files might not be autodetected as plain text until the search starts
+ VirtualFile custom = new WriteCommandAction<VirtualFile>(myProject) {
+ @Override
+ protected void run(@NotNull Result<VirtualFile> result) throws Throwable {
+ File dir = createTempDirectory();
+ File file = new File(dir.getPath(), "A.test1234");
+ file.createNewFile();
+ FileUtil.writeToFile(file, "foo fo foo");
+ addSourceContentToRoots(myModule, VfsUtil.findFileByIoFile(dir, true));
+ result.setResult(VfsUtil.findFileByIoFile(file, true));
+ }
+ }.execute().getResultObject();
+
+ assertNull(FileDocumentManager.getInstance().getCachedDocument(custom));
+ assertEquals(FileTypes.UNKNOWN, custom.getFileType());
+ assertFalse(FileTypeManagerImpl.isFileTypeDetectedFromContent(custom));
+
+ FindModel findModel = new FindModel();
+ findModel.setWholeWordsOnly(true);
+ findModel.setFromCursor(false);
+ findModel.setGlobal(true);
+ findModel.setMultipleFiles(true);
+ findModel.setProjectScope(true);
+
+ findModel.setStringToFind("fo");
+ assertSize(2, findUsages(findModel));
+
+ // and we should get the same with text loaded
+ assertNotNull(FileDocumentManager.getInstance().getDocument(custom));
+ assertEquals(FileTypes.PLAIN_TEXT, custom.getFileType());
+ assertTrue(FileTypeManagerImpl.isFileTypeDetectedFromContent(custom));
+
+ assertSize(2, findUsages(findModel));
+ }
+
public void testReplaceRegexp() {
FindModel findModel = new FindModel();
findModel.setStringToFind("bug_(?=here)");
diff --git a/java/java-tests/testSrc/com/intellij/ide/fileStructure/JavaFileStructureTestCase.java b/java/java-tests/testSrc/com/intellij/ide/fileStructure/JavaFileStructureTestCase.java
index 674d316..b031f0e 100644
--- a/java/java-tests/testSrc/com/intellij/ide/fileStructure/JavaFileStructureTestCase.java
+++ b/java/java-tests/testSrc/com/intellij/ide/fileStructure/JavaFileStructureTestCase.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 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,8 +18,8 @@
import com.intellij.JavaTestUtil;
import com.intellij.ide.structureView.impl.java.JavaAnonymousClassesNodeProvider;
import com.intellij.ide.structureView.impl.java.JavaInheritedMembersNodeProvider;
-import com.intellij.ide.util.FileStructurePopup;
import com.intellij.ide.util.PropertiesComponent;
+import com.intellij.ide.util.treeView.smartTree.TreeStructureUtil;
import com.intellij.testFramework.FileStructureTestBase;
import com.intellij.testFramework.IdeaTestCase;
@@ -66,7 +66,7 @@
}
private static String getAnonymousPropertyName() {
- return FileStructurePopup.getPropertyName(JavaAnonymousClassesNodeProvider.JAVA_ANONYMOUS_PROPERTY_NAME);
+ return TreeStructureUtil.getPropertyName(JavaAnonymousClassesNodeProvider.JAVA_ANONYMOUS_PROPERTY_NAME);
}
@Override
diff --git a/java/java-tests/testSrc/com/intellij/index/IndexTest.java b/java/java-tests/testSrc/com/intellij/index/IndexTest.java
index 7cbe2f6..fba5b6e 100644
--- a/java/java-tests/testSrc/com/intellij/index/IndexTest.java
+++ b/java/java-tests/testSrc/com/intellij/index/IndexTest.java
@@ -30,6 +30,7 @@
import com.intellij.testFramework.IdeaTestCase;
import com.intellij.testFramework.PlatformTestUtil;
import com.intellij.testFramework.PsiTestUtil;
+import com.intellij.testFramework.SkipSlowTestLocally;
import com.intellij.util.indexing.MapIndexStorage;
import com.intellij.util.indexing.StorageException;
import com.intellij.util.io.*;
@@ -44,8 +45,9 @@
* @author Eugene Zhuravlev
* Date: Dec 12, 2007
*/
+@SkipSlowTestLocally
public class IndexTest extends IdeaTestCase {
-
+
public void testUpdate() throws StorageException, IOException {
final File storageFile = FileUtil.createTempFile("indextest", "storage");
final File metaIndexFile = FileUtil.createTempFile("indextest_inputs", "storage");
@@ -137,7 +139,7 @@
FileTypeManager.getInstance().registerFileType(TestFileType.INSTANCE, "fff");
final FFFLangParserDefinition parserDefinition = new FFFLangParserDefinition();
LanguageParserDefinitions.INSTANCE.addExplicitExtension(FFFLanguage.INSTANCE, parserDefinition);
-
+
final TestStubElementType stubType = new TestStubElementType();
SerializationManager.getInstance().registerSerializer(TestStubElement.class, stubType);
@@ -145,7 +147,7 @@
fffFile.createNewFile();
final VirtualFile vFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(fffFile);
-
+
assertNotNull(vFile);
assertEquals(TestFileType.INSTANCE, vFile.getFileType());
@@ -181,9 +183,9 @@
final List<SerializedStubTree> trees = data.toValueList();
final SerializedStubTree tree = assertOneElement(trees);
-
+
assertTrue(Comparing.equal(bytes, tree.getBytes()));
-
+
final StubElement deserialized = tree.getStub();
}
finally {
@@ -192,7 +194,7 @@
}
*/
-
+
private static <T> void assertDataEquals(List<T> actual, T... expected) {
assertTrue(new HashSet<T>(Arrays.asList(expected)).equals(new HashSet<T>(actual)));
}
@@ -200,7 +202,7 @@
public void testCollectedPsiWithChangedDocument() throws IOException {
VirtualFile dir = getVirtualFile(createTempDirectory());
PsiTestUtil.addSourceContentToRoots(myModule, dir);
-
+
final VirtualFile vFile = createChildData(dir, "Foo.java");
VfsUtil.saveText(vFile, "class Foo {}");
@@ -232,11 +234,11 @@
}
});
}
-
+
public void testSavedUncommittedDocument() throws IOException {
VirtualFile dir = getVirtualFile(createTempDirectory());
PsiTestUtil.addSourceContentToRoots(myModule, dir);
-
+
final VirtualFile vFile = createChildData(dir, "Foo.java");
VfsUtil.saveText(vFile, "");
@@ -254,10 +256,10 @@
Document document = FileDocumentManager.getInstance().getDocument(vFile);
document.insertString(0, "class Foo {}");
FileDocumentManager.getInstance().saveDocument(document);
-
+
assertTrue(count == PsiManager.getInstance(myProject).getModificationTracker().getModificationCount());
assertNull(facade.findClass("Foo", scope));
-
+
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
assertNotNull(facade.findClass("Foo", scope));
assertNotNull(facade.findClass("Foo", scope).getText());
@@ -279,11 +281,11 @@
final Document document = FileDocumentManager.getInstance().getDocument(vFile);
//todo should file type be changed silently without events?
//assertEquals(UnknownFileType.INSTANCE, vFile.getFileType());
-
+
final PsiFile file = getPsiFile(document);
assertInstanceOf(file, PsiPlainTextFile.class);
assertEquals("Foo", file.getText());
-
+
assertEmpty(PsiSearchHelper.SERVICE.getInstance(myProject).findFilesWithPlainTextWords("Foo"));
WriteCommandAction.runWriteCommandAction(myProject, new Runnable() {
@@ -296,13 +298,13 @@
FileDocumentManager.getInstance().saveDocument(document);
assertEquals("Foo", file.getText());
assertEmpty(PsiSearchHelper.SERVICE.getInstance(myProject).findFilesWithPlainTextWords("Foo"));
-
+
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
assertEquals(" Foo", file.getText());
assertEmpty(PsiSearchHelper.SERVICE.getInstance(myProject).findFilesWithPlainTextWords("Foo"));
-
+
}
});
}
-
+
}
diff --git a/java/java-tests/testSrc/com/intellij/lang/java/parser/partial/ExpressionParserTest.java b/java/java-tests/testSrc/com/intellij/lang/java/parser/partial/ExpressionParserTest.java
index df470d8..3290863 100644
--- a/java/java-tests/testSrc/com/intellij/lang/java/parser/partial/ExpressionParserTest.java
+++ b/java/java-tests/testSrc/com/intellij/lang/java/parser/partial/ExpressionParserTest.java
@@ -77,6 +77,7 @@
public void testNew15() { doParserTest("new C<?>.B()"); }
public void testNew16() { doParserTest("new C<>()"); }
public void testNew17() { doParserTest("new Map<String, >()"); }
+ public void testNew18() { doParserTest("new int @A [2] @B"); }
public void testExprList0() { doParserTest("f(1,2)"); }
public void testExprList1() { doParserTest("f("); }
diff --git a/java/java-tests/testSrc/com/intellij/module/ModulePointerTest.java b/java/java-tests/testSrc/com/intellij/module/ModulePointerTest.java
deleted file mode 100644
index 55bc15f..0000000
--- a/java/java-tests/testSrc/com/intellij/module/ModulePointerTest.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright 2000-2012 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.module;
-
-import com.intellij.openapi.Disposable;
-import com.intellij.openapi.application.Result;
-import com.intellij.openapi.application.WriteAction;
-import com.intellij.openapi.module.*;
-import com.intellij.testFramework.PlatformTestCase;
-
-/**
- * @author nik
- */
-public class ModulePointerTest extends PlatformTestCase {
- public void testCreateByName() throws Exception {
- final ModulePointer pointer = getPointerManager().create("m");
- assertSame(pointer, getPointerManager().create("m"));
- assertNull(pointer.getModule());
- assertEquals("m", pointer.getModuleName());
-
- final Module module = addModule("m");
-
- assertSame(module, pointer.getModule());
- assertEquals("m", pointer.getModuleName());
- }
-
- public void testCreateByModule() throws Exception {
- final Module module = addModule("x");
- final ModulePointer pointer = getPointerManager().create(module);
- assertSame(pointer, getPointerManager().create(module));
- assertSame(pointer, getPointerManager().create("x"));
- assertSame(module, pointer.getModule());
- assertEquals("x", pointer.getModuleName());
-
- ModifiableModuleModel model = getModuleManager().getModifiableModel();
- model.disposeModule(module);
- commitModel(model);
-
- assertNull(pointer.getModule());
- assertEquals("x", pointer.getModuleName());
-
- final Module newModule = addModule("x");
- assertSame(pointer, getPointerManager().create(newModule));
- }
-
- public void testRenameModule() throws Exception {
- final ModulePointer pointer = getPointerManager().create("abc");
- final Module module = addModule("abc");
- ModifiableModuleModel model = getModuleManager().getModifiableModel();
- model.renameModule(module, "xyz");
- commitModel(model);
- assertSame(module, pointer.getModule());
- assertEquals("xyz", pointer.getModuleName());
- }
-
- public void testDisposePointerFromUncommitedModifiableModel() throws Exception {
- final ModulePointer pointer = getPointerManager().create("xxx");
-
- final ModifiableModuleModel modifiableModel = getModuleManager().getModifiableModel();
- final Module module = modifiableModel.newModule(myProject.getBaseDir().getPath() + "/xxx.iml", EmptyModuleType.getInstance().getId());
- assertSame(pointer, getPointerManager().create(module));
- assertSame(pointer, getPointerManager().create("xxx"));
-
- assertSame(module, pointer.getModule());
- assertEquals("xxx", pointer.getModuleName());
-
- modifiableModel.dispose();
-
- assertNull(pointer.getModule());
- assertEquals("xxx", pointer.getModuleName());
- }
-
- private ModuleManager getModuleManager() {
- return ModuleManager.getInstance(myProject);
- }
-
- private Module addModule(final String name) {
- final ModifiableModuleModel model = getModuleManager().getModifiableModel();
- final Module module = model.newModule(myProject.getBaseDir().getPath() + "/" + name + ".iml", EmptyModuleType.getInstance().getId());
- commitModel(model);
- disposeOnTearDown(new Disposable() {
- @Override
- public void dispose() {
- if (!module.isDisposed()) {
- getModuleManager().disposeModule(module);
- }
- }
- });
- return module;
- }
-
- private static void commitModel(final ModifiableModuleModel model) {
- new WriteAction() {
- @Override
- protected void run(final Result result) {
- model.commit();
- }
- }.execute();
- }
-
- private ModulePointerManager getPointerManager() {
- return ModulePointerManager.getInstance(myProject);
- }
-}
diff --git a/java/java-tests/testSrc/com/intellij/openapi/roots/impl/DirectoryIndexTest.java b/java/java-tests/testSrc/com/intellij/openapi/roots/impl/DirectoryIndexTest.java
index 51fdd8c..23334b6 100644
--- a/java/java-tests/testSrc/com/intellij/openapi/roots/impl/DirectoryIndexTest.java
+++ b/java/java-tests/testSrc/com/intellij/openapi/roots/impl/DirectoryIndexTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@
import com.intellij.testFramework.IdeaTestCase;
import com.intellij.testFramework.PlatformTestCase;
import com.intellij.testFramework.PsiTestUtil;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.java.JavaResourceRootType;
import org.jetbrains.jps.model.java.JavaSourceRootType;
@@ -501,7 +502,7 @@
final List<VirtualFile> created = new ArrayList<VirtualFile>();
VirtualFileListener l = new VirtualFileAdapter() {
@Override
- public void fileCreated(VirtualFileEvent e) {
+ public void fileCreated(@NotNull VirtualFileEvent e) {
VirtualFile file = e.getFile();
checkInfoNull(file);
created.add(file);
@@ -562,7 +563,7 @@
VirtualFileListener l = new VirtualFileAdapter() {
@Override
- public void fileCreated(VirtualFileEvent e) {
+ public void fileCreated(@NotNull VirtualFileEvent e) {
assertEquals("dir", e.getFileName());
VirtualFile file = e.getFile();
diff --git a/java/java-tests/testSrc/com/intellij/patterns/VirtualFilePatternsTest.groovy b/java/java-tests/testSrc/com/intellij/patterns/VirtualFilePatternsTest.groovy
deleted file mode 100644
index 18d5622..0000000
--- a/java/java-tests/testSrc/com/intellij/patterns/VirtualFilePatternsTest.groovy
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2000-2013 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.patterns
-import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
-/**
- * @author peter
- */
-public class VirtualFilePatternsTest extends LightCodeInsightFixtureTestCase {
-
- public void testWithSuperParent() {
- def file = myFixture.addFileToProject("foo/bar.txt", "").virtualFile
- assert PlatformPatterns.virtualFile().withSuperParent(1, PlatformPatterns.virtualFile().withName("foo")).accepts(file)
- assert !PlatformPatterns.virtualFile().withSuperParent(1, PlatformPatterns.virtualFile().withName("bar")).accepts(file)
- assert !PlatformPatterns.virtualFile().withSuperParent(2, PlatformPatterns.virtualFile().withName("bar")).accepts(file)
- assert !PlatformPatterns.virtualFile().withSuperParent(10, PlatformPatterns.virtualFile().withName("bar")).accepts(file)
- assert !PlatformPatterns.virtualFile().withSuperParent(10, PlatformPatterns.virtualFile().withName("foo")).accepts(file)
- }
-}
diff --git a/java/java-tests/testSrc/com/intellij/projectView/ClassNameConvertor.java b/java/java-tests/testSrc/com/intellij/projectView/ClassNameConvertor.java
index 65956b2..b879fab 100644
--- a/java/java-tests/testSrc/com/intellij/projectView/ClassNameConvertor.java
+++ b/java/java-tests/testSrc/com/intellij/projectView/ClassNameConvertor.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2000-2014 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.projectView;
import com.intellij.ide.projectView.PresentationData;
@@ -23,8 +38,9 @@
myProject = project;
}
+ @NotNull
@Override
- public Collection<AbstractTreeNode> modify(AbstractTreeNode parent, Collection<AbstractTreeNode> children, ViewSettings settings) {
+ public Collection<AbstractTreeNode> modify(@NotNull AbstractTreeNode parent, @NotNull Collection<AbstractTreeNode> children, ViewSettings settings) {
ArrayList<AbstractTreeNode> result = new ArrayList<AbstractTreeNode>();
for (final AbstractTreeNode aChildren : children) {
diff --git a/java/java-tests/testSrc/com/intellij/projectView/ProjectViewUpdatingTest.java b/java/java-tests/testSrc/com/intellij/projectView/ProjectViewUpdatingTest.java
index dc7ab08..8f95c73 100644
--- a/java/java-tests/testSrc/com/intellij/projectView/ProjectViewUpdatingTest.java
+++ b/java/java-tests/testSrc/com/intellij/projectView/ProjectViewUpdatingTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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,8 +427,9 @@
private TreeStructureProvider createWrapProvider(final NodeWrapper rootWrapper) {
return new TreeStructureProvider() {
+ @NotNull
@Override
- public Collection<AbstractTreeNode> modify(AbstractTreeNode parent, Collection<AbstractTreeNode> children, ViewSettings settings) {
+ public Collection<AbstractTreeNode> modify(@NotNull AbstractTreeNode parent, @NotNull Collection<AbstractTreeNode> children, ViewSettings settings) {
if (parent instanceof NodeWrapper) {
return children;
diff --git a/java/java-tests/testSrc/com/intellij/projectView/SameNamesJoiner.java b/java/java-tests/testSrc/com/intellij/projectView/SameNamesJoiner.java
index a9efd34..7b976f2 100644
--- a/java/java-tests/testSrc/com/intellij/projectView/SameNamesJoiner.java
+++ b/java/java-tests/testSrc/com/intellij/projectView/SameNamesJoiner.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2000-2014 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.projectView;
import com.intellij.ide.projectView.PresentationData;
@@ -17,8 +32,9 @@
import java.util.Iterator;
class SameNamesJoiner implements TreeStructureProvider {
+ @NotNull
@Override
- public Collection<AbstractTreeNode> modify(AbstractTreeNode parent, Collection<AbstractTreeNode> children, ViewSettings settings) {
+ public Collection<AbstractTreeNode> modify(@NotNull AbstractTreeNode parent, @NotNull Collection<AbstractTreeNode> children, ViewSettings settings) {
if (parent instanceof JoinedNode) return children;
ArrayList<AbstractTreeNode> result = new ArrayList<AbstractTreeNode>();
diff --git a/java/java-tests/testSrc/com/intellij/psi/ClsDuplicatesTest.java b/java/java-tests/testSrc/com/intellij/psi/ClsDuplicatesTest.java
index 81dcb5c..dd32222 100644
--- a/java/java-tests/testSrc/com/intellij/psi/ClsDuplicatesTest.java
+++ b/java/java-tests/testSrc/com/intellij/psi/ClsDuplicatesTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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,12 +20,14 @@
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.testFramework.PsiTestCase;
+import com.intellij.testFramework.SkipSlowTestLocally;
import com.intellij.usageView.UsageViewLongNameLocation;
import gnu.trove.THashSet;
import gnu.trove.TObjectHashingStrategy;
import java.util.Set;
+@SkipSlowTestLocally
public class ClsDuplicatesTest extends PsiTestCase {
private Set<PsiNamedElement> myUnique = new THashSet<PsiNamedElement>(new TObjectHashingStrategy<PsiNamedElement>() {
@Override
diff --git a/java/java-tests/testSrc/com/intellij/psi/JavaSOEOnReparsePerformanceTest.java b/java/java-tests/testSrc/com/intellij/psi/JavaSOEOnReparsePerformanceTest.java
index 4de8d98..cf79fd8 100644
--- a/java/java-tests/testSrc/com/intellij/psi/JavaSOEOnReparsePerformanceTest.java
+++ b/java/java-tests/testSrc/com/intellij/psi/JavaSOEOnReparsePerformanceTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,9 @@
import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.WriteCommandAction;
+import com.intellij.testFramework.SkipSlowTestLocally;
+@SkipSlowTestLocally
public class JavaSOEOnReparsePerformanceTest extends LightDaemonAnalyzerTestCase {
private StringBuilder myHugeExpr;
diff --git a/java/java-tests/testSrc/com/intellij/psi/PsiConcurrencyStressTest.java b/java/java-tests/testSrc/com/intellij/psi/PsiConcurrencyStressTest.java
index 95d54bb..9250602 100644
--- a/java/java-tests/testSrc/com/intellij/psi/PsiConcurrencyStressTest.java
+++ b/java/java-tests/testSrc/com/intellij/psi/PsiConcurrencyStressTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,25 +31,17 @@
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.search.GlobalSearchScope;
-import com.intellij.testFramework.IdeaTestUtil;
-import com.intellij.testFramework.PsiTestCase;
-import com.intellij.testFramework.PsiTestUtil;
-import com.intellij.testFramework.Timings;
+import com.intellij.testFramework.*;
import com.intellij.util.IncorrectOperationException;
import java.util.Random;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
+@SkipSlowTestLocally
public class PsiConcurrencyStressTest extends PsiTestCase {
- private static final boolean SKIP = "true".equalsIgnoreCase(System.getProperty("skip.psi.concurrency.test"));
-
- @Override
- public void runBare() throws Throwable {
- if (!SKIP) {
- super.runBare();
- }
- }
+ private volatile PsiJavaFile myFile;
+ private volatile boolean writeActionInProgress;
@Override
protected void setUp() throws Exception {
@@ -61,8 +53,6 @@
PsiTestUtil.createTestProjectStructure(myProject, myModule, root, myFilesToDelete);
}
- private volatile PsiJavaFile myFile;
- private volatile boolean writeActionInProgress;
public void testStress() throws Exception {
int numOfThreads = 10;
int iterations = Timings.adjustAccordingToMySpeed(20, true);
diff --git a/java/java-tests/testSrc/com/intellij/psi/PsiDocumentManagerImplTest.java b/java/java-tests/testSrc/com/intellij/psi/PsiDocumentManagerImplTest.java
deleted file mode 100644
index db2a5f1..0000000
--- a/java/java-tests/testSrc/com/intellij/psi/PsiDocumentManagerImplTest.java
+++ /dev/null
@@ -1,372 +0,0 @@
-/*
- * Copyright 2000-2013 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.psi;
-
-import com.intellij.ide.impl.ProjectUtil;
-import com.intellij.mock.MockDocument;
-import com.intellij.mock.MockPsiFile;
-import com.intellij.openapi.command.WriteCommandAction;
-import com.intellij.openapi.editor.Document;
-import com.intellij.openapi.editor.impl.DocumentImpl;
-import com.intellij.openapi.editor.impl.event.DocumentEventImpl;
-import com.intellij.openapi.fileEditor.FileDocumentManager;
-import com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.project.ex.ProjectManagerEx;
-import com.intellij.openapi.vfs.LocalFileSystem;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.psi.impl.DebugUtil;
-import com.intellij.psi.impl.PsiDocumentManagerImpl;
-import com.intellij.psi.impl.source.PsiFileImpl;
-import com.intellij.testFramework.LeakHunter;
-import com.intellij.testFramework.LightVirtualFile;
-import com.intellij.testFramework.PlatformTestCase;
-import com.intellij.util.Processor;
-import com.intellij.util.concurrency.Semaphore;
-import com.intellij.util.ui.UIUtil;
-
-import java.io.File;
-import java.lang.ref.Reference;
-import java.util.concurrent.atomic.AtomicInteger;
-
-public class PsiDocumentManagerImplTest extends PlatformTestCase {
- private PsiDocumentManagerImpl getPsiDocumentManager() {
- return (PsiDocumentManagerImpl)PsiDocumentManager.getInstance(getProject());
- }
-
- public void testGetCachedPsiFile_NoFile() throws Exception {
- final PsiFile file = getPsiDocumentManager().getCachedPsiFile(new MockDocument());
- assertNull(file);
- }
-
- public void testGetPsiFile_NotRegisteredDocument() throws Exception {
- final PsiFile file = getPsiDocumentManager().getPsiFile(new MockDocument());
- assertNull(file);
- }
-
- public void testGetDocument_FirstGet() throws Exception {
- VirtualFile vFile = createFile();
- final PsiFile file = new MockPsiFile(vFile, getPsiManager());
-
- final Document document = getPsiDocumentManager().getDocument(file);
- assertNotNull(document);
- assertSame(document, FileDocumentManager.getInstance().getDocument(vFile));
- }
-
- @Override
- protected boolean isRunInWriteAction() {
- return false;
- }
-
- private static LightVirtualFile createFile() {
- return new LightVirtualFile("foo.java");
- }
-
- public void testDocumentGced() throws Exception {
- VirtualFile vFile = createFile();
- PsiDocumentManagerImpl documentManager = getPsiDocumentManager();
- long id = System.identityHashCode(documentManager.getDocument(getPsiManager().findFile(vFile)));
-
- documentManager.commitAllDocuments();
- UIUtil.dispatchAllInvocationEvents();
- UIUtil.dispatchAllInvocationEvents();
- assertEmpty(documentManager.getUncommittedDocuments());
-
- LeakHunter.checkLeak(documentManager, DocumentImpl.class);
- LeakHunter.checkLeak(documentManager, PsiFileImpl.class, new Processor<PsiFileImpl>() {
- @Override
- public boolean process(PsiFileImpl psiFile) {
- return psiFile.getViewProvider().getVirtualFile().getFileSystem() instanceof LocalFileSystem;
- }
- });
- //Class.forName("com.intellij.util.ProfilingUtil").getDeclaredMethod("forceCaptureMemorySnapshot").invoke(null);
-
- Reference<Document> reference = vFile.getUserData(FileDocumentManagerImpl.DOCUMENT_KEY);
- assertNotNull(reference);
- for (int i=0;i<1000;i++) {
- UIUtil.dispatchAllInvocationEvents();
- if (reference.get() == null) break;
- System.gc();
- }
- assertNull(documentManager.getCachedDocument(getPsiManager().findFile(vFile)));
-
- Document newDoc = documentManager.getDocument(getPsiManager().findFile(vFile));
- assertTrue(id != System.identityHashCode(newDoc));
- }
-
- public void testGetUncommittedDocuments_noDocuments() throws Exception {
- assertEquals(0, getPsiDocumentManager().getUncommittedDocuments().length);
- }
-
- public void testGetUncommittedDocuments_documentChanged_DontProcessEvents() throws Exception {
- final PsiFile file = getPsiManager().findFile(createFile());
-
- final Document document = getPsiDocumentManager().getDocument(file);
-
- WriteCommandAction.runWriteCommandAction(null, new Runnable() {
- @Override
- public void run() {
- getPsiDocumentManager().getSynchronizer().performAtomically(file, new Runnable() {
- @Override
- public void run() {
- getPsiDocumentManager().documentChanged(new DocumentEventImpl(document, 0, "", "", document.getModificationStamp(), false));
- }
- });
- }
- });
-
-
- assertEquals(0, getPsiDocumentManager().getUncommittedDocuments().length);
- }
-
- public void testGetUncommittedDocuments_documentNotRegistered() throws Exception {
- final Document document = new MockDocument();
-
- WriteCommandAction.runWriteCommandAction(null, new Runnable() {
- @Override
- public void run() {
- getPsiDocumentManager().documentChanged(new DocumentEventImpl(document, 0, "", "", document.getModificationStamp(), false));
- }
- });
-
-
- assertEquals(0, getPsiDocumentManager().getUncommittedDocuments().length);
- }
-
- public void testCommitDocument_RemovesFromUncommittedList() throws Exception {
- PsiFile file = getPsiManager().findFile(createFile());
-
- final Document document = getPsiDocumentManager().getDocument(file);
-
- WriteCommandAction.runWriteCommandAction(null, new Runnable() {
- @Override
- public void run() {
- getPsiDocumentManager().documentChanged(new DocumentEventImpl(document, 0, "", "", document.getModificationStamp(), false));
- }
- });
-
-
- getPsiDocumentManager().commitDocument(document);
- assertEquals(0, getPsiDocumentManager().getUncommittedDocuments().length);
- }
-
- public void testCommitAllDocument_RemovesFromUncommittedList() throws Exception {
- PsiFile file = getPsiManager().findFile(createFile());
-
- final Document document = getPsiDocumentManager().getDocument(file);
-
- WriteCommandAction.runWriteCommandAction(null, new Runnable() {
- @Override
- public void run() {
- getPsiDocumentManager().documentChanged(new DocumentEventImpl(document, 0, "", "", document.getModificationStamp(), false));
- }
- });
-
-
- getPsiDocumentManager().commitAllDocuments();
- assertEquals(0, getPsiDocumentManager().getUncommittedDocuments().length);
- }
-
- public void testDocumentFromAlienProjectDoesNotEndUpInMyUncommittedList() throws Exception {
- PsiFile file = getPsiManager().findFile(createFile());
-
- final Document document = getPsiDocumentManager().getDocument(file);
-
- File temp = createTempDirectory();
- final Project alienProject = createProject(new File(temp, "alien.ipr"), DebugUtil.currentStackTrace());
- boolean succ2 = ProjectManagerEx.getInstanceEx().openProject(alienProject);
- assertTrue(succ2);
-
-
- try {
- PsiManager alienManager = PsiManager.getInstance(alienProject);
- final String alienText = "alien";
-
- LightVirtualFile alienVirt = new LightVirtualFile("foo.java", alienText);
- final PsiFile alienFile = alienManager.findFile(alienVirt);
- final PsiDocumentManagerImpl alienDocManager = (PsiDocumentManagerImpl)PsiDocumentManager.getInstance(alienProject);
- final Document alienDocument = alienDocManager.getDocument(alienFile);
- //alienDocument.putUserData(CACHED_VIEW_PROVIDER, new MockFileViewProvider(alienFile));
- assertEquals(0, alienDocManager.getUncommittedDocuments().length);
- assertEquals(0, getPsiDocumentManager().getUncommittedDocuments().length);
-
- WriteCommandAction.runWriteCommandAction(null, new Runnable() {
- @Override
- public void run() {
- getPsiDocumentManager()
- .documentChanged(new DocumentEventImpl(alienDocument, 0, "", "", alienDocument.getModificationStamp(), false));
- assertEquals(0, getPsiDocumentManager().getUncommittedDocuments().length);
- assertEquals(0, alienDocManager.getUncommittedDocuments().length);
-
- alienDocManager.documentChanged(new DocumentEventImpl(alienDocument, 0, "", "", alienDocument.getModificationStamp(), false));
- assertEquals(0, getPsiDocumentManager().getUncommittedDocuments().length);
- assertEquals(1, alienDocManager.getUncommittedDocuments().length);
-
- getPsiDocumentManager().documentChanged(new DocumentEventImpl(document, 0, "", "", document.getModificationStamp(), false));
- assertEquals(1, getPsiDocumentManager().getUncommittedDocuments().length);
- assertEquals(1, alienDocManager.getUncommittedDocuments().length);
-
- alienDocManager.documentChanged(new DocumentEventImpl(document, 0, "", "", document.getModificationStamp(), false));
- assertEquals(1, getPsiDocumentManager().getUncommittedDocuments().length);
- assertEquals(1, alienDocManager.getUncommittedDocuments().length);
- }
- });
- }
- finally {
- ProjectUtil.closeAndDispose(alienProject);
- }
- }
-
- public void testCommitInBackground() {
- PsiFile file = getPsiManager().findFile(createFile());
- assertNotNull(file);
- assertTrue(file.isPhysical());
- final Document document = getPsiDocumentManager().getDocument(file);
- assertNotNull(document);
-
- final Semaphore semaphore = new Semaphore();
- semaphore.down();
- getPsiDocumentManager().performWhenAllCommitted(new Runnable() {
- @Override
- public void run() {
- assertTrue(getPsiDocumentManager().isCommitted(document));
- semaphore.up();
- }
- });
- waitAndPump(semaphore, 30000);
- assertTrue(getPsiDocumentManager().isCommitted(document));
-
- WriteCommandAction.runWriteCommandAction(null, new Runnable() {
- @Override
- public void run() {
- document.insertString(0, "class X {}");
- }
- });
-
- semaphore.down();
- getPsiDocumentManager().performWhenAllCommitted(new Runnable() {
- @Override
- public void run() {
- assertTrue(getPsiDocumentManager().isCommitted(document));
- semaphore.up();
- }
- });
- waitAndPump(semaphore, 30000);
- assertTrue(getPsiDocumentManager().isCommitted(document));
-
- final AtomicInteger count = new AtomicInteger();
- final Runnable action = new Runnable() {
- @Override
- public void run() {
- count.incrementAndGet();
- }
- };
-
- WriteCommandAction.runWriteCommandAction(null, new Runnable() {
- @Override
- public void run() {
- document.insertString(0, "/**/");
- boolean executed = getPsiDocumentManager().cancelAndRunWhenAllCommitted("xxx", action);
- assertFalse(executed);
- executed = getPsiDocumentManager().cancelAndRunWhenAllCommitted("xxx", action);
- assertFalse(executed);
- assertEquals(0, count.get());
- }
- });
-
- while (!getPsiDocumentManager().isCommitted(document)) {
- UIUtil.dispatchAllInvocationEvents();
- }
- assertTrue(getPsiDocumentManager().isCommitted(document));
- assertEquals(1, count.get());
-
- count.set(0);
- WriteCommandAction.runWriteCommandAction(null, new Runnable() {
- @Override
- public void run() {
- document.insertString(0, "/**/");
- boolean executed = getPsiDocumentManager().performWhenAllCommitted(action);
- assertFalse(executed);
- executed = getPsiDocumentManager().performWhenAllCommitted(action);
- assertFalse(executed);
- assertEquals(0, count.get());
- }
- });
-
- while (!getPsiDocumentManager().isCommitted(document)) {
- UIUtil.dispatchAllInvocationEvents();
- }
- assertTrue(getPsiDocumentManager().isCommitted(document));
- assertEquals(2, count.get());
- }
-
- private static void waitAndPump(Semaphore semaphore, int timeout) {
- final long limit = System.currentTimeMillis() + timeout;
- while (System.currentTimeMillis() < limit) {
- if (semaphore.waitFor(10)) return;
- UIUtil.dispatchAllInvocationEvents();
- }
- fail("Timeout");
- }
-
- public void testDocumentFromAlienProjectGetsCommittedInBackground() throws Exception {
- LightVirtualFile virtualFile = createFile();
- PsiFile file = getPsiManager().findFile(virtualFile);
-
- final Document document = getPsiDocumentManager().getDocument(file);
-
- File temp = createTempDirectory();
- final Project alienProject = createProject(new File(temp, "alien.ipr"), DebugUtil.currentStackTrace());
- boolean succ2 = ProjectManagerEx.getInstanceEx().openProject(alienProject);
- assertTrue(succ2);
-
-
- try {
- PsiManager alienManager = PsiManager.getInstance(alienProject);
-
- final PsiFile alienFile = alienManager.findFile(virtualFile);
- assertNotNull(alienFile);
- final PsiDocumentManagerImpl alienDocManager = (PsiDocumentManagerImpl)PsiDocumentManager.getInstance(alienProject);
- final Document alienDocument = alienDocManager.getDocument(alienFile);
- assertSame(document, alienDocument);
- assertEquals(0, alienDocManager.getUncommittedDocuments().length);
- assertEquals(0, getPsiDocumentManager().getUncommittedDocuments().length);
-
- WriteCommandAction.runWriteCommandAction(null, new Runnable() {
- @Override
- public void run() {
- document.setText("xxx");
- assertOrderedEquals(getPsiDocumentManager().getUncommittedDocuments(), document);
- assertOrderedEquals(alienDocManager.getUncommittedDocuments(), alienDocument);
- }
- });
- assertEquals("xxx", document.getText());
- assertEquals("xxx", alienDocument.getText());
-
- while (!getPsiDocumentManager().isCommitted(document)) {
- UIUtil.dispatchAllInvocationEvents();
- }
- long start = System.currentTimeMillis();
- while (!alienDocManager.isCommitted(alienDocument) && System.currentTimeMillis()-start < 20000) {
- UIUtil.dispatchAllInvocationEvents();
- }
- assertTrue("Still not committed: "+alienDocument, alienDocManager.isCommitted(alienDocument));
- }
- finally {
- ProjectUtil.closeAndDispose(alienProject);
- }
- }
-}
diff --git a/java/java-tests/testSrc/com/intellij/psi/PsiModificationTrackerTest.java b/java/java-tests/testSrc/com/intellij/psi/PsiModificationTrackerTest.java
index bd9641f..6dd1248 100644
--- a/java/java-tests/testSrc/com/intellij/psi/PsiModificationTrackerTest.java
+++ b/java/java-tests/testSrc/com/intellij/psi/PsiModificationTrackerTest.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2000-2014 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;
import com.intellij.ide.highlighter.JavaFileType;
@@ -12,6 +27,7 @@
import com.intellij.psi.util.PsiModificationTracker;
import com.intellij.testFramework.IdeaTestCase;
import com.intellij.testFramework.PlatformTestUtil;
+import com.intellij.testFramework.SkipSlowTestLocally;
import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase;
import com.intellij.util.Processor;
import com.intellij.util.ui.UIUtil;
@@ -22,6 +38,7 @@
/**
* @author Dmitry Avdeev
*/
+@SkipSlowTestLocally
public class PsiModificationTrackerTest extends LightPlatformCodeInsightFixtureTestCase {
@Override
public void setUp() throws Exception {
@@ -171,7 +188,7 @@
assertSize(0, psiFile.getClasses());
assertEquals("", psiManager.findFile(file).getText());
PlatformTestUtil.tryGcSoftlyReachableObjects();
-
+
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
assertFalse(count1 == tracker.getJavaStructureModificationCount());
@@ -182,7 +199,7 @@
}
}.execute();
}
-
+
public void testClassShouldNotAppearWithoutEvents_WithoutPsi() throws IOException {
final GlobalSearchScope allScope = GlobalSearchScope.allScope(getProject());
final JavaPsiFacade facade = JavaPsiFacade.getInstance(getProject());
@@ -197,7 +214,7 @@
protected void run() throws Throwable {
assertNull(facade.findClass("Foo", allScope));
long count1 = tracker.getJavaStructureModificationCount();
-
+
PlatformTestUtil.tryGcSoftlyReachableObjects();
assertNull(PsiDocumentManager.getInstance(getProject()).getCachedPsiFile(document));
@@ -232,7 +249,7 @@
document.deleteString(0, document.getTextLength());
- // some plugins (e.g. Copyright) hold file reference in an invokeLater runnable, let them pass
+ // some plugins (e.g. Copyright) hold file reference in an invokeLater runnable, let them pass
UIUtil.dispatchAllInvocationEvents();
// gc softly-referenced file and AST
diff --git a/java/java-tests/testSrc/com/intellij/psi/codeStyle/arrangement/JavaRearrangerGrouperTest.groovy b/java/java-tests/testSrc/com/intellij/psi/codeStyle/arrangement/JavaRearrangerGrouperTest.groovy
index e094e86..6c8be11 100644
--- a/java/java-tests/testSrc/com/intellij/psi/codeStyle/arrangement/JavaRearrangerGrouperTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/psi/codeStyle/arrangement/JavaRearrangerGrouperTest.groovy
@@ -236,4 +236,137 @@
}
+ void "test dependent methods DFS"() {
+ doTest(
+ initial: '''
+public class Q {
+
+ void E() {
+ ER();
+ }
+
+ void B() {
+ E();
+ F();
+ }
+
+ void A() {
+ B();
+ C();
+ }
+
+ void F() {
+ }
+
+ void C() {
+ G();
+ }
+
+ void ER() {
+ }
+
+ void G() {
+ }
+
+}
+''',
+ expected: '''
+public class Q {
+
+ void A() {
+ B();
+ C();
+ }
+ void B() {
+ E();
+ F();
+ }
+ void E() {
+ ER();
+ }
+ void ER() {
+ }
+ void F() {
+ }
+ void C() {
+ G();
+ }
+ void G() {
+ }
+
+}
+''',
+ groups: [group(DEPENDENT_METHODS, DEPTH_FIRST)]
+ )
+ }
+
+
+ void "test dependent methods BFS"() {
+ doTest(
+ initial: '''
+public class Q {
+
+ void E() {
+ ER();
+ }
+
+ void B() {
+ E();
+ F();
+ }
+
+ void A() {
+ B();
+ C();
+ }
+
+ void F() {
+ }
+
+ void C() {
+ G();
+ }
+
+ void ER() {
+ }
+
+ void G() {
+ }
+
+}
+''',
+ expected: '''
+public class Q {
+
+ void A() {
+ B();
+ C();
+ }
+ void B() {
+ E();
+ F();
+ }
+ void C() {
+ G();
+ }
+ void E() {
+ ER();
+ }
+ void F() {
+ }
+ void G() {
+ }
+ void ER() {
+ }
+
+}
+''',
+ groups: [group(DEPENDENT_METHODS, BREADTH_FIRST)]
+ )
+ }
+
+
+
+
+
}
diff --git a/java/java-tests/testSrc/com/intellij/refactoring/ChangeSignatureTest.java b/java/java-tests/testSrc/com/intellij/refactoring/ChangeSignatureTest.java
index e769c7a..5190541 100644
--- a/java/java-tests/testSrc/com/intellij/refactoring/ChangeSignatureTest.java
+++ b/java/java-tests/testSrc/com/intellij/refactoring/ChangeSignatureTest.java
@@ -42,6 +42,15 @@
doTest(null, new ParameterInfoImpl[]{new ParameterInfoImpl(1), new ParameterInfoImpl(0)}, false);
}
+ public void testWarnAboutContract() throws Exception {
+ try {
+ doTest(null, new ParameterInfoImpl[]{new ParameterInfoImpl(1), new ParameterInfoImpl(0)}, false);
+ fail("Conflict expected");
+ }
+ catch (BaseRefactoringProcessor.ConflictsInTestsException ignored) {
+ }
+ }
+
public void testGenericTypes() throws Exception {
doTest(null, null, "T", new GenParams() {
@Override
diff --git a/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObjectTest.java b/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObjectTest.java
index 33cd43e..1efcf26 100644
--- a/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObjectTest.java
+++ b/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObjectTest.java
@@ -7,10 +7,12 @@
import com.intellij.JavaTestUtil;
import com.intellij.codeInsight.TargetElementUtilBase;
import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiMethod;
import com.intellij.refactoring.extractMethodObject.ExtractMethodObjectHandler;
import com.intellij.refactoring.extractMethodObject.ExtractMethodObjectProcessor;
+import com.intellij.testFramework.IdeaTestUtil;
import org.jetbrains.annotations.NotNull;
public class ExtractMethodObjectTest extends LightRefactoringTestCase {
@@ -120,4 +122,9 @@
public void testWithPrivateMethodWhichCantBeMoved() throws Exception {
doTest();
}
+
+ @Override
+ protected Sdk getProjectJDK() {
+ return IdeaTestUtil.getMockJdk18();
+ }
}
diff --git a/java/java-tests/testSrc/com/intellij/refactoring/FindMethodDuplicatesBaseTest.java b/java/java-tests/testSrc/com/intellij/refactoring/FindMethodDuplicatesBaseTest.java
index dea08d1..988cc4e 100644
--- a/java/java-tests/testSrc/com/intellij/refactoring/FindMethodDuplicatesBaseTest.java
+++ b/java/java-tests/testSrc/com/intellij/refactoring/FindMethodDuplicatesBaseTest.java
@@ -7,6 +7,7 @@
import com.intellij.JavaTestUtil;
import com.intellij.analysis.AnalysisScope;
import com.intellij.codeInsight.TargetElementUtilBase;
+import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiMember;
import com.intellij.refactoring.util.duplicates.MethodDuplicatesHandler;
@@ -51,4 +52,9 @@
}
protected abstract String getTestFilePath();
+
+ @Override
+ protected LanguageLevel getLanguageLevel() {
+ return LanguageLevel.JDK_1_7;
+ }
}
\ No newline at end of file
diff --git a/java/java-tests/testSrc/com/intellij/refactoring/InlineSuperClassTest.java b/java/java-tests/testSrc/com/intellij/refactoring/InlineSuperClassTest.java
index 690f7ac..701a967 100644
--- a/java/java-tests/testSrc/com/intellij/refactoring/InlineSuperClassTest.java
+++ b/java/java-tests/testSrc/com/intellij/refactoring/InlineSuperClassTest.java
@@ -13,11 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-/*
- * User: anna
- * Date: 20-Aug-2008
- */
package com.intellij.refactoring;
import com.intellij.JavaTestUtil;
@@ -28,6 +23,10 @@
import com.intellij.refactoring.util.DocCommentPolicy;
import org.jetbrains.annotations.NotNull;
+/**
+ * @author anna
+ * @since 20-Aug-2008
+ */
public class InlineSuperClassTest extends MultiFileTestCase {
@NotNull
@Override
@@ -40,33 +39,55 @@
return JavaTestUtil.getJavaTestDataPath();
}
- private void doTest() throws Exception {
- doTest(false);
+ public void testInlineOneClass() { doTest(false, true); }
+ public void testInlineOneClassWithConflicts() { doTest(true, true); }
+ public void testAbstractOverrides() { doTest(); }
+ public void testSimple() { doTest(); }
+ public void testSimpleGenerics() { doTest(); }
+ public void testConflictGenerics() { doTest(true, false); }
+ public void testImports() { doTest(); }
+ public void testGenerics() { doTest(); }
+ public void testNewExpr() { doTest(); }
+ public void testConflictConstructors() { doTest(true, false); }
+ public void testConflictMultipleConstructors() { doTest(true, false); }
+ public void testMultipleConstructors() { doTest(); }
+ public void testImplicitChildConstructor() { doTest(); }
+ public void testStaticMembers() { doTest(); }
+ public void testSuperReference() { doTest(); }
+ public void testInnerClassReference() { doTest(); }
+ public void testStaticImport() { doTest(); }
+ public void testNewArrayInitializerExpr() { doTest(); }
+ public void testNewArrayDimensionsExpr() { doTest(); }
+ public void testNewArrayComplexDimensionsExpr() { doTest(); }
+ public void testSuperConstructorWithReturnInside() { doTest(true, false); }
+ public void testSuperConstructorWithFieldInitialization() { doTest(); }
+ public void testSuperConstructorWithParam() { doTest(); }
+ public void testChildConstructorImplicitlyCallsSuper() { doTest(); }
+ public void testNoChildConstructorCallsSuperDefault() { doTest(); }
+ public void testReplaceGenericsInside() { doTest(); }
+ public void testMultipleSubclasses() { doTestMultipleSubclasses(); }
+ public void testMultipleSubstitutions() { doTestMultipleSubclasses(); }
+ public void testMultipleSubclassesInheritsOneBaseBase() { doTestMultipleSubclasses(); }
+ public void testInlineSuperclassExtendsList() { doTest(); }
+ public void testInterfaceHierarchyWithSubstitution() { doTest(); }
+
+ private void doTest() {
+ doTest(false, false);
}
- private void doTest(final boolean fail) throws Exception {
- doTest(fail, false);
- }
-
- private void doTest(final boolean fail, final boolean inlineOne) throws Exception {
+ private void doTest(boolean fail, final boolean inlineOne) {
try {
doTest(new PerformAction() {
@Override
public void performAction(final VirtualFile rootDir, final VirtualFile rootAfter) throws Exception {
- PsiClass aClass = myJavaFacade.findClass("Test", GlobalSearchScope.allScope(myProject));
-
- if (aClass == null) aClass = myJavaFacade.findClass("p.Test", GlobalSearchScope.allScope(myProject));
+ GlobalSearchScope scope = GlobalSearchScope.allScope(myProject);
+ PsiClass aClass = myJavaFacade.findClass("Test", scope);
+ if (aClass == null) aClass = myJavaFacade.findClass("p.Test", scope);
assertNotNull("Class Test not found", aClass);
-
- PsiClass superClass = myJavaFacade.findClass("Super", GlobalSearchScope.allScope(myProject));
-
- if (superClass == null) superClass = myJavaFacade.findClass("p1.Super", GlobalSearchScope.allScope(myProject));
+ PsiClass superClass = myJavaFacade.findClass("Super", scope);
+ if (superClass == null) superClass = myJavaFacade.findClass("p1.Super", scope);
assertNotNull("Class Super not found", superClass);
-
- new InlineSuperClassRefactoringProcessor(getProject(), inlineOne ? aClass : null, superClass, DocCommentPolicy.ASIS, aClass).run();
-
- //LocalFileSystem.getInstance().refresh(false);
- //FileDocumentManager.getInstance().saveAllDocuments();
+ new InlineSuperClassRefactoringProcessor(myProject, inlineOne ? aClass : null, superClass, DocCommentPolicy.ASIS, aClass).run();
}
});
}
@@ -83,140 +104,17 @@
}
}
- public void testInlineOneClass() throws Exception {
- doTest(false, true);
- }
-
- public void testInlineOneClassWithConflicts() throws Exception {
- doTest(true, true);
- }
-
- public void testAbstractOverrides() throws Exception {
- doTest();
- }
-
- public void testSimple() throws Exception {
- doTest();
- }
-
- public void testSimpleGenerics() throws Exception {
- doTest();
- }
-
- public void testConflictGenerics() throws Exception {
- doTest(true);
- }
-
- public void testImports() throws Exception {
- doTest();
- }
-
- public void testGenerics() throws Exception {
- doTest();
- }
-
- public void testNewexpr() throws Exception {
- doTest();
- }
-
- public void testConflictConstructors() throws Exception {
- doTest(true);
- }
-
- public void testConflictMultipleConstructors() throws Exception {
- doTest(true);
- }
-
- public void testMultipleConstructors() throws Exception {
- doTest();
- }
-
- public void testImplicitChildConstructor() throws Exception {
- doTest();
- }
-
- public void testStaticMembers() throws Exception {
- doTest();
- }
-
- public void testSuperReference() throws Exception {
- doTest();
- }
-
- public void testInnerclassReference() throws Exception {
- doTest();
- }
-
- public void testStaticImport() throws Exception {
- doTest();
- }
-
- public void testNewArrayInitializerExpr() throws Exception {
- doTest();
- }
-
- public void testNewArrayDimensionsExpr() throws Exception {
- doTest();
- }
-
- public void testNewArrayComplexDimensionsExpr() throws Exception {
- doTest();
- }
-
- public void testSuperConstructorWithReturnInside() throws Exception {
- doTest(true);
- }
-
- public void testSuperConstructorWithFieldInitialization() throws Exception {
- doTest();
- }
-
- public void testSuperConstructorWithParam() throws Exception {
- doTest();
- }
-
- public void testChildConstructorImplicitlyCallsSuper() throws Exception {
- doTest();
- }
-
- public void testNoChildConstructorCallsSuperDefault() throws Exception {
- doTest();
- }
-
- public void testReplaceGenericsInside() throws Exception {
- doTest();
- }
-
- public void testMultipleSubclasses() throws Exception {
- doTestMultipleSubclasses();
- }
-
- public void testMultipleSubstitutions() throws Exception {
- doTestMultipleSubclasses();
- }
-
- public void testMultipleSubclassesInheritsOneBaseBase() throws Exception {
- doTestMultipleSubclasses();
- }
-
- public void testInlineSuperclassExtendsList() throws Exception {
- doTest();
- }
-
- public void testInterfaceHierarchyWithSubstitution() throws Exception {
- doTest();
- }
-
- private void doTestMultipleSubclasses() throws Exception {
+ private void doTestMultipleSubclasses() {
doTest(new PerformAction() {
@Override
public void performAction(final VirtualFile rootDir, final VirtualFile rootAfter) throws Exception {
- PsiClass superClass = myJavaFacade.findClass("Super", GlobalSearchScope.allScope(myProject));
- if (superClass == null) superClass = myJavaFacade.findClass("p1.Super", GlobalSearchScope.allScope(myProject));
+ GlobalSearchScope scope = GlobalSearchScope.allScope(myProject);
+ PsiClass superClass = myJavaFacade.findClass("Super", scope);
+ if (superClass == null) superClass = myJavaFacade.findClass("p1.Super", scope);
assertNotNull("Class Super not found", superClass);
- new InlineSuperClassRefactoringProcessor(getProject(), null, superClass, DocCommentPolicy.ASIS,
- myJavaFacade.findClass("Test", GlobalSearchScope.allScope(myProject)),
- myJavaFacade.findClass("Test1", GlobalSearchScope.allScope(myProject))).run();
+ PsiClass target1 = myJavaFacade.findClass("Test", scope);
+ PsiClass target2 = myJavaFacade.findClass("Test1", scope);
+ new InlineSuperClassRefactoringProcessor(myProject, null, superClass, DocCommentPolicy.ASIS, target1, target2).run();
}
});
}
diff --git a/java/java-tests/testSrc/com/intellij/refactoring/IntroduceParameterTest.java b/java/java-tests/testSrc/com/intellij/refactoring/IntroduceParameterTest.java
index 618381a..8444c2b 100644
--- a/java/java-tests/testSrc/com/intellij/refactoring/IntroduceParameterTest.java
+++ b/java/java-tests/testSrc/com/intellij/refactoring/IntroduceParameterTest.java
@@ -463,4 +463,9 @@
IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE,
declareFinal, false, null, parametersToRemove).run();
}
+
+ @Override
+ protected LanguageLevel getLanguageLevel() {
+ return LanguageLevel.JDK_1_7;
+ }
}
diff --git a/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableSuite.java b/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableSuite.java
index b84f95e..d8123bf 100644
--- a/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableSuite.java
+++ b/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableSuite.java
@@ -1,13 +1,27 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.intellij.refactoring;
import junit.framework.Test;
-import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* @author dsl
*/
-public class IntroduceVariableSuite extends TestCase {
+public class IntroduceVariableSuite {
public static Test suite() {
final TestSuite suite = new TestSuite();
suite.addTestSuite(IntroduceVariableTest.class);
diff --git a/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java b/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java
index 16c7d33..fcadcd1 100644
--- a/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java
+++ b/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,7 +28,6 @@
import com.intellij.refactoring.ui.TypeSelectorManagerImpl;
import com.intellij.testFramework.LightCodeInsightTestCase;
import com.intellij.util.containers.MultiMap;
-import junit.framework.Assert;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -302,6 +301,7 @@
public void testNonExpression() throws Exception {
doTest(new MockIntroduceVariableHandler("sum", true, true, false, "int"));
}
+
public void testTypeAnnotations() throws Exception {
doTest(new MockIntroduceVariableHandler("y1", true, false, false, "@TA C"));
}
@@ -362,8 +362,8 @@
InputValidator validator,
PsiElement anchor, final OccurrencesChooser.ReplaceChoice replaceChoice) {
final PsiType type = typeSelectorManager.getDefaultType();
- Assert.assertTrue(type.getPresentableText(), type.getPresentableText().equals(expectedTypeName));
- Assert.assertEquals("path", IntroduceVariableBase.getSuggestedName(type, expr).names[0]);
+ assertTrue(type.getPresentableText(), type.getPresentableText().equals(expectedTypeName));
+ assertEquals("path", IntroduceVariableBase.getSuggestedName(type, expr).names[0]);
return super.getSettings(project, editor, expr, occurrences, typeSelectorManager, declareFinalIfAll, anyAssignmentLHS,
validator, anchor, replaceChoice);
}
@@ -381,7 +381,7 @@
InputValidator validator,
PsiElement anchor, final OccurrencesChooser.ReplaceChoice replaceChoice) {
final PsiType type = typeSelectorManager.getDefaultType();
- Assert.assertTrue(type.getPresentableText(), type.getPresentableText().equals("B"));
+ assertTrue(type.getPresentableText(), type.getPresentableText().equals("B"));
return super.getSettings(project, editor, expr, occurrences, typeSelectorManager, declareFinalIfAll, anyAssignmentLHS,
validator, anchor, replaceChoice);
}
@@ -428,6 +428,7 @@
}
public void testLambdaExpr() throws Exception {
+
doTest(new MockIntroduceVariableHandler("c", false, false, false, "SAM<java.lang.Integer>"));
}
@@ -436,7 +437,7 @@
}
public void testLambdaExprNotAccepted() throws Exception {
- doTest(new MockIntroduceVariableHandler("c", false, false, false, "SAM<java.lang.String>"));
+ doTest(new MockIntroduceVariableHandler("c", false, false, false, "SAM<X>"));
}
public void testOneLineLambdaVoidCompatible() throws Exception {
diff --git a/java/java-tests/testSrc/com/intellij/refactoring/MockIntroduceVariableHandler.java b/java/java-tests/testSrc/com/intellij/refactoring/MockIntroduceVariableHandler.java
index 008f3f9..9de7ab8 100644
--- a/java/java-tests/testSrc/com/intellij/refactoring/MockIntroduceVariableHandler.java
+++ b/java/java-tests/testSrc/com/intellij/refactoring/MockIntroduceVariableHandler.java
@@ -1,17 +1,35 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.intellij.refactoring;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
-import com.intellij.psi.*;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiExpression;
+import com.intellij.psi.PsiType;
import com.intellij.refactoring.introduce.inplace.OccurrencesChooser;
import com.intellij.refactoring.introduceVariable.InputValidator;
import com.intellij.refactoring.introduceVariable.IntroduceVariableBase;
import com.intellij.refactoring.introduceVariable.IntroduceVariableSettings;
import com.intellij.refactoring.ui.TypeSelectorManagerImpl;
import com.intellij.util.containers.MultiMap;
-import junit.framework.Assert;
import org.jetbrains.annotations.NonNls;
+import static org.junit.Assert.assertTrue;
+
/**
* @author dsl
*/
@@ -26,7 +44,6 @@
public MockIntroduceVariableHandler(@NonNls final String name, final boolean replaceAll,
final boolean declareFinal, final boolean replaceLValues,
@NonNls final String expectedTypeCanonicalName) {
-
this(name, replaceAll, declareFinal, replaceLValues, expectedTypeCanonicalName, false);
}
@@ -52,7 +69,7 @@
PsiElement anchor, final OccurrencesChooser.ReplaceChoice replaceChoice) {
final PsiType type = myLookForType ? findType(typeSelectorManager.getTypesForAll(), typeSelectorManager.getDefaultType())
: typeSelectorManager.getDefaultType();
- Assert.assertTrue(type.getInternalCanonicalText(), type.getInternalCanonicalText().equals(myExpectedTypeCanonicalName));
+ assertTrue(type.getInternalCanonicalText(), type.getInternalCanonicalText().equals(myExpectedTypeCanonicalName));
IntroduceVariableSettings introduceVariableSettings = new IntroduceVariableSettings() {
@Override
public String getEnteredName() {
@@ -90,7 +107,7 @@
}
protected void assertValidationResult(final boolean validationResult) {
- Assert.assertTrue(validationResult);
+ assertTrue(validationResult);
}
@Override
diff --git a/java/java-tests/testSrc/com/intellij/refactoring/MovePackageAsDirectoryTest.java b/java/java-tests/testSrc/com/intellij/refactoring/MovePackageAsDirectoryTest.java
index d4fb335..8b801b5 100644
--- a/java/java-tests/testSrc/com/intellij/refactoring/MovePackageAsDirectoryTest.java
+++ b/java/java-tests/testSrc/com/intellij/refactoring/MovePackageAsDirectoryTest.java
@@ -58,7 +58,7 @@
final boolean [] fileWasDeleted = new boolean[]{false};
final VirtualFileAdapter fileAdapter = new VirtualFileAdapter() {
@Override
- public void fileDeleted(VirtualFileEvent event) {
+ public void fileDeleted(@NotNull VirtualFileEvent event) {
fileWasDeleted[0] = !event.getFile().isDirectory();
}
};
diff --git a/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java b/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java
index b0dd70c..ec5ab9e 100644
--- a/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java
+++ b/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java
@@ -17,6 +17,7 @@
import com.intellij.JavaTestUtil;
import com.intellij.codeInsight.TargetElementUtilBase;
+import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiMethod;
@@ -26,6 +27,7 @@
import com.intellij.refactoring.LightRefactoringTestCase;
import com.intellij.refactoring.MockInlineMethodOptions;
import com.intellij.refactoring.util.InlineUtil;
+import com.intellij.testFramework.IdeaTestUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -299,4 +301,9 @@
new InlineMethodProcessor(getProject(), method, refExpr, myEditor, options.isInlineThisOnly(), nonCode, nonCode);
processor.run();
}
+
+ @Override
+ protected Sdk getProjectJDK() {
+ return IdeaTestUtil.getMockJdk18();
+ }
}
diff --git a/java/manifest/src/inspectionDescriptions/MissingFinalNewline.html b/java/manifest/src/inspectionDescriptions/MissingFinalNewline.html
index c02bc3b..3a819d6 100644
--- a/java/manifest/src/inspectionDescriptions/MissingFinalNewline.html
+++ b/java/manifest/src/inspectionDescriptions/MissingFinalNewline.html
@@ -1,30 +1,5 @@
-<!--
- ~ Copyright (c) 2007-2009, Osmorc Development Team
- ~ All rights reserved.
- ~
- ~ Redistribution and use in source and binary forms, with or without modification,
- ~ are permitted provided that the following conditions are met:
- ~ * Redistributions of source code must retain the above copyright notice, this list
- ~ of conditions and the following disclaimer.
- ~ * Redistributions in binary form must reproduce the above copyright notice, this
- ~ list of conditions and the following disclaimer in the documentation and/or other
- ~ materials provided with the distribution.
- ~ * Neither the name of 'Osmorc Development Team' nor the names of its contributors may be
- ~ used to endorse or promote products derived from this software without specific
- ~ prior written permission.
- ~ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
- ~ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- ~ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- ~ THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- ~ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- ~ OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- ~ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- ~ TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- ~ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -->
-
<html>
<body>
- <p>Checks whether a manifest file ends with a final newline (as required by the JAR file specification).</p>
+ Checks whether a manifest file ends with a final newline (as required by the JAR file specification).
</body>
</html>
\ No newline at end of file
diff --git a/java/manifest/src/inspectionDescriptions/MisspelledHeader.html b/java/manifest/src/inspectionDescriptions/MisspelledHeader.html
index 325bcb0..46a8138 100644
--- a/java/manifest/src/inspectionDescriptions/MisspelledHeader.html
+++ b/java/manifest/src/inspectionDescriptions/MisspelledHeader.html
@@ -1,30 +1,5 @@
-<!--
- ~ Copyright (c) 2007-2009, Osmorc Development Team
- ~ All rights reserved.
- ~
- ~ Redistribution and use in source and binary forms, with or without modification,
- ~ are permitted provided that the following conditions are met:
- ~ * Redistributions of source code must retain the above copyright notice, this list
- ~ of conditions and the following disclaimer.
- ~ * Redistributions in binary form must reproduce the above copyright notice, this
- ~ list of conditions and the following disclaimer in the documentation and/or other
- ~ materials provided with the distribution.
- ~ * Neither the name of 'Osmorc Development Team' nor the names of its contributors may be
- ~ used to endorse or promote products derived from this software without specific
- ~ prior written permission.
- ~ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
- ~ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- ~ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- ~ THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- ~ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- ~ OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- ~ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- ~ TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- ~ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -->
-
<html>
<body>
- <p>Reports any unknown and probably misspelled header names and provides possible variants.</p>
+ Reports any unknown and probably misspelled header names and provides possible variants.
</body>
</html>
\ No newline at end of file
diff --git a/java/manifest/src/org/jetbrains/lang/manifest/psi/impl/HeaderValuePartManipulator.java b/java/manifest/src/org/jetbrains/lang/manifest/psi/impl/HeaderValuePartManipulator.java
index 156b7b6..a4196dd 100644
--- a/java/manifest/src/org/jetbrains/lang/manifest/psi/impl/HeaderValuePartManipulator.java
+++ b/java/manifest/src/org/jetbrains/lang/manifest/psi/impl/HeaderValuePartManipulator.java
@@ -29,6 +29,7 @@
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiFileFactory;
import com.intellij.util.IncorrectOperationException;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.lang.manifest.ManifestFileTypeFactory;
import org.jetbrains.lang.manifest.psi.HeaderValue;
import org.jetbrains.lang.manifest.psi.HeaderValuePart;
@@ -39,7 +40,7 @@
*/
public class HeaderValuePartManipulator extends AbstractElementManipulator<HeaderValuePart> {
@Override
- public HeaderValuePart handleContentChange(HeaderValuePart element, TextRange range, String newContent) throws IncorrectOperationException {
+ public HeaderValuePart handleContentChange(@NotNull HeaderValuePart element, @NotNull TextRange range, String newContent) throws IncorrectOperationException {
String text = "HeaderValuePartManipulator: " + range.replace(element.getText(), newContent);
PsiFile file = PsiFileFactory.getInstance(element.getProject()).createFileFromText("DUMMY.MF", ManifestFileTypeFactory.MANIFEST, text);
HeaderValue value = ((ManifestFile)file).getHeaders().get(0).getHeaderValue();
diff --git a/java/openapi/src/com/intellij/lang/refactoring/JavaNamesValidator.java b/java/openapi/src/com/intellij/lang/refactoring/JavaNamesValidator.java
index 602ee86..f00fe56 100644
--- a/java/openapi/src/com/intellij/lang/refactoring/JavaNamesValidator.java
+++ b/java/openapi/src/com/intellij/lang/refactoring/JavaNamesValidator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,16 +17,19 @@
import com.intellij.openapi.project.Project;
import com.intellij.psi.JavaPsiFacade;
+import org.jetbrains.annotations.NotNull;
/**
* Default NamesValidator interface implementation. Uses java language keyword set and java language rules for identifier.
*/
public class JavaNamesValidator implements NamesValidator {
- public boolean isKeyword(String name, Project project) {
+ @Override
+ public boolean isKeyword(@NotNull String name, Project project) {
return JavaPsiFacade.getInstance(project).getNameHelper().isKeyword(name);
}
- public boolean isIdentifier(String name, Project project) {
+ @Override
+ public boolean isIdentifier(@NotNull String name, Project project) {
return JavaPsiFacade.getInstance(project).getNameHelper().isIdentifier(name);
}
}
diff --git a/java/openapi/src/com/intellij/psi/util/XmlMatchers.java b/java/openapi/src/com/intellij/psi/util/XmlMatchers.java
deleted file mode 100644
index d325296..0000000
--- a/java/openapi/src/com/intellij/psi/util/XmlMatchers.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2000-2013 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.psi.util;
-
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.xml.XmlTag;
-
-public class XmlMatchers {
- public static PsiMatcherExpression hasTagValue(final String value) {
- return new PsiMatcherExpression() {
- @Override
- public Boolean match(PsiElement element) {
- if (element instanceof XmlTag && value.equals(((XmlTag) element).getValue().getTrimmedText())) return Boolean.TRUE;
- return Boolean.FALSE;
- }
- };
- }
-}
diff --git a/java/openapi/src/com/intellij/refactoring/encapsulateFields/EncapsulateFieldHelper.java b/java/openapi/src/com/intellij/refactoring/encapsulateFields/EncapsulateFieldHelper.java
index fb7f01b..d7f0629 100644
--- a/java/openapi/src/com/intellij/refactoring/encapsulateFields/EncapsulateFieldHelper.java
+++ b/java/openapi/src/com/intellij/refactoring/encapsulateFields/EncapsulateFieldHelper.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -58,7 +58,7 @@
@NotNull FieldDescriptor fieldDescriptor,
@NotNull PsiReference reference);
- public static EncapsulateFieldHelper getHelper(Language lang) {
+ public static EncapsulateFieldHelper getHelper(@NotNull Language lang) {
return INSTANCE.forLanguage(lang);
}
}
diff --git a/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java b/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java
index aecd3d6..9aee3cf 100644
--- a/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java
+++ b/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java
@@ -39,7 +39,6 @@
import com.intellij.openapi.roots.ContentEntry;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.roots.ModuleRootManager;
-import com.intellij.openapi.util.Segment;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.*;
@@ -421,46 +420,10 @@
}
protected void setupCursorAndSelection(@NotNull final Editor editor) {
- ApplicationManager.getApplication().runWriteAction(new Runnable() {
- @Override
- public void run() {
- Document document = editor.getDocument();
- EditorTestUtil.CaretsState caretState = EditorTestUtil.extractCaretAndSelectionMarkers(document);
-
- final String newText = document.getText();
-
- if (editor.getCaretModel().supportsMultipleCarets()) {
- List<LogicalPosition> caretPositions = new ArrayList<LogicalPosition>();
- List<Segment> selections = new ArrayList<Segment>();
- for (EditorTestUtil.Caret caret : caretState.carets) {
- LogicalPosition pos = null;
- if (caret.offset != null) {
- int caretLine = StringUtil.offsetToLineNumber(newText, caret.offset);
- int caretCol = caret.offset - StringUtil.lineColToOffset(newText, caretLine, 0);
- pos = new LogicalPosition(caretLine, caretCol);
- }
- caretPositions.add(pos);
- selections.add(caret.selection == null ? null : caret.selection);
- }
- editor.getCaretModel().setCarets(caretPositions, selections);
- }
- else {
- assert caretState.carets.size() == 1 : "Multiple carets are not supported by the model";
- EditorTestUtil.Caret caret = caretState.carets.get(0);
- if (caret.offset != null) {
- int caretLine = StringUtil.offsetToLineNumber(newText, caret.offset);
- int caretCol = caret.offset - StringUtil.lineColToOffset(newText, caretLine, 0);
- LogicalPosition pos = new LogicalPosition(caretLine, caretCol);
- editor.getCaretModel().moveToLogicalPosition(pos);
- }
- if (caret.selection != null) {
- editor.getSelectionModel().setSelection(caret.selection.getStartOffset(), caret.selection.getEndOffset());
- }
- }
-
- PsiDocumentManager.getInstance(myProject).commitAllDocuments();
- }
- });
+ Document document = editor.getDocument();
+ EditorTestUtil.CaretAndSelectionState caretState = EditorTestUtil.extractCaretAndSelectionMarkers(document);
+ EditorTestUtil.setCaretsAndSelection(editor, caretState);
+ PsiDocumentManager.getInstance(myProject).commitAllDocuments();
}
@Override
@@ -516,7 +479,7 @@
String fileText = StringUtil.convertLineSeparators(ft);
Document document = EditorFactory.getInstance().createDocument(fileText);
- EditorTestUtil.CaretsState caretState = EditorTestUtil.extractCaretAndSelectionMarkers(document);
+ EditorTestUtil.CaretAndSelectionState caretState = EditorTestUtil.extractCaretAndSelectionMarkers(document);
String newFileText = document.getText();
String newFileText1 = newFileText;
@@ -536,47 +499,7 @@
assertEquals("Text mismatch in file " + filePath, newFileText1, text);
- CaretModel caretModel = myEditor.getCaretModel();
- List<Caret> allCarets = new ArrayList<Caret>(caretModel.getAllCarets());
- assertEquals("Unexpected number of carets", caretState.carets.size(), allCarets.size());
- for (int i = 0; i < caretState.carets.size(); i++) {
- String caretDescription = caretState.carets.size() == 1 ? "" : "caret " + (i + 1) + "/" + caretState.carets.size() + " ";
- Caret currentCaret = allCarets.get(i);
- LogicalPosition actualCaretPosition = currentCaret.getLogicalPosition();
- EditorTestUtil.Caret expected = caretState.carets.get(i);
- if (expected.offset != null) {
- int caretLine = StringUtil.offsetToLineNumber(newFileText, expected.offset);
- int caretCol = expected.offset - StringUtil.lineColToOffset(newFileText, caretLine, 0);
-
- assertEquals(caretDescription + "caretLine", caretLine + 1, actualCaretPosition.line + 1);
- assertEquals(caretDescription + "caretColumn", caretCol + 1, actualCaretPosition.column + 1);
- }
- int actualSelectionStart = currentCaret.getSelectionStart();
- int actualSelectionEnd = currentCaret.getSelectionEnd();
- if (expected.selection != null) {
- int selStartLine = StringUtil.offsetToLineNumber(newFileText, expected.selection.getStartOffset());
- int selStartCol = expected.selection.getStartOffset() - StringUtil.lineColToOffset(newFileText, selStartLine, 0);
-
- int selEndLine = StringUtil.offsetToLineNumber(newFileText, expected.selection.getEndOffset());
- int selEndCol = expected.selection.getEndOffset() - StringUtil.lineColToOffset(newFileText, selEndLine, 0);
-
- assertEquals(caretDescription + "selectionStartLine", selStartLine + 1,
- StringUtil.offsetToLineNumber(newFileText, actualSelectionStart) + 1);
-
- assertEquals(caretDescription + "selectionStartCol", selStartCol + 1,
- actualSelectionStart - StringUtil.lineColToOffset(newFileText, selStartLine, 0) + 1);
-
- assertEquals(caretDescription + "selectionEndLine", selEndLine + 1,
- StringUtil.offsetToLineNumber(newFileText, actualSelectionEnd) + 1);
-
- assertEquals(caretDescription + "selectionEndCol", selEndCol + 1,
- actualSelectionEnd - StringUtil.lineColToOffset(newFileText, selEndLine, 0) + 1);
- }
- else {
- assertFalse(caretDescription + "should has no selection, but was: (" + actualSelectionStart + ", " + actualSelectionEnd + ")",
- currentCaret.hasSelection());
- }
- }
+ EditorTestUtil.verifyCaretAndSelectionState(myEditor, caretState);
}
}.execute();
}
diff --git a/java/testFramework/src/com/intellij/codeInsight/EditorInfo.java b/java/testFramework/src/com/intellij/codeInsight/EditorInfo.java
index 78d75d6..cd4e97a 100644
--- a/java/testFramework/src/com/intellij/codeInsight/EditorInfo.java
+++ b/java/testFramework/src/com/intellij/codeInsight/EditorInfo.java
@@ -15,34 +15,20 @@
*/
package com.intellij.codeInsight;
-import com.intellij.openapi.application.Result;
-import com.intellij.openapi.command.WriteCommandAction;
-import com.intellij.openapi.editor.*;
-import com.intellij.openapi.util.Segment;
-import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.openapi.editor.Document;
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.editor.EditorFactory;
import com.intellij.testFramework.EditorTestUtil;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.ArrayList;
-import java.util.List;
/**
* @author cdr
*/
public class EditorInfo {
String newFileText = null;
- public EditorTestUtil.CaretsState caretState;
+ public EditorTestUtil.CaretAndSelectionState caretState;
public EditorInfo(final String fileText) {
- new WriteCommandAction(null){
- @Override
- protected void run(@NotNull Result result) throws Throwable {
- updateCaretAndSelection(EditorFactory.getInstance().createDocument(fileText));
- }
- }.execute();
- }
-
- private void updateCaretAndSelection(final Document document) {
+ Document document = EditorFactory.getInstance().createDocument(fileText);
caretState = EditorTestUtil.extractCaretAndSelectionMarkers(document, false);
newFileText = document.getText();
}
@@ -52,33 +38,6 @@
}
public void applyToEditor(Editor editor) {
- if (editor.getCaretModel().supportsMultipleCarets()) {
- List<LogicalPosition> caretPositions = new ArrayList<LogicalPosition>();
- List<Segment> selections = new ArrayList<Segment>();
- for (EditorTestUtil.Caret caret : caretState.carets) {
- LogicalPosition pos = null;
- if (caret.offset != null) {
- int caretLine = StringUtil.offsetToLineNumber(newFileText, caret.offset);
- int caretCol = caret.offset - StringUtil.lineColToOffset(newFileText, caretLine, 0);
- pos = new LogicalPosition(caretLine, caretCol);
- }
- caretPositions.add(pos);
- selections.add(caret.selection == null ? null : caret.selection);
- }
- editor.getCaretModel().setCarets(caretPositions, selections);
- }
- else {
- assert caretState.carets.size() == 1 : "Multiple carets are not supported by the model";
- EditorTestUtil.Caret caret = caretState.carets.get(0);
- if (caret.offset != null) {
- int caretLine = StringUtil.offsetToLineNumber(newFileText, caret.offset);
- int caretCol = caret.offset - StringUtil.lineColToOffset(newFileText, caretLine, 0);
- LogicalPosition pos = new LogicalPosition(caretLine, caretCol);
- editor.getCaretModel().moveToLogicalPosition(pos);
- }
- if (caret.selection != null) {
- editor.getSelectionModel().setSelection(caret.selection.getStartOffset(), caret.selection.getEndOffset());
- }
- }
+ EditorTestUtil.setCaretsAndSelection(editor, caretState);
}
}
diff --git a/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixParameterizedTestCase.java b/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixParameterizedTestCase.java
index 73e94a9..b4cd26e 100644
--- a/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixParameterizedTestCase.java
+++ b/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixParameterizedTestCase.java
@@ -16,11 +16,12 @@
package com.intellij.codeInsight.daemon.quickFix;
import com.intellij.testFramework.FileBasedTestCaseHelperEx;
+import com.intellij.testFramework.Parameterized;
import org.jetbrains.annotations.Nullable;
import org.junit.Test;
import org.junit.runner.RunWith;
-@RunWith(com.intellij.testFramework.Parameterized.class)
+@RunWith(Parameterized.class)
public abstract class LightQuickFixParameterizedTestCase extends LightQuickFixTestCase implements FileBasedTestCaseHelperEx {
@Override
public String getRelativeBasePath() {
@@ -34,32 +35,20 @@
return fileName.substring(BEFORE_PREFIX.length());
}
+ @SuppressWarnings("deprecation")
@Override
protected void doAllTests() {
super.doAllTests();
}
+ @SuppressWarnings("JUnit4AnnotatedMethodInJUnit3TestCase")
@Test
public void runSingle() throws Throwable {
- final Throwable[] throwables = new Throwable[1];
-
- Runnable runnable = new Runnable() {
+ runSingleTest(new Runnable() {
@Override
public void run() {
- try {
- doSingleTest(myFileSuffix, myTestDataPath);
- }
- catch (Throwable e) {
- throwables[0] = e;
- }
+ doSingleTest(myFileSuffix, myTestDataPath);
}
- };
-
- invokeTestRunnable(runnable);
-
- if (throwables[0] != null) {
- throw throwables[0];
- }
-
+ });
}
}
diff --git a/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixTestCase.java b/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixTestCase.java
index eafc24d..9bf434c 100644
--- a/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixTestCase.java
+++ b/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixTestCase.java
@@ -114,7 +114,9 @@
}
@NotNull
- public static Pair<String, Boolean> parseActionHint(@NotNull PsiFile file, @NotNull String contents, @NotNull @NonNls @RegExp String actionPattern) {
+ public static Pair<String, Boolean> parseActionHint(@NotNull PsiFile file,
+ @NotNull String contents,
+ @NotNull @NonNls @RegExp String actionPattern) {
PsiFile hostFile = InjectedLanguageManager.getInstance(file.getProject()).getTopLevelFile(file);
final Commenter commenter = LanguageCommenters.INSTANCE.forLanguage(hostFile.getLanguage());
@@ -198,6 +200,14 @@
return null;
}
+ /**
+ * @deprecated use {@link com.intellij.codeInsight.daemon.quickFix.LightQuickFixParameterizedTestCase}
+ * to get separate tests for all data files in testData directory.
+ */
+ protected void doAllTests() {
+ doAllTests(createWrapper());
+ }
+
public static void doAllTests(QuickFixTestCase testCase) {
assertNotNull("getBasePath() should not return null!", testCase.getBasePath());
@@ -210,7 +220,7 @@
}
});
- if (files == null) {
+ if (files == null || files.length == 0) {
fail("Test files not found in " + testDirPath);
}
@@ -218,20 +228,12 @@
final String testName = file.getName().substring(BEFORE_PREFIX.length());
doTestFor(testName, testCase);
}
- assertTrue("Test files not found in "+testDirPath,files.length != 0);
}
protected void doSingleTest(String fileSuffix) {
doTestFor(fileSuffix, createWrapper());
}
- /**
- * @deprecated use com.intellij.codeInsight.daemon.quickFix.LightQuickFixParameterizedTestCase to get separate tests for all data files in
- * testData directory
- */
- protected void doAllTests() {
- doAllTests(createWrapper());
- }
protected void doSingleTest(String fileSuffix, String testDataPath) {
doTestFor(fileSuffix, createWrapper(testDataPath));
}
diff --git a/java/testFramework/src/com/intellij/ide/projectWizard/ProjectWizardTestCase.java b/java/testFramework/src/com/intellij/ide/projectWizard/ProjectWizardTestCase.java
index d328f5a..96e85a2 100644
--- a/java/testFramework/src/com/intellij/ide/projectWizard/ProjectWizardTestCase.java
+++ b/java/testFramework/src/com/intellij/ide/projectWizard/ProjectWizardTestCase.java
@@ -82,7 +82,7 @@
return new NewModuleAction().createModuleFromWizard(myProject, null, myWizard);
}
- protected void runWizard(String group, String name, Project project, @Nullable Consumer<Step> adjuster) throws IOException {
+ protected void runWizard(String group, final String name, Project project, @Nullable final Consumer<Step> adjuster) throws IOException {
createWizard(project);
ProjectTypeStep step = (ProjectTypeStep)myWizard.getCurrentStepObject();
@@ -95,7 +95,17 @@
adjuster.consume(step);
}
- runWizard(adjuster);
+ runWizard(new Consumer<Step>() {
+ @Override
+ public void consume(Step step) {
+ if (name != null && step instanceof ChooseTemplateStep) {
+ ((ChooseTemplateStep)step).setSelectedTemplate(name);
+ }
+ if (adjuster != null) {
+ adjuster.consume(step);
+ }
+ }
+ });
}
protected void createWizard(Project project) throws IOException {
diff --git a/java/testFramework/src/com/intellij/refactoring/MultiFileTestCase.java b/java/testFramework/src/com/intellij/refactoring/MultiFileTestCase.java
index cadc61a..7f2716e 100644
--- a/java/testFramework/src/com/intellij/refactoring/MultiFileTestCase.java
+++ b/java/testFramework/src/com/intellij/refactoring/MultiFileTestCase.java
@@ -35,36 +35,44 @@
public abstract class MultiFileTestCase extends CodeInsightTestCase {
protected boolean myDoCompare = true;
- protected void doTest(final PerformAction performAction) throws Exception {
+ protected void doTest(final PerformAction performAction) {
doTest(performAction, getTestName(true));
}
- protected void doTest(final PerformAction performAction, final boolean lowercaseFirstLetter) throws Exception {
+ protected void doTest(final PerformAction performAction, final boolean lowercaseFirstLetter) {
doTest(performAction, getTestName(lowercaseFirstLetter));
}
- protected void doTest(final PerformAction performAction, final String testName) throws Exception {
- String path = getTestDataPath() + getTestRoot() + testName;
+ protected void doTest(final PerformAction performAction, final String testName) {
+ try {
+ String path = getTestDataPath() + getTestRoot() + testName;
- String pathBefore = path + "/before";
- final VirtualFile rootDir = PsiTestUtil.createTestProjectStructure(myProject, myModule, pathBefore, myFilesToDelete, false);
- prepareProject(rootDir);
- PsiDocumentManager.getInstance(myProject).commitAllDocuments();
+ String pathBefore = path + "/before";
+ VirtualFile rootDir = PsiTestUtil.createTestProjectStructure(myProject, myModule, pathBefore, myFilesToDelete, false);
+ prepareProject(rootDir);
+ PsiDocumentManager.getInstance(myProject).commitAllDocuments();
- String pathAfter = path + "/after";
- final VirtualFile rootAfter = LocalFileSystem.getInstance().findFileByPath(pathAfter.replace(File.separatorChar, '/'));
+ String pathAfter = path + "/after";
+ final VirtualFile rootAfter = LocalFileSystem.getInstance().findFileByPath(pathAfter.replace(File.separatorChar, '/'));
- performAction.performAction(rootDir, rootAfter);
- WriteCommandAction.runWriteCommandAction(getProject(), new Runnable() {
- public void run() {
- myProject.getComponent(PostprocessReformattingAspect.class).doPostponedFormatting();
+ performAction.performAction(rootDir, rootAfter);
+ WriteCommandAction.runWriteCommandAction(getProject(), new Runnable() {
+ public void run() {
+ myProject.getComponent(PostprocessReformattingAspect.class).doPostponedFormatting();
+ }
+ });
+
+ FileDocumentManager.getInstance().saveAllDocuments();
+
+ if (myDoCompare) {
+ PlatformTestUtil.assertDirectoriesEqual(rootAfter, rootDir);
}
- });
-
- FileDocumentManager.getInstance().saveAllDocuments();
-
- if (myDoCompare) {
- PlatformTestUtil.assertDirectoriesEqual(rootAfter, rootDir);
+ }
+ catch (RuntimeException e) {
+ throw e;
+ }
+ catch (Exception e) {
+ throw new RuntimeException(e);
}
}