diff options
author | Tor Norbye <tnorbye@google.com> | 2013-11-05 17:01:08 -0800 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2013-11-05 17:01:19 -0800 |
commit | f88d3e15cd8228cba4070811da68d8ad54d81fd7 (patch) | |
tree | fc5cac21534c8d02e2dad1248400388b318525d3 /java/java-impl/src/com/intellij | |
parent | 3a2425a5aed1bef93dab954745ad5665265eb70b (diff) | |
download | idea-f88d3e15cd8228cba4070811da68d8ad54d81fd7.tar.gz |
Snapshot 360576332daeb98660f594b84800d615f73977a3 from idea/132.947 of git://git.jetbrains.org/idea/community.git
3605763: better font on Linux
6a9ca0b: Merge remote-tracking branch 'origin/master'
7211304: fix equals()
effa719: IDEA-115986 ctrl+shift+n not found files: IOOBE in com.intellij.util.indexing.IdFilter$2.contains
f59423e: [^maxim] IDEA-96343 "Find Usages..." settings are not applied
b51049f: IDEA-115092 Progress indicator: Throwable at AbstractProgressIndicatorBase.start()
058ef8c: EA-51542 - PIEAE: ClsFileImpl.getContainingFile
2653c20: compilation fixed
1467565: extracted method to fetch library versions synchronously
6835df8: javadoc updated
4cf9761: [log] issue links in the table (IDEA-115992)
90761be: Merge remote-tracking branch 'origin/master'
01790a5: make IntelliJ available on Ubuntu
750d558: EA-51479 - IAE: PsiManagerImpl.findFile
f1d78bd: Error notification for root scanner fixed
3a8109e: fix SuppressLocalInspectionInJspTest
ea4323a: using FILE_HASHING_STRATEGY
7b0e4f4: External system: adding more source types to ExternalSystemSourceType (GENERATED, RESOURCE, TEST_RESOURCE)
1030d67: [log] Better UI of details + issue links in details (IDEA-115992)
4e871dd: add option to only report on truly superfluous (un)boxing
6e592a1: some dirs-by-package fixes
6099b1b: cache all directory infos
7a9c45f: show some meaningful progress for pushers
0962a75: registry properties controlling whether RootIndex is used
5088277: fix stupid typo in RootIndex
8768c25: import from Maven: mark a source root as 'generated' if it was imported as a ordinary source root by previous version of IDEA (IDEA-115755)
ec31385: Deprecated methods dropped; javadoc refined
dbb43a2: Get rid of needless check
a0c0793: fix
cf242e8: Merge remote-tracking branch 'origin/master'
6abc87f: Empty text rendering fix
7dbd71c: [log] IDEA-115908 Expect null value
e1a32de: Merge remote-tracking branch 'origin/master'
5dec682: IDEA-115817 Correctly create SVNCopySource for both url and file targets
271099a: Application menu on Unity (Ubuntu) is enabled now. To disable use linux.native.menu registry key.
5aa669d: IDEA-113876 Changed working directory for delete command - use idea home instead of folder being deleted
3bae8b9: CR-IU-343 javadoc
15135eb: simplify file info (use ony parsed Url)
4b61382: added comment to test
0602677: Flat & round stripe buttons (Internal Mode Only) v.3 (rectangles patch)
e798bd6: Gradle: extension point for executing tasks added
204c842: skip locations with lineNumber==1 to fix GWT debugging
1b92d0c: WEB-9744 Surround with Emmet dialog usability problems
445de2c: UI: add isComboPopupKeyEvent utility method
44cbcd6: Emmet usability fixes:
37a8a38: IDEA-115904 Mercurial Log: avoid exception with old (<2.6) versions
9ed136c: show it in 2 minutes after start
eb18856: IDEA-115959 IDEAC-132.940 Start Failed with java.lang.RuntimeException
d3d5a8be: IDEA-115788 Error Messages in Run Configuration Dialog
83eb8ea: IDEA-115788 Error Messages in Run Configuration Dialog
4af50cb: IDEA-115838 FQN inserted for annotated code instead of using imports
ae7e30e: java 8: forbid super in static methods
dda9d7d: CR-IC-2999 simplify API chooseFile — use native Mac OS X file chooser
1304a2a: JSPX supports jvm debugging, but not in XHTML files
058408f: simplify
0f6e267: DirectoryIndexTest reflecting current state of excluded lib dirs under module content
769720b: RootIndex: return no dirs for packages starting with a dot
c3e03fb: [log] implement CustomActionComponents to correctly add filters to the toolbar
989e597: in power save mode, display a hint in settings that autopopup completion and automake don't work (IDEA-115749, IDEA-102048)
7a50c93: remove smelly isPhysical() check
f64c700: (IDEA-115964) Fix root scanner and errors notification for vcs without RootChecker
4a3e403: [log] layout: align the changes browser toolbar with the log toolbar
714bfeb: Flat & round stripe buttons (Internal Mode only) v.2
483e172: IDEA-115884 Auto-complete qualified super reference in virtual extension methods.
49042b4: IDEA-115883 Add auto-fix for compiler error "Unqualified super reference is not allowed in extension method"
1753fe6: refixed IDEA-114815 (maven: new project from archetype: checkbox enabled but treeview inactive)
72ce296: IDEA-115074 New Project Wizard: Grails: grails-specific settings are missing
53ef1cf: source roots editor: panels swapped, toolbar extended, group for 'mark as resource' actions eliminated
bf9d331: don't throw exception on attempt to invoke 'setValue' for key which doesn't exist in registry.properties
5aa216c: Introduce field: 'initialize in method' option should exist only when all occurrences are in the single method
bb97c01: Introduce field: correct flow for introducing field from variable
c997b3c: in-place introduce variable from string part and from control branch without code block
99e5e55: Flat & round stripe buttons (Internal Mode only)
38099ed: document another checkbox
5d2c8a9: part 2 of IDEA-106425 (Ignore some 'Code maturity issues'-inspections for test code)
d7a7025: move test to correct location
ea4ea5c: document the new checkbox
89c52c3: when copying breakpoints to clipboard, use their display text instead of toString()
1d09658: remove unused field
781028d: Merge remote-tracking branch 'origin/master'
a201080: add Search Everywhere to statistics
6a0d9c6: enable filtering in autoimport candidates list (PY-10571)
048f2bd: enable configuring logs in Python run configurations (PY-8859)
596244e: allow running PEP8 inspection from Analyze | Inspect Code (PY-9157)
5696efb: FileReferenceCharFilter checks if the reference being completed is actually a file reference (PY-8341)
0bd6d87: register optimize imports quickfix for "multiple imports on one line" pep8 issue (PY-9745)
dd5841d: optimize imports inserts blank lines between groups also when we don't have any missorted imports (PY-8355)
4ca7cb7: restore space in Python line comment prefix (PY-10929); re-fix PY-9840 correctly
a00e03f: remove garbage from git
5cfd1a1: don't inject regexp into first argument of RegexpObject.sub() (PY-11069)
5d48217: define CTRL_CLICKABLE color in WarmNeon scheme (PY-3280)
63a2620: if an attribute is declared in __init__ and another method, prefer navigating to __init__ (PY-9228)
7b29990: if there are two existing import statements that import from the same file, don't show two same items in import popup (PY-9138)
363b5a6: select word works correctly inside escape sequence (PY-9014)
27d5125: move registration of RunConfigurationBeforeRunProvider to correct place (PY-9495)
de8bad3: enable rename project in PyCharm, handle attached modules better (PY-5787)
1b78c56: don't add parentheses when using class name completion for decorator (PY-10235)
ed93e59: [log] Shift mouse-over-node/branch area in multi-root projects
75a447a: foolproof null directory info caching
e9bd45e: RootIndex: cache null infos for foreign directories
bb9fa53: Merge branch 'master' of git.labs.intellij.net:idea/community
799303a: IDEA-106425 (Ignore some 'Code maturity issues'-inspections for test code)
08b28fa: Merge remote-tracking branch 'origin/master'
577ecc5: Merge branch 'master' of git.labs.intellij.net:idea/community
bde6166: testdata fixed
c2b39c7: IDEA-115885 False positive "Abstract method with missing implementations" using virtual extension methods.
3a224a1: just consider dash a part of word for hippie completion (IDEA-115762)
28dee7c: add println to jetbrains.dic (IDEA-115852)
ab339b8: [log] Consume less temporary memory
b23a916: [log] dispose the log structures on project dispose
2c0d754: [log] Don't display commit time if equal to author time
0f794b2: [log] defensive copying
78d0991: CloudFoundry integration - move to clouds api
95492f9: Cleanup (formatting)
df385cc: EA-51567 (JRE bug - just catch and log)
6afc6fc: Cleanup (code de-duplication)
fd00a8e: Merge remote-tracking branch 'origin/master'
a4da206: can't call actions by mouse
802cab3: make action event param Nullable
c66e59c: Merge remote-tracking branch 'origin/master'
fb98413: testdata fixed
4a725b5: IDEA-115789 an interface inheriting a default method and an abstract method
9ae4ece: IDEA-115790 default methods cannot override Object methods
3f2a4dc: IDEA-115867 Copy to temp final variable does not work correctly inside expression without braces
514b389: fix dom stub tests: visit attribute children before subtags
10066cc: SourceMapInspectorWindow
efff7e3: Merge remote-tracking branch 'origin/master'
cebd056: community splash + about
1da10b5: no code generation during dom stub building
ef17004: lazy runtime code generation in dom
b643124: cache complete directory infos in RootIndex
b1fdb06: optimization trick: on debugger attach invoke vm.allClasses() to cache loaded classes inside JDI, which makes operations involving class search work faster
aed76e8: hotswap's listener to consider under compile output roots only: IDEA-115853 plugin project hotswaps classes from sandbox when it shouldn't
8507ff3: enable IntelliJ laf on Windows
7f31deb: [log] Don't collect huge log.error attachments unless on debug level
df0f43a: [log] Less frightening pi text
12fcf3d: ArrayOutOfBounds Exception fixed when update log after commit
c343140: use same button painting in Darcula and IntelliJ
9cc66e7: custom colors for Darcula and IntelliJ
2ef657c: arrows should be centered
b160a77: fix Spinners
4cdc9b9: [log] Display tooltip above the root column indicator
fdeaac1: [log] display table header to allow columns resizing
0d93174: [log] Branch filter: remove branches with identical names for multi-root
49626ad: Merge remote-tracking branch 'origin/master'
e39e614: test fixed
196320b: Merge remote-tracking branch 'origin/master'
c8f60d6: intersection type presentable name with & (IDEA-115802)
0d65efb: EA-51497 - assert: FunctionalInterfaceParameterizationUtil.isWildcardParameterized
93a1d5e: disable test listener for non-java frameworks for a while
923195c: EA-51525 - NPE: TestNGUtil.isTestNGAnnotation
ea6a8c8: Test for root scanner and root errors detector moved to platform.
e4180e6: Root Checker and Root Problem Notifier
f519dd3: optimize imports
7f0888e: VcsRootErrorsFinder moved to vcs platform directory
68e50cc: GitRootErrorsFinder renamed to VcsRootErrorsFinder, git dependencies removed from RootErrorsFinder for future moving
45ec26a: VcsRootDetector moved to Vcs platform directory
14e9b61: GitRootDetector renamed to VcsRootDetector, git dependencies removed from RootDetector for further moving
54d4c7a: VcsRootDetectInfo moved to platform vcs
616bb51: GitRootDetectInfo renamed to VcsRootDetectInfo
e062077: new grid color
76acb20: Tab colors
14b5156: [log] Don't fail if there are more roots than predefined colors
791cae8: simplify API chooseFile — use native Mac OS X file chooser Dart — use native Mac OS X file chooser +review
3a94882: [log] Darcula-friendly colors for the root indicator.
3693ab4: [log] quick fix for the deadlock in IDEA-115483
502ebb5: Merge remote-tracking branch 'origin/master'
3d2d239: IDEA-115894 New git log looks scary on Retina + Java 7
232746d: Merge remote-tracking branch 'origin/master'
17fbe75: not initialized problem: fix static fields checks
0169da0: [log] Show "No commits selected" initially
fd333e0: [log] IDEA-115676 Details panel: centralize messages
d581f94: [log] Details panel: more precise "no commits selected"
32a0e7c: IDEA-115693 Exception on Show Bookmarks
757a12c: Github: fix Gists after using 'v3' media type
21e9980: Github: fix issues test
636548b: Github: specify 'Accept' header for all GET requests
daf54b1: support javac's line/column syntax in goto popups (IDEA-55616)
a1f8ef4: rationalize static import PlatformDataKeys -> CommonDataKeys
f2a5483: PlatformDataKeys -> CommonDataKeys
6d7d4cf: PlatformDataKeys -> CommonDataKeys
2cab88d: PlatformDataKeys -> CommonDataKeys
7c2e721: PlatformDataKeys -> CommonDataKeys
11e7d75: PlatformDataKeys -> CommonDataKeys
995e7f0: PlatformDataKeys -> CommonDataKeys
bd64990: PlatformDataKeys -> CommonDataKeys
6eacef1: PlatformDataKeys -> CommonDataKeys
59de59f: not only static constants may be inlined by compiler: IDEA-115878 Constants search should work for final fields
cd139bd: ensure smart step into methods, whose first statement's line has no executable instructions mapped
ad779bf: IDEA-115368 Smart type completion popup offers Object.class ahead of local Class<?> variable
60d1e15: log.debug who changes preselected completion elements
e99b775: recognize column number in choose by name popups (IDEA-55616)
e0124d9: continue VisualizeSourceMapAction
f359bd1: another Double Shift includes libs. UI and cosmetics
14b1ffa: property for disabling search ring
370f414: customizable search controls
84a81cc: Nimbus is cheating with colors
95081a2: Merge remote-tracking branch 'origin/master'
253ed8a: IDEA-115876 ToolWindow combo looks weird under Retina + jdk1.7
956ede2: [log] IDEA-115676 Don't scroll details panel to bottom on text update
324a0f6: [log] Details panel: display author/commit date
1915764: [log] Details panel: hide empty space if there are no refs on a commit
ec630c6: [log] "Revert" and other actions above the changes browser
279e5b6: [log] Add "Create Patch" action
32c3c35: [log] Add "New Branch", "New Tag" actions to the log + refactor
aef03d9: [log] "Checkout Revision" action to the new log, some refactoring
e5f8410: fix "not resumed" assertion
f248ffc: http://ea.jetbrains.com/browser/ea_problems/51445
e06d91c: don't use editor highlighter from editor as it is built with other options
49e112c: api for (re)creating PHM that rewrites it if it is broken (IDEA-115334)
8353b38: add a registry key to allow to preselect live templates in the autopopup
f7ae406: there's no need anymore to artificially move live template items to the second place in the autopopup
f92ce9a: add "pure" attribute to @Contract (IDEA-107864)
612c075: [log] Hide the Branches Panel by default, introduce log quick settings
b7dedf3: [log] cleanup
e0f3ec3: better error reporting
840b9f5: avoid IllegalThreadStateException
553a88b: do not check for obsolete
50e8277: EA-49101: getContainingFile() must not be called on invalid PsiElement
fc45939: avoid UnsupportedOperation exceptions
bbc6dbb: base tag support: file reference helper for local paths silence inspections for urls #WEB-497 fixed
dc5c46f: continue SourcemapVisualizationServer
9c7a198: continue WEB-6659 JS Debugger stops at arbitrary point in code
2b731b1: unmapped source entry must be mapped to effective script source
fd70156: http://ea.jetbrains.com/browser/ea_problems/51487
a80811a: Don't suggest idea-print-project-settings in Run Target dialog.
7e3644f: IDEA-115827 IDEA crashes with jayatana
18c466a: Minor code change: remove unnecessary cast.
b53b96a: cleanup
f7d60cd: IDEA-115605 New Project wizard: extra settings fields disappear on switching template (memory leak re-fixed)
67993a0: deprecate doWhenDone(Handler)
413c3d4: messages are broken under Mac: IDEA-115258
a3ed291: assertion
89cbfa1: cleanup
6bdf2d1: made fields final, cleanup
ba6b81f: @Override
e22b7e6: @Override
8b0a2b0: moved to right dir
b7bade6: IDEA-115584 (try-with-resources quickfix munges code)
a31a0d4: Hide fullscreen menu when mouse leaves IDE frame
d569722: google app engine: supported importing from Maven (IDEA-110891)
ceb5909: methods moved
0a6a0a4: Merge remote-tracking branch 'origin/master'
c5eff37: revert: NavigationGutterIconBuilder#DEFAULT_PSI_CONVERTOR -> public
b349b82: getChangeset instead of revision number if it is possible.
a1dc7dd: Gradle: update to Gradle 1.9-rc-2
275b54f: NavigationGutterIconBuilder#DEFAULT_PSI_CONVERTOR -> public
02b1eab: remote servers: generified
ff4f1bd: remote servers: pass server configuration to deployment editor
21808c8: navigation actions should be DumbAware
503dbe6: Merge remote-tracking branch 'origin/master'
bc12eaf: dead lock after indexes are built
9010d9f: Merge branch 'master' of git.labs.intellij.net:idea/community
627a698: build fix
aad3fad: IDEA-113879 "Show this page" in Run Configuration does not work
3d48c2d: Merge branch 'master' of git.labs.intellij.net:idea/community
61bcef3: Heroku integration - independent of JavaEE
f5ed1c1: methods chains completion on one index
4f6bbf3: IDEA-115687 Gradle: code completion for maven dependencies
4187d15: Gradle: code insight fixes
eb3c5b4: IDEA-115687 Gradle: code completion for maven dependencies
c155564: Merge remote-tracking branch 'origin/master'
9d1e4fb: Parameter type Class<T> changed to Class<? extends T> for PsiTreeUtil.findChildrenOfAnyType() +review CR-IC @traff
d9d8b47: Installers fix
8a3ee27: fix tests
6d542a6: "Editor Font Settings" fontsize fix
a558b1d: highlight star expression used outside of assignment context (PY-10177)
56b50d1: report parsing error if no expression was found after * (PY-10177 part 1)
8e3e414: verify argument list even if unable to resolve callee (PY-10351)
eb53fab: highlight keyword argument after **kwarg as error (PY-9934)
c61eb4b: default color for builtin names under darcula (PY-9529)
39bdf7e: external tool macro for directory containing Python interpreter (PY-6533)
9c4cb80: snakeCase() macro for live templates (PY-9989)
4216441: import sorter skips from __future__ imports (PY-10022)
09b25c1: from __future__ import is moved after module docstring (PY-10080)
2067b87: help for Python language injection settings (PY-10753)
d4fc857: PyStringLiteralLexer doesn't handle escape sequences in raw strings (PY-10322)
997bc54: allow "create class" fix for names which start with multiple uppercase characters but aren't entirely uppercase (PY-7423)
a867f5e: check for disposed project in invalid SDK notification (PY-7570)
eafc40e: expand ~ in file chooser path (PY-3138)
134b317: fix yellow code
6df23a1: hotswap: allow class reload task cancelling as long as no classes are actually reloaded
17a014e: IDEA-94376 Icons: web.xml
f16be9c: Merge remote-tracking branch 'origin/master'
adb5954: fix missing property
5ad289f: load file content for hotswap only if corresponding class is loaded in VM
32e25e52: more strict check for flattened intersection type
322e9f3: remove unknown property
11b281c: compilation fix for 1.6
7168a92: new inference: clear initial instantiations before resulted one is performed to avoid skip of non-proper types of the first run which become proper on the second one
7445e7f: accept intersection types in javadoc
cbb010a: Improve "Editor Font Settings" usability
364a57e: TreeElementPattern.withSuperParent returned true if there was no parent of that level gradle completion contributor should only work in .gradle files
f328160: Merge remote-tracking branch 'origin/master'
f5b0d17: disable double shift by adding dedicated shortcut
0e38755: Override getState method for HgRepository
ac377d4: Merge remote-tracking branch 'origin/master'
b590707: fix backspace. again
2239378: set "scan required" flag in DebugSession if hotswap was cancelled
804b35a: test fix, wrong test data params order
e927837: Merge remote-tracking branch 'origin/master'
b067500: Tags added to HgRepositoryUpdater
2f15377: Tags and local tags references added to new log and repository reader
7c84831: Merge remote-tracking branch 'origin/master'
df823d6: IDEA-115756 Caret is moved on the start of line after formatting, if positioned not on the end of line [CR-IC-2978]
97c9424: Merge remote-tracking branch 'origin/master'
b5a9cef: preview for introduce constant
8299623: preview for introduce field
f382bd4: simplifying
0f4872f: canceling introduce constant
96a0923: canceling introduce field
4c1e697: canceling introduce variable
12d0c64: shorten reference
2853332: unnecessary 'static'
0f469fb: fix CCE in introduce field to script
fbea82c: Merge branch 'svn_18_2'
578826b: disable flip intersection conjuncts for equal sides
67ccffd: rearrange package; check writable
6e8c549: warn about unsupported intersections in casts before 1.8
5bd8b62: fix to switch intersection types order in casts when one of the last types is not an interface
5eb0e62: accept intersection types in casts for 1.8 (IDEA-115720)
47fee8e: new inference: throws clause processed
eebe810: [log] Compact Changes in VcsFullCommitDetails
aaed311: [git] remove throws from methods where exception is not thrown
8ab2051: revert: the actual "reload classes" hotswap stage cannot be made cancelable, because this way application is brought into "partially reloaded" state.
7a8cabd: parentheses needed when a conditional is used as condition in a conditional
249c32e: IDEA-115602 (IDEA changes code semantic after "Replace 'if else' with '?:'" intention)
22f2bc2: IDEA-115729 Removed jna-platform.jar - existing jna-utils.jar should be used (and also for pty4j)
42f4d0f: expand ~ in WORKON_HOME (PY-10336)
74d8bc0: add some more builtin functions to PyNames (PY-10544)
3507095: hide skeletons from project view (PY-8916)
9de3be0: GradleL code cleanup
a2b32663: Merge branch 'python-fixes'
ae33c21: [git] Log exception if it prevented to start the Git process
9f32285: IDEA-114988 Hide error panel by escape
df9dea5: EA-51398
d18021f: convert if statement with any throwable to assert, not just AssertionErrors
df966e7: handle incomplete code and do not force braces
cebb81d: Fixed pyparsing imports
27e83cb: we should sort all action [rev Sergey Ignatov]
719fbf9: use correct category
e5b9ccc: IDEA-115687 Gradle: code completion for maven dependencies
55b0458: Made 'dict.fromkeys' a '@staticmethod' (PY-11169)
1913a06: IDEA-115604 (Intention "Negate '?:'")
66a17be: Fixed signatures of str() and unicode() (PY-11162)
81fe359: update jar version in required_for_dist.txt (IDEA-115728)
9460bc65: Make emmet configurable scrollable
908ace7: do not fail to report when StringBuilder constructor has method call argument
a618934: do not use deprecated DelegatingRuntimeConfiguration
9cfb82b: tests notifications: listener api for tests finish
8da75cc: allow statically imported static interface methods (IDEA-115716)
8e35162: disable FinderRecursivePanelTest#testUpdate
b46165e: Merge remote-tracking branch 'origin/master'
9323727: Infer Nullity action place (IDEA-115673)
f3e9903: cleanup
2da964c: open unsupported links in browser
c4511b6: trim html headers from template, remove #end and #treeend directives
9940fdd: support description trimming in tree nodes
dd55847: tests fix, jmockit was removed
c5b8b46: Gradle: EA-51407 - assert: PsiElementFactoryImpl.createType
1bb68c4: External system: EA-48201 - assert: ComponentManagerImpl.getPicoContainer
7668b0f: OpenShift integration - initial
1694ee4: new "Negated conditional expression" inspection (for IDEA-115604)
909c03f: speed search
c96acd5: use correct language level when creating name identifiers for renamed elements (EA-43620 - CCE: PyElementGeneratorImpl.createNameIdentifier)
f8ecd71: EA-43679 - NPE: OpenProjectFileChooserDescriptor.isProjectDirectory
bbbcefe: EA-51102 - assert: ComponentManagerImpl.getComponent
f64832e: diagnostics for EA-51270 - NPE: NewDirectoryProjectAction.generateProject
9de01fa: Apache Commons Codec updated to latest version (EA-49145 - NSME: GGSSchemeBase.<init>)
de58cf0: EA-51040 - IAE: PyClassImpl.findProperty
c41ede9: make hotswapping really cancellable
831a938: IDEA-115705 "Go to definition" for table names stopped working
5c70e41: Merge branch 'svn_18_2'
b1bd165: Added readme file for libpty library
8127178: Updated pty4j library version - support search native libraries in "libpty" subfolder
1e0a4e0: Moved pty4j (with dependencies) from terminal plugin to community
276e71e: svn: AuthCallbackCase refactored - update Command directly (instead of parameters list)
84b7ba4: svn: Refactored Command - renamed addParameters() to put()
1064a75: svn: Implemented proxies support for command line - use "--config-option" arguments (instead of temp directory with updated configuration file)
6b5ce91: svn: Refactored AuthenticationCallback - extracted methods to provide proxy server credentials
62e17cf: svn: Refactored SvnConfiguration - extracted methods to find config group for given host
b03dd2b: new inference: skip Object bound during incorporation
9286cb4: testdata fixed
cc96563: new inference: infer for constructor calls by containing class
b06d2d9: svn: Refactored CommandParametersResolutionModule - proxy settings initialization moved to separate ProxyModule
df370df: Refactored IdeaSvnkitBasedAuthenticationCallback - do not throw checked URISyntaxException when converting SVNURL to URI
abc8681: correct fix for PY-9356
4887bb6: svn: Refactored CommandRuntime - resolving command parameters (repository url, working directory) logic moved to separate command runtime module
987e2c6: IDEA-113593 Used new map instead of immutable empty map for ProxyGroup properties
699c06d: cleanup
b8d6cd5: Possibility to modify move refactoring dialogs in from scala plugin
781fa3e: more diagnostics for "tree changed while calculating text" (EA-51450)
585a0d6: RotoIndex: a bit more diagnostics for infinite VFS nesting
0083f69: IDEA-99810 Provide an automated mode to surround something with `
67114f7: remove color from more file template descriptions to get them to display nicely under Darcula
fbe5538: bold keyword
b9cc351: restore ability to compile under JDK 1.6.0_23
541daa4: Merge remote-tracking branch 'origin/master'
c09fed7: continue WEB-6413 sourcemap backed breakpoints do not work until page is loaded
210f353: Merge remote-tracking branch 'origin/master'
7eb82bd: Terminal shortcut conflicts with } symbol on French keyboard. Now it is Alt+F12 (PY-11011).
de1b9f2: optimization: for OptimizedFilemanager classes always use directory cache and clear affected cache entries on new files generation
8d80445: Cleanup (typos)
a9eacb0: [log] Don't load the log on startup: wait until user opens it
013f787: http://ea.jetbrains.com/browser/ea_problems/51445
6fece30: WI-20091 Rename refactoring produces unexpected results damaging code (cherry picked from commit 599fd3e)
09594c5: IDEA-115691 Keyboard shortcut for 'Refresh all Gradle project' should be accessible globally
45bfafe: revert changes with log command optimization instead of status command
12234b8: IDEA-115677 Jumplist shows a single project name, though there are several projects opened in one window
ea6952f: HashImpl.build methods and commit details constructors changed to VcsLogObjectsFactory methods.
7ed7cf8: jmockit added \IDEA\community\.idea\libraries\Mocks.xml
576df26: decrease font size
19687d9: method refs: ignore same method signatures, include superclass substitutions
3c0c498: new inference: choose proper type from equality bounds if present
f6a8f67: EA-51451 (avoid resolve on building .class mirror)
a4c1643: injected smart pointers
0b9244f: Merge remote-tracking branch 'origin/master'
b2c593b: IDEA-95533 Darcula: cannot use comboboxes with a keyboard
c68c3a6: IDEA-90470 Add Gradle Dependencies With Alt-Insert
59260a4: restored 'recover from PersistentHashMap storage format change' change
95e6d8c: Merge remote-tracking branch 'origin/master'
6fc37c0: migrated to SequenceLock from jsr166
1f47d8f: cleanup
a9da1ee: weak list implementation simplified, made not-random access, blinking tests nomore
9146a68: cleanup
efa003b: Gradle: support for discovery of Gradle 1.9 src layout
c5e1af3: Gradle: fix discovery of module path for custom named root project
2c448e7: EA-51361 - assert: PsiParserFacadeImpl.createLineOrBlockCommentFromText
8cdbb18: Make mercurial distributed vcs
92f362a: mercurial ref group changed to SingletonRefGroup
fe6fda3: IDEA-115660 Fix Spock library in Create test dialog does not work
d0c0584: new inference: simplification
fdd55c5: lambda: skip wildcards in return types for now
0b6ae5f: ensure junit_rt class version for community
df00d54: method refs: separate ::new now in api
0ba945c: new inference: method refs: do not provide raw substitutor when containing class provides empty one
80131fa: code style
de0ac91: [log] turn new Git log on by default
2aea0a6: [log] Don't wait under a modal progress until the log is loaded & built
ac28ad0: [log] Disable the assertion until properly fixed.
c7de3a7: NPE fix
9490f57: Restoring fix for RUBY-14390
9c59b57: Merge remote-tracking branch 'origin/master'
d30ad70: IDEA-115629 plugin.xml: provide bundle/property-key reference where applicable
d30cf27: remove annotation altogether
945d18b: fixed PY-10248 Suggestion does not suggest "in" keyword after "for x "
58c2b08: NPE fix
7e9c756: fixed PY-3687 No completion for keywords in list comprehensions
20ee27d: NPE fix
0ee1660: RUBY-12993 Quick Fix puts a new created sass file to the not corresponding place
16a2e62: http://ea.jetbrains.com/browser/ea_problems/49730
00d0ef5: ThreadFactory.newThread() is allowed to return null
365c726: Fix OC-5992 Formatter: PsiComment.BlockFormatting ->PsiDocCommentBase +review CR-OC-1034
07a29bd: RootIndex: less vfs lookups when searching for non-existing packages, don't cache empty results
54b7936: new inference: infer from return value from method ref
c61dbfb: root model: don't create synthetic entries for excluded output folders - fixed importing excluded roots from Maven
9d3d310: FacetImporterTestCase simplified
f9145cb: place of 'package-info.java' item in 'New' menu corrected (IDEA-115658, IDEA-115086)
6212b1d: root model: don't create synthetic entries for excluded output folders - 2
b8937b2: FIX: IllegalStateException with many duplicates
97cfae5: compile fix: implementation for RefGroup changed interface
00f7ea1: Find: Comments only: Groovy javadoc comments are skipped (IDEA-115578)
35f9256: new log for mercurial first implementation
4ff44ec: Fixing IDEA-115649 Compiler cannot resolve references to classes generated by annotation processors 1. save generated files synchronously 2. do not use cache when listing files from output directories
9b9dd9f: do not unwrap index elements in TypeScript when resolving type name
8685c8e: Fix winpty executables.
49b36a5: Merge remote-tracking branch 'origin/master'
2bfd6ef: Pty libraries for windows updated (PY-10548, PY-11207, PY-11179).
a9fb95a: NPE fix
2d080ba: to make programmatic registration easier, use explicit ExtensionPointName instance in extension points that use KeyedExtensionFactory
6c1b0cc: move XML highlighters to xml-psi
4919510: target 1.5 also for testng (IDEA-115618)
ed14625: init WEB-6413 sourcemap backed breakpoints do not work until page is loaded
4cfc285: IDEA-115583 exception on CTRL+SHiFT+A on welcome screen
0af73af: [log] log the error only once per request
d59d5f2: [log] toString()
633f1c7: [git] Don't print git log --tags command output to the log & console
6377dc2: [log] Allow null roots in the GraphTableModel.
f317ede: [log] Don't allow the graph table to repaint during graph modification
843a2a5: [log] IDEA-115370 Execute potentially slow tasks under modal progress
9e22d99: [log] invokeLater only if needed
54e1744: [log] New icons for expand/collapse branches & show/hide long edges
8afe9ac: Merge branch 'types-db-to-skeletons'
7a6ff4c: check disposed state
1f6b15f: more diagnostic for assertion
8ca343f: Removed properties-based stdlib types database
53a88a7: #WEB-555 fixed
bb0b789: Disabling JumpList because of some issues on win32 platform.
83f4128: Bug fix: Create Test dialog does not initialize 'superclass' field.
9f92b82: Added canonical import path for names of 'sqlite3' module
8c7b497: IDEA-113332 Typing an attribute in XML/HTML files ends up with corrupted XML
c4f7d79: IDEA-113332 Typing an attribute in XML/HTML files ends up with corrupted XML
1d41f55: fixed PY-4540 Completion: else keyword should be available in try block only after except
7eea5ac: Fix OC-3040 rollback changes in platform +review CR-OC-1015
c74d76e: Enabling jumplist for IDEA-108265.
d56e66b: IDEA-113758 Create Specifications when creating tests
e6d73b2: fixed PY-4539 Completion: elif keyword shouldn't be available in completion list after else extracted keyword completion tests
2f1950f: IDEA-115561 Appearance of vertical and horizontal scroll bars in the search results is unexpected often
aa8d3a6: make static method public
ad20fee: 'os.error' is now defined in Python skeletons
4b8e087: Merge remote-tracking branch 'origin/master'
989d844: make selected group always visible
fcc533c: added sources for asm4 to community project
54a9e14: adjust popup according to screen size
1675867: Merge remote-tracking branch 'origin/master'
9ac6c97: allow to change gap between popups
4bc1556: fixing tests
d88d171: support line-separated editing #WEB-2407 fixed
053d812: WEB-9778 Strange bug on Emmet when using curly braces
9aabdfa: fix test mem leak?
6abbcee: Merge remote-tracking branch 'origin/master'
4b0090a: Merge remote-tracking branch 'origin/master'
d2af65c: simplification: processing and removing excluded folders
7f3c767: IDEA-115541 'Navigate to class' is opened after Enter if nothing was found in 'Search Everywhere'.
7c26cf8: Revert API changes
f99d0ec: Cloud Bees: show application URL in console when application is deployed
4f00f3f: Decimal is a subclass of numbers.Number
a632bbd: Use constants for names of the 'numbers' classes
Change-Id: I3a503061740122065cef5ac45a01f0759b8f4073
Diffstat (limited to 'java/java-impl/src/com/intellij')
83 files changed, 626 insertions, 705 deletions
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionData.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionData.java index a9167f297091..52725a0afa77 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionData.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionData.java @@ -429,8 +429,13 @@ public class JavaCompletionData extends JavaAwareCompletionData { } if (SUPER_OR_THIS_PATTERN.accepts(position)) { - if (!AFTER_DOT.accepts(position) || isInsideQualifierClass(position)) { - result.addElement(createKeyword(position, PsiKeyword.THIS)); + final boolean afterDot = AFTER_DOT.accepts(position); + final boolean insideQualifierClass = isInsideQualifierClass(position); + final boolean insideInheritorClass = PsiUtil.isLanguageLevel8OrHigher(position) && isInsideInheritorClass(position); + if (!afterDot || insideQualifierClass || insideInheritorClass) { + if (!afterDot || insideQualifierClass) { + result.addElement(createKeyword(position, PsiKeyword.THIS)); + } final LookupItem superItem = (LookupItem)createKeyword(position, PsiKeyword.SUPER); if (psiElement().afterLeaf(psiElement().withText("{").withSuperParent(2, psiMethod().constructor(true))).accepts(position)) { @@ -732,6 +737,25 @@ public class JavaCompletionData extends JavaAwareCompletionData { return false; } + private static boolean isInsideInheritorClass(PsiElement position) { + if (position.getParent() instanceof PsiJavaCodeReferenceElement) { + final PsiElement qualifier = ((PsiJavaCodeReferenceElement)position.getParent()).getQualifier(); + if (qualifier instanceof PsiJavaCodeReferenceElement) { + final PsiElement qualifierClass = ((PsiJavaCodeReferenceElement)qualifier).resolve(); + if (qualifierClass instanceof PsiClass && ((PsiClass)qualifierClass).isInterface()) { + PsiElement parent = position; + while ((parent = PsiTreeUtil.getParentOfType(parent, PsiClass.class, true)) != null) { + if (PsiUtil.getEnclosingStaticElement(position, (PsiClass)parent) == null && + ((PsiClass)parent).isInheritor((PsiClass)qualifierClass, true)) { + return true; + } + } + } + } + } + return false; + } + private static boolean superConstructorHasParameters(PsiMethod method) { final PsiClass psiClass = method.getContainingClass(); if (psiClass == null) { diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java index 1ebc7e42cfb5..e2296e4c3d2c 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java @@ -331,7 +331,11 @@ public class JavaCompletionSorting { if (type instanceof PsiClassType) { final PsiClass psiClass = ((PsiClassType)type).resolve(); if (psiClass != null && CommonClassNames.JAVA_LANG_CLASS.equals(psiClass.getQualifiedName())) { - return GenericsUtil.eliminateWildcards(type); + PsiClassType erased = (PsiClassType)GenericsUtil.eliminateWildcards(type); + PsiType[] parameters = erased.getParameters(); + if (parameters.length == 1 && !parameters[0].equalsToText(CommonClassNames.JAVA_LANG_OBJECT)) { + return erased; + } } } return type; diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/methodChains/Constants.java b/java/java-impl/src/com/intellij/codeInsight/completion/methodChains/Constants.java deleted file mode 100644 index 7a326a70d4c7..000000000000 --- a/java/java-impl/src/com/intellij/codeInsight/completion/methodChains/Constants.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.intellij.codeInsight.completion.methodChains; - -/** - * @author Dmitry Batkovich - */ -public final class Constants { - - private Constants() { - } - - /** - * magic numbers - */ - public static final int SINGLETON_MAGIC_RATIO = 100; - - public static final int SINGLETON_MAGIC_RATIO2 = 5; - - public static final int CHAIN_SEARCH_MAGIC_RATIO = 12; - -} diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/methodChains/completion/MethodsChainsCompletionContributor.java b/java/java-impl/src/com/intellij/codeInsight/completion/methodChains/completion/MethodsChainsCompletionContributor.java index 8781e46630bf..9b602dc63dfa 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/methodChains/completion/MethodsChainsCompletionContributor.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/methodChains/completion/MethodsChainsCompletionContributor.java @@ -58,11 +58,9 @@ public class MethodsChainsCompletionContributor extends CompletionContributor { protected void addCompletions(final @NotNull CompletionParameters parameters, final ProcessingContext context, final @NotNull CompletionResultSet result) { - final ChainCompletionContext completionContext = extractContext(parameters); if (completionContext == null) return; - final String targetClassQName = completionContext.getTargetQName(); final Set<String> contextTypesKeysSet = completionContext.getContextTypes(); final Set<String> contextRelevantTypes = new HashSet<String>(contextTypesKeysSet.size() + 1); @@ -73,9 +71,7 @@ public class MethodsChainsCompletionContributor extends CompletionContributor { } contextRelevantTypes.remove(targetClassQName); - //final boolean useBigrams = ApplicationManager.getApplication().isUnitTestMode() || parameters.getInvocationCount() == 3; - final boolean useBigrams = true; - final List<LookupElement> foundElements = searchForLookups(targetClassQName, contextRelevantTypes, completionContext, useBigrams); + final List<LookupElement> foundElements = searchForLookups(targetClassQName, contextRelevantTypes, completionContext); result.addAllElements(foundElements); } }); @@ -83,9 +79,8 @@ public class MethodsChainsCompletionContributor extends CompletionContributor { private static List<LookupElement> searchForLookups(final String targetClassQName, final Set<String> contextRelevantTypes, - final ChainCompletionContext completionContext, - final boolean useBigrams) { - final MethodChainsSearchService searchService = new MethodChainsSearchService(completionContext.getProject(), useBigrams); + final ChainCompletionContext completionContext) { + final MethodChainsSearchService searchService = new MethodChainsSearchService(completionContext.getProject()); final List<MethodsChain> searchResult = searchChains(targetClassQName, contextRelevantTypes, MAX_SEARCH_RESULT_SIZE, MAX_CHAIN_SIZE, completionContext, searchService); if (searchResult.size() < MAX_SEARCH_RESULT_SIZE) { diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/methodChains/search/ChainsSearcher.java b/java/java-impl/src/com/intellij/codeInsight/completion/methodChains/search/ChainsSearcher.java index 660e0f7f67c3..5ecba096b7bb 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/methodChains/search/ChainsSearcher.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/methodChains/search/ChainsSearcher.java @@ -3,9 +3,13 @@ package com.intellij.codeInsight.completion.methodChains.search; import com.intellij.codeInsight.completion.methodChains.completion.context.ChainCompletionContext; import com.intellij.compilerOutputIndex.impl.MethodIncompleteSignature; import com.intellij.compilerOutputIndex.impl.UsageIndexValue; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.util.Pair; +import com.intellij.psi.PsiClass; +import com.intellij.psi.PsiManager; import com.intellij.psi.PsiMethod; +import com.intellij.psi.PsiModifier; import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.FactoryMap; @@ -16,7 +20,12 @@ import java.util.*; /** * @author Dmitry Batkovich */ -public class ChainsSearcher { +public final class ChainsSearcher { + private ChainsSearcher() { + } + + private static final Logger LOG = Logger.getInstance(ChainsSearcher.class); + private static final double NEXT_METHOD_IN_CHAIN_RATIO = 1.5; public static List<MethodsChain> search(final MethodChainsSearchService searchService, final String targetQName, @@ -86,7 +95,6 @@ public class ChainsSearcher { } final ResultHolder result = new ResultHolder(context); - while (!q.isEmpty()) { ProgressManager.checkCanceled(); final WeightAware<Pair<MethodIncompleteSignature, MethodsChain>> currentVertex = q.poll(); @@ -100,13 +108,13 @@ public class ChainsSearcher { result.add(currentVertex.getUnderlying().getSecond()); continue; } - final SortedSet<UsageIndexValue> bigrams = searchService.getBigram(currentVertexUnderlying.getFirst()); + final SortedSet<UsageIndexValue> nextMethods = searchService.getMethods(currentVertexUnderlying.getFirst().getOwner()); final MaxSizeTreeSet<WeightAware<MethodIncompleteSignature>> currentSignatures = new MaxSizeTreeSet<WeightAware<MethodIncompleteSignature>>(maxResultSize); - for (final UsageIndexValue indexValue : bigrams) { + for (final UsageIndexValue indexValue : nextMethods) { final MethodIncompleteSignature vertex = indexValue.getMethodIncompleteSignature(); final int occurrences = indexValue.getOccurrences(); - if (!vertex.getOwner().equals(targetQName)) { + if (vertex.isStatic() || !vertex.getOwner().equals(targetQName)) { final int vertexDistance = Math.min(currentVertexDistance, occurrences); final MethodsChain knownVertexMethodsChain = knownDistance.get(vertex); if ((knownVertexMethodsChain == null || knownVertexMethodsChain.getChainWeight() < vertexDistance)) { @@ -124,6 +132,9 @@ public class ChainsSearcher { } } } + else { + break; + } } } boolean updated = false; @@ -132,7 +143,7 @@ public class ChainsSearcher { for (final WeightAware<MethodIncompleteSignature> sign : currentSignatures) { final PsiMethod[] resolved = resolver.get(sign.getUnderlying()); if (!isBreak) { - if (sign.getWeight() * maxResultSize > currentVertex.getWeight()) { + if (sign.getWeight() * NEXT_METHOD_IN_CHAIN_RATIO > currentVertex.getWeight()) { final boolean stopChain = sign.getUnderlying().isStatic() || toSet.contains(sign.getUnderlying().getOwner()); if (stopChain) { updated = true; @@ -151,7 +162,8 @@ public class ChainsSearcher { } final MethodsChain methodsChain = currentVertexUnderlying.second.addEdge(resolved, sign.getUnderlying().getOwner(), sign.getWeight()); - if (ParametersMatcher.matchParameters(methodsChain, context).noUnmatchedAndHasMatched()) { + final ParametersMatcher.MatchResult parametersMatchResult = ParametersMatcher.matchParameters(methodsChain, context); + if (parametersMatchResult.noUnmatchedAndHasMatched() && parametersMatchResult.hasTarget()) { updated = true; q.addFirst(new WeightAware<Pair<MethodIncompleteSignature, MethodsChain>>( new Pair<MethodIncompleteSignature, MethodsChain>(sign.getUnderlying(), methodsChain), sign.getWeight())); @@ -171,8 +183,15 @@ public class ChainsSearcher { return result.getResult(); } - private static class ResultHolder { + private static MethodsChain createChainFromFirstElement(final MethodsChain chain, final PsiClass newQualifierClass) { + final String qualifiedClassName = newQualifierClass.getQualifiedName(); + if (qualifiedClassName == null) { + throw new IllegalArgumentException(); + } + return new MethodsChain(chain.getFirst(), chain.getChainWeight(), qualifiedClassName); + } + private static class ResultHolder { private final List<MethodsChain> myResult; private final ChainCompletionContext myContext; @@ -212,48 +231,67 @@ public class ChainsSearcher { } } - public List<MethodsChain> getResult() { + public List<MethodsChain> getRawResult() { return myResult; } + public List<MethodsChain> getResult() { + return findSimilar(reduceChainsSize(myResult, PsiManager.getInstance(myContext.getProject())), myContext); + } + public int size() { return myResult.size(); } - } - private static int sumWeight(MaxSizeTreeSet<WeightAware<MethodIncompleteSignature>> weightAwareSignatures) { - int weight = 0; - for (WeightAware<MethodIncompleteSignature> weightAware : weightAwareSignatures) { - weight += weightAware.getWeight(); + private static List<MethodsChain> reduceChainsSize(final List<MethodsChain> chains, final PsiManager psiManager) { + return ContainerUtil.map(chains, new Function<MethodsChain, MethodsChain>() { + @Override + public MethodsChain fun(final MethodsChain chain) { + final Iterator<PsiMethod[]> chainIterator = chain.iterator(); + if (!chainIterator.hasNext()) { + LOG.error("empty chain"); + return chain; + } + final PsiMethod[] first = chainIterator.next(); + while (chainIterator.hasNext()) { + final PsiMethod psiMethod = chainIterator.next()[0]; + if (psiMethod.hasModifierProperty(PsiModifier.STATIC)) { + continue; + } + final PsiClass current = psiMethod.getContainingClass(); + if (current == null) { + LOG.error("containing class must be not null"); + return chain; + } + final PsiMethod[] currentMethods = current.findMethodsByName(first[0].getName(), true); + if (currentMethods.length != 0) { + for (final PsiMethod f : first) { + final PsiMethod[] fSupers = f.findDeepestSuperMethods(); + final PsiMethod fSuper = fSupers.length == 0 ? first[0] : fSupers[0]; + for (final PsiMethod currentMethod : currentMethods) { + if (psiManager.areElementsEquivalent(currentMethod, fSuper)) { + return createChainFromFirstElement(chain, currentMethod.getContainingClass()); + } + for (final PsiMethod method : currentMethod.findDeepestSuperMethods()) { + if (psiManager.areElementsEquivalent(method, fSuper)) { + return createChainFromFirstElement(chain, method.getContainingClass()); + } + } + } + } + } + } + return chain; + } + }); } - return weight; - } - private static boolean doChoose(final SortedSet<UsageIndexValue> bigrams, final int currentWeight, final int maxResultSize) { - if (bigrams.size() == 1) { - return true; - } - int sumWeight = 0; - for (final UsageIndexValue bigram : bigrams) { - sumWeight += bigram.getOccurrences(); - } - if (Math.abs(sumWeight - currentWeight) < currentWeight / maxResultSize) { - return true; - } - final List<UsageIndexValue> essentialValues = new ArrayList<UsageIndexValue>(); - Integer max = null; - for (UsageIndexValue bigram : bigrams) { - if (max == null) { - max = bigram.getOccurrences(); - } - if (max / bigram.getOccurrences() > maxResultSize) { - break; - } - essentialValues.add(bigram); - if (essentialValues.size() > maxResultSize) { - return false; + private static List<MethodsChain> findSimilar(final List<MethodsChain> chains, final ChainCompletionContext context) { + final ResultHolder resultHolder = new ResultHolder(context); + for (final MethodsChain chain : chains) { + resultHolder.add(chain); } + return resultHolder.getRawResult(); } - return true; } -}
\ No newline at end of file +} diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/methodChains/search/MethodChainsSearchService.java b/java/java-impl/src/com/intellij/codeInsight/completion/methodChains/search/MethodChainsSearchService.java index 2c004593929e..587945d53fea 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/methodChains/search/MethodChainsSearchService.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/methodChains/search/MethodChainsSearchService.java @@ -1,9 +1,7 @@ package com.intellij.codeInsight.completion.methodChains.search; -import com.intellij.compilerOutputIndex.impl.MethodIncompleteSignature; import com.intellij.compilerOutputIndex.impl.MethodsUsageIndex; import com.intellij.compilerOutputIndex.impl.UsageIndexValue; -import com.intellij.compilerOutputIndex.impl.bigram.BigramMethodsUsageIndex; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiManager; import org.jetbrains.annotations.NotNull; @@ -18,14 +16,10 @@ public class MethodChainsSearchService { private final static SortedSet EMPTY_SORTED_SET = new TreeSet(); private final MethodsUsageIndex myMethodsUsageIndex; - private final BigramMethodsUsageIndex myBigramMethodsUsageIndex; private final Project myProject; - private final boolean myUseBigrams; - public MethodChainsSearchService(final Project project, final boolean useBigrams) { - myUseBigrams = useBigrams; + public MethodChainsSearchService(final Project project) { myMethodsUsageIndex = MethodsUsageIndex.getInstance(project); - myBigramMethodsUsageIndex = BigramMethodsUsageIndex.getInstance(project); myProject = project; } @@ -35,18 +29,6 @@ public class MethodChainsSearchService { @NotNull @SuppressWarnings("unchecked") - public SortedSet<UsageIndexValue> getBigram(final MethodIncompleteSignature methodIncompleteSignature) { - final TreeSet<UsageIndexValue> values = myUseBigrams - ? myBigramMethodsUsageIndex.getValues(methodIncompleteSignature) - : myMethodsUsageIndex.getValues(methodIncompleteSignature.getOwner()); - if (values != null) { - return values; - } - return EMPTY_SORTED_SET; - } - - @NotNull - @SuppressWarnings("unchecked") public SortedSet<UsageIndexValue> getMethods(final String targetQName) { final TreeSet<UsageIndexValue> value = myMethodsUsageIndex.getValues(targetQName); if (value != null) { diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/methodChains/search/MethodsChain.java b/java/java-impl/src/com/intellij/codeInsight/completion/methodChains/search/MethodsChain.java index 517a1d6181b8..a4b055b7e458 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/methodChains/search/MethodsChain.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/methodChains/search/MethodsChain.java @@ -4,13 +4,12 @@ import com.intellij.codeInsight.completion.methodChains.completion.context.Chain import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiManager; import com.intellij.psi.PsiMethod; -import com.intellij.util.containers.ContainerUtil; -import org.jetbrains.annotations.Nullable; +import com.intellij.psi.PsiParameter; +import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; +import java.util.*; +import static com.intellij.util.containers.ContainerUtil.findAll; import static com.intellij.util.containers.ContainerUtil.reverse; /** @@ -23,27 +22,41 @@ public class MethodsChain { // chain qualifier class could be different with method.getContainingClass() private final String myQualifierClassName; + private final Set<String> myExcludedQNames; + public MethodsChain(final PsiMethod[] methods, final int weight, final String qualifierClassName) { - this(ContainerUtil.<PsiMethod[]>newArrayList(methods), weight, qualifierClassName); + this(Collections.singletonList(methods), weight, qualifierClassName, chooseParametersQNames(methods)); } - public MethodsChain(final List<PsiMethod[]> revertedPath, final int weight, final String qualifierClassName) { + private MethodsChain(final List<PsiMethod[]> revertedPath, + final int weight, + final String qualifierClassName, + final Set<String> excludedQNames) { myRevertedPath = revertedPath; myWeight = weight; myQualifierClassName = qualifierClassName; + myExcludedQNames = excludedQNames; } public int size() { return myRevertedPath.size(); } + public Set<String> getExcludedQNames() { + return myExcludedQNames; + } + public String getQualifierClassName() { return myQualifierClassName; } - @Nullable - public PsiMethod getOneOfFirst() { - return (myRevertedPath.isEmpty() || myRevertedPath.get(0).length == 0) ? null : myRevertedPath.get(myRevertedPath.size() - 1)[0]; + public Iterator<PsiMethod[]> iterator() { + return myRevertedPath.iterator(); + } + + @NotNull + public PsiMethod[] getFirst() { + return myRevertedPath.get(0); } public List<PsiMethod[]> getPath() { @@ -54,13 +67,18 @@ public class MethodsChain { return myWeight; } + @SuppressWarnings("unchecked") public MethodsChain addEdge(final PsiMethod[] psiMethods, final String newQualifierClassName, final int newWeight) { final List<PsiMethod[]> newRevertedPath = new ArrayList<PsiMethod[]>(myRevertedPath.size() + 1); newRevertedPath.addAll(myRevertedPath); newRevertedPath.add(psiMethods); - return new MethodsChain(newRevertedPath, newWeight, newQualifierClassName); + return new MethodsChain(newRevertedPath, + newWeight, + newQualifierClassName, + joinSets(myExcludedQNames, chooseParametersQNames(psiMethods))); } + @Override public String toString() { return StringUtil.join(myRevertedPath, "<-"); @@ -100,8 +118,15 @@ public class MethodsChain { : CompareResult.NOT_EQUAL; } + public enum CompareResult { + LEFT_CONTAINS_RIGHT, + RIGHT_CONTAINS_LEFT, + EQUAL, + NOT_EQUAL + } + private static boolean hasBaseMethod(final PsiMethod[] left, final PsiMethod[] right, final PsiManager psiManager) { - for (PsiMethod rightMethod : right) { + for (final PsiMethod rightMethod : right) { final PsiMethod[] rightSupers = rightMethod.findDeepestSuperMethods(); if (rightSupers.length != 0) { for (final PsiMethod leftMethod : left) { @@ -113,13 +138,26 @@ public class MethodsChain { } } } - } return false; + } + return false; } - public enum CompareResult { - LEFT_CONTAINS_RIGHT, - RIGHT_CONTAINS_LEFT, - EQUAL, - NOT_EQUAL + private static Set<String> joinSets(final Set<String>... sets) { + final Set<String> result = new HashSet<String>(); + for (final Set<String> set : sets) { + for (final String s : set) { + result.add(s); + } + } + return result; + } + + private static Set<String> chooseParametersQNames(final PsiMethod[] methods) { + final Set<String> qNames = new HashSet<String>(); + for (final PsiParameter methodParameter : methods[0].getParameterList().getParameters()) { + qNames.add(methodParameter.getType().getCanonicalText()); + } + return qNames; } + } diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/methodChains/search/MethodsChainLookupRangingHelper.java b/java/java-impl/src/com/intellij/codeInsight/completion/methodChains/search/MethodsChainLookupRangingHelper.java index cd6d5516bd40..0389f76b35fb 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/methodChains/search/MethodsChainLookupRangingHelper.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/methodChains/search/MethodsChainLookupRangingHelper.java @@ -192,7 +192,6 @@ public class MethodsChainLookupRangingHelper { if (e != null) { final LookupElement firstChainElement; if (e instanceof PsiVariable) { - hasCallingVariableInContext = true; firstChainElement = new VariableLookupItem((PsiVariable)e); } else if (e instanceof PsiMethod) { @@ -204,6 +203,7 @@ public class MethodsChainLookupRangingHelper { else { throw new AssertionError(); } + hasCallingVariableInContext = true; lookupElement = new JavaChainLookupElement(firstChainElement, createLookupElement(method, parametersMap)); } else { diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/methodChains/search/ParametersMatcher.java b/java/java-impl/src/com/intellij/codeInsight/completion/methodChains/search/ParametersMatcher.java index 2c2a563cef8c..fd4d5d7c2d0b 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/methodChains/search/ParametersMatcher.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/methodChains/search/ParametersMatcher.java @@ -8,19 +8,22 @@ import com.intellij.psi.PsiType; import org.jetbrains.annotations.NotNull; import java.util.NavigableSet; +import java.util.Set; import java.util.TreeSet; /** * @author Dmitry Batkovich */ -public class ParametersMatcher { +public final class ParametersMatcher { + + private ParametersMatcher() {} public static MatchResult matchParameters(final MethodsChain chain, final ChainCompletionContext context) { MatchResult overallResult = EMPTY; for (final PsiMethod[] methods : chain.getPath()) { final NavigableSet<MatchResult> matchResults = new TreeSet<MatchResult>(); for (final PsiMethod method : methods) { - matchResults.add(matchParameters(method, context)); + matchResults.add(matchParameters(method, context, chain.getExcludedQNames())); } final MatchResult best = matchResults.first(); overallResult = overallResult.add(best); @@ -28,30 +31,37 @@ public class ParametersMatcher { return overallResult; } - public static MatchResult matchParameters(final PsiMethod method, final ChainCompletionContext context) { + private static MatchResult matchParameters(final PsiMethod method, final ChainCompletionContext context, final Set<String> additionalExcludedNames) { int matched = 0; int unMatched = 0; + boolean hasTarget = false; for (final PsiParameter parameter : method.getParameterList().getParameters()) { final PsiType type = parameter.getType(); - if (context.contains(type.getCanonicalText()) || type instanceof PsiPrimitiveType) { + final String canonicalText = type.getCanonicalText(); + if (context.contains(canonicalText) || type instanceof PsiPrimitiveType) { matched++; } else { unMatched++; } + if (context.getTargetQName().equals(canonicalText) || additionalExcludedNames.contains(canonicalText)) { + hasTarget = true; + } } - return new MatchResult(matched, unMatched); + return new MatchResult(matched, unMatched, hasTarget); } - private static final MatchResult EMPTY = new MatchResult(0, 0); + private static final MatchResult EMPTY = new MatchResult(0, 0, false); public static class MatchResult implements Comparable<MatchResult> { private final int myMatched; private final int myUnMatched; + private final boolean myHasTarget; - private MatchResult(final int matched, final int unMatched) { + private MatchResult(final int matched, final int unMatched, final boolean hasTarget) { myMatched = matched; myUnMatched = unMatched; + myHasTarget = hasTarget; } public int getMatched() { @@ -62,8 +72,12 @@ public class ParametersMatcher { return myUnMatched; } + public boolean hasTarget() { + return myHasTarget; + } + public MatchResult add(final MatchResult other) { - return new MatchResult(getMatched() + other.getMatched(), getUnMatched() + other.getUnMatched()); + return new MatchResult(getMatched() + other.getMatched(), getUnMatched() + other.getUnMatched(), other.myHasTarget || myHasTarget); } public boolean noUnmatchedAndHasMatched() { diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/methodChains/search/SearchInitializer.java b/java/java-impl/src/com/intellij/codeInsight/completion/methodChains/search/SearchInitializer.java index b89edb677836..54e6d01767e2 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/methodChains/search/SearchInitializer.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/methodChains/search/SearchInitializer.java @@ -1,6 +1,5 @@ package com.intellij.codeInsight.completion.methodChains.search; -import com.intellij.codeInsight.completion.methodChains.Constants; import com.intellij.compilerOutputIndex.impl.MethodIncompleteSignature; import com.intellij.compilerOutputIndex.impl.UsageIndexValue; import com.intellij.psi.PsiMethod; @@ -12,6 +11,8 @@ import java.util.*; * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com> */ public class SearchInitializer { + private final static int CHAIN_SEARCH_MAGIC_RATIO = 12; + private final List<WeightAware<MethodIncompleteSignature>> myVertices; private final LinkedHashMap<MethodIncompleteSignature, MethodsChain> myChains; private final FactoryMap<MethodIncompleteSignature, PsiMethod[]> myResolver; @@ -35,7 +36,7 @@ public class SearchInitializer { if (bestOccurrences == -1) { bestOccurrences = occurrences; } - else if (bestOccurrences > occurrences * Constants.CHAIN_SEARCH_MAGIC_RATIO) { + else if (bestOccurrences > occurrences * CHAIN_SEARCH_MAGIC_RATIO) { return; } } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/JavaAwareInspectionProfileCoverter.java b/java/java-impl/src/com/intellij/codeInsight/daemon/JavaAwareInspectionProfileCoverter.java index 5caad6166995..58e6fafa38c8 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/JavaAwareInspectionProfileCoverter.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/JavaAwareInspectionProfileCoverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ package com.intellij.codeInsight.daemon; import com.intellij.codeInspection.ModifiableModel; import com.intellij.codeInspection.ex.InspectionToolWrapper; import com.intellij.codeInspection.javaDoc.JavaDocLocalInspection; +import com.intellij.codeInspection.javaDoc.JavaDocLocalInspectionBase; import com.intellij.profile.codeInspection.InspectionProfileManager; import org.jdom.Element; import org.jetbrains.annotations.NonNls; @@ -52,7 +53,7 @@ public class JavaAwareInspectionProfileCoverter extends InspectionProfileConvert super.fillErrorLevels(profile); //javadoc attributes - final InspectionToolWrapper toolWrapper = profile.getInspectionTool(JavaDocLocalInspection.SHORT_NAME, null); + final InspectionToolWrapper toolWrapper = profile.getInspectionTool(JavaDocLocalInspectionBase.SHORT_NAME, null); JavaDocLocalInspection inspection = (JavaDocLocalInspection)toolWrapper.getTool(); inspection.myAdditionalJavadocTags = myAdditionalJavadocTags; } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/IconLineMarkerProvider.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/IconLineMarkerProvider.java index b3ef7ca2afce..5f470553e2d9 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/IconLineMarkerProvider.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/IconLineMarkerProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,7 +50,7 @@ import java.util.*; * @author Konstantin Bulenkov */ public class IconLineMarkerProvider implements LineMarkerProvider { - private static final @NonNls String JAVAX_SWING_ICON = "javax.swing.Icon"; + @NonNls private static final String JAVAX_SWING_ICON = "javax.swing.Icon"; private static final int ICON_MAX_WEIGHT = 16; private static final int ICON_MAX_HEIGHT = 16; private static final int ICON_MAX_SIZE = 2 * 1024 * 1024; //2Kb diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/MarkerType.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/MarkerType.java index 9b2b49328533..12b1788dcea7 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/MarkerType.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/MarkerType.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -298,8 +298,8 @@ public class MarkerType { } private static class OverridingMethodsUpdater extends ListBackgroundUpdaterTask { - private PsiMethod myMethod; - private PsiElementListCellRenderer myRenderer; + private final PsiMethod myMethod; + private final PsiElementListCellRenderer myRenderer; public OverridingMethodsUpdater(PsiMethod method, PsiElementListCellRenderer renderer) { super(method.getProject(), SEARCHING_FOR_OVERRIDING_METHODS); diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateClassFromUsageBaseFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateClassFromUsageBaseFix.java index 1845c960f7e9..ce91467d773d 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateClassFromUsageBaseFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateClassFromUsageBaseFix.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +44,7 @@ public abstract class CreateClassFromUsageBaseFix extends BaseIntentionAction { protected abstract String getText(String varName); - private boolean isAvailableInContext(final @NotNull PsiJavaCodeReferenceElement element) { + private boolean isAvailableInContext(@NotNull final PsiJavaCodeReferenceElement element) { PsiElement parent = element.getParent(); if (myKind == CreateClassKind.ANNOTATION) { diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateConstructorFromThisOrSuperFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateConstructorFromThisOrSuperFix.java index f944fc742b2a..4249e579aedf 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateConstructorFromThisOrSuperFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateConstructorFromThisOrSuperFix.java @@ -144,7 +144,7 @@ public abstract class CreateConstructorFromThisOrSuperFix extends CreateFromUsag PsiMethod method = (PsiMethod) methodCall.getMethodExpression().resolve(); PsiExpressionList argumentList = methodCall.getArgumentList(); List<PsiClass> classes = getTargetClasses(element); - return classes.size() > 0 && !CreateFromUsageUtils.shouldCreateConstructor(classes.get(0), argumentList, method); + return !classes.isEmpty() && !CreateFromUsageUtils.shouldCreateConstructor(classes.get(0), argumentList, method); } @Override diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateConstructorParameterFromFieldFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateConstructorParameterFromFieldFix.java index 2fc03f8b42ec..f47a780b599a 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateConstructorParameterFromFieldFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateConstructorParameterFromFieldFix.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -198,6 +198,7 @@ public class CreateConstructorParameterFromFieldFix implements IntentionAction { return finalFields.put(psiVariable, Boolean.TRUE) == null; } + @NotNull @Override public Iterator<SmartPsiElementPointer<PsiField>> iterator() { return finalFields.keySet().iterator(); diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreatePropertyFromUsageFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreatePropertyFromUsageFix.java index b1cf8282b263..c36c25f4b47b 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreatePropertyFromUsageFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreatePropertyFromUsageFix.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -82,7 +82,7 @@ public class CreatePropertyFromUsageFix extends CreateFromUsageBaseFix implement String methodName = myMethodCall.getMethodExpression().getReferenceName(); LOG.assertTrue(methodName != null); String propertyName = PropertyUtil.getPropertyName(methodName); - if (propertyName == null || propertyName.length() == 0) return false; + if (propertyName == null || propertyName.isEmpty()) return false; String getterOrSetter = null; if (methodName.startsWith(GET_PREFIX) || methodName.startsWith(IS_PREFIX)) { @@ -326,7 +326,7 @@ public class CreatePropertyFromUsageFix extends CreateFromUsageBaseFix implement JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(methodCall.getProject()); String methodName = methodCall.getMethodExpression().getReferenceName(); String propertyName = PropertyUtil.getPropertyName(methodName); - if (propertyName != null && propertyName.length() > 0) { + if (propertyName != null && !propertyName.isEmpty()) { VariableKind kind = isStatic ? VariableKind.STATIC_FIELD : VariableKind.FIELD; return codeStyleManager.propertyNameToVariableName(propertyName, kind); } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/LocateLibraryDialog.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/LocateLibraryDialog.java index 66af7f1300c9..ebc118e3e691 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/LocateLibraryDialog.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/LocateLibraryDialog.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,7 +52,7 @@ public class LocateLibraryDialog extends DialogWrapper { return myResultingLibraryPath; } - public LocateLibraryDialog(Module module, String libraryPath, final @NonNls String libraryName, final String libraryDescription ) { + public LocateLibraryDialog(Module module, String libraryPath, @NonNls final String libraryName, final String libraryDescription ) { super (module.getProject(), true); setTitle ( QuickFixBundle.message("add.library.title.dialog")); @@ -108,7 +108,7 @@ public class LocateLibraryDialog extends DialogWrapper { if ( copyEnabled ) { myCopyToDir.getTextField().requestFocusInWindow(); } - setOKActionEnabled(! copyEnabled || myCopyToDir.getText().length() != 0 ); + setOKActionEnabled(! copyEnabled || !myCopyToDir.getText().isEmpty()); } @Override @@ -147,7 +147,7 @@ public class LocateLibraryDialog extends DialogWrapper { } final String dstDir = myCopyToDir.getText(); - if ( dstDir.length() == 0 ) { + if (dstDir.isEmpty()) { return null; } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/PullAsAbstractUpFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/PullAsAbstractUpFix.java index c42829baafef..f079ffa1dc2d 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/PullAsAbstractUpFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/PullAsAbstractUpFix.java @@ -91,7 +91,7 @@ public class PullAsAbstractUpFix extends LocalQuickFixAndIntentionActionOnPsiEle collectClassesToPullUp(manager, classesToPullUp, containingClass.getExtendsListTypes()); collectClassesToPullUp(manager, classesToPullUp, containingClass.getImplementsListTypes()); - if (classesToPullUp.size() == 0) { + if (classesToPullUp.isEmpty()) { //check visibility new ExtractInterfaceHandler().invoke(project, new PsiElement[]{containingClass}, null); } @@ -154,7 +154,7 @@ public class PullAsAbstractUpFix extends LocalQuickFixAndIntentionActionOnPsiEle final LinkedHashSet<PsiClass> classesToPullUp = new LinkedHashSet<PsiClass>(); collectClassesToPullUp(manager, classesToPullUp, containingClass.getExtendsListTypes()); collectClassesToPullUp(manager, classesToPullUp, containingClass.getImplementsListTypes()); - if (classesToPullUp.size() == 0) { + if (classesToPullUp.isEmpty()) { name = "Extract method \'" + methodWithOverrides.getName() + "\' to new interface"; canBePulledUp = false; } else if (classesToPullUp.size() == 1) { diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/VariableAccessFromInnerClassFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/VariableAccessFromInnerClassFix.java index 131260f47cf7..98a271629093 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/VariableAccessFromInnerClassFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/VariableAccessFromInnerClassFix.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ import com.intellij.psi.codeStyle.JavaCodeStyleManager; import com.intellij.psi.controlFlow.ControlFlowUtil; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtil; +import com.intellij.refactoring.util.RefactoringUtil; import com.intellij.util.IncorrectOperationException; import com.intellij.util.containers.ConcurrentWeakHashMap; import gnu.trove.THashMap; @@ -139,6 +140,7 @@ public class VariableAccessFromInnerClassFix implements IntentionAction { return finalVars.put(psiVariable, Boolean.TRUE) == null; } + @NotNull @Override public Iterator<PsiVariable> iterator() { return finalVars.keySet().iterator(); @@ -203,9 +205,13 @@ public class VariableAccessFromInnerClassFix implements IntentionAction { PsiUtil.setModifierProperty(newVariable, PsiModifier.FINAL, true); PsiElement statement = getStatementToInsertBefore(); if (statement == null) return; - statement.getParent().addBefore(copyDecl, statement); PsiExpression newExpression = factory.createExpressionFromText(newName, myVariable); replaceReferences(myClass, myVariable, newExpression); + if (RefactoringUtil.isLoopOrIf(statement.getParent())) { + RefactoringUtil.putStatementInLoopBody(copyDecl, statement.getParent(), statement); + } else { + statement.getParent().addBefore(copyDecl, statement); + } } private PsiElement getStatementToInsertBefore() { @@ -216,7 +222,7 @@ public class VariableAccessFromInnerClassFix implements IntentionAction { PsiElement statement = myClass; nextInnerClass: do { - statement = PsiUtil.getEnclosingStatement(statement); + statement = RefactoringUtil.getParentStatement(statement, false); if (statement == null || statement.getParent() == null) { return null; diff --git a/java/java-impl/src/com/intellij/codeInsight/editorActions/wordSelection/MethodOrClassSelectioner.java b/java/java-impl/src/com/intellij/codeInsight/editorActions/wordSelection/MethodOrClassSelectioner.java index ef3315da52bd..c6526f63695c 100644 --- a/java/java-impl/src/com/intellij/codeInsight/editorActions/wordSelection/MethodOrClassSelectioner.java +++ b/java/java-impl/src/com/intellij/codeInsight/editorActions/wordSelection/MethodOrClassSelectioner.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ import com.intellij.openapi.editor.Editor; import com.intellij.openapi.util.TextRange; import com.intellij.psi.*; import com.intellij.psi.javadoc.PsiDocComment; -import com.intellij.util.containers.CollectionFactory; +import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import java.util.Collection; @@ -40,7 +40,7 @@ public class MethodOrClassSelectioner extends BasicSelectioner { @Override public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) { - List<TextRange> result = CollectionFactory.arrayList(e.getTextRange()); + List<TextRange> result = ContainerUtil.newArrayList(e.getTextRange()); result.addAll(expandToWholeLinesWithBlanks(editorText, e.getTextRange())); PsiElement firstChild = e.getFirstChild(); diff --git a/java/java-impl/src/com/intellij/codeInsight/highlighting/HighlightExitPointsHandlerFactory.java b/java/java-impl/src/com/intellij/codeInsight/highlighting/HighlightExitPointsHandlerFactory.java index 5b2a25e7678d..4a05420dd354 100644 --- a/java/java-impl/src/com/intellij/codeInsight/highlighting/HighlightExitPointsHandlerFactory.java +++ b/java/java-impl/src/com/intellij/codeInsight/highlighting/HighlightExitPointsHandlerFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,11 +15,11 @@ */ package com.intellij.codeInsight.highlighting; +import com.intellij.codeInsight.TargetElementUtilBase; import com.intellij.openapi.editor.Editor; -import com.intellij.psi.PsiFile; import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiFile; import com.intellij.psi.PsiKeyword; -import com.intellij.codeInsight.TargetElementUtilBase; /** * @author yole diff --git a/java/java-impl/src/com/intellij/codeInsight/highlighting/HighlightImportedElementsHandler.java b/java/java-impl/src/com/intellij/codeInsight/highlighting/HighlightImportedElementsHandler.java index b51094596c4f..71e301aa91f6 100644 --- a/java/java-impl/src/com/intellij/codeInsight/highlighting/HighlightImportedElementsHandler.java +++ b/java/java-impl/src/com/intellij/codeInsight/highlighting/HighlightImportedElementsHandler.java @@ -24,14 +24,12 @@ import com.intellij.openapi.ui.popup.PopupChooserBuilder; import com.intellij.psi.*; import com.intellij.psi.util.InheritanceUtil; import com.intellij.psi.util.PsiTreeUtil; -import com.intellij.ui.ListSpeedSearch; import com.intellij.ui.components.JBList; import com.intellij.util.Consumer; import com.intellij.util.Function; import org.jetbrains.annotations.NotNull; import javax.swing.*; -import java.io.Serializable; import java.util.*; /** @@ -165,6 +163,7 @@ public class HighlightImportedElementsHandler extends HighlightUsagesHandlerBase this.myImportStatic = importStatic; } + @Override public void visitReferenceElement(PsiJavaCodeReferenceElement reference) { super.visitReferenceElement(reference); if (!myImportStatic && reference.getText().equals(reference.getQualifiedName())) { @@ -283,6 +282,7 @@ public class HighlightImportedElementsHandler extends HighlightUsagesHandlerBase static class PsiMemberComparator implements Comparator<PsiMember> { + @Override public int compare(PsiMember member1, PsiMember member2) { final String name1 = member1.getName(); if (name1 == null) { diff --git a/java/java-impl/src/com/intellij/codeInsight/highlighting/HighlightOverridingMethodsHandlerFactory.java b/java/java-impl/src/com/intellij/codeInsight/highlighting/HighlightOverridingMethodsHandlerFactory.java index 965a90b8c414..bc9c0a47ce6f 100644 --- a/java/java-impl/src/com/intellij/codeInsight/highlighting/HighlightOverridingMethodsHandlerFactory.java +++ b/java/java-impl/src/com/intellij/codeInsight/highlighting/HighlightOverridingMethodsHandlerFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,9 +15,9 @@ */ package com.intellij.codeInsight.highlighting; +import com.intellij.codeInsight.TargetElementUtilBase; import com.intellij.openapi.editor.Editor; import com.intellij.psi.*; -import com.intellij.codeInsight.TargetElementUtilBase; /** * @author yole diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/ConvertAbsolutePathToRelativeIntentionAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/ConvertAbsolutePathToRelativeIntentionAction.java index 63df5bfa1288..dfede04c9fcd 100644 --- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/ConvertAbsolutePathToRelativeIntentionAction.java +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/ConvertAbsolutePathToRelativeIntentionAction.java @@ -20,14 +20,10 @@ import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiReference; -import com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference; import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReference; -import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceOwner; import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet; -import com.intellij.psi.impl.source.resolve.reference.impl.providers.PsiFileReference; import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; /** * @author spleaner @@ -41,7 +37,7 @@ public class ConvertAbsolutePathToRelativeIntentionAction extends BaseIntentionA @Override public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { final PsiReference reference = file.findReferenceAt(editor.getCaretModel().getOffset()); - final FileReference fileReference = reference == null ? null : findFileReference(reference); + final FileReference fileReference = reference == null ? null : FileReference.findFileReference(reference); if (fileReference != null) { final FileReferenceSet set = fileReference.getFileReferenceSet(); @@ -54,26 +50,6 @@ public class ConvertAbsolutePathToRelativeIntentionAction extends BaseIntentionA return false; } - @Nullable - private static FileReference findFileReference(@NotNull final PsiReference original) { - if (original instanceof PsiMultiReference) { - final PsiMultiReference multiReference = (PsiMultiReference)original; - for (PsiReference reference : multiReference.getReferences()) { - if (reference instanceof FileReference) { - return (FileReference)reference; - } - } - } - else if (original instanceof FileReferenceOwner) { - final PsiFileReference fileReference = ((FileReferenceOwner)original).getLastFileReference(); - if (fileReference instanceof FileReference) { - return (FileReference)fileReference; - } - } - - return null; - } - @Override @NotNull public String getFamilyName() { @@ -85,7 +61,7 @@ public class ConvertAbsolutePathToRelativeIntentionAction extends BaseIntentionA if (!FileModificationService.getInstance().prepareFileForWrite(file)) return; final PsiReference reference = file.findReferenceAt(editor.getCaretModel().getOffset()); - final FileReference fileReference = reference == null ? null : findFileReference(reference); + final FileReference fileReference = reference == null ? null : FileReference.findFileReference(reference); if (fileReference != null) { final FileReference lastReference = fileReference.getFileReferenceSet().getLastReference(); if (lastReference != null) lastReference.bindToElement(lastReference.resolve(), !isConvertToRelative()); diff --git a/java/java-impl/src/com/intellij/codeInspection/javaDoc/JavaDocReferenceInspection.java b/java/java-impl/src/com/intellij/codeInspection/javaDoc/JavaDocReferenceInspection.java index 1832a6fcdc3f..29e21845a7ad 100644 --- a/java/java-impl/src/com/intellij/codeInspection/javaDoc/JavaDocReferenceInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/javaDoc/JavaDocReferenceInspection.java @@ -42,6 +42,7 @@ import com.intellij.psi.PsiJavaCodeReferenceElement; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.proximity.PsiProximityComparator; import com.intellij.ui.components.JBList; +import com.intellij.util.Consumer; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -83,9 +84,9 @@ public class JavaDocReferenceInspection extends JavaDocReferenceInspectionBase { @Override public void applyFix(@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) { final AsyncResult<DataContext> asyncResult = DataManager.getInstance().getDataContextFromFocus(); - asyncResult.doWhenDone(new AsyncResult.Handler<DataContext>() { + asyncResult.doWhenDone(new Consumer<DataContext>() { @Override - public void run(DataContext dataContext) { + public void consume(DataContext dataContext) { final Editor editor = CommonDataKeys.EDITOR.getData(dataContext); assert editor != null; final TextRange textRange = ((ProblemDescriptorBase)descriptor).getTextRange(); @@ -152,9 +153,9 @@ public class JavaDocReferenceInspection extends JavaDocReferenceInspectionBase { } }; final AsyncResult<DataContext> asyncResult = DataManager.getInstance().getDataContextFromFocus(); - asyncResult.doWhenDone(new AsyncResult.Handler<DataContext>() { + asyncResult.doWhenDone(new Consumer<DataContext>() { @Override - public void run(DataContext dataContext) { + public void consume(DataContext dataContext) { new PopupChooserBuilder(list). setTitle(QuickFixBundle.message("add.qualifier.original.class.chooser.title")). setItemChoosenCallback(runnable). diff --git a/java/java-impl/src/com/intellij/compilerOutputIndex/api/fs/AsmUtil.java b/java/java-impl/src/com/intellij/compilerOutputIndex/api/fs/AsmUtil.java index 315a78e69c49..0ed09484e3ad 100644 --- a/java/java-impl/src/com/intellij/compilerOutputIndex/api/fs/AsmUtil.java +++ b/java/java-impl/src/com/intellij/compilerOutputIndex/api/fs/AsmUtil.java @@ -2,11 +2,13 @@ package com.intellij.compilerOutputIndex.api.fs; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.ArrayUtil; +import com.intellij.util.containers.ContainerUtil; import org.jetbrains.asm4.Opcodes; import org.jetbrains.asm4.Type; import java.util.ArrayList; import java.util.List; +import java.util.Set; /** * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com> @@ -52,4 +54,32 @@ public final class AsmUtil implements Opcodes { private static String asJavaInnerClassQName(final String byteCodeClassQName) { return StringUtil.replaceChar(byteCodeClassQName, '$', '.'); } + + //char + //double + //float + //int + //long + //short + //boolean + //byte + //void + //Object + //String + //Class + private static final Set<String> ASM_PRIMITIVE_TYPES = ContainerUtil.newHashSet("C", "D", "F", "I", "J", "S", "Z", "B", "V", + "Ljava/lang/Object;", + "Ljava/lang/String;", + "Ljava/lang/Class;"); + + public static boolean isPrimitive(final String asmType) { + return ASM_PRIMITIVE_TYPES.contains(asmType); + } + + public static boolean isPrimitiveOrArray(final String asmType) { + if (asmType.startsWith("[")) { + return true; + } + return isPrimitive(asmType); + } } diff --git a/java/java-impl/src/com/intellij/compilerOutputIndex/api/indexer/CompilerOutputBaseIndex.java b/java/java-impl/src/com/intellij/compilerOutputIndex/api/indexer/CompilerOutputBaseIndex.java index cc315b646281..1c0231b97b11 100644 --- a/java/java-impl/src/com/intellij/compilerOutputIndex/api/indexer/CompilerOutputBaseIndex.java +++ b/java/java-impl/src/com/intellij/compilerOutputIndex/api/indexer/CompilerOutputBaseIndex.java @@ -5,10 +5,11 @@ import com.intellij.openapi.extensions.ExtensionPointName; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Factory; import com.intellij.openapi.util.Ref; +import com.intellij.openapi.util.ThrowableComputable; import com.intellij.openapi.util.io.FileUtil; -import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.indexing.*; import com.intellij.util.io.DataExternalizer; +import com.intellij.util.io.IOUtil; import com.intellij.util.io.KeyDescriptor; import com.intellij.util.io.PersistentHashMap; import org.jetbrains.asm4.tree.ClassNode; @@ -51,24 +52,32 @@ public abstract class CompilerOutputBaseIndex<K, V> { if (!IndexInfrastructure.getIndexRootDir(indexId).exists()) { rewriteIndex.set(true); } - final File storageFile = IndexInfrastructure.getStorageFile(indexId); + final File storageFile = getStorageFile(indexId); final MapIndexStorage<K, V> indexStorage = new MapIndexStorage<K, V>(storageFile, myKeyDescriptor, myValueExternalizer, 1024); index = new MapReduceIndex<K, V, ClassNode>(indexId, getIndexer(), indexStorage); index.setInputIdToDataKeysIndex(new Factory<PersistentHashMap<Integer, Collection<K>>>() { @Override public PersistentHashMap<Integer, Collection<K>> create() { - Exception failCause = null; - for (int attempts = 0; attempts < 2; attempts++) { - try { - return FileBasedIndexImpl.createIdToDataKeysIndex(indexId, myKeyDescriptor, new MemoryIndexStorage<K, V>(indexStorage)); - } - catch (IOException e) { - failCause = e; - FileUtil.delete(IndexInfrastructure.getInputIndexStorageFile(getIndexId())); - rewriteIndex.set(true); - } + try { + return IOUtil.openCleanOrResetBroken( + new ThrowableComputable<PersistentHashMap<Integer, Collection<K>>, IOException>() { + @Override + public PersistentHashMap<Integer, Collection<K>> compute() throws IOException { + return FileBasedIndexImpl.createIdToDataKeysIndex(indexId, myKeyDescriptor, new MemoryIndexStorage<K, V>(indexStorage)); + } + }, + new Runnable() { + @Override + public void run() { + FileUtil.delete(getInputIndexStorageFile(getIndexId())); + rewriteIndex.set(true); + } + } + ); + } + catch (IOException e) { + throw new RuntimeException("couldn't create index", e); } - throw new RuntimeException("couldn't create index", failCause); } }); final File versionFile = getVersionFile(indexId); @@ -144,9 +153,4 @@ public abstract class CompilerOutputBaseIndex<K, V> { protected final ID<K, V> generateIndexId(final String indexName) { return CompilerOutputIndexUtil.generateIndexId(indexName, myProject); } - - protected final ID<K, V> generateIndexId(final Class aClass) { - final String className = StringUtil.getShortName(aClass); - return generateIndexId(StringUtil.trimEnd(className, "Index")); - } } diff --git a/java/java-impl/src/com/intellij/compilerOutputIndex/api/indexer/CompilerOutputIndexFeature.java b/java/java-impl/src/com/intellij/compilerOutputIndex/api/indexer/CompilerOutputIndexFeature.java index 95e0385e471f..7a8169fc1a74 100644 --- a/java/java-impl/src/com/intellij/compilerOutputIndex/api/indexer/CompilerOutputIndexFeature.java +++ b/java/java-impl/src/com/intellij/compilerOutputIndex/api/indexer/CompilerOutputIndexFeature.java @@ -16,7 +16,6 @@ package com.intellij.compilerOutputIndex.api.indexer; import com.intellij.compilerOutputIndex.impl.MethodsUsageIndex; -import com.intellij.compilerOutputIndex.impl.bigram.BigramMethodsUsageIndex; import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.registry.RegistryValue; import com.intellij.util.containers.ContainerUtil; @@ -31,7 +30,7 @@ import java.util.Collections; @SuppressWarnings("unchecked") public enum CompilerOutputIndexFeature { METHOD_CHAINS_COMPLETION("completion.enable.relevant.method.chain.suggestions", ContainerUtil - .<Class<? extends CompilerOutputBaseIndex>>newArrayList(BigramMethodsUsageIndex.class, MethodsUsageIndex.class)); + .<Class<? extends CompilerOutputBaseIndex>>newArrayList(MethodsUsageIndex.class)); @NotNull private final String myKey; diff --git a/java/java-impl/src/com/intellij/compilerOutputIndex/api/indexer/CompilerOutputIndexUtil.java b/java/java-impl/src/com/intellij/compilerOutputIndex/api/indexer/CompilerOutputIndexUtil.java index c096cc81a364..3ca255162ec3 100644 --- a/java/java-impl/src/com/intellij/compilerOutputIndex/api/indexer/CompilerOutputIndexUtil.java +++ b/java/java-impl/src/com/intellij/compilerOutputIndex/api/indexer/CompilerOutputIndexUtil.java @@ -11,11 +11,7 @@ public final class CompilerOutputIndexUtil { private CompilerOutputIndexUtil() {} public static <K, V> ID<K, V> generateIndexId(final String indexName, final Project project) { - return ID.create(String.format("compilerOutputIndex.%s.%d", indexName, Math.abs(project.getBasePath().hashCode()))); - } - - public static boolean isSetterOrConstructorMethodName(final String methodName) { - return MethodIncompleteSignature.CONSTRUCTOR_METHOD_NAME.equals(methodName) || methodName.startsWith("set"); - + final String hash = Integer.toHexString(project.getBasePath().hashCode()); + return ID.create(String.format("compilerOutputIndex.%s.%s", indexName, hash)); } } diff --git a/java/java-impl/src/com/intellij/compilerOutputIndex/api/indexer/CompilerOutputIndexer.java b/java/java-impl/src/com/intellij/compilerOutputIndex/api/indexer/CompilerOutputIndexer.java index d4f9927af485..fed4c02502b0 100644 --- a/java/java-impl/src/com/intellij/compilerOutputIndex/api/indexer/CompilerOutputIndexer.java +++ b/java/java-impl/src/com/intellij/compilerOutputIndex/api/indexer/CompilerOutputIndexer.java @@ -3,18 +3,16 @@ package com.intellij.compilerOutputIndex.api.indexer; import com.intellij.compilerOutputIndex.api.fs.CompilerOutputFilesUtil; import com.intellij.compilerOutputIndex.api.fs.FileVisitorService; import com.intellij.openapi.compiler.CompilationStatusAdapter; -import com.intellij.openapi.compiler.CompileContext; -import com.intellij.openapi.compiler.CompileTask; import com.intellij.openapi.compiler.CompilerManager; import com.intellij.openapi.components.AbstractProjectComponent; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.extensions.Extensions; -import com.intellij.openapi.module.Module; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.progress.Task; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.ThrowableComputable; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.registry.RegistryValue; import com.intellij.openapi.util.registry.RegistryValueListener; @@ -24,10 +22,7 @@ import com.intellij.util.containers.ConcurrentHashSet; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.indexing.ID; import com.intellij.util.indexing.IndexInfrastructure; -import com.intellij.util.io.DataExternalizer; -import com.intellij.util.io.EnumeratorStringDescriptor; -import com.intellij.util.io.PersistentEnumeratorDelegate; -import com.intellij.util.io.PersistentHashMap; +import com.intellij.util.io.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; @@ -159,10 +154,16 @@ public class CompilerOutputIndexer extends AbstractProjectComponent { private void doEnable() { if (myInitialized.compareAndSet(false, true)) { initTimestampIndex(); + final File storageFile = + IndexInfrastructure.getStorageFile(CompilerOutputIndexUtil.generateIndexId("compilerOutputIndexFileId.enum", myProject)); + try { - myFileEnumerator = new PersistentEnumeratorDelegate<String>( - IndexInfrastructure.getStorageFile(CompilerOutputIndexUtil.generateIndexId("compilerOutputIndexFileId.enum", myProject)), - new EnumeratorStringDescriptor(), 2048); + myFileEnumerator = IOUtil.openCleanOrResetBroken(new ThrowableComputable<PersistentEnumeratorDelegate<String>, IOException>() { + @Override + public PersistentEnumeratorDelegate<String> compute() throws IOException { + return new PersistentEnumeratorDelegate<String>(storageFile, new EnumeratorStringDescriptor(), 2048); + } + }, storageFile); } catch (IOException e) { throw new RuntimeException(e); @@ -187,29 +188,35 @@ public class CompilerOutputIndexer extends AbstractProjectComponent { } private void initTimestampIndex() { - for (int attempts = 0; attempts < 2; attempts++) { - try { - myFileTimestampsIndex = new PersistentHashMap<String, Long>(IndexInfrastructure.getStorageFile(getFileTimestampsIndexId()), - new EnumeratorStringDescriptor(), new DataExternalizer<Long>() { + final File storageFile = IndexInfrastructure.getStorageFile(getFileTimestampsIndexId()); + try { + myFileTimestampsIndex = IOUtil.openCleanOrResetBroken( + new ThrowableComputable<PersistentHashMap<String, Long>, IOException>() { @Override - public void save(final DataOutput out, final Long value) throws IOException { - out.writeLong(value); - } + public PersistentHashMap<String, Long> compute() throws IOException { + return new PersistentHashMap<String, Long>(storageFile, + new EnumeratorStringDescriptor(), new DataExternalizer<Long>() { + @Override + public void save(final DataOutput out, final Long value) throws IOException { + out.writeLong(value); + } - @Override - public Long read(final DataInput in) throws IOException { - return in.readLong(); + @Override + public Long read(final DataInput in) throws IOException { + return in.readLong(); + } + }); } - }); - } - catch (IOException e) { - FileUtil.delete(IndexInfrastructure.getIndexRootDir(getFileTimestampsIndexId())); - } - if (myFileTimestampsIndex != null) { - return; - } + }, + new Runnable() { + public void run() { + FileUtil.delete(IndexInfrastructure.getIndexRootDir(getFileTimestampsIndexId())); + } + } + ); + } catch (IOException ex) { + throw new RuntimeException("Timestamps index not initialized", ex); } - throw new RuntimeException("Timestamps index not initialized"); } public void reindex(final FileVisitorService visitorService, final @NotNull ProgressIndicator indicator) { diff --git a/java/java-impl/src/com/intellij/compilerOutputIndex/impl/ClassFileData.java b/java/java-impl/src/com/intellij/compilerOutputIndex/impl/ClassFileData.java deleted file mode 100644 index 10508d039791..000000000000 --- a/java/java-impl/src/com/intellij/compilerOutputIndex/impl/ClassFileData.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.intellij.compilerOutputIndex.impl; - -import com.intellij.codeInsight.completion.methodChains.ChainCompletionStringUtil; -import com.intellij.compilerOutputIndex.api.fs.AsmUtil; -import org.jetbrains.asm4.ClassReader; -import org.jetbrains.asm4.ClassVisitor; -import org.jetbrains.asm4.MethodVisitor; -import org.jetbrains.asm4.Opcodes; -import org.jetbrains.asm4.tree.ClassNode; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com> - */ -public class ClassFileData { - private final List<MethodData> myMethodDatas; - - public ClassFileData(final ClassNode classNode) { - this(classNode, true); - } - - public ClassFileData(final ClassNode classNode, final boolean checkForPrimitiveReturn) { - myMethodDatas = new ArrayList<MethodData>(); - classNode.accept(new ClassVisitor(Opcodes.ASM4) { - @Override - public MethodVisitor visitMethod(final int access, - final String name, - final String desc, - final String signature, - final String[] exceptions) { - final MethodDataAccumulator methodDataAccumulator = new MethodDataAccumulator(checkForPrimitiveReturn); - myMethodDatas.add(methodDataAccumulator.getMethodData()); - return methodDataAccumulator; - } - }); - } - - public List<MethodData> getMethodDatas() { - return myMethodDatas; - } - - public static class MethodData { - private final List<MethodInsnSignature> myMethodInsnSignatures = new ArrayList<MethodInsnSignature>(); - - private void addSign(final MethodInsnSignature signature) { - myMethodInsnSignatures.add(signature); - } - - public List<MethodInsnSignature> getMethodInsnSignatures() { - return myMethodInsnSignatures; - } - } - - private static class MethodDataAccumulator extends MethodVisitor { - private final MethodData myMethodData = new MethodData(); - private final boolean myCheckForPrimitiveReturn; - - public MethodDataAccumulator(final boolean checkForPrimitiveReturn) { - super(Opcodes.ASM4); - myCheckForPrimitiveReturn = checkForPrimitiveReturn; - } - - private MethodData getMethodData() { - return myMethodData; - } - - @Override - public void visitMethodInsn(final int opcode, final String owner, final String name, final String desc) { - if (MethodIncompleteSignature.CONSTRUCTOR_METHOD_NAME.equals(name)) { - return; - } - final String ownerClassName = AsmUtil.getQualifiedClassName(owner); - if (ChainCompletionStringUtil.isPrimitiveOrArrayOfPrimitives(ownerClassName)) { - return; - } - if (myCheckForPrimitiveReturn) { - final String returnType = AsmUtil.getReturnType(desc); - if (ChainCompletionStringUtil.isPrimitiveOrArrayOfPrimitives(returnType)) { - return; - } - } - myMethodData.addSign(new MethodInsnSignature(opcode, owner, name, desc)); - } - } - - public static class MethodInsnSignature { - private final int myOpcode; - private final String myOwner; - private final String myName; - private final String myDesc; - - private MethodInsnSignature(final int opcode, final String owner, final String name, final String desc) { - myOpcode = opcode; - myOwner = owner; - myName = name; - myDesc = desc; - } - - public int getOpcode() { - return myOpcode; - } - - public String getOwner() { - return myOwner; - } - - public String getName() { - return myName; - } - - public String getDesc() { - return myDesc; - } - } -}
\ No newline at end of file diff --git a/java/java-impl/src/com/intellij/compilerOutputIndex/impl/CompilerOutputBaseGramsIndex.java b/java/java-impl/src/com/intellij/compilerOutputIndex/impl/CompilerOutputBaseGramsIndex.java deleted file mode 100644 index b5a183a45eaf..000000000000 --- a/java/java-impl/src/com/intellij/compilerOutputIndex/impl/CompilerOutputBaseGramsIndex.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.intellij.compilerOutputIndex.impl; - -import com.google.common.collect.HashMultiset; -import com.google.common.collect.Multiset; -import com.intellij.compilerOutputIndex.api.indexer.CompilerOutputBaseIndex; -import com.intellij.openapi.project.Project; -import com.intellij.util.indexing.StorageException; -import com.intellij.util.indexing.ValueContainer; -import com.intellij.util.io.KeyDescriptor; - -import java.util.TreeSet; - -/** - * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com> - */ -public abstract class CompilerOutputBaseGramsIndex<K> extends CompilerOutputBaseIndex<K, Multiset<MethodIncompleteSignature>> { - - protected CompilerOutputBaseGramsIndex(final KeyDescriptor<K> keyDescriptor, final Project project) { - super(keyDescriptor, new GuavaHashMultiSetExternalizer<MethodIncompleteSignature>(MethodIncompleteSignature.createKeyDescriptor()), project); - } - - public TreeSet<UsageIndexValue> getValues(final K key) { - try { - final ValueContainer<Multiset<MethodIncompleteSignature>> valueContainer = myIndex.getData(key); - final Multiset<MethodIncompleteSignature> rawValues = HashMultiset.create(); - valueContainer.forEach(new ValueContainer.ContainerAction<Multiset<MethodIncompleteSignature>>() { - @Override - public boolean perform(final int id, final Multiset<MethodIncompleteSignature> values) { - for (final Multiset.Entry<MethodIncompleteSignature> entry : values.entrySet()) { - rawValues.add(entry.getElement(), entry.getCount()); - } - return true; - } - }); - return rawValuesToValues(rawValues); - } catch (StorageException e) { - throw new RuntimeException(); - } - } - - private static TreeSet<UsageIndexValue> rawValuesToValues(final Multiset<MethodIncompleteSignature> rawValues) { - final TreeSet<UsageIndexValue> values = new TreeSet<UsageIndexValue>(); - for (final Multiset.Entry<MethodIncompleteSignature> entry : rawValues.entrySet()) { - values.add(new UsageIndexValue(entry.getElement(), entry.getCount())); - } - return values; - } -} diff --git a/java/java-impl/src/com/intellij/compilerOutputIndex/impl/MethodIncompleteSignature.java b/java/java-impl/src/com/intellij/compilerOutputIndex/impl/MethodIncompleteSignature.java index ad85322f3f6a..c0904bc3e36e 100644 --- a/java/java-impl/src/com/intellij/compilerOutputIndex/impl/MethodIncompleteSignature.java +++ b/java/java-impl/src/com/intellij/compilerOutputIndex/impl/MethodIncompleteSignature.java @@ -1,5 +1,6 @@ package com.intellij.compilerOutputIndex.impl; +import com.intellij.compilerOutputIndex.api.fs.AsmUtil; import com.intellij.openapi.util.Condition; import com.intellij.psi.*; import com.intellij.psi.search.GlobalSearchScope; @@ -12,6 +13,7 @@ import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; import java.util.Comparator; import java.util.List; @@ -44,6 +46,13 @@ public class MethodIncompleteSignature { return new MethodIncompleteSignature(className, className, CONSTRUCTOR_METHOD_NAME, true); } + public MethodIncompleteSignature toExternalRepresentation() { + return new MethodIncompleteSignature(AsmUtil.getQualifiedClassName(getOwner()), + AsmUtil.getQualifiedClassName(getReturnType()), + getName(), + isStatic()); + } + @NotNull public String getOwner() { return myOwner; @@ -87,6 +96,14 @@ public class MethodIncompleteSignature { } } } + if (filtered.size() > 1) { + Collections.sort(filtered, new Comparator<PsiMethod>() { + @Override + public int compare(final PsiMethod o1, final PsiMethod o2) { + return o1.getParameterList().getParametersCount() - o2.getParameterList().getParametersCount(); + } + }); + } return filtered.toArray(new PsiMethod[filtered.size()]); } diff --git a/java/java-impl/src/com/intellij/compilerOutputIndex/impl/MethodsUsageIndex.java b/java/java-impl/src/com/intellij/compilerOutputIndex/impl/MethodsUsageIndex.java index 10061352f060..78a63bd41a17 100644 --- a/java/java-impl/src/com/intellij/compilerOutputIndex/impl/MethodsUsageIndex.java +++ b/java/java-impl/src/com/intellij/compilerOutputIndex/impl/MethodsUsageIndex.java @@ -3,32 +3,47 @@ package com.intellij.compilerOutputIndex.impl; import com.google.common.collect.HashMultiset; import com.google.common.collect.Multiset; import com.intellij.compilerOutputIndex.api.fs.AsmUtil; +import com.intellij.compilerOutputIndex.api.indexer.CompilerOutputBaseIndex; import com.intellij.compilerOutputIndex.api.indexer.CompilerOutputIndexer; import com.intellij.openapi.project.Project; +import com.intellij.openapi.roots.ModifiableRootModel; +import com.intellij.openapi.roots.ModuleRootManager; +import com.intellij.openapi.roots.ModuleRootModel; +import com.intellij.psi.*; import com.intellij.util.indexing.DataIndexer; import com.intellij.util.indexing.ID; import com.intellij.util.indexing.StorageException; +import com.intellij.util.indexing.ValueContainer; +import com.intellij.util.io.DataExternalizer; import com.intellij.util.io.EnumeratorStringDescriptor; +import com.intellij.util.io.KeyDescriptor; import org.jetbrains.annotations.NotNull; -import org.jetbrains.asm4.ClassReader; +import org.jetbrains.asm4.ClassVisitor; +import org.jetbrains.asm4.MethodVisitor; import org.jetbrains.asm4.Opcodes; +import org.jetbrains.asm4.Type; import org.jetbrains.asm4.tree.ClassNode; +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; import java.util.HashMap; import java.util.Map; +import java.util.TreeSet; /** * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com> */ -public class MethodsUsageIndex extends CompilerOutputBaseGramsIndex<String> { +public class MethodsUsageIndex extends CompilerOutputBaseIndex<String, Multiset<MethodIncompleteSignature>> { public static MethodsUsageIndex getInstance(final Project project) { return CompilerOutputIndexer.getInstance(project).getIndex(MethodsUsageIndex.class); } public MethodsUsageIndex(final Project project) { - super(new EnumeratorStringDescriptor(), project); + super(new EnumeratorStringDescriptor(), + new GuavaHashMultiSetExternalizer<MethodIncompleteSignature>(MethodIncompleteSignature.createKeyDescriptor()), project); } @Override @@ -38,25 +53,33 @@ public class MethodsUsageIndex extends CompilerOutputBaseGramsIndex<String> { @Override public Map<String, Multiset<MethodIncompleteSignature>> map(final ClassNode inputData) { final Map<String, Multiset<MethodIncompleteSignature>> map = new HashMap<String, Multiset<MethodIncompleteSignature>>(); - for (final ClassFileData.MethodData data : new ClassFileData(inputData).getMethodDatas()) { - for (final ClassFileData.MethodInsnSignature ms : data.getMethodInsnSignatures()) { - final String ownerClassName = AsmUtil.getQualifiedClassName(ms.getOwner()); - final String returnType = AsmUtil.getReturnType(ms.getDesc()); - if (MethodIncompleteSignature.CONSTRUCTOR_METHOD_NAME.equals(ms.getName())) { - addToIndex(map, ownerClassName, MethodIncompleteSignature.constructor(ownerClassName)); + final MethodVisitor methodVisitor = new MethodVisitor(Opcodes.ASM4) { + @Override + public void visitMethodInsn(final int opcode, final String owner, final String name, final String desc) { + final Type returnType = Type.getReturnType(desc); + if (MethodIncompleteSignature.CONSTRUCTOR_METHOD_NAME.equals(name) || + AsmUtil.isPrimitiveOrArray(returnType.getDescriptor())) { + return; } - else { - final boolean isStatic = ms.getOpcode() == Opcodes.INVOKESTATIC; - if (!ownerClassName.equals(returnType) || isStatic) { - addToIndex(map, returnType, new MethodIncompleteSignature(ownerClassName, returnType, ms.getName(), isStatic)); - } + final String returnClassName = returnType.getInternalName(); + final boolean isStatic = opcode == Opcodes.INVOKESTATIC; + if (!owner.equals(returnClassName) || isStatic) { + addToIndex(map, returnClassName, new MethodIncompleteSignature(owner, returnClassName, name, isStatic)); } } - } + }; + inputData.accept(new ClassVisitor(Opcodes.ASM4) { + @Override + public MethodVisitor visitMethod(final int access, + final String name, + final String desc, + final String signature, + final String[] exceptions) { + return methodVisitor; + } + }); return map; } - - }; } @@ -67,17 +90,46 @@ public class MethodsUsageIndex extends CompilerOutputBaseGramsIndex<String> { @Override protected int getVersion() { - return 0; + return 1; + } + + public TreeSet<UsageIndexValue> getValues(final String key) { + try { + final ValueContainer<Multiset<MethodIncompleteSignature>> valueContainer = myIndex.getData(key); + final Multiset<MethodIncompleteSignature> rawValues = HashMultiset.create(); + valueContainer.forEach(new ValueContainer.ContainerAction<Multiset<MethodIncompleteSignature>>() { + @Override + public boolean perform(final int id, final Multiset<MethodIncompleteSignature> values) { + for (final Multiset.Entry<MethodIncompleteSignature> entry : values.entrySet()) { + rawValues.add(entry.getElement(), entry.getCount()); + } + return true; + } + }); + return rawValuesToValues(rawValues); + } + catch (final StorageException e) { + throw new RuntimeException(); + } } private static void addToIndex(final Map<String, Multiset<MethodIncompleteSignature>> map, - final String key, + final String internalClassName, final MethodIncompleteSignature mi) { - Multiset<MethodIncompleteSignature> occurrences = map.get(key); + final String className = AsmUtil.getQualifiedClassName(internalClassName); + Multiset<MethodIncompleteSignature> occurrences = map.get(className); if (occurrences == null) { occurrences = HashMultiset.create(); - map.put(key, occurrences); + map.put(className, occurrences); } occurrences.add(mi); } -}
\ No newline at end of file + + private static TreeSet<UsageIndexValue> rawValuesToValues(final Multiset<MethodIncompleteSignature> rawValues) { + final TreeSet<UsageIndexValue> values = new TreeSet<UsageIndexValue>(); + for (final Multiset.Entry<MethodIncompleteSignature> entry : rawValues.entrySet()) { + values.add(new UsageIndexValue(entry.getElement().toExternalRepresentation(), entry.getCount())); + } + return values; + } +} diff --git a/java/java-impl/src/com/intellij/compilerOutputIndex/impl/bigram/Bigram.java b/java/java-impl/src/com/intellij/compilerOutputIndex/impl/bigram/Bigram.java deleted file mode 100644 index f5f4ff87a095..000000000000 --- a/java/java-impl/src/com/intellij/compilerOutputIndex/impl/bigram/Bigram.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.intellij.compilerOutputIndex.impl.bigram; - -import com.intellij.openapi.util.Pair; -import org.jetbrains.annotations.NotNull; - -/** - * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com> - */ -public class Bigram<E> extends Pair<E, E> { - public Bigram(@NotNull final E first, @NotNull final E second) { - super(first, second); - } - - public Bigram<E> swap() { - return new Bigram<E>(second, first); - } - - @Override - public String toString() { - return String.format("%s - %s", first, second); - } -} diff --git a/java/java-impl/src/com/intellij/compilerOutputIndex/impl/bigram/BigramMethodsUsageIndex.java b/java/java-impl/src/com/intellij/compilerOutputIndex/impl/bigram/BigramMethodsUsageIndex.java deleted file mode 100644 index 31bf75fef612..000000000000 --- a/java/java-impl/src/com/intellij/compilerOutputIndex/impl/bigram/BigramMethodsUsageIndex.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.intellij.compilerOutputIndex.impl.bigram; - -import com.google.common.collect.HashMultiset; -import com.google.common.collect.Multiset; -import com.intellij.compilerOutputIndex.api.fs.AsmUtil; -import com.intellij.compilerOutputIndex.api.indexer.CompilerOutputIndexer; -import com.intellij.compilerOutputIndex.impl.ClassFileData; -import com.intellij.compilerOutputIndex.impl.CompilerOutputBaseGramsIndex; -import com.intellij.compilerOutputIndex.impl.MethodIncompleteSignature; -import com.intellij.compilerOutputIndex.impl.MethodIncompleteSignatureChain; -import com.intellij.openapi.project.Project; -import com.intellij.util.SmartList; -import com.intellij.util.indexing.DataIndexer; -import com.intellij.util.indexing.ID; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.asm4.ClassReader; -import org.jetbrains.asm4.Opcodes; -import org.jetbrains.asm4.tree.ClassNode; - -import java.util.*; - -/** - * @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com> - */ -public class BigramMethodsUsageIndex extends CompilerOutputBaseGramsIndex<MethodIncompleteSignature> { - public static BigramMethodsUsageIndex getInstance(final Project project) { - return CompilerOutputIndexer.getInstance(project).getIndex(BigramMethodsUsageIndex.class); - } - - public BigramMethodsUsageIndex( final Project project) { - super(MethodIncompleteSignature.createKeyDescriptor(), project); - } - - @Override - protected ID<MethodIncompleteSignature, Multiset<MethodIncompleteSignature>> getIndexId() { - return generateIndexId("BigramMethodsUsage"); - } - - @Override - protected int getVersion() { - return 0; - } - - @Override - protected DataIndexer<MethodIncompleteSignature, Multiset<MethodIncompleteSignature>,ClassNode> getIndexer() { - // - // not fair way, but works fast - // - return new DataIndexer<MethodIncompleteSignature, Multiset<MethodIncompleteSignature>, ClassNode>() { - @NotNull - @Override - public Map<MethodIncompleteSignature, Multiset<MethodIncompleteSignature>> map(final ClassNode inputData) { - final Map<MethodIncompleteSignature, Multiset<MethodIncompleteSignature>> map = - new HashMap<MethodIncompleteSignature, Multiset<MethodIncompleteSignature>>(); - for (final ClassFileData.MethodData data : new ClassFileData(inputData).getMethodDatas()) { - final SimpleBigramsExtractor extractor = new SimpleBigramsExtractor(new SimpleBigramsExtractor.BigramMethodIncompleteSignatureProcessor() { - @Override - public void process(final Bigram<MethodIncompleteSignature> bigram) { - final MethodIncompleteSignature secondGram = bigram.getSecond(); - Multiset<MethodIncompleteSignature> occurrences = map.get(secondGram); - if (occurrences == null) { - occurrences = HashMultiset.create(); - map.put(secondGram, occurrences); - } - occurrences.add(bigram.getFirst()); - } - }); - for (final ClassFileData.MethodInsnSignature ms : data.getMethodInsnSignatures()) { - final List<MethodIncompleteSignature> methodInvocations = new SmartList<MethodIncompleteSignature>(); - final String ownerClassName = AsmUtil.getQualifiedClassName(ms.getOwner()); - final String returnType = AsmUtil.getReturnType(ms.getDesc()); - - if (ms.getName().equals(MethodIncompleteSignature.CONSTRUCTOR_METHOD_NAME)) { - methodInvocations.add(MethodIncompleteSignature.constructor(ownerClassName)); - } - else { - methodInvocations.add(new MethodIncompleteSignature(ownerClassName, returnType, ms.getName(), ms.getOpcode() == Opcodes.INVOKESTATIC)); - } - extractor.addChain(new MethodIncompleteSignatureChain(methodInvocations)); - } - } - return map; - } - }; - } - -} diff --git a/java/java-impl/src/com/intellij/compilerOutputIndex/impl/bigram/SimpleBigramsExtractor.java b/java/java-impl/src/com/intellij/compilerOutputIndex/impl/bigram/SimpleBigramsExtractor.java deleted file mode 100644 index d231a07e0f18..000000000000 --- a/java/java-impl/src/com/intellij/compilerOutputIndex/impl/bigram/SimpleBigramsExtractor.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.intellij.compilerOutputIndex.impl.bigram; - -import com.intellij.compilerOutputIndex.impl.MethodIncompleteSignature; -import com.intellij.compilerOutputIndex.impl.MethodIncompleteSignatureChain; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.*; - -/** -* @author Dmitry Batkovich -*/ -class SimpleBigramsExtractor { - private final Map<String, MethodIncompleteSignature> myHolder = new HashMap<String, MethodIncompleteSignature>(); - private final BigramMethodIncompleteSignatureProcessor myProcessor; - - public SimpleBigramsExtractor(final BigramMethodIncompleteSignatureProcessor processor) { - myProcessor = processor; - } - - public void addChain(final MethodIncompleteSignatureChain chain) { - if (chain.isEmpty()) { - return; - } - final MethodIncompleteSignature firstInvocation = chain.getFirstInvocation(); - assert firstInvocation != null; - final MethodIncompleteSignature head = firstInvocation.isStatic() ? null : myHolder.get(firstInvocation.getOwner()); - for (final Bigram<MethodIncompleteSignature> bigram : toBigrams(head, chain)) { - myProcessor.process(bigram); - } - final MethodIncompleteSignature lastInvocation = chain.getLastInvocation(); - assert lastInvocation != null; - myHolder.put(lastInvocation.getReturnType(), lastInvocation); - } - - private static Collection<Bigram<MethodIncompleteSignature>> toBigrams(final @Nullable MethodIncompleteSignature head, - final @NotNull MethodIncompleteSignatureChain chain) { - MethodIncompleteSignature currentLast = null; - if (head != null) { - currentLast = head; - } - final List<Bigram<MethodIncompleteSignature>> bigrams = new ArrayList<Bigram<MethodIncompleteSignature>>(chain.size()); - for (final MethodIncompleteSignature current : chain.list()) { - if (currentLast != null) { - bigrams.add(new Bigram<MethodIncompleteSignature>(currentLast, current)); - } - currentLast = current; - } - return bigrams; - } - - public interface BigramMethodIncompleteSignatureProcessor { - void process(Bigram<MethodIncompleteSignature> bigram); - } -} diff --git a/java/java-impl/src/com/intellij/ide/hierarchy/call/JavaCallHierarchyProvider.java b/java/java-impl/src/com/intellij/ide/hierarchy/call/JavaCallHierarchyProvider.java index 5c95175adce6..20caeb65d34f 100644 --- a/java/java-impl/src/com/intellij/ide/hierarchy/call/JavaCallHierarchyProvider.java +++ b/java/java-impl/src/com/intellij/ide/hierarchy/call/JavaCallHierarchyProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,17 +15,15 @@ */ package com.intellij.ide.hierarchy.call; -import com.intellij.ide.hierarchy.HierarchyProvider; -import com.intellij.ide.hierarchy.HierarchyBrowser; import com.intellij.ide.hierarchy.CallHierarchyBrowserBase; +import com.intellij.ide.hierarchy.HierarchyBrowser; +import com.intellij.ide.hierarchy.HierarchyProvider; import com.intellij.openapi.actionSystem.CommonDataKeys; +import com.intellij.openapi.actionSystem.DataContext; +import com.intellij.openapi.project.Project; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiMethod; import com.intellij.psi.util.PsiTreeUtil; -import com.intellij.openapi.actionSystem.DataContext; -import com.intellij.openapi.actionSystem.PlatformDataKeys; -import com.intellij.openapi.actionSystem.LangDataKeys; -import com.intellij.openapi.project.Project; import org.jetbrains.annotations.NotNull; /** @@ -34,7 +32,7 @@ import org.jetbrains.annotations.NotNull; public class JavaCallHierarchyProvider implements HierarchyProvider { @Override public PsiElement getTarget(@NotNull final DataContext dataContext) { - final Project project = PlatformDataKeys.PROJECT.getData(dataContext); + final Project project = CommonDataKeys.PROJECT.getData(dataContext); if (project == null) return null; final PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(dataContext); diff --git a/java/java-impl/src/com/intellij/ide/macro/ClasspathEntryMacro.java b/java/java-impl/src/com/intellij/ide/macro/ClasspathEntryMacro.java index 5ee1126b6f09..b28334802f24 100644 --- a/java/java-impl/src/com/intellij/ide/macro/ClasspathEntryMacro.java +++ b/java/java-impl/src/com/intellij/ide/macro/ClasspathEntryMacro.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ package com.intellij.ide.macro; import com.intellij.ide.IdeBundle; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.DataContext; -import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.ProjectRootManager; import com.intellij.openapi.vfs.VirtualFile; @@ -36,7 +35,7 @@ public final class ClasspathEntryMacro extends Macro { } public String expand(final DataContext dataContext) { - final Project project = PlatformDataKeys.PROJECT.getData(dataContext); + final Project project = CommonDataKeys.PROJECT.getData(dataContext); if (project == null) return null; final VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(dataContext); if (file == null) return null; diff --git a/java/java-impl/src/com/intellij/openapi/module/JavaModuleType.java b/java/java-impl/src/com/intellij/openapi/module/JavaModuleType.java index 0ad4e7c99309..ade31f9e3f2d 100644 --- a/java/java-impl/src/com/intellij/openapi/module/JavaModuleType.java +++ b/java/java-impl/src/com/intellij/openapi/module/JavaModuleType.java @@ -84,17 +84,17 @@ public class JavaModuleType extends ModuleType<JavaModuleBuilder> { @NotNull @Override public ModuleWizardStep[] createWizardSteps(@NotNull final WizardContext wizardContext, @NotNull final JavaModuleBuilder moduleBuilder, - @NotNull final ModulesProvider modulesProvider, boolean forNewWizard) { + @NotNull final ModulesProvider modulesProvider) { final ProjectWizardStepFactory wizardFactory = ProjectWizardStepFactory.getInstance(); ArrayList<ModuleWizardStep> steps = new ArrayList<ModuleWizardStep>(); - if (!forNewWizard) { + if (!wizardContext.isNewWizard()) { final ModuleWizardStep supportForFrameworksStep = wizardFactory.createSupportForFrameworksStep(wizardContext, moduleBuilder, modulesProvider); if (supportForFrameworksStep != null) { steps.add(supportForFrameworksStep); } } final ModuleWizardStep[] wizardSteps = steps.toArray(new ModuleWizardStep[steps.size()]); - return ArrayUtil.mergeArrays(wizardSteps, super.createWizardSteps(wizardContext, moduleBuilder, modulesProvider, forNewWizard)); + return ArrayUtil.mergeArrays(wizardSteps, super.createWizardSteps(wizardContext, moduleBuilder, modulesProvider)); } @Nullable diff --git a/java/java-impl/src/com/intellij/openapi/roots/impl/ExcludeCompilerOutputPolicy.java b/java/java-impl/src/com/intellij/openapi/roots/impl/ExcludeCompilerOutputPolicy.java index f880d36a6b19..adbacfcd38ce 100644 --- a/java/java-impl/src/com/intellij/openapi/roots/impl/ExcludeCompilerOutputPolicy.java +++ b/java/java-impl/src/com/intellij/openapi/roots/impl/ExcludeCompilerOutputPolicy.java @@ -25,6 +25,7 @@ import com.intellij.openapi.util.Comparing; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.pointers.VirtualFilePointer; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -78,14 +79,12 @@ public class ExcludeCompilerOutputPolicy implements DirectoryIndexExcludePolicy return VirtualFilePointer.EMPTY_ARRAY; } if (extension.isCompilerOutputPathInherited()) { - result.add(CompilerProjectExtension.getInstance(myProject).getCompilerOutputPointer()); + ContainerUtil.addIfNotNull(result, CompilerProjectExtension.getInstance(myProject).getCompilerOutputPointer()); } else { if (!extension.isExcludeOutput()) return VirtualFilePointer.EMPTY_ARRAY; - final VirtualFilePointer outputPath = extension.getCompilerOutputPointer(); - if (outputPath != null) result.add(outputPath); - final VirtualFilePointer outputPathForTests = extension.getCompilerOutputForTestsPointer(); - if (outputPathForTests != null) result.add(outputPathForTests); + ContainerUtil.addIfNotNull(result, extension.getCompilerOutputPointer()); + ContainerUtil.addIfNotNull(result, extension.getCompilerOutputForTestsPointer()); } return result.isEmpty() ? VirtualFilePointer.EMPTY_ARRAY : result.toArray(new VirtualFilePointer[result.size()]); } diff --git a/java/java-impl/src/com/intellij/psi/formatter/JavadocWhiteSpaceFormattingStrategy.java b/java/java-impl/src/com/intellij/psi/formatter/JavadocWhiteSpaceFormattingStrategy.java index 4f20b9225206..28ae06ea33c8 100644 --- a/java/java-impl/src/com/intellij/psi/formatter/JavadocWhiteSpaceFormattingStrategy.java +++ b/java/java-impl/src/com/intellij/psi/formatter/JavadocWhiteSpaceFormattingStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,6 @@ import org.jetbrains.annotations.NotNull; public class JavadocWhiteSpaceFormattingStrategy extends WhiteSpaceFormattingStrategyAdapter { @Override public boolean containsWhitespacesOnly(@NotNull final ASTNode node) { - return node.getElementType() == JavaDocTokenType.DOC_COMMENT_DATA && node.textContains('\n') && node.getText().trim().length() == 0; + return node.getElementType() == JavaDocTokenType.DOC_COMMENT_DATA && node.textContains('\n') && node.getText().trim().isEmpty(); } } diff --git a/java/java-impl/src/com/intellij/psi/formatter/java/BlockContainingJavaBlock.java b/java/java-impl/src/com/intellij/psi/formatter/java/BlockContainingJavaBlock.java index 5bbd481b6e40..cb5139cdef91 100644 --- a/java/java-impl/src/com/intellij/psi/formatter/java/BlockContainingJavaBlock.java +++ b/java/java-impl/src/com/intellij/psi/formatter/java/BlockContainingJavaBlock.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,9 +38,9 @@ public class BlockContainingJavaBlock extends AbstractJavaBlock{ JavaElementType.IF_STATEMENT, JavaElementType.WHILE_STATEMENT, JavaElementType.FOR_STATEMENT ); - private final static int BEFORE_FIRST = 0; - private final static int BEFORE_BLOCK = 1; - private final static int AFTER_ELSE = 2; + private static final int BEFORE_FIRST = 0; + private static final int BEFORE_BLOCK = 1; + private static final int AFTER_ELSE = 2; private final List<Indent> myIndentsBefore = new ArrayList<Indent>(); diff --git a/java/java-impl/src/com/intellij/psi/formatter/java/CodeBlockBlock.java b/java/java-impl/src/com/intellij/psi/formatter/java/CodeBlockBlock.java index bcec4eff628e..574c93f950b5 100644 --- a/java/java-impl/src/com/intellij/psi/formatter/java/CodeBlockBlock.java +++ b/java/java-impl/src/com/intellij/psi/formatter/java/CodeBlockBlock.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,9 +36,9 @@ import java.util.ArrayList; import java.util.List; public class CodeBlockBlock extends AbstractJavaBlock { - private final static int BEFORE_FIRST = 0; - private final static int BEFORE_LBRACE = 1; - private final static int INSIDE_BODY = 2; + private static final int BEFORE_FIRST = 0; + private static final int BEFORE_LBRACE = 1; + private static final int INSIDE_BODY = 2; private final int myChildrenIndent; diff --git a/java/java-impl/src/com/intellij/psi/formatter/java/CommentWithInjectionBlock.java b/java/java-impl/src/com/intellij/psi/formatter/java/CommentWithInjectionBlock.java index 08bb1f44fb72..7e31f44230b0 100644 --- a/java/java-impl/src/com/intellij/psi/formatter/java/CommentWithInjectionBlock.java +++ b/java/java-impl/src/com/intellij/psi/formatter/java/CommentWithInjectionBlock.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ import java.util.List; * @author nik */ public class CommentWithInjectionBlock extends AbstractJavaBlock { - private InjectedLanguageBlockBuilder myInjectedBlockBuilder; + private final InjectedLanguageBlockBuilder myInjectedBlockBuilder; public CommentWithInjectionBlock(ASTNode node, Wrap wrap, Alignment alignment, Indent indent, CommonCodeStyleSettings settings) { super(node, wrap, alignment, indent, settings); diff --git a/java/java-impl/src/com/intellij/psi/formatter/java/DocCommentBlock.java b/java/java-impl/src/com/intellij/psi/formatter/java/DocCommentBlock.java index b65393f3a4b3..4bc6f6d2616b 100644 --- a/java/java-impl/src/com/intellij/psi/formatter/java/DocCommentBlock.java +++ b/java/java-impl/src/com/intellij/psi/formatter/java/DocCommentBlock.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,7 +39,7 @@ public class DocCommentBlock extends AbstractJavaBlock{ while (child != null) { if (child.getElementType() == JavaDocTokenType.DOC_COMMENT_START) { result.add(createJavaBlock(child, mySettings, Indent.getNoneIndent(), null, AlignmentStrategy.getNullStrategy())); - } else if (!FormatterUtil.containsWhiteSpacesOnly(child) && child.getText().trim().length() > 0){ + } else if (!FormatterUtil.containsWhiteSpacesOnly(child) && !child.getText().trim().isEmpty()){ result.add(createJavaBlock(child, mySettings, Indent.getSpaceIndent(1), null, AlignmentStrategy.getNullStrategy())); } child = child.getTreeNext(); diff --git a/java/java-impl/src/com/intellij/psi/formatter/java/ExtendsListBlock.java b/java/java-impl/src/com/intellij/psi/formatter/java/ExtendsListBlock.java index 2a5098803d01..37e49def2526 100644 --- a/java/java-impl/src/com/intellij/psi/formatter/java/ExtendsListBlock.java +++ b/java/java-impl/src/com/intellij/psi/formatter/java/ExtendsListBlock.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import com.intellij.lang.ASTNode; import com.intellij.psi.codeStyle.CommonCodeStyleSettings; import com.intellij.psi.formatter.FormatterUtil; import com.intellij.psi.impl.source.tree.ElementType; +import com.intellij.psi.impl.source.tree.JavaElementType; import java.util.ArrayList; import java.util.List; @@ -78,9 +79,9 @@ public class ExtendsListBlock extends AbstractJavaBlock{ } private boolean alignList() { - if (myNode.getElementType() == ElementType.EXTENDS_LIST || myNode.getElementType() == ElementType.IMPLEMENTS_LIST) { + if (myNode.getElementType() == JavaElementType.EXTENDS_LIST || myNode.getElementType() == JavaElementType.IMPLEMENTS_LIST) { return mySettings.ALIGN_MULTILINE_EXTENDS_LIST; - } else if (myNode.getElementType() == ElementType.THROWS_LIST) { + } else if (myNode.getElementType() == JavaElementType.THROWS_LIST) { return mySettings.ALIGN_MULTILINE_THROWS_LIST; } return false; diff --git a/java/java-impl/src/com/intellij/psi/formatter/java/LabeledJavaBlock.java b/java/java-impl/src/com/intellij/psi/formatter/java/LabeledJavaBlock.java index c354bcc3de86..c3f0af11b33e 100644 --- a/java/java-impl/src/com/intellij/psi/formatter/java/LabeledJavaBlock.java +++ b/java/java-impl/src/com/intellij/psi/formatter/java/LabeledJavaBlock.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ import com.intellij.formatting.*; import com.intellij.formatting.alignment.AlignmentStrategy; import com.intellij.lang.ASTNode; import com.intellij.openapi.fileTypes.StdFileTypes; +import com.intellij.psi.JavaTokenType; import com.intellij.psi.codeStyle.CommonCodeStyleSettings; import com.intellij.psi.formatter.FormatterUtil; import com.intellij.psi.impl.source.tree.ElementType; @@ -45,7 +46,7 @@ public class LabeledJavaBlock extends AbstractJavaBlock{ while (child != null) { if (!FormatterUtil.containsWhiteSpacesOnly(child) && child.getTextLength() > 0){ result.add(createJavaBlock(child, mySettings, currentIndent, currentWrap, AlignmentStrategy.getNullStrategy())); - if (child.getElementType() == ElementType.COLON) { + if (child.getElementType() == JavaTokenType.COLON) { currentIndent = Indent.getNoneIndent(); currentWrap =Wrap.createWrap(WrapType.ALWAYS, true); } diff --git a/java/java-impl/src/com/intellij/psi/formatter/java/WrappingStrategy.java b/java/java-impl/src/com/intellij/psi/formatter/java/WrappingStrategy.java index 2429bc0212cc..e4d283edccb0 100644 --- a/java/java-impl/src/com/intellij/psi/formatter/java/WrappingStrategy.java +++ b/java/java-impl/src/com/intellij/psi/formatter/java/WrappingStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package com.intellij.psi.formatter.java; import com.intellij.formatting.Wrap; +import com.intellij.psi.JavaTokenType; import com.intellij.psi.tree.IElementType; import com.intellij.psi.impl.source.tree.ElementType; @@ -32,7 +33,7 @@ public abstract class WrappingStrategy { return new WrappingStrategy(wrap) { @Override protected boolean shouldWrap(final IElementType type) { - return type != ElementType.COMMA && type != ElementType.SEMICOLON; + return type != JavaTokenType.COMMA && type != JavaTokenType.SEMICOLON; } }; } 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 6f5fb24af9a8..52ea316861c6 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-2010 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -136,7 +136,7 @@ public class JavaChildWrapArranger { } if (role == ChildRole.LOOP_BODY) { final boolean dontWrap = (childType == JavaElementType.CODE_BLOCK || childType == JavaElementType.BLOCK_STATEMENT) && - settings.BRACE_STYLE == CodeStyleSettings.END_OF_LINE; + settings.BRACE_STYLE == CommonCodeStyleSettings.END_OF_LINE; return Wrap.createWrap(dontWrap ? WrapType.NONE : WrapType.NORMAL, true); } else { diff --git a/java/java-impl/src/com/intellij/psi/impl/beanProperties/CreateBeanPropertyFix.java b/java/java-impl/src/com/intellij/psi/impl/beanProperties/CreateBeanPropertyFix.java index 47618f5594ae..053a534e0c98 100644 --- a/java/java-impl/src/com/intellij/psi/impl/beanProperties/CreateBeanPropertyFix.java +++ b/java/java-impl/src/com/intellij/psi/impl/beanProperties/CreateBeanPropertyFix.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,7 +39,7 @@ import org.jetbrains.annotations.Nullable; */ public abstract class CreateBeanPropertyFix implements LocalQuickFix, IntentionAction { - private final static Logger LOG = Logger.getInstance("#com.intellij.psi.impl.beanProperties.CreateBeanPropertyFix"); + private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.beanProperties.CreateBeanPropertyFix"); private static final CreateBeanPropertyFix[] NO_FIXES = new CreateBeanPropertyFix[0]; protected final String myPropertyName; diff --git a/java/java-impl/src/com/intellij/psi/impl/file/PsiJavaDirectoryFactory.java b/java/java-impl/src/com/intellij/psi/impl/file/PsiJavaDirectoryFactory.java index e92396e00a2f..83761827f52d 100644 --- a/java/java-impl/src/com/intellij/psi/impl/file/PsiJavaDirectoryFactory.java +++ b/java/java-impl/src/com/intellij/psi/impl/file/PsiJavaDirectoryFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,7 +48,7 @@ public class PsiJavaDirectoryFactory extends PsiDirectoryFactory { final PsiPackage aPackage = JavaDirectoryService.getInstance().getPackage(directory); if (aPackage != null) { final String qualifiedName = aPackage.getQualifiedName(); - if (qualifiedName.length() > 0) return qualifiedName; + if (!qualifiedName.isEmpty()) return qualifiedName; if (presentable) { return PsiBundle.message("default.package.presentation") + " (" + directory.getVirtualFile().getPresentableUrl() + ")"; } diff --git a/java/java-impl/src/com/intellij/psi/impl/light/LightMethodBuilder.java b/java/java-impl/src/com/intellij/psi/impl/light/LightMethodBuilder.java index 70e7b8415990..d568db62854f 100644 --- a/java/java-impl/src/com/intellij/psi/impl/light/LightMethodBuilder.java +++ b/java/java-impl/src/com/intellij/psi/impl/light/LightMethodBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,9 +46,9 @@ public class LightMethodBuilder extends LightElement implements PsiMethod, Origi private final String myName; private Computable<PsiType> myReturnType; private final PsiModifierList myModifierList; - private PsiParameterList myParameterList; - private PsiTypeParameterList myTypeParameterList; - private PsiReferenceList myThrowsList; + private final PsiParameterList myParameterList; + private final PsiTypeParameterList myTypeParameterList; + private final PsiReferenceList myThrowsList; private Icon myBaseIcon; private PsiClass myContainingClass; private boolean myConstructor; diff --git a/java/java-impl/src/com/intellij/psi/impl/search/AnnotatedPackagesSearcher.java b/java/java-impl/src/com/intellij/psi/impl/search/AnnotatedPackagesSearcher.java index c1b65eccdccf..8e52d775a846 100644 --- a/java/java-impl/src/com/intellij/psi/impl/search/AnnotatedPackagesSearcher.java +++ b/java/java-impl/src/com/intellij/psi/impl/search/AnnotatedPackagesSearcher.java @@ -86,7 +86,7 @@ public class AnnotatedPackagesSearcher implements QueryExecutor<PsiPackage, Anno GlobalSearchScope infoFiles = useScope instanceof GlobalSearchScope ? ((GlobalSearchScope)useScope).intersectWith(infoFilesFilter) : infoFilesFilter; - final boolean[] wantmore = new boolean[]{true}; + final boolean[] wantmore = {true}; helper.processAllFilesWithWord(annotationShortName, infoFiles, new Processor<PsiFile>() { @Override public boolean process(final PsiFile psiFile) { diff --git a/java/java-impl/src/com/intellij/psi/impl/search/JavaIndexPatternBuilder.java b/java/java-impl/src/com/intellij/psi/impl/search/JavaIndexPatternBuilder.java index f404c401ae6f..50005842b25e 100644 --- a/java/java-impl/src/com/intellij/psi/impl/search/JavaIndexPatternBuilder.java +++ b/java/java-impl/src/com/intellij/psi/impl/search/JavaIndexPatternBuilder.java @@ -32,7 +32,7 @@ import org.jetbrains.annotations.Nullable; */ public class JavaIndexPatternBuilder implements IndexPatternBuilder { public static final TokenSet XML_DATA_CHARS = TokenSet.create(XmlTokenType.XML_DATA_CHARACTERS); - public static final TokenSet XML_COMMENT_BIT_SET = TokenSet.create(XmlElementType.XML_COMMENT_CHARACTERS); + public static final TokenSet XML_COMMENT_BIT_SET = TokenSet.create(XmlTokenType.XML_COMMENT_CHARACTERS); @Override @Nullable diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ImportsFormatter.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ImportsFormatter.java index aaf5f98540e2..4e81caef937b 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ImportsFormatter.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ImportsFormatter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,8 +39,8 @@ public class ImportsFormatter extends XmlRecursiveElementVisitor { private final FormattingDocumentModelImpl myDocumentModel; private final CommonCodeStyleSettings.IndentOptions myIndentOptions; - private static final @NonNls String PAGE_DIRECTIVE = "page"; - private static final @NonNls String IMPORT_ATT = "import"; + @NonNls private static final String PAGE_DIRECTIVE = "page"; + @NonNls private static final String IMPORT_ATT = "import"; private final PostFormatProcessorHelper myPostProcessor; @@ -134,7 +134,7 @@ public class ImportsFormatter extends XmlRecursiveElementVisitor { private static ASTNode findValueToken(final ASTNode node) { ASTNode child = node.getFirstChildNode(); while (child != null){ - if (child.getElementType() == XmlElementType.XML_ATTRIBUTE_VALUE_TOKEN) return child; + if (child.getElementType() == XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN) return child; child = child.getTreeNext(); } return null; diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaCodeStyleManagerImpl.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaCodeStyleManagerImpl.java index 7c257dd8c83a..3056eccd9291 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaCodeStyleManagerImpl.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaCodeStyleManagerImpl.java @@ -779,7 +779,7 @@ public class JavaCodeStyleManagerImpl extends JavaCodeStyleManager { String prefix = getPrefixByVariableKind(variableKind); String name = propertyName; - if (name.length() > 0 && prefix.length() > 0 && !StringUtil.endsWithChar(prefix, '_')) { + if (!name.isEmpty() && !prefix.isEmpty() && !StringUtil.endsWithChar(prefix, '_')) { name = Character.toUpperCase(name.charAt(0)) + name.substring(1); } name = prefix + name + getSuffixByVariableKind(variableKind); diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/PsiBasedFormatterModelWithShiftIndentInside.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/PsiBasedFormatterModelWithShiftIndentInside.java index 2eb7c78ca525..9782b5630500 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/PsiBasedFormatterModelWithShiftIndentInside.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/PsiBasedFormatterModelWithShiftIndentInside.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,6 +35,7 @@ import com.intellij.psi.formatter.PsiBasedFormattingModel; import com.intellij.psi.impl.source.tree.TreeUtil; import com.intellij.psi.tree.IElementType; import com.intellij.psi.xml.XmlElementType; +import com.intellij.psi.xml.XmlTokenType; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -84,7 +85,7 @@ public class PsiBasedFormatterModelWithShiftIndentInside extends PsiBasedFormatt if(type == TokenType.WHITE_SPACE) { final String text = prevNode.getText(); - final @NonNls String cdataStartMarker = "<![CDATA["; + @NonNls final String cdataStartMarker = "<![CDATA["; final int cdataPos = text.indexOf(cdataStartMarker); if (cdataPos != -1 && whiteSpace.indexOf(cdataStartMarker) == -1) { whiteSpace = DocumentBasedFormattingModel.mergeWsWithCdataMarker(whiteSpace, text, cdataPos); @@ -95,8 +96,8 @@ public class PsiBasedFormatterModelWithShiftIndentInside extends PsiBasedFormatt type = prevNode != null ? prevNode.getElementType():null; } - final @NonNls String cdataEndMarker = "]]>"; - if(type == XmlElementType.XML_CDATA_END && whiteSpace.indexOf(cdataEndMarker) == -1) { + @NonNls final String cdataEndMarker = "]]>"; + if(type == XmlTokenType.XML_CDATA_END && whiteSpace.indexOf(cdataEndMarker) == -1) { final ASTNode at = findElementAt(prevNode.getStartOffset()); if (at != null && at.getPsi() instanceof PsiWhiteSpace) { diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ShiftIndentInsideHelper.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ShiftIndentInsideHelper.java index f975f622407e..158e8b60cd2d 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ShiftIndentInsideHelper.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ShiftIndentInsideHelper.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -113,7 +113,7 @@ public class ShiftIndentInsideHelper { leafOffset = getStartOffset(element, leaf); } else { - if (newSpace.length() > 0) { + if (!newSpace.isEmpty()) { LeafElement newLeaf = ASTFactory.whitespace(newSpace); next.getTreeParent().addChild(newLeaf, next); } @@ -129,7 +129,7 @@ public class ShiftIndentInsideHelper { } String leafText = leaf.getText(); String newLeafText = leafText.substring(0, startOffset) + newSpace + leafText.substring(endOffset); - if (newLeafText.length() > 0) { + if (!newLeafText.isEmpty()) { LeafElement newLeaf = Factory.createSingleLeafElement(leaf.getElementType(), newLeafText,charTableByTree, SharedImplUtil.getManagerByTree(leaf)); if (leaf.getTreeParent() != null) { leaf.getTreeParent().replaceChild(leaf, newLeaf); diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDComment.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDComment.java index 740b77cb2228..0d51c0d2111f 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDComment.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDComment.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,11 +43,11 @@ public class JDComment { } protected static boolean isNull(@Nullable String s) { - return s == null || s.trim().length() == 0; + return s == null || s.trim().isEmpty(); } protected static boolean isNull(@Nullable List<?> l) { - return l == null || l.size() == 0; + return l == null || l.isEmpty(); } public void setMultiLine(boolean value) { diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDMethodComment.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDMethodComment.java index 0059b2f1274f..e541b0714c5b 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDMethodComment.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDMethodComment.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,7 +39,7 @@ public class JDMethodComment extends JDParamListOwnerComment { super.generateSpecial(prefix, sb); if (myReturnTag != null) { - if (myFormatter.getSettings().JD_KEEP_EMPTY_RETURN || myReturnTag.trim().length() != 0) { + if (myFormatter.getSettings().JD_KEEP_EMPTY_RETURN || !myReturnTag.trim().isEmpty()) { JDTag tag = JDTag.RETURN; sb.append(prefix); sb.append(tag.getWithEndWhitespace()); diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDParser.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDParser.java index 7220876dc0e9..05e359137e72 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDParser.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDParser.java @@ -73,7 +73,7 @@ public class JDParser { for (int i = 0; i < size; i++) { String line = l.get(i); line = line.trim(); - if (line.length() > 0) { + if (!line.isEmpty()) { if (line.charAt(0) == '*') { if ((markers.get(i)).booleanValue()) { if (line.length() > 1 && line.charAt(1) == ' ') { @@ -95,7 +95,7 @@ public class JDParser { String tag = null; for (int i = 0; i <= size; i++) { String line = i == size ? null : l.get(i); - if (i == size || line.length() > 0) { + if (i == size || !line.isEmpty()) { if (i == size || line.charAt(0) == '@') { if (tag == null) { comment.setDescription(sb.toString()); @@ -157,7 +157,7 @@ public class JDParser { private List<String> toArray(@Nullable String s, @NotNull String separators, @Nullable List<Boolean> markers) { if (s == null) return null; s = s.trim(); - if (s.length() == 0) return null; + if (s.isEmpty()) return null; boolean p2nl = markers != null && mySettings.JD_P_AT_EMPTY_LINES; List<String> list = new ArrayList<String>(); StringTokenizer st = new StringTokenizer(s, separators, true); @@ -232,7 +232,7 @@ public class JDParser { String seq = pair.getFirst(); boolean isMarked = pair.getSecond(); - if (seq.length() == 0) { + if (seq.isEmpty()) { // keep empty lines list.add(""); continue; @@ -514,9 +514,9 @@ public class JDParser { boolean insidePreTag = false; for (int i = 0; i < list.size(); i++) { String line = list.get(i); - if (line.length() == 0 && !mySettings.JD_KEEP_EMPTY_LINES) continue; + if (line.isEmpty() && !mySettings.JD_KEEP_EMPTY_LINES) continue; if (i != 0) sb.append(prefix); - if (line.length() == 0 && mySettings.JD_P_AT_EMPTY_LINES && !insidePreTag) { + if (line.isEmpty() && mySettings.JD_P_AT_EMPTY_LINES && !insidePreTag) { if (myLanguageLevel.isAtLeast(LanguageLevel.JDK_1_8)) { //Self-closing elements are not allowed for javadoc tool from JDK8 sb.append(P_START_TAG); 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 c23cf728f500..4ca7694dfd5b 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-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,7 +53,7 @@ public class FilePathReferenceProvider extends PsiReferenceProvider { String text, int offset, final boolean soft, - final @NotNull Module... forModules) { + @NotNull final Module... forModules) { return new FileReferenceSet(text, element, offset, this, true, myEndingSlashNotAllowed) { @@ -75,7 +75,7 @@ public class FilePathReferenceProvider extends PsiReferenceProvider { @Override public boolean absoluteUrlNeedsStartSlash() { final String s = getPathString(); - return s != null && s.length() > 0 && s.charAt(0) == '/'; + return s != null && !s.isEmpty() && s.charAt(0) == '/'; } @Override diff --git a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReference.java b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReference.java index c4024838e8af..5e4e42e66410 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReference.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReference.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -518,7 +518,6 @@ public class JavaClassReference extends GenericReference implements PsiJavaRefer return list; } - @NotNull public void processSubclassVariants(@NotNull PsiPackage context, @NotNull String[] extendClasses, Consumer<LookupElement> result) { GlobalSearchScope packageScope = PackageScope.packageScope(context, true); GlobalSearchScope scope = myJavaClassReferenceSet.getProvider().getScope(getElement().getProject()); diff --git a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReferenceProvider.java b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReferenceProvider.java index ebc7ec1de80c..6e9e92dc4ff9 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReferenceProvider.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReferenceProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,7 +61,7 @@ public class JavaClassReferenceProvider extends GenericReferenceProvider impleme private boolean myAllowEmpty; - private ParameterizedCachedValueProvider<List<PsiElement>, Project> myProvider = new ParameterizedCachedValueProvider<List<PsiElement>, Project>() { + private final ParameterizedCachedValueProvider<List<PsiElement>, Project> myProvider = new ParameterizedCachedValueProvider<List<PsiElement>, Project>() { @Override public CachedValueProvider.Result<List<PsiElement>> compute(Project project) { final List<PsiElement> psiPackages = new ArrayList<PsiElement>(); diff --git a/java/java-impl/src/com/intellij/psi/impl/source/tree/injected/MyTestInjector.java b/java/java-impl/src/com/intellij/psi/impl/source/tree/injected/MyTestInjector.java index 2876f7611a15..5139b49efc16 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/tree/injected/MyTestInjector.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/tree/injected/MyTestInjector.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -293,7 +293,7 @@ public class MyTestInjector { if (!method.hasModifierProperty(PsiModifier.NATIVE) || !method.hasModifierProperty(PsiModifier.PUBLIC)) return; String paramList = ""; for (PsiParameter parameter : method.getParameterList().getParameters()) { - if (paramList.length()!=0) paramList += ","; + if (!paramList.isEmpty()) paramList += ","; paramList += parameter.getName(); } @NonNls String header = "function " + method.getName() + "("+paramList+") {"; diff --git a/java/java-impl/src/com/intellij/psi/search/scope/packageSet/PatternPackageSetParserExtension.java b/java/java-impl/src/com/intellij/psi/search/scope/packageSet/PatternPackageSetParserExtension.java index d009798075b2..0b46bfee4f0f 100644 --- a/java/java-impl/src/com/intellij/psi/search/scope/packageSet/PatternPackageSetParserExtension.java +++ b/java/java-impl/src/com/intellij/psi/search/scope/packageSet/PatternPackageSetParserExtension.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ public class PatternPackageSetParserExtension implements PackageSetParserExtensi scope = PatternPackageSet.SCOPE_PROBLEM; } else if (PatternPackageSet.SCOPE_LIBRARY.equals(id)) { scope = PatternPackageSet.SCOPE_LIBRARY; - } else if (id.trim().length() > 0) { + } else if (!id.trim().isEmpty()) { scope = null; } final CharSequence buf = lexer.getBufferSequence(); diff --git a/java/java-impl/src/com/intellij/refactoring/introduceparameterobject/IntroduceParameterObjectUsageViewDescriptor.java b/java/java-impl/src/com/intellij/refactoring/introduceparameterobject/IntroduceParameterObjectUsageViewDescriptor.java index 31e8fd0b4646..87dc870bebe8 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceparameterobject/IntroduceParameterObjectUsageViewDescriptor.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceparameterobject/IntroduceParameterObjectUsageViewDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import com.intellij.psi.PsiMethod; import com.intellij.refactoring.RefactorJBundle; import com.intellij.refactoring.psi.MyUsageViewUtil; import com.intellij.refactoring.ui.UsageViewDescriptorAdapter; +import org.jetbrains.annotations.NotNull; class IntroduceParameterObjectUsageViewDescriptor extends UsageViewDescriptorAdapter { @@ -30,6 +31,7 @@ class IntroduceParameterObjectUsageViewDescriptor extends UsageViewDescriptorAda this.method = method; } + @NotNull public PsiElement[] getElements() { return new PsiElement[]{method}; } diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/JavaMoveClassesOrPackagesHandler.java b/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/JavaMoveClassesOrPackagesHandler.java index 905e3713197c..8719d9a45209 100644 --- a/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/JavaMoveClassesOrPackagesHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/JavaMoveClassesOrPackagesHandler.java @@ -43,6 +43,7 @@ import com.intellij.refactoring.util.RadioUpDownListener; import com.intellij.refactoring.util.RefactoringUtil; import com.intellij.util.IncorrectOperationException; import com.intellij.util.containers.HashSet; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -138,12 +139,19 @@ public class JavaMoveClassesOrPackagesHandler extends MoveHandlerDelegate { if (targetContainer instanceof PsiDirectory) { if (CommonRefactoringUtil.checkReadOnlyStatusRecursively(project, Arrays.asList(adjustedElements), true)) { if (!packageHasMultipleDirectoriesInModule(project, (PsiDirectory)targetContainer)) { - new MoveClassesOrPackagesToNewDirectoryDialog((PsiDirectory)targetContainer, adjustedElements, callback).show(); + createMoveClassesOrPackagesToNewDirectoryDialog((PsiDirectory)targetContainer, adjustedElements, callback).show(); return; } } } - MoveClassesOrPackagesImpl.doMove(project, adjustedElements, targetContainer, callback); + doMoveWithMoveClassesDialog(project, adjustedElements, targetContainer, callback); + } + + protected void doMoveWithMoveClassesDialog(final Project project, + PsiElement[] adjustedElements, + PsiElement initialTargetElement, + final MoveCallback moveCallback) { + MoveClassesOrPackagesImpl.doMove(project, adjustedElements, initialTargetElement, moveCallback); } private static void moveDirectoriesLibrariesSafe(Project project, @@ -173,6 +181,13 @@ public class JavaMoveClassesOrPackagesHandler extends MoveHandlerDelegate { } } + @NotNull + protected DialogWrapper createMoveClassesOrPackagesToNewDirectoryDialog(@NotNull final PsiDirectory directory, + PsiElement[] elementsToMove, + final MoveCallback moveCallback) { + return new MoveClassesOrPackagesToNewDirectoryDialog(directory, elementsToMove, moveCallback); + } + private static void moveAsDirectory(Project project, PsiElement targetContainer, final MoveCallback callback, @@ -445,7 +460,7 @@ public class JavaMoveClassesOrPackagesHandler extends MoveHandlerDelegate { if (adjustedElements == null) { return true; } - MoveClassesOrPackagesImpl.doMove(project, adjustedElements, initialTargetElement, null); + doMoveWithMoveClassesDialog(project, adjustedElements, initialTargetElement, null); return true; } return false; diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesToNewDirectoryDialog.java b/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesToNewDirectoryDialog.java index 4d1792cb9ee3..de16039b99b2 100644 --- a/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesToNewDirectoryDialog.java +++ b/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesToNewDirectoryDialog.java @@ -191,6 +191,19 @@ public class MoveClassesOrPackagesToNewDirectoryDialog extends DialogWrapper { return myDestDirectoryField.getTextField(); } + //for scala plugin + @NotNull + protected MoveClassesOrPackagesProcessor createMoveClassesOrPackagesProcessor(Project project, + PsiElement[] elements, + @NotNull final MoveDestination moveDestination, + boolean searchInComments, + boolean searchInNonJavaFiles, + MoveCallback moveCallback) { + + return new MoveClassesOrPackagesProcessor(project, elements, moveDestination, + searchInComments, searchInNonJavaFiles, moveCallback); + } + protected void performRefactoring(Project project, PsiDirectory directory, PsiPackage aPackage, boolean searchInComments, boolean searchForTextOccurences) { @@ -205,9 +218,9 @@ public class MoveClassesOrPackagesToNewDirectoryDialog extends DialogWrapper { ? factory.createSourceFolderPreservingMoveDestination(aPackage.getQualifiedName()) : factory.createSourceRootMoveDestination(aPackage.getQualifiedName(), sourceRoot); - MoveClassesOrPackagesProcessor processor = new MoveClassesOrPackagesProcessor(myDirectory.getProject(), myElementsToMove, destination, - searchInComments, searchForTextOccurences, - myMoveCallback); + MoveClassesOrPackagesProcessor processor = createMoveClassesOrPackagesProcessor(myDirectory.getProject(), myElementsToMove, destination, + searchInComments, searchForTextOccurences, myMoveCallback); + if (processor.verifyValidPackageName()) { processor.setPrepareSuccessfulSwingThreadCallback(new Runnable() { @Override diff --git a/java/java-impl/src/com/intellij/refactoring/removemiddleman/RemoveMiddlemanUsageViewDescriptor.java b/java/java-impl/src/com/intellij/refactoring/removemiddleman/RemoveMiddlemanUsageViewDescriptor.java index 4874b64f5ff7..c3bc67e81771 100644 --- a/java/java-impl/src/com/intellij/refactoring/removemiddleman/RemoveMiddlemanUsageViewDescriptor.java +++ b/java/java-impl/src/com/intellij/refactoring/removemiddleman/RemoveMiddlemanUsageViewDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,6 +39,7 @@ class RemoveMiddlemanUsageViewDescriptor implements UsageViewDescriptor { return RefactorJBundle.message("remove.middleman.field.header"); } + @NotNull public PsiElement[] getElements() { return new PsiElement[]{field}; } diff --git a/java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/WrapReturnValueUsageViewDescriptor.java b/java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/WrapReturnValueUsageViewDescriptor.java index 7ee4cfb3329a..409f50fd504e 100644 --- a/java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/WrapReturnValueUsageViewDescriptor.java +++ b/java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/WrapReturnValueUsageViewDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,6 +34,7 @@ class WrapReturnValueUsageViewDescriptor implements UsageViewDescriptor { this.method = method; } + @NotNull public PsiElement[] getElements(){ return new PsiElement[]{method}; } diff --git a/java/java-impl/src/com/intellij/testIntegration/createTest/CreateTestDialog.java b/java/java-impl/src/com/intellij/testIntegration/createTest/CreateTestDialog.java index 1185d60a7971..fe2b896499b3 100644 --- a/java/java-impl/src/com/intellij/testIntegration/createTest/CreateTestDialog.java +++ b/java/java-impl/src/com/intellij/testIntegration/createTest/CreateTestDialog.java @@ -40,6 +40,7 @@ import com.intellij.openapi.roots.ModuleRootManager; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Pair; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; import com.intellij.refactoring.PackageWrapper; @@ -215,13 +216,47 @@ public class CreateTestDialog extends DialogWrapper { updateMethodsTable(); } + private boolean isSuperclassSelectedManually() { + String superClass = mySuperClassField.getText(); + if (StringUtil.isEmptyOrSpaces(superClass)) { + return false; + } + + for (TestFramework framework : TestFramework.EXTENSION_NAME.getExtensions()) { + if (superClass.equals(framework.getDefaultSuperClass())) { + return false; + } + } + + return true; + } + private void onLibrarySelected(TestFramework descriptor) { - String text = CodeInsightBundle.message("intention.create.test.dialog.library.not.found", descriptor.getName()); - myFixLibraryLabel.setText(text); - myFixLibraryPanel.setVisible(!descriptor.isLibraryAttached(myTargetModule)); + if (descriptor.isLibraryAttached(myTargetModule)) { + myFixLibraryPanel.setVisible(false); + } + else { + myFixLibraryPanel.setVisible(true); + String text = CodeInsightBundle.message("intention.create.test.dialog.library.not.found", descriptor.getName()); + myFixLibraryLabel.setText(text); + + myFixLibraryButton.setVisible(descriptor.getLibraryPath() != null); + } String superClass = descriptor.getDefaultSuperClass(); - mySuperClassField.appendItem(superClass == null ? "" : superClass); + + if (isSuperclassSelectedManually()) { + if (superClass != null) { + String currentSuperClass = mySuperClassField.getText(); + mySuperClassField.appendItem(superClass); + mySuperClassField.setText(currentSuperClass); + } + } + else { + mySuperClassField.appendItem(StringUtil.notNullize(superClass)); + mySuperClassField.getChildComponent().setSelectedItem(StringUtil.notNullize(superClass)); + } + mySelectedFramework = descriptor; } @@ -524,7 +559,10 @@ public class CreateTestDialog extends DialogWrapper { dialog.showDialog(); PsiClass aClass = dialog.getSelected(); if (aClass != null) { - mySuperClassField.setText(aClass.getQualifiedName()); + String superClass = aClass.getQualifiedName(); + + mySuperClassField.appendItem(superClass); + mySuperClassField.getChildComponent().setSelectedItem(superClass); } } } diff --git a/java/java-impl/src/com/intellij/usageView/JavaUsageViewDescriptionProvider.java b/java/java-impl/src/com/intellij/usageView/JavaUsageViewDescriptionProvider.java index c31d9a5f5aaf..76b4e50f1680 100644 --- a/java/java-impl/src/com/intellij/usageView/JavaUsageViewDescriptionProvider.java +++ b/java/java-impl/src/com/intellij/usageView/JavaUsageViewDescriptionProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,12 +18,14 @@ package com.intellij.usageView; import com.intellij.psi.*; import com.intellij.psi.util.PsiFormatUtil; import com.intellij.lang.LangBundle; +import com.intellij.psi.util.PsiFormatUtilBase; import org.jetbrains.annotations.NotNull; /** * @author yole */ public class JavaUsageViewDescriptionProvider implements ElementDescriptionProvider { + @Override public String getElementDescription(@NotNull final PsiElement element, @NotNull final ElementDescriptionLocation location) { if (location instanceof UsageViewShortNameLocation) { if (element instanceof PsiThrowStatement) { @@ -53,7 +55,7 @@ public class JavaUsageViewDescriptionProvider implements ElementDescriptionProvi else if (element instanceof PsiMethod) { PsiMethod psiMethod = (PsiMethod)element; return PsiFormatUtil.formatMethod(psiMethod, PsiSubstitutor.EMPTY, - PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_PARAMETERS, PsiFormatUtil.SHOW_TYPE); + PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_PARAMETERS, PsiFormatUtilBase.SHOW_TYPE); } } diff --git a/java/java-impl/src/com/intellij/usages/impl/rules/ClassGroupingRule.java b/java/java-impl/src/com/intellij/usages/impl/rules/ClassGroupingRule.java index 3f4864ef6ffd..4dc906ea9d3e 100644 --- a/java/java-impl/src/com/intellij/usages/impl/rules/ClassGroupingRule.java +++ b/java/java-impl/src/com/intellij/usages/impl/rules/ClassGroupingRule.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,6 @@ import com.intellij.navigation.NavigationItemFileStatus; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.DataKey; import com.intellij.openapi.actionSystem.DataSink; -import com.intellij.openapi.actionSystem.LangDataKeys; import com.intellij.openapi.actionSystem.TypeSafeDataProvider; import com.intellij.openapi.util.Iconable; import com.intellij.openapi.vcs.FileStatus; @@ -181,7 +180,7 @@ public class ClassGroupingRule implements UsageGroupingRule { } @Override - public int compareTo(UsageGroup usageGroup) { + public int compareTo(@NotNull UsageGroup usageGroup) { return getText(null).compareToIgnoreCase(usageGroup.getText(null)); } diff --git a/java/java-impl/src/com/intellij/usages/impl/rules/ImportFilteringRule.java b/java/java-impl/src/com/intellij/usages/impl/rules/ImportFilteringRule.java index f3ecf42415e9..ce6ce08d4293 100644 --- a/java/java-impl/src/com/intellij/usages/impl/rules/ImportFilteringRule.java +++ b/java/java-impl/src/com/intellij/usages/impl/rules/ImportFilteringRule.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ import org.jetbrains.annotations.NotNull; * Date: Jan 17, 2005 */ public class ImportFilteringRule extends com.intellij.usages.rules.ImportFilteringRule { + @Override public boolean isVisible(@NotNull Usage usage) { if (usage instanceof PsiElementUsage) { final PsiElement psiElement = ((PsiElementUsage)usage).getElement(); diff --git a/java/java-impl/src/com/intellij/usages/impl/rules/JavaClassGroupRuleProvider.java b/java/java-impl/src/com/intellij/usages/impl/rules/JavaClassGroupRuleProvider.java index bf8561c9913a..82b156c59385 100644 --- a/java/java-impl/src/com/intellij/usages/impl/rules/JavaClassGroupRuleProvider.java +++ b/java/java-impl/src/com/intellij/usages/impl/rules/JavaClassGroupRuleProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import com.intellij.openapi.project.Project; * @author yole */ public class JavaClassGroupRuleProvider implements FileStructureGroupRuleProvider { + @Override public UsageGroupingRule getUsageGroupingRule(final Project project) { return new ClassGroupingRule(); } diff --git a/java/java-impl/src/com/intellij/usages/impl/rules/JavaMethodGroupRuleProvider.java b/java/java-impl/src/com/intellij/usages/impl/rules/JavaMethodGroupRuleProvider.java index 3ed6d3dafaa8..6ab324fcaa9c 100644 --- a/java/java-impl/src/com/intellij/usages/impl/rules/JavaMethodGroupRuleProvider.java +++ b/java/java-impl/src/com/intellij/usages/impl/rules/JavaMethodGroupRuleProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import com.intellij.openapi.project.Project; * @author yole */ public class JavaMethodGroupRuleProvider implements FileStructureGroupRuleProvider { + @Override public UsageGroupingRule getUsageGroupingRule(final Project project) { return new MethodGroupingRule(); } diff --git a/java/java-impl/src/com/intellij/usages/impl/rules/JavaUsageTypeProvider.java b/java/java-impl/src/com/intellij/usages/impl/rules/JavaUsageTypeProvider.java index 7cdf805178d0..445a8aab14a2 100644 --- a/java/java-impl/src/com/intellij/usages/impl/rules/JavaUsageTypeProvider.java +++ b/java/java-impl/src/com/intellij/usages/impl/rules/JavaUsageTypeProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,6 +35,7 @@ import java.util.Set; * @author yole */ public class JavaUsageTypeProvider implements UsageTypeProviderEx { + @Override public UsageType getUsageType(final PsiElement element) { return getUsageType(element, UsageTarget.EMPTY_ARRAY); } diff --git a/java/java-impl/src/com/intellij/usages/impl/rules/MethodGroupingRule.java b/java/java-impl/src/com/intellij/usages/impl/rules/MethodGroupingRule.java index 4eaa3cccd850..496703dd354f 100644 --- a/java/java-impl/src/com/intellij/usages/impl/rules/MethodGroupingRule.java +++ b/java/java-impl/src/com/intellij/usages/impl/rules/MethodGroupingRule.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,6 @@ import com.intellij.navigation.NavigationItemFileStatus; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.DataKey; import com.intellij.openapi.actionSystem.DataSink; -import com.intellij.openapi.actionSystem.LangDataKeys; import com.intellij.openapi.actionSystem.TypeSafeDataProvider; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; @@ -159,7 +158,7 @@ public class MethodGroupingRule implements UsageGroupingRule { } @Override - public int compareTo(UsageGroup usageGroup) { + public int compareTo(@NotNull UsageGroup usageGroup) { if (!(usageGroup instanceof MethodUsageGroup)) { LOG.error("MethodUsageGroup expected but " + usageGroup.getClass() + " found"); } diff --git a/java/java-impl/src/com/intellij/usages/impl/rules/NonJavaFileGroupRuleProvider.java b/java/java-impl/src/com/intellij/usages/impl/rules/NonJavaFileGroupRuleProvider.java index 5b56f973985a..41ccee880de4 100644 --- a/java/java-impl/src/com/intellij/usages/impl/rules/NonJavaFileGroupRuleProvider.java +++ b/java/java-impl/src/com/intellij/usages/impl/rules/NonJavaFileGroupRuleProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import com.intellij.openapi.project.Project; * @author yole */ public class NonJavaFileGroupRuleProvider implements FileStructureGroupRuleProvider { + @Override public UsageGroupingRule getUsageGroupingRule(final Project project) { return new NonJavaFileGroupingRule(project); } diff --git a/java/java-impl/src/com/intellij/usages/impl/rules/PackageGroupingRule.java b/java/java-impl/src/com/intellij/usages/impl/rules/PackageGroupingRule.java index 510ae816a14a..960e6180a7c7 100644 --- a/java/java-impl/src/com/intellij/usages/impl/rules/PackageGroupingRule.java +++ b/java/java-impl/src/com/intellij/usages/impl/rules/PackageGroupingRule.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ package com.intellij.usages.impl.rules; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.DataKey; import com.intellij.openapi.actionSystem.DataSink; -import com.intellij.openapi.actionSystem.LangDataKeys; import com.intellij.openapi.actionSystem.TypeSafeDataProvider; import com.intellij.openapi.project.Project; import com.intellij.openapi.vcs.FileStatus; @@ -42,6 +41,7 @@ public class PackageGroupingRule extends DirectoryGroupingRule { super(project); } + @Override protected UsageGroup getGroupForFile(final VirtualFile dir) { PsiDirectory psiDirectory = PsiManager.getInstance(myProject).findDirectory(dir); if (psiDirectory != null) { @@ -60,44 +60,53 @@ public class PackageGroupingRule extends DirectoryGroupingRule { update(); } + @Override public void update() { if (isValid()) { myIcon = myPackage.getIcon(0); } } + @Override public Icon getIcon(boolean isOpen) { return myIcon; } + @Override @NotNull public String getText(UsageView view) { return myPackage.getQualifiedName(); } + @Override public FileStatus getFileStatus() { if (!isValid()) return null; PsiDirectory[] dirs = myPackage.getDirectories(); return dirs.length == 1 ? FileStatusManager.getInstance(myProject).getStatus(dirs[0].getVirtualFile()) : null; } + @Override public boolean isValid() { return myPackage.isValid(); } + @Override public void navigate(boolean focus) throws UnsupportedOperationException { myPackage.navigate(focus); } + @Override public boolean canNavigate() { return myPackage.canNavigate(); } + @Override public boolean canNavigateToSource() { return false; } - public int compareTo(UsageGroup usageGroup) { + @Override + public int compareTo(@NotNull UsageGroup usageGroup) { return getText(null).compareToIgnoreCase(usageGroup.getText(null)); } @@ -112,6 +121,7 @@ public class PackageGroupingRule extends DirectoryGroupingRule { return myPackage.hashCode(); } + @Override public void calcData(final DataKey key, final DataSink sink) { if (!isValid()) return; if (CommonDataKeys.PSI_ELEMENT == key) { |