summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2014-04-10 10:54:17 -0700
committerTor Norbye <tnorbye@google.com>2014-04-10 10:54:39 -0700
commita3e39abd38575b02d52f05e041d797023938b6d6 (patch)
tree9791aa0988b9461354c1b1476b43bcb6b9ea7da4 /java
parent1fff8e2b7bbcfdea262d3782d4307ca6437da2a3 (diff)
downloadidea-a3e39abd38575b02d52f05e041d797023938b6d6.tar.gz
Snapshot 1fff8e2b7bbcfdea262d3782d4307ca6437da2a3 from idea/136.1153 of git://git.jetbrains.org/idea/community.git
38fcfd7: try more times to connect. 6ee4e80: Merge remote-tracking branch 'origin/master' 85a331b: Cleanup. 8e1582f: Logging an error in case of absent name. a33ddd0: Add javadoc for RemoteConnectionType. c9cea5a9: introduce OrphanGuardian interface cadf1a7: Revert "hide on UI changes" 62aa21e: avoid status bar update on internal method invoke c22e314: nashorn conditional breakpoints f03bc43: cleanup 9372f19: Merge remote-tracking branch 'origin/master' 94f10a8: PY-12367 loop variable should be able to reuse on else clause 1b02460: Merge remote-tracking branch 'origin/master' c5294ef: hide on UI changes 3259502: fix NavBar blinking and resizing on Color Scheme change due to async tweaking in updateUI 97eddb8: Cosmetic changes fede9f0: IDEA-122004 Good code red: surefire.forkNumber in pom.xml ce5b97b: fix UI artifacts after exiting from Presentation Mode 6937b4d: StatusBar doesn't change when perform Prefs -> Appearance -> Custom fonts 30d235a: IdeRepaintManager.checkThreadViolations fix during readExternal() 7346c3a: [log] IDEA-118576 Don't show focus border cc3e0c5: [log] IDEA-115902 Fix visual artifact on multi-repo indicator 1146cb6: Merge remote-tracking branch 'origin/master' b991bf2d: PY-11948 Run manage.py Task ignores environment variables defined for Django Console (and Python Console) 4e41daa: IDEA-122035 accept "tip" as a branch name d8382bb: remove unneeded read actions d348434: Merge remote-tracking branch 'origin/master' 6248e48: moved unittest tests to env tests ee3f4a5: IDEA-121966 Multiple-Cursor Jumpy f8e6cc5: moved doctest tests to env tests 914621c: IDEA-121295 If property part of new property - unable to introduce new property - Maven db3f6c7: replace tuple with list quick fix for tuple item assignment inspection e7cd951: Presentation Mode: common font-size fix for all toolwindows with trees 12f048b: Wrap with Exception quick fix for Raising a string exception inspection 0f5ec0d: Propose change signature quick fix for Method signature does not match signature of overridden method inspection 07ecf4d: cleanup 6ac6f4d: IDEA-122049 Mac messages: in some cases parent window is incorrectly detected 5ee2cf2: added remove return statement quick fix for the return from init inspection 1f0a076: IDEA-121995 Code selection is reseted on last line with space if Allow placement of caret inside tabs is enabled 54936df: added rename argument quick fix for the Incorrect call arguments inspection 45020ac: move quick fix to proper place e909581: IDEA-105935 Facets excluded from detection are still added on maven reimport 57c3cd7: Optimize MavenImporter.getSuitableImporters() f0d0f8e: do not build VFS for excluded directories 34c32ea: added remove argument quick fix to the Incorrect call arguments inspection 09f5de3: extract variables and method a145844: EA-54755 - NPE: FoldingUtil.findFoldRegionStartingAtLine c37d1ba: libs for project templates f7fad4d: IDEA-88443 (Run Inspection by Name: Inspections with same name are only shown once) 8521b4b: improve description b65fdb0: show problematic plugins 13cfa13: extract method 06cf300: Merge branch 'master' of git.labs.intellij.net:idea/community 4c2734f: after uninstall of a plugin the button should show "Restart" 1dbe26d: IDEA-121807 - Tomcat Logs doesn't show 02ad525: init nashorn conditional breakpoints 6cd525c: cleanup 1a0161e: cleanup e939ebe: reverted fix for IDEA-121961 because of failing test 8b32345: after installation of a plugin the button still shows "Install" e6e0d7d: Merge branch 'master' of git.labs.intellij.net:idea/community 1cb358a: IDEA-85098 Intellij is not supporting groovy-eclipse-compiler fd27d3b: IDEA-120027 - Import Git-cloud apps from sources - register VCS roots 787d068: filter by custom/bundled b5950b4: IDEA-120027 - Import Git-cloud apps from sources - single account for all run configurations 53f918f: align text and make header bg match to html bg cf75116: IDEA-121695 Add managed dependency info on hover over icon 2e5effd: IDEA-121762 Navigate->Select in: for Spring MVC Controller e301c4e: [log] IDEA-118328 Fix already disposed 5a621a4: updated plugin should have MODIFIED foreground b46a3bb: hide description on custom plugin panel f8155ad: add description label 6c9c9f6: added change signature refactoring quick fix to the Incompatible signatures of _new_ and _init_ inspection bb243be: cleanup 35312e5: Merge remote-tracking branch 'origin/master' e02ca9c: comment testdata 11cea86: New messages are implemented for jdk7 and latter jdk versions for now. 753497a3: Merge remote-tracking branch 'origin/master' ec60260: Merge remote-tracking branch 'origin/master' 2a91bce: highlight both incompatible signatures a314614: Merge remote-tracking branch 'origin/master' fefdeaf: Merge remote-tracking branch 'origin/master' 4afd85f: Merge branch 'python-fixes' 4b797eb: cleanup 168dbd0: IDEA-117493 Native crash in Mac launcher 88ed475: diff: do not show 'No changes' panel when 'Can not show diff' should be shown a148809: Merge remote-tracking branch 'origin/master' 88c7d65: lambda completion: strip unnecessary parenthesis, generate parameter names as for override/implement (IDEA-121947) f738b51: diamonds: incompatible error due to cls class in default package fixed - cls file doesn't process declarations! = need to switch to mirror (IDEA-121866) 2fefd8b: abstract method overrides abstract: distinguish between covariant returns (IDEA-121930) d851893: testdata for IDEA-121999 b89dc39: testdata for IDEA-121884 7d747c8: new inference: most specific with same functional interface presence 465325a: new inference: nested varargs 144684b: java 8: accept diamonds in method calls 4112118: new inference: choose most specifics between 2 varargs methods 1ee2942: new inference: raw inner class method qualifier fixed (IDEA-121909) 912e13d: add junit4.jar together with hamcrest (IDEA-119626) 10760d9: new inference: process varargs as separate method candidate/separate phase 69c6b7b: java 8 compatibility 62328cf: inspections: completely ignore currently unresolved scopes fb20169: new inference: reject varargs as method reference target 0f40eb9: new inference: exact method reference is not pertinent to applicability when target type is type parameter f64d239: rename suggestions: suggest new names for non-variables (IDEA-121982) 05289e4: Guess Python language level from SDKs of opened projects if it's not available for PSI elements c1346de: codestyle cleanup ee5f16e: added Add Exception base class quick fix to the Exception doesn't inherit from standard ''Exception'' class inspection 5b8ebf6: EA-54668 - NPE: Breakpoint.setLogEnabled 90c4e07: codestyle cleanup 61b1cb2: do not store reference to PsiElement in qFix, codestyle cleanup, cleanup deprecated method usage 28cc4de: Fix mappings initialization. 41c9f6f: NotNull annotations and checks. 4334ce2: Cleanup (pointless exceptions; field extracted; formatting) 278b8d6: IDEA-121928 Grails 2.3.7 reloading is broken in IntelliJ 13.0.2 bb5986d: IDEA-121938 (serialPersistentFields trips "MismatchedReadAndWriteOfArray" inspection) 93974a3: fix description 58a3377: IDEA-121920 (X/X can be replaced with X - incorrect arithmetic) 7f73d5e: Merge remote-tracking branch 'origin/master' 177f404: Fixed Nullable/NotNull annotations. f058695: IDEA-54387 (type annotations in introduce parameter) 6bf6d11: Cleanup (pointless exceptions; typos; formatting) e5fb46b: VcsIntegrationEnablerTest implemented for mock test vcs c6a1054: IDEA-121990 Filter by old branch fails with exception if full graph is not loaded 7a73eee: IDEA-121961 Debugger: evaluate from variables doesn't include context e2eaf0d: Support 'overwrite' parameter for maven-resources-plugin. 2acd338: rebase several problems fixed 2ace00e: cleanup deprecated method usage 298c646: @NotNull getStatementList 20269f4: do not store reference to PyFile in add function quickfix 5bd7108: code style cleanup 546c689: get rid of deprecated functions use 85b572b: do not store reference to PsiElement in add field quickfix a3343a3: Merge remote-tracking branch 'origin/master' f96d241: turn java messages on d2d3aa0: IDEA-116134 Inherited maven resource filtering is not applied 532e079: do not suggest python run configuration for scratch files fc9c134: fix ui under darcula b00e8a2: [log] IDEA-121992 Recalculate old heads values 813b0dc: Merge remote-tracking branch 'origin/master' 8d41286: Package method for checking version added 4155d62: code style cleanup 757f50b: code style cleanup f5ac410: cleanup 37c7fca: removed state from add super call quickfix, added tests 08e2f55: refactoring - following CR-IC-4721 c415007: Cleanup (formatting; javadoc) 64c651e: IDEA-54397 (type annotations in override/implement) 3f3e064: IDEA-54396 (type annotations in "Wrap Return Value") b360456: IDEA-104026 (Java type annotation formatting) 744d7c8: java: "wrap return value" bean formatting fixed 1540e54: Cleanup (pointless exceptions; formatting; nullability) fb7c097: IDEA-121834 (generic exception substituted) 378b22a: added format specifier quick fix for the python string format inspection 041748c: Package method for checking version addded 35cc71f: eclipse compiler updated to the latest version 7c1a2d6: [git log] Add icon for deep compare function 741e9b9: [log] IDEA-121875 Enable manual commits sorting in VCS that support it ee27725: make mouse shortcut for adding/removing carets configurable (IDEA-80056) 2ba4ece: Merge remote-tracking branch 'origin/master' 8dd9cc4: added remove dictionary key quick fix for the Dictionary contains duplicate keys inspection f0a66f7: [log] Fix HashImpl equals 5bd2cdd: [log] HashImpl: remove the caching map 0affa6a: dom: use ReflectionUtil.getClass{Public,Declared}Methods to skip synthetic methods (which change from one java version to another) aea8f6d: added move except clause quick fix for the Bad except clauses order inspection 39ca570: IDEA-121935 (Inspections: Overloaded variable argument method: every non-problematic method adds a warning) 8d172ac: IDEA-121952 (Java 1.8: "Interface may be annotated with @FunctionalInterface" inspection reports already annotated interfaces) b1977ea: added Remove assignment quick fix for the Assigning function call that doesn't return anything inspection 81ca41b: test fixed b6b5a68: fixed PY-11981 "PEP 8 naming convention violation" inspection treats class attributes as function variables f791db7: fixed PY-10342 Instance attribute defined outside init: detect functions called in init 4d76bdb: Statement list cannot be null f839260: Merge remote-tracking branch 'origin/master' 6f6d813: fixed PY-12033 PyAbstractClass invalid warning for properties. 85d52dd: IDEA-118296 Impossible to "Prevent App Nap" for the 133.* in MacOSX 10.9 (Mavericks) c748cef: artwork update for 13.1 2ee2888: attempt to clarify the inspection description c517b2c: add test 5a0f6fb: Merge remote-tracking branch 'origin/master' 4b96dbf: IDEA-116029 in-place introduce variable name suggestions popup disappears before I can select anything PARTIAL ROLLBACK, fix to be continued... bd199f1: Merge remote-tracking branch 'origin/master' b3dfff9: partially reverting 10f6a0f: psi depedent index get buffering status updates because they are applied to unsaved committed documents 255512d: Merge remote-tracking branch 'origin/master' fa8f612: Move ssh connection provider to remote-run. 1357e2b: use a more memory-efficient structure to hold a long indexed file list a0885a9: Merge remote-tracking branch 'origin/master' 23b20a8: Merge remote-tracking branch 'origin/master' 69c9865: fix test bbf4741: - Removed dependency on remote-run in vagrant plugin (PY-12254). - New api for path mappings providers (old left for compatibility with RubyMine and PhpStorm) - Fix launching of Python console for remote interpreter. e5d9dff: add -> keyword to cpp and make sure it's lexed correctly (IDEA-121906) 5e71180: add a proxy test that fails on java 8 ffa6350: enable new nashorn variables view by default c60c038: style: remove unnecessary method 965aafa: for unsaved documents with committed state and psi backed index use the same logic as for unsaved documents with plain index 8c56a6b: github tests with wrong notifications fixed 8ce415d: [log] Fix tests. (fix wrong line separators) ff002de: [log] Remake VcsLogJoiner without recursion. 7ac6e11: [log] IDEA-118947 Implement special highlighting for cherry-pick 881645a: [log] Add ability to listen to possible filter changes eff05ea: [log] Add ability to reuse branches filter popup d282a0e: [log] Expose VcsLogRefs into API 3d81303: [log] Expose the VcsLogFilterUi to the API, let set filter value a54504c: [log] repaint ui after adding highlighter 542550f: [log] make constants final 7066854: [log] Introduce VcsLogDataProvider to the API as part of VcsLogDataHolder e10b40f: [log] Expose VcsLogUI & DataPack to the vcs-log-api 55c79a0: [log] Make it possible to add VcsLogHighlighters to the log table. 0bca3c6: [log] Remove obsolete CommitCell & its Renderer 61e2ecc: renderValue — add XValue parameter to simplify, why we need to create b6738e4: Merge branch 'master' of git.labs.intellij.net:idea/community 8e48244: IDEA-119822 - Support Heroku Debug 1052ef2: less garbage 35a1eba: optimisation: use AtomicLazyNullableValue to avoid extra indirection and save memory cce38ff: cleanup 799041b: notnull f60abae: NPE protection e6806dd: remove old code commented code d7464ee: support run configurations 5717d3a: make public and refactor to make accessible from Search Everywhere 20d9cb0: make public 010566a: IDEA-58818 (SSR: strange highlighting of try-catch in preview pane) 4e1ef49: cleanup 52a92f2: Gradle: detect Scala plugin presence dynamically (to avoid cyclical plugin dependency) 0333bd1: Local History: do not load ignored files and folders into VFS 4fbcf60: cleanup 7a80e9c: fix duplicates and wrong order in search everywhere 48d4765: Platform: check and warn when trying to edit non-project files (do not update notifications, when not necessary) 8358761: IDEA-121898 (Add Don't ignore String for inspection "Number costructor..") 5e097fa: IDEA-121088 (Java Inspections: Type may be weakened readObject() writeObject()) 68b7c88: add fourth checkbox to description cbff651: Platform: check and warn when trying to edit non-project files (disabled in tests) c0847ee: Merge remote-tracking branch 'origin/master' 590f153: Platform: check and warn when trying to edit non-project files 14a5a6b: gradient colors for buttons ba067df: initial 774559b: cleanup 9a337d5: IDEA-121494 (Inspection "method overrides private method" can be improved) cc18c42: add table header with sorters a4d8900: always use gradient c559f14: diff: fix UnknownFileType detection 87113dc: re-arrange downloads label 311ff47: github: remove usage of deprecated VcsNotifier API c3b9b90: [log] IDEA-117553 Optimize details loading: don't parse Changes at once 645caac: 134->136 1168c7b: Cleanup (common method; pointless assertion; formatting) 66eaa91: nashorn: continue variables presentation simplify V8Scope 3627c46: dfa: treat different constants with same values as same (IDEA-121837) 8084cb0: Rebase feature for update project implemented fc56bcb: Increment hours in comments 044acff: IDEA-121835 "Breakpoints" UI looks clumsy aa2b1cb: always fold long command line in console (IDEA-121453) 6de56f5: some CharSequence utility methods defc8ce: IDEA-121800 Live templates are shown in 'Find in Path' dialog if 'autopopup completion' is enabled dccb826: new inference: cache substitutor for outer call conflict resolution a5adf26: IDEA-88643 delete item from list of breakpoints by pressing delete key: selection should not return to position 1. 424cffe: [git log] IDEA-121818 Accept HEAD as branch name a393838: [log] IDEA-121817 Fix keeping selection 70c52ca: [log] Remove the obsolete NoGraphTableModel & simplify the code which used to use it f41b964: [log] unused 611e758: StringExpressionHelper: JSF->Java-Analysis 54fccb5: IDEA-121828 (Add single member static import intention should be available on incomplete code) 6d2515c: fix IDEA-112499 for single member static imports 811fdf5: fix IDEA-112499 for on demand imports b52ec5f: IDEA-121784 (Add on demand static import intention not available when single-member static import present) 8853670: IDEA-119908 Smart Step doesn't work for classes generated with java 8 e36425ec: Moved LanguageLevel.forFile() to PyUtil.getLanguageLevelForVirtualFile() 8870abb: Get Python language level from PsiElements where possible instead VirtualFiles 7438ce8: added create property quick fix for the property access inspection ead71e4: IDEA-121645 Breakpoints conversion: disabled condition is just lost 60fa43c: use constant for history id 15cb81b: continue decouple xdebugger ex ui — XValue/XStackFrame impl 8238972: added Make public quick fix for the protected member access inspection f471666: fixed NPE in BreakpointManager.getPsiFile aae9011: Merge branch 'python-fixes' 155f99a: added create property quick fix d9ae792: IDEA-121806 Breakpoints fail after file modification e7713c6: test fixed b5b1518: cleanup 1f2f49e: Platform: do not reverse tabs order on project reopening (IDEA-121816) + new tabs should open on the right (OC-3490) 2b21896: enable multiple carets by default (IDEA-80056) 44646fe: comment added for CPP-147 fix 6da7645: EA-54287 (diagnostic) eab3611: fixed code style 25c45d1: added rename quick fix to the protected member inspection d29cdc8: Merge remote-tracking branch 'origin/master' 2527c3a: Merge remote-tracking branch 'origin/master' 6f729cf: EnforcedPlainTextFileTypeManager: pass project as a parameter [CR-IC-4656] 8e176ce: EnforcedPlainTextFileTypeManager: Fix broken file status update sequence (PhpCompletionTest.testExcludedFiles()) [CR-IC-4656] a5f3040: Use HttpMethod#hasBeenUsed to prevent NPE, if server response was not received 218756a: Merge remote-tracking branch 'origin/master' 3b799e4: filtering templates by frameworks 2670f2d: yellow code 6a440f7: IDEA-121259 Generated toString() placed in incorrect class 3588589: IDEA-121803 (Windows date/time format translation error) c49bd80: svn: Perform saving all documents during move/rename in SvnFileSystemListener only if operations are related to files under svn - otherwise it could break functionality not related to svn (like renaming file under git) if svn plugin is enabled b6f778a: disable test navigation outside test roots 43d2b2e: default mapping for SelectAllOccurrences action (IDEA-80056) da2374a: if facet has associated framework show 'add facet' instead of 'add framework support' dialog in Project Structure (IDEA-120643, IDEA-113833) 594cad9: WEB-10567 Implemented a way to stop run configurations when starting incompatible ones. The idea is that some run configurations may implement CompatibilityAwareRunProfile.isCompatibleWith method and signal that they are not compatible with the run configuration being started so a dialog is displayed to a user and the user can choose to stop incompatible configurations. +review CR-IC b814f54: IDEA-121403 Live Template: "Surround with tag" should not be applicable while editing XmlAttributeValue 8db0857: better category name 40c45ca: do not add generic builder for "category" templates (e.g. Java FX) 79feee3: EditorActionHandler API cleanup (IDEA-80056) f4bbcbc: notify listener on task cancellation a53cccd: IDEA-71048 (test fixed) 4b6b959: system.out removed 3b408e6: Merge remote-tracking branch 'origin/master' 38bdd09: Open terminal in folder that was dragged to it from project view (IDEA-115145). 4586d4a: IDEA-71048 (system date/time formats on Windows) 6a119d1: platform: batch load system date/time formats c4e7e1f: Cleanup (pointless exceptions; formatting) 177a1d9: drop deprecated stuff e5740c5: Return true from dispatch in case of event processing. 38764d4: Merge remote-tracking branch 'origin/master' 8f8ef28: IDEA-114457 Undocked 'project' tool window doesn't always automatically hide when I double-click to open a file Animation fix (don't freeze EDT, use Animator), request focus fix. 5ac6d6f: cleanup e02f4ef: Terminal should override IDE shortcuts by default (IDEA-118837). fd85821: Merge remote-tracking branch 'origin/master' 026cf99: PY-12022 Clicking "Rerun" button of "Run manage.py Task..." doesn't stop current process eb2b2db: don't treat live template complete() as second basic completion invocation (HtmlCompletionTest.testXhtmlCompletionInHtml) 6ebe750: dumb-aware actions in the Messages panel 557cca9: IDEA-108072 (Don't suggest to add on-demand static import for the current class) 8d6f72b: IDEA-121756 Don't provide postfix completion options in java string literals c738a20: IDEA-89020 Disappears value of the variables standing next in Live templates IDEA-121634 Live Template: template is broken with 3+ variables and leading space 31dbd88: use constant empty array (following CR-IC-4606) 8537206: Extract RSS parsing logic and thus remove Atlassian plugin sources completely 1f4a22c: Fix Flex tests + IDEA-121771 <fx:Script> tag autocomplete broken b08a89d: cache scope attribute keys to reduce daemon garbage ddd7530: IDEA-121609 Cannot find '+' + using Find in Path f723320: Merge branch 'master' of git.labs.intellij.net:idea/community c66ea39: Local History fix: load file children on fileCreated event (second try) 1c7fa2c: IDEA-120027 - Import Git-cloud apps from sources - Heroku 5eab7d1: try single member static import first in live templates 364298f: IDEA-121738 Shift-click in gutter doesn't create 'no suspend' breakpoint anymore a0a8fe7: fixed editBreakpoint 912e749: diff: do not apply single change multiple times 3403bab: IDEA-12609 diff: do not consider equal changes as conflict 5379407: diff: do not create empty change on applying modified part of 'modified - deleted' conflict a0c4ea5: diff: rewrite MergeBuilder and MergeList fc8f64b: merge: rewrite MergeBuilder 90390cf: merge: add test 0adb7cc: @NotNull bbe7af5: move Inject SQL tip to intelliLang-java f14856e: speeding up 'Synchronizing output directories': avoid unnecessary rootsChanges events if many output directories were created during compilation (ZD-22766, IDEA-116757) 06b2ee3: fixed PY-11293 namedtuple underscore-methods are not protected f00ecc2: Merge remote-tracking branch 'origin/master' 2a07097: [git log] don't query ALL when branches to query are specified 397158b: VcsNotifier methods renamed according to their notification groups 24ce9d6: Exception throw for Unit Test mode removed from GitBranchOperation 6ef9934: CPP-147 PSI is build for files from another project +review CR-IC 64ab58d: nullability c221e1a: cleanup 0d4f12a: nashorn: initial getReceiverVariable impl 5ab90de: continue nashorn: variables view c750301: nullability 86d092e: nullability c97dd80: IDEA-98746 Annoying editor tab tooltips Step 2: clicks will hide tooltips & affect the point below; true "contains" for balloons 060290a0: make carets retain valid positions on Tab width changes, when multiple carets are enabled (IDEA-80056) 7325dffa: Changed default language level to Python 2.7 fd361c4: Merge remote-tracking branch 'origin/master' 1a931f9: lambda: unhandled exceptions inside method body should be treated as those inside anonymous classes (IDEA-121741) a042720: stream migration inspection: preserve comments (IDEA-121679) b060c81: stream migration inspection: collapse only primitive new initializers (IDEA-121745) 4d87683: fixed PY-12113 Questionable "access to a protected member of a class" inspection in tests 90d0740: IDEA-98746 Annoying editor tab tooltips Step 1: new setting has been added (Editor -> Editor Tabs -> Show tabs tooltip) e50b960: [git] remove unused MultipleContentsRevision 70bb70d: [log] Added time measurements to the VCS log 66fb815: renamed resolveWithoutImplicits to getResolveContext (which is more meaningfull) e1ce2db: [log] Synchonize access to the VcsUserRegistry a29e2b1: [log] DRY 082b273: [log] prohibit repaint during collapse/expand all branches 6f4a2d5: [log] fireTableStructureChanged if graph changes after some action 23396b0: [log] rename updateUI to repaintUI; unwrap: it shouldn't be executed not from EDT. 347647a: [log] handle answer a631891: [log] No need to set default cursor 8475418: [log] let handleAnswer be in the single place: VcsLogUI. 43f775c: [log] Add support of getContainingBranches method. 480d1ab: [log] Fix wrong collapse branch nodes. 758c07e: [log] Fix bug related with not load commit node. a944fe6: [log] Create JumpToNotLoadCommitActionRequest. 610219e: [log] VcsLogSorted fixed. 2d748d6: [log] Disabled selection of relative commits. 03a2a25: [log] Fix performance of collapse all action. 75ff6e6: [log] Add LinearBranchesExpansionAction support. (But collapse all may need more time). 6eaa9bf: [log] Add several debug messages. 45da0e7: [log] Disable draw harmonics in filters. aeff40e: [log] Add graph for filters. 12bb25e: [log] Don't fail for fresh repositories without commits bfbc9e4: [log] Don't make graph with always-false filters 33a3bf2: some automatic changes in community modules ca7f8d3: remove unused cc1b58a: [log] no filter => null, enable new graph by default, temporary return null if no commits match c153674: [log] temp diagnostics: why graph sometimes disappear ab4b7ac: [log] VcsLogSorter stub 8a62c27: [log] temp diagnostics: why graph sometimes disappear 4fd20fc: [log] Fix crash, when mouse over empty row. 8af46ee: [log] Add CollapsedMutableGraph. 6cc0435: [log] Add FragmentGenerator. 0859662: [log] Added highlighting relative commits. 8922251: [log] Extract dfs to DfsUtil. fe36f19: [log] Simple painter fix. 3e9f31b: [log] Fix not load commit node. 90c7bd1: [log] Fix case when not using new graph for filtering & using old graph facade b6ed824: [log] IDEA-117157 Filter by multiple branches eeefcfa: [log] use new graph for filtering commits (disabled by default) 56f381b: [git log] Support filtering by several branches 0cfc872: [log] Fix author column width calculation 20aeb1a: [log] Optimize case with filters: read & store commits without details 01121ba: [log] Add arrow highlighted when mouse over. 4421f12: [log] Add GraphActionDispatcher. ecdc992: [log] Fix Image overflow. 52db2ef: [log] Fix GraphCellGeneratorImpl. 863d8c7: [log] Fix Branch color. 04a0bc7: [log] Use new GraphFacade dfc41b0: [log] Temp fix SimpleGraphCellPainter 4f028e7: [log] Copy GraphCellPainter from old log. 62dd4f6: [log] Fix graph, when not all log loaded. 84790b5: [log] Add GraphCellGenerator. 3bf48c4: [log] Add MutableGraph and simple Impl 232fe7f: [log] Add PermanentGraph & Layout 413a6a9: [log] Add GraphFlags 3e4e166: [log] Add IntToIntMap, AbstractIntToIntMap, TreeIntToIntMap and TestTreeIntToIntMap 7642e8a: [log] Get rid of VcsLogDataHolder#getDataPack: pass DataPack manually 435fffb: [log] Explicitly pass VcsLogDataHolder & VcsLogUiProperties 270649b: [log] VcsUserRegistry: return a copy of users map, to avoid CCME 5dd7cd9: [log] Extract graph facade building into separate class 691077d: GraphColorManager initial implementation a615943: [log] remove no more needed dependencies from vcs-log-graph be34c32: [log] DataPack: create GraphFacadeImpl instance in build 584e37d: [log] Move GraphFacade implementation to vcs-log-graph module 4e968e1: [log] remove unused stuff from the DataPack. bfcb3f4: Override paintComponent() instead of paint(). 99d52e8: [log] Delegate graph painting to the GraphFacade c152a29: Move clicks & hovers to the GraphFacade a00646d: GraphColorManager: more methods + javadocs 98b80a1: rename & check link listener first 54a50ae: GraphAnswer interface f9b9890: rename to GraphFacade 055f10b: optimize search commit by part of hash d1b69d1: remove getVisibleCommits since we've got getVisibleCommitCount & getCommitAtRow 411a76f: javadocs bb8b897: optimize getOneOfHeads: store it in Branch instead of the VirtualFile. cd4728b: Transition to GraphFacade, step 4: click to row a74518c: Transition to GraphFacade, step 3: expansion actions 9311f2f: Transition to GraphFacade, step 2: setVisibleBranches 89dd596: Transition to GraphFacade, step 1: getVisibleCommits(), getRoot() e852593: remove unused methods 8661db5: GraphColorManager 81488e4: some javadocs & GraphInfoProvider extraction 039520b: Graph Black Box refactoring initial step fce20a5: IDEA-121764 Debugger does not show null values e14e913: IDEA-121739 Debugger doesn't stop on breakpoints in some anonymous classes 675fa42: fix tests. Rebinding for 'def' reference should do nothing because it references to an inferred variable's type or to a variable itself. 5a54361: IDEA-116134 Inherited maven resource filtering is not applied 1766d06: Groovy: fix parameter info 812d0d6: Groovy: remove redundant GrDefaultAnnotationValue psi. 2bc747e: Groovy: import static intention should be available on argument list cdfdf8d: IDEA-121662 Unify Groovy and Java Intention behavior 82a4f0d: IDEA-121318 optimizing whether place is child of import statement. Actually place can be a child of an import statement only if it is a GrCodeReferenceElement. 400d1ff: one big comparator for ratings, downloads, updates and status dbe0372: memory leak fixed 3d017bc: Remove unused SOAP classes generated from WSDL. Leave only basic authorization in legacy connector d6528d3: vcs notification structure refactored and common integration enabler provided f or mercurial vcs IDEA-120440 71e985b: IDEA-118548 Fixed locale settings for Mac - so svn launched from IDEA should get correct locale 5f70222: IDEA-121403 Live Template: "Surround with tag" should not be applicable while editing XmlAttributeValue 0e90d93: avoid boxing/unboxing (following CR-IC-4606) 754e7d9: remote table header 99540a3: register all sorters for available plugins table 60861dd: new sorters ae5ff21: Merge branch 'python-fixes' 455db27: Fixed names of live templates for dict comprehensions (PY-12307) b2bbf8b: Typo 4569a1c: Don't suggest the initial name if un-pluralization failed (PY-12308) 816b0e4: Don't suggest collection names in live templates that aren't valid Python identifier (PY-12308) b8412c1: refactor to support multiple sorters 2814c77: Add bundle for common task messages a4b56a6: java: formatting of type annotations inside type elements 0813c3c: java: type cast intention fixed 37ec0df: update appinfo files 6ff02b1: optimization for breakpoint set in folded code 09c6a8d: method refs: search for potentially applicable members in supers (IDEA-121737) 5412fbc: overload resolution: grab lambda from nested parenthesis as well as conditional expressions 0c7adaa: java: split multi-catch intention simplified; test data made adequate 4969888: java: no annotations needed in type cast 1687a22: Cleanup (unneeded test data) 333e542: Dictionary extended 9da8f7d: IDEA-121384 Breakpoints dialog: for method breakpoint created in dialog new branch is created 20a0571: notnull dd09f59: notnull 8aab3af: notnull 9e433b6: data race 6c89ea9: cleanup da637a4: IDEA-84705 Live Template: should be possible to reset the changes made in default templates ae81974: Merge remote-tracking branch 'origin/master' f86ac6f: new inference: use equals bounds during incorporation e07fdee: testdata for IDEA-118965 46112ee: new inference: cache lambda functional type during expression constraints reduction (IDEA-121315) 5029b3f: new inference: do not prefer specifics based on void return type for both void and value compatible lambdas a70f823: new inference: postpone argument types calculation 2149ea3: Fixed project leak 1608a84: svn: Perform special check if svn repository supports "merge-info" tracking only when corresponding registry key is set 9142df3: classes from old build system API marked as deprecated (to be removed in IDEA 14) 9b4f8c02: svn: Refactored SvnUtil - removed duplicate methods for checking if svn repository supports "merge-info" tracking d334d41: IDEA-121688 Added CommitEventType.failedOutOfDate; do not fail if could not convert SVNEventAction to CommitEventType (just log warning) 70aed3f: Merge remote-tracking branch 'origin/master' ba09765: missing test data 76591fd: dfa: comparison with other variables shouldn't affect a variable's nullability status 2c6cea6: IDEA-121698 Automatically make variables accessed from outer scopes final 6166a0e: don't flush fields for pure method and getter calls (IDEA-117449) 80049df: mention method name in edit contract intention text c1b03f0: dfa: variables shouldn't be marked unknown if they don't have known constant values 1fd57b4: Close terminal tabs with middle click (IDEA-112321). 6ee5d4f: Terminal should sign as xterm-256color (IDEA-118841). 1cd41f0: Merge remote-tracking branch 'origin/master' 8d167c6: Fix the locale on mac only for pycharm processes creation. 96c2016: IDEA-54434 (type annotations in Convert to Atomic/ThreadLocal) 9ae9623: java: formatting of type annotations inside references 50bf5a3: Cleanup (pointless exceptions; formatting) d44fab7: fix for exception with list of indexed ids merging 39c8f52: Merge remote-tracking branch 'origin/master' bd3cf45: Launch terminal with fixed locale (IDEA-116401, IDEA-118832, IDEA-120131). 1b0bc5f: fixed regress introduced by c5819e4 : remove stale index data for removed files that were scheduled to update lazily 61d11c8: nashorn: x variables view a5c886b: cleanup 4433f97: use SingleAlarm 6822332: Fix locale env vars on mac (IDEA-121713). 8d82a44: IDEA-52034 Implemented option to authenticate svn+ssh repositories using ssh agent (for SVNKit integration) (inspired by @charles-dyfis-net pull request - see issue comments for details) 90b352d: svn: Refactored SSHCredentialsDialog - removed unnecessary code 7f5f956: svn: Updating license info related to svn4idea plugin cb98865: svn: Upgraded to SVNKit 1.7.11 9d57fb2: Upgraded jna-utils (= platform = jna-platform) to 3.4.0 (now it corresponds to currently used jna 3.4.0) (both jna and jna-utils are downloaded from https://github.com/twall/jna/releases/tag/3.4.0) d9267b7: Added jsch-agent-proxy library to community b51333a: IDEA-75033 Implemented feature to automatically switch directory on new branch creation ee584ce: svn: Refactored AutoSvnUpdater - utility method to run svn updates 97e7ceb: svn: Removed unused classes d62789b: svn: Refactored SvnConfigurationState - simplify java version checks 7eff048: svn: Make "command line" integration be primary for default svn settings Change-Id: Idc5975266870a8ad22b9cdd88181a4b53387735f
Diffstat (limited to 'java')
-rw-r--r--java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java2
-rw-r--r--java/compiler/impl/src/com/intellij/compiler/impl/CompilerUtil.java36
-rw-r--r--java/compiler/impl/src/com/intellij/compiler/impl/TranslatingCompilerFilesMonitor.java122
-rw-r--r--java/compiler/impl/src/com/intellij/openapi/compiler/generic/GenericCompiler.java4
-rw-r--r--java/compiler/openapi/src/com/intellij/openapi/compiler/ClassInstrumentingCompiler.java4
-rw-r--r--java/compiler/openapi/src/com/intellij/openapi/compiler/ClassPostProcessingCompiler.java4
-rw-r--r--java/compiler/openapi/src/com/intellij/openapi/compiler/CompilerManager.java4
-rw-r--r--java/compiler/openapi/src/com/intellij/openapi/compiler/CopyingCompiler.java4
-rw-r--r--java/compiler/openapi/src/com/intellij/openapi/compiler/GeneratingCompiler.java4
-rw-r--r--java/compiler/openapi/src/com/intellij/openapi/compiler/JavaSourceTransformingCompiler.java4
-rw-r--r--java/compiler/openapi/src/com/intellij/openapi/compiler/PackagingCompiler.java4
-rw-r--r--java/compiler/openapi/src/com/intellij/openapi/compiler/SourceGeneratingCompiler.java4
-rw-r--r--java/compiler/openapi/src/com/intellij/openapi/compiler/TranslatingCompiler.java4
-rw-r--r--java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildInstruction.java5
-rw-r--r--java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildInstructionVisitor.java6
-rw-r--r--java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildParticipant.java4
-rw-r--r--java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildParticipantProvider.java4
-rw-r--r--java/compiler/openapi/src/com/intellij/openapi/compiler/make/FileCopyInstruction.java7
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/actions/AdjustArrayRangeAction.java5
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/actions/CustomizeContextViewAction.java6
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/actions/JavaSmartStepIntoHandler.java10
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/actions/JvmSmartStepIntoHandler.java6
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/actions/LambdaSmartStepTarget.java5
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/actions/MethodSmartStepTarget.java11
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/actions/SmartStepTarget.java9
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/engine/AnonymousClassMethodFilter.java5
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/engine/BasicStepMethodFilter.java12
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/engine/CompoundPositionManager.java24
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/engine/ContextUtil.java4
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java60
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/engine/DebuggerManagerThreadImpl.java22
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/engine/LambdaMethodFilter.java10
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/engine/MethodFilter.java2
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerEx.java35
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.java34
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/engine/RequestHint.java15
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/engine/SuspendContextImpl.java21
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/engine/SuspendManagerImpl.java27
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/engine/SuspendManagerUtil.java13
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/engine/evaluation/EvaluationContextImpl.java21
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/engine/evaluation/TextWithImportsImpl.java10
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/BinaryExpressionEvaluator.java71
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/BlockStatementEvaluator.java2
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ConditionalExpressionEvaluator.java6
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java17
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ExpressionEvaluatorImpl.java15
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/LocalVariableEvaluator.java13
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/MethodEvaluator.java5
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/engine/events/DebuggerCommandImpl.java1
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/engine/events/DebuggerContextCommandImpl.java14
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/engine/events/SuspendContextCommandImpl.java22
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/impl/DebuggerContextImpl.java31
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/impl/DebuggerManagerImpl.java34
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/impl/DebuggerUtilsEx.java51
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/impl/InvokeThread.java7
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/impl/SimpleStackFrameContext.java6
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/ArgValueData.java3
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/ArrayItemData.java2
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/DescriptorData.java5
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/FieldData.java2
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/LocalData.java3
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/MethodReturnValueData.java2
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/StackFrameData.java17
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/StaticData.java2
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/StaticFieldData.java2
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/ThisData.java3
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/ThreadData.java3
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/ThreadGroupData.java3
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/ThrownExceptionValueData.java2
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/UserExpressionData.java3
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/WatchItemData.java3
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/jdi/LocalVariableProxyImpl.java8
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/jdi/ObjectReferenceProxyImpl.java7
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/jdi/StackFrameProxyImpl.java28
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/jdi/ThreadReferenceProxyImpl.java38
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/ui/DebuggerEditorImpl.java13
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/ui/DebuggerExpressionComboBox.java10
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/ui/FramesPanel.java34
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/ui/JavaDebuggerSupport.java8
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/Breakpoint.java110
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointManager.java30
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java23
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FilteredRequestorImpl.java5
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/StepIntoBreakpoint.java1
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/ui/impl/DebuggerTreePanel.java36
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/ui/impl/FrameVariablesTree.java44
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/ui/impl/VariablesPanel.java82
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/ui/impl/WatchPanel.java4
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTree.java60
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTreeNodeImpl.java24
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/LocalVariableDescriptorImpl.java12
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/MessageDescriptor.java22
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/NodeDescriptorFactoryImpl.java9
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/StackFrameDescriptorImpl.java18
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/ValueDescriptorImpl.java27
-rw-r--r--java/debugger/openapi/src/com/intellij/debugger/DebuggerContext.java4
-rw-r--r--java/debugger/openapi/src/com/intellij/debugger/PositionManagerFactory.java3
-rw-r--r--java/debugger/openapi/src/com/intellij/debugger/engine/DebugProcess.java3
-rw-r--r--java/debugger/openapi/src/com/intellij/debugger/engine/StackFrameContext.java13
-rw-r--r--java/debugger/openapi/src/com/intellij/debugger/engine/SuspendContext.java2
-rw-r--r--java/debugger/openapi/src/com/intellij/debugger/engine/evaluation/EvaluationContext.java7
-rw-r--r--java/debugger/openapi/src/com/intellij/debugger/engine/evaluation/expression/ExpressionEvaluator.java13
-rw-r--r--java/debugger/openapi/src/com/intellij/debugger/requests/ClassPrepareRequestor.java7
-rw-r--r--java/debugger/openapi/src/com/intellij/debugger/requests/Requestor.java7
-rw-r--r--java/execution/impl/src/com/intellij/execution/application/ApplicationConfiguration.java33
-rw-r--r--java/execution/openapi/src/com/intellij/execution/configurations/JavaCommandLineState.java2
-rw-r--r--java/execution/openapi/src/com/intellij/execution/configurations/JavaParameters.java2
-rw-r--r--java/execution/openapi/src/com/intellij/execution/process/DefaultJavaProcessHandler.java1
-rw-r--r--java/idea-ui/src/com/intellij/facet/impl/ui/actions/AddFacetToModuleAction.java8
-rw-r--r--java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.java68
-rw-r--r--java/idea-ui/src/com/intellij/ide/projectWizard/TemplateBasedCategory.java6
-rw-r--r--java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java2
-rw-r--r--java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworksTree.java17
-rw-r--r--java/idea-ui/src/com/intellij/platform/templates/ArchivedProjectTemplate.java64
-rw-r--r--java/idea-ui/src/com/intellij/platform/templates/LocalArchivedTemplate.java14
-rw-r--r--java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java93
-rw-r--r--java/idea-ui/src/com/intellij/platform/templates/SaveProjectAsTemplateAction.java4
-rw-r--r--java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeCastFix.java12
-rw-r--r--java/java-analysis-impl/src/com/intellij/codeInspection/StreamApiMigrationInspection.java32
-rw-r--r--java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java7
-rw-r--r--java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java30
-rw-r--r--java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/StringExpressionHelper.java178
-rw-r--r--java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/instructions/MethodCallInstruction.java26
-rw-r--r--java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/value/DfaConstValue.java5
-rw-r--r--java/java-impl/src/com/intellij/codeInsight/completion/JavaInheritorsGetter.java47
-rw-r--r--java/java-impl/src/com/intellij/codeInsight/completion/LambdaCompletionProvider.java16
-rw-r--r--java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddExceptionToThrowsFix.java41
-rw-r--r--java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/OrderEntryFix.java51
-rw-r--r--java/java-impl/src/com/intellij/codeInsight/generation/GenerateMembersUtil.java24
-rw-r--r--java/java-impl/src/com/intellij/codeInsight/intention/impl/AddOnDemandStaticImportAction.java54
-rw-r--r--java/java-impl/src/com/intellij/codeInsight/intention/impl/AddSingleMemberStaticImportAction.java52
-rw-r--r--java/java-impl/src/com/intellij/codeInsight/lookup/VariableLookupItem.java29
-rw-r--r--java/java-impl/src/com/intellij/codeInsight/template/impl/ShortenToStaticImportProcessor.java6
-rw-r--r--java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ExpressionPostfixTemplateWithChooser.java25
-rw-r--r--java/java-impl/src/com/intellij/codeInspection/dataFlow/EditContractIntention.java2
-rw-r--r--java/java-impl/src/com/intellij/psi/formatter/java/AbstractJavaBlock.java223
-rw-r--r--java/java-impl/src/com/intellij/psi/formatter/java/JavaFormatterUtil.java19
-rw-r--r--java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java321
-rw-r--r--java/java-impl/src/com/intellij/psi/formatter/java/SimpleJavaBlock.java23
-rw-r--r--java/java-impl/src/com/intellij/psi/formatter/java/wrap/impl/JavaChildWrapArranger.java148
-rw-r--r--java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FilePathReferenceProvider.java6
-rw-r--r--java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/PathListReferenceProvider.java4
-rw-r--r--java/java-impl/src/com/intellij/psi/resolve/JavaMethodResolveHelper.java2
-rw-r--r--java/java-impl/src/com/intellij/refactoring/introduceParameter/IntroduceParameterProcessor.java33
-rw-r--r--java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java14
-rw-r--r--java/java-impl/src/com/intellij/refactoring/psi/MutationUtils.java114
-rw-r--r--java/java-impl/src/com/intellij/refactoring/rename/JavaNameSuggestionProvider.java23
-rw-r--r--java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationProcessor.java47
-rw-r--r--java/java-impl/src/com/intellij/refactoring/util/FixableUsageInfo.java9
-rw-r--r--java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/ReturnValueBeanBuilder.java174
-rw-r--r--java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/WrapReturnValueProcessor.java110
-rw-r--r--java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/usageInfo/ChangeReturnType.java28
-rw-r--r--java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/usageInfo/ReturnWrappedValue.java31
-rw-r--r--java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/usageInfo/UnwrapCall.java28
-rw-r--r--java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/usageInfo/WrapReturnValue.java32
-rw-r--r--java/java-psi-api/src/com/intellij/codeInsight/AnnotationUtil.java4
-rw-r--r--java/java-psi-api/src/com/intellij/psi/LambdaUtil.java21
-rw-r--r--java/java-psi-api/src/com/intellij/psi/PsiNameHelper.java15
-rw-r--r--java/java-psi-api/src/com/intellij/psi/PsiPrimitiveType.java26
-rw-r--r--java/java-psi-api/src/com/intellij/psi/infos/MethodCandidateInfo.java160
-rw-r--r--java/java-psi-api/src/com/intellij/psi/util/PropertyUtil.java2
-rw-r--r--java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java2
-rw-r--r--java/java-psi-impl/src/com/intellij/codeInsight/ExceptionUtil.java16
-rw-r--r--java/java-psi-impl/src/com/intellij/psi/PsiDiamondTypeImpl.java16
-rw-r--r--java/java-psi-impl/src/com/intellij/psi/impl/PsiElementFactoryImpl.java16
-rw-r--r--java/java-psi-impl/src/com/intellij/psi/impl/PsiImplUtil.java39
-rw-r--r--java/java-psi-impl/src/com/intellij/psi/impl/PsiNameHelperImpl.java4
-rw-r--r--java/java-psi-impl/src/com/intellij/psi/impl/cache/TypeInfo.java5
-rw-r--r--java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsTypeElementImpl.java36
-rw-r--r--java/java-psi-impl/src/com/intellij/psi/impl/source/PsiClassImpl.java21
-rw-r--r--java/java-psi-impl/src/com/intellij/psi/impl/source/PsiClassReferenceType.java2
-rw-r--r--java/java-psi-impl/src/com/intellij/psi/impl/source/PsiTypeElementImpl.java5
-rw-r--r--java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/JavaResolveCache.java3
-rw-r--r--java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceIncorporationPhase.java17
-rw-r--r--java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java230
-rw-r--r--java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/ExpressionCompatibilityConstraint.java2
-rw-r--r--java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/InputOutputConstraintFormula.java10
-rw-r--r--java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/PsiMethodReferenceCompatibilityConstraint.java1
-rw-r--r--java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiLambdaExpressionImpl.java13
-rw-r--r--java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodReferenceExpressionImpl.java76
-rw-r--r--java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java126
-rw-r--r--java/java-psi-impl/src/com/intellij/psi/scope/processor/MethodCandidatesProcessor.java24
-rw-r--r--java/java-psi-impl/src/com/intellij/psi/scope/processor/MethodResolverProcessor.java5
-rw-r--r--java/java-tests/testData/codeInsight/clsHighlighting/IDEA121866.java5
-rw-r--r--java/java-tests/testData/codeInsight/clsHighlighting/libs/IDEA121866.jarbin0 -> 373 bytes
-rw-r--r--java/java-tests/testData/codeInsight/completion/smartType/DiamondsInsideMethodCall-out.java12
-rw-r--r--java/java-tests/testData/codeInsight/completion/smartType/DiamondsInsideMethodCall.java12
-rw-r--r--java/java-tests/testData/codeInsight/completion/smartType/InLambdaPositionNameSubstitution-out.java9
-rw-r--r--java/java-tests/testData/codeInsight/completion/smartType/InLambdaPositionNameSubstitution.java9
-rw-r--r--java/java-tests/testData/codeInsight/completion/smartType/InLambdaPositionSingleParam-out.java9
-rw-r--r--java/java-tests/testData/codeInsight/completion/smartType/InLambdaPositionSingleParam.java9
-rw-r--r--java/java-tests/testData/codeInsight/completion/smartType/InstanceofedInsideAnonymous-out.java2
-rw-r--r--java/java-tests/testData/codeInsight/completion/variables/locals/TestResult4.java2
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/TryWithResources.java29
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA91626.java2
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/diamond/IDEA97294.java8
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/diamond/Varargs.java26
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/IncorporationWithEqualsBoundsSubstitution.java14
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/OuterCallConflictResolution.java23
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/VarargsOnNonPertinentPlace.java8
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguityRawGenerics.java2
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguityReturnValueResolution1.java2
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ConflictResolution.java2
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific/BothVarargs.java14
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific/IDEA121884.java17
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific/IDEA121999.java21
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific/MostSpecificForSameFunctionalTypes.java33
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific/NestedLambdaSpecifics.java19
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific/NestedVarargs.java46
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA118965comment.java13
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA121315.java22
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/AmbiguityVarargs.java20
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/ExactMethodReferencePertinentToApplicabilityCheck.java30
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/RawInnerClassQualifier.java26
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/SuperClassPotentiallyApplicableMembers.java39
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/afterConflict.java15
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/afterImportPresent.java10
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/afterImportPresent2.java9
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/afterOwnMember.java10
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/afterSingleImportPresent.java8
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/afterSingleIncompleteCode.java8
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/afterSingleMethod.java14
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/afterSingleSuperMethod.java17
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/beforeConflict.java2
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/beforeImportPresent.java9
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/beforeImportPresent2.java9
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/beforeOwnMember.java10
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/beforeSingleImportPresent.java8
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/beforeSingleIncompleteCode.java6
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/beforeSingleMethod.java2
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/beforeSingleSuperMethod.java2
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addToThrows/afterLambdaInternal.java12
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addToThrows/beforeLambdaExternal.java9
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addToThrows/beforeLambdaInternal.java12
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/afterTypeAnnoArray.java2
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/afterTypeAnnoPrimitive.java12
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/afterTypeAnnoRefType.java5
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/afterTypeAnnoTypeParam.java13
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/afterTypeAnnoValued.java12
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/afterTypeAnnoWildcard.java13
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/beforeTypeAnnoPrimitive.java12
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/beforeTypeAnnoRefType.java5
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/beforeTypeAnnoTypeParam.java13
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/beforeTypeAnnoValued.java12
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/beforeTypeAnnoWildcard.java13
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/implementMethods/afterTypeAnnotated.java17
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/implementMethods/beforeTypeAnnotated.java13
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/orderEntry/A/src/x/DoTest.java2
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/orderEntry/A/src/x/DoTest4.java2
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/orderEntry/A/src/x/DoTest4junit.java2
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterCollectArrayListComment.java16
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterCollectArrayListNonTrivialInitializer.java20
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterNormalComments.java11
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeCollectArrayListComment.java18
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeCollectArrayListNonTrivialInitializer.java21
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeNormalComments.java13
-rw-r--r--java/java-tests/testData/codeInsight/template/postfix/templates/cast/insideString.java5
-rw-r--r--java/java-tests/testData/codeInsight/template/postfix/templates/cast/insideString_after.java5
-rw-r--r--java/java-tests/testData/codeInsight/template/postfix/templates/cast/singleArgument.java5
-rw-r--r--java/java-tests/testData/codeInsight/template/postfix/templates/cast/singleArgument_after.java5
-rw-r--r--java/java-tests/testData/inspection/dataFlow/fixture/ComparingToNullableShouldNotAffectNullity.java15
-rw-r--r--java/java-tests/testData/inspection/dataFlow/fixture/GettersAndPureNoFlushing.java31
-rw-r--r--java/java-tests/testData/inspection/dataFlow/fixture/SameComparisonTwice.java38
-rw-r--r--java/java-tests/testData/inspection/dataFlow/fixture/UnusedCallDoesNotMakeUnknown.java14
-rw-r--r--java/java-tests/testData/refactoring/introduceParameter/afterTypeAnnotation.java14
-rw-r--r--java/java-tests/testData/refactoring/introduceParameter/beforeTypeAnnotation.java15
-rw-r--r--java/java-tests/testData/refactoring/renameInplace/NameSuggestion.java7
-rw-r--r--java/java-tests/testData/refactoring/renameInplace/NameSuggestion_after.java7
-rw-r--r--java/java-tests/testData/refactoring/wrapReturnValue/generics/after/Wrapper.java2
-rw-r--r--java/java-tests/testData/refactoring/wrapReturnValue/hierarchy/after/Test.java4
-rw-r--r--java/java-tests/testData/refactoring/wrapReturnValue/hierarchy/before/Test.java2
-rw-r--r--java/java-tests/testData/refactoring/wrapReturnValue/innerClass/after/Test.java12
-rw-r--r--java/java-tests/testData/refactoring/wrapReturnValue/innerClass/before/Test.java12
-rw-r--r--java/java-tests/testData/refactoring/wrapReturnValue/returnInsideLambda/after/Test.java10
-rw-r--r--java/java-tests/testData/refactoring/wrapReturnValue/returnInsideLambda/before/Test.java10
-rw-r--r--java/java-tests/testData/refactoring/wrapReturnValue/simple/after/Wrapper.java2
-rw-r--r--java/java-tests/testData/refactoring/wrapReturnValue/staticMethodInnerClass/after/Test.java14
-rw-r--r--java/java-tests/testData/refactoring/wrapReturnValue/staticMethodInnerClass/before/Test.java12
-rw-r--r--java/java-tests/testData/refactoring/wrapReturnValue/typeAnnotations/after/Test.java10
-rw-r--r--java/java-tests/testData/refactoring/wrapReturnValue/typeAnnotations/after/Wrapper.java13
-rw-r--r--java/java-tests/testData/refactoring/wrapReturnValue/typeAnnotations/before/Test.java11
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/ClsGenerics15HighlightingTest.java (renamed from java/debugger/openapi/src/com/intellij/debugger/PositionManagerEx.java)22
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/ClsGenerics18HighlightingTest.java27
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/ClsGenericsHighlightingTest.java16
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/completion/HippieCompletionTest.groovy9
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy38
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy90
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType17CompletionTest.java2
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType18CompletionTest.java13
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Diamond8HighlightingTest.java4
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java12
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MostSpecificResolutionTest.java24
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java8
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java16
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/AddExceptionToThrowsTest.java8
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/intention/AddImportActionTest.groovy6
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy87
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInsight/template/postfix/templates/CastPostfixTemplateTest.java20
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java6
-rw-r--r--java/java-tests/testSrc/com/intellij/find/FindManagerTest.java15
-rw-r--r--java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterSpaceTest.java81
-rw-r--r--java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterWrapTest.java101
-rw-r--r--java/java-tests/testSrc/com/intellij/psi/resolve/ResolveClassTest.java7
-rw-r--r--java/java-tests/testSrc/com/intellij/refactoring/IntroduceParameterTest.java325
-rw-r--r--java/java-tests/testSrc/com/intellij/refactoring/RenameMembersInplaceTest.java18
-rw-r--r--java/java-tests/testSrc/com/intellij/refactoring/WrapReturnValueTest.java113
-rw-r--r--java/jdkAnnotations/java/util/regex/annotations.xml3
-rw-r--r--java/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/deployment/debug/JavaDebuggerLauncherImpl.java22
-rw-r--r--java/testFramework/src/com/intellij/debugger/impl/DescriptorTestCase.java35
-rw-r--r--java/testFramework/src/com/intellij/ide/projectWizard/ProjectWizardTestCase.java38
310 files changed, 4784 insertions, 2453 deletions
diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java
index a89c0760ba4f..015da86e2586 100644
--- a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java
+++ b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java
@@ -910,7 +910,7 @@ public class CompileDriver {
if (!outputs.isEmpty()) {
final ProgressIndicator indicator = compileContext.getProgressIndicator();
indicator.setText("Synchronizing output directories...");
- lfs.refreshIoFiles(outputs, _status == ExitStatus.CANCELLED, false, null);
+ CompilerUtil.refreshOutputDirectories(outputs, _status == ExitStatus.CANCELLED);
indicator.setText("");
}
if (compileContext.isAnnotationProcessorsEnabled() && !myProject.isDisposed()) {
diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/CompilerUtil.java b/java/compiler/impl/src/com/intellij/compiler/impl/CompilerUtil.java
index 1417fa69a0e2..9b227da1dbf8 100644
--- a/java/compiler/impl/src/com/intellij/compiler/impl/CompilerUtil.java
+++ b/java/compiler/impl/src/com/intellij/compiler/impl/CompilerUtil.java
@@ -35,7 +35,10 @@ import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.openapi.vfs.*;
+import com.intellij.openapi.vfs.CharsetToolkit;
+import com.intellij.openapi.vfs.LocalFileSystem;
+import com.intellij.openapi.vfs.VfsUtilCore;
+import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.newvfs.RefreshQueue;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.util.ThrowableRunnable;
@@ -128,6 +131,35 @@ public class CompilerUtil {
}
}
+ public static void refreshOutputDirectories(Set<File> outputs, boolean async) {
+ LocalFileSystem fileSystem = LocalFileSystem.getInstance();
+ List<VirtualFile> toRefresh = new ArrayList<VirtualFile>();
+
+ int newDirectories = 0;
+ for (File ioOutput : outputs) {
+ VirtualFile output = fileSystem.findFileByIoFile(ioOutput);
+ if (output != null) {
+ toRefresh.add(output);
+ }
+ else if (ioOutput.exists()) {
+ VirtualFile parent = fileSystem.refreshAndFindFileByIoFile(ioOutput.getParentFile());
+ if (parent != null) {
+ parent.getChildren();
+ toRefresh.add(parent);
+ newDirectories++;
+ }
+ }
+ }
+ if (newDirectories > 10) {
+ LOG.info(newDirectories + " new output directories were created, refreshing their parents together to avoid too many rootsChange events");
+ RefreshQueue.getInstance().refresh(async, false, null, toRefresh);
+ }
+ else {
+ LOG.debug("Refreshing " + outputs.size() + " outputs");
+ fileSystem.refreshIoFiles(outputs, async, false, null);
+ }
+ }
+
public static void refreshIOFile(final File file) {
final VirtualFile vFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file);
if (vFile != null) {
@@ -234,7 +266,7 @@ public class CompilerUtil {
final boolean is3OrNewer = is4OrNewer || isOfVersion(versionString, "1.3");
final boolean is2OrNewer = is3OrNewer || isOfVersion(versionString, "1.2");
final boolean is1OrNewer = is2OrNewer || isOfVersion(versionString, "1.0") || isOfVersion(versionString, "1.1");
-
+
if (!is1OrNewer) {
// unknown jdk version, cannot say anything about the corresponding language level, so leave it unchanged
return languageLevel;
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 411fa24b2978..3ee643e170cd 100644
--- a/java/compiler/impl/src/com/intellij/compiler/impl/TranslatingCompilerFilesMonitor.java
+++ b/java/compiler/impl/src/com/intellij/compiler/impl/TranslatingCompilerFilesMonitor.java
@@ -763,7 +763,7 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
}
}
- private int getProjectId(Project project) {
+ private static int getProjectId(Project project) {
try {
return FSRecords.getNames().enumerate(CompilerPaths.getCompilerSystemDirectoryName(project));
}
@@ -773,7 +773,7 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
return -1;
}
- private int getModuleId(Module module) {
+ private static int getModuleId(Module module) {
try {
return FSRecords.getNames().enumerate(module.getName().toLowerCase(Locale.US));
}
@@ -1035,13 +1035,13 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
void execute(VirtualFile file);
}
- private static void processRecursively(VirtualFile file, final boolean dbOnly, final FileProcessor processor) {
- if (!(file.getFileSystem() instanceof LocalFileSystem)) {
+ private static void processRecursively(final VirtualFile fromFile, final boolean dbOnly, final boolean needReadAction, final FileProcessor processor) {
+ if (!(fromFile.getFileSystem() instanceof LocalFileSystem)) {
return;
}
final FileTypeManager fileTypeManager = FileTypeManager.getInstance();
- VfsUtilCore.visitChildrenRecursively(file, new VirtualFileVisitor() {
+ VfsUtilCore.visitChildrenRecursively(fromFile, new VirtualFileVisitor() {
@NotNull @Override
public Result visitFileEx(@NotNull VirtualFile file) {
if (fileTypeManager.isFileIgnored(file)) {
@@ -1057,11 +1057,36 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
@Nullable
@Override
public Iterable<VirtualFile> getChildrenIterable(@NotNull VirtualFile file) {
- return file.isDirectory() && dbOnly ? ((NewVirtualFile)file).iterInDbChildren() : null;
+ if (dbOnly) {
+ return file.isDirectory()? ((NewVirtualFile)file).iterInDbChildren() : null;
+ }
+ if (file.equals(fromFile) || !file.isDirectory()) {
+ return null; // skipping additional checks for the initial file and non-directory files
+ }
+ // optimization: for all files that are not under content of currently opened projects iterate over DB children
+ return isInContentOfOpenedProject(file, needReadAction)? null : ((NewVirtualFile)file).iterInDbChildren();
}
});
}
+ private static boolean isInContentOfOpenedProject(@NotNull final VirtualFile file, boolean needReadAction) {
+ // probably need a read action to ensure that the project was not disposed during the iteration over the project list
+ final Computable<Boolean> computation = new Computable<Boolean>() {
+ public Boolean compute() {
+ for (Project project : ProjectManager.getInstance().getOpenProjects()) {
+ if (!project.isInitialized()) {
+ continue;
+ }
+ if (ProjectRootManager.getInstance(project).getFileIndex().isInContent(file)) {
+ return Boolean.TRUE;
+ }
+ }
+ return Boolean.FALSE;
+ }
+ };
+ return needReadAction? ApplicationManager.getApplication().runReadAction(computation) : computation.compute();
+ }
+
// made public for tests
public void scanSourceContent(final ProjectRef projRef, final Collection<VirtualFile> roots, final int totalRootCount, final boolean isNewRoots) {
if (roots.isEmpty()) {
@@ -1255,7 +1280,7 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
projRef.get();
indicator.setText2(root.getPresentableUrl());
indicator.setFraction(++processed / (double)totalRootsCount);
- processRecursively(root, false, processor);
+ processRecursively(root, false, true, processor);
}
}
@@ -1485,7 +1510,7 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
final Set<File> pathsToMark = new THashSet<File>(FileUtil.FILE_HASHING_STRATEGY);
- processRecursively(eventFile, true, new FileProcessor() {
+ processRecursively(eventFile, true, false, new FileProcessor() {
private final TIntArrayList myAssociatedProjectIds = new TIntArrayList();
public void execute(final VirtualFile file) {
@@ -1576,7 +1601,7 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
private void markDirtyIfSource(final VirtualFile file, final boolean fromMove) {
final Set<File> pathsToMark = new THashSet<File>(FileUtil.FILE_HASHING_STRATEGY);
- processRecursively(file, false, new FileProcessor() {
+ processRecursively(file, false, false, new FileProcessor() {
public void execute(final VirtualFile file) {
pathsToMark.add(new File(file.getPath()));
final SourceFileInfo srcInfo = file.isValid()? loadSourceInfo(file) : null;
@@ -1613,57 +1638,52 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
}
private void processNewFile(final VirtualFile file, final boolean notifyServer) {
- final Ref<Boolean> isInContent = Ref.create(false);
- ApplicationManager.getApplication().runReadAction(new Runnable() {
- // need read action to ensure that the project was not disposed during the iteration over the project list
- public void run() {
- for (final Project project : myProjectManager.getOpenProjects()) {
- if (!project.isInitialized()) {
- continue; // the content of this project will be scanned during its post-startup activities
- }
- final int projectId = getProjectId(project);
- final boolean projectSuspended = isSuspended(projectId);
- final ProjectRootManager rootManager = ProjectRootManager.getInstance(project);
- ProjectFileIndex fileIndex = rootManager.getFileIndex();
- if (fileIndex.isInContent(file)) {
- isInContent.set(true);
+ boolean isInContent = false;
+ for (final Project project : myProjectManager.getOpenProjects()) {
+ if (!project.isInitialized()) {
+ continue; // the content of this project will be scanned during its post-startup activities
+ }
+ final int projectId = getProjectId(project);
+ final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
+ if (fileIndex.isInContent(file)) {
+ isInContent = true;
+ }
+ if (isSuspended(projectId)) {
+ continue;
+ }
+ if (fileIndex.isInSourceContent(file)) {
+ final TranslatingCompiler[] translators = CompilerManager.getInstance(project).getCompilers(TranslatingCompiler.class);
+ processRecursively(file, false, false, new FileProcessor() {
+ public void execute(final VirtualFile file) {
+ if (isCompilable(file)) {
+ loadInfoAndAddSourceForRecompilation(projectId, file);
+ }
}
- if (fileIndex.isInSourceContent(file)) {
- final TranslatingCompiler[] translators = CompilerManager.getInstance(project).getCompilers(TranslatingCompiler.class);
- processRecursively(file, false, new FileProcessor() {
- public void execute(final VirtualFile file) {
- if (!projectSuspended && isCompilable(file)) {
- loadInfoAndAddSourceForRecompilation(projectId, file);
- }
- }
-
- boolean isCompilable(VirtualFile file) {
- for (TranslatingCompiler translator : translators) {
- if (translator.isCompilableFile(file, DummyCompileContext.getInstance())) {
- return true;
- }
- }
- return false;
+ boolean isCompilable(VirtualFile file) {
+ for (TranslatingCompiler translator : translators) {
+ if (translator.isCompilableFile(file, DummyCompileContext.getInstance())) {
+ return true;
}
- });
- }
- else {
- if (!projectSuspended && belongsToIntermediateSources(file, project)) {
- processRecursively(file, false, new FileProcessor() {
- public void execute(final VirtualFile file) {
- loadInfoAndAddSourceForRecompilation(projectId, file);
- }
- });
}
+ return false;
}
+ });
+ }
+ else {
+ if (belongsToIntermediateSources(file, project)) {
+ processRecursively(file, false, false, new FileProcessor() {
+ public void execute(final VirtualFile file) {
+ loadInfoAndAddSourceForRecompilation(projectId, file);
+ }
+ });
}
}
- });
+ }
if (notifyServer && !isIgnoredOrUnderIgnoredDirectory(file)) {
final Set<File> pathsToMark = new THashSet<File>(FileUtil.FILE_HASHING_STRATEGY);
- boolean dbOnly = !isInContent.get();
- processRecursively(file, dbOnly, new FileProcessor() {
+ boolean dbOnly = !isInContent;
+ processRecursively(file, dbOnly, false, new FileProcessor() {
@Override
public void execute(VirtualFile file) {
pathsToMark.add(new File(file.getPath()));
diff --git a/java/compiler/impl/src/com/intellij/openapi/compiler/generic/GenericCompiler.java b/java/compiler/impl/src/com/intellij/openapi/compiler/generic/GenericCompiler.java
index b09c8e599626..87136283737b 100644
--- a/java/compiler/impl/src/com/intellij/openapi/compiler/generic/GenericCompiler.java
+++ b/java/compiler/impl/src/com/intellij/openapi/compiler/generic/GenericCompiler.java
@@ -25,6 +25,10 @@ import org.jetbrains.annotations.NotNull;
/**
* @author nik
+ *
+ * @deprecated this interface is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
+ * integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
+ * Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public abstract class GenericCompiler<Key, SourceState, OutputState> implements Compiler {
protected static final KeyDescriptor<String> STRING_KEY_DESCRIPTOR = new EnumeratorStringDescriptor();
diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/ClassInstrumentingCompiler.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/ClassInstrumentingCompiler.java
index cfcf3373fa3f..4e5143aee495 100644
--- a/java/compiler/openapi/src/com/intellij/openapi/compiler/ClassInstrumentingCompiler.java
+++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/ClassInstrumentingCompiler.java
@@ -21,6 +21,10 @@ package com.intellij.openapi.compiler;
* This affects the order of compiler calls:
* The sequence in which compilers are called:
* SourceGeneratingCompiler -> SourceInstrumentingCompiler -> TranslatingCompiler -> ClassInstrumentingCompiler -> ClassPostProcessingCompiler -> PackagingCompiler -> Validator
+ *
+ * @deprecated this interface is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
+ * integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
+ * Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public interface ClassInstrumentingCompiler extends FileProcessingCompiler {
}
diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/ClassPostProcessingCompiler.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/ClassPostProcessingCompiler.java
index 203facd2b02d..c4c3e8b40cf1 100644
--- a/java/compiler/openapi/src/com/intellij/openapi/compiler/ClassPostProcessingCompiler.java
+++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/ClassPostProcessingCompiler.java
@@ -21,6 +21,10 @@ package com.intellij.openapi.compiler;
* This affects the order of compiler calls:
* The sequence in which compilers are called:
* SourceGeneratingCompiler -> SourceInstrumentingCompiler -> TranslatingCompiler -> ClassInstrumentingCompiler -> ClassPostProcessingCompiler -> PackagingCompiler -> Validator
+ *
+ * @deprecated this interface is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
+ * integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
+ * Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public interface ClassPostProcessingCompiler extends FileProcessingCompiler {
}
diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/CompilerManager.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/CompilerManager.java
index 4456665ef4bd..03d9be241ffb 100644
--- a/java/compiler/openapi/src/com/intellij/openapi/compiler/CompilerManager.java
+++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/CompilerManager.java
@@ -63,6 +63,10 @@ public abstract class CompilerManager {
* @param compiler compiler implementation
* @param inputTypes a set of filetypes that compiler accepts as input
* @param outputTypes a set of filetypes that compiler can generate
+ *
+ * @deprecated this method is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
+ * integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
+ * Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public abstract void addTranslatingCompiler(@NotNull TranslatingCompiler compiler, Set<FileType> inputTypes, Set<FileType> outputTypes);
diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/CopyingCompiler.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/CopyingCompiler.java
index 7d80c21daedf..758524e92426 100644
--- a/java/compiler/openapi/src/com/intellij/openapi/compiler/CopyingCompiler.java
+++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/CopyingCompiler.java
@@ -32,6 +32,10 @@ import java.util.List;
/**
* Compiler which copies the compiled files to a different directory.
+ *
+ * @deprecated this interface is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
+ * integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
+ * Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public abstract class CopyingCompiler implements PackagingCompiler{
public abstract VirtualFile[] getFilesToCopy(CompileContext context);
diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/GeneratingCompiler.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/GeneratingCompiler.java
index 962bcb218e5e..af1fb1eb8dd7 100644
--- a/java/compiler/openapi/src/com/intellij/openapi/compiler/GeneratingCompiler.java
+++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/GeneratingCompiler.java
@@ -21,6 +21,10 @@ import com.intellij.openapi.vfs.VirtualFile;
/**
* A base interface for all compilers that generate new files. The generated files may be processed by other compilers.
* Actual implementation should implement one of its subinterfaces. Currently only {@link SourceGeneratingCompiler} is available.
+ *
+ * @deprecated this interface is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
+ * integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
+ * Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public interface GeneratingCompiler extends Compiler, ValidityStateFactory, IntermediateOutputCompiler {
/**
diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/JavaSourceTransformingCompiler.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/JavaSourceTransformingCompiler.java
index 27a397569aad..1194efcccba3 100644
--- a/java/compiler/openapi/src/com/intellij/openapi/compiler/JavaSourceTransformingCompiler.java
+++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/JavaSourceTransformingCompiler.java
@@ -19,6 +19,10 @@ import com.intellij.openapi.vfs.VirtualFile;
/**
* This compiler is called right before the java sources compiler.
+ *
+ * @deprecated this interface is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
+ * integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
+ * Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public interface JavaSourceTransformingCompiler extends Compiler {
diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/PackagingCompiler.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/PackagingCompiler.java
index e7e1350b41b9..3055e0ff654f 100644
--- a/java/compiler/openapi/src/com/intellij/openapi/compiler/PackagingCompiler.java
+++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/PackagingCompiler.java
@@ -23,6 +23,10 @@ import org.jetbrains.annotations.Nullable;
* This affects the order of compiler calls.
* The sequence in which compilers are called:
* SourceGeneratingCompiler -> SourceInstrumentingCompiler -> TranslatingCompiler -> ClassInstrumentingCompiler -> ClassPostProcessingCompiler -> PackagingCompiler -> Validator
+ *
+ * @deprecated this interface is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
+ * integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
+ * Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public interface PackagingCompiler extends FileProcessingCompiler{
/**
diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/SourceGeneratingCompiler.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/SourceGeneratingCompiler.java
index 4c0b646658f6..2fe36ba202ba 100644
--- a/java/compiler/openapi/src/com/intellij/openapi/compiler/SourceGeneratingCompiler.java
+++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/SourceGeneratingCompiler.java
@@ -23,6 +23,10 @@ import com.intellij.openapi.vfs.VirtualFile;
* This affects the order of compiler calls.
* The sequence in which compilers are called:
* SourceGeneratingCompiler -> SourceInstrumentingCompiler -> TranslatingCompiler -> ClassInstrumentingCompiler -> ClassPostProcessingCompiler -> PackagingCompiler -> Validator
+ *
+ * @deprecated this interface is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
+ * integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
+ * Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public interface SourceGeneratingCompiler extends GeneratingCompiler {
diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/TranslatingCompiler.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/TranslatingCompiler.java
index 3c56f8d9f67d..c5ce012c9ce6 100644
--- a/java/compiler/openapi/src/com/intellij/openapi/compiler/TranslatingCompiler.java
+++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/TranslatingCompiler.java
@@ -26,6 +26,10 @@ import java.util.Collection;
* This affects the order of compiler calls.
* The sequence in which compilers are called:
* SourceGeneratingCompiler -> SourceInstrumentingCompiler -> TranslatingCompiler -> ClassInstrumentingCompiler -> ClassPostProcessingCompiler -> PackagingCompiler -> Validator
+ *
+ * @deprecated this interface is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
+ * integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
+ * Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public interface TranslatingCompiler extends Compiler {
diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildInstruction.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildInstruction.java
index 148e1524e4a2..eed2e77c8030 100644
--- a/java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildInstruction.java
+++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildInstruction.java
@@ -15,6 +15,11 @@
*/
package com.intellij.openapi.compiler.make;
+/**
+ * @deprecated this class is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
+ * integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
+ * Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
+ */
public interface BuildInstruction {
String getOutputRelativePath();
diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildInstructionVisitor.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildInstructionVisitor.java
index 6ae9b33e062b..0bd62be958f7 100644
--- a/java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildInstructionVisitor.java
+++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildInstructionVisitor.java
@@ -15,7 +15,11 @@
*/
package com.intellij.openapi.compiler.make;
-
+/**
+ * @deprecated this class is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
+ * integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
+ * Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
+ */
public abstract class BuildInstructionVisitor {
public boolean visitInstruction(BuildInstruction instruction) throws Exception {
return true;
diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildParticipant.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildParticipant.java
index 48022b6bf272..977772418589 100644
--- a/java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildParticipant.java
+++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildParticipant.java
@@ -20,7 +20,9 @@ import com.intellij.packaging.artifacts.Artifact;
import org.jetbrains.annotations.Nullable;
/**
- * @deprecated use interfaces from {@link com.intellij.openapi.compiler.Compiler}'s hierarchy instead
+ * @deprecated this class is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
+ * integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
+ * Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public abstract class BuildParticipant {
public static final BuildParticipant[] EMPTY_ARRAY = new BuildParticipant[0];
diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildParticipantProvider.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildParticipantProvider.java
index a0f46da79290..374e161549ad 100644
--- a/java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildParticipantProvider.java
+++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildParticipantProvider.java
@@ -24,7 +24,9 @@ import java.util.Collection;
/**
* @author nik
*
- * @deprecated use interfaces from {@link com.intellij.openapi.compiler.Compiler}'s hierarchy instead
+ * @deprecated this class is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
+ * integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
+ * Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
*/
public abstract class BuildParticipantProvider {
public static final ExtensionPointName<BuildParticipantProvider> EXTENSION_POINT_NAME = ExtensionPointName.create("com.intellij.compiler.buildParticipantProvider");
diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/make/FileCopyInstruction.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/make/FileCopyInstruction.java
index 4109410aec00..c5636394cfe0 100644
--- a/java/compiler/openapi/src/com/intellij/openapi/compiler/make/FileCopyInstruction.java
+++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/make/FileCopyInstruction.java
@@ -15,10 +15,13 @@
*/
package com.intellij.openapi.compiler.make;
-import org.jetbrains.annotations.Nullable;
-
import java.io.File;
+/**
+ * @deprecated this class is part of the obsolete build system which runs as part of the IDE process. Since IDEA 12 plugins need to
+ * integrate into 'external build system' instead (http://confluence.jetbrains.com/display/IDEADEV/External+Builder+API+and+Plugins).
+ * Since IDEA 13 users cannot switch to the old build system via UI and it will be completely removed in IDEA 14.
+ */
public interface FileCopyInstruction extends BuildInstruction {
File getFile();
diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/AdjustArrayRangeAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/AdjustArrayRangeAction.java
index bb74b8eccc45..3a821fb10c0f 100644
--- a/java/debugger/impl/src/com/intellij/debugger/actions/AdjustArrayRangeAction.java
+++ b/java/debugger/impl/src/com/intellij/debugger/actions/AdjustArrayRangeAction.java
@@ -32,6 +32,7 @@ import com.intellij.openapi.ui.DialogWrapper;
import org.jetbrains.annotations.Nullable;
public class AdjustArrayRangeAction extends DebuggerAction {
+ @Override
public void actionPerformed(AnActionEvent e) {
DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(e.getDataContext());
if(debuggerContext == null) {
@@ -73,6 +74,7 @@ public class AdjustArrayRangeAction extends DebuggerAction {
if(editor.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
debugProcess.getManagerThread().schedule(new SuspendContextCommandImpl(debuggerContext.getSuspendContext()) {
+ @Override
public void contextAction() throws Exception {
final ValueDescriptorImpl nodeDescriptor = (ValueDescriptorImpl)selectedNode.getDescriptor();
final Renderer lastRenderer = nodeDescriptor.getLastRenderer();
@@ -92,6 +94,7 @@ public class AdjustArrayRangeAction extends DebuggerAction {
}
}
+ @Override
public void update(AnActionEvent e) {
boolean enable = false;
DebuggerTreeNodeImpl selectedNode = getSelectedNode(e.getDataContext());
@@ -139,10 +142,12 @@ public class AdjustArrayRangeAction extends DebuggerAction {
myTitle = title;
}
+ @Override
public String getDisplayName() {
return myTitle;
}
+ @Override
public String getHelpTopic() {
return null;
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/CustomizeContextViewAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/CustomizeContextViewAction.java
index 4235b6923d3a..c08bfd51dbbd 100644
--- a/java/debugger/impl/src/com/intellij/debugger/actions/CustomizeContextViewAction.java
+++ b/java/debugger/impl/src/com/intellij/debugger/actions/CustomizeContextViewAction.java
@@ -45,11 +45,13 @@ import java.util.List;
* Time: 4:39:53 PM
*/
public class CustomizeContextViewAction extends DebuggerAction{
+ @Override
public void actionPerformed(AnActionEvent e) {
final Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
Disposable disposable = Disposer.newDisposable();
final CompositeConfigurable configurable = new TabbedConfigurable(disposable) {
+ @Override
protected List<Configurable> createConfigurables() {
ArrayList<Configurable> array = new ArrayList<Configurable>();
array.add(new DebuggerDataViewsConfigurable(project));
@@ -57,15 +59,18 @@ public class CustomizeContextViewAction extends DebuggerAction{
return array;
}
+ @Override
public void apply() throws ConfigurationException {
super.apply();
NodeRendererSettings.getInstance().fireRenderersChanged();
}
+ @Override
public String getDisplayName() {
return DebuggerBundle.message("title.customize.data.views");
}
+ @Override
public String getHelpTopic() {
return null;
}
@@ -85,6 +90,7 @@ public class CustomizeContextViewAction extends DebuggerAction{
editor.show();
}
+ @Override
public void update(AnActionEvent e) {
DebuggerTree tree = getTree(e.getDataContext());
e.getPresentation().setVisible(tree instanceof FrameVariablesTree || tree instanceof WatchDebuggerTree);
diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/JavaSmartStepIntoHandler.java b/java/debugger/impl/src/com/intellij/debugger/actions/JavaSmartStepIntoHandler.java
index a0a2146aca6f..8904331bfaba 100644
--- a/java/debugger/impl/src/com/intellij/debugger/actions/JavaSmartStepIntoHandler.java
+++ b/java/debugger/impl/src/com/intellij/debugger/actions/JavaSmartStepIntoHandler.java
@@ -22,6 +22,7 @@ import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
+import com.intellij.util.Range;
import com.intellij.util.containers.OrderedSet;
import com.intellij.util.text.CharArrayUtil;
import org.jetbrains.annotations.NotNull;
@@ -79,6 +80,8 @@ public class JavaSmartStepIntoHandler extends JvmSmartStepIntoHandler {
//noinspection unchecked
final List<SmartStepTarget> targets = new OrderedSet<SmartStepTarget>();
+ final Range<Integer> lines = new Range<Integer>(doc.getLineNumber(element.getTextOffset()), doc.getLineNumber(element.getTextOffset() + element.getTextLength()));
+
final PsiElementVisitor methodCollector = new JavaRecursiveElementVisitor() {
final Stack<PsiMethod> myContextStack = new Stack<PsiMethod>();
final Stack<String> myParamNameStack = new Stack<String>();
@@ -92,12 +95,12 @@ public class JavaSmartStepIntoHandler extends JvmSmartStepIntoHandler {
@Override
public void visitAnonymousClass(PsiAnonymousClass aClass) {
for (PsiMethod psiMethod : aClass.getMethods()) {
- targets.add(new MethodSmartStepTarget(psiMethod, getCurrentParamName(), psiMethod.getBody(), true));
+ targets.add(new MethodSmartStepTarget(psiMethod, getCurrentParamName(), psiMethod.getBody(), true, lines));
}
}
public void visitLambdaExpression(PsiLambdaExpression expression) {
- targets.add(new LambdaSmartStepTarget(expression, getCurrentParamName(), expression.getBody(), myNextLambdaExpressionOrdinal++));
+ targets.add(new LambdaSmartStepTarget(expression, getCurrentParamName(), expression.getBody(), myNextLambdaExpressionOrdinal++, lines));
}
@Override
@@ -141,7 +144,8 @@ public class JavaSmartStepIntoHandler extends JvmSmartStepIntoHandler {
expression instanceof PsiMethodCallExpression?
((PsiMethodCallExpression)expression).getMethodExpression().getReferenceNameElement()
: expression instanceof PsiNewExpression? ((PsiNewExpression)expression).getClassOrAnonymousClassReference() : expression,
- false
+ false,
+ lines
));
}
try {
diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/JvmSmartStepIntoHandler.java b/java/debugger/impl/src/com/intellij/debugger/actions/JvmSmartStepIntoHandler.java
index 5dde5d8ea13d..f62bd84982d9 100644
--- a/java/debugger/impl/src/com/intellij/debugger/actions/JvmSmartStepIntoHandler.java
+++ b/java/debugger/impl/src/com/intellij/debugger/actions/JvmSmartStepIntoHandler.java
@@ -23,7 +23,6 @@ import com.intellij.debugger.engine.MethodFilter;
import com.intellij.debugger.impl.DebuggerSession;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.AnAction;
-import com.intellij.openapi.actionSystem.ShortcutSet;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.fileEditor.TextEditor;
@@ -137,11 +136,12 @@ public abstract class JvmSmartStepIntoHandler {
protected MethodFilter createMethodFilter(SmartStepTarget stepTarget) {
if (stepTarget instanceof MethodSmartStepTarget) {
final PsiMethod method = ((MethodSmartStepTarget)stepTarget).getMethod();
- return stepTarget.needsBreakpointRequest()? new AnonymousClassMethodFilter(method) : new BasicStepMethodFilter(method);
+ return stepTarget.needsBreakpointRequest()? new AnonymousClassMethodFilter(method, stepTarget.getCallingExpressionLines()) :
+ new BasicStepMethodFilter(method, stepTarget.getCallingExpressionLines());
}
if (stepTarget instanceof LambdaSmartStepTarget) {
final LambdaSmartStepTarget lambdaTarget = (LambdaSmartStepTarget)stepTarget;
- return new LambdaMethodFilter(lambdaTarget.getLambda(), lambdaTarget.getOrdinal());
+ return new LambdaMethodFilter(lambdaTarget.getLambda(), lambdaTarget.getOrdinal(), stepTarget.getCallingExpressionLines());
}
return null;
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/LambdaSmartStepTarget.java b/java/debugger/impl/src/com/intellij/debugger/actions/LambdaSmartStepTarget.java
index da90bafd2a41..dec71630764e 100644
--- a/java/debugger/impl/src/com/intellij/debugger/actions/LambdaSmartStepTarget.java
+++ b/java/debugger/impl/src/com/intellij/debugger/actions/LambdaSmartStepTarget.java
@@ -17,6 +17,7 @@ package com.intellij.debugger.actions;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiLambdaExpression;
+import com.intellij.util.Range;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -28,8 +29,8 @@ public class LambdaSmartStepTarget extends SmartStepTarget{
private final PsiLambdaExpression myLambda;
private final int myOrdinal;
- public LambdaSmartStepTarget(@NotNull PsiLambdaExpression lambda, @Nullable String label, @Nullable PsiElement highlightElement, int ordinal) {
- super(label, highlightElement, true);
+ public LambdaSmartStepTarget(@NotNull PsiLambdaExpression lambda, @Nullable String label, @Nullable PsiElement highlightElement, int ordinal, Range<Integer> lines) {
+ super(label, highlightElement, true, lines);
myLambda = lambda;
myOrdinal = ordinal;
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/MethodSmartStepTarget.java b/java/debugger/impl/src/com/intellij/debugger/actions/MethodSmartStepTarget.java
index 461f89a6d594..69281e66c9bd 100644
--- a/java/debugger/impl/src/com/intellij/debugger/actions/MethodSmartStepTarget.java
+++ b/java/debugger/impl/src/com/intellij/debugger/actions/MethodSmartStepTarget.java
@@ -17,6 +17,7 @@ package com.intellij.debugger.actions;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiMethod;
+import com.intellij.util.Range;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -24,15 +25,11 @@ import org.jetbrains.annotations.Nullable;
* @author Eugene Zhuravlev
* Date: 10/25/13
*/
-public class MethodSmartStepTarget extends SmartStepTarget{
+public class MethodSmartStepTarget extends SmartStepTarget {
private final PsiMethod myMethod;
- public MethodSmartStepTarget(@NotNull PsiMethod method) {
- this(method, null, null, false);
- }
-
- public MethodSmartStepTarget(@NotNull PsiMethod method, @Nullable String label, @Nullable PsiElement highlightElement, boolean needBreakpointRequest) {
- super(label, highlightElement, needBreakpointRequest);
+ public MethodSmartStepTarget(@NotNull PsiMethod method, @Nullable String label, @Nullable PsiElement highlightElement, boolean needBreakpointRequest, Range<Integer> lines) {
+ super(label, highlightElement, needBreakpointRequest, lines);
myMethod = method;
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/SmartStepTarget.java b/java/debugger/impl/src/com/intellij/debugger/actions/SmartStepTarget.java
index f16557bd2c0e..ed758c902784 100644
--- a/java/debugger/impl/src/com/intellij/debugger/actions/SmartStepTarget.java
+++ b/java/debugger/impl/src/com/intellij/debugger/actions/SmartStepTarget.java
@@ -16,6 +16,7 @@
package com.intellij.debugger.actions;
import com.intellij.psi.PsiElement;
+import com.intellij.util.Range;
import org.jetbrains.annotations.Nullable;
/**
@@ -26,11 +27,13 @@ public abstract class SmartStepTarget {
private final PsiElement myHighlightElement;
private final String myLabel;
private final boolean myNeedBreakpointRequest;
+ private final Range<Integer> myExpressionLines;
- protected SmartStepTarget(@Nullable String label, @Nullable PsiElement highlightElement, boolean needBreakpointRequest) {
+ protected SmartStepTarget(@Nullable String label, @Nullable PsiElement highlightElement, boolean needBreakpointRequest, Range<Integer> expressionLines) {
myHighlightElement = highlightElement;
myLabel = label;
myNeedBreakpointRequest = needBreakpointRequest;
+ myExpressionLines = expressionLines;
}
@Nullable
@@ -46,4 +49,8 @@ public abstract class SmartStepTarget {
public boolean needsBreakpointRequest() {
return myNeedBreakpointRequest;
}
+
+ public Range<Integer> getCallingExpressionLines() {
+ return myExpressionLines;
+ }
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/AnonymousClassMethodFilter.java b/java/debugger/impl/src/com/intellij/debugger/engine/AnonymousClassMethodFilter.java
index 7f8436b3de69..aca3ff02d620 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/AnonymousClassMethodFilter.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/AnonymousClassMethodFilter.java
@@ -19,6 +19,7 @@ import com.intellij.debugger.SourcePosition;
import com.intellij.psi.PsiCodeBlock;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.PsiStatement;
+import com.intellij.util.Range;
import org.jetbrains.annotations.Nullable;
/**
@@ -30,8 +31,8 @@ public class AnonymousClassMethodFilter extends BasicStepMethodFilter implements
private final SourcePosition myBreakpointPosition;
private final int myLastStatementLine;
- public AnonymousClassMethodFilter(PsiMethod psiMethod) {
- super(psiMethod);
+ public AnonymousClassMethodFilter(PsiMethod psiMethod, Range<Integer> lines) {
+ super(psiMethod, lines);
SourcePosition firstStatementPosition = null;
SourcePosition lastStatementPosition = null;
final PsiCodeBlock body = psiMethod.getBody();
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/BasicStepMethodFilter.java b/java/debugger/impl/src/com/intellij/debugger/engine/BasicStepMethodFilter.java
index 89e1dec399fa..1e3fa9bcd452 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/BasicStepMethodFilter.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/BasicStepMethodFilter.java
@@ -18,6 +18,7 @@ package com.intellij.debugger.engine;
import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.impl.DebuggerUtilsEx;
import com.intellij.psi.PsiMethod;
+import com.intellij.util.Range;
import com.sun.jdi.Location;
import com.sun.jdi.Method;
import org.jetbrains.annotations.NotNull;
@@ -27,18 +28,20 @@ import org.jetbrains.annotations.Nullable;
* @author Eugene Zhuravlev
* Date: 10/26/13
*/
-public class BasicStepMethodFilter implements MethodFilter{
+public class BasicStepMethodFilter implements MethodFilter {
@NotNull
protected final JVMName myDeclaringClassName;
@NotNull
private final String myTargetMethodName;
@Nullable
protected final JVMName myTargetMethodSignature;
+ private final Range<Integer> myCallingExpressionLines;
- public BasicStepMethodFilter(PsiMethod psiMethod) {
+ public BasicStepMethodFilter(PsiMethod psiMethod, Range<Integer> callingExpressionLines) {
myDeclaringClassName = JVMNameUtil.getJVMQualifiedName(psiMethod.getContainingClass());
myTargetMethodName = psiMethod.isConstructor() ? "<init>" : psiMethod.getName();
myTargetMethodSignature = JVMNameUtil.getJVMSignature(psiMethod);
+ myCallingExpressionLines = callingExpressionLines;
}
@NotNull
@@ -71,4 +74,9 @@ public class BasicStepMethodFilter implements MethodFilter{
}
return false;
}
+
+ @Override
+ public Range<Integer> getCallingExpressionLines() {
+ return myCallingExpressionLines;
+ }
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/CompoundPositionManager.java b/java/debugger/impl/src/com/intellij/debugger/engine/CompoundPositionManager.java
index 399c55fd00e5..250186e74ae9 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/CompoundPositionManager.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/CompoundPositionManager.java
@@ -17,9 +17,11 @@ package com.intellij.debugger.engine;
import com.intellij.debugger.NoDataException;
import com.intellij.debugger.PositionManager;
-import com.intellij.debugger.PositionManagerEx;
import com.intellij.debugger.SourcePosition;
+import com.intellij.debugger.engine.evaluation.EvaluationContext;
+import com.intellij.debugger.jdi.StackFrameProxyImpl;
import com.intellij.debugger.requests.ClassPrepareRequestor;
+import com.intellij.util.ThreeState;
import com.intellij.xdebugger.frame.XStackFrame;
import com.sun.jdi.Location;
import com.sun.jdi.ReferenceType;
@@ -100,10 +102,10 @@ public class CompoundPositionManager extends PositionManagerEx {
@Nullable
@Override
- public XStackFrame createStackFrame(@NotNull Location location) {
+ public XStackFrame createStackFrame(@NotNull StackFrameProxyImpl frame, @NotNull DebugProcessImpl debugProcess, @NotNull Location location) {
for (PositionManager positionManager : myPositionManagers) {
if (positionManager instanceof PositionManagerEx) {
- XStackFrame xStackFrame = ((PositionManagerEx)positionManager).createStackFrame(location);
+ XStackFrame xStackFrame = ((PositionManagerEx)positionManager).createStackFrame(frame, debugProcess, location);
if (xStackFrame != null) {
return xStackFrame;
}
@@ -111,4 +113,20 @@ public class CompoundPositionManager extends PositionManagerEx {
}
return null;
}
+
+ @Override
+ public ThreeState evaluateCondition(@NotNull EvaluationContext context,
+ @NotNull StackFrameProxyImpl frame,
+ @NotNull Location location,
+ @NotNull String expression) {
+ for (PositionManager positionManager : myPositionManagers) {
+ if (positionManager instanceof PositionManagerEx) {
+ ThreeState result = ((PositionManagerEx)positionManager).evaluateCondition(context, frame, location, expression);
+ if (result != ThreeState.UNSURE) {
+ return result;
+ }
+ }
+ }
+ return ThreeState.UNSURE;
+ }
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/ContextUtil.java b/java/debugger/impl/src/com/intellij/debugger/engine/ContextUtil.java
index 26903c87ca4f..4ad9b0004266 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/ContextUtil.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/ContextUtil.java
@@ -137,8 +137,8 @@ public class ContextUtil {
}
@Nullable
- public static PsiElement getContextElement(final SourcePosition position) {
- return position == null ? null :position.getElementAt();
+ public static PsiElement getContextElement(@Nullable SourcePosition position) {
+ return position == null ? null : position.getElementAt();
}
public static boolean isJspImplicit(PsiElement element) {
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java
index b660d5f1ed6e..2570d9a01f8d 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java
@@ -72,12 +72,12 @@ import com.intellij.util.EventDispatcher;
import com.intellij.util.StringBuilderSpinAllocator;
import com.intellij.util.concurrency.Semaphore;
import com.intellij.util.containers.ContainerUtil;
+import com.intellij.util.containers.HashMap;
import com.sun.jdi.*;
import com.sun.jdi.connect.*;
import com.sun.jdi.request.EventRequest;
import com.sun.jdi.request.EventRequestManager;
import com.sun.jdi.request.StepRequest;
-import gnu.trove.THashMap;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -119,7 +119,10 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
private Map<String, Connector.Argument> myArguments;
private final List<NodeRenderer> myRenderers = new ArrayList<NodeRenderer>();
- private final Map<Type, NodeRenderer> myNodeRenderersMap = new THashMap<Type, NodeRenderer>();
+
+ // we use null key here
+ private final Map<Type, NodeRenderer> myNodeRenderersMap = new HashMap<Type, NodeRenderer>();
+
private final NodeRendererSettingsListener mySettingsListener = new NodeRendererSettingsListener() {
@Override
public void renderersChanged() {
@@ -905,8 +908,11 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
ClassNotLoadedException,
IncompatibleThreadStateException,
InvalidTypeException;
-
public E start(EvaluationContextImpl evaluationContext, Method method) throws EvaluateException {
+ return start(evaluationContext, method, false);
+ }
+
+ public E start(EvaluationContextImpl evaluationContext, Method method, boolean internalEvaluate) throws EvaluateException {
DebuggerManagerThreadImpl.assertIsManagerThread();
SuspendContextImpl suspendContext = evaluationContext.getSuspendContext();
SuspendManagerUtil.assertSuspendContext(suspendContext);
@@ -921,11 +927,11 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
final ThreadReference invokeThreadRef = invokeThread.getThreadReference();
myEvaluationDispatcher.getMulticaster().evaluationStarted(suspendContext);
- beforeMethodInvocation(suspendContext, method);
+ beforeMethodInvocation(suspendContext, method, internalEvaluate);
Object resumeData = null;
try {
- for (final SuspendContextImpl suspendingContext : suspendingContexts) {
+ for (SuspendContextImpl suspendingContext : suspendingContexts) {
final ThreadReferenceProxyImpl suspendContextThread = suspendingContext.getThread();
if (suspendContextThread != invokeThread) {
if (LOG.isDebugEnabled()) {
@@ -944,11 +950,11 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
while (true) {
try {
return invokeMethodAndFork(suspendContext);
- }
+ }
catch (ClassNotLoadedException e) {
ReferenceType loadedClass;
try {
- loadedClass = evaluationContext.isAutoLoadClasses()? loadClass(evaluationContext, e.className(), evaluationContext.getClassLoader()) : null;
+ loadedClass = evaluationContext.isAutoLoadClasses() ? loadClass(evaluationContext, e.className(), evaluationContext.getClassLoader()) : null;
}
catch (EvaluateException ignored) {
loadedClass = null;
@@ -995,7 +1001,7 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
LOG.debug("getVirtualMachine().clearCaches()");
}
getVirtualMachineProxy().clearCaches();
- afterMethodInvocation(suspendContext);
+ afterMethodInvocation(suspendContext, internalEvaluate);
myEvaluationDispatcher.getMulticaster().evaluationFinished(suspendContext);
}
@@ -1084,13 +1090,13 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
}
@Override
- public Value invokeMethod(final EvaluationContext evaluationContext, final ObjectReference objRef, final Method method, final List args) throws EvaluateException {
+ public Value invokeMethod(@NotNull EvaluationContext evaluationContext, @NotNull ObjectReference objRef, @NotNull Method method, final List args) throws EvaluateException {
return invokeInstanceMethod(evaluationContext, objRef, method, args, 0);
}
@Override
- public Value invokeInstanceMethod(final EvaluationContext evaluationContext, final ObjectReference objRef, final Method method,
- final List args, final int invocationOptions) throws EvaluateException {
+ public Value invokeInstanceMethod(@NotNull EvaluationContext evaluationContext, @NotNull final ObjectReference objRef, final Method method,
+ final List args, final int invocationOptions) throws EvaluateException {
final ThreadReference thread = getEvaluationThread(evaluationContext);
return new InvokeCommand<Value>(args) {
@Override
@@ -1115,9 +1121,16 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
public Value invokeMethod(final EvaluationContext evaluationContext, final ClassType classType,
final Method method,
final List args) throws EvaluateException {
+ return invokeMethod(evaluationContext, classType, method, args, false);
+ }
+ public Value invokeMethod(@NotNull EvaluationContext evaluationContext,
+ @NotNull final ClassType classType,
+ @NotNull final Method method,
+ final List args,
+ boolean internalEvaluate) throws EvaluateException {
final ThreadReference thread = getEvaluationThread(evaluationContext);
- InvokeCommand<Value> invokeCommand = new InvokeCommand<Value>(args) {
+ return new InvokeCommand<Value>(args) {
@Override
protected Value invokeMethod(int invokePolicy, final List args) throws InvocationException,
ClassNotLoadedException,
@@ -1128,8 +1141,7 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
}
return classType.invokeMethod(thread, method, args, invokePolicy);
}
- };
- return invokeCommand.start((EvaluationContextImpl)evaluationContext, method);
+ }.start((EvaluationContextImpl)evaluationContext, method, internalEvaluate);
}
@Override
@@ -1176,25 +1188,29 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
clearCashes(suspendContext.getSuspendPolicy());
}
- private void beforeMethodInvocation(SuspendContextImpl suspendContext, Method method) {
+ private void beforeMethodInvocation(SuspendContextImpl suspendContext, Method method, boolean internalEvaluate) {
if (LOG.isDebugEnabled()) {
LOG.debug(
"before invocation in thread " + suspendContext.getThread().name() + " method " + (method == null ? "null" : method.name()));
}
- if (method != null) {
- showStatusText(DebuggerBundle.message("progress.evaluating", DebuggerUtilsEx.methodName(method)));
- }
- else {
- showStatusText(DebuggerBundle.message("title.evaluating"));
+ if (!internalEvaluate) {
+ if (method != null) {
+ showStatusText(DebuggerBundle.message("progress.evaluating", DebuggerUtilsEx.methodName(method)));
+ }
+ else {
+ showStatusText(DebuggerBundle.message("title.evaluating"));
+ }
}
}
- private void afterMethodInvocation(SuspendContextImpl suspendContext) {
+ private void afterMethodInvocation(SuspendContextImpl suspendContext, boolean internalEvaluate) {
if (LOG.isDebugEnabled()) {
LOG.debug("after invocation in thread " + suspendContext.getThread().name());
}
- showStatusText("");
+ if (!internalEvaluate) {
+ showStatusText("");
+ }
}
@Override
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/DebuggerManagerThreadImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/DebuggerManagerThreadImpl.java
index 4f4eb3f3ffc2..abe71077bc9f 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/DebuggerManagerThreadImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/DebuggerManagerThreadImpl.java
@@ -37,15 +37,16 @@ import org.jetbrains.annotations.TestOnly;
* @author lex
*/
public class DebuggerManagerThreadImpl extends InvokeAndWaitThread<DebuggerCommandImpl> implements DebuggerManagerThread, Disposable {
- private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.engine.DebuggerManagerThreadImpl");
+ private static final Logger LOG = Logger.getInstance(DebuggerManagerThreadImpl.class);
public static final int COMMAND_TIMEOUT = 3000;
- private static final int RESTART_TIMEOUT = 500;
+
private volatile boolean myDisposed;
DebuggerManagerThreadImpl(@NotNull Disposable parent) {
Disposer.register(parent, this);
}
+ @Override
public void dispose() {
myDisposed = true;
}
@@ -63,6 +64,7 @@ public class DebuggerManagerThreadImpl extends InvokeAndWaitThread<DebuggerComma
LOG.assertTrue(isManagerThread(), "Should be invoked in manager thread, use DebuggerManagerThreadImpl.getInstance(..).invoke...");
}
+ @Override
public void invokeAndWait(DebuggerCommandImpl managerCommand) {
LOG.assertTrue(!isManagerThread(), "Should be invoked outside manager thread, use DebuggerManagerThreadImpl.getInstance(..).invoke...");
super.invokeAndWait(managerCommand);
@@ -77,6 +79,7 @@ public class DebuggerManagerThreadImpl extends InvokeAndWaitThread<DebuggerComma
}
}
+ @Override
public boolean pushBack(DebuggerCommandImpl managerCommand) {
final boolean pushed = super.pushBack(managerCommand);
if (!pushed) {
@@ -85,6 +88,7 @@ public class DebuggerManagerThreadImpl extends InvokeAndWaitThread<DebuggerComma
return pushed;
}
+ @Override
public boolean schedule(DebuggerCommandImpl managerCommand) {
final boolean scheduled = super.schedule(managerCommand);
if (!scheduled) {
@@ -106,6 +110,7 @@ public class DebuggerManagerThreadImpl extends InvokeAndWaitThread<DebuggerComma
if (currentCommand != null) {
final Alarm alarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD);
alarm.addRequest(new Runnable() {
+ @Override
public void run() {
try {
if (currentCommand == myEvents.getCurrentEvent()) {
@@ -135,10 +140,11 @@ public class DebuggerManagerThreadImpl extends InvokeAndWaitThread<DebuggerComma
}
+ @Override
public void processEvent(@NotNull DebuggerCommandImpl managerCommand) {
assertIsManagerThread();
try {
- if(myEvents.isClosed()) {
+ if (myEvents.isClosed()) {
managerCommand.notifyCancelled();
}
else {
@@ -161,14 +167,17 @@ public class DebuggerManagerThreadImpl extends InvokeAndWaitThread<DebuggerComma
public void startProgress(final DebuggerCommandImpl command, final ProgressWindowWithNotification progressWindow) {
progressWindow.addListener(new ProgressIndicatorListenerAdapter() {
+ @Override
public void cancelled() {
command.release();
}
});
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
+ @Override
public void run() {
ProgressManager.getInstance().runProcess(new Runnable() {
+ @Override
public void run() {
invokeAndWait(command);
}
@@ -193,10 +202,12 @@ public class DebuggerManagerThreadImpl extends InvokeAndWaitThread<DebuggerComma
}
super.invokeAndWait(new DebuggerCommandImpl() {
+ @Override
protected void action() throws Exception {
switchToRequest(request);
}
+ @Override
protected void commandCancelled() {
if (LOG.isDebugEnabled()) {
LOG.debug("Event queue was closed, killing request");
@@ -207,14 +218,17 @@ public class DebuggerManagerThreadImpl extends InvokeAndWaitThread<DebuggerComma
}
}
+ @Override
public void invokeCommand(final DebuggerCommand command) {
if(command instanceof SuspendContextCommand) {
SuspendContextCommand suspendContextCommand = (SuspendContextCommand)command;
schedule(new SuspendContextCommandImpl((SuspendContextImpl)suspendContextCommand.getSuspendContext()) {
+ @Override
public void contextAction() throws Exception {
command.action();
}
+ @Override
protected void commandCancelled() {
command.commandCancelled();
}
@@ -222,10 +236,12 @@ public class DebuggerManagerThreadImpl extends InvokeAndWaitThread<DebuggerComma
}
else {
schedule(new DebuggerCommandImpl() {
+ @Override
protected void action() throws Exception {
command.action();
}
+ @Override
protected void commandCancelled() {
command.commandCancelled();
}
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 c51326bd5a19..043b103ee734 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/LambdaMethodFilter.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/LambdaMethodFilter.java
@@ -22,6 +22,7 @@ import com.intellij.psi.PsiCodeBlock;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiLambdaExpression;
import com.intellij.psi.PsiStatement;
+import com.intellij.util.Range;
import com.sun.jdi.Location;
import com.sun.jdi.Method;
import org.jetbrains.annotations.Nullable;
@@ -36,9 +37,11 @@ public class LambdaMethodFilter implements BreakpointStepMethodFilter{
@Nullable
private final SourcePosition myFirstStatementPosition;
private final int myLastStatementLine;
+ private final Range<Integer> myCallingExpressionLines;
- public LambdaMethodFilter(PsiLambdaExpression lambda, int expressionOrdinal) {
+ public LambdaMethodFilter(PsiLambdaExpression lambda, int expressionOrdinal, Range<Integer> callingExpressionLines) {
myLambdaOrdinal = expressionOrdinal;
+ myCallingExpressionLines = callingExpressionLines;
SourcePosition firstStatementPosition = null;
SourcePosition lastStatementPosition = null;
@@ -78,4 +81,9 @@ public class LambdaMethodFilter implements BreakpointStepMethodFilter{
final Method method = location.method();
return method.name().startsWith(LAMBDA_METHOD_PREFIX) && (!vm.canGetSyntheticAttribute() || method.isSynthetic());
}
+
+ @Override
+ public Range<Integer> getCallingExpressionLines() {
+ return myCallingExpressionLines;
+ }
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/MethodFilter.java b/java/debugger/impl/src/com/intellij/debugger/engine/MethodFilter.java
index 665d52fb81f8..18ece3d40f0f 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/MethodFilter.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/MethodFilter.java
@@ -16,8 +16,10 @@
package com.intellij.debugger.engine;
import com.intellij.debugger.engine.evaluation.EvaluateException;
+import com.intellij.util.Range;
import com.sun.jdi.Location;
public interface MethodFilter {
boolean locationMatches(DebugProcessImpl process, Location location) throws EvaluateException;
+ Range<Integer> getCallingExpressionLines();
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerEx.java b/java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerEx.java
new file mode 100644
index 000000000000..b05e8b41589f
--- /dev/null
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerEx.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.debugger.engine;
+
+import com.intellij.debugger.PositionManager;
+import com.intellij.debugger.engine.evaluation.EvaluationContext;
+import com.intellij.debugger.jdi.StackFrameProxyImpl;
+import com.intellij.util.ThreeState;
+import com.intellij.xdebugger.frame.XStackFrame;
+import com.sun.jdi.Location;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+public abstract class PositionManagerEx implements PositionManager {
+ @Nullable
+ public abstract XStackFrame createStackFrame(@NotNull StackFrameProxyImpl frame, @NotNull DebugProcessImpl debugProcess, @NotNull Location location);
+
+ public abstract ThreeState evaluateCondition(@NotNull EvaluationContext context,
+ @NotNull StackFrameProxyImpl frame,
+ @NotNull Location location,
+ @NotNull String expression);
+}
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.java
index cd6944c31952..b3e371d7e327 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.java
@@ -29,7 +29,6 @@ import com.intellij.openapi.util.NullableComputable;
import com.intellij.openapi.util.Ref;
import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
-import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
import com.sun.jdi.AbsentInformationException;
import com.sun.jdi.Location;
@@ -258,14 +257,43 @@ public class PositionManagerImpl implements PositionManager {
private static int getNestingDepth(PsiClass aClass) {
int depth = 0;
- PsiClass enclosing = PsiTreeUtil.getParentOfType(aClass, PsiClass.class, true);
+ PsiClass enclosing = getEnclosingClass(aClass);
while (enclosing != null) {
depth++;
- enclosing = PsiTreeUtil.getParentOfType(enclosing, PsiClass.class, true);
+ enclosing = getEnclosingClass(enclosing);
}
return depth;
}
+ /**
+ * See IDEA-121739
+ * Anonymous classes inside other anonymous class parameters list should belong to parent class
+ * Inner in = new Inner(new Inner2(){}) {};
+ * Parent of Inner2 sub class here is not Inner sub class
+ */
+ private static PsiClass getEnclosingClass(PsiElement element) {
+ if (element == null) {
+ return null;
+ }
+
+ element = element.getParent();
+ PsiElement previous = null;
+
+ while (element != null) {
+ if (PsiClass.class.isInstance(element) && !(previous instanceof PsiExpressionList)) {
+ //noinspection unchecked
+ return (PsiClass)element;
+ }
+ if (element instanceof PsiFile) {
+ return null;
+ }
+ previous = element;
+ element = element.getParent();
+ }
+
+ return null;
+ }
+
@Nullable
private ReferenceType findNested(final ReferenceType fromClass, final int currentDepth, final PsiClass classToFind, final int requiredDepth, final SourcePosition position) {
final VirtualMachineProxyImpl vmProxy = myDebugProcess.getVirtualMachineProxy();
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 7a184270988d..a225ab0695c2 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/RequestHint.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/RequestHint.java
@@ -91,6 +91,7 @@ public class RequestHint {
}
}
+ @NotNull
public DebugProcess getDebugProcess() {
return suspendContext.getDebugProcess();
}
@@ -136,6 +137,16 @@ public class RequestHint {
return myMethodFilter instanceof BreakpointStepMethodFilter || myTargetMethodMatched;
}
+ private boolean isOnTheSameLine(SourcePosition locationPosition) {
+ if (myMethodFilter == null) {
+ return myPosition.getLine() == locationPosition.getLine();
+ }
+ else {
+ return locationPosition.getLine() >= myMethodFilter.getCallingExpressionLines().getFrom() &&
+ locationPosition.getLine() <= myMethodFilter.getCallingExpressionLines().getTo();
+ }
+ }
+
public int getNextStepDepth(final SuspendContextImpl context) {
try {
if ((myDepth == StepRequest.STEP_OVER || myDepth == StepRequest.STEP_INTO) && myPosition != null) {
@@ -155,7 +166,7 @@ public class RequestHint {
}
}
final boolean filesEqual = myPosition.getFile().equals(locationPosition.getFile());
- if (filesEqual && myPosition.getLine() == locationPosition.getLine() && myFrameCount == frameCount) {
+ if (filesEqual && isOnTheSameLine(locationPosition) && myFrameCount == frameCount) {
return myDepth;
}
if (myDepth == StepRequest.STEP_INTO) {
@@ -165,7 +176,7 @@ public class RequestHint {
return STOP;
}
// check if we are still at the line from which the stepping begun
- if (myFrameCount == frameCount && myPosition.getLine() != locationPosition.getLine()) {
+ if (myFrameCount == frameCount && !isOnTheSameLine(locationPosition)) {
return STOP;
}
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/SuspendContextImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/SuspendContextImpl.java
index c8536bef1702..a0a81d649040 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/SuspendContextImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/SuspendContextImpl.java
@@ -50,12 +50,12 @@ public abstract class SuspendContextImpl implements SuspendContext {
protected Set<ThreadReferenceProxyImpl> myResumedThreads;
private final EventSet myEventSet;
- private volatile boolean myIsResumed;
+ private volatile boolean myIsResumed;
public ConcurrentLinkedQueue<SuspendContextCommandImpl> myPostponedCommands = new ConcurrentLinkedQueue<SuspendContextCommandImpl>();
- public volatile boolean myInProgress;
- private final HashSet<ObjectReference> myKeptReferences = new HashSet<ObjectReference>();
- private EvaluationContextImpl myEvaluationContext = null;
+ public volatile boolean myInProgress;
+ private final HashSet<ObjectReference> myKeptReferences = new HashSet<ObjectReference>();
+ private EvaluationContextImpl myEvaluationContext = null;
SuspendContextImpl(@NotNull DebugProcessImpl debugProcess, int suspendPolicy, int eventVotes, EventSet set) {
myDebugProcess = debugProcess;
@@ -82,7 +82,7 @@ public abstract class SuspendContextImpl implements SuspendContext {
try {
objectReference.enableCollection();
}
- catch (UnsupportedOperationException e) {
+ catch (UnsupportedOperationException ignored) {
// ignore: some J2ME implementations does not provide this operation
}
}
@@ -115,25 +115,30 @@ public abstract class SuspendContextImpl implements SuspendContext {
return myEventSet;
}
+ @Override
+ @NotNull
public DebugProcessImpl getDebugProcess() {
assertNotResumed();
return myDebugProcess;
}
+ @Override
public StackFrameProxyImpl getFrameProxy() {
assertNotResumed();
try {
return myThread != null && myThread.frameCount() > 0 ? myThread.frame(0) : null;
}
- catch (EvaluateException e) {
+ catch (EvaluateException ignored) {
return null;
}
}
+ @Override
public ThreadReferenceProxyImpl getThread() {
return myThread;
}
+ @Override
public int getSuspendPolicy() {
assertNotResumed();
return mySuspendPolicy;
@@ -145,7 +150,7 @@ public abstract class SuspendContextImpl implements SuspendContext {
}
public boolean isExplicitlyResumed(ThreadReferenceProxyImpl thread) {
- return myResumedThreads != null ? myResumedThreads.contains(thread) : false;
+ return myResumedThreads != null && myResumedThreads.contains(thread);
}
public boolean suspends(ThreadReferenceProxyImpl thread) {
@@ -194,7 +199,7 @@ public abstract class SuspendContextImpl implements SuspendContext {
try {
reference.disableCollection();
}
- catch (UnsupportedOperationException e) {
+ catch (UnsupportedOperationException ignored) {
// ignore: some J2ME implementations does not provide this operation
}
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/SuspendManagerImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/SuspendManagerImpl.java
index de161f121d9e..576f781dc368 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/SuspendManagerImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/SuspendManagerImpl.java
@@ -21,6 +21,7 @@ import com.sun.jdi.InternalException;
import com.sun.jdi.ObjectCollectedException;
import com.sun.jdi.event.EventSet;
import com.sun.jdi.request.EventRequest;
+import org.jetbrains.annotations.NotNull;
import java.util.*;
@@ -33,7 +34,7 @@ public class SuspendManagerImpl implements SuspendManager {
private final LinkedList<SuspendContextImpl> myEventContexts = new LinkedList<SuspendContextImpl>();
/**
* contexts, paused at breakpoint or another debugger event requests. Note that thread, explicitly paused by user is not considered as
- * "paused at breakpoint" and JDI prohibits data queries on its stackframes
+ * "paused at breakpoint" and JDI prohibits data queries on its stack frames
*/
private final LinkedList<SuspendContextImpl> myPausedContexts = new LinkedList<SuspendContextImpl>();
private final Set<ThreadReferenceProxyImpl> myFrozenThreads = Collections.synchronizedSet(new HashSet<ThreadReferenceProxyImpl>());
@@ -42,9 +43,10 @@ public class SuspendManagerImpl implements SuspendManager {
public int suspends = 0;
- public SuspendManagerImpl(DebugProcessImpl debugProcess) {
+ public SuspendManagerImpl(@NotNull DebugProcessImpl debugProcess) {
myDebugProcess = debugProcess;
myDebugProcess.addDebugProcessListener(new DebugProcessAdapterImpl() {
+ @Override
public void processDetached(DebugProcessImpl process, boolean closedByUser) {
myEventContexts.clear();
myPausedContexts.clear();
@@ -53,8 +55,10 @@ public class SuspendManagerImpl implements SuspendManager {
});
}
+ @Override
public SuspendContextImpl pushSuspendContext(final int suspendPolicy, int nVotes) {
SuspendContextImpl suspendContext = new SuspendContextImpl(myDebugProcess, suspendPolicy, nVotes, null) {
+ @Override
protected void resumeImpl() {
if (LOG.isDebugEnabled()) {
LOG.debug("Start resuming...");
@@ -71,9 +75,9 @@ public class SuspendManagerImpl implements SuspendManager {
catch (InternalException e) {
//InternalException 13 means that there are running threads that we are trying to resume
//On MacOS it happened that native thread didn't stop while some java thread reached breakpoint
+ //noinspection StatementWithEmptyBody
if (/*Patches.MAC_RESUME_VM_HACK && */e.errorCode() == 13) {
//Its funny, but second resume solves the problem
- continue;
}
else {
LOG.error(e);
@@ -108,8 +112,10 @@ public class SuspendManagerImpl implements SuspendManager {
return suspendContext;
}
+ @Override
public SuspendContextImpl pushSuspendContext(final EventSet set) {
SuspendContextImpl suspendContext = new SuspendContextImpl(myDebugProcess, set.suspendPolicy(), set.size(), set) {
+ @Override
protected void resumeImpl() {
if (LOG.isDebugEnabled()) {
LOG.debug("Start resuming eventSet " + set.toString() + " suspendPolicy = " + set.suspendPolicy() + ",size = " + set.size());
@@ -138,14 +144,13 @@ public class SuspendManagerImpl implements SuspendManager {
catch (ObjectCollectedException e) {
// according to error reports set.resume() may throw this if one of the threads has been collected
LOG.info(e);
- continue;
}
catch (InternalException e) {
//InternalException 13 means that there are running threads that we are trying to resume
//On MacOS it happened that native thread didn't stop while some java thread reached breakpoint
+ //noinspection StatementWithEmptyBody
if (/*Patches.MAC_RESUME_VM_HACK && */e.errorCode() == 13 && set.suspendPolicy() == EventRequest.SUSPEND_ALL) {
//Its funny, but second resume solves the problem
- continue;
}
else {
LOG.error(e);
@@ -172,6 +177,7 @@ public class SuspendManagerImpl implements SuspendManager {
}
}
+ @Override
public void resume(SuspendContextImpl context) {
SuspendManagerUtil.prepareForResume(context);
@@ -182,6 +188,7 @@ public class SuspendManagerImpl implements SuspendManager {
myDebugProcess.clearCashes(suspendPolicy);
}
+ @Override
public void popFrame(SuspendContextImpl suspendContext) {
popContext(suspendContext);
SuspendContextImpl newSuspendContext = pushSuspendContext(suspendContext.getSuspendPolicy(), 0);
@@ -189,6 +196,7 @@ public class SuspendManagerImpl implements SuspendManager {
notifyPaused(newSuspendContext);
}
+ @Override
public SuspendContextImpl getPausedContext() {
return !myPausedContexts.isEmpty() ? myPausedContexts.getFirst() : null;
}
@@ -216,15 +224,18 @@ public class SuspendManagerImpl implements SuspendManager {
return myEventContexts.contains(suspendContext);
}
+ @Override
public List<SuspendContextImpl> getEventContexts() {
DebuggerManagerThreadImpl.assertIsManagerThread();
return Collections.unmodifiableList(myEventContexts);
}
+ @Override
public boolean isFrozen(ThreadReferenceProxyImpl thread) {
return myFrozenThreads.contains(thread);
}
+ @Override
public boolean isSuspended(ThreadReferenceProxyImpl thread) throws ObjectCollectedException{
DebuggerManagerThreadImpl.assertIsManagerThread();
@@ -249,6 +260,7 @@ public class SuspendManagerImpl implements SuspendManager {
return suspended && (thread == null || thread.isSuspended());
}
+ @Override
public void suspendThread(SuspendContextImpl context, ThreadReferenceProxyImpl thread) {
LOG.assertTrue(thread != context.getThread(), "Thread is already suspended at the breakpoint");
@@ -258,6 +270,7 @@ public class SuspendManagerImpl implements SuspendManager {
}
}
+ @Override
public void resumeThread(SuspendContextImpl context, ThreadReferenceProxyImpl thread) {
LOG.assertTrue(thread != context.getThread(), "Use resume() instead of resuming breakpoint thread");
LOG.assertTrue(!context.isExplicitlyResumed(thread));
@@ -269,12 +282,14 @@ public class SuspendManagerImpl implements SuspendManager {
thread.resume();
}
+ @Override
public void freezeThread(ThreadReferenceProxyImpl thread) {
if (myFrozenThreads.add(thread)) {
thread.suspend();
}
}
+ @Override
public void unfreezeThread(ThreadReferenceProxyImpl thread) {
if (myFrozenThreads.remove(thread)) {
thread.resume();
@@ -310,6 +325,7 @@ public class SuspendManagerImpl implements SuspendManager {
myDebugProcess.myDebugProcessDispatcher.getMulticaster().paused(suspendContext);
}
+ @Override
public void voteResume(SuspendContextImpl suspendContext) {
if (LOG.isDebugEnabled()) {
LOG.debug("Resume voted");
@@ -317,6 +333,7 @@ public class SuspendManagerImpl implements SuspendManager {
processVote(suspendContext);
}
+ @Override
public void voteSuspend(SuspendContextImpl suspendContext) {
suspendContext.myIsVotedForResume = false;
processVote(suspendContext);
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/SuspendManagerUtil.java b/java/debugger/impl/src/com/intellij/debugger/engine/SuspendManagerUtil.java
index e53f9d5a520e..8113121d3e1d 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/SuspendManagerUtil.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/SuspendManagerUtil.java
@@ -19,8 +19,6 @@ import com.intellij.debugger.jdi.ThreadReferenceProxyImpl;
import com.intellij.openapi.diagnostic.Logger;
import java.util.HashSet;
-import java.util.Iterator;
-import java.util.ListIterator;
import java.util.Set;
public class SuspendManagerUtil {
@@ -36,9 +34,8 @@ public class SuspendManagerUtil {
}
public static SuspendContextImpl findContextByThread(SuspendManager suspendManager, ThreadReferenceProxyImpl thread) {
- for (ListIterator<SuspendContextImpl> iterator = ((SuspendManagerImpl) suspendManager).getPausedContexts().listIterator(); iterator.hasNext();) {
- SuspendContextImpl context = iterator.next();
- if(context.getThread() == thread) {
+ for (SuspendContextImpl context : ((SuspendManagerImpl)suspendManager).getPausedContexts()) {
+ if (context.getThread() == thread) {
return context;
}
}
@@ -78,8 +75,7 @@ public class SuspendManagerUtil {
LOG.assertTrue(context.myResumedThreads == null);
if(data.myResumedThreads != null) {
- for (Iterator<ThreadReferenceProxyImpl> iterator = data.myResumedThreads.iterator(); iterator.hasNext();) {
- ThreadReferenceProxyImpl resumedThreads = iterator.next();
+ for (ThreadReferenceProxyImpl resumedThreads : data.myResumedThreads) {
resumedThreads.resume();
}
context.myResumedThreads = data.myResumedThreads;
@@ -101,8 +97,7 @@ public class SuspendManagerUtil {
LOG.debug("Resuming SuspendContextImpl...");
}
if(context.myResumedThreads != null) {
- for (Iterator<ThreadReferenceProxyImpl> iterator = context.myResumedThreads.iterator(); iterator.hasNext();) {
- ThreadReferenceProxyImpl resumedThreads = iterator.next();
+ for (ThreadReferenceProxyImpl resumedThreads : context.myResumedThreads) {
resumedThreads.suspend();
}
context.myResumedThreads = null;
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/EvaluationContextImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/EvaluationContextImpl.java
index 24babfd066b5..b6ca9eafe1f1 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/EvaluationContextImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/EvaluationContextImpl.java
@@ -23,51 +23,58 @@ import com.intellij.openapi.project.Project;
import com.sun.jdi.ClassLoaderReference;
import com.sun.jdi.Value;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
-/**
- * User: lex
- * Date: Aug 28, 2003
- * Time: 2:02:29 PM
- */
public final class EvaluationContextImpl implements EvaluationContext{
private final Value myThisObject;
private final SuspendContextImpl mySuspendContext;
private final StackFrameProxyImpl myFrameProxy;
private boolean myAutoLoadClasses = true;
- public EvaluationContextImpl(@NotNull SuspendContextImpl suspendContext, StackFrameProxyImpl frameProxy, Value thisObject) {
+ public EvaluationContextImpl(@NotNull SuspendContextImpl suspendContext, StackFrameProxyImpl frameProxy, @Nullable Value thisObject) {
myThisObject = thisObject;
myFrameProxy = frameProxy;
mySuspendContext = suspendContext;
}
+ @Nullable
+ @Override
public Value getThisObject() {
return myThisObject;
}
+ @NotNull
+ @Override
public SuspendContextImpl getSuspendContext() {
return mySuspendContext;
}
+ @Override
public StackFrameProxyImpl getFrameProxy() {
return myFrameProxy;
}
+ @NotNull
+ @Override
public DebugProcessImpl getDebugProcess() {
return getSuspendContext().getDebugProcess();
}
+ @Override
public Project getProject() {
DebugProcessImpl debugProcess = getDebugProcess();
- return debugProcess != null ? debugProcess.getProject() : null;
+ return debugProcess.getProject();
}
+ @Override
public EvaluationContextImpl createEvaluationContext(Value value) {
final EvaluationContextImpl copy = new EvaluationContextImpl(getSuspendContext(), getFrameProxy(), value);
copy.setAutoLoadClasses(myAutoLoadClasses);
return copy;
}
+ @Nullable
+ @Override
public ClassLoaderReference getClassLoader() throws EvaluateException {
DebuggerManagerThreadImpl.assertIsManagerThread();
return myFrameProxy != null ? myFrameProxy.getClassLoader() : null;
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/TextWithImportsImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/TextWithImportsImpl.java
index 4eda8984e285..e8db7893e16a 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/TextWithImportsImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/TextWithImportsImpl.java
@@ -73,14 +73,17 @@ public final class TextWithImportsImpl implements TextWithImports{
return Trinity.create(split[0], split.length > 1 ? split[1] : "", split.length > 2 ? FileTypeManager.getInstance().getStdFileType(split[2]) : null);
}
+ @Override
public CodeFragmentKind getKind() {
return myKind;
}
+ @Override
public String getText() {
return myText;
}
+ @Override
public @NotNull String getImports() {
return myImports;
}
@@ -97,6 +100,7 @@ public final class TextWithImportsImpl implements TextWithImports{
return getText();
}
+ @Override
public String toExternalForm() {
String result = myText;
if (StringUtil.isNotEmpty(myImports) || myFileType != null) {
@@ -112,15 +116,17 @@ public final class TextWithImportsImpl implements TextWithImports{
return myText.hashCode();
}
+ @Override
public boolean isEmpty() {
- final String text = getText();
- return text == null || "".equals(text.trim());
+ return StringUtil.isEmptyOrSpaces(getText());
}
+ @Override
public void setText(String newText) {
myText = newText;
}
+ @Override
public FileType getFileType() {
return myFileType;
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/BinaryExpressionEvaluator.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/BinaryExpressionEvaluator.java
index db00e47f9295..14d46e7f361b 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/BinaryExpressionEvaluator.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/BinaryExpressionEvaluator.java
@@ -21,6 +21,7 @@
package com.intellij.debugger.engine.evaluation.expression;
import com.intellij.debugger.DebuggerBundle;
+import com.intellij.debugger.engine.DebuggerUtils;
import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil;
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
@@ -45,10 +46,12 @@ class BinaryExpressionEvaluator implements Evaluator {
myExpectedType = expectedType;
}
+ @Override
public Modifier getModifier() {
return null;
}
+ @Override
public Object evaluate(EvaluationContextImpl context) throws EvaluateException {
Value leftResult = (Value)myLeftOperand.evaluate(context);
return evaluateOperation(leftResult, myOpType, myRightOperand, myExpectedType, context);
@@ -72,12 +75,12 @@ class BinaryExpressionEvaluator implements Evaluator {
}
Value rightResult = (Value)rightOperand.evaluate(context);
if (opType == JavaTokenType.PLUS) {
- if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
+ if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
final long v1 = ((PrimitiveValue)leftResult).longValue();
final long v2 = ((PrimitiveValue)rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 + v2);
}
- if (DebuggerUtilsEx.isNumeric(leftResult) && DebuggerUtilsEx.isNumeric(rightResult)) {
+ if (DebuggerUtils.isNumeric(leftResult) && DebuggerUtils.isNumeric(rightResult)) {
final double v1 = ((PrimitiveValue)leftResult).doubleValue();
final double v2 = ((PrimitiveValue)rightResult).doubleValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 + v2);
@@ -88,19 +91,19 @@ class BinaryExpressionEvaluator implements Evaluator {
return DebuggerUtilsEx.createValue(vm, expectedType, v1 + v2);
}
if (leftResult instanceof StringReference || rightResult instanceof StringReference) {
- String v1 = DebuggerUtilsEx.getValueAsString(context, leftResult);
- String v2 = DebuggerUtilsEx.getValueAsString(context, rightResult);
+ String v1 = DebuggerUtils.getValueAsString(context, leftResult);
+ String v2 = DebuggerUtils.getValueAsString(context, rightResult);
return vm.mirrorOf(v1 + v2);
}
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "+"));
}
else if (opType == JavaTokenType.MINUS) {
- if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
+ if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
final long v1 = ((PrimitiveValue)leftResult).longValue();
final long v2 = ((PrimitiveValue)rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 - v2);
}
- if (DebuggerUtilsEx.isNumeric(leftResult) && DebuggerUtilsEx.isNumeric(rightResult)) {
+ if (DebuggerUtils.isNumeric(leftResult) && DebuggerUtils.isNumeric(rightResult)) {
double v1 = ((PrimitiveValue)leftResult).doubleValue();
double v2 = ((PrimitiveValue)rightResult).doubleValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 - v2);
@@ -113,12 +116,12 @@ class BinaryExpressionEvaluator implements Evaluator {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "-"));
}
else if (opType == JavaTokenType.ASTERISK) {
- if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
+ if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
final long v1 = ((PrimitiveValue)leftResult).longValue();
final long v2 = ((PrimitiveValue)rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 * v2);
}
- if (DebuggerUtilsEx.isNumeric(leftResult) && DebuggerUtilsEx.isNumeric(rightResult)) {
+ if (DebuggerUtils.isNumeric(leftResult) && DebuggerUtils.isNumeric(rightResult)) {
double v1 = ((PrimitiveValue)leftResult).doubleValue();
double v2 = ((PrimitiveValue)rightResult).doubleValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 * v2);
@@ -131,12 +134,12 @@ class BinaryExpressionEvaluator implements Evaluator {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "*"));
}
else if (opType == JavaTokenType.DIV) {
- if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
+ if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
long v1 = ((PrimitiveValue)leftResult).longValue();
long v2 = ((PrimitiveValue)rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 / v2);
}
- if (DebuggerUtilsEx.isNumeric(leftResult) && DebuggerUtilsEx.isNumeric(rightResult)) {
+ if (DebuggerUtils.isNumeric(leftResult) && DebuggerUtils.isNumeric(rightResult)) {
double v1 = ((PrimitiveValue)leftResult).doubleValue();
double v2 = ((PrimitiveValue)rightResult).doubleValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 / v2);
@@ -149,12 +152,12 @@ class BinaryExpressionEvaluator implements Evaluator {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "/"));
}
else if (opType == JavaTokenType.PERC) {
- if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
+ if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
long v1 = ((PrimitiveValue)leftResult).longValue();
long v2 = ((PrimitiveValue)rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 % v2);
}
- if (DebuggerUtilsEx.isNumeric(leftResult) && DebuggerUtilsEx.isNumeric(rightResult)) {
+ if (DebuggerUtils.isNumeric(leftResult) && DebuggerUtils.isNumeric(rightResult)) {
double v1 = ((PrimitiveValue)leftResult).doubleValue();
double v2 = ((PrimitiveValue)rightResult).doubleValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 % v2);
@@ -167,7 +170,7 @@ class BinaryExpressionEvaluator implements Evaluator {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "%"));
}
else if (opType == JavaTokenType.LTLT) {
- if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
+ if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
final long v2 = ((PrimitiveValue)rightResult).longValue();
if (leftResult instanceof ByteValue) {
return DebuggerUtilsEx.createValue(vm, expectedType, ((ByteValue)leftResult).byteValue() << v2);
@@ -186,7 +189,7 @@ class BinaryExpressionEvaluator implements Evaluator {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "<<"));
}
else if (opType == JavaTokenType.GTGT) {
- if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
+ if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
final long v2 = ((PrimitiveValue)rightResult).longValue();
if (leftResult instanceof ByteValue) {
return DebuggerUtilsEx.createValue(vm, expectedType, ((ByteValue)leftResult).byteValue() >> v2);
@@ -205,7 +208,7 @@ class BinaryExpressionEvaluator implements Evaluator {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", ">>"));
}
else if (opType == JavaTokenType.GTGTGT) {
- if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
+ if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
final long v2 = ((PrimitiveValue)rightResult).longValue();
if (leftResult instanceof ByteValue) {
return DebuggerUtilsEx.createValue(vm, expectedType, ((ByteValue)leftResult).byteValue() >>> v2);
@@ -224,7 +227,7 @@ class BinaryExpressionEvaluator implements Evaluator {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", ">>>"));
}
else if (opType == JavaTokenType.AND) {
- if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
+ if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
long v1 = ((PrimitiveValue)leftResult).longValue();
long v2 = ((PrimitiveValue)rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 & v2);
@@ -242,7 +245,7 @@ class BinaryExpressionEvaluator implements Evaluator {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "&"));
}
else if (opType == JavaTokenType.OR) {
- if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
+ if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
long v1 = ((PrimitiveValue)leftResult).longValue();
long v2 = ((PrimitiveValue)rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 | v2);
@@ -260,7 +263,7 @@ class BinaryExpressionEvaluator implements Evaluator {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "|"));
}
else if (opType == JavaTokenType.XOR) {
- if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
+ if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
long v1 = ((PrimitiveValue)leftResult).longValue();
long v2 = ((PrimitiveValue)rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 ^ v2);
@@ -282,17 +285,17 @@ class BinaryExpressionEvaluator implements Evaluator {
return DebuggerUtilsEx.createValue(vm, expectedType, true);
}
if (leftResult == null) {
- return DebuggerUtilsEx.createValue(vm, expectedType, rightResult.equals(leftResult));
+ return DebuggerUtilsEx.createValue(vm, expectedType, rightResult.equals(null));
}
if (rightResult == null) {
- return DebuggerUtilsEx.createValue(vm, expectedType, leftResult.equals(rightResult));
+ return DebuggerUtilsEx.createValue(vm, expectedType, leftResult.equals(null));
}
- if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
+ if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
final long v1 = ((PrimitiveValue)leftResult).longValue();
final long v2 = ((PrimitiveValue)rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 == v2);
}
- if (DebuggerUtilsEx.isNumeric(leftResult) && DebuggerUtilsEx.isNumeric(rightResult)) {
+ if (DebuggerUtils.isNumeric(leftResult) && DebuggerUtils.isNumeric(rightResult)) {
double v1 = ((PrimitiveValue)leftResult).doubleValue();
double v2 = ((PrimitiveValue)rightResult).doubleValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 == v2);
@@ -332,14 +335,14 @@ class BinaryExpressionEvaluator implements Evaluator {
}
else if (opType == JavaTokenType.NE) {
if (leftResult == null && rightResult == null) return DebuggerUtilsEx.createValue(vm, expectedType, false);
- if (leftResult == null) return DebuggerUtilsEx.createValue(vm, expectedType, !rightResult.equals(leftResult));
- if (rightResult == null) return DebuggerUtilsEx.createValue(vm, expectedType, !leftResult.equals(rightResult));
- if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
+ if (leftResult == null) return DebuggerUtilsEx.createValue(vm, expectedType, !rightResult.equals(null));
+ if (rightResult == null) return DebuggerUtilsEx.createValue(vm, expectedType, !leftResult.equals(null));
+ if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
final long v1 = ((PrimitiveValue)leftResult).longValue();
final long v2 = ((PrimitiveValue)rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 != v2);
}
- if (DebuggerUtilsEx.isNumeric(leftResult) && DebuggerUtilsEx.isNumeric(rightResult)) {
+ if (DebuggerUtils.isNumeric(leftResult) && DebuggerUtils.isNumeric(rightResult)) {
double v1 = ((PrimitiveValue)leftResult).doubleValue();
double v2 = ((PrimitiveValue)rightResult).doubleValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 != v2);
@@ -362,12 +365,12 @@ class BinaryExpressionEvaluator implements Evaluator {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "!="));
}
else if (opType == JavaTokenType.LT) {
- if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
+ if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
final long v1 = ((PrimitiveValue)leftResult).longValue();
final long v2 = ((PrimitiveValue)rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 < v2);
}
- if (DebuggerUtilsEx.isNumeric(leftResult) && DebuggerUtilsEx.isNumeric(rightResult)) {
+ if (DebuggerUtils.isNumeric(leftResult) && DebuggerUtils.isNumeric(rightResult)) {
double v1 = ((PrimitiveValue)leftResult).doubleValue();
double v2 = ((PrimitiveValue)rightResult).doubleValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 < v2);
@@ -380,12 +383,12 @@ class BinaryExpressionEvaluator implements Evaluator {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "<"));
}
else if (opType == JavaTokenType.GT) {
- if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
+ if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
final long v1 = ((PrimitiveValue)leftResult).longValue();
final long v2 = ((PrimitiveValue)rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 > v2);
}
- if (DebuggerUtilsEx.isNumeric(leftResult) && DebuggerUtilsEx.isNumeric(rightResult)) {
+ if (DebuggerUtils.isNumeric(leftResult) && DebuggerUtils.isNumeric(rightResult)) {
double v1 = ((PrimitiveValue)leftResult).doubleValue();
double v2 = ((PrimitiveValue)rightResult).doubleValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 > v2);
@@ -398,12 +401,12 @@ class BinaryExpressionEvaluator implements Evaluator {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", ">"));
}
else if (opType == JavaTokenType.LE) {
- if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
+ if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
final long v1 = ((PrimitiveValue)leftResult).longValue();
final long v2 = ((PrimitiveValue)rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 <= v2);
}
- if (DebuggerUtilsEx.isNumeric(leftResult) && DebuggerUtilsEx.isNumeric(rightResult)) {
+ if (DebuggerUtils.isNumeric(leftResult) && DebuggerUtils.isNumeric(rightResult)) {
double v1 = ((PrimitiveValue)leftResult).doubleValue();
double v2 = ((PrimitiveValue)rightResult).doubleValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 <= v2);
@@ -416,12 +419,12 @@ class BinaryExpressionEvaluator implements Evaluator {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "<="));
}
else if (opType == JavaTokenType.GE) {
- if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
+ if (DebuggerUtils.isInteger(leftResult) && DebuggerUtils.isInteger(rightResult)) {
final long v1 = ((PrimitiveValue)leftResult).longValue();
final long v2 = ((PrimitiveValue)rightResult).longValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 >= v2);
}
- if (DebuggerUtilsEx.isNumeric(leftResult) && DebuggerUtilsEx.isNumeric(rightResult)) {
+ if (DebuggerUtils.isNumeric(leftResult) && DebuggerUtils.isNumeric(rightResult)) {
double v1 = ((PrimitiveValue)leftResult).doubleValue();
double v2 = ((PrimitiveValue)rightResult).doubleValue();
return DebuggerUtilsEx.createValue(vm, expectedType, v1 >= v2);
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/BlockStatementEvaluator.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/BlockStatementEvaluator.java
index 464aa6ea4f35..57b1a44bb3c5 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/BlockStatementEvaluator.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/BlockStatementEvaluator.java
@@ -28,6 +28,7 @@ public class BlockStatementEvaluator implements Evaluator {
myStatements = statements;
}
+ @Override
public Object evaluate(EvaluationContextImpl context) throws EvaluateException {
Object result = context.getSuspendContext().getDebugProcess().getVirtualMachineProxy().mirrorOf();
for (Evaluator statement : myStatements) {
@@ -36,6 +37,7 @@ public class BlockStatementEvaluator implements Evaluator {
return result;
}
+ @Override
public Modifier getModifier() {
return myStatements.length > 0 ? myStatements[myStatements.length - 1].getModifier() : null;
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ConditionalExpressionEvaluator.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ConditionalExpressionEvaluator.java
index 3514d357610b..7eacd4ace313 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ConditionalExpressionEvaluator.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ConditionalExpressionEvaluator.java
@@ -20,10 +20,10 @@
*/
package com.intellij.debugger.engine.evaluation.expression;
-import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
+import com.intellij.debugger.DebuggerBundle;
import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil;
-import com.intellij.debugger.DebuggerBundle;
+import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
import com.sun.jdi.BooleanValue;
import com.sun.jdi.Value;
@@ -38,10 +38,12 @@ class ConditionalExpressionEvaluator implements Evaluator {
myElseEvaluator = elseEvaluator;
}
+ @Override
public Modifier getModifier() {
return null;
}
+ @Override
public Object evaluate(EvaluationContextImpl context) throws EvaluateException {
Value condition = (Value)myConditionEvaluator.evaluate(context);
if (condition == null || !(condition instanceof BooleanValue)) {
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java
index ef444ea8d7ff..aa88a0bcf43a 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java
@@ -59,7 +59,7 @@ public class EvaluatorBuilderImpl implements EvaluatorBuilder {
return ourInstance;
}
- public static ExpressionEvaluator build(final TextWithImports text, final PsiElement contextElement, final SourcePosition position) throws EvaluateException {
+ public static ExpressionEvaluator build(final TextWithImports text, @Nullable PsiElement contextElement, final SourcePosition position) throws EvaluateException {
if (contextElement == null) {
throw EvaluateExceptionUtil.CANNOT_FIND_SOURCE_CLASS;
}
@@ -68,17 +68,16 @@ public class EvaluatorBuilderImpl implements EvaluatorBuilder {
CodeFragmentFactory factory = DebuggerEditorImpl.findAppropriateFactory(text, contextElement);
PsiCodeFragment codeFragment = new CodeFragmentFactoryContextWrapper(factory).createCodeFragment(text, contextElement, project);
- if(codeFragment == null) {
+ if (codeFragment == null) {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.invalid.expression", text.getText()));
}
codeFragment.forceResolveScope(GlobalSearchScope.allScope(project));
DebuggerUtils.checkSyntax(codeFragment);
- EvaluatorBuilder evaluatorBuilder = factory.getEvaluatorBuilder();
-
- return evaluatorBuilder.build(codeFragment, position);
+ return factory.getEvaluatorBuilder().build(codeFragment, position);
}
+ @Override
public ExpressionEvaluator build(final PsiElement codeFragment, final SourcePosition position) throws EvaluateException {
return new Builder(position).buildElement(codeFragment);
}
@@ -339,7 +338,7 @@ public class EvaluatorBuilderImpl implements EvaluatorBuilder {
@NotNull PsiType rType,
@NotNull IElementType operation,
@NotNull PsiType expressionExpectedType) {
- // handle unboxing if neccesary
+ // handle unboxing if necessary
if (isUnboxingInBinaryExpressionApplicable(lType, rType, operation)) {
if (rType instanceof PsiClassType && UnBoxingEvaluator.isTypeUnboxable(rType.getCanonicalText())) {
rResult = new UnBoxingEvaluator(rResult);
@@ -995,12 +994,12 @@ public class EvaluatorBuilderImpl implements EvaluatorBuilder {
/**
* Handles unboxing and numeric promotion issues for
- * - array diumention expressions
+ * - array dimension expressions
* - array index expression
* - unary +, -, and ~ operations
* @param operandExpressionType
- * @param operandEvaluator @return operandEvaluator possibly 'wrapped' with neccesary unboxing and type-casting evaluators to make returning value
- * sutable for mentioned contexts
+ * @param operandEvaluator @return operandEvaluator possibly 'wrapped' with necessary unboxing and type-casting evaluators to make returning value
+ * suitable for mentioned contexts
*/
private static Evaluator handleUnaryNumericPromotion(final PsiType operandExpressionType, Evaluator operandEvaluator) {
final PsiPrimitiveType unboxedType = PsiPrimitiveType.getUnboxedType(operandExpressionType);
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ExpressionEvaluatorImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ExpressionEvaluatorImpl.java
index 4b974c183b54..66fd0eb3971e 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ExpressionEvaluatorImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ExpressionEvaluatorImpl.java
@@ -15,11 +15,11 @@
*/
package com.intellij.debugger.engine.evaluation.expression;
+import com.intellij.debugger.DebuggerBundle;
import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil;
import com.intellij.debugger.engine.evaluation.EvaluationContext;
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
-import com.intellij.debugger.DebuggerBundle;
import com.intellij.openapi.diagnostic.Logger;
import com.sun.jdi.Value;
@@ -40,16 +40,19 @@ public class ExpressionEvaluatorImpl implements ExpressionEvaluator {
}
//call evaluate before
+ @Override
public Value getValue() {
return myValue;
}
//call evaluate before
+ @Override
public Modifier getModifier() {
return myEvaluator.getModifier();
}
// EvaluationContextImpl should be at the same stackFrame as it was in the call to EvaluatorBuilderImpl.build
+ @Override
public Value evaluate(final EvaluationContext context) throws EvaluateException {
if (!context.getDebugProcess().isAttached()) {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("error.vm.disconnected"));
@@ -61,22 +64,24 @@ public class ExpressionEvaluatorImpl implements ExpressionEvaluator {
Object value = myEvaluator.evaluate((EvaluationContextImpl)context);
- if(value != null && !(value instanceof Value)) {
+ if (value != null && !(value instanceof Value)) {
throw EvaluateExceptionUtil
.createEvaluateException(DebuggerBundle.message("evaluation.error.invalid.expression", ""));
}
- myValue = (Value) value;
+ myValue = (Value)value;
return myValue;
}
catch (Throwable/*IncompatibleThreadStateException*/ e) {
if (LOG.isDebugEnabled()) {
LOG.debug(e);
}
- if(e instanceof EvaluateException)
+ if (e instanceof EvaluateException) {
throw ((EvaluateException)e);
- else
+ }
+ else {
throw EvaluateExceptionUtil.createEvaluateException(e);
+ }
}
}
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/LocalVariableEvaluator.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/LocalVariableEvaluator.java
index ce060c0bfd26..b02ec96fad31 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/LocalVariableEvaluator.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/LocalVariableEvaluator.java
@@ -53,6 +53,7 @@ class LocalVariableEvaluator implements Evaluator {
myParameterIndex = parameterIndex;
}
+ @Override
public Object evaluate(EvaluationContextImpl context) throws EvaluateException {
StackFrameProxyImpl frameProxy = context.getFrameProxy();
if (frameProxy == null) {
@@ -109,37 +110,45 @@ class LocalVariableEvaluator implements Evaluator {
}
}
+ @Override
public Modifier getModifier() {
Modifier modifier = null;
if (myEvaluatedVariable != null && myContext != null) {
modifier = new Modifier() {
+ @Override
public boolean canInspect() {
return true;
}
+ @Override
public boolean canSetValue() {
return true;
}
+ @Override
public void setValue(Value value) throws ClassNotLoadedException, InvalidTypeException {
StackFrameProxyImpl frameProxy = myContext.getFrameProxy();
try {
+ assert frameProxy != null;
frameProxy.setValue(myEvaluatedVariable, value);
}
catch (EvaluateException e) {
- LOG.error(e);
+ LOG.error(e);
}
}
+ @Override
public Type getExpectedType() throws ClassNotLoadedException {
try {
return myEvaluatedVariable.getType();
- } catch (EvaluateException e) {
+ }
+ catch (EvaluateException e) {
LOG.error(e);
return null;
}
}
+ @Override
public NodeDescriptorImpl getInspectItem(Project project) {
return new LocalVariableDescriptorImpl(project, myEvaluatedVariable);
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/MethodEvaluator.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/MethodEvaluator.java
index a4f9a8d55d48..ed1ad4c2ab46 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/MethodEvaluator.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/MethodEvaluator.java
@@ -22,6 +22,7 @@ package com.intellij.debugger.engine.evaluation.expression;
import com.intellij.debugger.DebuggerBundle;
import com.intellij.debugger.engine.DebugProcessImpl;
+import com.intellij.debugger.engine.DebuggerUtils;
import com.intellij.debugger.engine.JVMName;
import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil;
@@ -53,10 +54,12 @@ public class MethodEvaluator implements Evaluator {
myArgumentEvaluators = argumentEvaluators;
}
+ @Override
public Modifier getModifier() {
return null;
}
+ @Override
public Object evaluate(EvaluationContextImpl context) throws EvaluateException {
if(!context.getDebugProcess().isAttached()) return null;
DebugProcessImpl debugProcess = context.getDebugProcess();
@@ -126,7 +129,7 @@ public class MethodEvaluator implements Evaluator {
if (requiresSuperObject && (referenceType instanceof ClassType)) {
_refType = ((ClassType)referenceType).superclass();
}
- final Method jdiMethod = DebuggerUtilsEx.findMethod(_refType, myMethodName, signature);
+ final Method jdiMethod = DebuggerUtils.findMethod(_refType, myMethodName, signature);
if (jdiMethod == null) {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.no.instance.method", methodName));
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/events/DebuggerCommandImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/events/DebuggerCommandImpl.java
index 038ff6db1b2a..3bfedcecfafe 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/events/DebuggerCommandImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/events/DebuggerCommandImpl.java
@@ -26,6 +26,7 @@ public abstract class DebuggerCommandImpl extends DebuggerTaskImpl {
protected void commandCancelled() {
}
+ @Override
public Priority getPriority() {
return Priority.LOW;
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/events/DebuggerContextCommandImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/events/DebuggerContextCommandImpl.java
index aaf363184e93..e53e92f5d6b8 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/events/DebuggerContextCommandImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/events/DebuggerContextCommandImpl.java
@@ -22,14 +22,16 @@ import com.intellij.debugger.impl.DebuggerContextImpl;
import com.intellij.debugger.jdi.ThreadReferenceProxyImpl;
import com.intellij.openapi.diagnostic.Logger;
import com.sun.jdi.ObjectCollectedException;
+import org.jetbrains.annotations.NotNull;
public abstract class DebuggerContextCommandImpl extends SuspendContextCommandImpl {
- private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.engine.events.DebuggerContextCommandImpl");
+ private static final Logger LOG = Logger.getInstance(DebuggerContextCommandImpl.class);
private final DebuggerContextImpl myDebuggerContext;
- protected DebuggerContextCommandImpl(DebuggerContextImpl debuggerContext) {
+ protected DebuggerContextCommandImpl(@NotNull DebuggerContextImpl debuggerContext) {
super(debuggerContext.getSuspendContext());
+
myDebuggerContext = debuggerContext;
}
@@ -37,15 +39,15 @@ public abstract class DebuggerContextCommandImpl extends SuspendContextCommandIm
return myDebuggerContext;
}
+ @Override
public final void contextAction() throws Exception {
final SuspendManager suspendManager = myDebuggerContext.getDebugProcess().getSuspendManager();
-
final ThreadReferenceProxyImpl debuggerContextThread = myDebuggerContext.getThreadProxy();
final boolean isSuspendedByContext;
try {
isSuspendedByContext = suspendManager.isSuspended(debuggerContextThread);
}
- catch (ObjectCollectedException e) {
+ catch (ObjectCollectedException ignored) {
notifyCancelled();
return;
}
@@ -59,7 +61,7 @@ public abstract class DebuggerContextCommandImpl extends SuspendContextCommandIm
else {
// there are no suspend context currently registered
SuspendContextImpl suspendContextForThread = SuspendManagerUtil.findContextByThread(suspendManager, debuggerContextThread);
- if(suspendContextForThread != null) {
+ if (suspendContextForThread != null) {
suspendContextForThread.postponeCommand(this);
}
else {
@@ -68,5 +70,5 @@ public abstract class DebuggerContextCommandImpl extends SuspendContextCommandIm
}
}
- abstract public void threadAction ();
+ abstract public void threadAction();
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/events/SuspendContextCommandImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/events/SuspendContextCommandImpl.java
index 739c96270cca..e3bdc6703859 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/events/SuspendContextCommandImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/events/SuspendContextCommandImpl.java
@@ -17,33 +17,32 @@ package com.intellij.debugger.engine.events;
import com.intellij.debugger.engine.DebuggerManagerThreadImpl;
import com.intellij.debugger.engine.SuspendContextImpl;
+import com.intellij.debugger.engine.managerThread.SuspendContextCommand;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.util.containers.Stack;
+import org.jetbrains.annotations.Nullable;
/**
- * Created by IntelliJ IDEA.
- * User: lex
- * Date: Feb 24, 2004
- * Time: 7:01:31 PM
* Performs contextAction when evaluation is available in suspend context
*/
public abstract class SuspendContextCommandImpl extends DebuggerCommandImpl {
- private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.engine.SuspendContextCommand");
+ private static final Logger LOG = Logger.getInstance(SuspendContextCommand.class);
+
private final SuspendContextImpl mySuspendContext;
- protected SuspendContextCommandImpl(SuspendContextImpl suspendContext) {
+ protected SuspendContextCommandImpl(@Nullable SuspendContextImpl suspendContext) {
mySuspendContext = suspendContext;
}
public abstract void contextAction() throws Exception;
+ @Override
public final void action() throws Exception {
- if(LOG.isDebugEnabled()) {
+ if (LOG.isDebugEnabled()) {
LOG.debug("trying " + this);
}
final SuspendContextImpl suspendContext = getSuspendContext();
-
if (suspendContext == null) {
if (LOG.isDebugEnabled()) {
LOG.debug("skip processing - context is null " + this);
@@ -52,12 +51,12 @@ public abstract class SuspendContextCommandImpl extends DebuggerCommandImpl {
return;
}
- if(suspendContext.myInProgress) {
+ if (suspendContext.myInProgress) {
suspendContext.postponeCommand(this);
}
else {
try {
- if(!suspendContext.isResumed()) {
+ if (!suspendContext.isResumed()) {
suspendContext.myInProgress = true;
contextAction();
}
@@ -65,7 +64,7 @@ public abstract class SuspendContextCommandImpl extends DebuggerCommandImpl {
notifyCancelled();
}
}
- finally{
+ finally {
suspendContext.myInProgress = false;
if (suspendContext.isResumed()) {
for (SuspendContextCommandImpl postponed = suspendContext.pollPostponedCommand(); postponed != null; postponed = suspendContext.pollPostponedCommand()) {
@@ -90,6 +89,7 @@ public abstract class SuspendContextCommandImpl extends DebuggerCommandImpl {
}
}
+ @Nullable
public SuspendContextImpl getSuspendContext() {
return mySuspendContext;
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerContextImpl.java b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerContextImpl.java
index 640f76cad628..6c3568c29347 100644
--- a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerContextImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerContextImpl.java
@@ -47,16 +47,23 @@ public final class DebuggerContextImpl implements DebuggerContext {
private boolean myInitialized;
@Nullable
- private final DebuggerSession myDebuggerSession;
- private final DebugProcessImpl myDebugProcess;
- private final SuspendContextImpl mySuspendContext;
+ private final DebuggerSession myDebuggerSession;
+ private final DebugProcessImpl myDebugProcess;
+ private final SuspendContextImpl mySuspendContext;
private final ThreadReferenceProxyImpl myThreadProxy;
- private StackFrameProxyImpl myFrameProxy;
- private SourcePosition mySourcePosition;
- private PsiElement myContextElement;
-
- private DebuggerContextImpl(@Nullable DebuggerSession session, DebugProcessImpl debugProcess, SuspendContextImpl context, ThreadReferenceProxyImpl threadProxy, StackFrameProxyImpl frameProxy, SourcePosition position, PsiElement contextElement, boolean initialized) {
+ private StackFrameProxyImpl myFrameProxy;
+ private SourcePosition mySourcePosition;
+ private PsiElement myContextElement;
+
+ private DebuggerContextImpl(@Nullable DebuggerSession session,
+ @Nullable DebugProcessImpl debugProcess,
+ @Nullable SuspendContextImpl context,
+ ThreadReferenceProxyImpl threadProxy,
+ StackFrameProxyImpl frameProxy,
+ SourcePosition position,
+ PsiElement contextElement,
+ boolean initialized) {
LOG.assertTrue(frameProxy == null || threadProxy == null || threadProxy == frameProxy.threadProxy());
LOG.assertTrue(debugProcess != null || frameProxy == null && threadProxy == null);
myDebuggerSession = session;
@@ -74,6 +81,7 @@ public final class DebuggerContextImpl implements DebuggerContext {
return myDebuggerSession;
}
+ @Nullable
@Override
public DebugProcessImpl getDebugProcess() {
return myDebugProcess;
@@ -133,7 +141,10 @@ public final class DebuggerContextImpl implements DebuggerContext {
return new EvaluationContextImpl(getSuspendContext(), frameProxy, objectReference);
}
- public static DebuggerContextImpl createDebuggerContext(DebuggerSession session, SuspendContextImpl context, ThreadReferenceProxyImpl threadProxy, StackFrameProxyImpl frameProxy) {
+ public static DebuggerContextImpl createDebuggerContext(@Nullable DebuggerSession session,
+ @Nullable SuspendContextImpl context,
+ ThreadReferenceProxyImpl threadProxy,
+ StackFrameProxyImpl frameProxy) {
LOG.assertTrue(frameProxy == null || threadProxy == null || threadProxy == frameProxy.threadProxy());
LOG.assertTrue(session == null || session.getProcess() != null);
return new DebuggerContextImpl(session, session != null ? session.getProcess() : null, context, threadProxy, frameProxy, null, null, context == null);
@@ -153,7 +164,7 @@ public final class DebuggerContextImpl implements DebuggerContext {
}
}
- if(myFrameProxy != null) {
+ if (myFrameProxy != null) {
PsiDocumentManager.getInstance(getProject()).commitAndRunReadAction(new Runnable() {
@Override
public void run() {
diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerManagerImpl.java b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerManagerImpl.java
index c60a3b220906..f5404cd65023 100644
--- a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerManagerImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerManagerImpl.java
@@ -81,6 +81,7 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
private final MyDebuggerStateManager myDebuggerStateManager = new MyDebuggerStateManager();
private final DebuggerContextListener mySessionListener = new DebuggerContextListener() {
+ @Override
public void changeEvent(DebuggerContextImpl newContext, int event) {
final DebuggerSession session = newContext.getDebuggerSession();
@@ -110,14 +111,17 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
};
@NonNls private static final String DEBUG_KEY_NAME = "idea.xdebug.key";
+ @Override
public void addClassNameMapper(final NameMapper mapper) {
myNameMappers.add(mapper);
}
+ @Override
public void removeClassNameMapper(final NameMapper mapper) {
myNameMappers.remove(mapper);
}
+ @Override
public String getVMClassQualifiedName(@NotNull final PsiClass aClass) {
for (NameMapper nameMapper : myNameMappers) {
final String qName = nameMapper.getQualifiedName(aClass);
@@ -128,10 +132,12 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
return aClass.getQualifiedName();
}
+ @Override
public void addDebuggerManagerListener(DebuggerManagerListener listener) {
myDispatcher.addListener(listener);
}
+ @Override
public void removeDebuggerManagerListener(DebuggerManagerListener listener) {
myDispatcher.removeListener(listener);
}
@@ -141,6 +147,7 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
myBreakpointManager = new BreakpointManager(myProject, startupManager, this);
if (!project.isDefault()) {
colorsManager.addEditorColorsListener(new EditorColorsListener() {
+ @Override
public void globalSchemeChange(EditorColorsScheme scheme) {
getBreakpointManager().updateBreakpointsUI();
}
@@ -148,6 +155,7 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
}
}
+ @Override
public DebuggerSession getSession(DebugProcess process) {
ApplicationManager.getApplication().assertIsDispatchThread();
for (final DebuggerSession debuggerSession : getSessions()) {
@@ -156,6 +164,7 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
return null;
}
+ @Override
public Collection<DebuggerSession> getSessions() {
synchronized (mySessions) {
final Collection<DebuggerSession> values = mySessions.values();
@@ -163,15 +172,19 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
}
}
+ @Override
public void disposeComponent() {
}
+ @Override
public void initComponent() {
}
+ @Override
public void projectClosed() {
}
+ @Override
public void projectOpened() {
myBreakpointManager.init();
}
@@ -193,6 +206,7 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
myBreakpointManager.writeExternal(element);
}
+ @Override
public DebuggerSession attachVirtualMachine(Executor executor,
ProgramRunner runner,
ModuleRunProfile profile,
@@ -209,10 +223,12 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
pollConnection));
}
+ @Override
public DebuggerSession attachVirtualMachine(DebugEnvironment environment) throws ExecutionException {
ApplicationManager.getApplication().assertIsDispatchThread();
final DebugProcessEvents debugProcess = new DebugProcessEvents(myProject);
debugProcess.addDebugProcessListener(new DebugProcessAdapter() {
+ @Override
public void processAttached(final DebugProcess process) {
process.removeDebugProcessListener(this);
for (Function<DebugProcess, PositionManager> factory : myCustomPositionManagerFactories) {
@@ -229,10 +245,12 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
}
}
+ @Override
public void processDetached(final DebugProcess process, final boolean closedByUser) {
debugProcess.removeDebugProcessListener(this);
}
+ @Override
public void attachException(final RunProfileState state,
final ExecutionException exception,
final RemoteConnection remoteConnection) {
@@ -263,6 +281,7 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
// RemoteProcessHandler on the other hand will call debugProcess.stop() as a part of destroyProcess() and detachProcess() implementation,
// so we shouldn't add the listener to avoid calling stop() twice
processHandler.addProcessListener(new ProcessAdapter() {
+ @Override
public void processWillTerminate(ProcessEvent event, boolean willBeDestroyed) {
final DebugProcessImpl debugProcess = getDebugProcess(event.getProcessHandler());
if (debugProcess != null) {
@@ -283,6 +302,7 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
}
+ @Override
public DebugProcessImpl getDebugProcess(final ProcessHandler processHandler) {
synchronized (mySessions) {
DebuggerSession session = mySessions.get(processHandler);
@@ -298,6 +318,7 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
}
}
+ @Override
public void addDebugProcessListener(final ProcessHandler processHandler, final DebugProcessListener listener) {
DebugProcessImpl debugProcess = getDebugProcess(processHandler);
if (debugProcess != null) {
@@ -305,6 +326,7 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
}
else {
processHandler.addProcessListener(new ProcessAdapter() {
+ @Override
public void startNotified(ProcessEvent event) {
DebugProcessImpl debugProcess = getDebugProcess(processHandler);
if (debugProcess != null) {
@@ -316,6 +338,7 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
}
}
+ @Override
public void removeDebugProcessListener(final ProcessHandler processHandler, final DebugProcessListener listener) {
DebugProcessImpl debugProcess = getDebugProcess(processHandler);
if (debugProcess != null) {
@@ -323,6 +346,7 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
}
else {
processHandler.addProcessListener(new ProcessAdapter() {
+ @Override
public void startNotified(ProcessEvent event) {
DebugProcessImpl debugProcess = getDebugProcess(processHandler);
if (debugProcess != null) {
@@ -334,31 +358,38 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
}
}
+ @Override
public boolean isDebuggerManagerThread() {
return DebuggerManagerThreadImpl.isManagerThread();
}
+ @Override
@NotNull
public String getComponentName() {
return "DebuggerManager";
}
+ @Override
public BreakpointManager getBreakpointManager() {
return myBreakpointManager;
}
+ @Override
public DebuggerContextImpl getContext() {
return getContextManager().getContext();
}
+ @Override
public DebuggerStateManager getContextManager() {
return myDebuggerStateManager;
}
+ @Override
public void registerPositionManagerFactory(final Function<DebugProcess, PositionManager> factory) {
myCustomPositionManagerFactories.add(factory);
}
+ @Override
public void unregisterPositionManagerFactory(final Function<DebugProcess, PositionManager> factory) {
myCustomPositionManagerFactories.remove(factory);
}
@@ -473,6 +504,7 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
final String _debuggeeRunProperties = debuggeeRunProperties;
ApplicationManager.getApplication().runReadAction(new Runnable() {
+ @Override
@SuppressWarnings({"HardCodedStringLiteral"})
public void run() {
JavaSdkUtil.addRtJar(parameters.getClassPath());
@@ -575,10 +607,12 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
private static class MyDebuggerStateManager extends DebuggerStateManager {
private DebuggerSession myDebuggerSession;
+ @Override
public DebuggerContextImpl getContext() {
return myDebuggerSession == null ? DebuggerContextImpl.EMPTY_CONTEXT : myDebuggerSession.getContextManager().getContext();
}
+ @Override
public void setState(final DebuggerContextImpl context, int state, int event, String description) {
ApplicationManager.getApplication().assertIsDispatchThread();
myDebuggerSession = context.getDebuggerSession();
diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerUtilsEx.java b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerUtilsEx.java
index aa2b4793ec42..f68436fbda52 100644
--- a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerUtilsEx.java
+++ b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerUtilsEx.java
@@ -60,20 +60,20 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils {
/**
* @param context
- * @return all CodeFragmentFactoryProviders that provide code fragment factories sutable in the context given
+ * @return all CodeFragmentFactoryProviders that provide code fragment factories suitable in the context given
*/
public static List<CodeFragmentFactory> getCodeFragmentFactories(@Nullable PsiElement context) {
- final DefaultCodeFragmentFactory defaultFactry = DefaultCodeFragmentFactory.getInstance();
+ final DefaultCodeFragmentFactory defaultFactory = DefaultCodeFragmentFactory.getInstance();
final CodeFragmentFactory[] providers = ApplicationManager.getApplication().getExtensions(CodeFragmentFactory.EXTENSION_POINT_NAME);
final List<CodeFragmentFactory> suitableFactories = new ArrayList<CodeFragmentFactory>(providers.length);
if (providers.length > 0) {
for (CodeFragmentFactory factory : providers) {
- if (factory != defaultFactry && factory.isContextAccepted(context)) {
+ if (factory != defaultFactory && factory.isContextAccepted(context)) {
suitableFactories.add(factory);
}
}
}
- suitableFactories.add(defaultFactry); // let default factory be the last one
+ suitableFactories.add(defaultFactory); // let default factory be the last one
return suitableFactories;
}
@@ -122,9 +122,8 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils {
return superClass;
}
}
- List<InterfaceType> ifaces = classType.allInterfaces();
- for (Iterator<InterfaceType> it = ifaces.iterator(); it.hasNext();) {
- InterfaceType iface = it.next();
+ List<InterfaceType> interfaces = classType.allInterfaces();
+ for (InterfaceType iface : interfaces) {
ReferenceType superClass = getSuperClass(baseQualifiedName, iface);
if (superClass != null) {
return superClass;
@@ -134,8 +133,7 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils {
if (checkedType instanceof InterfaceType) {
List<InterfaceType> list = ((InterfaceType)checkedType).superinterfaces();
- for (Iterator<InterfaceType> it = list.iterator(); it.hasNext();) {
- InterfaceType superInterface = it.next();
+ for (InterfaceType superInterface : list) {
ReferenceType superClass = getSuperClass(baseQualifiedName, superInterface);
if (superClass != null) {
return superClass;
@@ -246,9 +244,9 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils {
return ClassFilter.EMPTY_ARRAY;
}
List<ClassFilter> classFiltersList = new ArrayList<ClassFilter>(children.size());
- for (Iterator i = children.iterator(); i.hasNext();) {
+ for (Object aChildren : children) {
final ClassFilter classFilter = new ClassFilter();
- classFilter.readExternal((Element)i.next());
+ classFilter.readExternal((Element)aChildren);
classFiltersList.add(classFilter);
}
return classFiltersList.toArray(new ClassFilter[classFiltersList.size()]);
@@ -268,12 +266,8 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils {
}
final Set<ClassFilter> f1 = new HashSet<ClassFilter>(Math.max((int) (filters1.length/.75f) + 1, 16));
final Set<ClassFilter> f2 = new HashSet<ClassFilter>(Math.max((int) (filters2.length/.75f) + 1, 16));
- for (ClassFilter filter : filters1) {
- f1.add(filter);
- }
- for (ClassFilter aFilters2 : filters2) {
- f2.add(aFilters2);
- }
+ Collections.addAll(f1, filters1);
+ Collections.addAll(f2, filters2);
return f2.equals(f1);
}
@@ -284,13 +278,11 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils {
if(l1.size() != l2.size()) return false;
Iterator<Element> i1 = l1.iterator();
- Iterator<Element> i2 = l2.iterator();
- while (i2.hasNext()) {
+ for (Element aL2 : l2) {
Element elem1 = i1.next();
- Element elem2 = i2.next();
- if(!elementsEqual(elem1, elem2)) return false;
+ if (!elementsEqual(elem1, aL2)) return false;
}
return true;
}
@@ -302,13 +294,11 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils {
if(l1.size() != l2.size()) return false;
Iterator<Attribute> i1 = l1.iterator();
- Iterator<Attribute> i2 = l2.iterator();
- while (i2.hasNext()) {
+ for (Attribute aL2 : l2) {
Attribute attr1 = i1.next();
- Attribute attr2 = i2.next();
- if (!Comparing.equal(attr1.getName(), attr2.getName()) || !Comparing.equal(attr1.getValue(), attr2.getValue())) {
+ if (!Comparing.equal(attr1.getName(), aL2.getName()) || !Comparing.equal(attr1.getValue(), aL2.getValue())) {
return false;
}
}
@@ -322,10 +312,10 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils {
if (!Comparing.equal(e1.getName(), e2.getName())) {
return false;
}
- if (!elementListsEqual ((List<Element>)e1.getChildren(), (List<Element>)e2.getChildren())) {
+ if (!elementListsEqual (e1.getChildren(), e2.getChildren())) {
return false;
}
- if (!attributeListsEqual((List<Attribute>)e1.getAttributes(), (List<Attribute>)e2.getAttributes())) {
+ if (!attributeListsEqual(e1.getAttributes(), e2.getAttributes())) {
return false;
}
return true;
@@ -410,6 +400,7 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils {
@Nullable
public static CodeFragmentFactory getEffectiveCodeFragmentFactory(final PsiElement psiContext) {
final CodeFragmentFactory factory = ApplicationManager.getApplication().runReadAction(new Computable<CodeFragmentFactory>() {
+ @Override
public CodeFragmentFactory compute() {
final List<CodeFragmentFactory> codeFragmentFactories = getCodeFragmentFactories(psiContext);
// the list always contains at least DefaultCodeFragmentFactory
@@ -469,7 +460,7 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils {
case '[':
return getSignature() + "[]";
case '(':
- StringBuffer result = new StringBuffer("(");
+ StringBuilder result = new StringBuilder("(");
String separator = "";
while (peek() != ')') {
result.append(separator);
@@ -501,16 +492,18 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils {
public static String methodName(final String className, final String methodName, final String signature) {
try {
return new SigReader(signature) {
+ @Override
String getMethodName() {
return methodName;
}
+ @Override
String getClassName() {
return className;
}
}.getSignature();
}
- catch (Exception e) {
+ catch (Exception ignored) {
if (LOG.isDebugEnabled()) {
LOG.debug("Internal error : unknown signature" + signature);
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/InvokeThread.java b/java/debugger/impl/src/com/intellij/debugger/impl/InvokeThread.java
index 8e782c5ac0a0..72f9abf97af3 100644
--- a/java/debugger/impl/src/com/intellij/debugger/impl/InvokeThread.java
+++ b/java/debugger/impl/src/com/intellij/debugger/impl/InvokeThread.java
@@ -39,6 +39,7 @@ public abstract class InvokeThread<E extends PrioritizedTask> {
myOwner = owner;
}
+ @Override
public void run() {
synchronized (this) {
while (myRequestFuture == null) {
@@ -144,10 +145,10 @@ public abstract class InvokeThread<E extends PrioritizedTask> {
processEvent(myEvents.get());
}
- catch (VMDisconnectedException e) {
+ catch (VMDisconnectedException ignored) {
break;
}
- catch (EventQueueClosedException e) {
+ catch (EventQueueClosedException ignored) {
break;
}
catch (RuntimeException e) {
@@ -174,7 +175,7 @@ public abstract class InvokeThread<E extends PrioritizedTask> {
}
if (LOG.isDebugEnabled()) {
- LOG.debug("Request " + this.toString() + " exited");
+ LOG.debug("Request " + toString() + " exited");
}
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/SimpleStackFrameContext.java b/java/debugger/impl/src/com/intellij/debugger/impl/SimpleStackFrameContext.java
index 207c5be2742a..528af2307105 100644
--- a/java/debugger/impl/src/com/intellij/debugger/impl/SimpleStackFrameContext.java
+++ b/java/debugger/impl/src/com/intellij/debugger/impl/SimpleStackFrameContext.java
@@ -15,9 +15,10 @@
*/
package com.intellij.debugger.impl;
-import com.intellij.debugger.engine.StackFrameContext;
import com.intellij.debugger.engine.DebugProcess;
+import com.intellij.debugger.engine.StackFrameContext;
import com.intellij.debugger.engine.jdi.StackFrameProxy;
+import org.jetbrains.annotations.NotNull;
/**
* @author Eugene Zhuravlev
@@ -32,10 +33,13 @@ public final class SimpleStackFrameContext implements StackFrameContext{
myProcess = process;
}
+ @Override
public StackFrameProxy getFrameProxy() {
return myProxy;
}
+ @Override
+ @NotNull
public DebugProcess getDebugProcess() {
return myProcess;
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/ArgValueData.java b/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/ArgValueData.java
index 3595167f297d..de291e781f5c 100644
--- a/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/ArgValueData.java
+++ b/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/ArgValueData.java
@@ -18,6 +18,7 @@ package com.intellij.debugger.impl.descriptors.data;
import com.intellij.debugger.ui.impl.watch.ArgumentValueDescriptorImpl;
import com.intellij.openapi.project.Project;
import com.sun.jdi.Value;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class ArgValueData extends DescriptorData<ArgumentValueDescriptorImpl>{
@@ -33,7 +34,7 @@ public class ArgValueData extends DescriptorData<ArgumentValueDescriptorImpl>{
myDisplayName = displayName;
}
- protected ArgumentValueDescriptorImpl createDescriptorImpl(Project project) {
+ protected ArgumentValueDescriptorImpl createDescriptorImpl(@NotNull Project project) {
return new ArgumentValueDescriptorImpl(project, myIndex, myValue, myDisplayName);
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/ArrayItemData.java b/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/ArrayItemData.java
index 7973da61baef..5fc1d293b91a 100644
--- a/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/ArrayItemData.java
+++ b/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/ArrayItemData.java
@@ -36,7 +36,7 @@ public final class ArrayItemData extends DescriptorData<ArrayElementDescriptorIm
myIndex = idx;
}
- protected ArrayElementDescriptorImpl createDescriptorImpl(Project project) {
+ protected ArrayElementDescriptorImpl createDescriptorImpl(@NotNull Project project) {
return new ArrayElementDescriptorImpl(project, myArray, myIndex);
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/DescriptorData.java b/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/DescriptorData.java
index 41f918140896..3332fba80f35 100644
--- a/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/DescriptorData.java
+++ b/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/DescriptorData.java
@@ -18,6 +18,7 @@ package com.intellij.debugger.impl.descriptors.data;
import com.intellij.debugger.ui.tree.NodeDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
+import org.jetbrains.annotations.NotNull;
public abstract class DescriptorData <T extends NodeDescriptor> implements DescriptorKey<T>{
private static final Key DESCRIPTOR_DATA = new Key("DESCRIPTOR_DATA");
@@ -25,13 +26,13 @@ public abstract class DescriptorData <T extends NodeDescriptor> implements Descr
protected DescriptorData() {
}
- public T createDescriptor(Project project) {
+ public T createDescriptor(@NotNull Project project) {
T descriptor = createDescriptorImpl(project);
descriptor.putUserData(DESCRIPTOR_DATA, this);
return descriptor;
}
- protected abstract T createDescriptorImpl(Project project);
+ protected abstract T createDescriptorImpl(@NotNull Project project);
public abstract boolean equals(Object object);
diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/FieldData.java b/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/FieldData.java
index 8392489d8f83..d6b863ca74a0 100644
--- a/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/FieldData.java
+++ b/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/FieldData.java
@@ -30,7 +30,7 @@ public final class FieldData extends DescriptorData<FieldDescriptorImpl>{
myField = field;
}
- protected FieldDescriptorImpl createDescriptorImpl(Project project) {
+ protected FieldDescriptorImpl createDescriptorImpl(@NotNull Project project) {
return new FieldDescriptorImpl(project, myObjRef, myField);
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/LocalData.java b/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/LocalData.java
index 3e401a0dc052..576717649d9d 100644
--- a/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/LocalData.java
+++ b/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/LocalData.java
@@ -19,6 +19,7 @@ import com.intellij.debugger.jdi.LocalVariableProxyImpl;
import com.intellij.debugger.ui.impl.watch.LocalVariableDescriptorImpl;
import com.intellij.openapi.project.Project;
import com.intellij.util.StringBuilderSpinAllocator;
+import org.jetbrains.annotations.NotNull;
public class LocalData extends DescriptorData<LocalVariableDescriptorImpl>{
private final LocalVariableProxyImpl myLocalVariable;
@@ -28,7 +29,7 @@ public class LocalData extends DescriptorData<LocalVariableDescriptorImpl>{
myLocalVariable = localVariable;
}
- protected LocalVariableDescriptorImpl createDescriptorImpl(Project project) {
+ protected LocalVariableDescriptorImpl createDescriptorImpl(@NotNull Project project) {
return new LocalVariableDescriptorImpl(project, myLocalVariable);
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/MethodReturnValueData.java b/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/MethodReturnValueData.java
index 1139b2f96d01..f0ffbd751995 100644
--- a/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/MethodReturnValueData.java
+++ b/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/MethodReturnValueData.java
@@ -41,7 +41,7 @@ public final class MethodReturnValueData extends DescriptorData<MethodReturnValu
return myMethod;
}
- protected MethodReturnValueDescriptorImpl createDescriptorImpl(Project project) {
+ protected MethodReturnValueDescriptorImpl createDescriptorImpl(@NotNull Project project) {
return new MethodReturnValueDescriptorImpl(project, myMethod, myReturnValue);
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/StackFrameData.java b/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/StackFrameData.java
index 6dc840042a9a..dd1619ea2c70 100644
--- a/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/StackFrameData.java
+++ b/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/StackFrameData.java
@@ -21,27 +21,30 @@ import com.intellij.debugger.ui.impl.watch.NodeManagerImpl;
import com.intellij.debugger.ui.impl.watch.StackFrameDescriptorImpl;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Comparing;
+import org.jetbrains.annotations.NotNull;
public class StackFrameData extends DescriptorData<StackFrameDescriptorImpl>{
private final StackFrameProxyImpl myFrame;
private final FrameDisplayKey myDisplayKey;
private final MethodsTracker myMethodsTracker;
- public StackFrameData(StackFrameProxyImpl frame) {
+ public StackFrameData(@NotNull StackFrameProxyImpl frame) {
super();
+
myFrame = frame;
myDisplayKey = new FrameDisplayKey(NodeManagerImpl.getContextKeyForFrame(frame));
myMethodsTracker = new MethodsTracker();
-
}
- protected StackFrameDescriptorImpl createDescriptorImpl(Project project) {
+ @Override
+ protected StackFrameDescriptorImpl createDescriptorImpl(@NotNull Project project) {
return new StackFrameDescriptorImpl(myFrame, myMethodsTracker);
}
public boolean equals(Object object) {
- if(!(object instanceof StackFrameData)) return false;
-
+ if (!(object instanceof StackFrameData)) {
+ return false;
+ }
return ((StackFrameData)object).myFrame == myFrame;
}
@@ -49,6 +52,7 @@ public class StackFrameData extends DescriptorData<StackFrameDescriptorImpl>{
return myFrame.hashCode();
}
+ @Override
public DisplayKey<StackFrameDescriptorImpl> getDisplayKey() {
return myDisplayKey;
}
@@ -74,6 +78,5 @@ public class StackFrameData extends DescriptorData<StackFrameDescriptorImpl>{
public int hashCode() {
return myContextKey == null? 0 : myContextKey.hashCode();
}
- }
-
+ }
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/StaticData.java b/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/StaticData.java
index 178954b54a8d..327279e27513 100644
--- a/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/StaticData.java
+++ b/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/StaticData.java
@@ -34,7 +34,7 @@ public final class StaticData extends DescriptorData<StaticDescriptorImpl>{
return myRefType;
}
- protected StaticDescriptorImpl createDescriptorImpl(Project project) {
+ protected StaticDescriptorImpl createDescriptorImpl(@NotNull Project project) {
return new StaticDescriptorImpl(myRefType);
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/StaticFieldData.java b/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/StaticFieldData.java
index adfbd3a6314a..156d6647b65f 100644
--- a/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/StaticFieldData.java
+++ b/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/StaticFieldData.java
@@ -27,7 +27,7 @@ public final class StaticFieldData extends DescriptorData<FieldDescriptorImpl>{
myField = field;
}
- protected FieldDescriptorImpl createDescriptorImpl(Project project) {
+ protected FieldDescriptorImpl createDescriptorImpl(@NotNull Project project) {
return new FieldDescriptorImpl(project, null, myField);
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/ThisData.java b/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/ThisData.java
index 9a7afd6ec4b6..43648960b75a 100644
--- a/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/ThisData.java
+++ b/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/ThisData.java
@@ -18,12 +18,13 @@ package com.intellij.debugger.impl.descriptors.data;
import com.intellij.debugger.ui.impl.watch.ThisDescriptorImpl;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
+import org.jetbrains.annotations.NotNull;
public final class ThisData extends DescriptorData<ThisDescriptorImpl>{
private static final Key THIS = new Key("THIS");
- protected ThisDescriptorImpl createDescriptorImpl(Project project) {
+ protected ThisDescriptorImpl createDescriptorImpl(@NotNull Project project) {
return new ThisDescriptorImpl(project);
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/ThreadData.java b/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/ThreadData.java
index 543ce5327d53..2d1da9aef60c 100644
--- a/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/ThreadData.java
+++ b/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/ThreadData.java
@@ -18,6 +18,7 @@ package com.intellij.debugger.impl.descriptors.data;
import com.intellij.debugger.jdi.ThreadReferenceProxyImpl;
import com.intellij.debugger.ui.impl.watch.ThreadDescriptorImpl;
import com.intellij.openapi.project.Project;
+import org.jetbrains.annotations.NotNull;
public class ThreadData extends DescriptorData<ThreadDescriptorImpl> {
private final ThreadReferenceProxyImpl myThread;
@@ -26,7 +27,7 @@ public class ThreadData extends DescriptorData<ThreadDescriptorImpl> {
myThread = thread;
}
- protected ThreadDescriptorImpl createDescriptorImpl(Project project) {
+ protected ThreadDescriptorImpl createDescriptorImpl(@NotNull Project project) {
return new ThreadDescriptorImpl(myThread);
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/ThreadGroupData.java b/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/ThreadGroupData.java
index fef933316a8e..fd2a62f2982d 100644
--- a/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/ThreadGroupData.java
+++ b/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/ThreadGroupData.java
@@ -18,6 +18,7 @@ package com.intellij.debugger.impl.descriptors.data;
import com.intellij.debugger.jdi.ThreadGroupReferenceProxyImpl;
import com.intellij.debugger.ui.impl.watch.ThreadGroupDescriptorImpl;
import com.intellij.openapi.project.Project;
+import org.jetbrains.annotations.NotNull;
public class ThreadGroupData extends DescriptorData<ThreadGroupDescriptorImpl>{
private final ThreadGroupReferenceProxyImpl myThreadGroup;
@@ -27,7 +28,7 @@ public class ThreadGroupData extends DescriptorData<ThreadGroupDescriptorImpl>{
myThreadGroup = threadGroup;
}
- protected ThreadGroupDescriptorImpl createDescriptorImpl(Project project) {
+ protected ThreadGroupDescriptorImpl createDescriptorImpl(@NotNull Project project) {
return new ThreadGroupDescriptorImpl(myThreadGroup);
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/ThrownExceptionValueData.java b/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/ThrownExceptionValueData.java
index 5c8610255f22..6ca40003b85a 100644
--- a/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/ThrownExceptionValueData.java
+++ b/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/ThrownExceptionValueData.java
@@ -28,7 +28,7 @@ public final class ThrownExceptionValueData extends DescriptorData<ThrownExcepti
myExceptionObj = exceptionObj;
}
- protected ThrownExceptionValueDescriptorImpl createDescriptorImpl(Project project) {
+ protected ThrownExceptionValueDescriptorImpl createDescriptorImpl(@NotNull Project project) {
return new ThrownExceptionValueDescriptorImpl(project, myExceptionObj);
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/UserExpressionData.java b/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/UserExpressionData.java
index 5553d3b782fe..c48eca313be5 100644
--- a/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/UserExpressionData.java
+++ b/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/UserExpressionData.java
@@ -20,6 +20,7 @@ import com.intellij.debugger.ui.impl.watch.UserExpressionDescriptorImpl;
import com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl;
import com.intellij.debugger.ui.tree.UserExpressionDescriptor;
import com.intellij.openapi.project.Project;
+import org.jetbrains.annotations.NotNull;
public class UserExpressionData extends DescriptorData<UserExpressionDescriptor>{
private final ValueDescriptorImpl myParentDescriptor;
@@ -35,7 +36,7 @@ public class UserExpressionData extends DescriptorData<UserExpressionDescriptor>
myText = text;
}
- protected UserExpressionDescriptorImpl createDescriptorImpl(Project project) {
+ protected UserExpressionDescriptorImpl createDescriptorImpl(@NotNull Project project) {
return new UserExpressionDescriptorImpl(project, myParentDescriptor, myTypeName, myName, myText);
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/WatchItemData.java b/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/WatchItemData.java
index 4b44a0d060db..902973048f30 100644
--- a/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/WatchItemData.java
+++ b/java/debugger/impl/src/com/intellij/debugger/impl/descriptors/data/WatchItemData.java
@@ -19,6 +19,7 @@ import com.intellij.debugger.engine.evaluation.TextWithImports;
import com.intellij.debugger.ui.impl.watch.WatchItemDescriptor;
import com.intellij.openapi.project.Project;
import com.sun.jdi.Value;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
@@ -34,7 +35,7 @@ public final class WatchItemData extends DescriptorData<WatchItemDescriptor>{
myValue = value;
}
- protected WatchItemDescriptor createDescriptorImpl(final Project project) {
+ protected WatchItemDescriptor createDescriptorImpl(@NotNull final Project project) {
return new WatchItemDescriptor(project, myText, myValue);
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/jdi/LocalVariableProxyImpl.java b/java/debugger/impl/src/com/intellij/debugger/jdi/LocalVariableProxyImpl.java
index 0ccda00e2a4b..cca6b8029865 100644
--- a/java/debugger/impl/src/com/intellij/debugger/jdi/LocalVariableProxyImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/jdi/LocalVariableProxyImpl.java
@@ -40,6 +40,7 @@ public class LocalVariableProxyImpl extends JdiProxy implements LocalVariablePro
myVariable = variable;
}
+ @Override
protected void clearCaches() {
myVariable = null;
myVariableType = null;
@@ -47,10 +48,9 @@ public class LocalVariableProxyImpl extends JdiProxy implements LocalVariablePro
public LocalVariable getVariable() throws EvaluateException {
checkValid();
- if(myVariable == null) {
+ if (myVariable == null) {
myVariable = myFrame.visibleVariableByNameInt(myVariableName);
-
- if(myVariable == null) {
+ if (myVariable == null) {
//myFrame is not this variable's frame
throw EvaluateExceptionUtil.createEvaluateException(new IncompatibleThreadStateException());
}
@@ -75,7 +75,7 @@ public class LocalVariableProxyImpl extends JdiProxy implements LocalVariablePro
}
public boolean equals(Object o) {
- if(o instanceof LocalVariableProxyImpl) {
+ if (o instanceof LocalVariableProxyImpl) {
LocalVariableProxyImpl proxy = (LocalVariableProxyImpl)o;
return Comparing.equal(proxy.myFrame, myFrame) && myVariableName.equals(proxy.myVariableName);
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/jdi/ObjectReferenceProxyImpl.java b/java/debugger/impl/src/com/intellij/debugger/jdi/ObjectReferenceProxyImpl.java
index 4e395995fe5d..373404b9a0a7 100644
--- a/java/debugger/impl/src/com/intellij/debugger/jdi/ObjectReferenceProxyImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/jdi/ObjectReferenceProxyImpl.java
@@ -87,7 +87,7 @@ public class ObjectReferenceProxyImpl extends JdiProxy {
try {
myIsCollected = Boolean.valueOf(VirtualMachineProxyImpl.isCollected(myObjectReference));
}
- catch (VMDisconnectedException e) {
+ catch (VMDisconnectedException ignored) {
myIsCollected = Boolean.TRUE;
}
}
@@ -128,7 +128,7 @@ public class ObjectReferenceProxyImpl extends JdiProxy {
if(this == o) return true;
ObjectReference ref = myObjectReference;
- return ref != null && ref.equals(((ObjectReferenceProxyImpl)o).myObjectReference);
+ return ref.equals(((ObjectReferenceProxyImpl)o).myObjectReference);
}
@@ -139,9 +139,10 @@ public class ObjectReferenceProxyImpl extends JdiProxy {
/**
* The advice to the proxy to clear cached data.
*/
+ @Override
protected void clearCaches() {
if (Boolean.FALSE.equals(myIsCollected)) {
- // clearing cache makes sence only if the object has not been collected yet
+ // clearing cache makes sense only if the object has not been collected yet
myIsCollected = null;
}
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/jdi/StackFrameProxyImpl.java b/java/debugger/impl/src/com/intellij/debugger/jdi/StackFrameProxyImpl.java
index 5fed47929af3..94ff89a4dc31 100644
--- a/java/debugger/impl/src/com/intellij/debugger/jdi/StackFrameProxyImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/jdi/StackFrameProxyImpl.java
@@ -26,11 +26,15 @@ import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil;
import com.intellij.debugger.engine.jdi.StackFrameProxy;
import com.intellij.openapi.diagnostic.Logger;
import com.sun.jdi.*;
+import gnu.trove.THashMap;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
public class StackFrameProxyImpl extends JdiProxy implements StackFrameProxy {
private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.jdi.StackFrameProxyImpl");
@@ -43,7 +47,7 @@ public class StackFrameProxyImpl extends JdiProxy implements StackFrameProxy {
private ObjectReference myThisReference;
private ClassLoaderReference myClassLoader;
private Boolean myIsObsolete = null;
- private Map<LocalVariable,Value> myAllValues;
+ private Map<LocalVariable, Value> myAllValues;
public StackFrameProxyImpl(ThreadReferenceProxyImpl threadProxy, @NotNull StackFrame frame, int fromBottomIndex /* 1-based */) {
super(threadProxy.getVirtualMachine());
@@ -107,7 +111,7 @@ public class StackFrameProxyImpl extends JdiProxy implements StackFrameProxy {
checkValid();
- if(myStackFrame == null) {
+ if (myStackFrame == null) {
try {
final ThreadReference threadRef = myThreadProxy.getThreadReference();
myStackFrame = threadRef.frame(getFrameIndex());
@@ -252,6 +256,12 @@ public class StackFrameProxyImpl extends JdiProxy implements StackFrameProxy {
return variable != null ? new LocalVariableProxyImpl(this, variable) : null;
}
+ @Nullable
+ public Value visibleValueByName(@NotNull String name) throws EvaluateException {
+ LocalVariable variable = visibleVariableByNameInt(name);
+ return variable != null ? getValue(new LocalVariableProxyImpl(this, variable)) : null;
+ }
+
protected LocalVariable visibleVariableByNameInt(String name) throws EvaluateException {
DebuggerManagerThreadImpl.assertIsManagerThread();
InvalidStackFrameException error = null;
@@ -283,8 +293,7 @@ public class StackFrameProxyImpl extends JdiProxy implements StackFrameProxy {
InvalidStackFrameException error = null;
for (int attempt = 0; attempt < 2; attempt++) {
try {
- final Map<LocalVariable, Value> allValues = getAllValues();
- return allValues.get(localVariable.getVariable());
+ return getAllValues().get(localVariable.getVariable());
}
catch (InvalidStackFrameException e) {
error = e;
@@ -332,13 +341,8 @@ public class StackFrameProxyImpl extends JdiProxy implements StackFrameProxy {
checkValid();
if (myAllValues == null) {
try {
- final StackFrame stackFrame = getStackFrame();
- final Map<LocalVariable, Value> values = stackFrame.getValues(stackFrame.visibleVariables());
- myAllValues = new HashMap<LocalVariable, Value>(values.size());
- for (final LocalVariable variable : values.keySet()) {
- final Value value = values.get(variable);
- myAllValues.put(variable, value);
- }
+ StackFrame stackFrame = getStackFrame();
+ myAllValues = new THashMap<LocalVariable, Value>(stackFrame.getValues(stackFrame.visibleVariables()));
}
catch (InconsistentDebugInfoException ignored) {
clearCaches();
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 594e7a2ddd60..74b17865270d 100644
--- a/java/debugger/impl/src/com/intellij/debugger/jdi/ThreadReferenceProxyImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/jdi/ThreadReferenceProxyImpl.java
@@ -35,14 +35,15 @@ public final class ThreadReferenceProxyImpl extends ObjectReferenceProxyImpl imp
// cached data
private String myName;
private int myFrameCount = -1;
- // stackframes, 0 - bottom
+ // stack frames, 0 - bottom
private final List<StackFrameProxyImpl> myFramesFromBottom = new ArrayList<StackFrameProxyImpl>();
//cache build on the base of myFramesFromBottom 0 - top, initially nothing is cached
private List<StackFrameProxyImpl> myFrames = null;
private ThreadGroupReferenceProxyImpl myThreadGroupProxy;
- public static Comparator<ThreadReferenceProxyImpl> ourComparator = new Comparator<ThreadReferenceProxyImpl>() {
+ public static final Comparator<ThreadReferenceProxyImpl> ourComparator = new Comparator<ThreadReferenceProxyImpl>() {
+ @Override
public int compare(ThreadReferenceProxyImpl th1, ThreadReferenceProxyImpl th2) {
return th1.name().compareToIgnoreCase(th2.name());
}
@@ -52,11 +53,13 @@ public final class ThreadReferenceProxyImpl extends ObjectReferenceProxyImpl imp
super(virtualMachineProxy, threadReference);
}
+ @Override
public ThreadReference getThreadReference() {
DebuggerManagerThreadImpl.assertIsManagerThread();
return (ThreadReference)getObjectReference();
}
+ @Override
public VirtualMachineProxyImpl getVirtualMachine() {
DebuggerManagerThreadImpl.assertIsManagerThread();
return (VirtualMachineProxyImpl) myTimer;
@@ -68,10 +71,10 @@ public final class ThreadReferenceProxyImpl extends ObjectReferenceProxyImpl imp
try {
myName = getThreadReference().name();
}
- catch (ObjectCollectedException e) {
+ catch (ObjectCollectedException ignored) {
myName = "";
}
- catch (IllegalThreadStateException e) {
+ catch (IllegalThreadStateException ignored) {
myName = "zombie";
}
}
@@ -84,7 +87,7 @@ public final class ThreadReferenceProxyImpl extends ObjectReferenceProxyImpl imp
try {
return getThreadReference().suspendCount();
}
- catch (ObjectCollectedException e) {
+ catch (ObjectCollectedException ignored) {
return 0;
}
}
@@ -106,7 +109,7 @@ public final class ThreadReferenceProxyImpl extends ObjectReferenceProxyImpl imp
try {
threadRefString = getThreadReference().toString() ;
}
- catch (ObjectCollectedException e) {
+ catch (ObjectCollectedException ignored) {
threadRefString = "[thread collected]";
}
return "ThreadReferenceProxyImpl: " + threadRefString + " " + super.toString();
@@ -127,6 +130,7 @@ public final class ThreadReferenceProxyImpl extends ObjectReferenceProxyImpl imp
}
}
+ @Override
protected void clearCaches() {
DebuggerManagerThreadImpl.assertIsManagerThread();
myName = null;
@@ -139,7 +143,7 @@ public final class ThreadReferenceProxyImpl extends ObjectReferenceProxyImpl imp
try {
return getThreadReference().status();
}
- catch (ObjectCollectedException e) {
+ catch (ObjectCollectedException ignored) {
return ThreadReference.THREAD_STATUS_ZOMBIE;
}
}
@@ -152,7 +156,7 @@ public final class ThreadReferenceProxyImpl extends ObjectReferenceProxyImpl imp
try {
threadGroupRef = getThreadReference().threadGroup();
}
- catch (ObjectCollectedException e) {
+ catch (ObjectCollectedException ignored) {
threadGroupRef = null;
}
myThreadGroupProxy = getVirtualMachineProxy().getThreadGroupReferenceProxy(threadGroupRef);
@@ -160,6 +164,7 @@ public final class ThreadReferenceProxyImpl extends ObjectReferenceProxyImpl imp
return myThreadGroupProxy;
}
+ @Override
public int frameCount() throws EvaluateException {
DebuggerManagerThreadImpl.assertIsManagerThread();
checkValid();
@@ -168,7 +173,7 @@ public final class ThreadReferenceProxyImpl extends ObjectReferenceProxyImpl imp
try {
myFrameCount = threadReference.frameCount();
}
- catch(ObjectCollectedException e) {
+ catch(ObjectCollectedException ignored) {
myFrameCount = 0;
}
catch (IncompatibleThreadStateException e) {
@@ -176,7 +181,7 @@ public final class ThreadReferenceProxyImpl extends ObjectReferenceProxyImpl imp
try {
isSuspended = threadReference.isSuspended();
}
- catch (Throwable th) {
+ catch (Throwable ignored) {
// unable to determine whether the thread is actually suspended, so propagating original exception
throw EvaluateExceptionUtil.createEvaluateException(e);
}
@@ -207,12 +212,11 @@ public final class ThreadReferenceProxyImpl extends ObjectReferenceProxyImpl imp
myFrames = new ArrayList<StackFrameProxyImpl>(frameCount());
for (ListIterator<StackFrameProxyImpl> iterator = myFramesFromBottom.listIterator(frameCount()); iterator.hasPrevious();) {
- StackFrameProxyImpl stackFrameProxy = iterator.previous();
- myFrames.add(stackFrameProxy);
+ myFrames.add(iterator.previous());
}
}
}
- catch (ObjectCollectedException e) {
+ catch (ObjectCollectedException ignored) {
return Collections.emptyList();
}
return myFrames;
@@ -234,13 +238,13 @@ public final class ThreadReferenceProxyImpl extends ObjectReferenceProxyImpl imp
int index = myFramesFromBottom.size() + 1;
for (ListIterator<StackFrame> iterator = frames.listIterator(count - myFramesFromBottom.size()); iterator.hasPrevious();) {
- StackFrame stackFrame = iterator.previous();
- myFramesFromBottom.add(new StackFrameProxyImpl(this, stackFrame, index));
+ myFramesFromBottom.add(new StackFrameProxyImpl(this, iterator.previous(), index));
index++;
}
}
}
+ @Override
public StackFrameProxyImpl frame(int i) throws EvaluateException {
DebuggerManagerThreadImpl.assertIsManagerThread();
final ThreadReference threadReference = getThreadReference();
@@ -255,10 +259,10 @@ public final class ThreadReferenceProxyImpl extends ObjectReferenceProxyImpl imp
}
return myFramesFromBottom.get(frameCount - i - 1);
}
- catch (ObjectCollectedException e) {
+ catch (ObjectCollectedException ignored) {
return null;
}
- catch (IllegalThreadStateException e) {
+ catch (IllegalThreadStateException ignored) {
return null;
}
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerEditorImpl.java b/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerEditorImpl.java
index 1395654a06d1..1d10602e3b8f 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerEditorImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerEditorImpl.java
@@ -44,6 +44,7 @@ import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.reference.SoftReference;
import com.intellij.ui.ClickListener;
import com.intellij.util.containers.ContainerUtil;
+import com.intellij.xdebugger.impl.XDebuggerHistoryManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -74,12 +75,15 @@ public abstract class DebuggerEditorImpl extends CompletionEditor{
private WeakReference<ListPopup> myPopup;
private final PsiTreeChangeListener myPsiListener = new PsiTreeChangeAdapter() {
+ @Override
public void childRemoved(@NotNull PsiTreeChangeEvent event) {
checkContext();
}
+ @Override
public void childReplaced(@NotNull PsiTreeChangeEvent event) {
checkContext();
}
+ @Override
public void childMoved(@NotNull PsiTreeChangeEvent event) {
checkContext();
}
@@ -178,6 +182,7 @@ public abstract class DebuggerEditorImpl extends CompletionEditor{
public abstract JComponent getPreferredFocusedComponent();
+ @Override
public void setContext(@Nullable PsiElement context) {
myContext = context;
@@ -204,6 +209,7 @@ public abstract class DebuggerEditorImpl extends CompletionEditor{
protected abstract void updateEditorUi();
+ @Override
public PsiElement getContext() {
return myContext;
}
@@ -212,6 +218,7 @@ public abstract class DebuggerEditorImpl extends CompletionEditor{
return myProject;
}
+ @Override
public void requestFocus() {
getPreferredFocusedComponent().requestFocus();
}
@@ -258,13 +265,14 @@ public abstract class DebuggerEditorImpl extends CompletionEditor{
return myCurrentDocument;
}
+ @Override
public String getRecentsId() {
return myRecentsId;
}
public void addRecent(TextWithImports text) {
- if(getRecentsId() != null && text != null && !"".equals(text.getText())){
- DebuggerRecents.getInstance(getProject()).addRecent(getRecentsId(), text);
+ if(getRecentsId() != null && text != null && !text.isEmpty()){
+ XDebuggerHistoryManager.getInstance(getProject()).addRecentExpression(getRecentsId(), text.getText());
}
}
@@ -282,6 +290,7 @@ public abstract class DebuggerEditorImpl extends CompletionEditor{
}
}
+ @Override
public void dispose() {
PsiManager.getInstance(myProject).removePsiTreeChangeListener(myPsiListener);
myCurrentDocument = null;
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerExpressionComboBox.java b/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerExpressionComboBox.java
index 479c9331893b..455debbd20d7 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerExpressionComboBox.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerExpressionComboBox.java
@@ -30,6 +30,7 @@ import com.intellij.psi.PsiElement;
import com.intellij.ui.EditorComboBoxEditor;
import com.intellij.ui.EditorComboBoxRenderer;
import com.intellij.ui.EditorTextField;
+import com.intellij.xdebugger.impl.XDebuggerHistoryManager;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.Nullable;
@@ -37,7 +38,6 @@ import javax.swing.*;
import javax.swing.plaf.basic.ComboPopup;
import java.awt.*;
import java.util.ArrayList;
-import java.util.LinkedList;
import java.util.List;
/**
@@ -180,10 +180,10 @@ public class DebuggerExpressionComboBox extends DebuggerEditorImpl {
final String recentsId = getRecentsId();
if (recentsId != null) {
final List<TextWithImports> result = new ArrayList<TextWithImports>();
- LinkedList<TextWithImports> recents = DebuggerRecents.getInstance(getProject()).getRecents(getRecentsId());
- for (final TextWithImports evaluationText : recents) {
- if (evaluationText.getText().indexOf('\n') == -1) {
- result.add(evaluationText);
+ List<String> recents = XDebuggerHistoryManager.getInstance(getProject()).getRecentExpressions(getRecentsId());
+ for (String evaluationText : recents) {
+ if (evaluationText.indexOf('\n') == -1) {
+ result.add(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, evaluationText));
}
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/FramesPanel.java b/java/debugger/impl/src/com/intellij/debugger/ui/FramesPanel.java
index 6ed904d74bb9..52bcf8acce32 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/FramesPanel.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/FramesPanel.java
@@ -59,6 +59,7 @@ import com.intellij.ui.components.panels.Wrapper;
import com.intellij.util.Alarm;
import com.sun.jdi.ObjectCollectedException;
import com.sun.jdi.VMDisconnectedException;
+import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
@@ -102,6 +103,7 @@ public class FramesPanel extends UpdatableDebuggerView {
myFramesList.addListSelectionListener(myFramesListener);
myFramesList.addMouseListener(new MouseAdapter() {
+ @Override
public void mousePressed(final MouseEvent e) {
int index = myFramesList.locationToIndex(e.getPoint());
if (index >= 0 && myFramesList.isSelectedIndex(index)) {
@@ -140,6 +142,7 @@ public class FramesPanel extends UpdatableDebuggerView {
return toolbar;
}
+ @Override
public DebuggerStateManager getContextManager() {
return myStateManager;
}
@@ -151,6 +154,7 @@ public class FramesPanel extends UpdatableDebuggerView {
myIsEnabled = enabled;
}
+ @Override
public void valueChanged(ListSelectionEvent e) {
if (!myIsEnabled || e.getValueIsAdjusting()) {
return;
@@ -169,6 +173,7 @@ public class FramesPanel extends UpdatableDebuggerView {
private void registerThreadsPopupMenu(final JList framesList) {
final PopupHandler popupHandler = new PopupHandler() {
+ @Override
public void invokePopup(Component comp, int x, int y) {
DefaultActionGroup group = (DefaultActionGroup)ActionManager.getInstance().getAction(DebuggerActions.THREADS_PANEL_POPUP);
ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu(DebuggerActions.THREADS_PANEL_POPUP, group);
@@ -177,6 +182,7 @@ public class FramesPanel extends UpdatableDebuggerView {
};
framesList.addMouseListener(popupHandler);
registerDisposable(new Disposable() {
+ @Override
public void dispose() {
myThreadsCombo.removeItemListener(myThreadsListener);
framesList.removeMouseListener(popupHandler);
@@ -191,6 +197,7 @@ public class FramesPanel extends UpdatableDebuggerView {
myIsEnabled = enabled;
}
+ @Override
public void itemStateChanged(ItemEvent e) {
if (!myIsEnabled) return;
if (e.getStateChange() == ItemEvent.SELECTED) {
@@ -202,6 +209,7 @@ public class FramesPanel extends UpdatableDebuggerView {
private final AtomicBoolean myPerformFullRebuild = new AtomicBoolean(false);
+ @Override
protected void rebuild(int event) {
myRebuildAlarm.cancelAllRequests();
final boolean isRefresh = event == DebuggerSession.EVENT_REFRESH ||
@@ -211,12 +219,12 @@ public class FramesPanel extends UpdatableDebuggerView {
myPerformFullRebuild.set(true);
}
myRebuildAlarm.addRequest(new Runnable() {
+ @Override
public void run() {
try {
doRebuild(!myPerformFullRebuild.getAndSet(false));
}
- catch (VMDisconnectedException e) {
- // ignored
+ catch (VMDisconnectedException ignored) {
}
}
}, 100, ModalityState.NON_MODAL);
@@ -298,6 +306,7 @@ public class FramesPanel extends UpdatableDebuggerView {
return descriptors;
}
+ @Override
public void threadAction() {
if (myRefreshOnly && myThreadDescriptorsToUpdate.length != myThreadsCombo.getItemCount()) {
// there is no sense in refreshing combobox if thread list has changed since creation of this command
@@ -329,6 +338,7 @@ public class FramesPanel extends UpdatableDebuggerView {
descriptor.updateRepresentation(evaluationContext, DescriptorLabelListener.DUMMY_LISTENER);
}
DebuggerInvocationUtil.swingInvokeLater(getProject(), new Runnable() {
+ @Override
public void run() {
try {
myThreadsListener.setEnabled(false);
@@ -346,6 +356,7 @@ public class FramesPanel extends UpdatableDebuggerView {
}
}
+ @Override
protected void commandCancelled() {
if (!DebuggerManagerThreadImpl.isManagerThread()) {
return;
@@ -372,6 +383,7 @@ public class FramesPanel extends UpdatableDebuggerView {
private void refillThreadsCombo(final ThreadReferenceProxyImpl threadToSelect) {
final List<ThreadDescriptorImpl> threadItems = createThreadDescriptorsList();
DebuggerInvocationUtil.swingInvokeLater(getProject(), new Runnable() {
+ @Override
public void run() {
try {
myThreadsListener.setEnabled(false);
@@ -400,9 +412,11 @@ public class FramesPanel extends UpdatableDebuggerView {
myDebuggerContext = debuggerContext;
}
+ @Override
public void contextAction() throws Exception {
updateFrameList(myDebuggerContext.getThreadProxy());
DebuggerInvocationUtil.swingInvokeLater(getProject(), new Runnable() {
+ @Override
public void run() {
try {
myFramesListener.setEnabled(false);
@@ -425,7 +439,7 @@ public class FramesPanel extends UpdatableDebuggerView {
return;
}
}
- catch (ObjectCollectedException e) {
+ catch (ObjectCollectedException ignored) {
return;
}
@@ -462,11 +476,13 @@ public class FramesPanel extends UpdatableDebuggerView {
myDebuggerContext = debuggerContext;
}
+ @Override
public void contextAction() throws Exception {
final ThreadReferenceProxyImpl thread = myDebuggerContext.getThreadProxy();
try {
if(!getSuspendContext().getDebugProcess().getSuspendManager().isSuspended(thread)) {
DebuggerInvocationUtil.swingInvokeLater(getProject(), new Runnable() {
+ @Override
public void run() {
try {
myFramesListener.setEnabled(false);
@@ -491,7 +507,7 @@ public class FramesPanel extends UpdatableDebuggerView {
return;
}
}
- catch (ObjectCollectedException e) {
+ catch (ObjectCollectedException ignored) {
return;
}
@@ -499,7 +515,7 @@ public class FramesPanel extends UpdatableDebuggerView {
try {
frames = thread.frames();
}
- catch (EvaluateException e) {
+ catch (EvaluateException ignored) {
frames = Collections.emptyList();
}
@@ -601,7 +617,7 @@ public class FramesPanel extends UpdatableDebuggerView {
private final long myTimestamp;
private final IndexCounter myCounter;
- public AppendFrameCommand(SuspendContextImpl suspendContext, StackFrameProxyImpl frame, EvaluationContextImpl evaluationContext,
+ public AppendFrameCommand(@NotNull SuspendContextImpl suspendContext, @NotNull StackFrameProxyImpl frame, EvaluationContextImpl evaluationContext,
MethodsTracker tracker, int indexToInsert, final boolean isContextFrame, final long timestamp, IndexCounter counter) {
super(suspendContext);
myFrame = frame;
@@ -613,12 +629,14 @@ public class FramesPanel extends UpdatableDebuggerView {
myCounter = counter;
}
+ @Override
public void contextAction() throws Exception {
final StackFrameDescriptorImpl descriptor = new StackFrameDescriptorImpl(myFrame, myTracker);
descriptor.setContext(myEvaluationContext);
descriptor.updateRepresentation(myEvaluationContext, DescriptorLabelListener.DUMMY_LISTENER);
final Project project = getProject();
DebuggerInvocationUtil.swingInvokeLater(project, new Runnable() {
+ @Override
public void run() {
try {
myFramesListener.setEnabled(false);
@@ -650,6 +668,7 @@ public class FramesPanel extends UpdatableDebuggerView {
}
}
+ @Override
public void requestFocus() {
myFramesList.requestFocus();
}
@@ -672,6 +691,7 @@ public class FramesPanel extends UpdatableDebuggerView {
myShouldShow = DebuggerSettings.getInstance().SHOW_LIBRARY_STACKFRAMES;
}
+ @Override
public void update(final AnActionEvent e) {
super.update(e);
final Presentation presentation = e.getPresentation();
@@ -679,10 +699,12 @@ public class FramesPanel extends UpdatableDebuggerView {
presentation.setText(shouldShow ? ourTextWhenShowIsOn : ourTextWhenShowIsOff);
}
+ @Override
public boolean isSelected(AnActionEvent e) {
return !myShouldShow;
}
+ @Override
public void setSelected(AnActionEvent e, boolean enabled) {
myShouldShow = !enabled;
DebuggerSettings.getInstance().SHOW_LIBRARY_STACKFRAMES = myShouldShow;
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/JavaDebuggerSupport.java b/java/debugger/impl/src/com/intellij/debugger/ui/JavaDebuggerSupport.java
index 46f1515f1ea5..3b300fca2257 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/JavaDebuggerSupport.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/JavaDebuggerSupport.java
@@ -31,6 +31,7 @@ import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.xdebugger.AbstractDebuggerSession;
+import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroupingRule;
import com.intellij.xdebugger.impl.DebuggerSupport;
import com.intellij.xdebugger.impl.actions.DebuggerActionHandler;
@@ -41,6 +42,7 @@ import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointItem;
import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointPanelProvider;
import com.intellij.xdebugger.impl.evaluate.quick.common.QuickEvaluateHandler;
import com.intellij.xdebugger.impl.settings.DebuggerSettingsPanelProvider;
+import com.intellij.xdebugger.impl.ui.DebuggerUIUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -194,7 +196,7 @@ public class JavaDebuggerSupport extends DebuggerSupport {
@NotNull
@Override
public EditBreakpointActionHandler getEditBreakpointAction() {
- return DISABLED_EDIT;
+ return X_EDIT;
}
@Override
@@ -374,10 +376,10 @@ public class JavaDebuggerSupport extends DebuggerSupport {
}
};
- private static final EditBreakpointActionHandler DISABLED_EDIT = new EditBreakpointActionHandler() {
+ private static final EditBreakpointActionHandler X_EDIT = new EditBreakpointActionHandler() {
@Override
protected void doShowPopup(Project project, JComponent component, Point whereToShow, Object breakpoint) {
-
+ DebuggerUIUtil.showXBreakpointEditorBalloon(project, whereToShow, component, false, (XBreakpoint)breakpoint);
}
@Override
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/Breakpoint.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/Breakpoint.java
index bbbcf8ef1265..e013d7ccdcfb 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/Breakpoint.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/Breakpoint.java
@@ -41,9 +41,12 @@ import com.intellij.psi.PsiElement;
import com.intellij.ui.AppUIUtil;
import com.intellij.ui.classFilter.ClassFilter;
import com.intellij.util.StringBuilderSpinAllocator;
+import com.intellij.util.ThreeState;
import com.intellij.xdebugger.breakpoints.SuspendPolicy;
import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.intellij.xdebugger.breakpoints.XLineBreakpoint;
+import com.intellij.xdebugger.impl.XDebuggerHistoryManager;
+import com.intellij.xdebugger.impl.breakpoints.ui.DefaultLogExpressionComboBoxPanel;
import com.sun.jdi.*;
import com.sun.jdi.event.LocatableEvent;
import org.jdom.Element;
@@ -130,11 +133,12 @@ public abstract class Breakpoint<P extends JavaBreakpointProperties> implements
@Nullable
public String getShortClassName() {
final String className = getClassName();
- if (className != null) {
- final int dotIndex = className.lastIndexOf('.');
- return dotIndex >= 0 && dotIndex + 1 < className.length()? className.substring(dotIndex + 1) : className;
+ if (className == null) {
+ return null;
}
- return className;
+
+ final int dotIndex = className.lastIndexOf('.');
+ return dotIndex >= 0 && dotIndex + 1 < className.length() ? className.substring(dotIndex + 1) : className;
}
@Nullable
@@ -297,8 +301,8 @@ public abstract class Breakpoint<P extends JavaBreakpointProperties> implements
}
public boolean evaluateCondition(final EvaluationContextImpl context, LocatableEvent event) throws EvaluateException {
- if(isCountFilterEnabled()) {
- final DebugProcessImpl debugProcess = context.getDebugProcess();
+ final DebugProcessImpl debugProcess = context.getDebugProcess();
+ if (isCountFilterEnabled()) {
debugProcess.getVirtualMachineProxy().suspend();
debugProcess.getRequestsManager().deleteRequest(this);
((Breakpoint)this).createRequest(debugProcess);
@@ -308,7 +312,7 @@ public abstract class Breakpoint<P extends JavaBreakpointProperties> implements
Value value = context.getThisObject();
if (value != null) { // non-static
ObjectReference reference = (ObjectReference)value;
- if(!hasObjectID(reference.uniqueID())) {
+ if (!hasObjectID(reference.uniqueID())) {
return false;
}
}
@@ -319,40 +323,52 @@ public abstract class Breakpoint<P extends JavaBreakpointProperties> implements
if (!typeMatchesClassFilters(typeName)) return false;
}
- if (isConditionEnabled() && !getCondition().getText().isEmpty()) {
- try {
- ExpressionEvaluator evaluator = DebuggerInvocationUtil.commitAndRunReadAction(context.getProject(), new EvaluatingComputable<ExpressionEvaluator>() {
- public ExpressionEvaluator compute() throws EvaluateException {
- final SourcePosition contextSourcePosition = ContextUtil.getSourcePosition(context);
- // IMPORTANT: calculate context psi element basing on the location where the exception
- // has been hit, not on the location where it was set. (For line breakpoints these locations are the same, however,
- // for method, exception and field breakpoints these locations differ)
- PsiElement contextPsiElement = ContextUtil.getContextElement(contextSourcePosition);
- if (contextPsiElement == null) {
- contextPsiElement = getEvaluationElement(); // as a last resort
- }
- return EvaluatorBuilderImpl.build(getCondition(), contextPsiElement, contextSourcePosition);
- }
- });
- final Value value = evaluator.evaluate(context);
- if (!(value instanceof BooleanValue)) {
- throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.boolean.expected"));
- }
- if(!((BooleanValue)value).booleanValue()) {
- return false;
+ if (!isConditionEnabled() || getCondition().getText().isEmpty()) {
+ return true;
+ }
+
+ StackFrameProxyImpl frame = context.getFrameProxy();
+ if (frame != null) {
+ Location location = frame.location();
+ if (location != null) {
+ ThreeState result = debugProcess.getPositionManager().evaluateCondition(context, frame, location, getCondition().getText());
+ if (result != ThreeState.UNSURE) {
+ return result == ThreeState.YES;
}
}
- catch (EvaluateException ex) {
- if(ex.getCause() instanceof VMDisconnectedException) {
- return false;
+ }
+
+ try {
+ ExpressionEvaluator evaluator = DebuggerInvocationUtil.commitAndRunReadAction(context.getProject(), new EvaluatingComputable<ExpressionEvaluator>() {
+ @Override
+ public ExpressionEvaluator compute() throws EvaluateException {
+ final SourcePosition contextSourcePosition = ContextUtil.getSourcePosition(context);
+ // IMPORTANT: calculate context psi element basing on the location where the exception
+ // has been hit, not on the location where it was set. (For line breakpoints these locations are the same, however,
+ // for method, exception and field breakpoints these locations differ)
+ PsiElement contextPsiElement = ContextUtil.getContextElement(contextSourcePosition);
+ if (contextPsiElement == null) {
+ contextPsiElement = getEvaluationElement(); // as a last resort
+ }
+ return EvaluatorBuilderImpl.build(getCondition(), contextPsiElement, contextSourcePosition);
}
- throw EvaluateExceptionUtil.createEvaluateException(
- DebuggerBundle.message("error.failed.evaluating.breakpoint.condition", getCondition(), ex.getMessage())
- );
+ });
+ final Value value = evaluator.evaluate(context);
+ if (!(value instanceof BooleanValue)) {
+ throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.boolean.expected"));
+ }
+ if (!((BooleanValue)value).booleanValue()) {
+ return false;
}
- return true;
}
-
+ catch (EvaluateException ex) {
+ if (ex.getCause() instanceof VMDisconnectedException) {
+ return false;
+ }
+ throw EvaluateExceptionUtil.createEvaluateException(
+ DebuggerBundle.message("error.failed.evaluating.breakpoint.condition", getCondition(), ex.getMessage())
+ );
+ }
return true;
}
@@ -421,24 +437,30 @@ public abstract class Breakpoint<P extends JavaBreakpointProperties> implements
requestor.readTo(parentNode, this);
try {
setEnabled(Boolean.valueOf(JDOMExternalizerUtil.readField(parentNode, "ENABLED")));
- } catch (Exception e) {
+ }
+ catch (Exception ignored) {
}
try {
setLogEnabled(Boolean.valueOf(JDOMExternalizerUtil.readField(parentNode, "LOG_ENABLED")));
- } catch (Exception e) {
+ }
+ catch (Exception ignored) {
}
try {
- if (Boolean.valueOf(JDOMExternalizerUtil.readField(parentNode, "LOG_EXPRESSION_ENABLED"))) {
- String logMessage = JDOMExternalizerUtil.readField(parentNode, LOG_MESSAGE_OPTION_NAME);
- if (logMessage != null) {
- setLogMessage(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, logMessage));
+ String logMessage = JDOMExternalizerUtil.readField(parentNode, LOG_MESSAGE_OPTION_NAME);
+ if (logMessage != null && !logMessage.isEmpty()) {
+ TextWithImportsImpl text = new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, logMessage);
+ XDebuggerHistoryManager.getInstance(myProject).addRecentExpression(DefaultLogExpressionComboBoxPanel.HISTORY_KEY, text.getText());
+ if (Boolean.valueOf(JDOMExternalizerUtil.readField(parentNode, "LOG_EXPRESSION_ENABLED"))) {
+ setLogMessage(text);
}
}
- } catch (Exception e) {
+ }
+ catch (Exception ignored) {
}
try {
setRemoveAfterHit(Boolean.valueOf(JDOMExternalizerUtil.readField(parentNode, "REMOVE_AFTER_HIT")));
- } catch (Exception e) {
+ }
+ catch (Exception ignored) {
}
}
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 76c55c7b4ae9..ac2778805ef6 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
@@ -44,9 +44,7 @@ import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.util.*;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
-import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiField;
-import com.intellij.psi.PsiFile;
import com.intellij.util.Alarm;
import com.intellij.util.EventDispatcher;
import com.intellij.xdebugger.XDebuggerManager;
@@ -56,6 +54,7 @@ import com.intellij.xdebugger.impl.DebuggerSupport;
import com.intellij.xdebugger.impl.XDebugSessionImpl;
import com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl;
import com.intellij.xdebugger.impl.breakpoints.XDependentBreakpointManager;
+import com.intellij.xdebugger.impl.breakpoints.XLineBreakpointImpl;
import com.sun.jdi.InternalException;
import com.sun.jdi.ThreadReference;
import com.sun.jdi.request.*;
@@ -173,13 +172,16 @@ public class BreakpointManager {
DebuggerInvocationUtil.swingInvokeLater(myProject, new Runnable() {
@Override
public void run() {
- final RangeHighlighter highlighter = ((BreakpointWithHighlighter)breakpoint).getHighlighter();
- if (highlighter != null) {
- final GutterIconRenderer renderer = highlighter.getGutterIconRenderer();
- if (renderer != null) {
- DebuggerSupport.getDebuggerSupport(JavaDebuggerSupport.class).getEditBreakpointAction().editBreakpoint(
- myProject, editor, breakpoint, renderer
- );
+ XBreakpoint xBreakpoint = breakpoint.myXBreakpoint;
+ if (xBreakpoint instanceof XLineBreakpointImpl) {
+ RangeHighlighter highlighter = ((XLineBreakpointImpl)xBreakpoint).getHighlighter();
+ if (highlighter != null) {
+ GutterIconRenderer renderer = highlighter.getGutterIconRenderer();
+ if (renderer != null) {
+ DebuggerSupport.getDebuggerSupport(JavaDebuggerSupport.class).getEditBreakpointAction().editBreakpoint(
+ myProject, editor, breakpoint.myXBreakpoint, renderer
+ );
+ }
}
}
}
@@ -1056,14 +1058,4 @@ public class BreakpointManager {
public String setProperty(String name, String value) {
return myUIProperties.put(name, value);
}
-
- public static PsiFile getPsiFile(XBreakpoint xBreakpoint, Project project) {
- try {
- final Document document = FileDocumentManager.getInstance().getDocument(xBreakpoint.getSourcePosition().getFile());
- return PsiDocumentManager.getInstance(project).getPsiFile(document);
- } catch (Exception e) {
- LOG.error(e);
- }
- return null;
- }
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java
index 8cd1bfbe8151..63ec571d6d24 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java
@@ -293,14 +293,25 @@ public abstract class BreakpointWithHighlighter<P extends JavaBreakpointProperti
@Override
public void reload() {
ApplicationManager.getApplication().assertReadAccessAllowed();
- final XSourcePosition position = myXBreakpoint.getSourcePosition();
- try {
- final PsiFile psiFile = PsiManager.getInstance(myProject).findFile(position.getFile());
- mySourcePosition = SourcePosition.createFromOffset(psiFile, position.getOffset());
- } catch (Exception e) {
+ XSourcePosition position = myXBreakpoint.getSourcePosition();
+ PsiFile psiFile = getPsiFile();
+ if (position != null && psiFile != null) {
+ mySourcePosition = SourcePosition.createFromLine(psiFile, position.getLine());
+ reload(psiFile);
+ }
+ else {
mySourcePosition = null;
}
- reload(BreakpointManager.getPsiFile(myXBreakpoint, myProject));
+ }
+
+ @Nullable
+ public PsiFile getPsiFile() {
+ ApplicationManager.getApplication().assertReadAccessAllowed();
+ XSourcePosition position = myXBreakpoint.getSourcePosition();
+ if (position != null) {
+ return PsiManager.getInstance(myProject).findFile(position.getFile());
+ }
+ return null;
}
@Override
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FilteredRequestorImpl.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FilteredRequestorImpl.java
index 496292881354..c4175eb0b6af 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FilteredRequestorImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FilteredRequestorImpl.java
@@ -29,6 +29,8 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.*;
import com.intellij.psi.PsiElement;
import com.intellij.ui.classFilter.ClassFilter;
+import com.intellij.xdebugger.impl.XDebuggerHistoryManager;
+import com.intellij.xdebugger.impl.breakpoints.ui.DefaultConditionComboBoxPanel;
import com.sun.jdi.event.LocatableEvent;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
@@ -130,6 +132,9 @@ public class FilteredRequestorImpl implements JDOMExternalizable, FilteredReques
breakpoint.setCountFilter(COUNT_FILTER);
breakpoint.setCondition(CONDITION_ENABLED ? myCondition : null);
+ if (myCondition != null && !myCondition.isEmpty()) {
+ XDebuggerHistoryManager.getInstance(myProject).addRecentExpression(DefaultConditionComboBoxPanel.HISTORY_KEY, myCondition.getText());
+ }
breakpoint.setClassFiltersEnabled(CLASS_FILTERS_ENABLED);
breakpoint.setClassFilters(getClassFilters());
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/StepIntoBreakpoint.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/StepIntoBreakpoint.java
index af7d6755523a..e41127e9bf97 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/StepIntoBreakpoint.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/StepIntoBreakpoint.java
@@ -153,7 +153,6 @@ public class StepIntoBreakpoint extends RunToCursorBreakpoint {
if (pos != null) {
final StepIntoBreakpoint breakpoint = new StepIntoBreakpoint(project, pos, filter);
breakpoint.init();
- breakpoint.setLogEnabled(false);
return breakpoint;
}
return null;
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 c04f1bf63d67..1bd00d1c5576 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
@@ -24,13 +24,12 @@ import com.intellij.debugger.impl.DebuggerStateManager;
import com.intellij.debugger.ui.impl.watch.DebuggerTree;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
-import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.keymap.KeymapManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.wm.ex.IdeFocusTraversalPolicy;
import com.intellij.ui.PopupHandler;
-import com.intellij.util.Alarm;
+import com.intellij.util.SingleAlarm;
import com.intellij.xdebugger.impl.actions.XDebuggerActions;
import com.sun.jdi.VMDisconnectedException;
@@ -41,7 +40,21 @@ import java.awt.event.KeyEvent;
public abstract class DebuggerTreePanel extends UpdatableDebuggerView implements DataProvider {
public static final DataKey<DebuggerTreePanel> DATA_KEY = DataKey.create("DebuggerPanel");
- private final Alarm myRebuildAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD);
+ private final SingleAlarm myRebuildAlarm = new SingleAlarm(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ final DebuggerContextImpl context = getContext();
+ if(context.getDebuggerSession() != null) {
+ getTree().rebuild(context);
+ }
+ }
+ catch (VMDisconnectedException ignored) {
+ }
+
+ }
+ }, 100);
+
protected DebuggerTree myTree;
public DebuggerTreePanel(Project project, DebuggerStateManager stateManager) {
@@ -80,24 +93,9 @@ public abstract class DebuggerTreePanel extends UpdatableDebuggerView implements
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();
- if(context.getDebuggerSession() != null) {
- getTree().rebuild(context);
- }
- }
- catch (VMDisconnectedException ignored) {
- // ignored
- }
- }
- }, 100, ModalityState.NON_MODAL);
+ myRebuildAlarm.cancelAndRequest();
}
@Override
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/FrameVariablesTree.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/FrameVariablesTree.java
index 788cb17b477e..5694eb1cba67 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/FrameVariablesTree.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/FrameVariablesTree.java
@@ -52,9 +52,12 @@ import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.text.CharArrayUtil;
import com.intellij.util.ui.tree.TreeModelAdapter;
import com.intellij.xdebugger.XDebuggerBundle;
+import com.intellij.xdebugger.frame.XStackFrame;
import com.sun.jdi.*;
import gnu.trove.TIntObjectHashMap;
import gnu.trove.TObjectProcedure;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import javax.swing.event.TreeModelEvent;
import javax.swing.tree.TreeModel;
@@ -62,13 +65,22 @@ import javax.swing.tree.TreePath;
import java.util.*;
public class FrameVariablesTree extends DebuggerTree {
- private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.ui.impl.FrameDebuggerTree");
+ private static final Logger LOG = Logger.getInstance(FrameVariablesTree.class);
+
private boolean myAnyNewLocals;
private boolean myAutoWatchMode = false;
- public FrameVariablesTree(Project project) {
+ private final VariablesPanel myVariablesPanel;
+
+ public FrameVariablesTree(@NotNull Project project) {
+ this(project, null);
+ }
+
+ public FrameVariablesTree(@NotNull Project project, @Nullable VariablesPanel variablesPanel) {
super(project);
+
getEmptyText().setText(XDebuggerBundle.message("debugger.variables.not.available"));
+ myVariablesPanel = variablesPanel;
}
public boolean isAutoWatchMode() {
@@ -110,7 +122,7 @@ public class FrameVariablesTree extends DebuggerTree {
@Override
- protected DebuggerCommandImpl getBuildNodeCommand(final DebuggerTreeNodeImpl node) {
+ protected DebuggerCommandImpl getBuildNodeCommand(@NotNull DebuggerTreeNodeImpl node) {
if (node.getDescriptor() instanceof StackFrameDescriptorImpl) {
return new BuildFrameTreeVariablesCommand(node);
}
@@ -121,7 +133,21 @@ public class FrameVariablesTree extends DebuggerTree {
public BuildFrameTreeVariablesCommand(DebuggerTreeNodeImpl stackNode) {
super(stackNode);
}
-
+
+ @Override
+ public void threadAction() {
+ if (myVariablesPanel != null) {
+ StackFrameDescriptorImpl stackDescriptor = (StackFrameDescriptorImpl)getNode().getDescriptor();
+ XStackFrame xStackFrame = stackDescriptor.getXStackFrame();
+ myVariablesPanel.stackChanged(xStackFrame);
+ if (xStackFrame != null) {
+ return;
+ }
+ }
+
+ super.threadAction();
+ }
+
@Override
protected void buildVariables(final StackFrameDescriptorImpl stackDescriptor, final EvaluationContextImpl evaluationContext) throws EvaluateException {
final DebuggerContextImpl debuggerContext = getDebuggerContext();
@@ -129,6 +155,7 @@ public class FrameVariablesTree extends DebuggerTree {
if (sourcePosition == null) {
return;
}
+
try {
if (!ViewsGeneralSettings.getInstance().ENABLE_AUTO_EXPRESSIONS && !myAutoWatchMode) {
// optimization
@@ -165,9 +192,7 @@ public class FrameVariablesTree extends DebuggerTree {
catch (EvaluateException e) {
if (e.getCause() instanceof AbsentInformationException) {
final StackFrameProxyImpl frame = stackDescriptor.getFrameProxy();
- if (frame == null) {
- throw e;
- }
+
final Collection<Value> argValues = frame.getArgumentValues();
int index = 0;
for (Value argValue : argValues) {
@@ -206,6 +231,7 @@ public class FrameVariablesTree extends DebuggerTree {
}
try {
final Location location = frame.location();
+ LOG.assertTrue(location != null);
final Method method = location.method();
final Location methodLocation = method.location();
if (methodLocation == null || methodLocation.codeIndex() < 0) {
@@ -252,9 +278,6 @@ public class FrameVariablesTree extends DebuggerTree {
private static Map<String, LocalVariableProxyImpl> getVisibleVariables(final StackFrameDescriptorImpl stackDescriptor) throws EvaluateException {
final StackFrameProxyImpl frame = stackDescriptor.getFrameProxy();
- if (frame == null) {
- return Collections.emptyMap();
- }
final Map<String, LocalVariableProxyImpl> vars = new HashMap<String, LocalVariableProxyImpl>();
for (LocalVariableProxyImpl localVariableProxy : frame.visibleVariables()) {
vars.put(localVariableProxy.name(), localVariableProxy);
@@ -413,7 +436,6 @@ public class FrameVariablesTree extends DebuggerTree {
try {
StackFrameProxyImpl frame = debuggerContext.getFrameProxy();
-
if (frame != null) {
NodeManagerImpl nodeManager = getNodeFactory();
rootNode = nodeManager.createNode(nodeManager.getStackFrameDescriptor(null, frame), debuggerContext.createEvaluationContext());
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/VariablesPanel.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/VariablesPanel.java
index af482239ab27..dc80f8b139af 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/VariablesPanel.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/VariablesPanel.java
@@ -23,26 +23,48 @@ import com.intellij.debugger.impl.DebuggerStateManager;
import com.intellij.debugger.ui.impl.watch.DebuggerTree;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
+import com.intellij.openapi.editor.Document;
+import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.project.Project;
+import com.intellij.ui.AppUIUtil;
import com.intellij.ui.ScrollPaneFactory;
+import com.intellij.util.SystemProperties;
+import com.intellij.xdebugger.XSourcePosition;
+import com.intellij.xdebugger.evaluation.EvaluationMode;
+import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider;
+import com.intellij.xdebugger.frame.XStackFrame;
+import com.intellij.xdebugger.impl.frame.XVariablesViewBase;
import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent;
-public class VariablesPanel extends DebuggerTreePanel implements DataProvider{
-
+public class VariablesPanel extends DebuggerTreePanel implements DataProvider {
@NonNls private static final String HELP_ID = "debugging.debugFrame";
+ private static final String TREE = "tree";
+ private static final String X_TREE = "xTree";
+ private final JPanel myCards;
+ private final MyXVariablesView myXTree;
+
public VariablesPanel(Project project, DebuggerStateManager stateManager, Disposable parent) {
super(project, stateManager);
- setBorder(null);
+ setBorder(null);
final FrameVariablesTree frameTree = getFrameTree();
- add(ScrollPaneFactory.createScrollPane(frameTree), BorderLayout.CENTER);
+ myCards = new JPanel(new CardLayout());
+ myCards.add(frameTree, TREE);
+
+ myXTree = new MyXVariablesView(project);
+ registerDisposable(myXTree);
+ myCards.add(myXTree.getTree(), X_TREE);
+
+ add(ScrollPaneFactory.createScrollPane(myCards), BorderLayout.CENTER);
registerDisposable(DebuggerAction.installEditAction(frameTree, DebuggerActions.EDIT_NODE_SOURCE));
overrideShortcut(frameTree, DebuggerActions.COPY_VALUE, CommonShortcuts.getCopy());
@@ -51,21 +73,25 @@ public class VariablesPanel extends DebuggerTreePanel implements DataProvider{
new ValueNodeDnD(myTree, parent);
}
+ @Override
protected DebuggerTree createTreeView() {
- return new FrameVariablesTree(getProject());
+ return new FrameVariablesTree(getProject(), SystemProperties.getBooleanProperty("java.debugger.xTree", true) ? this : null);
}
+ @Override
protected void changeEvent(DebuggerContextImpl newContext, int event) {
if (event != DebuggerSession.EVENT_THREADS_REFRESH) {
super.changeEvent(newContext, event);
}
}
+ @Override
protected ActionPopupMenu createPopupMenu() {
ActionGroup group = (ActionGroup)ActionManager.getInstance().getAction(DebuggerActions.FRAME_PANEL_POPUP);
return ActionManager.getInstance().createActionPopupMenu(DebuggerActions.FRAME_PANEL_POPUP, group);
}
+ @Override
public Object getData(String dataId) {
if (PlatformDataKeys.HELP_ID.is(dataId)) {
return HELP_ID;
@@ -73,9 +99,51 @@ public class VariablesPanel extends DebuggerTreePanel implements DataProvider{
return super.getData(dataId);
}
-
public FrameVariablesTree getFrameTree() {
- return (FrameVariablesTree) getTree();
+ return (FrameVariablesTree)getTree();
}
+ public void stackChanged(@Nullable final XStackFrame xStackFrame) {
+ AppUIUtil.invokeOnEdt(new Runnable() {
+ @Override
+ public void run() {
+ myXTree.stackChanged(xStackFrame);
+ ((CardLayout)(myCards.getLayout())).show(myCards, xStackFrame == null ? TREE : X_TREE);
+ }
+ });
+ }
+
+ private static final class MyXVariablesView extends XVariablesViewBase {
+ private XStackFrame myCurrentXStackFrame;
+
+ public MyXVariablesView(@NotNull Project project) {
+ super(project, new XDebuggerEditorsProvider() {
+ @NotNull
+ @Override
+ public FileType getFileType() {
+ throw new UnsupportedOperationException();
+ }
+
+ @NotNull
+ @Override
+ public Document createDocument(@NotNull Project project, @NotNull String text, @Nullable XSourcePosition sourcePosition, @NotNull EvaluationMode mode) {
+ throw new UnsupportedOperationException();
+ }
+ }, null);
+ }
+
+ public void stackChanged(@Nullable XStackFrame stackFrame) {
+ if (myCurrentXStackFrame != null) {
+ saveCurrentTreeState(stackFrame);
+ }
+
+ myCurrentXStackFrame = stackFrame;
+ if (stackFrame == null) {
+ getTree().setSourcePosition(null);
+ }
+ else {
+ buildTreeAndRestoreState(stackFrame);
+ }
+ }
+ }
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/WatchPanel.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/WatchPanel.java
index 8d9cefcb25f7..78d1f9194bfb 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/WatchPanel.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/WatchPanel.java
@@ -53,10 +53,12 @@ public abstract class WatchPanel extends DebuggerTreePanel {
return ScrollPaneFactory.createScrollPane(tree);
}
+ @Override
protected DebuggerTree createTreeView() {
return new WatchDebuggerTree(getProject());
}
+ @Override
protected void changeEvent(DebuggerContextImpl newContext, int event) {
if (event == DebuggerSession.EVENT_THREADS_REFRESH) {
return;
@@ -74,10 +76,12 @@ public abstract class WatchPanel extends DebuggerTreePanel {
rebuildIfVisible(event);
}
+ @Override
protected ActionPopupMenu createPopupMenu() {
return null;
}
+ @Override
public Object getData(String dataId) {
if (PlatformDataKeys.HELP_ID.is(dataId)) {
return HELP_ID;
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTree.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTree.java
index 39c2775df018..e5d5b79ebd29 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTree.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTree.java
@@ -68,7 +68,7 @@ import java.util.*;
import java.util.List;
public abstract class DebuggerTree extends DebuggerTreeBase implements DataProvider {
- private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.ui.impl.watch.DebuggerTree");
+ private static final Logger LOG = Logger.getInstance(DebuggerTree.class);
protected static final Key<Rectangle> VISIBLE_RECT = Key.create("VISIBLE_RECT");
public static final DataKey<DebuggerTree> DATA_KEY = DataKey.create("DebuggerTree");
@@ -85,6 +85,7 @@ public abstract class DebuggerTree extends DebuggerTreeBase implements DataProvi
myNodeManager = createNodeManager(project);
final TreeBuilder model = new TreeBuilder(this) {
+ @Override
public void buildChildren(TreeBuilderNode node) {
final DebuggerTreeNodeImpl debuggerTreeNode = (DebuggerTreeNodeImpl)node;
if (debuggerTreeNode.getDescriptor() instanceof DefaultNodeDescriptor) {
@@ -93,24 +94,29 @@ public abstract class DebuggerTree extends DebuggerTreeBase implements DataProvi
buildNode(debuggerTreeNode);
}
+ @Override
public boolean isExpandable(TreeBuilderNode builderNode) {
return DebuggerTree.this.isExpandable((DebuggerTreeNodeImpl)builderNode);
}
};
model.setRoot(getNodeFactory().getDefaultNode());
model.addTreeModelListener(new TreeModelListener() {
+ @Override
public void treeNodesChanged(TreeModelEvent event) {
hideTooltip();
}
+ @Override
public void treeNodesInserted(TreeModelEvent event) {
hideTooltip();
}
+ @Override
public void treeNodesRemoved(TreeModelEvent event) {
hideTooltip();
}
+ @Override
public void treeStructureChanged(TreeModelEvent event) {
hideTooltip();
}
@@ -126,6 +132,7 @@ public abstract class DebuggerTree extends DebuggerTreeBase implements DataProvi
return new NodeManagerImpl(project, this);
}
+ @Override
public void dispose() {
myNodeManager.dispose();
myDebuggerContext = DebuggerContextImpl.EMPTY_CONTEXT;
@@ -137,8 +144,9 @@ public abstract class DebuggerTree extends DebuggerTreeBase implements DataProvi
return descriptor.isExpandable();
}
+ @Override
public Object getData(String dataId) {
- if (DebuggerTree.DATA_KEY.is(dataId)) {
+ if (DATA_KEY.is(dataId)) {
return this;
}
return null;
@@ -234,6 +242,7 @@ public abstract class DebuggerTree extends DebuggerTreeBase implements DataProvi
}
}
+ @Override
public void scrollRectToVisible(Rectangle aRect) {
// see IDEADEV-432
aRect.width += aRect.x;
@@ -336,9 +345,11 @@ public abstract class DebuggerTree extends DebuggerTreeBase implements DataProvi
myDebuggerContext = context;
saveState();
process.getManagerThread().schedule(new DebuggerCommandImpl() {
+ @Override
protected void action() throws Exception {
getNodeFactory().setHistoryByContext(context);
}
+ @Override
public Priority getPriority() {
return Priority.NORMAL;
}
@@ -371,6 +382,7 @@ public abstract class DebuggerTree extends DebuggerTreeBase implements DataProvi
protected abstract static class RefreshDebuggerTreeCommand extends SuspendContextCommandImpl {
private final DebuggerContextImpl myDebuggerContext;
+ @Override
public Priority getPriority() {
return Priority.NORMAL;
}
@@ -399,6 +411,7 @@ public abstract class DebuggerTree extends DebuggerTreeBase implements DataProvi
myNode = node;
}
+ @Override
public Priority getPriority() {
return Priority.NORMAL;
}
@@ -409,6 +422,7 @@ public abstract class DebuggerTree extends DebuggerTreeBase implements DataProvi
protected void updateUI(final boolean scrollToVisible) {
DebuggerInvocationUtil.swingInvokeLater(getProject(), new Runnable() {
+ @Override
public void run() {
myNode.removeAllChildren();
for (DebuggerTreeNode debuggerTreeNode : myChildren) {
@@ -425,31 +439,28 @@ public abstract class DebuggerTree extends DebuggerTreeBase implements DataProvi
super(stackNode);
}
- public final void threadAction() {
+ @Override
+ public void threadAction() {
try {
final StackFrameDescriptorImpl stackDescriptor = (StackFrameDescriptorImpl)getNode().getDescriptor();
final StackFrameProxyImpl frame = stackDescriptor.getFrameProxy();
- if (frame == null) {
- return;
- }
- final Location location = frame.location();
-
- final ObjectReference thisObjectReference = frame.thisObject();
final DebuggerContextImpl debuggerContext = getDebuggerContext();
final EvaluationContextImpl evaluationContext = debuggerContext.createEvaluationContext();
-
if (!debuggerContext.isEvaluationPossible()) {
myChildren.add(myNodeManager.createNode(MessageDescriptor.EVALUATION_NOT_POSSIBLE, evaluationContext));
}
+ final Location location = frame.location();
+ LOG.assertTrue(location != null);
+
+ final ObjectReference thisObjectReference = frame.thisObject();
final NodeDescriptor descriptor;
if (thisObjectReference != null) {
descriptor = myNodeManager.getThisDescriptor(stackDescriptor, thisObjectReference);
}
else {
- final ReferenceType type = location.method().declaringType();
- descriptor = myNodeManager.getStaticDescriptor(stackDescriptor, type);
+ descriptor = myNodeManager.getStaticDescriptor(stackDescriptor, location.method().declaringType());
}
myChildren.add(myNodeManager.createNode(descriptor, evaluationContext));
@@ -483,10 +494,8 @@ public abstract class DebuggerTree extends DebuggerTreeBase implements DataProvi
// add last method return value if any
final Pair<Method, Value> methodValuePair = debuggerContext.getDebugProcess().getLastExecutedMethod();
if (methodValuePair != null) {
- final ValueDescriptorImpl returnValueDescriptor =
- myNodeManager.getMethodReturnValueDescriptor(stackDescriptor, methodValuePair.getFirst(), methodValuePair.getSecond());
- final DebuggerTreeNodeImpl methodReturnValueNode = myNodeManager.createNode(returnValueDescriptor, evaluationContext);
- myChildren.add(1, methodReturnValueNode);
+ ValueDescriptorImpl returnValueDescriptor = myNodeManager.getMethodReturnValueDescriptor(stackDescriptor, methodValuePair.getFirst(), methodValuePair.getSecond());
+ myChildren.add(1, myNodeManager.createNode(returnValueDescriptor, evaluationContext));
}
// add context exceptions
for (Pair<Breakpoint, Event> pair : DebuggerUtilsEx.getEventDescriptors(getSuspendContext())) {
@@ -526,12 +535,10 @@ public abstract class DebuggerTree extends DebuggerTreeBase implements DataProvi
protected void buildVariables(final StackFrameDescriptorImpl stackDescriptor, final EvaluationContextImpl evaluationContext) throws EvaluateException {
final StackFrameProxyImpl frame = stackDescriptor.getFrameProxy();
- if (frame != null) {
- for (final LocalVariableProxyImpl local : frame.visibleVariables()) {
- final LocalVariableDescriptorImpl localVariableDescriptor = myNodeManager.getLocalVariableDescriptor(stackDescriptor, local);
- final DebuggerTreeNodeImpl variableNode = myNodeManager.createNode(localVariableDescriptor, evaluationContext);
- myChildren.add(variableNode);
- }
+ for (final LocalVariableProxyImpl local : frame.visibleVariables()) {
+ final LocalVariableDescriptorImpl localVariableDescriptor = myNodeManager.getLocalVariableDescriptor(stackDescriptor, local);
+ final DebuggerTreeNodeImpl variableNode = myNodeManager.createNode(localVariableDescriptor, evaluationContext);
+ myChildren.add(variableNode);
}
}
}
@@ -541,6 +548,7 @@ public abstract class DebuggerTree extends DebuggerTreeBase implements DataProvi
super(node);
}
+ @Override
public void threadAction() {
final DebuggerTreeNodeImpl node = getNode();
ValueDescriptorImpl descriptor = (ValueDescriptorImpl)node.getDescriptor();
@@ -563,19 +571,23 @@ public abstract class DebuggerTree extends DebuggerTreeBase implements DataProvi
}
}
+ @Override
public NodeManagerImpl getNodeManager() {
return myNodeManager;
}
+ @Override
public NodeManagerImpl getDescriptorManager() {
return myNodeManager;
}
+ @Override
public ValueDescriptorImpl getParentDescriptor() {
return (ValueDescriptorImpl)getNode().getDescriptor();
}
+ @Override
public void setChildren(final List<DebuggerTreeNode> children) {
myChildren.addAll(children);
updateUI(false);
@@ -587,6 +599,7 @@ public abstract class DebuggerTree extends DebuggerTreeBase implements DataProvi
super(node);
}
+ @Override
public void threadAction() {
final StaticDescriptorImpl sd = (StaticDescriptorImpl)getNode().getDescriptor();
final ReferenceType refType = sd.getType();
@@ -609,6 +622,7 @@ public abstract class DebuggerTree extends DebuggerTreeBase implements DataProvi
super(threadNode);
}
+ @Override
public void threadAction() {
ThreadDescriptorImpl threadDescriptor = ((ThreadDescriptorImpl)getNode().getDescriptor());
ThreadReferenceProxyImpl threadProxy = threadDescriptor.getThreadReference();
@@ -653,6 +667,7 @@ public abstract class DebuggerTree extends DebuggerTreeBase implements DataProvi
myNode = node;
}
+ @Override
protected void action() throws Exception {
ThreadGroupDescriptorImpl groupDescriptor = (ThreadGroupDescriptorImpl)myNode.getDescriptor();
ThreadGroupReferenceProxyImpl threadGroup = groupDescriptor.getThreadGroupReference();
@@ -701,6 +716,7 @@ public abstract class DebuggerTree extends DebuggerTreeBase implements DataProvi
protected void updateUI(final boolean scrollToVisible) {
DebuggerInvocationUtil.swingInvokeLater(getProject(), new Runnable() {
+ @Override
public void run() {
myNode.removeAllChildren();
for (DebuggerTreeNode debuggerTreeNode : myChildren) {
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTreeNodeImpl.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTreeNodeImpl.java
index b6877dc6acc3..ed9f76ff3db8 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTreeNodeImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTreeNodeImpl.java
@@ -29,7 +29,6 @@ import com.intellij.debugger.ui.impl.tree.TreeBuilderNode;
import com.intellij.debugger.ui.tree.DebuggerTreeNode;
import com.intellij.debugger.ui.tree.NodeDescriptor;
import com.intellij.debugger.ui.tree.ValueDescriptor;
-import com.intellij.xdebugger.impl.ui.tree.ValueMarkup;
import com.intellij.debugger.ui.tree.render.DescriptorLabelListener;
import com.intellij.debugger.ui.tree.render.NodeRenderer;
import com.intellij.openapi.application.ApplicationManager;
@@ -37,6 +36,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import com.intellij.ui.SimpleColoredText;
import com.intellij.util.containers.HashMap;
+import com.intellij.xdebugger.impl.ui.tree.ValueMarkup;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
@@ -54,10 +54,12 @@ public class DebuggerTreeNodeImpl extends TreeBuilderNode implements DebuggerTre
myTree = tree;
}
+ @Override
public DebuggerTreeNodeImpl getParent() {
return (DebuggerTreeNodeImpl) super.getParent();
}
+ @Override
protected TreeBuilder getTreeBuilder() {
return myTree.getMutableModel();
}
@@ -70,14 +72,17 @@ public class DebuggerTreeNodeImpl extends TreeBuilderNode implements DebuggerTre
return myText != null? myText.toString() : "";
}
+ @Override
public NodeDescriptorImpl getDescriptor() {
return (NodeDescriptorImpl)getUserObject();
}
+ @Override
public Project getProject() {
return getTree().getProject();
}
+ @Override
public void setRenderer(NodeRenderer renderer) {
((ValueDescriptorImpl) getDescriptor()).setRenderer(renderer);
calcRepresentation();
@@ -110,6 +115,7 @@ public class DebuggerTreeNodeImpl extends TreeBuilderNode implements DebuggerTre
return myMarkupTooltipText;
}
+ @Override
public void clear() {
removeAllChildren();
myIcon = null;
@@ -129,10 +135,12 @@ public class DebuggerTreeNodeImpl extends TreeBuilderNode implements DebuggerTre
myText = DebuggerTreeRenderer.getDescriptorText(context, MessageDescriptor.EVALUATING, false);
context.getDebugProcess().getManagerThread().invoke(new DebuggerContextCommandImpl(context) {
+ @Override
public void threadAction() {
runnable.run();
}
+ @Override
protected void commandCancelled() {
clear();
getDescriptor().clear();
@@ -141,6 +149,7 @@ public class DebuggerTreeNodeImpl extends TreeBuilderNode implements DebuggerTre
labelChanged();
childrenChanged(true);
}
+ @Override
public Priority getPriority() {
return Priority.NORMAL;
}
@@ -157,8 +166,10 @@ public class DebuggerTreeNodeImpl extends TreeBuilderNode implements DebuggerTre
public void calcLabel() {
final DebuggerContextImpl context = getTree().getDebuggerContext();
update(context, new Runnable() {
+ @Override
public void run() {
getDescriptor().updateRepresentation(context.createEvaluationContext(), new DescriptorLabelListener() {
+ @Override
public void labelChanged() {
updateCaches();
DebuggerTreeNodeImpl.this.labelChanged();
@@ -171,8 +182,10 @@ public class DebuggerTreeNodeImpl extends TreeBuilderNode implements DebuggerTre
public void calcRepresentation() {
final DebuggerContextImpl context = getTree().getDebuggerContext();
update(context, new Runnable() {
+ @Override
public void run() {
getDescriptor().updateRepresentation(context.createEvaluationContext(), new DescriptorLabelListener() {
+ @Override
public void labelChanged() {
updateCaches();
DebuggerTreeNodeImpl.this.labelChanged();
@@ -187,21 +200,23 @@ public class DebuggerTreeNodeImpl extends TreeBuilderNode implements DebuggerTre
update(
context,
new Runnable() {
+ @Override
public void run() {
EvaluationContextImpl evaluationContext = context.createEvaluationContext();
getDescriptor().setContext(evaluationContext);
getDescriptor().updateRepresentation(evaluationContext, new DescriptorLabelListener() {
+ @Override
public void labelChanged() {
updateCaches();
DebuggerTreeNodeImpl.this.labelChanged();
}
});
- DebuggerTreeNodeImpl.this.childrenChanged(true);
+ childrenChanged(true);
}
}, false);
}
- private void invoke(Runnable r) {
+ private static void invoke(Runnable r) {
if(ApplicationManager.getApplication().isDispatchThread()) {
r.run();
}
@@ -212,6 +227,7 @@ public class DebuggerTreeNodeImpl extends TreeBuilderNode implements DebuggerTre
public void labelChanged() {
invoke(new Runnable() {
+ @Override
public void run() {
updateCaches();
getTree().getMutableModel().nodeChanged(DebuggerTreeNodeImpl.this);
@@ -221,6 +237,7 @@ public class DebuggerTreeNodeImpl extends TreeBuilderNode implements DebuggerTre
public void childrenChanged(final boolean scrollToVisible) {
invoke(new Runnable() {
+ @Override
public void run() {
getTree().getMutableModel().nodeStructureChanged(DebuggerTreeNodeImpl.this);
getTree().restoreState(DebuggerTreeNodeImpl.this);
@@ -255,6 +272,7 @@ public class DebuggerTreeNodeImpl extends TreeBuilderNode implements DebuggerTre
protected static DebuggerTreeNodeImpl createNode(DebuggerTree tree, NodeDescriptorImpl descriptor, EvaluationContextImpl evaluationContext) {
final DebuggerTreeNodeImpl node = new DebuggerTreeNodeImpl(tree, descriptor);
descriptor.updateRepresentationNoNotify(evaluationContext, new DescriptorLabelListener() {
+ @Override
public void labelChanged() {
node.updateCaches();
node.labelChanged();
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/LocalVariableDescriptorImpl.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/LocalVariableDescriptorImpl.java
index 96f0dc6ff61f..f93ab91056b8 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/LocalVariableDescriptorImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/LocalVariableDescriptorImpl.java
@@ -44,7 +44,6 @@ public class LocalVariableDescriptorImpl extends ValueDescriptorImpl implements
private boolean myIsPrimitive;
private boolean myIsNewLocal = true;
- private boolean myIsVisible = true;
public LocalVariableDescriptorImpl(Project project,
@NotNull LocalVariableProxyImpl local) {
@@ -54,6 +53,7 @@ public class LocalVariableDescriptorImpl extends ValueDescriptorImpl implements
myLocalVariable = local;
}
+ @Override
public LocalVariableProxyImpl getLocalVariable() {
return myLocalVariable;
}
@@ -83,13 +83,15 @@ public class LocalVariableDescriptorImpl extends ValueDescriptorImpl implements
return myIsNewLocal;
}
+ @Override
public boolean isPrimitive() {
return myIsPrimitive;
}
+ @Override
public Value calcValue(EvaluationContextImpl evaluationContext) throws EvaluateException {
- myIsVisible = myFrameProxy.isLocalVariableVisible(getLocalVariable());
- if (myIsVisible) {
+ boolean isVisible = myFrameProxy.isLocalVariableVisible(getLocalVariable());
+ if (isVisible) {
final String typeName = getLocalVariable().typeName();
myTypeName = typeName;
myIsPrimitive = DebuggerUtils.isPrimitiveType(typeName);
@@ -103,6 +105,7 @@ public class LocalVariableDescriptorImpl extends ValueDescriptorImpl implements
myIsNewLocal = aNew;
}
+ @Override
public void displayAs(NodeDescriptor descriptor) {
super.displayAs(descriptor);
if(descriptor instanceof LocalVariableDescriptorImpl) {
@@ -110,10 +113,12 @@ public class LocalVariableDescriptorImpl extends ValueDescriptorImpl implements
}
}
+ @Override
public String getName() {
return myLocalVariable.name();
}
+ @Override
public String calcValueName() {
final ClassRenderer classRenderer = NodeRendererSettings.getInstance().getClassRenderer();
StringBuilder buf = StringBuilderSpinAllocator.alloc();
@@ -130,6 +135,7 @@ public class LocalVariableDescriptorImpl extends ValueDescriptorImpl implements
}
}
+ @Override
public PsiExpression getDescriptorEvaluation(DebuggerContext context) throws EvaluateException {
PsiElementFactory elementFactory = JavaPsiFacade.getInstance(context.getProject()).getElementFactory();
try {
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/MessageDescriptor.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/MessageDescriptor.java
index 6f2aa4e09f0d..dbcd11cdea64 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/MessageDescriptor.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/MessageDescriptor.java
@@ -30,21 +30,21 @@ public class MessageDescriptor extends NodeDescriptorImpl {
private int myKind;
private String myMessage;
- public static MessageDescriptor DEBUG_INFO_UNAVAILABLE = new MessageDescriptor(DebuggerBundle.message("message.node.debug.info.not.available"));
- public static MessageDescriptor LOCAL_VARIABLES_INFO_UNAVAILABLE = new MessageDescriptor(
+ public static final MessageDescriptor DEBUG_INFO_UNAVAILABLE = new MessageDescriptor(DebuggerBundle.message("message.node.debug.info.not.available"));
+ public static final MessageDescriptor LOCAL_VARIABLES_INFO_UNAVAILABLE = new MessageDescriptor(
DebuggerBundle.message("message.node.local.variables.debug.info.not.available")
);
- public static MessageDescriptor ALL_ELEMENTS_IN_VISIBLE_RANGE_ARE_NULL = new MessageDescriptor(
+ public static final MessageDescriptor ALL_ELEMENTS_IN_VISIBLE_RANGE_ARE_NULL = new MessageDescriptor(
DebuggerBundle.message("message.node.all.array.elements.null"));
- public static MessageDescriptor ALL_ELEMENTS_IN_RANGE_ARE_NULL = new MessageDescriptor(
+ public static final MessageDescriptor ALL_ELEMENTS_IN_RANGE_ARE_NULL = new MessageDescriptor(
DebuggerBundle.message("message.node.all.elements.null"));
- public static MessageDescriptor ARRAY_IS_EMPTY = new MessageDescriptor(DebuggerBundle.message("message.node.empty.array"));
- public static MessageDescriptor CLASS_HAS_NO_FIELDS = new MessageDescriptor(DebuggerBundle.message("message.node.class.has.no.fields"));
- public static MessageDescriptor OBJECT_COLLECTED = new MessageDescriptor(DebuggerBundle.message("message.node.object.collected"));
- public static MessageDescriptor EVALUATING = new MessageDescriptor(XDebuggerUIConstants.COLLECTING_DATA_MESSAGE);
- public static MessageDescriptor THREAD_IS_RUNNING = new MessageDescriptor(DebuggerBundle.message("message.node.thread.running"));
- public static MessageDescriptor THREAD_IS_EMPTY = new MessageDescriptor(DebuggerBundle.message("message.node.thread.has.no.frames"));
- public static MessageDescriptor EVALUATION_NOT_POSSIBLE = new MessageDescriptor(DebuggerBundle.message("message.node.evaluation.not.possible", WARNING));
+ public static final MessageDescriptor ARRAY_IS_EMPTY = new MessageDescriptor(DebuggerBundle.message("message.node.empty.array"));
+ public static final MessageDescriptor CLASS_HAS_NO_FIELDS = new MessageDescriptor(DebuggerBundle.message("message.node.class.has.no.fields"));
+ public static final MessageDescriptor OBJECT_COLLECTED = new MessageDescriptor(DebuggerBundle.message("message.node.object.collected"));
+ public static final MessageDescriptor EVALUATING = new MessageDescriptor(XDebuggerUIConstants.COLLECTING_DATA_MESSAGE);
+ public static final MessageDescriptor THREAD_IS_RUNNING = new MessageDescriptor(DebuggerBundle.message("message.node.thread.running"));
+ public static final MessageDescriptor THREAD_IS_EMPTY = new MessageDescriptor(DebuggerBundle.message("message.node.thread.has.no.frames"));
+ public static final MessageDescriptor EVALUATION_NOT_POSSIBLE = new MessageDescriptor(DebuggerBundle.message("message.node.evaluation.not.possible", WARNING));
public MessageDescriptor(String message) {
this(message, INFORMATION);
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/NodeDescriptorFactoryImpl.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/NodeDescriptorFactoryImpl.java
index a98afc7c9eb8..54e4826f8d1d 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/NodeDescriptorFactoryImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/NodeDescriptorFactoryImpl.java
@@ -32,6 +32,7 @@ import com.intellij.debugger.ui.tree.UserExpressionDescriptor;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.sun.jdi.*;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
@@ -97,6 +98,7 @@ public class NodeDescriptorFactoryImpl implements NodeDescriptorFactory {
final MarkedDescriptorTree displayDescriptorTree = new MarkedDescriptorTree();
tree.dfst(new DescriptorTree.DFSTWalker() {
+ @Override
public void visit(NodeDescriptor parent, NodeDescriptor child) {
final DescriptorData<NodeDescriptor> descriptorData = DescriptorData.getDescriptorData(child);
descriptorTree.addChild(parent, child, descriptorData);
@@ -130,10 +132,12 @@ public class NodeDescriptorFactoryImpl implements NodeDescriptorFactory {
return descriptorTree;
}
+ @Override
public ArrayElementDescriptorImpl getArrayItemDescriptor(NodeDescriptor parent, ArrayReference array, int index) {
return getDescriptor(parent, new ArrayItemData(array, index));
}
+ @Override
public FieldDescriptorImpl getFieldDescriptor(NodeDescriptor parent, ObjectReference objRef, Field field) {
final DescriptorData<FieldDescriptorImpl> descriptorData;
if (objRef == null ) {
@@ -148,6 +152,7 @@ public class NodeDescriptorFactoryImpl implements NodeDescriptorFactory {
return getDescriptor(parent, descriptorData);
}
+ @Override
public LocalVariableDescriptorImpl getLocalVariableDescriptor(NodeDescriptor parent, LocalVariableProxy local) {
return getDescriptor(parent, new LocalData((LocalVariableProxyImpl)local));
}
@@ -156,7 +161,7 @@ public class NodeDescriptorFactoryImpl implements NodeDescriptorFactory {
return getDescriptor(parent, new ArgValueData(index, value, name));
}
- public StackFrameDescriptorImpl getStackFrameDescriptor(NodeDescriptorImpl parent, StackFrameProxyImpl frameProxy) {
+ public StackFrameDescriptorImpl getStackFrameDescriptor(@Nullable NodeDescriptorImpl parent, @NotNull StackFrameProxyImpl frameProxy) {
return getDescriptor(parent, new StackFrameData(frameProxy));
}
@@ -184,6 +189,7 @@ public class NodeDescriptorFactoryImpl implements NodeDescriptorFactory {
return getDescriptor(parent, new ThreadGroupData(group));
}
+ @Override
public UserExpressionDescriptor getUserExpressionDescriptor(NodeDescriptor parent, final DescriptorData<UserExpressionDescriptor> data) {
return getDescriptor(parent, data);
}
@@ -232,6 +238,7 @@ public class NodeDescriptorFactoryImpl implements NodeDescriptorFactory {
super(descriportTree);
}
+ @Override
protected NodeDescriptor getSearched(NodeDescriptor parent) {
NodeDescriptor searched = super.getSearched(parent);
if(searched == null) {
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/StackFrameDescriptorImpl.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/StackFrameDescriptorImpl.java
index 8e11e545dcd0..2b6f292e0d38 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/StackFrameDescriptorImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/StackFrameDescriptorImpl.java
@@ -16,10 +16,7 @@
package com.intellij.debugger.ui.impl.watch;
import com.intellij.debugger.SourcePosition;
-import com.intellij.debugger.engine.ContextUtil;
-import com.intellij.debugger.engine.DebugProcess;
-import com.intellij.debugger.engine.DebuggerManagerThreadImpl;
-import com.intellij.debugger.engine.DebuggerUtils;
+import com.intellij.debugger.engine.*;
import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
import com.intellij.debugger.jdi.StackFrameProxyImpl;
@@ -38,6 +35,7 @@ import com.intellij.util.ui.TextTransferable;
import com.intellij.xdebugger.frame.XStackFrame;
import com.intellij.xdebugger.impl.ui.tree.ValueMarkup;
import com.sun.jdi.*;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
@@ -61,8 +59,9 @@ public class StackFrameDescriptorImpl extends NodeDescriptorImpl implements Stac
private Icon myIcon = AllIcons.Debugger.StackFrame;
- public StackFrameDescriptorImpl(StackFrameProxyImpl frame, final MethodsTracker tracker) {
+ public StackFrameDescriptorImpl(@NotNull StackFrameProxyImpl frame, @NotNull MethodsTracker tracker) {
myFrame = frame;
+
try {
myUiIndex = frame.getFrameIndex();
myLocation = frame.location();
@@ -102,7 +101,12 @@ public class StackFrameDescriptorImpl extends NodeDescriptorImpl implements Stac
myIsInLibraryContent = false;
}
- myXStackFrame = myLocation == null ? null : getDebugProcess().getPositionManager().createStackFrame(myLocation);
+ myXStackFrame = myLocation == null ? null : ((DebugProcessImpl)getDebugProcess()).getPositionManager().createStackFrame(frame, (DebugProcessImpl)getDebugProcess(), myLocation);
+ }
+
+ @Nullable
+ public XStackFrame getXStackFrame() {
+ return myXStackFrame;
}
public int getUiIndex() {
@@ -110,10 +114,12 @@ public class StackFrameDescriptorImpl extends NodeDescriptorImpl implements Stac
}
@Override
+ @NotNull
public StackFrameProxyImpl getFrameProxy() {
return myFrame;
}
+ @NotNull
@Override
public DebugProcess getDebugProcess() {
return myFrame.getVirtualMachine().getDebugProcess();
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/ValueDescriptorImpl.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/ValueDescriptorImpl.java
index ec762c3ace72..5e9c81732613 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/ValueDescriptorImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/ValueDescriptorImpl.java
@@ -76,7 +76,8 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
myProject = project;
}
- public boolean isArray() {
+ @Override
+ public boolean isArray() {
return myValue instanceof ArrayReference;
}
@@ -84,11 +85,13 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
return myIsDirty;
}
- public boolean isLvalue() {
+ @Override
+ public boolean isLvalue() {
return myIsLvalue;
}
- public boolean isNull() {
+ @Override
+ public boolean isNull() {
return myValue == null;
}
@@ -97,6 +100,7 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
return myValue instanceof StringReference;
}
+ @Override
public boolean isPrimitive() {
return myValue instanceof PrimitiveValue;
}
@@ -113,6 +117,7 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
myShowIdLabel = showIdLabel;
}
+ @Override
public Value getValue() {
// the following code makes sense only if we do not use ObjectReference.enableCollection() / disableCollection()
// to keep temporary objects
@@ -124,6 +129,7 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
final Semaphore semaphore = new Semaphore();
semaphore.down();
evalContext.getDebugProcess().getManagerThread().invoke(new SuspendContextCommandImpl(evalContext.getSuspendContext()) {
+ @Override
public void contextAction() throws Exception {
// re-setting the context will cause value recalculation
try {
@@ -134,6 +140,7 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
}
}
+ @Override
protected void commandCancelled() {
semaphore.up();
}
@@ -145,12 +152,14 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
return myValue;
}
+ @Override
public boolean isExpandable() {
return myIsExpandable;
}
public abstract Value calcValue(EvaluationContextImpl evaluationContext) throws EvaluateException;
+ @Override
public final void setContext(EvaluationContextImpl evaluationContext) {
DebuggerManagerThreadImpl.assertIsManagerThread();
myStoredEvaluationContext = evaluationContext;
@@ -170,7 +179,7 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
myIsDirty = (value == null) ? myValue != null : !value.equals(myValue);
}
}
- catch (ObjectCollectedException e) {
+ catch (ObjectCollectedException ignored) {
myIsDirty = true;
}
}
@@ -227,6 +236,7 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
return exceptionObj;
}
+ @Override
public void setAncestor(NodeDescriptor oldDescriptor) {
super.setAncestor(oldDescriptor);
myIsNew = false;
@@ -237,6 +247,7 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
myIsLvalue = value;
}
+ @Override
protected String calcRepresentation(EvaluationContextImpl context, DescriptorLabelListener labelListener){
DebuggerManagerThreadImpl.assertIsManagerThread();
@@ -288,18 +299,21 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
}
+ @Override
public String setValueLabel(String label) {
final String customLabel = getCustomLabel(label);
myValueLabel = customLabel;
return setLabel(calcValueName() + " = " + customLabel);
}
+ @Override
public String setValueLabelFailed(EvaluateException e) {
final String label = setFailed(e);
setValueLabel(label);
return label;
}
+ @Override
public Icon setValueIcon(Icon icon) {
return myValueIcon = icon;
}
@@ -311,6 +325,7 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
public abstract String calcValueName();
+ @Override
public void displayAs(NodeDescriptor descriptor) {
if (descriptor instanceof ValueDescriptorImpl) {
ValueDescriptorImpl valueDescriptor = (ValueDescriptorImpl)descriptor;
@@ -370,6 +385,7 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
//use 'this' to reference parent node
//for ex. FieldDescriptorImpl should return
//this.fieldName
+ @Override
public abstract PsiExpression getDescriptorEvaluation(DebuggerContext context) throws EvaluateException;
public static String getIdLabel(ObjectReference objRef) {
@@ -425,12 +441,14 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
}
//Context is set to null
+ @Override
public void clear() {
super.clear();
setValueLabel("");
myIsExpandable = false;
}
+ @Override
@Nullable
public ValueMarkup getMarkup(final DebugProcess debugProcess) {
final Value value = getValue();
@@ -444,6 +462,7 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
return null;
}
+ @Override
public void setMarkup(final DebugProcess debugProcess, @Nullable final ValueMarkup markup) {
final Value value = getValue();
if (value instanceof ObjectReference) {
diff --git a/java/debugger/openapi/src/com/intellij/debugger/DebuggerContext.java b/java/debugger/openapi/src/com/intellij/debugger/DebuggerContext.java
index d2c918061155..b9bf49b94af0 100644
--- a/java/debugger/openapi/src/com/intellij/debugger/DebuggerContext.java
+++ b/java/debugger/openapi/src/com/intellij/debugger/DebuggerContext.java
@@ -18,8 +18,10 @@ package com.intellij.debugger;
import com.intellij.debugger.engine.StackFrameContext;
import com.intellij.debugger.engine.SuspendContext;
import com.intellij.openapi.project.Project;
+import org.jetbrains.annotations.Nullable;
-public interface DebuggerContext extends StackFrameContext{
+public interface DebuggerContext extends StackFrameContext {
+ @Nullable
SuspendContext getSuspendContext();
Project getProject();
diff --git a/java/debugger/openapi/src/com/intellij/debugger/PositionManagerFactory.java b/java/debugger/openapi/src/com/intellij/debugger/PositionManagerFactory.java
index e89d423deef0..ff118b89c10c 100644
--- a/java/debugger/openapi/src/com/intellij/debugger/PositionManagerFactory.java
+++ b/java/debugger/openapi/src/com/intellij/debugger/PositionManagerFactory.java
@@ -17,6 +17,7 @@ package com.intellij.debugger;
import com.intellij.debugger.engine.DebugProcess;
import com.intellij.openapi.extensions.ExtensionPointName;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
@@ -26,5 +27,5 @@ public abstract class PositionManagerFactory {
public static final ExtensionPointName<PositionManagerFactory> EP_NAME = ExtensionPointName.create("com.intellij.debugger.positionManagerFactory");
@Nullable
- public abstract PositionManager createPositionManager(DebugProcess process);
+ public abstract PositionManager createPositionManager(@NotNull DebugProcess process);
}
diff --git a/java/debugger/openapi/src/com/intellij/debugger/engine/DebugProcess.java b/java/debugger/openapi/src/com/intellij/debugger/engine/DebugProcess.java
index 43c7fd47f02f..66fea2d7f38c 100644
--- a/java/debugger/openapi/src/com/intellij/debugger/engine/DebugProcess.java
+++ b/java/debugger/openapi/src/com/intellij/debugger/engine/DebugProcess.java
@@ -16,7 +16,6 @@
package com.intellij.debugger.engine;
import com.intellij.debugger.PositionManager;
-import com.intellij.debugger.PositionManagerEx;
import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.engine.evaluation.EvaluationContext;
import com.intellij.debugger.engine.jdi.VirtualMachineProxy;
@@ -45,7 +44,7 @@ public interface DebugProcess {
RequestManager getRequestsManager();
- PositionManagerEx getPositionManager();
+ PositionManager getPositionManager();
VirtualMachineProxy getVirtualMachineProxy();
diff --git a/java/debugger/openapi/src/com/intellij/debugger/engine/StackFrameContext.java b/java/debugger/openapi/src/com/intellij/debugger/engine/StackFrameContext.java
index 442f2c7c0a89..f4fe5ca9bcb7 100644
--- a/java/debugger/openapi/src/com/intellij/debugger/engine/StackFrameContext.java
+++ b/java/debugger/openapi/src/com/intellij/debugger/engine/StackFrameContext.java
@@ -18,15 +18,10 @@ package com.intellij.debugger.engine;
import com.intellij.debugger.engine.jdi.StackFrameProxy;
import org.jetbrains.annotations.Nullable;
-/**
- * Created by IntelliJ IDEA.
- * User: lex
- * Date: Jun 3, 2003
- * Time: 5:58:58 PM
- * To change this template use Options | File Templates.
- */
public interface StackFrameContext {
@Nullable
- StackFrameProxy getFrameProxy();
- DebugProcess getDebugProcess();
+ StackFrameProxy getFrameProxy();
+
+ @Nullable
+ DebugProcess getDebugProcess();
}
diff --git a/java/debugger/openapi/src/com/intellij/debugger/engine/SuspendContext.java b/java/debugger/openapi/src/com/intellij/debugger/engine/SuspendContext.java
index ae89344dec63..be2c891d5fd0 100644
--- a/java/debugger/openapi/src/com/intellij/debugger/engine/SuspendContext.java
+++ b/java/debugger/openapi/src/com/intellij/debugger/engine/SuspendContext.java
@@ -18,7 +18,7 @@ package com.intellij.debugger.engine;
import com.intellij.debugger.engine.jdi.ThreadReferenceProxy;
public interface SuspendContext extends StackFrameContext {
- public int getSuspendPolicy();
+ int getSuspendPolicy();
ThreadReferenceProxy getThread();
}
diff --git a/java/debugger/openapi/src/com/intellij/debugger/engine/evaluation/EvaluationContext.java b/java/debugger/openapi/src/com/intellij/debugger/engine/evaluation/EvaluationContext.java
index e50ef4380968..f6e1531cb978 100644
--- a/java/debugger/openapi/src/com/intellij/debugger/engine/evaluation/EvaluationContext.java
+++ b/java/debugger/openapi/src/com/intellij/debugger/engine/evaluation/EvaluationContext.java
@@ -21,17 +21,24 @@ import com.intellij.debugger.engine.SuspendContext;
import com.intellij.openapi.project.Project;
import com.sun.jdi.ClassLoaderReference;
import com.sun.jdi.Value;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
public interface EvaluationContext extends StackFrameContext{
+ @Override
+ @NotNull
DebugProcess getDebugProcess();
EvaluationContext createEvaluationContext(Value value);
+ @NotNull
SuspendContext getSuspendContext();
Project getProject();
+ @Nullable
ClassLoaderReference getClassLoader() throws EvaluateException;
+ @Nullable
Value getThisObject();
}
diff --git a/java/debugger/openapi/src/com/intellij/debugger/engine/evaluation/expression/ExpressionEvaluator.java b/java/debugger/openapi/src/com/intellij/debugger/engine/evaluation/expression/ExpressionEvaluator.java
index 18528c275c39..04b869fcbd08 100644
--- a/java/debugger/openapi/src/com/intellij/debugger/engine/evaluation/expression/ExpressionEvaluator.java
+++ b/java/debugger/openapi/src/com/intellij/debugger/engine/evaluation/expression/ExpressionEvaluator.java
@@ -19,19 +19,12 @@ import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.engine.evaluation.EvaluationContext;
import com.sun.jdi.Value;
-/**
- * Created by IntelliJ IDEA.
- * User: lex
- * Date: Jul 15, 2003
- * Time: 1:44:35 PM
- * To change this template use Options | File Templates.
- */
public interface ExpressionEvaluator {
//call evaluate before
- public Value getValue();
+ Value getValue();
//call evaluate before
- public Modifier getModifier();
+ Modifier getModifier();
- public Value evaluate(final EvaluationContext context) throws EvaluateException;
+ Value evaluate(final EvaluationContext context) throws EvaluateException;
}
diff --git a/java/debugger/openapi/src/com/intellij/debugger/requests/ClassPrepareRequestor.java b/java/debugger/openapi/src/com/intellij/debugger/requests/ClassPrepareRequestor.java
index e58e05290b5b..e53ccf3e7d81 100644
--- a/java/debugger/openapi/src/com/intellij/debugger/requests/ClassPrepareRequestor.java
+++ b/java/debugger/openapi/src/com/intellij/debugger/requests/ClassPrepareRequestor.java
@@ -18,13 +18,6 @@ package com.intellij.debugger.requests;
import com.intellij.debugger.engine.DebugProcess;
import com.sun.jdi.ReferenceType;
-/**
- * Created by IntelliJ IDEA.
- * User: lex
- * Date: Jun 27, 2003
- * Time: 7:27:41 PM
- * To change this template use Options | File Templates.
- */
public interface ClassPrepareRequestor extends Requestor {
void processClassPrepare(DebugProcess debuggerProcess, final ReferenceType referenceType);
}
diff --git a/java/debugger/openapi/src/com/intellij/debugger/requests/Requestor.java b/java/debugger/openapi/src/com/intellij/debugger/requests/Requestor.java
index 9a1383296ccc..93bba20a02d2 100644
--- a/java/debugger/openapi/src/com/intellij/debugger/requests/Requestor.java
+++ b/java/debugger/openapi/src/com/intellij/debugger/requests/Requestor.java
@@ -15,12 +15,5 @@
*/
package com.intellij.debugger.requests;
-/**
- * Created by IntelliJ IDEA.
- * User: lex
- * Date: Jun 27, 2003
- * Time: 8:06:36 PM
- * To change this template use Options | File Templates.
- */
public interface Requestor {
}
diff --git a/java/execution/impl/src/com/intellij/execution/application/ApplicationConfiguration.java b/java/execution/impl/src/com/intellij/execution/application/ApplicationConfiguration.java
index f98100026007..2370ad3bda71 100644
--- a/java/execution/impl/src/com/intellij/execution/application/ApplicationConfiguration.java
+++ b/java/execution/impl/src/com/intellij/execution/application/ApplicationConfiguration.java
@@ -26,7 +26,6 @@ import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.util.JavaParametersUtil;
import com.intellij.execution.util.ProgramParametersUtil;
import com.intellij.openapi.components.PathMacroManager;
-import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.options.SettingsEditor;
@@ -49,7 +48,6 @@ import java.util.Map;
public class ApplicationConfiguration extends ModuleBasedConfiguration<JavaRunConfigurationModule>
implements CommonJavaRunConfigurationParameters, SingleClassConfiguration, RefactoringListenerProvider {
- private static final Logger LOG = Logger.getInstance("com.intellij.execution.application.ApplicationConfiguration");
public String MAIN_CLASS_NAME;
public String VM_PARAMETERS;
@@ -71,6 +69,7 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration<JavaRunCo
super(name, new JavaRunConfigurationModule(project, true), factory);
}
+ @Override
public void setMainClass(final PsiClass psiClass) {
final Module originalModule = getConfigurationModule().getModule();
setMainClassName(JavaExecutionUtil.getRuntimeQualifiedName(psiClass));
@@ -78,6 +77,7 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration<JavaRunCo
restoreOriginalModule(originalModule);
}
+ @Override
public RunProfileState getState(@NotNull final Executor executor, @NotNull final ExecutionEnvironment env) throws ExecutionException {
final JavaCommandLineState state = new JavaApplicationCommandLineState(this, env);
JavaRunConfigurationModule module = getConfigurationModule();
@@ -85,6 +85,7 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration<JavaRunCo
return state;
}
+ @Override
@NotNull
public SettingsEditor<? extends RunConfiguration> getConfigurationEditor() {
SettingsEditorGroup<ApplicationConfiguration> group = new SettingsEditorGroup<ApplicationConfiguration>();
@@ -94,12 +95,14 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration<JavaRunCo
return group;
}
+ @Override
public RefactoringElementListener getRefactoringElementListener(final PsiElement element) {
final RefactoringElementListener listener = RefactoringListeners.
getClassOrPackageListener(element, new RefactoringListeners.SingleClassConfigurationAccessor(this));
return RunConfigurationExtension.wrapRefactoringElementListener(element, this, listener);
}
+ @Override
@Nullable
public PsiClass getMainClass() {
return getConfigurationModule().findClass(MAIN_CLASS_NAME);
@@ -122,10 +125,12 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration<JavaRunCo
return ProgramRunnerUtil.shortenName(JavaExecutionUtil.getShortClassName(MAIN_CLASS_NAME), 6) + ".main()";
}
+ @Override
public void setMainClassName(final String qualifiedName) {
MAIN_CLASS_NAME = qualifiedName;
}
+ @Override
public void checkConfiguration() throws RuntimeConfigurationException {
JavaParametersUtil.checkAlternativeJRE(this);
final JavaRunConfigurationModule configurationModule = getConfigurationModule();
@@ -137,78 +142,96 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration<JavaRunCo
JavaRunConfigurationExtensionManager.checkConfigurationIsValid(this);
}
+ @Override
public void setVMParameters(String value) {
VM_PARAMETERS = value;
}
+ @Override
public String getVMParameters() {
return VM_PARAMETERS;
}
+ @Override
public void setProgramParameters(String value) {
PROGRAM_PARAMETERS = value;
}
+ @Override
public String getProgramParameters() {
return PROGRAM_PARAMETERS;
}
+ @Override
public void setWorkingDirectory(String value) {
WORKING_DIRECTORY = ExternalizablePath.urlValue(value);
}
+ @Override
public String getWorkingDirectory() {
return ExternalizablePath.localPathValue(WORKING_DIRECTORY);
}
+ @Override
public void setPassParentEnvs(boolean passParentEnvs) {
PASS_PARENT_ENVS = passParentEnvs;
}
+ @Override
@NotNull
public Map<String, String> getEnvs() {
return myEnvs;
}
+ @Override
public void setEnvs(@NotNull final Map<String, String> envs) {
myEnvs.clear();
myEnvs.putAll(envs);
}
+ @Override
public boolean isPassParentEnvs() {
return PASS_PARENT_ENVS;
}
+ @Override
@Nullable
public String getRunClass() {
return MAIN_CLASS_NAME;
}
+ @Override
@Nullable
public String getPackage() {
return null;
}
+ @Override
public boolean isAlternativeJrePathEnabled() {
return ALTERNATIVE_JRE_PATH_ENABLED;
}
+ @Override
public void setAlternativeJrePathEnabled(boolean enabled) {
- this.ALTERNATIVE_JRE_PATH_ENABLED = enabled;
+ ALTERNATIVE_JRE_PATH_ENABLED = enabled;
}
+ @Override
public String getAlternativeJrePath() {
return ALTERNATIVE_JRE_PATH;
}
+ @Override
public void setAlternativeJrePath(String path) {
- this.ALTERNATIVE_JRE_PATH = path;
+ ALTERNATIVE_JRE_PATH = path;
}
+ @Override
public Collection<Module> getValidModules() {
return JavaRunConfigurationModule.getModulesForClass(getProject(), MAIN_CLASS_NAME);
}
+ @Override
public void readExternal(final Element element) throws InvalidDataException {
PathMacroManager.getInstance(getProject()).expandPaths(element);
super.readExternal(element);
@@ -218,6 +241,7 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration<JavaRunCo
EnvironmentVariablesComponent.readExternal(element, getEnvs());
}
+ @Override
public void writeExternal(final Element element) throws WriteExternalException {
super.writeExternal(element);
JavaRunConfigurationExtensionManager.getInstance().writeExternal(this, element);
@@ -237,6 +261,7 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration<JavaRunCo
myConfiguration = configuration;
}
+ @Override
protected JavaParameters createJavaParameters() throws ExecutionException {
final JavaParameters params = new JavaParameters();
final JavaRunConfigurationModule module = myConfiguration.getConfigurationModule();
diff --git a/java/execution/openapi/src/com/intellij/execution/configurations/JavaCommandLineState.java b/java/execution/openapi/src/com/intellij/execution/configurations/JavaCommandLineState.java
index bab671678c57..47e0c35ade6b 100644
--- a/java/execution/openapi/src/com/intellij/execution/configurations/JavaCommandLineState.java
+++ b/java/execution/openapi/src/com/intellij/execution/configurations/JavaCommandLineState.java
@@ -30,6 +30,7 @@ public abstract class JavaCommandLineState extends CommandLineState implements J
super(environment);
}
+ @Override
public JavaParameters getJavaParameters() throws ExecutionException {
if (myParams == null) {
myParams = createJavaParameters();
@@ -37,6 +38,7 @@ public abstract class JavaCommandLineState extends CommandLineState implements J
return myParams;
}
+ @Override
@NotNull
protected OSProcessHandler startProcess() throws ExecutionException {
return JavaCommandLineStateUtil.startProcess(createCommandLine(), ansiColoringEnabled());
diff --git a/java/execution/openapi/src/com/intellij/execution/configurations/JavaParameters.java b/java/execution/openapi/src/com/intellij/execution/configurations/JavaParameters.java
index 99bb06703f0a..daf045c2638f 100644
--- a/java/execution/openapi/src/com/intellij/execution/configurations/JavaParameters.java
+++ b/java/execution/openapi/src/com/intellij/execution/configurations/JavaParameters.java
@@ -41,7 +41,7 @@ public class JavaParameters extends SimpleJavaParameters {
}
final String jdkHome = jdk.getHomeDirectory().getPresentableUrl();
- if (jdkHome == null || jdkHome.length() == 0) {
+ if (jdkHome.isEmpty()) {
throw new CantRunException(ExecutionBundle.message("home.directory.not.specified.for.jdk.error.message"));
}
return jdkHome;
diff --git a/java/execution/openapi/src/com/intellij/execution/process/DefaultJavaProcessHandler.java b/java/execution/openapi/src/com/intellij/execution/process/DefaultJavaProcessHandler.java
index 444f66d55443..b6721ac58fed 100644
--- a/java/execution/openapi/src/com/intellij/execution/process/DefaultJavaProcessHandler.java
+++ b/java/execution/openapi/src/com/intellij/execution/process/DefaultJavaProcessHandler.java
@@ -39,6 +39,7 @@ public class DefaultJavaProcessHandler extends OSProcessHandler {
myCharset = charset;
}
+ @Override
public Charset getCharset() {
return myCharset;
}
diff --git a/java/idea-ui/src/com/intellij/facet/impl/ui/actions/AddFacetToModuleAction.java b/java/idea-ui/src/com/intellij/facet/impl/ui/actions/AddFacetToModuleAction.java
index 6e82be2ccbb1..1b17fc7aa8cd 100644
--- a/java/idea-ui/src/com/intellij/facet/impl/ui/actions/AddFacetToModuleAction.java
+++ b/java/idea-ui/src/com/intellij/facet/impl/ui/actions/AddFacetToModuleAction.java
@@ -100,14 +100,14 @@ public class AddFacetToModuleAction extends AnAction implements DumbAware {
public static Collection<AnAction> createAddFrameworkActions(FacetEditorFacade editor, Project project) {
SortedMap<String, AnAction> actions = new TreeMap<String, AnAction>();
- for (FacetType type : FacetTypeRegistry.getInstance().getFacetTypes()) {
- actions.put(type.getPresentableName(), new AddFacetToModuleAction(editor, project, type));
- }
for (FrameworkTypeEx frameworkType : FrameworkTypeEx.EP_NAME.getExtensions()) {
- final AnAction action = new AddFrameworkSupportInProjectStructureAction(frameworkType, frameworkType.createProvider(),
+ final AnAction action = new AddFrameworkSupportInProjectStructureAction(frameworkType, frameworkType.createProvider(),
ModuleStructureConfigurable.getInstance(project));
actions.put(frameworkType.getPresentableName(), action);
}
+ for (FacetType type : FacetTypeRegistry.getInstance().getFacetTypes()) {
+ actions.put(type.getPresentableName(), new AddFacetToModuleAction(editor, project, type));
+ }
return actions.values();
}
}
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 2c8ac124a2f4..2a61684a6619 100644
--- a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.java
+++ b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.java
@@ -21,6 +21,7 @@ import com.intellij.ide.util.PropertiesComponent;
import com.intellij.ide.util.frameworkSupport.FrameworkRole;
import com.intellij.ide.util.frameworkSupport.FrameworkSupportUtil;
import com.intellij.ide.util.newProjectWizard.AddSupportForFrameworksPanel;
+import com.intellij.ide.util.newProjectWizard.FrameworkSupportNode;
import com.intellij.ide.util.newProjectWizard.TemplatesGroup;
import com.intellij.ide.util.newProjectWizard.impl.FrameworkSupportModelBase;
import com.intellij.ide.util.newProjectWizard.modes.CreateFromTemplateMode;
@@ -50,10 +51,7 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.platform.ProjectTemplate;
import com.intellij.platform.ProjectTemplateEP;
import com.intellij.platform.ProjectTemplatesFactory;
-import com.intellij.platform.templates.ArchivedProjectTemplate;
-import com.intellij.platform.templates.BuilderBasedTemplate;
-import com.intellij.platform.templates.LocalArchivedTemplate;
-import com.intellij.platform.templates.RemoteTemplatesFactory;
+import com.intellij.platform.templates.*;
import com.intellij.ui.*;
import com.intellij.ui.SingleSelectionModel;
import com.intellij.ui.components.JBList;
@@ -91,6 +89,12 @@ public class ProjectTypeStep extends ModuleWizardStep implements Disposable {
return o.getId();
}
};
+ public static final Function<FrameworkSupportNode, String> NODE_STRING_FUNCTION = new Function<FrameworkSupportNode, String>() {
+ @Override
+ public String fun(FrameworkSupportNode node) {
+ return node.getId();
+ }
+ };
private JPanel myPanel;
private JPanel myOptionsPanel;
@@ -377,8 +381,9 @@ public class ProjectTypeStep extends ModuleWizardStep implements Disposable {
private void setTemplatesList(TemplatesGroup group, Collection<ProjectTemplate> templates, boolean preserveSelection) {
List<ProjectTemplate> list = new ArrayList<ProjectTemplate>(templates);
- if (group.getModuleBuilder() != null) {
- list.add(0, new BuilderBasedTemplate(group.getModuleBuilder()));
+ ModuleBuilder moduleBuilder = group.getModuleBuilder();
+ if (moduleBuilder != null && !(moduleBuilder instanceof TemplateModuleBuilder)) {
+ list.add(0, new BuilderBasedTemplate(moduleBuilder));
}
if (group.getParentGroup() == null) {
for (TemplatesGroup templatesGroup : myTemplatesMap.keySet()) {
@@ -426,7 +431,23 @@ public class ProjectTypeStep extends ModuleWizardStep implements Disposable {
}
public Collection<ProjectTemplate> getAvailableTemplates() {
- return myCurrentCard != FRAMEWORKS_CARD ? Collections.<ProjectTemplate>emptyList() : myTemplatesMap.get(getSelectedGroup());
+ if (myCurrentCard != FRAMEWORKS_CARD) {
+ return Collections.emptyList();
+ }
+ else {
+ Collection<ProjectTemplate> templates = myTemplatesMap.get(getSelectedGroup());
+ List<FrameworkSupportNode> nodes = myFrameworksPanel.getSelectedNodes();
+ if (nodes.isEmpty()) return templates;
+ final List<String> selectedFrameworks = ContainerUtil.map(nodes, NODE_STRING_FUNCTION);
+ return ContainerUtil.filter(templates, new Condition<ProjectTemplate>() {
+ @Override
+ public boolean value(ProjectTemplate template) {
+ if (!(template instanceof ArchivedProjectTemplate)) return true;
+ List<String> frameworks = ((ArchivedProjectTemplate)template).getFrameworks();
+ return frameworks.containsAll(selectedFrameworks);
+ }
+ });
+ }
}
public void onWizardFinished() throws CommitStepException {
@@ -469,19 +490,6 @@ public class ProjectTypeStep extends ModuleWizardStep implements Disposable {
return myProjectTypeList;
}
- @TestOnly
- public boolean setSelectedTemplate(String group, String name) {
- ListModel model = myProjectTypeList.getModel();
- for (int i = 0; i < model.getSize(); i++) {
- if (group.equals(((TemplatesGroup)model.getElementAt(i)).getName())) {
- myProjectTypeList.setSelectedIndex(i);
- if (name == null) return getSelectedGroup().getName().equals(group);
- return myTemplatesList.setSelectedTemplate(name);
- }
- }
- return false;
- }
-
@Override
public void dispose() {
}
@@ -500,7 +508,7 @@ public class ProjectTypeStep extends ModuleWizardStep implements Disposable {
if (url != null) {
LocalArchivedTemplate template = new LocalArchivedTemplate(url, classLoader);
if (ep.category) {
- TemplateBasedCategory category = new TemplateBasedCategory(template);
+ TemplateBasedCategory category = new TemplateBasedCategory(template, ep.projectType);
myTemplatesMap.putValue(new TemplatesGroup(category), template);
}
else {
@@ -562,4 +570,22 @@ public class ProjectTypeStep extends ModuleWizardStep implements Disposable {
myWizard.getSequence().setType(builder.getBuilderId());
}
}
+
+ @TestOnly
+ public boolean setSelectedTemplate(String group, String name) {
+ ListModel model = myProjectTypeList.getModel();
+ for (int i = 0; i < model.getSize(); i++) {
+ if (group.equals(((TemplatesGroup)model.getElementAt(i)).getName())) {
+ myProjectTypeList.setSelectedIndex(i);
+ if (name == null) return getSelectedGroup().getName().equals(group);
+ return myTemplatesList.setSelectedTemplate(name);
+ }
+ }
+ return false;
+ }
+
+ @TestOnly
+ public AddSupportForFrameworksPanel getFrameworksPanel() {
+ return myFrameworksPanel;
+ }
}
diff --git a/java/idea-ui/src/com/intellij/ide/projectWizard/TemplateBasedCategory.java b/java/idea-ui/src/com/intellij/ide/projectWizard/TemplateBasedCategory.java
index 6c0067399142..f5aa60baebd1 100644
--- a/java/idea-ui/src/com/intellij/ide/projectWizard/TemplateBasedCategory.java
+++ b/java/idea-ui/src/com/intellij/ide/projectWizard/TemplateBasedCategory.java
@@ -27,14 +27,16 @@ import javax.swing.*;
public class TemplateBasedCategory extends ProjectCategory {
private final ArchivedProjectTemplate myTemplate;
+ private final String myProjectType;
- public TemplateBasedCategory(ArchivedProjectTemplate template) {
+ public TemplateBasedCategory(ArchivedProjectTemplate template, String projectType) {
myTemplate = template;
+ myProjectType = projectType;
}
@Override
public String getDisplayName() {
- return myTemplate.getName();
+ return myProjectType;
}
@Override
diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java
index f772f04660ec..200d63580438 100644
--- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java
+++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java
@@ -368,7 +368,7 @@ public class AddSupportForFrameworksPanel implements Disposable {
return !getSelectedNodes().isEmpty();
}
- private List<FrameworkSupportNode> getSelectedNodes() {
+ public List<FrameworkSupportNode> getSelectedNodes() {
List<FrameworkSupportNode> list = new ArrayList<FrameworkSupportNode>();
if (myRoots != null) {
addChildFrameworks(myRoots, list);
diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworksTree.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworksTree.java
index 894bfcb9ce42..b7a4e12b7681 100644
--- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworksTree.java
+++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworksTree.java
@@ -20,10 +20,12 @@ import com.intellij.ide.util.newProjectWizard.impl.FrameworkSupportModelBase;
import com.intellij.ui.*;
import com.intellij.util.containers.Convertor;
import com.intellij.util.ui.tree.TreeUtil;
+import org.jetbrains.annotations.TestOnly;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import java.awt.*;
import java.awt.event.MouseEvent;
@@ -123,4 +125,19 @@ public class FrameworksTree extends CheckboxTree {
}
}
}
+
+ @TestOnly
+ public boolean selectFramework(final String id, final boolean checked) {
+ TreeNode root = (TreeNode)getModel().getRoot();
+ return !TreeUtil.traverse(root, new TreeUtil.Traverse() {
+ @Override
+ public boolean accept(Object node) {
+ if (node instanceof FrameworkSupportNode && id.equals(((FrameworkSupportNode)node).getId())) {
+ ((FrameworkSupportNode)node).setChecked(checked);
+ return false;
+ }
+ return true;
+ }
+ });
+ }
}
diff --git a/java/idea-ui/src/com/intellij/platform/templates/ArchivedProjectTemplate.java b/java/idea-ui/src/com/intellij/platform/templates/ArchivedProjectTemplate.java
index 8937dd97dcc8..35944487e624 100644
--- a/java/idea-ui/src/com/intellij/platform/templates/ArchivedProjectTemplate.java
+++ b/java/idea-ui/src/com/intellij/platform/templates/ArchivedProjectTemplate.java
@@ -15,28 +15,46 @@
*/
package com.intellij.platform.templates;
+import com.intellij.facet.frameworks.beans.Artifact;
import com.intellij.ide.util.projectWizard.ModuleBuilder;
+import com.intellij.ide.util.projectWizard.ProjectTemplateParameterFactory;
import com.intellij.ide.util.projectWizard.WizardInputField;
import com.intellij.openapi.module.ModuleType;
import com.intellij.openapi.ui.ValidationInfo;
import com.intellij.platform.ProjectTemplate;
+import com.intellij.util.Function;
+import com.intellij.util.containers.ContainerUtil;
+import com.intellij.util.xmlb.XmlSerializer;
+import com.intellij.util.xmlb.annotations.AbstractCollection;
+import com.intellij.util.xmlb.annotations.Property;
+import com.intellij.util.xmlb.annotations.Tag;
+import org.jdom.Element;
+import org.jdom.Namespace;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.zip.ZipInputStream;
/**
* @author Dmitry Avdeev
- * Date: 11/14/12
*/
+@Tag("template")
public abstract class ArchivedProjectTemplate implements ProjectTemplate {
+ public static final String INPUT_FIELD = "input-field";
+
protected final String myDisplayName;
@Nullable private final String myCategory;
+ private List<WizardInputField> myInputFields = Collections.emptyList();
+ private List<String> myFrameworks = new ArrayList<String>();
+ private List<Artifact> myArtifacts = new ArrayList<Artifact>();
+
public ArchivedProjectTemplate(@NotNull String displayName, @Nullable String category) {
myDisplayName = displayName;
myCategory = category;
@@ -60,7 +78,31 @@ public abstract class ArchivedProjectTemplate implements ProjectTemplate {
return new TemplateModuleBuilder(this, getModuleType(), getInputFields());
}
- public abstract List<WizardInputField> getInputFields();
+ @NotNull
+ public List<WizardInputField> getInputFields() {
+ return myInputFields;
+ }
+
+ @Property(surroundWithTag = false)
+ @AbstractCollection(elementTag = "artifact", surroundWithTag = false)
+ public List<Artifact> getArtifacts() {
+ return myArtifacts;
+ }
+
+ public void setArtifacts(List<Artifact> artifacts) {
+ myArtifacts = artifacts;
+ }
+
+ @NotNull
+ @Property(surroundWithTag = false)
+ @AbstractCollection(elementTag = "framework", surroundWithTag = false, elementValueAttribute = "")
+ public List<String> getFrameworks() {
+ return myFrameworks;
+ }
+
+ public void setFrameworks(List<String> frameworks) {
+ myFrameworks = frameworks;
+ }
@Nullable
@Override
@@ -74,4 +116,22 @@ public abstract class ArchivedProjectTemplate implements ProjectTemplate {
public String getCategory() {
return myCategory;
}
+
+ public void populateFromElement(@NotNull Element element, final Namespace ns) {
+ XmlSerializer.deserializeInto(this, element);
+ myInputFields = getFields(element, ns);
+ }
+
+ private static List<WizardInputField> getFields(Element templateElement, final Namespace ns) {
+ //noinspection unchecked
+ return ContainerUtil
+ .mapNotNull(templateElement.getChildren(INPUT_FIELD, ns), new Function<Element, WizardInputField>() {
+ @Override
+ public WizardInputField fun(Element element) {
+ ProjectTemplateParameterFactory factory = WizardInputField.getFactoryById(element.getText());
+ return factory == null ? null : factory.createField(element.getAttributeValue(RemoteTemplatesFactory.INPUT_DEFAULT));
+ }
+ });
+ }
+
}
diff --git a/java/idea-ui/src/com/intellij/platform/templates/LocalArchivedTemplate.java b/java/idea-ui/src/com/intellij/platform/templates/LocalArchivedTemplate.java
index e9c84800dafe..df6a4c285c8f 100644
--- a/java/idea-ui/src/com/intellij/platform/templates/LocalArchivedTemplate.java
+++ b/java/idea-ui/src/com/intellij/platform/templates/LocalArchivedTemplate.java
@@ -46,12 +46,13 @@ import java.util.zip.ZipInputStream;
public class LocalArchivedTemplate extends ArchivedProjectTemplate {
public static final String DESCRIPTION_PATH = Project.DIRECTORY_STORE_FOLDER + "/description.html";
- static final String IDEA_INPUT_FIELDS_XML = Project.DIRECTORY_STORE_FOLDER + "/project-template.xml";
+ static final String TEMPLATE_DESCRIPTOR = Project.DIRECTORY_STORE_FOLDER + "/project-template.xml";
private final URL myArchivePath;
private final ModuleType myModuleType;
private List<WizardInputField> myInputFields = Collections.emptyList();
private Icon myIcon;
+ private List<String> myFrameworks = Collections.emptyList();
public LocalArchivedTemplate(@NotNull URL archivePath,
@NotNull ClassLoader classLoader) {
@@ -62,13 +63,13 @@ public class LocalArchivedTemplate extends ArchivedProjectTemplate {
String s = readEntry(new Condition<ZipEntry>() {
@Override
public boolean value(ZipEntry entry) {
- return entry.getName().endsWith(IDEA_INPUT_FIELDS_XML);
+ return entry.getName().endsWith(TEMPLATE_DESCRIPTOR);
}
});
if (s != null) {
try {
Element templateElement = JDOMUtil.loadDocument(s).getRootElement();
- myInputFields = RemoteTemplatesFactory.getFields(templateElement, Namespace.NO_NAMESPACE);
+ populateFromElement(templateElement, Namespace.NO_NAMESPACE);
String iconPath = templateElement.getChildText("icon-path");
if (iconPath != null) {
myIcon = IconLoader.findIcon(iconPath, classLoader);
@@ -145,11 +146,18 @@ public class LocalArchivedTemplate extends ArchivedProjectTemplate {
return myModuleType;
}
+ @NotNull
@Override
public List<WizardInputField> getInputFields() {
return myInputFields;
}
+ @NotNull
+ @Override
+ public List<String> getFrameworks() {
+ return myFrameworks;
+ }
+
@Override
public ZipInputStream getStream() throws IOException {
return new ZipInputStream(myArchivePath.openStream());
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 dd30f52a5386..bcdd02433832 100644
--- a/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java
+++ b/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java
@@ -16,9 +16,7 @@
package com.intellij.platform.templates;
import com.intellij.ide.plugins.PluginManager;
-import com.intellij.ide.util.projectWizard.ProjectTemplateParameterFactory;
import com.intellij.ide.util.projectWizard.WizardContext;
-import com.intellij.ide.util.projectWizard.WizardInputField;
import com.intellij.openapi.application.ApplicationInfo;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.extensions.PluginId;
@@ -56,9 +54,14 @@ public class RemoteTemplatesFactory extends ProjectTemplatesFactory {
private static final String URL = "http://download.jetbrains.com/idea/project_templates/";
- public static final String INPUT_FIELD = "input-field";
public static final String TEMPLATE = "template";
public static final String INPUT_DEFAULT = "default";
+ public static final Function<Element, String> ELEMENT_STRING_FUNCTION = new Function<Element, String>() {
+ @Override
+ public String fun(Element element) {
+ return element.getText();
+ }
+ };
private final ClearableLazyValue<MultiMap<String, ArchivedProjectTemplate>> myTemplates = new ClearableLazyValue<MultiMap<String, ArchivedProjectTemplate>>() {
@NotNull
@@ -133,52 +136,19 @@ public class RemoteTemplatesFactory extends ProjectTemplatesFactory {
final ModuleType moduleType = ModuleTypeManager.getInstance().findByID(type);
- final List<WizardInputField> inputFields = getFields(element, ns);
final String path = element.getChildText("path", ns);
final String description = element.getChildTextTrim("description", ns);
String name = element.getChildTextTrim("name", ns);
- return new ArchivedProjectTemplate(name, element.getChildTextTrim("category")) {
- @Override
- protected ModuleType getModuleType() {
- return moduleType;
- }
-
- @Override
- public List<WizardInputField> getInputFields() {
- return inputFields;
- }
-
- @Override
- public ZipInputStream getStream() throws IOException {
- final HttpURLConnection connection = getConnection(path);
- return new ZipInputStream(connection.getInputStream()) {
- @Override
- public void close() throws IOException {
- super.close();
- connection.disconnect();
- }
- };
- }
-
- @Nullable
- @Override
- public String getDescription() {
- return description;
- }
- };
+ RemoteProjectTemplate template = new RemoteProjectTemplate(name, element, moduleType, path, description);
+ template.populateFromElement(element, ns);
+ return template;
}
});
}
- static List<WizardInputField> getFields(Element templateElement, final Namespace ns) {
- //noinspection unchecked
- return ContainerUtil.mapNotNull(templateElement.getChildren(INPUT_FIELD, ns), new Function<Element, WizardInputField>() {
- @Override
- public WizardInputField fun(Element element) {
- ProjectTemplateParameterFactory factory = WizardInputField.getFactoryById(element.getText());
- return factory == null ? null : factory.createField(element.getAttributeValue(INPUT_DEFAULT));
- }
- });
+ public static List<String> getFrameworks(Element element) {
+ List<Element> frameworks = element.getChildren("framework");
+ return ContainerUtil.map(frameworks, ELEMENT_STRING_FUNCTION);
}
private static boolean checkRequiredPlugins(Element element, Namespace ns) {
@@ -201,4 +171,43 @@ public class RemoteTemplatesFactory extends ProjectTemplatesFactory {
}
private final static Logger LOG = Logger.getInstance(RemoteTemplatesFactory.class);
+
+ private static class RemoteProjectTemplate extends ArchivedProjectTemplate {
+ private final ModuleType myModuleType;
+ private final String myPath;
+ private final String myDescription;
+
+ public RemoteProjectTemplate(String name,
+ Element element,
+ ModuleType moduleType,
+ String path, String description) {
+ super(name, element.getChildTextTrim("category"));
+ myModuleType = moduleType;
+ myPath = path;
+ myDescription = description;
+ }
+
+ @Override
+ protected ModuleType getModuleType() {
+ return myModuleType;
+ }
+
+ @Override
+ public ZipInputStream getStream() throws IOException {
+ final HttpURLConnection connection = getConnection(myPath);
+ return new ZipInputStream(connection.getInputStream()) {
+ @Override
+ public void close() throws IOException {
+ super.close();
+ connection.disconnect();
+ }
+ };
+ }
+
+ @Nullable
+ @Override
+ public String getDescription() {
+ return myDescription;
+ }
+ }
}
diff --git a/java/idea-ui/src/com/intellij/platform/templates/SaveProjectAsTemplateAction.java b/java/idea-ui/src/com/intellij/platform/templates/SaveProjectAsTemplateAction.java
index 2ef20073fc12..c2fafe029658 100644
--- a/java/idea-ui/src/com/intellij/platform/templates/SaveProjectAsTemplateAction.java
+++ b/java/idea-ui/src/com/intellij/platform/templates/SaveProjectAsTemplateAction.java
@@ -143,7 +143,7 @@ public class SaveProjectAsTemplateAction extends AnAction {
writeFile(LocalArchivedTemplate.DESCRIPTION_PATH, description, project, dir, stream, true);
if (replaceParameters) {
String text = getInputFieldsText(parameters);
- writeFile(LocalArchivedTemplate.IDEA_INPUT_FIELDS_XML, text, project, dir, stream, false);
+ writeFile(LocalArchivedTemplate.TEMPLATE_DESCRIPTOR, text, project, dir, stream, false);
}
FileIndex index = moduleToSave == null
@@ -299,7 +299,7 @@ public class SaveProjectAsTemplateAction extends AnAction {
private static String getInputFieldsText(Map<String, String> parameters) {
Element element = new Element(RemoteTemplatesFactory.TEMPLATE);
for (Map.Entry<String, String> entry : parameters.entrySet()) {
- Element field = new Element(RemoteTemplatesFactory.INPUT_FIELD);
+ Element field = new Element(ArchivedProjectTemplate.INPUT_FIELD);
field.setText(entry.getValue());
field.setAttribute(RemoteTemplatesFactory.INPUT_DEFAULT, entry.getKey());
element.addContent(field);
diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeCastFix.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeCastFix.java
index a5104f1deb51..68e3554ce314 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeCastFix.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeCastFix.java
@@ -81,14 +81,15 @@ public class AddTypeCastFix extends LocalQuickFixAndIntentionActionOnPsiElement
originalExpression.replace(typeCast);
}
- static PsiExpression createCastExpression(PsiExpression originalExpression, Project project, PsiType type) {
+ static PsiExpression createCastExpression(PsiExpression original, Project project, PsiType type) {
// remove nested casts
- PsiElement expression = PsiUtil.deparenthesizeExpression(originalExpression);
+ PsiElement expression = PsiUtil.deparenthesizeExpression(original);
if (expression == null) return null;
- PsiElementFactory factory = JavaPsiFacade.getInstance(originalExpression.getProject()).getElementFactory();
- PsiTypeCastExpression typeCast = (PsiTypeCastExpression)factory.createExpressionFromText("(Type)value", null);
- assertNotNull(typeCast.getCastType()).replace(factory.createTypeElement(type));
+ PsiElementFactory factory = JavaPsiFacade.getInstance(original.getProject()).getElementFactory();
+ if (type instanceof PsiEllipsisType) type = ((PsiEllipsisType)type).toArrayType();
+ String text = "(" + type.getCanonicalText(false) + ")value";
+ PsiTypeCastExpression typeCast = (PsiTypeCastExpression)factory.createExpressionFromText(text, original);
typeCast = (PsiTypeCastExpression)CodeStyleManager.getInstance(project).reformat(typeCast);
if (expression instanceof PsiConditionalExpression) {
@@ -124,5 +125,4 @@ public class AddTypeCastFix extends LocalQuickFixAndIntentionActionOnPsiElement
public boolean startInWriteAction() {
return true;
}
-
}
diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/StreamApiMigrationInspection.java b/java/java-analysis-impl/src/com/intellij/codeInspection/StreamApiMigrationInspection.java
index 919fb4ea28db..b06ba2a5358b 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInspection/StreamApiMigrationInspection.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/StreamApiMigrationInspection.java
@@ -195,6 +195,13 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
PsiStatement body = foreachStatement.getBody();
final PsiExpression iteratedValue = foreachStatement.getIteratedValue();
if (body != null && iteratedValue != null) {
+ final Collection<PsiComment> comments = PsiTreeUtil.findChildrenOfType(body, PsiComment.class);
+
+ final PsiElement parent = foreachStatement.getParent();
+ for (PsiElement comment : PsiTreeUtil.findChildrenOfType(body, PsiComment.class)) {
+ parent.addBefore(comment, foreachStatement);
+ }
+
final PsiParameter parameter = foreachStatement.getIterationParameter();
final PsiIfStatement ifStmt = extractIfStatement(body);
@@ -294,13 +301,19 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
iteration += ").collect(java.util.stream.Collectors.";
String variableName = null;
- PsiExpression initializer = null;
+ PsiExpression primitiveInitializer = null;
final PsiExpression qualifierExpression = methodCallExpression.getMethodExpression().getQualifierExpression();
if (qualifierExpression instanceof PsiReferenceExpression) {
final PsiElement resolve = ((PsiReferenceExpression)qualifierExpression).resolve();
if (resolve instanceof PsiVariable) {
if (resolve instanceof PsiLocalVariable && foreachStatement.equals(PsiTreeUtil.skipSiblingsForward(resolve.getParent(), PsiWhiteSpace.class))) {
- initializer = ((PsiVariable)resolve).getInitializer();
+ final PsiExpression initializer = ((PsiVariable)resolve).getInitializer();
+ if (initializer instanceof PsiNewExpression) {
+ final PsiExpressionList argumentList = ((PsiNewExpression)initializer).getArgumentList();
+ if (argumentList != null && argumentList.getExpressions().length == 0) {
+ primitiveInitializer = initializer;
+ }
+ }
}
variableName = ((PsiVariable)resolve).getName() + ".";
}
@@ -308,19 +321,26 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
variableName = "";
}
+ if (variableName != null) {
+ final PsiElement parent = foreachStatement.getParent();
+ for (PsiElement comment : PsiTreeUtil.findChildrenOfType(body, PsiComment.class)) {
+ parent.addBefore(comment, foreachStatement);
+ }
+ }
+
PsiElement result = null;
- if (initializer != null) {
- final PsiType initializerType = initializer.getType();
+ if (primitiveInitializer != null) {
+ final PsiType initializerType = primitiveInitializer.getType();
final PsiClassType rawType = initializerType instanceof PsiClassType ? ((PsiClassType)initializerType).rawType() : null;
if (rawType != null && rawType.equalsToText(CommonClassNames.JAVA_UTIL_ARRAY_LIST)) {
iteration += "toList()";
} else if (rawType != null && rawType.equalsToText(CommonClassNames.JAVA_UTIL_HASH_SET)) {
iteration += "toSet()";
} else {
- iteration += "toCollection(() -> " + initializer.getText() +")";
+ iteration += "toCollection(() -> " + primitiveInitializer.getText() +")";
}
iteration += ")";
- result = initializer.replace(JavaPsiFacade.getElementFactory(project).createExpressionFromText(iteration, foreachStatement));
+ result = primitiveInitializer.replace(JavaPsiFacade.getElementFactory(project).createExpressionFromText(iteration, foreachStatement));
foreachStatement.delete();
} else if (variableName != null){
iteration += "toList())";
diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java
index 75f241975083..68ac7f694f7c 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java
@@ -1602,6 +1602,7 @@ public class ControlFlowAnalyzer extends JavaElementVisitor {
return Collections.emptyList();
}
+ @Nullable
public static PsiAnnotation findContractAnnotation(PsiMethod method) {
return AnnotationUtil.findAnnotation(method, ORG_JETBRAINS_ANNOTATIONS_CONTRACT);
}
@@ -1741,6 +1742,9 @@ public class ControlFlowAnalyzer extends JavaElementVisitor {
if (psiVariable != null) {
DfaVariableValue dfaVariable = myFactory.getVarFactory().createVariableValue(psiVariable, false);
addInstruction(new FlushVariableInstruction(dfaVariable));
+ if (psiVariable instanceof PsiField) {
+ addInstruction(new FlushVariableInstruction(null));
+ }
}
}
@@ -1774,6 +1778,9 @@ public class ControlFlowAnalyzer extends JavaElementVisitor {
if (psiVariable != null) {
DfaVariableValue dfaVariable = myFactory.getVarFactory().createVariableValue(psiVariable, false);
addInstruction(new FlushVariableInstruction(dfaVariable));
+ if (psiVariable instanceof PsiField) {
+ addInstruction(new FlushVariableInstruction(null));
+ }
}
}
}
diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java
index c3f81ec0da3a..a1df3bc6424a 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DfaMemoryStateImpl.java
@@ -614,7 +614,7 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
private void updateVarStateOnComparison(DfaVariableValue dfaVar, DfaValue value) {
if (!isUnknownState(dfaVar)) {
- if (isNull(value)) {
+ if (value instanceof DfaConstValue && ((DfaConstValue)value).getValue() == null) {
setVariableState(dfaVar, getVariableState(dfaVar).withNullability(Nullness.NULLABLE));
} else if (isNotNull(value) && !isNotNull(dfaVar)) {
setVariableState(dfaVar, getVariableState(dfaVar).withNullability(Nullness.UNKNOWN));
@@ -815,20 +815,34 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
@Override
public void flushFields() {
+ Set<DfaVariableValue> vars = ContainerUtil.newLinkedHashSet(getChangedVariables());
for (EqClass aClass : myEqClasses) {
if (aClass != null) {
- for (DfaVariableValue value : aClass.getVariables()) {
- if (value.isFlushableByCalls()) {
- doFlush(value, true);
- }
- }
+ vars.addAll(aClass.getVariables());
}
}
- for (DfaVariableValue value : new ArrayList<DfaVariableValue>(getChangedVariables())) {
+ for (DfaVariableValue value : vars) {
if (value.isFlushableByCalls()) {
- doFlush(value, true);
+ doFlush(value, shouldMarkUnknown(value));
+ }
+ }
+ }
+
+ private boolean shouldMarkUnknown(DfaVariableValue value) {
+ int eqClassIndex = getEqClassIndex(value);
+ if (eqClassIndex < 0) return false;
+
+ EqClass eqClass = myEqClasses.get(eqClassIndex);
+ if (eqClass == null) return false;
+ if (eqClass.findConstant(true) != null) return true;
+
+ for (UnorderedPair<EqClass> pair : getDistinctClassPairs()) {
+ if (pair.first == eqClass && pair.second.findConstant(true) != null ||
+ pair.second == eqClass && pair.first.findConstant(true) != null) {
+ return true;
}
}
+ return false;
}
Set<DfaVariableValue> getChangedVariables() {
diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/StringExpressionHelper.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/StringExpressionHelper.java
new file mode 100644
index 000000000000..b187d80a3957
--- /dev/null
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/StringExpressionHelper.java
@@ -0,0 +1,178 @@
+/*
+ * 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.dataFlow;
+
+import com.intellij.openapi.util.Pair;
+import com.intellij.psi.*;
+import com.intellij.psi.search.SearchScope;
+import com.intellij.psi.search.searches.MethodReferencesSearch;
+import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.util.Processor;
+import com.intellij.util.containers.hash.HashSet;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Collection;
+import java.util.Set;
+
+public class StringExpressionHelper {
+
+ @Nullable
+ public static Pair<PsiElement, String> evaluateExpression(@NotNull PsiElement expression) {
+ return evaluateExpression(expression, new HashSet<PsiElement>());
+ }
+
+ @Nullable
+ public static Pair<PsiElement, String> evaluateExpression(@NotNull PsiElement expression, @NotNull Collection<PsiElement> visited) {
+ visited.add(expression);
+
+ if (expression instanceof PsiLiteralExpression) {
+ return evaluatePsiLiteralExpression(expression);
+ }
+
+ if (expression instanceof PsiReferenceExpression) {
+ PsiElement resolve = ((PsiReferenceExpression)expression).resolve();
+ if (resolve instanceof PsiVariable) {
+ PsiExpression initializer = ((PsiVariable)resolve).getInitializer();
+ if (initializer != null) {
+ Pair<PsiElement, String> expr = evaluateExpression(initializer, visited);
+ if (expr != null) return expr;
+ }
+ }
+ }
+
+ if (expression instanceof PsiMethodCallExpression) {
+ final PsiElement element = ((PsiMethodCallExpression)expression).getMethodExpression().resolve();
+ if (element instanceof PsiMethod) {
+ PsiCodeBlock body = ((PsiMethod)element).getBody();
+ if (body != null) {
+ final Set<PsiExpression> returns = new com.intellij.util.containers.HashSet<PsiExpression>();
+
+ body.accept(new JavaRecursiveElementVisitor() {
+ @Override
+ public void visitReturnStatement(PsiReturnStatement statement) {
+ PsiExpression returnValue = statement.getReturnValue();
+ if (returnValue != null) {
+ returns.add(returnValue);
+ }
+ }
+ });
+
+ for (PsiExpression psiExpression : returns) {
+ Pair<PsiElement, String> pair = evaluateExpression(psiExpression, visited);
+ if (pair != null) {
+ return pair;
+ }
+ }
+ }
+
+ return evaluateExpression(element, visited);
+ }
+ return null;
+ }
+
+ Pair<PsiElement, String> constantExpression = evaluateConstantExpression(expression);
+ if (constantExpression != null) {
+ return constantExpression;
+ }
+
+ if (expression instanceof PsiBinaryExpression) {
+ // a="a"; b="b" return a+b;
+ PsiBinaryExpression binaryExpression = (PsiBinaryExpression)expression;
+ return evaluatePolyadicExpressions(expression, visited, binaryExpression.getLOperand(), binaryExpression.getROperand());
+ }
+ if (expression instanceof PsiPolyadicExpression) {
+ // a="a"; b="b"; c="c" return a+b+c;
+ return evaluatePolyadicExpressions(expression, visited, ((PsiPolyadicExpression)expression).getOperands());
+ }
+
+
+ Collection<? extends PsiElement> elements = DfaUtil.getPossibleInitializationElements(expression);
+ for (PsiElement element : elements) {
+ if (!visited.contains(element)) {
+ Pair<PsiElement, String> expr = evaluateExpression(element);
+ if (expr != null) return expr;
+ }
+ }
+
+ return null;
+ }
+
+ @Nullable
+ private static Pair<PsiElement, String> evaluatePolyadicExpressions(@NotNull PsiElement expression,
+ @NotNull Collection<PsiElement> visited,
+ @NotNull PsiExpression... operands) {
+ StringBuilder sb = new StringBuilder();
+ for (PsiExpression operand : operands) {
+ Pair<PsiElement, String> pair = evaluateExpression(operand, visited);
+ if (pair == null) return null;
+ sb.append(pair.second);
+ }
+ return Pair.create(expression, sb.toString());
+ }
+
+ @Nullable
+ public static Pair<PsiElement, String> evaluatePsiLiteralExpression(@NotNull PsiElement expression) {
+ return Pair.create(expression, ElementManipulators.getValueText(expression));
+ }
+
+ @Nullable
+ public static Pair<PsiElement, String> evaluateConstantExpression(@NotNull PsiElement expression) {
+ PsiConstantEvaluationHelper helper = JavaPsiFacade.getInstance(expression.getProject()).getConstantEvaluationHelper();
+ Object result = helper.computeConstantExpression(expression);
+ if (result instanceof String) {
+ return Pair.create(expression, (String)result);
+ }
+ return null;
+ }
+
+ @NotNull
+ public static Set<Pair<PsiElement, String>> searchStringExpressions(@NotNull final PsiMethod psiMethod,
+ @NotNull SearchScope searchScope,
+ int expNum) {
+ Set<Pair<PsiElement, String>> pairs = new com.intellij.util.containers.HashSet<Pair<PsiElement, String>>();
+ for (PsiMethodCallExpression methodCallExpression : searchMethodCalls(psiMethod, searchScope)) {
+ final PsiExpression[] expressions = methodCallExpression.getArgumentList().getExpressions();
+ if (expressions.length > expNum) {
+ final PsiExpression expression = expressions[expNum];
+ Pair<PsiElement, String> pair = evaluateExpression(expression);
+ if (pair != null) {
+ pairs.add(pair);
+ }
+ }
+ }
+
+ return pairs;
+ }
+
+ @NotNull
+ public static Set<PsiMethodCallExpression> searchMethodCalls(@NotNull final PsiMethod psiMethod, @NotNull SearchScope searchScope) {
+ final Set<PsiMethodCallExpression> callExpressions = new com.intellij.util.containers.HashSet<PsiMethodCallExpression>();
+ MethodReferencesSearch.search(psiMethod, searchScope, true).forEach(new Processor<PsiReference>() {
+ @Override
+ public boolean process(PsiReference psiReference) {
+ final PsiMethodCallExpression methodCallExpression =
+ PsiTreeUtil.getParentOfType(psiReference.getElement(), PsiMethodCallExpression.class);
+
+ if (methodCallExpression != null) {
+ callExpressions.add(methodCallExpression);
+ }
+ return true;
+ }
+ });
+ return callExpressions;
+ }
+}
diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/instructions/MethodCallInstruction.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/instructions/MethodCallInstruction.java
index a46abb680cd6..76fd8d7b994a 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/instructions/MethodCallInstruction.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/instructions/MethodCallInstruction.java
@@ -24,12 +24,11 @@
*/
package com.intellij.codeInspection.dataFlow.instructions;
-import com.intellij.codeInspection.dataFlow.DataFlowRunner;
-import com.intellij.codeInspection.dataFlow.DfaInstructionState;
-import com.intellij.codeInspection.dataFlow.DfaMemoryState;
-import com.intellij.codeInspection.dataFlow.InstructionVisitor;
+import com.intellij.codeInsight.AnnotationUtil;
+import com.intellij.codeInspection.dataFlow.*;
import com.intellij.codeInspection.dataFlow.value.DfaValue;
import com.intellij.psi.*;
+import com.intellij.psi.util.PropertyUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -56,17 +55,26 @@ public class MethodCallInstruction extends Instruction {
myPrecalculatedReturnValue = null;
}
- public MethodCallInstruction(@NotNull PsiCallExpression context, @Nullable DfaValue precalculatedReturnValue) {
- myContext = context;
+ public MethodCallInstruction(@NotNull PsiCallExpression call, @Nullable DfaValue precalculatedReturnValue) {
+ myContext = call;
myMethodType = MethodType.REGULAR_METHOD_CALL;
- myCall = context;
- final PsiExpressionList argList = context.getArgumentList();
+ myCall = call;
+ final PsiExpressionList argList = call.getArgumentList();
myArgs = argList != null ? argList.getExpressions() : PsiExpression.EMPTY_ARRAY;
myType = myCall.getType();
- myShouldFlushFields = !(myCall instanceof PsiNewExpression && myType != null && myType.getArrayDimensions() > 0);
+
+ myShouldFlushFields = !(myCall instanceof PsiNewExpression && myType != null && myType.getArrayDimensions() > 0) && !isPureCall(call);
myPrecalculatedReturnValue = precalculatedReturnValue;
}
+ private static boolean isPureCall(PsiCallExpression call) {
+ PsiMethod method = call.resolveMethod();
+ if (method == null) return false;
+ PsiAnnotation anno = ControlFlowAnalyzer.findContractAnnotation(method);
+ if (anno != null && Boolean.TRUE.equals(AnnotationUtil.getBooleanAttributeValue(anno, "pure"))) return true;
+ return PropertyUtil.isSimplePropertyGetter(method);
+ }
+
@Nullable
public PsiType getResultType() {
return myType;
diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/value/DfaConstValue.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/value/DfaConstValue.java
index 5ed0c6b81dde..ca2e13620c92 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/value/DfaConstValue.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/value/DfaConstValue.java
@@ -89,11 +89,10 @@ public class DfaConstValue extends DfaValue {
if (TypeConversionUtil.isNumericType(type) && !TypeConversionUtil.isFloatOrDoubleType(type)) {
value = TypeConversionUtil.computeCastTo(value, PsiType.LONG);
}
- Object key = constant != null ? constant : value;
- DfaConstValue instance = myValues.get(key);
+ DfaConstValue instance = myValues.get(value);
if (instance == null) {
instance = new DfaConstValue(value, myFactory, constant);
- myValues.put(key, instance);
+ myValues.put(value, instance);
}
return instance;
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaInheritorsGetter.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaInheritorsGetter.java
index 18ca74b8ff6c..1a14010ec834 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaInheritorsGetter.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaInheritorsGetter.java
@@ -18,14 +18,15 @@ package com.intellij.codeInsight.completion;
import com.intellij.codeInsight.CodeInsightUtil;
import com.intellij.codeInsight.ExpectedTypeInfo;
import com.intellij.codeInsight.daemon.impl.analysis.HighlightClassUtil;
-import com.intellij.codeInsight.lookup.*;
+import com.intellij.codeInsight.lookup.AutoCompletionPolicy;
+import com.intellij.codeInsight.lookup.LookupElement;
+import com.intellij.codeInsight.lookup.LookupElementDecorator;
+import com.intellij.codeInsight.lookup.PsiTypeLookupItem;
import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.util.Comparing;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.*;
import com.intellij.psi.filters.getters.ExpectedTypesGetter;
import com.intellij.psi.impl.source.PsiClassReferenceType;
-import com.intellij.psi.infos.MethodCandidateInfo;
import com.intellij.psi.statistics.JavaStatisticsManager;
import com.intellij.psi.statistics.StatisticsInfo;
import com.intellij.psi.statistics.StatisticsManager;
@@ -169,7 +170,7 @@ public class JavaInheritorsGetter extends CompletionProvider<CompletionParameter
final PsiDiamondTypeImpl.DiamondInferenceResult inferenceResult = PsiDiamondTypeImpl.resolveInferredTypes(initializer);
if (inferenceResult.getErrorMessage() == null &&
!psiClass.hasModifierProperty(PsiModifier.ABSTRACT) &&
- areInferredTypesApplicable(inferenceResult.getTypes(), parameters.getOriginalPosition())) {
+ areInferredTypesApplicable(inferenceResult.getTypes(), parameters.getPosition())) {
psiType = initializer.getType();
}
}
@@ -186,18 +187,36 @@ public class JavaInheritorsGetter extends CompletionProvider<CompletionParameter
return LookupElementDecorator.withInsertHandler(item, myConstructorInsertHandler);
}
- private static boolean areInferredTypesApplicable(@NotNull PsiType[] types, PsiElement originalPosition) {
- final PsiMethodCallExpression methodCallExpression = PsiTreeUtil.getParentOfType(originalPosition, PsiMethodCallExpression.class);
+ private static boolean areInferredTypesApplicable(@NotNull PsiType[] types, PsiElement position) {
+ final PsiMethodCallExpression methodCallExpression = PsiTreeUtil.getParentOfType(position, PsiMethodCallExpression.class);
if (methodCallExpression != null) {
- final PsiNewExpression newExpression = PsiTreeUtil.getParentOfType(originalPosition, PsiNewExpression.class);
- if (newExpression != null && ArrayUtil.find(methodCallExpression.getArgumentList().getExpressions(), newExpression) > -1 ||
- Comparing.equal(originalPosition.getParent(), methodCallExpression.getArgumentList())) {
- final JavaResolveResult resolveResult = methodCallExpression.resolveMethodGenerics();
- final PsiMethod method = (PsiMethod)resolveResult.getElement();
- return method == null ||
- PsiUtil.getApplicabilityLevel(method, resolveResult.getSubstitutor(), types, PsiUtil.getLanguageLevel(originalPosition))
- != MethodCandidateInfo.ApplicabilityLevel.NOT_APPLICABLE;
+ if (PsiUtil.isLanguageLevel8OrHigher(methodCallExpression)) {
+ final PsiNewExpression newExpression = PsiTreeUtil.getParentOfType(position, PsiNewExpression.class, false);
+ if (newExpression != null) {
+ PsiElement parent = newExpression;
+ while (parent.getParent() instanceof PsiParenthesizedExpression) {
+ parent = parent.getParent();
+ }
+ final int idx = ArrayUtil.find(methodCallExpression.getArgumentList().getExpressions(), parent);
+ if (idx > -1) {
+ final JavaResolveResult resolveResult = methodCallExpression.resolveMethodGenerics();
+ final PsiMethod method = (PsiMethod)resolveResult.getElement();
+ if (method != null) {
+ final PsiParameter[] parameters = method.getParameterList().getParameters();
+ if (idx < parameters.length) {
+ final PsiType expectedType = resolveResult.getSubstitutor().substitute(parameters[idx].getType());
+ final PsiClass aClass = PsiUtil.resolveClassInType(expectedType);
+ if (aClass != null) {
+ final PsiClassType inferredArg = JavaPsiFacade.getElementFactory(method.getProject()).createType(aClass, types);
+ LOG.assertTrue(expectedType != null);
+ return TypeConversionUtil.isAssignable(expectedType, inferredArg);
+ }
+ }
+ }
+ }
+ }
}
+ return false;
}
return true;
}
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 386c8a2296c6..3c0e9ace5e3b 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/LambdaCompletionProvider.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/LambdaCompletionProvider.java
@@ -16,13 +16,16 @@
package com.intellij.codeInsight.completion;
import com.intellij.codeInsight.ExpectedTypeInfo;
+import com.intellij.codeInsight.generation.GenerateMembersUtil;
import com.intellij.codeInsight.lookup.AutoCompletionPolicy;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.EditorModificationUtil;
+import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
+import com.intellij.psi.codeStyle.JavaCodeStyleManager;
import com.intellij.psi.util.PsiUtil;
import com.intellij.util.Function;
import com.intellij.util.ProcessingContext;
@@ -43,8 +46,17 @@ public class LambdaCompletionProvider extends CompletionProvider<CompletionParam
if (LambdaUtil.isFunctionalType(defaultType)) {
final PsiMethod method = LambdaUtil.getFunctionalInterfaceMethod(defaultType);
if (method != null) {
- final PsiParameter[] params = method.getParameterList().getParameters();
- final String paramsString = "(" + StringUtil.join(params, new Function<PsiParameter, String>() {
+ PsiParameter[] params = method.getParameterList().getParameters();
+ final Project project = method.getProject();
+ final PsiElement originalPosition = parameters.getOriginalPosition();
+ final JVMElementFactory jvmElementFactory = originalPosition != null ? JVMElementFactories.getFactory(originalPosition.getLanguage(), project) : null;
+ if (jvmElementFactory != null) {
+ final PsiSubstitutor substitutor = LambdaUtil.getSubstitutor(method, PsiUtil.resolveGenericsClassInType(defaultType));
+ final JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(project);
+ params = GenerateMembersUtil.overriddenParameters(params, jvmElementFactory, codeStyleManager, substitutor, originalPosition);
+ }
+
+ final String paramsString = params.length == 1 ? params[0].getName() : "(" + StringUtil.join(params, new Function<PsiParameter, String>() {
@Override
public String fun(PsiParameter parameter) {
return parameter.getName();
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddExceptionToThrowsFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddExceptionToThrowsFix.java
index 7e70dbe8dd9c..13f9162f5f65 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddExceptionToThrowsFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddExceptionToThrowsFix.java
@@ -57,8 +57,21 @@ public class AddExceptionToThrowsFix extends BaseIntentionAction {
PsiDocumentManager.getInstance(project).commitAllDocuments();
- PsiMethod targetMethod = PsiTreeUtil.getParentOfType(myWrongElement, PsiMethod.class);
- List<PsiClassType> exceptions = getUnhandledExceptions(myWrongElement, targetMethod);
+ PsiElement targetElement = null;
+ PsiMethod targetMethod = null;
+
+ final PsiLambdaExpression lambdaExpression = PsiTreeUtil.getParentOfType(myWrongElement, PsiLambdaExpression.class);
+ if (lambdaExpression != null) {
+ targetMethod = LambdaUtil.getFunctionalInterfaceMethod(lambdaExpression);
+ targetElement = lambdaExpression.getBody();
+ }
+
+ if (targetElement == null && targetMethod == null) {
+ targetMethod = PsiTreeUtil.getParentOfType(myWrongElement, PsiMethod.class);
+ targetElement = targetMethod;
+ }
+
+ List<PsiClassType> exceptions = getUnhandledExceptions(myWrongElement, targetElement, targetMethod);
if (exceptions == null || targetMethod == null) return;
Set<PsiClassType> unhandledExceptions = new THashSet<PsiClassType>(exceptions);
@@ -168,9 +181,21 @@ public class AddExceptionToThrowsFix extends BaseIntentionAction {
if (!(file instanceof PsiJavaFile)) return false;
if (myWrongElement == null || !myWrongElement.isValid()) return false;
- PsiMethod method = PsiTreeUtil.getParentOfType(myWrongElement, PsiMethod.class);
- if (method == null || !method.getThrowsList().isPhysical()) return false;
- List<PsiClassType> unhandled = getUnhandledExceptions(myWrongElement, method);
+ PsiElement targetElement = null;
+ PsiMethod targetMethod = null;
+
+ final PsiLambdaExpression lambdaExpression = PsiTreeUtil.getParentOfType(myWrongElement, PsiLambdaExpression.class);
+ if (lambdaExpression != null) {
+ targetMethod = LambdaUtil.getFunctionalInterfaceMethod(lambdaExpression);
+ targetElement = lambdaExpression.getBody();
+ }
+
+ if (targetElement == null && targetMethod == null) {
+ targetMethod = PsiTreeUtil.getParentOfType(myWrongElement, PsiMethod.class);
+ targetElement = targetMethod;
+ }
+ if (targetElement == null || targetMethod == null || !targetMethod.getThrowsList().isPhysical()) return false;
+ List<PsiClassType> unhandled = getUnhandledExceptions(myWrongElement, targetElement, targetMethod);
if (unhandled == null || unhandled.isEmpty()) return false;
setText(QuickFixBundle.message("add.exception.to.throws.text", unhandled.size()));
@@ -184,13 +209,13 @@ public class AddExceptionToThrowsFix extends BaseIntentionAction {
}
@Nullable
- private static List<PsiClassType> getUnhandledExceptions(@Nullable PsiElement element, PsiMethod topElement) {
+ private static List<PsiClassType> getUnhandledExceptions(@Nullable PsiElement element, PsiElement topElement, PsiMethod targetMethod) {
if (element == null || element == topElement) return null;
List<PsiClassType> unhandledExceptions = ExceptionUtil.getUnhandledExceptions(element);
- if (!filterInProjectExceptions(topElement, unhandledExceptions).isEmpty()) {
+ if (!filterInProjectExceptions(targetMethod, unhandledExceptions).isEmpty()) {
return unhandledExceptions;
}
- return getUnhandledExceptions(element.getParent(), topElement);
+ return getUnhandledExceptions(element.getParent(), topElement, targetMethod);
}
@NotNull
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/OrderEntryFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/OrderEntryFix.java
index d1c9989794cf..6b4a4721b4f0 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/OrderEntryFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/OrderEntryFix.java
@@ -43,6 +43,10 @@ import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.PsiShortNamesCache;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
+import com.intellij.psi.util.PsiUtilCore;
+import com.intellij.util.Function;
+import com.intellij.util.PathUtil;
+import com.intellij.util.containers.ContainerUtil;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -116,8 +120,35 @@ public abstract class OrderEntryFix implements IntentionAction, LocalQuickFix {
@Override
public void invoke(@NotNull Project project, @Nullable Editor editor, PsiFile file) {
- String jarPath = isJunit4 ? JavaSdkUtil.getJunit4JarPath() : JavaSdkUtil.getJunit3JarPath();
- addBundledJarToRoots(project, editor, currentModule, reference, className, jarPath);
+ if (isJunit4) {
+ final VirtualFile location = PsiUtilCore.getVirtualFile(reference != null ? reference.getElement() : null);
+ boolean inTests = location != null && ModuleRootManager.getInstance(currentModule).getFileIndex().isInTestSourceContent(location);
+ try {
+ final String[] junit4Paths = {JavaSdkUtil.getJunit4JarPath(),
+ PathUtil.getJarPathForClass(Class.forName("org.hamcrest.Matcher")),
+ PathUtil.getJarPathForClass(Class.forName("org.hamcrest.Matchers"))};
+ ModuleRootModificationUtil.addModuleLibrary(currentModule,
+ "JUnit4",
+ ContainerUtil.map(junit4Paths,
+ new Function<String, String>() {
+ @Override
+ public String fun(String libPath) {
+ return convertToLibraryRoot(libPath).getUrl();
+ }
+ }),
+ Collections.<String>emptyList(), inTests ? DependencyScope.TEST : DependencyScope.COMPILE);
+ final GlobalSearchScope scope = GlobalSearchScope.moduleWithLibrariesScope(currentModule);
+ final PsiClass aClass = JavaPsiFacade.getInstance(project).findClass(className, scope);
+ if (aClass != null && editor != null && reference != null) {
+ new AddImportAction(project, reference, editor, aClass).execute();
+ }
+ }
+ catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ } else {
+ addBundledJarToRoots(project, editor, currentModule, reference, className, JavaSdkUtil.getJunit3JarPath());
+ }
}
};
registrar.register(fix);
@@ -297,11 +328,7 @@ public abstract class OrderEntryFix implements IntentionAction, LocalQuickFix {
}
public static void addJarToRoots(String libPath, final Module module, @Nullable PsiElement location) {
- final File libraryRoot = new File(libPath);
- LocalFileSystem.getInstance().refreshAndFindFileByIoFile(libraryRoot);
- String url = VfsUtil.getUrlForLibraryRoot(libraryRoot);
- VirtualFile libVirtFile = VirtualFileManager.getInstance().findFileByUrl(url);
- assert libVirtFile != null : libPath;
+ VirtualFile libVirtFile = convertToLibraryRoot(libPath);
boolean inTests = false;
if (location != null) {
@@ -314,6 +341,16 @@ public abstract class OrderEntryFix implements IntentionAction, LocalQuickFix {
Collections.<String>emptyList(), inTests ? DependencyScope.TEST : DependencyScope.COMPILE);
}
+ @NotNull
+ private static VirtualFile convertToLibraryRoot(String libPath) {
+ final File libraryRoot = new File(libPath);
+ LocalFileSystem.getInstance().refreshAndFindFileByIoFile(libraryRoot);
+ String url = VfsUtil.getUrlForLibraryRoot(libraryRoot);
+ VirtualFile libVirtFile = VirtualFileManager.getInstance().findFileByUrl(url);
+ assert libVirtFile != null : libPath;
+ return libVirtFile;
+ }
+
public static boolean ensureAnnotationsJarInPath(final Module module) {
if (isAnnotationsJarInPath(module)) return true;
if (module == null) return false;
diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/GenerateMembersUtil.java b/java/java-impl/src/com/intellij/codeInsight/generation/GenerateMembersUtil.java
index a389a64436ea..1288318e4d52 100644
--- a/java/java-impl/src/com/intellij/codeInsight/generation/GenerateMembersUtil.java
+++ b/java/java-impl/src/com/intellij/codeInsight/generation/GenerateMembersUtil.java
@@ -385,10 +385,25 @@ public class GenerateMembersUtil {
@NotNull PsiParameterList sourceParameterList,
@NotNull PsiParameterList targetParameterList,
@NotNull PsiSubstitutor substitutor, PsiElement target) {
- PsiParameter[] parameters = sourceParameterList.getParameters();
+ final PsiParameter[] parameters = sourceParameterList.getParameters();
+ final PsiParameter[] newParameters = overriddenParameters(parameters, factory, codeStyleManager, substitutor, target);
+ for (int i = 0; i < newParameters.length; i++) {
+ final PsiParameter newParameter = newParameters[i];
+ copyOrReplaceModifierList(parameters[i], newParameter);
+ targetParameterList.add(newParameter);
+ }
+ }
+
+ public static PsiParameter[] overriddenParameters(PsiParameter[] parameters,
+ @NotNull JVMElementFactory factory,
+ @NotNull JavaCodeStyleManager codeStyleManager,
+ @NotNull PsiSubstitutor substitutor,
+ PsiElement target) {
+ PsiParameter[] result = new PsiParameter[parameters.length];
UniqueNameGenerator generator = new UniqueNameGenerator();
- for (PsiParameter parameter : parameters) {
+ for (int i = 0; i < parameters.length; i++) {
+ PsiParameter parameter = parameters[i];
final PsiType parameterType = parameter.getType();
final PsiType substituted = substituteType(substitutor, parameterType, (PsiMethod)parameter.getDeclarationScope());
@NonNls String paramName = parameter.getName();
@@ -413,10 +428,9 @@ public class GenerateMembersUtil {
paramName = generator.generateUniqueName(paramName);
}
generator.addExistingName(paramName);
- final PsiParameter newParameter = factory.createParameter(paramName, substituted, target);
- copyOrReplaceModifierList(parameter, newParameter);
- targetParameterList.add(newParameter);
+ result[i] = factory.createParameter(paramName, substituted, target);
}
+ return result;
}
private static void substituteThrows(@NotNull JVMElementFactory factory,
diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddOnDemandStaticImportAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddOnDemandStaticImportAction.java
index a1d7988b9ed3..36344aa00785 100644
--- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddOnDemandStaticImportAction.java
+++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddOnDemandStaticImportAction.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,7 +18,7 @@ package com.intellij.codeInsight.intention.impl;
import com.intellij.codeInsight.CodeInsightBundle;
import com.intellij.codeInsight.FileModificationService;
import com.intellij.codeInsight.highlighting.HighlightManager;
-import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction;
+import com.intellij.codeInsight.intention.BaseElementAtCaretIntentionAction;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.colors.EditorColors;
@@ -39,7 +39,7 @@ import java.util.List;
/**
* @author ven
*/
-public class AddOnDemandStaticImportAction extends PsiElementBaseIntentionAction {
+public class AddOnDemandStaticImportAction extends BaseElementAtCaretIntentionAction {
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.intention.impl.AddOnDemandStaticImportAction");
@Override
@@ -72,15 +72,29 @@ public class AddOnDemandStaticImportAction extends PsiElementBaseIntentionAction
return null;
}
PsiClass psiClass = (PsiClass)resolved;
+ final PsiElement ggParent = gParent.getParent();
+ if (ggParent instanceof PsiMethodCallExpression) {
+ final PsiMethodCallExpression call = (PsiMethodCallExpression)ggParent.copy();
+ final PsiElement qualifier = call.getMethodExpression().getQualifier();
+ if (qualifier == null) return null;
+ qualifier.delete();
+ final PsiMethod method = call.resolveMethod();
+ if (method != null && method.getContainingClass() != psiClass) return null;
+ }
+ else {
+ final PsiJavaCodeReferenceElement copy = (PsiJavaCodeReferenceElement)gParent.copy();
+ final PsiElement qualifier = copy.getQualifier();
+ if (qualifier == null) return null;
+ qualifier.delete();
+ final PsiElement target = copy.resolve();
+ if (target != null && PsiTreeUtil.getParentOfType(target, PsiClass.class) != psiClass) return null;
+ }
+
if (Comparing.strEqual(psiClass.getName(), psiClass.getQualifiedName()) || psiClass.hasModifierProperty(PsiModifier.PRIVATE)) return null;
PsiFile file = refExpr.getContainingFile();
if (!(file instanceof PsiJavaFile)) return null;
PsiImportList importList = ((PsiJavaFile)file).getImportList();
if (importList == null) return null;
- for (PsiImportStaticStatement statement : importList.getImportStaticStatements()) {
- PsiClass staticResolve = statement.resolveTargetClass();
- if (psiClass == staticResolve) return null; //already imported
- }
return psiClass;
}
@@ -103,13 +117,27 @@ public class AddOnDemandStaticImportAction extends PsiElementBaseIntentionAction
if (aClass == null) {
return;
}
- PsiImportStaticStatement importStaticStatement =
- JavaPsiFacade.getInstance(file.getProject()).getElementFactory().createImportStaticStatement(aClass, "*");
- PsiImportList importList = ((PsiJavaFile)file).getImportList();
- if (importList == null) {
- return;
+ final PsiClass containingClass = PsiUtil.getTopLevelClass(refExpr);
+ if (aClass != containingClass) {
+ PsiImportList importList = ((PsiJavaFile)file).getImportList();
+ if (importList == null) {
+ return;
+ }
+ boolean alreadyImported = false;
+ for (PsiImportStaticStatement statement : importList.getImportStaticStatements()) {
+ if (!statement.isOnDemand()) continue;
+ PsiClass staticResolve = statement.resolveTargetClass();
+ if (aClass == staticResolve) {
+ alreadyImported = true;
+ break;
+ }
+ }
+ if (!alreadyImported) {
+ PsiImportStaticStatement importStaticStatement =
+ JavaPsiFacade.getInstance(file.getProject()).getElementFactory().createImportStaticStatement(aClass, "*");
+ importList.add(importStaticStatement);
+ }
}
- importList.add(importStaticStatement);
List<PsiFile> roots = file.getViewProvider().getAllFiles();
for (final PsiFile root : roots) {
diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddSingleMemberStaticImportAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddSingleMemberStaticImportAction.java
index d37a9fd7028b..37065846b002 100644
--- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddSingleMemberStaticImportAction.java
+++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddSingleMemberStaticImportAction.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.
@@ -21,7 +21,7 @@ package com.intellij.codeInsight.intention.impl;
import com.intellij.codeInsight.CodeInsightBundle;
import com.intellij.codeInsight.FileModificationService;
-import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction;
+import com.intellij.codeInsight.intention.BaseElementAtCaretIntentionAction;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
@@ -29,12 +29,14 @@ import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Key;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.tree.java.PsiReferenceExpressionImpl;
-import com.intellij.psi.util.*;
+import com.intellij.psi.util.InheritanceUtil;
+import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.psi.util.PsiUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-public class AddSingleMemberStaticImportAction extends PsiElementBaseIntentionAction {
+public class AddSingleMemberStaticImportAction extends BaseElementAtCaretIntentionAction {
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.intention.impl.AddSingleMemberStaticImportAction");
private static final Key<PsiElement> TEMP_REFERENT_USER_DATA = new Key<PsiElement>("TEMP_REFERENT_USER_DATA");
@@ -51,7 +53,7 @@ public class AddSingleMemberStaticImportAction extends PsiElementBaseIntentionAc
* @return not-null qualified name of the class which method may be statically imported if any; <code>null</code> otherwise
*/
@Nullable
- public static String getStaticImportClass(@NotNull PsiElement element, boolean useExisting) {
+ public static String getStaticImportClass(@NotNull PsiElement element) {
if (!PsiUtil.isLanguageLevel5OrHigher(element)) return null;
if (element instanceof PsiIdentifier) {
final PsiElement parent = element.getParent();
@@ -60,11 +62,29 @@ public class AddSingleMemberStaticImportAction extends PsiElementBaseIntentionAc
if (PsiTreeUtil.getParentOfType(parent, PsiImportList.class) != null) return null;
PsiJavaCodeReferenceElement refExpr = (PsiJavaCodeReferenceElement)parent;
if (checkParameterizedReference(refExpr)) return null;
- PsiElement resolved = refExpr.resolve();
- if (resolved instanceof PsiMember && ((PsiModifierListOwner)resolved).hasModifierProperty(PsiModifier.STATIC)) {
- PsiClass aClass = getResolvedClass(element, (PsiMember)resolved);
- if (aClass != null && !PsiTreeUtil.isAncestor(aClass, element, true) && !aClass.hasModifierProperty(PsiModifier.PRIVATE)) {
- if (findExistingImport(element.getContainingFile(), aClass, refExpr.getReferenceName()) == null || useExisting) {
+ JavaResolveResult[] results = refExpr.multiResolve(false);
+ for (JavaResolveResult result : results) {
+ final PsiElement resolved = result.getElement();
+ if (resolved instanceof PsiMember && ((PsiModifierListOwner)resolved).hasModifierProperty(PsiModifier.STATIC)) {
+ PsiClass aClass = getResolvedClass(element, (PsiMember)resolved);
+ if (aClass != null && !PsiTreeUtil.isAncestor(aClass, element, true) && !aClass.hasModifierProperty(PsiModifier.PRIVATE)) {
+ final PsiElement gParent = refExpr.getParent();
+ if (gParent instanceof PsiMethodCallExpression) {
+ final PsiMethodCallExpression call = (PsiMethodCallExpression)gParent.copy();
+ final PsiElement qualifier = call.getMethodExpression().getQualifier();
+ if (qualifier == null) return null;
+ qualifier.delete();
+ final PsiMethod method = call.resolveMethod();
+ if (method != null && method.getContainingClass() != aClass) return null;
+ }
+ else {
+ final PsiJavaCodeReferenceElement copy = (PsiJavaCodeReferenceElement)refExpr.copy();
+ final PsiElement qualifier = copy.getQualifier();
+ if (qualifier == null) return null;
+ qualifier.delete();
+ final PsiElement target = copy.resolve();
+ if (target != null && PsiTreeUtil.getParentOfType(target, PsiClass.class) != aClass) return null;
+ }
String qName = aClass.getQualifiedName();
if (qName != null && !Comparing.strEqual(qName, aClass.getName())) {
return qName + "." +refExpr.getReferenceName();
@@ -123,7 +143,7 @@ public class AddSingleMemberStaticImportAction extends PsiElementBaseIntentionAc
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
- String classQName = getStaticImportClass(element, false);
+ String classQName = getStaticImportClass(element);
if (classQName != null) {
setText(CodeInsightBundle.message("intention.add.single.member.static.import.text", classQName));
}
@@ -134,9 +154,15 @@ public class AddSingleMemberStaticImportAction extends PsiElementBaseIntentionAc
if (!FileModificationService.getInstance().prepareFileForWrite(file)) return;
final PsiJavaCodeReferenceElement refExpr = (PsiJavaCodeReferenceElement)element.getParent();
- final PsiElement resolved = refExpr.resolve();
final String referenceName = refExpr.getReferenceName();
- bindAllClassRefs(file, resolved, referenceName, resolved != null ? getResolvedClass(element, (PsiMember)resolved) : null);
+ final JavaResolveResult[] targets = refExpr.multiResolve(false);
+ for (JavaResolveResult target : targets) {
+ final PsiElement resolved = target.getElement();
+ if (resolved != null) {
+ bindAllClassRefs(file, resolved, referenceName, getResolvedClass(element, (PsiMember)resolved));
+ return;
+ }
+ }
}
public static void bindAllClassRefs(final PsiFile file,
diff --git a/java/java-impl/src/com/intellij/codeInsight/lookup/VariableLookupItem.java b/java/java-impl/src/com/intellij/codeInsight/lookup/VariableLookupItem.java
index db14ecafdff3..9f23dba0b7df 100644
--- a/java/java-impl/src/com/intellij/codeInsight/lookup/VariableLookupItem.java
+++ b/java/java-impl/src/com/intellij/codeInsight/lookup/VariableLookupItem.java
@@ -3,16 +3,23 @@ package com.intellij.codeInsight.lookup;
import com.intellij.codeInsight.AutoPopupController;
import com.intellij.codeInsight.TailType;
import com.intellij.codeInsight.completion.*;
+import com.intellij.codeInsight.daemon.impl.analysis.HighlightControlFlowUtil;
import com.intellij.featureStatistics.FeatureUsageTracker;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.RangeMarker;
+import com.intellij.openapi.util.registry.Registry;
import com.intellij.psi.*;
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
+import com.intellij.psi.controlFlow.ControlFlowUtil;
import com.intellij.psi.impl.source.PostprocessReformattingAspect;
import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.psi.util.PsiUtil;
+import com.intellij.util.containers.HashMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import java.util.Collection;
+
/**
* @author peter
*/
@@ -115,6 +122,9 @@ public class VariableLookupItem extends LookupItem<PsiVariable> implements Typed
JavaCodeStyleManager.getInstance(context.getProject()).shortenClassReferences(ref);
}
+ ref = PsiTreeUtil.findElementOfClassAtOffset(context.getFile(), context.getTailOffset() - 1, PsiReferenceExpression.class, false);
+ makeVariableFinalIfNeeded(context, ref);
+
final char completionChar = context.getCompletionChar();
if (completionChar == '=') {
context.setAddCompletionChar(false);
@@ -141,6 +151,25 @@ public class VariableLookupItem extends LookupItem<PsiVariable> implements Typed
}
}
+ private static void makeVariableFinalIfNeeded(InsertionContext context, @Nullable PsiReferenceExpression ref) {
+ if (!Registry.is("java.completion.make.outer.variables.final") ||
+ ref == null || PsiUtil.isLanguageLevel8OrHigher(ref) || JspPsiUtil.isInJspFile(ref)) {
+ return;
+ }
+
+ PsiElement target = ref.resolve();
+ if (target instanceof PsiLocalVariable || target instanceof PsiParameter) {
+ PsiClass placeClass = PsiTreeUtil.findElementOfClassAtOffset(context.getFile(), context.getTailOffset() - 1, PsiClass.class, false);
+ if (placeClass != null && !PsiTreeUtil.isAncestor(placeClass, target, true) &&
+ !HighlightControlFlowUtil.isReassigned((PsiVariable)target, new HashMap<PsiElement, Collection<ControlFlowUtil.VariableInfo>>())) {
+ PsiModifierList modifierList = ((PsiVariable)target).getModifierList();
+ if (modifierList != null) {
+ modifierList.setModifierProperty(PsiModifier.FINAL, true);
+ }
+ }
+ }
+ }
+
private boolean shouldQualify(PsiField field, InsertionContext context) {
if (myHelper != null && !myHelper.willBeImported()) {
return true;
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/impl/ShortenToStaticImportProcessor.java b/java/java-impl/src/com/intellij/codeInsight/template/impl/ShortenToStaticImportProcessor.java
index 637ce3ede147..cf2f8c1176ba 100644
--- a/java/java-impl/src/com/intellij/codeInsight/template/impl/ShortenToStaticImportProcessor.java
+++ b/java/java-impl/src/com/intellij/codeInsight/template/impl/ShortenToStaticImportProcessor.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.
@@ -34,6 +34,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import static java.util.Arrays.asList;
@@ -72,6 +73,7 @@ public class ShortenToStaticImportProcessor implements TemplateOptionalProcessor
}
}
+ Collections.reverse(staticImportTargets);
for (Pair<PsiElement, StaticImporter> pair : staticImportTargets) {
if (pair.first.isValid()) {
pair.second.perform(project, file, editor, pair.first);
@@ -117,7 +119,7 @@ public class ShortenToStaticImportProcessor implements TemplateOptionalProcessor
private static class SingleMemberStaticImporter implements StaticImporter {
@Override
public boolean canPerform(@NotNull PsiElement element) {
- return AddSingleMemberStaticImportAction.getStaticImportClass(element, true) != null;
+ return AddSingleMemberStaticImportAction.getStaticImportClass(element) != null;
}
@Override
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ExpressionPostfixTemplateWithChooser.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ExpressionPostfixTemplateWithChooser.java
index 6f09a79e5b60..7efead36faa9 100644
--- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ExpressionPostfixTemplateWithChooser.java
+++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/ExpressionPostfixTemplateWithChooser.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.postfix.util.PostfixTemplatesUtils;
@@ -65,8 +80,14 @@ public abstract class ExpressionPostfixTemplateWithChooser extends PostfixTempla
}
@NotNull
- protected List<PsiExpression> getExpressions(@NotNull PsiElement context, @NotNull Document document, int offset) {
- List<PsiExpression> expressions = IntroduceVariableBase.collectExpressions(context.getContainingFile(), document, offset, false);
+ protected List<PsiExpression> getExpressions(@NotNull PsiElement context, @NotNull Document document, final int offset) {
+ List<PsiExpression> expressions = ContainerUtil.filter(IntroduceVariableBase.collectExpressions(context.getContainingFile(), document, offset - 1, false),
+ new Condition<PsiExpression>() {
+ @Override
+ public boolean value(PsiExpression expression) {
+ return expression.getTextRange().getEndOffset() == offset;
+ }
+ });
return ContainerUtil.filter(expressions.isEmpty() ? maybeTopmostExpression(context) : expressions, getTypeCondition());
}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/EditContractIntention.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/EditContractIntention.java
index 767077b3448e..c962e2ee25fc 100644
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/EditContractIntention.java
+++ b/java/java-impl/src/com/intellij/codeInspection/dataFlow/EditContractIntention.java
@@ -61,7 +61,7 @@ public class EditContractIntention extends BaseIntentionAction {
final PsiMethod method = getTargetMethod(project, editor, file);
if (method != null) {
boolean hasContract = ControlFlowAnalyzer.findContractAnnotation(method) != null;
- setText(hasContract ? "Edit method contract" : "Add method contract");
+ setText(hasContract ? "Edit method contract of '" + method.getName() + "'" : "Add method contract to '" + method.getName() + "'");
return true;
}
return false;
diff --git a/java/java-impl/src/com/intellij/psi/formatter/java/AbstractJavaBlock.java b/java/java-impl/src/com/intellij/psi/formatter/java/AbstractJavaBlock.java
index 59dc77a693da..b1d4c675d8b2 100644
--- a/java/java-impl/src/com/intellij/psi/formatter/java/AbstractJavaBlock.java
+++ b/java/java-impl/src/com/intellij/psi/formatter/java/AbstractJavaBlock.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.
@@ -45,6 +45,8 @@ import org.jetbrains.annotations.Nullable;
import java.util.*;
+import static com.intellij.psi.formatter.java.JavaFormatterUtil.getWrapType;
+
public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlock, ReservedWrapsProvider {
/**
@@ -82,7 +84,6 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
protected boolean myUseChildAttributes = false;
@NotNull protected final AlignmentStrategy myAlignmentStrategy;
private boolean myIsAfterClassKeyword = false;
- private Wrap myAnnotationWrap = null;
protected Alignment myReservedAlignment;
protected Alignment myReservedAlignment2;
@@ -137,15 +138,14 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
}
return strategy.getAlignment(node.getElementType());
}
-
+
@NotNull
public static Block createJavaBlock(@NotNull ASTNode child,
@NotNull CommonCodeStyleSettings settings,
@NotNull JavaCodeStyleSettings javaSettings,
@Nullable Indent indent,
@Nullable Wrap wrap,
- Alignment alignment)
- {
+ Alignment alignment) {
return createJavaBlock(child, settings, javaSettings,indent, wrap, AlignmentStrategy.wrap(alignment));
}
@@ -166,8 +166,7 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
@Nullable Indent indent,
Wrap wrap,
@NotNull AlignmentStrategy alignmentStrategy,
- int startOffset)
- {
+ int startOffset) {
Indent actualIndent = indent == null ? getDefaultSubtreeIndent(child, getJavaIndentOptions(settings)) : indent;
final IElementType elementType = child.getElementType();
Alignment alignment = alignmentStrategy.getAlignment(elementType);
@@ -189,8 +188,9 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
if (isStatement(child, child.getTreeParent())) {
return new CodeBlockBlock(child, wrap, alignment, actualIndent, settings, javaSettings);
}
- if (child instanceof PsiComment && child instanceof PsiLanguageInjectionHost && InjectedLanguageUtil
- .hasInjections((PsiLanguageInjectionHost)child)) {
+ if (child instanceof PsiComment &&
+ child instanceof PsiLanguageInjectionHost &&
+ InjectedLanguageUtil.hasInjections((PsiLanguageInjectionHost)child)) {
return new CommentWithInjectionBlock(child, wrap, alignment, indent, settings, javaSettings);
}
if (child instanceof LeafElement) {
@@ -500,36 +500,26 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
if (mySettings.PREFER_PARAMETERS_WRAP) {
wrap.ignoreParentWraps();
}
- child = processParenthesisBlock(result,
- child,
+ child = processParenthesisBlock(result, child,
WrappingStrategy.createDoNotWrapCommaStrategy(wrap),
mySettings.ALIGN_MULTILINE_PARAMETERS_IN_CALLS);
}
else if (childType == JavaTokenType.LPARENTH && nodeType == JavaElementType.PARAMETER_LIST) {
- final Wrap wrap;
- Wrap reservedWrap = getReservedWrap(JavaElementType.MODIFIER_LIST);
// There is a possible case that particular annotated method definition is too long. We may wrap either after annotation
// or after opening lbrace then. Our strategy is to wrap after annotation whenever possible.
- if (reservedWrap == null) {
- wrap = Wrap.createWrap(getWrapType(mySettings.METHOD_PARAMETERS_WRAP), false);
- }
- else {
- wrap = Wrap.createChildWrap(reservedWrap, getWrapType(mySettings.METHOD_PARAMETERS_WRAP), false);
- }
+ Wrap wrap = Wrap.createWrap(getWrapType(mySettings.METHOD_PARAMETERS_WRAP), false);
child = processParenthesisBlock(result, child,
WrappingStrategy.createDoNotWrapCommaStrategy(wrap),
mySettings.ALIGN_MULTILINE_PARAMETERS);
}
else if (childType == JavaTokenType.LPARENTH && nodeType == JavaElementType.RESOURCE_LIST) {
- final Wrap reservedWrap = getReservedWrap(JavaElementType.MODIFIER_LIST);
- final Wrap wrap = reservedWrap != null
- ? Wrap.createChildWrap(reservedWrap, getWrapType(mySettings.RESOURCE_LIST_WRAP), false)
- : Wrap.createWrap(getWrapType(mySettings.RESOURCE_LIST_WRAP), false);
- child = processParenthesisBlock(result, child, WrappingStrategy.createDoNotWrapCommaStrategy(wrap),
- mySettings.ALIGN_MULTILINE_RESOURCES);
+ Wrap wrap = Wrap.createWrap(getWrapType(mySettings.RESOURCE_LIST_WRAP), false);
+ child = processParenthesisBlock(result, child,
+ WrappingStrategy.createDoNotWrapCommaStrategy(wrap),
+ mySettings.ALIGN_MULTILINE_RESOURCES);
}
else if (childType == JavaTokenType.LPARENTH && nodeType == JavaElementType.ANNOTATION_PARAMETER_LIST) {
- final Wrap wrap = Wrap.createWrap(getWrapType(mySettings.CALL_PARAMETERS_WRAP), false);
+ Wrap wrap = Wrap.createWrap(getWrapType(mySettings.CALL_PARAMETERS_WRAP), false);
child = processParenthesisBlock(result, child,
WrappingStrategy.createDoNotWrapCommaStrategy(wrap),
mySettings.ALIGN_MULTILINE_PARAMETERS_IN_CALLS);
@@ -548,63 +538,37 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
else if (childType == JavaElementType.FIELD) {
child = processField(result, child, alignmentStrategy, defaultWrap, childIndent);
}
- else if (childType == JavaElementType.LOCAL_VARIABLE
- || childType == JavaElementType.DECLARATION_STATEMENT && myNode.getElementType() == JavaElementType.METHOD)
- {
+ else if (childType == JavaElementType.LOCAL_VARIABLE ||
+ childType == JavaElementType.DECLARATION_STATEMENT && myNode.getElementType() == JavaElementType.METHOD) {
result.add(new SimpleJavaBlock(child, defaultWrap, alignmentStrategy, childIndent, mySettings, myJavaSettings));
}
else {
AlignmentStrategy alignmentStrategyToUse = AlignmentStrategy.wrap(arrangeChildAlignment(child, alignmentStrategy));
- if (myAlignmentStrategy.getAlignment(nodeType, childType) != null
- && (nodeType == JavaElementType.IMPLEMENTS_LIST || nodeType == JavaElementType.CLASS))
- {
+ if (myAlignmentStrategy.getAlignment(nodeType, childType) != null &&
+ (nodeType == JavaElementType.IMPLEMENTS_LIST || nodeType == JavaElementType.CLASS)) {
alignmentStrategyToUse = myAlignmentStrategy;
}
- final Block block = createJavaBlock(
- child, mySettings, myJavaSettings, childIndent, arrangeChildWrap(child, defaultWrap), alignmentStrategyToUse, childOffset
- );
- if (childType == JavaElementType.MODIFIER_LIST && containsAnnotations(child)) {
- myAnnotationWrap = Wrap.createWrap(getWrapType(getAnnotationWrapType(child)), true);
- }
+ Wrap wrap = arrangeChildWrap(child, defaultWrap);
+
+ Block block = createJavaBlock(child, mySettings, myJavaSettings, childIndent, wrap, alignmentStrategyToUse, childOffset);
if (block instanceof AbstractJavaBlock) {
final AbstractJavaBlock javaBlock = (AbstractJavaBlock)block;
- if (nodeType == JavaElementType.METHOD_CALL_EXPRESSION && childType == JavaElementType.REFERENCE_EXPRESSION
- || nodeType == JavaElementType.REFERENCE_EXPRESSION && childType == JavaElementType.METHOD_CALL_EXPRESSION)
- {
+ if (nodeType == JavaElementType.METHOD_CALL_EXPRESSION && childType == JavaElementType.REFERENCE_EXPRESSION ||
+ nodeType == JavaElementType.REFERENCE_EXPRESSION && childType == JavaElementType.METHOD_CALL_EXPRESSION) {
javaBlock.setReservedWrap(getReservedWrap(nodeType), nodeType);
javaBlock.setReservedWrap(getReservedWrap(childType), childType);
}
else if (nodeType == JavaElementType.BINARY_EXPRESSION) {
javaBlock.setReservedWrap(defaultWrap, nodeType);
}
- else if (childType == JavaElementType.MODIFIER_LIST) {
- javaBlock.setReservedWrap(myAnnotationWrap, JavaElementType.MODIFIER_LIST);
- if (!lastChildIsAnnotation(child)) {
- myAnnotationWrap = null;
- }
- }
- else if (childType == JavaElementType.PARAMETER_LIST && nodeType == JavaElementType.METHOD) {
- // We prefer wrapping after method annotation to wrapping method parameter list, hence, deliver target wrap object
- // to child block if necessary.
- if (!result.isEmpty()) {
- Block firstChildBlock = result.get(0);
- if (firstChildBlock instanceof AbstractJavaBlock) {
- AbstractJavaBlock childJavaBlock = (AbstractJavaBlock)firstChildBlock;
- if (firstChildIsAnnotation(childJavaBlock.getNode())) {
- javaBlock.setReservedWrap(childJavaBlock.getReservedWrap(JavaElementType.MODIFIER_LIST), JavaElementType.MODIFIER_LIST);
- }
- }
- }
- }
}
result.add(block);
}
}
-
return child;
}
@@ -647,7 +611,7 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
* <code>'Composite field definition'</code> looks like {@code 'int i1, i2 = 2'}. It produces two nodes of type
* {@link JavaElementType#FIELD} - {@code 'int i1'} and {@code 'i2 = 2'}. This method returns the second node if the first one
* is given (the given node is returned for <code>'single'</code> fields).
- *
+ *
* @param child child field node to check
* @return last child field node at the field group identified by the given node if any; given child otherwise
*/
@@ -777,62 +741,6 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
}
}
- private static boolean firstChildIsAnnotation(@NotNull final ASTNode child) {
- ASTNode current = child.getFirstChildNode();
- while (current != null && current.getElementType() == TokenType.WHITE_SPACE) {
- current = current.getTreeNext();
- }
- return current != null && current.getElementType() == JavaElementType.ANNOTATION;
- }
-
- private static boolean lastChildIsAnnotation(@NotNull final ASTNode child) {
- ASTNode current = child.getLastChildNode();
- while (current != null && current.getElementType() == TokenType.WHITE_SPACE) {
- current = current.getTreePrev();
- }
- return current != null && current.getElementType() == JavaElementType.ANNOTATION;
- }
-
- private static boolean containsAnnotations(@NotNull final ASTNode child) {
- PsiElement psi = child.getPsi();
- return psi instanceof PsiModifierList && ((PsiModifierList)psi).getAnnotations().length > 0;
- }
-
- private int getAnnotationWrapType(@NotNull ASTNode child) {
- final IElementType nodeType = myNode.getElementType();
- if (nodeType == JavaElementType.METHOD) {
- return mySettings.METHOD_ANNOTATION_WRAP;
- }
- if (nodeType == JavaElementType.CLASS) {
- // There is a possible case that current document state is invalid from language syntax point of view, e.g. the user starts
- // typing field definition and re-formatting is triggered by 'auto insert javadoc' processing. Example:
- // class Test {
- // @NotNull Object
- // }
- // Here '@NotNull' has a 'class' node as a parent but we want to use field annotation setting value. Hence, we check if subsequent
- // parsed info is valid.
- for (ASTNode node = child.getTreeNext(); node != null; node = node.getTreeNext()) {
- if (TokenType.WHITE_SPACE == node.getElementType() || node instanceof PsiTypeElement) {
- continue;
- }
- if (node instanceof PsiErrorElement) {
- return mySettings.FIELD_ANNOTATION_WRAP;
- }
- }
- return mySettings.CLASS_ANNOTATION_WRAP;
- }
- if (nodeType == JavaElementType.FIELD) {
- return mySettings.FIELD_ANNOTATION_WRAP;
- }
- if (nodeType == JavaElementType.PARAMETER) {
- return mySettings.PARAMETER_ANNOTATION_WRAP;
- }
- if (nodeType == JavaElementType.LOCAL_VARIABLE) {
- return mySettings.VARIABLE_ANNOTATION_WRAP;
- }
- return CommonCodeStyleSettings.DO_NOT_WRAP;
- }
-
@Nullable
private Alignment arrangeChildAlignment(@NotNull final ASTNode child, @NotNull final AlignmentStrategy alignmentStrategy) {
int role = getChildRole(child);
@@ -905,7 +813,7 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
}
return null;
}
-
+
else {
return defaultAlignment;
}
@@ -944,21 +852,6 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
return myAlignmentStrategy.getAlignment(childType);
}
- /*
- private boolean isAfterClassKeyword(final ASTNode child) {
- ASTNode treePrev = child.getTreePrev();
- while (treePrev != null) {
- if (treePrev.getElementType() == ElementType.CLASS_KEYWORD ||
- treePrev.getElementType() == ElementType.INTERFACE_KEYWORD) {
- return true;
- }
- treePrev = treePrev.getTreePrev();
- }
- return false;
- }
-
- */
-
@Nullable
private static Alignment createAlignment(final boolean alignOption, @Nullable final Alignment defaultAlignment) {
return alignOption ? createAlignmentOrDefault(null, defaultAlignment) : defaultAlignment;
@@ -971,37 +864,14 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
@Nullable
protected Wrap arrangeChildWrap(final ASTNode child, Wrap defaultWrap) {
- if (myAnnotationWrap != null) {
- try {
- return myAnnotationWrap;
- }
- finally {
- myAnnotationWrap = null;
- }
- }
return myWrapManager.arrangeChildWrap(child, myNode, getSettings(), defaultWrap, this);
}
@NotNull
- private static WrapType getWrapType(final int wrap) {
- switch (wrap) {
- case CommonCodeStyleSettings.WRAP_ALWAYS:
- return WrapType.ALWAYS;
- case CommonCodeStyleSettings.WRAP_AS_NEEDED:
- return WrapType.NORMAL;
- case CommonCodeStyleSettings.DO_NOT_WRAP:
- return WrapType.NONE;
- default:
- return WrapType.CHOP_DOWN_IF_LONG;
- }
- }
-
- @NotNull
private ASTNode processParenthesisBlock(@NotNull List<Block> result,
@NotNull ASTNode child,
@NotNull WrappingStrategy wrappingStrategy,
final boolean doAlign) {
-
myUseChildAttributes = true;
final IElementType from = JavaTokenType.LPARENTH;
@@ -1010,7 +880,6 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
return processParenthesisBlock(from, to, result, child, wrappingStrategy, doAlign);
}
-
@NotNull
private ASTNode processParenthesisBlock(@NotNull IElementType from,
@Nullable final IElementType to,
@@ -1084,22 +953,22 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
private static boolean canUseAnonymousClassAlignment(@NotNull ASTNode child) {
// The general idea is to handle situations like below:
- // test(new Runnable() {
+ // test(new Runnable() {
// public void run() {
- // }
- // }, new Runnable() {
+ // }
+ // }, new Runnable() {
// public void run() {
- // }
+ // }
// }
// );
- // I.e. we want to align subsequent anonymous class argument to the previous one if it's not preceded by another argument
+ // I.e. we want to align subsequent anonymous class argument to the previous one if it's not preceded by another argument
// at the same line, e.g.:
- // test("this is a long argument", new Runnable() {
+ // test("this is a long argument", new Runnable() {
// public void run() {
- // }
- // }, new Runnable() {
+ // }
+ // }, new Runnable() {
// public void run() {
- // }
+ // }
// }
// );
if (!isAnonymousClass(child)) {
@@ -1122,7 +991,7 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
}
return true;
}
-
+
private boolean shouldEnforceIndentToChildren() {
if (myNode.getElementType() != JavaElementType.EXPRESSION_LIST) {
return false;
@@ -1144,7 +1013,7 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
ASTNode lastChild = node.getLastChildNode();
return lastChild != null && lastChild.getElementType() == JavaElementType.ANONYMOUS_CLASS;
}
-
+
@Nullable
private ASTNode processEnumBlock(@NotNull List<Block> result,
@Nullable ASTNode child,
@@ -1194,7 +1063,7 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
protected Indent getCodeBlockInternalIndent(final int baseChildrenIndent) {
return getCodeBlockInternalIndent(baseChildrenIndent, false);
}
-
+
protected Indent getCodeBlockInternalIndent(final int baseChildrenIndent, boolean enforceParentIndent) {
if (isTopLevelClass() && mySettings.DO_NOT_INDENT_TOP_LEVEL_CLASS_MEMBERS) {
return Indent.getNoneIndent();
@@ -1209,7 +1078,7 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
protected static Indent createNormalIndent(final int baseChildrenIndent) {
return createNormalIndent(baseChildrenIndent, false);
}
-
+
protected static Indent createNormalIndent(final int baseChildrenIndent, boolean enforceIndentToChildren) {
if (baseChildrenIndent == 1) {
return Indent.getIndent(Indent.Type.NORMAL, false, enforceIndentToChildren);
@@ -1370,9 +1239,9 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
}
final boolean rBrace = isRBrace(child);
Indent childIndent = rBrace ? Indent.getNoneIndent() : getCodeBlockInternalIndent(childrenIndent, false);
- if (!rBrace && child.getElementType() == JavaElementType.CODE_BLOCK
- && (getBraceStyle() == CommonCodeStyleSettings.NEXT_LINE_SHIFTED
- || getBraceStyle() == CommonCodeStyleSettings.NEXT_LINE_SHIFTED2))
+ if (!rBrace && child.getElementType() == JavaElementType.CODE_BLOCK
+ && (getBraceStyle() == CommonCodeStyleSettings.NEXT_LINE_SHIFTED
+ || getBraceStyle() == CommonCodeStyleSettings.NEXT_LINE_SHIFTED2))
{
childIndent = Indent.getNormalIndent();
}
@@ -1384,7 +1253,7 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
return child;
}
}
-
+
if (child != null) {
child = child.getTreeNext();
}
@@ -1418,11 +1287,11 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
* <p/>
* <pre>
* int i1, i2 = 2;
- * </pre>
+ * </pre>
* <p/>
* Parsing such a code produces two fields - {@code 'int i1'} and {@code 'i2 = 2'}. This method returns <code>true</code>
* for the second one.
- *
+ *
* @param node node to check
* @return <code>true</code> if given node is a non-first part of composite field definition; <code>false</code> otherwise
*/
diff --git a/java/java-impl/src/com/intellij/psi/formatter/java/JavaFormatterUtil.java b/java/java-impl/src/com/intellij/psi/formatter/java/JavaFormatterUtil.java
index 5c1b5b7e84d4..7bc17fa33851 100644
--- a/java/java-impl/src/com/intellij/psi/formatter/java/JavaFormatterUtil.java
+++ b/java/java-impl/src/com/intellij/psi/formatter/java/JavaFormatterUtil.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.
@@ -15,6 +15,7 @@
*/
package com.intellij.psi.formatter.java;
+import com.intellij.formatting.WrapType;
import com.intellij.lang.ASTNode;
import com.intellij.psi.*;
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
@@ -39,8 +40,7 @@ public class JavaFormatterUtil {
JavaElementType.ASSIGNMENT_EXPRESSION, JavaElementType.LOCAL_VARIABLE, JavaElementType.FIELD
));
- private JavaFormatterUtil() {
- }
+ private JavaFormatterUtil() { }
/**
* Allows to answer if given node wraps assignment operation.
@@ -119,4 +119,17 @@ public class JavaFormatterUtil {
&& node.textContains('\n');
}
+ @NotNull
+ public static WrapType getWrapType(int wrap) {
+ switch (wrap) {
+ case CommonCodeStyleSettings.WRAP_ALWAYS:
+ return WrapType.ALWAYS;
+ case CommonCodeStyleSettings.WRAP_AS_NEEDED:
+ return WrapType.NORMAL;
+ case CommonCodeStyleSettings.DO_NOT_WRAP:
+ return WrapType.NONE;
+ default:
+ return WrapType.CHOP_DOWN_IF_LONG;
+ }
+ }
}
diff --git a/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java b/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java
index b904628d91d4..390116c3793c 100644
--- a/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java
+++ b/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java
@@ -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.
@@ -93,8 +93,7 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
myResult = Spacing.getReadOnlySpacing();
}
else if (mySettings.KEEP_FIRST_COLUMN_COMMENT) {
- myResult = Spacing
- .createKeepingFirstColumnSpacing(0, Integer.MAX_VALUE, true, mySettings.KEEP_BLANK_LINES_IN_CODE);
+ myResult = Spacing.createKeepingFirstColumnSpacing(0, Integer.MAX_VALUE, true, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
else {
myResult = Spacing.createSpacing(0, Integer.MAX_VALUE, 0, true, mySettings.KEEP_BLANK_LINES_IN_CODE);
@@ -107,12 +106,10 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
if (myResult == null) {
final ASTNode prev = getPrevElementType(myChild2);
if (prev != null && prev.getElementType() == JavaTokenType.END_OF_LINE_COMMENT) {
- myResult = Spacing
- .createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
+ myResult = Spacing.createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
else if (!canStickChildrenTogether(myChild1, myChild2)) {
- myResult = Spacing
- .createSpacing(1, Integer.MIN_VALUE, 0, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
+ myResult = Spacing.createSpacing(1, Integer.MIN_VALUE, 0, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
else if (myChild1.getElementType() == JavaTokenType.C_STYLE_COMMENT){
myResult = null;
@@ -179,7 +176,8 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
return result;
}
- @Override public void visitArrayAccessExpression(PsiArrayAccessExpression expression) {
+ @Override
+ public void visitArrayAccessExpression(PsiArrayAccessExpression expression) {
if (myRole1 == ChildRole.ARRAY && myRole2 == ChildRole.LBRACKET) {
final boolean space = false;
createSpaceInCode(space);
@@ -193,7 +191,8 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
createSpaceProperty(space, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
- @Override public void visitNewExpression(PsiNewExpression expression) {
+ @Override
+ public void visitNewExpression(PsiNewExpression expression) {
if (myRole2 == ChildRole.ARRAY_INITIALIZER) {
createSpaceInCode(mySettings.SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE);
}
@@ -210,14 +209,15 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
}
- @Override public void visitArrayInitializerExpression(PsiArrayInitializerExpression expression) {
+ @Override
+ public void visitArrayInitializerExpression(PsiArrayInitializerExpression expression) {
visitArrayInitializer();
}
- @Override public void visitClass(PsiClass aClass) {
+ @Override
+ public void visitClass(PsiClass aClass) {
if (myChild1.getElementType() == JavaDocElementType.DOC_COMMENT) {
- myResult = Spacing
- .createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
+ myResult = Spacing.createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
return;
}
if (myRole2 == ChildRole.LBRACE) {
@@ -248,9 +248,7 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
}
else {
- myResult = Spacing.createSpacing(
- 0, 0, mySettings.BLANK_LINES_AFTER_CLASS_HEADER + 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS
- );
+ myResult = Spacing.createSpacing(0, 0, mySettings.BLANK_LINES_AFTER_CLASS_HEADER + 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
}
}
else if (myRole2 == ChildRole.RBRACE && aClass.isEnum()) {
@@ -283,7 +281,7 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
ASTNode prev = node.getTreePrev();
if (prev == null || !(prev.getElementType() == JavaTokenType.LBRACE)) return false;
-
+
return true;
}
@@ -303,44 +301,37 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
// However, it's not convenient for a situation when particular code is created via PSI - it's easier to not bothering
// with whitespace elements when inserting, say, new initialization blocks. That's why we don't enforce new line
// only during explicit reformatting ('Reformat' action).
- int minLineFeeds = FormatterUtil.isFormatterCalledExplicitly() ? 0 : 1;
- myResult = Spacing.createSpacing(0, mySettings.SPACE_BEFORE_CLASS_LBRACE ? 1 : 0, 1, true, mySettings.KEEP_BLANK_LINES_BEFORE_RBRACE,
- lines);
+ //int minLineFeeds = FormatterUtil.isFormatterCalledExplicitly() ? 0 : 1;
+ myResult = Spacing.createSpacing(0, mySettings.SPACE_BEFORE_CLASS_LBRACE ? 1 : 0, 1, true, mySettings.KEEP_BLANK_LINES_BEFORE_RBRACE, lines);
}
else if (myRole1 == ChildRole.CLASS) {
setAroundClassSpacing();
}
else {
final int blankLines = getLinesAroundMethod() + 1;
- myResult = Spacing
- .createSpacing(0, 0, blankLines, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
+ myResult = Spacing.createSpacing(0, 0, blankLines, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
}
}
else if (myRole1 == ChildRole.CLASS_INITIALIZER) {
if (myRole2 == ChildRole.RBRACE) {
int minLineFeeds = getMinLineFeedsBetweenRBraces(myChild1);
- myResult = Spacing.createSpacing(
- 0, Integer.MAX_VALUE, minLineFeeds, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_BEFORE_RBRACE
- );
+ myResult = Spacing.createSpacing(0, Integer.MAX_VALUE, minLineFeeds, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_BEFORE_RBRACE);
}
else if (myRole2 == ChildRole.CLASS) {
setAroundClassSpacing();
}
else {
final int blankLines = getLinesAroundMethod() + 1;
- myResult = Spacing
- .createSpacing(0, Integer.MAX_VALUE, blankLines, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
+ myResult = Spacing.createSpacing(0, Integer.MAX_VALUE, blankLines, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
}
}
else if (myRole1 == ChildRole.CLASS) {
if (myRole2 == ChildRole.RBRACE) {
- myResult = Spacing
- .createSpacing(0, Integer.MAX_VALUE, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_BEFORE_RBRACE);
+ myResult = Spacing.createSpacing(0, Integer.MAX_VALUE, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_BEFORE_RBRACE);
}
else {
final int blankLines = mySettings.BLANK_LINES_AROUND_CLASS + 1;
- myResult = Spacing
- .createSpacing(0, Integer.MAX_VALUE, blankLines, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
+ myResult = Spacing.createSpacing(0, Integer.MAX_VALUE, blankLines, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
}
}
else if (myRole2 == ChildRole.CLASS) {
@@ -349,8 +340,7 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
else {
final int blankLines = mySettings.BLANK_LINES_AROUND_CLASS + 1;
- myResult = Spacing
- .createSpacing(0, Integer.MAX_VALUE, blankLines, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
+ myResult = Spacing.createSpacing(0, Integer.MAX_VALUE, blankLines, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
}
}
@@ -364,8 +354,7 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
else {
final int blankLines = getLinesAroundField() + 1;
- myResult = Spacing
- .createSpacing(0, Integer.MAX_VALUE, blankLines, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
+ myResult = Spacing.createSpacing(0, Integer.MAX_VALUE, blankLines, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
}
}
@@ -373,21 +362,18 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
if (myRole2 == ChildRole.COMMA) {
ASTNode lastChildNode = myChild1.getLastChildNode();
if (lastChildNode != null && lastChildNode.getElementType() == JavaTokenType.SEMICOLON) {
- myResult = Spacing
- .createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
+ myResult = Spacing.createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
}
else {
createSpaceProperty(false, false, 0);
}
}
else if (myRole2 == ChildRole.RBRACE) {
- myResult = Spacing
- .createSpacing(0, Integer.MAX_VALUE, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_BEFORE_RBRACE);
+ myResult = Spacing.createSpacing(0, Integer.MAX_VALUE, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_BEFORE_RBRACE);
}
else {
final int blankLines = getLinesAroundField() + 1;
- myResult = Spacing
- .createSpacing(0, Integer.MAX_VALUE, blankLines, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
+ myResult = Spacing.createSpacing(0, Integer.MAX_VALUE, blankLines, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
}
}
else if (myRole2 == ChildRole.COMMA || myChild2.getElementType() == JavaTokenType.SEMICOLON) {
@@ -402,8 +388,7 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
else if (myRole1 == ChildRole.LBRACE && myRole2 == ChildRole.RBRACE) {
- myResult = Spacing
- .createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_BEFORE_RBRACE);
+ myResult = Spacing.createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_BEFORE_RBRACE);
}
else if (myRole2 == ChildRole.EXTENDS_LIST || myRole2 == ChildRole.IMPLEMENTS_LIST) {
@@ -418,8 +403,7 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
createSpaceInCode(false);
}
else if (myRole2 == ChildRole.RBRACE) {
- myResult = Spacing
- .createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_BEFORE_RBRACE);
+ myResult = Spacing.createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_BEFORE_RBRACE);
}
}
@@ -439,8 +423,7 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
else {
final int blankLines = getLinesAroundMethod() + 1;
- myResult = Spacing
- .createSpacing(0, 0, blankLines, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
+ myResult = Spacing.createSpacing(0, 0, blankLines, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
}
}
else if (myRole1 == ChildRole.METHOD || myChild1.getElementType() == JavaElementType.METHOD) {
@@ -449,17 +432,14 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
else {
final int blankLines = getLinesAroundMethod() + 1;
- myResult = Spacing
- .createSpacing(0, 0, blankLines, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
+ myResult = Spacing.createSpacing(0, 0, blankLines, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
}
if (myRole2 == ChildRole.RBRACE) {
- myResult = Spacing
- .createSpacing(0, Integer.MAX_VALUE, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_BEFORE_RBRACE);
+ myResult = Spacing.createSpacing(0, Integer.MAX_VALUE, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_BEFORE_RBRACE);
}
else {
final int blankLines = getLinesAroundMethod() + 1;
- myResult = Spacing
- .createSpacing(0, Integer.MAX_VALUE, blankLines, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
+ myResult = Spacing.createSpacing(0, Integer.MAX_VALUE, blankLines, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
}
}
return myResult != null;
@@ -518,11 +498,13 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
return false;
}
- @Override public void visitInstanceOfExpression(PsiInstanceOfExpression expression) {
+ @Override
+ public void visitInstanceOfExpression(PsiInstanceOfExpression expression) {
createSpaceInCode(true);
}
- @Override public void visitEnumConstantInitializer(PsiEnumConstantInitializer enumConstantInitializer) {
+ @Override
+ public void visitEnumConstantInitializer(PsiEnumConstantInitializer enumConstantInitializer) {
if (myRole2 == ChildRole.EXTENDS_LIST || myRole2 == ChildRole.IMPLEMENTS_LIST) {
createSpaceInCode(true);
} else {
@@ -530,7 +512,8 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
}
- @Override public void visitImportList(PsiImportList list) {
+ @Override
+ public void visitImportList(PsiImportList list) {
if (ElementType.IMPORT_STATEMENT_BASE_BIT_SET.contains(myChild1.getElementType()) &&
ElementType.IMPORT_STATEMENT_BASE_BIT_SET.contains(myChild2.getElementType())) {
if (myImportHelper == null) myImportHelper = new ImportHelper(mySettings.getRootSettings());
@@ -545,39 +528,36 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
- @Override public void visitFile(PsiFile file) {
+ @Override
+ public void visitFile(PsiFile file) {
if (myType1 == JavaElementType.PACKAGE_STATEMENT) {
int lf = mySettings.BLANK_LINES_AFTER_PACKAGE + 1;
- myResult = Spacing
- .createSpacing(0, 0, lf, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
+ myResult = Spacing.createSpacing(0, 0, lf, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
}
else if (myType2 == JavaElementType.PACKAGE_STATEMENT) {
int lf = mySettings.BLANK_LINES_BEFORE_PACKAGE + 1;
- myResult = Spacing
- .createSpacing(0, 0, lf, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
+ myResult = Spacing.createSpacing(0, 0, lf, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
}
else if (myType1 == JavaElementType.IMPORT_LIST) {
int lf = mySettings.BLANK_LINES_AFTER_IMPORTS + 1;
- myResult = Spacing
- .createSpacing(0, 0, lf, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
+ myResult = Spacing.createSpacing(0, 0, lf, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
}
else if (myType2 == JavaElementType.IMPORT_LIST) {
int lf = mySettings.BLANK_LINES_BEFORE_IMPORTS + 1;
- myResult = Spacing
- .createSpacing(0, 0, lf, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
+ myResult = Spacing.createSpacing(0, 0, lf, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
}
else if (myType2 == JavaElementType.CLASS) {
int lf = mySettings.BLANK_LINES_AROUND_CLASS + 1;
- myResult = Spacing
- .createSpacing(0, 0, lf, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
+ myResult = Spacing.createSpacing(0, 0, lf, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
}
}
- @Override public void visitWhileStatement(PsiWhileStatement statement) {
+ @Override
+ public void visitWhileStatement(PsiWhileStatement statement) {
if (myRole2 == ChildRole.LPARENTH) {
createSpaceInCode(mySettings.SPACE_BEFORE_WHILE_PARENTHESES);
}
@@ -596,7 +576,8 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
- @Override public void visitDoWhileStatement(PsiDoWhileStatement statement) {
+ @Override
+ public void visitDoWhileStatement(PsiDoWhileStatement statement) {
if (myRole1 == ChildRole.WHILE_KEYWORD && myRole2 == ChildRole.LPARENTH) {
createSpaceInCode(mySettings.SPACE_BEFORE_WHILE_PARENTHESES);
}
@@ -619,15 +600,14 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
private void processOnNewLineCondition(final boolean onNewLine) {
processOnNewLineCondition(onNewLine, true);
}
-
+
private void processOnNewLineCondition(final boolean onNewLine, final boolean createSpaceInline) {
if (onNewLine) {
if (!mySettings.KEEP_SIMPLE_BLOCKS_IN_ONE_LINE) {
myResult = Spacing.createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
else {
- myResult = Spacing
- .createDependentLFSpacing(0, 1, myParent.getTextRange(), mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
+ myResult = Spacing.createDependentLFSpacing(0, 1, myParent.getTextRange(), mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
}
else {
@@ -636,13 +616,15 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
- @Override public void visitThrowStatement(PsiThrowStatement statement) {
+ @Override
+ public void visitThrowStatement(PsiThrowStatement statement) {
if (myChild1.getElementType() == JavaTokenType.THROW_KEYWORD) {
createSpaceInCode(true);
}
}
- @Override public void visitTryStatement(PsiTryStatement statement) {
+ @Override
+ public void visitTryStatement(PsiTryStatement statement) {
if (myRole2 == ChildRole.FINALLY_KEYWORD || myRole2 == ChildRole.CATCH_SECTION) {
boolean putRightChildOnNewLine = myRole2 == ChildRole.FINALLY_KEYWORD ? mySettings.FINALLY_ON_NEW_LINE : mySettings.CATCH_ON_NEW_LINE;
if (putRightChildOnNewLine) {
@@ -675,7 +657,8 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
: null;
}
- @Override public void visitForeachStatement(PsiForeachStatement statement) {
+ @Override
+ public void visitForeachStatement(PsiForeachStatement statement) {
if (myRole1 == ChildRole.FOR_KEYWORD && myRole2 == ChildRole.LPARENTH) {
createSpaceInCode(mySettings.SPACE_BEFORE_FOR_PARENTHESES);
}
@@ -694,8 +677,7 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
mySettings.KEEP_SIMPLE_BLOCKS_IN_ONE_LINE, true);
}
else if (mySettings.KEEP_CONTROL_STATEMENT_IN_ONE_LINE) {
- myResult = Spacing
- .createDependentLFSpacing(1, 1, myParent.getTextRange(), false, mySettings.KEEP_BLANK_LINES_IN_CODE);
+ myResult = Spacing.createDependentLFSpacing(1, 1, myParent.getTextRange(), false, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
else {
myResult = Spacing.createSpacing(0, 0, 1, false, mySettings.KEEP_BLANK_LINES_IN_CODE);
@@ -705,13 +687,15 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
- @Override public void visitAssignmentExpression(PsiAssignmentExpression expression) {
+ @Override
+ public void visitAssignmentExpression(PsiAssignmentExpression expression) {
if (myRole1 == ChildRole.OPERATION_SIGN || myRole2 == ChildRole.OPERATION_SIGN) {
createSpaceInCode(mySettings.SPACE_AROUND_ASSIGNMENT_OPERATORS);
}
}
- @Override public void visitParenthesizedExpression(PsiParenthesizedExpression expression) {
+ @Override
+ public void visitParenthesizedExpression(PsiParenthesizedExpression expression) {
if (myRole1 == ChildRole.LPARENTH) {
createParenthSpace(mySettings.PARENTHESES_EXPRESSION_LPAREN_WRAP, mySettings.SPACE_WITHIN_PARENTHESES);
@@ -722,11 +706,13 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
- @Override public void visitCodeBlock(PsiCodeBlock block) {
+ @Override
+ public void visitCodeBlock(PsiCodeBlock block) {
processCodeBlock(keepInOneLine(block), block.getTextRange());
}
- @Override public void visitCodeFragment(JavaCodeFragment codeFragment) {
+ @Override
+ public void visitCodeFragment(JavaCodeFragment codeFragment) {
if (myChild1.getPsi() instanceof PsiStatement && myChild2.getPsi() instanceof PsiStatement) {
myResult = Spacing.createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
@@ -765,27 +751,22 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
}
}
- myResult = Spacing.createSpacing(
- 0, 0, blankLines, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE
- );
+ myResult = Spacing.createSpacing(0, 0, blankLines, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
else {
- myResult = Spacing
- .createDependentLFSpacing(0, 1, textRange, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
+ myResult = Spacing.createDependentLFSpacing(0, 1, textRange, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
}
else if (myRole2 == ChildRole.RBRACE) {
if (!keepInOneLine) {
- myResult = Spacing
- .createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_BEFORE_RBRACE);
+ myResult = Spacing.createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_BEFORE_RBRACE);
}
else {
- myResult = Spacing
- .createDependentLFSpacing(0, 1, textRange, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_BEFORE_RBRACE);
+ myResult = Spacing.createDependentLFSpacing(0, 1, textRange, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_BEFORE_RBRACE);
}
}
- else if (myChild1.getElementType() == JavaElementType.SWITCH_LABEL_STATEMENT
- && myChild2.getElementType() == JavaElementType.BLOCK_STATEMENT)
+ else if (myChild1.getElementType() == JavaElementType.SWITCH_LABEL_STATEMENT
+ && myChild2.getElementType() == JavaElementType.BLOCK_STATEMENT)
{
myResult = getSpaceBeforeLBrace(mySettings.SPACE_BEFORE_SWITCH_LBRACE, mySettings.BRACE_STYLE, null, false, true);
@@ -794,7 +775,7 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
int minSpaces = 0;
int minLineFeeds = 1;
PsiElement psi = myChild1.getPsi();
-
+
// We want to avoid situations like below:
// 1. Call 'introduce variable' refactoring for the code like 'System.out.println(1);';
// 2. When KEEP_MULTIPLE_EXPRESSIONS_IN_ONE_LINE is on, the output looks like 'int i = 1; System.out.println(i);';
@@ -825,7 +806,8 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
}
- @Override public void visitIfStatement(PsiIfStatement statement) {
+ @Override
+ public void visitIfStatement(PsiIfStatement statement) {
if (myRole2 == ChildRole.ELSE_KEYWORD) {
if (myChild1.getElementType() != JavaElementType.BLOCK_STATEMENT) {
myResult = Spacing.createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
@@ -900,12 +882,10 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
private Spacing createNonLFSpace(int spaces, @Nullable final TextRange dependantRange, final boolean keepLineBreaks) {
final ASTNode prev = getPrevElementType(myChild2);
if (prev != null && prev.getElementType() == JavaTokenType.END_OF_LINE_COMMENT) {
- return Spacing
- .createSpacing(0, Integer.MAX_VALUE, 1, keepLineBreaks, mySettings.KEEP_BLANK_LINES_IN_CODE);
+ return Spacing.createSpacing(0, Integer.MAX_VALUE, 1, keepLineBreaks, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
else if (dependantRange != null) {
- return Spacing
- .createDependentLFSpacing(spaces, spaces, dependantRange, keepLineBreaks, mySettings.KEEP_BLANK_LINES_IN_CODE);
+ return Spacing.createDependentLFSpacing(spaces, spaces, dependantRange, keepLineBreaks, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
else {
return Spacing.createSpacing(spaces, spaces, 0, keepLineBreaks, mySettings.KEEP_BLANK_LINES_IN_CODE);
@@ -972,10 +952,10 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
}
- @Override public void visitField(PsiField field) {
+ @Override
+ public void visitField(PsiField field) {
if (myChild1.getElementType() == JavaDocElementType.DOC_COMMENT) {
- myResult = Spacing
- .createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
+ myResult = Spacing.createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
return;
}
@@ -993,7 +973,8 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
}
- @Override public void visitLocalVariable(PsiLocalVariable variable) {
+ @Override
+ public void visitLocalVariable(PsiLocalVariable variable) {
if (myRole1 == ChildRole.INITIALIZER_EQ || myRole2 == ChildRole.INITIALIZER_EQ) {
createSpaceInCode(mySettings.SPACE_AROUND_ASSIGNMENT_OPERATORS);
}
@@ -1019,14 +1000,14 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
}
- @Override public void visitMethod(PsiMethod method) {
+ @Override
+ public void visitMethod(PsiMethod method) {
if (myChild1.getElementType() == JavaDocElementType.DOC_COMMENT) {
- myResult = Spacing
- .createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
+ myResult = Spacing.createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
return;
}
-
+
if (myRole2 == ChildRole.PARAMETER_LIST) {
createSpaceInCode(mySettings.SPACE_BEFORE_METHOD_PARENTHESES);
}
@@ -1093,11 +1074,13 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
}
- @Override public void visitModifierList(PsiModifierList list) {
+ @Override
+ public void visitModifierList(PsiModifierList list) {
createSpaceInCode(true);
}
- @Override public void visitParameterList(PsiParameterList list) {
+ @Override
+ public void visitParameterList(PsiParameterList list) {
if (myRole1 == ChildRole.LPARENTH && myRole2 == ChildRole.RPARENTH) {
createParenthSpace(mySettings.METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE, mySettings.SPACE_WITHIN_EMPTY_METHOD_PARENTHESES);
}
@@ -1130,7 +1113,8 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
}
- @Override public void visitElement(PsiElement element) {
+ @Override
+ public void visitElement(PsiElement element) {
if (myRole1 == ChildRole.MODIFIER_LIST) {
processModifierList();
}
@@ -1149,7 +1133,8 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
}
- @Override public void visitExpressionList(PsiExpressionList list) {
+ @Override
+ public void visitExpressionList(PsiExpressionList list) {
if (myRole1 == ChildRole.LPARENTH && myRole2 == ChildRole.RPARENTH) {
createParenthSpace(mySettings.CALL_PARAMETERS_LPAREN_ON_NEXT_LINE, mySettings.SPACE_WITHIN_EMPTY_METHOD_CALL_PARENTHESES);
}
@@ -1174,7 +1159,8 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
}
- @Override public void visitSynchronizedStatement(PsiSynchronizedStatement statement) {
+ @Override
+ public void visitSynchronizedStatement(PsiSynchronizedStatement statement) {
if (myRole1 == ChildRole.SYNCHRONIZED_KEYWORD || myRole2 == ChildRole.LPARENTH) {
createSpaceInCode(mySettings.SPACE_BEFORE_SYNCHRONIZED_PARENTHESES);
}
@@ -1187,13 +1173,15 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
}
- @Override public void visitSwitchLabelStatement(PsiSwitchLabelStatement statement) {
+ @Override
+ public void visitSwitchLabelStatement(PsiSwitchLabelStatement statement) {
if (myRole1 == ChildRole.CASE_KEYWORD || myRole2 == ChildRole.CASE_EXPRESSION) {
createSpaceProperty(true, false, 0);
}
}
- @Override public void visitSwitchStatement(PsiSwitchStatement statement) {
+ @Override
+ public void visitSwitchStatement(PsiSwitchStatement statement) {
if (myRole1 == ChildRole.SWITCH_KEYWORD && myRole2 == ChildRole.LPARENTH) {
createSpaceInCode(mySettings.SPACE_BEFORE_SWITCH_PARENTHESES);
}
@@ -1209,7 +1197,7 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
@Override
public void visitLambdaExpression(PsiLambdaExpression expression) {
- if ((myRole1 == ChildRole.ARROW && (myRole2 == ChildRole.LBRACE || myRole2 == ChildRole.EXPRESSION)) ||
+ if ((myRole1 == ChildRole.ARROW && (myRole2 == ChildRole.LBRACE || myRole2 == ChildRole.EXPRESSION)) ||
(myRole1 == ChildRole.PARAMETER_LIST && myRole2 == ChildRole.ARROW)) {
createSpaceInCode(mySettings.SPACE_AROUND_LAMBDA_ARROW);
}
@@ -1223,7 +1211,8 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
}
- @Override public void visitForStatement(PsiForStatement statement) {
+ @Override
+ public void visitForStatement(PsiForStatement statement) {
if (myRole2 == ChildRole.LPARENTH) {
createSpaceInCode(mySettings.SPACE_BEFORE_FOR_PARENTHESES);
}
@@ -1273,8 +1262,7 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
mySettings.KEEP_SIMPLE_BLOCKS_IN_ONE_LINE, true);
}
else if (mySettings.KEEP_CONTROL_STATEMENT_IN_ONE_LINE) {
- myResult = Spacing
- .createDependentLFSpacing(1, 1, myParent.getTextRange(), false, mySettings.KEEP_BLANK_LINES_IN_CODE);
+ myResult = Spacing.createDependentLFSpacing(1, 1, myParent.getTextRange(), false, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
else {
myResult = Spacing.createSpacing(0, 0, 1, false, mySettings.KEEP_BLANK_LINES_IN_CODE);
@@ -1291,7 +1279,8 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
return null;
}
- @Override public void visitCatchSection(PsiCatchSection section) {
+ @Override
+ public void visitCatchSection(PsiCatchSection section) {
if (myRole2 == ChildRole.CATCH_BLOCK) {
TextRange dependantRange = mySettings.KEEP_SIMPLE_BLOCKS_IN_ONE_LINE ? section.getTextRange() : null;
myResult = getSpaceBeforeLBrace(mySettings.SPACE_BEFORE_CATCH_LBRACE, mySettings.BRACE_STYLE, dependantRange,
@@ -1324,7 +1313,8 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
}
- @Override public void visitReferenceParameterList(PsiReferenceParameterList list) {
+ @Override
+ public void visitReferenceParameterList(PsiReferenceParameterList list) {
if (myRole1 == ChildRole.LT_IN_TYPE_LIST && myRole2 == ChildRole.GT_IN_TYPE_LIST
|| myRole1 == ChildRole.TYPE_IN_REFERENCE_PARAMETER_LIST && myRole2 == ChildRole.COMMA) {
createSpaceInCode(false);
@@ -1340,7 +1330,8 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
}
- @Override public void visitTypeCastExpression(PsiTypeCastExpression expression) {
+ @Override
+ public void visitTypeCastExpression(PsiTypeCastExpression expression) {
if (myRole1 == ChildRole.LPARENTH || myRole2 == ChildRole.RPARENTH) {
createSpaceInCode(mySettings.SPACE_WITHIN_CAST_PARENTHESES);
}
@@ -1370,7 +1361,8 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
}
- @Override public void visitReferenceList(PsiReferenceList list) {
+ @Override
+ public void visitReferenceList(PsiReferenceList list) {
if (myRole1 == ChildRole.COMMA) {
createSpaceInCode(true);
}
@@ -1390,11 +1382,13 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
}
- @Override public void visitReferenceExpression(PsiReferenceExpression expression) {
+ @Override
+ public void visitReferenceExpression(PsiReferenceExpression expression) {
visitReferenceElement(expression);
}
- @Override public void visitConditionalExpression(PsiConditionalExpression expression) {
+ @Override
+ public void visitConditionalExpression(PsiConditionalExpression expression) {
if (myRole2 == ChildRole.QUEST) {
createSpaceInCode(mySettings.SPACE_BEFORE_QUEST);
}
@@ -1409,7 +1403,8 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
}
- @Override public void visitStatement(PsiStatement statement) {
+ @Override
+ public void visitStatement(PsiStatement statement) {
if (myRole2 == ChildRole.CLOSING_SEMICOLON) {
createSpaceInCode(false);
}
@@ -1419,7 +1414,8 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
}
- @Override public void visitReturnStatement(PsiReturnStatement statement) {
+ @Override
+ public void visitReturnStatement(PsiReturnStatement statement) {
if (myChild2.getElementType() == JavaTokenType.SEMICOLON) {
createSpaceInCode(false);
}
@@ -1431,21 +1427,24 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
}
- @Override public void visitMethodCallExpression(PsiMethodCallExpression expression) {
+ @Override
+ public void visitMethodCallExpression(PsiMethodCallExpression expression) {
if (myRole2 == ChildRole.ARGUMENT_LIST) {
createSpaceInCode(mySettings.SPACE_BEFORE_METHOD_CALL_PARENTHESES);
}
}
- @Override public void visitTypeParameter(PsiTypeParameter classParameter) {
- createSpaceInCode(true);
+ @Override
+ public void visitTypeParameter(PsiTypeParameter classParameter) {
+ createSpaceInCode(true);
}
- @Override public void visitTypeElement(PsiTypeElement type) {
- if (myChild2.getElementType() == JavaTokenType.ELLIPSIS
- || myChild2.getElementType() == JavaTokenType.LBRACKET
- || myChild2.getElementType() == JavaTokenType.RBRACKET)
- {
+ @Override
+ public void visitTypeElement(PsiTypeElement type) {
+ if (myType1 == JavaElementType.ANNOTATION || myType2 == JavaElementType.ANNOTATION) {
+ createSpaceInCode(true);
+ }
+ else if (myType2 == JavaTokenType.ELLIPSIS || myType2 == JavaTokenType.LBRACKET || myType2 == JavaTokenType.RBRACKET) {
createSpaceInCode(false);
}
else if (type.getType() instanceof PsiDisjunctionType) {
@@ -1456,15 +1455,18 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
}
- @Override public void visitDeclarationStatement(PsiDeclarationStatement declarationStatement) {
+ @Override
+ public void visitDeclarationStatement(PsiDeclarationStatement declarationStatement) {
if (myRole2 == ChildRole.COMMA) {
createSpaceProperty(false, false, mySettings.KEEP_BLANK_LINES_IN_CODE);
- } else if (myRole1 == ChildRole.COMMA) {
+ }
+ else if (myRole1 == ChildRole.COMMA) {
createSpaceInCode(true);
}
}
- @Override public void visitTypeParameterList(PsiTypeParameterList list) {
+ @Override
+ public void visitTypeParameterList(PsiTypeParameterList list) {
if (myRole1 == ChildRole.LT_IN_TYPE_LIST || myRole2 == ChildRole.GT_IN_TYPE_LIST) {
createSpaceInCode(myJavaSettings.SPACES_WITHIN_ANGLE_BRACKETS);
}
@@ -1473,19 +1475,24 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
}
- @Override public void visitReferenceElement(PsiJavaCodeReferenceElement reference) {
+ @Override
+ public void visitReferenceElement(PsiJavaCodeReferenceElement reference) {
if (myRole1 == ChildRole.REFERENCE_PARAMETER_LIST && myRole2 == ChildRole.REFERENCE_NAME) {
createSpaceInCode(myJavaSettings.SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TYPE_ARGUMENT);
}
else if (myRole2 == ChildRole.REFERENCE_PARAMETER_LIST) {
createSpaceInCode(mySettings.SPACE_BEFORE_TYPE_PARAMETER_LIST);
}
- else if (myRole2 == ChildRole.DOT){
+ else if (myRole2 == ChildRole.DOT) {
createSpaceInCode(false);
}
+ else if (myType1 == JavaElementType.ANNOTATION) {
+ createSpaceInCode(true);
+ }
}
- @Override public void visitAnnotation(PsiAnnotation annotation) {
+ @Override
+ public void visitAnnotation(PsiAnnotation annotation) {
if (myRole2 == ChildRole.PARAMETER_LIST) {
createSpaceInCode(mySettings.SPACE_BEFORE_ANOTATION_PARAMETER_LIST);
}
@@ -1494,21 +1501,21 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
}
- @Override public void visitClassInitializer(PsiClassInitializer initializer) {
+ @Override
+ public void visitClassInitializer(PsiClassInitializer initializer) {
if (myChild2.getElementType() == JavaElementType.CODE_BLOCK) {
myResult = getSpaceBeforeLBrace(mySettings.SPACE_BEFORE_METHOD_LBRACE, mySettings.BRACE_STYLE, null, false, true);
}
}
- @Override public void visitAnnotationParameterList(PsiAnnotationParameterList list) {
+ @Override
+ public void visitAnnotationParameterList(PsiAnnotationParameterList list) {
if (myRole1 == ChildRole.LPARENTH && myRole2 == ChildRole.RPARENTH) {
createSpaceInCode(false);
}
// There is a possible case that annotation key-value pair is used in 'shorten' form (with implicit name 'values'). It's also
// possible that target value is surrounded by curly braces. We want to define child role accordingly then.
- else if (myRole1 == ChildRole.LPARENTH && mySettings.SPACE_BEFORE_ANNOTATION_ARRAY_INITIALIZER_LBRACE
- && myRole2 == ChildRole.ANNOTATION_VALUE)
- {
+ else if (myRole1 == ChildRole.LPARENTH && mySettings.SPACE_BEFORE_ANNOTATION_ARRAY_INITIALIZER_LBRACE && myRole2 == ChildRole.ANNOTATION_VALUE) {
createSpaceInCode(true);
}
else if (myRole1 == ChildRole.LPARENTH || myRole2 == ChildRole.RPARENTH) {
@@ -1520,16 +1527,17 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
else if (myRole1 == ChildRole.COMMA) {
createSpaceInCode(true);
}
-
}
- @Override public void visitNameValuePair(PsiNameValuePair pair) {
+ @Override
+ public void visitNameValuePair(PsiNameValuePair pair) {
if (myRole1 == ChildRole.OPERATION_SIGN || myRole2 == ChildRole.OPERATION_SIGN) {
createSpaceInCode(mySettings.SPACE_AROUND_ASSIGNMENT_OPERATORS);
}
}
- @Override public void visitAnnotationArrayInitializer(PsiArrayInitializerMemberValue initializer) {
+ @Override
+ public void visitAnnotationArrayInitializer(PsiArrayInitializerMemberValue initializer) {
visitArrayInitializer();
}
@@ -1537,8 +1545,7 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
if (myRole1 == ChildRole.LBRACE) {
if (mySettings.ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE) {
int spaces = mySettings.SPACE_WITHIN_ARRAY_INITIALIZER_BRACES ? 1 : 0;
- myResult = Spacing
- .createDependentLFSpacing(spaces, spaces, myParent.getTextRange(), mySettings.KEEP_LINE_BREAKS,
+ myResult = Spacing.createDependentLFSpacing(spaces, spaces, myParent.getTextRange(), mySettings.KEEP_LINE_BREAKS,
mySettings.KEEP_BLANK_LINES_IN_CODE);
}
else {
@@ -1552,8 +1559,7 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
else if (myRole2 == ChildRole.RBRACE) {
if (mySettings.ARRAY_INITIALIZER_RBRACE_ON_NEXT_LINE) {
int spaces = mySettings.SPACE_WITHIN_ARRAY_INITIALIZER_BRACES ? 1 : 0;
- myResult = Spacing
- .createDependentLFSpacing(spaces, spaces, myParent.getTextRange(), mySettings.KEEP_LINE_BREAKS,
+ myResult = Spacing.createDependentLFSpacing(spaces, spaces, myParent.getTextRange(), mySettings.KEEP_LINE_BREAKS,
mySettings.KEEP_BLANK_LINES_BEFORE_RBRACE);
}
else {
@@ -1568,7 +1574,8 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
}
- @Override public void visitEnumConstant(PsiEnumConstant enumConstant) {
+ @Override
+ public void visitEnumConstant(PsiEnumConstant enumConstant) {
if (myRole2 == ChildRole.ARGUMENT_LIST) {
createSpaceInCode(mySettings.SPACE_BEFORE_METHOD_CALL_PARENTHESES);
}
@@ -1578,14 +1585,16 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
}
- @Override public void visitDocTag(PsiDocTag tag) {
+ @Override
+ public void visitDocTag(PsiDocTag tag) {
if (myType1 == JavaDocTokenType.DOC_TAG_NAME && myType2 == JavaDocElementType.DOC_TAG_VALUE_ELEMENT) {
myResult = Spacing.createSpacing(1, 1, 0, false, 0);
}
}
- @Override public void visitAssertStatement(PsiAssertStatement statement) {
+ @Override
+ public void visitAssertStatement(PsiAssertStatement statement) {
if (myChild1.getElementType() == JavaTokenType.ASSERT_KEYWORD) {
createSpaceInCode(true);
}
@@ -1598,7 +1607,8 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
- @Override public void visitParameter(PsiParameter parameter) {
+ @Override
+ public void visitParameter(PsiParameter parameter) {
if (myRole1 == ChildRole.TYPE || myRole1 == ChildRole.MODIFIER_LIST) {
createSpaceInCode(true);
}
@@ -1669,5 +1679,4 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
lexer.advance();
return lexer.getTokenType() == null;
}
-
}
diff --git a/java/java-impl/src/com/intellij/psi/formatter/java/SimpleJavaBlock.java b/java/java-impl/src/com/intellij/psi/formatter/java/SimpleJavaBlock.java
index 34d677289a49..c74b9c05b19b 100644
--- a/java/java-impl/src/com/intellij/psi/formatter/java/SimpleJavaBlock.java
+++ b/java/java-impl/src/com/intellij/psi/formatter/java/SimpleJavaBlock.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.
@@ -27,17 +27,16 @@ import com.intellij.psi.impl.source.tree.JavaDocElementType;
import com.intellij.psi.impl.source.tree.JavaElementType;
import com.intellij.psi.impl.source.tree.StdTokenSets;
import com.intellij.psi.tree.IElementType;
+import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class SimpleJavaBlock extends AbstractJavaBlock {
-
+ private final Map<IElementType, Wrap> myReservedWrap = ContainerUtil.newHashMap();
private int myStartOffset = -1;
- private final Map<IElementType, Wrap> myReservedWrap = new HashMap<IElementType, Wrap>();
public SimpleJavaBlock(ASTNode node,
Wrap wrap,
@@ -81,9 +80,9 @@ public class SimpleJavaBlock extends AbstractJavaBlock {
if (astNode != child && child != null) {
offset = child.getTextRange().getStartOffset();
}
- if (indent != null
- && !(myNode.getPsi() instanceof PsiFile) && child != null && child.getElementType() != JavaElementType.MODIFIER_LIST)
- {
+ if (indent != null &&
+ !(myNode.getPsi() instanceof PsiFile) &&
+ child != null && child.getElementType() != JavaElementType.MODIFIER_LIST) {
indent = Indent.getContinuationIndent(myIndentSettings.USE_RELATIVE_INDENTS);
}
}
@@ -99,10 +98,7 @@ public class SimpleJavaBlock extends AbstractJavaBlock {
@Override
@NotNull
public TextRange getTextRange() {
- if (myStartOffset != -1) {
- return new TextRange(myStartOffset, myStartOffset + myNode.getTextLength());
- }
- return super.getTextRange();
+ return myStartOffset == -1 ? super.getTextRange() : new TextRange(myStartOffset, myStartOffset + myNode.getTextLength());
}
@Override
@@ -111,8 +107,9 @@ public class SimpleJavaBlock extends AbstractJavaBlock {
if (myNode.getElementType() == JavaElementType.CONDITIONAL_EXPRESSION && mySettings.ALIGN_MULTILINE_TERNARY_OPERATION) {
final Alignment usedAlignment = getUsedAlignment(newChildIndex);
if (usedAlignment != null) {
- return new ChildAttributes(null, usedAlignment);
- } else {
+ return new ChildAttributes(null, usedAlignment);
+ }
+ else {
return super.getChildAttributes(newChildIndex);
}
}
diff --git a/java/java-impl/src/com/intellij/psi/formatter/java/wrap/impl/JavaChildWrapArranger.java b/java/java-impl/src/com/intellij/psi/formatter/java/wrap/impl/JavaChildWrapArranger.java
index 52ea316861c6..954f03248b9c 100644
--- a/java/java-impl/src/com/intellij/psi/formatter/java/wrap/impl/JavaChildWrapArranger.java
+++ b/java/java-impl/src/com/intellij/psi/formatter/java/wrap/impl/JavaChildWrapArranger.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,10 +18,7 @@ package com.intellij.psi.formatter.java.wrap.impl;
import com.intellij.formatting.Wrap;
import com.intellij.formatting.WrapType;
import com.intellij.lang.ASTNode;
-import com.intellij.psi.JavaTokenType;
-import com.intellij.psi.PsiPolyadicExpression;
-import com.intellij.psi.PsiStatement;
-import com.intellij.psi.codeStyle.CodeStyleSettings;
+import com.intellij.psi.*;
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
import com.intellij.psi.formatter.FormatterUtil;
import com.intellij.psi.formatter.java.JavaFormatterUtil;
@@ -34,20 +31,21 @@ import com.intellij.psi.tree.IElementType;
import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.Nullable;
+import static com.intellij.psi.formatter.java.JavaFormatterUtil.getWrapType;
+import static com.intellij.psi.impl.PsiImplUtil.isTypeAnnotation;
+
/**
- * Encapsulates implementation of
- * {@link JavaWrapManager#arrangeChildWrap(ASTNode, ASTNode, CodeStyleSettings, Wrap, ReservedWrapsProvider)}.
+ * Encapsulates the implementation of
+ * {@link JavaWrapManager#arrangeChildWrap(ASTNode, ASTNode, CommonCodeStyleSettings, Wrap, ReservedWrapsProvider)}.
* <p/>
* Thread-safe.
*
* @author Denis Zhdanov
- * @since Apr 21, 2010 2:30:29 PM
+ * @since Apr 21, 2010
*/
public class JavaChildWrapArranger {
-
/**
- * Provides implementation of {@link JavaWrapManager#arrangeChildWrap(ASTNode, ASTNode, CodeStyleSettings, Wrap, ReservedWrapsProvider)}
- * method.
+ * Provides implementation of {@link JavaWrapManager#arrangeChildWrap} method.
*
* @param child child node which {@link Wrap wrap} is to be defined
* @param parent direct or indirect parent of the given <code>'child'</code> node. Defines usage context
@@ -66,23 +64,32 @@ public class JavaChildWrapArranger {
*/
@SuppressWarnings({"MethodMayBeStatic"})
@Nullable
- public Wrap arrange(ASTNode child, ASTNode parent, CommonCodeStyleSettings settings, Wrap suggestedWrap, ReservedWrapsProvider reservedWrapsProvider) {
+ public Wrap arrange(ASTNode child,
+ ASTNode parent,
+ CommonCodeStyleSettings settings,
+ Wrap suggestedWrap,
+ ReservedWrapsProvider reservedWrapsProvider) {
ASTNode directParent = child.getTreeParent();
int role = ((CompositeElement)directParent).getChildRole(child);
- final IElementType nodeType = parent.getElementType();
+
if (parent instanceof PsiPolyadicExpression) {
if (role == ChildRole.OPERATION_SIGN && !settings.BINARY_OPERATION_SIGN_ON_NEXT_LINE) return null;
boolean rOperand = ArrayUtil.indexOf(((PsiPolyadicExpression)parent).getOperands(), child.getPsi()) > 0;
if (settings.BINARY_OPERATION_SIGN_ON_NEXT_LINE && rOperand) return null;
return suggestedWrap;
}
- final IElementType childType = child.getElementType();
+
+ IElementType nodeType = parent.getElementType();
+ IElementType childType = child.getElementType();
+
if (childType == JavaElementType.EXTENDS_LIST || childType == JavaElementType.IMPLEMENTS_LIST) {
return Wrap.createWrap(settings.EXTENDS_KEYWORD_WRAP, true);
}
+
else if (childType == JavaElementType.THROWS_LIST) {
return Wrap.createWrap(settings.THROWS_KEYWORD_WRAP, true);
}
+
else if (nodeType == JavaElementType.EXTENDS_LIST || nodeType == JavaElementType.IMPLEMENTS_LIST) {
if (role == ChildRole.REFERENCE_IN_LIST) {
return suggestedWrap;
@@ -91,6 +98,7 @@ public class JavaChildWrapArranger {
return null;
}
}
+
else if (nodeType == JavaElementType.THROWS_LIST) {
if (role == ChildRole.REFERENCE_IN_LIST) {
return suggestedWrap;
@@ -99,26 +107,21 @@ public class JavaChildWrapArranger {
return null;
}
}
+
else if (nodeType == JavaElementType.CONDITIONAL_EXPRESSION) {
if (role == ChildRole.COLON && !settings.TERNARY_OPERATION_SIGNS_ON_NEXT_LINE) return null;
if (role == ChildRole.QUEST && !settings.TERNARY_OPERATION_SIGNS_ON_NEXT_LINE) return null;
if (role == ChildRole.THEN_EXPRESSION && settings.TERNARY_OPERATION_SIGNS_ON_NEXT_LINE) return null;
if (role == ChildRole.ELSE_EXPRESSION && settings.TERNARY_OPERATION_SIGNS_ON_NEXT_LINE) return null;
return suggestedWrap;
-
}
- else if (JavaFormatterUtil.isAssignment(parent)) {
- if (role == ChildRole.INITIALIZER_EQ && settings.PLACE_ASSIGNMENT_SIGN_ON_NEXT_LINE) return suggestedWrap;
- if (role == ChildRole.INITIALIZER_EQ && !settings.PLACE_ASSIGNMENT_SIGN_ON_NEXT_LINE) return null;
- if (role == ChildRole.OPERATION_SIGN && settings.PLACE_ASSIGNMENT_SIGN_ON_NEXT_LINE) return suggestedWrap;
- if (role == ChildRole.OPERATION_SIGN && !settings.PLACE_ASSIGNMENT_SIGN_ON_NEXT_LINE) return null;
- if (role == ChildRole.INITIALIZER && !settings.PLACE_ASSIGNMENT_SIGN_ON_NEXT_LINE) return suggestedWrap;
- if (role == ChildRole.INITIALIZER && settings.PLACE_ASSIGNMENT_SIGN_ON_NEXT_LINE) return null;
- if (role == ChildRole.ROPERAND && !settings.PLACE_ASSIGNMENT_SIGN_ON_NEXT_LINE) return suggestedWrap;
- if (role == ChildRole.ROPERAND && settings.PLACE_ASSIGNMENT_SIGN_ON_NEXT_LINE) return null;
+ else if (JavaFormatterUtil.isAssignment(parent) && role != ChildRole.TYPE) {
+ if (role == ChildRole.INITIALIZER_EQ) return settings.PLACE_ASSIGNMENT_SIGN_ON_NEXT_LINE ? suggestedWrap : null;
+ if (role == ChildRole.OPERATION_SIGN) return settings.PLACE_ASSIGNMENT_SIGN_ON_NEXT_LINE ? suggestedWrap : null;
+ if (role == ChildRole.INITIALIZER) return settings.PLACE_ASSIGNMENT_SIGN_ON_NEXT_LINE ? null : suggestedWrap;
+ if (role == ChildRole.ROPERAND) return settings.PLACE_ASSIGNMENT_SIGN_ON_NEXT_LINE ? null : suggestedWrap;
if (role == ChildRole.CLOSING_SEMICOLON) return null;
- //if (role == ChildRole.TYPE) return suggestedWrap;
return suggestedWrap;
}
@@ -130,6 +133,7 @@ public class JavaChildWrapArranger {
return suggestedWrap;
}
}
+
else if (nodeType == JavaElementType.FOR_STATEMENT) {
if (role == ChildRole.FOR_INITIALIZATION || role == ChildRole.CONDITION || role == ChildRole.FOR_UPDATE) {
return suggestedWrap;
@@ -142,33 +146,48 @@ public class JavaChildWrapArranger {
else {
return null;
}
-
}
- else if (nodeType == JavaElementType.METHOD) {
- if (role == ChildRole.THROWS_LIST) {
- return suggestedWrap;
- }
- else {
- return null;
+ else if (parent.getPsi() instanceof PsiModifierListOwner) {
+ ASTNode prev = FormatterUtil.getPreviousNonWhitespaceSibling(child);
+ if (prev != null && prev.getElementType() == JavaElementType.MODIFIER_LIST) {
+ ASTNode last = prev.getLastChildNode();
+ if (last != null && last.getElementType() == JavaElementType.ANNOTATION) {
+ if (isTypeAnnotation(last.getPsi())) {
+ return Wrap.createWrap(WrapType.NONE, false);
+ }
+ else {
+ return Wrap.createWrap(getWrapType(getAnnotationWrapType(parent, child, settings)), true);
+ }
+ }
}
+
+ return null;
}
else if (nodeType == JavaElementType.MODIFIER_LIST) {
if (childType == JavaElementType.ANNOTATION) {
- return reservedWrapsProvider.getReservedWrap(JavaElementType.MODIFIER_LIST);
+ if (isTypeAnnotation(child.getPsi())) {
+ ASTNode prev = FormatterUtil.getPreviousNonWhitespaceSibling(child);
+ if (prev == null || prev.getElementType() != JavaElementType.ANNOTATION || isTypeAnnotation(prev.getPsi())) {
+ return Wrap.createWrap(WrapType.NONE, false);
+ }
+ }
+
+ return Wrap.createWrap(getWrapType(getAnnotationWrapType(parent.getTreeParent(), child, settings)), true);
}
else if (childType == JavaTokenType.END_OF_LINE_COMMENT) {
return Wrap.createWrap(WrapType.NORMAL, true);
}
- ASTNode prevElement = FormatterUtil.getPreviousNonWhitespaceSibling(child);
- if (prevElement != null && prevElement.getElementType() == JavaElementType.ANNOTATION) {
- return reservedWrapsProvider.getReservedWrap(JavaElementType.MODIFIER_LIST);
- }
- else {
- return null;
+
+ ASTNode prev = FormatterUtil.getPreviousNonWhitespaceSibling(child);
+ if (prev != null && prev.getElementType() == JavaElementType.ANNOTATION) {
+ return Wrap.createWrap(getWrapType(getAnnotationWrapType(parent.getTreeParent(), child, settings)), true);
}
+
+ return null;
}
+
else if (nodeType == JavaElementType.ASSERT_STATEMENT) {
if (role == ChildRole.CONDITION) {
return suggestedWrap;
@@ -181,6 +200,7 @@ public class JavaChildWrapArranger {
}
return null;
}
+
else if (nodeType == JavaElementType.CODE_BLOCK) {
if (child.getPsi() instanceof PsiStatement) {
return suggestedWrap;
@@ -218,10 +238,13 @@ public class JavaChildWrapArranger {
else if (nodeType == JavaElementType.DO_WHILE_STATEMENT) {
if (role == ChildRole.LOOP_BODY) {
return Wrap.createWrap(WrapType.NORMAL, true);
- } else if (role == ChildRole.WHILE_KEYWORD) {
+ }
+ else if (role == ChildRole.WHILE_KEYWORD) {
return Wrap.createWrap(WrapType.NORMAL, true);
}
- } else if (nodeType == JavaElementType.ANNOTATION_ARRAY_INITIALIZER) {
+ }
+
+ else if (nodeType == JavaElementType.ANNOTATION_ARRAY_INITIALIZER) {
if (suggestedWrap != null) {
return suggestedWrap;
}
@@ -232,4 +255,47 @@ public class JavaChildWrapArranger {
return suggestedWrap;
}
+
+ private static int getAnnotationWrapType(ASTNode parent, ASTNode child, CommonCodeStyleSettings settings) {
+ IElementType nodeType = parent.getElementType();
+
+ if (nodeType == JavaElementType.METHOD) {
+ return settings.METHOD_ANNOTATION_WRAP;
+ }
+
+ if (nodeType == JavaElementType.CLASS) {
+ // There is a possible case that current document state is invalid from language syntax point of view, e.g. the user starts
+ // typing field definition and re-formatting is triggered by 'auto insert javadoc' processing. Example:
+ // class Test {
+ // @NotNull Object
+ // }
+ // Here '@NotNull' has a 'class' node as a parent but we want to use field annotation setting value.
+ // Hence we check if subsequent parsed info is valid.
+ for (ASTNode node = child.getTreeNext(); node != null; node = node.getTreeNext()) {
+ if (node.getElementType() == TokenType.WHITE_SPACE || node instanceof PsiTypeElement) {
+ continue;
+ }
+ if (node instanceof PsiErrorElement) {
+ return settings.FIELD_ANNOTATION_WRAP;
+ }
+ }
+ return settings.CLASS_ANNOTATION_WRAP;
+ }
+
+ if (nodeType == JavaElementType.FIELD) {
+ return settings.FIELD_ANNOTATION_WRAP;
+ }
+
+ if (nodeType == JavaElementType.PARAMETER ||
+ nodeType == JavaElementType.RECEIVER_PARAMETER ||
+ nodeType == JavaElementType.RESOURCE_VARIABLE) {
+ return settings.PARAMETER_ANNOTATION_WRAP;
+ }
+
+ if (nodeType == JavaElementType.LOCAL_VARIABLE) {
+ return settings.VARIABLE_ANNOTATION_WRAP;
+ }
+
+ return CommonCodeStyleSettings.DO_NOT_WRAP;
+ }
}
diff --git a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FilePathReferenceProvider.java b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FilePathReferenceProvider.java
index 4ca7694dfd5b..827a3d128a24 100644
--- a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FilePathReferenceProvider.java
+++ b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FilePathReferenceProvider.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.
@@ -44,12 +44,12 @@ public class FilePathReferenceProvider extends PsiReferenceProvider {
}
@NotNull
- public PsiReference[] getReferencesByElement(PsiElement element, String text, int offset, final boolean soft) {
+ public PsiReference[] getReferencesByElement(@NotNull PsiElement element, String text, int offset, final boolean soft) {
return getReferencesByElement(element, text, offset, soft, Module.EMPTY_ARRAY);
}
@NotNull
- public PsiReference[] getReferencesByElement(PsiElement element,
+ public PsiReference[] getReferencesByElement(@NotNull PsiElement element,
String text,
int offset,
final boolean soft,
diff --git a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/PathListReferenceProvider.java b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/PathListReferenceProvider.java
index 3685ef7c9b8b..df171339ff01 100644
--- a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/PathListReferenceProvider.java
+++ b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/PathListReferenceProvider.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.
@@ -75,7 +75,7 @@ public class PathListReferenceProvider extends PsiReferenceProvider {
return ',';
}
- protected PsiReference[] createReferences(PsiElement element, String s, int offset, final boolean soft) {
+ protected PsiReference[] createReferences(@NotNull PsiElement element, String s, int offset, final boolean soft) {
int contentOffset = StringUtil.findFirst(s, CharFilter.NOT_WHITESPACE_FILTER);
if (contentOffset >= 0) {
offset += contentOffset;
diff --git a/java/java-impl/src/com/intellij/psi/resolve/JavaMethodResolveHelper.java b/java/java-impl/src/com/intellij/psi/resolve/JavaMethodResolveHelper.java
index 2a17536550d1..c89ac7281c60 100644
--- a/java/java-impl/src/com/intellij/psi/resolve/JavaMethodResolveHelper.java
+++ b/java/java-impl/src/com/intellij/psi/resolve/JavaMethodResolveHelper.java
@@ -56,7 +56,7 @@ public class JavaMethodResolveHelper {
@Override
protected MethodCandidateInfo createCandidateInfo(final PsiMethod method, final PsiSubstitutor substitutor,
final boolean staticProblem,
- final boolean accessible) {
+ final boolean accessible, final boolean varargs) {
return JavaMethodResolveHelper.this
.createCandidateInfo(method, substitutor, staticProblem, myCurrentFileContext, !accessible, argumentList, argumentTypes,
languageLevel);
diff --git a/java/java-impl/src/com/intellij/refactoring/introduceParameter/IntroduceParameterProcessor.java b/java/java-impl/src/com/intellij/refactoring/introduceParameter/IntroduceParameterProcessor.java
index 076734e90a7f..dc1f1668d744 100644
--- a/java/java-impl/src/com/intellij/refactoring/introduceParameter/IntroduceParameterProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/introduceParameter/IntroduceParameterProcessor.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,15 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-/*
- * Created by IntelliJ IDEA.
- * User: dsl
- * Date: 07.05.2002
- * Time: 11:17:31
- * To change template for new class use
- * Code Style | Class Templates options (Tools | IDE Options).
- */
package com.intellij.refactoring.introduceParameter;
import com.intellij.codeInsight.ChangeContextUtil;
@@ -62,6 +53,10 @@ import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Set;
+/**
+ * @author dsl
+ * @since 07.05.2002
+ */
public class IntroduceParameterProcessor extends BaseRefactoringProcessor implements IntroduceParameterData {
private static final Logger LOG = Logger.getInstance("#com.intellij.refactoring.introduceParameter.IntroduceParameterProcessor");
@@ -72,7 +67,7 @@ public class IntroduceParameterProcessor extends BaseRefactoringProcessor implem
private final PsiLocalVariable myLocalVariable;
private final boolean myRemoveLocalVariable;
private final String myParameterName;
- private final boolean myReplaceAllOccurences;
+ private final boolean myReplaceAllOccurrences;
private int myReplaceFieldsWithGetters;
private final boolean myDeclareFinal;
@@ -94,7 +89,7 @@ public class IntroduceParameterProcessor extends BaseRefactoringProcessor implem
PsiLocalVariable localVariable,
boolean removeLocalVariable,
String parameterName,
- boolean replaceAllOccurences,
+ boolean replaceAllOccurrences,
int replaceFieldsWithGetters,
boolean declareFinal,
boolean generateDelegate,
@@ -110,7 +105,7 @@ public class IntroduceParameterProcessor extends BaseRefactoringProcessor implem
myLocalVariable = localVariable;
myRemoveLocalVariable = removeLocalVariable;
myParameterName = parameterName;
- myReplaceAllOccurences = replaceAllOccurences;
+ myReplaceAllOccurrences = replaceAllOccurrences;
myReplaceFieldsWithGetters = replaceFieldsWithGetters;
myDeclareFinal = declareFinal;
myGenerateDelegate = generateDelegate;
@@ -177,7 +172,7 @@ public class IntroduceParameterProcessor extends BaseRefactoringProcessor implem
}
}
- if (myReplaceAllOccurences) {
+ if (myReplaceAllOccurrences) {
for (PsiElement expr : getOccurrences()) {
result.add(new InternalUsageInfo(expr));
}
@@ -245,8 +240,9 @@ public class IntroduceParameterProcessor extends BaseRefactoringProcessor implem
for (UsageInfo usageInfo : usagesIn) {
if (!(usageInfo.getElement() instanceof PsiMethod) && !(usageInfo instanceof InternalUsageInfo)) {
if (!PsiTreeUtil.isAncestor(myMethodToReplaceIn.getContainingClass(), usageInfo.getElement(), false)) {
- conflicts.putValue(myParameterInitializer, RefactoringBundle.message("parameter.initializer.contains.0.but.not.all.calls.to.method.are.in.its.class",
- CommonRefactoringUtil.htmlEmphasize(PsiKeyword.SUPER)));
+ String message = RefactoringBundle.message("parameter.initializer.contains.0.but.not.all.calls.to.method.are.in.its.class",
+ CommonRefactoringUtil.htmlEmphasize(PsiKeyword.SUPER));
+ conflicts.putValue(myParameterInitializer, message);
break;
}
}
@@ -272,7 +268,8 @@ public class IntroduceParameterProcessor extends BaseRefactoringProcessor implem
if (usageInfo instanceof ExternalUsageInfo && IntroduceParameterUtil.isMethodUsage(usageInfo)) {
final PsiElement place = usageInfo.getElement();
for (PsiElement element : result) {
- if (element instanceof PsiField && myReplaceFieldsWithGetters != IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE) { //check getter access instead
+ if (element instanceof PsiField && myReplaceFieldsWithGetters != IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE) {
+ //check getter access instead
final PsiClass psiClass = ((PsiField)element).getContainingClass();
LOG.assertTrue(psiClass != null);
final PsiMethod method = psiClass.findMethodBySignature(PropertyUtil.generateGetterPrototype((PsiField)element), true);
@@ -370,7 +367,7 @@ public class IntroduceParameterProcessor extends BaseRefactoringProcessor implem
myInitializerWrapper = new JavaExpressionWrapper(myParameterInitializer);
- // Changing external occurences (the tricky part)
+ // Changing external occurrences (the tricky part)
IntroduceParameterUtil.processUsages(usages, this);
diff --git a/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java b/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java
index 5c6f5d3d4de9..5386aaf57d00 100644
--- a/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java
+++ b/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java
@@ -37,7 +37,10 @@ import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.*;
+import com.intellij.openapi.util.Key;
+import com.intellij.openapi.util.Pass;
+import com.intellij.openapi.util.Ref;
+import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.wm.WindowManager;
@@ -49,7 +52,6 @@ import com.intellij.psi.codeStyle.VariableKind;
import com.intellij.psi.impl.PsiDiamondTypeUtil;
import com.intellij.psi.impl.source.jsp.jspJava.JspCodeBlock;
import com.intellij.psi.impl.source.jsp.jspJava.JspHolderMethod;
-import com.intellij.psi.impl.source.resolve.DefaultParameterTypeInferencePolicy;
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
import com.intellij.psi.impl.source.tree.java.ReplaceExpressionUtil;
import com.intellij.psi.scope.processor.VariablesProcessor;
@@ -466,7 +468,8 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
final String[] varargsExpressions = text.split("s*,s*");
if (varargsExpressions.length > 1) {
final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(parent.getProject());
- final PsiMethod psiMethod = parent.resolveMethod();
+ final JavaResolveResult resolveResult = parent.resolveMethodGenerics();
+ final PsiMethod psiMethod = (PsiMethod)resolveResult.getElement();
if (psiMethod == null || !psiMethod.isVarArgs()) return null;
final PsiParameter[] parameters = psiMethod.getParameterList().getParameters();
final PsiParameter varargParameter = parameters[parameters.length - 1];
@@ -474,10 +477,7 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
LOG.assertTrue(type instanceof PsiEllipsisType);
final PsiArrayType psiType = (PsiArrayType)((PsiEllipsisType)type).toArrayType();
final PsiExpression[] args = parent.getArgumentList().getExpressions();
- final PsiSubstitutor psiSubstitutor =
- JavaPsiFacade.getInstance(parent.getProject()).getResolveHelper().inferTypeArguments(psiMethod.getTypeParameters(), parameters,
- args, PsiSubstitutor.EMPTY, parent,
- DefaultParameterTypeInferencePolicy.INSTANCE);
+ final PsiSubstitutor psiSubstitutor = resolveResult.getSubstitutor();
if (args.length < parameters.length || startOffset < args[parameters.length - 1].getTextRange().getStartOffset()) return null;
diff --git a/java/java-impl/src/com/intellij/refactoring/psi/MutationUtils.java b/java/java-impl/src/com/intellij/refactoring/psi/MutationUtils.java
index 2ad62807adf5..064f98b2630e 100644
--- a/java/java-impl/src/com/intellij/refactoring/psi/MutationUtils.java
+++ b/java/java-impl/src/com/intellij/refactoring/psi/MutationUtils.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.
@@ -21,96 +21,66 @@ import com.intellij.psi.codeStyle.CodeStyleManager;
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.util.IncorrectOperationException;
+import org.jetbrains.annotations.NotNull;
public class MutationUtils {
- private MutationUtils() {
- super();
- }
-
+ private MutationUtils() { }
- public static void replaceType(String newExpression,
- PsiTypeElement typeElement)
- throws IncorrectOperationException {
- final PsiManager mgr = typeElement.getManager();
- final PsiElementFactory factory = JavaPsiFacade.getInstance(mgr.getProject()).getElementFactory();
- final PsiType newType =
- factory.createTypeFromText(newExpression, null);
- final PsiTypeElement newTypeElement = factory.createTypeElement(newType);
- final PsiElement insertedElement = typeElement.replace(newTypeElement);
- final CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(mgr.getProject());
- final PsiElement shortenedElement = JavaCodeStyleManager.getInstance(mgr.getProject()).shortenClassReferences(insertedElement);
- codeStyleManager.reformat(shortenedElement);
- }
+ public static void replaceType(@NotNull String newTypeText, @NotNull PsiTypeElement typeElement) throws IncorrectOperationException {
+ final Project project = typeElement.getProject();
+ final PsiElementFactory factory = JavaPsiFacade.getInstance(project).getElementFactory();
+ final PsiType newType = factory.createTypeFromText(newTypeText, null);
+ final PsiTypeElement newTypeElement = factory.createTypeElement(newType);
+ final PsiElement insertedElement = typeElement.replace(newTypeElement);
+ final PsiElement shortenedElement = JavaCodeStyleManager.getInstance(project).shortenClassReferences(insertedElement);
+ CodeStyleManager.getInstance(project).reformat(shortenedElement);
+ }
- public static void replaceExpression(String newExpression,
- PsiExpression exp)
- throws IncorrectOperationException {
- final PsiManager mgr = exp.getManager();
- final PsiElementFactory factory = JavaPsiFacade.getInstance(mgr.getProject()).getElementFactory();
- final PsiExpression newCall =
- factory.createExpressionFromText(newExpression, null);
- final PsiElement insertedElement = exp.replace(newCall);
- final CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(mgr.getProject());
- final PsiElement shortenedElement = JavaCodeStyleManager.getInstance(mgr.getProject()).shortenClassReferences(insertedElement);
- codeStyleManager.reformat(shortenedElement);
- }
+ public static void replaceExpression(@NotNull String newExpression, @NotNull PsiExpression exp) throws IncorrectOperationException {
+ final Project project = exp.getProject();
+ final PsiElementFactory factory = JavaPsiFacade.getInstance(project).getElementFactory();
+ final PsiExpression newCall = factory.createExpressionFromText(newExpression, null);
+ final PsiElement insertedElement = exp.replace(newCall);
+ final PsiElement shortenedElement = JavaCodeStyleManager.getInstance(project).shortenClassReferences(insertedElement);
+ CodeStyleManager.getInstance(project).reformat(shortenedElement);
+ }
- public static void replaceExpressionIfValid(String newExpression,
- PsiExpression exp) throws IncorrectOperationException{
- final PsiManager mgr = exp.getManager();
- final PsiElementFactory factory = JavaPsiFacade.getInstance(mgr.getProject()).getElementFactory();
- final PsiExpression newCall;
- try{
- newCall = factory.createExpressionFromText(newExpression, null);
- } catch(IncorrectOperationException e){
- return;
- }
- final PsiElement insertedElement = exp.replace(newCall);
- final CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(mgr.getProject());
- final PsiElement shortenedElement =JavaCodeStyleManager.getInstance(mgr.getProject()).shortenClassReferences(insertedElement);
- codeStyleManager.reformat(shortenedElement);
+ public static void replaceExpressionIfValid(@NotNull String newExpression, @NotNull PsiExpression exp) throws IncorrectOperationException {
+ try {
+ replaceExpression(newExpression, exp);
}
+ catch (IncorrectOperationException ignored) { }
+ }
- public static void replaceReference(String className,
- PsiJavaCodeReferenceElement reference)
- throws IncorrectOperationException {
- final PsiManager mgr = reference.getManager();
- final Project project = mgr.getProject();
- final JavaPsiFacade facade = JavaPsiFacade.getInstance(mgr.getProject());
+ public static void replaceReference(@NotNull String className, @NotNull PsiJavaCodeReferenceElement ref) throws IncorrectOperationException {
+ final Project project = ref.getProject();
+ final JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
final PsiElementFactory factory = facade.getElementFactory();
final GlobalSearchScope scope = GlobalSearchScope.allScope(project);
-
final PsiElement insertedElement;
- final PsiElement parent = reference.getParent();
+ final PsiElement parent = ref.getParent();
if (parent instanceof PsiReferenceExpression) {
final PsiClass aClass = facade.findClass(className, scope);
if (aClass == null) return;
((PsiReferenceExpression)parent).setQualifierExpression(factory.createReferenceExpression(aClass));
insertedElement = ((PsiReferenceExpression)parent).getQualifierExpression();
+ assert insertedElement != null : parent;
}
else {
- final PsiJavaCodeReferenceElement newReference =
- factory.createReferenceElementByFQClassName(className, scope);
- insertedElement = reference.replace(newReference);
+ final PsiJavaCodeReferenceElement newReference = factory.createReferenceElementByFQClassName(className, scope);
+ insertedElement = ref.replace(newReference);
}
- final CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(mgr.getProject());
- final PsiElement shortenedElement = JavaCodeStyleManager.getInstance(mgr.getProject()).shortenClassReferences(insertedElement);
- codeStyleManager.reformat(shortenedElement);
+ final PsiElement shortenedElement = JavaCodeStyleManager.getInstance(project).shortenClassReferences(insertedElement);
+ CodeStyleManager.getInstance(project).reformat(shortenedElement);
}
- public static void replaceStatement(String newStatement,
- PsiStatement statement)
- throws IncorrectOperationException {
- final Project project = statement.getProject();
- final PsiManager mgr = PsiManager.getInstance(project);
- final PsiElementFactory factory = JavaPsiFacade.getInstance(mgr.getProject()).getElementFactory();
- final PsiStatement newCall =
- factory.createStatementFromText(newStatement, null);
- final PsiElement insertedElement = statement.replace(newCall);
- final CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(mgr.getProject());
- final PsiElement shortenedElement = JavaCodeStyleManager.getInstance(mgr.getProject()).shortenClassReferences(insertedElement);
- codeStyleManager.reformat(shortenedElement);
- }
-
+ public static void replaceStatement(@NotNull String newStatement, @NotNull PsiStatement statement) throws IncorrectOperationException {
+ final Project project = statement.getProject();
+ final PsiElementFactory factory = JavaPsiFacade.getInstance(project).getElementFactory();
+ final PsiStatement newCall = factory.createStatementFromText(newStatement, null);
+ final PsiElement insertedElement = statement.replace(newCall);
+ final PsiElement shortenedElement = JavaCodeStyleManager.getInstance(project).shortenClassReferences(insertedElement);
+ CodeStyleManager.getInstance(project).reformat(shortenedElement);
+ }
}
diff --git a/java/java-impl/src/com/intellij/refactoring/rename/JavaNameSuggestionProvider.java b/java/java-impl/src/com/intellij/refactoring/rename/JavaNameSuggestionProvider.java
index 258826422a4c..d1c23a9763f2 100644
--- a/java/java-impl/src/com/intellij/refactoring/rename/JavaNameSuggestionProvider.java
+++ b/java/java-impl/src/com/intellij/refactoring/rename/JavaNameSuggestionProvider.java
@@ -97,10 +97,11 @@ public class JavaNameSuggestionProvider implements NameSuggestionProvider {
if (!(psiElement instanceof PsiNamedElement)) return null;
String name = ((PsiNamedElement)psiElement).getName();
if (name == null) return null;
+ String prefix = "";
if (psiElement instanceof PsiVariable) {
final JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(psiElement.getProject());
final VariableKind kind = codeStyleManager.getVariableKind((PsiVariable)psiElement);
- final String prefix = codeStyleManager.getPrefixByVariableKind(kind);
+ prefix = codeStyleManager.getPrefixByVariableKind(kind);
if (kind == VariableKind.STATIC_FINAL_FIELD) {
final String[] words = NameUtil.splitNameIntoWords(name);
StringBuilder buffer = new StringBuilder();
@@ -111,19 +112,15 @@ public class JavaNameSuggestionProvider implements NameSuggestionProvider {
}
return new String[] {buffer.toString()};
}
- else {
- final List<String> result = new ArrayList<String>();
- result.add(suggestProperlyCasedName(prefix, NameUtil.splitNameIntoWords(name)));
- if (name.startsWith(prefix)) {
- name = name.substring(prefix.length());
- result.add(suggestProperlyCasedName(prefix, NameUtil.splitNameIntoWords(name)));
- }
- result.add(suggestProperlyCasedName(prefix, NameUtil.splitNameIntoWords(name.toLowerCase())));
- return ArrayUtil.toStringArray(result);
- }
-
}
- return new String[]{name};
+ final List<String> result = new ArrayList<String>();
+ result.add(suggestProperlyCasedName(prefix, NameUtil.splitNameIntoWords(name)));
+ if (name.startsWith(prefix)) {
+ name = name.substring(prefix.length());
+ result.add(suggestProperlyCasedName(prefix, NameUtil.splitNameIntoWords(name)));
+ }
+ result.add(suggestProperlyCasedName(prefix, NameUtil.splitNameIntoWords(name.toLowerCase())));
+ return ArrayUtil.toStringArray(result);
}
private static String suggestProperlyCasedName(String prefix, String[] words) {
diff --git a/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationProcessor.java b/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationProcessor.java
index 2f85e7a8fe31..609a981b7bf4 100644
--- a/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationProcessor.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.
@@ -43,8 +43,9 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-public class TypeMigrationProcessor extends BaseRefactoringProcessor {
+import static com.intellij.util.ObjectUtils.assertNotNull;
+public class TypeMigrationProcessor extends BaseRefactoringProcessor {
private PsiElement[] myRoot;
private final TypeMigrationRules myRules;
private TypeMigrationLabeler myLabeler;
@@ -53,6 +54,12 @@ public class TypeMigrationProcessor extends BaseRefactoringProcessor {
this(project, getRoots(root), rules);
}
+ public TypeMigrationProcessor(final Project project, final PsiElement[] roots, final TypeMigrationRules rules) {
+ super(project);
+ myRoot = roots;
+ myRules = rules;
+ }
+
private static PsiElement[] getRoots(PsiElement root) {
if (root instanceof PsiVariable) {
final PsiElement parent = root.getParent();
@@ -77,12 +84,6 @@ public class TypeMigrationProcessor extends BaseRefactoringProcessor {
return new PsiElement[]{root};
}
- public TypeMigrationProcessor(final Project project, final PsiElement[] roots, final TypeMigrationRules rules) {
- super(project);
- myRoot = roots;
- myRules = rules;
- }
-
public static void runHighlightingTypeMigration(final Project project,
final Editor editor,
final TypeMigrationRules rules,
@@ -115,10 +116,12 @@ public class TypeMigrationProcessor extends BaseRefactoringProcessor {
}
@NotNull
+ @Override
protected UsageViewDescriptor createUsageViewDescriptor(UsageInfo[] usages) {
return new TypeMigrationViewDescriptor(myRoot[0]);
}
+ @Override
protected boolean preprocessUsages(Ref<UsageInfo[]> refUsages) {
if (hasFailedConversions()) {
if (ApplicationManager.getApplication().isUnitTestMode()) {
@@ -162,19 +165,16 @@ public class TypeMigrationProcessor extends BaseRefactoringProcessor {
else {
text = Arrays.toString(myRoot);
}
- Content content = UsageViewManager.getInstance(myProject)
- .addContent("Migrate Type of " +
- text +
- " from \'" +
- TypeMigrationLabeler.getElementType(myRoot[0]).getPresentableText() +
- "\' to \'" +
- myRules.getMigrationRootType().getPresentableText() +
- "\'", false, panel, true, true);
+ String fromType = assertNotNull(TypeMigrationLabeler.getElementType(myRoot[0])).getPresentableText();
+ String toType = myRules.getMigrationRootType().getPresentableText();
+ String name = "Migrate Type of " + text + " from \'" + fromType + "\' to \'" + toType + "\'";
+ Content content = UsageViewManager.getInstance(myProject).addContent(name, false, panel, true, true);
panel.setContent(content);
ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.FIND).activate(null);
}
@NotNull
+ @Override
public UsageInfo[] findUsages() {
myLabeler = new TypeMigrationLabeler(myRules);
@@ -187,10 +187,12 @@ public class TypeMigrationProcessor extends BaseRefactoringProcessor {
}
}
+ @Override
protected void refreshElements(PsiElement[] elements) {
myRoot = elements;
}
+ @Override
public void performRefactoring(UsageInfo[] usages) {
change(myLabeler, usages);
}
@@ -200,9 +202,13 @@ public class TypeMigrationProcessor extends BaseRefactoringProcessor {
for (UsageInfo usage : usages) {
if (((TypeMigrationUsageInfo)usage).isExcluded()) continue;
final PsiElement element = usage.getElement();
- if (element instanceof PsiVariable || element instanceof PsiMember || element instanceof PsiExpression || element instanceof PsiReferenceParameterList) {
+ if (element instanceof PsiVariable ||
+ element instanceof PsiMember ||
+ element instanceof PsiExpression ||
+ element instanceof PsiReferenceParameterList) {
labeler.change((TypeMigrationUsageInfo)usage);
- } else {
+ }
+ else {
nonCodeUsages.add(usage);
}
}
@@ -216,9 +222,7 @@ public class TypeMigrationProcessor extends BaseRefactoringProcessor {
try {
reference.bindToElement((PsiElement)target);
}
- catch (IncorrectOperationException e) {
- //skip
- }
+ catch (IncorrectOperationException ignored) { }
}
}
}
@@ -229,6 +233,7 @@ public class TypeMigrationProcessor extends BaseRefactoringProcessor {
return myLabeler;
}
+ @Override
protected String getCommandName() {
return "TypeMigration";
}
diff --git a/java/java-impl/src/com/intellij/refactoring/util/FixableUsageInfo.java b/java/java-impl/src/com/intellij/refactoring/util/FixableUsageInfo.java
index 309b3516fd9e..7bb73920a980 100644
--- a/java/java-impl/src/com/intellij/refactoring/util/FixableUsageInfo.java
+++ b/java/java-impl/src/com/intellij/refactoring/util/FixableUsageInfo.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.
@@ -20,12 +20,11 @@ import com.intellij.usageView.UsageInfo;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.Nullable;
-
@SuppressWarnings({"AbstractClassExtendsConcreteClass"})
public abstract class FixableUsageInfo extends UsageInfo {
- public FixableUsageInfo(PsiElement element) {
- super(element);
- }
+ public FixableUsageInfo(PsiElement element) {
+ super(element);
+ }
public abstract void fixUsage() throws IncorrectOperationException;
diff --git a/java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/ReturnValueBeanBuilder.java b/java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/ReturnValueBeanBuilder.java
index 33650b414c0e..965083e8ddc0 100644
--- a/java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/ReturnValueBeanBuilder.java
+++ b/java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/ReturnValueBeanBuilder.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,117 +22,113 @@ import com.intellij.psi.PsiTypeParameter;
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
import com.intellij.psi.codeStyle.VariableKind;
-import org.jetbrains.annotations.NonNls;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
class ReturnValueBeanBuilder {
- private String className = null;
- private String packageName = null;
- private final List<PsiTypeParameter> typeParams = new ArrayList<PsiTypeParameter>();
- private Project myProject = null;
- private PsiType valueType = null;
+ private final List<PsiTypeParameter> myTypeParams = new ArrayList<PsiTypeParameter>();
+ private String myClassName = null;
+ private String myPackageName = null;
+ private Project myProject = null;
+ private PsiType myValueType = null;
private boolean myStatic;
public void setClassName(String className) {
- this.className = className;
- }
+ myClassName = className;
+ }
- public void setPackageName(String packageName) {
- this.packageName = packageName;
- }
+ public void setPackageName(String packageName) {
+ myPackageName = packageName;
+ }
- public void setTypeArguments(List<PsiTypeParameter> typeParams) {
- this.typeParams.clear();
- this.typeParams.addAll(typeParams);
- }
+ public void setTypeArguments(List<PsiTypeParameter> typeParams) {
+ myTypeParams.clear();
+ myTypeParams.addAll(typeParams);
+ }
- public void setCodeStyleSettings(Project settings) {
- this.myProject = settings;
- }
+ public void setProject(Project project) {
+ myProject = project;
+ }
- public String buildBeanClass() throws IOException {
- @NonNls final StringBuffer out = new StringBuffer(1024);
-
- if (packageName.length() > 0) out.append("package " + packageName + ';');
- out.append('\n');
- out.append("public ");
- if (myStatic) out.append("static ");
- out.append("class ").append(className);
- if (!typeParams.isEmpty()) {
- out.append('<');
- boolean first = true;
- for (PsiTypeParameter typeParam : typeParams) {
- if (!first) {
- out.append(',');
- }
- final String parameterText = typeParam.getText();
- out.append(parameterText);
- first = false;
- }
- out.append('>');
- }
- out.append('\n');
-
- out.append('{');
- outputField(out);
- out.append('\n');
- outputConstructor(out);
- out.append('\n');
- outputGetter(out);
- out.append("}\n");
- return out.toString();
- }
+ public void setValueType(PsiType valueType) {
+ myValueType = valueType;
+ }
- private void outputGetter(@NonNls StringBuffer out) {
- final String typeText = valueType.getCanonicalText();
- @NonNls final String name = "value";
- final String capitalizedName = StringUtil.capitalize(name);
- out.append("\tpublic " + typeText + " get" + capitalizedName + "()\n");
- out.append("\t{\n");
- final String fieldName = getFieldName(name);
- out.append("\t\treturn " + fieldName + ";\n");
- out.append("\t}\n");
- out.append('\n');
- }
+ public void setStatic(boolean isStatic) {
+ myStatic = isStatic;
+ }
- private void outputField(@NonNls StringBuffer out) {
- final String typeText = valueType.getCanonicalText();
- out.append('\t' + "private final " + typeText + ' ' + getFieldName("value") + ";\n");
+ public String buildBeanClass() throws IOException {
+ final StringBuilder out = new StringBuilder(1024);
+
+ if (myPackageName.length() > 0) {
+ out.append("package ").append(myPackageName).append(";\n\n");
}
- private void outputConstructor(@NonNls StringBuffer out) {
- out.append("\tpublic " + className + '(');
- final String typeText = valueType.getCanonicalText();
- @NonNls final String name = "value";
- final String parameterName =
- JavaCodeStyleManager.getInstance(myProject).propertyNameToVariableName(name, VariableKind.PARAMETER);
- out.append(CodeStyleSettingsManager.getSettings(myProject).GENERATE_FINAL_PARAMETERS ? "final " : "");
- out.append(typeText + ' ' + parameterName);
- out.append(")\n");
- out.append("\t{\n");
- final String fieldName = getFieldName(name);
- if (fieldName.equals(parameterName)) {
- out.append("\t\tthis." + fieldName + " = " + parameterName + ";\n");
- } else {
- out.append("\t\t" + fieldName + " = " + parameterName + ";\n");
+ out.append("public ");
+ if (myStatic) out.append("static ");
+ out.append("class ").append(myClassName);
+ if (!myTypeParams.isEmpty()) {
+ out.append('<');
+ boolean first = true;
+ for (PsiTypeParameter typeParam : myTypeParams) {
+ if (!first) {
+ out.append(',');
}
- out.append("\t}\n");
- out.append('\n');
+ final String parameterText = typeParam.getText();
+ out.append(parameterText);
+ first = false;
+ }
+ out.append('>');
}
- private String getFieldName(final String name) {
- return JavaCodeStyleManager.getInstance(myProject).propertyNameToVariableName(name, VariableKind.FIELD);
+ out.append(" {\n");
+ outputField(out);
+ out.append("\n\n");
+ outputConstructor(out);
+ out.append("\n\n");
+ outputGetter(out);
+ out.append("\n}\n");
+
+ return out.toString();
}
- public void setValueType(PsiType valueType) {
- this.valueType = valueType;
+ private void outputField(StringBuilder out) {
+ final String typeText = myValueType.getCanonicalText(false);
+ out.append('\t' + "private final ").append(typeText).append(' ').append(getFieldName("value")).append(";");
+ }
+
+ private void outputConstructor(StringBuilder out) {
+ final String typeText = myValueType.getCanonicalText(true);
+ final String name = "value";
+ final String parameterName = JavaCodeStyleManager.getInstance(myProject).propertyNameToVariableName(name, VariableKind.PARAMETER);
+ final String fieldName = getFieldName(name);
+ out.append("\tpublic ").append(myClassName).append('(');
+ out.append(CodeStyleSettingsManager.getSettings(myProject).GENERATE_FINAL_PARAMETERS ? "final " : "");
+ out.append(typeText).append(' ').append(parameterName);
+ out.append(") {\n");
+ if (fieldName.equals(parameterName)) {
+ out.append("\t\tthis.").append(fieldName).append(" = ").append(parameterName).append(";\n");
+ }
+ else {
+ out.append("\t\t").append(fieldName).append(" = ").append(parameterName).append(";\n");
}
+ out.append("\t}");
+ }
- public void setStatic(final boolean isStatic) {
- myStatic = isStatic;
+ private void outputGetter(StringBuilder out) {
+ final String typeText = myValueType.getCanonicalText(true);
+ final String name = "value";
+ final String capitalizedName = StringUtil.capitalize(name);
+ final String fieldName = getFieldName(name);
+ out.append("\tpublic ").append(typeText).append(" get").append(capitalizedName).append("() {\n");
+ out.append("\t\treturn ").append(fieldName).append(";\n");
+ out.append("\t}");
}
-}
+ private String getFieldName(final String name) {
+ return JavaCodeStyleManager.getInstance(myProject).propertyNameToVariableName(name, VariableKind.FIELD);
+ }
+}
diff --git a/java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/WrapReturnValueProcessor.java b/java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/WrapReturnValueProcessor.java
index b967928aa34d..31dedf13d170 100644
--- a/java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/WrapReturnValueProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/WrapReturnValueProcessor.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.
@@ -19,7 +19,7 @@ import com.intellij.ide.highlighter.JavaFileType;
import com.intellij.ide.util.PackageUtil;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.module.Module;
-import com.intellij.openapi.module.ModuleUtil;
+import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Ref;
@@ -47,7 +47,6 @@ import com.intellij.usageView.UsageViewDescriptor;
import com.intellij.util.Function;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.containers.MultiMap;
-import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
@@ -57,47 +56,47 @@ import java.util.List;
import java.util.Set;
public class WrapReturnValueProcessor extends FixableUsagesRefactoringProcessor {
-
private static final Logger LOG = Logger.getInstance("com.siyeh.rpp.wrapreturnvalue.WrapReturnValueProcessor");
private MoveDestination myMoveDestination;
- private final PsiMethod method;
- private final String className;
- private final String packageName;
+ private final PsiMethod myMethod;
+ private final String myClassName;
+ private final String myPackageName;
private final boolean myCreateInnerClass;
private final PsiField myDelegateField;
private final String myQualifiedName;
private final boolean myUseExistingClass;
- private final List<PsiTypeParameter> typeParams;
- @NonNls
- private final String unwrapMethodName;
+ private final List<PsiTypeParameter> myTypeParameters;
+ private final String myUnwrapMethodName;
public WrapReturnValueProcessor(String className,
String packageName,
- MoveDestination moveDestination, PsiMethod method,
+ MoveDestination moveDestination,
+ PsiMethod method,
boolean useExistingClass,
- final boolean createInnerClass, PsiField delegateField) {
+ final boolean createInnerClass,
+ PsiField delegateField) {
super(method.getProject());
myMoveDestination = moveDestination;
- this.method = method;
- this.className = className;
- this.packageName = packageName;
+ myMethod = method;
+ myClassName = className;
+ myPackageName = packageName;
myCreateInnerClass = createInnerClass;
myDelegateField = delegateField;
myQualifiedName = StringUtil.getQualifiedName(packageName, className);
- this.myUseExistingClass = useExistingClass;
+ myUseExistingClass = useExistingClass;
final Set<PsiTypeParameter> typeParamSet = new HashSet<PsiTypeParameter>();
final TypeParametersVisitor visitor = new TypeParametersVisitor(typeParamSet);
final PsiTypeElement returnTypeElement = method.getReturnTypeElement();
assert returnTypeElement != null;
returnTypeElement.accept(visitor);
- typeParams = new ArrayList<PsiTypeParameter>(typeParamSet);
+ myTypeParameters = new ArrayList<PsiTypeParameter>(typeParamSet);
if (useExistingClass) {
- unwrapMethodName = calculateUnwrapMethodName();
+ myUnwrapMethodName = calculateUnwrapMethodName();
}
else {
- unwrapMethodName = "getValue";
+ myUnwrapMethodName = "getValue";
}
}
@@ -118,13 +117,15 @@ public class WrapReturnValueProcessor extends FixableUsagesRefactoringProcessor
}
@NotNull
+ @Override
protected UsageViewDescriptor createUsageViewDescriptor(UsageInfo[] usageInfos) {
- return new WrapReturnValueUsageViewDescriptor(method, usageInfos);
+ return new WrapReturnValueUsageViewDescriptor(myMethod, usageInfos);
}
+ @Override
public void findUsages(@NotNull List<FixableUsageInfo> usages) {
- findUsagesForMethod(method, usages);
- for (PsiMethod overridingMethod : OverridingMethodsSearch.search(method)) {
+ findUsagesForMethod(myMethod, usages);
+ for (PsiMethod overridingMethod : OverridingMethodsSearch.search(myMethod)) {
findUsagesForMethod(overridingMethod, usages);
}
}
@@ -134,7 +135,7 @@ public class WrapReturnValueProcessor extends FixableUsagesRefactoringProcessor
final PsiElement referenceElement = reference.getElement();
final PsiElement parent = referenceElement.getParent();
if (parent instanceof PsiCallExpression) {
- usages.add(new UnwrapCall((PsiCallExpression)parent, unwrapMethodName));
+ usages.add(new UnwrapCall((PsiCallExpression)parent, myUnwrapMethodName));
}
}
final String returnType = calculateReturnTypeString();
@@ -143,11 +144,12 @@ public class WrapReturnValueProcessor extends FixableUsagesRefactoringProcessor
}
private String calculateReturnTypeString() {
- final String qualifiedName = StringUtil.getQualifiedName(packageName, className);
+ final String qualifiedName = StringUtil.getQualifiedName(myPackageName, myClassName);
final StringBuilder returnTypeBuffer = new StringBuilder(qualifiedName);
- if (!typeParams.isEmpty()) {
+ if (!myTypeParameters.isEmpty()) {
returnTypeBuffer.append('<');
- returnTypeBuffer.append(StringUtil.join(typeParams, new Function<PsiTypeParameter, String>() {
+ returnTypeBuffer.append(StringUtil.join(myTypeParameters, new Function<PsiTypeParameter, String>() {
+ @Override
public String fun(final PsiTypeParameter typeParameter) {
final String paramName = typeParameter.getName();
LOG.assertTrue(paramName != null);
@@ -165,19 +167,19 @@ public class WrapReturnValueProcessor extends FixableUsagesRefactoringProcessor
final PsiClass existingClass = JavaPsiFacade.getInstance(myProject).findClass(myQualifiedName, GlobalSearchScope.allScope(myProject));
if (myUseExistingClass) {
if (existingClass == null) {
- conflicts.putValue(existingClass, RefactorJBundle.message("could.not.find.selected.wrapping.class"));
+ conflicts.putValue(null, RefactorJBundle.message("could.not.find.selected.wrapping.class"));
}
else {
boolean foundConstructor = false;
final Set<PsiType> returnTypes = new HashSet<PsiType>();
- returnTypes.add(method.getReturnType());
- final PsiCodeBlock methodBody = method.getBody();
+ returnTypes.add(myMethod.getReturnType());
+ final PsiCodeBlock methodBody = myMethod.getBody();
if (methodBody != null) {
methodBody.accept(new JavaRecursiveElementWalkingVisitor() {
@Override
public void visitReturnStatement(final PsiReturnStatement statement) {
super.visitReturnStatement(statement);
- if (PsiTreeUtil.getParentOfType(statement, PsiMethod.class) != method) return;
+ if (PsiTreeUtil.getParentOfType(statement, PsiMethod.class) != myMethod) return;
final PsiExpression returnValue = statement.getReturnValue();
if (returnValue != null) {
returnTypes.add(returnValue.getType());
@@ -223,7 +225,7 @@ public class WrapReturnValueProcessor extends FixableUsagesRefactoringProcessor
conflicts.putValue(existingClass, "Existing class does not have appropriate constructor");
}
}
- if (unwrapMethodName.length() == 0) {
+ if (myUnwrapMethodName.length() == 0) {
conflicts.putValue(existingClass,
"Existing class does not have getter for selected field");
}
@@ -232,28 +234,29 @@ public class WrapReturnValueProcessor extends FixableUsagesRefactoringProcessor
if (existingClass != null) {
conflicts.putValue(existingClass, RefactorJBundle.message("there.already.exists.a.class.with.the.selected.name"));
}
- if (myMoveDestination != null && !myMoveDestination.isTargetAccessible(myProject, method.getContainingFile().getVirtualFile())) {
- conflicts.putValue(method, "Created class won't be accessible in the call place");
+ if (myMoveDestination != null && !myMoveDestination.isTargetAccessible(myProject, myMethod.getContainingFile().getVirtualFile())) {
+ conflicts.putValue(myMethod, "Created class won't be accessible in the call place");
}
}
return showConflicts(conflicts, refUsages.get());
}
+ @Override
protected void performRefactoring(UsageInfo[] usageInfos) {
if (!myUseExistingClass && !buildClass()) return;
super.performRefactoring(usageInfos);
}
private boolean buildClass() {
- final PsiManager manager = method.getManager();
- final Project project = method.getProject();
+ final PsiManager manager = myMethod.getManager();
+ final Project project = myMethod.getProject();
final ReturnValueBeanBuilder beanClassBuilder = new ReturnValueBeanBuilder();
- beanClassBuilder.setCodeStyleSettings(project);
- beanClassBuilder.setTypeArguments(typeParams);
- beanClassBuilder.setClassName(className);
- beanClassBuilder.setPackageName(packageName);
- beanClassBuilder.setStatic(myCreateInnerClass && method.hasModifierProperty(PsiModifier.STATIC));
- final PsiType returnType = method.getReturnType();
+ beanClassBuilder.setProject(project);
+ beanClassBuilder.setTypeArguments(myTypeParameters);
+ beanClassBuilder.setClassName(myClassName);
+ beanClassBuilder.setPackageName(myPackageName);
+ beanClassBuilder.setStatic(myCreateInnerClass && myMethod.hasModifierProperty(PsiModifier.STATIC));
+ final PsiType returnType = myMethod.getReturnType();
beanClassBuilder.setValueType(returnType);
final String classString;
@@ -267,29 +270,32 @@ public class WrapReturnValueProcessor extends FixableUsagesRefactoringProcessor
try {
final PsiFileFactory factory = PsiFileFactory.getInstance(project);
- final PsiJavaFile psiFile = (PsiJavaFile)factory.createFileFromText(className + ".java", JavaFileType.INSTANCE, classString);
+ final PsiJavaFile psiFile = (PsiJavaFile)factory.createFileFromText(myClassName + ".java", JavaFileType.INSTANCE, classString);
final CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(manager.getProject());
if (myCreateInnerClass) {
- final PsiClass containingClass = method.getContainingClass();
+ final PsiClass containingClass = myMethod.getContainingClass();
final PsiElement innerClass = containingClass.add(psiFile.getClasses()[0]);
JavaCodeStyleManager.getInstance(project).shortenClassReferences(innerClass);
- } else {
- final PsiFile containingFile = method.getContainingFile();
+ }
+ else {
+ final PsiFile containingFile = myMethod.getContainingFile();
final PsiDirectory containingDirectory = containingFile.getContainingDirectory();
final PsiDirectory directory;
if (myMoveDestination != null) {
directory = myMoveDestination.getTargetDirectory(containingDirectory);
- } else {
- final Module module = ModuleUtil.findModuleForPsiElement(containingFile);
- directory = PackageUtil.findOrCreateDirectoryForPackage(module, packageName, containingDirectory, true, true);
+ }
+ else {
+ final Module module = ModuleUtilCore.findModuleForPsiElement(containingFile);
+ directory = PackageUtil.findOrCreateDirectoryForPackage(module, myPackageName, containingDirectory, true, true);
}
if (directory != null) {
final PsiElement shortenedFile = JavaCodeStyleManager.getInstance(project).shortenClassReferences(psiFile);
final PsiElement reformattedFile = codeStyleManager.reformat(shortenedFile);
directory.add(reformattedFile);
- } else {
+ }
+ else {
return false;
}
}
@@ -302,8 +308,8 @@ public class WrapReturnValueProcessor extends FixableUsagesRefactoringProcessor
}
protected String getCommandName() {
- final PsiClass containingClass = method.getContainingClass();
- return RefactorJBundle.message("wrapped.return.command.name", className, containingClass.getName(), '.', method.getName());
+ final PsiClass containingClass = myMethod.getContainingClass();
+ return RefactorJBundle.message("wrapped.return.command.name", myClassName, containingClass.getName(), '.', myMethod.getName());
}
@@ -334,7 +340,7 @@ public class WrapReturnValueProcessor extends FixableUsagesRefactoringProcessor
if (callExpression.getArgumentList().getExpressions().length == 0) {
final PsiReferenceExpression callMethodExpression = callExpression.getMethodExpression();
final String methodName = callMethodExpression.getReferenceName();
- if (Comparing.strEqual(unwrapMethodName, methodName)) {
+ if (Comparing.strEqual(myUnwrapMethodName, methodName)) {
final PsiExpression qualifier = callMethodExpression.getQualifierExpression();
if (qualifier != null) {
final PsiType qualifierType = qualifier.getType();
diff --git a/java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/usageInfo/ChangeReturnType.java b/java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/usageInfo/ChangeReturnType.java
index d1ee2b0f0c65..f3d80aa6e70b 100644
--- a/java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/usageInfo/ChangeReturnType.java
+++ b/java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/usageInfo/ChangeReturnType.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.
@@ -23,19 +23,19 @@ import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
public class ChangeReturnType extends FixableUsageInfo {
- @NotNull
- private final PsiMethod method;
- @NotNull
- private final String type;
+ private final PsiMethod myMethod;
+ private final String myType;
- public ChangeReturnType(@NotNull PsiMethod method, @NotNull String type) {
- super(method);
- this.type = type;
- this.method = method;
- }
+ public ChangeReturnType(@NotNull PsiMethod method, @NotNull String type) {
+ super(method);
+ myMethod = method;
+ myType = type;
+ }
- public void fixUsage() throws IncorrectOperationException {
- final PsiTypeElement returnType = method.getReturnTypeElement();
- MutationUtils.replaceType(type, returnType);
- }
+ @Override
+ public void fixUsage() throws IncorrectOperationException {
+ PsiTypeElement returnType = myMethod.getReturnTypeElement();
+ assert returnType != null : myMethod;
+ MutationUtils.replaceType(myType, returnType);
+ }
}
diff --git a/java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/usageInfo/ReturnWrappedValue.java b/java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/usageInfo/ReturnWrappedValue.java
index ffa1c9f8924a..1d4eb7de5b8e 100644
--- a/java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/usageInfo/ReturnWrappedValue.java
+++ b/java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/usageInfo/ReturnWrappedValue.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.
@@ -21,24 +21,21 @@ import com.intellij.psi.PsiReturnStatement;
import com.intellij.refactoring.psi.MutationUtils;
import com.intellij.refactoring.util.FixableUsageInfo;
import com.intellij.util.IncorrectOperationException;
-import org.jetbrains.annotations.NonNls;
public class ReturnWrappedValue extends FixableUsageInfo {
- private final PsiReturnStatement statement;
+ private final PsiReturnStatement myStatement;
- public ReturnWrappedValue(PsiReturnStatement statement) {
- super(statement);
- this.statement = statement;
- }
+ public ReturnWrappedValue(PsiReturnStatement statement) {
+ super(statement);
+ myStatement = statement;
+ }
- public void fixUsage() throws IncorrectOperationException{
- final PsiMethodCallExpression returnValue =
- (PsiMethodCallExpression) statement.getReturnValue();
- assert returnValue != null;
- final PsiExpression qualifier =
- returnValue.getMethodExpression().getQualifierExpression();
- assert qualifier != null;
- @NonNls final String newExpression = qualifier.getText();
- MutationUtils.replaceExpression(newExpression, returnValue);
- }
+ @Override
+ public void fixUsage() throws IncorrectOperationException {
+ PsiMethodCallExpression returnValue = (PsiMethodCallExpression)myStatement.getReturnValue();
+ assert returnValue != null;
+ PsiExpression qualifier = returnValue.getMethodExpression().getQualifierExpression();
+ assert qualifier != null;
+ MutationUtils.replaceExpression(qualifier.getText(), returnValue);
+ }
}
diff --git a/java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/usageInfo/UnwrapCall.java b/java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/usageInfo/UnwrapCall.java
index 332751be3ed8..f69bf5a37eee 100644
--- a/java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/usageInfo/UnwrapCall.java
+++ b/java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/usageInfo/UnwrapCall.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,23 +19,21 @@ import com.intellij.psi.PsiCallExpression;
import com.intellij.refactoring.psi.MutationUtils;
import com.intellij.refactoring.util.FixableUsageInfo;
import com.intellij.util.IncorrectOperationException;
-import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
public class UnwrapCall extends FixableUsageInfo {
- @NotNull
- private final PsiCallExpression call;
- @NotNull
- private final String unwrapMethod;
+ private final PsiCallExpression myCall;
+ private final String myUnwrapMethod;
- public UnwrapCall(@NotNull PsiCallExpression call, @NotNull String unwrapMethod) {
- super(call);
- this.call =call;
- this.unwrapMethod = unwrapMethod;
- }
+ public UnwrapCall(@NotNull PsiCallExpression call, @NotNull String unwrapMethod) {
+ super(call);
+ myCall = call;
+ myUnwrapMethod = unwrapMethod;
+ }
- public void fixUsage() throws IncorrectOperationException {
- @NonNls final String newExpression = call.getText() + '.' + unwrapMethod +"()";
- MutationUtils.replaceExpression(newExpression, call);
- }
+ @Override
+ public void fixUsage() throws IncorrectOperationException {
+ String newExpression = myCall.getText() + '.' + myUnwrapMethod + "()";
+ MutationUtils.replaceExpression(newExpression, myCall);
+ }
}
diff --git a/java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/usageInfo/WrapReturnValue.java b/java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/usageInfo/WrapReturnValue.java
index 318e517bfda4..4018557fa8cd 100644
--- a/java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/usageInfo/WrapReturnValue.java
+++ b/java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/usageInfo/WrapReturnValue.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.
@@ -20,23 +20,23 @@ import com.intellij.psi.PsiReturnStatement;
import com.intellij.refactoring.psi.MutationUtils;
import com.intellij.refactoring.util.FixableUsageInfo;
import com.intellij.util.IncorrectOperationException;
-import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
public class WrapReturnValue extends FixableUsageInfo {
- private final PsiReturnStatement statement;
- private final String type;
+ private final PsiReturnStatement myStatement;
+ private final String myType;
- public WrapReturnValue(PsiReturnStatement statement, String type) {
- super(statement);
- this.type = type;
- this.statement = statement;
- }
+ public WrapReturnValue(@NotNull PsiReturnStatement statement, @NotNull String type) {
+ super(statement);
+ myStatement = statement;
+ myType = type;
+ }
- public void fixUsage() throws IncorrectOperationException {
- final PsiExpression returnValue = statement.getReturnValue();
- assert returnValue != null;
- @NonNls final String newExpression =
- "new " + type + '(' + returnValue.getText() + ')';
- MutationUtils.replaceExpression(newExpression, returnValue);
- }
+ @Override
+ public void fixUsage() throws IncorrectOperationException {
+ PsiExpression returnValue = myStatement.getReturnValue();
+ assert returnValue != null;
+ String newExpression = "new " + myType + '(' + returnValue.getText() + ')';
+ MutationUtils.replaceExpression(newExpression, returnValue);
+ }
}
diff --git a/java/java-psi-api/src/com/intellij/codeInsight/AnnotationUtil.java b/java/java-psi-api/src/com/intellij/codeInsight/AnnotationUtil.java
index a5cf55067a8c..c0cd96c20d47 100644
--- a/java/java-psi-api/src/com/intellij/codeInsight/AnnotationUtil.java
+++ b/java/java-psi-api/src/com/intellij/codeInsight/AnnotationUtil.java
@@ -436,13 +436,13 @@ public class AnnotationUtil {
}
@Nullable
- public static String getStringAttributeValue(PsiAnnotation anno, @Nullable final String attributeName) {
+ public static String getStringAttributeValue(@NotNull PsiAnnotation anno, @Nullable final String attributeName) {
PsiAnnotationMemberValue attrValue = anno.findAttributeValue(attributeName);
Object constValue = JavaPsiFacade.getInstance(anno.getProject()).getConstantEvaluationHelper().computeConstantExpression(attrValue);
return constValue instanceof String ? (String)constValue : null;
}
@Nullable
- public static Boolean getBooleanAttributeValue(PsiAnnotation anno, @Nullable final String attributeName) {
+ public static Boolean getBooleanAttributeValue(@NotNull PsiAnnotation anno, @Nullable final String attributeName) {
PsiAnnotationMemberValue attrValue = anno.findAttributeValue(attributeName);
Object constValue = JavaPsiFacade.getInstance(anno.getProject()).getConstantEvaluationHelper().computeConstantExpression(attrValue);
return constValue instanceof Boolean ? (Boolean)constValue : null;
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 54bd0241e64e..a77be4313ed8 100644
--- a/java/java-psi-api/src/com/intellij/psi/LambdaUtil.java
+++ b/java/java-psi-api/src/com/intellij/psi/LambdaUtil.java
@@ -18,7 +18,6 @@ package com.intellij.psi;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Computable;
-import com.intellij.openapi.util.Pair;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.infos.MethodCandidateInfo;
import com.intellij.psi.util.*;
@@ -33,6 +32,7 @@ import java.util.*;
* Date: 7/17/12
*/
public class LambdaUtil {
+ public static ThreadLocal<Map<PsiElement, PsiType>> ourFunctionTypes = new ThreadLocal<Map<PsiElement, PsiType>>();
private static final Logger LOG = Logger.getInstance("#" + LambdaUtil.class.getName());
@NonNls public static final String JAVA_LANG_FUNCTIONAL_INTERFACE = "java.lang.FunctionalInterface";
@@ -311,6 +311,14 @@ public class LambdaUtil {
if (gParent instanceof PsiCall) {
final PsiCall contextCall = (PsiCall)gParent;
+ final MethodCandidateInfo.CurrentCandidateProperties properties = MethodCandidateInfo.getCurrentMethod(contextCall.getArgumentList());
+ if (properties != null && properties.isApplicabilityCheck()) { //todo simplification
+ final PsiParameter[] parameters = properties.getMethod().getParameterList().getParameters();
+ final int finalLambdaIdx = adjustLambdaIdx(lambdaIdx, properties.getMethod(), parameters);
+ if (finalLambdaIdx < parameters.length) {
+ return properties.getSubstitutor().substitute(getNormalizedType(parameters[finalLambdaIdx]));
+ }
+ }
final JavaResolveResult resolveResult = contextCall.resolveMethodGenerics();
final PsiElement resolve = resolveResult.getElement();
if (resolve instanceof PsiMethod) {
@@ -318,6 +326,13 @@ public class LambdaUtil {
final int finalLambdaIdx = adjustLambdaIdx(lambdaIdx, (PsiMethod)resolve, parameters);
if (finalLambdaIdx < parameters.length) {
if (!tryToSubstitute) return getNormalizedType(parameters[finalLambdaIdx]);
+ final Map<PsiElement, PsiType> map = ourFunctionTypes.get();
+ if (map != null) {
+ final PsiType type = map.get(expression);
+ if (type != null) {
+ return type;
+ }
+ }
return PsiResolveHelper.ourGraphGuard.doPreventingRecursion(expression, true, new Computable<PsiType>() {
@Override
public PsiType compute() {
@@ -454,8 +469,8 @@ public class LambdaUtil {
if (parent instanceof PsiExpressionList) {
final PsiElement gParent = parent.getParent();
if (gParent instanceof PsiCall) {
- final Pair<PsiMethod, PsiSubstitutor> pair = MethodCandidateInfo.getCurrentMethod(parent);
- myMethod = pair != null ? pair.first : null;
+ final MethodCandidateInfo.CurrentCandidateProperties pair = MethodCandidateInfo.getCurrentMethod(parent);
+ myMethod = pair != null ? pair.getMethod() : null;
if (myMethod == null) {
myMethod = ((PsiCall)gParent).resolveMethod();
}
diff --git a/java/java-psi-api/src/com/intellij/psi/PsiNameHelper.java b/java/java-psi-api/src/com/intellij/psi/PsiNameHelper.java
index 6e5e6563dc3b..9b7252714cd1 100644
--- a/java/java-psi-api/src/com/intellij/psi/PsiNameHelper.java
+++ b/java/java-psi-api/src/com/intellij/psi/PsiNameHelper.java
@@ -58,7 +58,7 @@ public abstract class PsiNameHelper {
* @param languageLevel to check text against. For instance 'assert' or 'enum' might or might not be identifiers depending on language level
* @return true if the text is an identifier, false otherwise
*/
- public abstract boolean isIdentifier(@Nullable String text, LanguageLevel languageLevel);
+ public abstract boolean isIdentifier(@Nullable String text, @NotNull LanguageLevel languageLevel);
/**
* Checks if the specified text is a Java keyword, using the language level of the project
@@ -80,7 +80,9 @@ public abstract class PsiNameHelper {
@NotNull
public static String getShortClassName(@NotNull String referenceText) {
- int lessPos = referenceText.length(), bracesBalance = 0, i;
+ int lessPos = referenceText.length();
+ int bracesBalance = 0;
+ int i;
loop:
for (i = referenceText.length() - 1; i >= 0; i--) {
@@ -137,7 +139,7 @@ public abstract class PsiNameHelper {
}
@NotNull
- public static String getQualifiedClassName(String referenceText, boolean removeWhitespace) {
+ public static String getQualifiedClassName(@NotNull String referenceText, boolean removeWhitespace) {
if (removeWhitespace) {
referenceText = removeWhitespace(referenceText);
}
@@ -166,7 +168,7 @@ public abstract class PsiNameHelper {
}
private static final Pattern WHITESPACE_PATTERN = Pattern.compile("(?:\\s)|(?:/\\*.*\\*/)|(?://[^\\n]*)");
- private static String removeWhitespace(String referenceText) {
+ private static String removeWhitespace(@NotNull String referenceText) {
return WHITESPACE_PATTERN.matcher(referenceText).replaceAll("");
}
@@ -178,7 +180,8 @@ public abstract class PsiNameHelper {
* @param referenceText the text of the reference to calculate type parameters for.
* @return the calculated array of type parameters.
*/
- public static String[] getClassParametersText(String referenceText) {
+ @NotNull
+ public static String[] getClassParametersText(@NotNull String referenceText) {
if (referenceText.indexOf('<') < 0) return ArrayUtil.EMPTY_STRING_ARRAY;
referenceText = removeWhitespace(referenceText);
final char[] chars = referenceText.toCharArray();
@@ -287,6 +290,6 @@ public abstract class PsiNameHelper {
}
sb.append(' ');
}
- return annotations.size() > 0;
+ return !annotations.isEmpty();
}
}
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 cad6cfda7234..207cdecfc538 100644
--- a/java/java-psi-api/src/com/intellij/psi/PsiPrimitiveType.java
+++ b/java/java-psi-api/src/com/intellij/psi/PsiPrimitiveType.java
@@ -115,11 +115,19 @@ public class PsiPrimitiveType extends PsiType.Stub {
@Nullable
public static PsiPrimitiveType getUnboxedType(PsiType type) {
if (!(type instanceof PsiClassType)) return null;
- assert type.isValid();
- if (!((PsiClassType)type).getLanguageLevel().isAtLeast(LanguageLevel.JDK_1_5)) return null;
- final PsiClass psiClass = ((PsiClassType)type).resolve();
+ LanguageLevel languageLevel = ((PsiClassType)type).getLanguageLevel();
+ if (!languageLevel.isAtLeast(LanguageLevel.JDK_1_5)) return null;
+
+ assert type.isValid() : type;
+ PsiClass psiClass = ((PsiClassType)type).resolve();
if (psiClass == null) return null;
- return ourQNameToUnboxed.get(psiClass.getQualifiedName());
+
+ PsiPrimitiveType unboxed = ourQNameToUnboxed.get(psiClass.getQualifiedName());
+ PsiAnnotation[] annotations = type.getAnnotations();
+ if (unboxed != null && annotations.length > 0) {
+ unboxed = new PsiPrimitiveType(unboxed.myName, annotations);
+ }
+ return unboxed;
}
public String getBoxedTypeName() {
@@ -137,15 +145,15 @@ public class PsiPrimitiveType extends PsiType.Stub {
public PsiClassType getBoxedType(PsiElement context) {
LanguageLevel languageLevel = PsiUtil.getLanguageLevel(context);
if (!languageLevel.isAtLeast(LanguageLevel.JDK_1_5)) return null;
- final String boxedQName = getBoxedTypeName();
+ String boxedQName = getBoxedTypeName();
//[ven]previous call returns null for NULL, VOID
if (boxedQName == null) return null;
-
- PsiManager manager = context.getManager();
- final PsiClass aClass = JavaPsiFacade.getInstance(manager.getProject()).findClass(boxedQName, context.getResolveScope());
+ PsiClass aClass = JavaPsiFacade.getInstance(context.getProject()).findClass(boxedQName, context.getResolveScope());
if (aClass == null) return null;
- return JavaPsiFacade.getInstance(manager.getProject()).getElementFactory().createType(aClass, PsiSubstitutor.EMPTY, languageLevel);
+
+ PsiElementFactory factory = JavaPsiFacade.getInstance(context.getProject()).getElementFactory();
+ return factory.createType(aClass, PsiSubstitutor.EMPTY, languageLevel, getAnnotations());
}
@Nullable
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 2afc76a5d060..30da36ef7eae 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
@@ -19,7 +19,6 @@ 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.Pair;
import com.intellij.openapi.util.RecursionGuard;
import com.intellij.openapi.util.RecursionManager;
import com.intellij.pom.java.LanguageLevel;
@@ -39,7 +38,7 @@ import java.util.Map;
*/
public class MethodCandidateInfo extends CandidateInfo{
public static final RecursionGuard ourOverloadGuard = RecursionManager.createGuard("overload.guard");
- public static final ThreadLocal<Map<PsiElement, Pair<PsiMethod, PsiSubstitutor>>> CURRENT_CANDIDATE = new ThreadLocal<Map<PsiElement, Pair<PsiMethod, PsiSubstitutor>>>();
+ public static final ThreadLocal<Map<PsiElement, CurrentCandidateProperties>> CURRENT_CANDIDATE = new ThreadLocal<Map<PsiElement, CurrentCandidateProperties>>();
@ApplicabilityLevelConstant
private int myApplicabilityLevel; // benign race
private final PsiElement myArgumentList;
@@ -76,15 +75,21 @@ public class MethodCandidateInfo extends CandidateInfo{
myLanguageLevel = languageLevel;
}
+ public boolean isVarargs() {
+ return false;
+ }
+
public boolean isApplicable(){
return getApplicabilityLevel() != ApplicabilityLevel.NOT_APPLICABLE;
}
@ApplicabilityLevelConstant
private int getApplicabilityLevelInner() {
- if (myArgumentTypes == null) return ApplicabilityLevel.NOT_APPLICABLE;
+ final PsiType[] argumentTypes = getArgumentTypes();
- int level = PsiUtil.getApplicabilityLevel(getElement(), getSubstitutor(), myArgumentTypes, myLanguageLevel);
+ if (argumentTypes == null) return ApplicabilityLevel.NOT_APPLICABLE;
+
+ int level = PsiUtil.getApplicabilityLevel(getElement(), getSubstitutor(), argumentTypes, myLanguageLevel);
if (level > ApplicabilityLevel.NOT_APPLICABLE && !isTypeArgumentsApplicable()) level = ApplicabilityLevel.NOT_APPLICABLE;
return level;
}
@@ -100,34 +105,62 @@ public class MethodCandidateInfo extends CandidateInfo{
@ApplicabilityLevelConstant
public int getPertinentApplicabilityLevel() {
- if (myTypeArguments != null) {
+ if (myArgumentList == null || !PsiUtil.isLanguageLevel8OrHigher(myArgumentList)) {
return getApplicabilityLevel();
}
-
- if (myArgumentTypes == null) {
- return ApplicabilityLevel.NOT_APPLICABLE;
- }
-
@ApplicabilityLevelConstant int level;
Integer boxedLevel = ourOverloadGuard.doPreventingRecursion(myArgumentList, false, new Computable<Integer>() {
@Override
public Integer compute() {
-
- final PsiMethod method = getElement();
- if (method != null && method.hasTypeParameters() || myArgumentList == null || !PsiUtil.isLanguageLevel8OrHigher(myArgumentList)) {
- return PsiUtil.getApplicabilityLevel(getElement(), getSubstitutor(false), myArgumentTypes, myLanguageLevel);
+ if (PsiUtil.isLanguageLevel8OrHigher(myArgumentList)) {
+ PsiSubstitutor substitutor = getSubstitutor(false);
+ Map<PsiElement, CurrentCandidateProperties> map = CURRENT_CANDIDATE.get();
+ if (map == null) {
+ map = new ConcurrentWeakHashMap<PsiElement, CurrentCandidateProperties>();
+ CURRENT_CANDIDATE.set(map);
+ }
+ final PsiMethod method = getElement();
+ final CurrentCandidateProperties properties = new CurrentCandidateProperties(method, substitutor, isVarargs(), true);
+ final CurrentCandidateProperties alreadyThere = map.put(getMarkerList(), properties);
+ try {
+ properties.setSubstitutor(substitutor);
+ PsiType[] argumentTypes = getArgumentTypes();
+ if (argumentTypes == null) {
+ return ApplicabilityLevel.NOT_APPLICABLE;
+ }
+
+ final int applicabilityLevel = PsiUtil.getApplicabilityLevel(method, substitutor, argumentTypes, myLanguageLevel);
+ if (!isVarargs() && applicabilityLevel < ApplicabilityLevel.FIXED_ARITY) {
+ return ApplicabilityLevel.NOT_APPLICABLE;
+ }
+ return applicabilityLevel;
+ }
+ finally {
+ if (alreadyThere == null) map.remove(getMarkerList());
+ }
}
return getApplicabilityLevelInner();
}
});
- level = boxedLevel != null ? boxedLevel : getApplicabilityLevel();
+ assert boxedLevel != null;
+ level = boxedLevel;
if (level > ApplicabilityLevel.NOT_APPLICABLE && !isTypeArgumentsApplicable(false)) level = ApplicabilityLevel.NOT_APPLICABLE;
return level;
}
public PsiSubstitutor getSiteSubstitutor() {
- return super.getSubstitutor();
+ PsiSubstitutor incompleteSubstitutor = super.getSubstitutor();
+ if (myTypeArguments != null) {
+ 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
@@ -147,7 +180,7 @@ public class MethodCandidateInfo extends CandidateInfo{
final PsiSubstitutor inferredSubstitutor = inferTypeArguments(DefaultParameterTypeInferencePolicy.INSTANCE, includeReturnConstraint);
- if (!stackStamp.mayCacheNow() || !includeReturnConstraint && myLanguageLevel.isAtLeast(LanguageLevel.JDK_1_8)) {
+ if (!stackStamp.mayCacheNow() || !ourOverloadGuard.currentStack().isEmpty() || !includeReturnConstraint && myLanguageLevel.isAtLeast(LanguageLevel.JDK_1_8)) {
return inferredSubstitutor;
}
@@ -206,35 +239,24 @@ public class MethodCandidateInfo extends CandidateInfo{
return inferTypeArguments(policy, arguments, true);
}
else {
- 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 getSiteSubstitutor();
}
- return incompleteSubstitutor;
}
@NotNull
public PsiSubstitutor inferTypeArguments(@NotNull ParameterTypeInferencePolicy policy,
@NotNull PsiExpression[] arguments,
boolean includeReturnConstraint) {
- Map<PsiElement, Pair<PsiMethod, PsiSubstitutor>> map = CURRENT_CANDIDATE.get();
+ Map<PsiElement, CurrentCandidateProperties> map = CURRENT_CANDIDATE.get();
if (map == null) {
- map = new ConcurrentWeakHashMap<PsiElement, Pair<PsiMethod, PsiSubstitutor>>();
+ map = new ConcurrentWeakHashMap<PsiElement, CurrentCandidateProperties>();
CURRENT_CANDIDATE.set(map);
}
final PsiMethod method = getElement();
- final Pair<PsiMethod, PsiSubstitutor> alreadyThere = includeReturnConstraint
- ? map.put(getMarkerList(), Pair.create(method, super.getSubstitutor()))
- : null;
+ final CurrentCandidateProperties alreadyThere = map.get(getMarkerList());
+ if (alreadyThere == null) {
+ map.put(getMarkerList(), new CurrentCandidateProperties(method, super.getSubstitutor(), isVarargs(), !includeReturnConstraint));
+ }
try {
PsiTypeParameter[] typeParameters = method.getTypeParameters();
@@ -268,21 +290,77 @@ public class MethodCandidateInfo extends CandidateInfo{
}
- public static Pair<PsiMethod, PsiSubstitutor> getCurrentMethod(PsiElement context) {
- final Map<PsiElement,Pair<PsiMethod,PsiSubstitutor>> currentMethodCandidates = CURRENT_CANDIDATE.get();
+ public static CurrentCandidateProperties getCurrentMethod(PsiElement context) {
+ final Map<PsiElement, CurrentCandidateProperties> currentMethodCandidates = CURRENT_CANDIDATE.get();
return currentMethodCandidates != null ? currentMethodCandidates.get(context) : null;
}
public static void updateSubstitutor(PsiElement context, PsiSubstitutor newSubstitutor) {
- final Map<PsiElement,Pair<PsiMethod,PsiSubstitutor>> currentMethodCandidates = CURRENT_CANDIDATE.get();
+ final Map<PsiElement, CurrentCandidateProperties> currentMethodCandidates = CURRENT_CANDIDATE.get();
if (currentMethodCandidates != null) {
- final Pair<PsiMethod, PsiSubstitutor> pair = currentMethodCandidates.get(context);
- if (pair != null) {
- currentMethodCandidates.put(context, Pair.create(pair.first, newSubstitutor));
+ final CurrentCandidateProperties properties = currentMethodCandidates.get(context);
+ if (properties != null) {
+ properties.setSubstitutor(newSubstitutor);
}
}
}
+ public PsiType[] getArgumentTypes() {
+ return myArgumentTypes;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ return super.equals(o) && isVarargs() == ((MethodCandidateInfo)o).isVarargs();
+ }
+
+ @Override
+ public int hashCode() {
+ return 31 * super.hashCode() + (isVarargs() ? 1 : 0);
+ }
+
+ public static class CurrentCandidateProperties {
+ private final PsiMethod myMethod;
+ private PsiSubstitutor mySubstitutor;
+ private boolean myVarargs;
+ private boolean myApplicabilityCheck;
+
+ public CurrentCandidateProperties(PsiMethod method, PsiSubstitutor substitutor, boolean varargs, boolean applicabilityCheck) {
+ myMethod = method;
+ mySubstitutor = substitutor;
+ myVarargs = varargs;
+ myApplicabilityCheck = applicabilityCheck;
+ }
+
+ public PsiMethod getMethod() {
+ return myMethod;
+ }
+
+ public PsiSubstitutor getSubstitutor() {
+ return mySubstitutor;
+ }
+
+ public void setSubstitutor(PsiSubstitutor substitutor) {
+ mySubstitutor = substitutor;
+ }
+
+ public boolean isVarargs() {
+ return myVarargs;
+ }
+
+ public void setVarargs(boolean varargs) {
+ myVarargs = varargs;
+ }
+
+ public boolean isApplicabilityCheck() {
+ return myApplicabilityCheck;
+ }
+
+ public void setApplicabilityCheck(boolean applicabilityCheck) {
+ myApplicabilityCheck = applicabilityCheck;
+ }
+ }
+
public static class ApplicabilityLevel {
public static final int NOT_APPLICABLE = 1;
public static final int VARARGS = 2;
diff --git a/java/java-psi-api/src/com/intellij/psi/util/PropertyUtil.java b/java/java-psi-api/src/com/intellij/psi/util/PropertyUtil.java
index 2e126d1ee42d..425b46dfef15 100644
--- a/java/java-psi-api/src/com/intellij/psi/util/PropertyUtil.java
+++ b/java/java-psi-api/src/com/intellij/psi/util/PropertyUtil.java
@@ -44,7 +44,7 @@ public class PropertyUtil {
private PropertyUtil() {
}
- public static boolean isSimplePropertyGetter(PsiMethod method) {
+ public static boolean isSimplePropertyGetter(@NotNull PsiMethod method) {
return hasGetterName(method) && method.getParameterList().getParametersCount() == 0;
}
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 2bf734b9438b..1f9ef6adef34 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
@@ -706,7 +706,7 @@ public class TypeConversionUtil {
final PsiType lType = ((PsiMethodReferenceType)left).getExpression().getFunctionalInterfaceType();
return Comparing.equal(rType, lType);
}
- return methodReferenceExpression.isAcceptable(left);
+ return !(left instanceof PsiArrayType) && methodReferenceExpression.isAcceptable(left);
}
if (right instanceof PsiLambdaExpressionType) {
final PsiLambdaExpression rLambdaExpression = ((PsiLambdaExpressionType)right).getExpression();
diff --git a/java/java-psi-impl/src/com/intellij/codeInsight/ExceptionUtil.java b/java/java-psi-impl/src/com/intellij/codeInsight/ExceptionUtil.java
index d9ec369b4199..ada64c0d7452 100644
--- a/java/java-psi-impl/src/com/intellij/codeInsight/ExceptionUtil.java
+++ b/java/java-psi-impl/src/com/intellij/codeInsight/ExceptionUtil.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.
@@ -487,15 +487,17 @@ public class ExceptionUtil {
}
@NotNull
- public static List<PsiClassType> getCloserExceptions(@NotNull final PsiResourceVariable resource) {
- final PsiMethod method = PsiUtil.getResourceCloserMethod(resource);
- return method != null ? getExceptionsByMethod(method, PsiSubstitutor.EMPTY) : Collections.<PsiClassType>emptyList();
+ public static List<PsiClassType> getCloserExceptions(@NotNull PsiResourceVariable resource) {
+ PsiMethod method = PsiUtil.getResourceCloserMethod(resource);
+ PsiSubstitutor substitutor = PsiUtil.resolveGenericsClassInType(resource.getType()).getSubstitutor();
+ return method != null ? getExceptionsByMethod(method, substitutor) : Collections.<PsiClassType>emptyList();
}
@NotNull
- public static List<PsiClassType> getUnhandledCloserExceptions(@NotNull final PsiResourceVariable resource, @Nullable final PsiElement topElement) {
- final PsiMethod method = PsiUtil.getResourceCloserMethod(resource);
- return method != null ? getUnhandledExceptions(method, resource, topElement, PsiSubstitutor.EMPTY) : Collections.<PsiClassType>emptyList();
+ public static List<PsiClassType> getUnhandledCloserExceptions(@NotNull PsiResourceVariable resource, @Nullable PsiElement topElement) {
+ PsiMethod method = PsiUtil.getResourceCloserMethod(resource);
+ PsiSubstitutor substitutor = PsiUtil.resolveGenericsClassInType(resource.getType()).getSubstitutor();
+ return method != null ? getUnhandledExceptions(method, resource, topElement, substitutor) : Collections.<PsiClassType>emptyList();
}
@NotNull
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 e7ebfca1a4e1..d92ec8c0673c 100644
--- a/java/java-psi-impl/src/com/intellij/psi/PsiDiamondTypeImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/PsiDiamondTypeImpl.java
@@ -148,7 +148,7 @@ public class PsiDiamondTypeImpl extends PsiDiamondType {
}
staticFactoryRef.set(staticFactory);
- return inferTypeParametersForStaticFactory(staticFactory, newExpression, context);
+ return inferTypeParametersForStaticFactory(staticFactory, newExpression, context, false);
}
});
if (inferredSubstitutor == null) {
@@ -278,7 +278,8 @@ public class PsiDiamondTypeImpl extends PsiDiamondType {
buf.append("{}");
try {
- return elementFactory.createMethodFromText(buf.toString(), constructor != null ? constructor : containingClass);
+ final PsiNameIdentifierOwner owner = constructor != null ? constructor : containingClass;
+ return elementFactory.createMethodFromText(buf.toString(), owner instanceof PsiCompiledElement ? ((PsiCompiledElement)owner).getMirror() : owner);
}
catch (IncorrectOperationException e) {
return null;
@@ -297,13 +298,19 @@ public class PsiDiamondTypeImpl extends PsiDiamondType {
private static PsiSubstitutor inferTypeParametersForStaticFactory(@NotNull PsiMethod staticFactoryMethod,
PsiNewExpression expression,
- final PsiElement parent) {
+ final PsiElement parent,
+ final boolean varargs) {
final PsiExpressionList argumentList = expression.getArgumentList();
if (argumentList != null) {
final MethodCandidateInfo staticFactoryCandidateInfo =
new MethodCandidateInfo(staticFactoryMethod, PsiSubstitutor.EMPTY, false, false, argumentList, parent,
argumentList.getExpressionTypes(), null) {
@Override
+ public boolean isVarargs() {
+ return varargs;
+ }
+
+ @Override
protected PsiElement getParent() {
return parent;
}
@@ -313,6 +320,9 @@ public class PsiDiamondTypeImpl extends PsiDiamondType {
return parent instanceof PsiNewExpression ? ((PsiNewExpression)parent).getArgumentList() : super.getMarkerList();
}
};
+ if (!varargs && staticFactoryMethod.isVarArgs() && staticFactoryCandidateInfo.getPertinentApplicabilityLevel() < MethodCandidateInfo.ApplicabilityLevel.FIXED_ARITY) {
+ return inferTypeParametersForStaticFactory(staticFactoryMethod, expression, parent, true);
+ }
return staticFactoryCandidateInfo.getSubstitutor();
}
else {
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 b427f91648ca..0515b4983ce2 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
@@ -165,7 +165,7 @@ public class PsiElementFactoryImpl extends PsiJavaParserFacadeImpl implements Ps
final PsiClassType.ClassResolveResult resolveResult = type.resolveGenerics();
final PsiClass refClass = resolveResult.getElement();
assert refClass != null : type;
- return new LightClassReference(myManager, type.getCanonicalText(), refClass, resolveResult.getSubstitutor());
+ return new LightClassReference(myManager, type.getCanonicalText(true), refClass, resolveResult.getSubstitutor());
}
@NotNull
@@ -186,7 +186,7 @@ public class PsiElementFactoryImpl extends PsiJavaParserFacadeImpl implements Ps
builder.append(" extends ");
for (PsiClassType type : superTypes) {
if (type.equalsToText(CommonClassNames.JAVA_LANG_OBJECT)) continue;
- builder.append(type.getCanonicalText()).append('&');
+ builder.append(type.getCanonicalText(true)).append('&');
}
builder.delete(builder.length() - 1, builder.length());
@@ -208,7 +208,7 @@ public class PsiElementFactoryImpl extends PsiJavaParserFacadeImpl implements Ps
throw new IncorrectOperationException("Cannot create field with type \"null\".");
}
- @NonNls final String text = "class _Dummy_ { private " + type.getCanonicalText() + " " + name + "; }";
+ @NonNls final String text = "class _Dummy_ { private " + type.getCanonicalText(true) + " " + name + "; }";
final PsiJavaFile aFile = createDummyJavaFile(text);
final PsiClass[] classes = aFile.getClasses();
if (classes.length < 1) {
@@ -232,7 +232,7 @@ public class PsiElementFactoryImpl extends PsiJavaParserFacadeImpl implements Ps
throw new IncorrectOperationException("Cannot create method with type \"null\".");
}
- final String canonicalText = returnType.getCanonicalText();
+ final String canonicalText = returnType.getCanonicalText(true);
final PsiJavaFile aFile = createDummyJavaFile("class _Dummy_ { public " + canonicalText + " " + name + "() {} }");
final PsiClass[] classes = aFile.getClasses();
if (classes.length < 1) {
@@ -282,7 +282,7 @@ public class PsiElementFactoryImpl extends PsiJavaParserFacadeImpl implements Ps
throw new IncorrectOperationException("Cannot create parameter with type \"null\".");
}
- final String text = type.getCanonicalText() + " " + name;
+ final String text = type.getCanonicalText(true) + " " + name;
PsiParameter parameter = createParameterFromText(text, null);
final CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(myManager.getProject());
PsiUtil.setModifierProperty(parameter, PsiModifier.FINAL,
@@ -294,7 +294,7 @@ public class PsiElementFactoryImpl extends PsiJavaParserFacadeImpl implements Ps
@Override
public PsiParameter createParameter(@NotNull @NonNls String name, PsiType type, PsiElement context) throws IncorrectOperationException {
- final PsiMethod psiMethod = createMethodFromText("void f(" + type.getCanonicalText() + " " + name + ") {}", context);
+ final PsiMethod psiMethod = createMethodFromText("void f(" + type.getCanonicalText(true) + " " + name + ") {}", context);
final PsiParameter[] parameters = psiMethod.getParameterList().getParameters();
return parameters[0];
}
@@ -480,7 +480,7 @@ public class PsiElementFactoryImpl extends PsiJavaParserFacadeImpl implements Ps
builder.append("void method(");
for (int i = 0; i < names.length; i++) {
if (i > 0) builder.append(", ");
- builder.append(types[i].getCanonicalText()).append(' ').append(names[i]);
+ builder.append(types[i].getCanonicalText(true)).append(' ').append(names[i]);
}
builder.append(");");
return createMethodFromText(builder.toString(), null).getParameterList();
@@ -742,7 +742,7 @@ public class PsiElementFactoryImpl extends PsiJavaParserFacadeImpl implements Ps
throw new IncorrectOperationException("Unexpected type:" + exceptionType);
}
- @NonNls final String text = "catch (" + exceptionType.getCanonicalText() + " " + exceptionName + ") {}";
+ @NonNls final String text = "catch (" + exceptionType.getCanonicalText(true) + " " + exceptionName + ") {}";
final DummyHolder holder = DummyHolderFactory.createHolder(myManager, new JavaDummyElement(text, CATCH_SECTION, level(context)), context);
final PsiElement element = SourceTreeToPsiMap.treeElementToPsi(holder.getTreeElement().getFirstChildNode());
if (!(element instanceof PsiCatchSection)) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiImplUtil.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiImplUtil.java
index 77fd0081d161..81ada724578f 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiImplUtil.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiImplUtil.java
@@ -20,6 +20,7 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Comparing;
+import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
import com.intellij.psi.filters.ElementFilter;
@@ -709,10 +710,9 @@ public class PsiImplUtil {
if (count == 0) return result;
int idx = 0;
for (ASTNode child = psiCodeBlock.getFirstChildNode(); child != null && idx < count; child = child.getTreeNext()) {
- if (child.getPsi() instanceof PsiStatement) {
- PsiStatement element = (PsiStatement)child.getPsi();
- LOG.assertTrue(element != null, child);
- result[idx++] = element;
+ PsiElement element = child.getPsi();
+ if (element instanceof PsiStatement) {
+ result[idx++] = (PsiStatement)element;
}
}
return result;
@@ -740,12 +740,17 @@ public class PsiImplUtil {
return null;
}
+ public static boolean isTypeAnnotation(@Nullable PsiElement element) {
+ return element instanceof PsiAnnotation &&
+ findApplicableTarget((PsiAnnotation)element, TargetType.TYPE_USE) == TargetType.TYPE_USE;
+ }
+
@Nullable
public static List<PsiAnnotation> getTypeUseAnnotations(@NotNull PsiModifierList modifierList) {
SmartList<PsiAnnotation> result = null;
for (PsiAnnotation annotation : modifierList.getAnnotations()) {
- if (findApplicableTarget(annotation, TargetType.TYPE_USE) == TargetType.TYPE_USE) {
+ if (isTypeAnnotation(annotation)) {
if (result == null) result = new SmartList<PsiAnnotation>();
result.add(annotation);
}
@@ -754,6 +759,30 @@ public class PsiImplUtil {
return result;
}
+ private static final Key<Boolean> TYPE_ANNO_MARK = Key.create("type.annotation.mark");
+
+ public static void markTypeAnnotations(@NotNull PsiTypeElement typeElement) {
+ PsiElement left = PsiTreeUtil.skipSiblingsBackward(typeElement, PsiComment.class, PsiWhiteSpace.class, PsiTypeParameterList.class);
+ if (left instanceof PsiModifierList) {
+ for (PsiAnnotation annotation : ((PsiModifierList)left).getAnnotations()) {
+ if (isTypeAnnotation(annotation)) {
+ annotation.putUserData(TYPE_ANNO_MARK, Boolean.TRUE);
+ }
+ }
+ }
+ }
+
+ public static void deleteTypeAnnotations(@NotNull PsiTypeElement typeElement) {
+ PsiElement left = PsiTreeUtil.skipSiblingsBackward(typeElement, PsiComment.class, PsiWhiteSpace.class, PsiTypeParameterList.class);
+ if (left instanceof PsiModifierList) {
+ for (PsiAnnotation annotation : ((PsiModifierList)left).getAnnotations()) {
+ if (TYPE_ANNO_MARK.get(annotation) == Boolean.TRUE) {
+ annotation.delete();
+ }
+ }
+ }
+ }
+
public static boolean isLeafElementOfType(@Nullable PsiElement element, IElementType type) {
return element instanceof LeafElement && ((LeafElement)element).getElementType() == type;
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiNameHelperImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiNameHelperImpl.java
index 702ed8e36e20..cc99abe4ca97 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiNameHelperImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiNameHelperImpl.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.
@@ -36,6 +36,7 @@ public class PsiNameHelperImpl extends PsiNameHelper {
return isIdentifier(text, getLanguageLevel());
}
+ @NotNull
protected LanguageLevel getLanguageLevel() {
return myLanguageLevelExtension.getLanguageLevel();
}
@@ -65,6 +66,7 @@ public class PsiNameHelperImpl extends PsiNameHelper {
public static PsiNameHelper getInstance() {
return new PsiNameHelperImpl() {
+ @NotNull
@Override
protected LanguageLevel getLanguageLevel() {
return LanguageLevel.HIGHEST;
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/cache/TypeInfo.java b/java/java-psi-impl/src/com/intellij/psi/impl/cache/TypeInfo.java
index 2adc6f1a9947..41a6d35c3e0c 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/cache/TypeInfo.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/cache/TypeInfo.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.
@@ -42,7 +42,6 @@ import org.jetbrains.annotations.Nullable;
import java.io.IOException;
import java.util.List;
-import static com.intellij.psi.PsiAnnotation.TargetType;
import static com.intellij.util.BitUtil.isSet;
/**
@@ -110,7 +109,7 @@ public class TypeInfo {
for (StubElement child : modifierList.getChildrenStubs()) {
if (!(child instanceof PsiAnnotationStub)) continue;
PsiAnnotationStub annotationStub = (PsiAnnotationStub)child;
- if (PsiImplUtil.findApplicableTarget(annotationStub.getPsiElement(), TargetType.TYPE_USE) == TargetType.TYPE_USE) {
+ if (PsiImplUtil.isTypeAnnotation(annotationStub.getPsiElement())) {
annotationStubs.add(annotationStub);
}
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsTypeElementImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsTypeElementImpl.java
index 16d971238684..9d4e3888771c 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsTypeElementImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsTypeElementImpl.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.
@@ -16,8 +16,8 @@
package com.intellij.psi.impl.compiled;
import com.intellij.openapi.util.AtomicNotNullLazyValue;
+import com.intellij.openapi.util.AtomicNullableLazyValue;
import com.intellij.openapi.util.NotNullLazyValue;
-import com.intellij.openapi.util.Ref;
import com.intellij.psi.*;
import com.intellij.psi.impl.PsiImplUtil;
import com.intellij.psi.impl.PsiJavaParserFacadeImpl;
@@ -39,18 +39,17 @@ public class ClsTypeElementImpl extends ClsElementImpl implements PsiTypeElement
private final PsiElement myParent;
private final String myTypeText;
private final char myVariance;
- private final NotNullLazyValue<Ref<ClsElementImpl>> myChild;
+ private final AtomicNullableLazyValue<ClsElementImpl> myChild;
private final NotNullLazyValue<PsiType> myCachedType;
public ClsTypeElementImpl(@NotNull PsiElement parent, @NotNull String typeText, char variance) {
myParent = parent;
myTypeText = TypeInfo.internFrequentType(typeText);
myVariance = variance;
- myChild = new AtomicNotNullLazyValue<Ref<ClsElementImpl>>() {
- @NotNull
+ myChild = new AtomicNullableLazyValue<ClsElementImpl>() {
@Override
- protected Ref<ClsElementImpl> compute() {
- return Ref.create(calculateChild());
+ protected ClsElementImpl compute() {
+ return calculateChild();
}
};
myCachedType = new AtomicNotNullLazyValue<PsiType>() {
@@ -65,7 +64,7 @@ public class ClsTypeElementImpl extends ClsElementImpl implements PsiTypeElement
@Override
@NotNull
public PsiElement[] getChildren() {
- ClsElementImpl child = myChild.getValue().get();
+ ClsElementImpl child = myChild.getValue();
return child != null ? new PsiElement[]{child} : PsiElement.EMPTY_ARRAY;
}
@@ -109,7 +108,7 @@ public class ClsTypeElementImpl extends ClsElementImpl implements PsiTypeElement
public void setMirror(@NotNull TreeElement element) throws InvalidMirrorException {
setMirrorCheckingType(element, JavaElementType.TYPE);
- ClsElementImpl child = myChild.getValue().get();
+ ClsElementImpl child = myChild.getValue();
if (child != null) {
child.setMirror(element.getFirstChildNode());
}
@@ -138,24 +137,23 @@ public class ClsTypeElementImpl extends ClsElementImpl implements PsiTypeElement
if (PsiJavaParserFacadeImpl.getPrimitiveType(myTypeText) != null) {
return null;
}
- else if (isArray()) {
+ if (isArray()) {
return myVariance == VARIANCE_NONE
? new ClsTypeElementImpl(this, myTypeText.substring(0, myTypeText.length() - 2), myVariance)
: new ClsTypeElementImpl(this, myTypeText, VARIANCE_NONE);
}
- else if (isVarArgs()) {
+ if (isVarArgs()) {
return new ClsTypeElementImpl(this, myTypeText.substring(0, myTypeText.length() - 3), myVariance);
}
- else {
- return myVariance != VARIANCE_INVARIANT ? new ClsJavaCodeReferenceElementImpl(this, myTypeText) : null;
- }
+ return myVariance == VARIANCE_INVARIANT ? null : new ClsJavaCodeReferenceElementImpl(this, myTypeText);
}
+ @NotNull
private PsiType calculateType() {
PsiType result = PsiJavaParserFacadeImpl.getPrimitiveType(myTypeText);
if (result != null) return result;
- ClsElementImpl childElement = myChild.getValue().get();
+ ClsElementImpl childElement = myChild.getValue();
if (childElement instanceof ClsTypeElementImpl) {
if (isArray()) {
switch (myVariance) {
@@ -175,7 +173,7 @@ public class ClsTypeElementImpl extends ClsElementImpl implements PsiTypeElement
return new PsiEllipsisType(((PsiTypeElement)childElement).getType());
}
}
- else if (childElement instanceof ClsJavaCodeReferenceElementImpl) {
+ if (childElement instanceof ClsJavaCodeReferenceElementImpl) {
PsiClassReferenceType psiClassReferenceType = new PsiClassReferenceType((PsiJavaCodeReferenceElement)childElement, null);
switch (myVariance) {
case VARIANCE_NONE:
@@ -191,10 +189,8 @@ public class ClsTypeElementImpl extends ClsElementImpl implements PsiTypeElement
return null;
}
}
- else {
- assert childElement == null : this;
- return PsiWildcardType.createUnbounded(getManager());
- }
+ assert childElement == null : this;
+ return PsiWildcardType.createUnbounded(getManager());
}
@Override
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiClassImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiClassImpl.java
index 5edd337f5113..d7ba848980de 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiClassImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiClassImpl.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.
@@ -494,20 +494,19 @@ public class PsiClassImpl extends JavaStubPsiElement<PsiClassStub<?>> implements
@Override
public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, @NotNull PsiElement place) {
if (isEnum()) {
- String name = getName();
- if (name != null) {
+ String myName = getName();
+ if (myName != null) {
try {
final NameHint nameHint = processor.getHint(NameHint.KEY);
final ElementClassHint classHint = processor.getHint(ElementClassHint.KEY);
- if (nameHint == null || VALUES_METHOD.equals(nameHint.getName(state))) {
- if (classHint == null || classHint.shouldProcess(ElementClassHint.DeclarationKind.METHOD)) {
- if (!processor.execute(getValuesMethod(), ResolveState.initial())) return false;
- }
+ String nameToSearch = nameHint == null ? null : nameHint.getName(state);
+ if (VALUES_METHOD.equals(nameToSearch) &&
+ (classHint == null || classHint.shouldProcess(ElementClassHint.DeclarationKind.METHOD))) {
+ if (!processor.execute(getValuesMethod(), ResolveState.initial())) return false;
}
- if (nameHint == null || VALUE_OF_METHOD.equals(nameHint.getName(state))) {
- if (classHint == null || classHint.shouldProcess(ElementClassHint.DeclarationKind.METHOD)) {
- if (!processor.execute(getValueOfMethod(), ResolveState.initial())) return false;
- }
+ if (VALUE_OF_METHOD.equals(nameToSearch) &&
+ (classHint == null || classHint.shouldProcess(ElementClassHint.DeclarationKind.METHOD))) {
+ if (!processor.execute(getValueOfMethod(), ResolveState.initial())) return false;
}
}
catch (IncorrectOperationException e) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiClassReferenceType.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiClassReferenceType.java
index f304fe250bae..361f2374b904 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiClassReferenceType.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiClassReferenceType.java
@@ -139,7 +139,7 @@ public class PsiClassReferenceType extends PsiClassType.Stub {
public ClassResolveResult resolveGenerics() {
PsiUtilCore.ensureValid(myReference);
final JavaResolveResult result = myReference.advancedResolve(false);
- return new DelegatingClassResolveResult(result);
+ return result.getElement() == null ? ClassResolveResult.EMPTY : new DelegatingClassResolveResult(result);
}
@Override
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiTypeElementImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiTypeElementImpl.java
index 283c0cd4b5f0..9c7ebcfa0e40 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiTypeElementImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiTypeElementImpl.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.
@@ -239,7 +239,10 @@ public class PsiTypeElementImpl extends CompositePsiElement implements PsiTypeEl
@Override
public PsiElement replace(@NotNull PsiElement newElement) throws IncorrectOperationException {
+ // neighbouring type annotations are logical part of this type element and should be dropped
+ PsiImplUtil.markTypeAnnotations(this);
PsiElement result = super.replace(newElement);
+ PsiImplUtil.deleteTypeAnnotations((PsiTypeElement)result);
// We want to reformat method call arguments on method return type change because there is a possible situation that they are aligned
// and the change breaks the alignment.
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/JavaResolveCache.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/JavaResolveCache.java
index 185d08ee8fd3..58b1e2253d14 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/JavaResolveCache.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/JavaResolveCache.java
@@ -30,6 +30,7 @@ import com.intellij.psi.impl.AnyPsiChangeListener;
import com.intellij.psi.impl.PsiManagerImpl;
import com.intellij.psi.impl.source.PsiClassReferenceType;
import com.intellij.psi.impl.source.PsiImmediateClassType;
+import com.intellij.psi.infos.MethodCandidateInfo;
import com.intellij.psi.util.TypeConversionUtil;
import com.intellij.reference.SoftReference;
import com.intellij.util.Function;
@@ -90,7 +91,7 @@ public class JavaResolveCache {
final RecursionGuard.StackStamp dStackStamp = PsiDiamondType.ourDiamondGuard.markStack();
final RecursionGuard.StackStamp gStackStamp = PsiResolveHelper.ourGraphGuard.markStack();
type = f.fun(expr);
- if (!dStackStamp.mayCacheNow() || !gStackStamp.mayCacheNow()) {
+ if (!dStackStamp.mayCacheNow() || !gStackStamp.mayCacheNow() || !MethodCandidateInfo.ourOverloadGuard.currentStack().isEmpty()) {
return type;
}
if (type == null) type = TypeConversionUtil.NULL_TYPE;
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 f30c7ae6382c..9766122e31d0 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
@@ -74,7 +74,9 @@ public class InferenceIncorporationPhase {
}
public boolean incorporate() {
- for (InferenceVariable inferenceVariable : mySession.getInferenceVariables()) {
+ final Collection<InferenceVariable> inferenceVariables = mySession.getInferenceVariables();
+ final PsiSubstitutor substitutor = mySession.retrieveNonPrimitiveEqualsBounds(inferenceVariables);
+ for (InferenceVariable inferenceVariable : inferenceVariables) {
if (inferenceVariable.getInstantiation() != PsiType.NULL) continue;
final List<PsiType> eqBounds = inferenceVariable.getBounds(InferenceBound.EQ);
final List<PsiType> upperBounds = inferenceVariable.getBounds(InferenceBound.UPPER);
@@ -82,15 +84,14 @@ public class InferenceIncorporationPhase {
eqEq(eqBounds);
- upDown(lowerBounds, upperBounds);
- upDown(eqBounds, upperBounds);
- upDown(lowerBounds, eqBounds);
+ upDown(lowerBounds, upperBounds, substitutor);
+ upDown(eqBounds, upperBounds, substitutor);
+ upDown(lowerBounds, eqBounds, substitutor);
upUp(upperBounds);
for (PsiType eqBound : eqBounds) {
if (mySession.isProperType(eqBound)) {
- final PsiSubstitutor substitutor = PsiSubstitutor.EMPTY.put(inferenceVariable.getParameter(), eqBound);
for (PsiType upperBound : upperBounds) {
if (!mySession.isProperType(upperBound)) {
addConstraint(new StrictSubtypingConstraint(substitutor.substitute(upperBound), eqBound));
@@ -274,12 +275,12 @@ public class InferenceIncorporationPhase {
* or
* S <: a & a <: T imply S <: T
*/
- private void upDown(List<PsiType> eqBounds, List<PsiType> upperBounds) {
+ private void upDown(List<PsiType> eqBounds, List<PsiType> upperBounds, PsiSubstitutor substitutor) {
for (PsiType upperBound : upperBounds) {
if (upperBound == null) continue;
for (PsiType eqBound : eqBounds) {
if (eqBound == null) continue;
- addConstraint(new StrictSubtypingConstraint(upperBound, eqBound));
+ addConstraint(new StrictSubtypingConstraint(substitutor.substitute(upperBound), substitutor.substitute(eqBound)));
}
}
}
@@ -289,7 +290,7 @@ public class InferenceIncorporationPhase {
*/
private void eqEq(List<PsiType> eqBounds) {
for (int i = 0; i < eqBounds.size(); i++) {
- PsiType sBound= eqBounds.get(i);
+ PsiType sBound = eqBounds.get(i);
for (int j = i + 1; j < eqBounds.size(); j++) {
final PsiType tBound = eqBounds.get(j);
addConstraint(new TypeEqualityConstraint(tBound, sBound));
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 53911011bc17..b8abab6bc997 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
@@ -90,40 +90,54 @@ public class InferenceSession {
}
public void initExpressionConstraints(PsiParameter[] parameters, PsiExpression[] args, PsiElement parent, PsiMethod method) {
+ final MethodCandidateInfo.CurrentCandidateProperties currentProperties = getCurrentProperties(parent);
+ initExpressionConstraints(parameters, args, parent, method, currentProperties != null && currentProperties.isVarargs());
+ }
+
+ public void initExpressionConstraints(PsiParameter[] parameters,
+ PsiExpression[] args,
+ PsiElement parent,
+ PsiMethod method,
+ boolean varargs) {
+ final MethodCandidateInfo.CurrentCandidateProperties currentProperties = getCurrentProperties(parent);
if (method == null) {
- final Pair<PsiMethod, PsiCallExpression> pair = getPair(parent);
- if (pair != null) {
- method = pair.first;
+ if (currentProperties != null) {
+ method = currentProperties.getMethod();
}
}
if (parameters.length > 0) {
for (int i = 0; i < args.length; i++) {
if (args[i] != null && isPertinentToApplicability(args[i], method)) {
- PsiType parameterType = getParameterType(parameters, args, i, mySiteSubstitutor);
+ PsiType parameterType = getParameterType(parameters, i, mySiteSubstitutor, varargs);
myConstraints.add(new ExpressionCompatibilityConstraint(args[i], parameterType));
}
}
}
}
- private static Pair<PsiMethod, PsiCallExpression> getPair(PsiElement parent) {
+ private static MethodCandidateInfo.CurrentCandidateProperties getCurrentProperties(PsiElement parent) {
if (parent instanceof PsiCallExpression) {
- final Pair<PsiMethod, PsiSubstitutor> pair = MethodCandidateInfo.getCurrentMethod(((PsiCallExpression)parent).getArgumentList());
- if (pair != null) {
- return Pair.create(pair.first, (PsiCallExpression)parent);
- }
+ return MethodCandidateInfo.getCurrentMethod(((PsiCallExpression)parent).getArgumentList());
}
return null;
}
+ /**
+ * Definition from 15.12.2.2 Phase 1: Identify Matching Arity Methods Applicable by Subtyping Strict Invocation
+ * An argument expression is considered pertinent to applicability for a potentially-applicable method m unless it has one of the following forms:
+
+ 1) An implicitly-typed lambda expression (15.27.1).
+ 2) An inexact method reference (15.13.1).
+ 3) If m is a generic method and the method invocation does not provide explicit type arguments, an explicitly-typed lambda expression or
+ an exact method reference for which the corresponding target type (as derived from the signature of m) is a type parameter of m.
+ 4) An explicitly-typed lambda expression whose body is an expression that is not pertinent to applicability.
+ 5) An explicitly-typed lambda expression whose body is a block, where at least one result expression is not pertinent to applicability.
+ 6) A parenthesized expression (15.8.5) whose contained expression is not pertinent to applicability.
+ 7) A conditional expression (15.25) whose second or third operand is not pertinent to applicability.
+ */
public static boolean isPertinentToApplicability(PsiExpression expr, PsiMethod method) {
- if (expr instanceof PsiLambdaExpression) {
- if (!((PsiLambdaExpression)expr).hasFormalParameterTypes()) {
- return false;
- }
- for (PsiExpression expression : LambdaUtil.getReturnExpressions((PsiLambdaExpression)expr)) {
- if (!isPertinentToApplicability(expression, method)) return false;
- }
+ if (expr instanceof PsiLambdaExpression && ((PsiLambdaExpression)expr).hasFormalParameterTypes() ||
+ expr instanceof PsiMethodReferenceExpression && ((PsiMethodReferenceExpression)expr).isExact()) {
if (method != null && method.getTypeParameters().length > 0) {
final PsiElement parent = PsiUtil.skipParenthesizedExprUp(expr.getParent());
if (parent instanceof PsiExpressionList) {
@@ -139,16 +153,19 @@ public class InferenceSession {
else {
paramType = parameters[idx].getType();
}
- final PsiClass psiClass = PsiUtil.resolveClassInClassTypeOnly(paramType);
+ final PsiClass psiClass = PsiUtil.resolveClassInType(paramType); //accept ellipsis here
if (psiClass instanceof PsiTypeParameter && ((PsiTypeParameter)psiClass).getOwner() == method) return false;
}
}
-
- for (PsiExpression expression : LambdaUtil.getReturnExpressions((PsiLambdaExpression)expr)) {
- if (PsiPolyExpressionUtil.isPolyExpression(expression)) {
- return false;
- }
- }
+ }
+ return true;
+ }
+ if (expr instanceof PsiLambdaExpression) {
+ if (!((PsiLambdaExpression)expr).hasFormalParameterTypes()) {
+ return false;
+ }
+ for (PsiExpression expression : LambdaUtil.getReturnExpressions((PsiLambdaExpression)expr)) {
+ if (!isPertinentToApplicability(expression, method)) return false;
}
return true;
}
@@ -167,31 +184,11 @@ public class InferenceSession {
return true;
}
- private static PsiType getParameterType(PsiParameter[] parameters, PsiExpression[] args, int i, @Nullable PsiSubstitutor substitutor) {
+ private static PsiType getParameterType(PsiParameter[] parameters, int i, @Nullable PsiSubstitutor substitutor, boolean varargs) {
if (substitutor == null) return null;
PsiType parameterType = substitutor.substitute(parameters[i < parameters.length ? i : parameters.length - 1].getType());
- if (parameterType instanceof PsiEllipsisType) {
- 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();
- }
+ if (parameterType instanceof PsiEllipsisType && varargs) {
+ parameterType = ((PsiEllipsisType)parameterType).getComponentType();
}
return parameterType;
}
@@ -201,17 +198,18 @@ public class InferenceSession {
return infer(null, null, null);
}
- private PsiSubstitutor tryToInfer(@Nullable PsiParameter[] parameters,
- @Nullable PsiExpression[] args,
- @Nullable PsiCallExpression parent,
- PsiMethod parentMethod) {
+ @NotNull
+ public PsiSubstitutor infer(@Nullable PsiParameter[] parameters,
+ @Nullable PsiExpression[] args,
+ @Nullable PsiElement parent) {
+ final MethodCandidateInfo.CurrentCandidateProperties properties = getCurrentProperties(parent);
if (!repeatInferencePhases(true)) {
//inferred result would be checked as candidate won't be applicable
return resolveSubset(myInferenceVariables.values(), mySiteSubstitutor);
}
- if (parentMethod != null) {
- initReturnTypeConstraint(parentMethod, parent);
+ if (properties != null && !properties.isApplicabilityCheck()) {
+ initReturnTypeConstraint(properties.getMethod(), (PsiCallExpression)parent);
if (!repeatInferencePhases(true)) {
return prepareSubstitution();
}
@@ -219,7 +217,7 @@ public class InferenceSession {
if (parameters != null && args != null) {
final Set<ConstraintFormula> additionalConstraints = new HashSet<ConstraintFormula>();
if (parameters.length > 0) {
- collectAdditionalConstraints(parameters, args, parentMethod, PsiSubstitutor.EMPTY, additionalConstraints);
+ collectAdditionalConstraints(parameters, args, properties.getMethod(), PsiSubstitutor.EMPTY, additionalConstraints, properties.isVarargs());
}
if (!additionalConstraints.isEmpty() && !proceedWithAdditionalConstraints(additionalConstraints)) {
@@ -228,17 +226,34 @@ public class InferenceSession {
}
}
- return null;
+ 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);
+ }
+
+ return prepareSubstitution();
}
private static void collectAdditionalConstraints(PsiParameter[] parameters,
PsiExpression[] args,
PsiMethod parentMethod,
PsiSubstitutor siteSubstitutor,
- Set<ConstraintFormula> additionalConstraints) {
+ Set<ConstraintFormula> additionalConstraints,
+ boolean varargs) {
for (int i = 0; i < args.length; i++) {
if (args[i] != null) {
- PsiType parameterType = getParameterType(parameters, args, i, siteSubstitutor);
+ PsiType parameterType = getParameterType(parameters, i, siteSubstitutor, varargs);
if (!isPertinentToApplicability(args[i], parentMethod)) {
additionalConstraints.add(new ExpressionCompatibilityConstraint(args[i], parameterType));
}
@@ -256,7 +271,8 @@ public class InferenceSession {
final PsiExpression[] newArgs = argumentList.getExpressions();
final PsiParameter[] newParams = method.getParameterList().getParameters();
if (newParams.length > 0) {
- collectAdditionalConstraints(newParams, newArgs, method, ((MethodCandidateInfo)result).getSiteSubstitutor(), additionalConstraints);
+ collectAdditionalConstraints(newParams, newArgs, method, ((MethodCandidateInfo)result).getSiteSubstitutor(),
+ additionalConstraints, ((MethodCandidateInfo)result).isVarargs());
}
}
}
@@ -265,40 +281,6 @@ public class InferenceSession {
}
}
- @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);
- }
-
- return prepareSubstitution();
- }
-
public PsiSubstitutor retrieveNonPrimitiveEqualsBounds(Collection<InferenceVariable> variables) {
PsiSubstitutor substitutor = mySiteSubstitutor;
for (InferenceVariable variable : variables) {
@@ -493,8 +475,23 @@ public class InferenceSession {
if (gParent instanceof PsiCallExpression) {
final PsiExpressionList argumentList = ((PsiCallExpression)gParent).getArgumentList();
if (argumentList != null) {
+ final MethodCandidateInfo.CurrentCandidateProperties properties = MethodCandidateInfo.getCurrentMethod(argumentList);
+ if (properties != null && properties.isApplicabilityCheck()) {
+ return getTypeByMethod(context, argumentList, properties.getMethod(), properties.isVarargs(), properties.getSubstitutor());
+ }
final JavaResolveResult result = ((PsiCallExpression)gParent).resolveMethodGenerics();
- return getTypeByMethod(context, argumentList, result, result.getElement());
+ final boolean varargs = properties != null && properties.isVarargs() || result instanceof MethodCandidateInfo && ((MethodCandidateInfo)result).isVarargs();
+ return getTypeByMethod(context, argumentList, result.getElement(),
+ varargs,
+ PsiResolveHelper.ourGraphGuard.doPreventingRecursion(argumentList.getParent(), false,
+ new Computable<PsiSubstitutor>() {
+ @Override
+ public PsiSubstitutor compute() {
+ return result.getSubstitutor();
+ }
+ }
+ )
+ );
}
}
} else if (parent instanceof PsiConditionalExpression) {
@@ -516,7 +513,9 @@ public class InferenceSession {
private static PsiType getTypeByMethod(PsiExpression context,
PsiExpressionList argumentList,
- final JavaResolveResult result, PsiElement parentMethod) {
+ PsiElement parentMethod,
+ boolean varargs,
+ PsiSubstitutor substitutor) {
if (parentMethod instanceof PsiMethod) {
final PsiParameter[] parameters = ((PsiMethod)parentMethod).getParameterList().getParameters();
if (parameters.length == 0) return null;
@@ -528,13 +527,7 @@ public class InferenceSession {
}
final int i = ArrayUtilRt.find(args, arg);
if (i < 0) return null;
- return getParameterType(parameters, args, i, PsiResolveHelper.ourGraphGuard.doPreventingRecursion(argumentList.getParent(), false,
- new Computable<PsiSubstitutor>() {
- @Override
- public PsiSubstitutor compute() {
- return result.getSubstitutor();
- }
- }));
+ return getParameterType(parameters, i, substitutor, varargs);
}
return null;
}
@@ -823,15 +816,19 @@ public class InferenceSession {
MethodCandidateInfo.updateSubstitutor(argumentList, substitutor);
}
- for (ConstraintFormula additionalConstraint : subset) {
- additionalConstraint.apply(substitutor);
- }
+ try {
+ for (ConstraintFormula additionalConstraint : subset) {
+ additionalConstraint.apply(substitutor);
+ }
- myConstraints.addAll(subset);
- if (!repeatInferencePhases(true)) {
- return false;
+ myConstraints.addAll(subset);
+ if (!repeatInferencePhases(true)) {
+ return false;
+ }
+ }
+ finally {
+ LambdaUtil.ourFunctionTypes.set(null);
}
-
}
return true;
}
@@ -931,7 +928,7 @@ public class InferenceSession {
}
if (varargs) {
- PsiType sType = siteSubstitutor2.substitute(parameters1[paramsLength].getType());
+ PsiType sType = siteSubstitutor2.substitute(getVarargParameterType(true, paramsLength, parameters1));
PsiType tType = siteSubstitutor2.substitute(getVarargParameterType(true, paramsLength, parameters2));
session.addConstraint(new StrictSubtypingConstraint(tType, sType));
}
@@ -942,8 +939,9 @@ public class InferenceSession {
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();
+ if (lastParamType instanceof PsiEllipsisType) {
+ return ((PsiEllipsisType)lastParamType).getComponentType();
+ }
}
return parameters2[i].getType();
}
@@ -995,8 +993,9 @@ public class InferenceSession {
return true;
}
- if (sReturnType == PsiType.VOID && session != null) {
- return false;
+ final List<PsiExpression> returnExpressions = LambdaUtil.getReturnExpressions((PsiLambdaExpression)arg);
+ if (sReturnType == PsiType.VOID) {
+ return returnExpressions.isEmpty() && session == null;
}
if (LambdaUtil.isFunctionalType(sReturnType) && LambdaUtil.isFunctionalType(tReturnType) &&
@@ -1005,15 +1004,14 @@ public class InferenceSession {
//Otherwise, if R1 and R2 are functional interface types, and neither interface is a subinterface of the other,
//then these rules are applied recursively to R1 and R2, for each result expression in expi.
- final List<PsiExpression> returnExpressions = LambdaUtil.getReturnExpressions((PsiLambdaExpression)arg);
if (!isFunctionalTypeMoreSpecific(sReturnType, tReturnType, session, returnExpressions.toArray(new PsiExpression[returnExpressions.size()]))) {
return false;
}
} else {
- 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) {
- for (PsiExpression returnExpression : LambdaUtil.getReturnExpressions((PsiLambdaExpression)arg)) {
+ for (PsiExpression returnExpression : returnExpressions) {
if (!PsiPolyExpressionUtil.isPolyExpression(returnExpression)) {
final PsiType returnExpressionType = returnExpression.getType();
if (sPrimitive) {
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 ebcbda6a2926..ff462cef03a8 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
@@ -129,7 +129,7 @@ public class ExpressionCompatibilityConstraint extends InputOutputConstraintForm
if (method != null) {
final PsiExpression[] args = argumentList.getExpressions();
final PsiParameter[] parameters = method.getParameterList().getParameters();
- callSession.initExpressionConstraints(parameters, args, myExpression, method);
+ callSession.initExpressionConstraints(parameters, args, myExpression, method, resolveResult instanceof MethodCandidateInfo && ((MethodCandidateInfo)resolveResult).isVarargs());
}
final boolean accepted = callSession.repeatInferencePhases(true);
if (!accepted) {
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 0a49428722a1..fbd04e531e22 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
@@ -22,9 +22,7 @@ import com.intellij.psi.impl.source.resolve.graphInference.InferenceVariable;
import com.intellij.psi.util.PsiUtil;
import org.jetbrains.annotations.Nullable;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
+import java.util.*;
/**
* User: anna
@@ -110,5 +108,11 @@ public abstract class InputOutputConstraintFormula implements ConstraintFormula
@Override
public void apply(PsiSubstitutor substitutor) {
setT(substitutor.substitute(getT()));
+ Map<PsiElement, PsiType> map = LambdaUtil.ourFunctionTypes.get();
+ if (map == null) {
+ map = new HashMap<PsiElement, PsiType>();
+ LambdaUtil.ourFunctionTypes.set(map);
+ }
+ map.put(getExpression(), getT());
}
}
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 21480db73b07..391eafef02b5 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
@@ -208,7 +208,6 @@ public class PsiMethodReferenceCompatibilityConstraint implements ConstraintForm
if (res instanceof PsiClass) {
PsiClass containingClass = (PsiClass)res;
final boolean isRawSubst = !myExpression.isConstructor() &&
- PsiTreeUtil.isAncestor(containingClass, myExpression, true) &&
PsiUtil.isRawSubstitutor(containingClass, resolveResult.getSubstitutor());
qualifierType = JavaPsiFacade.getElementFactory(res.getProject()).createType(containingClass, isRawSubst ? PsiSubstitutor.EMPTY : resolveResult.getSubstitutor());
}
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 d6f9f1bc50f7..7bdd013b5792 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
@@ -21,8 +21,10 @@ 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;
+import com.intellij.psi.impl.source.resolve.graphInference.InferenceSession;
import com.intellij.psi.impl.source.tree.ChildRole;
import com.intellij.psi.impl.source.tree.JavaElementType;
+import com.intellij.psi.infos.MethodCandidateInfo;
import com.intellij.psi.scope.PsiScopeProcessor;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.util.PsiTreeUtil;
@@ -153,6 +155,17 @@ public class PsiLambdaExpressionImpl extends ExpressionPsiElement implements Psi
}
return false;
}
+ final PsiElement argsList = PsiTreeUtil.getParentOfType(this, PsiExpressionList.class);
+ if (MethodCandidateInfo.ourOverloadGuard.currentStack().contains(argsList)) {
+ if (!hasFormalParameterTypes()) {
+ return true;
+ }
+ final MethodCandidateInfo.CurrentCandidateProperties candidateProperties = MethodCandidateInfo.getCurrentMethod(argsList);
+ if (candidateProperties != null && !InferenceSession.isPertinentToApplicability(this, candidateProperties.getMethod())) {
+ return true;
+ }
+ }
+
leftType = FunctionalInterfaceParameterizationUtil.getGroundTargetType(leftType, this);
final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(leftType);
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 084be88d7428..f48fcb59f57a 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
@@ -18,7 +18,6 @@ package com.intellij.psi.impl.source.tree.java;
import com.intellij.lang.ASTNode;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Comparing;
-import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.*;
import com.intellij.psi.impl.PsiManagerEx;
@@ -51,7 +50,10 @@ import com.intellij.util.SmartList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase implements PsiMethodReferenceExpression {
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.tree.java.PsiMethodReferenceExpressionImpl");
@@ -161,7 +163,7 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase
if (containingClass != null) {
PsiMethod[] methods = null;
if (element instanceof PsiIdentifier) {
- methods = containingClass.findMethodsByName(element.getText(), false);
+ methods = containingClass.findMethodsByName(element.getText(), true);
}
else if (isConstructor()) {
final PsiElementFactory factory = JavaPsiFacade.getElementFactory(getProject());
@@ -444,19 +446,30 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase
final MethodCandidatesProcessor processor =
new MethodCandidatesProcessor(reference, getContainingFile(), new PsiConflictResolver[] {conflictResolver}, new SmartList<CandidateInfo>()) {
@Override
+ protected boolean acceptVarargs() {
+ return true;
+ }
+
+ @Override
protected MethodCandidateInfo createCandidateInfo(final PsiMethod method,
final PsiSubstitutor substitutor,
final boolean staticProblem,
- final boolean accessible) {
+ final boolean accessible,
+ final boolean varargs) {
final PsiExpressionList argumentList = getArgumentList();
final PsiType[] typeParameters = reference.getTypeParameters();
return new MethodCandidateInfo(method, substitutor, !accessible, staticProblem, argumentList, myCurrentFileContext,
argumentList != null ? argumentList.getExpressionTypes() : null, typeParameters.length > 0 ? typeParameters : null,
getLanguageLevel()) {
+ @Override
+ public boolean isVarargs() {
+ return varargs;
+ }
+
@NotNull
@Override
public PsiSubstitutor inferTypeArguments(@NotNull ParameterTypeInferencePolicy policy, boolean includeReturnConstraint) {
- return inferTypeArguments(false);
+ return inferTypeArguments(varargs);
}
public PsiSubstitutor inferTypeArguments(boolean varargs) {
@@ -465,9 +478,9 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase
final InferenceSession session = new InferenceSession(method.getTypeParameters(), substitutor, getManager(), reference);
//lift parameters from outer call
- final Pair<PsiMethod,PsiSubstitutor> methodSubstitutorPair = MethodCandidateInfo.getCurrentMethod(reference.getParent());
+ final CurrentCandidateProperties methodSubstitutorPair = MethodCandidateInfo.getCurrentMethod(reference.getParent());
if (methodSubstitutorPair != null) {
- session.initBounds(methodSubstitutorPair.first.getTypeParameters());
+ session.initBounds(methodSubstitutorPair.getMethod().getTypeParameters());
}
final PsiParameter[] functionalMethodParameters = interfaceMethod.getParameterList().getParameters();
@@ -515,9 +528,6 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase
}
if (!session.repeatInferencePhases(false)) {
- if (method.isVarArgs() && !varargs) {
- return inferTypeArguments(true);
- }
return substitutor;
}
@@ -598,13 +608,14 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase
mySignature = signature;
}
- @Nullable
@Override
- public CandidateInfo resolveConflict(@NotNull List<CandidateInfo> conflicts) {
- return resolveConflict(conflicts, false);
+ protected int getPertinentApplicabilityLevel(MethodCandidateInfo conflict) {
+ return conflict.isVarargs() ? MethodCandidateInfo.ApplicabilityLevel.VARARGS : MethodCandidateInfo.ApplicabilityLevel.FIXED_ARITY;
}
- public CandidateInfo resolveConflict(@NotNull List<CandidateInfo> conflicts, boolean varargs) {
+ @Nullable
+ @Override
+ public CandidateInfo resolveConflict(@NotNull List<CandidateInfo> conflicts) {
if (mySignature == null) return null;
checkSameSignatures(conflicts);
@@ -625,6 +636,7 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase
final PsiSubstitutor substitutor = conflict.getSubstitutor();
final PsiType[] signatureParameterTypes2 = psiMethod.getSignature(substitutor).getParameterTypes();
+ final boolean varargs = ((MethodCandidateInfo)conflict).isVarargs();
if (varargs && (!psiMethod.isVarArgs() || myFunctionalMethodVarArgs)) continue;
if ((varargs || parameterTypes.length == signatureParameterTypes2.length) &&
@@ -653,19 +665,12 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase
}
}
- checkSpecifics(firstCandidates,
- varargs ? MethodCandidateInfo.ApplicabilityLevel.VARARGS : MethodCandidateInfo.ApplicabilityLevel.FIXED_ARITY, myLanguageLevel);
-
- checkSpecifics(secondCandidates,
- varargs ? MethodCandidateInfo.ApplicabilityLevel.VARARGS : MethodCandidateInfo.ApplicabilityLevel.FIXED_ARITY, myLanguageLevel);
-
- final int acceptedCount = firstCandidates.size() + secondCandidates.size();
- if (acceptedCount == 1) {
+ if (resolveConflicts(firstCandidates, secondCandidates, MethodCandidateInfo.ApplicabilityLevel.FIXED_ARITY)) {
return !firstCandidates.isEmpty() ? firstCandidates.get(0) : secondCandidates.get(0);
}
- if (!varargs) {
- return resolveConflict(conflicts, true);
+ if (resolveConflicts(firstCandidates, secondCandidates, MethodCandidateInfo.ApplicabilityLevel.VARARGS)) {
+ return !firstCandidates.isEmpty() ? firstCandidates.get(0) : secondCandidates.get(0);
}
conflicts.clear();
@@ -674,6 +679,17 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase
return null;
}
+ private boolean resolveConflicts(List<CandidateInfo> firstCandidates, List<CandidateInfo> secondCandidates, int applicabilityLevel) {
+
+ checkApplicability(firstCandidates);
+ checkSpecifics(firstCandidates, applicabilityLevel, myLanguageLevel);
+
+ checkApplicability(secondCandidates);
+ checkSpecifics(secondCandidates, applicabilityLevel, myLanguageLevel);
+
+ return firstCandidates.size() + secondCandidates.size() == 1;
+ }
+
@Override
protected boolean nonComparable(CandidateInfo method, CandidateInfo conflict) {
if (method == conflict) return true;
@@ -748,14 +764,22 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase
return false;
}
+ final PsiElement argsList = PsiTreeUtil.getParentOfType(this, PsiExpressionList.class);
+ final boolean isExact = isExact();
+ if (MethodCandidateInfo.ourOverloadGuard.currentStack().contains(argsList) && isExact) {
+ final MethodCandidateInfo.CurrentCandidateProperties candidateProperties = MethodCandidateInfo.getCurrentMethod(argsList);
+ if (candidateProperties != null && !InferenceSession.isPertinentToApplicability(this, candidateProperties.getMethod())) {
+ return true;
+ }
+ }
+
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()) {
+ if (!isExact) {
return true;
}
}
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 406abbf9ee7a..6c979cf01aac 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
@@ -72,7 +72,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
if (conflicts.isEmpty()) return null;
if (conflicts.size() == 1) return conflicts.get(0);
- boolean atLeastOneMatch = checkParametersNumber(conflicts, getActualParameterTypes().length, true);
+ boolean atLeastOneMatch = checkParametersNumber(conflicts, getActualParametersLength(), true);
if (conflicts.size() == 1) return conflicts.get(0);
checkSameSignatures(conflicts);
@@ -81,7 +81,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
checkAccessStaticLevels(conflicts, true);
if (conflicts.size() == 1) return conflicts.get(0);
- checkParametersNumber(conflicts, getActualParameterTypes().length, false);
+ checkParametersNumber(conflicts, getActualParametersLength(), false);
if (conflicts.size() == 1) return conflicts.get(0);
final int applicabilityLevel = checkApplicability(conflicts);
@@ -97,7 +97,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
checkSpecifics(conflicts, applicabilityLevel, myLanguageLevel);
if (conflicts.size() == 1) return conflicts.get(0);
- checkPrimitiveVarargs(conflicts, getActualParameterTypes().length);
+ checkPrimitiveVarargs(conflicts, getActualParametersLength());
if (conflicts.size() == 1) return conflicts.get(0);
checkAccessStaticLevels(conflicts, false);
@@ -110,23 +110,51 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
private void checkLambdaApplicable(@NotNull List<CandidateInfo> conflicts, @NotNull LanguageLevel languageLevel) {
if (!languageLevel.isAtLeast(LanguageLevel.JDK_1_8)) return;
- for (int i = 0; i < getActualParameterTypes().length; i++) {
- PsiType parameterType = getActualParameterTypes()[i];
- if (parameterType instanceof PsiLambdaExpressionType) {
- final PsiLambdaExpression lambdaExpression = ((PsiLambdaExpressionType)parameterType).getExpression();
- for (Iterator<CandidateInfo> iterator = conflicts.iterator(); iterator.hasNext(); ) {
- ProgressManager.checkCanceled();
- final CandidateInfo conflict = iterator.next();
- final PsiMethod method = (PsiMethod)conflict.getElement();
- if (method != null) {
- final PsiParameter[] methodParameters = method.getParameterList().getParameters();
- if (methodParameters.length == 0) continue;
- final PsiParameter param = i < methodParameters.length ? methodParameters[i] : methodParameters[methodParameters.length - 1];
- final PsiType paramType = param.getType();
- if (!lambdaExpression.isAcceptable(((MethodCandidateInfo)conflict).getSubstitutor(false).substitute(paramType), lambdaExpression.hasFormalParameterTypes())) {
- iterator.remove();
- }
- }
+ for (int i = 0; i < getActualParametersLength(); i++) {
+
+ PsiExpression expression;
+ if (myArgumentsList instanceof PsiExpressionList) {
+ expression = ((PsiExpressionList)myArgumentsList).getExpressions()[i];
+ }
+ else {
+ final PsiType argType = getActualParameterTypes()[i];
+ expression = argType instanceof PsiLambdaExpressionType ? ((PsiLambdaExpressionType)argType).getExpression() : null;
+ }
+
+ final PsiLambdaExpression lambdaExpression = findNestedLambdaExpression(expression);
+ if (lambdaExpression != null) {
+ checkLambdaApplicable(conflicts, i, lambdaExpression);
+ }
+ }
+ }
+
+ private static PsiLambdaExpression findNestedLambdaExpression(PsiExpression expression) {
+ if (expression instanceof PsiLambdaExpression) {
+ return (PsiLambdaExpression)expression;
+ } else if (expression instanceof PsiParenthesizedExpression) {
+ return findNestedLambdaExpression(((PsiParenthesizedExpression)expression).getExpression());
+ } else if (expression instanceof PsiConditionalExpression) {
+ PsiLambdaExpression lambdaExpression = findNestedLambdaExpression(((PsiConditionalExpression)expression).getThenExpression());
+ if (lambdaExpression != null) {
+ return lambdaExpression;
+ }
+ return findNestedLambdaExpression(((PsiConditionalExpression)expression).getElseExpression());
+ }
+ return null;
+ }
+
+ private static void checkLambdaApplicable(List<CandidateInfo> conflicts, int i, PsiLambdaExpression lambdaExpression) {
+ for (Iterator<CandidateInfo> iterator = conflicts.iterator(); iterator.hasNext(); ) {
+ ProgressManager.checkCanceled();
+ final CandidateInfo conflict = iterator.next();
+ final PsiMethod method = (PsiMethod)conflict.getElement();
+ if (method != null) {
+ final PsiParameter[] methodParameters = method.getParameterList().getParameters();
+ if (methodParameters.length == 0) continue;
+ final PsiParameter param = i < methodParameters.length ? methodParameters[i] : methodParameters[methodParameters.length - 1];
+ final PsiType paramType = param.getType();
+ if (!lambdaExpression.isAcceptable(((MethodCandidateInfo)conflict).getSubstitutor(false).substitute(paramType), lambdaExpression.hasFormalParameterTypes())) {
+ iterator.remove();
}
}
}
@@ -323,7 +351,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
}
private static boolean areTypeParametersAgree(CandidateInfo info) {
- return ((MethodCandidateInfo)info).isApplicable();
+ return ((MethodCandidateInfo)info).getPertinentApplicabilityLevel() != MethodCandidateInfo.ApplicabilityLevel.NOT_APPLICABLE;
}
private static boolean checkParametersNumber(final List<CandidateInfo> conflicts,
@@ -364,12 +392,12 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
}
@MethodCandidateInfo.ApplicabilityLevelConstant
- private static int checkApplicability(List<CandidateInfo> conflicts) {
+ protected int checkApplicability(List<CandidateInfo> conflicts) {
@MethodCandidateInfo.ApplicabilityLevelConstant int maxApplicabilityLevel = 0;
boolean toFilter = false;
for (CandidateInfo conflict : conflicts) {
ProgressManager.checkCanceled();
- @MethodCandidateInfo.ApplicabilityLevelConstant final int level = ((MethodCandidateInfo)conflict).getPertinentApplicabilityLevel();
+ @MethodCandidateInfo.ApplicabilityLevelConstant final int level = getPertinentApplicabilityLevel((MethodCandidateInfo)conflict);
if (maxApplicabilityLevel > 0 && maxApplicabilityLevel != level) {
toFilter = true;
}
@@ -382,7 +410,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
for (Iterator<CandidateInfo> iterator = conflicts.iterator(); iterator.hasNext();) {
ProgressManager.checkCanceled();
CandidateInfo info = iterator.next();
- final int level = ((MethodCandidateInfo)info).getPertinentApplicabilityLevel();
+ final int level = getPertinentApplicabilityLevel((MethodCandidateInfo)info);
if (level < maxApplicabilityLevel) {
iterator.remove();
}
@@ -392,6 +420,10 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
return maxApplicabilityLevel;
}
+ protected int getPertinentApplicabilityLevel(MethodCandidateInfo conflict) {
+ return conflict.getPertinentApplicabilityLevel();
+ }
+
private static int getCheckAccessLevel(MethodCandidateInfo method){
boolean visible = method.isAccessible();
return visible ? 1 : 0;
@@ -411,6 +443,14 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
return myActualParameterTypes;
}
+ private int getActualParametersLength() {
+ if (myActualParameterTypes == null) {
+ LOG.assertTrue(myArgumentsList instanceof PsiExpressionList, myArgumentsList);
+ return ((PsiExpressionList)myArgumentsList).getExpressions().length;
+ }
+ return myActualParameterTypes.length;
+ }
+
protected PsiType[] getArgumentTypes() {
return ((PsiExpressionList)myArgumentsList).getExpressionTypes();
}
@@ -500,8 +540,8 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
final PsiSubstitutor siteSubstitutor1 = info1.getSiteSubstitutor();
final PsiSubstitutor siteSubstitutor2 = info2.getSiteSubstitutor();
- final PsiType[] types2AtSite = typesAtSite(types2, siteSubstitutor2, typeParameters2);
- final PsiType[] types1AtSite = typesAtSite(types1, siteSubstitutor1, typeParameters1);
+ final PsiType[] types2AtSite = typesAtSite(types2, siteSubstitutor2);
+ final PsiType[] types1AtSite = typesAtSite(types1, siteSubstitutor1);
final PsiSubstitutor methodSubstitutor1 = calculateMethodSubstitutor(typeParameters1, method1, siteSubstitutor1, types1, types2AtSite,
languageLevel);
@@ -534,16 +574,24 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
if (abstract2 && !abstract1) {
return Specifics.FIRST;
}
+
}
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)]) &&
- types2.length > 0 && LambdaUtil.isFunctionalType(types2[Math.min(i, types2.length - 1)])) {
- types1AtSite[Math.min(i, types1.length - 1)] = PsiType.NULL;
- types2AtSite[Math.min(i, types2.length - 1)] = PsiType.NULL;
- toCompareFunctional = true;
+ if (types1.length > 0 && types2.length > 0) {
+ for (int i = 0; i < getActualParametersLength(); i++) {
+ final PsiType type1 = types1[Math.min(i, types1.length - 1)];
+ final PsiType type2 = types2[Math.min(i, types2.length - 1)];
+ //from 15.12.2.5 Choosing the Most Specific Method
+ //In addition, a functional interface type S is more specific than a functional interface type T for an expression exp
+ // if T is not a subtype of S and one of the following conditions apply.
+ if (LambdaUtil.isFunctionalType(type1) && !type1.isAssignableFrom(type2) &&
+ LambdaUtil.isFunctionalType(type2) && !type2.isAssignableFrom(type1)) {
+ types1AtSite[Math.min(i, types1.length - 1)] = PsiType.NULL;
+ types2AtSite[Math.min(i, types2.length - 1)] = PsiType.NULL;
+ toCompareFunctional = true;
+ }
}
}
@@ -555,9 +603,9 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
if (applicable12ignoreFunctionalType || applicable21ignoreFunctionalType) {
Specifics specifics = null;
- for (int i = 0; i < myActualParameterTypes.length; i++) {
- if (types1.length > 0 && types1AtSite[Math.min(i, types1.length - 1)] == PsiType.NULL &&
- types2.length > 0 && types2AtSite[Math.min(i, types2.length - 1)] == PsiType.NULL) {
+ for (int i = 0; i < getActualParametersLength(); i++) {
+ if (types1AtSite[Math.min(i, types1.length - 1)] == PsiType.NULL &&
+ types2AtSite[Math.min(i, types2.length - 1)] == PsiType.NULL) {
Specifics specific = isFunctionalTypeMoreSpecific(info1, info2, ((PsiExpressionList)myArgumentsList).getExpressions()[i], i);
if (specific == Specifics.NEITHER) {
specifics = Specifics.NEITHER;
@@ -625,6 +673,12 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
return raw1 ? Specifics.SECOND : Specifics.FIRST;
}
+ final boolean varargs1 = info1.isVarargs();
+ final boolean varargs2 = info2.isVarargs();
+ if (varargs1 ^ varargs2) {
+ return varargs1 ? Specifics.SECOND : Specifics.FIRST;
+ }
+
return Specifics.NEITHER;
}
@@ -642,7 +696,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
return applicabilityLevel > MethodCandidateInfo.ApplicabilityLevel.NOT_APPLICABLE;
}
- private static PsiType[] typesAtSite(PsiType[] types1, PsiSubstitutor siteSubstitutor1, PsiTypeParameter[] typeParameters1) {
+ private static PsiType[] typesAtSite(PsiType[] types1, PsiSubstitutor siteSubstitutor1) {
final PsiType[] types = PsiType.createArray(types1.length);
for (int i = 0; i < types1.length; i++) {
types[i] = siteSubstitutor1.substitute(types1[i]);
diff --git a/java/java-psi-impl/src/com/intellij/psi/scope/processor/MethodCandidatesProcessor.java b/java/java-psi-impl/src/com/intellij/psi/scope/processor/MethodCandidatesProcessor.java
index ad0e7358842c..e44dfc7a9040 100644
--- a/java/java-psi-impl/src/com/intellij/psi/scope/processor/MethodCandidatesProcessor.java
+++ b/java/java-psi-impl/src/com/intellij/psi/scope/processor/MethodCandidatesProcessor.java
@@ -21,6 +21,7 @@ import com.intellij.psi.infos.CandidateInfo;
import com.intellij.psi.infos.MethodCandidateInfo;
import com.intellij.psi.scope.PsiConflictResolver;
import com.intellij.psi.scope.conflictResolvers.DuplicateConflictResolver;
+import com.intellij.psi.util.PsiUtil;
import com.intellij.util.SmartList;
import org.jetbrains.annotations.NotNull;
@@ -54,16 +55,33 @@ public class MethodCandidatesProcessor extends MethodsProcessor{
myPlace, myAccessClass, myCurrentFileContext, myPlaceFile) &&
!isShadowed(method);
if (isAccepted(method)) {
- add(createCandidateInfo(method, substitutor, staticProblem, isAccessible));
+ add(createCandidateInfo(method, substitutor, staticProblem, isAccessible, false));
+ if (acceptVarargs() && method.isVarArgs() && PsiUtil.isLanguageLevel8OrHigher(myPlace)) {
+ add(createCandidateInfo(method, substitutor, staticProblem, isAccessible, true));
+ }
myHasAccessibleStaticCorrectCandidate |= isAccessible && !staticProblem;
}
}
+ protected boolean acceptVarargs() {
+ return false;
+ }
+
protected MethodCandidateInfo createCandidateInfo(final PsiMethod method, final PsiSubstitutor substitutor,
- final boolean staticProblem, final boolean accessible) {
+ final boolean staticProblem, final boolean accessible, final boolean varargs) {
final PsiExpressionList argumentList = getArgumentList();
return new MethodCandidateInfo(method, substitutor, !accessible, staticProblem, argumentList, myCurrentFileContext,
- getExpressionTypes(argumentList), getTypeArguments(), getLanguageLevel());
+ null, getTypeArguments(), getLanguageLevel()) {
+ @Override
+ public PsiType[] getArgumentTypes() {
+ return getExpressionTypes(argumentList);
+ }
+
+ @Override
+ public boolean isVarargs() {
+ return varargs;
+ }
+ };
}
protected PsiType[] getExpressionTypes(PsiExpressionList argumentList) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/scope/processor/MethodResolverProcessor.java b/java/java-psi-impl/src/com/intellij/psi/scope/processor/MethodResolverProcessor.java
index 396d9b3b60d0..b73f87b72ce4 100644
--- a/java/java-psi-impl/src/com/intellij/psi/scope/processor/MethodResolverProcessor.java
+++ b/java/java-psi-impl/src/com/intellij/psi/scope/processor/MethodResolverProcessor.java
@@ -63,4 +63,9 @@ public class MethodResolverProcessor extends MethodCandidatesProcessor {
public boolean execute(@NotNull PsiElement element, ResolveState state) {
return !myStopAcceptingCandidates && super.execute(element, state);
}
+
+ @Override
+ protected boolean acceptVarargs() {
+ return true;
+ }
}
diff --git a/java/java-tests/testData/codeInsight/clsHighlighting/IDEA121866.java b/java/java-tests/testData/codeInsight/clsHighlighting/IDEA121866.java
new file mode 100644
index 000000000000..fe3235c55df9
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/clsHighlighting/IDEA121866.java
@@ -0,0 +1,5 @@
+class IDEA121866 {
+ {
+ A<String> a = new A<>();
+ }
+} \ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/clsHighlighting/libs/IDEA121866.jar b/java/java-tests/testData/codeInsight/clsHighlighting/libs/IDEA121866.jar
new file mode 100644
index 000000000000..0151e3545391
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/clsHighlighting/libs/IDEA121866.jar
Binary files differ
diff --git a/java/java-tests/testData/codeInsight/completion/smartType/DiamondsInsideMethodCall-out.java b/java/java-tests/testData/codeInsight/completion/smartType/DiamondsInsideMethodCall-out.java
new file mode 100644
index 000000000000..f8768f665909
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/smartType/DiamondsInsideMethodCall-out.java
@@ -0,0 +1,12 @@
+class A<T> {
+ A(T... t) {
+ }
+
+ {
+ bar(new A<>(<caret>) );
+ }
+
+ <T> void bar(A<T> s) {}
+
+
+}
diff --git a/java/java-tests/testData/codeInsight/completion/smartType/DiamondsInsideMethodCall.java b/java/java-tests/testData/codeInsight/completion/smartType/DiamondsInsideMethodCall.java
new file mode 100644
index 000000000000..9e776bb6baba
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/smartType/DiamondsInsideMethodCall.java
@@ -0,0 +1,12 @@
+class A<T> {
+ A(T... t) {
+ }
+
+ {
+ bar(new <caret> );
+ }
+
+ <T> void bar(A<T> s) {}
+
+
+}
diff --git a/java/java-tests/testData/codeInsight/completion/smartType/InLambdaPositionNameSubstitution-out.java b/java/java-tests/testData/codeInsight/completion/smartType/InLambdaPositionNameSubstitution-out.java
new file mode 100644
index 000000000000..5412eabcf355
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/smartType/InLambdaPositionNameSubstitution-out.java
@@ -0,0 +1,9 @@
+interface I<T> {
+ void m(T t);
+}
+
+class Test {
+ public static void main(String[] args) {
+ I<String> i = s -> <caret>
+ }
+} \ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/completion/smartType/InLambdaPositionNameSubstitution.java b/java/java-tests/testData/codeInsight/completion/smartType/InLambdaPositionNameSubstitution.java
new file mode 100644
index 000000000000..6e57fe289d79
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/smartType/InLambdaPositionNameSubstitution.java
@@ -0,0 +1,9 @@
+interface I<T> {
+ void m(T t);
+}
+
+class Test {
+ public static void main(String[] args) {
+ I<String> i = <caret>
+ }
+} \ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/completion/smartType/InLambdaPositionSingleParam-out.java b/java/java-tests/testData/codeInsight/completion/smartType/InLambdaPositionSingleParam-out.java
new file mode 100644
index 000000000000..96fd5f16074b
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/smartType/InLambdaPositionSingleParam-out.java
@@ -0,0 +1,9 @@
+interface I {
+ void m(int x);
+}
+
+class Test {
+ public static void main(String[] args) {
+ I i = x -> <caret>
+ }
+} \ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/completion/smartType/InLambdaPositionSingleParam.java b/java/java-tests/testData/codeInsight/completion/smartType/InLambdaPositionSingleParam.java
new file mode 100644
index 000000000000..7de98c3770c7
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/smartType/InLambdaPositionSingleParam.java
@@ -0,0 +1,9 @@
+interface I {
+ void m(int x);
+}
+
+class Test {
+ public static void main(String[] args) {
+ I i = <caret>
+ }
+} \ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/completion/smartType/InstanceofedInsideAnonymous-out.java b/java/java-tests/testData/codeInsight/completion/smartType/InstanceofedInsideAnonymous-out.java
index 3cfb17dfc9a6..7b4d91ff6e20 100644
--- a/java/java-tests/testData/codeInsight/completion/smartType/InstanceofedInsideAnonymous-out.java
+++ b/java/java-tests/testData/codeInsight/completion/smartType/InstanceofedInsideAnonymous-out.java
@@ -1,6 +1,6 @@
class C{
{
- Object o;
+ final Object o;
if (o instanceof Foo) {
new Runnable() {
public void run() {
diff --git a/java/java-tests/testData/codeInsight/completion/variables/locals/TestResult4.java b/java/java-tests/testData/codeInsight/completion/variables/locals/TestResult4.java
index cc417f518b5d..fa9a5487bedd 100644
--- a/java/java-tests/testData/codeInsight/completion/variables/locals/TestResult4.java
+++ b/java/java-tests/testData/codeInsight/completion/variables/locals/TestResult4.java
@@ -10,7 +10,7 @@ package codeInsight.completion.variables.locals;
public class TestSource4 {
int aaa = 0;
public static void foo(){
- int abc = 0;
+ final int abc = 0;
class Inner1{
int sbe=abc<caret>
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/TryWithResources.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/TryWithResources.java
index b21f42ccaf4c..289dc6167f68 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/TryWithResources.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/TryWithResources.java
@@ -1,18 +1,3 @@
-/*
- * Copyright 2000-2012 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
class C {
static class E extends Exception { }
static class E1 extends E { }
@@ -25,7 +10,15 @@ class C {
@Override public void close() throws E3 { }
}
- static interface I extends AutoCloseable { }
+ interface I extends AutoCloseable { }
+
+ interface Gen<E extends Exception> extends AutoCloseable {
+ @Override void close() throws E;
+
+ class Impl implements Gen<E2> {
+ @Override public void close() throws E2 { }
+ }
+ }
void m1() {
try (MyResource r = new MyResource()) { r.doSomething(); }
@@ -90,4 +83,8 @@ class C {
MyResource r;
try (MyResource r1 = <error descr="Variable 'r' might not have been initialized">r</error>) { }
}
+
+ void m5() {
+ try (<error descr="Unhandled exception from auto-closeable resource: C.E2">Gen<E2> gen = new Gen.Impl()</error>) { }
+ }
} \ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA91626.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA91626.java
index ff29729bc977..d8db681dd0de 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA91626.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA91626.java
@@ -11,7 +11,7 @@ class Test {
}
static void foo2(final A<? extends Integer> bar) {
- bar._<error descr="'_(capture<? extends java.lang.Integer>...)' in 'Test.A' cannot be applied to '(java.lang.String)'">("")</error>;
+ bar._<error descr="Cannot resolve method '_(java.lang.String)'">("")</error>;
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/diamond/IDEA97294.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/diamond/IDEA97294.java
index 04fd969b5309..525afaa530e0 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/diamond/IDEA97294.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/diamond/IDEA97294.java
@@ -13,12 +13,12 @@ class SortedOp<T> implements StatefulOp<T, T> {
}
}
-class Usage<T> {
- public <E, S extends BaseStream<E>> S pipeline(IntermediateOp<T, E> newOp) { return null; }
- public <R> R pipeline(TerminalOp<T, R> terminal) { return null;}
+class Usage<Ts> {
+ public <E, S extends BaseStream<E>> S pipeline(IntermediateOp<Ts, E> newOp) { return null; }
+ public <R> R pipeline(TerminalOp<Ts, R> terminal) { return null;}
- public Stream<T> sorted(Comparator<? super T> comparator) {
+ public Stream<Ts> sorted(Comparator<? super Ts> comparator) {
return pipeline(new SortedOp<>(comparator));
}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/diamond/Varargs.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/diamond/Varargs.java
new file mode 100644
index 000000000000..2826e5802e91
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/diamond/Varargs.java
@@ -0,0 +1,26 @@
+class A<T> {
+ A(T... t) {
+ }
+
+ {
+ A<String> a = new A<>("a", "b");
+ foo(new A<>("", ""));
+ bar(new A<>("", ""));
+ bar(new A<>(get()));
+ //bar(new A<>(get( ), ""));
+ }
+
+ void foo(A<String> s) {}
+ <T> void bar(A<T> s) {}
+
+ <K> K get() {return null;}
+
+ <M> A<M> s(M... m) {
+ return null;
+ }
+
+ {
+ bar(s(get()));
+ bar(s(get(), ""));
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/IncorporationWithEqualsBoundsSubstitution.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/IncorporationWithEqualsBoundsSubstitution.java
new file mode 100644
index 000000000000..5f85bc0d79eb
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/IncorporationWithEqualsBoundsSubstitution.java
@@ -0,0 +1,14 @@
+abstract class Test {
+ abstract <Tf extends String> Tf foo(Class<Tf> c);
+ abstract <Tf1> Tf1 foo1(Class<Tf1> c);
+
+ abstract <U> Class<? extends U> bar(Class<U> clazz);
+ abstract <U1> Class<U1> bar1(Class<U1> clazz);
+
+ {
+ foo(bar(String.class));
+ foo(bar1(String.class));
+ foo1(bar(String.class));
+ foo1(bar1(String.class));
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/OuterCallConflictResolution.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/OuterCallConflictResolution.java
new file mode 100644
index 000000000000..dd04a51b2703
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/OuterCallConflictResolution.java
@@ -0,0 +1,23 @@
+import java.util.*;
+
+class Test {
+
+
+ void m(Runnable p) { }
+ void m(List<Runnable> p) { }
+
+ {
+ m(foo());
+ m<error descr="Cannot resolve method 'm(java.lang.Object)'">(bar())</error>;
+ }
+
+ <T> List<T> foo() {
+ return null;
+ }
+
+ <T> T bar() {
+ return null;
+ }
+
+
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/VarargsOnNonPertinentPlace.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/VarargsOnNonPertinentPlace.java
new file mode 100644
index 000000000000..4d10bd47b5eb
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/VarargsOnNonPertinentPlace.java
@@ -0,0 +1,8 @@
+abstract class Im {
+ public static final Class[] EMPTY_CLASS_ARRAY = new Class[0];
+ public abstract <T> T createProxy(final Class<T> superClass, final Class... otherInterfaces);
+
+ void f(Class<?> implementation, Class rawType, boolean isInterface) {
+ createProxy(implementation, isInterface ? new Class[]{rawType} : EMPTY_CLASS_ARRAY);
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguityRawGenerics.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguityRawGenerics.java
index 6c664dd9e65a..595787704437 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguityRawGenerics.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguityRawGenerics.java
@@ -22,6 +22,6 @@ class AmbiguityRawGenerics {
<Z> void foo(I3<Z> s) { }
void bar() {
- foo<error descr="Ambiguous method call: both 'AmbiguityRawGenerics.foo(I1)' and 'AmbiguityRawGenerics.foo(I2)' match">(()-> { throw new RuntimeException(); })</error>;
+ foo<error descr="Ambiguous method call: both 'AmbiguityRawGenerics.foo(I)' and 'AmbiguityRawGenerics.foo(I1)' match">(()-> { throw new RuntimeException(); })</error>;
}
} \ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguityReturnValueResolution1.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguityReturnValueResolution1.java
index fab979466120..a6abf3db299a 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguityReturnValueResolution1.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguityReturnValueResolution1.java
@@ -1,4 +1,4 @@
-public class Test {
+class Test {
interface II {
int _();
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ConflictResolution.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ConflictResolution.java
index 2c39efa13400..0cc3741e0f61 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ConflictResolution.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ConflictResolution.java
@@ -1,7 +1,7 @@
class Demo {
public void f1() {
- f2<error descr="'f2()' in 'Demo' cannot be applied to '(int, <lambda expression>)'">(2, input -> input)</error>;
+ f2(2, <error descr="Target type of a lambda conversion must be an interface">input -> input</error>);
}
public void f2() {
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific/BothVarargs.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific/BothVarargs.java
new file mode 100644
index 000000000000..c4cfbcdd426c
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific/BothVarargs.java
@@ -0,0 +1,14 @@
+import java.util.List;
+
+abstract class StreamMain {
+ public abstract <T> Iterable<T> concat(final Iterable<? extends T>... iterables);
+ public abstract <T> Iterable<T> concat(final List<? extends T>... iterables);
+
+
+ public final List<String> errorFixesToShow = null;
+ public final List<String> inspectionFixesToShow = null;
+
+ {
+ concat(errorFixesToShow, inspectionFixesToShow);
+ }
+} \ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific/IDEA121884.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific/IDEA121884.java
new file mode 100644
index 000000000000..e823de324ef5
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific/IDEA121884.java
@@ -0,0 +1,17 @@
+class Main {
+ interface MyCall {
+ void call(int n);
+ }
+ interface MyCallRet {
+ int call(int n);
+ }
+ public static void caller(MyCall c) {
+ c.call(2);
+ }
+ public static void caller(MyCallRet c) {
+ c.call(3);
+ }
+ public static void main(String[] args) {
+ caller( (int n) -> { System.out.println(" " + n); } );
+ }
+} \ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific/IDEA121999.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific/IDEA121999.java
new file mode 100644
index 000000000000..79994326c61a
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific/IDEA121999.java
@@ -0,0 +1,21 @@
+import java.util.function.Supplier;
+
+class LambdaTest {
+
+ static {
+ int <warning descr="Variable 'i' is never used">i</warning> = doSync(() -> foo());
+ int <warning descr="Variable 'i1' is never used">i1</warning> = doSync(LambdaTest::foo);
+ }
+
+ public static <T> T doSync(Supplier<T> <warning descr="Parameter 'block' is never used">block</warning>) {
+ return null;
+ }
+
+ public static void doSync(Runnable <warning descr="Parameter 'block' is never used">block</warning>) {
+ }
+
+ public static int foo() {
+ return 0;
+ }
+
+} \ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific/MostSpecificForSameFunctionalTypes.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific/MostSpecificForSameFunctionalTypes.java
new file mode 100644
index 000000000000..14cba01e1550
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific/MostSpecificForSameFunctionalTypes.java
@@ -0,0 +1,33 @@
+abstract class HighlightTestInfo {
+ protected final String[] filePaths;
+ public HighlightTestInfo(Disposable <warning descr="Parameter 'buf' is never used">buf</warning>, String... filePaths) {
+ this.filePaths = filePaths;
+ }
+
+ protected abstract HighlightTestInfo doTest();
+}
+
+class StreamMain {
+ private Disposable <warning descr="Private field 'testRootDisposable' is never assigned">testRootDisposable</warning>;
+
+ public HighlightTestInfo testFile(String... filePath) {
+ return new HighlightTestInfo(getTestRootDisposable(), filePath) {
+ public HighlightTestInfo doTest() {
+ return this;
+ }
+ };
+ }
+
+ public Disposable getTestRootDisposable() {
+ return testRootDisposable;
+ }
+}
+
+interface Disposable {
+ void dispose();
+
+ interface Parent extends Disposable {
+ void beforeTreeDispose();
+ }
+
+} \ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific/NestedLambdaSpecifics.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific/NestedLambdaSpecifics.java
new file mode 100644
index 000000000000..be47ffbc83b8
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific/NestedLambdaSpecifics.java
@@ -0,0 +1,19 @@
+class Test {
+
+ interface A<T> {
+ T a();
+ }
+
+ interface B<T> {
+ T b();
+ }
+
+ private void m(A<Integer> <warning descr="Parameter 'a' is never used">a</warning>) { }
+ private void <warning descr="Private method 'm(Test.B<java.lang.String>)' is never used">m</warning>(B<String> <warning descr="Parameter 'b' is never used">b</warning>) { }
+
+ {
+ m((() -> 42));
+ m(true ? () -> 42 : () -> 42);
+ m(true ? null : (() -> 42));
+ }
+} \ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific/NestedVarargs.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific/NestedVarargs.java
new file mode 100644
index 000000000000..55f2e00f76ba
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific/NestedVarargs.java
@@ -0,0 +1,46 @@
+import java.util.List;
+
+abstract class StreamMain {
+ public abstract <T> Iterable<T> concat(final Iterable<? extends T>... iterables);
+ public abstract <T> Iterable<T> concat(final List<? extends T>... iterables);
+
+ public final List<String> errorFixesToShow = null;
+ public final List<String> inspectionFixesToShow = null;
+
+ void foo() {
+ exists(concat(errorFixesToShow, inspectionFixesToShow), "");
+ }
+
+ public abstract <T> boolean exists(T[] iterable, T t);
+ public abstract <T> boolean exists(Iterable<T> iterable, T t);
+
+}
+
+
+abstract class StreamMainComplexSecendArgument {
+ public abstract <T> Iterable<T> concat(final Iterable<? extends T>... iterables);
+ public abstract <T> Iterable<T> concat(final List<? extends T>... iterables);
+
+
+ public final List<String> errorFixesToShow = null;
+ public final List<String> inspectionFixesToShow = null;
+
+ void foo() {
+ Condition<String> condition = new Condition<String>() {
+ @Override
+ public boolean value(String s) {
+ return false;
+ }
+ };
+ exists(concat(errorFixesToShow, inspectionFixesToShow), condition);
+ }
+
+ public abstract <T> boolean exists(T[] iterable, Condition<T> condition);
+
+ public abstract <T> boolean exists(Iterable<T> iterable, Condition<T> condition);
+
+
+ interface Condition<T> {
+ boolean value(T t);
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA118965comment.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA118965comment.java
new file mode 100644
index 000000000000..501e5f8d51cc
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA118965comment.java
@@ -0,0 +1,13 @@
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+class IDEA118965 {
+ {
+ Stream<String> words = Arrays.asList("one", "one", "two").stream();
+ List<Map.Entry<String,Integer>> res = words.collect(Collectors.toMap(w -> w, w -> 1, (a, b) -> a + b))
+ .entrySet().stream().filter(e -> e.getValue() > 1).collect(Collectors.toList());
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA121315.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA121315.java
new file mode 100644
index 000000000000..1c22302f2523
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA121315.java
@@ -0,0 +1,22 @@
+import java.util.Map;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+public class IDEA121315 {
+ class Issue {
+ Long getId() {
+ return 1l;
+ }
+ }
+
+ <T> T id(T i) {
+ return i;
+ }
+
+ void foo(Stream<Issue> map){
+ Map<Long, Issue> id2Issue = map.collect(Collectors.toMap(null, p -> id(p)));
+ Map<Long, Issue> id2Issue1 = map.collect(Collectors.toMap(null, p -> p));
+ Map<Long, Issue> id2Issue2 = map.collect(Collectors.toMap(null, this::id));
+
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/AmbiguityVarargs.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/AmbiguityVarargs.java
new file mode 100644
index 000000000000..bb3a6432e895
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/AmbiguityVarargs.java
@@ -0,0 +1,20 @@
+class Test {
+
+ interface IntMapper {
+ int map();
+ }
+
+ interface LongMapper {
+ long map();
+ }
+
+ void m(IntMapper im1, IntMapper... im) { }
+ void m(LongMapper... lm) { }
+
+ {
+ m<error descr="Ambiguous method call: both 'Test.m(IntMapper, IntMapper...)' and 'Test.m(LongMapper...)' match">(this ::ii)</error>;
+ }
+
+ int ii() {return 0;}
+
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/ExactMethodReferencePertinentToApplicabilityCheck.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/ExactMethodReferencePertinentToApplicabilityCheck.java
new file mode 100644
index 000000000000..c76e109aa0ff
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/ExactMethodReferencePertinentToApplicabilityCheck.java
@@ -0,0 +1,30 @@
+
+import java.util.*;
+
+class Test {
+ {
+ List<UnaryOperator<String>> a = asList(String::intern);
+ }
+
+ public static <Ta> List<Ta> asList(Ta a) {
+ return null;
+ }
+
+ interface UnaryOperator<T> {
+ T apply(T t);
+ }
+}
+
+class TestVarargs {
+ {
+ List<UnaryOperator<String>> a = asList(String::intern);
+ }
+
+ public static <Ta> List<Ta> asList(Ta... a) {
+ return null;
+ }
+
+ interface UnaryOperator<T> {
+ T apply(T t);
+ }
+} \ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/RawInnerClassQualifier.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/RawInnerClassQualifier.java
new file mode 100644
index 000000000000..25b85d7de9a9
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/RawInnerClassQualifier.java
@@ -0,0 +1,26 @@
+import java.util.Collections;
+import java.util.Map;
+import java.util.Optional;
+
+
+class StreamMain {
+ public static void main(final String... args) {
+ x(Collections.<Integer, String>emptyMap().entrySet().stream().
+ filter(entry -> 0 == entry.getKey() % 2).
+ findFirst().
+ map(Map.Entry::getValue).
+ orElse("Bob!"), true);
+ }
+
+ public static void x(final String s, final boolean b) {
+ System.out.println(s);
+ }
+}
+
+class StreamMainSimplified {
+ public static void main(Optional<Map.Entry<Integer, String>> first) {
+ String s = first.map(Map.Entry::getValue).orElse("Bob!");
+ String s1 = first.map((e) -> e.getValue()).orElse("Bob!");
+ }
+
+} \ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/SuperClassPotentiallyApplicableMembers.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/SuperClassPotentiallyApplicableMembers.java
new file mode 100644
index 000000000000..d9f05fb8a075
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/SuperClassPotentiallyApplicableMembers.java
@@ -0,0 +1,39 @@
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+interface Base {
+ int getInt(String a);
+ int getInt();
+
+ void foo();
+}
+
+abstract class ABase implements Base {
+ @Override
+ public int getInt(String a) {
+ return 0;
+ }
+
+ @Override
+ public int getInt() {
+ return 0;
+ }
+}
+
+class Impl extends ABase {
+ @Override
+ public int getInt() {
+ return 0;
+ }
+
+ @Override
+ public void foo() {
+ List<String> strs = Arrays.asList("one", "two");
+
+ List<Integer> withMethodRef = strs
+ .stream()
+ .map(this::getInt)
+ .collect( Collectors.toList());
+ }
+} \ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/afterConflict.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/afterConflict.java
deleted file mode 100644
index fe1cbb4cfcf2..000000000000
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/afterConflict.java
+++ /dev/null
@@ -1,15 +0,0 @@
-// "Add on demand static import for 'test.Bar'" "true"
-package test;
-
-import static test.Bar.*;
-
-class Bar {
- public static final void f() {}
-}
-public class Foo {
- public static final void f(int i) {}
-
- {
- <caret>Bar.f(); // invoke 'add on demand static import' for Bar class here. The call is now done to other method.
- }
-} \ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/afterImportPresent.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/afterImportPresent.java
new file mode 100644
index 000000000000..3da923ad88c8
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/afterImportPresent.java
@@ -0,0 +1,10 @@
+// "Add on demand static import for 'java.lang.Math'" "true"
+package test;
+
+import static java.lang.Math.*;
+import static java.lang.Math.abs;
+
+public class C {{
+ abs(1.0);
+ max(1, 2);
+}} \ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/afterImportPresent2.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/afterImportPresent2.java
new file mode 100644
index 000000000000..987661ba26bd
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/afterImportPresent2.java
@@ -0,0 +1,9 @@
+// "Add on demand static import for 'java.lang.Math'" "true"
+package test;
+
+import static java.lang.Math.*;
+
+public class C {{
+ abs(1.0);
+ max(1, 2);
+}} \ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/afterOwnMember.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/afterOwnMember.java
new file mode 100644
index 000000000000..926689ce7891
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/afterOwnMember.java
@@ -0,0 +1,10 @@
+// "Add on demand static import for 'test.Foo'" "true"
+package test;
+
+class Foo {
+ public static void m() {}
+
+ public static void main(String[] args) {
+ m();
+ }
+} \ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/afterSingleImportPresent.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/afterSingleImportPresent.java
new file mode 100644
index 000000000000..aeb54782cd2c
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/afterSingleImportPresent.java
@@ -0,0 +1,8 @@
+// "Add static import for 'java.lang.Math.abs'" "true"
+package test;
+
+import static java.lang.Math.abs;
+
+public class X {{
+ abs(1.0);
+}} \ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/afterSingleIncompleteCode.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/afterSingleIncompleteCode.java
new file mode 100644
index 000000000000..b0b13008d588
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/afterSingleIncompleteCode.java
@@ -0,0 +1,8 @@
+// "Add static import for 'java.lang.Math.abs'" "true"
+package test;
+
+import static java.lang.Math.abs;
+
+class X {{
+ abs();
+}} \ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/afterSingleMethod.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/afterSingleMethod.java
deleted file mode 100644
index 7a212101e730..000000000000
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/afterSingleMethod.java
+++ /dev/null
@@ -1,14 +0,0 @@
-// "Add static import for 'test.Bar.f'" "true"
-package test;
-
-import static test.Bar.f;
-
-class Bar {
- public static final void f() {}
-}
-public class Foo {
- public static final void f(int i) {}
- {
- Bar.<caret>f();
- }
-} \ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/afterSingleSuperMethod.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/afterSingleSuperMethod.java
deleted file mode 100644
index f408a05c9e60..000000000000
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/afterSingleSuperMethod.java
+++ /dev/null
@@ -1,17 +0,0 @@
-// "Add static import for 'test.Bar.f'" "true"
-package test;
-
-import static test.Bar.f;
-
-class Bar {
- public static final void f() {}
-}
-public class Foo extends FooSuper{
- {
- Bar.<caret>f();
- }
-}
-
-class FooSuper {
- public static final void f(int i) {}
-} \ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/beforeConflict.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/beforeConflict.java
index 09af9dce48f1..e9da55cac8ff 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/beforeConflict.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/beforeConflict.java
@@ -1,4 +1,4 @@
-// "Add on demand static import for 'test.Bar'" "true"
+// "Add on demand static import for 'test.Bar'" "false"
package test;
class Bar {
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/beforeImportPresent.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/beforeImportPresent.java
new file mode 100644
index 000000000000..9a8cb7547c2e
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/beforeImportPresent.java
@@ -0,0 +1,9 @@
+// "Add on demand static import for 'java.lang.Math'" "true"
+package test;
+
+import static java.lang.Math.abs;
+
+public class C {{
+ abs(1.0);
+ <caret>Math.max(1, 2);
+}} \ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/beforeImportPresent2.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/beforeImportPresent2.java
new file mode 100644
index 000000000000..6ba0ba6a840d
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/beforeImportPresent2.java
@@ -0,0 +1,9 @@
+// "Add on demand static import for 'java.lang.Math'" "true"
+package test;
+
+import static java.lang.Math.*;
+
+public class C {{
+ abs(1.0);
+ <caret>Math.max(1, 2);
+}} \ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/beforeOwnMember.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/beforeOwnMember.java
new file mode 100644
index 000000000000..fba407683654
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/beforeOwnMember.java
@@ -0,0 +1,10 @@
+// "Add on demand static import for 'test.Foo'" "true"
+package test;
+
+class Foo {
+ public static void m() {}
+
+ public static void main(String[] args) {
+ Foo<caret>.m();
+ }
+} \ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/beforeSingleImportPresent.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/beforeSingleImportPresent.java
new file mode 100644
index 000000000000..1636ec79b66e
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/beforeSingleImportPresent.java
@@ -0,0 +1,8 @@
+// "Add static import for 'java.lang.Math.abs'" "true"
+package test;
+
+import static java.lang.Math.abs;
+
+public class X {{
+ Math.abs<caret>(1.0);
+}} \ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/beforeSingleIncompleteCode.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/beforeSingleIncompleteCode.java
new file mode 100644
index 000000000000..462713c98f66
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/beforeSingleIncompleteCode.java
@@ -0,0 +1,6 @@
+// "Add static import for 'java.lang.Math.abs'" "true"
+package test;
+
+class X {{
+ Math.abs<caret>();
+}} \ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/beforeSingleMethod.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/beforeSingleMethod.java
index e199b822fbee..db823f144fe3 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/beforeSingleMethod.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/beforeSingleMethod.java
@@ -1,4 +1,4 @@
-// "Add static import for 'test.Bar.f'" "true"
+// "Add static import for 'test.Bar.f'" "false"
package test;
class Bar {
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/beforeSingleSuperMethod.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/beforeSingleSuperMethod.java
index e6cdb19c0d79..bfa85a2dca1e 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/beforeSingleSuperMethod.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addOnDemandStaticImport/beforeSingleSuperMethod.java
@@ -1,4 +1,4 @@
-// "Add static import for 'test.Bar.f'" "true"
+// "Add static import for 'test.Bar.f'" "false"
package test;
class Bar {
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addToThrows/afterLambdaInternal.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addToThrows/afterLambdaInternal.java
new file mode 100644
index 000000000000..056c098fcf7e
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addToThrows/afterLambdaInternal.java
@@ -0,0 +1,12 @@
+// "Add Exception to Method Signature" "true"
+class C {
+ interface I {
+ void a() throws InterruptedException;
+ }
+
+ {
+ I i = () -> {
+ Thread.sleep(2000);
+ };
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addToThrows/beforeLambdaExternal.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addToThrows/beforeLambdaExternal.java
new file mode 100644
index 000000000000..5aac457b22ef
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addToThrows/beforeLambdaExternal.java
@@ -0,0 +1,9 @@
+// "Add Exception to Method Signature" "false"
+class C {
+
+ public static void main(String[] args) throws InterruptedException {
+ new Thread(( ) -> {
+ Thread.sl<caret>eep(2000);
+ }).start();
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addToThrows/beforeLambdaInternal.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addToThrows/beforeLambdaInternal.java
new file mode 100644
index 000000000000..9c62d2b6cff1
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addToThrows/beforeLambdaInternal.java
@@ -0,0 +1,12 @@
+// "Add Exception to Method Signature" "true"
+class C {
+ interface I {
+ void a();
+ }
+
+ {
+ I i = () -> {
+ Thread.sl<caret>eep(2000);
+ };
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/afterTypeAnnoArray.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/afterTypeAnnoArray.java
index 659a3bb0b844..dc9c06ca5329 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/afterTypeAnnoArray.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/afterTypeAnnoArray.java
@@ -7,6 +7,6 @@ import static java.lang.annotation.ElementType.*;
class C {
{
Object o = null;
- @TA int @TA [] a = (@TA int @TA[]) o;
+ @TA int @TA [] a = (int[]) o;
}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/afterTypeAnnoPrimitive.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/afterTypeAnnoPrimitive.java
deleted file mode 100644
index 8cd2a01d46e8..000000000000
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/afterTypeAnnoPrimitive.java
+++ /dev/null
@@ -1,12 +0,0 @@
-// "Cast to 'int'" "true"
-import java.lang.annotation.*;
-import static java.lang.annotation.ElementType.*;
-
-@Target({TYPE_USE}) @interface TA { }
-
-class C {
- {
- Object o = null;
- @TA <caret>int i = (@TA int) o;
- }
-}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/afterTypeAnnoRefType.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/afterTypeAnnoRefType.java
index 28420d1f46ea..d1b92436866a 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/afterTypeAnnoRefType.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/afterTypeAnnoRefType.java
@@ -1,5 +1,6 @@
-// "Cast to 'java.lang.Integer'" "true"
+// "Cast to 'java.util.List<java.lang.Integer>'" "true"
import java.lang.annotation.*;
+import java.util.*;
import static java.lang.annotation.ElementType.*;
@Target({TYPE_USE}) @interface TA { }
@@ -7,6 +8,6 @@ import static java.lang.annotation.ElementType.*;
class C {
{
Object o = null;
- @TA <caret>Integer i = (@TA Integer) o;
+ @TA List<@TA Integer> i = (List<Integer>) o;
}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/afterTypeAnnoTypeParam.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/afterTypeAnnoTypeParam.java
deleted file mode 100644
index 6fa421e10993..000000000000
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/afterTypeAnnoTypeParam.java
+++ /dev/null
@@ -1,13 +0,0 @@
-// "Cast to 'java.util.List<java.lang.String>'" "true"
-import java.lang.annotation.*;
-import java.util.List;
-import static java.lang.annotation.ElementType.*;
-
-@Target({TYPE_USE}) @interface TA { }
-
-class C {
- {
- Object o = null;
- @TA <caret>List<@TA String> l = (@TA List<@TA String>) o;
- }
-}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/afterTypeAnnoValued.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/afterTypeAnnoValued.java
deleted file mode 100644
index bfedf89bc35f..000000000000
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/afterTypeAnnoValued.java
+++ /dev/null
@@ -1,12 +0,0 @@
-// "Cast to 'int'" "true"
-import java.lang.annotation.*;
-import static java.lang.annotation.ElementType.*;
-
-@Target({TYPE_USE}) @interface TA { String value() default ""; }
-
-class C {
- {
- Object o = null;
- @TA("wtf") <caret>int i = (@TA("wtf") int) o;
- }
-}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/afterTypeAnnoWildcard.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/afterTypeAnnoWildcard.java
deleted file mode 100644
index a114746c145d..000000000000
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/afterTypeAnnoWildcard.java
+++ /dev/null
@@ -1,13 +0,0 @@
-// "Cast to 'java.util.List<? extends java.lang.String>'" "true"
-import java.lang.annotation.*;
-import java.util.List;
-import static java.lang.annotation.ElementType.*;
-
-@Target({TYPE_USE}) @interface TA { }
-
-class C {
- {
- Object o = null;
- @TA List<@TA ? extends @TA String> l = (@TA List<@TA ? extends @TA String>) o;
- }
-}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/beforeTypeAnnoPrimitive.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/beforeTypeAnnoPrimitive.java
deleted file mode 100644
index 5d17c26ca97a..000000000000
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/beforeTypeAnnoPrimitive.java
+++ /dev/null
@@ -1,12 +0,0 @@
-// "Cast to 'int'" "true"
-import java.lang.annotation.*;
-import static java.lang.annotation.ElementType.*;
-
-@Target({TYPE_USE}) @interface TA { }
-
-class C {
- {
- Object o = null;
- @TA <caret>int i = o;
- }
-}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/beforeTypeAnnoRefType.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/beforeTypeAnnoRefType.java
index 7948738bb264..7c95d5eae896 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/beforeTypeAnnoRefType.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/beforeTypeAnnoRefType.java
@@ -1,5 +1,6 @@
-// "Cast to 'java.lang.Integer'" "true"
+// "Cast to 'java.util.List<java.lang.Integer>'" "true"
import java.lang.annotation.*;
+import java.util.*;
import static java.lang.annotation.ElementType.*;
@Target({TYPE_USE}) @interface TA { }
@@ -7,6 +8,6 @@ import static java.lang.annotation.ElementType.*;
class C {
{
Object o = null;
- @TA <caret>Integer i = o;
+ @TA <caret>List<@TA Integer> i = o;
}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/beforeTypeAnnoTypeParam.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/beforeTypeAnnoTypeParam.java
deleted file mode 100644
index 33b2d0be44da..000000000000
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/beforeTypeAnnoTypeParam.java
+++ /dev/null
@@ -1,13 +0,0 @@
-// "Cast to 'java.util.List<java.lang.String>'" "true"
-import java.lang.annotation.*;
-import java.util.List;
-import static java.lang.annotation.ElementType.*;
-
-@Target({TYPE_USE}) @interface TA { }
-
-class C {
- {
- Object o = null;
- @TA <caret>List<@TA String> l = o;
- }
-}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/beforeTypeAnnoValued.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/beforeTypeAnnoValued.java
deleted file mode 100644
index 726856c931b7..000000000000
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/beforeTypeAnnoValued.java
+++ /dev/null
@@ -1,12 +0,0 @@
-// "Cast to 'int'" "true"
-import java.lang.annotation.*;
-import static java.lang.annotation.ElementType.*;
-
-@Target({TYPE_USE}) @interface TA { String value() default ""; }
-
-class C {
- {
- Object o = null;
- @TA("wtf") <caret>int i = o;
- }
-}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/beforeTypeAnnoWildcard.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/beforeTypeAnnoWildcard.java
deleted file mode 100644
index 84a9df6fad0a..000000000000
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addTypeCast/beforeTypeAnnoWildcard.java
+++ /dev/null
@@ -1,13 +0,0 @@
-// "Cast to 'java.util.List<? extends java.lang.String>'" "true"
-import java.lang.annotation.*;
-import java.util.List;
-import static java.lang.annotation.ElementType.*;
-
-@Target({TYPE_USE}) @interface TA { }
-
-class C {
- {
- Object o = null;
- @TA <caret>List<@TA ? extends @TA String> l = o;
- }
-}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/implementMethods/afterTypeAnnotated.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/implementMethods/afterTypeAnnotated.java
new file mode 100644
index 000000000000..9e123de77cae
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/implementMethods/afterTypeAnnotated.java
@@ -0,0 +1,17 @@
+// "Implement Methods" "true"
+import java.lang.annotation.*;
+import java.util.*;
+
+@Target(ElementType.TYPE_USE)
+@interface TA { int value() default 0; }
+
+interface I {
+ @TA List<@TA String> i(@TA int p1, @TA(1) int @TA(2) [] p2 @TA(3) []) throws @TA IllegalArgumentException;
+}
+
+class C implements I {
+ @Override
+ public @TA List<@TA String> i(@TA int p1, @TA(1) int @TA(2) [] @TA(3) [] p2) throws @TA IllegalArgumentException {
+ return null;
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/implementMethods/beforeTypeAnnotated.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/implementMethods/beforeTypeAnnotated.java
new file mode 100644
index 000000000000..f19a1097082a
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/implementMethods/beforeTypeAnnotated.java
@@ -0,0 +1,13 @@
+// "Implement Methods" "true"
+import java.lang.annotation.*;
+import java.util.*;
+
+@Target(ElementType.TYPE_USE)
+@interface TA { int value() default 0; }
+
+interface I {
+ @TA List<@TA String> i(@TA int p1, @TA(1) int @TA(2) [] p2 @TA(3) []) throws @TA IllegalArgumentException;
+}
+
+<caret>class C implements I {
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/orderEntry/A/src/x/DoTest.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/orderEntry/A/src/x/DoTest.java
index 2421a3518dbe..8c5e48133c24 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/orderEntry/A/src/x/DoTest.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/orderEntry/A/src/x/DoTest.java
@@ -1,4 +1,4 @@
-// "Add 'junit.jar' to classpath" "true"
+// "Add junit to classpath" "true"
package x;
public class DoTest extends TestCase<caret>{
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/orderEntry/A/src/x/DoTest4.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/orderEntry/A/src/x/DoTest4.java
index 9856b2d9b0f3..6747302b815b 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/orderEntry/A/src/x/DoTest4.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/orderEntry/A/src/x/DoTest4.java
@@ -1,4 +1,4 @@
-// "Add 'junit.jar' to classpath" "true"
+// "Add junit to classpath" "true"
package x;
public class DoTest4 {
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/orderEntry/A/src/x/DoTest4junit.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/orderEntry/A/src/x/DoTest4junit.java
index 8a776a67fffd..d196e93cb9ea 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/orderEntry/A/src/x/DoTest4junit.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/orderEntry/A/src/x/DoTest4junit.java
@@ -1,4 +1,4 @@
-// "Add 'junit.jar' to classpath" "true"
+// "Add junit to classpath" "true"
package x;
public class DoTest4junit {
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterCollectArrayListComment.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterCollectArrayListComment.java
new file mode 100644
index 000000000000..a9b24a5a2005
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterCollectArrayListComment.java
@@ -0,0 +1,16 @@
+// "Replace with collect" "true"
+import java.util.*;
+import java.util.stream.Collectors;
+
+public class Collect {
+ class Person {
+ String getName() {
+ return "";
+ }
+ }
+
+ void collectNames(List<Person> persons){
+ List<String> names = persons.stream().map(Person::getName).collect(Collectors.toList());
+ //some comment
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterCollectArrayListNonTrivialInitializer.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterCollectArrayListNonTrivialInitializer.java
new file mode 100644
index 000000000000..641617eb642b
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterCollectArrayListNonTrivialInitializer.java
@@ -0,0 +1,20 @@
+// "Replace with collect" "true"
+import java.util.*;
+import java.util.stream.Collectors;
+
+public class Collect {
+ class Person {
+ String getName() {
+ return "";
+ }
+ }
+
+ ArrayList<String> foo() {
+ return new ArrayList<>();
+ }
+
+ void collectNames(List<Person> persons){
+ List<String> names = foo();
+ names.addAll(persons.stream().map(Person::getName).collect(Collectors.toList()));
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterNormalComments.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterNormalComments.java
new file mode 100644
index 000000000000..c1bbf0a0924b
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterNormalComments.java
@@ -0,0 +1,11 @@
+// "Replace with forEach" "true"
+import java.util.ArrayList;
+import java.util.List;
+
+class Sample {
+ List<String> foo = new ArrayList<>();
+ {
+ //some comment
+ foo.forEach(System.out::println);
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeCollectArrayListComment.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeCollectArrayListComment.java
new file mode 100644
index 000000000000..c26fa6954bd6
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeCollectArrayListComment.java
@@ -0,0 +1,18 @@
+// "Replace with collect" "true"
+import java.util.*;
+
+public class Collect {
+ class Person {
+ String getName() {
+ return "";
+ }
+ }
+
+ void collectNames(List<Person> persons){
+ List<String> names = new ArrayList<>();
+ for (Person person : pers<caret>ons) {
+ //some comment
+ names.add(person.getName());
+ }
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeCollectArrayListNonTrivialInitializer.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeCollectArrayListNonTrivialInitializer.java
new file mode 100644
index 000000000000..6a276c0033ce
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeCollectArrayListNonTrivialInitializer.java
@@ -0,0 +1,21 @@
+// "Replace with collect" "true"
+import java.util.*;
+
+public class Collect {
+ class Person {
+ String getName() {
+ return "";
+ }
+ }
+
+ ArrayList<String> foo() {
+ return new ArrayList<>();
+ }
+
+ void collectNames(List<Person> persons){
+ List<String> names = foo();
+ for (Person person : pers<caret>ons) {
+ names.add(person.getName());
+ }
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeNormalComments.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeNormalComments.java
new file mode 100644
index 000000000000..f394dd7d9696
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeNormalComments.java
@@ -0,0 +1,13 @@
+// "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) {
+ //some comment
+ System.out.println(s);
+ }
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/template/postfix/templates/cast/insideString.java b/java/java-tests/testData/codeInsight/template/postfix/templates/cast/insideString.java
new file mode 100644
index 000000000000..8e2d4d8e59cb
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/template/postfix/templates/cast/insideString.java
@@ -0,0 +1,5 @@
+public class Foo {
+ void m(Object o) {
+ Integer string = (Integer.parseInt("test.test.cast<caret>"));
+ }
+} \ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/template/postfix/templates/cast/insideString_after.java b/java/java-tests/testData/codeInsight/template/postfix/templates/cast/insideString_after.java
new file mode 100644
index 000000000000..f51c17698074
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/template/postfix/templates/cast/insideString_after.java
@@ -0,0 +1,5 @@
+public class Foo {
+ void m(Object o) {
+ Integer string = (Integer.parseInt("test.test.cast <caret>"));
+ }
+} \ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/template/postfix/templates/cast/singleArgument.java b/java/java-tests/testData/codeInsight/template/postfix/templates/cast/singleArgument.java
new file mode 100644
index 000000000000..29bd8830d679
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/template/postfix/templates/cast/singleArgument.java
@@ -0,0 +1,5 @@
+public class Foo {
+ void m(Object o) {
+ Integer string = (Integer.parseInt("test.test".cast<caret>));
+ }
+} \ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/template/postfix/templates/cast/singleArgument_after.java b/java/java-tests/testData/codeInsight/template/postfix/templates/cast/singleArgument_after.java
new file mode 100644
index 000000000000..61720cad312a
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/template/postfix/templates/cast/singleArgument_after.java
@@ -0,0 +1,5 @@
+public class Foo {
+ void m(Object o) {
+ Integer string = (Integer.parseInt((() "test.test")<caret>));
+ }
+} \ No newline at end of file
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/ComparingToNullableShouldNotAffectNullity.java b/java/java-tests/testData/inspection/dataFlow/fixture/ComparingToNullableShouldNotAffectNullity.java
new file mode 100644
index 000000000000..c57e9696bd5f
--- /dev/null
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/ComparingToNullableShouldNotAffectNullity.java
@@ -0,0 +1,15 @@
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Collection;
+
+class Bar3 {
+
+ public void main2(Object o1, Object o2) {
+ if (o1 == null) {
+ System.out.println();
+ }
+ if (o1 != o2 || o2.hashCode() == 3) {
+
+ }
+ }
+} \ No newline at end of file
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/GettersAndPureNoFlushing.java b/java/java-tests/testData/inspection/dataFlow/fixture/GettersAndPureNoFlushing.java
new file mode 100644
index 000000000000..bab8354ee7b4
--- /dev/null
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/GettersAndPureNoFlushing.java
@@ -0,0 +1,31 @@
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.Nullable;
+
+class Doo {
+
+ @Nullable
+ Object getMethod() {return null;}
+
+ boolean isSomething() { return false;}
+
+ @Contract(pure=true)
+ boolean pureSomething() { return false;}
+
+ public void main2() {
+ if (getMethod() == null && !isSomething()) {
+ return;
+ } else {
+ System.out.println(<warning descr="Method invocation 'getMethod().hashCode()' may produce 'java.lang.NullPointerException'">getMethod().hashCode()</warning>);
+ }
+ }
+
+ public void main3() {
+ if (getMethod() == null && !pureSomething()) {
+ return;
+ } else {
+ System.out.println(<warning descr="Method invocation 'getMethod().hashCode()' may produce 'java.lang.NullPointerException'">getMethod().hashCode()</warning>);
+ }
+ }
+
+}
+
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/SameComparisonTwice.java b/java/java-tests/testData/inspection/dataFlow/fixture/SameComparisonTwice.java
new file mode 100644
index 000000000000..52abf5b39e46
--- /dev/null
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/SameComparisonTwice.java
@@ -0,0 +1,38 @@
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.Nullable;
+
+class Doo {
+
+ static final int TYPE_1 = 20;
+ static final int TYPE_2 = 20;
+
+ public static void failedSecondCondition(int type) {
+ if(type != TYPE_1) {
+ return;
+ }
+
+ if(<warning descr="Condition 'type != TYPE_2' is always 'false'">type != TYPE_2</warning>) {
+ System.out.println();
+ }
+ }
+
+
+}
+
+class Doo2 {
+
+ static final int TYPE_1 = 200;
+ static final int TYPE_2 = 200;
+
+ public static void failedSecondCondition(int type) {
+ if(type != TYPE_1) {
+ return;
+ }
+
+ if(<warning descr="Condition 'type != TYPE_2' is always 'false'">type != TYPE_2</warning>) {
+ System.out.println();
+ }
+ }
+
+
+}
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/UnusedCallDoesNotMakeUnknown.java b/java/java-tests/testData/inspection/dataFlow/fixture/UnusedCallDoesNotMakeUnknown.java
new file mode 100644
index 000000000000..288cc07a51b1
--- /dev/null
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/UnusedCallDoesNotMakeUnknown.java
@@ -0,0 +1,14 @@
+import org.jetbrains.annotations.Nullable;
+
+class Doo {
+
+ @Nullable
+ Object getMethod() {
+ return null;
+ }
+
+ public void main(String[] args) {
+ Object method = getMethod();
+ System.out.println(<warning descr="Method invocation 'getMethod().hashCode()' may produce 'java.lang.NullPointerException'">getMethod().hashCode()</warning>);
+ }
+} \ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/introduceParameter/afterTypeAnnotation.java b/java/java-tests/testData/refactoring/introduceParameter/afterTypeAnnotation.java
new file mode 100644
index 000000000000..a14b989bbc89
--- /dev/null
+++ b/java/java-tests/testData/refactoring/introduceParameter/afterTypeAnnotation.java
@@ -0,0 +1,14 @@
+import java.lang.annotation.*;
+
+@Target(value = ElementType.TYPE_USE)
+public @interface TA { }
+
+class Test {
+ void m(@TA String anObject) {
+ System.out.println(anObject);
+ }
+
+ void use() {
+ m("smth");
+ }
+} \ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/introduceParameter/beforeTypeAnnotation.java b/java/java-tests/testData/refactoring/introduceParameter/beforeTypeAnnotation.java
new file mode 100644
index 000000000000..949419221d40
--- /dev/null
+++ b/java/java-tests/testData/refactoring/introduceParameter/beforeTypeAnnotation.java
@@ -0,0 +1,15 @@
+import java.lang.annotation.*;
+
+@Target(value = ElementType.TYPE_USE)
+public @interface TA { }
+
+class Test {
+ void m() {
+ @TA String <caret>v = "smth";
+ System.out.println(v);
+ }
+
+ void use() {
+ m();
+ }
+} \ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/renameInplace/NameSuggestion.java b/java/java-tests/testData/refactoring/renameInplace/NameSuggestion.java
new file mode 100644
index 000000000000..947f2728a872
--- /dev/null
+++ b/java/java-tests/testData/refactoring/renameInplace/NameSuggestion.java
@@ -0,0 +1,7 @@
+class MyTest {
+
+ static class Foo {
+ }
+
+ static Foo get<caret>_i() { return null; }
+} \ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/renameInplace/NameSuggestion_after.java b/java/java-tests/testData/refactoring/renameInplace/NameSuggestion_after.java
new file mode 100644
index 000000000000..dd78c8b995ea
--- /dev/null
+++ b/java/java-tests/testData/refactoring/renameInplace/NameSuggestion_after.java
@@ -0,0 +1,7 @@
+class MyTest {
+
+ static class Foo {
+ }
+
+ static Foo getI() { return null; }
+} \ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/wrapReturnValue/generics/after/Wrapper.java b/java/java-tests/testData/refactoring/wrapReturnValue/generics/after/Wrapper.java
index 0b351ee1aee6..79bfc1a8ede3 100644
--- a/java/java-tests/testData/refactoring/wrapReturnValue/generics/after/Wrapper.java
+++ b/java/java-tests/testData/refactoring/wrapReturnValue/generics/after/Wrapper.java
@@ -5,9 +5,7 @@ public class Wrapper<T> {
this.value = value;
}
-
public T getValue() {
return value;
}
-
}
diff --git a/java/java-tests/testData/refactoring/wrapReturnValue/hierarchy/after/Test.java b/java/java-tests/testData/refactoring/wrapReturnValue/hierarchy/after/Test.java
index a7c2a2dad00e..2cb2b1e94530 100644
--- a/java/java-tests/testData/refactoring/wrapReturnValue/hierarchy/after/Test.java
+++ b/java/java-tests/testData/refactoring/wrapReturnValue/hierarchy/after/Test.java
@@ -1,5 +1,5 @@
abstract class Test {
- abstract Wrapper foo();
+ abstract Wrapper foo();
public class Wrapper {
private final String value;
@@ -8,10 +8,8 @@ abstract class Test {
this.value = value;
}
-
public String getValue() {
return value;
}
-
}
} \ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/wrapReturnValue/hierarchy/before/Test.java b/java/java-tests/testData/refactoring/wrapReturnValue/hierarchy/before/Test.java
index 5b11736b28d4..e883ab1004fa 100644
--- a/java/java-tests/testData/refactoring/wrapReturnValue/hierarchy/before/Test.java
+++ b/java/java-tests/testData/refactoring/wrapReturnValue/hierarchy/before/Test.java
@@ -1,3 +1,3 @@
abstract class Test {
- abstract String foo();
+ abstract String foo();
} \ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/wrapReturnValue/innerClass/after/Test.java b/java/java-tests/testData/refactoring/wrapReturnValue/innerClass/after/Test.java
index 59509c2700b8..4d933a44c247 100644
--- a/java/java-tests/testData/refactoring/wrapReturnValue/innerClass/after/Test.java
+++ b/java/java-tests/testData/refactoring/wrapReturnValue/innerClass/after/Test.java
@@ -1,11 +1,11 @@
class Test {
Wrapper foo() {
- return new Wrapper("");
- }
+ return new Wrapper("");
+ }
- void bar() {
- String s = foo().getValue();
- }
+ void bar() {
+ String s = foo().getValue();
+ }
public class Wrapper {
private final String value;
@@ -14,10 +14,8 @@ class Test {
this.value = value;
}
-
public String getValue() {
return value;
}
-
}
} \ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/wrapReturnValue/innerClass/before/Test.java b/java/java-tests/testData/refactoring/wrapReturnValue/innerClass/before/Test.java
index 029bda94dc51..7d4f5f239652 100644
--- a/java/java-tests/testData/refactoring/wrapReturnValue/innerClass/before/Test.java
+++ b/java/java-tests/testData/refactoring/wrapReturnValue/innerClass/before/Test.java
@@ -1,9 +1,9 @@
class Test {
- String foo() {
- return "";
- }
+ String foo() {
+ return "";
+ }
- void bar() {
- String s = foo();
- }
+ void bar() {
+ String s = foo();
+ }
} \ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/wrapReturnValue/returnInsideLambda/after/Test.java b/java/java-tests/testData/refactoring/wrapReturnValue/returnInsideLambda/after/Test.java
index f74dbb90ad34..541d37adb883 100644
--- a/java/java-tests/testData/refactoring/wrapReturnValue/returnInsideLambda/after/Test.java
+++ b/java/java-tests/testData/refactoring/wrapReturnValue/returnInsideLambda/after/Test.java
@@ -1,9 +1,9 @@
class Test {
Wrapper foo() {
- return new Wrapper((o) -> {
- return 0;
- });
- }
+ return new Wrapper((o) -> {
+ return 0;
+ });
+ }
public class Wrapper {
private final Comparable<String> value;
@@ -12,10 +12,8 @@ class Test {
this.value = value;
}
-
public Comparable<String> getValue() {
return value;
}
-
}
} \ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/wrapReturnValue/returnInsideLambda/before/Test.java b/java/java-tests/testData/refactoring/wrapReturnValue/returnInsideLambda/before/Test.java
index bbc57c1c8095..e8936135daa4 100644
--- a/java/java-tests/testData/refactoring/wrapReturnValue/returnInsideLambda/before/Test.java
+++ b/java/java-tests/testData/refactoring/wrapReturnValue/returnInsideLambda/before/Test.java
@@ -1,7 +1,7 @@
class Test {
- Comparable<String> foo() {
- return (o) -> {
- return 0;
- };
- }
+ Comparable<String> foo() {
+ return (o) -> {
+ return 0;
+ };
+ }
} \ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/wrapReturnValue/simple/after/Wrapper.java b/java/java-tests/testData/refactoring/wrapReturnValue/simple/after/Wrapper.java
index 35fba31a1e74..f41758e35766 100644
--- a/java/java-tests/testData/refactoring/wrapReturnValue/simple/after/Wrapper.java
+++ b/java/java-tests/testData/refactoring/wrapReturnValue/simple/after/Wrapper.java
@@ -5,9 +5,7 @@ public class Wrapper {
this.value = value;
}
-
public String getValue() {
return value;
}
-
}
diff --git a/java/java-tests/testData/refactoring/wrapReturnValue/staticMethodInnerClass/after/Test.java b/java/java-tests/testData/refactoring/wrapReturnValue/staticMethodInnerClass/after/Test.java
index 035212c0a74e..810e741d28b4 100644
--- a/java/java-tests/testData/refactoring/wrapReturnValue/staticMethodInnerClass/after/Test.java
+++ b/java/java-tests/testData/refactoring/wrapReturnValue/staticMethodInnerClass/after/Test.java
@@ -1,11 +1,11 @@
class Test {
- static Wrapper foo() {
- return new Wrapper("");
- }
+ static Wrapper foo() {
+ return new Wrapper("");
+ }
- void bar() {
- String s = foo().getValue();
- }
+ void bar() {
+ String s = foo().getValue();
+ }
public static class Wrapper {
private final String value;
@@ -14,10 +14,8 @@ class Test {
this.value = value;
}
-
public String getValue() {
return value;
}
-
}
} \ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/wrapReturnValue/staticMethodInnerClass/before/Test.java b/java/java-tests/testData/refactoring/wrapReturnValue/staticMethodInnerClass/before/Test.java
index d406379d1e43..9dc5783d11f5 100644
--- a/java/java-tests/testData/refactoring/wrapReturnValue/staticMethodInnerClass/before/Test.java
+++ b/java/java-tests/testData/refactoring/wrapReturnValue/staticMethodInnerClass/before/Test.java
@@ -1,9 +1,9 @@
class Test {
- static String foo() {
- return "";
- }
+ static String foo() {
+ return "";
+ }
- void bar() {
- String s = foo();
- }
+ void bar() {
+ String s = foo();
+ }
} \ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/wrapReturnValue/typeAnnotations/after/Test.java b/java/java-tests/testData/refactoring/wrapReturnValue/typeAnnotations/after/Test.java
new file mode 100644
index 000000000000..894943706ffd
--- /dev/null
+++ b/java/java-tests/testData/refactoring/wrapReturnValue/typeAnnotations/after/Test.java
@@ -0,0 +1,10 @@
+import java.lang.annotation.*;
+
+@Target({ElementType.TYPE_USE})
+@interface TA { }
+
+class Test {
+ Wrapper foo() {
+ return new Wrapper(null);
+ }
+} \ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/wrapReturnValue/typeAnnotations/after/Wrapper.java b/java/java-tests/testData/refactoring/wrapReturnValue/typeAnnotations/after/Wrapper.java
new file mode 100644
index 000000000000..754c77ab22c4
--- /dev/null
+++ b/java/java-tests/testData/refactoring/wrapReturnValue/typeAnnotations/after/Wrapper.java
@@ -0,0 +1,13 @@
+import java.util.List;
+
+public class Wrapper {
+ private final List<String> value;
+
+ public Wrapper(@TA List<@TA String> value) {
+ this.value = value;
+ }
+
+ public @TA List<@TA String> getValue() {
+ return value;
+ }
+}
diff --git a/java/java-tests/testData/refactoring/wrapReturnValue/typeAnnotations/before/Test.java b/java/java-tests/testData/refactoring/wrapReturnValue/typeAnnotations/before/Test.java
new file mode 100644
index 000000000000..3fc443dad610
--- /dev/null
+++ b/java/java-tests/testData/refactoring/wrapReturnValue/typeAnnotations/before/Test.java
@@ -0,0 +1,11 @@
+import java.lang.annotation.*;
+import java.util.*;
+
+@Target({ElementType.TYPE_USE})
+@interface TA { }
+
+class Test {
+ @TA List<@TA String> foo() {
+ return null;
+ }
+} \ No newline at end of file
diff --git a/java/debugger/openapi/src/com/intellij/debugger/PositionManagerEx.java b/java/java-tests/testSrc/com/intellij/codeInsight/ClsGenerics15HighlightingTest.java
index c1faee1f763f..36533d72893d 100644
--- a/java/debugger/openapi/src/com/intellij/debugger/PositionManagerEx.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/ClsGenerics15HighlightingTest.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,14 +13,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.intellij.debugger;
-import com.intellij.xdebugger.frame.XStackFrame;
-import com.sun.jdi.Location;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
+package com.intellij.codeInsight;
-public abstract class PositionManagerEx implements PositionManager {
- @Nullable
- public abstract XStackFrame createStackFrame(@NotNull Location location);
+import com.intellij.pom.java.LanguageLevel;
+
+public class ClsGenerics15HighlightingTest extends ClsGenericsHighlightingTest {
+
+ @Override
+ protected LanguageLevel getLanguageLevel() {
+ return LanguageLevel.JDK_1_5;
+ }
+
+ public void testIDEA97887() { doTest(); }
+ public void testIDEA118733() { doTest(); }
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/ClsGenerics18HighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/ClsGenerics18HighlightingTest.java
new file mode 100644
index 000000000000..ae0ec20ab4d2
--- /dev/null
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/ClsGenerics18HighlightingTest.java
@@ -0,0 +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.codeInsight;
+
+import com.intellij.pom.java.LanguageLevel;
+
+public class ClsGenerics18HighlightingTest extends ClsGenericsHighlightingTest {
+ public void testIDEA121866() { doTest(); }
+
+ @Override
+ protected LanguageLevel getLanguageLevel() {
+ return LanguageLevel.JDK_1_8;
+ }
+}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/ClsGenericsHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/ClsGenericsHighlightingTest.java
index 3cf2a8392089..839d933437fc 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/ClsGenericsHighlightingTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/ClsGenericsHighlightingTest.java
@@ -14,10 +14,6 @@
* limitations under the License.
*/
-/*
- * User: anna
- * Date: 27-Jun-2007
- */
package com.intellij.codeInsight;
import com.intellij.openapi.application.ex.PathManagerEx;
@@ -31,6 +27,7 @@ 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.pom.java.LanguageLevel;
import com.intellij.testFramework.IdeaTestCase;
import com.intellij.testFramework.UsefulTestCase;
import com.intellij.testFramework.builders.JavaModuleFixtureBuilder;
@@ -38,7 +35,7 @@ import com.intellij.testFramework.fixtures.*;
import com.intellij.util.Consumer;
import org.jetbrains.annotations.NotNull;
-public class ClsGenericsHighlightingTest extends UsefulTestCase {
+public abstract class ClsGenericsHighlightingTest extends UsefulTestCase {
private CodeInsightTestFixture myFixture;
private Module myModule;
@@ -54,11 +51,13 @@ public class ClsGenericsHighlightingTest extends UsefulTestCase {
myFixture = JavaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(projectBuilder.getFixture());
myFixture.setTestDataPath(PathManagerEx.getTestDataPath() + "/codeInsight/clsHighlighting");
JavaModuleFixtureBuilder builder = projectBuilder.addModule(JavaModuleFixtureBuilder.class);
- builder.setMockJdkLevel(JavaModuleFixtureBuilder.MockJdkLevel.jdk15);
+ builder.setLanguageLevel(getLanguageLevel());
myFixture.setUp();
myModule = builder.getFixture().getModule();
}
+ protected abstract LanguageLevel getLanguageLevel();
+
@Override
protected void tearDown() throws Exception {
super.tearDown();
@@ -67,10 +66,7 @@ public class ClsGenericsHighlightingTest extends UsefulTestCase {
myModule = null;
}
- public void testIDEA97887() { doTest(); }
- public void testIDEA118733() { doTest(); }
-
- private void doTest() {
+ protected void doTest() {
String name = getTestName(false);
addLibrary(name + ".jar");
myFixture.configureByFile(name + ".java");
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/HippieCompletionTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/HippieCompletionTest.groovy
index 4cad78b0c467..7de79b533944 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/HippieCompletionTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/HippieCompletionTest.groovy
@@ -189,7 +189,16 @@ class Xoo {
class Xoo {
}
'''
+ }
+ public void "test cpp indirection"() {
+ myFixture.configureByText "a.c", '''f<caret>
+foo->bar
+'''
+ complete()
+ myFixture.checkResult '''foo<caret>
+foo->bar
+'''
}
private void complete() {
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 0b12b544bbfd..e626fd42b37f 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy
@@ -1179,36 +1179,36 @@ class Foo {{
}
private doTestMulticaret(final String textBefore, final String toType, final String textAfter) {
- EditorTestUtil.enableMultipleCarets()
+ myFixture.configureByText "a.java", textBefore
+ type 'toStr'
+ assert lookup
+ type toType
+ myFixture.checkResult textAfter
+ }
+
+ private doTestBlockSelection(final String textBefore, final String toType, final String textAfter) {
+ EditorTestUtil.disableMultipleCarets()
try {
myFixture.configureByText "a.java", textBefore
+ edt {
+ def caret = myFixture.editor.offsetToLogicalPosition(myFixture.editor.caretModel.offset)
+ myFixture.editor.selectionModel.setBlockSelection(caret, new LogicalPosition(caret.line + 1, caret.column + 1))
+ }
type 'toStr'
assert lookup
type toType
myFixture.checkResult textAfter
+ def start = myFixture.editor.selectionModel.blockStart
+ def end = myFixture.editor.selectionModel.blockEnd
+ assert start.line == end.line - 1
+ assert start.column == end.column
+ assert end == myFixture.editor.caretModel.logicalPosition
}
finally {
- EditorTestUtil.disableMultipleCarets()
+ EditorTestUtil.enableMultipleCarets()
}
}
- private doTestBlockSelection(final String textBefore, final String toType, final String textAfter) {
- myFixture.configureByText "a.java", textBefore
- edt {
- def caret = myFixture.editor.offsetToLogicalPosition(myFixture.editor.caretModel.offset)
- myFixture.editor.selectionModel.setBlockSelection(caret, new LogicalPosition(caret.line + 1, caret.column + 1))
- }
- type 'toStr'
- assert lookup
- type toType
- myFixture.checkResult textAfter
- def start = myFixture.editor.selectionModel.blockStart
- def end = myFixture.editor.selectionModel.blockEnd
- assert start.line == end.line - 1
- assert start.column == end.column
- assert end == myFixture.editor.caretModel.logicalPosition
- }
-
public void "test two non-imported classes when space selects first autopopup item"() {
myFixture.addClass("package foo; public class Abcdefg {}")
myFixture.configureByText 'a.java', 'class Foo extends <caret>'
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 35b71f8cc33b..d30e3520f932 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy
@@ -882,16 +882,6 @@ public class ListUtils {
doAntiTest()
}
- private void doMultiCaretTest() throws Exception {
- EditorTestUtil.enableMultipleCarets()
- try {
- doTest()
- }
- finally {
- EditorTestUtil.disableMultipleCarets()
- }
- }
-
private void doTest() throws Exception {
configure()
checkResult();
@@ -1366,68 +1356,44 @@ class XInternalError {}
}
public void "test block selection from bottom to top with single-item insertion"() {
- myFixture.configureByText "a.java", """
-class Foo {{
- ret<caret>;
- ret;
-}}"""
- edt {
- def caret = myFixture.editor.offsetToLogicalPosition(myFixture.editor.caretModel.offset)
- myFixture.editor.selectionModel.setBlockSelection(new LogicalPosition(caret.line + 1, caret.column), caret)
+ EditorTestUtil.disableMultipleCarets()
+ try {
+ myFixture.configureByText "a.java", """
+ class Foo {{
+ ret<caret>;
+ ret;
+ }}"""
+ edt {
+ def caret = myFixture.editor.offsetToLogicalPosition(myFixture.editor.caretModel.offset)
+ myFixture.editor.selectionModel.setBlockSelection(new LogicalPosition(caret.line + 1, caret.column), caret)
+ }
+ myFixture.completeBasic()
+ myFixture.checkResult '''
+ class Foo {{
+ return<caret>;
+ return;
+ }}'''
+ }
+ finally {
+ EditorTestUtil.enableMultipleCarets()
}
- myFixture.completeBasic()
- myFixture.checkResult '''
-class Foo {{
- return<caret>;
- return;
-}}'''
}
public void testMulticaretSingleItemInsertion() {
- doMultiCaretTest()
+ doTest()
}
public void testMulticaretMethodWithParen() {
- doMultiCaretTest()
- }
-
- public void testFinishWithEqualsWhenMultipleCaretsAreEnabled() {
- EditorTestUtil.enableMultipleCarets()
- try {
- configureByFile("SpacesAroundEq.java");
- type('=');
- checkResultByFile("SpacesAroundEq_after.java");
- }
- finally {
- EditorTestUtil.disableMultipleCarets()
- }
- }
-
- public void testPrimitiveSquareBracketWhenMultipleCaretsAreEnabled() {
- EditorTestUtil.enableMultipleCarets()
- try {
- configureByFile("PrimitiveSquareBracket.java");
- type('[');
- checkResultByFile("PrimitiveSquareBracket_after.java");
- }
- finally {
- EditorTestUtil.disableMultipleCarets()
- }
+ doTest()
}
public void testMulticaretTyping() {
- EditorTestUtil.enableMultipleCarets()
- try {
- configure()
- assert lookup
- type('p')
- assert lookup
- type('\n')
- checkResult()
- }
- finally {
- EditorTestUtil.disableMultipleCarets()
- }
+ configure()
+ assert lookup
+ type('p')
+ assert lookup
+ type('\n')
+ checkResult()
}
public void "test complete lowercase class name"() {
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType17CompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType17CompletionTest.java
index 548f5df1500a..02773d45cd72 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType17CompletionTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType17CompletionTest.java
@@ -35,7 +35,7 @@ public class SmartType17CompletionTest extends LightFixtureCompletionTestCase {
@NotNull
@Override
protected LightProjectDescriptor getProjectDescriptor() {
- return JAVA_LATEST;
+ return JAVA_1_7;
}
public void testDiamondCollapsed() throws Exception {
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType18CompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType18CompletionTest.java
index 72840250b795..a9811983947e 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType18CompletionTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType18CompletionTest.java
@@ -73,6 +73,14 @@ public class SmartType18CompletionTest extends LightFixtureCompletionTestCase {
doTest();
}
+ public void testInLambdaPositionSingleParam() throws Exception {
+ doTest();
+ }
+
+ public void testInLambdaPositionNameSubstitution() throws Exception {
+ doTest();
+ }
+
public void testFilteredMethodReference() throws Exception {
doTest();
}
@@ -96,6 +104,11 @@ public class SmartType18CompletionTest extends LightFixtureCompletionTestCase {
}
}
+ public void testDiamondsInsideMethodCall() throws Exception {
+ configureByFile("/" + getTestName(false) + ".java");
+ checkResultByFile("/" + getTestName(false) + "-out.java");
+ }
+
private void doTest() {
configureByFile("/" + getTestName(false) + ".java");
assertNotNull(myItems);
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Diamond8HighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Diamond8HighlightingTest.java
index ca4133b79172..eb73906a5f15 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Diamond8HighlightingTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Diamond8HighlightingTest.java
@@ -31,6 +31,10 @@ public class Diamond8HighlightingTest extends LightDaemonAnalyzerTestCase {
doTest();
}
+ public void testVarargs() throws Exception {
+ doTest();
+ }
+
private void doTest() throws Exception {
doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", false, 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 8af0821571d6..dbf3e3703992 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
@@ -168,6 +168,18 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
doTest();
}
+ public void testIncorporationWithEqualsBoundsSubstitution() throws Exception {
+ doTest();
+ }
+
+ public void testOuterCallConflictResolution() throws Exception {
+ doTest();
+ }
+
+ public void testVarargsOnNonPertinentPlace() throws Exception {
+ doTest();
+ }
+
private void doTest() throws Exception {
doTest(false);
}
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
index 0cb2f0ecc65c..5f4d01e4ab5e 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MostSpecificResolutionTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MostSpecificResolutionTest.java
@@ -39,6 +39,30 @@ public class MostSpecificResolutionTest extends LightDaemonAnalyzerTestCase {
doTest();
}
+ public void testNestedLambdaSpecifics() throws Exception {
+ doTest();
+ }
+
+ public void testBothVarargs() throws Exception {
+ doTest();
+ }
+
+ public void testNestedVarargs() throws Exception {
+ doTest();
+ }
+
+ public void testMostSpecificForSameFunctionalTypes() throws Exception {
+ doTest();
+ }
+
+ public void testIDEA121884() throws Exception {
+ doTest();
+ }
+
+ public void testIDEA121999() throws Exception {
+ doTest();
+ }
+
private void doTest() {
doTest(true);
}
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 826193c90f90..a3c2b12515eb 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
@@ -146,6 +146,14 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
doTest();
}
+ public void testIDEA121315() throws Exception {
+ doTest();
+ }
+
+ public void testIDEA118965comment() 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 83f0dfac5c1e..f18ae823c7ff 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
@@ -181,6 +181,22 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
doTest();
}
+ public void testSuperClassPotentiallyApplicableMembers() throws Exception {
+ doTest();
+ }
+
+ public void testExactMethodReferencePertinentToApplicabilityCheck() throws Exception {
+ doTest();
+ }
+
+ public void testAmbiguityVarargs() throws Exception {
+ doTest();
+ }
+
+ public void testRawInnerClassQualifier() throws Exception {
+ doTest();
+ }
+
private void doTest() {
doTest(false);
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/AddExceptionToThrowsTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/AddExceptionToThrowsTest.java
index f25775fb962b..5fa9b96f574d 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/AddExceptionToThrowsTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/AddExceptionToThrowsTest.java
@@ -1,5 +1,8 @@
package com.intellij.codeInsight.daemon.quickFix;
+import com.intellij.openapi.projectRoots.Sdk;
+import com.intellij.testFramework.IdeaTestUtil;
+
public class AddExceptionToThrowsTest extends LightQuickFixParameterizedTestCase {
public void test() throws Exception {
doAllTests();
@@ -9,4 +12,9 @@ public class AddExceptionToThrowsTest extends LightQuickFixParameterizedTestCase
protected String getBasePath() {
return "/codeInsight/daemonCodeAnalyzer/quickFix/addToThrows";
}
+
+ @Override
+ protected Sdk getProjectJDK() {
+ return IdeaTestUtil.getMockJdk18();
+ }
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/intention/AddImportActionTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/intention/AddImportActionTest.groovy
index 662762ba2a69..ead75a2936e2 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/intention/AddImportActionTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/intention/AddImportActionTest.groovy
@@ -133,8 +133,7 @@ import java.util.Collection;
@Target(ElementType.TYPE_USE) @interface TA { }
class Test {
- @TA
- Collection<caret> c;
+ @TA Collection<caret> c;
}
'''
}
@@ -157,8 +156,7 @@ import java.util.Collection;
@Target(ElementType.TYPE_USE) @interface TA { }
class Test {
- @TA
- Collection<caret> c;
+ @TA Collection<caret> c;
}
'''
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy
index 939e7520ecf5..cef42e9ea06d 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/template/LiveTemplateTest.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.
@@ -29,6 +29,7 @@ import com.intellij.openapi.command.WriteCommandAction
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.impl.DocumentImpl
import com.intellij.openapi.util.Disposer
+import com.intellij.openapi.util.text.StringUtil
import com.intellij.psi.PsiDocumentManager
import com.intellij.psi.codeStyle.CodeStyleSettingsManager
import com.intellij.psi.codeStyle.CommonCodeStyleSettings
@@ -74,15 +75,50 @@ public class LiveTemplateTest extends LightCodeInsightFixtureTestCase {
String group = "user";
final Template template = manager.createTemplate(templateName, group, templateText);
template.addVariable("ARG", "", "", false);
- final TemplateContextType contextType =
- ContainerUtil.findInstance(TemplateContextType.EP_NAME.getExtensions(), JavaCodeContextType.class);
+ TemplateContextType contextType = contextType(JavaCodeContextType.class);
((TemplateImpl)template).getTemplateContext().setEnabled(contextType, true);
addTemplate(template, testRootDisposable)
- final Editor editor = getEditor();
manager.startTemplate(editor, (char)'\t');
checkResultByText(expected);
}
+
+ public void testTemplateWithSegmentsAtTheSamePosition_1() {
+ doTestTemplateWithThreeVariables("", "", "", "class A { void test() { for(TestValue1TestValue2TestValue3) {} } }")
+ }
+
+ public void testTemplateWithSegmentsAtTheSamePosition_2() {
+ doTestTemplateWithThreeVariables("Def1", "Def2", "DefaultValue", "class A { void test() { for(Def1Def2DefaultValue) {} } }")
+ }
+
+ public void testTemplateWithSegmentsAtTheSamePosition_3() {
+ doTestTemplateWithThreeVariables("", "DefaultValue", "", "class A { void test() { for(TestValue1DefaultValueTestValue3) {} } }")
+ }
+
+ private void doTestTemplateWithThreeVariables(String firstDefaultValue, String secondDefaultValue, String thirdDefaultValue,
+ String expectedText) {
+ configureFromFileText("dummy.java", "class A { void test() { <caret> } }")
+
+ TemplateManager manager = TemplateManager.getInstance(getProject())
+ def templateName = "tst_template"
+ def templateGroup = "user"
+ final Template template = manager.createTemplate(templateName, templateGroup, 'for($TEST1$$TEST2$$TEST3$) {}')
+ template.addVariable("TEST1", "", StringUtil.wrapWithDoubleQuote(firstDefaultValue), true)
+ template.addVariable("TEST2", "", StringUtil.wrapWithDoubleQuote(secondDefaultValue), true)
+ template.addVariable("TEST3", "", StringUtil.wrapWithDoubleQuote(thirdDefaultValue), true)
+ ((TemplateImpl)template).templateContext.setEnabled(contextType(JavaCodeContextType.class), true)
+ addTemplate(template, testRootDisposable)
+
+ startTemplate(templateName, templateGroup)
+ if (firstDefaultValue.empty) myFixture.type("TestValue1")
+ myFixture.type("\t")
+ if (secondDefaultValue.empty) myFixture.type("TestValue2")
+ myFixture.type("\t")
+ if (thirdDefaultValue.empty) myFixture.type("TestValue3")
+ myFixture.type("\t")
+ assert state == null
+ checkResultByText(expectedText);
+ }
public void testTemplateWithArg1() throws IOException {
doTestTemplateWithArg("tst", 'wrap($ARG$)', "tst arg<caret>", "wrap(arg)");
@@ -245,6 +281,10 @@ class Foo {
TemplateManager.getInstance(getProject()).startTemplate(getEditor(), TemplateSettings.getInstance().getTemplate(name, group));
}
+ private static <T extends TemplateContextType> T contextType(Class<T> clazz) {
+ ContainerUtil.findInstance(TemplateContextType.EP_NAME.getExtensions(), clazz)
+ }
+
private void configure() {
myFixture.configureByFile(getTestName(false) + ".java");
}
@@ -397,7 +437,7 @@ class Foo {
assertTrue(isApplicable("class Foo { <caret>xxx void foo(String bar, xxx goo ) {} }", template));
assertTrue(isApplicable("class Foo { void foo(<caret>String[] bar) {} }", template));
assertTrue(isApplicable("class Foo { <caret>xxx String[] foo(String[] bar) {} }", template));
-
+
assertTrue(isApplicable("<caret>xxx package foo; class Foo {}", template));
}
@@ -448,7 +488,7 @@ class Foo {
new ListTemplatesHandler().invoke(project, editor, myFixture.file);
assert myFixture.lookupElementStrings.containsAll(['iter', 'itco', 'toar'])
-
+
myFixture.type('it')
assert myFixture.lookupElementStrings[0].startsWith('it')
assert LookupManager.getInstance(project).activeLookup.currentItem == myFixture.getLookupElements()[0]
@@ -549,8 +589,7 @@ class Foo {
public void testTemplateExpandingWithSelection() {
final TemplateManager manager = TemplateManager.getInstance(getProject());
final Template template = manager.createTemplate("tpl", "user", 'expanded');
- final JavaStringContextType contextType =
- ContainerUtil.findInstance(TemplateContextType.EP_NAME.getExtensions(), JavaStringContextType.class);
+ final JavaStringContextType contextType = contextType(JavaStringContextType.class);
((TemplateImpl)template).getTemplateContext().setEnabled(contextType, true);
myFixture.configureByText("a.java", "class A { void f() { Stri<selection>ng s = \"tpl</selection><caret>\"; } }")
@@ -559,7 +598,7 @@ class Foo {
myFixture.type '\t'
myFixture.checkResult 'class A { void f() { Stri "; } }'
}
-
+
static void addTemplate(Template template, Disposable parentDisposable) {
def settings = TemplateSettings.getInstance()
settings.addTemplate(template);
@@ -589,7 +628,7 @@ class Foo {{
class Foo {{
java.util.List<String[]> list;
String[][] s = list.toArray(new String[list.size()][])<caret>
-}}'''
+}}'''
}
public void "test inner class name"() {
@@ -722,4 +761,32 @@ class Foo {
myFixture.checkResult('-foo-bar_goo- _foo_bar_goo_ c<caret>')
}
+ public void "test use single member static import first"() {
+ myFixture.addClass("""package foo;
+public class Bar {
+ public static void someMethod() {}
+ public static void someMethod(int a) {}
+}""")
+ myFixture.configureByText "a.java", """
+
+class Foo {
+ {
+ <caret>
+ }
+}
+"""
+ final TemplateManager manager = TemplateManager.getInstance(getProject());
+ final Template template = manager.createTemplate("xxx", "user", 'foo.Bar.someMethod($END$)');
+ template.setValue(USE_STATIC_IMPORT_IF_POSSIBLE, true);
+
+ manager.startTemplate(editor, template);
+ myFixture.checkResult """import static foo.Bar.someMethod;
+
+class Foo {
+ {
+ someMethod(<caret>)
+ }
+}
+"""
+ }
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/template/postfix/templates/CastPostfixTemplateTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/template/postfix/templates/CastPostfixTemplateTest.java
index dbd4c1ddd20d..b7d4ef358823 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/template/postfix/templates/CastPostfixTemplateTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/template/postfix/templates/CastPostfixTemplateTest.java
@@ -1,10 +1,22 @@
+/*
+ * 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;
-/**
- * @author ignatov
- */
public class CastPostfixTemplateTest extends PostfixTemplateTestCase {
@NotNull
@Override
@@ -12,4 +24,6 @@ public class CastPostfixTemplateTest extends PostfixTemplateTestCase {
public void testSingleExpression() { doTest(); } // jdk mock needed
public void testVoidExpression() { doTest(); }
+ public void testSingleArgument() { doTest(); }
+ public void testInsideString() { doTest(); }
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java
index e4cf4c7480a5..f636c11b37ab 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java
@@ -79,6 +79,7 @@ public class DataFlowInspectionTest extends LightCodeInsightFixtureTestCase {
public void testIDEA84489() throws Throwable { doTest(); }
public void testComparingToNotNullShouldNotAffectNullity() throws Throwable { doTest(); }
+ public void testComparingToNullableShouldNotAffectNullity() throws Throwable { doTest(); }
public void testStringTernaryAlwaysTrue() throws Throwable { doTest(); }
public void testStringConcatAlwaysNotNull() throws Throwable { doTest(); }
@@ -305,6 +306,11 @@ public class DataFlowInspectionTest extends LightCodeInsightFixtureTestCase {
public void testNotEqualsTypo() { doTest(); }
public void testAndEquals() { doTest(); }
+ public void testUnusedCallDoesNotMakeUnknown() { doTest(); }
+ public void testGettersAndPureNoFlushing() { doTest(); }
+
+ public void testSameComparisonTwice() { doTest(); }
+
public void testParametersAreNonnullByDefault() {
myFixture.addClass("package javax.annotation; public @interface ParametersAreNonnullByDefault {}");
myFixture.addClass("package javax.annotation; public @interface ParametersAreNullableByDefault {}");
diff --git a/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java b/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java
index bfd1de796f90..b0bc587fd406 100644
--- a/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java
+++ b/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java
@@ -600,4 +600,19 @@ public class FindManagerTest extends DaemonAnalyzerTestCase {
findModel.setInCommentsOnly(true);
FindManagerTestUtils.runFindForwardAndBackward(myFindManager, findModel, text, "java");
}
+
+ public void testPlusWholeWordsOnly() throws Exception {
+ createFile(myModule, "A.java", "3 + '+' + 2");
+
+ FindModel findModel = FindManagerTestUtils.configureFindModel("'+' +");
+ findModel.setMultipleFiles(true);
+
+ assertSize(1, findUsages(findModel));
+
+ findModel.setCaseSensitive(true);
+ assertSize(1, findUsages(findModel));
+
+ findModel.setWholeWordsOnly(true);
+ assertSize(1, findUsages(findModel));
+ }
}
diff --git a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterSpaceTest.java b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterSpaceTest.java
index ec5081ca1da6..c4cd499ccd96 100644
--- a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterSpaceTest.java
+++ b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterSpaceTest.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.
@@ -25,7 +25,7 @@ import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
*/
public class JavaFormatterSpaceTest extends AbstractJavaFormatterTest {
- public void testSpacingBetweenTypeParameters() throws Exception {
+ public void testSpacingBetweenTypeParameters() {
// Implied by IDEADEV-3666
getSettings().SPACE_AFTER_COMMA = true;
@@ -33,6 +33,7 @@ public class JavaFormatterSpaceTest extends AbstractJavaFormatterTest {
"class Foo {\n" + " Map<String, String> map() {\n" + " }\n" + "}");
}
+ @SuppressWarnings("SpellCheckingInspection")
public void testDoNotPlaceStatementsOnOneLineIfFirstEndsWithSingleLineComment() {
getSettings().KEEP_MULTIPLE_EXPRESSIONS_IN_ONE_LINE = true;
getSettings().KEEP_LINE_BREAKS = false;
@@ -195,7 +196,7 @@ public class JavaFormatterSpaceTest extends AbstractJavaFormatterTest {
"}");
}
- public void testSpaceWithArrayBrackets() throws Exception {
+ public void testSpaceWithArrayBrackets() {
// Inspired by IDEA-58510
getSettings().SPACE_WITHIN_BRACKETS = true;
doMethodTest(
@@ -207,11 +208,11 @@ public class JavaFormatterSpaceTest extends AbstractJavaFormatterTest {
"int[] i2 = new int[]{1}"
);
}
-
- public void testSpaceBeforeElse() throws Exception {
+
+ public void testSpaceBeforeElse() {
// Inspired by IDEA-58068
getSettings().ELSE_ON_NEW_LINE = false;
-
+
getSettings().SPACE_BEFORE_ELSE_KEYWORD = false;
doMethodTest(
"if (true) {\n" +
@@ -233,7 +234,7 @@ public class JavaFormatterSpaceTest extends AbstractJavaFormatterTest {
);
}
- public void testSpaceBeforeWhile() throws Exception {
+ public void testSpaceBeforeWhile() {
// Inspired by IDEA-58068
getSettings().WHILE_ON_NEW_LINE = false;
@@ -254,8 +255,8 @@ public class JavaFormatterSpaceTest extends AbstractJavaFormatterTest {
);
}
-
- public void testSpaceBeforeCatch() throws Exception {
+
+ public void testSpaceBeforeCatch() {
// Inspired by IDEA-58068
getSettings().CATCH_ON_NEW_LINE = false;
@@ -280,7 +281,7 @@ public class JavaFormatterSpaceTest extends AbstractJavaFormatterTest {
);
}
- public void testSpaceBeforeFinally() throws Exception {
+ public void testSpaceBeforeFinally() {
// Inspired by IDEA-58068
getSettings().FINALLY_ON_NEW_LINE = false;
@@ -305,19 +306,19 @@ public class JavaFormatterSpaceTest extends AbstractJavaFormatterTest {
);
}
- public void testEmptyIterationAtFor() throws Exception {
+ public void testEmptyIterationAtFor() {
// Inspired by IDEA-58293
getSettings().SPACE_AFTER_SEMICOLON = true;
getSettings().SPACE_WITHIN_FOR_PARENTHESES = false;
-
+
doMethodTest(
"for ( ; ; )",
"for (; ; )"
);
}
- public void testSpacesInDisjunctiveType() throws Exception {
+ public void testSpacesInDisjunctiveType() {
getSettings().KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = true;
getSettings().CATCH_ON_NEW_LINE = false;
@@ -330,7 +331,7 @@ public class JavaFormatterSpaceTest extends AbstractJavaFormatterTest {
"try { } catch (E1|E2 e) { }");
}
- public void testSpacesInsideLambda() throws Exception {
+ public void testSpacesInsideLambda() {
getSettings().KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = true;
getSettings().SPACE_AROUND_LAMBDA_ARROW = true;
@@ -342,7 +343,7 @@ public class JavaFormatterSpaceTest extends AbstractJavaFormatterTest {
"()->{}");
}
- public void testSpacesInsideMethodRef() throws Exception {
+ public void testSpacesInsideMethodRef() {
getSettings().SPACE_AROUND_METHOD_REF_DBL_COLON = true;
doMethodTest("Runnable r = this::foo",
@@ -353,7 +354,7 @@ public class JavaFormatterSpaceTest extends AbstractJavaFormatterTest {
"Runnable r = this::foo");
}
- public void testSpacesBeforeResourceList() throws Exception {
+ public void testSpacesBeforeResourceList() {
getSettings().KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = true;
getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
@@ -368,7 +369,7 @@ public class JavaFormatterSpaceTest extends AbstractJavaFormatterTest {
"try(AutoCloseable r = null){ }");
}
- public void testSpacesWithinResourceList() throws Exception {
+ public void testSpacesWithinResourceList() {
getSettings().KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = true;
getSettings().SPACE_WITHIN_TRY_PARENTHESES = false;
@@ -386,7 +387,7 @@ public class JavaFormatterSpaceTest extends AbstractJavaFormatterTest {
"try ( R r1 = null; R r2 = null; ) { }");
}
- public void testSpacesBetweenResources() throws Exception {
+ public void testSpacesBetweenResources() {
getSettings().KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = true;
getSettings().SPACE_BEFORE_SEMICOLON = false;
@@ -400,7 +401,7 @@ public class JavaFormatterSpaceTest extends AbstractJavaFormatterTest {
"try (R r1 = null ;R r2 = null ;) { }");
}
- public void testSpacesInResourceAssignment() throws Exception {
+ public void testSpacesInResourceAssignment() {
getSettings().KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = true;
getSettings().SPACE_AROUND_ASSIGNMENT_OPERATORS = true;
@@ -412,20 +413,20 @@ public class JavaFormatterSpaceTest extends AbstractJavaFormatterTest {
"try (R r=null) { }");
}
- public void testBetweenMethodCallArguments() throws Exception {
+ public void testBetweenMethodCallArguments() {
// Inspired by IDEA-71823
getSettings().SPACE_AFTER_COMMA = false;
-
+
doMethodTest(
"foo(1, 2, 3);",
"foo(1,2,3);"
);
}
- public void testBeforeAnonymousClassConstructor() throws Exception {
+ public void testBeforeAnonymousClassConstructor() {
// Inspired by IDEA-72321.
getSettings().SPACE_BEFORE_METHOD_CALL_PARENTHESES = true;
-
+
doMethodTest(
"actions.add(new Action(this) {\n" +
" public void run() {\n" +
@@ -438,11 +439,11 @@ public class JavaFormatterSpaceTest extends AbstractJavaFormatterTest {
);
}
- public void testBeforeAnnotationArrayInitializer() throws Exception {
+ public void testBeforeAnnotationArrayInitializer() {
// Inspired by IDEA-72317
getSettings().SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE = false;
getSettings().SPACE_BEFORE_ANNOTATION_ARRAY_INITIALIZER_LBRACE = true;
-
+
doClassTest(
"@SuppressWarnings({\"HardCodedStringLiteral\"})\n" +
"void test() {\n" +
@@ -455,7 +456,7 @@ public class JavaFormatterSpaceTest extends AbstractJavaFormatterTest {
);
}
- public void testBetweenParenthesesOfNoArgsMethod() throws Exception {
+ public void testBetweenParenthesesOfNoArgsMethod() {
// Inspired by IDEA-74751
getSettings().SPACE_WITHIN_METHOD_CALL_PARENTHESES = false;
getSettings().SPACE_WITHIN_EMPTY_METHOD_CALL_PARENTHESES = false;
@@ -484,7 +485,7 @@ public class JavaFormatterSpaceTest extends AbstractJavaFormatterTest {
);
}
- public void testIncompleteCastExpression() throws Exception {
+ public void testIncompleteCastExpression() {
// Inspired by IDEA-75043.
String text = "void test(int i) {\n" +
" (() i)\n" +
@@ -492,7 +493,7 @@ public class JavaFormatterSpaceTest extends AbstractJavaFormatterTest {
doClassTest(text, text);
}
- public void testSpacesWithinAngleBrackets() throws Exception {
+ public void testSpacesWithinAngleBrackets() {
getJavaSettings().SPACES_WITHIN_ANGLE_BRACKETS = true;
String beforeMethod = "static < T > void fromArray( T [ ] a , Collection< T > c) {\n}";
@@ -510,7 +511,7 @@ public class JavaFormatterSpaceTest extends AbstractJavaFormatterTest {
doTextTest(beforeClass, "class A<U> {\n}");
}
- public void testSpaceAfterClosingAngleBracket_InTypeArgument() throws Exception {
+ public void testSpaceAfterClosingAngleBracket_InTypeArgument() {
String before = "Bar.<String, Integer> mess(null);";
getJavaSettings().SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TYPE_ARGUMENT = false;
@@ -520,7 +521,7 @@ public class JavaFormatterSpaceTest extends AbstractJavaFormatterTest {
doMethodTest(before, "Bar.<String, Integer> mess(null);");
}
- public void testSpaceBeforeOpeningAngleBracket_InTypeParameter() throws Exception {
+ public void testSpaceBeforeOpeningAngleBracket_InTypeParameter() {
String before = "class A<T> {\n}";
getJavaSettings().SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TYPE_PARAMETER = false;
@@ -530,7 +531,7 @@ public class JavaFormatterSpaceTest extends AbstractJavaFormatterTest {
doTextTest(before, "class A <T> {\n}");
}
- public void testSpaceAroundTypeBounds() throws Exception {
+ public void testSpaceAroundTypeBounds() {
String before = "public class Foo<T extends Bar & Abba, U> {\n}";
getJavaSettings().SPACE_AROUND_TYPE_BOUNDS_IN_TYPE_PARAMETERS = true;
@@ -539,4 +540,22 @@ public class JavaFormatterSpaceTest extends AbstractJavaFormatterTest {
getJavaSettings().SPACE_AROUND_TYPE_BOUNDS_IN_TYPE_PARAMETERS = false;
doTextTest(before, "public class Foo<T extends Bar&Abba, U> {\n}");
}
+
+ public void testInnerTypeAnnotations() {
+ doTextTest(
+ "class C<@TA(1)T> {\n" +
+ " L<@TA(2)A> f = (@TA(3) A) new @TA(4) A() {\n" +
+ " void m(@TA(6) int @TA(7)[] p) {\n" +
+ " }\n" +
+ " };\n" +
+ "}",
+
+ "class C<@TA(1) T> {\n" +
+ " L<@TA(2) A> f = (@TA(3) A) new @TA(4) A() {\n" +
+ " void m(@TA(6) int @TA(7) [] p) {\n" +
+ " }\n" +
+ " };\n" +
+ "}"
+ );
+ }
}
diff --git a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterWrapTest.java b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterWrapTest.java
index 5e545ecb8be6..4482dd7985ae 100644
--- a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterWrapTest.java
+++ b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterWrapTest.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.
@@ -15,10 +15,14 @@
*/
package com.intellij.psi.formatter.java;
+import com.intellij.idea.Bombed;
import com.intellij.lang.java.JavaLanguage;
import com.intellij.openapi.util.TextRange;
+import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
+import java.util.Calendar;
+
/**
* Is intended to hold specific java formatting tests for 'wrapping' settings.
*
@@ -26,8 +30,8 @@ import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
* @since Apr 29, 2010 4:06:15 PM
*/
public class JavaFormatterWrapTest extends AbstractJavaFormatterTest {
-
- public void testWrappingAnnotationArrayParameters() throws Exception {
+ @SuppressWarnings("SpellCheckingInspection")
+ public void testWrappingAnnotationArrayParameters() {
getSettings().getRootSettings().RIGHT_MARGIN = 80;
getSettings().ARRAY_INITIALIZER_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
doTextTest(
@@ -42,7 +46,7 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest {
"@AttributeOverride(name = \"systemExchangeRate\", column = @Column(name = \"system_exchange_rate\")) })\n" +
"class Foo {\n" +
"}",
-
+
"@AttributeOverrides({\n" +
" @AttributeOverride(name = \"id\", column = @Column(name = \"recovery_id\")),\n" +
" @AttributeOverride(name = \"transactionReference\", column = @Column(name = \"deal_reference\")),\n" +
@@ -58,7 +62,7 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest {
);
}
- public void testAnnotationParamValueExceedingRightMargin() throws Exception {
+ public void testAnnotationParamValueExceedingRightMargin() {
// Inspired by IDEA-18051
getSettings().getRootSettings().RIGHT_MARGIN = 80;
doTextTest(
@@ -83,7 +87,8 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest {
" }\n" +
"\n" +
"\n" +
- " @TheAnnotation(value = {TheEnum.FIRST, TheEnum.SECOND}, comment = \"some long comment that goes longer that right margin 012345678901234567890\")\n" +
+ " @TheAnnotation(value = {TheEnum.FIRST, TheEnum.SECOND}, comment =" +
+ " \"some long comment that goes longer that right margin 012345678901234567890\")\n" +
" public class Test {\n" +
"\n" +
" }\n" +
@@ -110,7 +115,8 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest {
" }\n" +
"\n" +
"\n" +
- " @TheAnnotation(value = {TheEnum.FIRST, TheEnum.SECOND}, comment = \"some long comment that goes longer that right margin 012345678901234567890\")\n" +
+ " @TheAnnotation(value = {TheEnum.FIRST, TheEnum.SECOND}, comment =" +
+ " \"some long comment that goes longer that right margin 012345678901234567890\")\n" +
" public class Test {\n" +
"\n" +
" }\n" +
@@ -118,6 +124,7 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest {
"}");
}
+ @SuppressWarnings("SpellCheckingInspection")
public void testEnumConstantsWrapping() {
// Inspired by IDEA-54667
getSettings().ENUM_CONSTANTS_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
@@ -139,15 +146,15 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest {
);
}
- public void testMethodAnnotationFollowedBySingleLineComment() throws Exception {
+ public void testMethodAnnotationFollowedBySingleLineComment() {
// Inspired by IDEA-22808
getSettings().METHOD_ANNOTATION_WRAP = CommonCodeStyleSettings.WRAP_ALWAYS;
String text =
- "@Test//mycomment\n" +
+ "@Test//my_comment\n" +
"public void foo() {\n" +
"}";
-
+
// Expecting the code to be left as-is
doClassTest(text, text);
}
@@ -163,7 +170,7 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest {
"}";
doTextTest(text, text);
}
-
+
public void testWrapLongLine() {
// Inspired by IDEA-55782
getSettings().getRootSettings().RIGHT_MARGIN = 50;
@@ -237,24 +244,24 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest {
"}"
);
}
-
- public void testWrapMethodAnnotationBeforeParams() throws Exception {
+
+ @Bombed(user = "Roman Shevchenko", year = 2014, month = Calendar.MARCH, day = 14)
+ public void testWrapMethodAnnotationBeforeParams() {
// Inspired by IDEA-59536
getSettings().getRootSettings().RIGHT_MARGIN = 90;
getSettings().METHOD_ANNOTATION_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
getSettings().METHOD_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
-
+
doClassTest(
"@SuppressWarnings({\"SomeInspectionIWantToIgnore\"}) public void doSomething(int x, int y) {}",
"@SuppressWarnings({\"SomeInspectionIWantToIgnore\"})\n" +
- "public void doSomething(int x, int y) {" +
- "\n}"
+ "public void doSomething(int x, int y) {\n}"
);
}
-
- public void testMultipleExpressionInSameLine() throws Exception {
+
+ public void testMultipleExpressionInSameLine() {
// Inspired by IDEA-64975.
-
+
getSettings().KEEP_MULTIPLE_EXPRESSIONS_IN_ONE_LINE = true;
doMethodTest(
"int i = 1; int j = 2;",
@@ -268,10 +275,10 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest {
"int j = 2;"
);
}
-
- public void testIncompleteFieldAndAnnotationWrap() throws Exception {
+
+ public void testIncompleteFieldAndAnnotationWrap() {
// Inspired by IDEA-64725
-
+
getSettings().FIELD_ANNOTATION_WRAP = CommonCodeStyleSettings.DO_NOT_WRAP;
doClassTest(
"@NotNull Comparable<String>",
@@ -279,7 +286,7 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest {
);
}
- public void testResourceListWrap() throws Exception {
+ public void testResourceListWrap() {
getSettings().KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = true;
getSettings().getRootSettings().RIGHT_MARGIN = 40;
getSettings().RESOURCE_LIST_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
@@ -296,7 +303,8 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest {
") { }");
}
- public void testLineLongEnoughToExceedAfterFirstWrapping() throws Exception {
+ @SuppressWarnings("SpellCheckingInspection")
+ public void testLineLongEnoughToExceedAfterFirstWrapping() {
// Inspired by IDEA-103624
getSettings().WRAP_LONG_LINES = true;
getSettings().getRootSettings().RIGHT_MARGIN = 40;
@@ -316,7 +324,8 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest {
);
}
- public void testNoUnnecessaryWrappingIsPerformedForLongLine() throws Exception {
+ @SuppressWarnings("SpellCheckingInspection")
+ public void testNoUnnecessaryWrappingIsPerformedForLongLine() {
// Inspired by IDEA-103624
getSettings().WRAP_LONG_LINES = true;
getSettings().getRootSettings().RIGHT_MARGIN = 40;
@@ -332,13 +341,14 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest {
doMethodTest(text, text);
}
- public void testEnforceIndent_MethodCallParamWrap() throws Exception {
+ public void testEnforceIndentMethodCallParamWrap() {
getSettings().WRAP_LONG_LINES = true;
getSettings().getRootSettings().RIGHT_MARGIN = 140;
getSettings().PREFER_PARAMETERS_WRAP = true;
getSettings().CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM;
- String before = "processingEnv.getMessenger().printMessage(Diagnostic.Kind.ERROR, String.format(\"Could not process annotations: %s%n%s\", e.toString(), writer.toString()));";
+ String before = "processingEnv.getMessenger().printMessage(Diagnostic.Kind.ERROR, " +
+ "String.format(\"Could not process annotations: %s%n%s\", e.toString(), writer.toString()));";
String afterFirstReformat = "processingEnv.getMessenger().printMessage(\n" +
" Diagnostic.Kind.ERROR, String.format(\n" +
@@ -362,17 +372,19 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest {
getSettings().CALL_PARAMETERS_LPAREN_ON_NEXT_LINE = true;
doMethodTest(before, after);
- before = "processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, call(\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"));\n";
- after = "processingEnv.getMessager().printMessage(\n" +
+ String literal = "\"" + StringUtil.repeatSymbol('A', 128) + "\"";
+ before = "processingEnv.getMessenger().printMessage(Diagnostic.Kind.ERROR, call(" + literal + "));\n";
+ after = "processingEnv.getMessenger().printMessage(\n" +
" Diagnostic.Kind.ERROR, call(\n" +
- " \"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"\n" +
+ " " + literal + "\n" +
" )\n" +
");\n";
doMethodTest(before, after);
}
- public void testDoNotWrap_MethodsWithMethodCallAsParameters() throws Exception {
+ @SuppressWarnings("SpellCheckingInspection")
+ public void testDoNotWrapMethodsWithMethodCallAsParameters() {
getSettings().WRAP_LONG_LINES = true;
getSettings().getRootSettings().RIGHT_MARGIN = 140;
getSettings().PREFER_PARAMETERS_WRAP = true;
@@ -391,6 +403,33 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest {
doMethodTest(before, after);
}
+ public void testFieldAnnotationWithoutModifier() {
+ doClassTest("@NotNull String myFoo = null;", "@NotNull\nString myFoo = null;");
+ }
+ public void testTypeAnnotationsInModifierList() {
+ getSettings().getRootSettings().FORMATTER_TAGS_ENABLED = true;
+ String prefix =
+ "import java.lang.annotation.*;\n\n" +
+ "//@formatter:off\n" +
+ "@interface A { }\n" +
+ "@Target({ElementType.TYPE_USE}) @interface TA { int value() default 0; }\n" +
+ "//@formatter:on\n\n";
+
+ doTextTest(
+ prefix + "interface C {\n" +
+ " @TA(0)String m();\n" +
+ " @A @TA(1) @TA(2)String m();\n" +
+ " @A public @TA String m();\n" +
+ "}",
+
+ prefix + "interface C {\n" +
+ " @TA(0) String m();\n\n" +
+ " @A\n" +
+ " @TA(1) @TA(2) String m();\n\n" +
+ " @A\n" +
+ " public @TA String m();\n" +
+ "}");
+ }
}
diff --git a/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveClassTest.java b/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveClassTest.java
index 4c925fe931b2..df27bc351bb8 100644
--- a/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveClassTest.java
+++ b/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveClassTest.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.
@@ -162,7 +162,7 @@ public class ResolveClassTest extends ResolveTestCase {
configureDependency();
PsiReference ref = configure();
PsiElement target = ((PsiJavaReference)ref).advancedResolve(true).getElement();
- assertTrue(target instanceof PsiClass);
+ assertTrue(String.valueOf(target), target instanceof PsiClass);
}
public void testTwoModules2() throws Exception {
@@ -203,7 +203,8 @@ public class ResolveClassTest extends ResolveTestCase {
PsiReference ref = configure();
long start = System.currentTimeMillis();
assertNull(ref.resolve());
- PlatformTestUtil.assertTiming("exponent?", 200, System.currentTimeMillis() - start);
+ long elapsed = System.currentTimeMillis() - start;
+ PlatformTestUtil.assertTiming("exponent?", 200, elapsed);
}
public void testStaticImportNetwork() throws Exception {
diff --git a/java/java-tests/testSrc/com/intellij/refactoring/IntroduceParameterTest.java b/java/java-tests/testSrc/com/intellij/refactoring/IntroduceParameterTest.java
index 8444c2b547c6..0423d0939242 100644
--- a/java/java-tests/testSrc/com/intellij/refactoring/IntroduceParameterTest.java
+++ b/java/java-tests/testSrc/com/intellij/refactoring/IntroduceParameterTest.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,15 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-/*
- * Created by IntelliJ IDEA.
- * User: dsl
- * Date: 07.05.2002
- * Time: 13:59:01
- * To change template for new class use
- * Code Style | Class Templates options (Tools | IDE Options).
- */
package com.intellij.refactoring;
import com.intellij.JavaTestUtil;
@@ -38,6 +29,7 @@ import com.intellij.refactoring.introduceParameter.IntroduceParameterProcessor;
import com.intellij.refactoring.introduceParameter.Util;
import com.intellij.refactoring.util.occurrences.ExpressionOccurrenceManager;
import com.intellij.testFramework.TestDataPath;
+import com.intellij.util.ObjectUtils;
import gnu.trove.TIntArrayList;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -45,6 +37,10 @@ import org.jetbrains.annotations.Nullable;
import java.util.List;
+/**
+ * @author dsl
+ * @since 07.05.2002
+ */
@TestDataPath("$CONTENT_ROOT/testData")
public class IntroduceParameterTest extends LightRefactoringTestCase {
@NotNull
@@ -53,247 +49,230 @@ public class IntroduceParameterTest extends LightRefactoringTestCase {
return JavaTestUtil.getJavaTestDataPath();
}
- private void doTest(int replaceFieldsWithGetters, boolean removeUnusedParameters, boolean searchForSuper, boolean declareFinal,
- final boolean generateDelegate) throws Exception {
- doTest(replaceFieldsWithGetters, removeUnusedParameters, searchForSuper, declareFinal, generateDelegate, null);
- }
-
- private void doTest(int replaceFieldsWithGetters, boolean removeUnusedParameters, boolean searchForSuper, boolean declareFinal, final boolean generateDelegate,
- String conflict) throws Exception {
- boolean enabled = true;
- try {
- configureByFile("/refactoring/introduceParameter/before" + getTestName(false) + ".java");
- enabled = myEditor.getSettings().isVariableInplaceRenameEnabled();
- myEditor.getSettings().setVariableInplaceRenameEnabled(false);
- perform(true, replaceFieldsWithGetters, "anObject", searchForSuper, declareFinal, removeUnusedParameters, generateDelegate);
- checkResultByFile("/refactoring/introduceParameter/after" + getTestName(false) + ".java");
- if (conflict != null) {
- fail("Conflict expected");
- }
- }
- catch (BaseRefactoringProcessor.ConflictsInTestsException e) {
- if (conflict == null) {
- throw e;
- }
- assertEquals(conflict, e.getMessage());
- } finally {
- myEditor.getSettings().setVariableInplaceRenameEnabled(enabled);
- }
+ @Override
+ protected LanguageLevel getLanguageLevel() {
+ return LanguageLevel.JDK_1_7;
}
- public void testNoUsages() throws Exception {
+ public void testNoUsages() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, false, false, false, false);
}
- public void testSimpleUsage() throws Exception {
+ public void testSimpleUsage() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, false, false, false, false);
}
- public void testMethodWithoutParams() throws Exception {
+ public void testMethodWithoutParams() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, false, false, false, false);
}
- public void testParameterSubstitution() throws Exception {
+ public void testParameterSubstitution() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, false, false, false, false);
}
- public void testThisSubstitution() throws Exception {
+ public void testThisSubstitution() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, false, false, false, false);
}
- public void testThisSubstitutionInQualifier() throws Exception {
- doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, false, false, false, false, "field <b><code>Test.i</code></b> is not accessible from method <b><code>XTest.n()</code></b>. Value for introduced parameter in that method call will be incorrect.");
+ public void testThisSubstitutionInQualifier() {
+ doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, false, false, false, false,
+ "field <b><code>Test.i</code></b> is not accessible from method <b><code>XTest.n()</code></b>. " +
+ "Value for introduced parameter in that method call will be incorrect.");
}
- public void testFieldAccess() throws Exception {
+ public void testFieldAccess() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, false, false, false, false);
}
- public void testMethodAccess() throws Exception {
+ public void testMethodAccess() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, false, false, false, false);
}
- public void testStaticFieldAccess() throws Exception {
+ public void testStaticFieldAccess() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, false, false, false, false);
}
- public void testFieldWithGetterReplacement() throws Exception {
+ public void testFieldWithGetterReplacement() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, false, false, false, false);
}
- public void testFieldWithInaccessibleGetterReplacement() throws Exception {
+ public void testFieldWithInaccessibleGetterReplacement() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, false, false);
}
- public void testWeirdQualifier() throws Exception {
+ public void testWeirdQualifier() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, false, false);
}
- public void testSuperInExpression() throws Exception {
- doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, false, false, "Parameter initializer contains <b><code>super</code></b>, but not all calls to method are in its class");
+ public void testSuperInExpression() {
+ doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, false, false,
+ "Parameter initializer contains <b><code>super</code></b>, but not all calls to method are in its class");
}
- public void testNull() throws Exception {
+ public void testNull() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, false, false);
}
- public void testWeirdQualifierAndParameter() throws Exception {
+ public void testWeirdQualifierAndParameter() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, false, false);
}
- public void testImplicitSuperCall() throws Exception {
+ public void testImplicitSuperCall() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, false, false);
}
- public void testImplicitDefaultConstructor() throws Exception {
+ public void testImplicitDefaultConstructor() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, false, false);
}
- public void testLocalVarDeclaration() throws Exception {
+ public void testLocalVarDeclaration() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, false, false);
}
- public void testInternalSideEffect() throws Exception {
+ public void testInternalSideEffect() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, false, false);
}
- public void testQualifiedNew() throws Exception {
+ public void testQualifiedNew() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, false, false);
}
- public void testAnonymousClass() throws Exception {
+ public void testAnonymousClass() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, false, false);
}
- public void testSuperWithSideEffect() throws Exception {
- doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, false, false, "Parameter initializer contains <b><code>super</code></b>, but not all calls to method are in its class");
+ public void testSuperWithSideEffect() {
+ doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, false, false,
+ "Parameter initializer contains <b><code>super</code></b>, but not all calls to method are in its class");
}
- public void testConflictingField() throws Exception {
+ public void testConflictingField() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, true, false, false);
}
- public void testParameterInFor() throws Exception {
+ public void testParameterInFor() {
configureByFile("/refactoring/introduceParameter/beforeParameterInFor.java");
performForLocal(true, true, true, false, false);
checkResultByFile("/refactoring/introduceParameter/afterParameterInFor.java");
}
- public void testParameterJavaDoc1() throws Exception {
+ public void testParameterJavaDoc1() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, true, false);
}
- public void testParameterJavaDoc2() throws Exception {
+ public void testParameterJavaDoc2() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, true, false);
}
- public void testParameterJavaDoc3() throws Exception {
+ public void testParameterJavaDoc3() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, true, false);
}
- public void testParameterJavaDocBeforeVararg() throws Exception {
+ public void testParameterJavaDocBeforeVararg() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, true, false);
}
- public void testIncompleteVararg() throws Exception {
- doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, true, false, true, false, "Incomplete call(method()): 2 parameters expected but only 0 found\n" +
- "Incomplete call(method()): expected to delete the 0 parameter but only 0 parameters found");
+ public void testIncompleteVararg() {
+ doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, true, false, true, false,
+ "Incomplete call(method()): 2 parameters expected but only 0 found\n" +
+ "Incomplete call(method()): expected to delete the 0 parameter but only 0 parameters found");
}
- public void testIncorrectScope() throws Exception {
+ public void testIncorrectScope() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, true, true, false);
}
- public void testExpectedType() throws Exception {
+ public void testExpectedType() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, true, false);
}
- public void testRemoveParameter() throws Exception {
+ public void testRemoveParameter() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, true, false, false, false);
}
- public void testRemoveParameterAfterVariable() throws Exception {
+ public void testRemoveParameterAfterVariable() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, true, false, false, false);
}
- public void testRemoveParameterInHierarchy() throws Exception {
+ public void testRemoveParameterInHierarchy() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, true, false, false, false);
}
- public void testRemoveParameterWithJavadoc() throws Exception {
+ public void testRemoveParameterWithJavadoc() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, true, false, false, false);
}
- public void testVarargs() throws Exception { // IDEADEV-16828
+ public void testVarargs() { // IDEADEV-16828
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, false, false, false, false);
}
- public void testVarargs1() throws Exception { // IDEADEV-33555
+ public void testVarargs1() { // IDEADEV-33555
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, true, false, false, false);
}
- public void testUseInInnerClass() throws Exception {
+ public void testUseInInnerClass() {
doTestThroughHandler();
}
- public void testLocalVarSelection() throws Exception {
+ public void testLocalVarSelection() {
doTestThroughHandler();
}
- public void testGenerateDelegate() throws Exception {
+ public void testGenerateDelegate() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, false, false, false, true);
}
- public void testGenerateDelegateRemoveParameter() throws Exception {
+ public void testGenerateDelegateRemoveParameter() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, true, false, false, true);
}
- public void testGenerateDelegateNoArgs() throws Exception {
+ public void testGenerateDelegateNoArgs() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, false, false, false, true);
}
- public void testEnums() throws Exception {
+ public void testEnums() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, false, false, false, false);
}
- public void testMethodUsageInThisMethodInheritor() throws Exception {
+ public void testMethodUsageInThisMethodInheritor() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, false, false, false, false);
}
- public void testGetterQualifier() throws Exception {
+ public void testGetterQualifier() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, false, false);
}
- public void testArrayInitializer() throws Exception {
+ public void testArrayInitializer() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, true, false, false, false);
}
- public void testIncompleteEnumDefinition() throws Exception {
- doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, true, false, false, false, "Incomplete call(Root()): 2 parameters expected but only 0 found\n" +
- "Incomplete call(Root()): expected to delete the 1 parameter but only 0 parameters found");
+ public void testIncompleteEnumDefinition() {
+ doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, true, false, false, false,
+ "Incomplete call(Root()): 2 parameters expected but only 0 found\n" +
+ "Incomplete call(Root()): expected to delete the 1 parameter but only 0 parameters found");
}
- public void testStaticFieldWithGetterReplacement() throws Exception {
+ public void testStaticFieldWithGetterReplacement() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, true, false, true, false);
}
- public void testGenerateDelegateInSuperClass() throws Exception {
+ public void testGenerateDelegateInSuperClass() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, true, true, true, true);
}
- public void testGenerateDelegateInSuperInterface() throws Exception {
+ public void testGenerateDelegateInSuperInterface() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, true, true, true, true);
}
- public void testReplaceAllAndDeleteUnused() throws Exception {
+ public void testReplaceAllAndDeleteUnused() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, true, false, true, false);
}
- public void testDiamond2Raw() throws Exception {
+ public void testDiamond2Raw() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, true, false, true, false);
}
- public void testDiamondOccurrences() throws Exception {
+ public void testDiamondOccurrences() {
final LanguageLevel oldLevel = getLanguageLevel();
try {
setLanguageLevel(LanguageLevel.JDK_1_7);
@@ -304,39 +283,39 @@ public class IntroduceParameterTest extends LightRefactoringTestCase {
}
}
- public void testPreserveDiamondOccurrences() throws Exception {
+ public void testPreserveDiamondOccurrences() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, true, false, true, false);
}
- public void testSubstituteTypeParams() throws Exception {
+ public void testSubstituteTypeParams() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, true, false, true, false);
}
- public void testDelegateWithVarargs() throws Exception {
+ public void testDelegateWithVarargs() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, true, false, true, true);
}
- public void testSelfReference() throws Exception {
+ public void testSelfReference() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, true, false, true, false);
}
- public void testSelfReferenceVarargs() throws Exception {
+ public void testSelfReferenceVarargs() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, true, false, true, false);
}
-
- public void testSelfReferenceVarargs1() throws Exception {
+
+ public void testSelfReferenceVarargs1() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, true, false, true, false);
}
- public void testSimplifiedResultedType() throws Exception {
+ public void testSimplifiedResultedType() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, true, false, true, false);
}
- public void testPackageReferenceShouldBeIgnored() throws Exception {
+ public void testPackageReferenceShouldBeIgnored() {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, true, false, true, false);
}
- private void doTestThroughHandler() throws Exception {
+ private void doTestThroughHandler() {
configureByFile("/refactoring/introduceParameter/before" + getTestName(false) + ".java");
boolean enabled = true;
try {
@@ -357,46 +336,87 @@ public class IntroduceParameterTest extends LightRefactoringTestCase {
}
}
- public void testEnclosingWithParamDeletion() throws Exception {
+ public void testEnclosingWithParamDeletion() {
configureByFile("/refactoring/introduceParameter/before" + getTestName(false) + ".java");
perform(true, 0, "anObject", false, true, true, false, 1);
checkResultByFile("/refactoring/introduceParameter/after" + getTestName(false) + ".java");
}
- private static boolean perform(boolean replaceAllOccurences,
+ public void testTypeAnnotation() {
+ doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, false, false, false, false);
+ }
+
+ private void doTest(int replaceFieldsWithGetters,
+ boolean removeUnusedParameters,
+ boolean searchForSuper,
+ boolean declareFinal,
+ boolean generateDelegate) {
+ doTest(replaceFieldsWithGetters, removeUnusedParameters, searchForSuper, declareFinal, generateDelegate, null);
+ }
+
+ private void doTest(int replaceFieldsWithGetters,
+ boolean removeUnusedParameters,
+ boolean searchForSuper,
+ boolean declareFinal,
+ boolean generateDelegate,
+ String conflict) {
+ boolean enabled = true;
+ try {
+ configureByFile("/refactoring/introduceParameter/before" + getTestName(false) + ".java");
+ enabled = myEditor.getSettings().isVariableInplaceRenameEnabled();
+ myEditor.getSettings().setVariableInplaceRenameEnabled(false);
+ perform(true, replaceFieldsWithGetters, "anObject", searchForSuper, declareFinal, removeUnusedParameters, generateDelegate);
+ checkResultByFile("/refactoring/introduceParameter/after" + getTestName(false) + ".java");
+ if (conflict != null) {
+ fail("Conflict expected");
+ }
+ }
+ catch (BaseRefactoringProcessor.ConflictsInTestsException e) {
+ if (conflict == null) {
+ throw e;
+ }
+ assertEquals(conflict, e.getMessage());
+ } finally {
+ myEditor.getSettings().setVariableInplaceRenameEnabled(enabled);
+ }
+ }
+
+ private static boolean perform(boolean replaceAllOccurrences,
int replaceFieldsWithGetters,
@NonNls String parameterName,
boolean searchForSuper,
boolean declareFinal,
- final boolean removeUnusedParameters,
- final boolean generateDelegate) {
- return perform(replaceAllOccurences, replaceFieldsWithGetters, parameterName, searchForSuper, declareFinal, removeUnusedParameters,
- generateDelegate, 0);
+ boolean removeUnusedParameters,
+ boolean generateDelegate) {
+ return perform(
+ replaceAllOccurrences, replaceFieldsWithGetters, parameterName, searchForSuper, declareFinal,
+ removeUnusedParameters, generateDelegate, 0
+ );
}
- private static boolean perform(boolean replaceAllOccurences,
+ private static boolean perform(boolean replaceAllOccurrences,
int replaceFieldsWithGetters,
@NonNls String parameterName,
boolean searchForSuper,
boolean declareFinal,
- final boolean removeUnusedParameters,
- final boolean generateDelegate,
+ boolean removeUnusedParameters,
+ boolean generateDelegate,
int enclosingLevel) {
final ElementToWorkOn[] elementToWorkOn = new ElementToWorkOn[1];
- ElementToWorkOn
- .processElementToWorkOn(myEditor, myFile, "INtr param", HelpID.INTRODUCE_PARAMETER, getProject(), new ElementToWorkOn.ElementsProcessor<ElementToWorkOn>() {
- @Override
- public boolean accept(ElementToWorkOn el) {
- return true;
- }
-
- @Override
- public void pass(final ElementToWorkOn e) {
- if (e == null) return;
-
- elementToWorkOn[0] = e;
- }
- });
+ ElementToWorkOn.processElementToWorkOn(myEditor, myFile, "INtr param", HelpID.INTRODUCE_PARAMETER, getProject(),
+ new ElementToWorkOn.ElementsProcessor<ElementToWorkOn>() {
+ @Override
+ public boolean accept(ElementToWorkOn el) {
+ return true;
+ }
+
+ @Override
+ public void pass(final ElementToWorkOn e) {
+ if (e != null) {
+ elementToWorkOn[0] = e;
+ }
+ }
+ });
final PsiExpression expr = elementToWorkOn[0].getExpression();
final PsiLocalVariable localVar = elementToWorkOn[0].getLocalVariable();
@@ -411,41 +431,46 @@ public class IntroduceParameterTest extends LightRefactoringTestCase {
final PsiMethod methodToSearchFor;
if (searchForSuper) {
- methodToSearchFor = method.findDeepestSuperMethod();
+ methodToSearchFor = method.findDeepestSuperMethods()[0];
}
else {
methodToSearchFor = method;
}
- PsiExpression[] occurences;
+ PsiExpression[] occurrences;
PsiExpression initializer;
if (expr == null) {
initializer = localVar.getInitializer();
- occurences = CodeInsightUtil.findReferenceExpressions(method, localVar);
+ assertNotNull(initializer);
+ occurrences = CodeInsightUtil.findReferenceExpressions(method, localVar);
}
else {
initializer = expr;
- occurences = new ExpressionOccurrenceManager(expr, method, null).findExpressionOccurrences();
+ occurrences = new ExpressionOccurrenceManager(expr, method, null).findExpressionOccurrences();
}
- TIntArrayList parametersToRemove = removeUnusedParameters ? Util.findParametersToRemove(method, initializer, occurences) : new TIntArrayList();
+ TIntArrayList parametersToRemove = removeUnusedParameters ? Util.findParametersToRemove(method, initializer, occurrences)
+ : new TIntArrayList();
new IntroduceParameterProcessor(
- getProject(), method, methodToSearchFor, initializer, expr, localVar, true, parameterName, replaceAllOccurences,
- replaceFieldsWithGetters,
- declareFinal, generateDelegate, null, parametersToRemove).run();
+ getProject(), method, methodToSearchFor, initializer, expr, localVar, true, parameterName, replaceAllOccurrences,
+ replaceFieldsWithGetters, declareFinal, generateDelegate, null, parametersToRemove
+ ).run();
myEditor.getSelectionModel().removeSelection();
return true;
}
- private static void performForLocal(boolean searchForSuper, boolean removeLocalVariable, boolean replaceAllOccurrences, boolean declareFinal,
+ private static void performForLocal(boolean searchForSuper,
+ boolean removeLocalVariable,
+ boolean replaceAllOccurrences,
+ boolean declareFinal,
final boolean removeUnusedParameters) {
final int offset = myEditor.getCaretModel().getOffset();
- final PsiElement element = myFile.findElementAt(offset).getParent();
+ final PsiElement element = ObjectUtils.assertNotNull(myFile.findElementAt(offset)).getParent();
assertTrue(element instanceof PsiLocalVariable);
PsiMethod method = Util.getContainingMethod(element);
final PsiMethod methodToSearchFor;
if (searchForSuper) {
- final PsiMethod deepestSuperMethod = method.findDeepestSuperMethod();
- methodToSearchFor = deepestSuperMethod != null ? deepestSuperMethod : method;
+ PsiMethod[] deepestSuperMethods = method.findDeepestSuperMethods();
+ methodToSearchFor = deepestSuperMethods.length > 0 ? deepestSuperMethods[0] : method;
}
else {
methodToSearchFor = method;
@@ -454,18 +479,14 @@ public class IntroduceParameterTest extends LightRefactoringTestCase {
assertNotNull(methodToSearchFor);
final PsiLocalVariable localVariable = (PsiLocalVariable)element;
final PsiExpression parameterInitializer = localVariable.getInitializer();
- TIntArrayList parametersToRemove = removeUnusedParameters ? Util.findParametersToRemove(method, parameterInitializer, null) : new TIntArrayList();
+ assertNotNull(parameterInitializer);
+ TIntArrayList parametersToRemove = removeUnusedParameters ? Util.findParametersToRemove(method, parameterInitializer, null)
+ : new TIntArrayList();
new IntroduceParameterProcessor(
- getProject(), method, methodToSearchFor,
- parameterInitializer, null, localVariable, removeLocalVariable,
- localVariable.getName(), replaceAllOccurrences,
- IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE,
- declareFinal, false, null, parametersToRemove).run();
- }
-
- @Override
- protected LanguageLevel getLanguageLevel() {
- return LanguageLevel.JDK_1_7;
+ getProject(), method, methodToSearchFor, parameterInitializer, null, localVariable, removeLocalVariable,
+ localVariable.getName(), replaceAllOccurrences, IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE,
+ declareFinal, false, null, parametersToRemove
+ ).run();
}
}
diff --git a/java/java-tests/testSrc/com/intellij/refactoring/RenameMembersInplaceTest.java b/java/java-tests/testSrc/com/intellij/refactoring/RenameMembersInplaceTest.java
index f77166535cef..d15dc3c2969c 100644
--- a/java/java-tests/testSrc/com/intellij/refactoring/RenameMembersInplaceTest.java
+++ b/java/java-tests/testSrc/com/intellij/refactoring/RenameMembersInplaceTest.java
@@ -18,11 +18,15 @@ package com.intellij.refactoring;
import com.intellij.JavaTestUtil;
import com.intellij.codeInsight.TargetElementUtilBase;
import com.intellij.psi.PsiElement;
+import com.intellij.refactoring.rename.JavaNameSuggestionProvider;
import com.intellij.refactoring.rename.inplace.MemberInplaceRenameHandler;
import com.intellij.testFramework.LightCodeInsightTestCase;
import com.intellij.testFramework.fixtures.CodeInsightTestUtil;
import org.jetbrains.annotations.NotNull;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
/**
* User: anna
* Date: 12/4/11
@@ -76,6 +80,20 @@ public class RenameMembersInplaceTest extends LightCodeInsightTestCase {
doTestInplaceRename("bar");
}
+ public void testNameSuggestion() throws Exception {
+ configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
+
+ final PsiElement element = TargetElementUtilBase.findTargetElement(myEditor, TargetElementUtilBase.getInstance().getAllAccepted());
+ assertNotNull(element);
+
+ final Set<String> result = new LinkedHashSet<String>();
+ new JavaNameSuggestionProvider().getSuggestedNames(element, getFile(), result);
+
+ CodeInsightTestUtil.doInlineRename(new MemberInplaceRenameHandler(), result.iterator().next(), getEditor(), element);
+
+ checkResultByFile(BASE_PATH + getTestName(false) + "_after.java");
+ }
+
public void testConflictingMethodName() throws Exception {
try {
doTestInplaceRename("bar");
diff --git a/java/java-tests/testSrc/com/intellij/refactoring/WrapReturnValueTest.java b/java/java-tests/testSrc/com/intellij/refactoring/WrapReturnValueTest.java
index 1b0d7f1072fd..01c5907754f1 100644
--- a/java/java-tests/testSrc/com/intellij/refactoring/WrapReturnValueTest.java
+++ b/java/java-tests/testSrc/com/intellij/refactoring/WrapReturnValueTest.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.openapi.vfs.VirtualFile;
@@ -30,7 +25,10 @@ import com.intellij.JavaTestUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
-public class WrapReturnValueTest extends MultiFileTestCase{
+/**
+ * @author anna
+ */
+public class WrapReturnValueTest extends MultiFileTestCase {
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -42,39 +40,43 @@ public class WrapReturnValueTest extends MultiFileTestCase{
return "/refactoring/wrapReturnValue/";
}
- private void doTest(final boolean existing) throws Exception {
+ public void testSimple() { doTest(false); }
+ public void testGenerics() { doTest(false); }
+ public void testInconsistentWrapper() { doTest(true, "Existing class does not have getter for selected field"); }
+ public void testWrapper() { doTest(true); }
+ public void testStrip() { doTest(true); }
+ public void testNoConstructor() { doTest(true, "Existing class does not have appropriate constructor"); }
+ public void testInnerClass() { doTest(false, null, true); }
+ public void testHierarchy() { doTest(false, null, true); }
+ public void testAnonymous() { doTest(true, null, false); }
+ public void testWrongFieldAssignment() { doTest(true, "Existing class does not have appropriate constructor", false); }
+ public void testWrongFieldType() { doTest(true, "Existing class does not have appropriate constructor", false); }
+ public void testStaticMethodInnerClass() { doTest(false, null, true); }
+ public void testRawReturnType() { doTest(true, "Existing class does not have appropriate constructor"); }
+ public void testReturnInsideLambda() { doTest(false, null, true); }
+ public void testTypeAnnotations() { doTest(false); }
+
+ private void doTest(final boolean existing) {
doTest(existing, null);
}
- private void doTest(final boolean existing, @NonNls String exceptionMessage) throws Exception {
+ private void doTest(final boolean existing, @NonNls String exceptionMessage) {
doTest(existing, exceptionMessage, false);
}
- private void doTest(final boolean existing, String exceptionMessage, final boolean createInnerClass) throws Exception {
+ private void doTest(final boolean existing, String exceptionMessage, final boolean createInnerClass) {
try {
doTest(new PerformAction() {
@Override
- public void performAction(final VirtualFile rootDir, final VirtualFile rootAfter) throws Exception {
+ public void performAction(final VirtualFile rootDir, final VirtualFile rootAfter) {
PsiClass aClass = myJavaFacade.findClass("Test", GlobalSearchScope.projectScope(getProject()));
-
assertNotNull("Class Test not found", aClass);
-
- final PsiMethod method = aClass.findMethodsByName("foo", false)[0];
-
-
-
- @NonNls final String wrapperClassName = "Wrapper";
-
- final PsiClass wrapperClass = myJavaFacade.findClass(wrapperClassName, GlobalSearchScope.projectScope(getProject()));
-
+ PsiMethod method = aClass.findMethodsByName("foo", false)[0];
+ String wrapperClassName = "Wrapper";
+ PsiClass wrapperClass = myJavaFacade.findClass(wrapperClassName, GlobalSearchScope.projectScope(getProject()));
assertTrue(!existing || wrapperClass != null);
- final PsiField delegateField = existing ? wrapperClass.findFieldByName("myField", false) : null;
- WrapReturnValueProcessor processor = new WrapReturnValueProcessor(wrapperClassName, "",
- null, method, existing, createInnerClass,
- delegateField);
- processor.run();
- /*LocalFileSystem.getInstance().refresh(false);
- FileDocumentManager.getInstance().saveAllDocuments();*/
+ PsiField delegateField = existing ? wrapperClass.findFieldByName("myField", false) : null;
+ new WrapReturnValueProcessor(wrapperClassName, "", null, method, existing, createInnerClass, delegateField).run();
}
});
}
@@ -89,61 +91,4 @@ public class WrapReturnValueTest extends MultiFileTestCase{
fail("Conflict was not found");
}
}
-
- public void testSimple() throws Exception {
- doTest(false);
- }
-
- public void testGenerics() throws Exception {
- doTest(false);
- }
-
- public void testInconsistentWrapper() throws Exception {
- doTest(true, "Existing class does not have getter for selected field");
- }
-
- public void testWrapper() throws Exception {
- doTest(true);
- }
-
- public void testStrip() throws Exception {
- doTest(true);
- }
-
- public void testNoConstructor() throws Exception {
- doTest(true, "Existing class does not have appropriate constructor");
- }
-
- public void testInnerClass() throws Exception {
- doTest(false, null, true);
- }
-
- public void testHierarchy() throws Exception {
- doTest(false, null, true);
- }
-
- public void testAnonymous() throws Exception {
- doTest(true, null, false);
- }
-
- public void testWrongFieldAssignment() throws Exception {
- doTest(true, "Existing class does not have appropriate constructor", false);
- }
-
- public void testWrongFieldType() throws Exception {
- doTest(true, "Existing class does not have appropriate constructor", false);
- }
-
- public void testStaticMethodInnerClass() throws Exception {
- doTest(false, null, true);
- }
-
- public void testRawReturnType() throws Exception {
- doTest(true, "Existing class does not have appropriate constructor");
- }
-
- public void testReturnInsideLambda() throws Exception {
- doTest(false, null, true);
- }
-
} \ No newline at end of file
diff --git a/java/jdkAnnotations/java/util/regex/annotations.xml b/java/jdkAnnotations/java/util/regex/annotations.xml
index 2afbcb551b37..c12985e6c529 100644
--- a/java/jdkAnnotations/java/util/regex/annotations.xml
+++ b/java/jdkAnnotations/java/util/regex/annotations.xml
@@ -14,6 +14,9 @@
<item name='java.util.regex.Pattern java.util.regex.Matcher matcher(java.lang.CharSequence)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
+ <item name='java.util.regex.Pattern java.util.regex.Matcher matcher(java.lang.CharSequence) 0'>
+ <annotation name='org.jetbrains.annotations.NotNull'/>
+ </item>
<item name="java.util.regex.Pattern java.util.regex.Pattern compile(java.lang.String) 0">
<annotation name="org.jetbrains.annotations.NonNls" />
<annotation name="org.jetbrains.annotations.NotNull" />
diff --git a/java/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/deployment/debug/JavaDebuggerLauncherImpl.java b/java/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/deployment/debug/JavaDebuggerLauncherImpl.java
index 76658698d034..9fb0d3f81e3c 100644
--- a/java/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/deployment/debug/JavaDebuggerLauncherImpl.java
+++ b/java/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/deployment/debug/JavaDebuggerLauncherImpl.java
@@ -2,6 +2,9 @@ package com.intellij.remoteServer.impl.runtime.deployment.debug;
import com.intellij.debugger.DebugEnvironment;
import com.intellij.debugger.DebugUIEnvironment;
+import com.intellij.debugger.DebuggerManager;
+import com.intellij.debugger.engine.DebugProcess;
+import com.intellij.debugger.engine.DebugProcessAdapter;
import com.intellij.debugger.engine.RemoteDebugProcessHandler;
import com.intellij.debugger.ui.DebuggerPanelsManager;
import com.intellij.diagnostic.logging.LogFilesManager;
@@ -21,6 +24,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.remoteServer.configuration.RemoteServer;
import com.intellij.remoteServer.runtime.deployment.debug.JavaDebugConnectionData;
+import com.intellij.remoteServer.runtime.deployment.debug.JavaDebugServerModeHandler;
import com.intellij.remoteServer.runtime.deployment.debug.JavaDebuggerLauncher;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -39,7 +43,9 @@ public class JavaDebuggerLauncherImpl extends JavaDebuggerLauncher {
final Project project = executionEnvironment.getProject();
Executor executor = DefaultDebugExecutor.getDebugExecutorInstance();
final DebuggerPanelsManager manager = DebuggerPanelsManager.getInstance(project);
- final RemoteConnection remoteConnection = new RemoteConnection(true, info.getHost(), String.valueOf(info.getPort()), false);
+ final JavaDebugServerModeHandler serverModeHandler = info.getServerModeHandler();
+ boolean serverMode = serverModeHandler != null;
+ final RemoteConnection remoteConnection = new RemoteConnection(true, info.getHost(), String.valueOf(info.getPort()), serverMode);
DebugEnvironment debugEnvironment = new RemoteServerDebugEnvironment(project, remoteConnection, executionEnvironment.getRunProfile());
DebugUIEnvironment debugUIEnvironment = new RemoteServerDebugUIEnvironment(debugEnvironment, executionEnvironment);
RunContentDescriptor debugContentDescriptor = manager.attachVirtualMachine(debugUIEnvironment);
@@ -49,6 +55,20 @@ public class JavaDebuggerLauncherImpl extends JavaDebuggerLauncher {
processHandler.startNotify();
ExecutionManager.getInstance(project).getContentManager().showRunContent(executor, debugContentDescriptor,
executionEnvironment.getContentToReuse());
+ if (serverMode) {
+ serverModeHandler.attachRemote();
+ DebuggerManager.getInstance(executionEnvironment.getProject())
+ .addDebugProcessListener(processHandler, new DebugProcessAdapter() {
+ public void processDetached(DebugProcess process, boolean closedByUser) {
+ try {
+ serverModeHandler.detachRemote();
+ }
+ catch (ExecutionException e) {
+ LOG.info(e);
+ }
+ }
+ });
+ }
}
private static class RemoteServerDebugUIEnvironment implements DebugUIEnvironment {
diff --git a/java/testFramework/src/com/intellij/debugger/impl/DescriptorTestCase.java b/java/testFramework/src/com/intellij/debugger/impl/DescriptorTestCase.java
index 0d6624d9894b..a3ad0c55ceab 100644
--- a/java/testFramework/src/com/intellij/debugger/impl/DescriptorTestCase.java
+++ b/java/testFramework/src/com/intellij/debugger/impl/DescriptorTestCase.java
@@ -34,7 +34,10 @@ import com.intellij.execution.process.ProcessOutputTypes;
import com.intellij.openapi.util.Pair;
import com.sun.jdi.Value;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
public abstract class DescriptorTestCase extends DebuggerTestCase {
private final List<Pair<NodeDescriptorImpl,List<String>>> myDescriptorLog = new ArrayList<Pair<NodeDescriptorImpl, List<String>>>();
@@ -51,10 +54,9 @@ public abstract class DescriptorTestCase extends DebuggerTestCase {
return getAlternateCollectionRenderer("Map");
}
- private NodeRenderer getAlternateCollectionRenderer(final String name) {
+ private static NodeRenderer getAlternateCollectionRenderer(final String name) {
final NodeRenderer[] renderers = NodeRendererSettings.getInstance().getAlternateCollectionRenderers();
- for (int idx = 0; idx < renderers.length; idx++) {
- NodeRenderer renderer = renderers[idx];
+ for (NodeRenderer renderer : renderers) {
if (name.equals(renderer.getName())) {
return renderer;
}
@@ -105,9 +107,8 @@ public abstract class DescriptorTestCase extends DebuggerTestCase {
private Pair<NodeDescriptorImpl, List<String>> findDescriptorLog(final NodeDescriptorImpl descriptor) {
Pair<NodeDescriptorImpl, List<String>> descriptorText = null;
- for (Iterator<Pair<NodeDescriptorImpl, List<String>>> iterator = myDescriptorLog.iterator(); iterator.hasNext();) {
- Pair<NodeDescriptorImpl, List<String>> pair = iterator.next();
- if(pair.getFirst() == descriptor) {
+ for (Pair<NodeDescriptorImpl, List<String>> pair : myDescriptorLog) {
+ if (pair.getFirst() == descriptor) {
descriptorText = pair;
break;
}
@@ -115,24 +116,15 @@ public abstract class DescriptorTestCase extends DebuggerTestCase {
return descriptorText;
}
- protected void flushDescriptor(final NodeDescriptorImpl descriptor) {
- Pair<NodeDescriptorImpl, List<String>> descriptorLog = findDescriptorLog(descriptor);
- if(descriptorLog != null) {
- printDescriptorLog(descriptorLog);
- myDescriptorLog.remove(descriptorLog);
- }
- }
-
protected void flushDescriptors() {
- for (Iterator<Pair<NodeDescriptorImpl, List<String>>> iterator = myDescriptorLog.iterator(); iterator.hasNext();) {
- printDescriptorLog(iterator.next());
+ for (Pair<NodeDescriptorImpl, List<String>> aMyDescriptorLog : myDescriptorLog) {
+ printDescriptorLog(aMyDescriptorLog);
}
myDescriptorLog.clear();
}
private void printDescriptorLog(Pair<NodeDescriptorImpl, List<String>> pair) {
- for (Iterator<String> it = pair.getSecond().iterator(); it.hasNext();) {
- String text = it.next();
+ for (String text : pair.getSecond()) {
print(text, ProcessOutputTypes.SYSTEM);
}
}
@@ -150,6 +142,7 @@ public abstract class DescriptorTestCase extends DebuggerTestCase {
String name) {
try {
StackFrameProxy frameProxy = evaluationContext.getFrameProxy();
+ assert frameProxy != null;
LocalVariableDescriptorImpl local = frameTree.getNodeFactory().getLocalVariableDescriptor(null, frameProxy.visibleVariableByName(name));
local.setContext(evaluationContext);
return local;
@@ -169,7 +162,7 @@ public abstract class DescriptorTestCase extends DebuggerTestCase {
doExpandAll(tree, runnable, new HashSet<Value>(), null);
}
- protected static interface NodeFilter {
+ protected interface NodeFilter {
boolean shouldExpand(DebuggerTreeNode node);
}
@@ -186,7 +179,7 @@ public abstract class DescriptorTestCase extends DebuggerTestCase {
final DebuggerTreeNode treeNode = (DebuggerTreeNode)tree.getPathForRow(i).getLastPathComponent();
if(tree.isCollapsed(i) && !treeNode.isLeaf()) {
final NodeDescriptor nodeDescriptor = treeNode.getDescriptor();
- boolean shouldExpand = filter == null? true : filter.shouldExpand(treeNode);
+ boolean shouldExpand = filter == null || filter.shouldExpand(treeNode);
if (shouldExpand) {
// additional checks to prevent infinite expand
if (nodeDescriptor instanceof ValueDescriptor) {
diff --git a/java/testFramework/src/com/intellij/ide/projectWizard/ProjectWizardTestCase.java b/java/testFramework/src/com/intellij/ide/projectWizard/ProjectWizardTestCase.java
index 96e85a21f989..dd94962cddfd 100644
--- a/java/testFramework/src/com/intellij/ide/projectWizard/ProjectWizardTestCase.java
+++ b/java/testFramework/src/com/intellij/ide/projectWizard/ProjectWizardTestCase.java
@@ -91,10 +91,6 @@ public abstract class ProjectWizardTestCase<T extends AbstractProjectWizard> ext
throw new IllegalArgumentException(group + "/" + name + " template not found");
}
- if (adjuster != null) {
- adjuster.consume(step);
- }
-
runWizard(new Consumer<Step>() {
@Override
public void consume(Step step) {
@@ -108,6 +104,23 @@ public abstract class ProjectWizardTestCase<T extends AbstractProjectWizard> ext
});
}
+ protected void runWizard(Consumer<Step> adjuster) {
+ while(true) {
+ ModuleWizardStep currentStep = myWizard.getCurrentStepObject();
+ if (adjuster != null) {
+ adjuster.consume(currentStep);
+ }
+ if (myWizard.isLast()) {
+ break;
+ }
+ myWizard.doNextAction();
+ if (currentStep == myWizard.getCurrentStepObject()) {
+ throw new RuntimeException(currentStep + " is not validated");
+ }
+ }
+ myWizard.doOk();
+ }
+
protected void createWizard(Project project) throws IOException {
File directory = FileUtil.createTempDirectory(getName(), "new", false);
myFilesToDelete.add(directory);
@@ -126,23 +139,6 @@ public abstract class ProjectWizardTestCase<T extends AbstractProjectWizard> ext
return (T)new AddModuleWizard(project, DefaultModulesProvider.createForProject(project), directory.getPath());
}
- protected void runWizard(Consumer<Step> adjuster) {
- while(true) {
- ModuleWizardStep currentStep = myWizard.getCurrentStepObject();
- if (adjuster != null) {
- adjuster.consume(currentStep);
- }
- if (myWizard.isLast()) {
- break;
- }
- myWizard.doNextAction();
- if (currentStep == myWizard.getCurrentStepObject()) {
- throw new RuntimeException(currentStep + " is not validated");
- }
- }
- myWizard.doOk();
- }
-
@Override
protected void setUp() throws Exception {
super.setUp();