Snapshot 205707dc11cdd6508ae84db85d104f834028fd65 from idea/132.1045 of git://git.jetbrains.org/idea/community.git
205707d: support abbreviations in Search Everywhere
9eeb98a: NPE fix
f701598: AA painting for shortcuts
9636e23: add abbreviations
d1f7c58: IDEA-116296 Search match looks terrible under Retina
8bc5adc: AIOOBE
f92fa41: IDEA-116194 "Generate equals() and hashcode()" for final classes should disable "accept subclasses" variant
ec773fc: CCE
9a208ab: selected completion item should be the first or second visible (IDEA-115199)
be542d6: linear-time filterByDumbAwareness
83273e5: faster next/prev occurrence action in the console (IDEA-115163)
d684469: LanguageConsole: shutdown printXXX fiesta. Everyone is advised to use ConsoleView API the right way.
480215a: Merge branch 'master' of git.labs.intellij.net:idea/community
c85aae4: https://android-review.googlesource.com/69716
76daf2e: Heroku integration - show log on redeploy
c567431: Jediterm updated (PY-11368).
5d325de: Accept only terminal tabs on DnD.
a1d5cd4: Merge remote-tracking branch 'origin/master'
0a3bcdb: Jediterm updated.
218607a8: Terminal: support presentation mode.
ea6fd6f: switch on console-content-type highlighting in all language consoles
e824117: Quick fix for RefParserTest
450ecea: suggest scrambled classes on second completion
7ba82d9: NPE fixed
525a30d: cleanup
2fa314d: don't display "Loading spellchecker dictionaries" in status bar (IDEA-115130)
276a47a: don't suggest scrambled classes in autopopup (IDEA-115199)
b4a4b99: temporary fix for layouts of small IDEs
02e07e1: [log] Move SimpleHash from vcs-log-graph to vcs-log-impl
f7b1796: [log] Hash -> int in Graph
0c4d0bb: [log] Don't call new VcsRefImpl() directly, use the factory
4c1c1c2: [log] Memory consumption: Hash -> int. Take 1
2e36939: Improvement from Roman Shevchenko to be compatible with Ubuntu 13.10.
b6edb35: Show pin icon in pinned Find Usages tabs
c143cee: IDEA-110064 JSF 2.2: Pass-through elements: if upper-case symbols are used instead of default 'jsf' namespace prefix, attributes are red-highlihted
3a69458: added actions 'mark/unmark as generated sources root' to popup menu
bdfc48c: Use maven3 importer by default.
d9417b6: Merge remote-tracking branch 'origin/master'
5b526fc: Add pty libs to pycharm community build.
c912c67: add HowTo
6d940b1: depend on PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT if the file cannot be resolved yet
7c63c25: platform: jayatana patched to support Ubuntu 13.10 (sources only)
59622ee: IDEA-116276 Console font is small in Presentation mode
6863abc: IDEA-115889 Framework toolwindows: support scope-based file colors for items
ac0f8ab: obtaining framework libraries from app server: download libraries list asynchronously from server
185804e: refactor supported root type checking according to CR-IC-3056
6b085fe: formatter removes spaces in import statement parentheses (PY-11359)
b04030e: Show pin icon in pinned Find Usages tabs
90ea6d7: do not disable empty frameworks page if no templates available
bb55e29: platform: jayatana sources attached
d1911f7: platform: Ubuntu app menu loading code extracted and corrected
897738a: Cleanup (deprecated code)
56e41fb: Check Grails SDK in background thread, not in the AWT. +review CR-IU @gromopert
fd2b6b3: IDEA-115074 New Project Wizard: Grails: grails-specific settings are missing
a69a88a: spi: decline abstract classes, suggest all available inheritors (IDEA-115502)
eeaee1e: SIOOBE
6cd3cb9: Fix spelling
5f4c814: IDEA-102413 (pointless assertion dropped)
dc455bd: Cleanup (arrangement, formatting)
44590dc: IDEA-25934 Maven: Webapp resources filtering store web resources configuration.
6e65f2b: IDEA-25934 Maven: Webapp resources filtering store web resources configuration.
df137ae: DOM stubs: namespace key index
046e455: Merge remote-tracking branch 'origin/master'
0681517: testdata fixed
dd63221: IDEA-116168 Action creation does not escape special chars in plugin.xml
48fa01e: restore plugin description
d34d829: new project wizard: remote templates
389db71: methods renamed
b07e674: prefer non-qualified xml completion variants (IDEA-115355)
add165a: IDEA-116144 Opening build.gradle of android project fails
d524a84: refixed IDEA-111753 to remove unnecessary dependency on debugger
b8df146: show usages from generated code in separate group (IDEA-97579)
034f42b: removed obsolete 'remote-server-util' module from installation, added new module to git plugin installation
c8deccf: download libraries in parallel (IDEA-88561)
674de91: our LinkedHashMap: added methods to obtain last added key/value
43aced8: Restore context menu after DnD back to Terminal View.
b6987d3: Merge remote-tracking branch 'origin/master'
c147027: Fix: terminal tab doesn't save name change after DnD.
495bda4: JediTerm update to version 1.0
46667e2: Fix closing tab on session end. Fix popup for editor terminal tabs.
fdd3e70: Fix potential NPE.
9ea940a: [git] Fix refresh notification after changing non-active branch hashes
34b357c: more console folding by default
d21cf01: Fix memory leak.
1dcfd64: Fix removing terminal tabs on drag'n'drop.
29a4f60: add accessOrder parameter to our LinkedHashMap
e0ff96d: DockableEditorTabbedContainer shouldn't return root pane as accept area as it makes impossible to add any other dockable container. It is better to return root pane in the special fallback method after we checked all containers.
4b22045: Terminal tabs: drag'n'drop to editor and back implemented.
6ac9ae9: DockableEditor doesn't need EditorWindow reference.
73f7ab5: [log] IDEA-115980 Don't show Git actions if there are no Git roots
7964385: [log] "Go To Commit" action
c647083: [log] Extract the popup text field used for user completion
7e9497a: Merge remote-tracking branch 'origin/master'
0eb8a6f: [log] Fix hidden graph because of the date filter existance
95d5d5b: [log] IDEA-116022 Implement Structure filter for VCS Log & Git
4989fa1: [vcs] VcsStructureChooser: remove dependency on the AbstractVcs.
278cd62: [log] move structure filter implementation to vcs-log-impl
9b5b1c2: Github: change search request parameter
a543347: IDEA-115330 Incorrect "condition is always false"
0b85cc1: trying to make project opening progress information more meaningful (IDEA-115130)
35af155: Don't display empty panel if there are no moreMessage in the dialog
41592ca: [vcs] IDEA-116036 Pressing Escape in Commit/TODO dialog performs commit
7c5ba53: [log] Fix IDEA-115676 once again
8fb8d34: [log] IDEA-116056 Display commit time in details if different from author time
9b6d291: [log] IDEA-116022 Add filter by date
c49b45b: only suppress eager psi creation when there were stubs in the file
f815aa9: our LinkedHashMap clients aren't necessarily aware that it updates its ordering on every get. Let clients specify if they need this feature (IDEA-116222)
6fcd19c: return not-null MODULE_CONTEXT data only for single content roots (IDEA-115422)
0af49e6: fix two psi elements per one ast element in stub-ast switch: psi1 is taken from stub psi2 is eagerly created during chameleon parsing another thread gets the ast when some psi1 parent is already switched and psi1 is not, it walks down the ast and gets psi2
fcfef16: remove big JI sign
2ad7bd2: support for <shortcut>
cd74ff8: IDEA-116206
59b556f: set transparency 20%
152e772: fix missing help button
b8f59ef: add getLanguage() method
25dece1: IDEA-110540 ("String concat (+) and super.toString()" template adds "+ super.toString()" even if no super)
35c07da: new inference: reject isExact for no constructor parameterized class
5fafbd5: EA-51725 - NPE: IntroduceVariableBase.replace
22cf8de: ignore anonymous classes when generating constructors EA-51713 - assert: CreateConstructorMatchingSuperFix$.run
1735391: getWidget method
fcb4970: attempt to fix IDEA-116128 LiveEdit doesn't work correctly for JSP files
36e4932: continue "ability to return list of URLs" — isConfigurationFromContext
d67f88c: Cleanup (formatting)
3112d12: reliably check if a task for debugger manager thread was interrupted
201c7b5: IDEA-75717 ("Referenced checked for null not used inside if" false positive)
795357c: do not suppress file-level inspections
4745efc: continue "ability to return list of URLs" IDEA-115787
43216f8: IDEA-115787 Better resolvement for JSF page URLs
2e6db86: IDEA-100279 ChooseComponentsToExportDialog
72ee12c: fix warning "mac file equals"
19576b2: overrides, cleanup
0a15306: IDEA-100279 git init
b596340: IDEA-100279 xml editor location dialog
3c0f6cd: IDEA-100279 copyright plugin
b7c6e4c: overrides
e9e6eb2: 'Download library' refactored a little
946216e: IDEA-116197 (filter improvements)
9439744: EA-51425 - ISE: MavenUtil.resolveSuperPomFile add assertion.
9c38499: EA-51325 - assert: MavenIndices.createNewDir
9346755: don't log Connection reset by peer
cfb11fa: cleanup
038e39d: IDEA-114461 Structure tool window: Jump to Source (F4) does not move focus to Editor
ed4794e: VcsRootDetector and RootErrorsFinder tests updated
c196ab3: Remove unnecessary check and param from HgRepositoryImpl
b486fcb: template actions are now injection aware
773f5f0: IDEA-102454 Parameter Info: TAB/Shift-TAB and editing does not work in language injected fragment
3b34a0b: IDEA-49273 Injected language: parameter info tooltip disappears on moving caret
7afa57d: move indexer to indexing-impl
4ab17a0: don't shift text range if the element has no last child (PY-11344)
9e3bbe9: don't show "inspect test source" checkbox in PyCharm (PY-1187)
ac7f1b2: IDEA-113483 (action fixed to select directories too)
7bd9931: Emmet: extract SurroundWithEmmetAction
625e81b: don't show "production" and "test" scopes in predefined scopes if current product doesn't support test source roots (PY-7324)
f01a713: grouping by directory uses project-relative paths (PY-11176); rename the action from "Group by package" to "Group by directory" in platform-based IDEs
be45c85: move GeneralFormatterTest to platform-tests; fix NPE in DocumentImpl when running standalone GeneralFormatterTest
4d22f5e: DirectoryIndex: don't include roots from content to projectExcludeRoots set, update projectExcludeRoots on VFS change
02f7305: Merge branch 'master' of git.labs.intellij.net:idea/community
7994da2: External System: test fix Related task: IDEA-79466 gradle support should generate web module configuration
e3cfba1: IDEA-116126 - NoClassDefFound on attempt to deploy to heroku
630eacf: Merge remote-tracking branch 'origin/master'
a902c4e: testdata fixed
db0433c: fix NPE — final class variable is not yet initialized — we must not open connection until debug process class is not constructed.
dd2d5f6: platform: ensure event file validity on dropping symlink target
eaeed33: platform: better pairing of before/after VFS events
97aec30: Cleanup (formatting)
017646f: remove dead code, cleanup
2181005: more templates
ab315c8: new project wizard: template description & count
e789a57: External system: adding TEST_GENERATED source type to ExternalSystemSourceType
62eeca9: new project wizard: adding project templates
25e633c: SimpleColoredComponent: builder style
84c2eb6: ColoredListCellRenderer parameterized
3c567ba: cleanup
ab15886: cleanup
aaad70d: cleanup
81c7d30: update Key.findKeyByName usages due to API changes
41ca0a4: CCE aware API
fe3700f: java call hierarchy extension
51c76a3: Make view meta model extendable
e17daa4: unused methods with strange names deprecated
4910498: service replaced by utility methods
d0fd16f: faster for simple cases
3dd6919: fix CSS completion tests: if the reference starts at completion start location, we do need to overwrite it when Tab is pressed
22c1ef9: Gradle: update to Gradle 1.9-rc-3
7a38323: Pty4j updated.
29ac873: IDEA-97390 Java Debugger: View Text action shows white on white [2]
1c329ac: Merge branch 'master' of git.labs.intellij.net:idea/community
0c60dd9: IDEA-86998 Evaluate expression mixes colorschemas when displaying injected code
ce6fbd9: IDEA-97390 Java Debugger: View Text action shows white on white
a50bd7e: Merge branch 'master' of git.labs.intellij.net:idea/community
8de20e2: remote servers - headers cleanup
c5e1cf7: don't reformat mock variable during control flow building
8e11281: don't walk module src roots in search for .class file source (IDEA-116085)
992d740: cache expected names (IDEA-116085)
10976b3: walk library src roots once when searching for class sources (IDEA-116085)
dfc71fc: fix java pull up refactoring!
4af2a83: Merge remote-tracking branch 'origin/master'
a818922: javadoc: include in classpath only libraries from modules which participate in the scope (IDEA-116083)
38e2991: new inference: do not use nested call args to infer on the top level
465762a: new inference: reject multiple eq bounds
d84a0a0: Darcula eats almost all EDT cpu time
fe23143: IDEA-94922 (Report negatively named boolean variables and suggest to perform 'Invert Boolean' for them)
f637ac6: fix description
9005acd: common "invert boolean" quickfix
9a5bfa9: add #loc's
dd94fc6: fix "No dependencies provided which causes CachedValue to be never recalculated again."
e4cce36: java.lang.IllegalThreadStateException additional handling
1249362: disposed check
0495c47: cleanup
25fc653: extra inspections
8850957: IDEA-101405 Call hierarchy support for Groovy
3026341: hierarchy package
deb52f5: Flat & round stripe buttons (Internal Mode only) v.3, colors improvement
d903511: IDEA-116139 Workaround NPE fix
8fccc30: avoid assertion on file path completion (EA-51068)
fdb9f6e: ctrl+w shouldn't choke on unclosed argument lists (EA-51589)
1de20e6: don't inc modification counter on first load of gant/gradle settings
8a9c177: IDEA-25934 Maven: Webapp resources filtering store web resource configuration.
9553c1a: catch all exceptions that may influence VM attach process
aa8a8e8: IDEA-116146 Search everywhere has small font in Presentation mode
9c7d5d5: #WEB-8915 fixed
5d96196: dfa: flush resource variables when leaving try block
15c0fd6: jsr166e.jar included into standalone jps distribution
edbde43: generics: bounds check should stop expanding nested wildcards up to 2nd level
d991c73: fix invalid file assertion
aae4c5a: IDEA-116049 Mercurial log problem with Mac default locale (x_MacRoman)
08a6b0c: Unnecessary encoding argument in new hg log removed.
5cd75d1: style
5a365fd: fix BooleanParameterInspectionTest
4e2e6ca: [log] IDEA-115966 Show HAND cursor over branch arrows
7793ca6: [log] Collect user information from the whole log
4e8c466: [log] Completion in filter by user
bc4c9f8: [log] intern VcsUsers.
0505705: [log] Encapsulate author & committer into VcsUser
1fb280e: [log] Let VcsLogObjectsFactory be project service & depend on VcsLogManager
2f2f008: Gradle: add Tooling API extra models support. Related task: IDEA-79466 gradle support should generate web module configuration
3c9aa6d: convert EventLogCategory to abstract class
0804cb1: html5 char entities for fragments
0e50db9: #IDEA-116106 fixed
483a5d1: enable entities validation for html5 #WEB-7053 fixed
962e050: generated entities for html 5 chars, use it in resolve and completion
b57823a: Merge remote-tracking branch 'origin/master'
da8e5d0: we must add "http://" prefix if specified path is not absolute
6bb2810: small lens mode fix
88caaf7: Merge remote-tracking branch 'origin/master'
4268072: IDEA-116125 extra gutter in presentation mode
6d03a86: Eliminated dependencies on pthread, glib rec mutex synchronization. A crash fixed.
b5f05f4: Quick fix for not Unity window managers. Should be moved into linux-specific code.
fe27876: WI-14476 When hovering over variable, Expression Evaluation tooltip disappears before I can click the + icon (cherry picked from commit 3034e98)
202e2ae: Cleanup (test)
a5960af: java: no need to check package prefix for annotations on ref adjustment
ab262e2: Cleanup (test)
5b2a86b: IDEA-89720 Preview usages: "select usages to preview" should be shown at the center of panel
7b82bf1: IDEA-116119 Darcula: links are hardly visible on warnings
d2a2cd9: don't hide run configuration type if there are only one irrelevant type (IDEA-116046)
15e08d4: javadoc corrected
5575eb1: hide 'deploy to cloud' run configurations if corresponding cloud isn't configured (IDEA-116046)
3b3c221: WEB-9876 Fuzzy search is still colliding with completion
50bd840: Spock method should be a GrMethod.
5364513: exception-safe rendering
544a580: thread assertion fix
bc4c101: fix NPEs
56940f1: a way to increase dismiss delay
9aee54e: framework version from existing library
37f430f: removing borders automatically
19a21fd: new "Non-varargs method overrides varargs method" inspection
e82e54d: improve description
31fedec: New in 13
0fbffa1: fixed downloading client libraries from modal dialog (IDEA-115975)
5db09f5: CCE from android step fixed
cded14f: IDEA-115064 New Project Wizard: Spring page looks bad: preselected frameworks
e6b1f8e: fix NPE (request status)
8bba7c9: IDEA-115076 Groovy: New Project Wizard: IAE at DialogWrapperPeerFactoryImpl.createPeer() on 'Create Groovy Library'
5a47ef8: app server editor: don't show 'change version' button for app server library
f510156: IDEA-115398 New Project Wizard: libraries downloading doesn't work
3d251be: event log category EP
7d76939: Take shortcuts for next tab and prev tabs from keymap.
be19e2e: Next tab and Previous tab actions.
67310ba: Null class name tolerated
db170d7: Fixed text shaking on tab name editing.
bd3c4bc: Some cleanup.
b27ba6e: IDEA-112596 SQL: MySQL uncomment doesn't work with "--"
a67dac8: IDEA-115954 lens mode warning annotation bubbles overlap text on retina
b6c179c: IDEA-93733 Double line above editor tabs
2c91f79: EA-51491 - assert: DocumentImpl.createRangeMarker
1743e7b: EA-51650 - assert: JavaDocInfoGenerator.getDocComment
16712b8: Todo
f9d2c43: Cleanup (formatting)
38f058d: failing test for PY-10319
dd3f3fa: rename some methods and cleanup code to make logic clearer
aa885ea: report missing identifier after 'as' (PY-9853)
52efcb5: only allow single expression after 'in'; tweak error recovery when waiting for colon (PY-9561)
7f8dc3d: change default match-from-start to false
bfb1819: EA-51669 (unneeded augmentation avoided)
b27e492: platform: extension point declaration moved to correct .xml
4d9e686: sourcemaps: ability to resolve sources relative to generated file
40e08dc: Fix the size changing of text field for terminal tabs.
62223eb: Merge remote-tracking branch 'origin/master'
6c84d33: take synchronized statements into account when mapping local variable names to slots
4e560b6: allow to view hidden items in 'New Run Configuration' popup (IDEA-116046)
37caefe: IDEA-72889 (CodeStyle inspection to check tabs instead of spaces in file)
f345cfd: EA-51469: do not call GemManager.updateGemset(Module) with null
e27287d: ShowSettingUtil: selecting configurable by class is fixed
b9f0e95: new inference: infer recursively for conditional expression
646aea3: new inference: avoid self bounds when possible
a2ad6fd: new inference: accept captured wildcard opening during subtype constraint reduction
66462d0: remove incorrect copyright messages
c3c03a0: don't set default cursor if empty text is invisible
4f009e8: IDEA-115398 New Project Wizard: libraries downloading doesn't work
3607191: Merge remote-tracking branch 'origin/master'
a95509a: extracted method to get/set 'for generated source' option via API
7b00b8f: hide Groovy run configuration if there are no groovy files in project (IDEA-116046)
89f2a76: Minor VFS optimization (cleanup)
0defb40: less spam in the logs when there's PSI/document inconsistency during reference search (IDEA-115950)
29427e7: added service to quickly find modules by module type; hide DevKit and J2ME run configurations if there are no corresponding modules (IDEA-116046)
d031ebc: hide Python run configurations if they are irrelevant (IDEA-116046)
75ca45a: IDEA-116000 Error message shown if hg root marked as git
e9b3a8c: style
24f91c2: IDEA-115474 Maven Dependency template broken in latest Idea Cardea
26b5659: added API to hide irrelevant run configuration types from 'New' popup in 'Edit Configurations' dialog (IDEA-116046)
5b6b259: Merge remote-tracking branch 'origin/master'
0525b10: Revert the change.
4f9d3f0: Disable formatter ranges in formatter off/on tags [CR-IC-2916]
f760c44: IDEA-36685: Provide better 'no matching constructor' warnings where possible
915fb35a: new overload resolution: testdata
3546317: new overload resolution
971909a: method refs: exact tweaks
f6932ac: Merge remote-tracking branch 'origin/master'
c22e14c: JediTerm jar updated.
08eed1d: Merge remote-tracking branch 'origin/master'
5ff6e1a: Merge remote-tracking branch 'origin/master'
feec183: Pty4j with debug info.
08c90e8: Minor VFS optimization
53a81a0: Cleanup (formatting)
dc52633: EA-50578 - assert: TextRange.<init>
b532d92: Merge remote-tracking branch 'origin/master'
aa20e7d: status bar should have a height at least of an icon, even before any icons appear, to prevent unnecessary blinking (IDEA-114453)
1e0e31e: IDEA-112982 Status bar starts with bad layout before project is fully loaded default min height was 1 which made BoxLayout center-align everything along the top border resulting in 2x less memory indicator height
5fdc8f8: Merge branch 'svn_18_2'
cc6dd17: svn: Fixed destroy for process under terminal
9826ae7: external system: EA-51656, check for disposable project components added
7337a62: external system: EA-51656, check for disposable project components added
ea5159b: IDEA-116001 Incorrect behavior of root scanner in case non hg project marked as hg fixed
2186112: Merge remote-tracking branch 'origin/master'
9f02f7e: don't generate icons for IntelliJ laf
0f252a9: IDEA-90751 Scope tabs coloring does not affect hidden tabs pop-up
ab0e88a: cleanup dead code
79bf40e: IDEA-114608 breakpoints dialog: add panel must be at top
d9b94c5: new icons: vendors & sql structure view
5b4b9a7: svn: Do not read from error stream for process under terminal
ca6a8ac: drop command wrapper
5617a42: use correct date format in command to fix reverting changes on file with a sticky date
afbef4d: new inference: mark List::get as inexact
4fde439: EA-51621 - IOE: CheckUtil.checkWritable
eb79b67: EA-51643 - assert: DataManagerImpl$MyDataContext.getData
e1b69a4: new inference: exact method reference: decline constructor with parameter with type parameter of class
664ee85: improve parser recovery if keyword is used as function or class name (PY-8319)
5d6bac5: improve parser recovery if keyword is used as named parameter (PY-8318)
ce1ff5d: if we have only one import candidate, show its name instead of "import this name" (PY-8067)
27c5fbb: Visual Studio keymap maps Shift+F1 to both QuickJavaDoc and ExternalJavaDoc (PY-7291)
baaf551: rename file when renaming class if file name equals lowercased class name (PY-7155)
f52709b: tweak decorator parsing so that following line comment is outside the text range of PyDecorator (PY-5912)
a61112a: don't overwrite reference by Tab if it starts exactly after reference being completed (PY-6095)
12249d1: tab completion for keyword arguments overwrites the = sign (PY-1337(
a351f53: highlight only the last line of string literal when triple quotes are unclosed (PY-1780); allow running StringLiteralQuotesAnnotator in dumb mode
1bf4336: consistent behavior of PyFunction.getContainingClass() in stub-based and non-stub-based cases (PY-1448)
36c20c2: fix caret position after pressing Enter in Python line comment
e55c85f: fix HtmlCompletionTest.testDotTypeWhileActiveLookupInFileReference
a3e89bc: IntelliLang PatternValidator: class parsing errors should not fail the build if the class is not going to be instrumented by the validator. Covered 2 more cases when this check was not performed (IDEA-115189 IntelliLang Pattern Validator: Class not found)
6f7b23e: Merge remote-tracking branch 'origin/master'
c5d7ccd: Merge remote-tracking branch 'origin/master'
946d9ab: svn: terminal: Implemented handling of "unknown host" prompt for ssh
f1e1ceb: IDEA-113191 Used "write" access to sqlite db and try to access db several times if failed
b95367c: svn: Do not handle auth errors when command is finished if in terminal mode
e306801: svn: terminal: Added separate logging for status command output (as there are some issues with terminal output parsing)
f22a4ed: svn: terminal: Implemented cancelling authentication prompts
4e7c774: svn: terminal: Treat stdout lines with svn errors as stderr lines
a48733d: svn: Fixed default focused element for credentials dialog opening (password is focused if username is disabled)
aac45e5: svn: Implemented password prompts for ssh authentication through terminal
b8768d1: svn: Implemented basic svn+ssh authentication using terminal (under svn.use.terminal registry key)
13a217b: svn: Refactored CommandExecutor - ability to write to process input stream, small changes for inheritors
e9ccca6: svn: Moved setting "non-interactive" mode when command executor is created
4092ffa: svn: Added command logging in for non-zero exit code
8441324: Tab name length is limited by 50 in jediterm library.
1c63154: Use JB tabs in terminal(PY-10609). Pass disposable to terminal widget.
2ba2163: Extract method that sets content to the holder.
9c5a392: NPE (IDEA-115607).
Change-Id: I83d19d7826b59dbc1d782247b78553b4632e7635
diff --git a/.idea/libraries/jayatana.xml b/.idea/libraries/jayatana.xml
index a6f1222..ff31714 100644
--- a/.idea/libraries/jayatana.xml
+++ b/.idea/libraries/jayatana.xml
@@ -4,6 +4,8 @@
<root url="jar://$PROJECT_DIR$/lib/jayatana-1.2.4.jar!/" />
</CLASSES>
<JAVADOC />
- <SOURCES />
+ <SOURCES>
+ <root url="jar://$PROJECT_DIR$/lib/src/jayatana-1.2.4-src.zip!/" />
+ </SOURCES>
</library>
</component>
\ No newline at end of file
diff --git a/build/scripts/layouts.gant b/build/scripts/layouts.gant
index b9a4772..79a4506 100644
--- a/build/scripts/layouts.gant
+++ b/build/scripts/layouts.gant
@@ -327,6 +327,11 @@
jar("git4idea-rt.jar") {
module("git4idea-rt")
}
+ if (!isDefined("pluginFilter")) {//temporary fix to exclude remote-servers-git module from layout for small IDEs because corresponding module isn't compiled
+ jar("remote-servers-git.jar") {
+ module("remote-servers-git")
+ }
+ }
fileset(dir: "$home/plugins/git4idea/lib") {
include(name: "trilead-ssh2.jar")
}
@@ -717,6 +722,7 @@
include(name: "log4j.jar")
include(name: "jgoodies-forms.jar")
include(name: "ecj*.jar")
+ include(name: "jsr166e.jar")
}
dir("test") {
jar("jps-build-test.jar") {
diff --git a/colorSchemes/src/colorSchemes/Darcula.xml b/colorSchemes/src/colorSchemes/Darcula.xml
index bd7b3ac..724db8f 100644
--- a/colorSchemes/src/colorSchemes/Darcula.xml
+++ b/colorSchemes/src/colorSchemes/Darcula.xml
@@ -1,4 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ How to make changes in Darcula.xml
+ Open Settings -> Editor -> Colors & Fonts and make a copy of Darcula scheme. Say 'Darcula_copy'
+ In 'Colors & Fonts' settings panel make changes in 'Darcula_copy' scheme and save it
+ Open <IDEA_SETTINGS>/config/colors/Darcula_copy.icls and copy it's content into clipboard
+ Open Darcula.xml in editor and call 'Compare with Clipboard'
+ Apply necessary changes and commit
+-->
<scheme name="Darcula" version="1" parent_scheme="Default">
<option name="LINE_SPACING" value="1.0" />
<option name="EDITOR_FONT_SIZE" value="12" linux="14"/>
diff --git a/community-resources/src/idea/IdeaApplicationInfo.xml b/community-resources/src/idea/IdeaApplicationInfo.xml
index 1a80a08..084236c 100644
--- a/community-resources/src/idea/IdeaApplicationInfo.xml
+++ b/community-resources/src/idea/IdeaApplicationInfo.xml
@@ -15,7 +15,7 @@
<third-party url="http://www.jetbrains.org/"/>
- <editor background-url="/idea_logo_background.png"/>
+ <editor background-url="/idea_logo_welcome.png"/>
<update-urls check="http://www.jetbrains.com/updates/updates.xml"
patches="http://download.jetbrains.com/idea/"/>
diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java
index b644c8a..6655fe8 100644
--- a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java
+++ b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java
@@ -913,7 +913,7 @@
lfs.refreshIoFiles(outputs, _status == ExitStatus.CANCELLED, false, null);
indicator.setText("");
}
- if (compileContext.isAnnotationProcessorsEnabled()) {
+ if (compileContext.isAnnotationProcessorsEnabled() && !myProject.isDisposed()) {
final Set<File> genSourceRoots = new THashSet<File>(FileUtil.FILE_HASHING_STRATEGY);
final CompilerConfiguration config = CompilerConfiguration.getInstance(myProject);
for (Module module : affectedModules) {
diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/ui/actions/PackageFileWorker.java b/java/compiler/impl/src/com/intellij/packaging/impl/ui/actions/PackageFileWorker.java
index 2428990..8f815f3 100644
--- a/java/compiler/impl/src/com/intellij/packaging/impl/ui/actions/PackageFileWorker.java
+++ b/java/compiler/impl/src/com/intellij/packaging/impl/ui/actions/PackageFileWorker.java
@@ -87,6 +87,7 @@
for (final VirtualFile file : files) {
indicator.checkCanceled();
new ReadAction() {
+ @Override
protected void run(final Result result) {
try {
packageFile(file, project, artifacts, packIntoArchives);
diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/AutoRendererAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/AutoRendererAction.java
index 1891a77..1d1537f 100644
--- a/java/debugger/impl/src/com/intellij/debugger/actions/AutoRendererAction.java
+++ b/java/debugger/impl/src/com/intellij/debugger/actions/AutoRendererAction.java
@@ -15,6 +15,7 @@
*/
package com.intellij.debugger.actions;
+import com.intellij.debugger.engine.DebugProcessImpl;
import com.intellij.debugger.engine.events.DebuggerContextCommandImpl;
import com.intellij.debugger.impl.DebuggerContextImpl;
import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl;
@@ -26,21 +27,25 @@
public class AutoRendererAction extends AnAction{
public void actionPerformed(AnActionEvent e) {
final DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(e.getDataContext());
- final DebuggerTreeNodeImpl[] selectedNodes = DebuggerAction.getSelectedNodes(e.getDataContext());
- if(debuggerContext != null && debuggerContext.getDebugProcess() != null) {
- debuggerContext.getDebugProcess().getManagerThread().schedule(new DebuggerContextCommandImpl(debuggerContext) {
- public void threadAction() {
- for (int i = 0; i < selectedNodes.length; i++) {
- DebuggerTreeNodeImpl selectedNode = selectedNodes[i];
- NodeDescriptorImpl descriptor = selectedNode.getDescriptor();
- if (descriptor instanceof ValueDescriptorImpl) {
- ((ValueDescriptorImpl) descriptor).setRenderer(null);
- selectedNode.calcRepresentation();
+ if(debuggerContext != null) {
+ final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
+ if(debugProcess != null) {
+ final DebuggerTreeNodeImpl[] selectedNodes = DebuggerAction.getSelectedNodes(e.getDataContext());
+ if (selectedNodes != null) {
+ debugProcess.getManagerThread().schedule(new DebuggerContextCommandImpl(debuggerContext) {
+ public void threadAction() {
+ for (DebuggerTreeNodeImpl selectedNode : selectedNodes) {
+ final NodeDescriptorImpl descriptor = selectedNode.getDescriptor();
+ if (descriptor instanceof ValueDescriptorImpl) {
+ ((ValueDescriptorImpl)descriptor).setRenderer(null);
+ selectedNode.calcRepresentation();
+ }
+ }
}
- }
- }
- });
+ });
+ }
+ }
}
}
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/ThreadDumpAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/ThreadDumpAction.java
index ac513d7..a4fe426 100644
--- a/java/debugger/impl/src/com/intellij/debugger/actions/ThreadDumpAction.java
+++ b/java/debugger/impl/src/com/intellij/debugger/actions/ThreadDumpAction.java
@@ -33,7 +33,6 @@
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
-import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
@@ -298,12 +297,30 @@
catch (Throwable e) {
sourceName = "Unknown Source";
}
- return DebuggerBundle.message(
- "export.threads.stackframe.format",
- location.declaringType().name() + "." + location.method().name(),
- sourceName,
- location.lineNumber()
- );
+
+ final StringBuilder methodName = new StringBuilder();
+ try {
+ methodName.append(location.declaringType().name());
+ }
+ catch (Throwable e) {
+ methodName.append(e.getMessage());
+ }
+ methodName.append(".");
+ try {
+ methodName.append(location.method().name());
+ }
+ catch (Throwable e) {
+ methodName.append(e.getMessage());
+ }
+
+ int lineNumber;
+ try {
+ lineNumber = location.lineNumber();
+ }
+ catch (Throwable e) {
+ lineNumber = -1;
+ }
+ return DebuggerBundle.message("export.threads.stackframe.format", methodName.toString(), sourceName, lineNumber);
}
private static String threadName(ThreadReference threadReference) {
diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerContextImpl.java b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerContextImpl.java
index d353368..e35ba83 100644
--- a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerContextImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerContextImpl.java
@@ -171,6 +171,7 @@
}
public boolean isEvaluationPossible() {
- return getDebugProcess().getSuspendManager().getPausedContext() != null;
+ final DebugProcessImpl debugProcess = getDebugProcess();
+ return debugProcess != null && debugProcess.getSuspendManager().getPausedContext() != null;
}
}
\ No newline at end of file
diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/InvokeThread.java b/java/debugger/impl/src/com/intellij/debugger/impl/InvokeThread.java
index 84ed730..804799d 100644
--- a/java/debugger/impl/src/com/intellij/debugger/impl/InvokeThread.java
+++ b/java/debugger/impl/src/com/intellij/debugger/impl/InvokeThread.java
@@ -34,6 +34,7 @@
public static final class WorkerThreadRequest<E extends PrioritizedTask> implements Runnable {
private final InvokeThread<E> myOwner;
private volatile Future<?> myRequestFuture;
+ private volatile boolean myStopRequested = false;
WorkerThreadRequest(InvokeThread<E> owner) {
myOwner = owner;
@@ -60,13 +61,16 @@
}
public void interrupt() {
- assert myRequestFuture != null;
- myRequestFuture.cancel( true );
+ final Future<?> future = myRequestFuture;
+ assert future != null;
+ myStopRequested = true;
+ future.cancel(true);
}
public boolean isInterrupted() {
- assert myRequestFuture != null;
- return myRequestFuture.isCancelled() || myRequestFuture.isDone();
+ final Future<?> future = myRequestFuture;
+ assert future != null;
+ return myStopRequested || future.isCancelled() || future.isDone();
}
public void join() throws InterruptedException, ExecutionException {
@@ -189,15 +193,15 @@
return myEvents.pushBack(r, r.getPriority().ordinal());
}
- protected void switchToRequest(WorkerThreadRequest newWorkerThread) {
- final WorkerThreadRequest request = getCurrentThreadRequest();
- LOG.assertTrue(request != null);
- myCurrentRequest = newWorkerThread;
+ protected void switchToRequest(WorkerThreadRequest newRequest) {
+ final WorkerThreadRequest currentThreadRequest = getCurrentThreadRequest();
+ LOG.assertTrue(currentThreadRequest != null);
+ myCurrentRequest = newRequest;
if (LOG.isDebugEnabled()) {
- LOG.debug("Closing " + request + " new request = " + newWorkerThread);
+ LOG.debug("Closing " + currentThreadRequest + " new request = " + newRequest);
}
- request.interrupt();
+ currentThreadRequest.interrupt();
}
public WorkerThreadRequest getCurrentRequest() {
diff --git a/java/debugger/impl/src/com/intellij/debugger/jdi/ThreadReferenceProxyImpl.java b/java/debugger/impl/src/com/intellij/debugger/jdi/ThreadReferenceProxyImpl.java
index 25d08bb..38140c6 100644
--- a/java/debugger/impl/src/com/intellij/debugger/jdi/ThreadReferenceProxyImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/jdi/ThreadReferenceProxyImpl.java
@@ -171,7 +171,15 @@
myFrameCount = 0;
}
catch (IncompatibleThreadStateException e) {
- if (!threadReference.isSuspended()) {
+ final boolean isSuspended;
+ try {
+ isSuspended = threadReference.isSuspended();
+ }
+ catch (Throwable th) {
+ // unable to determine whether the thread is actually suspended, so propagating original exception
+ throw EvaluateExceptionUtil.createEvaluateException(e);
+ }
+ if (!isSuspended) {
// give up because it seems to be really resumed
throw EvaluateExceptionUtil.createEvaluateException(e);
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/jdi/VirtualMachineProxyImpl.java b/java/debugger/impl/src/com/intellij/debugger/jdi/VirtualMachineProxyImpl.java
index 109b51e..345637b 100644
--- a/java/debugger/impl/src/com/intellij/debugger/jdi/VirtualMachineProxyImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/jdi/VirtualMachineProxyImpl.java
@@ -68,7 +68,18 @@
canWatchFieldModification();
canPopFrames();
- virtualMachine.allClasses(); // this will cache classes inside JDI and enable faster search of classes later
+ try {
+ // this will cache classes inside JDI and enable faster search of classes later
+ virtualMachine.allClasses();
+ }
+ catch (Throwable e) {
+ // catch all exceptions in order not to break vm attach process
+ // Example:
+ // java.lang.IllegalArgumentException: Invalid JNI signature character ';'
+ // caused by some bytecode "optimizers" which break type signatures as a side effect.
+ // solution if you are using JAX-WS: add -Dcom.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize=true to JVM args
+ LOG.info(e);
+ }
List<ThreadGroupReference> groups = virtualMachine.topLevelThreadGroups();
for (ThreadGroupReference threadGroupReference : groups) {
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/PositionHighlighter.java b/java/debugger/impl/src/com/intellij/debugger/ui/PositionHighlighter.java
index 1339e9c..fa91c9b 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/PositionHighlighter.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/PositionHighlighter.java
@@ -15,7 +15,6 @@
*/
package com.intellij.debugger.ui;
-import com.intellij.codeInsight.daemon.impl.DaemonListeners;
import com.intellij.debugger.DebuggerBundle;
import com.intellij.debugger.DebuggerInvocationUtil;
import com.intellij.debugger.SourcePosition;
@@ -131,9 +130,9 @@
private static void adjustCounter(@NotNull Editor editor, int increment) {
JComponent component = editor.getComponent();
- Object o = component.getClientProperty(DaemonListeners.IGNORE_MOUSE_TRACKING);
+ Object o = component.getClientProperty(Editor.IGNORE_MOUSE_TRACKING);
Integer value = ((o instanceof Integer) ? (Integer)o : 0) + increment;
- component.putClientProperty(DaemonListeners.IGNORE_MOUSE_TRACKING, value > 0 ? value : null);
+ component.putClientProperty(Editor.IGNORE_MOUSE_TRACKING, value > 0 ? value : null);
}
public void remove() {
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointNameCellRenderer.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointNameCellRenderer.java
deleted file mode 100644
index eac638e..0000000
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointNameCellRenderer.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2000-2009 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.debugger.ui.breakpoints;
-
-import com.intellij.util.ui.UIUtil;
-
-import javax.swing.*;
-import javax.swing.table.DefaultTableCellRenderer;
-import java.awt.*;
-
-/**
- * @author Jeka
- */
-public class BreakpointNameCellRenderer extends DefaultTableCellRenderer {
- private final Color myAnyExceptionForeground = new Color(128, 0, 0);
-
- public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
- super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
- setBorder(null);
- BreakpointTableModel tableModel = (BreakpointTableModel)table.getModel();
- Breakpoint breakpoint = tableModel.getBreakpoint(row);
- if (breakpoint == null){
- return this;
- };
- final Icon icon = (breakpoint instanceof BreakpointWithHighlighter)?
- breakpoint.ENABLED? ((BreakpointWithHighlighter)breakpoint).getSetIcon(false) : ((BreakpointWithHighlighter)breakpoint).getDisabledIcon(
- false) : breakpoint.getIcon();
- setIcon(icon);
- setDisabledIcon(icon);
-
- if(isSelected){
- setForeground(UIUtil.getTableSelectionForeground());
- }
- else{
- Color foreColor;
- if(breakpoint instanceof AnyExceptionBreakpoint){
- foreColor = myAnyExceptionForeground;
- }
- else{
- foreColor = UIUtil.getTableForeground();
- }
- setForeground(foreColor);
- }
- setEnabled(isSelected || breakpoint.ENABLED);
- return this;
- }
-}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointTable.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointTable.java
deleted file mode 100644
index 7530fa5..0000000
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointTable.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright 2000-2009 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.debugger.ui.breakpoints;
-
-import com.intellij.openapi.project.Project;
-import com.intellij.util.ui.Table;
-import com.intellij.xdebugger.XDebuggerBundle;
-
-import javax.swing.*;
-import javax.swing.table.DefaultTableCellRenderer;
-import javax.swing.table.TableCellRenderer;
-import javax.swing.table.TableColumn;
-import javax.swing.table.TableColumnModel;
-import java.awt.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.KeyEvent;
-
-/**
- * @author Eugene Zhuravlev
- * Date: May 23, 2005
- */
-public class BreakpointTable extends Table {
- public BreakpointTable(final Project project) {
- super(new BreakpointTableModel(project));
- setColumnSelectionAllowed(false);
- InputMap inputMap = getInputMap();
- ActionMap actionMap = getActionMap();
- Object o = inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0));
- if (o == null) {
- //noinspection HardCodedStringLiteral
- o = "enable_disable";
- inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), o);
- }
- actionMap.put(o, new AbstractAction() {
- public void actionPerformed(ActionEvent e) {
- if (isEditing()) {
- return;
- }
- int[] indices = getSelectedRows();
- boolean currentlyMarked = true;
- for (int i = 0; i < indices.length; i++) {
- final Boolean isMarked = (Boolean)getValueAt(indices[i], BreakpointTableModel.ENABLED_STATE);
- currentlyMarked = isMarked != null? isMarked.booleanValue() : false;
- if (!currentlyMarked) {
- break;
- }
- }
- final Boolean valueToSet = currentlyMarked ? Boolean.FALSE : Boolean.TRUE;
- for (int i = 0; i < indices.length; i++) {
- setValueAt(valueToSet, indices[i], BreakpointTableModel.ENABLED_STATE);
- }
- }
- });
-
- setShowGrid(false);
- setIntercellSpacing(new Dimension(0, 0));
- setTableHeader(null);
- setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
- setColumnSelectionAllowed(false);
-
- int width = new JCheckBox().getPreferredSize().width;
- TableColumnModel columnModel = getColumnModel();
-
- TableColumn enabledStateColumn = columnModel.getColumn(BreakpointTableModel.ENABLED_STATE);
- enabledStateColumn.setPreferredWidth(width);
- enabledStateColumn.setMaxWidth(width);
- final Class enabledStateColumnClass = getModel().getColumnClass(BreakpointTableModel.ENABLED_STATE);
- final TableCellRenderer delegateRenderer = getDefaultRenderer(enabledStateColumnClass);
- setDefaultRenderer(enabledStateColumnClass, new DefaultTableCellRenderer() {
- public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
- final Component component = delegateRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
- if (component instanceof JComponent) {
- ((JComponent)component).setBorder(null);
- }
- return component;
- }
- });
- columnModel.getColumn(BreakpointTableModel.NAME).setCellRenderer(new BreakpointNameCellRenderer());
-
- getEmptyText().setText(XDebuggerBundle.message("debugger.no.breakpoints"));
- }
-
- public BreakpointTableModel getModel() {
- return (BreakpointTableModel)super.getModel();
- }
-
- public void setBreakpoints(Breakpoint[] breakpoints) {
- getModel().setBreakpoints(breakpoints);
- }
-
- public final java.util.List<Breakpoint> getBreakpoints() {
- return getModel().getBreakpoints();
- }
-
- public Breakpoint[] getSelectedBreakpoints() {
- if (getRowCount() == 0) {
- return Breakpoint.EMPTY_ARRAY;
- }
-
- int[] rows = getSelectedRows();
- if (rows.length == 0) {
- return Breakpoint.EMPTY_ARRAY;
- }
- Breakpoint[] rv = new Breakpoint[rows.length];
- for (int idx = 0; idx < rows.length; idx++) {
- rv[idx] = getModel().getBreakpoint(rows[idx]);
- }
- return rv;
- }
-}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointTableModel.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointTableModel.java
deleted file mode 100644
index 6999260..0000000
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointTableModel.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright 2000-2009 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * Class BreakpointTableModel
- * @author Jeka
- */
-package com.intellij.debugger.ui.breakpoints;
-
-import com.intellij.debugger.DebuggerBundle;
-import com.intellij.debugger.DebuggerManagerEx;
-import com.intellij.openapi.project.Project;
-import com.intellij.util.containers.ContainerUtil;
-import com.intellij.util.ui.ItemRemovable;
-
-import javax.swing.table.AbstractTableModel;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-public class BreakpointTableModel extends AbstractTableModel implements ItemRemovable {
- public static final int ENABLED_STATE = 0;
- public static final int NAME = 1;
-
- private java.util.List<Breakpoint> myBreakpoints = null;
- private final BreakpointManager myBreakpointManager;
-
- public BreakpointTableModel(final Project project) {
- myBreakpoints = new ArrayList<Breakpoint>();
- myBreakpointManager = DebuggerManagerEx.getInstanceEx(project).getBreakpointManager();
- }
-
- public final void setBreakpoints(Breakpoint[] breakpoints) {
- myBreakpoints.clear();
- if (breakpoints != null) {
- ContainerUtil.addAll(myBreakpoints, breakpoints);
- }
- fireTableDataChanged();
- }
-
- public List<Breakpoint> getBreakpoints() {
- return Collections.unmodifiableList(myBreakpoints);
- }
-
- public void removeBreakpoints(Breakpoint[] breakpoints) {
- myBreakpoints.removeAll(Arrays.asList(breakpoints));
- fireTableDataChanged();
- }
-
- public Breakpoint getBreakpoint(int index) {
- if (index < 0 || index >= myBreakpoints.size()) return null;
- return myBreakpoints.get(index);
- }
-
- public boolean isBreakpointEnabled(int index) {
- return ((Boolean)getValueAt(index, ENABLED_STATE)).booleanValue();
- }
-
- public int getBreakpointIndex(Breakpoint breakpoint) {
- return myBreakpoints.indexOf(breakpoint);
- }
-
- public void insertBreakpointAt(Breakpoint breakpoint, int index) {
- myBreakpoints.add(index, breakpoint);
- fireTableRowsInserted(index, index);
- }
-
- public void addBreakpoint(Breakpoint breakpoint) {
- myBreakpoints.add(breakpoint);
- int row = myBreakpoints.size() - 1;
- fireTableRowsInserted(row, row);
- }
-
- public void removeRow(int idx) {
- if (idx >= 0 && idx < myBreakpoints.size()) {
- myBreakpoints.remove(idx);
- fireTableRowsDeleted(idx, idx);
- }
- }
-
- public int getRowCount() {
- return myBreakpoints.size();
- }
-
- public int getColumnCount() {
- return 2;
- }
-
- public String getColumnName(int column) {
- switch (column) {
- case ENABLED_STATE:
- return DebuggerBundle.message("breakpoint.table.header.column.enabled");
- case NAME:
- return DebuggerBundle.message("breakpoint.table.header.column.name");
- default :
- return "";
- }
- }
-
- public Object getValueAt(int rowIndex, int columnIndex) {
- Breakpoint breakpoint = myBreakpoints.get(rowIndex);
- if (columnIndex == NAME) {
- return breakpoint.getDisplayName();
- }
- if (columnIndex == ENABLED_STATE) {
- return breakpoint.ENABLED? Boolean.TRUE : Boolean.FALSE;
- }
- return null;
- }
-
- public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
- if (rowIndex < 0 || rowIndex >= myBreakpoints.size()) {
- return;
- }
- Breakpoint breakpoint = myBreakpoints.get(rowIndex);
-/*
- if (columnIndex == NAME) {
- breakpoint.setDisplayName((aValue != null)? aValue.toString() : "");
- }
- else
-*/
- if (columnIndex == ENABLED_STATE) {
- final boolean isEnabled = aValue == null || ((Boolean)aValue).booleanValue();
- final boolean valueChanged = isEnabled != breakpoint.ENABLED;
- breakpoint.ENABLED = isEnabled;
- if (valueChanged) {
- breakpoint.updateUI();
- }
- }
- fireTableRowsUpdated(rowIndex, rowIndex);
- }
-
- public Class getColumnClass(int columnIndex) {
- if (columnIndex == ENABLED_STATE) {
- return Boolean.class;
- }
- return super.getColumnClass(columnIndex);
- }
-
- public boolean isCellEditable(int rowIndex, int columnIndex) {
- if (columnIndex != ENABLED_STATE) {
- return false;
- }
- final boolean isSlave = myBreakpointManager.findMasterBreakpoint(myBreakpoints.get(rowIndex)) != null;
- return !isSlave;
- }
-}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointTree.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointTree.java
deleted file mode 100644
index 695fea471..0000000
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointTree.java
+++ /dev/null
@@ -1,824 +0,0 @@
-/*
- * Copyright 2000-2009 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.debugger.ui.breakpoints;
-import com.intellij.debugger.DebuggerBundle;
-import com.intellij.debugger.DebuggerManagerEx;
-import com.intellij.openapi.project.Project;
-import com.intellij.ui.*;
-import com.intellij.util.ArrayUtil;
-import com.intellij.util.PlatformIcons;
-import com.intellij.util.containers.ContainerUtil;
-import com.intellij.util.containers.Convertor;
-import com.intellij.util.ui.tree.TreeUtil;
-import com.intellij.xdebugger.XDebuggerBundle;
-import org.jetbrains.annotations.NotNull;
-
-import javax.swing.*;
-import javax.swing.tree.DefaultTreeModel;
-import javax.swing.tree.TreePath;
-import java.util.*;
-
-/**
- * @author Eugene Zhuravlev
- * Date: May 20, 2005
- */
-public class BreakpointTree extends CheckboxTree {
- private static final String DEFAULT_PACKAGE_NAME = DebuggerBundle.message("default.package.name");
- private final CheckedTreeNode myRootNode;
- private final List<Breakpoint> myBreakpoints = new ArrayList<Breakpoint>();
- private final Map<TreeDescriptor, CheckedTreeNode> myDescriptorToNodeMap = new HashMap<TreeDescriptor, CheckedTreeNode>();
-
- private boolean myGroupByMethods = false;
- private boolean myGroupByClasses = true;
- private boolean myFlattenPackages = true;
-
- private final NodeAppender[] myAppenders = {
- new BreakpointToMethodAppender(),
- new BreakpointToClassAppender(),
- new BreakpointToPackageAppender(),
- new MethodToClassAppender(),
- new MethodToPackageAppender(),
- new ClassToPackageAppender(),
- new PackageToPackageAppender(),
- };
-
- private final Comparator<CheckedTreeNode> myNodeComparator = new Comparator<CheckedTreeNode>() {
- public int compare(CheckedTreeNode o1, CheckedTreeNode o2) {
- final int w1 = getWeight(o1);
- final int w2 = getWeight(o2);
- if (w1 != w2) {
- return w1 - w2;
- }
- final TreeDescriptor d1 = (TreeDescriptor)o1.getUserObject();
- final TreeDescriptor d2 = (TreeDescriptor)o2.getUserObject();
- if (d1 instanceof BreakpointDescriptor && d2 instanceof BreakpointDescriptor) {
- return 0;
- }
- return d1.getDisplayString().compareTo(d2.getDisplayString());
- }
-
- private int getWeight(CheckedTreeNode node) {
- if (node.getUserObject() instanceof BreakpointDescriptor) {
- return 100;
- }
- if (node.getUserObject() instanceof MethodDescriptor) {
- return 90;
- }
- if (node.getUserObject() instanceof PackageDescriptor) {
- return 80;
- }
- if (node.getUserObject() instanceof ClassDescriptor) {
- return 70;
- }
- return 50;
- }
- };
- private final BreakpointManager myBreakpointManager;
- private final BreakpointManagerListener myNodeUpdateListener;
-
- protected void installSpeedSearch() {
- new TreeSpeedSearch(this, new Convertor<TreePath, String>() {
- public String convert(TreePath path) {
- final CheckedTreeNode node = (CheckedTreeNode)path.getLastPathComponent();
- return ((TreeDescriptor)node.getUserObject()).getDisplayString();
- }
- });
- }
-
- public boolean getExpandsSelectedPaths() {
- return true;
- }
-
- public Breakpoint[] getSelectedBreakpoints() {
- final TreePath[] selectionPaths = getSelectionPaths();
- if (selectionPaths == null || selectionPaths.length == 0) {
- return Breakpoint.EMPTY_ARRAY;
- }
- final List<Breakpoint> breakpoints = new ArrayList<Breakpoint>(selectionPaths.length);
- for (TreePath path : selectionPaths) {
- final CheckedTreeNode node = (CheckedTreeNode)path.getLastPathComponent();
- TreeUtil.traverseDepth(node, new TreeUtil.Traverse() {
- public boolean accept(Object _node) {
- final CheckedTreeNode node = (CheckedTreeNode)_node;
- final TreeDescriptor descriptor = (TreeDescriptor)node.getUserObject();
- if (descriptor instanceof BreakpointDescriptor) {
- breakpoints.add(((BreakpointDescriptor)descriptor).getBreakpoint());
- }
- return true;
- }
- });
- }
- return breakpoints.toArray(new Breakpoint[breakpoints.size()]);
- }
-
- public void selectBreakpoint(Breakpoint breakpoint) {
- final CheckedTreeNode node = myDescriptorToNodeMap.get(new BreakpointDescriptor(breakpoint));
- if (node == null) {
- return;
- }
- TreeUtil.selectNode(this, node);
- }
-
- public void selectBreakpoints(Breakpoint[] breakpoints) {
- final List<CheckedTreeNode> nodes = new ArrayList<CheckedTreeNode>(breakpoints.length);
- for (Breakpoint breakpoint : breakpoints) {
- final CheckedTreeNode node = myDescriptorToNodeMap.get(new BreakpointDescriptor(breakpoint));
- if (node != null) {
- nodes.add(node);
- }
- }
- clearSelection();
- for (CheckedTreeNode node : nodes) {
- addSelectionPath(new TreePath(node.getPath()));
- }
- }
-
- public void selectFirstBreakpoint() {
- TreeUtil.traverseDepth(myRootNode, new TreeUtil.Traverse() {
- public boolean accept(Object node) {
- final CheckedTreeNode treeNode = (CheckedTreeNode)node;
- final TreeDescriptor descriptor = (TreeDescriptor)treeNode.getUserObject();
- if (descriptor instanceof BreakpointDescriptor) {
- TreeUtil.selectNode(BreakpointTree.this, treeNode);
- return false;
- }
- return true;
- }
- });
- }
-
- public List<Breakpoint> getBreakpoints() {
- return Collections.unmodifiableList(myBreakpoints);
- }
-
- public void dispose() {
- final KeyStroke[] treeStrokes = getRegisteredKeyStrokes();
- for (KeyStroke stroke : treeStrokes) {
- unregisterKeyboardAction(stroke);
- }
- myBreakpointManager.removeBreakpointManagerListener(myNodeUpdateListener);
- }
-
- private abstract static class TreeDescriptor {
- protected void customizeCellRenderer(final ColoredTreeCellRenderer targetRenderer, CheckedTreeNode node, boolean selected, final boolean checked, boolean expanded, boolean leaf, boolean hasFocus) {
- targetRenderer.setIcon(getDisplayIcon());
- targetRenderer.append(getDisplayString(), checked? SimpleTextAttributes.SIMPLE_CELL_ATTRIBUTES : SimpleTextAttributes.GRAYED_ATTRIBUTES);
- }
-
- protected abstract String getDisplayString();
-
- protected abstract Icon getDisplayIcon();
-
- }
-
- private final class BreakpointDescriptor extends TreeDescriptor {
- private final Breakpoint myBreakpoint;
- public BreakpointDescriptor(Breakpoint breakpoint) {
- myBreakpoint = breakpoint;
- }
- @NotNull
- public Breakpoint getBreakpoint() {
- return myBreakpoint;
- }
-
- protected Icon getDisplayIcon() {
- return myBreakpoint instanceof BreakpointWithHighlighter ?
- myBreakpoint.ENABLED? ((BreakpointWithHighlighter)myBreakpoint).getSetIcon(false) : ((BreakpointWithHighlighter)myBreakpoint).getDisabledIcon(false) : myBreakpoint.getIcon();
- }
-
- public String getDisplayString() {
- return myBreakpoint.getDisplayName();
- }
-
- public boolean equals(final Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- final BreakpointDescriptor breakpointDescriptor = (BreakpointDescriptor)o;
- return myBreakpoint.equals(breakpointDescriptor.myBreakpoint);
- }
-
- public int hashCode() {
- return myBreakpoint.hashCode();
- }
-
- public boolean isSlave() {
- final Breakpoint breakpoint = getBreakpoint();
- return myBreakpointManager.findMasterBreakpoint(breakpoint) != null;
- }
- }
-
- private static final class MethodDescriptor extends TreeDescriptor {
- @NotNull
- private final String myClassName;
- @NotNull
- private final String myMethodName;
- @NotNull
- private final String myPackageName;
-
- public MethodDescriptor(@NotNull String methodName, @NotNull String className, @NotNull String packageName) {
- myClassName = className;
- myMethodName = methodName.endsWith("()")? methodName : methodName + "()";
- myPackageName = packageName;
- }
-
- @NotNull
- public String getPackageName() {
- return myPackageName;
- }
-
- public String getClassName() {
- return myClassName;
- }
-
- public String getMethodName() {
- return myMethodName;
- }
-
- protected String getDisplayString() {
- return myMethodName;
- }
-
- protected Icon getDisplayIcon() {
- return PlatformIcons.METHOD_ICON;
- }
-
- public boolean equals(final Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- final MethodDescriptor methodDescriptor = (MethodDescriptor)o;
- if (!myClassName.equals(methodDescriptor.myClassName)) {
- return false;
- }
- return myMethodName.equals(methodDescriptor.myMethodName);
- }
-
- public int hashCode() {
- int result = myClassName.hashCode();
- result = 29 * result + myMethodName.hashCode();
- return result;
- }
- }
-
- private static final class ClassDescriptor extends TreeDescriptor {
- @NotNull private final String myClassName;
- @NotNull private final String myPackageName;
-
- public ClassDescriptor(@NotNull String className, @NotNull String packageName) {
- myClassName = className;
- myPackageName = packageName.length() == 0? DEFAULT_PACKAGE_NAME : packageName;
- }
-
- @NotNull
- public String getPackageName() {
- return myPackageName;
- }
-
- @NotNull
- public String getClassName() {
- return myClassName;
- }
-
- protected String getDisplayString() {
- return getClassName();
- }
-
- protected Icon getDisplayIcon() {
- return PlatformIcons.CLASS_ICON;
- }
-
- public boolean equals(final Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- final ClassDescriptor classDescriptor = (ClassDescriptor)o;
-
- return myClassName.equals(classDescriptor.myClassName);
-
- }
-
- public int hashCode() {
- return myClassName.hashCode();
- }
- }
-
- private static final class PackageDescriptor extends TreeDescriptor {
- private final String myPackageName;
-
- public PackageDescriptor(String packageName) {
- myPackageName = "".equals(packageName)? DEFAULT_PACKAGE_NAME : packageName;
- }
-
- public String getPackageName() {
- return myPackageName;
- }
-
- public String getParentPackageName() {
- final int dotIndex = myPackageName.lastIndexOf('.');
- return dotIndex >= 0 ? myPackageName.substring(0, dotIndex) : null;
- }
-
- public void customizeCellRenderer(final ColoredTreeCellRenderer targetRenderer, CheckedTreeNode node, boolean selected,
- final boolean checked, boolean expanded, boolean leaf, boolean hasFocus) {
- targetRenderer.setIcon(PlatformIcons.PACKAGE_ICON);
- final String displayName;
- final CheckedTreeNode parent = (CheckedTreeNode)node.getParent();
- if (parent != null && parent.getUserObject() instanceof PackageDescriptor) {
- final String parentPackageInTree = ((PackageDescriptor)parent.getUserObject()).getPackageName() + ".";
- displayName = myPackageName.startsWith(parentPackageInTree)? myPackageName.substring(parentPackageInTree.length()) : myPackageName;
- }
- else {
- displayName = myPackageName;
- }
- targetRenderer.append(displayName, checked? SimpleTextAttributes.SIMPLE_CELL_ATTRIBUTES : SimpleTextAttributes.GRAYED_ATTRIBUTES);
- }
-
- protected String getDisplayString() {
- return myPackageName;
- }
-
- protected Icon getDisplayIcon() {
- return PlatformIcons.PACKAGE_ICON;
- }
-
- public boolean equals(final Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- final PackageDescriptor packageDescriptor = (PackageDescriptor)o;
-
- return myPackageName.equals(packageDescriptor.myPackageName);
-
- }
-
- public int hashCode() {
- return myPackageName.hashCode();
- }
- }
-
- public BreakpointTree(final Project project) {
- super(new BreakpointTreeCellRenderer(), new CheckedTreeNode(new RootDescriptor()));
- myRootNode = (CheckedTreeNode)getModel().getRoot();
- myDescriptorToNodeMap.put((TreeDescriptor)myRootNode.getUserObject(), myRootNode);
- myBreakpointManager = DebuggerManagerEx.getInstanceEx(project).getBreakpointManager();
- myNodeUpdateListener = new BreakpointManagerListener() {
- public void breakpointsChanged() {
- repaint();
- }
- };
- myBreakpointManager.addBreakpointManagerListener(myNodeUpdateListener);
- getEmptyText().setText(XDebuggerBundle.message("debugger.no.breakpoints"));
- }
-
- public boolean isGroupByMethods() {
- return myGroupByMethods;
- }
-
- public void setGroupByMethods(boolean groupByMethods) {
- if (myGroupByMethods != groupByMethods) {
- myGroupByMethods = groupByMethods;
- rebuildTree();
- }
- }
-
- public boolean isGroupByClasses() {
- return myGroupByClasses;
- }
-
- public void setGroupByClasses(boolean groupByClasses) {
- if (myGroupByClasses != groupByClasses) {
- myGroupByClasses = groupByClasses;
- rebuildTree();
- }
- }
-
- public boolean isFlattenPackages() {
- return myFlattenPackages;
- }
-
- public void setFlattenPackages(boolean flattenPackages) {
- if (myFlattenPackages != flattenPackages) {
- myFlattenPackages = flattenPackages;
- rebuildTree();
- }
- }
-
- @Override
- protected void onNodeStateChanged(final CheckedTreeNode node) {
- final Object descriptor = node.getUserObject();
- final Breakpoint breakpoint;
- if (descriptor instanceof BreakpointDescriptor) {
- breakpoint = ((BreakpointDescriptor)descriptor).getBreakpoint();
- if (myBreakpointManager.findMasterBreakpoint(breakpoint) != null) {
- return;
- }
- }
- else {
- breakpoint = null;
- }
-
- if (breakpoint != null) {
- myBreakpointManager.setBreakpointEnabled(breakpoint, node.isChecked());
- }
-
- }
-
- public void addBreakpoint(final Breakpoint breakpoint) {
- myBreakpoints.add(breakpoint);
- breakpoint.updateUI(new Runnable() {
- public void run() {
- rebuildTree();
- }
- });
- rebuildTree();
- selectBreakpoint(breakpoint);
- }
-
- public void removeBreakpoint(Breakpoint breakpoint) {
- myBreakpoints.remove(breakpoint);
- rebuildTree();
- }
-
- public void removeBreakpoints(Breakpoint[] breakpoints) {
- myBreakpoints.removeAll(Arrays.asList(breakpoints));
- rebuildTree();
- }
-
- public void setBreakpoints(Breakpoint[] breakpoints) {
- myBreakpoints.clear();
- ContainerUtil.addAll(myBreakpoints, breakpoints);
- rebuildTree();
- }
-
- public Breakpoint getPreviousSibling(Breakpoint breakpoint) {
- return getSibling(breakpoint, false);
- }
-
-
- public Breakpoint getNextSibling(Breakpoint breakpoint) {
- return getSibling(breakpoint, true);
- }
-
- private Breakpoint getSibling(Breakpoint breakpoint, boolean nextSibling) {
- final CheckedTreeNode node = myDescriptorToNodeMap.get(new BreakpointDescriptor(breakpoint));
- if (node == null) {
- return null;
- }
- final CheckedTreeNode sibling = (CheckedTreeNode) (nextSibling? node.getNextSibling() : node.getPreviousSibling());
- if (sibling == null) {
- return null;
- }
- final TreeDescriptor descriptor = (TreeDescriptor)sibling.getUserObject();
- return descriptor instanceof BreakpointDescriptor ? ((BreakpointDescriptor)descriptor).getBreakpoint() : null;
- }
-
- private void rebuildTree() {
- final TreeStateSnapshot treeStateSnapshot = new TreeStateSnapshot(this);
- myRootNode.removeAllChildren();
- myDescriptorToNodeMap.clear();
- myDescriptorToNodeMap.put((TreeDescriptor)myRootNode.getUserObject(), myRootNode);
- // build tree
- for (final Breakpoint breakpoint : myBreakpoints) {
- CheckedTreeNode node = createNode(new BreakpointDescriptor(breakpoint));
- node.setChecked(breakpoint.ENABLED);
- addNode(node);
- }
- // remove all package nodes with one child
- final int count = myRootNode.getChildCount();
- final List<CheckedTreeNode> children = new ArrayList<CheckedTreeNode>();
- for (int idx = 0; idx < count; idx++) {
- CheckedTreeNode child = (CheckedTreeNode)myRootNode.getChildAt(idx);
- if (!(child.getUserObject() instanceof PackageDescriptor)) {
- children.add(child);
- continue;
- }
- while (child.getUserObject() instanceof PackageDescriptor && child.getChildCount() <= 1) {
- child = (CheckedTreeNode)child.getChildAt(0);
- }
- if (!(child.getUserObject() instanceof PackageDescriptor)) {
- child = (CheckedTreeNode)child.getParent();
- }
- for (CheckedTreeNode childToRemove = (CheckedTreeNode)child.getParent(); !childToRemove.equals(myRootNode); childToRemove = (CheckedTreeNode)childToRemove.getParent()) {
- myDescriptorToNodeMap.remove(childToRemove.getUserObject());
- }
- children.add(child);
- }
- for (final CheckedTreeNode aChildren : children) {
- aChildren.removeFromParent();
- }
- myRootNode.removeAllChildren();
- for (final CheckedTreeNode child : children) {
- myRootNode.add(child);
- }
- sortChildren(myRootNode);
- ((DefaultTreeModel)getModel()).nodeStructureChanged(myRootNode);
- treeStateSnapshot.restore(this);
- expandPath(new TreePath(myRootNode));
- }
-
- private void sortChildren(CheckedTreeNode node) {
- final int childCount = node.getChildCount();
- if (childCount == 0) {
- return;
- }
- final List<CheckedTreeNode> children = new ArrayList<CheckedTreeNode>(childCount);
- for (int idx = 0; idx < childCount; idx++) {
- children.add((CheckedTreeNode)node.getChildAt(idx));
- }
- for (CheckedTreeNode child : children) {
- sortChildren(child);
- child.removeFromParent();
- }
- Collections.sort(children, myNodeComparator);
- for (CheckedTreeNode child : children) {
- node.add(child);
- }
- }
-
- @NotNull
- private CheckedTreeNode createNode(final TreeDescriptor descriptor) {
- final CheckedTreeNode node = new CheckedTreeNode(descriptor);
- myDescriptorToNodeMap.put(descriptor, node);
- return node;
- }
-
- /**
- * @param node
- */
- private void addNode(CheckedTreeNode node) {
- for (final NodeAppender appender : myAppenders) {
- node = appender.append(node);
- if (node == null) {
- break;
- }
- }
- if (node != null) {
- attachNodeToParent(getDescriptor(myRootNode), node);
- }
- }
-
- private static TreeDescriptor getDescriptor(final CheckedTreeNode node) {
- return (TreeDescriptor)node.getUserObject();
- }
-
- /**
- * @param parentDescriptor a descriptor of the childNode (possibly not existing) to attach to
- * @param childNode the childNode to be attached
- * @return either parent node if it has just been created or null, if the node has been attached to already existing childNode
- */
- private CheckedTreeNode attachNodeToParent(final TreeDescriptor parentDescriptor, final CheckedTreeNode childNode) {
- CheckedTreeNode parentNode = myDescriptorToNodeMap.get(parentDescriptor);
- try {
- if (parentNode != null) {
- parentNode.add(childNode);
- return null; // added to already existing, so stop iteration over appenders
- }
- parentNode = createNode(parentDescriptor);
- parentNode.add(childNode);
- return parentNode;
- }
- finally {
- if (parentNode != null && parentNode.getChildCount() == 1) {
- expandPath(new TreePath(parentNode.getPath()));
- }
- }
- }
-
- private static class BreakpointTreeCellRenderer extends CheckboxTreeCellRenderer {
- public void customizeRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
- if (value instanceof CheckedTreeNode) {
- final CheckedTreeNode node = (CheckedTreeNode)value;
- final TreeDescriptor descriptor = getDescriptor(node);
- descriptor.customizeCellRenderer(getTextRenderer(), node, selected, node.isChecked(), expanded, leaf, hasFocus);
- if (descriptor instanceof BreakpointDescriptor) {
- myCheckbox.setEnabled(node.isEnabled() && !((BreakpointDescriptor)descriptor).isSlave());
- }
- }
- }
- }
-
- private abstract static class NodeAppender {
- public abstract CheckedTreeNode append(CheckedTreeNode node);
- }
-
- private class BreakpointToMethodAppender extends NodeAppender {
- public CheckedTreeNode append(CheckedTreeNode node) {
- if (!myGroupByMethods) {
- return node;
- }
- final TreeDescriptor descriptor = getDescriptor(node);
- if (!(descriptor instanceof BreakpointDescriptor)) {
- return node;
- }
- final Breakpoint breakpoint = ((BreakpointDescriptor)descriptor).getBreakpoint();
- if (!(breakpoint instanceof LineBreakpoint)) {
- return node;
- }
- final LineBreakpoint lineBreakpoint = (LineBreakpoint)breakpoint;
- final String methodName = lineBreakpoint.getMethodName();
- final String className = lineBreakpoint.getShortClassName();
- final String packageName = lineBreakpoint.getPackageName();
- if (methodName == null || className == null || packageName == null) {
- return node;
- }
- return attachNodeToParent(new MethodDescriptor(methodName, className, packageName), node);
- }
- }
-
- private class BreakpointToClassAppender extends NodeAppender {
- public CheckedTreeNode append(CheckedTreeNode node) {
- if (!myGroupByClasses) {
- return node;
- }
- final TreeDescriptor descriptor = getDescriptor(node);
- if (!(descriptor instanceof BreakpointDescriptor)) {
- return node;
- }
-
- final Breakpoint breakpoint = ((BreakpointDescriptor)descriptor).getBreakpoint();
- final String className = breakpoint.getShortClassName();
- if (className == null) {
- return node;
- }
- final String packageName = breakpoint.getPackageName();
- if (packageName == null) {
- return node;
- }
- return attachNodeToParent(new ClassDescriptor(className, packageName), node);
- }
- }
-
- private class BreakpointToPackageAppender extends NodeAppender {
- public CheckedTreeNode append(CheckedTreeNode node) {
- final TreeDescriptor descriptor = getDescriptor(node);
- if (!(descriptor instanceof BreakpointDescriptor)) {
- return node;
- }
-
- final Breakpoint breakpoint = ((BreakpointDescriptor)descriptor).getBreakpoint();
- final String packageName;
- if (breakpoint instanceof ExceptionBreakpoint) {
- packageName = breakpoint.getPackageName();
- }
- else if (breakpoint instanceof BreakpointWithHighlighter) {
- packageName = breakpoint.getPackageName();
- }
- else {
- packageName = null;
- }
- if (packageName == null) {
- return node;
- }
- return attachNodeToParent(new PackageDescriptor(packageName), node);
- }
- }
-
- private class MethodToClassAppender extends NodeAppender {
- public CheckedTreeNode append(CheckedTreeNode node) {
- if (!myGroupByClasses) {
- return node;
- }
- final TreeDescriptor descriptor = getDescriptor(node);
- if (!(descriptor instanceof MethodDescriptor)) {
- return node;
- }
- final MethodDescriptor methodDescriptor = (MethodDescriptor)descriptor;
- final String className = methodDescriptor.getClassName();
- final String packageName = methodDescriptor.getPackageName();
- return attachNodeToParent(new ClassDescriptor(className, packageName), node);
- }
- }
-
- private class MethodToPackageAppender extends NodeAppender {
- public CheckedTreeNode append(CheckedTreeNode node) {
- final TreeDescriptor descriptor = getDescriptor(node);
- if (!(descriptor instanceof MethodDescriptor)) {
- return node;
- }
- final MethodDescriptor methodDescriptor = (MethodDescriptor)descriptor;
- final String packageName = methodDescriptor.getPackageName();
- return attachNodeToParent(new PackageDescriptor(packageName), node);
- }
- }
-
- private class ClassToPackageAppender extends NodeAppender {
- public CheckedTreeNode append(CheckedTreeNode node) {
- final TreeDescriptor descriptor = getDescriptor(node);
- if (!(descriptor instanceof ClassDescriptor)) {
- return node;
- }
-
- final String packageName = ((ClassDescriptor)descriptor).getPackageName();
- return attachNodeToParent(new PackageDescriptor(packageName), node);
- }
- }
-
- private class PackageToPackageAppender extends NodeAppender {
- public CheckedTreeNode append(CheckedTreeNode node) {
- if (myFlattenPackages) {
- return node;
- }
- final TreeDescriptor descriptor = getDescriptor(node);
- if (!(descriptor instanceof PackageDescriptor)) {
- return node;
- }
-
- final PackageDescriptor packageDescriptor = (PackageDescriptor)descriptor;
- final String parentPackageName = packageDescriptor.getParentPackageName();
- if (parentPackageName == null) {
- return node;
- }
- final CheckedTreeNode parentNode = attachNodeToParent(new PackageDescriptor(parentPackageName), node);
- if (parentNode == null) {
- return null;
- }
- return append(parentNode);
- }
- }
-
- private static class RootDescriptor extends TreeDescriptor {
-
- protected String getDisplayString() {
- return "";
- }
-
- protected Icon getDisplayIcon() {
- return PlatformIcons.PROJECT_ICON;
- }
- }
-
- private static class TreeStateSnapshot {
- private final Object[] myExpandedUserObjects;
- private final Object[] mySelectedUserObjects;
-
- public TreeStateSnapshot(BreakpointTree tree) {
- final List<TreePath> expandedPaths = TreeUtil.collectExpandedPaths(tree);
- myExpandedUserObjects = getUserObjects(expandedPaths.toArray(new TreePath[expandedPaths.size()]));
- mySelectedUserObjects =getUserObjects(tree.getSelectionPaths());
- }
-
- private static Object[] getUserObjects(final TreePath[] treePaths) {
- if (treePaths == null) {
- return ArrayUtil.EMPTY_OBJECT_ARRAY;
- }
- Object[] userObjects = new Object[treePaths.length];
- int index = 0;
- for (TreePath path : treePaths) {
- userObjects[index++] = ((CheckedTreeNode)path.getLastPathComponent()).getUserObject();
- }
- return userObjects;
- }
-
- public void restore(BreakpointTree tree) {
- final List<TreePath> pathsToExpand = getPaths(tree, myExpandedUserObjects);
- if (!pathsToExpand.isEmpty()) {
- TreeUtil.restoreExpandedPaths(tree, pathsToExpand);
- }
-
- final List<TreePath> pathsToSelect = getPaths(tree, mySelectedUserObjects);
- if (!pathsToSelect.isEmpty()) {
- tree.getSelectionModel().clearSelection();
- tree.setSelectionPaths(pathsToSelect.toArray(new TreePath[pathsToSelect.size()]));
- }
- }
-
- private static List<TreePath> getPaths(BreakpointTree tree, final Object[] userObjects) {
- final List<TreePath> paths = new ArrayList<TreePath>(userObjects.length);
- for (Object descriptor : userObjects) {
- final CheckedTreeNode node = tree.myDescriptorToNodeMap.get(descriptor);
- if (node != null) {
- paths.add(new TreePath(node.getPath()));
- }
- }
- return paths;
- }
- }
-}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/DebuggerTreeRenderer.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/DebuggerTreeRenderer.java
index 857443f..fe69418 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/DebuggerTreeRenderer.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/DebuggerTreeRenderer.java
@@ -23,12 +23,14 @@
import com.intellij.icons.AllIcons;
import com.intellij.ide.highlighter.JavaHighlightingColors;
import com.intellij.openapi.editor.colors.EditorColorsManager;
+import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.*;
import com.intellij.util.PlatformIcons;
import com.intellij.xdebugger.impl.ui.XDebuggerUIConstants;
import com.intellij.xdebugger.impl.ui.tree.ValueMarkup;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
@@ -112,15 +114,37 @@
return nodeIcon;
}
+ @NotNull
+ public static EditorColorsScheme getColorScheme(@Nullable JComponent component) {
+ EditorColorsScheme globalScheme = EditorColorsManager.getInstance().getGlobalScheme();
+ if (component != null && ColorUtil.isDark(component.getBackground()) != ColorUtil.isDark(globalScheme.getDefaultBackground())) {
+ EditorColorsScheme scheme = EditorColorsManager.getInstance().getScheme(EditorColorsScheme.DEFAULT_SCHEME_NAME);
+ if (scheme != null) {
+ return scheme;
+ }
+ }
+ return globalScheme;
+ }
+
+ public static SimpleColoredText getDescriptorText(DebuggerContextImpl debuggerContext,
+ NodeDescriptorImpl descriptor,
+ EditorColorsScheme colorsScheme,
+ boolean multiline) {
+ return getDescriptorText(debuggerContext, descriptor, colorsScheme, multiline, true);
+ }
+
public static SimpleColoredText getDescriptorText(final DebuggerContextImpl debuggerContext, NodeDescriptorImpl descriptor, boolean multiline) {
- return getDescriptorText(debuggerContext, descriptor, multiline, true);
+ return getDescriptorText(debuggerContext, descriptor, getColorScheme(null), multiline, true);
}
public static SimpleColoredText getDescriptorTitle(final DebuggerContextImpl debuggerContext, NodeDescriptorImpl descriptor) {
- return getDescriptorText(debuggerContext, descriptor, false, false);
+ return getDescriptorText(debuggerContext, descriptor, getColorScheme(null), false, false);
}
- private static SimpleColoredText getDescriptorText(final DebuggerContextImpl debuggerContext, final NodeDescriptorImpl descriptor, boolean multiline,
+ private static SimpleColoredText getDescriptorText(DebuggerContextImpl debuggerContext,
+ NodeDescriptorImpl descriptor,
+ EditorColorsScheme colorScheme,
+ boolean multiline,
boolean appendValue) {
SimpleColoredText descriptorText = new SimpleColoredText();
@@ -195,10 +219,10 @@
else {
TextAttributes attributes = null;
if (valueDescriptor.isNull()){
- attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(JavaHighlightingColors.KEYWORD);
+ attributes = colorScheme.getAttributes(JavaHighlightingColors.KEYWORD);
}
else if (valueDescriptor.isString()) {
- attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(JavaHighlightingColors.STRING);
+ attributes = colorScheme.getAttributes(JavaHighlightingColors.STRING);
}
valueLabelAttribs = attributes != null? SimpleTextAttributes.fromTextAttributes(attributes) : DEFAULT_ATTRIBUTES;
}
@@ -207,11 +231,11 @@
if(exception != null) {
final String errorMessage = exception.getMessage();
if(valueLabel.endsWith(errorMessage)) {
- appendValueTextWithEscapesRendering(descriptorText, valueLabel.substring(0, valueLabel.length() - errorMessage.length()), valueLabelAttribs);
+ appendValueTextWithEscapesRendering(descriptorText, valueLabel.substring(0, valueLabel.length() - errorMessage.length()), valueLabelAttribs, colorScheme);
descriptorText.append(errorMessage, XDebuggerUIConstants.EXCEPTION_ATTRIBUTES);
}
else {
- appendValueTextWithEscapesRendering(descriptorText, valueLabel, valueLabelAttribs);
+ appendValueTextWithEscapesRendering(descriptorText, valueLabel, valueLabelAttribs, colorScheme);
descriptorText.append(errorMessage, XDebuggerUIConstants.EXCEPTION_ATTRIBUTES);
}
}
@@ -220,7 +244,7 @@
descriptorText.append(XDebuggerUIConstants.COLLECTING_DATA_MESSAGE, XDebuggerUIConstants.COLLECTING_DATA_HIGHLIGHT_ATTRIBUTES);
}
else {
- appendValueTextWithEscapesRendering(descriptorText, valueLabel, valueLabelAttribs);
+ appendValueTextWithEscapesRendering(descriptorText, valueLabel, valueLabelAttribs, colorScheme);
}
}
}
@@ -233,7 +257,10 @@
return descriptorText;
}
- private static void appendValueTextWithEscapesRendering(SimpleColoredText descriptorText, String valueText, final SimpleTextAttributes attribs) {
+ private static void appendValueTextWithEscapesRendering(SimpleColoredText descriptorText,
+ String valueText,
+ SimpleTextAttributes attribs,
+ EditorColorsScheme colorScheme) {
SimpleTextAttributes escapeAttribs = null;
final StringBuilder buf = new StringBuilder();
boolean slashFound = false;
@@ -248,7 +275,7 @@
}
if (escapeAttribs == null) { // lazy init
- TextAttributes fromHighlighter = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(JavaHighlightingColors.VALID_STRING_ESCAPE);
+ TextAttributes fromHighlighter = colorScheme.getAttributes(JavaHighlightingColors.VALID_STRING_ESCAPE);
if (fromHighlighter != null) {
escapeAttribs = SimpleTextAttributes.fromTextAttributes(fromHighlighter);
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/ArgumentValueDescriptorImpl.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/ArgumentValueDescriptorImpl.java
index 3cb94d4..7adee9d 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/ArgumentValueDescriptorImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/ArgumentValueDescriptorImpl.java
@@ -30,6 +30,8 @@
import com.sun.jdi.PrimitiveValue;
import com.sun.jdi.Value;
+import java.util.HashSet;
+import java.util.Set;
import java.util.Stack;
public class ArgumentValueDescriptorImpl extends ValueDescriptorImpl{
@@ -110,6 +112,7 @@
private class LocalVariableNameFinder extends JavaRecursiveElementVisitor {
private final int myStartSlot;
private final StringBuilder myNameBuilder;
+ private final Set<String> myVisitedNames = new HashSet<String>();
private int myCurrentSlotIndex;
private final Stack<Integer> myIndexStack;
@@ -122,14 +125,24 @@
@Override
public void visitLocalVariable(PsiLocalVariable variable) {
- if (myCurrentSlotIndex == myIndex) {
+ appendName(variable.getName());
+ final PsiType varType = variable.getType();
+ myCurrentSlotIndex += (varType == PsiType.DOUBLE || varType == PsiType.LONG)? 2 : 1;
+ }
+
+ public void visitSynchronizedStatement(PsiSynchronizedStatement statement) {
+ appendName("<monitor>");
+ myCurrentSlotIndex++;
+ super.visitSynchronizedStatement(statement);
+ }
+
+ private void appendName(String varName) {
+ if (myCurrentSlotIndex == myIndex && myVisitedNames.add(varName)) {
if (myNameBuilder.length() != 0) {
myNameBuilder.append(" | ");
}
- myNameBuilder.append(variable.getName());
+ myNameBuilder.append(varName);
}
- final PsiType varType = variable.getType();
- myCurrentSlotIndex += (varType == PsiType.DOUBLE || varType == PsiType.LONG)? 2 : 1;
}
@Override
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTreeNodeImpl.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTreeNodeImpl.java
index 665a6a1..b6877dc 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTreeNodeImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTreeNodeImpl.java
@@ -87,7 +87,7 @@
final NodeDescriptorImpl descriptor = getDescriptor();
myIcon = DebuggerTreeRenderer.getDescriptorIcon(descriptor);
final DebuggerContextImpl context = getTree().getDebuggerContext();
- myText = DebuggerTreeRenderer.getDescriptorText(context, descriptor, false);
+ myText = DebuggerTreeRenderer.getDescriptorText(context, descriptor, DebuggerTreeRenderer.getColorScheme(myTree), false);
if (descriptor instanceof ValueDescriptor) {
final ValueMarkup markup = ((ValueDescriptor)descriptor).getMarkup(context.getDebugProcess());
myMarkupTooltipText = markup != null? markup.getToolTipText() : null;
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/FieldDescriptorImpl.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/FieldDescriptorImpl.java
index 521c223..586dadf 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/FieldDescriptorImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/FieldDescriptorImpl.java
@@ -18,12 +18,14 @@
import com.intellij.debugger.DebuggerBundle;
import com.intellij.debugger.DebuggerContext;
import com.intellij.debugger.SourcePosition;
+import com.intellij.debugger.engine.DebugProcessImpl;
import com.intellij.debugger.engine.DebuggerManagerThreadImpl;
import com.intellij.debugger.engine.DebuggerUtils;
import com.intellij.debugger.engine.JVMNameUtil;
import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil;
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
+import com.intellij.debugger.engine.events.DebuggerContextCommandImpl;
import com.intellij.debugger.impl.DebuggerContextImpl;
import com.intellij.debugger.impl.DebuggerSession;
import com.intellij.debugger.impl.PositionUtil;
@@ -32,6 +34,8 @@
import com.intellij.debugger.ui.tree.NodeDescriptor;
import com.intellij.debugger.ui.tree.render.ClassRenderer;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Computable;
+import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
@@ -98,20 +102,43 @@
PsiClass aClass = facade.findClass(type.name().replace('$', '.'), scope);
if (aClass == null) {
// trying to search, assuming declaring class is an anonymous class
- try {
- final List<Location> locations = type.allLineLocations();
- if (!locations.isEmpty()) {
- // important: use the last location to be sure the position will be within the anonymous class
- final Location lastLocation = locations.get(locations.size() - 1);
- final SourcePosition position = context.getDebugProcess().getPositionManager().getSourcePosition(lastLocation);
- if (position != null) {
- aClass = JVMNameUtil.getClassAt(position);
+ final DebugProcessImpl debugProcess = context.getDebugProcess();
+ if (debugProcess != null) {
+ final Computable<PsiClass> classComputable = new Computable<PsiClass>() {
+ public PsiClass compute() {
+ try {
+ final List<Location> locations = type.allLineLocations();
+ if (!locations.isEmpty()) {
+ // important: use the last location to be sure the position will be within the anonymous class
+ final Location lastLocation = locations.get(locations.size() - 1);
+ final SourcePosition position = debugProcess.getPositionManager().getSourcePosition(lastLocation);
+ if (position != null) {
+ return JVMNameUtil.getClassAt(position);
+ }
+ }
+ }
+ catch (AbsentInformationException ignored) {
+ }
+ catch (ClassNotPreparedException ignored) {
+ }
+ return null;
}
+ };
+ if (!DebuggerManagerThreadImpl.isManagerThread()) {
+ final Ref<PsiClass> classRef = new Ref<PsiClass>(null);
+ debugProcess.getManagerThread().invokeAndWait(new DebuggerContextCommandImpl(context) {
+ public Priority getPriority() {
+ return Priority.HIGH;
+ }
+ public void threadAction() {
+ classRef.set(classComputable.compute());
+ }
+ });
+ aClass = classRef.get();
}
- }
- catch (AbsentInformationException ignored) {
- }
- catch (ClassNotPreparedException ignored) {
+ else {
+ aClass = classComputable.compute();
+ }
}
}
diff --git a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryOptionsPanel.java b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryOptionsPanel.java
index 3eb6b0a..0d06c9f 100644
--- a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryOptionsPanel.java
+++ b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryOptionsPanel.java
@@ -125,10 +125,7 @@
public void run() {
if (!myDisposed) {
showSettingsPanel(libraryDescription, baseDirectoryPath, versionFilter, showDoNotCreateOption, versions);
- LibraryDownloadSettings settings = mySettings.getDownloadSettings();
- if (settings != null) {
- onVersionChanged(settings.getVersion());
- }
+ onVersionChanged(getPresentableVersion());
}
}
});
@@ -141,7 +138,28 @@
}
}
- protected void onVersionChanged(FrameworkLibraryVersion version) {
+ @Nullable
+ private String getPresentableVersion() {
+ switch (myButtonEnumModel.getSelected()) {
+ case DOWNLOAD:
+ LibraryDownloadSettings settings = mySettings.getDownloadSettings();
+ if (settings != null) {
+ return settings.getVersion().getVersionNumber();
+ }
+ break;
+ case USE_LIBRARY:
+ LibraryEditor item = myLibraryComboBoxModel.getSelectedItem();
+ if (item instanceof ExistingLibraryEditor) {
+ return item.getName();
+ }
+ break;
+ default:
+ return null;
+ }
+ return null;
+ }
+
+ protected void onVersionChanged(@Nullable String version) {
}
public JPanel getSimplePanel() {
@@ -176,6 +194,7 @@
@Override
public void actionPerformed(ActionEvent e) {
updateState();
+ onVersionChanged(getPresentableVersion());
}
});
@@ -208,6 +227,7 @@
myButtonEnumModel.setSelected(Choice.USE_LIBRARY);
}
updateState();
+ onVersionChanged(getPresentableVersion());
}
});
myExistingLibraryComboBox.setRenderer(new ColoredListCellRenderer() {
@@ -346,7 +366,7 @@
}
private void doCreate() {
- final NewLibraryConfiguration libraryConfiguration = myLibraryDescription.createNewLibrary(myPanel, getBaseDirectory());
+ final NewLibraryConfiguration libraryConfiguration = myLibraryDescription.createNewLibrary(myCreateButton, getBaseDirectory());
if (libraryConfiguration != null) {
final NewLibraryEditor libraryEditor = new NewLibraryEditor(libraryConfiguration.getLibraryType(), libraryConfiguration.getProperties());
libraryEditor.setName(myLibrariesContainer.suggestUniqueLibraryName(libraryConfiguration.getDefaultLibraryName()));
diff --git a/java/idea-ui/src/com/intellij/ide/projectWizard/NewProjectWizard.java b/java/idea-ui/src/com/intellij/ide/projectWizard/NewProjectWizard.java
index 290d3cd..77d6d91 100644
--- a/java/idea-ui/src/com/intellij/ide/projectWizard/NewProjectWizard.java
+++ b/java/idea-ui/src/com/intellij/ide/projectWizard/NewProjectWizard.java
@@ -33,8 +33,6 @@
public NewProjectWizard(@Nullable Project project, @NotNull ModulesProvider modulesProvider, @Nullable String defaultPath) {
super("New Project", project, defaultPath);
-// addStep();
-// addStep(new ProjectSummaryStep(myWizardContext));
myWizardContext.setNewWizard(true);
mySequence = new StepSequence();
mySequence.addCommonStep(new ProjectTypeStep(myWizardContext, this, modulesProvider));
diff --git a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectCategory.java b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectCategory.java
index 0862c73..7ef2e82 100644
--- a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectCategory.java
+++ b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectCategory.java
@@ -69,6 +69,10 @@
return ArrayUtil.EMPTY_STRING_ARRAY;
}
+ public String[] getPreselectedFrameworkIds() {
+ return ArrayUtil.EMPTY_STRING_ARRAY;
+ }
+
@Override
public String toString() {
return getDisplayName();
diff --git a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectSummaryStep.form b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectSummaryStep.form
deleted file mode 100644
index a0f1f25..0000000
--- a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectSummaryStep.form
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.ide.projectWizard.ProjectSummaryStep">
- <grid id="27dc6" binding="myRootPanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
- <margin top="0" left="0" bottom="0" right="0"/>
- <constraints>
- <xy x="20" y="20" width="500" height="400"/>
- </constraints>
- <properties/>
- <border type="none"/>
- <children>
- <grid id="15993" binding="myNameAndLocationPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
- <constraints>
- <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
- </constraints>
- <properties/>
- <border type="none"/>
- <children/>
- </grid>
- <vspacer id="c6894">
- <constraints>
- <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
- </constraints>
- </vspacer>
- </children>
- </grid>
-</form>
diff --git a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectSummaryStep.java b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectSummaryStep.java
deleted file mode 100644
index 28e9cec..0000000
--- a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectSummaryStep.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2000-2013 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.ide.projectWizard;
-
-import com.intellij.ide.util.projectWizard.NamePathComponent;
-import com.intellij.ide.util.projectWizard.WizardContext;
-import com.intellij.ide.wizard.CommitStepException;
-import com.intellij.ide.wizard.StepAdapter;
-
-import javax.swing.*;
-import java.awt.*;
-
-/**
- * @author Dmitry Avdeev
- * Date: 20.09.13
- */
-public class ProjectSummaryStep extends StepAdapter {
-
- private final WizardContext myWizardContext;
- private JPanel myRootPanel;
- private JPanel myNameAndLocationPanel;
- private final NamePathComponent myNamePathComponent;
-
- public ProjectSummaryStep(WizardContext context) {
- myWizardContext = context;
- myNamePathComponent = NamePathComponent.initNamePathComponent(myWizardContext);
- myNameAndLocationPanel.add(myNamePathComponent, BorderLayout.CENTER);
- }
-
- @Override
- public void _commit(boolean finishChosen) throws CommitStepException {
- myWizardContext.setProjectName(myNamePathComponent.getNameValue());
- myWizardContext.setProjectFileDirectory(myNamePathComponent.getPath());
- }
-
- @Override
- public JComponent getComponent() {
- return myRootPanel;
- }
-
- @Override
- public JComponent getPreferredFocusedComponent() {
- return myNamePathComponent.getNameComponent();
- }
-}
diff --git a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.form b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.form
index 000469c..1eaf128 100644
--- a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.form
+++ b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.form
@@ -45,29 +45,7 @@
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"/>
</clientProperties>
<border type="none"/>
- <children>
- <grid id="4ffce" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
- <margin top="0" left="0" bottom="0" right="0"/>
- <constraints>
- <card name="group description card"/>
- </constraints>
- <properties/>
- <border type="none"/>
- <children>
- <component id="3c23c" class="com.intellij.ui.components.JBLabel" binding="myGroupDescriptionLabel">
- <constraints>
- <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="2" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
- </constraints>
- <properties/>
- </component>
- <vspacer id="617a5">
- <constraints>
- <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
- </constraints>
- </vspacer>
- </children>
- </grid>
- </children>
+ <children/>
</grid>
</children>
</grid>
diff --git a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.java b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.java
index 3efa8182..4c66356 100644
--- a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.java
+++ b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.java
@@ -15,6 +15,7 @@
*/
package com.intellij.ide.projectWizard;
+import com.intellij.CommonBundle;
import com.intellij.framework.addSupport.FrameworkSupportInModuleProvider;
import com.intellij.ide.util.frameworkSupport.FrameworkRole;
import com.intellij.ide.util.frameworkSupport.FrameworkSupportUtil;
@@ -25,19 +26,35 @@
import com.intellij.ide.util.projectWizard.ModuleBuilder;
import com.intellij.ide.util.projectWizard.ModuleWizardStep;
import com.intellij.ide.util.projectWizard.WizardContext;
+import com.intellij.ide.wizard.CommitStepException;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.module.Module;
+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.project.ProjectBundle;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.roots.ui.configuration.ModulesProvider;
import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer;
import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainerFactory;
+import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.platform.ProjectTemplate;
-import com.intellij.ui.components.JBLabel;
+import com.intellij.platform.ProjectTemplateEP;
+import com.intellij.platform.templates.ArchivedProjectTemplate;
+import com.intellij.platform.templates.LocalArchivedTemplate;
+import com.intellij.platform.templates.RemoteTemplatesFactory;
+import com.intellij.ui.*;
import com.intellij.ui.components.JBList;
+import com.intellij.ui.tabs.TabInfo;
+import com.intellij.ui.tabs.TabsListener;
+import com.intellij.ui.tabs.impl.JBTabsImpl;
+import com.intellij.util.Function;
+import com.intellij.util.containers.ConcurrentMultiMap;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.FactoryMap;
import com.intellij.util.containers.MultiMap;
@@ -49,6 +66,7 @@
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.*;
+import java.net.URL;
import java.util.*;
import java.util.List;
@@ -56,18 +74,21 @@
* @author Dmitry Avdeev
* Date: 04.09.13
*/
-public class ProjectTypeStep extends ModuleWizardStep {
+public class ProjectTypeStep extends ModuleWizardStep implements Disposable {
private static final String FRAMEWORKS_CARD = "frameworks card";
- private static final String GROUP_CARD = "group description card";
private final WizardContext myContext;
private final NewProjectWizard myWizard;
private final ModulesProvider myModulesProvider;
+ private final JTextPane myTemplateDescription;
private JPanel myPanel;
private JPanel myOptionsPanel;
- private JBLabel myGroupDescriptionLabel;
private JBList myProjectTypeList;
- private final ProjectTypesList myList;
+
+ private final ProjectTypesList myProjectTypesList;
+ private final JBList myTemplatesList;
+ private final TabInfo myFrameworksTab;
+ private final TabInfo myTemplatesTab;
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
private final FactoryMap<ProjectCategory, ModuleBuilder> myBuilders = new FactoryMap<ProjectCategory, ModuleBuilder>() {
@@ -81,6 +102,9 @@
private final AddSupportForFrameworksPanel myFrameworksPanel;
private final ModuleBuilder.ModuleConfigurationUpdater myConfigurationUpdater;
+ private boolean myCommitted;
+ private final JBTabsImpl myTabs;
+ private final MultiMap<String, ProjectTemplate> myTemplates = loadLocalTemplates();
public ProjectTypeStep(WizardContext context, NewProjectWizard wizard, ModulesProvider modulesProvider) {
myContext = context;
@@ -124,80 +148,148 @@
}
}
- myList = new ProjectTypesList(myProjectTypeList, map);
+ myProjectTypesList = new ProjectTypesList(myProjectTypeList, map);
myProjectTypeList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
-
@Override
public void valueChanged(ListSelectionEvent e) {
- ModuleBuilder builder = getSelectedBuilder();
- if (builder != null) {
- myContext.setProjectBuilder(builder);
- myWizard.getSequence().setType(builder.getBuilderId());
- builder.addModuleConfigurationUpdater(myConfigurationUpdater);
- }
- updateOptionsPanel(getSelectedObject());
+ projectTypeChanged(true);
}
});
for (ProjectCategory category : map.values()) {
myWizard.getSequence().addStepsForBuilder(myBuilders.get(category), context, modulesProvider);
}
-
myFrameworksPanel = new AddSupportForFrameworksPanel(Collections.<FrameworkSupportInModuleProvider>emptyList(), model, true);
Disposer.register(wizard.getDisposable(), myFrameworksPanel);
- myOptionsPanel.add(myFrameworksPanel.getMainPanel(), FRAMEWORKS_CARD);
+ myTemplatesList = new JBList();
+ myTemplatesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ myTemplatesList.setCellRenderer(new ColoredListCellRenderer<ProjectCategory>() {
+ @Override
+ protected void customizeCellRenderer(JList list, ProjectCategory value, int index, boolean selected, boolean hasFocus) {
+ append(value.getDisplayName()).setIcon(value.getIcon());
+ }
+ });
+ myTemplatesList.addListSelectionListener(new ListSelectionListener() {
+ @Override
+ public void valueChanged(ListSelectionEvent e) {
+ projectTypeChanged(false);
+ ProjectCategory type = (ProjectCategory)myTemplatesList.getSelectedValue();
+ myTemplateDescription.setText(type == null ? "" : type.getDescription());
+ }
+ });
+
+ myTabs = new JBTabsImpl(null, IdeFocusManager.findInstance(), this);
+ myFrameworksTab = new TabInfo(myFrameworksPanel.getMainPanel()).setText(" Frameworks ");
+ myTabs.addTab(myFrameworksTab);
+
+ JPanel templatesPanel = new JPanel(new BorderLayout());
+ templatesPanel.add(ScrollPaneFactory.createScrollPane(myTemplatesList, SideBorder.BOTTOM));
+ myTemplateDescription = new JTextPane();
+ myTemplateDescription.setBorder(IdeBorderFactory.createEmptyBorder(5, 5, 5, 5));
+ Messages.installHyperlinkSupport(myTemplateDescription);
+ templatesPanel.add(myTemplateDescription, BorderLayout.SOUTH);
+
+ myTemplatesTab = new TabInfo(templatesPanel).setText(" Templates ");
+ myTabs.addTab(myTemplatesTab);
+ myOptionsPanel.add(myTabs.getComponent(), FRAMEWORKS_CARD);
+
+ myTabs.addListener(new TabsListener.Adapter() {
+ @Override
+ public void selectionChanged(TabInfo oldSelection, TabInfo newSelection) {
+ projectTypeChanged(false);
+ }
+ });
+ }
+
+ // new category or template is selected
+ public void projectTypeChanged(boolean updatePanel) {
+ ModuleBuilder builder = getSelectedBuilder();
+ if (builder != null) {
+ myContext.setProjectBuilder(builder);
+ myWizard.getSequence().setType(builder.getBuilderId());
+ if (myFrameworksTab == myTabs.getSelectedInfo()) {
+ builder.addModuleConfigurationUpdater(myConfigurationUpdater);
+ }
+ }
+ if (updatePanel) {
+ ProjectCategory type = getSelectedProjectType();
+ if (type != null) {
+ updateOptionsPanel(type);
+ }
+ }
}
@Nullable
- public ProjectCategory getSelectedObject() {
- return myList.getSelectedTemplate();
+ public ProjectCategory getSelectedProjectType() {
+ if (myTabs.getSelectedInfo() == myFrameworksTab) {
+ return myProjectTypesList.getSelectedType();
+ }
+ else {
+ return (ProjectCategory)myTemplatesList.getSelectedValue();
+ }
}
@Nullable
private ModuleBuilder getSelectedBuilder() {
- ProjectCategory object = getSelectedObject();
+ ProjectCategory object = getSelectedProjectType();
return object == null ? null : myBuilders.get(object);
}
- private void updateOptionsPanel(Object object) {
- String card = GROUP_CARD;
- if (object instanceof ProjectCategory) {
- final ProjectCategory projectCategory = (ProjectCategory)object;
- ModuleBuilder builder = myBuilders.get(projectCategory);
- JComponent panel = builder.getCustomOptionsPanel(new Disposable() {
- @Override
- public void dispose() {
- disposeUIResources();
- }
- });
- if (panel != null) {
- card = builder.getBuilderId();
- if (myCards.add(card)) {
- myOptionsPanel.add(panel, card);
- }
+ private void updateOptionsPanel(final @NotNull ProjectCategory projectCategory) {
+ ModuleBuilder builder = myBuilders.get(projectCategory);
+ JComponent panel = builder.getCustomOptionsPanel(new Disposable() {
+ @Override
+ public void dispose() {
+ disposeUIResources();
}
- else {
- card = FRAMEWORKS_CARD;
- List<FrameworkSupportInModuleProvider> allProviders = FrameworkSupportUtil.getProviders(builder);
- List<FrameworkSupportInModuleProvider> matched =
- ContainerUtil.filter(allProviders, new Condition<FrameworkSupportInModuleProvider>() {
- @Override
- public boolean value(FrameworkSupportInModuleProvider provider) {
- return matchFramework(projectCategory, provider);
- }
- });
-
- myFrameworksPanel.setProviders(matched, new HashSet<String>(Arrays.asList(projectCategory.getAssociatedFrameworkIds())));
+ });
+ String card;
+ if (panel != null) {
+ card = builder.getBuilderId();
+ if (myCards.add(card)) {
+ myOptionsPanel.add(panel, card);
}
}
- else if (object instanceof TemplatesGroup) {
- myGroupDescriptionLabel.setText(((TemplatesGroup)object).getDescription());
+ else {
+ card = FRAMEWORKS_CARD;
+ List<FrameworkSupportInModuleProvider> allProviders = FrameworkSupportUtil.getProviders(builder);
+ List<FrameworkSupportInModuleProvider> matched =
+ ContainerUtil.filter(allProviders, new Condition<FrameworkSupportInModuleProvider>() {
+ @Override
+ public boolean value(FrameworkSupportInModuleProvider provider) {
+ return matchFramework(projectCategory, provider);
+ }
+ });
+
+ myFrameworksPanel.setProviders(matched,
+ new HashSet<String>(Arrays.asList(projectCategory.getAssociatedFrameworkIds())),
+ new HashSet<String>(Arrays.asList(projectCategory.getPreselectedFrameworkIds())));
+
+ boolean hasTemplates = updateTemplates(projectCategory, true);
+ myFrameworksTab.setEnabled(!matched.isEmpty() || !hasTemplates);
}
((CardLayout)myOptionsPanel.getLayout()).show(myOptionsPanel, card);
}
+ private boolean updateTemplates(ProjectCategory projectCategory, boolean initial) {
+ List<ProjectCategory> templates = ContainerUtil.map(myTemplates.get(projectCategory.getId()), new Function<ProjectTemplate, ProjectCategory>() {
+ @Override
+ public ProjectCategory fun(ProjectTemplate template) {
+ return new TemplateBasedProjectType(template);
+ }
+ });
+
+ //noinspection unchecked
+ myTemplatesList.setModel(new CollectionListModel<ProjectCategory>(templates));
+ myTemplatesTab.setEnabled(!templates.isEmpty());
+ if (initial && !templates.isEmpty()) {
+ myTemplatesList.setSelectedIndex(0);
+ }
+ return !templates.isEmpty();
+ }
+
private boolean matchFramework(ProjectCategory projectCategory, FrameworkSupportInModuleProvider framework) {
if (!framework.isEnabledForModuleBuilder(myBuilders.get(projectCategory))) return false;
@@ -223,12 +315,29 @@
@Override
public void updateStep() {
- myList.resetSelection();
+ myProjectTypesList.resetSelection();
+ loadRemoteTemplates();
}
@Override
public void onStepLeaving() {
- myList.saveSelection();
+ myProjectTypesList.saveSelection();
+ }
+
+ @Override
+ public void onWizardFinished() throws CommitStepException {
+ if (!myCommitted && myTabs.getSelectedInfo() == myFrameworksTab) {
+ boolean ok = myFrameworksPanel.downloadLibraries();
+ if (!ok) {
+ int answer = Messages.showYesNoDialog(getComponent(),
+ ProjectBundle.message("warning.message.some.required.libraries.wasn.t.downloaded"),
+ CommonBundle.getWarningTitle(), Messages.getWarningIcon());
+ if (answer != 0) {
+ throw new CommitStepException(null);
+ }
+ }
+ myCommitted = true;
+ }
}
@Override
@@ -243,6 +352,63 @@
@TestOnly
public boolean setSelectedProjectType(String group, String name) {
- return myList.setSelectedTemplate(group, name);
+ return myProjectTypesList.setSelectedType(group, name);
+ }
+
+ @Override
+ public void dispose() {
+ }
+
+ @Override
+ public void disposeUIResources() {
+ Disposer.dispose(this);
+ }
+
+ private static MultiMap<String, ProjectTemplate> loadLocalTemplates() {
+ ConcurrentMultiMap<String, ProjectTemplate> map = new ConcurrentMultiMap<String, ProjectTemplate>();
+ ProjectTemplateEP[] extensions = ProjectTemplateEP.EP_NAME.getExtensions();
+ for (ProjectTemplateEP ep : extensions) {
+ ClassLoader classLoader = ep.getLoaderForClass();
+ URL url = classLoader.getResource(ep.templatePath);
+ if (url != null) {
+ map.putValue(ep.projectType, new LocalArchivedTemplate(url, classLoader));
+ }
+ }
+ return map;
+ }
+
+ private void loadRemoteTemplates() {
+ ProgressManager.getInstance().run(new Task.Backgroundable(myContext.getProject(), "Loading Templates") {
+ @Override
+ public void run(@NotNull ProgressIndicator indicator) {
+ try {
+ myTemplatesList.setPaintBusy(true);
+ RemoteTemplatesFactory factory = new RemoteTemplatesFactory();
+ String[] groups = factory.getGroups();
+ for (String group : groups) {
+ ProjectTemplate[] templates = factory.createTemplates(group, myContext);
+ for (ProjectTemplate template : templates) {
+ String id = ((ArchivedProjectTemplate)template).getCategory();
+ myTemplates.putValue(id == null ? group : id, template);
+ }
+ }
+ //noinspection SSBasedInspection
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ int index = myTemplatesList.getSelectedIndex();
+ ProjectCategory type = myProjectTypesList.getSelectedType();
+ if (type != null) {
+ updateTemplates(type, false);
+ }
+ myTemplatesList.setSelectedIndex(index);
+ }
+ });
+ }
+ finally {
+ myTemplatesList.setPaintBusy(false);
+ }
+ }
+ });
+
}
}
diff --git a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypesList.java b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypesList.java
index ddac3b1..b5d60bc 100644
--- a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypesList.java
+++ b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypesList.java
@@ -125,7 +125,7 @@
void resetSelection() {
if (myList.getSelectedIndex() != -1) return;
SelectTemplateSettings settings = SelectTemplateSettings.getInstance();
- if (settings.getLastGroup() == null || !setSelectedTemplate(settings.getLastGroup(), settings.getLastTemplate())) {
+ if (settings.getLastGroup() == null || !setSelectedType(settings.getLastGroup(), settings.getLastTemplate())) {
myList.setSelectedIndex(0);
}
}
@@ -151,12 +151,12 @@
}
@Nullable
- public ProjectCategory getSelectedTemplate() {
+ public ProjectCategory getSelectedType() {
Object value = myList.getSelectedValue();
return value instanceof TemplateItem ? ((TemplateItem)value).myTemplate : null;
}
- public boolean setSelectedTemplate(@Nullable String group, @Nullable String name) {
+ public boolean setSelectedType(@Nullable String group, @Nullable String name) {
for (int i = 0; i < myList.getModel().getSize(); i++) {
Object o = myList.getModel().getElementAt(i);
if (o instanceof TemplateItem && ((TemplateItem)o).myGroup.equals(group) && ((TemplateItem)o).getName().equals(name)) {
@@ -173,7 +173,7 @@
public void dispose() {
}
- class TemplateItem {
+ static class TemplateItem {
private final ProjectCategory myTemplate;
private final String myGroup;
diff --git a/java/idea-ui/src/com/intellij/ide/projectWizard/TemplateBasedProjectType.java b/java/idea-ui/src/com/intellij/ide/projectWizard/TemplateBasedProjectType.java
index 8f462ae..e9eefe5 100644
--- a/java/idea-ui/src/com/intellij/ide/projectWizard/TemplateBasedProjectType.java
+++ b/java/idea-ui/src/com/intellij/ide/projectWizard/TemplateBasedProjectType.java
@@ -17,12 +17,10 @@
import com.intellij.ide.util.projectWizard.ModuleBuilder;
import com.intellij.platform.ProjectTemplate;
-import com.intellij.platform.templates.ArchivedTemplatesFactory;
import com.intellij.platform.templates.LocalArchivedTemplate;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
-import java.io.File;
import java.net.URL;
/**
@@ -36,8 +34,7 @@
public TemplateBasedProjectType(String templatePath) {
URL resource = getClass().getResource(templatePath);
assert resource != null : templatePath;
- String name = ArchivedTemplatesFactory.getTemplateName(new File(templatePath).getName());
- myTemplate = new LocalArchivedTemplate(name, resource, getClass().getClassLoader());
+ myTemplate = new LocalArchivedTemplate(resource, getClass().getClassLoader());
}
public TemplateBasedProjectType(ProjectTemplate template) {
diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AbstractProjectWizard.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AbstractProjectWizard.java
index 60f6f69..4de1dda 100644
--- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AbstractProjectWizard.java
+++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AbstractProjectWizard.java
@@ -31,11 +31,13 @@
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.ui.IdeBorderFactory;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
+import javax.swing.*;
import java.awt.*;
import java.io.File;
@@ -56,6 +58,14 @@
myWizardContext = initContext(project, null);
}
+ @Override
+ protected String addStepComponent(Component component) {
+ if (component instanceof JComponent) {
+ ((JComponent)component).setBorder(IdeBorderFactory.createEmptyBorder(0, 0, 0, 0));
+ }
+ return super.addStepComponent(component);
+ }
+
public abstract StepSequence getSequence();
private static WizardContext initContext(@Nullable Project project, @Nullable String defaultPath) {
@@ -156,15 +166,21 @@
step._commit(true);
}
catch (CommitStepException e) {
- String message = e.getMessage();
- if (message != null) {
- Messages.showErrorDialog(getCurrentStepComponent(), message);
- }
+ handleCommitException(e);
return;
}
if (!isLastStep(idx)) {
idx = getNextStep(idx);
} else {
+ for (ModuleWizardStep wizardStep : mySteps) {
+ try {
+ wizardStep.onWizardFinished();
+ }
+ catch (CommitStepException e) {
+ handleCommitException(e);
+ return;
+ }
+ }
break;
}
} while (true);
@@ -176,6 +192,13 @@
super.doOKAction();
}
+ private void handleCommitException(CommitStepException e) {
+ String message = e.getMessage();
+ if (message != null) {
+ Messages.showErrorDialog(getCurrentStepComponent(), message);
+ }
+ }
+
protected boolean commitStepData(final ModuleWizardStep step) {
try {
if (!step.validate()) {
diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddModuleWizard.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddModuleWizard.java
index 31af15d..13f019e 100644
--- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddModuleWizard.java
+++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddModuleWizard.java
@@ -36,13 +36,11 @@
import com.intellij.openapi.util.Condition;
import com.intellij.projectImport.ProjectImportBuilder;
import com.intellij.projectImport.ProjectImportProvider;
-import com.intellij.ui.IdeBorderFactory;
import com.intellij.util.Function;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
-import javax.swing.*;
import java.awt.*;
public class AddModuleWizard extends AbstractProjectWizard {
@@ -135,14 +133,6 @@
}
@Override
- protected String addStepComponent(Component component) {
- if (component instanceof JComponent) {
- ((JComponent)component).setBorder(IdeBorderFactory.createEmptyBorder(0, 0, 0, 0));
- }
- return super.addStepComponent(component);
- }
-
- @Override
public StepSequence getSequence() {
return myWizardMode.getSteps(myWizardContext, myModulesProvider);
}
diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java
index 2657104..79cace7 100644
--- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java
+++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java
@@ -108,7 +108,7 @@
((DefaultTreeModel)myFrameworksTree.getModel()).nodeChanged(getSelectedNode());
}
}, this);
- setProviders(providers, Collections.<String>emptySet());
+ setProviders(providers, Collections.<String>emptySet(), Collections.<String>emptySet());
myFrameworksTree.addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
@@ -129,10 +129,15 @@
}
- public void setProviders(List<FrameworkSupportInModuleProvider> providers, Set<String> associated) {
+ public void setProviders(List<FrameworkSupportInModuleProvider> providers, Set<String> associated, Set<String> preselected) {
myProviders = providers;
myAssociatedFrameworks = createNodes(myProviders, associated);
+ for (FrameworkSupportNodeBase node : myRoots) {
+ if (preselected.contains(node.getId())) {
+ node.setChecked(true);
+ }
+ }
setAssociatedFrameworks();
myFrameworksTree.setRoots(myRoots);
@@ -253,7 +258,7 @@
private List<LibraryCompositionSettings> getLibrariesCompositionSettingsList() {
List<LibraryCompositionSettings> list = new ArrayList<LibraryCompositionSettings>();
- List<FrameworkSupportNode> selected = getFrameworkNodes(true);
+ List<FrameworkSupportNode> selected = getSelectedNodes();
for (FrameworkSupportNode node : selected) {
ContainerUtil.addIfNotNull(list, getLibraryCompositionSettings(node));
}
@@ -349,34 +354,33 @@
}
public boolean hasSelectedFrameworks() {
- return !getFrameworkNodes(true).isEmpty();
+ return !getSelectedNodes().isEmpty();
}
- private List<FrameworkSupportNode> getFrameworkNodes(final boolean selectedOnly) {
+ private List<FrameworkSupportNode> getSelectedNodes() {
List<FrameworkSupportNode> list = new ArrayList<FrameworkSupportNode>();
if (myRoots != null) {
- addChildFrameworks(myRoots, list, selectedOnly);
+ addChildFrameworks(myRoots, list);
}
+ list.addAll(ContainerUtil.mapNotNull(myAssociatedFrameworks, new Function.InstanceOf<FrameworkSupportNodeBase, FrameworkSupportNode>(FrameworkSupportNode.class)));
return list;
}
- private static void addChildFrameworks(final List<FrameworkSupportNodeBase> list, final List<FrameworkSupportNode> result,
- final boolean selectedOnly) {
+ private static void addChildFrameworks(final List<FrameworkSupportNodeBase> list, final List<FrameworkSupportNode> result) {
for (FrameworkSupportNodeBase node : list) {
- if (!selectedOnly || node.isChecked() || node instanceof FrameworkGroupNode) {
+ if (node.isChecked() || node instanceof FrameworkGroupNode) {
if (node instanceof FrameworkSupportNode) {
result.add((FrameworkSupportNode)node);
}
//noinspection unchecked
- addChildFrameworks(node.getChildren(), result, selectedOnly);
+ addChildFrameworks(node.getChildren(), result);
}
}
}
public void addSupport(final @NotNull Module module, final @NotNull ModifiableRootModel rootModel) {
List<Library> addedLibraries = new ArrayList<Library>();
- List<FrameworkSupportNode> selectedFrameworks = getFrameworkNodes(true);
- selectedFrameworks.addAll(ContainerUtil.mapNotNull(myAssociatedFrameworks, new Function.InstanceOf<FrameworkSupportNodeBase, FrameworkSupportNode>(FrameworkSupportNode.class)));
+ List<FrameworkSupportNode> selectedFrameworks = getSelectedNodes();
sortFrameworks(selectedFrameworks);
List<FrameworkSupportConfigurable> selectedConfigurables = new ArrayList<FrameworkSupportConfigurable>();
final IdeaModifiableModelsProvider modifiableModelsProvider = new IdeaModifiableModelsProvider();
diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworkSupportOptionsComponent.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworkSupportOptionsComponent.java
index 8237baf..1b5c3b94 100644
--- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworkSupportOptionsComponent.java
+++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworkSupportOptionsComponent.java
@@ -100,7 +100,7 @@
myLibraryOptionsPanel = new LibraryOptionsPanel(description, myModel.getBaseDirectoryForLibrariesPath(), createLibraryVersionFilter(),
container, !myConfigurable.isOnlyLibraryAdded()) {
@Override
- protected void onVersionChanged(FrameworkLibraryVersion version) {
+ protected void onVersionChanged(@Nullable String version) {
if (myFrameworkVersionComponent == null) {
myModel.setSelectedLibraryVersion(provider.getId(), version);
}
diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworksTree.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworksTree.java
index 6dcd225..dc2cecd 100644
--- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworksTree.java
+++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworksTree.java
@@ -16,7 +16,6 @@
package com.intellij.ide.util.newProjectWizard;
import com.intellij.framework.FrameworkOrGroup;
-import com.intellij.framework.PresentableVersion;
import com.intellij.ide.util.newProjectWizard.impl.FrameworkSupportModelBase;
import com.intellij.ui.CheckboxTree;
import com.intellij.ui.CheckedTreeNode;
@@ -114,9 +113,9 @@
getTextRenderer().append(node.getTitle(), attributes);
if (node.isChecked()) {
FrameworkOrGroup object = node.getUserObject();
- PresentableVersion version = myModel.getPresentableVersion(object.getId());
+ String version = myModel.getFrameworkVersion(object.getId());
if (version != null) {
- getTextRenderer().append(" (" + version.getVersionNumber() + ")", SimpleTextAttributes.GRAYED_ATTRIBUTES);
+ getTextRenderer().append(" (" + version + ")", SimpleTextAttributes.GRAYED_ATTRIBUTES);
}
}
getTextRenderer().setIcon(node.getIcon());
diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/LoadingProjectTemplate.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/LoadingProjectTemplate.java
index 2154ec2..9cd0f67 100644
--- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/LoadingProjectTemplate.java
+++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/LoadingProjectTemplate.java
@@ -27,7 +27,7 @@
* @author Dmitry Avdeev
* Date: 11/28/12
*/
-class LoadingProjectTemplate implements ProjectTemplate {
+public class LoadingProjectTemplate implements ProjectTemplate {
@NotNull
@Override
public String getName() {
diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectTypesList.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectTypesList.java
index 813eae7..1af97c1 100644
--- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectTypesList.java
+++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/ProjectTypesList.java
@@ -68,7 +68,6 @@
}
}.setComparator(new SpeedSearchComparator(false));
List<TemplateItem> items = buildItems(map);
- final RemoteTemplatesFactory factory = new RemoteTemplatesFactory();
final TemplatesGroup samplesGroup = new TemplatesGroup("Loading Templates...", "", null, 0);
myLoadingItem = new TemplateItem(new LoadingProjectTemplate(), samplesGroup) {
@Override
@@ -84,6 +83,7 @@
items.add(myLoadingItem);
myModel = new CollectionListModel<TemplateItem>(items);
+ final RemoteTemplatesFactory factory = new RemoteTemplatesFactory();
ProgressManager.getInstance().run(new Task.Backgroundable(context.getProject(), "Loading Templates") {
@Override
public void run(@NotNull ProgressIndicator indicator) {
diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SelectTemplateStep.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SelectTemplateStep.java
index e1d46ea..d0a3536 100644
--- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SelectTemplateStep.java
+++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SelectTemplateStep.java
@@ -519,6 +519,7 @@
myModuleNameDocListenerEnabled = true;
}
+ @Override
@NotNull
public JTextField getModuleNameField() {
return myModuleName;
diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/impl/FrameworkSupportModelBase.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/impl/FrameworkSupportModelBase.java
index 3ac7333..aa109764 100644
--- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/impl/FrameworkSupportModelBase.java
+++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/impl/FrameworkSupportModelBase.java
@@ -17,10 +17,8 @@
import com.intellij.facet.impl.ui.libraries.FrameworkLibraryProvider;
import com.intellij.framework.FrameworkVersion;
-import com.intellij.framework.PresentableVersion;
import com.intellij.framework.addSupport.FrameworkSupportInModuleProvider;
import com.intellij.framework.addSupport.FrameworkVersionListener;
-import com.intellij.framework.library.FrameworkLibraryVersion;
import com.intellij.ide.util.frameworkSupport.FrameworkSupportConfigurable;
import com.intellij.ide.util.frameworkSupport.FrameworkSupportModel;
import com.intellij.ide.util.frameworkSupport.FrameworkSupportModelListener;
@@ -55,7 +53,7 @@
private final Map<String, FrameworkSupportNode> mySettingsMap = new HashMap<String, FrameworkSupportNode>();
private final Map<String, FrameworkSupportOptionsComponent> myOptionsComponentsMap = new HashMap<String, FrameworkSupportOptionsComponent>();
private final Map<String, FrameworkVersion> mySelectedVersions = new HashMap<String, FrameworkVersion>();
- private final Map<String, FrameworkLibraryVersion> myLibraryVersions = new HashMap<String, FrameworkLibraryVersion>();
+ private final Map<String, String> myFrameworkVersions = new HashMap<String, String>();
private FrameworkLibraryProvider myLibraryProvider;
public FrameworkSupportModelBase(final @Nullable Project project, @Nullable ModuleBuilder builder, @NotNull LibrariesContainer librariesContainer) {
@@ -169,7 +167,7 @@
return myLibraryProvider;
}
- public void setLibraryProvider(FrameworkLibraryProvider libraryProvider) {
+ public void setLibraryProvider(@Nullable FrameworkLibraryProvider libraryProvider) {
myLibraryProvider = libraryProvider;
for (FrameworkSupportOptionsComponent optionsComponent : myOptionsComponentsMap.values()) {
optionsComponent.updateLibrariesPanel();
@@ -205,13 +203,13 @@
return myLibrariesContainer;
}
- public void setSelectedLibraryVersion(String id, FrameworkLibraryVersion version) {
- myLibraryVersions.put(id, version);
+ public void setSelectedLibraryVersion(String id, String version) {
+ myFrameworkVersions.put(id, version);
myVersionEventDispatcher.getMulticaster().versionChanged(getSelectedVersion(id));
}
- public PresentableVersion getPresentableVersion(String id) {
+ public String getFrameworkVersion(String id) {
FrameworkVersion version = mySelectedVersions.get(id);
- return version == null ? myLibraryVersions.get(id) : version;
+ return version == null ? myFrameworkVersions.get(id) : version.getVersionNumber();
}
}
diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/ExistingLibraryEditor.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/ExistingLibraryEditor.java
index 7e4b772..d33dbb5 100644
--- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/ExistingLibraryEditor.java
+++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/ExistingLibraryEditor.java
@@ -71,10 +71,13 @@
private LibraryType detectType() {
if (!myDetectedTypeComputed) {
- final Pair<LibraryType<?>,LibraryProperties<?>> pair = LibraryDetectionManager.getInstance().detectType(Arrays.asList(getFiles(OrderRootType.CLASSES)));
- if (pair != null) {
- myDetectedType = pair.getFirst();
- myDetectedLibraryProperties = pair.getSecond();
+ LibraryTable libraryTable = myLibrary.getTable();
+ if (libraryTable == null || libraryTable.isEditable()) {
+ final Pair<LibraryType<?>,LibraryProperties<?>> pair = LibraryDetectionManager.getInstance().detectType(Arrays.asList(getFiles(OrderRootType.CLASSES)));
+ if (pair != null) {
+ myDetectedType = pair.getFirst();
+ myDetectedLibraryProperties = pair.getSecond();
+ }
}
myDetectedTypeComputed = true;
}
diff --git a/java/idea-ui/src/com/intellij/platform/templates/ArchivedProjectTemplate.java b/java/idea-ui/src/com/intellij/platform/templates/ArchivedProjectTemplate.java
index adc9ddd..8937dd9 100644
--- a/java/idea-ui/src/com/intellij/platform/templates/ArchivedProjectTemplate.java
+++ b/java/idea-ui/src/com/intellij/platform/templates/ArchivedProjectTemplate.java
@@ -35,9 +35,11 @@
public abstract class ArchivedProjectTemplate implements ProjectTemplate {
protected final String myDisplayName;
+ @Nullable private final String myCategory;
- public ArchivedProjectTemplate(@NotNull String displayName) {
+ public ArchivedProjectTemplate(@NotNull String displayName, @Nullable String category) {
myDisplayName = displayName;
+ myCategory = category;
}
@NotNull
@@ -67,4 +69,9 @@
}
public abstract ZipInputStream getStream() throws IOException;
+
+ @Nullable
+ public String getCategory() {
+ return myCategory;
+ }
}
diff --git a/java/idea-ui/src/com/intellij/platform/templates/ArchivedTemplatesFactory.java b/java/idea-ui/src/com/intellij/platform/templates/ArchivedTemplatesFactory.java
index 08c673f..b2ea502 100644
--- a/java/idea-ui/src/com/intellij/platform/templates/ArchivedTemplatesFactory.java
+++ b/java/idea-ui/src/com/intellij/platform/templates/ArchivedTemplatesFactory.java
@@ -17,7 +17,7 @@
import com.intellij.ide.fileTemplates.impl.UrlUtil;
import com.intellij.ide.plugins.IdeaPluginDescriptor;
-import com.intellij.ide.plugins.PluginManager;
+import com.intellij.ide.plugins.PluginManagerCore;
import com.intellij.ide.util.projectWizard.WizardContext;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.diagnostic.Logger;
@@ -41,14 +41,14 @@
*/
public class ArchivedTemplatesFactory extends ProjectTemplatesFactory {
- private static final String ZIP = ".zip";
+ static final String ZIP = ".zip";
private final ClearableLazyValue<MultiMap<String, Pair<URL, ClassLoader>>> myGroups = new ClearableLazyValue<MultiMap<String, Pair<URL, ClassLoader>>>() {
@NotNull
@Override
protected MultiMap<String, Pair<URL, ClassLoader>> compute() {
MultiMap<String, Pair<URL, ClassLoader>> map = new MultiMap<String, Pair<URL, ClassLoader>>();
- IdeaPluginDescriptor[] plugins = PluginManager.getPlugins();
+ IdeaPluginDescriptor[] plugins = PluginManagerCore.getPlugins();
Map<URL, ClassLoader> urls = new HashMap<URL, ClassLoader>();
for (IdeaPluginDescriptor plugin : plugins) {
if (!plugin.isEnabled()) continue;
@@ -83,7 +83,8 @@
if (index != -1) {
child = child.substring(0, index);
}
- map.putValue(child.replace('_', ' '), Pair.create(new URL(url.getKey().toExternalForm() + "/" + child), url.getValue()));
+ String name = child.replace('_', ' ');
+ map.putValue(name, Pair.create(new URL(url.getKey().toExternalForm() + "/" + child), url.getValue()));
}
}
catch (IOException e) {
@@ -132,8 +133,7 @@
for (String child : children) {
if (child.endsWith(ZIP)) {
URL templateUrl = new URL(url.first.toExternalForm() + "/" + child);
- String name = getTemplateName(child);
- templates.add(new LocalArchivedTemplate(name, templateUrl, url.second));
+ templates.add(new LocalArchivedTemplate(templateUrl, url.second));
}
}
}
@@ -144,10 +144,6 @@
return templates.toArray(new ProjectTemplate[templates.size()]);
}
- public static String getTemplateName(String child) {
- return child.substring(0, child.length() - ZIP.length()).replace('_', ' ');
- }
-
@Override
public int getGroupWeight(String group) {
return CUSTOM_GROUP.equals(group) ? -2 : 0;
diff --git a/java/idea-ui/src/com/intellij/platform/templates/LocalArchivedTemplate.java b/java/idea-ui/src/com/intellij/platform/templates/LocalArchivedTemplate.java
index f671335..e9c8480 100644
--- a/java/idea-ui/src/com/intellij/platform/templates/LocalArchivedTemplate.java
+++ b/java/idea-ui/src/com/intellij/platform/templates/LocalArchivedTemplate.java
@@ -31,6 +31,7 @@
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
+import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.Collections;
@@ -52,10 +53,9 @@
private List<WizardInputField> myInputFields = Collections.emptyList();
private Icon myIcon;
- public LocalArchivedTemplate(@NotNull String displayName,
- @NotNull URL archivePath,
+ public LocalArchivedTemplate(@NotNull URL archivePath,
@NotNull ClassLoader classLoader) {
- super(displayName);
+ super(getTemplateName(archivePath), null);
myArchivePath = archivePath;
myModuleType = computeModuleType(this);
@@ -80,6 +80,11 @@
}
}
+ private static String getTemplateName(URL url) {
+ String fileName = new File(url.getPath()).getName();
+ return fileName.substring(0, fileName.length() - ArchivedTemplatesFactory.ZIP.length()).replace('_', ' ');
+ }
+
@Override
public String getDescription() {
return readEntry(new Condition<ZipEntry>() {
diff --git a/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java b/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java
index d3db364..f62333c 100644
--- a/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java
+++ b/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java
@@ -147,7 +147,7 @@
final String path = element.getChildText("path", ns);
final String description = element.getChildTextTrim("description", ns);
String name = element.getChildTextTrim("name", ns);
- return new ArchivedProjectTemplate(name) {
+ return new ArchivedProjectTemplate(name, element.getChildTextTrim("category")) {
@Override
protected ModuleType getModuleType() {
return moduleType;
diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java
index 0a804c5..064888b 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java
@@ -539,6 +539,7 @@
@NotNull PsiResolveHelper resolveHelper,
@NotNull TextRange range,
@NotNull PsiClassType[] handledExceptions) {
+ if (aClass instanceof PsiAnonymousClass) return null;
PsiClass baseClass = aClass.getSuperClass();
if (baseClass == null) return null;
PsiMethod[] constructors = baseClass.getConstructors();
diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java
index 7a89381..8d845ff 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java
@@ -31,6 +31,7 @@
import com.intellij.util.SmartList;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.Stack;
+import com.siyeh.ig.numeric.UnnecessaryExplicitNumericCastInspection;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -79,7 +80,7 @@
myAssertionError = createClassType(manager, scope, JAVA_LANG_ASSERTION_ERROR);
myString = myFactory.createTypeValue(createClassType(manager, scope, JAVA_LANG_STRING), Nullness.NOT_NULL);
- PsiParameter mockVar = JavaPsiFacade.getElementFactory(manager.getProject()).createParameter("$exception$", createClassType(manager, scope, JAVA_LANG_OBJECT));
+ PsiParameter mockVar = JavaPsiFacade.getElementFactory(manager.getProject()).createParameterFromText("java.lang.Object $exception$", null);
myExceptionHolder = myFactory.getVarFactory().createVariableValue(mockVar, false);
myFields = new HashSet<DfaVariableValue>();
@@ -312,6 +313,14 @@
}
}
}
+ else if (parent instanceof PsiTryStatement) {
+ PsiResourceList list = ((PsiTryStatement)parent).getResourceList();
+ if (list != null) {
+ for (PsiResourceVariable variable : list.getResourceVariables()) {
+ myCurrentFlow.removeVariable(variable);
+ }
+ }
+ }
}
@Override public void visitBlockStatement(PsiBlockStatement statement) {
@@ -1866,7 +1875,13 @@
final PsiTypeElement typeElement = castExpression.getCastType();
if (typeElement != null && operand != null) {
- addInstruction(new TypeCastInstruction(castExpression, operand, typeElement.getType()));
+ if (typeElement.getType() instanceof PsiPrimitiveType &&
+ UnnecessaryExplicitNumericCastInspection.isPrimitiveNumericCastNecessary(castExpression)) {
+ addInstruction(new PopInstruction());
+ pushUnknown();
+ } else {
+ addInstruction(new TypeCastInstruction(castExpression, operand, typeElement.getType()));
+ }
}
finishElement(castExpression);
}
diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/miscGenerics/RedundantTypeArgsInspection.java b/java/java-analysis-impl/src/com/intellij/codeInspection/miscGenerics/RedundantTypeArgsInspection.java
index f94d1a6..bb3c4ea 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInspection/miscGenerics/RedundantTypeArgsInspection.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/miscGenerics/RedundantTypeArgsInspection.java
@@ -15,6 +15,7 @@
*/
package com.intellij.codeInspection.miscGenerics;
+import com.intellij.codeInsight.FileModificationService;
import com.intellij.codeInsight.daemon.GroupNames;
import com.intellij.codeInspection.*;
import com.intellij.openapi.diagnostic.Logger;
@@ -150,6 +151,7 @@
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
final PsiReferenceParameterList typeArgumentList = (PsiReferenceParameterList)descriptor.getPsiElement();
+ if (!FileModificationService.getInstance().preparePsiElementForWrite(typeArgumentList)) return;
try {
final PsiMethodCallExpression expr =
(PsiMethodCallExpression)JavaPsiFacade.getInstance(project).getElementFactory().createExpressionFromText("foo()", null);
diff --git a/java/java-impl/src/com/intellij/codeInsight/ExpectedTypeInfoImpl.java b/java/java-impl/src/com/intellij/codeInsight/ExpectedTypeInfoImpl.java
index dd46437..227825b 100644
--- a/java/java-impl/src/com/intellij/codeInsight/ExpectedTypeInfoImpl.java
+++ b/java/java-impl/src/com/intellij/codeInsight/ExpectedTypeInfoImpl.java
@@ -17,10 +17,13 @@
package com.intellij.codeInsight;
import com.intellij.openapi.util.NullableComputable;
+import com.intellij.openapi.util.NullableLazyValue;
+import com.intellij.openapi.util.VolatileNullableLazyValue;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.PsiType;
import com.intellij.psi.util.PsiUtil;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
public class ExpectedTypeInfoImpl implements ExpectedTypeInfo {
public static final NullableComputable<String> NULL = new NullableComputable<String>() {
@@ -37,7 +40,8 @@
@NotNull
private final TailType myTailType;
private final PsiMethod myCalledMethod;
- @NotNull private final NullableComputable<String> expectedName;
+ @NotNull private final NullableComputable<String> expectedNameComputable;
+ @NotNull private final NullableLazyValue<String> expectedNameLazyValue;
@Override
public int getKind() {
@@ -62,15 +66,22 @@
this.myTailType = myTailType;
this.defaultType = defaultType;
myCalledMethod = calledMethod;
- this.expectedName = expectedName;
+ this.expectedNameComputable = expectedName;
+ expectedNameLazyValue = new VolatileNullableLazyValue<String>() {
+ @Nullable
+ @Override
+ protected String compute() {
+ return expectedNameComputable.compute();
+ }
+ };
PsiUtil.ensureValidType(type);
PsiUtil.ensureValidType(defaultType);
}
- @NotNull
- public NullableComputable<String> getExpectedName() {
- return expectedName;
+ @Nullable
+ public String getExpectedName() {
+ return expectedNameLazyValue.getValue();
}
@Override
diff --git a/java/java-impl/src/com/intellij/codeInsight/ExpectedTypesProvider.java b/java/java-impl/src/com/intellij/codeInsight/ExpectedTypesProvider.java
index bc6273e..c9f75a0 100644
--- a/java/java-impl/src/com/intellij/codeInsight/ExpectedTypesProvider.java
+++ b/java/java-impl/src/com/intellij/codeInsight/ExpectedTypesProvider.java
@@ -630,9 +630,15 @@
myResult = visitor.getResult();
if (!(expr.getParent() instanceof PsiExpressionList)) {
for (int i = 0; i < myResult.length; i++) {
- ExpectedTypeInfo info = myResult[i];
+ final ExpectedTypeInfo info = myResult[i];
myResult[i] = createInfoImpl(info.getType(), info.getKind(), info.getDefaultType(), TailType.NONE, info.getCalledMethod(),
- ((ExpectedTypeInfoImpl)info).getExpectedName());
+ new NullableComputable<String>() {
+ @Nullable
+ @Override
+ public String compute() {
+ return ((ExpectedTypeInfoImpl)info).getExpectedName();
+ }
+ });
}
}
return;
@@ -870,9 +876,15 @@
else if (myExpr.equals(expr.getThenExpression())) {
ExpectedTypeInfo[] types = getExpectedTypes(expr, myForCompletion);
for (int i = 0; i < types.length; i++) {
- ExpectedTypeInfo info = types[i];
+ final ExpectedTypeInfo info = types[i];
types[i] = createInfoImpl(info.getType(), info.getKind(), info.getDefaultType(), TailType.COND_EXPR_COLON, info.getCalledMethod(),
- ((ExpectedTypeInfoImpl)info).getExpectedName());
+ new NullableComputable<String>() {
+ @Nullable
+ @Override
+ public String compute() {
+ return ((ExpectedTypeInfoImpl)info).getExpectedName();
+ }
+ });
}
myResult = types;
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/AllClassesGetter.java b/java/java-impl/src/com/intellij/codeInsight/completion/AllClassesGetter.java
index 1bdedaf..2367ce3 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/AllClassesGetter.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/AllClassesGetter.java
@@ -25,6 +25,7 @@
import com.intellij.openapi.util.Condition;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.PostprocessReformattingAspect;
+import com.intellij.psi.impl.source.tree.java.PsiReferenceExpressionImpl;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.searches.AllClassesSearch;
import com.intellij.util.Consumer;
@@ -155,6 +156,10 @@
@Override
public boolean process(PsiClass psiClass) {
+ if (parameters.getInvocationCount() < 2 && PsiReferenceExpressionImpl.seemsScrambled(psiClass)) {
+ return true;
+ }
+
assert psiClass != null;
if (isAcceptableInContext(context, psiClass, filterByScope, pkgContext)) {
String qName = psiClass.getQualifiedName();
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 e2296e4..cabc5d9 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java
@@ -227,7 +227,7 @@
private static int calcMatch(final List<String> words, int max, ExpectedTypeInfo[] myExpectedInfos) {
for (ExpectedTypeInfo myExpectedInfo : myExpectedInfos) {
- String expectedName = ((ExpectedTypeInfoImpl)myExpectedInfo).getExpectedName().compute();
+ String expectedName = ((ExpectedTypeInfoImpl)myExpectedInfo).getExpectedName();
if (expectedName == null) continue;
max = calcMatch(expectedName, words, max);
max = calcMatch(truncDigits(expectedName), words, max);
@@ -504,7 +504,7 @@
int max = 0;
final List<String> wordsNoDigits = NameUtil.nameToWordsLowerCase(truncDigits(name));
for (ExpectedTypeInfo myExpectedInfo : myExpectedTypes) {
- String expectedName = ((ExpectedTypeInfoImpl)myExpectedInfo).getExpectedName().compute();
+ String expectedName = ((ExpectedTypeInfoImpl)myExpectedInfo).getExpectedName();
if (expectedName != null) {
final THashSet<String> set = new THashSet<String>(NameUtil.nameToWordsLowerCase(truncDigits(expectedName)));
set.retainAll(wordsNoDigits);
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionStatistician.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionStatistician.java
index bcc7836..c5c1e39 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionStatistician.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionStatistician.java
@@ -56,7 +56,7 @@
PsiClass containingClass = ((PsiMember)o).getContainingClass();
if (containingClass != null) {
- String expectedName = firstInfo instanceof ExpectedTypeInfoImpl ? ((ExpectedTypeInfoImpl)firstInfo).getExpectedName().compute() : null;
+ String expectedName = firstInfo instanceof ExpectedTypeInfoImpl ? ((ExpectedTypeInfoImpl)firstInfo).getExpectedName() : null;
String contextPrefix = expectedName == null ? "" : "expectedName=" + expectedName + "###";
String context = contextPrefix + JavaStatisticsManager.getMemberUseKey2(containingClass);
diff --git a/java/java-impl/src/com/intellij/codeInsight/editorActions/wordSelection/ListSelectioner.java b/java/java-impl/src/com/intellij/codeInsight/editorActions/wordSelection/ListSelectioner.java
index 2404f21..a608c6e 100644
--- a/java/java-impl/src/com/intellij/codeInsight/editorActions/wordSelection/ListSelectioner.java
+++ b/java/java-impl/src/com/intellij/codeInsight/editorActions/wordSelection/ListSelectioner.java
@@ -50,7 +50,9 @@
}
List<TextRange> result = new ArrayList<TextRange>();
- result.add(new TextRange(start, end));
+ if (start != 0 && end != 0) {
+ result.add(new TextRange(start, end));
+ }
return result;
}
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/ui/GenerateEqualsWizard.java b/java/java-impl/src/com/intellij/codeInsight/generation/ui/GenerateEqualsWizard.java
index 85e9674..c051e3a 100644
--- a/java/java-impl/src/com/intellij/codeInsight/generation/ui/GenerateEqualsWizard.java
+++ b/java/java-impl/src/com/intellij/codeInsight/generation/ui/GenerateEqualsWizard.java
@@ -243,7 +243,7 @@
@Override
protected void addSteps() {
if (myEqualsPanel != null) {
- addStep(new InstanceofOptionStep());
+ addStep(new InstanceofOptionStep(myClass.hasModifierProperty(PsiModifier.FINAL)));
}
super.addSteps();
}
@@ -322,9 +322,10 @@
private static class InstanceofOptionStep extends StepAdapter {
private final JComponent myPanel;
- private InstanceofOptionStep() {
+ private InstanceofOptionStep(boolean isFinal) {
final JCheckBox checkbox = new NonFocusableCheckBox(CodeInsightBundle.message("generate.equals.hashcode.accept.sublcasses"));
- checkbox.setSelected(CodeInsightSettings.getInstance().USE_INSTANCEOF_ON_EQUALS_PARAMETER);
+ checkbox.setSelected(!isFinal && CodeInsightSettings.getInstance().USE_INSTANCEOF_ON_EQUALS_PARAMETER);
+ checkbox.setEnabled(!isFinal);
checkbox.addActionListener(new ActionListener() {
public void actionPerformed(@NotNull final ActionEvent M) {
CodeInsightSettings.getInstance().USE_INSTANCEOF_ON_EQUALS_PARAMETER = checkbox.isSelected();
diff --git a/java/java-impl/src/com/intellij/externalSystem/JavaProjectDataService.java b/java/java-impl/src/com/intellij/externalSystem/JavaProjectDataService.java
index 47f4b0a..bd39412 100644
--- a/java/java-impl/src/com/intellij/externalSystem/JavaProjectDataService.java
+++ b/java/java-impl/src/com/intellij/externalSystem/JavaProjectDataService.java
@@ -18,6 +18,7 @@
import com.intellij.openapi.externalSystem.model.DataNode;
import com.intellij.openapi.externalSystem.model.Key;
import com.intellij.openapi.externalSystem.service.project.manage.ProjectDataService;
+import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange;
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.projectRoots.JavaSdk;
@@ -105,9 +106,9 @@
if (languageLevelExtension.getLanguageLevel().isAtLeast(languageLevel)) {
return;
}
- ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new Runnable() {
+ ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new DisposeAwareProjectChange(project) {
@Override
- public void run() {
+ public void execute() {
languageLevelExtension.setLanguageLevel(languageLevel);
}
});
diff --git a/java/java-impl/src/com/intellij/ide/hierarchy/call/CallHierarchyNodeDescriptor.java b/java/java-impl/src/com/intellij/ide/hierarchy/call/CallHierarchyNodeDescriptor.java
index 4dacb84..4eb3a33 100644
--- a/java/java-impl/src/com/intellij/ide/hierarchy/call/CallHierarchyNodeDescriptor.java
+++ b/java/java-impl/src/com/intellij/ide/hierarchy/call/CallHierarchyNodeDescriptor.java
@@ -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,12 +34,8 @@
import com.intellij.pom.Navigatable;
import com.intellij.psi.*;
import com.intellij.psi.presentation.java.ClassPresentationUtil;
-import com.intellij.psi.util.PsiFormatUtil;
-import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.psi.util.PsiUtilBase;
-import com.intellij.psi.util.PsiUtilCore;
+import com.intellij.psi.util.*;
import com.intellij.ui.LayeredIcon;
-import com.intellij.psi.util.FileTypeUtils;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -68,7 +64,7 @@
return myElement == null ? null : getEnclosingElement(myElement);
}
- static PsiMember getEnclosingElement(final PsiElement element){
+ public static PsiMember getEnclosingElement(final PsiElement element){
return PsiTreeUtil.getNonStrictParentOfType(element, PsiMethod.class, PsiClass.class);
}
@@ -138,8 +134,8 @@
}
final String methodText = PsiFormatUtil.formatMethod(
method,
- PsiSubstitutor.EMPTY, PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_PARAMETERS,
- PsiFormatUtil.SHOW_TYPE
+ PsiSubstitutor.EMPTY, PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_PARAMETERS,
+ PsiFormatUtilBase.SHOW_TYPE
);
buffer.append(methodText);
diff --git a/java/java-impl/src/com/intellij/ide/hierarchy/call/CallerMethodsTreeStructure.java b/java/java-impl/src/com/intellij/ide/hierarchy/call/CallerMethodsTreeStructure.java
index 5699d33..45363bb 100644
--- a/java/java-impl/src/com/intellij/ide/hierarchy/call/CallerMethodsTreeStructure.java
+++ b/java/java-impl/src/com/intellij/ide/hierarchy/call/CallerMethodsTreeStructure.java
@@ -17,12 +17,11 @@
import com.intellij.ide.hierarchy.HierarchyNodeDescriptor;
import com.intellij.ide.hierarchy.HierarchyTreeStructure;
+import com.intellij.ide.util.treeView.NodeDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.intellij.psi.search.SearchScope;
import com.intellij.psi.search.searches.MethodReferencesSearch;
-import com.intellij.psi.util.PsiUtil;
-import com.intellij.psi.util.TypeConversionUtil;
import com.intellij.util.ArrayUtil;
import com.intellij.util.Processor;
import com.intellij.util.containers.ContainerUtil;
@@ -63,69 +62,15 @@
methodsToFind.add(method);
ContainerUtil.addAll(methodsToFind, method.findDeepestSuperMethods());
- final Map<PsiMember, CallHierarchyNodeDescriptor> methodToDescriptorMap = new HashMap<PsiMember, CallHierarchyNodeDescriptor>();
+ final Map<PsiMember, NodeDescriptor> methodToDescriptorMap = new HashMap<PsiMember, NodeDescriptor>();
for (final PsiMethod methodToFind : methodsToFind) {
+ final JavaCallHierarchyData data = new JavaCallHierarchyData(originalClass, methodToFind, originalType, method, methodsToFind, descriptor, methodToDescriptorMap, myProject);
+
MethodReferencesSearch.search(methodToFind, searchScope, true).forEach(new Processor<PsiReference>() {
@Override
public boolean process(final PsiReference reference) {
- if (reference instanceof PsiReferenceExpression) {
- final PsiExpression qualifier = ((PsiReferenceExpression)reference).getQualifierExpression();
- if (qualifier instanceof PsiSuperExpression) { // filter super.foo() call inside foo() and similar cases (bug 8411)
- final PsiClass superClass = PsiUtil.resolveClassInType(qualifier.getType());
- if (originalClass.isInheritor(superClass, true)) {
- return true;
- }
- }
- if (qualifier != null && !methodToFind.hasModifierProperty(PsiModifier.STATIC)) {
- final PsiType qualifierType = qualifier.getType();
- if (qualifierType instanceof PsiClassType &&
- !TypeConversionUtil.isAssignable(qualifierType, originalType) &&
- methodToFind != method) {
- final PsiClass psiClass = ((PsiClassType)qualifierType).resolve();
- if (psiClass != null) {
- final PsiMethod callee = psiClass.findMethodBySignature(methodToFind, true);
- if (callee != null && !methodsToFind.contains(callee)) {
- // skip sibling methods
- return true;
- }
- }
- }
- }
- }
- else {
- if (!(reference instanceof PsiElement)) {
- return true;
- }
-
- final PsiElement parent = ((PsiElement)reference).getParent();
- if (parent instanceof PsiNewExpression) {
- if (((PsiNewExpression)parent).getClassReference() != reference) {
- return true;
- }
- }
- else if (parent instanceof PsiAnonymousClass) {
- if (((PsiAnonymousClass)parent).getBaseClassReference() != reference) {
- return true;
- }
- }
- else {
- return true;
- }
- }
-
- final PsiElement element = reference.getElement();
- final PsiMember key = CallHierarchyNodeDescriptor.getEnclosingElement(element);
-
- synchronized (methodToDescriptorMap) {
- CallHierarchyNodeDescriptor d = methodToDescriptorMap.get(key);
- if (d == null) {
- d = new CallHierarchyNodeDescriptor(myProject, descriptor, element, false, true);
- methodToDescriptorMap.put(key, d);
- }
- else if (!d.hasReference(reference)) {
- d.incrementUsageCount();
- }
- d.addReference(reference);
+ for (CallReferenceProcessor processor : CallReferenceProcessor.EP_NAME.getExtensions()) {
+ if (!processor.process(reference, data)) break;
}
return true;
}
diff --git a/java/java-impl/src/com/intellij/ide/hierarchy/call/JavaCallReferenceProcessor.java b/java/java-impl/src/com/intellij/ide/hierarchy/call/JavaCallReferenceProcessor.java
new file mode 100644
index 0000000..e563ee6
--- /dev/null
+++ b/java/java-impl/src/com/intellij/ide/hierarchy/call/JavaCallReferenceProcessor.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.ide.hierarchy.call;
+
+import com.intellij.ide.util.treeView.NodeDescriptor;
+import com.intellij.openapi.project.Project;
+import com.intellij.psi.*;
+import com.intellij.psi.util.PsiUtil;
+import com.intellij.psi.util.TypeConversionUtil;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Created by Max Medvedev on 10/5/13
+ */
+public class JavaCallReferenceProcessor implements CallReferenceProcessor {
+ @Override
+ public boolean process(@NotNull PsiReference reference, @NotNull JavaCallHierarchyData data) {
+ PsiClass originalClass = data.getOriginalClass();
+ PsiMethod method = data.getMethod();
+ Set<PsiMethod> methodsToFind = data.getMethodsToFind();
+ PsiMethod methodToFind = data.getMethodToFind();
+ PsiClassType originalType = data.getOriginalType();
+ Map<PsiMember, NodeDescriptor> methodToDescriptorMap = data.getResultMap();
+ Project myProject = data.getProject();
+
+ if (reference instanceof PsiReferenceExpression) {
+ final PsiExpression qualifier = ((PsiReferenceExpression)reference).getQualifierExpression();
+ if (qualifier instanceof PsiSuperExpression) { // filter super.foo() call inside foo() and similar cases (bug 8411)
+ final PsiClass superClass = PsiUtil.resolveClassInType(qualifier.getType());
+ if (superClass == null || originalClass.isInheritor(superClass, true)) {
+ return true;
+ }
+ }
+ if (qualifier != null && !methodToFind.hasModifierProperty(PsiModifier.STATIC)) {
+ final PsiType qualifierType = qualifier.getType();
+ if (qualifierType instanceof PsiClassType &&
+ !TypeConversionUtil.isAssignable(qualifierType, originalType) &&
+ methodToFind != method) {
+ final PsiClass psiClass = ((PsiClassType)qualifierType).resolve();
+ if (psiClass != null) {
+ final PsiMethod callee = psiClass.findMethodBySignature(methodToFind, true);
+ if (callee != null && !methodsToFind.contains(callee)) {
+ // skip sibling methods
+ return true;
+ }
+ }
+ }
+ }
+ }
+ else {
+ if (!(reference instanceof PsiElement)) {
+ return true;
+ }
+
+ final PsiElement parent = ((PsiElement)reference).getParent();
+ if (parent instanceof PsiNewExpression) {
+ if (((PsiNewExpression)parent).getClassReference() != reference) {
+ return true;
+ }
+ }
+ else if (parent instanceof PsiAnonymousClass) {
+ if (((PsiAnonymousClass)parent).getBaseClassReference() != reference) {
+ return true;
+ }
+ }
+ else {
+ return true;
+ }
+ }
+
+ final PsiElement element = reference.getElement();
+ final PsiMember key = CallHierarchyNodeDescriptor.getEnclosingElement(element);
+
+ synchronized (methodToDescriptorMap) {
+ CallHierarchyNodeDescriptor d = (CallHierarchyNodeDescriptor)methodToDescriptorMap.get(key);
+ if (d == null) {
+ d = new CallHierarchyNodeDescriptor(myProject, (CallHierarchyNodeDescriptor)data.getNodeDescriptor(), element, false, true);
+ methodToDescriptorMap.put(key, d);
+ }
+ else if (!d.hasReference(reference)) {
+ d.incrementUsageCount();
+ }
+ d.addReference(reference);
+ }
+ return false;
+ }
+}
diff --git a/java/java-impl/src/com/intellij/ide/projectView/actions/MarkGeneratedSourceRootAction.java b/java/java-impl/src/com/intellij/ide/projectView/actions/MarkGeneratedSourceRootAction.java
new file mode 100644
index 0000000..e56a432
--- /dev/null
+++ b/java/java-impl/src/com/intellij/ide/projectView/actions/MarkGeneratedSourceRootAction.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.ide.projectView.actions;
+
+import com.intellij.icons.AllIcons;
+import com.intellij.openapi.actionSystem.Presentation;
+import com.intellij.openapi.module.JavaModuleType;
+import com.intellij.openapi.module.Module;
+import com.intellij.openapi.module.ModuleType;
+import com.intellij.openapi.roots.ContentEntry;
+import com.intellij.openapi.roots.SourceFolder;
+import com.intellij.openapi.vfs.VirtualFile;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.jps.model.java.JavaModuleSourceRootTypes;
+import org.jetbrains.jps.model.java.JavaSourceRootProperties;
+import org.jetbrains.jps.model.java.JavaSourceRootType;
+import org.jetbrains.jps.model.java.JpsJavaExtensionService;
+
+/**
+ * @author nik
+ */
+public class MarkGeneratedSourceRootAction extends MarkRootActionBase {
+ public MarkGeneratedSourceRootAction() {
+ Presentation presentation = getTemplatePresentation();
+ presentation.setIcon(AllIcons.Modules.SourceRoot);
+ presentation.setText("Generated Sources Root");
+ presentation.setDescription("Mark directory as a source root for generated files");
+ }
+
+ @Override
+ protected boolean isEnabled(@NotNull RootsSelection selection, @NotNull Module module) {
+ if (!(ModuleType.get(module) instanceof JavaModuleType)) return false;
+
+ if (selection.myHaveSelectedFilesUnderSourceRoots) {
+ return false;
+ }
+
+ if (!selection.mySelectedDirectories.isEmpty()) {
+ return true;
+ }
+
+ for (SourceFolder root : selection.mySelectedRoots) {
+ JavaSourceRootProperties properties = root.getJpsElement().getProperties(JavaModuleSourceRootTypes.SOURCES);
+ if (properties != null && !properties.isForGeneratedSources()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ protected void modifyRoots(VirtualFile vFile, ContentEntry entry) {
+ JavaSourceRootProperties properties = JpsJavaExtensionService.getInstance().createSourceRootProperties("", true);
+ entry.addSourceFolder(vFile, JavaSourceRootType.SOURCE, properties);
+ }
+}
diff --git a/java/java-impl/src/com/intellij/ide/projectView/actions/UnmarkGeneratedSourceRootAction.java b/java/java-impl/src/com/intellij/ide/projectView/actions/UnmarkGeneratedSourceRootAction.java
new file mode 100644
index 0000000..0af8706
--- /dev/null
+++ b/java/java-impl/src/com/intellij/ide/projectView/actions/UnmarkGeneratedSourceRootAction.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.ide.projectView.actions;
+
+import com.intellij.icons.AllIcons;
+import com.intellij.openapi.actionSystem.Presentation;
+import com.intellij.openapi.module.Module;
+import com.intellij.openapi.roots.ContentEntry;
+import com.intellij.openapi.roots.SourceFolder;
+import com.intellij.openapi.vfs.VirtualFile;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.jps.model.java.JavaModuleSourceRootTypes;
+import org.jetbrains.jps.model.java.JavaSourceRootProperties;
+import org.jetbrains.jps.model.java.JavaSourceRootType;
+
+/**
+ * @author nik
+ */
+public class UnmarkGeneratedSourceRootAction extends MarkRootActionBase {
+ public UnmarkGeneratedSourceRootAction() {
+ Presentation presentation = getTemplatePresentation();
+ presentation.setIcon(AllIcons.Modules.SourceRoot);
+ presentation.setText("Unmark Generated Sources Root");
+ presentation.setDescription("Mark directory as an ordinary source root");
+ }
+
+ @Override
+ protected boolean isEnabled(@NotNull RootsSelection selection, @NotNull Module module) {
+ for (SourceFolder root : selection.mySelectedRoots) {
+ JavaSourceRootProperties properties = root.getJpsElement().getProperties(JavaModuleSourceRootTypes.SOURCES);
+ if (properties != null && properties.isForGeneratedSources()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ protected void modifyRoots(VirtualFile vFile, ContentEntry entry) {
+ entry.addSourceFolder(vFile, JavaSourceRootType.SOURCE);
+ }
+}
diff --git a/java/java-impl/src/com/intellij/javadoc/JavadocConfiguration.java b/java/java-impl/src/com/intellij/javadoc/JavadocConfiguration.java
index bf58e0f..fe598e3 100644
--- a/java/java-impl/src/com/intellij/javadoc/JavadocConfiguration.java
+++ b/java/java-impl/src/com/intellij/javadoc/JavadocConfiguration.java
@@ -30,6 +30,7 @@
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleUtil;
+import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.projectRoots.JavaSdk;
@@ -57,6 +58,7 @@
import java.io.PrintWriter;
import java.util.Collection;
import java.util.List;
+import java.util.Set;
/**
* @author Eugene Zhuravlev
@@ -228,13 +230,24 @@
parameters.addParametersString(OTHER_OPTIONS);
+ final Set<Module> modules = new HashSet<Module>();
+ myGenerationOptions.accept(new PsiRecursiveElementWalkingVisitor() {
+ @Override
+ public void visitFile(PsiFile file) {
+ final Module module = ModuleUtilCore.findModuleForPsiElement(file);
+ if (module != null) {
+ modules.add(module);
+ }
+ }
+ });
final PathsList classPath;
+ final OrderEnumerator orderEnumerator = ProjectRootManager.getInstance(myProject).orderEntries(modules);
if (jdk.getSdkType() instanceof JavaSdk) {
- classPath = OrderEnumerator.orderEntries(myProject).withoutSdk().withoutModuleSourceEntries().getPathsList();
+ classPath = orderEnumerator.withoutSdk().withoutModuleSourceEntries().getPathsList();
}
else {
//libraries are included into jdk
- classPath = OrderEnumerator.orderEntries(myProject).withoutModuleSourceEntries().getPathsList();
+ classPath = orderEnumerator.withoutModuleSourceEntries().getPathsList();
}
final String classPathString = classPath.getPathsString();
if (classPathString.length() > 0) {
diff --git a/java/java-impl/src/com/intellij/openapi/roots/JavaGeneratedSourcesFilter.java b/java/java-impl/src/com/intellij/openapi/roots/JavaGeneratedSourcesFilter.java
new file mode 100644
index 0000000..89e121e
--- /dev/null
+++ b/java/java-impl/src/com/intellij/openapi/roots/JavaGeneratedSourcesFilter.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.openapi.roots;
+
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.vfs.VirtualFile;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author nik
+ */
+public class JavaGeneratedSourcesFilter extends GeneratedSourcesFilter {
+ @Override
+ public boolean isGeneratedSource(@NotNull VirtualFile file, @NotNull Project project) {
+ return JavaProjectRootsUtil.isInGeneratedCode(file, project);
+ }
+}
diff --git a/java/java-impl/src/com/intellij/openapi/roots/JavaProjectRootsUtil.java b/java/java-impl/src/com/intellij/openapi/roots/JavaProjectRootsUtil.java
index 6a04def..cecab4e 100644
--- a/java/java-impl/src/com/intellij/openapi/roots/JavaProjectRootsUtil.java
+++ b/java/java-impl/src/com/intellij/openapi/roots/JavaProjectRootsUtil.java
@@ -3,7 +3,6 @@
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.roots.impl.SourceFolderImpl;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiCodeFragment;
import com.intellij.psi.PsiFile;
@@ -39,8 +38,7 @@
for (Module module : ModuleManager.getInstance(project).getModules()) {
for (ContentEntry entry : ModuleRootManager.getInstance(module).getContentEntries()) {
for (SourceFolder sourceFolder : entry.getSourceFolders(JavaModuleSourceRootTypes.SOURCES)) {
- JavaSourceRootProperties properties = (JavaSourceRootProperties)((SourceFolderImpl)sourceFolder).getJpsElement().getProperties();
- if (!properties.isForGeneratedSources()) {
+ if (!isForGeneratedSources(sourceFolder)) {
ContainerUtil.addIfNotNull(roots, sourceFolder.getFile());
}
}
@@ -48,4 +46,27 @@
}
return roots;
}
+
+ private static boolean isForGeneratedSources(SourceFolder sourceFolder) {
+ JavaSourceRootProperties properties = sourceFolder.getJpsElement().getProperties(JavaModuleSourceRootTypes.SOURCES);
+ return properties != null && properties.isForGeneratedSources();
+ }
+
+ public static boolean isInGeneratedCode(@NotNull VirtualFile file, @NotNull Project project) {
+ ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
+ Module module = fileIndex.getModuleForFile(file);
+ if (module == null) return false;
+
+ VirtualFile sourceRoot = fileIndex.getSourceRootForFile(file);
+ if (sourceRoot == null) return false;
+
+ for (ContentEntry entry : ModuleRootManager.getInstance(module).getContentEntries()) {
+ for (SourceFolder folder : entry.getSourceFolders()) {
+ if (sourceRoot.equals(folder.getFile())) {
+ return isForGeneratedSources(folder);
+ }
+ }
+ }
+ return false;
+ }
}
diff --git a/java/java-impl/src/com/intellij/psi/impl/JavaPsiImplementationHelperImpl.java b/java/java-impl/src/com/intellij/psi/impl/JavaPsiImplementationHelperImpl.java
index d720a01e..ab62895 100644
--- a/java/java-impl/src/com/intellij/psi/impl/JavaPsiImplementationHelperImpl.java
+++ b/java/java-impl/src/com/intellij/psi/impl/JavaPsiImplementationHelperImpl.java
@@ -40,10 +40,12 @@
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
+import com.intellij.util.containers.ContainerUtil;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import java.util.Collections;
import java.util.List;
import java.util.Properties;
import java.util.Set;
@@ -115,19 +117,22 @@
final VirtualFile vFile = clsFile.getContainingFile().getVirtualFile();
ProjectFileIndex projectFileIndex = ProjectFileIndex.SERVICE.getInstance(clsFile.getProject());
- final List<OrderEntry> orderEntries = projectFileIndex.getOrderEntriesForFile(vFile);
- for (OrderEntry orderEntry : orderEntries) {
- VirtualFile[] files = orderEntry.getFiles(OrderRootType.SOURCES);
- for (VirtualFile file : files) {
- VirtualFile source = file.findFileByRelativePath(relativeFilePath);
- if (source != null) {
- PsiFile psiSource = clsFile.getManager().findFile(source);
- if (psiSource instanceof PsiClassOwner) {
- return psiSource;
- }
+ final Set<VirtualFile> sourceRoots = ContainerUtil.newLinkedHashSet();
+ for (OrderEntry orderEntry : projectFileIndex.getOrderEntriesForFile(vFile)) {
+ if (orderEntry instanceof LibraryOrSdkOrderEntry) {
+ Collections.addAll(sourceRoots, orderEntry.getFiles(OrderRootType.SOURCES));
+ }
+ }
+ for (VirtualFile root : sourceRoots) {
+ VirtualFile source = root.findFileByRelativePath(relativeFilePath);
+ if (source != null) {
+ PsiFile psiSource = clsFile.getManager().findFile(source);
+ if (psiSource instanceof PsiClassOwner) {
+ return psiSource;
}
}
}
+
return clsFile;
}
diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaReferenceAdjuster.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaReferenceAdjuster.java
index 446a6a2..c069767 100644
--- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaReferenceAdjuster.java
+++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaReferenceAdjuster.java
@@ -133,8 +133,13 @@
PsiJavaCodeReferenceElement ref = (PsiJavaCodeReferenceElement)element.getPsi();
PsiElement qualifier = ref.getQualifier();
- if (qualifier instanceof PsiJavaCodeReferenceElement && PsiTreeUtil.getChildOfType(qualifier, PsiAnnotation.class) != null) {
- return true;
+ if (qualifier instanceof PsiJavaCodeReferenceElement) {
+ if (((PsiJavaCodeReferenceElement)qualifier).resolve() instanceof PsiPackage) {
+ return false;
+ }
+ if (PsiTreeUtil.getChildOfType(qualifier, PsiAnnotation.class) != null) {
+ return true;
+ }
}
PsiModifierList modifierList = PsiImplUtil.findNeighbourModifierList(ref);
diff --git a/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java b/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java
index 271e832..4ec3a13 100644
--- a/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java
+++ b/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java
@@ -954,6 +954,7 @@
final PsiElement parent = expr1.getUserData(ElementToWorkOn.PARENT);
final RangeMarker rangeMarker = expr1.getUserData(ElementToWorkOn.TEXT_RANGE);
+ LOG.assertTrue(parent != null, expr1);
return parent.replace(createReplacement(ref.getText(), project, prefix, suffix, parent, rangeMarker, new int[1]));
}
}
diff --git a/java/java-impl/src/com/intellij/refactoring/invertBoolean/InvertBooleanHandler.java b/java/java-impl/src/com/intellij/refactoring/invertBoolean/InvertBooleanHandler.java
index 3cc473a..be8cab8 100644
--- a/java/java-impl/src/com/intellij/refactoring/invertBoolean/InvertBooleanHandler.java
+++ b/java/java-impl/src/com/intellij/refactoring/invertBoolean/InvertBooleanHandler.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 @@
import com.intellij.ide.util.SuperMethodWarningUtil;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
-import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.ScrollType;
import com.intellij.openapi.project.Project;
@@ -70,8 +69,13 @@
}
public void invoke(@NotNull Project project, @NotNull PsiElement[] elements, @NotNull DataContext dataContext) {
- if (elements.length == 1 && elements[0] instanceof PsiMethod) {
- invoke((PsiMethod)elements[0], project, null);
+ if (elements.length == 1) {
+ if (elements[0] instanceof PsiMethod) {
+ invoke((PsiMethod)elements[0], project, null);
+ }
+ else if (elements[0] instanceof PsiVariable) {
+ invoke((PsiVariable)elements[0], project, null);
+ }
}
}
diff --git a/java/java-impl/src/com/intellij/slicer/SliceForwardUtil.java b/java/java-impl/src/com/intellij/slicer/SliceForwardUtil.java
index 7374d11..254498e 100644
--- a/java/java-impl/src/com/intellij/slicer/SliceForwardUtil.java
+++ b/java/java-impl/src/com/intellij/slicer/SliceForwardUtil.java
@@ -23,7 +23,7 @@
import com.intellij.psi.search.searches.ReferencesSearch;
import com.intellij.psi.util.MethodSignatureUtil;
import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.util.ArrayUtil;
+import com.intellij.util.ArrayUtilRt;
import com.intellij.util.Processor;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;
@@ -242,7 +242,7 @@
//method call
else if (parent instanceof PsiExpressionList && parent.getParent() instanceof PsiCallExpression) {
PsiExpression[] expressions = ((PsiExpressionList)parent).getExpressions();
- int index = ArrayUtil.find(expressions, element);
+ int index = ArrayUtilRt.find(expressions, element);
PsiCallExpression methodCall = (PsiCallExpression)parent.getParent();
JavaResolveResult result = methodCall.resolveMethodGenerics();
PsiMethod method = (PsiMethod)result.getElement();
diff --git a/java/java-impl/src/com/intellij/spi/psi/SPIClassProviderReferenceElement.java b/java/java-impl/src/com/intellij/spi/psi/SPIClassProviderReferenceElement.java
index 7d9fc02..1563ada 100644
--- a/java/java-impl/src/com/intellij/spi/psi/SPIClassProviderReferenceElement.java
+++ b/java/java-impl/src/com/intellij/spi/psi/SPIClassProviderReferenceElement.java
@@ -45,11 +45,13 @@
ClassInheritorsSearch.search(superProvider).forEach(new Processor<PsiClass>() {
@Override
public boolean process(PsiClass psiClass) {
- final String jvmClassName = ClassUtil.getJVMClassName(psiClass);
- if (jvmClassName != null) {
- result.add(LookupElementBuilder.create(psiClass, jvmClassName));
+ if (!psiClass.hasModifierProperty(PsiModifier.ABSTRACT)) {
+ final String jvmClassName = ClassUtil.getJVMClassName(psiClass);
+ if (jvmClassName != null) {
+ result.add(LookupElementBuilder.create(psiClass, jvmClassName));
+ }
}
- return false;
+ return true;
}
});
return ArrayUtil.toObjectArray(result);
diff --git a/java/java-impl/src/com/intellij/usageView/UsageContextDataflowToPanel.java b/java/java-impl/src/com/intellij/usageView/UsageContextDataflowToPanel.java
index b097a8a..de31282 100644
--- a/java/java-impl/src/com/intellij/usageView/UsageContextDataflowToPanel.java
+++ b/java/java-impl/src/com/intellij/usageView/UsageContextDataflowToPanel.java
@@ -84,7 +84,7 @@
public void updateLayoutLater(@Nullable final List<UsageInfo> infos) {
if (infos == null) {
removeAll();
- JComponent titleComp = new JLabel(UsageViewBundle.message("select.the.usage.to.preview"));
+ JComponent titleComp = new JLabel(UsageViewBundle.message("select.the.usage.to.preview"), SwingConstants.CENTER);
add(titleComp, BorderLayout.CENTER);
revalidate();
}
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 960e618..86f57a4 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
@@ -27,6 +27,7 @@
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiManager;
import com.intellij.psi.PsiPackage;
+import com.intellij.usageView.UsageViewBundle;
import com.intellij.usages.UsageGroup;
import com.intellij.usages.UsageView;
import org.jetbrains.annotations.NotNull;
@@ -51,6 +52,11 @@
return super.getGroupForFile(dir);
}
+ @Override
+ public String getActionTitle() {
+ return UsageViewBundle.message("action.group.by.package");
+ }
+
private class PackageGroup implements UsageGroup, TypeSafeDataProvider {
private final PsiPackage myPackage;
private Icon myIcon;
diff --git a/java/java-psi-api/src/com/intellij/psi/GenericsUtil.java b/java/java-psi-api/src/com/intellij/psi/GenericsUtil.java
index 5ef2b8f..d8cdf47 100644
--- a/java/java-psi-api/src/com/intellij/psi/GenericsUtil.java
+++ b/java/java-psi-api/src/com/intellij/psi/GenericsUtil.java
@@ -270,16 +270,13 @@
continue;
}
final PsiType extendsBound = ((PsiWildcardType)substituted).getExtendsBound();
- if (Comparing.equal(TypeConversionUtil.erasure(extendsType), TypeConversionUtil.erasure(extendsBound))) {
- if (extendsBound instanceof PsiClassType) {
- if (acceptExtendsBound((PsiClassType)extendsBound, 0)) continue;
- } else if (extendsBound instanceof PsiIntersectionType) {
- for (PsiType psiType : ((PsiIntersectionType)extendsBound).getConjuncts()) {
- if (psiType instanceof PsiClassType) {
- if (acceptExtendsBound((PsiClassType)psiType, 0)) continue nextTypeParam;
- }
- }
- }
+ if (acceptExtendsBound(extendsType, extendsBound)) {
+ continue nextTypeParam;
+ }
+ }
+ else if (substituted instanceof PsiIntersectionType) {
+ for (PsiType extendsBound : ((PsiIntersectionType)substituted).getConjuncts()) {
+ if (acceptExtendsBound(extendsType, extendsBound)) continue nextTypeParam;
}
}
if (extendsType != null && !TypeConversionUtil.isAssignable(extendsType, substituted, allowUncheckedConversion)) {
@@ -290,6 +287,22 @@
return null;
}
+ public static boolean acceptExtendsBound(PsiType extendsType, PsiType extendsBound) {
+ if (Comparing.equal(TypeConversionUtil.erasure(extendsType), TypeConversionUtil.erasure(extendsBound))) {
+ if (extendsBound instanceof PsiClassType) {
+ if (acceptExtendsBound((PsiClassType)extendsBound, 0)) return true;
+ }
+ else if (extendsBound instanceof PsiIntersectionType) {
+ for (PsiType psiType : ((PsiIntersectionType)extendsBound).getConjuncts()) {
+ if (psiType instanceof PsiClassType) {
+ if (acceptExtendsBound((PsiClassType)psiType, 0)) return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
private static boolean acceptExtendsBound(PsiClassType extendsBound, int depth) {
PsiType[] parameters = extendsBound.getParameters();
if (parameters.length == 1) {
@@ -303,6 +316,13 @@
if (bound instanceof PsiClassType && TypeConversionUtil.erasure(bound).equals(TypeConversionUtil.erasure(extendsBound))) {
return acceptExtendsBound((PsiClassType)bound, depth + 1);
}
+ if (bound instanceof PsiIntersectionType) {
+ for (PsiType extendsType : ((PsiIntersectionType)bound).getConjuncts()) {
+ if (acceptExtendsBound(extendsBound, extendsType)) {
+ return true;
+ }
+ }
+ }
}
}
return false;
diff --git a/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceUtil.java b/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceUtil.java
index 9bbb84e..f5f0bf9 100644
--- a/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceUtil.java
+++ b/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceUtil.java
@@ -18,6 +18,7 @@
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.pom.java.LanguageLevel;
+import com.intellij.psi.infos.MethodCandidateInfo;
import com.intellij.psi.util.*;
import com.intellij.util.Function;
import com.sun.tools.javac.code.Kinds;
@@ -163,6 +164,10 @@
public static boolean isAcceptable(@Nullable final PsiMethodReferenceExpression methodReferenceExpression, PsiType left) {
if (methodReferenceExpression == null) return false;
+ final PsiElement argsList = PsiTreeUtil.getParentOfType(methodReferenceExpression, PsiExpressionList.class);
+ if (MethodCandidateInfo.ourOverloadGuard.currentStack().contains(argsList)) {
+ if (!methodReferenceExpression.isExact()) return true;
+ }
if (left instanceof PsiIntersectionType) {
for (PsiType conjunct : ((PsiIntersectionType)left).getConjuncts()) {
if (isAcceptable(methodReferenceExpression, conjunct)) return true;
diff --git a/java/java-psi-api/src/com/intellij/psi/infos/MethodCandidateInfo.java b/java/java-psi-api/src/com/intellij/psi/infos/MethodCandidateInfo.java
index 3a0bfdd..8e4a130 100644
--- a/java/java-psi-api/src/com/intellij/psi/infos/MethodCandidateInfo.java
+++ b/java/java-psi-api/src/com/intellij/psi/infos/MethodCandidateInfo.java
@@ -18,8 +18,10 @@
import com.intellij.openapi.project.Project;
import com.intellij.openapi.projectRoots.JavaSdkVersion;
import com.intellij.openapi.projectRoots.JavaVersionService;
+import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.RecursionGuard;
+import com.intellij.openapi.util.RecursionManager;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.*;
@@ -37,6 +39,7 @@
* @author ik, dsl
*/
public class MethodCandidateInfo extends CandidateInfo{
+ public static final RecursionGuard ourOverloadGuard = RecursionManager.createGuard("overload.guard");
public static final ThreadLocal<Map<PsiElement, Pair<PsiMethod, PsiSubstitutor>>> CURRENT_CANDIDATE = new ThreadLocal<Map<PsiElement, Pair<PsiMethod, PsiSubstitutor>>>();
@ApplicabilityLevelConstant private int myApplicabilityLevel = 0;
private final PsiElement myArgumentList;
@@ -95,6 +98,20 @@
return myApplicabilityLevel;
}
+ @ApplicabilityLevelConstant
+ public int getPertinentApplicabilityLevel() {
+ final PsiMethod method = getElement();
+ if (method != null && method.hasTypeParameters() || myArgumentList == null || !PsiUtil.isLanguageLevel8OrHigher(myArgumentList)) {
+ return getApplicabilityLevel();
+ }
+ return ourOverloadGuard.doPreventingRecursion(myArgumentList, false, new Computable<Integer>() {
+ @Override
+ public Integer compute() {
+ return getApplicabilityLevelInner();
+ }
+ });
+ }
+
public PsiSubstitutor getSiteSubstitutor() {
return super.getSubstitutor();
}
diff --git a/java/java-psi-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java b/java/java-psi-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java
index ea5a668..4a99129 100644
--- a/java/java-psi-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java
+++ b/java/java-psi-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java
@@ -409,7 +409,8 @@
private static PsiDocComment getDocComment(final PsiDocCommentOwner docOwner) {
PsiElement navElement = docOwner.getNavigationElement();
if (!(navElement instanceof PsiDocCommentOwner)) {
- throw new AssertionError("Wrong navElement: " + navElement + "; original = " + docOwner + " of class " + docOwner.getClass());
+ LOG.info("Wrong navElement: " + navElement + "; original = " + docOwner + " of class " + docOwner.getClass());
+ return null;
}
PsiDocComment comment = ((PsiDocCommentOwner)navElement).getDocComment();
if (comment == null) { //check for non-normalized fields
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiElementFactoryImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiElementFactoryImpl.java
index 5b659f0..e87fbe3 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiElementFactoryImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiElementFactoryImpl.java
@@ -49,7 +49,6 @@
private PsiClass myArrayClass15;
private final ConcurrentHashMap<GlobalSearchScope, PsiClassType> myCachedObjectType = new ConcurrentHashMap<GlobalSearchScope, PsiClassType>();
-
public PsiElementFactoryImpl(final PsiManagerEx manager) {
super(manager);
manager.registerRunnableToRunOnChange(new Runnable() {
@@ -66,14 +65,14 @@
if (!languageLevel.isAtLeast(LanguageLevel.JDK_1_5)) {
if (myArrayClass == null) {
@NonNls final String body = "public class __Array__{\n public final int length;\n public Object clone() {}\n}";
- myArrayClass = createClassFromText(body, null).getInnerClasses()[0];
+ myArrayClass = ((PsiExtensibleClass)createClassFromText(body, null)).getOwnInnerClasses().get(0);
}
return myArrayClass;
}
else {
if (myArrayClass15 == null) {
@NonNls final String body = "public class __Array__<T>{\n public final int length;\n public T[] clone() {}\n}";
- myArrayClass15 = createClassFromText(body, null).getInnerClasses()[0];
+ myArrayClass15 = ((PsiExtensibleClass)createClassFromText(body, null)).getOwnInnerClasses().get(0);
}
return myArrayClass15;
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiImplUtil.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiImplUtil.java
index 365c5e66..48c9d63 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiImplUtil.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiImplUtil.java
@@ -345,7 +345,6 @@
if (annotationType instanceof PsiClass) {
return findApplicableTarget((PsiClass)annotationType, types);
}
- if (annotationType == null) return null;
}
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/ProcessCandidateParameterTypeInferencePolicy.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/ProcessCandidateParameterTypeInferencePolicy.java
index e88fca2..96b6f4b 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/ProcessCandidateParameterTypeInferencePolicy.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/ProcessCandidateParameterTypeInferencePolicy.java
@@ -109,10 +109,9 @@
return substitutor.substitute(finalParameter.getType());
}
});
- PsiResolveHelperImpl resolveHelper = (PsiResolveHelperImpl)JavaPsiFacade.getInstance(method.getProject()).getResolveHelper();
final LanguageLevel languageLevel = PsiUtil.getLanguageLevel(finalParameter);
final Pair<PsiType, ConstraintType> constraint =
- ((PsiOldInferenceHelper)resolveHelper.getInferenceHelper(languageLevel)).getSubstitutionForTypeParameterConstraint(typeParameter, innerReturnType, type, false, languageLevel);
+ new PsiOldInferenceHelper(element.getManager()).getSubstitutionForTypeParameterConstraint(typeParameter, innerReturnType, type, false, languageLevel);
if (constraint != null) return constraint;
}
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java
index 27a949b..76fc67d 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java
@@ -28,7 +28,6 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import java.io.Serializable;
import java.util.*;
/**
@@ -70,16 +69,15 @@
}
public InferenceSession(PsiTypeParameter[] typeParams,
- PsiParameter[] parameters,
- PsiExpression[] args,
PsiSubstitutor siteSubstitutor,
- PsiElement parent,
PsiManager manager) {
myManager = manager;
mySiteSubstitutor = siteSubstitutor;
initBounds(typeParams);
+ }
+ public void initExpressionConstraints(PsiParameter[] parameters, PsiExpression[] args, PsiElement parent) {
final Pair<PsiMethod, PsiCallExpression> pair = getPair(parent);
if (parameters.length > 0) {
for (int i = 0; i < args.length; i++) {
@@ -274,32 +272,7 @@
if (!PsiType.VOID.equals(returnType) && returnType != null) {
PsiType targetType = PsiTypesUtil.getExpectedTypeByParent(context);
if (targetType == null) {
- final PsiElement parent = PsiUtil.skipParenthesizedExprUp(context.getParent());
- if (parent instanceof PsiExpressionList) {
- final PsiElement gParent = parent.getParent();
- if (gParent instanceof PsiCallExpression) {
- final PsiExpressionList argumentList = ((PsiCallExpression)gParent).getArgumentList();
- if (argumentList != null) {
- final Pair<PsiMethod, PsiSubstitutor> pair = MethodCandidateInfo.getCurrentMethod(argumentList);
- final JavaResolveResult resolveResult = pair == null ? ((PsiCallExpression)gParent).resolveMethodGenerics() : null;
- final PsiElement parentMethod = pair != null ? pair.first : resolveResult.getElement();
- if (parentMethod instanceof PsiMethod) {
- final PsiParameter[] parameters = ((PsiMethod)parentMethod).getParameterList().getParameters();
- PsiElement arg = context;
- while (arg.getParent() instanceof PsiParenthesizedExpression) {
- arg = parent.getParent();
- }
- final PsiExpression[] args = argumentList.getExpressions();
- targetType = getParameterType(parameters, args, ArrayUtilRt.find(args, arg), pair != null ? pair.second : resolveResult.getSubstitutor());
- }
- }
- }
- } else if (parent instanceof PsiConditionalExpression) {
- targetType = PsiTypesUtil.getExpectedTypeByParent((PsiExpression)parent);
- }
- else if (parent instanceof PsiLambdaExpression) {
- targetType = LambdaUtil.getFunctionalInterfaceReturnType(((PsiLambdaExpression)parent).getFunctionalInterfaceType());
- }
+ targetType = getTargetType(context);
}
if (targetType != null) {
myConstraints.add(new TypeCompatibilityConstraint(GenericsUtil.eliminateWildcards(targetType, false), PsiImplUtil.normalizeWildcardTypeByPosition(returnType, context)));
@@ -308,6 +281,43 @@
}
}
+ private static PsiType getTargetType(PsiExpression context) {
+ final PsiElement parent = PsiUtil.skipParenthesizedExprUp(context.getParent());
+ if (parent instanceof PsiExpressionList) {
+ final PsiElement gParent = parent.getParent();
+ if (gParent instanceof PsiCallExpression) {
+ final PsiExpressionList argumentList = ((PsiCallExpression)gParent).getArgumentList();
+ if (argumentList != null) {
+ final Pair<PsiMethod, PsiSubstitutor> pair = MethodCandidateInfo.getCurrentMethod(argumentList);
+ final JavaResolveResult resolveResult = pair == null ? ((PsiCallExpression)gParent).resolveMethodGenerics() : null;
+ final PsiElement parentMethod = pair != null ? pair.first : resolveResult.getElement();
+ if (parentMethod instanceof PsiMethod) {
+ final PsiParameter[] parameters = ((PsiMethod)parentMethod).getParameterList().getParameters();
+ if (parameters.length == 0) return null;
+ PsiElement arg = context;
+ while (arg.getParent() instanceof PsiParenthesizedExpression) {
+ arg = arg.getParent();
+ }
+ final PsiExpression[] args = argumentList.getExpressions();
+ final int i = ArrayUtilRt.find(args, arg);
+ if (i < 0) return null;
+ return getParameterType(parameters, args, i, pair != null ? pair.second : resolveResult.getSubstitutor());
+ }
+ }
+ }
+ } else if (parent instanceof PsiConditionalExpression) {
+ PsiType targetType = PsiTypesUtil.getExpectedTypeByParent((PsiExpression)parent);
+ if (targetType == null) {
+ targetType = getTargetType((PsiExpression)parent);
+ }
+ return targetType;
+ }
+ else if (parent instanceof PsiLambdaExpression) {
+ return LambdaUtil.getFunctionalInterfaceReturnType(((PsiLambdaExpression)parent).getFunctionalInterfaceType());
+ }
+ return null;
+ }
+
public InferenceVariable getInferenceVariable(PsiType psiType) {
return getInferenceVariable(psiType, true);
}
@@ -419,16 +429,17 @@
inferenceVariable.setInstantiation(null);
continue;
}
- PsiType bound = null;
- for (PsiType eqBound : eqBounds) {
- if (eqBound == null) continue;
- if (bound != null && !isProperType(eqBound)) continue;
- bound = acceptBoundsWithRecursiveDependencies(typeParameter, eqBound, substitutor);
- }
- if (bound != null) {
- if (bound instanceof PsiCapturedWildcardType && eqBounds.size() > 1) {
- continue;
+ if (eqBounds.size() > 1) {
+ for (Iterator<PsiType> iterator = eqBounds.iterator(); iterator.hasNext(); ) {
+ PsiType eqBound = iterator.next();
+ if (PsiUtil.resolveClassInType(eqBound) == typeParameter) {
+ iterator.remove();
+ }
}
+ if (eqBounds.size() > 1) continue;
+ }
+ PsiType bound = eqBounds.isEmpty() ? null : acceptBoundsWithRecursiveDependencies(typeParameter, eqBounds.get(0), substitutor);
+ if (bound != null) {
inferenceVariable.setInstantiation(bound);
} else {
PsiType lub = null;
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/PsiGraphInferenceHelper.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/PsiGraphInferenceHelper.java
index 84c8b7c..ebec24e 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/PsiGraphInferenceHelper.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/PsiGraphInferenceHelper.java
@@ -38,8 +38,8 @@
@NotNull PsiSubstitutor partialSubstitutor,
@Nullable PsiElement parent,
@NotNull ParameterTypeInferencePolicy policy) {
- final InferenceSession inferenceSession =
- new InferenceSession(new PsiTypeParameter[]{typeParameter}, parameters, arguments, partialSubstitutor, parent, myManager);
+ final InferenceSession inferenceSession = new InferenceSession(new PsiTypeParameter[]{typeParameter}, partialSubstitutor, myManager);
+ inferenceSession.initExpressionConstraints(parameters, arguments, parent);
return inferenceSession.infer(parameters, arguments, parent).substitute(typeParameter);
}
@@ -53,8 +53,8 @@
@NotNull ParameterTypeInferencePolicy policy,
@NotNull LanguageLevel languageLevel) {
if (typeParameters.length == 0) return partialSubstitutor;
- final InferenceSession inferenceSession =
- new InferenceSession(typeParameters, parameters, arguments, partialSubstitutor, parent, myManager);
+ final InferenceSession inferenceSession = new InferenceSession(typeParameters, partialSubstitutor, myManager);
+ inferenceSession.initExpressionConstraints(parameters, arguments, parent);
return inferenceSession.infer(parameters, arguments, parent);
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/ExpressionCompatibilityConstraint.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/ExpressionCompatibilityConstraint.java
index 7ef2a72..830fad9 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/ExpressionCompatibilityConstraint.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/ExpressionCompatibilityConstraint.java
@@ -83,11 +83,9 @@
InferenceSession callSession = null;
if (method != null && !method.isConstructor()) {
returnType = method.getReturnType();
- final PsiParameter[] parameters = method.getParameterList().getParameters();
if (returnType != null) {
- callSession = new InferenceSession(method.getTypeParameters(), parameters,
- argumentList.getExpressions(),
- PsiSubstitutor.EMPTY, null, myExpression.getManager());
+ callSession = new InferenceSession(method.getTypeParameters(),
+ PsiSubstitutor.EMPTY, myExpression.getManager());
}
} else if (myExpression instanceof PsiNewExpression) { //default constructor
@@ -97,9 +95,7 @@
if (psiClass instanceof PsiClass) {
returnType = JavaPsiFacade.getElementFactory(argumentList.getProject()).createType((PsiClass)psiClass, PsiSubstitutor.EMPTY);
callSession = new InferenceSession(((PsiClass)psiClass).getTypeParameters(),
- PsiParameter.EMPTY_ARRAY,
- argumentList.getExpressions(),
- PsiSubstitutor.EMPTY, null, myExpression.getManager());
+ PsiSubstitutor.EMPTY, myExpression.getManager());
}
}
}
@@ -118,7 +114,9 @@
else {
returnType = callSubstitutor.substitute(returnType);
}
- constraints.add(new TypeCompatibilityConstraint(GenericsUtil.eliminateWildcards(myT, false), returnType));
+ if (!TypeConversionUtil.isAssignable(myT, returnType)) {
+ constraints.add(new TypeCompatibilityConstraint(GenericsUtil.eliminateWildcards(myT, false), returnType));
+ }
}
}
return true;
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/SubtypingConstraint.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/SubtypingConstraint.java
index cfda8a0..d519c74 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/SubtypingConstraint.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/SubtypingConstraint.java
@@ -114,6 +114,11 @@
if (tBound.equalsToText(CommonClassNames.JAVA_LANG_OBJECT)) {
return true;
}
+
+ if (myS instanceof PsiCapturedWildcardType) {
+ myS = ((PsiCapturedWildcardType)myS).getWildcard();
+ }
+
if (myS instanceof PsiWildcardType) {
final PsiType sBound = ((PsiWildcardType)myS).getBound();
if (sBound != null && ((PsiWildcardType)myS).isExtends()) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodReferenceExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodReferenceExpressionImpl.java
index eb4d501..9d0d23a 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodReferenceExpressionImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodReferenceExpressionImpl.java
@@ -84,25 +84,41 @@
}
else if (isConstructor()) {
methods = containingClass.getConstructors();
- if (methods.length == 0) { //default constructor
- return containingClass;
- }
}
if (methods != null) {
PsiMethod psiMethod = null;
- for (PsiMethod method : methods) {
- if (PsiUtil.isAccessible(method, this, null)) {
- if (psiMethod != null) return null;
- psiMethod = method;
+ if (methods.length > 0) {
+ for (PsiMethod method : methods) {
+ if (PsiUtil.isAccessible(method, this, null)) {
+ if (psiMethod != null) return null;
+ psiMethod = method;
+ }
+ }
+ if (psiMethod == null) return null;
+ if (psiMethod.isVarArgs()) return null;
+ if (psiMethod.getTypeParameters().length > 0) {
+ final PsiReferenceParameterList parameterList = getParameterList();
+ return parameterList != null && parameterList.getTypeParameterElements().length > 0 ? psiMethod : null;
}
}
- if (psiMethod == null) return null;
- if (psiMethod.isVarArgs()) return null;
- if (psiMethod.getTypeParameters().length > 0) {
- final PsiReferenceParameterList parameterList = getParameterList();
- return parameterList != null && parameterList.getTypeParameterElements().length > 0 ? psiMethod : null;
+ if (containingClass.hasTypeParameters()) {
+ final PsiElement qualifier = getQualifier();
+ if (qualifier instanceof PsiTypeElement) {
+ final PsiJavaCodeReferenceElement referenceElement = ((PsiTypeElement)qualifier).getInnermostComponentReferenceElement();
+ if (referenceElement != null) {
+ final PsiReferenceParameterList parameterList = referenceElement.getParameterList();
+ if (parameterList == null || parameterList.getTypeParameterElements().length == 0) {
+ return null;
+ }
+ }
+ } else if (qualifier instanceof PsiReferenceExpression) {
+ final PsiReferenceParameterList parameterList = ((PsiReferenceExpression)qualifier).getParameterList();
+ if (parameterList == null || parameterList.getTypeParameterElements().length == 0) {
+ return null;
+ }
+ }
}
- return psiMethod;
+ return psiMethod == null ? containingClass : psiMethod;
}
}
return null;
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiReferenceExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiReferenceExpressionImpl.java
index 6395749..7f4a7dd 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiReferenceExpressionImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiReferenceExpressionImpl.java
@@ -509,16 +509,13 @@
PsiScopesUtil.resolveAndWalk(filterProcessor, this, null, true);
}
- private static boolean seemsScrambled(PsiClass element) {
- if (!(element instanceof PsiCompiledElement)) {
+ public static boolean seemsScrambled(PsiClass aClass) {
+ if (!(aClass instanceof PsiCompiledElement)) {
return false;
}
- final String qualifiedName = element.getQualifiedName();
- return qualifiedName != null &&
- qualifiedName.length() <= 2 &&
- !qualifiedName.isEmpty() &&
- Character.isLowerCase(qualifiedName.charAt(0));
+ final String name = aClass.getName();
+ return name != null && !name.isEmpty() && name.length() <= 2;
}
@Override
diff --git a/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java b/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java
index 084ad32..2241851 100644
--- a/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java
+++ b/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java
@@ -394,7 +394,7 @@
for (Iterator<CandidateInfo> iterator = conflicts.iterator(); iterator.hasNext();) {
ProgressManager.checkCanceled();
CandidateInfo info = iterator.next();
- final int level = preferVarargs(info);
+ final int level = preferVarargs((MethodCandidateInfo)info);
if (level < maxApplicabilityLevel) {
iterator.remove();
}
@@ -404,10 +404,10 @@
return maxApplicabilityLevel;
}
- private static int preferVarargs(CandidateInfo info) {
- final int level = ((MethodCandidateInfo)info).getApplicabilityLevel();
+ private static int preferVarargs(MethodCandidateInfo info) {
+ final int level = info.getPertinentApplicabilityLevel();
if (level == MethodCandidateInfo.ApplicabilityLevel.FIXED_ARITY) {
- final PsiMethod psiMethod = (PsiMethod)info.getElement();
+ final PsiMethod psiMethod = info.getElement();
if (psiMethod != null && psiMethod.isVarArgs() && JavaVersionService.getInstance().isAtLeast(psiMethod, JavaSdkVersion.JDK_1_7)) {
return level + 1;
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57492.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57492.java
index 03a45cf..b7829da 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57492.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57492.java
@@ -3,7 +3,7 @@
<S extends Number & Comparable<? extends Number>> void baz(A<S> a){}
void bar(A<Long> x, A<Integer> y){
- <error descr="Inferred type 'capture<? extends java.lang.Number & java.lang.Comparable<? extends java.lang.Comparable<?>>>' for type parameter 'S' is not within its bound; should implement 'java.lang.Comparable<? extends java.lang.Number>'">baz(foo(x, y))</error>;
+ baz<error descr="'baz(A<java.lang.Number & java.lang.Comparable<? extends java.lang.Number>>)' in 'A' cannot be applied to '(A<capture<? extends java.lang.Number & java.lang.Comparable<? extends java.lang.Comparable<?>>>>)'">(foo(x, y))</error>;
}
}
@@ -12,6 +12,6 @@
<T extends Number & Comparable<?>, S extends Number & Comparable<? extends T>> void baz(A1<S> a){}
void bar(A1<Long> x, A1<Integer> y){
- <error descr="Inferred type 'capture<? extends java.lang.Number & java.lang.Comparable<? extends java.lang.Comparable<?>>>' for type parameter 'S' is not within its bound; should implement 'java.lang.Comparable<? extends java.lang.Number & java.lang.Comparable<?>>'">baz(foo(x, y))</error>;
+ baz<error descr="'baz(A1<java.lang.Number & java.lang.Comparable<? extends java.lang.Number & java.lang.Comparable<?>>>)' in 'A1' cannot be applied to '(A1<capture<? extends java.lang.Number & java.lang.Comparable<? extends java.lang.Comparable<?>>>>)'">(foo(x, y))</error>;
}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA94011.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA94011.java
index 0dd027c..cf11bfd 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA94011.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA94011.java
@@ -10,7 +10,7 @@
public void test(Set<MyConsumer> set) {
@SuppressWarnings("unchecked")
- <error descr="Incompatible types. Found: 'java.util.Map<Test.Parent,Test.MyConsumer>', required: 'java.util.Map<Test.Parent,Test.MyConsumer<Test.Parent>>'">Map<Parent, MyConsumer<Parent>> map = create(set);</error>
+ Map<Parent, MyConsumer<Parent>> map = <error descr="Inferred type 'T' for type parameter 'T' is not within its bound; should implement 'Test.Consumer<Test.Parent>'">create(set)</error>;
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IntersectionTypes.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IntersectionTypes.java
index 48bb90c..cba83dc 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IntersectionTypes.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IntersectionTypes.java
@@ -128,7 +128,7 @@
class Client {
void f(Date d) {
//this call should be OK
- <warning descr="Unchecked generics array creation for varargs parameter">Maps.asMap</warning>(Maps.entry(fieldName(), "Test"),
+ Maps.asMap(Maps.entry(fieldName(), "Test"),
Maps.entry(fieldName(), 1),
Maps.entry(fieldName(), d));
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/InferenceFromReturnType.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/InferenceFromReturnType.java
index 69fea2d..5f087e1 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/InferenceFromReturnType.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/InferenceFromReturnType.java
@@ -17,11 +17,11 @@
}
private static void <warning descr="Private method 'foo(MyTestDefaultConstructor.I1)' is never used">foo</warning>(I1 i) {System.out.println(i);}
- private static void foo(I2 i) {System.out.println(i);}
+ private static void <warning descr="Private method 'foo(MyTestDefaultConstructor.I2)' is never used">foo</warning>(I2 i) {System.out.println(i);}
private static void <warning descr="Private method 'foo(MyTestDefaultConstructor.I3)' is never used">foo</warning>(I3 i) {System.out.println(i);}
static {
- foo(Foo::new);
+ foo<error descr="Cannot resolve method 'foo(<method reference>)'">(Foo::new)</error>;
}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/MethodTypeParamsInference.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/MethodTypeParamsInference.java
index 11c284f..06e4520 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/MethodTypeParamsInference.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/MethodTypeParamsInference.java
@@ -20,7 +20,7 @@
static void foo(I3 i) {}
static {
- foo(MyTest::m);
+ foo<error descr="Cannot resolve method 'foo(<method reference>)'">(MyTest::m)</error>;
foo<error descr="Ambiguous method call: both 'MyTest.foo(I1)' and 'MyTest.foo(I2)' match">(MyTest::m1)</error>;
}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/RawQualifier.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/RawQualifier.java
index ee1ad6c..67bbac2 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/RawQualifier.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/RawQualifier.java
@@ -39,6 +39,6 @@
static void foo(I3 i) {}
static {
- foo(Foo::new);
+ foo<error descr="Cannot resolve method 'foo(<method reference>)'">(Foo::new)</error>;
}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ReturnTypeSpecific.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ReturnTypeSpecific.java
index 249114c..93ca789 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ReturnTypeSpecific.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ReturnTypeSpecific.java
@@ -62,12 +62,12 @@
System.out.println(i);
}
- private static void m(I3 i) {
+ private static void <warning descr="Private method 'm(MyTest1.I3)' is never used">m</warning>(I3 i) {
System.out.println(i);
}
public static void main(String[] args) {
- m(Foo::new);
+ m<error descr="Ambiguous method call: both 'MyTest1.m(I2)' and 'MyTest1.m(I3)' match">(Foo::new)</error>;
}
}
class MyTest2 {
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/StaticProblems.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/StaticProblems.java
index edaa26b..194eaac 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/StaticProblems.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/StaticProblems.java
@@ -115,10 +115,10 @@
static void call3(I1 s) {}
static void call3(I2 s) {}
static {
- call3(<error descr="Non-static method cannot be referenced from a static context">MyTest2::m1</error>);
- call3(MyTest2::m2);
- call3(MyTest2::m3);
- call3(<error descr="Non-static method cannot be referenced from a static context">MyTest2::m4</error>);
+ call3<error descr="Cannot resolve method 'call3(<method reference>)'">(MyTest2::m1)</error>;
+ call3<error descr="Cannot resolve method 'call3(<method reference>)'">(MyTest2::m2)</error>;
+ call3<error descr="Cannot resolve method 'call3(<method reference>)'">(MyTest2::m3)</error>;
+ call3<error descr="Cannot resolve method 'call3(<method reference>)'">(MyTest2::m4)</error>;
}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createConstructorMatchingSuper/beforeInAnonymous.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createConstructorMatchingSuper/beforeInAnonymous.java
new file mode 100644
index 0000000..9d9e88f
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/createConstructorMatchingSuper/beforeInAnonymous.java
@@ -0,0 +1,13 @@
+// "Create constructor matching super" "false"
+public class Test {
+ private Test() {}
+}
+
+class Foo {
+ {
+ new Test() {
+ Te<caret>st() {
+ }
+ };
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/PrimitiveCastMayChangeValue.java b/java/java-tests/testData/inspection/dataFlow/fixture/PrimitiveCastMayChangeValue.java
new file mode 100644
index 0000000..652f0dc
--- /dev/null
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/PrimitiveCastMayChangeValue.java
@@ -0,0 +1,15 @@
+
+public class BrokenAlignment {
+ private static void foo(long value) {
+ if (value == (byte)value) {
+ System.out.println("1");
+ } else if (value == (short)value) {
+ System.out.println("2");
+ } else if (value == (int)value) {
+ System.out.println("3");
+ } else {
+ System.out.println("4");
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/psi/formatter/java/FormatterOnOffTags.java b/java/java-tests/testData/psi/formatter/java/FormatterOnOffTags.java
index 319b8eb..93e69f1 100644
--- a/java/java-tests/testData/psi/formatter/java/FormatterOnOffTags.java
+++ b/java/java-tests/testData/psi/formatter/java/FormatterOnOffTags.java
@@ -1,6 +1,13 @@
import java.util.*;
public class CollectionTest {
+ /**
+ * Normal JavaDoc, can
+ * be
+ * formatted.
+ * @param args
+ * Arguments.
+ */
public static void main(String[] args) {
int size;
HashSet collection = new HashSet();
@@ -22,4 +29,34 @@
System.out.print(iterator.next() + " ");
}
}
+
+ // @formatter:off
+ /**
+ * And please don't touch this:
+ * @param x
+ * These are my nice comments.
+ * @param y
+ * And yet another one.
+ */
+ public void doSomething(String x, String y) {
+ }
+ // @formatter:on
+
+ /**
+ * It's OK to format this comment.
+ * @param z
+ * Parameter Z.
+ */
+ public void doSomethingElse(String z) {}
+
+ // @formatter:off
+ /**
+ * This comment must be preserved too.
+ * @param i
+ * Parameter I.
+ * @param j
+ * Parameter J.
+ */
+ public void evenMore(int i, int j) {}
+ // @formatter:on
}
diff --git a/java/java-tests/testData/psi/formatter/java/FormatterOnOffTags_after.java b/java/java-tests/testData/psi/formatter/java/FormatterOnOffTags_after.java
index 8e1abcb..01233b3a 100644
--- a/java/java-tests/testData/psi/formatter/java/FormatterOnOffTags_after.java
+++ b/java/java-tests/testData/psi/formatter/java/FormatterOnOffTags_after.java
@@ -1,6 +1,13 @@
import java.util.*;
public class CollectionTest {
+ /**
+ * Normal JavaDoc, can
+ * be
+ * formatted.
+ *
+ * @param args Arguments.
+ */
public static void main(String[] args) {
int size;
HashSet collection = new HashSet();
@@ -22,4 +29,35 @@
System.out.print(iterator.next() + " ");
}
}
+
+ // @formatter:off
+ /**
+ * And please don't touch this:
+ * @param x
+ * These are my nice comments.
+ * @param y
+ * And yet another one.
+ */
+ public void doSomething(String x, String y) {
+ }
+ // @formatter:on
+
+ /**
+ * It's OK to format this comment.
+ *
+ * @param z Parameter Z.
+ */
+ public void doSomethingElse(String z) {
+ }
+
+ // @formatter:off
+ /**
+ * This comment must be preserved too.
+ * @param i
+ * Parameter I.
+ * @param j
+ * Parameter J.
+ */
+ public void evenMore(int i, int j) {}
+ // @formatter:on
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java
index 39ff89a..159759f 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java
@@ -71,7 +71,7 @@
public void testInferenceWithBounds() {
doTest();
}
- public void testInferenceWithSuperBounds() {
+ public void _testInferenceWithSuperBounds() {
doTest();
}
public void testInferenceWithUpperBoundPromotion() {
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/intention/AddImportActionTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/intention/AddImportActionTest.groovy
index 14486f7..b2a4447 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/intention/AddImportActionTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/intention/AddImportActionTest.groovy
@@ -20,23 +20,17 @@
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
public class AddImportActionTest extends LightCodeInsightFixtureTestCase {
- @Override
- protected void tearDown() {
- IdeaTestUtil.setModuleLanguageLevel(myModule, LanguageLevel.HIGHEST)
- super.tearDown()
- }
-
public void testMap15() {
- IdeaTestUtil.setModuleLanguageLevel(myModule, LanguageLevel.JDK_1_5)
- myFixture.configureByText 'a.java', '''\
+ IdeaTestUtil.withLevel(myModule, LanguageLevel.JDK_1_5, {
+ myFixture.configureByText 'a.java', '''\
public class Foo {
void foo() {
Ma<caret>p<> l;
}
}
'''
- importClass()
- myFixture.checkResult '''import java.util.Map;
+ importClass()
+ myFixture.checkResult '''import java.util.Map;
public class Foo {
void foo() {
@@ -44,6 +38,7 @@
}
}
'''
+ })
}
public void testMapLatestLanguageLevel() {
@@ -118,7 +113,6 @@
public void foo(Log<caret> log) {}
}
'''
-
}
public void testAnnotatedImport() {
@@ -167,9 +161,9 @@
Collection<caret> c;
}
'''
- }
+ }
- public void testUnresolvedAnnotatedQualifiedImport() {
+ public void testUnresolvedAnnotatedImport() {
myFixture.configureByText 'a.java', '''
class Test {
@Nullable Collection<caret> c;
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java
index 02dcfc00..30993c0 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java
@@ -122,6 +122,7 @@
}
public void testPreserveNullableOnUncheckedCast() throws Throwable { doTest(); }
+ public void testPrimitiveCastMayChangeValue() throws Throwable { doTest(); }
public void testPassingNullableIntoVararg() throws Throwable { doTest(); }
public void testEqualsImpliesNotNull() throws Throwable { doTest(); }
diff --git a/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java b/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java
index a7c477a..0110fdc 100644
--- a/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java
+++ b/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,6 +25,8 @@
import com.intellij.openapi.application.ex.PathManagerEx;
import com.intellij.openapi.fileTypes.FileTypes;
import com.intellij.openapi.projectRoots.Sdk;
+import com.intellij.openapi.util.ProperTextRange;
+import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
@@ -51,22 +53,31 @@
import java.util.Collections;
import java.util.List;
-/*
- * @author: MYakovlev
- * Date: Oct 17, 2002
- * Time: 7:53:31 PM
+/**
+ * @author MYakovlev
+ * @since Oct 17, 2002
*/
-@SuppressWarnings({"HardCodedStringLiteral"})
public class FindManagerTest extends DaemonAnalyzerTestCase {
- protected VirtualFile[] mySourceDirs;
+ private FindManager myFindManager;
+ private VirtualFile[] mySourceDirs;
- public void testFindString() throws Exception{
- FindManager findManager = FindManager.getInstance(myProject);
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ myFindManager = FindManager.getInstance(myProject);
+ }
+ @Override
+ protected void tearDown() throws Exception {
+ myFindManager = null;
+ super.tearDown();
+ }
+
+ public void testFindString() {
FindModel findModel = FindManagerTestUtils.configureFindModel("done");
String text = "public static class MyClass{\n/*done*/\npublic static void main(){}}";
- FindResult findResult = findManager.findString(text, 0, findModel);
+ FindResult findResult = myFindManager.findString(text, 0, findModel);
assertTrue(findResult.isStringFound());
findModel = new FindModel();
@@ -77,7 +88,7 @@
findModel.setMultipleFiles(false);
findModel.setProjectScope(true);
- findResult = findManager.findString(text, 40, findModel);
+ findResult = myFindManager.findString(text, 40, findModel);
assertFalse(findResult.isStringFound());
findModel = new FindModel();
@@ -89,7 +100,7 @@
findModel.setProjectScope(true);
findModel.setForward(false);
- findResult = findManager.findString(text, 40, findModel);
+ findResult = myFindManager.findString(text, 40, findModel);
assertTrue(findResult.isStringFound());
findModel = new FindModel();
@@ -100,7 +111,7 @@
findModel.setMultipleFiles(false);
findModel.setProjectScope(true);
- findResult = findManager.findString(text, 0, findModel);
+ findResult = myFindManager.findString(text, 0, findModel);
assertTrue(findResult.isStringFound());
findModel = new FindModel();
@@ -112,7 +123,7 @@
findModel.setProjectScope(true);
final FindResult[] findResultArr = new FindResult[1];
- findInNewThread(findModel, findManager, text, 0, findResultArr);
+ findInNewThread(findModel, myFindManager, text, 0, findResultArr);
new WaitFor(30 *1000){
@Override
protected boolean condition() {
@@ -139,9 +150,9 @@
return findThread;
}
- public void testFindUsages() throws Exception{
+ public void testFindUsages() {
initProject("findManager", "src", "src1");
- final String projectDir = (PathManagerEx.getTestDataPath() + "/find/findManager").replace('/', File.separatorChar);
+ String projectDir = FileUtil.toSystemDependentName(PathManagerEx.getTestDataPath() + "/find/findManager");
FindModel findModel = new FindModel();
findModel.setStringToFind("done");
@@ -154,7 +165,6 @@
findModel.setWithSubdirectories(true);
checkFindUsages(12, findModel);
- //findModel = new FindModel();
findModel.setFromCursor(false);
findModel.setGlobal(true);
findModel.setMultipleFiles(true);
@@ -165,13 +175,9 @@
findModel.setWholeWordsOnly(true);
checkFindUsages(5, findModel);
-// findModel.setForward(false);
-// findModel.setCaseSensitive();
-
-
}
- private void checkFindUsages(int expectedResults, FindModel findModel) throws Exception{
+ private void checkFindUsages(int expectedResults, FindModel findModel) {
Collection<UsageInfo> usages = findUsages(findModel);
assertEquals(expectedResults, usages.size());
}
@@ -184,9 +190,8 @@
return result;
}
- public void testFindWholeWordsInProperties() throws Exception {
+ public void testFindWholeWordsInProperties() {
initProject("findInPath", "src");
-
searchProperty("xx.yy");
searchProperty(".yy");
searchProperty("xx.");
@@ -208,22 +213,31 @@
if (!(usages.get(0).getFile() instanceof PsiJavaFile)) {
Collections.swap(usages, 0, 1);
}
- PsiElement element = usages.get(0).getElement();
- //assertTrue(element instanceof PsiJavaFile);
- PsiElement refElement = element.findElementAt(usages.get(0).getRangeInElement().getStartOffset()).getParent();
+
+ PsiElement refElement = getParentFromUsage(usages.get(0));
assertTrue(refElement instanceof PsiLiteralExpression);
assertEquals("xx.yy", ((PsiLiteralExpression)refElement).getValue());
VirtualFile file = mySourceDirs[0].findFileByRelativePath("x/dd.properties");
+ assertNotNull(file);
PropertiesFile propertiesFile = (PropertiesFile)PsiManager.getInstance(myProject).findFile(file);
- element = usages.get(1).getElement();
- //assertTrue(element instanceof PropertiesFile);
- refElement = element.findElementAt(usages.get(1).getRangeInElement().getStartOffset()).getParent();
+ assertNotNull(propertiesFile);
+ refElement = getParentFromUsage(usages.get(1));
assertTrue(refElement instanceof IProperty);
assertSame(propertiesFile.findPropertyByKey("xx.yy"), refElement);
}
- public void testFindInClassHierarchy() throws Exception {
+ private static PsiElement getParentFromUsage(UsageInfo usage) {
+ ProperTextRange range = usage.getRangeInElement();
+ assertNotNull(range);
+ PsiElement element = usage.getElement();
+ assertNotNull(element);
+ PsiElement elementAt = element.findElementAt(range.getStartOffset());
+ assertNotNull(elementAt);
+ return elementAt.getParent();
+ }
+
+ public void testFindInClassHierarchy() {
initProject("findInClassHierarchy", "src");
FindModel findModel = new FindModel();
@@ -244,7 +258,7 @@
public void testDollars() throws Exception {
createFile(myModule, "A.java", "foo foo$ $foo");
createFile(myModule, "A.txt", "foo foo$ $foo");
-
+
FindModel findModel = new FindModel();
findModel.setWholeWordsOnly(true);
findModel.setFromCursor(false);
@@ -260,15 +274,12 @@
findModel.setStringToFind("$foo");
assertSize(2, findUsages(findModel));
-
}
- public void testReplaceRegexp() throws Throwable {
- FindManager findManager = FindManager.getInstance(myProject);
-
+ public void testReplaceRegexp() {
FindModel findModel = new FindModel();
- findModel.setStringToFind("bug(?=here)");
- findModel.setStringToReplace("x$0y");
+ findModel.setStringToFind("bug_(?=here)");
+ findModel.setStringToReplace("x_$0t");
findModel.setWholeWordsOnly(false);
findModel.setFromCursor(false);
findModel.setGlobal(true);
@@ -277,21 +288,19 @@
findModel.setRegularExpressions(true);
findModel.setPromptOnReplace(false);
- findManager.setFindNextModel(null);
- findManager.getFindInFileModel().copyFrom(findModel);
+ myFindManager.setFindNextModel(null);
+ myFindManager.getFindInFileModel().copyFrom(findModel);
- String text = "bughere\n" + "bughere";
+ String text = "bug_here\nbug_here";
configureByText(FileTypes.PLAIN_TEXT, text);
- boolean succ = FindUtil.replace(getProject(), getEditor(), 0, findModel);
- assertTrue(succ);
+ assertTrue(FindUtil.replace(getProject(), getEditor(), 0, findModel));
- assertEquals("xbugyhere\n" + "xbugyhere", getEditor().getDocument().getText());
+ assertEquals("x_bug_there\nx_bug_there", getEditor().getDocument().getText());
}
- public void testReplaceRegexp1() throws Throwable {
- FindManager findManager = FindManager.getInstance(myProject);
+ public void testReplaceRegexp1() {
FindModel findModel = new FindModel();
- findModel.setStringToFind("bug(?=here)");
+ findModel.setStringToFind("bug_(?=here)");
findModel.setStringToReplace("$0");
findModel.setWholeWordsOnly(false);
findModel.setFromCursor(false);
@@ -301,20 +310,17 @@
findModel.setRegularExpressions(true);
findModel.setPromptOnReplace(false);
- findManager.setFindNextModel(null);
- findManager.getFindInFileModel().copyFrom(findModel);
+ myFindManager.setFindNextModel(null);
+ myFindManager.getFindInFileModel().copyFrom(findModel);
- String text = "bughere\n" + "bughere";
+ String text = "bug_here\nbug_here";
configureByText(FileTypes.PLAIN_TEXT, text);
- boolean succ = FindUtil.replace(getProject(), getEditor(), 0, findModel);
- assertTrue(succ);
+ assertTrue(FindUtil.replace(getProject(), getEditor(), 0, findModel));
assertEquals(text, getEditor().getDocument().getText());
}
- public void testReplaceRegexpWithNewLine() throws Throwable {
- FindManager findManager = FindManager.getInstance(myProject);
-
+ public void testReplaceRegexpWithNewLine() {
FindModel findModel = new FindModel();
findModel.setStringToFind("xxx");
findModel.setStringToReplace("xxx\\n");
@@ -326,18 +332,17 @@
findModel.setRegularExpressions(true);
findModel.setPromptOnReplace(false);
- findManager.setFindNextModel(null);
- findManager.getFindInFileModel().copyFrom(findModel);
+ myFindManager.setFindNextModel(null);
+ myFindManager.getFindInFileModel().copyFrom(findModel);
String text = "xxx";
configureByText(FileTypes.PLAIN_TEXT, text);
- boolean succ = FindUtil.replace(getProject(), getEditor(), 0, findModel);
- assertTrue(succ);
+ assertTrue(FindUtil.replace(getProject(), getEditor(), 0, findModel));
assertEquals(text+"\n", getEditor().getDocument().getText());
}
- private void initProject(String folderName, final String... sourceDirs) throws Exception{
+ private void initProject(String folderName, final String... sourceDirs) {
final String testDir = JavaTestUtil.getJavaTestDataPath() + "/find/" + folderName;
ApplicationManager.getApplication().runWriteAction(new Runnable(){
@Override
@@ -345,11 +350,11 @@
try{
mySourceDirs = new VirtualFile[sourceDirs.length];
for (int i = 0; i < sourceDirs.length; i++){
- String sourceDir = sourceDirs[i];
- mySourceDirs[i] = LocalFileSystem.getInstance().refreshAndFindFileByPath(new File(testDir + File.separatorChar + sourceDir).getCanonicalPath().replace(File.separatorChar, '/'));
+ String sourcePath = testDir + "/" + sourceDirs[i];
+ mySourceDirs[i] = LocalFileSystem.getInstance().refreshAndFindFileByPath(FileUtil.toSystemIndependentName(sourcePath));
}
- VirtualFile projectDir = LocalFileSystem.getInstance().refreshAndFindFileByPath(new File(testDir).getCanonicalPath().replace(File.separatorChar, '/'));
+ VirtualFile projectDir = LocalFileSystem.getInstance().refreshAndFindFileByPath(FileUtil.toSystemIndependentName(testDir));
Sdk jdk = IdeaTestUtil.getMockJdk17();
PsiTestUtil.removeAllRoots(myModule, jdk);
PsiTestUtil.addContentRoot(myModule, projectDir);
@@ -364,12 +369,10 @@
});
}
- public void testReplaceAll() throws Throwable {
- FindManager findManager = FindManager.getInstance(myProject);
-
+ public void testReplaceAll() throws FindManager.MalformedReplacementStringException {
FindModel findModel = new FindModel();
String toFind = "xxx";
- String toReplace = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
+ @SuppressWarnings("SpellCheckingInspection") String toReplace = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
findModel.setStringToFind(toFind);
findModel.setStringToReplace(toReplace);
findModel.setWholeWordsOnly(true);
@@ -380,13 +383,14 @@
findModel.setRegularExpressions(false);
findModel.setPromptOnReplace(false);
- findManager.setFindNextModel(null);
- findManager.getFindInFileModel().copyFrom(findModel);
+ myFindManager.setFindNextModel(null);
+ myFindManager.getFindInFileModel().copyFrom(findModel);
String text = StringUtil.repeat(toFind + "\n",6);
configureByText(FileTypes.PLAIN_TEXT, text);
List<Usage> usages = FindUtil.findAll(getProject(), myEditor, findModel);
+ assertNotNull(usages);
for (Usage usage : usages) {
ReplaceInProjectManager.getInstance(getProject()).replaceUsage(usage, findModel, Collections.<Usage>emptySet(), false);
}
@@ -394,9 +398,10 @@
assertEquals(newText, getEditor().getDocument().getText());
}
- public void testFindInFileUnderLibraryUnderProject() throws Exception {
+ public void testFindInFileUnderLibraryUnderProject() {
initProject("libUnderProject", "src");
- PsiTestUtil.addLibrary(myModule, "lib", JavaTestUtil.getJavaTestDataPath() + "/find/libUnderProject/lib", new String[]{""}, ArrayUtil.EMPTY_STRING_ARRAY);
+ String libDir = JavaTestUtil.getJavaTestDataPath() + "/find/libUnderProject/lib";
+ PsiTestUtil.addLibrary(myModule, "lib", libDir, new String[]{""}, ArrayUtil.EMPTY_STRING_ARRAY);
FindModel findModel = new FindModel();
findModel.setStringToFind("TargetWord");
@@ -411,7 +416,7 @@
assertSize(2, findUsages(findModel));
}
- public void testLocalScopeSearchPerformance() throws Throwable {
+ public void testLocalScopeSearchPerformance() throws Exception {
final int fileCount = 3000;
final int lineCount = 500;
TempDirTestFixture fixture = new LightTempDirTestFixtureImpl();
@@ -426,6 +431,7 @@
VirtualFile file = fixture.createFile("target.txt", sampleText);
PsiFile psiFile = PsiManager.getInstance(myProject).findFile(file);
+ assertNotNull(psiFile);
final FindModel findModel = new FindModel();
findModel.setStringToFind("TargetWord");
findModel.setWholeWordsOnly(true);
@@ -451,38 +457,28 @@
}
}
- public void testFindInCommentsAndLiterals() throws Exception{
- FindManager findManager = FindManager.getInstance(myProject);
-
+ public void testFindInCommentsAndLiterals() {
FindModel findModel = FindManagerTestUtils.configureFindModel("done");
String text = "\"done done done\" /* done done done */";
-
- FindManagerTestUtils.runFindInCommentsAndLiterals(findManager, findModel, text);
+ FindManagerTestUtils.runFindInCommentsAndLiterals(myFindManager, findModel, text);
findModel.setRegularExpressions(true);
- FindManagerTestUtils.runFindInCommentsAndLiterals(findManager, findModel, text);
+ FindManagerTestUtils.runFindInCommentsAndLiterals(myFindManager, findModel, text);
}
- public void testFindInJavaDocs() throws Exception{
- FindManager findManager = FindManager.getInstance(myProject);
-
+ public void testFindInJavaDocs() {
FindModel findModel = FindManagerTestUtils.configureFindModel("done");
-
String text = "/** done done done */";
findModel.setInCommentsOnly(true);
- FindManagerTestUtils.runFindForwardAndBackward(findManager, findModel, text);
+ FindManagerTestUtils.runFindForwardAndBackward(myFindManager, findModel, text);
findModel.setRegularExpressions(true);
- FindManagerTestUtils.runFindForwardAndBackward(findManager, findModel, text);
-
- FindManagerTestUtils.runFindForwardAndBackward(findManager, findModel, text, "groovy");
+ FindManagerTestUtils.runFindForwardAndBackward(myFindManager, findModel, text);
}
- public void testFindInCommentsProperlyWorksWithOffsets() throws Exception{
- FindManager findManager = FindManager.getInstance(myProject);
-
+ public void testFindInCommentsProperlyWorksWithOffsets() {
FindModel findModel = FindManagerTestUtils.configureFindModel("done");
String prefix = "/*";
@@ -491,72 +487,45 @@
findModel.setInCommentsOnly(true);
LightVirtualFile file = new LightVirtualFile("A.java", text);
- FindResult findResult = findManager.findString(text, prefix.length(), findModel, file);
+ FindResult findResult = myFindManager.findString(text, prefix.length(), findModel, file);
assertTrue(findResult.isStringFound());
findModel.setRegularExpressions(true);
- findResult = findManager.findString(text, prefix.length(), findModel, file);
+ findResult = myFindManager.findString(text, prefix.length(), findModel, file);
assertTrue(findResult.isStringFound());
}
- public void testFindInUserFileType() throws Exception{
- FindManager findManager = FindManager.getInstance(myProject);
-
+ public void testFindInUserFileType() {
FindModel findModel = FindManagerTestUtils.configureFindModel("done");
-
String text = "\"done done\"; 'done'; // done\n" +
"/* done\n" +
"done */";
-
- FindManagerTestUtils.runFindInCommentsAndLiterals(findManager, findModel, text, "cs");
+ FindManagerTestUtils.runFindInCommentsAndLiterals(myFindManager, findModel, text, "cs");
}
- public void testFindInLiteralToSkipQuotes() throws Exception{
- FindManager findManager = FindManager.getInstance(myProject);
-
+ public void testFindInLiteralToSkipQuotes() {
FindModel findModel = FindManagerTestUtils.configureFindModel("^done$");
+
findModel.setRegularExpressions(true);
-
- String text = "\"done\"; 'done'; 'done' \"done2\"";
-
findModel.setInStringLiteralsOnly(true);
findModel.setInCommentsOnly(false);
- FindManagerTestUtils.runFindForwardAndBackward(findManager, findModel, text, "java");
-
- text = "def n = \"\"\"done\"\"\"\n def n = /done/\n def n = \"done\"\n def n = \"done2\"";
-
- FindManagerTestUtils.runFindForwardAndBackward(findManager, findModel, text, "groovy");
-
- text = "\"\"; \"done\"; 'done'; 'done' \"done2\"";
+ String text = "\"done\"; 'done'; 'done' \"done2\"";
+ FindManagerTestUtils.runFindForwardAndBackward(myFindManager, findModel, text, "java");
findModel.setStringToFind("done");
findModel.setWholeWordsOnly(true);
findModel.setRegularExpressions(false);
-
- FindManagerTestUtils.runFindForwardAndBackward(findManager, findModel, text, "java");
+ text = "\"\"; \"done\"; 'done'; 'done' \"done2\"";
+ FindManagerTestUtils.runFindForwardAndBackward(myFindManager, findModel, text, "java");
}
- public void testFindInShellCommentsOfGroovy() throws Exception{
- FindManager findManager = FindManager.getInstance(myProject);
-
- FindModel findModel = FindManagerTestUtils.configureFindModel("done");
- findModel.setWholeWordsOnly(true);
-
- String text = "#! done done done\n";
-
- findModel.setInCommentsOnly(true);
- FindManagerTestUtils.runFindForwardAndBackward(findManager, findModel, text, "groovy");
- }
-
- public void testFindInJavaDoc() throws Exception{
- FindManager findManager = FindManager.getInstance(myProject);
-
+ public void testFindInJavaDoc() {
FindModel findModel = FindManagerTestUtils.configureFindModel("do ne");
findModel.setWholeWordsOnly(true);
String text = "/** do ne do ne do ne */";
findModel.setInCommentsOnly(true);
- FindManagerTestUtils.runFindForwardAndBackward(findManager, findModel, text, "java");
+ FindManagerTestUtils.runFindForwardAndBackward(myFindManager, findModel, text, "java");
}
}
diff --git a/java/java-tests/testSrc/com/intellij/openapi/roots/impl/DirectoryIndexTest.java b/java/java-tests/testSrc/com/intellij/openapi/roots/impl/DirectoryIndexTest.java
index d86fd6b..dbdbb5a 100644
--- a/java/java-tests/testSrc/com/intellij/openapi/roots/impl/DirectoryIndexTest.java
+++ b/java/java-tests/testSrc/com/intellij/openapi/roots/impl/DirectoryIndexTest.java
@@ -412,7 +412,7 @@
checkInfoNull(module2Output);
checkInfoNull(module2TestOutput);
- assertTrue(myIndex.isProjectExcludeRoot(excluded));
+ assertFalse(myIndex.isProjectExcludeRoot(excluded));
excluded.delete(this);
projectOutput.delete(this);
@@ -430,7 +430,7 @@
};
VirtualFileManager.getInstance().addVirtualFileListener(l, getTestRootDisposable());
excluded = myModule1Dir.createChildDirectory(this, excluded.getName());
- //todo assertTrue(myIndex.isProjectExcludeRoot(excluded));
+ assertFalse(myIndex.isProjectExcludeRoot(excluded));
projectOutput = myModule1Dir.createChildDirectory(this, projectOutput.getName());
module2Output = myModule1Dir.createChildDirectory(this, module2Output.getName());
module2TestOutput = myModule2Dir.createChildDirectory(this, module2TestOutput.getName());
@@ -442,7 +442,7 @@
assertEquals(created.toString(), 4, created.size());
- assertTrue(myIndex.isProjectExcludeRoot(excluded));
+ assertFalse(myIndex.isProjectExcludeRoot(excluded));
}
public void testExcludesShouldBeRecognizedRightOnRefresh() throws Exception {
@@ -521,12 +521,24 @@
checkInfo(myExcludedLibClsDir, null, true, false, "lib.cls.exc", null, myModule3);
}
-
public void testExcludeCompilerOutputOutsideOfContentRoot() throws Exception {
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
assertTrue(fileIndex.isIgnored(myOutputDir));
assertTrue(fileIndex.isIgnored(myModule1OutputDir));
assertFalse(fileIndex.isIgnored(myOutputDir.getParent()));
+ assertTrue(myIndex.isProjectExcludeRoot(myOutputDir));
+ assertFalse(myIndex.isProjectExcludeRoot(myModule1OutputDir));
+ String moduleOutputUrl = myModule1OutputDir.getUrl();
+
+ myOutputDir.delete(this);
+
+ PsiTestUtil.setCompilerOutputPath(myModule, moduleOutputUrl, false);
+ myOutputDir = myRootVFile.createChildDirectory(this, "out");
+ myModule1OutputDir = myOutputDir.createChildDirectory(this, "module1");
+
+ assertTrue(myIndex.isProjectExcludeRoot(myOutputDir));
+ assertTrue(myIndex.isProjectExcludeRoot(myModule1OutputDir));
+ assertTrue(fileIndex.isIgnored(myModule1OutputDir));
}
private void checkInfo(VirtualFile dir,
diff --git a/java/java-tests/testSrc/com/intellij/psi/StubAstSwitchTest.groovy b/java/java-tests/testSrc/com/intellij/psi/StubAstSwitchTest.groovy
index b7b39fb..936bb1c 100644
--- a/java/java-tests/testSrc/com/intellij/psi/StubAstSwitchTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/psi/StubAstSwitchTest.groovy
@@ -66,7 +66,9 @@
int count = 100
List<PsiClass> classList = (0..<count).collect {
myFixture.addClass("class Foo$it { " +
- (0..<100).collect { "void foo$it(int i, boolean b, Object o) {}" }.join("\n") +
+ "void foo$it(" +
+ (0..250).collect { "int i$it"}.join(", ") +
+ ") {}" +
" }")
}
CountDownLatch latch = new CountDownLatch(count)
diff --git a/java/openapi/src/com/intellij/ide/hierarchy/call/CallReferenceProcessor.java b/java/openapi/src/com/intellij/ide/hierarchy/call/CallReferenceProcessor.java
new file mode 100644
index 0000000..5c2585f
--- /dev/null
+++ b/java/openapi/src/com/intellij/ide/hierarchy/call/CallReferenceProcessor.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.ide.hierarchy.call;
+
+import com.intellij.openapi.extensions.ExtensionPointName;
+import com.intellij.psi.PsiReference;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Created by Max Medvedev on 10/5/13
+ */
+public interface CallReferenceProcessor {
+ ExtensionPointName<CallReferenceProcessor> EP_NAME = ExtensionPointName.create("com.intellij.hierarchy.referenceProcessor");
+
+ /**
+ *
+ * @param reference reference to process
+ * @param data settings to use while processing
+ * @return false if the reference is processed
+ */
+ boolean process(@NotNull PsiReference reference, @NotNull JavaCallHierarchyData data);
+}
diff --git a/java/openapi/src/com/intellij/ide/hierarchy/call/JavaCallHierarchyData.java b/java/openapi/src/com/intellij/ide/hierarchy/call/JavaCallHierarchyData.java
new file mode 100644
index 0000000..e2b5a7a
--- /dev/null
+++ b/java/openapi/src/com/intellij/ide/hierarchy/call/JavaCallHierarchyData.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.ide.hierarchy.call;
+
+import com.intellij.ide.util.treeView.NodeDescriptor;
+import com.intellij.openapi.project.Project;
+import com.intellij.psi.PsiClass;
+import com.intellij.psi.PsiClassType;
+import com.intellij.psi.PsiMember;
+import com.intellij.psi.PsiMethod;
+
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Created by Max Medvedev on 10/5/13
+ */
+public class JavaCallHierarchyData {
+ private final PsiClass myOriginalClass;
+ private final PsiMethod myMethodToFind;
+ private final PsiClassType myOriginalType;
+ private final PsiMethod myMethod;
+ private final Set<PsiMethod> myMethodsToFind;
+ private final NodeDescriptor myNodeDescriptor;
+ private final Map<PsiMember, NodeDescriptor> myResultMap;
+ private final Project myProject;
+
+ public JavaCallHierarchyData(PsiClass originalClass,
+ PsiMethod methodToFind,
+ PsiClassType originalType,
+ PsiMethod method,
+ Set<PsiMethod> methodsToFind,
+ NodeDescriptor nodeDescriptor,
+ Map<PsiMember, NodeDescriptor> resultMap,
+ Project project) {
+
+ myOriginalClass = originalClass;
+ myMethodToFind = methodToFind;
+ myOriginalType = originalType;
+ myMethod = method;
+ myMethodsToFind = methodsToFind;
+ myNodeDescriptor = nodeDescriptor;
+ myResultMap = resultMap;
+ myProject = project;
+ }
+
+ public PsiClass getOriginalClass() {
+ return myOriginalClass;
+ }
+
+ public PsiMethod getMethodToFind() {
+ return myMethodToFind;
+ }
+
+ public PsiClassType getOriginalType() {
+ return myOriginalType;
+ }
+
+ public PsiMethod getMethod() {
+ return myMethod;
+ }
+
+ public Set<PsiMethod> getMethodsToFind() {
+ return myMethodsToFind;
+ }
+
+ public NodeDescriptor getNodeDescriptor() {
+ return myNodeDescriptor;
+ }
+
+ public Map<PsiMember, NodeDescriptor> getResultMap() {
+ return myResultMap;
+ }
+
+ public Project getProject() {
+ return myProject;
+ }
+}
diff --git a/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java b/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java
index 142b66c..add2b67 100644
--- a/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java
+++ b/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java
@@ -139,36 +139,41 @@
return configureByFile(vFile, projectFile);
}
- protected PsiFile configureByText(@NotNull FileType fileType, @NonNls final String text) throws Exception {
+ protected PsiFile configureByText(@NotNull FileType fileType, @NonNls final String text) {
return configureByText(fileType, text, null);
}
- protected PsiFile configureByText(@NotNull final FileType fileType, @NonNls final String text, @Nullable String _extension) throws Exception {
- final String extension = _extension == null ? fileType.getDefaultExtension():_extension;
+ protected PsiFile configureByText(@NotNull final FileType fileType, @NonNls final String text, @Nullable String _extension) {
+ try {
+ final String extension = _extension == null ? fileType.getDefaultExtension():_extension;
- File dir = createTempDirectory();
- final File tempFile = FileUtil.createTempFile(dir, "aaa", "." + extension, true);
- final FileTypeManager fileTypeManager = FileTypeManager.getInstance();
- if (fileTypeManager.getFileTypeByExtension(extension) != fileType) {
- new WriteCommandAction(getProject()) {
- @Override
- protected void run(Result result) throws Exception {
- fileTypeManager.associateExtension(fileType, extension);
- }
- }.execute();
+ File dir = createTempDirectory();
+ final File tempFile = FileUtil.createTempFile(dir, "aaa", "." + extension, true);
+ final FileTypeManager fileTypeManager = FileTypeManager.getInstance();
+ if (fileTypeManager.getFileTypeByExtension(extension) != fileType) {
+ new WriteCommandAction(getProject()) {
+ @Override
+ protected void run(Result result) throws Exception {
+ fileTypeManager.associateExtension(fileType, extension);
+ }
+ }.execute();
+ }
+ final VirtualFile vFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(tempFile);
+ assert vFile != null;
+ VfsUtil.saveText(vFile, text);
+
+ final VirtualFile vdir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(dir);
+
+ PsiTestUtil.addSourceRoot(myModule, vdir);
+
+ configureByExistingFile(vFile);
+
+ assertEquals(fileType, myFile.getVirtualFile().getFileType());
+ return myFile;
}
- final VirtualFile vFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(tempFile);
- assert vFile != null;
- VfsUtil.saveText(vFile, text);
-
- final VirtualFile vdir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(dir);
-
- PsiTestUtil.addSourceRoot(myModule, vdir);
-
- configureByExistingFile(vFile);
-
- assertEquals(fileType, myFile.getVirtualFile().getFileType());
- return myFile;
+ catch (IOException e) {
+ throw new RuntimeException(e);
+ }
}
diff --git a/java/java-tests/testSrc/com/intellij/find/FindManagerTestUtils.java b/java/testFramework/src/com/intellij/find/FindManagerTestUtils.java
similarity index 75%
rename from java/java-tests/testSrc/com/intellij/find/FindManagerTestUtils.java
rename to java/testFramework/src/com/intellij/find/FindManagerTestUtils.java
index d5e498f..89b2578 100644
--- a/java/java-tests/testSrc/com/intellij/find/FindManagerTestUtils.java
+++ b/java/testFramework/src/com/intellij/find/FindManagerTestUtils.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.intellij.find;
import com.intellij.testFramework.LightVirtualFile;
@@ -8,10 +23,7 @@
runFindInCommentsAndLiterals(findManager, findModel, text, "java");
}
- static void runFindInCommentsAndLiterals(FindManager findManager,
- FindModel findModel,
- String text,
- String ext) {
+ public static void runFindInCommentsAndLiterals(FindManager findManager, FindModel findModel, String text, String ext) {
findModel.setInStringLiteralsOnly(true);
findModel.setInCommentsOnly(false);
runFindForwardAndBackward(findManager, findModel, text, ext);
@@ -21,7 +33,7 @@
runFindForwardAndBackward(findManager, findModel, text, ext);
}
- static void runFindForwardAndBackward(FindManager findManager, FindModel findModel, String text) {
+ public static void runFindForwardAndBackward(FindManager findManager, FindModel findModel, String text) {
runFindForwardAndBackward(findManager, findModel, text, "java");
}
diff --git a/jps/jps-builders/src/org/jetbrains/jps/cmdline/ClasspathBootstrap.java b/jps/jps-builders/src/org/jetbrains/jps/cmdline/ClasspathBootstrap.java
index c6cc117..d2b4c7f 100644
--- a/jps/jps-builders/src/org/jetbrains/jps/cmdline/ClasspathBootstrap.java
+++ b/jps/jps-builders/src/org/jetbrains/jps/cmdline/ClasspathBootstrap.java
@@ -146,6 +146,7 @@
cp.add(getResourcePath(NotNullVerifyingInstrumenter.class)); // not-null
cp.add(getResourcePath(IXMLBuilder.class)); // nano-xml
cp.add(getResourcePath(SequenceLock.class)); // jsr166
+ //don't forget to update layoutCommunityJps() in layouts.gant accordingly
if (!isLauncherUsed) {
appendJavaCompilerClasspath(cp);
diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/ResourcesTarget.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/ResourcesTarget.java
index 90348b8..21c3291 100644
--- a/jps/jps-builders/src/org/jetbrains/jps/incremental/ResourcesTarget.java
+++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/ResourcesTarget.java
@@ -32,7 +32,6 @@
import org.jetbrains.jps.indices.IgnoredFileIndex;
import org.jetbrains.jps.indices.ModuleExcludeIndex;
import org.jetbrains.jps.model.JpsModel;
-import org.jetbrains.jps.model.JpsSimpleElement;
import org.jetbrains.jps.model.java.JavaResourceRootType;
import org.jetbrains.jps.model.java.JavaSourceRootProperties;
import org.jetbrains.jps.model.java.JavaSourceRootType;
@@ -93,9 +92,9 @@
JavaSourceRootType type = isTests() ? JavaSourceRootType.TEST_SOURCE : JavaSourceRootType.SOURCE;
Iterable<ExcludedJavaSourceRootProvider> excludedRootProviders = JpsServiceManager.getInstance().getExtensions(ExcludedJavaSourceRootProvider.class);
- for (JpsTypedModuleSourceRoot<? extends JpsSimpleElement<JavaSourceRootProperties>> sourceRoot : myModule.getSourceRoots(type)) {
+ for (JpsTypedModuleSourceRoot<JavaSourceRootProperties> sourceRoot : myModule.getSourceRoots(type)) {
if (!isExcludedFromCompilation(excludedRootProviders, sourceRoot)) {
- final String packagePrefix = sourceRoot.getProperties().getData().getPackagePrefix();
+ final String packagePrefix = sourceRoot.getProperties().getPackagePrefix();
final File rootFile = sourceRoot.getFile();
roots.add(new FilteredResourceRootDescriptor(rootFile, this, packagePrefix, computeRootExcludes(rootFile, index)));
}
diff --git a/jps/model-api/src/org/jetbrains/jps/model/module/JpsModuleSourceRoot.java b/jps/model-api/src/org/jetbrains/jps/model/module/JpsModuleSourceRoot.java
index 87af190..6e07aa7 100644
--- a/jps/model-api/src/org/jetbrains/jps/model/module/JpsModuleSourceRoot.java
+++ b/jps/model-api/src/org/jetbrains/jps/model/module/JpsModuleSourceRoot.java
@@ -20,6 +20,7 @@
import org.jetbrains.jps.model.JpsElement;
import java.io.File;
+import java.util.Set;
/**
* @author nik
@@ -28,9 +29,18 @@
@NotNull
JpsModuleSourceRootType<?> getRootType();
+ /**
+ * @return the root properties element or {@code null} if the root type doesn't equal to {@code type}
+ */
@Nullable
<P extends JpsElement> P getProperties(@NotNull JpsModuleSourceRootType<P> type);
+ /**
+ * @return the root properties element or {@code null} if the root type isn't contained in {@code types}
+ */
+ @Nullable
+ <P extends JpsElement> P getProperties(@NotNull Set<? extends JpsModuleSourceRootType<P>> types);
+
@Nullable
<P extends JpsElement> JpsTypedModuleSourceRoot<P> asTyped(@NotNull JpsModuleSourceRootType<P> type);
diff --git a/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsModuleSourceRootImpl.java b/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsModuleSourceRootImpl.java
index 7ba971b..f32c814 100644
--- a/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsModuleSourceRootImpl.java
+++ b/jps/model-impl/src/org/jetbrains/jps/model/module/impl/JpsModuleSourceRootImpl.java
@@ -25,6 +25,7 @@
import org.jetbrains.jps.model.module.JpsTypedModuleSourceRoot;
import java.io.File;
+import java.util.Set;
/**
* @author nik
@@ -57,6 +58,15 @@
@Nullable
@Override
+ public <P extends JpsElement> P getProperties(@NotNull Set<? extends JpsModuleSourceRootType<P>> types) {
+ if (types.contains(myRootType)) {
+ return (P)getProperties();
+ }
+ return null;
+ }
+
+ @Nullable
+ @Override
public <P extends JpsElement> JpsTypedModuleSourceRoot<P> asTyped(@NotNull JpsModuleSourceRootType<P> type) {
//noinspection unchecked
return myRootType.equals(type) ? (JpsTypedModuleSourceRoot<P>)this : null;
diff --git a/lib/jayatana-1.2.4.jar b/lib/jayatana-1.2.4.jar
index 4a25474..8f73939 100644
--- a/lib/jayatana-1.2.4.jar
+++ b/lib/jayatana-1.2.4.jar
Binary files differ
diff --git a/lib/pty4j-0.3.jar b/lib/pty4j-0.3.jar
index e67a795..9868cdd 100644
--- a/lib/pty4j-0.3.jar
+++ b/lib/pty4j-0.3.jar
Binary files differ
diff --git a/lib/src/jayatana-1.2.4-src.zip b/lib/src/jayatana-1.2.4-src.zip
index ccae832..a60cda1 100644
--- a/lib/src/jayatana-1.2.4-src.zip
+++ b/lib/src/jayatana-1.2.4-src.zip
Binary files differ
diff --git a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/GeneralHighlightingPass.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/GeneralHighlightingPass.java
index fd9e6df..a29c339 100644
--- a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/GeneralHighlightingPass.java
+++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/GeneralHighlightingPass.java
@@ -119,7 +119,7 @@
// initial guess to show correct progress in the traffic light icon
setProgressLimit(document.getTextLength()/2); // approx number of PSI elements = file length/2
- myGlobalScheme = EditorColorsManager.getInstance().getGlobalScheme();
+ myGlobalScheme = myEditor != null ? myEditor.getColorsScheme() : EditorColorsManager.getInstance().getGlobalScheme();
}
private static final Key<AtomicInteger> HIGHLIGHT_VISITOR_INSTANCE_COUNT = new Key<AtomicInteger>("HIGHLIGHT_VISITOR_INSTANCE_COUNT");
diff --git a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java
index 783b01b..fcb7075 100644
--- a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java
+++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java
@@ -92,7 +92,7 @@
final int group,
@NotNull Map<TextRange, RangeMarker> ranges2markersCache) {
ApplicationManager.getApplication().assertIsDispatchThread();
- if (info.isFileLevelAnnotation() || info.getGutterIconRenderer() != null) return;
+ if (isFileLevelOrGutterAnnotation(info)) return;
if (info.getStartOffset() < startOffset || info.getEndOffset() > endOffset) return;
MarkupModel markup = DocumentMarkupModel.forDocument(document, project, true);
@@ -119,6 +119,10 @@
}
}
+ public static boolean isFileLevelOrGutterAnnotation(HighlightInfo info) {
+ return info.isFileLevelAnnotation() || info.getGutterIconRenderer() != null;
+ }
+
public static void setHighlightersToEditor(@NotNull Project project,
@NotNull Document document,
int startOffset,
diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/ProblemDescriptorUtil.java b/platform/analysis-impl/src/com/intellij/codeInspection/ProblemDescriptorUtil.java
index 4a4e40f..b5643b7 100644
--- a/platform/analysis-impl/src/com/intellij/codeInspection/ProblemDescriptorUtil.java
+++ b/platform/analysis-impl/src/com/intellij/codeInspection/ProblemDescriptorUtil.java
@@ -20,20 +20,27 @@
import com.intellij.lang.annotation.HighlightSeverity;
import com.intellij.openapi.editor.colors.CodeInsightColors;
import com.intellij.openapi.editor.colors.TextAttributesKey;
+import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiElement;
import org.intellij.lang.annotations.MagicConstant;
import org.jetbrains.annotations.NotNull;
+import java.util.ArrayList;
+import java.util.List;
+
public class ProblemDescriptorUtil {
- public static final int NONE = 0x00000000;
+ public static final int NONE = 0x00000000;
public static final int APPEND_LINE_NUMBER = 0x00000001;
- public static final int TRIM_AT_END = 0x00000002;
- public static final int TRIM_AT_TREE_END = 0x00000004;
+ public static final int TRIM_AT_END = 0x00000002;
+ public static final int TRIM_AT_TREE_END = 0x00000004;
@MagicConstant(flags = {NONE, APPEND_LINE_NUMBER, TRIM_AT_END, TRIM_AT_TREE_END})
- @interface FlagConstant {}
+ @interface FlagConstant {
+ }
+
+ public static Pair<String, String> XML_CODE_MARKER = Pair.create("<xml-code>", "</xml-code>");
public static String extractHighlightedText(@NotNull CommonProblemDescriptor descriptor, PsiElement psiElement) {
if (psiElement == null || !psiElement.isValid()) return "";
@@ -65,10 +72,14 @@
// noinspection ConstantConditions
if (message == null) return "";
- if ((flags & APPEND_LINE_NUMBER) != 0 && descriptor instanceof ProblemDescriptor && !message.contains("#ref") && message.contains("#loc")) {
+ if ((flags & APPEND_LINE_NUMBER) != 0 &&
+ descriptor instanceof ProblemDescriptor &&
+ !message.contains("#ref") &&
+ message.contains("#loc")) {
final int lineNumber = ((ProblemDescriptor)descriptor).getLineNumber();
if (lineNumber >= 0) {
- message = StringUtil.replace(message, "#loc", "(" + InspectionsBundle.message("inspection.export.results.at.line") + " " + lineNumber + ")");
+ message = StringUtil
+ .replace(message, "#loc", "(" + InspectionsBundle.message("inspection.export.results.at.line") + " " + lineNumber + ")");
}
}
message = StringUtil.replace(message, "<code>", "'");
@@ -89,17 +100,45 @@
message = StringUtil.replace(message, "#end", "");
message = StringUtil.replace(message, "#treeend", "");
- message = StringUtil.unescapeXml(message).trim();
+ if (message.contains(XML_CODE_MARKER.first)) {
+ message = unescapeXmlCode(message);
+ }
+ else {
+ message = StringUtil.unescapeXml(message).trim();
+ }
return message;
}
+ private static String unescapeXmlCode(final String message) {
+ List<String> strings = new ArrayList<String>();
+ for (String string : StringUtil.split(message, XML_CODE_MARKER.first)) {
+ if (string.contains(XML_CODE_MARKER.second)) {
+ strings.addAll(StringUtil.split(string, XML_CODE_MARKER.second, false));
+ }
+ else {
+ strings.add(string);
+ }
+ }
+ StringBuilder builder = new StringBuilder();
+ for (String string : strings) {
+ if (string.contains(XML_CODE_MARKER.second)) {
+ builder.append(string.replace(XML_CODE_MARKER.second, ""));
+ } else {
+ builder.append(StringUtil.unescapeXml(string));
+ }
+ }
+ return builder.toString();
+ }
+
@NotNull
public static String renderDescriptionMessage(@NotNull CommonProblemDescriptor descriptor, PsiElement element) {
return renderDescriptionMessage(descriptor, element, false);
}
@NotNull
- public static HighlightInfoType highlightTypeFromDescriptor(@NotNull ProblemDescriptor problemDescriptor, @NotNull HighlightSeverity severity, @NotNull SeverityRegistrar severityRegistrar) {
+ public static HighlightInfoType highlightTypeFromDescriptor(@NotNull ProblemDescriptor problemDescriptor,
+ @NotNull HighlightSeverity severity,
+ @NotNull SeverityRegistrar severityRegistrar) {
final ProblemHighlightType highlightType = problemDescriptor.getHighlightType();
switch (highlightType) {
case GENERIC_ERROR_OR_WARNING:
@@ -133,5 +172,4 @@
}
throw new RuntimeException("Cannot map " + highlightType);
}
-
}
diff --git a/platform/core-api/src/com/intellij/openapi/project/DumbService.java b/platform/core-api/src/com/intellij/openapi/project/DumbService.java
index 925f5f7..825e101 100644
--- a/platform/core-api/src/com/intellij/openapi/project/DumbService.java
+++ b/platform/core-api/src/com/intellij/openapi/project/DumbService.java
@@ -29,7 +29,6 @@
import javax.swing.*;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Iterator;
import java.util.List;
/**
@@ -158,10 +157,10 @@
@NotNull
public <T> List<T> filterByDumbAwareness(@NotNull Collection<T> collection) {
if (isDumb()) {
- final ArrayList<T> result = new ArrayList<T>(collection);
- for (Iterator<T> iterator = result.iterator(); iterator.hasNext();) {
- if (!isDumbAware(iterator.next())) {
- iterator.remove();
+ final ArrayList<T> result = new ArrayList<T>(collection.size());
+ for (T element : collection) {
+ if (isDumbAware(element)) {
+ result.add(element);
}
}
return result;
diff --git a/platform/core-api/src/com/intellij/openapi/vfs/newvfs/events/VFileCreateEvent.java b/platform/core-api/src/com/intellij/openapi/vfs/newvfs/events/VFileCreateEvent.java
index b75988b..e3a9b90 100644
--- a/platform/core-api/src/com/intellij/openapi/vfs/newvfs/events/VFileCreateEvent.java
+++ b/platform/core-api/src/com/intellij/openapi/vfs/newvfs/events/VFileCreateEvent.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.
@@ -63,6 +63,10 @@
return myParent;
}
+ public boolean isReCreation() {
+ return myReCreation;
+ }
+
@NonNls
@Override
public String toString() {
@@ -81,6 +85,10 @@
return myCreatedFile = myParent.findChild(myChildName);
}
+ public void resetCache() {
+ myCreatedFile = null;
+ }
+
@NotNull
@Override
public VirtualFileSystem getFileSystem() {
diff --git a/platform/core-api/src/com/intellij/util/FileContentUtilCore.java b/platform/core-api/src/com/intellij/util/FileContentUtilCore.java
index 2578fde..93833db 100644
--- a/platform/core-api/src/com/intellij/util/FileContentUtilCore.java
+++ b/platform/core-api/src/com/intellij/util/FileContentUtilCore.java
@@ -20,6 +20,7 @@
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
+import com.intellij.openapi.vfs.newvfs.BulkFileListener;
import com.intellij.openapi.vfs.newvfs.events.VFileEvent;
import com.intellij.openapi.vfs.newvfs.events.VFilePropertyChangeEvent;
import gnu.trove.THashSet;
@@ -28,6 +29,7 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
import java.util.Set;
/**
@@ -47,28 +49,27 @@
saveOrReload(file, events);
}
- ApplicationManager.getApplication().getMessageBus().syncPublisher(VirtualFileManager.VFS_CHANGES)
- .before(new ArrayList<VFileEvent>(events));
- ApplicationManager.getApplication().getMessageBus().syncPublisher(VirtualFileManager.VFS_CHANGES)
- .after(new ArrayList<VFileEvent>(events));
+ BulkFileListener publisher = ApplicationManager.getApplication().getMessageBus().syncPublisher(VirtualFileManager.VFS_CHANGES);
+ List<VFileEvent> eventList = new ArrayList<VFileEvent>(events);
+ publisher.before(eventList);
+ publisher.after(eventList);
}
});
}
- private static void saveOrReload(final VirtualFile virtualFile, Collection<VFilePropertyChangeEvent> events) {
- if (virtualFile == null || virtualFile.isDirectory() || !virtualFile.isValid()) {
+ private static void saveOrReload(VirtualFile file, Collection<VFilePropertyChangeEvent> events) {
+ if (file == null || file.isDirectory() || !file.isValid()) {
return;
}
- final FileDocumentManager documentManager = FileDocumentManager.getInstance();
- if (documentManager.isFileModified(virtualFile)) {
- Document document = documentManager.getDocument(virtualFile);
+
+ FileDocumentManager documentManager = FileDocumentManager.getInstance();
+ if (documentManager.isFileModified(file)) {
+ Document document = documentManager.getDocument(file);
if (document != null) {
documentManager.saveDocument(document);
}
}
- events.add(
- new VFilePropertyChangeEvent(FORCE_RELOAD_REQUESTOR, virtualFile, VirtualFile.PROP_NAME, virtualFile.getName(), virtualFile.getName(),
- false));
- }
+ events.add(new VFilePropertyChangeEvent(FORCE_RELOAD_REQUESTOR, file, VirtualFile.PROP_NAME, file.getName(), file.getName(), false));
+ }
}
diff --git a/platform/core-api/src/com/intellij/util/IconUtil.java b/platform/core-api/src/com/intellij/util/IconUtil.java
index 0327435..3109717 100644
--- a/platform/core-api/src/com/intellij/util/IconUtil.java
+++ b/platform/core-api/src/com/intellij/util/IconUtil.java
@@ -93,6 +93,13 @@
return new ImageIcon(img);
}
+ public static Icon cropIcon(@NotNull Icon icon, Rectangle area) {
+ if (!new Rectangle(icon.getIconWidth(), icon.getIconHeight()).contains(area)) {
+ return icon;
+ }
+ return new CropIcon(icon, area);
+ }
+
@NotNull
public static Icon flip(@NotNull Icon icon, boolean horizontal) {
int w = icon.getIconWidth();
@@ -334,4 +341,29 @@
return myHeight;
}
}
+
+ private static class CropIcon implements Icon {
+ private final Icon mySrc;
+ private final Rectangle myCrop;
+
+ private CropIcon(@NotNull Icon src, Rectangle crop) {
+ mySrc = src;
+ myCrop = crop;
+ }
+
+ @Override
+ public void paintIcon(Component c, Graphics g, int x, int y) {
+ mySrc.paintIcon(c, g, x - myCrop.x, y - myCrop.y);
+ }
+
+ @Override
+ public int getIconWidth() {
+ return myCrop.width;
+ }
+
+ @Override
+ public int getIconHeight() {
+ return myCrop.height;
+ }
+ }
}
diff --git a/platform/core-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java b/platform/core-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java
index 2abdb51..1ceaba4 100644
--- a/platform/core-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java
+++ b/platform/core-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java
@@ -556,11 +556,14 @@
@NotNull
private DocumentEvent doBeforeChangedUpdate(int offset, CharSequence oldString, CharSequence newString, boolean wholeTextReplaced) {
- FileDocumentManager manager = FileDocumentManager.getInstance();
- if (manager != null) {
- VirtualFile file = manager.getFile(this);
- if (file != null && !file.isValid()) {
- LOG.error("File of this document has been deleted.");
+ Application app = ApplicationManager.getApplication();
+ if (app != null) {
+ FileDocumentManager manager = FileDocumentManager.getInstance();
+ if (manager != null) {
+ VirtualFile file = manager.getFile(this);
+ if (file != null && !file.isValid()) {
+ LOG.error("File of this document has been deleted.");
+ }
}
}
diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/PsiFileImpl.java b/platform/core-impl/src/com/intellij/psi/impl/source/PsiFileImpl.java
index 7c883dc..23e3c8d 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/source/PsiFileImpl.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/source/PsiFileImpl.java
@@ -268,35 +268,41 @@
final List<Pair<StubBasedPsiElementBase, CompositeElement>> result = ContainerUtil.newArrayList();
final StubBuilder builder = ((IStubFileElementType)getContentElementType()).getBuilder();
- ((TreeElement)root).acceptTree(new RecursiveTreeElementWalkingVisitor() {
- @Override
- protected void visitNode(TreeElement node) {
- CompositeElement parent = node.getTreeParent();
- if (parent != null && TreeUtil.skipNode(builder, parent, node)) {
- return;
- }
-
-
- IElementType type = node.getElementType();
- if (type instanceof IStubElementType && ((IStubElementType)type).shouldCreateStub(node)) {
- if (!stubs.hasNext()) {
- reportStubAstMismatch("Stub list is less than AST, last AST element: " + node.getElementType() + " " + node, stubTree, cachedDocument);
+ LazyParseableElement.setSuppressEagerPsiCreation(true);
+ try {
+ ((TreeElement)root).acceptTree(new RecursiveTreeElementWalkingVisitor() {
+ @Override
+ protected void visitNode(TreeElement node) {
+ CompositeElement parent = node.getTreeParent();
+ if (parent != null && TreeUtil.skipNode(builder, parent, node)) {
+ return;
}
-
- final StubElement stub = stubs.next();
- if (stub.getStubType() != node.getElementType()) {
- reportStubAstMismatch("Stub and PSI element type mismatch in " + getName() + ": stub " + stub + ", AST " +
- node.getElementType() + "; " + node, stubTree, cachedDocument);
+
+
+ IElementType type = node.getElementType();
+ if (type instanceof IStubElementType && ((IStubElementType)type).shouldCreateStub(node)) {
+ if (!stubs.hasNext()) {
+ reportStubAstMismatch("Stub list is less than AST, last AST element: " + node.getElementType() + " " + node, stubTree, cachedDocument);
+ }
+
+ final StubElement stub = stubs.next();
+ if (stub.getStubType() != node.getElementType()) {
+ reportStubAstMismatch("Stub and PSI element type mismatch in " + getName() + ": stub " + stub + ", AST " +
+ node.getElementType() + "; " + node, stubTree, cachedDocument);
+ }
+
+ PsiElement psi = stub.getPsi();
+ assert psi != null : "Stub " + stub + " (" + stub.getClass() + ") has returned null PSI";
+ result.add(Pair.create((StubBasedPsiElementBase)psi, (CompositeElement)node));
}
-
- PsiElement psi = stub.getPsi();
- assert psi != null : "Stub " + stub + " (" + stub.getClass() + ") has returned null PSI";
- result.add(Pair.create((StubBasedPsiElementBase)psi, (CompositeElement)node));
+
+ super.visitNode(node);
}
-
- super.visitNode(node);
- }
- });
+ });
+ }
+ finally {
+ LazyParseableElement.setSuppressEagerPsiCreation(false);
+ }
if (stubs.hasNext()) {
reportStubAstMismatch("Stub list in " + getName() + " has more elements than PSI", stubTree, cachedDocument);
}
diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/tree/LazyParseableElement.java b/platform/core-impl/src/com/intellij/psi/impl/source/tree/LazyParseableElement.java
index 15b605c..a09ab19 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/source/tree/LazyParseableElement.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/source/tree/LazyParseableElement.java
@@ -48,6 +48,7 @@
// Under no circumstances should you grab the PSI_LOCK while holding this lock.
private final ChameleonLock lock = new ChameleonLock();
private CharSequence myText; /** guarded by {@link #lock} */
+ private static final ThreadLocal<Boolean> ourSuppressEagerPsiCreation = new ThreadLocal<Boolean>();
public LazyParseableElement(@NotNull IElementType type, CharSequence text) {
super(type);
@@ -181,9 +182,11 @@
super.rawAddChildrenWithoutNotifications((TreeElement)parsedNode);
}
- // create PSI all at once, to reduce contention of PsiLock in CompositeElement.getPsi()
- // create PSI outside the 'lock' since this method grabs PSI_LOCK and deadlock is possible when someone else locks in the other order.
- createAllChildrenPsiIfNecessary();
+ if (!Boolean.TRUE.equals(ourSuppressEagerPsiCreation.get())) {
+ // create PSI all at once, to reduce contention of PsiLock in CompositeElement.getPsi()
+ // create PSI outside the 'lock' since this method grabs PSI_LOCK and deadlock is possible when someone else locks in the other order.
+ createAllChildrenPsiIfNecessary();
+ }
}
@Override
@@ -222,4 +225,8 @@
public static void setParsingAllowed(boolean allowed) {
ourParsingAllowed = allowed;
}
+
+ public static void setSuppressEagerPsiCreation(boolean suppress) {
+ ourSuppressEagerPsiCreation.set(suppress);
+ }
}
diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/Editor.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/Editor.java
index bd63b43..1b2dcbb 100644
--- a/platform/editor-ui-api/src/com/intellij/openapi/editor/Editor.java
+++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/Editor.java
@@ -22,6 +22,7 @@
import com.intellij.openapi.editor.markup.MarkupModel;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.UserDataHolder;
+import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -37,6 +38,7 @@
* @see EditorFactory#createViewer(Document)
*/
public interface Editor extends UserDataHolder {
+ @NonNls Object IGNORE_MOUSE_TRACKING = "ignore_mouse_tracking";
Editor[] EMPTY_ARRAY = new Editor[0];
/**
diff --git a/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java b/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java
index 7f29254..f841300 100644
--- a/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java
+++ b/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java
@@ -625,7 +625,7 @@
@Override
public int getConsoleFontSize() {
String font = getConsoleFontName();
- if (myConsoleFontPreferences.hasSize(font)) {
+ if (!UISettings.getInstance().PRESENTATION_MODE && myConsoleFontPreferences.hasSize(font)) {
return myConsoleFontPreferences.getSize(font);
}
else {
diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/DataNode.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/DataNode.java
index d55acc4..4efac18 100644
--- a/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/DataNode.java
+++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/DataNode.java
@@ -56,6 +56,11 @@
myParent = parent;
}
+ @Nullable
+ public DataNode<?> getParent() {
+ return myParent;
+ }
+
@NotNull
public <T> DataNode<T> createChild(@NotNull Key<T> key, @NotNull T data) {
DataNode<T> result = new DataNode<T>(key, data, this);
diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ExternalSystemSourceType.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ExternalSystemSourceType.java
index 167a21a..ffe8a52 100644
--- a/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ExternalSystemSourceType.java
+++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ExternalSystemSourceType.java
@@ -15,7 +15,8 @@
@NotNull public static final ExternalSystemSourceType SOURCE = new ExternalSystemSourceType("SOURCE");
@NotNull public static final ExternalSystemSourceType TEST = new ExternalSystemSourceType("TEST");
@NotNull public static final ExternalSystemSourceType EXCLUDED = new ExternalSystemSourceType("EXCLUDED");
- @NotNull public static final ExternalSystemSourceType GENERATED = new ExternalSystemSourceType("GENERATED");
+ @NotNull public static final ExternalSystemSourceType SOURCE_GENERATED = new ExternalSystemSourceType("SOURCE_GENERATED");
+ @NotNull public static final ExternalSystemSourceType TEST_GENERATED = new ExternalSystemSourceType("TEST_GENERATED");
@NotNull public static final ExternalSystemSourceType RESOURCE = new ExternalSystemSourceType("RESOURCE");
@NotNull public static final ExternalSystemSourceType TEST_RESOURCE = new ExternalSystemSourceType("TEST_RESOURCE");
diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/DisposeAwareProjectChange.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/DisposeAwareProjectChange.java
new file mode 100644
index 0000000..a3e7a7d
--- /dev/null
+++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/DisposeAwareProjectChange.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.openapi.externalSystem.util;
+
+import com.intellij.openapi.components.ComponentManager;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author Vladislav.Soroka
+ * @since 11/6/13
+ */
+public abstract class DisposeAwareProjectChange implements Runnable {
+ private final ComponentManager myComponentManager;
+
+ protected DisposeAwareProjectChange(@NotNull ComponentManager componentManager) {
+ myComponentManager = componentManager;
+ }
+
+ public abstract void execute();
+
+ public final void run() {
+ if (!myComponentManager.isDisposed()) {
+ execute();
+ }
+ }
+}
diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemApiUtil.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemApiUtil.java
index 1df9a6c..0080611 100644
--- a/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemApiUtil.java
+++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemApiUtil.java
@@ -323,11 +323,11 @@
return result == null ? Collections.<DataNode<T>>emptyList() : result;
}
- public static void executeProjectChangeAction(@NotNull final Runnable task) {
+ public static void executeProjectChangeAction(@NotNull final DisposeAwareProjectChange task) {
executeProjectChangeAction(false, task);
}
- public static void executeProjectChangeAction(boolean synchronous, @NotNull final Runnable task) {
+ public static void executeProjectChangeAction(boolean synchronous, @NotNull final DisposeAwareProjectChange task) {
executeOnEdt(synchronous, new Runnable() {
public void run() {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/action/RefreshExternalProjectAction.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/action/RefreshExternalProjectAction.java
index 70801dc..e0e424b 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/action/RefreshExternalProjectAction.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/action/RefreshExternalProjectAction.java
@@ -10,6 +10,7 @@
import com.intellij.openapi.externalSystem.model.project.ProjectData;
import com.intellij.openapi.externalSystem.service.project.ExternalProjectRefreshCallback;
import com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager;
+import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange;
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
import com.intellij.openapi.externalSystem.util.ExternalSystemBundle;
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
@@ -74,9 +75,9 @@
if (externalProject == null) {
return;
}
- ExternalSystemApiUtil.executeProjectChangeAction(true, new Runnable() {
+ ExternalSystemApiUtil.executeProjectChangeAction(true, new DisposeAwareProjectChange(project) {
@Override
- public void run() {
+ public void execute() {
ProjectRootManagerEx.getInstanceEx(project).mergeRootsChangesDuring(new Runnable() {
@Override
public void run() {
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/autoimport/ExternalSystemAutoImporter.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/autoimport/ExternalSystemAutoImporter.java
index 9f30aa2..15300f0 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/autoimport/ExternalSystemAutoImporter.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/autoimport/ExternalSystemAutoImporter.java
@@ -29,6 +29,7 @@
import com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager;
import com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings;
import com.intellij.openapi.externalSystem.settings.ExternalProjectSettings;
+import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange;
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
import com.intellij.openapi.externalSystem.util.ExternalSystemConstants;
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
@@ -87,9 +88,9 @@
@Override
public void onSuccess(@Nullable final DataNode<ProjectData> externalProject) {
if (externalProject != null) {
- ExternalSystemApiUtil.executeProjectChangeAction(new Runnable() {
+ ExternalSystemApiUtil.executeProjectChangeAction(new DisposeAwareProjectChange(myProject) {
@Override
- public void run() {
+ public void execute() {
ProjectRootManagerEx.getInstanceEx(myProject).mergeRootsChangesDuring(new Runnable() {
@Override
public void run() {
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/AbstractDependencyDataService.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/AbstractDependencyDataService.java
index 3defa33..db57667 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/AbstractDependencyDataService.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/AbstractDependencyDataService.java
@@ -16,6 +16,7 @@
package com.intellij.openapi.externalSystem.service.project.manage;
import com.intellij.openapi.externalSystem.model.project.AbstractDependencyData;
+import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange;
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
import com.intellij.openapi.externalSystem.util.ExternalSystemConstants;
import com.intellij.openapi.externalSystem.util.Order;
@@ -39,9 +40,9 @@
{
public void setScope(@NotNull final DependencyScope scope, @NotNull final ExportableOrderEntry dependency, boolean synchronous) {
- ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new Runnable() {
+ ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new DisposeAwareProjectChange(dependency.getOwnerModule()) {
@Override
- public void run() {
+ public void execute() {
doForDependency(dependency, new Consumer<ExportableOrderEntry>() {
@Override
public void consume(ExportableOrderEntry entry) {
@@ -53,9 +54,9 @@
}
public void setExported(final boolean exported, @NotNull final ExportableOrderEntry dependency, boolean synchronous) {
- ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new Runnable() {
+ ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new DisposeAwareProjectChange(dependency.getOwnerModule()) {
@Override
- public void run() {
+ public void execute() {
doForDependency(dependency, new Consumer<ExportableOrderEntry>() {
@Override
public void consume(ExportableOrderEntry entry) {
@@ -116,9 +117,9 @@
return;
}
for (final ExportableOrderEntry dependency : toRemove) {
- ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new Runnable() {
+ ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new DisposeAwareProjectChange(dependency.getOwnerModule()) {
@Override
- public void run() {
+ public void execute() {
ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
final ModifiableRootModel moduleRootModel = moduleRootManager.getModifiableModel();
try {
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ContentRootDataService.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ContentRootDataService.java
index bcd3e9e..335cbcf 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ContentRootDataService.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ContentRootDataService.java
@@ -8,19 +8,19 @@
import com.intellij.openapi.externalSystem.model.project.ExternalSystemSourceType;
import com.intellij.openapi.externalSystem.model.project.ModuleData;
import com.intellij.openapi.externalSystem.service.project.ProjectStructureHelper;
+import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange;
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
import com.intellij.openapi.externalSystem.util.ExternalSystemConstants;
import com.intellij.openapi.externalSystem.util.Order;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.*;
-import com.intellij.openapi.roots.impl.SourceFolderImpl;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.util.containers.ContainerUtilRt;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.jps.model.JpsElement;
+import org.jetbrains.jps.model.java.JavaModuleSourceRootTypes;
import org.jetbrains.jps.model.java.JavaResourceRootType;
import org.jetbrains.jps.model.java.JavaSourceRootProperties;
import org.jetbrains.jps.model.java.JavaSourceRootType;
@@ -81,9 +81,9 @@
@NotNull final Module module,
boolean synchronous)
{
- ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new Runnable() {
+ ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new DisposeAwareProjectChange(module) {
@Override
- public void run() {
+ public void execute() {
final ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
final ModifiableRootModel model = moduleRootManager.getModifiableModel();
final ContentEntry[] contentEntries = model.getContentEntries();
@@ -113,10 +113,14 @@
createSourceRootIfAbsent(contentEntry, path, module.getName(), JavaResourceRootType.TEST_RESOURCE, false);
retainedPaths.add(ExternalSystemApiUtil.toCanonicalPath(path));
}
- for (String path : contentRoot.getPaths(ExternalSystemSourceType.GENERATED)) {
+ for (String path : contentRoot.getPaths(ExternalSystemSourceType.SOURCE_GENERATED)) {
createSourceRootIfAbsent(contentEntry, path, module.getName(), JavaSourceRootType.SOURCE, true);
retainedPaths.add(ExternalSystemApiUtil.toCanonicalPath(path));
}
+ for (String path : contentRoot.getPaths(ExternalSystemSourceType.TEST_GENERATED)) {
+ createSourceRootIfAbsent(contentEntry, path, module.getName(), JavaSourceRootType.TEST_SOURCE, true);
+ retainedPaths.add(ExternalSystemApiUtil.toCanonicalPath(path));
+ }
for (String path : contentRoot.getPaths(ExternalSystemSourceType.EXCLUDED)) {
createExcludedRootIfAbsent(contentEntry, path, module.getName());
retainedPaths.add(ExternalSystemApiUtil.toCanonicalPath(path));
@@ -183,10 +187,10 @@
}
LOG.info(String.format("Importing source root '%s' for content root '%s' of module '%s'", path, entry.getUrl(), moduleName));
SourceFolder sourceFolder = entry.addSourceFolder(toVfsUrl(path), sourceRootType);
- if (generated && sourceFolder instanceof SourceFolderImpl) {
- JpsElement properties = ((SourceFolderImpl)sourceFolder).getJpsElement().getProperties();
- if(properties instanceof JavaSourceRootProperties) {
- JavaSourceRootProperties.class.cast(properties).setForGeneratedSources(true);
+ if (generated) {
+ JavaSourceRootProperties properties = sourceFolder.getJpsElement().getProperties(JavaModuleSourceRootTypes.SOURCES);
+ if(properties != null) {
+ properties.setForGeneratedSources(true);
}
}
}
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/LibraryDataService.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/LibraryDataService.java
index 848a9a7..c564670 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/LibraryDataService.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/LibraryDataService.java
@@ -9,6 +9,7 @@
import com.intellij.openapi.externalSystem.service.project.ExternalLibraryPathTypeMapper;
import com.intellij.openapi.externalSystem.service.project.PlatformFacade;
import com.intellij.openapi.externalSystem.service.project.ProjectStructureHelper;
+import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange;
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
import com.intellij.openapi.externalSystem.util.ExternalSystemConstants;
import com.intellij.openapi.externalSystem.util.Order;
@@ -78,7 +79,7 @@
Library library = myProjectStructureHelper.findIdeLibrary(toImport, project);
if (library != null) {
- syncPaths(toImport, library, synchronous);
+ syncPaths(toImport, library, project, synchronous);
return;
}
importLibrary(toImport.getName(), libraryFiles, project, synchronous);
@@ -102,9 +103,9 @@
@NotNull final Project project,
boolean synchronous)
{
- ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new Runnable() {
+ ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new DisposeAwareProjectChange(project) {
@Override
- public void run() {
+ public void execute() {
// Is assumed to be called from the EDT.
final LibraryTable libraryTable = myPlatformFacade.getProjectLibraryTable(project);
final LibraryTable.ModifiableModel projectLibraryModel = libraryTable.getModifiableModel();
@@ -165,9 +166,9 @@
if (libraries.isEmpty()) {
return;
}
- ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new Runnable() {
+ ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new DisposeAwareProjectChange(project) {
@Override
- public void run() {
+ public void execute() {
final LibraryTable libraryTable = myPlatformFacade.getProjectLibraryTable(project);
final LibraryTable.ModifiableModel model = libraryTable.getModifiableModel();
try {
@@ -188,7 +189,7 @@
});
}
- public void syncPaths(@NotNull final LibraryData externalLibrary, @NotNull final Library ideLibrary, boolean synchronous) {
+ public void syncPaths(@NotNull final LibraryData externalLibrary, @NotNull final Library ideLibrary, @NotNull final Project project, boolean synchronous) {
if (externalLibrary.isUnresolved()) {
return;
}
@@ -212,9 +213,9 @@
if (toRemove.isEmpty() && toAdd.isEmpty()) {
return;
}
- ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new Runnable() {
+ ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new DisposeAwareProjectChange(project) {
@Override
- public void run() {
+ public void execute() {
Library.ModifiableModel model = ideLibrary.getModifiableModel();
try {
for (Map.Entry<OrderRootType, Set<String>> entry : toRemove.entrySet()) {
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/LibraryDependencyDataService.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/LibraryDependencyDataService.java
index 80d832f..0f7485d 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/LibraryDependencyDataService.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/LibraryDependencyDataService.java
@@ -22,6 +22,7 @@
import com.intellij.openapi.externalSystem.model.project.*;
import com.intellij.openapi.externalSystem.service.project.PlatformFacade;
import com.intellij.openapi.externalSystem.service.project.ProjectStructureHelper;
+import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange;
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
import com.intellij.openapi.externalSystem.util.ExternalSystemConstants;
import com.intellij.openapi.externalSystem.util.Order;
@@ -100,9 +101,9 @@
@NotNull final Module module,
final boolean synchronous)
{
- ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new Runnable() {
+ ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new DisposeAwareProjectChange(module) {
@Override
- public void run() {
+ public void execute() {
importMissingProjectLibraries(module, nodesToImport, synchronous);
// The general idea is to import all external project library dependencies and module libraries which don't present at the
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDataService.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDataService.java
index 57e123b..9bb095f 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDataService.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDataService.java
@@ -10,6 +10,7 @@
import com.intellij.openapi.externalSystem.model.project.ModuleData;
import com.intellij.openapi.externalSystem.model.project.ProjectData;
import com.intellij.openapi.externalSystem.service.project.ProjectStructureHelper;
+import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange;
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
import com.intellij.openapi.externalSystem.util.ExternalSystemConstants;
import com.intellij.openapi.externalSystem.util.Order;
@@ -72,9 +73,9 @@
myAlarm.addRequest(new ImportModulesTask(project, toImport, synchronous), PROJECT_INITIALISATION_DELAY_MS);
return;
}
- ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new Runnable() {
+ ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new DisposeAwareProjectChange(project) {
@Override
- public void run() {
+ public void execute() {
final Collection<DataNode<ModuleData>> toCreate = filterExistingModules(toImport, project);
if (!toCreate.isEmpty()) {
createModules(toCreate, project);
@@ -90,7 +91,7 @@
}
private void createModules(@NotNull final Collection<DataNode<ModuleData>> toCreate, @NotNull final Project project) {
- removeExistingModulesConfigs(toCreate);
+ removeExistingModulesConfigs(toCreate, project);
Application application = ApplicationManager.getApplication();
final Map<DataNode<ModuleData>, Module> moduleMappings = ContainerUtilRt.newHashMap();
application.runWriteAction(new Runnable() {
@@ -162,13 +163,13 @@
return result;
}
- private void removeExistingModulesConfigs(@NotNull final Collection<DataNode<ModuleData>> nodes) {
+ private void removeExistingModulesConfigs(@NotNull final Collection<DataNode<ModuleData>> nodes, @NotNull final Project project) {
if (nodes.isEmpty()) {
return;
}
- ExternalSystemApiUtil.executeProjectChangeAction(true, new Runnable() {
+ ExternalSystemApiUtil.executeProjectChangeAction(true, new DisposeAwareProjectChange(project) {
@Override
- public void run() {
+ public void execute() {
LocalFileSystem fileSystem = LocalFileSystem.getInstance();
for (DataNode<ModuleData> node : nodes) {
// Remove existing '*.iml' file if necessary.
@@ -218,9 +219,9 @@
if (modules.isEmpty()) {
return;
}
- ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new Runnable() {
+ ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new DisposeAwareProjectChange(project) {
@Override
- public void run() {
+ public void execute() {
for (Module module : modules) {
ModuleManager moduleManager = ModuleManager.getInstance(module.getProject());
String path = module.getModuleFilePath();
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDependencyDataService.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDependencyDataService.java
index be88a64..5a78201 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDependencyDataService.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDependencyDataService.java
@@ -23,6 +23,7 @@
import com.intellij.openapi.externalSystem.model.project.ModuleDependencyData;
import com.intellij.openapi.externalSystem.model.project.ProjectData;
import com.intellij.openapi.externalSystem.service.project.ProjectStructureHelper;
+import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange;
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
import com.intellij.openapi.externalSystem.util.ExternalSystemConstants;
import com.intellij.openapi.externalSystem.util.Order;
@@ -88,9 +89,9 @@
@NotNull final Module module,
final boolean synchronous)
{
- ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new Runnable() {
+ ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new DisposeAwareProjectChange(module) {
@Override
- public void run() {
+ public void execute() {
ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
Map<Pair<String /* dependency module name */, /* dependency module scope */DependencyScope> , ModuleOrderEntry> toRemove = ContainerUtilRt.newHashMap();
for (OrderEntry entry : moduleRootManager.getOrderEntries()) {
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataServiceImpl.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataServiceImpl.java
index b9b7854..b6f564b 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataServiceImpl.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataServiceImpl.java
@@ -20,10 +20,7 @@
import com.intellij.openapi.externalSystem.model.ProjectKeys;
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
import com.intellij.openapi.externalSystem.model.project.ProjectData;
-import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
-import com.intellij.openapi.externalSystem.util.ExternalSystemConstants;
-import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
-import com.intellij.openapi.externalSystem.util.Order;
+import com.intellij.openapi.externalSystem.util.*;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ex.ProjectEx;
import org.jetbrains.annotations.NotNull;
@@ -73,9 +70,9 @@
if (!(project instanceof ProjectEx) || newName.equals(project.getName())) {
return;
}
- ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new Runnable() {
+ ExternalSystemApiUtil.executeProjectChangeAction(synchronous, new DisposeAwareProjectChange(project) {
@Override
- public void run() {
+ public void execute() {
String oldName = project.getName();
((ProjectEx)project).setProjectName(newName);
ExternalSystemApiUtil.getSettings(project, externalSystemId).getPublisher().onProjectRenamed(oldName, newName);
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractExternalProjectImportBuilder.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractExternalProjectImportBuilder.java
index d1969cf..5de8d46 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractExternalProjectImportBuilder.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractExternalProjectImportBuilder.java
@@ -7,15 +7,14 @@
import com.intellij.openapi.externalSystem.model.ExternalSystemDataKeys;
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
import com.intellij.openapi.externalSystem.model.project.ProjectData;
-import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId;
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListener;
-import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListenerAdapter;
import com.intellij.openapi.externalSystem.service.internal.ExternalSystemResolveProjectTask;
import com.intellij.openapi.externalSystem.service.project.ExternalProjectRefreshCallback;
import com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager;
import com.intellij.openapi.externalSystem.service.settings.AbstractImportFromExternalSystemControl;
import com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings;
import com.intellij.openapi.externalSystem.settings.ExternalProjectSettings;
+import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange;
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
import com.intellij.openapi.externalSystem.util.ExternalSystemBundle;
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
@@ -135,9 +134,9 @@
if (externalProjectNode != null) {
ExternalSystemUtil.ensureToolWindowInitialized(project, myExternalSystemId);
- ExternalSystemApiUtil.executeProjectChangeAction(new Runnable() {
+ ExternalSystemApiUtil.executeProjectChangeAction(new DisposeAwareProjectChange(project) {
@Override
- public void run() {
+ public void execute() {
ProjectRootManagerEx.getInstanceEx(project).mergeRootsChangesDuring(new Runnable() {
@Override
public void run() {
@@ -210,9 +209,9 @@
* dependencies information available at the given gradle project
*/
private void setupLibraries(@NotNull final DataNode<ProjectData> projectWithResolvedLibraries, final Project project) {
- ExternalSystemApiUtil.executeProjectChangeAction(new Runnable() {
+ ExternalSystemApiUtil.executeProjectChangeAction(new DisposeAwareProjectChange(project) {
@Override
- public void run() {
+ public void execute() {
ProjectRootManagerEx.getInstanceEx(project).mergeRootsChangesDuring(new Runnable() {
@Override
public void run() {
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUtil.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUtil.java
index 6e0536d..bc0e06c 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUtil.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUtil.java
@@ -33,16 +33,13 @@
import com.intellij.openapi.externalSystem.model.execution.ExternalTaskExecutionInfo;
import com.intellij.openapi.externalSystem.model.project.ModuleData;
import com.intellij.openapi.externalSystem.model.project.ProjectData;
-import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId;
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListener;
-import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListenerAdapter;
import com.intellij.openapi.externalSystem.service.ImportCanceledException;
import com.intellij.openapi.externalSystem.service.execution.AbstractExternalSystemTaskConfigurationType;
import com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfiguration;
import com.intellij.openapi.externalSystem.service.execution.ProgressExecutionMode;
import com.intellij.openapi.externalSystem.service.internal.ExternalSystemResolveProjectTask;
import com.intellij.openapi.externalSystem.service.notification.ExternalSystemIdeNotificationManager;
-import com.intellij.openapi.externalSystem.service.notification.ExternalSystemNotificationExtension;
import com.intellij.openapi.externalSystem.service.project.ExternalProjectRefreshCallback;
import com.intellij.openapi.externalSystem.service.project.PlatformFacade;
import com.intellij.openapi.externalSystem.service.project.manage.ModuleDataService;
@@ -76,7 +73,6 @@
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtilRt;
import com.intellij.util.ui.UIUtil;
-import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -211,9 +207,9 @@
for (DataNode<ModuleData> node : moduleNodes) {
myExternalModulePaths.add(node.getData().getLinkedExternalProjectPath());
}
- ExternalSystemApiUtil.executeProjectChangeAction(true, new Runnable() {
+ ExternalSystemApiUtil.executeProjectChangeAction(true, new DisposeAwareProjectChange(project) {
@Override
- public void run() {
+ public void execute() {
ProjectRootManagerEx.getInstanceEx(project).mergeRootsChangesDuring(new Runnable() {
@Override
public void run() {
@@ -449,6 +445,7 @@
if (stamp > 0) {
ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(externalSystemId);
assert manager != null;
+ if(project.isDisposed()) return;
manager.getLocalSettingsProvider().fun(project).getExternalConfigModificationStamps().put(externalProjectPath, stamp);
}
DataNode<ProjectData> externalProject = task.getExternalProject();
@@ -697,9 +694,9 @@
projects.add(projectSettings);
systemSettings.setLinkedProjectsSettings(projects);
ensureToolWindowInitialized(project, externalSystemId);
- ExternalSystemApiUtil.executeProjectChangeAction(new Runnable() {
+ ExternalSystemApiUtil.executeProjectChangeAction(new DisposeAwareProjectChange(project) {
@Override
- public void run() {
+ public void execute() {
ProjectRootManagerEx.getInstanceEx(project).mergeRootsChangesDuring(new Runnable() {
@Override
public void run() {
diff --git a/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/test/AbstractExternalSystemTest.groovy b/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/test/AbstractExternalSystemTest.groovy
index 75cf210..95d1089 100644
--- a/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/test/AbstractExternalSystemTest.groovy
+++ b/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/test/AbstractExternalSystemTest.groovy
@@ -23,6 +23,7 @@
import com.intellij.openapi.externalSystem.model.ProjectSystemId
import com.intellij.openapi.externalSystem.model.project.ProjectData
import com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager
+import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil
import com.intellij.openapi.project.Project
import com.intellij.openapi.roots.ex.ProjectRootManagerEx
@@ -151,10 +152,15 @@
def settings = ExternalSystemApiUtil.getSettings(project, ExternalSystemTestUtil.TEST_EXTERNAL_SYSTEM_ID)
settings.linkedProjectsSettings = [new TestExternalProjectSettings(externalProjectPath: node.data.linkedExternalProjectPath)]
}
- ExternalSystemApiUtil.executeProjectChangeAction(true, {
- ProjectRootManagerEx.getInstanceEx(project).mergeRootsChangesDuring {
- dataManager.importData(node.key, [node], project, true)
- } })
+
+ final Project myProject = project
+ ExternalSystemApiUtil.executeProjectChangeAction(true, new DisposeAwareProjectChange(myProject) {
+ @Override
+ void execute() {
+ ProjectRootManagerEx.getInstanceEx(myProject).mergeRootsChangesDuring {
+ dataManager.importData(node.key, [node], myProject, true)
+ }
+ }})
}
}
}
diff --git a/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/test/ExternalProjectBuilder.groovy b/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/test/ExternalProjectBuilder.groovy
index b0480ac..957f072 100644
--- a/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/test/ExternalProjectBuilder.groovy
+++ b/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/test/ExternalProjectBuilder.groovy
@@ -81,6 +81,9 @@
getLevel(attributes))
data.scope = getScope(attributes)
return parentNode.createChild(ProjectKeys.LIBRARY_DEPENDENCY, data)
+ case 'extraModel':
+ DataNode<ModuleData> parentNode = current as DataNode
+ return parentNode.createChild(attributes.key, attributes.model)
case 'task':
DataNode<ExternalConfigPathAware> parentNode = current as DataNode
ProjectSystemId projectSystemId = attributes.projectSystemId ?: TEST_EXTERNAL_SYSTEM_ID
diff --git a/platform/icons/src/idea_logo_welcome.png b/platform/icons/src/idea_logo_welcome.png
index f0d023c..4ac4551 100644
--- a/platform/icons/src/idea_logo_welcome.png
+++ b/platform/icons/src/idea_logo_welcome.png
Binary files differ
diff --git a/platform/icons/src/providers/h2.png b/platform/icons/src/providers/h2.png
new file mode 100644
index 0000000..3485508
--- /dev/null
+++ b/platform/icons/src/providers/h2.png
Binary files differ
diff --git a/platform/icons/src/providers/h2@2x.png b/platform/icons/src/providers/h2@2x.png
new file mode 100644
index 0000000..432ed2a
--- /dev/null
+++ b/platform/icons/src/providers/h2@2x.png
Binary files differ
diff --git a/platform/icons/src/providers/hsqldb.png b/platform/icons/src/providers/hsqldb.png
new file mode 100644
index 0000000..15229aa
--- /dev/null
+++ b/platform/icons/src/providers/hsqldb.png
Binary files differ
diff --git a/platform/icons/src/providers/hsqldb@2x.png b/platform/icons/src/providers/hsqldb@2x.png
new file mode 100644
index 0000000..43c5729
--- /dev/null
+++ b/platform/icons/src/providers/hsqldb@2x.png
Binary files differ
diff --git a/platform/icons/src/providers/sybase.png b/platform/icons/src/providers/sybase.png
new file mode 100644
index 0000000..d2f0509
--- /dev/null
+++ b/platform/icons/src/providers/sybase.png
Binary files differ
diff --git a/platform/icons/src/providers/sybase@2x.png b/platform/icons/src/providers/sybase@2x.png
new file mode 100644
index 0000000..cdadeb0
--- /dev/null
+++ b/platform/icons/src/providers/sybase@2x.png
Binary files differ
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/cache/impl/todo/LexerBasedTodoIndexer.java b/platform/indexing-impl/src/com/intellij/psi/impl/cache/impl/todo/LexerBasedTodoIndexer.java
similarity index 100%
rename from platform/lang-impl/src/com/intellij/psi/impl/cache/impl/todo/LexerBasedTodoIndexer.java
rename to platform/indexing-impl/src/com/intellij/psi/impl/cache/impl/todo/LexerBasedTodoIndexer.java
diff --git a/platform/indexing-impl/src/com/intellij/psi/impl/search/LowLevelSearchUtil.java b/platform/indexing-impl/src/com/intellij/psi/impl/search/LowLevelSearchUtil.java
index 7082b0e..09fdd72 100644
--- a/platform/indexing-impl/src/com/intellij/psi/impl/search/LowLevelSearchUtil.java
+++ b/platform/indexing-impl/src/com/intellij/psi/impl/search/LowLevelSearchUtil.java
@@ -18,7 +18,6 @@
import com.intellij.lang.ASTNode;
import com.intellij.lang.injection.InjectedLanguageManager;
-import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Pair;
@@ -39,10 +38,6 @@
import java.util.List;
public class LowLevelSearchUtil {
- private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.search.LowLevelSearchUtil");
-
- private LowLevelSearchUtil() {
- }
// TRUE/FALSE -> injected psi has been discovered and processor returned true/false;
// null -> there were nothing injected found
@@ -95,7 +90,7 @@
start = offset - leafElement.getTextRange().getStartOffset() + scopeStartOffset;
}
if (start < 0) {
- LOG.error("offset=" + offset + " scopeStartOffset=" + scopeStartOffset + " leafElement=" + leafElement + " scope=" + scope);
+ throw new AssertionError("offset=" + offset + " scopeStartOffset=" + scopeStartOffset + " leafElement=" + leafElement + " scope=" + scope);
}
boolean contains = false;
PsiElement prev = null;
@@ -159,7 +154,7 @@
int startOffset = scopeStart;
int endOffset = range.getEndOffset();
if (endOffset > buffer.length()) {
- LOG.error("Range for element: '"+scope+"' = "+range+" is out of file '" + file + "' range: " + file.getTextLength());
+ throw new AssertionError("Range for element: '"+scope+"' = "+range+" is out of file '" + file + "' range: " + file.getTextLength());
}
final char[] bufferArray = CharArrayUtil.fromSequenceWithoutCopying(buffer);
@@ -194,7 +189,9 @@
int endOffset,
@NotNull StringSearcher searcher,
@Nullable ProgressIndicator progress) {
- LOG.assertTrue(endOffset <= text.length());
+ if (endOffset > text.length()) {
+ throw new AssertionError("end>length");
+ }
for (int index = startOffset; index < endOffset; index++) {
if (progress != null) progress.checkCanceled();
diff --git a/platform/indexing-impl/src/com/intellij/psi/search/FileTypeIndex.java b/platform/indexing-impl/src/com/intellij/psi/search/FileTypeIndex.java
index 8f0ed10..b0a8673 100644
--- a/platform/indexing-impl/src/com/intellij/psi/search/FileTypeIndex.java
+++ b/platform/indexing-impl/src/com/intellij/psi/search/FileTypeIndex.java
@@ -103,4 +103,13 @@
public Map<FileType, Void> map(FileContent inputData) {
return Collections.singletonMap(inputData.getFileType(), null);
}
+
+ public static boolean containsFileOfType(@NotNull FileType type, @NotNull GlobalSearchScope scope) {
+ return !FileBasedIndex.getInstance().processValues(NAME, type, null, new FileBasedIndex.ValueProcessor<Void>() {
+ @Override
+ public boolean process(VirtualFile file, Void value) {
+ return false;
+ }
+ }, scope);
+ }
}
diff --git a/platform/lang-api/src/com/intellij/codeInsight/lookup/Lookup.java b/platform/lang-api/src/com/intellij/codeInsight/lookup/Lookup.java
index 10f124a..74599ef 100644
--- a/platform/lang-api/src/com/intellij/codeInsight/lookup/Lookup.java
+++ b/platform/lang-api/src/com/intellij/codeInsight/lookup/Lookup.java
@@ -32,6 +32,8 @@
char COMPLETE_STATEMENT_SELECT_CHAR = '\r';
char AUTO_INSERT_SELECT_CHAR = (char) 0;
+ int getLookupStart();
+
@Nullable
LookupElement getCurrentItem();
diff --git a/platform/lang-api/src/com/intellij/execution/configurations/ConfigurationFactory.java b/platform/lang-api/src/com/intellij/execution/configurations/ConfigurationFactory.java
index 33828da..c687538 100644
--- a/platform/lang-api/src/com/intellij/execution/configurations/ConfigurationFactory.java
+++ b/platform/lang-api/src/com/intellij/execution/configurations/ConfigurationFactory.java
@@ -53,6 +53,16 @@
}
/**
+ * Override this method and return {@code false} to hide the configuration from 'New' popup in 'Edit Configurations' dialog. It will be
+ * still possible to create this configuration by clicking on '42 more items' in the 'New' popup.
+ *
+ * @return {@code true} if it makes sense to create configurations of this type in {@code project}
+ */
+ public boolean isApplicable(@NotNull Project project) {
+ return true;
+ }
+
+ /**
* Creates a new template run configuration within the context of the specified project.
*
* @param project the project in which the run configuration will be used
diff --git a/platform/lang-api/src/com/intellij/ide/util/projectWizard/ModuleWizardStep.java b/platform/lang-api/src/com/intellij/ide/util/projectWizard/ModuleWizardStep.java
index e7d5584..5aecef6 100644
--- a/platform/lang-api/src/com/intellij/ide/util/projectWizard/ModuleWizardStep.java
+++ b/platform/lang-api/src/com/intellij/ide/util/projectWizard/ModuleWizardStep.java
@@ -16,6 +16,7 @@
package com.intellij.ide.util.projectWizard;
import com.intellij.ide.util.BrowseFilesListener;
+import com.intellij.ide.wizard.CommitStepException;
import com.intellij.ide.wizard.StepAdapter;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.util.IconLoader;
@@ -51,7 +52,9 @@
}
public void onStepLeaving() {
- // empty by default
+ }
+
+ public void onWizardFinished() throws CommitStepException {
}
@Override
diff --git a/platform/lang-api/src/com/intellij/ide/util/projectWizard/SettingsStep.java b/platform/lang-api/src/com/intellij/ide/util/projectWizard/SettingsStep.java
index ab493e9..f831960 100644
--- a/platform/lang-api/src/com/intellij/ide/util/projectWizard/SettingsStep.java
+++ b/platform/lang-api/src/com/intellij/ide/util/projectWizard/SettingsStep.java
@@ -33,4 +33,7 @@
void addExpertPanel(@NotNull JComponent panel);
void addExpertField(@NotNull String label, @NotNull JComponent field);
+
+ @NotNull
+ JTextField getModuleNameField();
}
diff --git a/platform/lang-api/src/com/intellij/openapi/module/ModuleType.java b/platform/lang-api/src/com/intellij/openapi/module/ModuleType.java
index 3e09802..b6b5457 100644
--- a/platform/lang-api/src/com/intellij/openapi/module/ModuleType.java
+++ b/platform/lang-api/src/com/intellij/openapi/module/ModuleType.java
@@ -26,6 +26,7 @@
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.jetbrains.jps.model.module.JpsModuleSourceRootType;
import javax.swing.*;
@@ -115,4 +116,8 @@
public FrameworkRole getDefaultAcceptableRole() {
return myFrameworkRole;
}
+
+ public boolean isSupportedRootType(JpsModuleSourceRootType type) {
+ return true;
+ }
}
diff --git a/platform/lang-api/src/com/intellij/openapi/module/ModuleUtil.java b/platform/lang-api/src/com/intellij/openapi/module/ModuleUtil.java
index baaef3d..3aeae29 100644
--- a/platform/lang-api/src/com/intellij/openapi/module/ModuleUtil.java
+++ b/platform/lang-api/src/com/intellij/openapi/module/ModuleUtil.java
@@ -19,16 +19,42 @@
*/
package com.intellij.openapi.module;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.roots.ProjectRootManager;
+import com.intellij.openapi.util.Key;
+import com.intellij.psi.util.CachedValueProvider;
+import com.intellij.psi.util.CachedValuesManager;
+import com.intellij.psi.util.ParameterizedCachedValue;
+import com.intellij.psi.util.ParameterizedCachedValueProvider;
+import com.intellij.util.containers.MultiMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.jetbrains.jps.model.module.JpsModuleSourceRootType;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
public class ModuleUtil extends ModuleUtilCore {
+ private static final ParameterizedCachedValueProvider<MultiMap<ModuleType<?>,Module>,Project> MODULE_BY_TYPE_VALUE_PROVIDER =
+ new ParameterizedCachedValueProvider<MultiMap<ModuleType<?>, Module>, Project>() {
+ @Nullable
+ @Override
+ public CachedValueProvider.Result<MultiMap<ModuleType<?>, Module>> compute(Project param) {
+ MultiMap<ModuleType<?>, Module> map = new MultiMap<ModuleType<?>, Module>();
+ for (Module module : ModuleManager.getInstance(param).getModules()) {
+ map.putValue(ModuleType.get(module), module);
+ }
+ return CachedValueProvider.Result.createSingleDependency(map, ProjectRootManager.getInstance(param));
+ }
+ };
+ private static final Key<ParameterizedCachedValue<MultiMap<ModuleType<?>, Module>, Project>> MODULES_BY_TYPE_KEY = Key.create("MODULES_BY_TYPE");
private ModuleUtil() {}
+ /**
+ * @deprecated use ModuleManager#getModuleDependentModules(com.intellij.openapi.module.Module) instead
+ */
@Nullable
public static Module getParentModuleOfType(ModuleType expectedModuleType, Module module) {
if (module == null) return null;
@@ -37,6 +63,9 @@
return parents.isEmpty() ? null : parents.get(0);
}
+ /**
+ * @deprecated use ModuleManager#getModuleDependentModules(com.intellij.openapi.module.Module) instead
+ */
@NotNull
public static List<Module> getParentModulesOfType(ModuleType expectedModuleType, Module module) {
final List<Module> parents = ModuleManager.getInstance(module.getProject()).getModuleDependentModules(module);
@@ -48,4 +77,24 @@
}
return modules;
}
+
+ @NotNull
+ public static Collection<Module> getModulesOfType(@NotNull Project project, @NotNull ModuleType<?> moduleType) {
+ return CachedValuesManager.getManager(project).getParameterizedCachedValue(project, MODULES_BY_TYPE_KEY, MODULE_BY_TYPE_VALUE_PROVIDER,
+ false, project).get(moduleType);
+ }
+
+ public static boolean hasModulesOfType(@NotNull Project project, @NotNull ModuleType<?> module) {
+ return !getModulesOfType(project, module).isEmpty();
+ }
+
+ public static boolean isSupportedRootType(Project project, JpsModuleSourceRootType sourceRootType) {
+ Module[] modules = ModuleManager.getInstance(project).getModules();
+ for (Module module : modules) {
+ if (ModuleType.get(module).isSupportedRootType(sourceRootType)) {
+ return true;
+ }
+ }
+ return modules.length == 0;
+ }
}
diff --git a/platform/lang-api/src/com/intellij/openapi/roots/GeneratedSourcesFilter.java b/platform/lang-api/src/com/intellij/openapi/roots/GeneratedSourcesFilter.java
new file mode 100644
index 0000000..ce15635
--- /dev/null
+++ b/platform/lang-api/src/com/intellij/openapi/roots/GeneratedSourcesFilter.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.openapi.roots;
+
+import com.intellij.openapi.extensions.ExtensionPointName;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.vfs.VirtualFile;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author nik
+ */
+public abstract class GeneratedSourcesFilter {
+ public static final ExtensionPointName<GeneratedSourcesFilter> EP_NAME = ExtensionPointName.create("com.intellij.generatedSourcesFilter");
+
+ public abstract boolean isGeneratedSource(@NotNull VirtualFile file, @NotNull Project project);
+}
diff --git a/platform/lang-api/src/com/intellij/refactoring/util/MoveRenameUsageInfo.java b/platform/lang-api/src/com/intellij/refactoring/util/MoveRenameUsageInfo.java
index cc96ace..f8a3f5f 100644
--- a/platform/lang-api/src/com/intellij/refactoring/util/MoveRenameUsageInfo.java
+++ b/platform/lang-api/src/com/intellij/refactoring/util/MoveRenameUsageInfo.java
@@ -15,6 +15,7 @@
*/
package com.intellij.refactoring.util;
+import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.RangeMarker;
import com.intellij.openapi.project.Project;
@@ -24,6 +25,7 @@
import org.jetbrains.annotations.Nullable;
public class MoveRenameUsageInfo extends UsageInfo{
+ private static final Logger LOG = Logger.getInstance("#" + MoveRenameUsageInfo.class.getName());
private SmartPsiElementPointer myReferencedElementPointer = null;
private PsiElement myReferencedElement;
@@ -63,9 +65,11 @@
if (reference != null) {
Document document = PsiDocumentManager.getInstance(project).getDocument(containingFile);
if (document != null) {
- int elementStart = reference.getElement().getTextRange().getStartOffset();
- myReferenceRangeMarker = document.createRangeMarker(elementStart + reference.getRangeInElement().getStartOffset(),
- elementStart + reference.getRangeInElement().getEndOffset());
+ final int elementStart = reference.getElement().getTextRange().getStartOffset();
+ final TextRange rangeInElement = reference.getRangeInElement();
+ LOG.assertTrue(elementStart + rangeInElement.getEndOffset() <= document.getTextLength(), reference);
+ myReferenceRangeMarker = document.createRangeMarker(elementStart + rangeInElement.getStartOffset(),
+ elementStart + rangeInElement.getEndOffset());
}
myDynamicUsage = reference.resolve() == null;
}
diff --git a/platform/lang-impl/src/com/intellij/analysis/BaseAnalysisActionDialog.java b/platform/lang-impl/src/com/intellij/analysis/BaseAnalysisActionDialog.java
index 9d1dfa7..2042fcd 100644
--- a/platform/lang-impl/src/com/intellij/analysis/BaseAnalysisActionDialog.java
+++ b/platform/lang-impl/src/com/intellij/analysis/BaseAnalysisActionDialog.java
@@ -20,6 +20,7 @@
import com.intellij.ide.util.scopeChooser.ScopeChooserCombo;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
+import com.intellij.openapi.module.ModuleUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ProjectFileIndex;
import com.intellij.openapi.roots.ProjectRootManager;
@@ -40,6 +41,7 @@
import com.intellij.ui.TitledSeparator;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.jetbrains.jps.model.java.JavaSourceRootType;
import javax.swing.*;
import java.awt.*;
@@ -110,6 +112,7 @@
//include test option
myInspectTestSource.setSelected(myAnalysisOptions.ANALYZE_TEST_SOURCES);
+ myInspectTestSource.setVisible(ModuleUtil.isSupportedRootType(myProject, JavaSourceRootType.TEST_SOURCE));
//module scope if applicable
myModuleButton.setText(AnalysisScopeBundle.message("scope.option.module.with.mnemonic", myModuleName));
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java
index 899a601..52ed9c8 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java
@@ -209,7 +209,11 @@
final int selectionEndOffset = initContext.getSelectionEndOffset();
final PsiReference reference = initContext.getFile().findReferenceAt(selectionEndOffset);
if (reference != null) {
- initContext.setReplacementOffset(findReplacementOffset(selectionEndOffset, reference));
+ int referenceStart = reference.getElement().getTextRange().getStartOffset();
+ if (referenceStart + reference.getRangeInElement().getStartOffset() != selectionEndOffset ||
+ referenceStart == initContext.getStartOffset()) {
+ initContext.setReplacementOffset(findReplacementOffset(selectionEndOffset, reference));
+ }
}
}
catch (IndexNotReadyException ignored) {
@@ -351,7 +355,7 @@
myLookup.refreshUi(true, justShown);
hideAutopopupIfMeaningless();
if (justShown) {
- myLookup.ensureSelectionVisible();
+ myLookup.ensureSelectionVisible(true);
}
return true;
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/FilePathCompletionContributor.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/FilePathCompletionContributor.java
index 2e113d0..65c2a74 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/completion/FilePathCompletionContributor.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/FilePathCompletionContributor.java
@@ -292,11 +292,11 @@
if (myFile.isValid()) {
final PsiReference psiReference = context.getFile().findReferenceAt(context.getStartOffset());
final Pair<FileReference, Boolean> fileReferencePair = getReference(psiReference);
- LOG.assertTrue(fileReferencePair != null);
-
- FileReference ref = fileReferencePair.getFirst();
- context.setTailOffset(ref.getRangeInElement().getEndOffset() + ref.getElement().getTextRange().getStartOffset());
- ref.bindToElement(myFile);
+ if (fileReferencePair != null) {
+ FileReference ref = fileReferencePair.getFirst();
+ context.setTailOffset(ref.getRangeInElement().getEndOffset() + ref.getElement().getTextRange().getStartOffset());
+ ref.bindToElement(myFile);
+ }
}
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java
index 5efc486..24f1716 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java
@@ -92,7 +92,6 @@
*/
public class DaemonListeners implements Disposable {
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.DaemonListeners");
- @NonNls public static final Object IGNORE_MOUSE_TRACKING = "ignore_mouse_tracking";
private final Project myProject;
private final DaemonCodeAnalyzerImpl myDaemonCodeAnalyzer;
@@ -582,7 +581,7 @@
public void mouseMoved(EditorMouseEvent e) {
Editor editor = e.getEditor();
if (myProject != editor.getProject()) return;
- if (editor.getComponent().getClientProperty(IGNORE_MOUSE_TRACKING) != null) return;
+ if (editor.getComponent().getClientProperty(Editor.IGNORE_MOUSE_TRACKING) != null) return;
boolean shown = false;
try {
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/BraceMatcherBasedSelectioner.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/BraceMatcherBasedSelectioner.java
index bddf785..37ee0ab 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/BraceMatcherBasedSelectioner.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/BraceMatcherBasedSelectioner.java
@@ -36,7 +36,6 @@
* @author Gregory.Shrago
*/
public abstract class BraceMatcherBasedSelectioner extends ExtendWordSelectionHandlerBase {
-
@Override
public List<TextRange> select(final PsiElement e, final CharSequence editorText, final int cursorOffset, final Editor editor) {
final VirtualFile file = e.getContainingFile().getVirtualFile();
@@ -60,8 +59,8 @@
result.addAll(expandToWholeLine(editorText, new TextRange(last.first, iterator.getEnd())));
int bodyStart = last.second;
int bodyEnd = iterator.getStart();
- while (bodyStart < textLength && Character.isWhitespace(editorText.charAt(bodyStart))) bodyStart ++;
- while (bodyEnd > 0 && Character.isWhitespace(editorText.charAt(bodyEnd - 1))) bodyEnd --;
+ while (bodyStart < textLength && Character.isWhitespace(editorText.charAt(bodyStart))) bodyStart++;
+ while (bodyEnd > 0 && bodyStart < bodyEnd && Character.isWhitespace(editorText.charAt(bodyEnd - 1))) bodyEnd--;
result.addAll(expandToWholeLine(editorText, new TextRange(bodyStart, bodyEnd)));
}
iterator.advance();
@@ -69,5 +68,4 @@
result.add(e.getTextRange());
return result;
}
-
}
\ No newline at end of file
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/EnterHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/EnterHandler.java
index 9fc8492..8eddff1 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/EnterHandler.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/EnterHandler.java
@@ -27,7 +27,6 @@
import com.intellij.lexer.Lexer;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
-import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.*;
@@ -451,7 +450,7 @@
}
if ((commentContext.docAsterisk || commentContext.slashSlash) && !commentContext.docStart) {
- myCaretAdvance += commentContext.slashSlash ? commentContext.commenter.getLineCommentPrefix().length() : 1;
+ myCaretAdvance += commentContext.slashSlash ? commentContext.commenter.getLineCommentPrefix().trim().length() : 1;
}
}
catch (IncorrectOperationException e) {
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/enter/EnterInLineCommentHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/enter/EnterInLineCommentHandler.java
index 8a0d8d4..f09d798 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/enter/EnterInLineCommentHandler.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/enter/EnterInLineCommentHandler.java
@@ -48,7 +48,6 @@
if (offset < document.getTextLength() && text.charAt(offset) != '\n') {
String prefix = commenter.getLineCommentPrefix();
assert prefix != null: "Line Comment type is set but Line Comment Prefix is null!";
- prefix = prefix.trim();
if (!StringUtil.startsWith(text, offset, prefix)) {
if (text.charAt(caretOffset) != ' ' && !prefix.endsWith(" ")) {
prefix += " ";
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/generation/SelfManagingCommenterUtil.java b/platform/lang-impl/src/com/intellij/codeInsight/generation/SelfManagingCommenterUtil.java
new file mode 100644
index 0000000..1efdcea
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/codeInsight/generation/SelfManagingCommenterUtil.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.codeInsight.generation;
+
+import com.intellij.openapi.editor.Document;
+import com.intellij.openapi.util.TextRange;
+import com.intellij.util.text.CharArrayUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * @author ignatov
+ */
+public class SelfManagingCommenterUtil {
+ @Nullable
+ public static TextRange getBlockCommentRange(int selectionStart,
+ int selectionEnd,
+ @NotNull Document document,
+ @NotNull String prefix,
+ @NotNull String suffix) {
+ CharSequence sequence = document.getCharsSequence();
+ selectionStart = CharArrayUtil.shiftForward(sequence, selectionStart, " \t\n");
+ selectionEnd = CharArrayUtil.shiftBackward(sequence, selectionEnd - 1, " \t\n") + 1;
+
+ if (selectionEnd < selectionStart) {
+ selectionEnd = selectionStart;
+ }
+
+ if (CharArrayUtil.regionMatches(sequence, selectionEnd - suffix.length(), suffix) &&
+ CharArrayUtil.regionMatches(sequence, selectionStart, prefix)) {
+ return new TextRange(selectionStart, selectionEnd);
+ }
+ return null;
+ }
+
+ @NotNull
+ public static TextRange insertBlockComment(int startOffset,
+ int endOffset,
+ @NotNull Document document,
+ @NotNull String prefix,
+ @NotNull String suffix) {
+ document.insertString(startOffset, prefix);
+ document.insertString(endOffset + prefix.length(), suffix);
+ return new TextRange(startOffset, endOffset + prefix.length() + suffix.length());
+ }
+
+ public static void uncommentBlockComment(int startOffset,
+ int endOffset,
+ @NotNull Document document,
+ @NotNull String prefix,
+ @NotNull String suffix) {
+ document.deleteString(endOffset - suffix.length(), endOffset);
+ document.deleteString(startOffset, startOffset + prefix.length());
+ }
+}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceHighlightingHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceHighlightingHandler.java
index f5596d8..f8274729 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceHighlightingHandler.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceHighlightingHandler.java
@@ -409,7 +409,7 @@
return;
}
- EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
+ EditorColorsScheme scheme = myEditor.getColorsScheme();
final TextAttributes attributes =
matched ? scheme.getAttributes(CodeInsightColors.MATCHED_BRACE_ATTRIBUTES)
: scheme.getAttributes(CodeInsightColors.UNMATCHED_BRACE_ATTRIBUTES);
@@ -466,7 +466,7 @@
}
private void highlightBrace(@NotNull TextRange braceRange, boolean matched) {
- EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
+ EditorColorsScheme scheme = myEditor.getColorsScheme();
final TextAttributes attributes =
matched ? scheme.getAttributes(CodeInsightColors.MATCHED_BRACE_ATTRIBUTES)
: scheme.getAttributes(CodeInsightColors.UNMATCHED_BRACE_ATTRIBUTES);
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hint/ShowParameterInfoContext.java b/platform/lang-impl/src/com/intellij/codeInsight/hint/ShowParameterInfoContext.java
index 562fd9a..5f61a84 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/hint/ShowParameterInfoContext.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/hint/ShowParameterInfoContext.java
@@ -16,6 +16,7 @@
package com.intellij.codeInsight.hint;
import com.intellij.codeInsight.lookup.LookupManager;
+import com.intellij.injected.editor.EditorWindow;
import com.intellij.lang.parameterInfo.CreateParameterInfoContext;
import com.intellij.lang.parameterInfo.ParameterInfoHandler;
import com.intellij.openapi.application.ApplicationManager;
@@ -141,7 +142,8 @@
HintHint hintHint = HintManagerImpl.createHintHint(editor, pos.getFirst(), hint, pos.getSecond());
hintHint.setExplicitClose(true);
- hintManager.showEditorHint(hint, editor, pos.getFirst(), HintManager.HIDE_BY_ESCAPE | HintManager.UPDATE_BY_SCROLLING, 0, false, hintHint);
+ Editor editorToShow = editor instanceof EditorWindow ? ((EditorWindow)editor).getDelegate() : editor;
+ hintManager.showEditorHint(hint, editorToShow, pos.getFirst(), HintManager.HIDE_BY_ESCAPE | HintManager.UPDATE_BY_SCROLLING, 0, false, hintHint);
new ParameterInfoController(project, editor, elementStart, hint, handler, provider);
}
});
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hint/actions/NextParameterAction.java b/platform/lang-impl/src/com/intellij/codeInsight/hint/actions/NextParameterAction.java
index 8bb50f9..9bf90de 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/hint/actions/NextParameterAction.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/hint/actions/NextParameterAction.java
@@ -25,5 +25,6 @@
public class NextParameterAction extends EditorAction {
public NextParameterAction() {
super(new PrevNextParameterHandler(true));
+ setInjectedContext(true);
}
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hint/actions/PrevParameterAction.java b/platform/lang-impl/src/com/intellij/codeInsight/hint/actions/PrevParameterAction.java
index 678de36..ec8f8b9 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/hint/actions/PrevParameterAction.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/hint/actions/PrevParameterAction.java
@@ -25,5 +25,6 @@
public class PrevParameterAction extends EditorAction {
public PrevParameterAction() {
super(new PrevNextParameterHandler(false));
+ setInjectedContext(true);
}
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionSettingsConfigurable.java b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionSettingsConfigurable.java
index 46c9490..cdeee7a 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionSettingsConfigurable.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionSettingsConfigurable.java
@@ -105,7 +105,7 @@
@Override
public Runnable enableSearch(String option) {
- return myPanel.showOption(this, option);
+ return myPanel.showOption(option);
}
@Override
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionSettingsPanel.java b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionSettingsPanel.java
index 68c6b36..bba8e74 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionSettingsPanel.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionSettingsPanel.java
@@ -19,7 +19,6 @@
import com.intellij.ide.ui.search.SearchUtil;
import com.intellij.ide.ui.search.SearchableOptionsRegistrar;
import com.intellij.openapi.options.MasterDetails;
-import com.intellij.openapi.options.SearchableConfigurable;
import com.intellij.openapi.ui.DetailsComponent;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.GuiUtils;
@@ -189,11 +188,9 @@
}
try {
final TextDescriptor description = metaData.getDescription();
- if (description != null) {
- if (StringUtil.containsIgnoreCase(description.getText(), stripped)){
- if (!forceInclude) return true;
- } else if (forceInclude) return false;
- }
+ if (StringUtil.containsIgnoreCase(description.getText(), stripped)){
+ if (!forceInclude) return true;
+ } else if (forceInclude) return false;
}
catch (IOException e) {
//skip then
@@ -214,7 +211,7 @@
return forceInclude;
}
- public Runnable showOption(final SearchableConfigurable configurable, final String option) {
+ public Runnable showOption(final String option) {
return new Runnable() {
@Override
public void run() {
@@ -223,7 +220,4 @@
}
};
}
-
- public void clearSearch() {
- }
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java
index c7e2161..46c9b34 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java
@@ -415,7 +415,6 @@
}
requestResize();
refreshUi(false, true);
- ensureSelectionVisible();
}
public void setStartCompletionWhenNothingMatches(boolean startCompletionWhenNothingMatches) {
@@ -426,10 +425,23 @@
return myStartCompletionWhenNothingMatches;
}
- public void ensureSelectionVisible() {
- if (!isSelectionVisible()) {
- ListScrollingUtil.ensureIndexIsVisible(myList, myList.getSelectedIndex(), 1);
+ public void ensureSelectionVisible(boolean forceTopSelection) {
+ if (isSelectionVisible() && !forceTopSelection) {
+ return;
}
+
+ // selected item should be at the top of the visible list
+ int top = myList.getSelectedIndex();
+ if (top > 0) {
+ top--; // show one element above the selected one to give the hint that there are more available via scrolling
+ }
+
+ int firstVisibleIndex = myList.getFirstVisibleIndex();
+ if (firstVisibleIndex == top) {
+ return;
+ }
+
+ ListScrollingUtil.ensureRangeIsVisible(myList, top, top + myList.getLastVisibleIndex() - firstVisibleIndex);
}
boolean truncatePrefix(boolean preserveSelection) {
@@ -449,7 +461,6 @@
requestResize();
if (shouldUpdate) {
refreshUi(false, true);
- ensureSelectionVisible();
}
return true;
@@ -737,6 +748,7 @@
return lookupString;
}
+ @Override
public int getLookupStart() {
return myOffsets.getLookupStart(disposeTrace);
}
@@ -1299,7 +1311,7 @@
HintManagerImpl.updateLocation(this, myEditor, rectangle.getLocation());
if (reused || selectionVisible || onExplicitAction) {
- ensureSelectionVisible();
+ ensureSelectionVisible(onExplicitAction);
}
}
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/actions/ChooseItemAction.java b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/actions/ChooseItemAction.java
index 1295027..693c8ca 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/actions/ChooseItemAction.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/actions/ChooseItemAction.java
@@ -22,6 +22,8 @@
import com.intellij.codeInsight.lookup.Lookup;
import com.intellij.codeInsight.lookup.LookupManager;
import com.intellij.codeInsight.lookup.impl.LookupImpl;
+import com.intellij.codeInsight.template.CustomLiveTemplate;
+import com.intellij.codeInsight.template.CustomTemplateCallback;
import com.intellij.codeInsight.template.impl.*;
import com.intellij.featureStatistics.FeatureUsageTracker;
import com.intellij.openapi.actionSystem.DataContext;
@@ -110,8 +112,21 @@
final LiveTemplateLookupElement liveTemplateLookup = ContainerUtil.findInstance(lookup.getItems(), LiveTemplateLookupElement.class);
if (liveTemplateLookup == null) {
- // Lookup doesn't contain live templates. It means that there are no any live template or completion provider worked too long.
- // Anyway in this case we should find live template with appropriate prefix (custom live templates should not participate in this action).
+ // Lookup doesn't contain live templates. It means that
+ // - there are no any live template:
+ // in this case we should find live template with appropriate prefix (custom live templates doesn't participate in this action).
+ // - completion provider worked too long:
+ // in this case we should check custom templates that provides completion lookup.
+
+ final CustomTemplateCallback callback = new CustomTemplateCallback(editor, file, false);
+ for (CustomLiveTemplate customLiveTemplate : CustomLiveTemplate.EP_NAME.getExtensions()) {
+ final int offset = editor.getCaretModel().getOffset();
+ if (customLiveTemplate.getShortcut() == shortcutChar && customLiveTemplate.hasCompletionItem(file, offset)) {
+ return customLiveTemplate.computeTemplateKey(callback) != null;
+ }
+ }
+
+
final int end = editor.getCaretModel().getOffset();
final int start = lookup.getLookupStart();
final String prefix = !lookup.getItems().isEmpty()
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/navigation/CtrlMouseHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/navigation/CtrlMouseHandler.java
index 85bc7fd..f66fb88 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/CtrlMouseHandler.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/CtrlMouseHandler.java
@@ -101,8 +101,8 @@
public class CtrlMouseHandler extends AbstractProjectComponent {
private static final AbstractDocumentationTooltipAction[] ourTooltipActions = {new ShowQuickDocAtPinnedWindowFromTooltipAction()};
- private static Key<Boolean> ourDebuggerHighlighterKey;
- private static Key<Boolean> ourXDebuggerHighlighterKey;
+ private static Key<?> ourDebuggerHighlighterKey;
+ private static Key<?> ourXDebuggerHighlighterKey;
private final EditorColorsManager myEditorColorsManager;
private HighlightersSet myHighlighter;
@@ -897,8 +897,7 @@
List<RangeHighlighter> highlighters = new ArrayList<RangeHighlighter>();
TextAttributes attributes = myEditorColorsManager.getGlobalScheme().getAttributes(EditorColors.REFERENCE_HYPERLINK_COLOR);
for (TextRange range : info.getRanges()) {
- TextAttributes attr = patchAttributesColor(attributes, range, editor, getOrInitDebuggerHighlighterKey());
- attr = patchAttributesColor(attributes, range, editor, getOrInitXDebuggerHighlighterKey());
+ TextAttributes attr = patchAttributesColor(attributes, range, editor);
final RangeHighlighter highlighter = editor.getMarkupModel().addRangeHighlighter(range.getStartOffset(), range.getEndOffset(),
HighlighterLayer.SELECTION + 1,
attr,
@@ -914,14 +913,15 @@
* Patches attributes to be visible under debugger active line
*/
@SuppressWarnings("UseJBColor")
- private static TextAttributes patchAttributesColor(TextAttributes attributes, TextRange range, Editor editor, Key<Boolean> key) {
- if (key != null) {
- int line = editor.offsetToLogicalPosition(range.getStartOffset()).line;
- for (RangeHighlighter highlighter : editor.getMarkupModel().getAllHighlighters()) {
-
- Boolean hasKey = highlighter.getUserData(key);
- if (hasKey != null && hasKey) {
- if (editor.offsetToLogicalPosition(highlighter.getStartOffset()).line == line) {
+ private static TextAttributes patchAttributesColor(TextAttributes attributes, TextRange range, Editor editor) {
+ int line = editor.offsetToLogicalPosition(range.getStartOffset()).line;
+ for (RangeHighlighter highlighter : editor.getMarkupModel().getAllHighlighters()) {
+ if (highlighter.getTargetArea() == HighlighterTargetArea.LINES_IN_RANGE &&
+ editor.offsetToLogicalPosition(highlighter.getStartOffset()).line == line) {
+ TextAttributes textAttributes = highlighter.getTextAttributes();
+ if (textAttributes != null) {
+ Color color = textAttributes.getBackgroundColor();
+ if (color.getBlue() > 128 && color.getRed() < 128 && color.getGreen() < 128) {
TextAttributes clone = attributes.clone();
clone.setForegroundColor(Color.orange);
clone.setEffectColor(Color.orange);
@@ -933,18 +933,6 @@
return attributes;
}
- private static Key<Boolean> getOrInitDebuggerHighlighterKey() {
- if (ourDebuggerHighlighterKey == null) {
- ourDebuggerHighlighterKey = Key.findKeyByName("HIGHLIGHTER_USERDATA_KEY");
- }
- return ourDebuggerHighlighterKey;
- }
- private static Key<Boolean> getOrInitXDebuggerHighlighterKey() {
- if (ourXDebuggerHighlighterKey == null) {
- ourXDebuggerHighlighterKey = Key.findKeyByName("EXECUTION_POINT_HIGHLIGHTER_KEY");
- }
- return ourXDebuggerHighlighterKey;
- }
private class HighlightersSet {
private final List<RangeHighlighter> myHighlighters;
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/CustomLiveTemplate.java b/platform/lang-impl/src/com/intellij/codeInsight/template/CustomLiveTemplate.java
index 3dfd9b1..a56f535 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/template/CustomLiveTemplate.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/template/CustomLiveTemplate.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.
@@ -41,4 +41,10 @@
String getTitle();
char getShortcut();
+
+ /**
+ * Implementation should returns {@code true} if it has own lookup item in completion autopopup
+ * and it is supposed that template should be expanded while completion auto-popup is active.
+ */
+ boolean hasCompletionItem(@NotNull PsiFile file, int offset);
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/editorActions/ExpandLiveTemplateByTabAction.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/editorActions/ExpandLiveTemplateByTabAction.java
index b037ff2..67aca8e 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/editorActions/ExpandLiveTemplateByTabAction.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/editorActions/ExpandLiveTemplateByTabAction.java
@@ -43,5 +43,6 @@
((TemplateManagerImpl)TemplateManager.getInstance(project)).prepareTemplate(editor, TemplateSettings.TAB_CHAR, null) != null;
}
});
+ setInjectedContext(true);
}
}
diff --git a/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java b/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java
index f0ec3f0..b1857f5 100644
--- a/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java
+++ b/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java
@@ -16,6 +16,7 @@
package com.intellij.execution.console;
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
+import com.intellij.execution.impl.ConsoleViewImpl;
import com.intellij.execution.impl.ConsoleViewUtil;
import com.intellij.execution.ui.ConsoleViewContentType;
import com.intellij.ide.DataManager;
@@ -26,10 +27,7 @@
import com.intellij.lang.annotation.HighlightSeverity;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
-import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.application.ModalityState;
-import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.*;
import com.intellij.openapi.editor.actions.EditorActionUtil;
import com.intellij.openapi.editor.colors.EditorColors;
@@ -37,7 +35,6 @@
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.colors.impl.DelegateColorScheme;
import com.intellij.openapi.editor.event.*;
-import com.intellij.openapi.editor.ex.DocumentEx;
import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.editor.ex.FocusChangeListener;
import com.intellij.openapi.editor.ex.RangeHighlighterEx;
@@ -64,9 +61,7 @@
import com.intellij.ui.JBColor;
import com.intellij.ui.SideBorder;
import com.intellij.util.FileContentUtil;
-import com.intellij.util.Function;
import com.intellij.util.ObjectUtils;
-import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.AbstractLayoutManager;
import com.intellij.util.ui.UIUtil;
import com.intellij.util.ui.update.MergingUpdateQueue;
@@ -89,7 +84,6 @@
* In case of REPL consider to use {@link com.intellij.execution.runners.LanguageConsoleBuilder}
*/
public class LanguageConsoleImpl implements Disposable, TypeSafeDataProvider {
- private static final Logger LOG = Logger.getInstance("#" + LanguageConsoleImpl.class.getName());
private static final int SEPARATOR_THICKNESS = 1;
private final Project myProject;
@@ -391,57 +385,6 @@
this.myTitle = title;
}
- public void printToHistory(@NotNull final List<Pair<String, TextAttributes>> attributedText) {
- ApplicationManager.getApplication().assertIsDispatchThread();
- if (LOG.isDebugEnabled()) {
- LOG.debug("printToHistory(): " + attributedText.size());
- }
- final boolean scrollToEnd = shouldScrollHistoryToEnd();
- final int[] offsets = new int[attributedText.size() + 1];
- int i = 0;
- offsets[i] = 0;
- final StringBuilder sb = new StringBuilder();
- for (final Pair<String, TextAttributes> pair : attributedText) {
- sb.append(StringUtil.convertLineSeparators(pair.getFirst()));
- offsets[++i] = sb.length();
- }
- final DocumentEx history = myHistoryViewer.getDocument();
- final int oldHistoryLength = history.getTextLength();
- appendToHistoryDocument(history, sb);
-
- assert oldHistoryLength + offsets[i] >= history.getTextLength()
- : "unexpected history length " + oldHistoryLength + " " + offsets[i] + " " + history.getTextLength();
-
- if (oldHistoryLength + offsets[i] != history.getTextLength()) {
- // due to usage of cyclic buffer old text can be dropped
- final int correction = oldHistoryLength + offsets[i] - history.getTextLength();
- for (i = 0; i < offsets.length; ++i) {
- offsets[i] -= correction;
- }
- }
- LOG.debug("printToHistory(): text processed");
- final MarkupModel markupModel = DocumentMarkupModel.forDocument(history, myProject, true);
- i = 0;
- for (final Pair<String, TextAttributes> pair : attributedText) {
- if (offsets[i] >= 0) {
- markupModel.addRangeHighlighter(
- oldHistoryLength + offsets[i],
- oldHistoryLength + offsets[i+1],
- HighlighterLayer.SYNTAX,
- pair.getSecond(),
- HighlighterTargetArea.EXACT_RANGE
- );
- }
- ++i;
- }
- LOG.debug("printToHistory(): markup added");
- if (scrollToEnd) {
- scrollHistoryToEnd();
- }
- queueUiUpdate(scrollToEnd);
- LOG.debug("printToHistory(): completed");
- }
-
public void printToHistory(@NotNull CharSequence text, @NotNull TextAttributes attributes) {
ApplicationManager.getApplication().assertIsDispatchThread();
text = StringUtilRt.unifyLineSeparators(text);
@@ -685,6 +628,10 @@
return myCurrentEditor == null? myConsoleEditor : myCurrentEditor;
}
+ public Language getLanguage() {
+ return myVirtualFile.getLanguage();
+ }
+
public void setLanguage(@NotNull Language language) {
myVirtualFile.setLanguage(language);
myVirtualFile.setContent(myEditorDocument, myEditorDocument.getText(), false);
@@ -701,74 +648,18 @@
});
}
- public static void printToConsole(
- @NotNull final LanguageConsoleImpl console,
- @NotNull final ConsoleViewContentType mainType,
- @NotNull final List<Pair<String, ConsoleViewContentType>> textToPrint)
- {
- final List<Pair<String, TextAttributes>> attributedText = ContainerUtil.map(
- textToPrint,
- new Function<Pair<String, ConsoleViewContentType>, Pair<String, TextAttributes>>() {
- @Override
- public Pair<String, TextAttributes> fun(Pair<String, ConsoleViewContentType> input) {
- final TextAttributes mainAttributes = mainType.getAttributes();
- final TextAttributes attributes;
- if (input.getSecond() == null) {
- attributes = mainAttributes;
- }
- else {
- attributes = input.getSecond().getAttributes().clone();
- attributes.setBackgroundColor(mainAttributes.getBackgroundColor());
- }
- return Pair.create(input.getFirst(), attributes);
- }
+ /**
+ * todo ruby plugin compatibility. Remove on the next update.
+ */
+ @Deprecated
+ public static void printToConsole(@NotNull LanguageConsoleImpl console, @NotNull ConsoleViewContentType mainType,
+ @NotNull List<Pair<String, ConsoleViewContentType>> textToPrint) {
+ ConsoleViewImpl consoleView = console.getHistoryViewer().getUserData(ConsoleViewImpl.CONSOLE_VIEW_IN_EDITOR_VIEW);
+ if (consoleView != null) {
+ for (Pair<String, ConsoleViewContentType> pair : textToPrint) {
+ consoleView.print(pair.first, ObjectUtils.chooseNotNull(pair.second, mainType));
}
- );
-
- Application application = ApplicationManager.getApplication();
- if (application.isDispatchThread()) {
- console.printToHistory(attributedText);
}
- else {
- application.invokeLater(new Runnable() {
- @Override
- public void run() {
- console.printToHistory(attributedText);
- }
- }, ModalityState.stateForComponent(console.getComponent()));
- }
- }
-
- public void printToHistoryOnEdt(@NotNull final CharSequence text, @NotNull final TextAttributes attributes) {
- Application application = ApplicationManager.getApplication();
- if (application.isDispatchThread()) {
- printToHistory(text, attributes);
- }
- else {
- application.invokeLater(new Runnable() {
- @Override
- public void run() {
- printToHistory(text, attributes);
- }
- }, ModalityState.stateForComponent(getComponent()));
- }
- }
-
- public static void printToConsole(@NotNull final LanguageConsoleImpl console,
- @NotNull final CharSequence string,
- @NotNull final ConsoleViewContentType mainType,
- @Nullable ConsoleViewContentType additionalType) {
- final TextAttributes mainAttributes = mainType.getAttributes();
- final TextAttributes attributes;
- if (additionalType == null) {
- attributes = mainAttributes;
- }
- else {
- attributes = additionalType.getAttributes().clone();
- attributes.setBackgroundColor(mainAttributes.getBackgroundColor());
- }
-
- console.printToHistoryOnEdt(string, attributes);
}
@NotNull
diff --git a/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java b/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java
index 6fa2533..817e41f 100644
--- a/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java
+++ b/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java
@@ -107,7 +107,7 @@
private final CommandLineFolding myCommandLineFolding = new CommandLineFolding();
private final DisposedPsiManagerCheck myPsiDisposedCheck;
- private final boolean isViewer;
+ private final boolean myIsViewer;
private ConsoleState myState;
@@ -127,7 +127,8 @@
private boolean myAllowHeavyFilters = false;
private static final int myFlushDelay = DEFAULT_FLUSH_DELAY;
- private boolean mySpareTimeUpdateStarted = false;
+ private boolean myInSpareTimeUpdate;
+ private boolean myInDocumentUpdate;
public Editor getEditor() {
return myEditor;
@@ -300,7 +301,7 @@
boolean usePredefinedMessageFilter)
{
super(new BorderLayout());
- isViewer = viewer;
+ myIsViewer = viewer;
myState = initialState;
myPsiDisposedCheck = new DisposedPsiManagerCheck(project);
myProject = project;
@@ -578,7 +579,7 @@
}
}
- private void printHyperlink(String s, ConsoleViewContentType contentType, @Nullable HyperlinkInfo info) {
+ private void printHyperlink(@NotNull String s, @NotNull ConsoleViewContentType contentType, @Nullable HyperlinkInfo info) {
synchronized (LOCK) {
Pair<String, Integer> pair = myBuffer.print(s, contentType, info);
s = pair.first;
@@ -596,18 +597,18 @@
}
}
+ /**
+ * todo python plugin compatibility. Remove on the next update.
+ */
+ @Deprecated
protected void beforeExternalAddContentToDocument(int length, ConsoleViewContentType contentType) {
- synchronized (LOCK) {
- myContentSize += length;
- addToken(length, null, contentType);
- }
}
private void addToken(int length, @Nullable HyperlinkInfo info, ConsoleViewContentType contentType) {
ConsoleUtil.addToken(length, info, contentType, myTokens);
}
- private ModalityState getStateForUpdate() {
+ private static ModalityState getStateForUpdate() {
return null;//myStateForUpdate != null ? myStateForUpdate.compute() : ModalityState.stateForComponent(this);
}
@@ -660,10 +661,12 @@
public void run() {
document.setInBulkUpdate(true);
try {
+ myInDocumentUpdate = true;
document.deleteString(0, documentTextLength);
}
finally {
document.setInBulkUpdate(false);
+ myInDocumentUpdate = false;
}
}
}, null, DocCommandGroupId.noneGroupId(document));
@@ -702,6 +705,7 @@
myEditor.getScrollingModel().accumulateViewportChanges();
}
try {
+ myInDocumentUpdate = true;
String[] strings = text.split("\\r");
for (int i = 0; i < strings.length - 1; i++) {
document.insertString(document.getTextLength(), strings[i]);
@@ -717,6 +721,7 @@
}
}
finally {
+ myInDocumentUpdate = false;
if (preserveCurrentVisualArea) {
myEditor.getScrollingModel().flushViewportChanges();
}
@@ -741,8 +746,8 @@
final int newLineCount = document.getLineCount();
if (cycleUsed) {
clearHyperlinkAndFoldings();
- if (!mySpareTimeUpdateStarted) {
- mySpareTimeUpdateStarted = true;
+ if (!myInSpareTimeUpdate) {
+ myInSpareTimeUpdate = true;
final EditorNotificationPanel comp = new EditorNotificationPanel() {
{
myLabel.setIcon(AllIcons.General.ExclMark);
@@ -759,7 +764,7 @@
highlightHyperlinksAndFoldings(0, document.getLineCount() - 1);
}
finally {
- mySpareTimeUpdateStarted = false;
+ myInSpareTimeUpdate = false;
remove(comp);
}
}
@@ -874,50 +879,62 @@
popupInvoked(event.getMouseEvent());
}
});
+ editor.getDocument().addDocumentListener(new DocumentListener() {
+ @Override
+ public void beforeDocumentChange(DocumentEvent event) {
+ }
+ @Override
+ public void documentChanged(DocumentEvent event) {
+ onDocumentChanged(event);
+ }
+ }, ConsoleViewImpl.this);
- final int bufferSize = myBuffer.isUseCyclicBuffer() ? myBuffer.getCyclicBufferSize() : 0;
+ int bufferSize = myBuffer.isUseCyclicBuffer() ? myBuffer.getCyclicBufferSize() : 0;
editor.getDocument().setCyclicBufferSize(bufferSize);
editor.putUserData(CONSOLE_VIEW_IN_EDITOR_VIEW, ConsoleViewImpl.this);
+ editor.getSettings().setAllowSingleLogicalLineFolding(true); // We want to fold long soft-wrapped command lines
+ editor.setHighlighter(createHighlighter());
+
+ if (!myIsViewer) {
+ registerConsoleEditorActions(editor);
+ }
return editor;
}
});
}
- protected EditorEx createRealEditor() {
- final EditorEx editor = ConsoleViewUtil.setupConsoleEditor(myProject, true, false);
-
- editor.getDocument().addDocumentListener(new DocumentListener() {
- @Override
- public void beforeDocumentChange(DocumentEvent event) {
+ private void onDocumentChanged(DocumentEvent event) {
+ if (event.getNewLength() == 0) {
+ // string has been removed, adjust token ranges
+ synchronized (LOCK) {
+ ConsoleUtil.updateTokensOnTextRemoval(myTokens, event.getOffset(), event.getOffset() + event.getOldLength());
+ int toRemoveLen = event.getOldLength();
+ myContentSize -= Math.min(myContentSize, toRemoveLen);
}
-
- @Override
- public void documentChanged(DocumentEvent event) {
- if (event.getNewLength() == 0) {
- // string has been removed, adjust token ranges
- synchronized (LOCK) {
- ConsoleUtil.updateTokensOnTextRemoval(myTokens, event.getOffset(), event.getOffset() + event.getOldLength());
- int toRemoveLen = event.getOldLength();
- myContentSize -= Math.min(myContentSize, toRemoveLen);
- }
- }
- if (myFileType != null) {
- highlightUserTokens();
- }
- }
- }, this);
-
- editor.getSettings().setAllowSingleLogicalLineFolding(true); // We want to fold long soft-wrapped command lines
- editor.setHighlighter(createHighlighter());
-
- if (!isViewer) {
- setEditorUpActions(editor);
}
+ else if (!myInDocumentUpdate) {
+ int newFragmentLength = event.getNewFragment().length();
+ // track external appends
+ if (event.getOldFragment().length() == 0 && newFragmentLength > 0) {
+ synchronized (LOCK) {
+ myContentSize += newFragmentLength;
+ addToken(newFragmentLength, null, ConsoleViewContentType.NORMAL_OUTPUT);
+ }
+ }
+ else {
+ LOG.warn("unhandled external change: " + event);
+ }
+ }
+ if (myFileType != null) {
+ highlightUserTokens();
+ }
+ }
- return editor;
+ protected EditorEx createRealEditor() {
+ return ConsoleViewUtil.setupConsoleEditor(myProject, true, false);
}
protected MyHighlighter createHighlighter() {
@@ -958,7 +975,7 @@
}
}
- private static void setEditorUpActions(final Editor editor) {
+ private static void registerConsoleEditorActions(Editor editor) {
new EnterHandler().registerCustomShortcutSet(CommonShortcuts.ENTER, editor.getContentComponent());
registerActionHandler(editor, IdeActions.ACTION_EDITOR_PASTE, new PasteHandler());
registerActionHandler(editor, IdeActions.ACTION_EDITOR_BACKSPACE, new BackSpaceHandler());
@@ -1140,8 +1157,8 @@
if (oStart > 0) oStart--;
int oEnd = CharArrayUtil.shiftBackward(chars, document.getLineEndOffset(lEnd) - 1, " \t") + 1;
- FoldRegion region =
- myEditor.getFoldingModel().createFoldRegion(oStart, oEnd, prevFolding.getPlaceholderText(toFold), null, false);
+ String placeholder = prevFolding.getPlaceholderText(toFold);
+ FoldRegion region = placeholder == null ? null : myEditor.getFoldingModel().createFoldRegion(oStart, oEnd, placeholder, null, false);
if (region != null) {
toAdd.add(region);
}
@@ -1266,7 +1283,7 @@
@Override
public void execute(@NotNull final Editor editor, final char charTyped, @NotNull final DataContext dataContext) {
final ConsoleViewImpl consoleView = editor.getUserData(CONSOLE_VIEW_IN_EDITOR_VIEW);
- if (consoleView == null || !consoleView.myState.isRunning() || consoleView.isViewer) {
+ if (consoleView == null || !consoleView.myState.isRunning() || consoleView.myIsViewer) {
if (myOriginalHandler != null) myOriginalHandler.execute(editor, charTyped, dataContext);
}
else {
@@ -1641,7 +1658,13 @@
consoleView.myContentSize += charCountToAdd;
}
- document.insertString(startOffset, textToUse);
+ try {
+ myInDocumentUpdate = true;
+ document.insertString(startOffset, textToUse);
+ }
+ finally {
+ myInDocumentUpdate = false;
+ }
// Math.max is needed when cyclic buffer is used
editor.getCaretModel().moveToOffset(Math.min(startOffset + textToUse.length(), document.getTextLength()));
editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
@@ -1701,7 +1724,13 @@
consoleView.myContentSize += charCountToReplace;
}
- document.replaceString(startOffset, endOffset, s);
+ try {
+ myInDocumentUpdate = true;
+ document.replaceString(startOffset, endOffset, s);
+ }
+ finally {
+ myInDocumentUpdate = false;
+ }
editor.getCaretModel().moveToOffset(startOffset + s.length());
editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
editor.getSelectionModel().removeSelection();
@@ -1710,8 +1739,8 @@
/**
* delete text
*
- * @param offset relativly to all document text
- * @param length lenght of deleted text
+ * @param offset relatively to all document text
+ * @param length length of deleted text
*/
private void deleteUserText(int offset, int length) {
ConsoleViewImpl consoleView = this;
@@ -1742,7 +1771,13 @@
buffer.removeUserText(startOffset - deferredOffset, endOffset - deferredOffset);
}
- document.deleteString(startOffset, endOffset);
+ try {
+ myInDocumentUpdate = true;
+ document.deleteString(startOffset, endOffset);
+ }
+ finally {
+ myInDocumentUpdate = false;
+ }
editor.getCaretModel().moveToOffset(startOffset);
editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
editor.getSelectionModel().removeSelection();
diff --git a/platform/lang-impl/src/com/intellij/execution/impl/RunConfigurable.java b/platform/lang-impl/src/com/intellij/execution/impl/RunConfigurable.java
index 418eefd..f8b5143 100644
--- a/platform/lang-impl/src/com/intellij/execution/impl/RunConfigurable.java
+++ b/platform/lang-impl/src/com/intellij/execution/impl/RunConfigurable.java
@@ -45,8 +45,7 @@
import com.intellij.util.IconUtil;
import com.intellij.util.PlatformIcons;
import com.intellij.util.config.StorageAccessors;
-import com.intellij.util.containers.ContainerUtil;
-import com.intellij.util.containers.Convertor;
+import com.intellij.util.containers.*;
import com.intellij.util.containers.HashMap;
import com.intellij.util.ui.EditableModel;
import com.intellij.util.ui.EmptyIcon;
@@ -68,6 +67,7 @@
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.util.*;
+import java.util.HashSet;
import java.util.List;
import static com.intellij.execution.impl.RunConfigurable.NodeKind.*;
@@ -1079,31 +1079,35 @@
@Override
public void actionPerformed(AnActionEvent e) {
- showAddPopup();
+ showAddPopup(true);
}
@Override
public void run(AnActionButton button) {
- showAddPopup();
+ showAddPopup(true);
}
- private void showAddPopup() {
- final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
- final ConfigurationType[] configurationTypes = getRunManager().getConfigurationFactories(false);
- Arrays.sort(configurationTypes, new Comparator<ConfigurationType>() {
+ private void showAddPopup(final boolean showApplicableTypesOnly) {
+ ConfigurationType[] allTypes = getRunManager().getConfigurationFactories(false);
+ final List<ConfigurationType> configurationTypes = getTypesToShow(showApplicableTypesOnly, allTypes);
+ Collections.sort(configurationTypes, new Comparator<ConfigurationType>() {
@Override
public int compare(final ConfigurationType type1, final ConfigurationType type2) {
- return type1.getDisplayName().compareTo(type2.getDisplayName());
+ return type1.getDisplayName().compareToIgnoreCase(type2.getDisplayName());
}
});
- final ListPopup popup =
- popupFactory.createListPopup(new BaseListPopupStep<ConfigurationType>(
+ final int hiddenCount = allTypes.length - configurationTypes.size();
+ if (hiddenCount > 0) {
+ configurationTypes.add(null);
+ }
+
+ final ListPopup popup = JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<ConfigurationType>(
ExecutionBundle.message("add.new.run.configuration.acrtion.name"), configurationTypes) {
@Override
@NotNull
public String getTextFor(final ConfigurationType type) {
- return type.getDisplayName();
+ return type != null ? type.getDisplayName() : "(" + hiddenCount + " more items)";
}
@Override
@@ -1118,7 +1122,7 @@
@Override
public Icon getIconFor(final ConfigurationType type) {
- return type.getIcon();
+ return type != null ? type.getIcon() : EmptyIcon.ICON_16;
}
@Override
@@ -1126,6 +1130,15 @@
if (hasSubstep(type)) {
return getSupStep(type);
}
+ if (type == null) {
+ return doFinalStep(new Runnable() {
+ @Override
+ public void run() {
+ showAddPopup(false);
+ }
+ });
+ }
+
final ConfigurationFactory[] factories = type.getConfigurationFactories();
if (factories.length > 0) {
createNewConfiguration(factories[0]);
@@ -1136,7 +1149,7 @@
@Override
public int getDefaultOptionIndex() {
ConfigurationType type = getSelectedConfigurationType();
- return type != null ? ArrayUtilRt.find(configurationTypes, type) : super.getDefaultOptionIndex();
+ return type != null ? configurationTypes.indexOf(type) : super.getDefaultOptionIndex();
}
private ListPopupStep getSupStep(final ConfigurationType type) {
@@ -1144,7 +1157,7 @@
Arrays.sort(factories, new Comparator<ConfigurationFactory>() {
@Override
public int compare(final ConfigurationFactory factory1, final ConfigurationFactory factory2) {
- return factory1.getName().compareTo(factory2.getName());
+ return factory1.getName().compareToIgnoreCase(factory2.getName());
}
});
return new BaseListPopupStep<ConfigurationFactory>(
@@ -1166,19 +1179,41 @@
createNewConfiguration(factory);
return FINAL_CHOICE;
}
-
};
}
@Override
public boolean hasSubstep(final ConfigurationType type) {
- return type.getConfigurationFactories().length > 1;
+ return type != null && type.getConfigurationFactories().length > 1;
}
-
});
//new TreeSpeedSearch(myTree);
popup.showUnderneathOf(myToolbarDecorator.getActionsPanel());
}
+
+ private List<ConfigurationType> getTypesToShow(boolean showApplicableTypesOnly, ConfigurationType[] allTypes) {
+ if (showApplicableTypesOnly) {
+ List<ConfigurationType> applicableTypes = new ArrayList<ConfigurationType>();
+ for (ConfigurationType type : allTypes) {
+ if (isApplicable(type)) {
+ applicableTypes.add(type);
+ }
+ }
+ if (applicableTypes.size() < allTypes.length - 1) {
+ return applicableTypes;
+ }
+ }
+ return new ArrayList<ConfigurationType>(Arrays.asList(allTypes));
+ }
+
+ private boolean isApplicable(ConfigurationType type) {
+ for (ConfigurationFactory factory : type.getConfigurationFactories()) {
+ if (factory.isApplicable(myProject)) {
+ return true;
+ }
+ }
+ return false;
+ }
}
diff --git a/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/RunnerContentUi.java b/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/RunnerContentUi.java
index 6bd3eb4..4c9425d 100644
--- a/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/RunnerContentUi.java
+++ b/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/RunnerContentUi.java
@@ -236,7 +236,7 @@
myComponent.setContent(wrappper);
- myTabs.addListener(new TabsListener() {
+ myTabs.addListener(new TabsListener.Adapter() {
@Override
public void beforeSelectionChanged(TabInfo oldSelection, TabInfo newSelection) {
@@ -449,6 +449,11 @@
return new RelativeRectangle(myTabs.getComponent());
}
+ @Override
+ public RelativeRectangle getAcceptAreaFallback() {
+ return getAcceptArea();
+ }
+
@NotNull
@Override
public ContentResponse getContentResponse(@NotNull DockableContent content, RelativePoint point) {
diff --git a/platform/lang-impl/src/com/intellij/formatting/AbstractBlockWrapper.java b/platform/lang-impl/src/com/intellij/formatting/AbstractBlockWrapper.java
index d2a9b2b..7896c1b 100644
--- a/platform/lang-impl/src/com/intellij/formatting/AbstractBlockWrapper.java
+++ b/platform/lang-impl/src/com/intellij/formatting/AbstractBlockWrapper.java
@@ -81,6 +81,12 @@
return myWhiteSpace;
}
+ /**
+ * Returns the list of wraps for this block and its parent blocks that start at the same offset. The returned list is ordered from top
+ * to bottom (higher-level wraps go first). Stops if the wrap for a block is marked as "ignore parent wraps".
+ *
+ * @return the list of wraps.
+ */
public ArrayList<WrapImpl> getWraps() {
final ArrayList<WrapImpl> result = new ArrayList<WrapImpl>(3);
AbstractBlockWrapper current = this;
@@ -342,7 +348,7 @@
IndentData indent = getIndent(indentOption, index, childIndent);
if (childIndent.isRelativeToDirectParent()) {
- return new IndentData(indent.getIndentSpaces() + CoreFormatterUtil.getOffsetBefore(CoreFormatterUtil.getFirstLeaf(this)),
+ return new IndentData(indent.getIndentSpaces() + CoreFormatterUtil.getStartColumn(CoreFormatterUtil.getFirstLeaf(this)),
indent.getSpaces());
}
if (myParent == null || (myFlags & CAN_USE_FIRST_CHILD_INDENT_AS_BLOCK_INDENT) != 0 && getWhiteSpace().containsLineFeeds()) {
diff --git a/platform/lang-impl/src/com/intellij/formatting/CoreFormatterUtil.java b/platform/lang-impl/src/com/intellij/formatting/CoreFormatterUtil.java
index 59e9b26..b9b8bbf 100644
--- a/platform/lang-impl/src/com/intellij/formatting/CoreFormatterUtil.java
+++ b/platform/lang-impl/src/com/intellij/formatting/CoreFormatterUtil.java
@@ -90,7 +90,7 @@
* @param block target wrapped block to be used at a boundary during counting non-line feed symbols to the left of it
* @return non-line feed symbols to the left of the given wrapped block
*/
- public static int getOffsetBefore(@Nullable LeafBlockWrapper block) {
+ public static int getStartColumn(@Nullable LeafBlockWrapper block) {
if (block != null) {
int result = 0;
while (true) {
diff --git a/platform/lang-impl/src/com/intellij/formatting/FormatProcessor.java b/platform/lang-impl/src/com/intellij/formatting/FormatProcessor.java
index 2865822..5786bc8 100644
--- a/platform/lang-impl/src/com/intellij/formatting/FormatProcessor.java
+++ b/platform/lang-impl/src/com/intellij/formatting/FormatProcessor.java
@@ -452,7 +452,7 @@
}
try {
- if (processWrap(spaceProperty)) {
+ if (processWrap()) {
return;
}
}
@@ -525,24 +525,31 @@
return whiteSpace.getStartOffset() < dependency.getEndOffset();
}
- private boolean processWrap(SpacingImpl spacing) {
+ /**
+ * Processes the wrap of the current block.
+ *
+ * @return true if we have changed myCurrentBlock and need to restart its processing; false if myCurrentBlock is unchanged and we can
+ * continue processing
+ */
+ private boolean processWrap() {
+ final SpacingImpl spacing = myCurrentBlock.getSpaceProperty();
final WhiteSpace whiteSpace = myCurrentBlock.getWhiteSpace();
- boolean wrapWasPresent = whiteSpace.containsLineFeeds();
+ final boolean wrapWasPresent = whiteSpace.containsLineFeeds();
if (wrapWasPresent) {
myFirstWrappedBlockOnLine = null;
+
+ if (!whiteSpace.containsLineFeedsInitially()) {
+ whiteSpace.removeLineFeeds(spacing, this);
+ }
}
- if (whiteSpace.containsLineFeeds() && !whiteSpace.containsLineFeedsInitially()) {
- whiteSpace.removeLineFeeds(spacing, this);
- }
-
- boolean wrapIsPresent = whiteSpace.containsLineFeeds();
+ final boolean wrapIsPresent = whiteSpace.containsLineFeeds();
final ArrayList<WrapImpl> wraps = myCurrentBlock.getWraps();
for (WrapImpl wrap : wraps) {
- wrap.processNextEntry(myCurrentBlock.getStartOffset());
+ wrap.setWrapOffset(myCurrentBlock.getStartOffset());
}
final WrapImpl wrap = getWrapToBeUsed(wraps);
@@ -552,18 +559,20 @@
myCurrentBlock = myWrapCandidate;
return true;
}
- if (wrap != null && wrap.getFirstEntry() != null) {
- myCurrentBlock = wrap.getFirstEntry();
- wrap.markAsUsed();
+ if (wrap != null && wrap.getChopStartBlock() != null) {
+ // getWrapToBeUsed() returns the block only if it actually exceeds the right margin. In this case, we need to go back to the
+ // first block that has the CHOP_IF_NEEDED wrap type and start wrapping from there.
+ myCurrentBlock = wrap.getChopStartBlock();
+ wrap.setActive();
return true;
}
- if (wrap != null && wrapCanBeUsedInTheFuture(wrap)) {
- wrap.markAsUsed();
+ if (wrap != null && isChopNeeded(wrap)) {
+ wrap.setActive();
}
- if (!whiteSpace.containsLineFeeds()) {
+ if (!wrapIsPresent) {
whiteSpace.ensureLineFeed();
- if (!wrapWasPresent && wrap != null) {
+ if (!wrapWasPresent) {
if (myFirstWrappedBlockOnLine != null && wrap.isChildOf(myFirstWrappedBlockOnLine.getWrap(), myCurrentBlock)) {
wrap.ignoreParentWrap(myFirstWrappedBlockOnLine.getWrap(), myCurrentBlock);
myCurrentBlock = myFirstWrappedBlockOnLine;
@@ -582,8 +591,8 @@
if (isCandidateToBeWrapped(wrap1) && canReplaceWrapCandidate(wrap1)) {
myWrapCandidate = myCurrentBlock;
}
- if (wrapCanBeUsedInTheFuture(wrap1)) {
- wrap1.saveFirstEntry(myCurrentBlock);
+ if (isChopNeeded(wrap1)) {
+ wrap1.saveChopBlock(myCurrentBlock);
}
}
}
@@ -606,7 +615,7 @@
private boolean canReplaceWrapCandidate(WrapImpl wrap) {
if (myWrapCandidate == null) return true;
WrapImpl.Type type = wrap.getType();
- if (wrap.isIsActive() && (type == WrapImpl.Type.CHOP_IF_NEEDED || type == WrapImpl.Type.WRAP_ALWAYS)) return true;
+ if (wrap.isActive() && (type == WrapImpl.Type.CHOP_IF_NEEDED || type == WrapImpl.Type.WRAP_ALWAYS)) return true;
final WrapImpl currentWrap = myWrapCandidate.getWrap();
return wrap == currentWrap || !wrap.isChildOf(currentWrap, myCurrentBlock);
}
@@ -731,12 +740,12 @@
myCurrentBlock.getWhiteSpace().setSpaces(offset.getSpaces(), offset.getIndentSpaces());
}
- private boolean wrapCanBeUsedInTheFuture(final WrapImpl wrap) {
+ private boolean isChopNeeded(final WrapImpl wrap) {
return wrap != null && wrap.getType() == WrapImpl.Type.CHOP_IF_NEEDED && isSuitableInTheCurrentPosition(wrap);
}
private boolean isSuitableInTheCurrentPosition(final WrapImpl wrap) {
- if (wrap.getFirstPosition() < myCurrentBlock.getStartOffset()) {
+ if (wrap.getWrapOffset() < myCurrentBlock.getStartOffset()) {
return true;
}
@@ -762,11 +771,11 @@
final int spaces = whiteSpace.getSpaces();
int indentSpaces = whiteSpace.getIndentSpaces();
try {
- final int offsetBefore = CoreFormatterUtil.getOffsetBefore(myCurrentBlock);
+ final int startColumnNow = CoreFormatterUtil.getStartColumn(myCurrentBlock);
whiteSpace.ensureLineFeed();
adjustLineIndent();
- final int offsetAfter = CoreFormatterUtil.getOffsetBefore(myCurrentBlock);
- return offsetBefore > offsetAfter;
+ final int startColumnAfterWrap = CoreFormatterUtil.getStartColumn(myCurrentBlock);
+ return startColumnNow > startColumnAfterWrap;
}
finally {
whiteSpace.removeLineFeeds(myCurrentBlock.getSpaceProperty(), this);
@@ -783,7 +792,7 @@
for (final WrapImpl wrap : wraps) {
if (!isSuitableInTheCurrentPosition(wrap)) continue;
- if (wrap.isIsActive()) return wrap;
+ if (wrap.isActive()) return wrap;
final WrapImpl.Type type = wrap.getType();
if (type == WrapImpl.Type.WRAP_ALWAYS) return wrap;
@@ -802,7 +811,7 @@
*/
private boolean lineOver() {
return !myCurrentBlock.containsLineFeeds() &&
- CoreFormatterUtil.getOffsetBefore(myCurrentBlock) + myCurrentBlock.getLength() > mySettings.RIGHT_MARGIN;
+ CoreFormatterUtil.getStartColumn(myCurrentBlock) + myCurrentBlock.getLength() > mySettings.RIGHT_MARGIN;
}
private void defineAlignOffset(final LeafBlockWrapper block) {
@@ -836,7 +845,7 @@
return new IndentData(whiteSpace.getIndentSpaces(), whiteSpace.getSpaces());
}
else {
- final int offsetBeforeBlock = CoreFormatterUtil.getOffsetBefore(offsetResponsibleBlock);
+ final int offsetBeforeBlock = CoreFormatterUtil.getStartColumn(offsetResponsibleBlock);
final AbstractBlockWrapper indentedParentBlock = CoreFormatterUtil.getIndentedParentBlock(myCurrentBlock);
if (indentedParentBlock == null) {
return new IndentData(0, offsetBeforeBlock);
@@ -1018,7 +1027,7 @@
if (alignment == null) return -1;
final LeafBlockWrapper alignRespBlock = ((AlignmentImpl)alignment).getOffsetRespBlockBefore(blockAfter);
if (alignRespBlock != null) {
- return CoreFormatterUtil.getOffsetBefore(alignRespBlock);
+ return CoreFormatterUtil.getStartColumn(alignRespBlock);
}
else {
return -1;
diff --git a/platform/lang-impl/src/com/intellij/formatting/FormatterTagHandler.java b/platform/lang-impl/src/com/intellij/formatting/FormatterTagHandler.java
new file mode 100644
index 0000000..af5164d
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/formatting/FormatterTagHandler.java
@@ -0,0 +1,156 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.formatting;
+
+import com.intellij.lang.ASTNode;
+import com.intellij.openapi.util.TextRange;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.psi.PsiComment;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiRecursiveElementVisitor;
+import com.intellij.psi.codeStyle.CodeStyleSettings;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.regex.Pattern;
+
+/**
+ * @author Rustam Vishnyakov
+ */
+public class FormatterTagHandler {
+
+ public enum FormatterTag {ON, OFF, NONE}
+ private final CodeStyleSettings mySettings;
+
+ public FormatterTagHandler(CodeStyleSettings settings) {
+ mySettings = settings;
+ }
+
+ public FormatterTag getFormatterTag(Block block) {
+ if (mySettings.FORMATTER_TAGS_ENABLED &&
+ !StringUtil.isEmpty(mySettings.FORMATTER_ON_TAG) &&
+ !StringUtil.isEmpty(mySettings.FORMATTER_OFF_TAG) &&
+ block instanceof ASTBlock) {
+ ASTNode node = ((ASTBlock)block).getNode();
+ PsiElement element = node.getPsi();
+ if (element != null && element instanceof PsiComment) {
+ return getFormatterTag((PsiComment)element);
+ }
+ }
+ return FormatterTag.NONE;
+ }
+
+ private FormatterTag getFormatterTag(@NotNull PsiComment comment) {
+ CharSequence nodeChars = comment.getNode().getChars();
+ if (mySettings.FORMATTER_TAGS_ACCEPT_REGEXP) {
+ Pattern onPattern = mySettings.getFormatterOnPattern();
+ Pattern offPattern = mySettings.getFormatterOffPattern();
+ if (onPattern != null && onPattern.matcher(nodeChars).find()) return FormatterTag.ON;
+ if (offPattern != null && offPattern.matcher(nodeChars).find()) return FormatterTag.OFF;
+ }
+ else {
+ for (int i = 0; i < nodeChars.length(); i++) {
+ if (isFormatterTagAt(nodeChars, i, mySettings.FORMATTER_ON_TAG)) return FormatterTag.ON;
+ if (isFormatterTagAt(nodeChars, i, mySettings.FORMATTER_OFF_TAG)) return FormatterTag.OFF;
+ }
+ }
+ return FormatterTag.NONE;
+ }
+
+ private static boolean isFormatterTagAt(@NotNull CharSequence s, int pos, @NotNull String tagName) {
+ if (!tagName.isEmpty() && tagName.charAt(0) == s.charAt(pos)) {
+ int end = pos + tagName.length();
+ if (end <= s.length()) {
+ return StringUtil.equalsIgnoreCase(s.subSequence(pos, end), tagName);
+ }
+ }
+ return false;
+ }
+
+ public List<TextRange> getEnabledRanges(ASTNode rootNode, TextRange initialRange) {
+ EnabledRangesCollector collector = new EnabledRangesCollector(initialRange);
+ rootNode.getPsi().accept(collector);
+ return collector.getRanges();
+ }
+
+ private class EnabledRangesCollector extends PsiRecursiveElementVisitor {
+ private final List<FormatterTagInfo> myTagInfoList = new ArrayList<FormatterTagInfo>();
+ private final TextRange myInitialRange;
+
+ private EnabledRangesCollector(TextRange initialRange) {
+ myInitialRange = initialRange;
+ }
+
+ @Override
+ public void visitComment(PsiComment comment) {
+ FormatterTag tag = getFormatterTag(comment);
+ //noinspection EnumSwitchStatementWhichMissesCases
+ switch (tag) {
+ case OFF:
+ myTagInfoList.add(new FormatterTagInfo(comment.getTextRange().getEndOffset(), FormatterTag.OFF));
+ break;
+ case ON:
+ myTagInfoList.add(new FormatterTagInfo(comment.getTextRange().getEndOffset(), FormatterTag.ON));
+ break;
+ }
+ }
+
+ private List<TextRange> getRanges() {
+ List<TextRange> enabledRanges = new ArrayList<TextRange>();
+ Collections.sort(myTagInfoList, new Comparator<FormatterTagInfo>() {
+ @Override
+ public int compare(FormatterTagInfo tagInfo1,
+ FormatterTagInfo tagInfo2) {
+ return tagInfo1.offset - tagInfo2.offset;
+ }
+ });
+
+ int start = myInitialRange.getStartOffset();
+ boolean formatterEnabled = true;
+ for (FormatterTagInfo tagInfo: myTagInfoList) {
+ if (tagInfo.tag == FormatterTag.OFF && formatterEnabled) {
+ if (tagInfo.offset > start) {
+ TextRange range = new TextRange(start, tagInfo.offset);
+ enabledRanges.add(range);
+ }
+ formatterEnabled = false;
+ }
+ else if (tagInfo.tag == FormatterTag.ON && !formatterEnabled) {
+ start = Math.max(tagInfo.offset, myInitialRange.getStartOffset());
+ if (start >= myInitialRange.getEndOffset()) break;
+ formatterEnabled = true;
+ }
+ }
+ if (start < myInitialRange.getEndOffset()) {
+ enabledRanges.add(new TextRange(start, myInitialRange.getEndOffset()));
+ }
+ return enabledRanges;
+ }
+
+ private class FormatterTagInfo {
+ public int offset;
+ public FormatterTag tag;
+
+ private FormatterTagInfo(int offset, FormatterTag tag) {
+ this.offset = offset;
+ this.tag = tag;
+ }
+ }
+ }
+}
diff --git a/platform/lang-impl/src/com/intellij/formatting/InitialInfoBuilder.java b/platform/lang-impl/src/com/intellij/formatting/InitialInfoBuilder.java
index 51ffbb9..6f3d949 100644
--- a/platform/lang-impl/src/com/intellij/formatting/InitialInfoBuilder.java
+++ b/platform/lang-impl/src/com/intellij/formatting/InitialInfoBuilder.java
@@ -17,12 +17,8 @@
package com.intellij.formatting;
import com.intellij.diagnostic.LogMessageEx;
-import com.intellij.lang.ASTNode;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.TextRange;
-import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.psi.PsiComment;
-import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
@@ -38,7 +34,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import java.util.regex.Pattern;
/**
* Allows to build {@link AbstractBlockWrapper formatting block wrappers} for the target {@link Block formatting blocks}.
@@ -54,13 +49,11 @@
private final int myPositionOfInterest;
@NotNull
private final FormattingProgressCallback myProgressCallback;
+ private final FormatterTagHandler myFormatterTagHandler;
+
private final CommonCodeStyleSettings.IndentOptions myOptions;
- private final CodeStyleSettings mySettings;
private final Stack<State> myStates = new Stack<State>();
-
- private enum FormatterTag {ON, OFF, NONE}
-
private WhiteSpace myCurrentWhiteSpace;
private CompositeBlockWrapper myRootBlockWrapper;
private LeafBlockWrapper myPreviousBlock;
@@ -86,7 +79,7 @@
myOptions = options;
myPositionOfInterest = positionOfInterest;
myReadOnlyMode = false;
- mySettings = settings;
+ myFormatterTagHandler = new FormatterTagHandler(settings);
}
public static InitialInfoBuilder prepareToBuildBlocksSequentially(Block root,
@@ -297,7 +290,7 @@
info.arrangeParentTextRange();
}
- switch (getFormatterTag(rootBlock)) {
+ switch (myFormatterTagHandler.getFormatterTag(rootBlock)) {
case ON:
myReadOnlyMode = false;
break;
@@ -416,42 +409,6 @@
LogMessageEx.error(LOG, messageBuffer.toString(), buffer.toString());
}
- private FormatterTag getFormatterTag(Block block) {
- if (mySettings.FORMATTER_TAGS_ENABLED &&
- !StringUtil.isEmpty(mySettings.FORMATTER_ON_TAG) &&
- !StringUtil.isEmpty(mySettings.FORMATTER_OFF_TAG) &&
- block instanceof ASTBlock) {
- ASTNode node = ((ASTBlock)block).getNode();
- PsiElement element = node.getPsi();
- if (element != null && element instanceof PsiComment) {
- CharSequence nodeChars = node.getChars();
- if (mySettings.FORMATTER_TAGS_ACCEPT_REGEXP) {
- Pattern onPattern = mySettings.getFormatterOnPattern();
- Pattern offPattern = mySettings.getFormatterOffPattern();
- if (onPattern != null && onPattern.matcher(nodeChars).find()) return FormatterTag.ON;
- if (offPattern != null && offPattern.matcher(nodeChars).find()) return FormatterTag.OFF;
- }
- else {
- for (int i = 0; i < nodeChars.length(); i++) {
- if (isFormatterTagAt(nodeChars, i, mySettings.FORMATTER_ON_TAG)) return FormatterTag.ON;
- if (isFormatterTagAt(nodeChars, i, mySettings.FORMATTER_OFF_TAG)) return FormatterTag.OFF;
- }
- }
- }
- }
- return FormatterTag.NONE;
- }
-
- private static boolean isFormatterTagAt(@NotNull CharSequence s, int pos, @NotNull String tagName) {
- if (!tagName.isEmpty() && tagName.charAt(0) == s.charAt(pos)) {
- int end = pos + tagName.length();
- if (end <= s.length()) {
- return StringUtil.equalsIgnoreCase(s.subSequence(pos, end), tagName);
- }
- }
- return false;
- }
-
/**
* We want to wrap {@link Block code blocks} sequentially, hence, need to store a processing state and continue from the point
* where we stopped the processing last time.
diff --git a/platform/lang-impl/src/com/intellij/formatting/LeftEdgeAlignmentProcessor.java b/platform/lang-impl/src/com/intellij/formatting/LeftEdgeAlignmentProcessor.java
index 94f719d..6aa91a7 100644
--- a/platform/lang-impl/src/com/intellij/formatting/LeftEdgeAlignmentProcessor.java
+++ b/platform/lang-impl/src/com/intellij/formatting/LeftEdgeAlignmentProcessor.java
@@ -38,7 +38,7 @@
return new IndentData(whiteSpace.getIndentSpaces(), whiteSpace.getSpaces());
}
else {
- final int offsetBeforeBlock = CoreFormatterUtil.getOffsetBefore(offsetResponsibleBlock);
+ final int offsetBeforeBlock = CoreFormatterUtil.getStartColumn(offsetResponsibleBlock);
final AbstractBlockWrapper prevIndentedBlock = CoreFormatterUtil.getIndentedParentBlock(context.targetBlock);
if (prevIndentedBlock == null) {
return new IndentData(0, offsetBeforeBlock);
diff --git a/platform/lang-impl/src/com/intellij/formatting/RightEdgeAlignmentProcessor.java b/platform/lang-impl/src/com/intellij/formatting/RightEdgeAlignmentProcessor.java
index 2108261..d8b5cdd 100644
--- a/platform/lang-impl/src/com/intellij/formatting/RightEdgeAlignmentProcessor.java
+++ b/platform/lang-impl/src/com/intellij/formatting/RightEdgeAlignmentProcessor.java
@@ -38,7 +38,7 @@
return new IndentData(whiteSpace.getIndentSpaces() + offsetResponsibleBlock.getSymbolsAtTheLastLine(), whiteSpace.getSpaces());
}
else {
- final int targetIndent = CoreFormatterUtil.getOffsetBefore(offsetResponsibleBlock)
+ final int targetIndent = CoreFormatterUtil.getStartColumn(offsetResponsibleBlock)
+ offsetResponsibleBlock.getSymbolsAtTheLastLine();
final AbstractBlockWrapper prevIndentedBlock = CoreFormatterUtil.getIndentedParentBlock(context.targetBlock);
if (prevIndentedBlock == null) {
diff --git a/platform/lang-impl/src/com/intellij/formatting/WrapImpl.java b/platform/lang-impl/src/com/intellij/formatting/WrapImpl.java
index 0a63272..7be44a8 100644
--- a/platform/lang-impl/src/com/intellij/formatting/WrapImpl.java
+++ b/platform/lang-impl/src/com/intellij/formatting/WrapImpl.java
@@ -21,8 +21,11 @@
import java.util.*;
class WrapImpl extends Wrap {
- private LeafBlockWrapper myFirstEntry = null;
- private int myFirstPosition = -1;
+ /**
+ * The block where the wrap needs to happen if the CHOP wrap mode is used and the chain of blocks exceeds the right margin.
+ */
+ private LeafBlockWrapper myChopStartBlock = null;
+ private int myWrapOffset = -1;
private int myFlags;
private static int ourId = 0;
@@ -74,14 +77,14 @@
/**
* Resets the following state of the current wrap object:
* <ul>
- * <li>'{@link #getFirstEntry() firstEntry}' property value is set to <code>null</code>;</li>
- * <li>'{@link #getFirstPosition() firstPosition}' property value is set to <code>'-1'</code>;</li>
- * <li>'{@link #isIsActive() isActive}' property value is set to <code>'false'</code>;</li>
+ * <li>'{@link #getChopStartBlock() firstEntry}' property value is set to <code>null</code>;</li>
+ * <li>'{@link #getWrapOffset() firstPosition}' property value is set to <code>'-1'</code>;</li>
+ * <li>'{@link #isActive() isActive}' property value is set to <code>'false'</code>;</li>
* </ul>
*/
public void reset() {
- myFirstEntry = null;
- myFirstPosition = -1;
+ myChopStartBlock = null;
+ myWrapOffset = -1;
myFlags &=~ ACTIVE_MASK;
}
@@ -121,58 +124,44 @@
myIgnoredWraps.get(wrap).add(currentBlock);
}
- /**
- * Allows to check if given block is used as a '{@link #getFirstEntry() firstEntry}' property value of the current wrap object.
- * <p/>
- * <b>Note:</b> object identity (<code>'=='</code> operator) is used during checking given block against the current
- * '{@link #getFirstEntry() firstEntry}' property value.
- *
- * @param currentBlock block to check
- * @return <code>true</code> if '{@link #getFirstEntry() firstEntry}' property value is defined
- * (not <code>null</code>) and is the same as the given block; <code>false</code> otherwise
- */
- public boolean isFirstWrapped(final LeafBlockWrapper currentBlock) {
- return myFirstEntry != null && myFirstEntry == currentBlock;
- }
-
enum Type{
DO_NOT_WRAP, WRAP_AS_NEEDED, CHOP_IF_NEEDED, WRAP_ALWAYS
}
- LeafBlockWrapper getFirstEntry() {
- return myFirstEntry;
+ LeafBlockWrapper getChopStartBlock() {
+ return myChopStartBlock;
}
/**
* Performs the following changes at wrap object state:
* <ul>
- * <li>'{@link #getFirstEntry() firstEntry}' property value is dropped (set to <code>null</code>)</li>
- * <li>'{@link #isIsActive() isActive}' property value is set (to <code>true</code>)</li>
+ * <li>'{@link #getChopStartBlock() firstEntry}' property value is dropped (set to <code>null</code>)</li>
+ * <li>'{@link #isActive() isActive}' property value is set (to <code>true</code>)</li>
* </ul>
*/
- void markAsUsed() {
- myFirstEntry = null;
+ void setActive() {
+ myChopStartBlock = null;
myFlags |= ACTIVE_MASK;
}
/**
- * Applies given value to the '{@link #getFirstPosition() firstPosition}' property value if it's value is undefined at the moment
+ * Applies given value to the '{@link #getWrapOffset() firstPosition}' property value if it's value is undefined at the moment
* (has negative value).
*
- * @param startOffset new '{@link #getFirstPosition() firstPosition}' property value to use if current value is undefined (negative)
+ * @param startOffset new '{@link #getWrapOffset() firstPosition}' property value to use if current value is undefined (negative)
*/
- void processNextEntry(final int startOffset) {
- if (myFirstPosition < 0) {
- myFirstPosition = startOffset;
+ void setWrapOffset(final int startOffset) {
+ if (myWrapOffset < 0) {
+ myWrapOffset = startOffset;
}
}
/**
- * @return '{@link #getFirstPosition() firstPosition}' property value defined previously via {@link #processNextEntry(int)} if any;
+ * @return '{@link #getWrapOffset() firstPosition}' property value defined previously via {@link #setWrapOffset(int)} if any;
* <code>'-1'</code> otherwise
*/
- int getFirstPosition() {
- return myFirstPosition;
+ int getWrapOffset() {
+ return myWrapOffset;
}
public WrapImpl(WrapType type, boolean wrapFirstElement) {
@@ -205,22 +194,13 @@
return (myFlags & WRAP_FIRST_ELEMENT_MASK) != 0;
}
- /**
- * Allows to define given block as a <code>'first entry'</code> of the current wrap object. I.e. given block is returned on
- * subsequent {@link #getFirstEntry()} calls.
- * <p/>
- * <b>Note:</b> given block is applied only if '{@link #getFirstEntry() firstEntry}' property is undefined,
- * i.e. has a <code>null</code> value.
- *
- * @param current block to remember as a first entry of the current wrap object
- */
- void saveFirstEntry(LeafBlockWrapper current) {
- if (myFirstEntry == null) {
- myFirstEntry = current;
+ void saveChopBlock(LeafBlockWrapper current) {
+ if (myChopStartBlock == null) {
+ myChopStartBlock = current;
}
}
- final boolean isIsActive() {
+ final boolean isActive() {
return (myFlags & ACTIVE_MASK) != 0;
}
diff --git a/platform/lang-impl/src/com/intellij/ide/actions/GoToLinkTargetAction.java b/platform/lang-impl/src/com/intellij/ide/actions/GoToLinkTargetAction.java
index 60a7ae8..951ff97 100644
--- a/platform/lang-impl/src/com/intellij/ide/actions/GoToLinkTargetAction.java
+++ b/platform/lang-impl/src/com/intellij/ide/actions/GoToLinkTargetAction.java
@@ -22,7 +22,7 @@
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VFileProperty;
import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.psi.PsiFile;
+import com.intellij.psi.PsiFileSystemItem;
import com.intellij.psi.PsiManager;
public class GoToLinkTargetAction extends DumbAwareAction {
@@ -40,7 +40,8 @@
if (project != null && file != null && file.is(VFileProperty.SYMLINK)) {
VirtualFile target = file.getCanonicalFile();
if (target != null) {
- PsiFile psiFile = PsiManager.getInstance(project).findFile(target);
+ PsiManager psiManager = PsiManager.getInstance(project);
+ PsiFileSystemItem psiFile = target.isDirectory() ? psiManager.findDirectory(target) : psiManager.findFile(target);
if (psiFile != null) {
ProjectView.getInstance(project).select(psiFile, target, false);
}
diff --git a/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java b/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java
index 83fff01..bc6237f 100644
--- a/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java
+++ b/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java
@@ -561,13 +561,13 @@
final JPanel panel = new JPanel(new BorderLayout()) {
@Override
protected void paintComponent(Graphics g) {
- ((Graphics2D)g).setPaint(new GradientPaint(0,0, new JBColor(new Color(0x6688f2), new Color(48, 87, 186)), 0, getHeight(),
- new JBColor(new Color(0x2d60ee), new Color(43, 80, 172))));
+ ((Graphics2D)g).setPaint(new GradientPaint(0,0, new JBColor(new Color(211, 232, 253), new Color(64, 80, 94)), 0, getHeight(),
+ new JBColor(new Color(200, 215, 239), new Color(53, 65, 87))));
g.fillRect(0, 0, getWidth(), getHeight());
}
};
final JLabel title = new JLabel(" Search Everywhere:");
- title.setForeground(new JBColor(Gray._255, Gray._180));
+ title.setForeground(new JBColor(Gray._50, Gray._180));
if (SystemInfo.isMac) {
title.setFont(title.getFont().deriveFont(Font.BOLD, title.getFont().getSize() - 1f));
} else {
@@ -604,6 +604,7 @@
showPoint = JBPopupFactory.getInstance().guessBestPopupLocation(e.getDataContext());
}
}
+ myList.setFont(UIUtil.getListFont());
myBalloon.show(showPoint);
initSearchActions(myBalloon, myPopupField);
IdeFocusManager focusManager = IdeFocusManager.getInstance(e.getProject());
@@ -672,7 +673,7 @@
getTextEditor().putClientProperty("JTextField.Search.noBorderRing", Boolean.TRUE);
if (UIUtil.isUnderDarcula()) {
- getTextEditor().setBackground(Gray._55);
+ getTextEditor().setBackground(Gray._45);
getTextEditor().setForeground(Gray._240);
}
}
@@ -972,6 +973,7 @@
updatePopup();
}
catch (Exception ignore) {
+ ignore.printStackTrace();
}
finally {
myList.getEmptyText().setText(StatusText.DEFAULT_EMPTY_TEXT);
@@ -1262,6 +1264,12 @@
}
};
+ final ActionManager actionManager = ActionManager.getInstance();
+ final List<String> actions = AbbreviationManager.getInstance().findActions(pattern);
+ for (String actionId : actions) {
+ consumer.consume(actionManager.getAction(actionId));
+ }
+
for (SearchTopHitProvider provider : SearchTopHitProvider.EP_NAME.getExtensions()) {
myProgressIndicator.checkCanceled();
provider.consumeTopHits(pattern, consumer);
diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesTreeViewPanel.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesTreeViewPanel.java
index 1dd80ac..f97eb9e 100644
--- a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesTreeViewPanel.java
+++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesTreeViewPanel.java
@@ -796,6 +796,11 @@
return new RelativeRectangle(myTree);
}
+ @Override
+ public RelativeRectangle getAcceptAreaFallback() {
+ return getAcceptArea();
+ }
+
@NotNull
@Override
public ContentResponse getContentResponse(@NotNull DockableContent content, RelativePoint point) {
diff --git a/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FileTemplatesLoader.java b/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FileTemplatesLoader.java
index 2f9d057..a067ed3 100644
--- a/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FileTemplatesLoader.java
+++ b/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FileTemplatesLoader.java
@@ -17,7 +17,7 @@
import com.intellij.ide.fileTemplates.FileTemplateManager;
import com.intellij.ide.plugins.IdeaPluginDescriptorImpl;
-import com.intellij.ide.plugins.PluginManager;
+import com.intellij.ide.plugins.PluginManagerCore;
import com.intellij.ide.plugins.cl.PluginClassLoader;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.extensions.PluginDescriptor;
@@ -129,7 +129,7 @@
private void loadDefaultTemplates() {
final Set<URL> processedUrls = new HashSet<URL>();
- for (PluginDescriptor plugin : PluginManager.getPlugins()) {
+ for (PluginDescriptor plugin : PluginManagerCore.getPlugins()) {
if (plugin instanceof IdeaPluginDescriptorImpl && ((IdeaPluginDescriptorImpl)plugin).isEnabled()) {
final ClassLoader loader = plugin.getPluginClassLoader();
if (loader instanceof PluginClassLoader && ((PluginClassLoader)loader).getUrls().isEmpty()) {
diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/actions/MarkExcludeRootAction.java b/platform/lang-impl/src/com/intellij/ide/projectView/actions/MarkExcludeRootAction.java
index 823a798..1ff9a78 100644
--- a/platform/lang-impl/src/com/intellij/ide/projectView/actions/MarkExcludeRootAction.java
+++ b/platform/lang-impl/src/com/intellij/ide/projectView/actions/MarkExcludeRootAction.java
@@ -17,7 +17,7 @@
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
-import com.intellij.openapi.actionSystem.PlatformDataKeys;
+import com.intellij.openapi.module.Module;
import com.intellij.openapi.roots.ContentEntry;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.io.FileUtil;
@@ -51,7 +51,7 @@
}
@Override
- protected boolean isEnabled(@NotNull RootsSelection selection) {
+ protected boolean isEnabled(@NotNull RootsSelection selection, @NotNull Module module) {
return true;
}
}
diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/actions/MarkRootActionBase.java b/platform/lang-impl/src/com/intellij/ide/projectView/actions/MarkRootActionBase.java
index 2c14eba..20570cd 100644
--- a/platform/lang-impl/src/com/intellij/ide/projectView/actions/MarkRootActionBase.java
+++ b/platform/lang-impl/src/com/intellij/ide/projectView/actions/MarkRootActionBase.java
@@ -19,7 +19,6 @@
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.LangDataKeys;
-import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.DumbAwareAction;
@@ -82,13 +81,14 @@
@Override
public void update(AnActionEvent e) {
+ Module module = e.getData(LangDataKeys.MODULE);
RootsSelection selection = getSelection(e);
- boolean enabled = (!selection.mySelectedRoots.isEmpty() || !selection.mySelectedFiles.isEmpty()) && isEnabled(selection);
+ boolean enabled = module != null && (!selection.mySelectedRoots.isEmpty() || !selection.mySelectedDirectories.isEmpty()) && isEnabled(selection, module);
e.getPresentation().setVisible(enabled);
e.getPresentation().setEnabled(enabled);
}
- protected abstract boolean isEnabled(@NotNull RootsSelection selection);
+ protected abstract boolean isEnabled(@NotNull RootsSelection selection, @NotNull Module module);
protected static RootsSelection getSelection(AnActionEvent e) {
Module module = e.getData(LangDataKeys.MODULE);
@@ -111,7 +111,7 @@
selection.mySelectedRoots.add(folder);
}
else {
- selection.mySelectedFiles.add(file);
+ selection.mySelectedDirectories.add(file);
if (fileIndex.isInSourceContent(file)) {
selection.myHaveSelectedFilesUnderSourceRoots = true;
}
@@ -124,7 +124,7 @@
public static final RootsSelection EMPTY = new RootsSelection();
public List<SourceFolder> mySelectedRoots = new ArrayList<SourceFolder>();
- public List<VirtualFile> mySelectedFiles = new ArrayList<VirtualFile>();
+ public List<VirtualFile> mySelectedDirectories = new ArrayList<VirtualFile>();
public boolean myHaveSelectedFilesUnderSourceRoots;
}
}
diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/actions/MarkSourceRootAction.java b/platform/lang-impl/src/com/intellij/ide/projectView/actions/MarkSourceRootAction.java
index aaa21dc..08eabbb 100644
--- a/platform/lang-impl/src/com/intellij/ide/projectView/actions/MarkSourceRootAction.java
+++ b/platform/lang-impl/src/com/intellij/ide/projectView/actions/MarkSourceRootAction.java
@@ -16,6 +16,7 @@
package com.intellij.ide.projectView.actions;
import com.intellij.openapi.actionSystem.Presentation;
+import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.ProjectBundle;
import com.intellij.openapi.roots.ContentEntry;
import com.intellij.openapi.roots.SourceFolder;
@@ -44,12 +45,12 @@
}
@Override
- protected boolean isEnabled(@NotNull RootsSelection selection) {
+ protected boolean isEnabled(@NotNull RootsSelection selection, @NotNull Module module) {
if (selection.myHaveSelectedFilesUnderSourceRoots) {
return false;
}
- if (!selection.mySelectedFiles.isEmpty()) {
+ if (!selection.mySelectedDirectories.isEmpty()) {
return true;
}
diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/actions/UnmarkRootAction.java b/platform/lang-impl/src/com/intellij/ide/projectView/actions/UnmarkRootAction.java
index e84f682..cf2724dc 100644
--- a/platform/lang-impl/src/com/intellij/ide/projectView/actions/UnmarkRootAction.java
+++ b/platform/lang-impl/src/com/intellij/ide/projectView/actions/UnmarkRootAction.java
@@ -16,6 +16,7 @@
package com.intellij.ide.projectView.actions;
import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.module.Module;
import com.intellij.openapi.roots.ContentEntry;
import com.intellij.openapi.roots.SourceFolder;
import com.intellij.openapi.roots.ui.configuration.ModuleSourceRootEditHandler;
@@ -55,8 +56,8 @@
}
@Override
- protected boolean isEnabled(@NotNull RootsSelection selection) {
- return selection.mySelectedFiles.isEmpty() && !selection.mySelectedRoots.isEmpty();
+ protected boolean isEnabled(@NotNull RootsSelection selection, @NotNull Module module) {
+ return selection.mySelectedDirectories.isEmpty() && !selection.mySelectedRoots.isEmpty();
}
protected void modifyRoots(VirtualFile vFile, ContentEntry entry) {
diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java
index 06aeda8..1dd47c6 100644
--- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java
+++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java
@@ -1092,10 +1092,10 @@
return !((Module)selected).isDisposed() ? selected : null;
}
else if (selected instanceof PsiDirectory) {
- return moduleByContentRoot(((PsiDirectory)selected).getVirtualFile());
+ return moduleBySingleContentRoot(((PsiDirectory)selected).getVirtualFile());
}
else if (selected instanceof VirtualFile) {
- return moduleByContentRoot((VirtualFile)selected);
+ return moduleBySingleContentRoot((VirtualFile)selected);
}
else {
return null;
@@ -1203,11 +1203,11 @@
result.addAll(modules);
}
else if (element instanceof PsiDirectory) {
- Module module = moduleByContentRoot(((PsiDirectory)element).getVirtualFile());
+ Module module = moduleBySingleContentRoot(((PsiDirectory)element).getVirtualFile());
if (module != null) result.add(module);
}
else if (element instanceof VirtualFile) {
- Module module = moduleByContentRoot((VirtualFile)element);
+ Module module = moduleBySingleContentRoot((VirtualFile)element);
if (module != null) result.add(module);
}
}
@@ -1221,11 +1221,17 @@
}
}
+ /** Project view has the same node for module and its single content root
+ * => MODULE_CONTEXT data key should return the module when its content root is selected
+ * When there are multiple content roots, they have different nodes under the module node
+ * => MODULE_CONTEXT should be only available for the module node
+ * otherwise VirtualFileArrayRule will return all module's content roots when just one of them is selected
+ */
@Nullable
- private Module moduleByContentRoot(VirtualFile file) {
+ private Module moduleBySingleContentRoot(VirtualFile file) {
if (ProjectRootsUtil.isModuleContentRoot(file, myProject)) {
Module module = ProjectRootManager.getInstance(myProject).getFileIndex().getModuleForFile(file);
- if (module != null && !module.isDisposed()) {
+ if (module != null && !module.isDisposed() && ModuleRootManager.getInstance(module).getContentRoots().length == 1) {
return module;
}
}
diff --git a/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/StructureViewComponent.java b/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/StructureViewComponent.java
index b04ce6b..ae8ceda 100644
--- a/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/StructureViewComponent.java
+++ b/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/StructureViewComponent.java
@@ -35,8 +35,6 @@
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.fileEditor.FileEditor;
import com.intellij.openapi.fileEditor.FileEditorManager;
-import com.intellij.openapi.fileEditor.OpenFileDescriptor;
-import com.intellij.openapi.fileEditor.TextEditor;
import com.intellij.openapi.project.IndexNotReadyException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.SimpleToolWindowPanel;
@@ -761,9 +759,6 @@
if (PlatformDataKeys.FILE_EDITOR.is(dataId)) {
return myFileEditor;
}
- if (OpenFileDescriptor.NAVIGATE_IN_EDITOR.is(dataId) && myFileEditor instanceof TextEditor) {
- return ((TextEditor)myFileEditor).getEditor();
- }
if (PlatformDataKeys.CUT_PROVIDER.is(dataId)) {
return myCopyPasteDelegator.getCutProvider();
}
diff --git a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java
index 8f4d650..fec55d0 100644
--- a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java
+++ b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java
@@ -1651,6 +1651,7 @@
final String prefixPattern = myFindUsagesTitle + " \'" + myTextField.getText().trim() + "\'";
final String nonPrefixPattern = myFindUsagesTitle + " \'*" + myTextField.getText().trim() + "*\'";
presentation.setCodeUsagesString(prefixPattern);
+ presentation.setUsagesInGeneratedCodeString(prefixPattern + " in generated code");
presentation.setDynamicUsagesString(nonPrefixPattern);
presentation.setTabName(prefixPattern);
presentation.setTabText(prefixPattern);
diff --git a/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeChooserCombo.java b/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeChooserCombo.java
index bc6aa19..37b1573 100644
--- a/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeChooserCombo.java
+++ b/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeChooserCombo.java
@@ -23,11 +23,11 @@
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.LangDataKeys;
-import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.module.Module;
+import com.intellij.openapi.module.ModuleUtil;
import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Pair;
@@ -54,6 +54,7 @@
import com.intellij.util.TreeItem;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.jetbrains.jps.model.java.JavaSourceRootType;
import javax.swing.*;
import java.awt.*;
@@ -238,7 +239,7 @@
result.add(GlobalSearchScope.allScope(project));
}
- if (!PlatformUtils.isCidr()) { // TODO: fix these scopes in AppCode
+ if (!PlatformUtils.isCidr() && ModuleUtil.isSupportedRootType(project, JavaSourceRootType.TEST_SOURCE)) { // TODO: fix these scopes in AppCode
result.add(GlobalSearchScopes.projectProductionScope(project));
result.add(GlobalSearchScopes.projectTestScope(project));
}
diff --git a/platform/lang-impl/src/com/intellij/openapi/module/impl/ModuleManagerComponent.java b/platform/lang-impl/src/com/intellij/openapi/module/impl/ModuleManagerComponent.java
index 0d12404..e713170 100644
--- a/platform/lang-impl/src/com/intellij/openapi/module/impl/ModuleManagerComponent.java
+++ b/platform/lang-impl/src/com/intellij/openapi/module/impl/ModuleManagerComponent.java
@@ -152,7 +152,7 @@
ProgressIndicator progressIndicator = myProgressManager.getProgressIndicator();
if (progressIndicator == null) {
- myProgressManager.runProcessWithProgressSynchronously(runnableWithProgress, "Loading modules", false, myProject);
+ myProgressManager.runProcessWithProgressSynchronously(runnableWithProgress, "Initializing modules...", false, myProject);
}
else {
runnableWithProgress.run();
diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/PlatformModifiableModelsProvider.java b/platform/lang-impl/src/com/intellij/openapi/roots/PlatformModifiableModelsProvider.java
index 6c72c69..2619ad0 100644
--- a/platform/lang-impl/src/com/intellij/openapi/roots/PlatformModifiableModelsProvider.java
+++ b/platform/lang-impl/src/com/intellij/openapi/roots/PlatformModifiableModelsProvider.java
@@ -6,13 +6,14 @@
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.libraries.LibraryTable;
import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar;
+import org.jetbrains.annotations.NotNull;
/**
* @author Dennis.Ushakov
*/
public class PlatformModifiableModelsProvider implements ModifiableModelsProvider {
@Override
- public ModifiableRootModel getModuleModifiableModel(final Module module) {
+ public ModifiableRootModel getModuleModifiableModel(@NotNull final Module module) {
return ModuleRootManager.getInstance(module).getModifiableModel();
}
diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/DirectoryIndexImpl.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/DirectoryIndexImpl.java
index 2c0566aeb..8c2948f 100644
--- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/DirectoryIndexImpl.java
+++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/DirectoryIndexImpl.java
@@ -188,7 +188,7 @@
VirtualFile parent = file.getParent();
if (!(parent instanceof NewVirtualFile)) return;
DirectoryInfo existing = myState.getInfo(((NewVirtualFile)file).getId());
- assert existing == null : file+" -> "+existing;
+ assert existing == null : file + " -> " + existing;
IndexState newState = updateStateWithNewFile((NewVirtualFile)file, (NewVirtualFile)parent);
replaceState(newState);
}
@@ -226,14 +226,19 @@
}
}
- if (parentInfo == null) return state;
-
- Module module = parentInfo.getModule();
-
for (DirectoryIndexExcludePolicy policy : myExcludePolicies) {
- if (policy.isExcludeRoot(file)) return state;
+ if (policy.isExcludeRoot(file)) {
+ if (parentInfo == null || parentInfo.getContentRoot() == null) {
+ if (state == originalState) state = state.copy(null);
+ state.myProjectExcludeRoots.add(file.getId());
+ }
+ return state;
+ }
}
+ if (parentInfo == null) return state;
+ Module module = parentInfo.getModule();
+
if (state == originalState) state = state.copy(null);
VirtualFile parentContentRoot = parentInfo.getContentRoot();
state.fillMapWithModuleContent(file, module, (NewVirtualFile)parentContentRoot, null);
@@ -251,8 +256,7 @@
if (parentInfo.hasLibraryClassRoot()) {
String newDirPackageName = getPackageNameForSubdir(parentPackage, file.getName());
- state.fillMapWithLibraryClasses(file, newDirPackageName, (NewVirtualFile)parentInfo.getLibraryClassRoot(), null, interned,
- null);
+ state.fillMapWithLibraryClasses(file, newDirPackageName, (NewVirtualFile)parentInfo.getLibraryClassRoot(), null, interned, null);
}
if (parentInfo.isInLibrarySource()) {
@@ -303,12 +307,14 @@
IndexState copy = null;
for (int id : list) {
if (myState.getInfo(id) != null) {
- if (copy == null) copy = myState.copy(new TIntProcedure() {
- @Override
- public boolean execute(int fid) {
- return ArrayUtil.indexOf(list, fid) == -1;
- }
- });
+ if (copy == null) {
+ copy = myState.copy(new TIntProcedure() {
+ @Override
+ public boolean execute(int fid) {
+ return ArrayUtil.indexOf(list, fid) == -1;
+ }
+ });
+ }
copy.myDirToInfoMap.remove(id);
copy.setPackageName(id, null);
@@ -342,7 +348,6 @@
}
private boolean myBatchChangePlanned;
- private static final boolean ourCanHaveBatchUpdate = true;
@Override
public void before(@NotNull List<? extends VFileEvent> events) {
@@ -354,40 +359,40 @@
int directoriesRemoved = 0;
int directoriesCreated = 0;
- for(VFileEvent event:events) {
+ for (VFileEvent event : events) {
if (event instanceof VFileDeleteEvent) {
VirtualFile file = event.getFile();
if (file != null && file.isDirectory()) {
directoriesRemoved += 1 + countDirectories(file, MAX_DEPTH_TO_COUNT);
}
- } else if(event instanceof VFileCreateEvent) {
+ }
+ else if (event instanceof VFileCreateEvent) {
VirtualFile file = event.getFile();
if (file != null && file.isDirectory() ||
- file == null && ((VFileCreateEvent)event).isDirectory()
- ) {
+ file == null && ((VFileCreateEvent)event).isDirectory()) {
directoriesCreated += 1 + countDirectories(file, MAX_DEPTH_TO_COUNT);
}
}
}
final boolean willDoBatchUpdate = directoriesCreated + directoriesRemoved > DIRECTORIES_CHANGED_THRESHOLD;
-
- if (willDoBatchUpdate && ourCanHaveBatchUpdate) {
+ if (willDoBatchUpdate) {
myBatchChangePlanned = true;
- LOG.info("Too many directories created / deleted: " + directoriesCreated + "," + directoriesRemoved + ", will rebuild indexstate");
- } else {
+ LOG.info("Too many directories created / deleted: " + directoriesCreated + "," + directoriesRemoved + ", will rebuild index state");
+ }
+ else {
for (VFileEvent event : events) {
BulkVirtualFileListenerAdapter.fireBefore(this, event);
}
}
}
- private int countDirectories(VirtualFile file, int depth) {
+ private int countDirectories(@Nullable VirtualFile file, int depth) {
if (!(file instanceof NewVirtualFile)) return 0;
int counter = 0;
- for(VirtualFile child:((NewVirtualFile)file).iterInDbChildren()) {
- if (child.isDirectory()) counter += 1 + (depth > 0 ? countDirectories(child, depth - 1):0);
+ for (VirtualFile child : ((NewVirtualFile)file).iterInDbChildren()) {
+ if (child.isDirectory()) counter += 1 + (depth > 0 ? countDirectories(child, depth - 1) : 0);
}
return counter;
}
@@ -615,7 +620,7 @@
if (ourUseRootIndexOnly) {
return riInfo;
}
-
+
return assertConsistentResult(dir, riInfo, myState.getInfo(((NewVirtualFile)dir).getId()));
}
@@ -636,7 +641,7 @@
if (ourUseRootIndexOnly) {
return riType;
}
-
+
return assertConsistentResult(info, riType, myState.getRootTypeById(info.getSourceRootTypeId()));
}
return null;
@@ -677,7 +682,7 @@
if (ourUseRootIndexOnly) {
return riResult;
}
-
+
return assertConsistentResult(dir, riResult, myState.getPackageNameForDirectory((NewVirtualFile)dir));
}
@@ -1038,11 +1043,11 @@
@NotNull final NewVirtualFile sourceRoot,
final int rootTypeId,
@Nullable final ProgressIndicator progress,
- final @Nullable TObjectIntHashMap<String> interned
- ) {
+ final @Nullable TObjectIntHashMap<String> interned) {
assertWritable();
if (!isValid(dir)) return;
- assert VfsUtilCore.isAncestor(sourceRoot, dir, false) : "SourceRoot: "+sourceRoot+" ("+sourceRoot.getFileSystem()+"); dir: "+dir+" ("+dir.getFileSystem()+")";
+ assert VfsUtilCore.isAncestor(sourceRoot, dir, false) :
+ "SourceRoot: "+sourceRoot+" ("+sourceRoot.getFileSystem()+"); dir: "+dir+" ("+dir.getFileSystem()+")";
VfsUtilCore.visitChildrenRecursively(dir, new DirectoryVisitor() {
private final Stack<String> myPackages = new Stack<String>();
@@ -1061,7 +1066,8 @@
if (isAnotherRoot(id)) return null; // another source root starts here
}
- assert VfsUtilCore.isAncestor(dir, file, false) : "dir: " + dir + " (" + dir.getFileSystem() + "); file: " + file + " (" + file.getFileSystem() + ")";
+ assert VfsUtilCore.isAncestor(dir, file, false) :
+ "dir: " + dir + " (" + dir.getFileSystem() + "); file: " + file + " (" + file.getFileSystem() + ")";
int flag = DirectoryInfo.createSourceRootTypeData(true, info.isInLibrarySource(), rootTypeId);
info = with(id, info, null, null, sourceRoot, null, flag, null);
@@ -1223,7 +1229,7 @@
}
return null;
}
-
+
private void initOrderEntries(@NotNull Module module,
@NotNull MultiMap<VirtualFile, OrderEntry> depEntries,
@NotNull MultiMap<VirtualFile, OrderEntry> libClassRootEntries,
@@ -1415,6 +1421,7 @@
fillMapWithOrderEntries(depEntries, libClassRootEntries, libSourceRootEntries, progress);
internDirectoryInfos();
+ progress.popState();
}
private void internDirectoryInfos() {
@@ -1470,7 +1477,7 @@
for (VirtualFile excludeRoot : contentEntry.getExcludeFolderFiles()) {
// Output paths should be excluded (if marked as such) regardless if they're under corresponding module's content root
if (excludeRoot instanceof NewVirtualFile) {
- if (!FileUtil.startsWith(contentRoot.getUrl(), excludeRoot.getUrl())) {
+ if (!FileUtil.startsWith(excludeRoot.getUrl(), contentRoot.getUrl())) {
if (isExcludeRootForModule(module, excludeRoot)) {
putForFileAndAllAncestors((NewVirtualFile)excludeRoot, excludeRoot.getUrl());
}
@@ -1614,19 +1621,19 @@
private void assertAncestor(@NotNull DirectoryInfo info, @NotNull VirtualFile root, int myId) {
VirtualFile myFile = findFileById(myId);
- assert myFile.getFileSystem() == root.getFileSystem() : myFile.getFileSystem() +", "+ root.getFileSystem() +"; my file: "+myFile+"; root: "+root + "; "+
- myFile.getParent().getPath().equals(root.getPath());
- assert VfsUtilCore.isAncestor(root, myFile, false) : "my file: "+myFile+" ("+
- ((NewVirtualFile)myFile).getId() +")" + myFile.getClass() + " - " +System.identityHashCode(myFile) +
- "; root: "+root +" ("+
- ((NewVirtualFile)root).getId() +")" + root.getClass() + " - " +System.identityHashCode(root) +
- "; equalsToParent:"+ (myFile.getParent() == null ? "" : myFile.getParent().getPath()).equals(root.getPath()) +
- "; equalsToRoot:"+ myFile.equals(root) +
- "; equalsToRootPath:"+ myFile.getPath().equals(root.getPath()) +
- "; my contentRoot: "+info.getContentRoot()+
- "; my sourceRoot: "+info.getSourceRoot()+
- "; my classRoot: "+info.getLibraryClassRoot() +
- "; path is substring: "+FileUtil.isAncestor(root.getPath(), myFile.getPath(), false)
+ assert myFile.getFileSystem() == root.getFileSystem() :
+ myFile.getFileSystem() + ", " + root.getFileSystem() + "; my file: " + myFile + "; root: " + root + "; " +
+ myFile.getParent().getPath().equals(root.getPath());
+ assert VfsUtilCore.isAncestor(root, myFile, false) :
+ "my file: " + myFile + " (" + ((NewVirtualFile)myFile).getId() + ")" + myFile.getClass() + " - " + System.identityHashCode(myFile) +
+ "; root: " + root + " (" + ((NewVirtualFile)root).getId() + ")" + root.getClass() + " - " + System.identityHashCode(root) +
+ "; equalsToParent:" + (myFile.getParent() == null ? "" : myFile.getParent().getPath()).equals(root.getPath()) +
+ "; equalsToRoot:" + myFile.equals(root) +
+ "; equalsToRootPath:" + myFile.getPath().equals(root.getPath()) +
+ "; my contentRoot: " + info.getContentRoot() +
+ "; my sourceRoot: " + info.getSourceRoot() +
+ "; my classRoot: " + info.getLibraryClassRoot() +
+ "; path is substring: " + FileUtil.isAncestor(root.getPath(), myFile.getPath(), false)
;
}
-}
\ No newline at end of file
+}
diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/ContentRootPanel.java b/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/ContentRootPanel.java
index ad21db8..469d966 100644
--- a/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/ContentRootPanel.java
+++ b/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/ContentRootPanel.java
@@ -22,7 +22,6 @@
import com.intellij.openapi.roots.ContentFolder;
import com.intellij.openapi.roots.ExcludeFolder;
import com.intellij.openapi.roots.SourceFolder;
-import com.intellij.openapi.roots.impl.SourceFolderImpl;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VfsUtilCore;
@@ -49,8 +48,10 @@
import javax.swing.event.HyperlinkListener;
import java.awt.*;
import java.io.File;
-import java.util.*;
+import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
/**
* @author Eugene Zhuravlev
@@ -208,8 +209,7 @@
private <P extends JpsElement> JComponent createFolderComponent(final ContentFolder folder, Color foreground, ModuleSourceRootEditHandler<P> editor) {
final VirtualFile folderFile = folder.getFile();
final VirtualFile contentEntryFile = getContentEntry().getFile();
- final String properties = folder instanceof SourceFolderImpl? StringUtil.notNullize(
- editor.getPropertiesString((P)((SourceFolderImpl)folder).getJpsElement().getProperties())) : "";
+ final String properties = folder instanceof SourceFolder? StringUtil.notNullize(editor.getPropertiesString((P)((SourceFolder)folder).getJpsElement().getProperties())) : "";
if (folderFile != null && contentEntryFile != null) {
String path = folderFile.equals(contentEntryFile)? "." : VfsUtilCore.getRelativePath(folderFile, contentEntryFile, File.separatorChar);
HoverHyperlinkLabel hyperlinkLabel = new HoverHyperlinkLabel(path + properties, foreground);
diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/JavaSourceRootEditHandlerBase.java b/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/JavaSourceRootEditHandlerBase.java
index ce2fb65..7b3f587 100644
--- a/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/JavaSourceRootEditHandlerBase.java
+++ b/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/JavaSourceRootEditHandlerBase.java
@@ -18,14 +18,13 @@
import com.intellij.icons.AllIcons;
import com.intellij.openapi.project.ProjectBundle;
import com.intellij.openapi.roots.SourceFolder;
-import com.intellij.openapi.roots.impl.SourceFolderImpl;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.ui.roots.IconActionComponent;
import com.intellij.util.ui.FormBuilder;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import org.jetbrains.jps.model.JpsElement;
+import org.jetbrains.jps.model.java.JavaModuleSourceRootTypes;
import org.jetbrains.jps.model.java.JavaSourceRootProperties;
import org.jetbrains.jps.model.module.JpsModuleSourceRootType;
@@ -64,8 +63,9 @@
ProjectBundle.message("module.paths.edit.properties.tooltip"), new Runnable() {
@Override
public void run() {
- JpsElement properties = ((SourceFolderImpl)folder).getJpsElement().getProperties();
- SourceRootPropertiesDialog dialog = new SourceRootPropertiesDialog(parentComponent, (JavaSourceRootProperties)properties);
+ JavaSourceRootProperties properties = folder.getJpsElement().getProperties(JavaModuleSourceRootTypes.SOURCES);
+ assert properties != null;
+ SourceRootPropertiesDialog dialog = new SourceRootPropertiesDialog(parentComponent, properties);
dialog.show();
if (dialog.isOK()) {
callback.onSourceRootPropertiesChanged(folder);
diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/actions/ToggleSourcesStateAction.java b/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/actions/ToggleSourcesStateAction.java
index 62159b6..c893d04 100644
--- a/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/actions/ToggleSourcesStateAction.java
+++ b/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/actions/ToggleSourcesStateAction.java
@@ -20,7 +20,6 @@
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.project.ProjectBundle;
import com.intellij.openapi.roots.SourceFolder;
-import com.intellij.openapi.roots.impl.SourceFolderImpl;
import com.intellij.openapi.roots.ui.configuration.ContentEntryEditor;
import com.intellij.openapi.roots.ui.configuration.ContentEntryTreeEditor;
import com.intellij.openapi.roots.ui.configuration.ModuleSourceRootEditHandler;
@@ -72,7 +71,7 @@
else if (!myEditHandler.getRootType().equals(sourceFolder.getRootType())) {
P properties;
if (myEditHandler.getRootType().getClass().equals(sourceFolder.getRootType().getClass())) {
- properties = (P)((SourceFolderImpl)sourceFolder).getJpsElement().getProperties().getBulkModificationSupport().createCopy();
+ properties = (P)sourceFolder.getJpsElement().getProperties().getBulkModificationSupport().createCopy();
}
else {
properties = myEditHandler.getRootType().createDefaultProperties();
diff --git a/platform/lang-impl/src/com/intellij/openapi/vcs/checkin/TodoCheckinHandler.java b/platform/lang-impl/src/com/intellij/openapi/vcs/checkin/TodoCheckinHandler.java
index 1a9fa06..f0970d0 100644
--- a/platform/lang-impl/src/com/intellij/openapi/vcs/checkin/TodoCheckinHandler.java
+++ b/platform/lang-impl/src/com/intellij/openapi/vcs/checkin/TodoCheckinHandler.java
@@ -184,24 +184,24 @@
final String text = createMessage(worker);
final String[] buttons;
final boolean thereAreTodoFound = worker.getAddedOrEditedTodos().size() + worker.getInChangedTodos().size() > 0;
+ int commitOption;
if (thereAreTodoFound) {
buttons = new String[]{VcsBundle.message("todo.in.new.review.button"), commitButtonText, CommonBundle.getCancelButtonText()};
+ commitOption = 1;
}
else {
buttons = new String[]{commitButtonText, CommonBundle.getCancelButtonText()};
+ commitOption = 0;
}
-
- final int answer = Messages.showOkCancelDialog(myCheckinProjectPanel.getComponent(), text, "TODO", buttons[0], buttons[1], UIUtil.getWarningIcon());
+ final int answer = Messages.showDialog(myProject, text, "TODO", null, buttons, 0, 1, UIUtil.getWarningIcon());
if (thereAreTodoFound && answer == Messages.OK) {
showTodo(worker);
return ReturnResult.CLOSE_WINDOW;
}
- if (!thereAreTodoFound && answer != Messages.OK) {
- return ReturnResult.CANCEL;
- }
- else {
+ if (answer == commitOption) {
return ReturnResult.COMMIT;
}
+ return ReturnResult.CANCEL;
}
private void showTodo(final TodoCheckinHandlerWorker worker) {
diff --git a/platform/lang-impl/src/com/intellij/platform/templates/github/DownloadUtil.java b/platform/lang-impl/src/com/intellij/platform/templates/github/DownloadUtil.java
index 205df47..14c6674 100644
--- a/platform/lang-impl/src/com/intellij/platform/templates/github/DownloadUtil.java
+++ b/platform/lang-impl/src/com/intellij/platform/templates/github/DownloadUtil.java
@@ -76,6 +76,22 @@
* @param indicator progress indicator
* @param url url to download
* @param outputFile output file
+ */
+ public static void downloadAtomically(@Nullable ProgressIndicator indicator,
+ @NotNull String url,
+ @NotNull File outputFile) throws IOException
+ {
+ File tempFile = FileUtil.createTempFile("for-actual-downloading-", null);
+ downloadAtomically(indicator, url, outputFile, tempFile, null);
+ }
+
+ /**
+ * Downloads content of {@code url} to {@code outputFile} atomically.
+ * {@code outputFile} won't be modified in case of any I/O download errors.
+ *
+ * @param indicator progress indicator
+ * @param url url to download
+ * @param outputFile output file
* @param tempFile temporary file to download to. This file is deleted on method exit.
*/
public static void downloadAtomically(@Nullable ProgressIndicator indicator,
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeFormatterFacade.java b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeFormatterFacade.java
index a8bdbae..7ea3475 100644
--- a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeFormatterFacade.java
+++ b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeFormatterFacade.java
@@ -79,9 +79,11 @@
= new Key<Boolean>("WRAP_LONG_LINE_DURING_FORMATTING_IN_PROGRESS_KEY");
private final CodeStyleSettings mySettings;
+ private final FormatterTagHandler myTagHandler;
public CodeFormatterFacade(CodeStyleSettings settings) {
mySettings = settings;
+ myTagHandler = new FormatterTagHandler(settings);
}
public ASTNode processElement(ASTNode element) {
@@ -253,7 +255,7 @@
}
}
- private static TextRange preprocess(@NotNull final ASTNode node, @NotNull TextRange range) {
+ private TextRange preprocess(@NotNull final ASTNode node, @NotNull TextRange range) {
TextRange result = range;
PsiElement psi = node.getPsi();
if (!psi.isValid()) {
@@ -324,13 +326,33 @@
}
}
- for(PreFormatProcessor processor: Extensions.getExtensions(PreFormatProcessor.EP_NAME)) {
- result = processor.process(node, result);
+ if (!mySettings.FORMATTER_TAGS_ENABLED) {
+ for(PreFormatProcessor processor: Extensions.getExtensions(PreFormatProcessor.EP_NAME)) {
+ result = processor.process(node, result);
+ }
+ }
+ else {
+ result = preprocessEnabledRanges(node, result);
}
return result;
}
+ private TextRange preprocessEnabledRanges(@NotNull final ASTNode node, @NotNull TextRange range) {
+ TextRange result = TextRange.create(range.getStartOffset(), range.getEndOffset());
+ List<TextRange> enabledRanges = myTagHandler.getEnabledRanges(node, result);
+ int delta = 0;
+ for (TextRange enabledRange : enabledRanges) {
+ enabledRange = enabledRange.shiftRight(delta);
+ for (PreFormatProcessor processor : Extensions.getExtensions(PreFormatProcessor.EP_NAME)) {
+ TextRange processedRange = processor.process(node, enabledRange);
+ delta += processedRange.getLength() - enabledRange.getLength();
+ }
+ }
+ result = result.grown(delta);
+ return result;
+ }
+
@NotNull
private static Collection<PsiLanguageInjectionHost> collectInjectionHosts(@NotNull PsiFile file, @NotNull TextRange range) {
Stack<PsiElement> toProcess = new Stack<PsiElement>();
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReferenceCharFilter.java b/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReferenceCharFilter.java
index f4d6e11..d5ac449c 100644
--- a/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReferenceCharFilter.java
+++ b/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReferenceCharFilter.java
@@ -29,7 +29,7 @@
public Result acceptChar(char c, int prefixLength, Lookup lookup) {
final LookupElement item = lookup.getCurrentItem();
if ('.' == c && item != null && item.getObject() instanceof PsiFileSystemItem) {
- PsiReference referenceAtCaret = lookup.getPsiFile().findReferenceAt(lookup.getEditor().getCaretModel().getOffset() - 1);
+ PsiReference referenceAtCaret = lookup.getPsiFile().findReferenceAt(lookup.getLookupStart());
if (referenceAtCaret != null && FileReference.findFileReference(referenceAtCaret) != null) {
return Result.ADD_TO_PREFIX;
}
diff --git a/platform/lang-impl/src/com/intellij/refactoring/BaseRefactoringProcessor.java b/platform/lang-impl/src/com/intellij/refactoring/BaseRefactoringProcessor.java
index ed6ec4d..13f6c9f 100644
--- a/platform/lang-impl/src/com/intellij/refactoring/BaseRefactoringProcessor.java
+++ b/platform/lang-impl/src/com/intellij/refactoring/BaseRefactoringProcessor.java
@@ -22,7 +22,6 @@
import com.intellij.ide.DataManager;
import com.intellij.lang.Language;
import com.intellij.openapi.actionSystem.CommonDataKeys;
-import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.command.UndoConfirmationPolicy;
@@ -370,6 +369,7 @@
presentation.setCodeUsagesString(descriptor.getCodeReferencesText(codeUsageCount, codeFiles.size()));
presentation.setNonCodeUsagesString(descriptor.getCommentReferencesText(nonCodeUsageCount, nonCodeFiles.size()));
presentation.setDynamicUsagesString("Dynamic " + StringUtil.decapitalize(descriptor.getCodeReferencesText(dynamicUsagesCount, dynamicUsagesCodeFiles.size())));
+ presentation.setUsagesInGeneratedCodeString(descriptor.getCodeReferencesText(codeUsageCount, codeFiles.size()) + " in generated code");
return presentation;
}
diff --git a/platform/lang-impl/src/com/intellij/refactoring/copy/CopyFilesOrDirectoriesDialog.java b/platform/lang-impl/src/com/intellij/refactoring/copy/CopyFilesOrDirectoriesDialog.java
index 70e5826..1a0882a 100644
--- a/platform/lang-impl/src/com/intellij/refactoring/copy/CopyFilesOrDirectoriesDialog.java
+++ b/platform/lang-impl/src/com/intellij/refactoring/copy/CopyFilesOrDirectoriesDialog.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.intellij.refactoring.copy;
import com.intellij.ide.util.DirectoryUtil;
@@ -28,9 +27,9 @@
import com.intellij.openapi.keymap.KeymapUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
+import com.intellij.openapi.ui.DialogWrapperPeer;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.TextComponentAccessor;
-import com.intellij.openapi.ui.impl.DialogWrapperPeerImpl;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
@@ -43,7 +42,6 @@
import com.intellij.util.PathUtil;
import com.intellij.util.ui.FormBuilder;
import com.intellij.util.ui.UIUtil;
-import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -55,29 +53,33 @@
public class CopyFilesOrDirectoriesDialog extends DialogWrapper {
public static final int MAX_PATH_LENGTH = 70;
- private static final String COPY_OPEN_IN_EDITOR = "Copy.OpenInEditor";
- private JLabel myInformationLabel;
- private TextFieldWithHistoryWithBrowseButton myTargetDirectoryField;
- private JCheckBox myOpenFilesInEditor = createOpenInEditorCB();
+ private static final String COPY_OPEN_IN_EDITOR = "Copy.OpenInEditor";
+ private static final String RECENT_KEYS = "CopyFile.RECENT_KEYS";
+
+ public static String shortenPath(VirtualFile file) {
+ return StringUtil.shortenPathWithEllipsis(file.getPresentableUrl(), MAX_PATH_LENGTH);
+ }
public static JCheckBox createOpenInEditorCB() {
- final JCheckBox checkBox = new JCheckBox("Open copy in editor", PropertiesComponent.getInstance().getBoolean(COPY_OPEN_IN_EDITOR, true));
+ JCheckBox checkBox = new JCheckBox("Open copy in editor", PropertiesComponent.getInstance().getBoolean(COPY_OPEN_IN_EDITOR, true));
checkBox.setMnemonic('o');
return checkBox;
}
-
+
public static void saveOpenInEditorState(boolean selected) {
PropertiesComponent.getInstance().setValue(COPY_OPEN_IN_EDITOR, String.valueOf(selected));
}
+ private JLabel myInformationLabel;
+ private TextFieldWithHistoryWithBrowseButton myTargetDirectoryField;
+ private JCheckBox myOpenFilesInEditor = createOpenInEditorCB();
private JTextField myNewNameField;
private final Project myProject;
private final boolean myShowDirectoryField;
private final boolean myShowNewNameField;
private PsiDirectory myTargetDirectory;
- @NonNls private static final String RECENT_KEYS = "CopyFile.RECENT_KEYS";
private boolean myFileCopy = false;
public CopyFilesOrDirectoriesDialog(PsiElement[] elements, PsiDirectory defaultTargetDirectory, Project project, boolean doClone) {
@@ -90,9 +92,7 @@
throw new IllegalArgumentException("wrong number of elements to clone: " + elements.length);
}
- setTitle(doClone ?
- RefactoringBundle.message("copy.files.clone.title") :
- RefactoringBundle.message("copy.files.copy.title"));
+ setTitle(RefactoringBundle.message(doClone ? "copy.files.clone.title" : "copy.files.copy.title"));
init();
if (elements.length == 1) {
@@ -100,24 +100,20 @@
if (elements[0] instanceof PsiFile) {
PsiFile file = (PsiFile)elements[0];
String url = shortenPath(file.getVirtualFile());
- text = doClone ?
- RefactoringBundle.message("copy.files.clone.file.0", url) :
- RefactoringBundle.message("copy.files.copy.file.0", url);
+ text = RefactoringBundle.message(doClone ? "copy.files.clone.file.0" : "copy.files.copy.file.0", url);
final String fileName = file.getName();
myNewNameField.setText(fileName);
final int dotIdx = fileName.lastIndexOf(".");
if (dotIdx > -1) {
myNewNameField.select(0, dotIdx);
- myNewNameField.putClientProperty(DialogWrapperPeerImpl.HAVE_INITIAL_SELECTION, true);
+ myNewNameField.putClientProperty(DialogWrapperPeer.HAVE_INITIAL_SELECTION, true);
}
myFileCopy = true;
}
else {
PsiDirectory directory = (PsiDirectory)elements[0];
String url = shortenPath(directory.getVirtualFile());
- text = doClone ?
- RefactoringBundle.message("copy.files.clone.directory.0", url) :
- RefactoringBundle.message("copy.files.copy.directory.0", url);
+ text = RefactoringBundle.message(doClone ? "copy.files.clone.directory.0" : "copy.files.copy.directory.0", url);
myNewNameField.setText(directory.getName());
}
myInformationLabel.setText(text);
@@ -137,16 +133,12 @@
myOpenFilesInEditor.setVisible(false);
}
if (myShowDirectoryField) {
- myTargetDirectoryField.getChildComponent()
- .setText(defaultTargetDirectory == null ? "" : defaultTargetDirectory.getVirtualFile().getPresentableUrl());
+ String targetPath = defaultTargetDirectory == null ? "" : defaultTargetDirectory.getVirtualFile().getPresentableUrl();
+ myTargetDirectoryField.getChildComponent().setText(targetPath);
}
validateOKButton();
}
- public static String shortenPath(VirtualFile file) {
- return StringUtil.shortenPathWithEllipsis(file.getPresentableUrl(), MAX_PATH_LENGTH);
- }
-
private void setMultipleElementCopyLabel(PsiElement[] elements) {
boolean allFiles = true;
boolean allDirectories = true;
@@ -252,11 +244,10 @@
String newName = getNewName();
if (newName.length() == 0) {
- Messages.showMessageDialog(myProject, RefactoringBundle.message("no.new.name.specified"), RefactoringBundle.message("error.title"),
- Messages.getErrorIcon());
+ Messages.showErrorDialog(myProject, RefactoringBundle.message("no.new.name.specified"), RefactoringBundle.message("error.title"));
return;
}
-
+
if (myFileCopy && !PathUtil.isValidFileName(newName)) {
Messages.showErrorDialog(myNewNameField, "Name is not a valid file name");
return;
@@ -268,8 +259,8 @@
final String targetDirectoryName = myTargetDirectoryField.getChildComponent().getText();
if (targetDirectoryName.length() == 0) {
- Messages.showMessageDialog(myProject, RefactoringBundle.message("no.target.directory.specified"),
- RefactoringBundle.message("error.title"), Messages.getErrorIcon());
+ Messages.showErrorDialog(myProject, RefactoringBundle.message("no.target.directory.specified"),
+ RefactoringBundle.message("error.title"));
return;
}
@@ -285,17 +276,14 @@
myTargetDirectory =
DirectoryUtil.mkdirs(PsiManager.getInstance(myProject), targetDirectoryName.replace(File.separatorChar, '/'));
}
- catch (IncorrectOperationException e) {
- }
+ catch (IncorrectOperationException ignored) { }
}
});
}
}, RefactoringBundle.message("create.directory"), null);
if (myTargetDirectory == null) {
- Messages
- .showMessageDialog(myProject, RefactoringBundle.message("cannot.create.directory"), RefactoringBundle.message("error.title"),
- Messages.getErrorIcon());
+ Messages.showErrorDialog(myProject, RefactoringBundle.message("cannot.create.directory"), RefactoringBundle.message("error.title"));
return;
}
}
diff --git a/platform/lang-impl/src/com/intellij/refactoring/copy/CopyFilesOrDirectoriesHandler.java b/platform/lang-impl/src/com/intellij/refactoring/copy/CopyFilesOrDirectoriesHandler.java
index fcce076..eb2aa59 100644
--- a/platform/lang-impl/src/com/intellij/refactoring/copy/CopyFilesOrDirectoriesHandler.java
+++ b/platform/lang-impl/src/com/intellij/refactoring/copy/CopyFilesOrDirectoriesHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.intellij.refactoring.copy;
import com.intellij.CommonBundle;
@@ -39,11 +38,12 @@
import java.io.IOException;
import java.util.HashSet;
+import java.util.Set;
public class CopyFilesOrDirectoriesHandler extends CopyHandlerDelegateBase {
@Override
public boolean canCopy(PsiElement[] elements, boolean fromUpdate) {
- HashSet<String> names = new HashSet<String>();
+ Set<String> names = new HashSet<String>();
for (PsiElement element : elements) {
if (!(element instanceof PsiFileSystemItem)) return false;
if (!element.isValid()) return false;
@@ -105,6 +105,7 @@
CommonRefactoringUtil.showErrorHint(project, null, e.getMessage(), CommonBundle.getErrorTitle(), null);
return;
}
+
copyImpl(elements, newName, targetDirectory, false, openInEditor);
}
}
@@ -118,6 +119,7 @@
PsiDirectory targetDirectory;
if (element instanceof PsiDirectory) {
targetDirectory = ((PsiDirectory)element).getParentDirectory();
+ assert targetDirectory != null : element;
}
else {
targetDirectory = ((PsiFile)element).getContainingDirectory();
@@ -166,7 +168,6 @@
}
/**
- *
* @param elements
* @param newName can be not null only if elements.length == 1
* @param targetDirectory
@@ -175,7 +176,7 @@
private static void copyImpl(@NotNull final PsiElement[] elements,
@Nullable final String newName,
@NotNull final PsiDirectory targetDirectory,
- final boolean doClone,
+ final boolean doClone,
final boolean openInEditor) {
if (doClone && elements.length != 1) {
throw new IllegalArgumentException("invalid number of elements to clone:" + elements.length);
@@ -207,11 +208,11 @@
if (!(firstFile instanceof PsiBinaryFile) && openInEditor){
EditorHelper.openInEditor(firstFile);
ApplicationManager.getApplication().invokeLater(new Runnable() {
- @Override
- public void run() {
- ToolWindowManager.getInstance(project).activateEditorComponent();
- }
- });
+ @Override
+ public void run() {
+ ToolWindowManager.getInstance(project).activateEditorComponent();
+ }
+ });
}
}
}
@@ -219,7 +220,7 @@
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
- Messages.showMessageDialog(project, ex.getMessage(), RefactoringBundle.message("error.title"), Messages.getErrorIcon());
+ Messages.showErrorDialog(project, ex.getMessage(), RefactoringBundle.message("error.title"));
}
});
}
@@ -227,7 +228,7 @@
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
- Messages.showMessageDialog(project, ex.getMessage(), RefactoringBundle.message("error.title"), Messages.getErrorIcon());
+ Messages.showErrorDialog(project, ex.getMessage(), RefactoringBundle.message("error.title"));
}
});
}
@@ -236,36 +237,34 @@
ApplicationManager.getApplication().runWriteAction(action);
}
};
- CommandProcessor.getInstance().executeCommand(project, command, doClone ?
- RefactoringBundle.message("copy,handler.clone.files.directories") :
- RefactoringBundle.message("copy.handler.copy.files.directories"), null);
+
+ String title = RefactoringBundle.message(doClone ? "copy,handler.clone.files.directories" : "copy.handler.copy.files.directories");
+ CommandProcessor.getInstance().executeCommand(project, command, title, null);
}
/**
* @param elementToCopy PsiFile or PsiDirectory
* @param newName can be not null only if elements.length == 1
- * @return first copied PsiFile (recursivly); null if no PsiFiles copied
+ * @return first copied PsiFile (recursively); null if no PsiFiles copied
*/
@Nullable
public static PsiFile copyToDirectory(@NotNull PsiFileSystemItem elementToCopy,
@Nullable String newName,
- @NotNull PsiDirectory targetDirectory)
- throws IncorrectOperationException, IOException {
+ @NotNull PsiDirectory targetDirectory) throws IncorrectOperationException, IOException {
return copyToDirectory(elementToCopy, newName, targetDirectory, null);
}
/**
- *
* @param elementToCopy PsiFile or PsiDirectory
* @param newName can be not null only if elements.length == 1
- * @param choice
- * @return first copied PsiFile (recursivly); null if no PsiFiles copied
+ * @param choice a horrible way to pass/keep user preference
+ * @return first copied PsiFile (recursively); null if no PsiFiles copied
*/
@Nullable
public static PsiFile copyToDirectory(@NotNull PsiFileSystemItem elementToCopy,
@Nullable String newName,
- @NotNull PsiDirectory targetDirectory, int[] choice)
- throws IncorrectOperationException, IOException {
+ @NotNull PsiDirectory targetDirectory,
+ @Nullable int[] choice) throws IncorrectOperationException, IOException {
if (elementToCopy instanceof PsiFile) {
PsiFile file = (PsiFile)elementToCopy;
String name = newName == null ? file.getName() : newName;
@@ -303,23 +302,33 @@
}
}
- public static boolean checkFileExist(PsiDirectory targetDirectory, int[] choice, PsiFile file, String name, final String title) {
+ public static boolean checkFileExist(PsiDirectory targetDirectory, int[] choice, PsiFile file, String name, String title) {
final PsiFile existing = targetDirectory.findFile(name);
if (existing != null && !existing.equals(file)) {
- int selection = choice == null || choice[0] == -1 ? Messages.showDialog(
- String.format("File '%s' already exists in directory '%s'", name, targetDirectory.getVirtualFile().getPath()),
- title,
- choice == null ? new String[]{"Overwrite", "Skip"}
- : new String[]{"Overwrite", "Skip", "Overwrite for all", "Skip for all"}, 0, Messages.getQuestionIcon())
- : choice[0];
+ int selection;
+ if (choice == null || choice[0] == -1) {
+ String message = String.format("File '%s' already exists in directory '%s'", name, targetDirectory.getVirtualFile().getPath());
+ String[] options = choice == null ? new String[]{"Overwrite", "Skip"}
+ : new String[]{"Overwrite", "Skip", "Overwrite for all", "Skip for all"};
+ selection = Messages.showDialog(message, title, options, 0, Messages.getQuestionIcon());
+ }
+ else {
+ selection = choice[0];
+ }
+
if (choice != null && selection > 1) {
choice[0] = selection % 2;
selection = choice[0];
}
+
if (selection == 0 && file != existing) {
existing.delete();
- } else return true;
+ }
+ else {
+ return true;
+ }
}
+
return false;
}
diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/naming/AutomaticRenamer.java b/platform/lang-impl/src/com/intellij/refactoring/rename/naming/AutomaticRenamer.java
index f586257..5db4a96 100644
--- a/platform/lang-impl/src/com/intellij/refactoring/rename/naming/AutomaticRenamer.java
+++ b/platform/lang-impl/src/com/intellij/refactoring/rename/naming/AutomaticRenamer.java
@@ -132,18 +132,7 @@
final PsiNamedElement element = myElements.get(varIndex);
final String name = element.getName();
if (!myRenames.containsKey(element)) {
- String newName;
- if (oldClassName.equals(name)) {
- newName = newClassName;
- } else {
- String canonicalName = nameToCanonicalName(name, element);
- final String newCanonicalName = suggester.suggestName(canonicalName);
- if (newCanonicalName.length() == 0) {
- LOG.error("oldClassName = " + oldClassName + ", newClassName = " + newClassName + ", name = " + name + ", canonicalName = " +
- canonicalName + ", newCanonicalName = " + newCanonicalName);
- }
- newName = canonicalNameToName(newCanonicalName, element);
- }
+ String newName = suggestNameForElement(element, suggester, newClassName, oldClassName);
if (!newName.equals(name)) {
myRenames.put(element, newName);
}
@@ -157,6 +146,20 @@
}
}
+ protected String suggestNameForElement(PsiNamedElement element, NameSuggester suggester, String newClassName, String oldClassName) {
+ String name = element.getName();
+ if (oldClassName.equals(name)) {
+ return newClassName;
+ }
+ String canonicalName = nameToCanonicalName(name, element);
+ final String newCanonicalName = suggester.suggestName(canonicalName);
+ if (newCanonicalName.length() == 0) {
+ LOG.error("oldClassName = " + oldClassName + ", newClassName = " + newClassName + ", name = " + name + ", canonicalName = " +
+ canonicalName + ", newCanonicalName = " + newCanonicalName);
+ }
+ return canonicalNameToName(newCanonicalName, element);
+ }
+
@NonNls
protected String canonicalNameToName(@NonNls String canonicalName, PsiNamedElement element) {
return canonicalName;
diff --git a/platform/lang-impl/src/com/intellij/refactoring/safeDelete/SafeDeleteProcessor.java b/platform/lang-impl/src/com/intellij/refactoring/safeDelete/SafeDeleteProcessor.java
index 4e70241..2d64138 100644
--- a/platform/lang-impl/src/com/intellij/refactoring/safeDelete/SafeDeleteProcessor.java
+++ b/platform/lang-impl/src/com/intellij/refactoring/safeDelete/SafeDeleteProcessor.java
@@ -244,6 +244,7 @@
presentation.setShowReadOnlyStatusAsRed(true);
presentation.setShowCancelButton(true);
presentation.setCodeUsagesString(RefactoringBundle.message("references.found.in.code"));
+ presentation.setUsagesInGeneratedCodeString(RefactoringBundle.message("references.found.in.generated.code"));
presentation.setNonCodeUsagesString(RefactoringBundle.message("occurrences.found.in.comments.strings.and.non.java.files"));
presentation.setUsagesString(RefactoringBundle.message("usageView.usagesText"));
diff --git a/platform/lang-impl/src/com/intellij/usageView/impl/UsageContextCallHierarchyPanel.java b/platform/lang-impl/src/com/intellij/usageView/impl/UsageContextCallHierarchyPanel.java
index 1a23bd1..21e8742 100644
--- a/platform/lang-impl/src/com/intellij/usageView/impl/UsageContextCallHierarchyPanel.java
+++ b/platform/lang-impl/src/com/intellij/usageView/impl/UsageContextCallHierarchyPanel.java
@@ -101,7 +101,7 @@
removeAll();
if (element == null) {
- JComponent titleComp = new JLabel(UsageViewBundle.message("select.the.usage.to.preview"));
+ JComponent titleComp = new JLabel(UsageViewBundle.message("select.the.usage.to.preview"), SwingConstants.CENTER);
add(titleComp, BorderLayout.CENTER);
revalidate();
}
diff --git a/platform/lang-impl/src/com/intellij/usageView/impl/UsageViewManagerImpl.java b/platform/lang-impl/src/com/intellij/usageView/impl/UsageViewManagerImpl.java
index 0640c9b..b2ee89c 100644
--- a/platform/lang-impl/src/com/intellij/usageView/impl/UsageViewManagerImpl.java
+++ b/platform/lang-impl/src/com/intellij/usageView/impl/UsageViewManagerImpl.java
@@ -83,6 +83,7 @@
content.setTabName(tabName);
content.setToolwindowTitle(toolwindowTitle);
content.putUserData(contentKey, Boolean.TRUE);
+ content.putUserData(ToolWindow.SHOW_CONTENT_ICON, Boolean.TRUE);
myFindContentManager.addContent(content);
myFindContentManager.setSelectedContent(content);
diff --git a/platform/lang-impl/src/com/intellij/util/download/impl/FileDownloaderImpl.java b/platform/lang-impl/src/com/intellij/util/download/impl/FileDownloaderImpl.java
index 0ed979c..fece314 100644
--- a/platform/lang-impl/src/com/intellij/util/download/impl/FileDownloaderImpl.java
+++ b/platform/lang-impl/src/com/intellij/util/download/impl/FileDownloaderImpl.java
@@ -16,6 +16,8 @@
package com.intellij.util.download.impl;
+import com.google.common.util.concurrent.AtomicDouble;
+import com.intellij.concurrency.JobLauncher;
import com.intellij.ide.IdeBundle;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.application.Result;
@@ -27,6 +29,7 @@
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
+import com.intellij.openapi.progress.util.AbstractProgressIndicatorBase;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Pair;
@@ -34,6 +37,8 @@
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.*;
+import com.intellij.util.Processor;
+import com.intellij.util.containers.hash.LinkedHashMap;
import com.intellij.util.download.DownloadableFileDescription;
import com.intellij.util.download.FileDownloader;
import com.intellij.util.io.UrlConnectionUtil;
@@ -49,6 +54,7 @@
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.atomic.AtomicReference;
/**
* @author nik
@@ -147,49 +153,60 @@
@NotNull
@Override
- public List<Pair<File, DownloadableFileDescription>> download(@NotNull File targetDir) throws IOException {
+ public List<Pair<File, DownloadableFileDescription>> download(@NotNull final File targetDir) throws IOException {
final List<Pair<File, DownloadableFileDescription>> downloadedFiles = new ArrayList<Pair<File, DownloadableFileDescription>>();
final List<Pair<File, DownloadableFileDescription>> existingFiles = new ArrayList<Pair<File, DownloadableFileDescription>>();
- ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
- if (indicator == null) {
- indicator = new EmptyProgressIndicator();
- }
+ final ProgressIndicator parentIndicator = getProgressIndicator();
try {
- for (int i = 0; i < myFileDescriptions.size(); i++) {
- DownloadableFileDescription description = myFileDescriptions.get(i);
- indicator.checkCanceled();
- indicator.setText(IdeBundle.message("progress.downloading.0.of.1.file.text", i + 1, myFileDescriptions.size()));
+ final AtomicReference<IOException> ioException = new AtomicReference<IOException>();
+ final ConcurrentTasksProgressManager progressManager = new ConcurrentTasksProgressManager(parentIndicator, myFileDescriptions.size());
+ parentIndicator.setText(IdeBundle.message("progress.downloading.0.files.text", myFileDescriptions.size()));
+ boolean finished = JobLauncher.getInstance().invokeConcurrentlyUnderProgress(myFileDescriptions, parentIndicator, false, false, new Processor<DownloadableFileDescription>() {
+ @Override
+ public boolean process(DownloadableFileDescription description) {
+ SubTaskProgressIndicator indicator = progressManager.createSubTaskIndicator();
+ indicator.checkCanceled();
- final File existing = new File(targetDir, description.getDefaultFileName());
- final String url = description.getDownloadUrl();
- if (url.startsWith(LIB_SCHEMA)) {
- indicator.setText2(IdeBundle.message("progress.locate.file.text", description.getPresentableFileName()));
- final String path = FileUtil.toSystemDependentName(StringUtil.trimStart(url, LIB_SCHEMA));
- final File file = PathManager.findFileInLibDirectory(path);
- existingFiles.add(Pair.create(file, description));
- }
- else if (url.startsWith(LocalFileSystem.PROTOCOL_PREFIX)) {
- String path = FileUtil.toSystemDependentName(StringUtil.trimStart(url, LocalFileSystem.PROTOCOL_PREFIX));
- File file = new File(path);
- if (file.exists()) {
+ final File existing = new File(targetDir, description.getDefaultFileName());
+ final String url = description.getDownloadUrl();
+ if (url.startsWith(LIB_SCHEMA)) {
+ final String path = FileUtil.toSystemDependentName(StringUtil.trimStart(url, LIB_SCHEMA));
+ final File file = PathManager.findFileInLibDirectory(path);
existingFiles.add(Pair.create(file, description));
}
- }
- else {
- File downloaded;
- try {
- downloaded = downloadFile(description, existing, indicator);
- }
- catch (IOException e) {
- throw new IOException(IdeBundle.message("error.file.download.failed", description.getDownloadUrl(), e.getMessage()), e);
- }
- if (FileUtil.filesEqual(downloaded, existing)) {
- existingFiles.add(Pair.create(existing, description));
+ else if (url.startsWith(LocalFileSystem.PROTOCOL_PREFIX)) {
+ String path = FileUtil.toSystemDependentName(StringUtil.trimStart(url, LocalFileSystem.PROTOCOL_PREFIX));
+ File file = new File(path);
+ if (file.exists()) {
+ existingFiles.add(Pair.create(file, description));
+ }
}
else {
- downloadedFiles.add(Pair.create(downloaded, description));
+ File downloaded;
+ try {
+ downloaded = downloadFile(description, existing, indicator);
+ }
+ catch (IOException e) {
+ ioException.compareAndSet(null, new IOException(IdeBundle.message("error.file.download.failed", description.getDownloadUrl(),
+ e.getMessage()), e));
+ return false;
+ }
+ if (FileUtil.filesEqual(downloaded, existing)) {
+ existingFiles.add(Pair.create(existing, description));
+ }
+ else {
+ downloadedFiles.add(Pair.create(downloaded, description));
+ }
}
+ indicator.finished();
+ return true;
}
+ });
+ if (!finished) {
+ if (ioException.get() != null) {
+ throw ioException.get();
+ }
+ throw new ProcessCanceledException();
}
List<Pair<File, DownloadableFileDescription>> localFiles = new ArrayList<Pair<File, DownloadableFileDescription>>();
localFiles.addAll(moveToDir(downloadedFiles, targetDir));
@@ -206,6 +223,12 @@
}
}
+ @NotNull
+ private static ProgressIndicator getProgressIndicator() {
+ ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
+ return indicator == null ? new EmptyProgressIndicator() : indicator;
+ }
+
@Nullable
private static VirtualFile chooseDirectoryForFiles(Project project, JComponent parentComponent) {
final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
@@ -330,4 +353,82 @@
public List<Pair<VirtualFile, DownloadableFileDescription>> downloadAndReturnWithDescriptions() {
return downloadWithProgress(myDirectoryForDownloadedFilesPath, myProject, myParentComponent);
}
+
+ private static class ConcurrentTasksProgressManager {
+ private final ProgressIndicator myParent;
+ private final int myTasksCount;
+ private final AtomicDouble myTotalFraction;
+ private LinkedHashMap<SubTaskProgressIndicator, String> myText2Stack = new LinkedHashMap<SubTaskProgressIndicator, String>();
+
+ private ConcurrentTasksProgressManager(ProgressIndicator parent, int tasksCount) {
+ myParent = parent;
+ myTasksCount = tasksCount;
+ myTotalFraction = new AtomicDouble();
+ }
+
+ public void updateFraction(double delta) {
+ myTotalFraction.addAndGet(delta / myTasksCount);
+ myParent.setFraction(myTotalFraction.get());
+ }
+
+ public SubTaskProgressIndicator createSubTaskIndicator() {
+ return new SubTaskProgressIndicator(this);
+ }
+
+ public void setText2(@NotNull SubTaskProgressIndicator subTask, @Nullable String text) {
+ if (text != null) {
+ myText2Stack.put(subTask, text);
+ myParent.setText2(text);
+ }
+ else {
+ myText2Stack.remove(subTask);
+ String prev = myText2Stack.getLastValue();
+ if (prev != null) {
+ myParent.setText2(prev);
+ }
+ }
+ }
+ }
+
+ private static class SubTaskProgressIndicator extends AbstractProgressIndicatorBase {
+ private final AtomicDouble myFraction;
+ private final ConcurrentTasksProgressManager myProgressManager;
+
+ private SubTaskProgressIndicator(ConcurrentTasksProgressManager progressManager) {
+ myProgressManager = progressManager;
+ myFraction = new AtomicDouble();
+ }
+
+ @Override
+ public void setFraction(double newValue) {
+ double oldValue = myFraction.getAndSet(newValue);
+ myProgressManager.updateFraction(newValue - oldValue);
+ }
+
+ @Override
+ public void setIndeterminate(boolean indeterminate) {
+ if (myProgressManager.myTasksCount > 1) return;
+ super.setIndeterminate(indeterminate);
+ }
+
+ @Override
+ public void setText2(String text) {
+ myProgressManager.setText2(this, text);
+ }
+
+ @Override
+ public double getFraction() {
+ return myFraction.get();
+ }
+
+ public void finished() {
+ setFraction(1);
+ myProgressManager.setText2(this, null);
+ }
+
+ @Override
+ public boolean isCanceled() {
+ return super.isCanceled() || myProgressManager.myParent.isCanceled();
+ }
+ }
}
diff --git a/platform/platform-api/src/com/intellij/execution/process/ColoredProcessHandler.java b/platform/platform-api/src/com/intellij/execution/process/ColoredProcessHandler.java
index 59b87d5..6250080 100644
--- a/platform/platform-api/src/com/intellij/execution/process/ColoredProcessHandler.java
+++ b/platform/platform-api/src/com/intellij/execution/process/ColoredProcessHandler.java
@@ -32,6 +32,10 @@
public class ColoredProcessHandler extends OSProcessHandler implements AnsiEscapeDecoder.ColoredTextAcceptor {
private final AnsiEscapeDecoder myAnsiEscapeDecoder = new AnsiEscapeDecoder();
+ /**
+ * todo ruby plugin compatibility. Remove on the next update.
+ */
+ @Deprecated
public static TextAttributes getByKey(final TextAttributesKey key) {
return EditorColorsManager.getInstance().getGlobalScheme().getAttributes(key);
}
diff --git a/platform/platform-api/src/com/intellij/execution/ui/ConsoleViewContentType.java b/platform/platform-api/src/com/intellij/execution/ui/ConsoleViewContentType.java
index 1b51bac..1a74012 100644
--- a/platform/platform-api/src/com/intellij/execution/ui/ConsoleViewContentType.java
+++ b/platform/platform-api/src/com/intellij/execution/ui/ConsoleViewContentType.java
@@ -23,6 +23,7 @@
import com.intellij.openapi.util.Key;
import com.intellij.util.containers.HashMap;
import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
import java.util.Map;
@@ -82,6 +83,12 @@
return myTextAttributes;
}
+ public static ConsoleViewContentType registerNewConsoleViewType(@NotNull Key key, @NotNull TextAttributesKey attributesKey) {
+ ConsoleViewContentType type = new ConsoleViewContentType(key.toString(), attributesKey);
+ registerNewConsoleViewType(key, type);
+ return type;
+ }
+
public static synchronized void registerNewConsoleViewType(final Key processOutputType, final ConsoleViewContentType attributes) {
ourRegisteredTypes.put(processOutputType, attributes);
}
diff --git a/platform/platform-api/src/com/intellij/notification/EventLogCategory.java b/platform/platform-api/src/com/intellij/notification/EventLogCategory.java
new file mode 100644
index 0000000..5cb872a
--- /dev/null
+++ b/platform/platform-api/src/com/intellij/notification/EventLogCategory.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.notification;
+
+import com.intellij.openapi.extensions.ExtensionPointName;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author gregsh
+ */
+public abstract class EventLogCategory {
+ public static final ExtensionPointName<EventLogCategory> EP_NAME = ExtensionPointName.create("com.intellij.eventLogCategory");
+
+ private final String myDisplayName;
+
+ protected EventLogCategory(@NotNull String displayName) {
+ myDisplayName = displayName;
+ }
+
+ @NotNull
+ public final String getDisplayName() {
+ return myDisplayName;
+ }
+
+ public abstract boolean acceptsNotification(@NotNull String groupId);
+}
diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/AbbreviationManager.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/AbbreviationManager.java
new file mode 100644
index 0000000..78db7cf
--- /dev/null
+++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/AbbreviationManager.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.openapi.actionSystem;
+
+import com.intellij.openapi.application.ApplicationManager;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author Konstantin Bulenkov
+ * @since 13
+ */
+public abstract class AbbreviationManager {
+ public static AbbreviationManager getInstance() {
+ return ApplicationManager.getApplication().getComponent(AbbreviationManager.class);
+ }
+ public abstract Set<String> getAbbreviations();
+ public abstract Set<String> getAbbreviations(String actionId);
+ public abstract List<String> findActions(String abbreviation);
+ public abstract void register(String abbreviation, String actionId);
+ public abstract void remove(String abbreviation, String actionId);
+}
diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/ActionManagerEx.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/ActionManagerEx.java
index e010f66..e1f198d 100644
--- a/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/ActionManagerEx.java
+++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/ActionManagerEx.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.
@@ -21,7 +21,9 @@
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
+import java.util.Collections;
import java.util.Comparator;
+import java.util.List;
public abstract class ActionManagerEx extends ActionManager {
@@ -114,5 +116,13 @@
public abstract boolean isActionPopupStackEmpty();
public abstract boolean isTransparentOnlyActionsUpdateNow();
+
+ public List<String> getAbbreviations() {
+ return Collections.emptyList();
+ }
+
+ public List<String> findActionIdsByAbbreviation(String abbreviation) {
+ return Collections.emptyList();
+ }
}
diff --git a/platform/platform-api/src/com/intellij/openapi/keymap/Keymap.java b/platform/platform-api/src/com/intellij/openapi/keymap/Keymap.java
index 94c53b7..35a9c5e 100644
--- a/platform/platform-api/src/com/intellij/openapi/keymap/Keymap.java
+++ b/platform/platform-api/src/com/intellij/openapi/keymap/Keymap.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.
@@ -79,6 +79,12 @@
void removeAllActionShortcuts(String actionId);
+ String[] getAbbreviations();
+
+ void addAbbreviation(String actionId, String abbreviation);
+
+ void removeAbbreviation(String actionId, String abbreviation);
+
interface Listener {
void onShortcutChanged(String actionId);
}
diff --git a/platform/platform-api/src/com/intellij/openapi/ui/DialogBuilder.java b/platform/platform-api/src/com/intellij/openapi/ui/DialogBuilder.java
index d3959de..76c10a8 100644
--- a/platform/platform-api/src/com/intellij/openapi/ui/DialogBuilder.java
+++ b/platform/platform-api/src/com/intellij/openapi/ui/DialogBuilder.java
@@ -25,6 +25,7 @@
import org.intellij.lang.annotations.MagicConstant;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
@@ -317,6 +318,12 @@
myHelpId = helpId;
}
+ @Nullable
+ @Override
+ protected String getHelpId() {
+ return myHelpId;
+ }
+
public void init() { super.init(); }
@NotNull
public Action getOKAction() { return super.getOKAction(); } // Make it public
diff --git a/platform/platform-api/src/com/intellij/openapi/ui/MessageType.java b/platform/platform-api/src/com/intellij/openapi/ui/MessageType.java
index a9d4ca3..c9f9a28 100644
--- a/platform/platform-api/src/com/intellij/openapi/ui/MessageType.java
+++ b/platform/platform-api/src/com/intellij/openapi/ui/MessageType.java
@@ -29,7 +29,7 @@
public static final MessageType INFO = new MessageType(UIUtil.getBalloonInformationIcon(),
new JBColor(new Color(186, 238, 186, 230), new Color(73, 117, 73)));
public static final MessageType WARNING = new MessageType(UIUtil.getBalloonWarningIcon(),
- new JBColor(new Color(249, 247, 142, 230), new Color(128, 125, 75)));
+ new JBColor(new Color(249, 247, 142, 230), new Color(90, 82, 33)));
private final Icon myDefaultIcon;
private final Color myPopupBackground;
diff --git a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java
index a23ac12..fb21fe2 100644
--- a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java
+++ b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java
@@ -182,7 +182,7 @@
public static int showDialog(Project project,
String message,
@NotNull String title,
- String moreInfo,
+ @Nullable String moreInfo,
@NotNull String[] options,
int defaultOptionIndex,
int focusedOptionIndex,
@@ -1055,12 +1055,12 @@
}
private static class MoreInfoMessageDialog extends MessageDialog {
- private final String myInfoText;
+ @Nullable private final String myInfoText;
public MoreInfoMessageDialog(Project project,
String message,
String title,
- String moreInfo,
+ @Nullable String moreInfo,
@NotNull String[] options,
int defaultOptionIndex, int focusedOptionIndex, Icon icon) {
super(project);
@@ -1075,6 +1075,9 @@
@Override
protected JComponent createCenterPanel() {
+ if (myInfoText == null) {
+ return null;
+ }
final JPanel panel = new JPanel(new BorderLayout());
final JTextArea area = new JTextArea(myInfoText);
area.setEditable(false);
diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/LocalFileSystem.java b/platform/platform-api/src/com/intellij/openapi/vfs/LocalFileSystem.java
index a54db56..58b5469 100644
--- a/platform/platform-api/src/com/intellij/openapi/vfs/LocalFileSystem.java
+++ b/platform/platform-api/src/com/intellij/openapi/vfs/LocalFileSystem.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.
@@ -26,7 +26,6 @@
import org.jetbrains.annotations.Nullable;
import java.io.File;
-import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
@@ -102,18 +101,6 @@
public abstract void refreshFiles(@NotNull Iterable<VirtualFile> files, boolean async, boolean recursive, @Nullable Runnable onFinish);
- /** @deprecated use {@linkplain com.intellij.openapi.vfs.VirtualFile#contentsToByteArray()} (to remove in IDEA 13) */
- @SuppressWarnings({"MethodMayBeStatic", "UnusedDeclaration"})
- public byte[] physicalContentsToByteArray(@NotNull VirtualFile virtualFile) throws IOException{
- return virtualFile.contentsToByteArray();
- }
-
- /** @deprecated use {@linkplain VirtualFile#getLength()} (to remove in IDEA 13) */
- @SuppressWarnings({"MethodMayBeStatic", "UnusedDeclaration"})
- public long physicalLength(@NotNull VirtualFile virtualFile) throws IOException{
- return virtualFile.getLength();
- }
-
@NotNull
public final VirtualFile getRoot() {
final String rootPath = SystemInfo.isWindows ? "" : "/";
@@ -127,14 +114,6 @@
String getRootPath();
boolean isToWatchRecursively();
-
- /** @deprecated implementation details (to remove in IDEA 13) */
- @SuppressWarnings({"UnusedDeclaration"})
- String getFileSystemRootPath();
-
- /** @deprecated implementation details (to remove in IDEA 13) */
- @SuppressWarnings({"UnusedDeclaration"})
- boolean dominates(@NotNull WatchRequest other);
}
@Nullable
diff --git a/platform/platform-api/src/com/intellij/openapi/wm/StatusBar.java b/platform/platform-api/src/com/intellij/openapi/wm/StatusBar.java
index 1005734..3895ce9 100644
--- a/platform/platform-api/src/com/intellij/openapi/wm/StatusBar.java
+++ b/platform/platform-api/src/com/intellij/openapi/wm/StatusBar.java
@@ -85,6 +85,9 @@
void updateWidget(@NotNull String id);
+ @Nullable
+ StatusBarWidget getWidget(String id);
+
void fireNotificationPopup(@NotNull JComponent content, Color backgroundColor);
StatusBar createChild();
diff --git a/platform/platform-api/src/com/intellij/ui/ColoredListCellRenderer.java b/platform/platform-api/src/com/intellij/ui/ColoredListCellRenderer.java
index 8c06941..372c4b563 100644
--- a/platform/platform-api/src/com/intellij/ui/ColoredListCellRenderer.java
+++ b/platform/platform-api/src/com/intellij/ui/ColoredListCellRenderer.java
@@ -24,7 +24,7 @@
/**
* @author Vladimir Kondratyev
*/
-public abstract class ColoredListCellRenderer extends SimpleColoredComponent implements ListCellRenderer {
+public abstract class ColoredListCellRenderer<T> extends SimpleColoredComponent implements ListCellRenderer {
private final ListCellRenderer myDefaultGtkRenderer = UIUtil.isUnderGTKLookAndFeel() ? new JComboBox().getRenderer() : null;
protected boolean mySelected;
@@ -61,7 +61,7 @@
setPaintFocusBorder(hasFocus);
- customizeCellRenderer(list, value, index, selected, hasFocus);
+ customizeCellRenderer(list, (T)value, index, selected, hasFocus);
if (myDefaultGtkRenderer != null && list.getModel() instanceof ComboBoxModel) {
final Component component = myDefaultGtkRenderer.getListCellRendererComponent(list, value, index, selected, hasFocus);
@@ -104,5 +104,5 @@
return result;
}
- protected abstract void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus);
+ protected abstract void customizeCellRenderer(JList list, T value, int index, boolean selected, boolean hasFocus);
}
diff --git a/platform/platform-api/src/com/intellij/ui/FilterComponent.java b/platform/platform-api/src/com/intellij/ui/FilterComponent.java
index 37b5249..2d4f97e 100644
--- a/platform/platform-api/src/com/intellij/ui/FilterComponent.java
+++ b/platform/platform-api/src/com/intellij/ui/FilterComponent.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,7 +34,7 @@
public abstract class FilterComponent extends JPanel {
private final SearchTextFieldWithStoredHistory myFilter;
private final Alarm myUpdateAlarm = new Alarm();
- private boolean myOnTheFly;
+ private final boolean myOnTheFly;
public FilterComponent(@NonNls String propertyName, int historySize) {
this(propertyName, historySize, true);
@@ -60,6 +60,12 @@
protected Component getPopupLocationComponent() {
return FilterComponent.this.getPopupLocationComponent();
}
+
+ @Override
+ protected void onFocusLost() {
+ addCurrentTextToHistory();
+ super.onFocusLost();
+ }
};
myFilter.getTextEditor().addKeyListener(new KeyAdapter() {
//to consume enter in combo box - do not process this event by default button from DialogWrapper
diff --git a/platform/platform-api/src/com/intellij/ui/ListScrollingUtil.java b/platform/platform-api/src/com/intellij/ui/ListScrollingUtil.java
index 49777bf..dd58560 100644
--- a/platform/platform-api/src/com/intellij/ui/ListScrollingUtil.java
+++ b/platform/platform-api/src/com/intellij/ui/ListScrollingUtil.java
@@ -149,7 +149,6 @@
public static void ensureIndexIsVisible(JList list, int index, int moveDirection) {
int visible = getVisibleRowCount(list);
- int size = list.getModel().getSize();
int top;
int bottom;
if (moveDirection == 0) {
@@ -164,6 +163,11 @@
top = index;
bottom = index + ROW_PADDING;
}
+ ensureRangeIsVisible(list, top, bottom);
+ }
+
+ public static void ensureRangeIsVisible(JList list, int top, int bottom) {
+ int size = list.getModel().getSize();
if (top < 0) {
top = 0;
}
diff --git a/platform/platform-api/src/com/intellij/ui/SearchTextField.java b/platform/platform-api/src/com/intellij/ui/SearchTextField.java
index b2bd48e..ac1b73b 100644
--- a/platform/platform-api/src/com/intellij/ui/SearchTextField.java
+++ b/platform/platform-api/src/com/intellij/ui/SearchTextField.java
@@ -26,6 +26,7 @@
import com.intellij.openapi.ui.popup.JBPopup;
import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.util.SystemInfo;
+import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.components.JBList;
import com.intellij.util.ui.UIUtil;
@@ -196,7 +197,7 @@
}
else {
for (int i = 0; i < itemsCount; i++) {
- String item = (String)myModel.getElementAt(i);
+ final String item = myModel.getElementAt(i);
addMenuItem(item);
}
}
@@ -242,9 +243,9 @@
public List<String> getHistory() {
final int itemsCount = myModel.getSize();
- List<String> history = new ArrayList<String>(itemsCount);
+ final List<String> history = new ArrayList<String>(itemsCount);
for (int i = 0; i < itemsCount; i++) {
- history.add((String)myModel.getElementAt(i));
+ history.add(myModel.getElementAt(i));
}
return history;
}
@@ -263,6 +264,9 @@
}
public void addCurrentTextToHistory() {
+ if ((myNativeSearchPopup != null && myNativeSearchPopup.isVisible()) || (myPopup != null && myPopup.isVisible())) {
+ return;
+ }
final String item = getText();
myModel.addElement(item);
}
@@ -275,6 +279,7 @@
menuItem.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
myTextField.setText(item);
+ addCurrentTextToHistory();
}
});
}
@@ -299,9 +304,9 @@
public class MyModel extends AbstractListModel {
private List<String> myFullList = new ArrayList<String>();
- private Object mySelectedItem;
+ private String mySelectedItem;
- public Object getElementAt(int index) {
+ public String getElementAt(int index) {
return myFullList.get(index);
}
@@ -309,28 +314,45 @@
return Math.min(myHistorySize, myFullList.size());
}
- public void addElement(Object obj) {
- String newItem = ((String)obj).trim();
-
- if (0 == newItem.length()) {
+ public void addElement(String item) {
+ final String newItem = item.trim();
+ if (newItem.isEmpty()) {
return;
}
- if (!contains(newItem)) {
- insertElementAt(newItem, 0);
+ final int length = myFullList.size();
+ int index = -1;
+ for (int i = 0; i < length; i++) {
+ if (StringUtil.equalsIgnoreCase(myFullList.get(i), newItem)) {
+ index = i;
+ break;
+ }
}
+ if (index == 0) {
+ // item is already at the top of the list
+ return;
+ }
+ else if (index > 0) {
+ // move item to top of the list
+ myFullList.remove(index);
+ }
+ else if (myFullList.size() >= myHistorySize) {
+ // trim list
+ myFullList.remove(myFullList.size() - 1);
+ }
+ insertElementAt(newItem, 0);
}
- public void insertElementAt(Object obj, int index) {
- myFullList.add(index, (String)obj);
+ public void insertElementAt(String item, int index) {
+ myFullList.add(index, item);
fireContentsChanged();
}
- public Object getSelectedItem() {
+ public String getSelectedItem() {
return mySelectedItem;
}
- public void setSelectedItem(Object anItem) {
+ public void setSelectedItem(String anItem) {
mySelectedItem = anItem;
}
@@ -339,10 +361,6 @@
updateMenu();
}
- public boolean contains(String aNewValue) {
- return myFullList.contains(aNewValue);
- }
-
public void setItems(List<String> aList) {
myFullList = new ArrayList<String>(aList);
fireContentsChanged();
@@ -361,6 +379,7 @@
public void run() {
final String value = (String)list.getSelectedValue();
getTextEditor().setText(value != null ? value : "");
+ addCurrentTextToHistory();
if (myPopup != null) {
myPopup.cancel();
myPopup = null;
diff --git a/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java b/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java
index 532562d2..7e0d6cd 100644
--- a/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java
+++ b/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java
@@ -128,8 +128,9 @@
myIconOnTheRight = iconOnTheRight;
}
- public final void append(@NotNull String fragment) {
+ public final SimpleColoredComponent append(@NotNull String fragment) {
append(fragment, SimpleTextAttributes.REGULAR_ATTRIBUTES);
+ return this;
}
/**
diff --git a/platform/platform-api/src/com/intellij/ui/components/JBPanel.java b/platform/platform-api/src/com/intellij/ui/components/JBPanel.java
index f4f7d11..c686ee1 100644
--- a/platform/platform-api/src/com/intellij/ui/components/JBPanel.java
+++ b/platform/platform-api/src/com/intellij/ui/components/JBPanel.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.
@@ -87,6 +87,10 @@
super.paintComponent(g);
}
+ paintCenterImage(g);
+ }
+
+ protected void paintCenterImage(Graphics g) {
Icon centerImage = getCenterImage();
if (centerImage != null) {
IconUtil.paintInCenterOf(this, g, centerImage);
diff --git a/platform/platform-api/src/com/intellij/ui/docking/DockContainer.java b/platform/platform-api/src/com/intellij/ui/docking/DockContainer.java
index 5d26e4c..d2201cd 100644
--- a/platform/platform-api/src/com/intellij/ui/docking/DockContainer.java
+++ b/platform/platform-api/src/com/intellij/ui/docking/DockContainer.java
@@ -33,6 +33,11 @@
RelativeRectangle getAcceptArea();
+ /**
+ * This area is used when nothing was found with getAcceptArea
+ */
+ RelativeRectangle getAcceptAreaFallback();
+
@NotNull
ContentResponse getContentResponse(@NotNull DockableContent content, RelativePoint point);
diff --git a/platform/platform-api/src/com/intellij/ui/tabs/TabsListener.java b/platform/platform-api/src/com/intellij/ui/tabs/TabsListener.java
index a9bba15..5ca61fe 100644
--- a/platform/platform-api/src/com/intellij/ui/tabs/TabsListener.java
+++ b/platform/platform-api/src/com/intellij/ui/tabs/TabsListener.java
@@ -22,18 +22,26 @@
void beforeSelectionChanged(TabInfo oldSelection, TabInfo newSelection);
+ void tabRemoved(TabInfo tabToRemove);
+
void tabsMoved();
class Adapter implements TabsListener {
+ @Override
public void selectionChanged(TabInfo oldSelection, TabInfo newSelection) {
}
+ @Override
public void beforeSelectionChanged(TabInfo oldSelection, TabInfo newSelection) {
}
@Override
public void tabsMoved() {
}
+
+ @Override
+ public void tabRemoved(TabInfo tabToRemove) {
+ }
}
}
diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java
index 79a5ae9..2908b4f 100644
--- a/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java
+++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java
@@ -562,6 +562,7 @@
if (!mySingleRowLayout.isTabHidden(each)) continue;
final JBMenuItem item = new JBMenuItem(each.getText(), each.getIcon());
item.setForeground(each.getDefaultForeground());
+ item.setBackground(each.getTabColor());
mySingleRowLayout.myMorePopup.add(item);
item.addActionListener(new ActionListener() {
@Override
@@ -890,6 +891,15 @@
}
}
+
+ void fireTabRemoved(TabInfo info) {
+ for (TabsListener eachListener : myTabListeners) {
+ if (eachListener != null) {
+ eachListener.tabRemoved(info);
+ }
+ }
+ }
+
@NotNull
private ActionCallback requestFocus(final JComponent toFocus) {
if (toFocus == null) return new ActionCallback.Done();
@@ -2437,6 +2447,8 @@
}
revalidateAndRepaint(true);
+
+ fireTabRemoved(info);
return result;
}
diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/TabLabel.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/TabLabel.java
index cc31280..21c36d5 100644
--- a/platform/platform-api/src/com/intellij/ui/tabs/impl/TabLabel.java
+++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/TabLabel.java
@@ -42,26 +42,8 @@
import java.awt.image.BufferedImage;
public class TabLabel extends JPanel {
- protected final SimpleColoredComponent myLabel = new SimpleColoredComponent() {
- @Override
- protected boolean shouldDrawMacShadow() {
- return SystemInfo.isMac || UIUtil.isUnderDarcula();
- }
+ protected final SimpleColoredComponent myLabel;
- @Override
- protected boolean shouldDrawDimmed() {
- return myTabs.getSelectedInfo() != myInfo || myTabs.useBoldLabels();
- }
-
- @Override
- public Font getFont() {
- if (isFontSet() || !myTabs.useSmallLabels()) {
- return super.getFont();
- }
- return UIUtil.getLabelFont(UIUtil.FontSize.SMALL);
- }
- };
-
private final LayeredIcon myIcon;
private Icon myOverlayedIcon;
@@ -80,11 +62,9 @@
myTabs = tabs;
myInfo = info;
- myLabel.setOpaque(false);
- myLabel.setBorder(null);
- myLabel.setIconTextGap(tabs.isEditorTabs() ? 2 : new JLabel().getIconTextGap());
- myLabel.setIconOpaque(false);
- myLabel.setIpad(new Insets(0, 0, 0, 0));
+
+ myLabel = createLabel(tabs);
+
setOpaque(false);
setLayout(new BorderLayout());
@@ -123,6 +103,35 @@
});
}
+ private SimpleColoredComponent createLabel(JBTabsImpl tabs) {
+ SimpleColoredComponent label = new SimpleColoredComponent() {
+ @Override
+ protected boolean shouldDrawMacShadow() {
+ return SystemInfo.isMac || UIUtil.isUnderDarcula();
+ }
+
+ @Override
+ protected boolean shouldDrawDimmed() {
+ return myTabs.getSelectedInfo() != myInfo || myTabs.useBoldLabels();
+ }
+
+ @Override
+ public Font getFont() {
+ if (isFontSet() || !myTabs.useSmallLabels()) {
+ return super.getFont();
+ }
+ return UIUtil.getLabelFont(UIUtil.FontSize.SMALL);
+ }
+ };
+ label.setOpaque(false);
+ label.setBorder(null);
+ label.setIconTextGap(tabs.isEditorTabs() ? 2 : new JLabel().getIconTextGap());
+ label.setIconOpaque(false);
+ label.setIpad(new Insets(0, 0, 0, 0));
+
+ return label;
+ }
+
@Override
public Insets getInsets() {
Insets insets = super.getInsets();
@@ -131,27 +140,34 @@
return new Insets(insets.top, insets.left, insets.bottom, 3);
}
}
-
+
return insets;
}
public void setAlignmentToCenter(boolean toCenter) {
- if (myCentered == toCenter && myLabel.getParent() != null) return;
+ if (myCentered == toCenter && getLabelComponent().getParent() != null) return;
+ setPlaceholderContent(toCenter, getLabelComponent());
+ }
+
+ protected void setPlaceholderContent(boolean toCenter, JComponent component) {
myLabelPlaceholder.removeAll();
if (toCenter) {
- final Centerizer center = new Centerizer(myLabel);
+ final Centerizer center = new Centerizer(component);
myLabelPlaceholder.setContent(center);
- } else {
- myLabelPlaceholder.setContent(myLabel);
+ }
+ else {
+ myLabelPlaceholder.setContent(component);
}
myCentered = toCenter;
}
+
+
public void paintOffscreen(Graphics g) {
- synchronized(getTreeLock()) {
+ synchronized (getTreeLock()) {
validateTree();
}
doPaint(g);
@@ -205,12 +221,13 @@
dYs = selected;
break;
}
-
+
if (!myTabs.isDropTarget(myInfo)) {
if (myTabs.getSelectedInfo() != myInfo) {
- consumer.consume(dX, dY);
- } else {
- consumer.consume(dXs, dYs);
+ consumer.consume(dX, dY);
+ }
+ else {
+ consumer.consume(dXs, dYs);
}
}
}
@@ -259,7 +276,10 @@
case bottom:
if (myTabs.hasUnderline()) size.height += TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT - 1;
break;
- case left: case right: size.width += getSelectedOffset(); break;
+ case left:
+ case right:
+ size.width += getSelectedOffset();
+ break;
}
return size;
@@ -280,7 +300,8 @@
toShow.addSeparator();
}
- JBTabsImpl tabs = JBTabsImpl.NAVIGATION_ACTIONS_KEY.getData(DataManager.getInstance().getDataContext(e.getComponent(), e.getX(), e.getY()));
+ JBTabsImpl tabs =
+ JBTabsImpl.NAVIGATION_ACTIONS_KEY.getData(DataManager.getInstance().getDataContext(e.getComponent(), e.getX(), e.getY()));
if (tabs == myTabs && myTabs.myAddNavigationGroup) {
toShow.addAll(myTabs.myNavigationActions);
}
@@ -313,17 +334,17 @@
private void invalidateIfNeeded() {
- if (myLabel.getRootPane() == null) return;
+ if (getLabelComponent().getRootPane() == null) return;
- Dimension d = myLabel.getSize();
- Dimension pref = myLabel.getPreferredSize();
+ Dimension d = getLabelComponent().getSize();
+ Dimension pref = getLabelComponent().getPreferredSize();
if (d != null && d.equals(pref)) {
return;
}
setInactiveStateImage(null);
- myLabel.invalidate();
+ getLabelComponent().invalidate();
if (myActionPanel != null) {
myActionPanel.invalidate();
@@ -346,19 +367,20 @@
break;
}
}
-
+
return hasIcons;
}
-
+
private void setIcon(@Nullable final Icon icon, int layer) {
LayeredIcon layeredIcon = getLayeredIcon();
layeredIcon.setIcon(icon, layer);
if (hasIcons()) {
myLabel.setIcon(layeredIcon);
- } else {
+ }
+ else {
myLabel.setIcon(null);
}
-
+
invalidateIfNeeded();
}
@@ -373,7 +395,7 @@
public void apply(UiDecorator.UiDecoration decoration) {
if (decoration.getLabelFont() != null) {
setFont(decoration.getLabelFont());
- myLabel.setFont(decoration.getLabelFont());
+ getLabelComponent().setFont(decoration.getLabelFont());
}
Insets insets = decoration.getLabelInsets();
@@ -420,14 +442,14 @@
public boolean updateTabActions() {
return myActionPanel != null && myActionPanel.update();
-
}
private void setAttractionIcon(@Nullable Icon icon) {
if (myIcon.getIcon(0) == null) {
setIcon(null, 1);
myOverlayedIcon = icon;
- } else {
+ }
+ else {
setIcon(icon, 1);
myOverlayedIcon = null;
}
@@ -492,16 +514,15 @@
protected void paintChildren(final Graphics g) {
super.paintChildren(g);
- if (myOverlayedIcon == null || myLabel.getParent() == null) return;
+ if (myOverlayedIcon == null || getLabelComponent().getParent() == null) return;
- final Rectangle textBounds = SwingUtilities.convertRectangle(myLabel.getParent(), myLabel.getBounds(), this);
+ final Rectangle textBounds = SwingUtilities.convertRectangle(getLabelComponent().getParent(), getLabelComponent().getBounds(), this);
if (getLayeredIcon().isLayerEnabled(1)) {
final int top = (getSize().height - myOverlayedIcon.getIconHeight()) / 2;
myOverlayedIcon.paintIcon(this, g, textBounds.x - myOverlayedIcon.getIconWidth() / 2, top);
}
-
}
public void setTabActionsAutoHide(final boolean autoHide) {
@@ -530,7 +551,7 @@
}
public void setTabEnabled(boolean enabled) {
- myLabel.setEnabled(enabled);
+ getLabelComponent().setEnabled(enabled);
}
@@ -539,7 +560,8 @@
BufferedImage img = null;
if (myLastPaintedInactiveImageBounds != null && myLastPaintedInactiveImageBounds.getSize().equals(effectiveBounds.getSize())) {
img = myInactiveStateImage;
- } else {
+ }
+ else {
setInactiveStateImage(null);
}
myLastPaintedInactiveImageBounds = effectiveBounds;
@@ -552,4 +574,8 @@
}
myInactiveStateImage = img;
}
+
+ public JComponent getLabelComponent() {
+ return myLabel;
+ }
}
diff --git a/platform/platform-api/src/com/intellij/util/ui/StatusText.java b/platform/platform-api/src/com/intellij/util/ui/StatusText.java
index 8b19e77c..3aa1dd0 100644
--- a/platform/platform-api/src/com/intellij/util/ui/StatusText.java
+++ b/platform/platform-api/src/com/intellij/util/ui/StatusText.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.
@@ -67,11 +67,13 @@
myMouseMotionListener = new MouseAdapter() {
@Override
public void mouseMoved(final MouseEvent e) {
- if (findActionListenerAt(e.getPoint()) != null) {
- myMouseTarget.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
- }
- else {
- myMouseTarget.setCursor(Cursor.getDefaultCursor());
+ if (isStatusVisible()) {
+ if (findActionListenerAt(e.getPoint()) != null) {
+ myMouseTarget.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
+ }
+ else {
+ myMouseTarget.setCursor(Cursor.getDefaultCursor());
+ }
}
}
};
diff --git a/platform/platform-impl/src/com/intellij/execution/impl/ConsoleViewUtil.java b/platform/platform-impl/src/com/intellij/execution/impl/ConsoleViewUtil.java
index 898ccab..ecd084b 100644
--- a/platform/platform-impl/src/com/intellij/execution/impl/ConsoleViewUtil.java
+++ b/platform/platform-impl/src/com/intellij/execution/impl/ConsoleViewUtil.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.
@@ -16,6 +16,7 @@
package com.intellij.execution.impl;
import com.intellij.execution.ui.ConsoleViewContentType;
+import com.intellij.ide.ui.UISettings;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.EditorFactory;
@@ -66,6 +67,9 @@
editor.putUserData(EDITOR_IS_CONSOLE_VIEW, true);
final DelegateColorScheme scheme = updateConsoleColorScheme(editor.getColorsScheme());
+ if (UISettings.getInstance().PRESENTATION_MODE) {
+ scheme.setEditorFontSize(UISettings.getInstance().PRESENTATION_MODE_FONT_SIZE);
+ }
editor.setColorsScheme(scheme);
scheme.setColor(EditorColors.CARET_ROW_COLOR, null);
scheme.setColor(EditorColors.RIGHT_MARGIN_COLOR, null);
diff --git a/platform/platform-impl/src/com/intellij/execution/impl/EditorHyperlinkSupport.java b/platform/platform-impl/src/com/intellij/execution/impl/EditorHyperlinkSupport.java
index fed9c1f..c0e0362 100644
--- a/platform/platform-impl/src/com/intellij/execution/impl/EditorHyperlinkSupport.java
+++ b/platform/platform-impl/src/com/intellij/execution/impl/EditorHyperlinkSupport.java
@@ -323,12 +323,6 @@
final int delta,
final Consumer<RangeHighlighter> action) {
final List<RangeHighlighter> ranges = new ArrayList<RangeHighlighter>(sortedHighlighters);
- for (Iterator<RangeHighlighter> iterator = ranges.iterator(); iterator.hasNext();) {
- RangeHighlighter highlighter = iterator.next();
- if (editor.getFoldingModel().getCollapsedRegionAtOffset(highlighter.getStartOffset()) != null) {
- iterator.remove();
- }
- }
int i;
for (i = 0; i < ranges.size(); i++) {
RangeHighlighter range = ranges.get(i);
@@ -336,15 +330,23 @@
break;
}
}
- int newIndex = ranges.isEmpty() ? -1 : i == ranges.size() ? 0 : (i + delta + ranges.size()) % ranges.size();
- final RangeHighlighter next = newIndex < ranges.size() && newIndex >= 0 ? ranges.get(newIndex) : null;
- if (next == null) return null;
- return new OccurenceNavigator.OccurenceInfo(new NavigatableAdapter() {
- public void navigate(final boolean requestFocus) {
- action.consume(next);
- linkFollowed(editor, ranges, next);
+ int newIndex = i;
+ while (newIndex < ranges.size() && newIndex >= 0) {
+ newIndex = (newIndex + delta + ranges.size()) % ranges.size();
+ final RangeHighlighter next = ranges.get(newIndex);
+ if (editor.getFoldingModel().getCollapsedRegionAtOffset(next.getStartOffset()) == null) {
+ return new OccurenceNavigator.OccurenceInfo(new NavigatableAdapter() {
+ public void navigate(final boolean requestFocus) {
+ action.consume(next);
+ linkFollowed(editor, ranges, next);
+ }
+ }, newIndex == -1 ? -1 : newIndex + 1, ranges.size());
}
- }, newIndex == -1 ? -1 : newIndex + 1, ranges.size());
+ if (newIndex == i) {
+ break; // cycled through everything, found no next/prev hyperlink
+ }
+ }
+ return null;
}
// todo fix link followed here!
diff --git a/platform/platform-impl/src/com/intellij/ide/IdeTooltip.java b/platform/platform-impl/src/com/intellij/ide/IdeTooltip.java
index ee0c9ce..6c8a63f 100644
--- a/platform/platform-impl/src/com/intellij/ide/IdeTooltip.java
+++ b/platform/platform-impl/src/com/intellij/ide/IdeTooltip.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,7 +24,7 @@
import java.awt.*;
public class IdeTooltip extends ComparableObject.Impl {
-
+ public static final Object TOOLTIP_DISMISS_DELAY_KEY = "TOOLTIP_DISMISS_DELAY_KEY";
private Component myComponent;
private Point myPoint;
@@ -134,6 +134,12 @@
}
public int getDismissDelay() {
+ if (myComponent instanceof JComponent) {
+ final Object value = ((JComponent)myComponent).getClientProperty(TOOLTIP_DISMISS_DELAY_KEY);
+ if (value instanceof Integer) {
+ return ((Integer)value).intValue();
+ }
+ }
return Registry.intValue("ide.tooltip.dismissDelay");
}
diff --git a/platform/platform-impl/src/com/intellij/ide/actions/ChooseComponentsToExportDialog.java b/platform/platform-impl/src/com/intellij/ide/actions/ChooseComponentsToExportDialog.java
index 356ad8f..7bbc3e0 100644
--- a/platform/platform-impl/src/com/intellij/ide/actions/ChooseComponentsToExportDialog.java
+++ b/platform/platform-impl/src/com/intellij/ide/actions/ChooseComponentsToExportDialog.java
@@ -26,11 +26,13 @@
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.VerticalFlowLayout;
+import com.intellij.openapi.util.AsyncResult;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.FieldPanel;
+import com.intellij.util.Consumer;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -84,12 +86,15 @@
});
final ActionListener browseAction = new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
- String oldPath = myPathPanel.getText();
- String path = chooseSettingsFile(oldPath, getWindow(), IdeBundle.message("title.export.file.location"),
- IdeBundle.message("prompt.choose.export.settings.file.path"));
- if (path == null) return;
- myPathPanel.setText(FileUtil.toSystemDependentName(path));
+ chooseSettingsFile(myPathPanel.getText(), getWindow(), IdeBundle.message("title.export.file.location"), IdeBundle.message("prompt.choose.export.settings.file.path"))
+ .doWhenDone(new Consumer<String>() {
+ @Override
+ public void consume(String path) {
+ myPathPanel.setText(FileUtil.toSystemDependentName(path));
+ }
+ });
}
};
@@ -154,7 +159,7 @@
for (final ExportableComponent tiedComponent : tiedComponents) {
if (tiedComponent == component) continue;
final ComponentElementProperties elementProperties = componentToContainingListElement.get(tiedComponent);
- if (elementProperties != null && !exportFile.equals(file)) {
+ if (elementProperties != null && !FileUtil.filesEqual(exportFile, file)) {
LOG.assertTrue(file == null, "Component " + component + " serialize itself into " + file + " and " + exportFile);
// found
elementProperties.addComponent(component);
@@ -166,8 +171,8 @@
return file != null;
}
- @Nullable
- public static String chooseSettingsFile(String oldPath, Component parent, final String title, final String description) {
+ @NotNull
+ public static AsyncResult<String> chooseSettingsFile(String oldPath, Component parent, final String title, final String description) {
FileChooserDescriptor chooserDescriptor = FileChooserDescriptorFactory.createSingleLocalFileDescriptor();
chooserDescriptor.setDescription(description);
chooserDescriptor.setHideIgnored(false);
@@ -184,33 +189,43 @@
else {
initialDir = null;
}
- final VirtualFile file = FileChooser.chooseFile(chooserDescriptor, parent, null, initialDir);
- if (file == null) {
- return null;
- }
- String path;
- if (file.isDirectory()) {
- String defaultName = new File(DEFAULT_PATH).getName();
- path = file.getPath() + "/" + defaultName;
- }
- else {
- path = file.getPath();
- }
- return path;
+ final AsyncResult<String> result = new AsyncResult<String>();
+ FileChooser.chooseFiles(chooserDescriptor, null, parent, initialDir, new FileChooser.FileChooserConsumer() {
+ @Override
+ public void consume(List<VirtualFile> files) {
+ VirtualFile file = files.get(0);
+ if (file.isDirectory()) {
+ result.setDone(file.getPath() + '/' + new File(DEFAULT_PATH).getName());
+ }
+ else {
+ result.setDone(file.getPath());
+ }
+ }
+
+ @Override
+ public void cancelled() {
+ result.setRejected();
+ }
+ });
+ return result;
}
+ @Override
public JComponent getPreferredFocusedComponent() {
return myPathPanel.getTextField();
}
+ @Override
protected JComponent createNorthPanel() {
return new JLabel(myDescription);
}
+ @Override
protected JComponent createCenterPanel() {
return myChooser;
}
+ @Override
protected JComponent createSouthPanel() {
final JComponent buttons = super.createSouthPanel();
if (!myShowFilePath) return buttons;
@@ -236,11 +251,13 @@
return myComponents.add(component);
}
+ @Override
@Nullable
public Icon getIcon() {
return null;
}
+ @Override
@Nullable
public Color getColor() {
return null;
@@ -261,6 +278,7 @@
return new File(myPathPanel.getText());
}
+ @Override
protected String getDimensionServiceKey() {
return "#com.intellij.ide.actions.ChooseComponentsToExportDialog";
}
diff --git a/platform/platform-impl/src/com/intellij/ide/actions/ImportSettingsAction.java b/platform/platform-impl/src/com/intellij/ide/actions/ImportSettingsAction.java
index 539cbd7..efe1ac6 100644
--- a/platform/platform-impl/src/com/intellij/ide/actions/ImportSettingsAction.java
+++ b/platform/platform-impl/src/com/intellij/ide/actions/ImportSettingsAction.java
@@ -35,6 +35,7 @@
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.updateSettings.impl.UpdateSettings;
import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.util.Consumer;
import com.intellij.util.io.ZipUtil;
import java.awt.*;
@@ -47,14 +48,19 @@
import java.util.zip.ZipFile;
public class ImportSettingsAction extends AnAction implements DumbAware {
+ @Override
public void actionPerformed(AnActionEvent e) {
final DataContext dataContext = e.getDataContext();
final Component component = PlatformDataKeys.CONTEXT_COMPONENT.getData(dataContext);
- final String path = ChooseComponentsToExportDialog.chooseSettingsFile(PathManager.getConfigPath(), component,
- IdeBundle.message("title.import.file.location"),
- IdeBundle.message("prompt.choose.import.file.path"));
- if (path == null) return;
+ ChooseComponentsToExportDialog.chooseSettingsFile(PathManager.getConfigPath(), component, IdeBundle.message("title.import.file.location"), IdeBundle.message("prompt.choose.import.file.path")).doWhenDone(new Consumer<String>() {
+ @Override
+ public void consume(String path) {
+ doImport(path);
+ }
+ });
+ }
+ private static void doImport(String path) {
final File saveFile = new File(path);
try {
if (!saveFile.exists()) {
@@ -62,9 +68,8 @@
IdeBundle.message("title.file.not.found"));
return;
}
- final ZipFile zipFile = new ZipFile(saveFile);
- final ZipEntry magicEntry = zipFile.getEntry(ImportSettingsFilenameFilter.SETTINGS_JAR_MARKER);
+ final ZipEntry magicEntry = new ZipFile(saveFile).getEntry(ImportSettingsFilenameFilter.SETTINGS_JAR_MARKER);
if (magicEntry == null) {
Messages.showErrorDialog(
IdeBundle.message("error.file.contains.no.settings.to.import", presentableFileName(saveFile), promptLocationMessage()),
@@ -76,8 +81,8 @@
final Map<File, Set<ExportableComponent>> filesToComponents = ExportSettingsAction.getRegisteredComponentsAndFiles(registeredComponents);
List<ExportableComponent> components = getComponentsStored(saveFile, registeredComponents);
final ChooseComponentsToExportDialog dialog = new ChooseComponentsToExportDialog(components, filesToComponents, false,
- IdeBundle.message("title.select.components.to.import"),
- IdeBundle.message("prompt.check.components.to.import"));
+ IdeBundle.message("title.select.components.to.import"),
+ IdeBundle.message("prompt.check.components.to.import"));
dialog.show();
if (!dialog.isOK()) return;
final Set<ExportableComponent> chosenComponents = dialog.getExportableComponents();
@@ -115,13 +120,13 @@
ApplicationNamesInfo.getInstance().getFullProductName()),
IdeBundle.message("title.restart.needed"), Messages.getQuestionIcon());
if (ret == 0) {
- ((ApplicationEx) ApplicationManager.getApplication()).restart(true);
+ ((ApplicationEx)ApplicationManager.getApplication()).restart(true);
}
}
catch (ZipException e1) {
Messages.showErrorDialog(
IdeBundle.message("error.reading.settings.file", presentableFileName(saveFile), e1.getMessage(), promptLocationMessage()),
- IdeBundle.message("title.invalid.file"));
+ IdeBundle.message("title.invalid.file"));
}
catch (IOException e1) {
Messages.showErrorDialog(IdeBundle.message("error.reading.settings.file.2", presentableFileName(saveFile), e1.getMessage()),
diff --git a/platform/platform-impl/src/com/intellij/ide/actions/ShowSettingsUtilImpl.java b/platform/platform-impl/src/com/intellij/ide/actions/ShowSettingsUtilImpl.java
index 06317a6..7e31726 100644
--- a/platform/platform-impl/src/com/intellij/ide/actions/ShowSettingsUtilImpl.java
+++ b/platform/platform-impl/src/com/intellij/ide/actions/ShowSettingsUtilImpl.java
@@ -48,7 +48,7 @@
private AtomicBoolean myShown = new AtomicBoolean(false);
@Override
- public void showSettingsDialog(Project project, ConfigurableGroup[] group) {
+ public void showSettingsDialog(@NotNull Project project, @NotNull ConfigurableGroup[] group) {
try {
myShown.set(true);
_showSettingsDialog(project, group, null);
@@ -61,7 +61,7 @@
}
}
- private static void _showSettingsDialog(final Project project, ConfigurableGroup[] group, @Nullable Configurable toSelect) {
+ private static void _showSettingsDialog(@NotNull final Project project, @NotNull ConfigurableGroup[] group, @Nullable Configurable toSelect) {
group = filterEmptyGroups(group);
if (Registry.is("ide.perProjectModality")) {
new OptionsEditorDialog(project, group, toSelect, true).show();
@@ -78,15 +78,24 @@
public void showSettingsDialog(@Nullable final Project project, final Class configurableClass) {
assert Configurable.class.isAssignableFrom(configurableClass) : "Not a configurable: " + configurableClass.getName();
- Project actualProject = project != null ? project : ProjectManager.getInstance().getDefaultProject();
- Configurable config = findByClass(new IdeConfigurablesGroup().getConfigurables(), configurableClass);
- if (config == null && project != null) {
- config = findByClass(new ProjectConfigurablesGroup(project).getConfigurables(), configurableClass);
+ ConfigurableGroup[] groups;
+ IdeConfigurablesGroup commonGroup = new IdeConfigurablesGroup();
+ ProjectConfigurablesGroup projectGroup = project == null ? null : new ProjectConfigurablesGroup(project);
+ if (projectGroup == null) {
+ groups = new ConfigurableGroup[] {commonGroup};
+ } else {
+ groups = new ConfigurableGroup[] {projectGroup, commonGroup};
+ }
+
+ Configurable config = findByClass(commonGroup.getConfigurables(), configurableClass);
+ if (config == null && projectGroup != null) {
+ config = findByClass(projectGroup.getConfigurables(), configurableClass);
}
assert config != null : "Cannot find configurable: " + configurableClass.getName();
- showSettingsDialog(actualProject, config);
+ @NotNull Project nnProject = project != null ? project : ProjectManager.getInstance().getDefaultProject();
+ _showSettingsDialog(nnProject, groups, config);
}
@Nullable
@@ -188,7 +197,8 @@
}, toSelect);
}
- private static ConfigurableGroup[] filterEmptyGroups(final ConfigurableGroup[] group) {
+ @NotNull
+ private static ConfigurableGroup[] filterEmptyGroups(@NotNull final ConfigurableGroup[] group) {
List<ConfigurableGroup> groups = new ArrayList<ConfigurableGroup>();
for (ConfigurableGroup g : group) {
if (g.getConfigurables().length > 0) {
diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/PluginManager.java b/platform/platform-impl/src/com/intellij/ide/plugins/PluginManager.java
index b735545..87e06c3 100644
--- a/platform/platform-impl/src/com/intellij/ide/plugins/PluginManager.java
+++ b/platform/platform-impl/src/com/intellij/ide/plugins/PluginManager.java
@@ -197,7 +197,7 @@
return null;
}
- public static void handleComponentError(Throwable t, String componentClassName, ComponentConfig config) {
+ public static void handleComponentError(Throwable t, @Nullable String componentClassName, @Nullable ComponentConfig config) {
if (t instanceof StartupAbortedException) {
throw (StartupAbortedException)t;
}
@@ -207,7 +207,9 @@
pluginId = config.getPluginId();
}
if (pluginId == null || CORE_PLUGIN_ID.equals(pluginId.getIdString())) {
- pluginId = getPluginByClassName(componentClassName);
+ if (componentClassName != null) {
+ pluginId = getPluginByClassName(componentClassName);
+ }
}
if (pluginId == null || CORE_PLUGIN_ID.equals(pluginId.getIdString())) {
if (t instanceof PicoPluginExtensionInitializationException) {
diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaButtonUI.java b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaButtonUI.java
index 92e90e8..5d36876 100644
--- a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaButtonUI.java
+++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaButtonUI.java
@@ -94,7 +94,9 @@
public void update(Graphics g, JComponent c) {
super.update(g, c);
if (((JButton)c).isDefaultButton() && !SystemInfo.isMac) {
- c.setFont(c.getFont().deriveFont(Font.BOLD));
+ if (!c.getFont().isBold()) {
+ c.setFont(c.getFont().deriveFont(Font.BOLD));
+ }
}
}
diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/icons/icon-robots.txt b/platform/platform-impl/src/com/intellij/ide/ui/laf/icons/icon-robots.txt
new file mode 100644
index 0000000..f216014
--- /dev/null
+++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/icons/icon-robots.txt
@@ -0,0 +1 @@
+skip: *
\ No newline at end of file
diff --git a/platform/platform-impl/src/com/intellij/notification/EventLog.java b/platform/platform-impl/src/com/intellij/notification/EventLog.java
index 2a666cc..8a71083 100644
--- a/platform/platform-impl/src/com/intellij/notification/EventLog.java
+++ b/platform/platform-impl/src/com/intellij/notification/EventLog.java
@@ -33,7 +33,9 @@
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.wm.*;
import com.intellij.ui.awt.RelativePoint;
+import com.intellij.ui.content.Content;
import com.intellij.util.IJSwingUtilities;
+import com.intellij.util.ObjectUtils;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.hash.LinkedHashMap;
import com.intellij.util.text.CharArrayUtil;
@@ -53,11 +55,13 @@
public static final String LOG_REQUESTOR = "Internal log requestor";
public static final String LOG_TOOL_WINDOW_ID = "Event Log";
public static final String HELP_ID = "reference.toolwindows.event.log";
- private final LogModel myModel = new LogModel(null, ApplicationManager.getApplication());
private static final String A_CLOSING = "</a>";
private static final Pattern TAG_PATTERN = Pattern.compile("<[^>]*>");
private static final Pattern A_PATTERN = Pattern.compile("<a ([^>]* )?href=[\"\']([^>]*)[\"\'][^>]*>");
private static final Set<String> NEW_LINES = ContainerUtil.newHashSet("<br>", "</br>", "<br/>", "<p>", "</p>", "<p/>");
+ private static final String DEFAULT_CATEGORY = "";
+
+ private final LogModel myModel = new LogModel(null, ApplicationManager.getApplication());
public EventLog() {
ApplicationManager.getApplication().getMessageBus().connect().subscribe(Notifications.TOPIC, new NotificationsAdapter() {
@@ -305,19 +309,30 @@
return project == null ? null : ToolWindowManager.getInstance(project).getToolWindow(LOG_TOOL_WINDOW_ID);
}
- public static void toggleLog(final Project project) {
+ public static void toggleLog(@Nullable final Project project, @Nullable final Notification notification) {
final ToolWindow eventLog = getEventLog(project);
if (eventLog != null) {
if (!eventLog.isVisible()) {
- eventLog.activate(null, true);
- } else {
+ eventLog.activate(new Runnable() {
+ @Override
+ public void run() {
+ if (notification == null) return;
+ String contentName = getContentName(notification);
+ Content content = eventLog.getContentManager().findContent(contentName);
+ if (content != null) {
+ eventLog.getContentManager().setSelectedContent(content);
+ }
+ }
+ }, true);
+ }
+ else {
eventLog.hide(null);
}
}
}
public static class ProjectTracker extends AbstractProjectComponent {
- private volatile EventLogConsole myConsole;
+ private final Map<String, EventLogConsole> myCategoryMap = ContainerUtil.newConcurrentMap();
private final List<Notification> myInitial = ContainerUtil.createLockFreeCopyOnWriteList();
private final LogModel myProjectModel;
@@ -338,13 +353,8 @@
});
}
- EventLogConsole getConsole() {
- return myConsole;
- }
-
- @Override
- public void projectOpened() {
- myConsole = new EventLogConsole(myProjectModel);
+ void initDefaultContent() {
+ createNewContent(DEFAULT_CATEGORY);
for (Notification notification : myInitial) {
printNotification(notification);
@@ -353,13 +363,17 @@
}
@Override
+ public void projectOpened() {
+ }
+
+ @Override
public void projectClosed() {
getApplicationComponent().myModel.setStatusMessage(null, 0);
- StatusBar.Info.set("", null, EventLog.LOG_REQUESTOR);
+ StatusBar.Info.set("", null, LOG_REQUESTOR);
}
private void printNotification(final Notification notification) {
- final EventLogConsole console = myConsole;
+ final EventLogConsole console = getConsole(notification);
if (console == null) {
myInitial.add(notification);
return;
@@ -384,6 +398,36 @@
}
});
}
+
+ @Nullable
+ private EventLogConsole getConsole(Notification notification) {
+ if (myCategoryMap.get(DEFAULT_CATEGORY) == null) return null; // still not initialized
+
+ String name = getContentName(notification);
+ EventLogConsole console = myCategoryMap.get(name);
+ return console != null ? console : createNewContent(name);
+ }
+
+ @NotNull
+ private EventLogConsole createNewContent(String name) {
+ ApplicationManager.getApplication().assertIsDispatchThread();
+ EventLogConsole newConsole = new EventLogConsole(myProjectModel);
+ EventLogToolWindowFactory.createContent(myProject, getEventLog(myProject), newConsole, name);
+ myCategoryMap.put(name, newConsole);
+
+ return newConsole;
+ }
+
+ }
+
+ @NotNull
+ private static String getContentName(Notification notification) {
+ for (EventLogCategory category : EventLogCategory.EP_NAME.getExtensions()) {
+ if (category.acceptsNotification(notification.getGroupId())) {
+ return category.getDisplayName();
+ }
+ }
+ return DEFAULT_CATEGORY;
}
static ProjectTracker getProjectComponent(Project project) {
@@ -403,7 +447,8 @@
public void navigate(Project project) {
NotificationListener listener = myNotification.getListener();
if (listener != null) {
- JComponent component = getProjectComponent(project).myConsole.getConsoleEditor().getContentComponent();
+ EventLogConsole console = ObjectUtils.assertNotNull(getProjectComponent(project).getConsole(myNotification));
+ JComponent component = console.getConsoleEditor().getContentComponent();
listener.hyperlinkUpdate(myNotification, IJSwingUtilities.createHyperlinkEvent(myHref, component));
}
}
@@ -424,7 +469,8 @@
hideBalloon(notification);
}
- RelativePoint target = getProjectComponent(project).myConsole.getHyperlinkLocation(this);
+ EventLogConsole console = ObjectUtils.assertNotNull(getProjectComponent(project).getConsole(myNotification));
+ RelativePoint target = console.getHyperlinkLocation(this);
if (target != null) {
IdeFrame frame = WindowManager.getInstance().getIdeFrame(project);
assert frame != null;
diff --git a/platform/platform-impl/src/com/intellij/notification/EventLogToolWindowFactory.java b/platform/platform-impl/src/com/intellij/notification/EventLogToolWindowFactory.java
index b25c470..1fd6c34 100644
--- a/platform/platform-impl/src/com/intellij/notification/EventLogToolWindowFactory.java
+++ b/platform/platform-impl/src/com/intellij/notification/EventLogToolWindowFactory.java
@@ -15,8 +15,6 @@
*/
package com.intellij.notification;
-import com.intellij.execution.ExecutionBundle;
-import com.intellij.execution.ui.ConsoleView;
import com.intellij.icons.AllIcons;
import com.intellij.ide.actions.ContextHelpAction;
import com.intellij.notification.impl.NotificationsConfigurable;
@@ -36,6 +34,7 @@
import com.intellij.ui.AncestorListenerAdapter;
import com.intellij.ui.content.Content;
import com.intellij.ui.content.ContentFactory;
+import com.intellij.ui.content.ContentManager;
import org.jetbrains.annotations.NonNls;
import javax.swing.event.AncestorEvent;
@@ -46,7 +45,17 @@
public class EventLogToolWindowFactory implements ToolWindowFactory, DumbAware {
@Override
public void createToolWindowContent(final Project project, ToolWindow toolWindow) {
- EventLogConsole console = EventLog.getProjectComponent(project).getConsole();
+ EventLog.getProjectComponent(project).initDefaultContent();
+ }
+
+ static void createContent(Project project, ToolWindow toolWindow, EventLogConsole console, String title) {
+ // update default Event Log tab title
+ ContentManager contentManager = toolWindow.getContentManager();
+ Content generalContent = contentManager.getContent(0);
+ if (generalContent != null && contentManager.getContentCount() == 1) {
+ generalContent.setDisplayName("General");
+ }
+
final Editor editor = console.getConsoleEditor();
SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true) {
@@ -62,8 +71,9 @@
toolbar.setTargetComponent(editor.getContentComponent());
panel.setToolbar(toolbar.getComponent());
- final Content content = ContentFactory.SERVICE.getInstance().createContent(panel, "", false);
- toolWindow.getContentManager().addContent(content);
+ Content content = ContentFactory.SERVICE.getInstance().createContent(panel, title, false);
+ contentManager.addContent(content);
+ contentManager.setSelectedContent(content);
}
private static ActionToolbar createToolbar(Project project, Editor editor, EventLogConsole console) {
diff --git a/platform/platform-impl/src/com/intellij/notification/LogModel.java b/platform/platform-impl/src/com/intellij/notification/LogModel.java
index a1d7115..438b81c 100644
--- a/platform/platform-impl/src/com/intellij/notification/LogModel.java
+++ b/platform/platform-impl/src/com/intellij/notification/LogModel.java
@@ -88,7 +88,7 @@
StatusBar.Info.set("", myProject, EventLog.LOG_REQUESTOR);
}
- @Nullable
+ @Nullable
Trinity<Notification, String, Long> getStatusMessage() {
synchronized (myNotifications) {
return myStatusMessage;
@@ -142,8 +142,9 @@
}
});
if (message == null) {
- setStatusMessage(message, 0);
- } else {
+ setStatusMessage(null, 0);
+ }
+ else {
Long notificationTime = getNotificationTime(message);
assert notificationTime != null;
setStatusMessage(message, notificationTime);
diff --git a/platform/platform-impl/src/com/intellij/notification/impl/IdeNotificationArea.java b/platform/platform-impl/src/com/intellij/notification/impl/IdeNotificationArea.java
index 97e922f..804b677 100644
--- a/platform/platform-impl/src/com/intellij/notification/impl/IdeNotificationArea.java
+++ b/platform/platform-impl/src/com/intellij/notification/impl/IdeNotificationArea.java
@@ -24,7 +24,6 @@
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationType;
import com.intellij.openapi.actionSystem.CommonDataKeys;
-import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
@@ -65,7 +64,7 @@
new ClickListener() {
@Override
public boolean onClick(MouseEvent e, int clickCount) {
- EventLog.toggleLog(getProject());
+ EventLog.toggleLog(getProject(), null);
return true;
}
}.installOn(this);
diff --git a/platform/platform-impl/src/com/intellij/notification/impl/ui/NotificationsUtil.java b/platform/platform-impl/src/com/intellij/notification/impl/ui/NotificationsUtil.java
index 900cc9f..cb04f8b 100644
--- a/platform/platform-impl/src/com/intellij/notification/impl/ui/NotificationsUtil.java
+++ b/platform/platform-impl/src/com/intellij/notification/impl/ui/NotificationsUtil.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.
@@ -99,7 +99,7 @@
case ERROR:
return new JBColor(Color.gray, new Color(0xc8c8c8));
case WARNING:
- return new JBColor(Color.gray, new Color(0x977124));
+ return new JBColor(Color.gray, new Color(0x615f51));
case INFORMATION:
default:
return new JBColor(Color.gray, new Color(0x205c00));
diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/AbbreviationManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/AbbreviationManagerImpl.java
new file mode 100644
index 0000000..97196b7
--- /dev/null
+++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/AbbreviationManagerImpl.java
@@ -0,0 +1,207 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.openapi.actionSystem.impl;
+
+import com.intellij.openapi.actionSystem.AbbreviationManager;
+import com.intellij.openapi.application.PathManager;
+import com.intellij.openapi.components.*;
+import gnu.trove.THashMap;
+import org.jdom.Element;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.io.File;
+import java.util.*;
+
+/**
+ * @author Konstantin Bulenkov
+ */
+@State(
+ name = "AbbreviationManager",
+ roamingType = RoamingType.PER_PLATFORM,
+ storages = {
+ @Storage(
+ file = StoragePathMacros.APP_CONFIG + "/abbreviations.xml"
+ )}
+)
+public class AbbreviationManagerImpl extends AbbreviationManager implements
+ ExportableApplicationComponent, PersistentStateComponent<Element> {
+ private final Map<String, List<String>> myAbbreviation2ActionId = new THashMap<String, List<String>>();
+ private final Map<String, LinkedHashSet<String>> myActionId2Abbreviations = new THashMap<String, LinkedHashSet<String>>();
+ private final Map<String, LinkedHashSet<String>> myPluginsActionId2Abbreviations = new THashMap<String, LinkedHashSet<String>>();
+
+ @Override
+ public void initComponent() {
+
+ }
+
+ @Override
+ public void disposeComponent() {
+
+ }
+
+ @NotNull
+ @Override
+ public String getComponentName() {
+ return "AbbreviationManager";
+ }
+
+ @Nullable
+ @Override
+ public Element getState() {
+ final Element actions = new Element("actions");
+ final Element abbreviations = new Element("abbreviations");
+ actions.addContent(abbreviations);
+ for (String key : myActionId2Abbreviations.keySet()) {
+ final LinkedHashSet<String> abbrs = myActionId2Abbreviations.get(key);
+ final LinkedHashSet<String> pluginAbbrs = myPluginsActionId2Abbreviations.get(key);
+ if (abbrs == pluginAbbrs || (abbrs != null && abbrs.equals(pluginAbbrs))) {
+ continue;
+ }
+ if (abbrs != null) {
+ final Element action = new Element("action");
+ action.setAttribute("id", key);
+ abbreviations.addContent(action);
+ for (String abbr : abbrs) {
+ final Element abbreviation = new Element("abbreviation");
+ abbreviation.setAttribute("name", abbr);
+ action.addContent(abbreviation);
+ }
+ }
+ }
+
+ return actions;
+ }
+
+ @Override
+ public void loadState(Element state) {
+ final List<Element> abbreviations = state.getChildren("abbreviations");
+ if (abbreviations != null && abbreviations.size() == 1) {
+ final List<Element> actions = abbreviations.get(0).getChildren("action");
+ if (actions != null && actions.size() > 0) {
+ for (Element action : actions) {
+ final String actionId = action.getAttributeValue("id");
+ LinkedHashSet<String> values = myActionId2Abbreviations.get(actionId);
+ if (values == null) {
+ values = new LinkedHashSet<String>(1);
+ myActionId2Abbreviations.put(actionId, values);
+ }
+
+ final List<Element> abbreviation = action.getChildren("abbreviation");
+ if (abbreviation != null) {
+ for (Element abbr : abbreviation) {
+ final String abbrValue = abbr.getAttributeValue("name");
+ if (abbrValue != null) {
+ values.add(abbrValue);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ @NotNull
+ @Override
+ public File[] getExportFiles() {
+ return new File[]{PathManager.getOptionsFile("abbreviations")};
+ }
+
+ @NotNull
+ @Override
+ public String getPresentableName() {
+ return "Actions";
+ }
+
+ @Override
+ public Set<String> getAbbreviations() {
+ final Set<String> result = new HashSet<String>();
+ for (Set<String> abbrs : myActionId2Abbreviations.values()) {
+ result.addAll(abbrs);
+ }
+ return result;
+ }
+
+ @Override
+ public Set<String> getAbbreviations(String actionId) {
+ final LinkedHashSet<String> abbreviations = myActionId2Abbreviations.get(actionId);
+ if (abbreviations == null) {
+ return Collections.emptySet();
+ }
+ return Collections.unmodifiableSet(abbreviations);
+ }
+
+ @Override
+ public List<String> findActions(String abbreviation) {
+ final List<String> actions = myAbbreviation2ActionId.get(abbreviation);
+ return actions == null ? Collections.<String>emptyList() : Collections.unmodifiableList(actions);
+ }
+
+
+ public void register(String abbreviation, String actionId, Map<String, LinkedHashSet<String>> storage) {
+ LinkedHashSet<String> abbreviations = storage.get(actionId);
+ if (abbreviations == null) {
+ abbreviations = new LinkedHashSet<String>(1);
+ storage.put(actionId, abbreviations);
+ }
+ abbreviations.add(abbreviation);
+ }
+
+ public void register(String abbreviation, String actionId, boolean fromPluginXml) {
+ if (fromPluginXml && myActionId2Abbreviations.containsKey(actionId)) {
+ register(abbreviation, actionId, myPluginsActionId2Abbreviations);
+ return;
+ }
+ register(abbreviation, actionId, myActionId2Abbreviations);
+ if (fromPluginXml) {
+ register(abbreviation, actionId, myPluginsActionId2Abbreviations);
+ }
+
+ List<String> ids = myAbbreviation2ActionId.get(abbreviation);
+ if (ids == null) {
+ ids = new ArrayList<String>(0);
+ myAbbreviation2ActionId.put(abbreviation, ids);
+ }
+
+ if (!ids.contains(actionId)) {
+ ids.add(actionId);
+ }
+ }
+
+ @Override
+ public void register(String abbreviation, String actionId) {
+ register(abbreviation, actionId, false);
+ }
+
+ @Override
+ public void remove(String abbreviation, String actionId) {
+ final List<String> actions = myAbbreviation2ActionId.get(abbreviation);
+ if (actions != null) {
+ actions.remove(actionId);
+ }
+ final LinkedHashSet<String> abbreviations = myActionId2Abbreviations.get(actionId);
+ if (abbreviations != null) {
+ abbreviations.remove(abbreviation);
+ } else {
+ final LinkedHashSet<String> abbrs = myActionId2Abbreviations.get(actionId);
+ if (abbrs != null) {
+ final LinkedHashSet<String> customValues = new LinkedHashSet<String>(abbrs);
+ customValues.remove(abbreviation);
+ myActionId2Abbreviations.put(actionId, customValues);
+ }
+ }
+ }
+}
diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionManagerImpl.java
index d4481aa..f67aae3 100644
--- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionManagerImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionManagerImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,7 +38,10 @@
import com.intellij.openapi.keymap.KeymapUtil;
import com.intellij.openapi.keymap.ex.KeymapManagerEx;
import com.intellij.openapi.progress.ProcessCanceledException;
-import com.intellij.openapi.util.*;
+import com.intellij.openapi.util.ActionCallback;
+import com.intellij.openapi.util.Computable;
+import com.intellij.openapi.util.Disposer;
+import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.wm.IdeFocusManager;
@@ -101,6 +104,7 @@
@NonNls public static final String COMPACT_ATTR_NAME = "compact";
@NonNls public static final String SEPARATOR_ELEMENT_NAME = "separator";
@NonNls public static final String REFERENCE_ELEMENT_NAME = "reference";
+ @NonNls public static final String ABBREVIATION_ELEMENT_NAME = "abbreviation";
@NonNls public static final String GROUPID_ATTR_NAME = "group-id";
@NonNls public static final String ANCHOR_ELEMENT_NAME = "anchor";
@NonNls public static final String FIRST = "first";
@@ -116,6 +120,7 @@
@NonNls public static final String KEYMAP_ATTR_NAME = "keymap";
@NonNls public static final String KEYSTROKE_ATTR_NAME = "keystroke";
@NonNls public static final String REF_ATTR_NAME = "ref";
+ @NonNls public static final String VALUE_ATTR_NAME = "value";
@NonNls public static final String ACTIONS_BUNDLE = "messages.ActionsBundle";
@NonNls public static final String USE_SHORTCUT_OF_ATTR_NAME = "use-shortcut-of";
@@ -395,6 +400,9 @@
else if (MOUSE_SHORTCUT_ELEMENT_NAME.equals(e.getName())) {
processMouseShortcutNode(e, id, pluginId);
}
+ else if (ABBREVIATION_ELEMENT_NAME.equals(e.getName())) {
+ processAbbreviationNode(e, id);
+ }
else {
reportActionError(pluginId, "unexpected name of element \"" + e.getName() + "\"");
return null;
@@ -409,6 +417,14 @@
return stub;
}
+ private static void processAbbreviationNode(Element e, String id) {
+ final String abbr = e.getAttributeValue(VALUE_ATTR_NAME);
+ if (!StringUtil.isEmpty(abbr)) {
+ final AbbreviationManagerImpl abbreviationManager = ((AbbreviationManagerImpl)AbbreviationManager.getInstance());
+ abbreviationManager.register(abbr, id, true);
+ }
+ }
+
@Nullable
private static ResourceBundle getActionsResourceBundle(ClassLoader loader, IdeaPluginDescriptor plugin) {
@NonNls final String resBundleName = plugin != null && !plugin.getPluginId().getIdString().equals("com.intellij") ? plugin.getResourceBundleBaseName() : ACTIONS_BUNDLE;
diff --git a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/DirectoryBasedStorage.java b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/DirectoryBasedStorage.java
index 7ee3a54..164b5b4 100644
--- a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/DirectoryBasedStorage.java
+++ b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/DirectoryBasedStorage.java
@@ -40,28 +40,24 @@
import static com.intellij.util.io.fs.FileSystem.FILE_SYSTEM;
//todo: support missing plugins
-
//todo: support storage data
public class DirectoryBasedStorage implements StateStorage, Disposable {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.components.impl.stores.DirectoryBasedStorage");
+ private static final IFile[] EMPTY_FILES = new IFile[0];
private final TrackingPathMacroSubstitutor myPathMacroSubstitutor;
private final IFile myDir;
private final StateSplitter mySplitter;
+ private final FileTypeManager myFileTypeManager;
private Object mySession;
private DirectoryStorageData myStorageData = null;
- private static final IFile[] EMPTY_FILES = new IFile[0];
-
- private final FileTypeManager myFileTypeManager;
-
- public DirectoryBasedStorage(final TrackingPathMacroSubstitutor pathMacroSubstitutor,
- final String dir,
- final StateSplitter splitter,
- Disposable parentDisposable,
- final PicoContainer picoContainer) {
- assert !dir.contains("$") : dir;
+ public DirectoryBasedStorage(@Nullable TrackingPathMacroSubstitutor pathMacroSubstitutor,
+ @NotNull String dir,
+ @NotNull StateSplitter splitter,
+ @NotNull Disposable parentDisposable,
+ @NotNull PicoContainer picoContainer) {
myPathMacroSubstitutor = pathMacroSubstitutor;
myDir = FILE_SYSTEM.createFile(dir);
mySplitter = splitter;
@@ -70,12 +66,9 @@
VirtualFileTracker virtualFileTracker = (VirtualFileTracker)picoContainer.getComponentInstanceOfType(VirtualFileTracker.class);
MessageBus messageBus = (MessageBus)picoContainer.getComponentInstanceOfType(MessageBus.class);
-
if (virtualFileTracker != null && messageBus != null) {
final String path = myDir.getAbsolutePath();
final String fileUrl = LocalFileSystem.PROTOCOL_PREFIX + path.replace(File.separatorChar, '/');
-
-
final Listener listener = messageBus.syncPublisher(STORAGE_TOPIC);
virtualFileTracker.addTracker(fileUrl, new VirtualFileAdapter() {
@Override
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java
index 9b31fd7..745d40f 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java
@@ -160,14 +160,16 @@
@Override
public Dimension getPreferredSize() {
- if (UISettings.getInstance().PRESENTATION_MODE) {
+ int w = getLineNumberAreaWidth() + getLineMarkerAreaWidth() + getFoldingAreaWidth() + getAnnotationsAreaWidth();
+
+ if (w > 0 && UISettings.getInstance().PRESENTATION_MODE) {
final Dimension dimension = new Dimension(myEditor.getFontMetrics(Font.PLAIN).getHeight(), myEditor.getPreferredHeight());
if (isLineMarkersShown()) {
dimension.width += getLineNumberAreaWidth() + getLineMarkerAreaWidth();
}
return dimension;
}
- int w = getLineNumberAreaWidth() + getLineMarkerAreaWidth() + getFoldingAreaWidth() + getAnnotationsAreaWidth();
+
myLastPreferredHeight = myEditor.getPreferredHeight();
return new Dimension(w, myLastPreferredHeight);
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorMarkupModelImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorMarkupModelImpl.java
index b515362..0452a66 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorMarkupModelImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorMarkupModelImpl.java
@@ -36,6 +36,7 @@
import com.intellij.openapi.command.UndoConfirmationPolicy;
import com.intellij.openapi.editor.*;
import com.intellij.openapi.editor.actionSystem.DocCommandGroupId;
+import com.intellij.openapi.editor.colors.EditorFontType;
import com.intellij.openapi.editor.ex.*;
import com.intellij.openapi.editor.markup.ErrorStripeRenderer;
import com.intellij.openapi.editor.markup.RangeHighlighter;
@@ -1177,10 +1178,11 @@
Point placeToShow = myEditor.logicalPositionToXY(logicalPosition);
logicalPosition = myEditor.xyToLogicalPosition(placeToShow);//wraps&foldings workaround
placeToShow.x += R * 3 / 2;
- placeToShow.y -= myCacheStartLine * myEditor.getLineHeight();
+ placeToShow.y -= myCacheStartLine * myEditor.getLineHeight() - 1;
+ Font font = myEditor.getColorsScheme().getFont(EditorFontType.PLAIN);
+ g2d.setFont(font.deriveFont(font.getSize() *.8F));
int w = g2d.getFontMetrics().stringWidth(s);
- int a = g2d.getFontMetrics().getAscent();
int rightEdge = rightEdges.get(logicalPosition.line);
placeToShow.x = Math.max(placeToShow.x, rightEdge);
@@ -1192,7 +1194,7 @@
g2d.setColor(new JBColor(JBColor.GRAY, Gray._200));
g2d.drawRoundRect(placeToShow.x, placeToShow.y, w + 2 * R, h, R, R);
g2d.setColor(JBColor.foreground());
- g2d.drawString(s, placeToShow.x + R, placeToShow.y - g2d.getFontMetrics().getDescent() + R/2 + a);
+ g2d.drawString(s, placeToShow.x + R, placeToShow.y + h - g2d.getFontMetrics(g2d.getFont()).getDescent()/2 - 2);
}
isDirty = false;
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/DockableEditorTabbedContainer.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/DockableEditorTabbedContainer.java
index e48da04..4da325b 100644
--- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/DockableEditorTabbedContainer.java
+++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/DockableEditorTabbedContainer.java
@@ -88,6 +88,10 @@
@Override
public RelativeRectangle getAcceptArea() {
+ return new RelativeRectangle(mySplitters);
+ }
+
+ public RelativeRectangle getAcceptAreaFallback() {
JRootPane root = mySplitters.getRootPane();
return root != null ? new RelativeRectangle(root) : new RelativeRectangle(mySplitters);
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorTabbedContainer.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorTabbedContainer.java
index 58bee7d..c2353d5 100644
--- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorTabbedContainer.java
+++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorTabbedContainer.java
@@ -182,7 +182,7 @@
public static DockableEditor createDockableEditor(Project project, Image image, VirtualFile file, Presentation presentation, EditorWindow window) {
- return new DockableEditor(project, image, file, presentation, window);
+ return new DockableEditor(project, image, file, presentation, window.getSize(), window.isFilePinned(file));
}
private void updateTabBorder() {
@@ -663,19 +663,17 @@
final Image myImg;
private DockableEditorTabbedContainer myContainer;
private Presentation myPresentation;
- private EditorWindow myEditorWindow;
private Dimension myPreferredSize;
private boolean myPinned;
private VirtualFile myFile;
- public DockableEditor(Project project, Image img, VirtualFile file, Presentation presentation, EditorWindow window) {
+ public DockableEditor(Project project, Image img, VirtualFile file, Presentation presentation, Dimension preferredSize, boolean isFilePinned) {
myImg = img;
myFile = file;
myPresentation = presentation;
myContainer = new DockableEditorTabbedContainer(project);
- myEditorWindow = window;
- myPreferredSize = myEditorWindow.getSize();
- myPinned = window.isFilePinned(file);
+ myPreferredSize = preferredSize;
+ myPinned = isFilePinned;
}
@NotNull
diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java
index 06a8f79..d29cbcb 100644
--- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java
+++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java
@@ -165,22 +165,22 @@
g.setFont(UIUtil.getLabelFont().deriveFont(isDarkBackground ? 24f : 20f));
final UIUtil.TextPainter painter = new UIUtil.TextPainter().withLineSpacing(1.5f);
- painter.withShadow(true, new JBColor(Gray._200.withAlpha(100), Gray._0.withAlpha(200)));
+ painter.withShadow(true, new JBColor(Gray._200.withAlpha(100), Gray._0.withAlpha(255)));
- painter.appendLine("No files are open").underlined(new JBColor(isDarkBackground ? Gray._210 : Gray._150, Gray._100));
+ painter.appendLine("No files are open").underlined(new JBColor(Gray._150, Gray._180));
final Shortcut[] shortcuts = KeymapManager.getInstance().getActiveKeymap().getShortcuts(IdeActions.ACTION_SEARCH_EVERYWHERE);
final String everywhere;
if (shortcuts.length == 0) {
- everywhere = "Search Everywhere with Double " + (SystemInfo.isMac ? MacKeymapUtil.SHIFT : "Shift");
+ everywhere = "Search Everywhere with <shortcut>Double " + (SystemInfo.isMac ? MacKeymapUtil.SHIFT : "Shift");
} else {
- everywhere = "Search Everywhere " + KeymapUtil.getShortcutsText(shortcuts);
+ everywhere = "Search Everywhere <shortcut>" + KeymapUtil.getShortcutsText(shortcuts);
}
- painter.appendLine(everywhere).smaller().withBullet();
+ painter.appendLine(everywhere + "</shortcut>").smaller().withBullet();
if (!isProjectViewVisible()) {
- painter.appendLine("Open Project View with " + KeymapUtil.getShortcutText(new KeyboardShortcut(
- KeyStroke.getKeyStroke((SystemInfo.isMac ? "meta" : "alt") + " 1"), null))).smaller().withBullet();
+ painter.appendLine("Open Project View with <shortcut>" + KeymapUtil.getShortcutText(new KeyboardShortcut(
+ KeyStroke.getKeyStroke((SystemInfo.isMac ? "meta" : "alt") + " 1"), null)) + "</shortcut>").smaller().withBullet();
}
painter.appendLine("Open a file by name with " + getActionShortcutText("GotoFile")).smaller().withBullet()
@@ -207,7 +207,7 @@
}
}
- return shortcutText;
+ return "<shortcut>" + shortcutText + "</shortcut>";
}
public void writeExternal(final Element element) {
diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/OpenFilesActivity.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/OpenFilesActivity.java
index 62866d3..94d0883 100644
--- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/OpenFilesActivity.java
+++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/OpenFilesActivity.java
@@ -16,6 +16,8 @@
package com.intellij.openapi.fileEditor.impl;
import com.intellij.openapi.fileEditor.FileEditorManager;
+import com.intellij.openapi.progress.ProgressIndicator;
+import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.startup.StartupActivity;
@@ -42,7 +44,15 @@
}
};
if (Registry.is("ide.open.editors.asynchronously")) {
+ ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
+ if (indicator != null) {
+ indicator.pushState();
+ indicator.setText("Preparing editors to open...");
+ }
runnable.run();
+ if (indicator != null) {
+ indicator.popState();
+ }
}
else {
UIUtil.invokeLaterIfNeeded(runnable);
diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/KeymapImpl.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/KeymapImpl.java
index cc0dafe..7e2e860 100644
--- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/KeymapImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/KeymapImpl.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.
@@ -59,6 +59,7 @@
@NonNls private static final String KEYSTROKE_ATTRIBUTE = "keystroke";
@NonNls private static final String FIRST_KEYSTROKE_ATTRIBUTE = "first-keystroke";
@NonNls private static final String SECOND_KEYSTROKE_ATTRIBUTE = "second-keystroke";
+ @NonNls private static final String ABBREVIATION = "abbreviation";
@NonNls private static final String ACTION = "action";
@NonNls private static final String VERSION_ATTRIBUTE = "version";
@NonNls private static final String PARENT_ATTRIBUTE = "parent";
@@ -900,6 +901,21 @@
}
}
+ @Override
+ public String[] getAbbreviations() {
+ return new String[0];
+ }
+
+ @Override
+ public void addAbbreviation(String actionId, String abbreviation) {
+
+ }
+
+ @Override
+ public void removeAbbreviation(String actionId, String abbreviation) {
+
+ }
+
@NotNull
public ExternalInfo getExternalInfo() {
return myExternalInfo;
diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/ActionsTree.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/ActionsTree.java
index d394d85..eeb31e0 100644
--- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/ActionsTree.java
+++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/ActionsTree.java
@@ -26,6 +26,7 @@
import com.intellij.openapi.keymap.KeymapUtil;
import com.intellij.openapi.keymap.impl.KeymapImpl;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.GraphicsConfig;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
@@ -33,6 +34,7 @@
import com.intellij.ui.treeStructure.Tree;
import com.intellij.ui.treeStructure.treetable.TreeTableModel;
import com.intellij.util.ui.EmptyIcon;
+import com.intellij.util.ui.GraphicsUtil;
import com.intellij.util.ui.PlatformColors;
import com.intellij.util.ui.UIUtil;
import com.intellij.util.ui.tree.TreeUtil;
@@ -46,6 +48,7 @@
import java.awt.*;
import java.util.ArrayList;
import java.util.Enumeration;
+import java.util.Set;
public class ActionsTree {
private static final Icon EMPTY_ICON = EmptyIcon.ICON_18;
@@ -519,20 +522,22 @@
}
private void paintRowData(Tree tree, Object data, Rectangle bounds, Graphics2D g) {
- Shortcut[] shortcuts;
+ Shortcut[] shortcuts = null;
+ Set<String> abbreviations = null;
if (data instanceof String) {
- shortcuts = myKeymap.getShortcuts((String)data);
+ final String actionId = (String)data;
+ shortcuts = myKeymap.getShortcuts(actionId);
+ abbreviations = AbbreviationManager.getInstance().getAbbreviations(actionId);
}
else if (data instanceof QuickList) {
shortcuts = myKeymap.getShortcuts(((QuickList)data).getActionId());
}
- else {
- shortcuts = null;
- }
+ final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
+
+ int totalWidth = 0;
+ final FontMetrics metrics = tree.getFontMetrics(tree.getFont());
if (shortcuts != null && shortcuts.length > 0) {
- int totalWidth = 0;
- final FontMetrics metrics = tree.getFontMetrics(tree.getFont());
for (Shortcut shortcut : shortcuts) {
totalWidth += metrics.stringWidth(KeymapUtil.getShortcutText(shortcut));
totalWidth += 10;
@@ -558,5 +563,33 @@
}
g.translate(0, -bounds.y + 1);
}
+ if (Registry.is("actionSystem.enableAbbreviations") && abbreviations != null && abbreviations.size() > 0) {
+ for (String abbreviation : abbreviations) {
+ totalWidth += metrics.stringWidth(abbreviation);
+ totalWidth += 10;
+ }
+ totalWidth -= 5;
+
+ int x = bounds.x + bounds.width - totalWidth;
+ int fontHeight = (int)metrics.getMaxCharBounds(g).getHeight();
+
+ Color c1 = new Color(206, 234, 176);
+ Color c2 = new Color(126, 208, 82);
+
+ g.translate(0, bounds.y - 1);
+
+ for (String abbreviation : abbreviations) {
+ int width = metrics.stringWidth(abbreviation);
+ UIUtil.drawSearchMatch(g, x, x + width, bounds.height, c1, c2);
+ g.setColor(Gray._50);
+ g.drawString(abbreviation, x, fontHeight);
+
+ x += width;
+ x += 10;
+ }
+ g.translate(0, -bounds.y + 1);
+ }
+
+ config.restore();
}
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/KeymapPanel.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/KeymapPanel.java
index 30be58d..1ce3b0f 100644
--- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/KeymapPanel.java
+++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/KeymapPanel.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.
@@ -48,6 +48,7 @@
import com.intellij.openapi.ui.popup.ListPopup;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Disposer;
+import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.packageDependencies.ui.TreeExpansionMonitor;
import com.intellij.ui.DocumentAdapter;
@@ -925,7 +926,7 @@
}
public String getHelpTopic() {
- return null;
+ return "preferences.keymap";
}
public JComponent createComponent() {
@@ -953,6 +954,7 @@
DefaultActionGroup group = new DefaultActionGroup();
final Shortcut[] shortcuts = mySelectedKeymap.getShortcuts(actionId);
+ final Set<String> abbreviations = AbbreviationManager.getInstance().getAbbreviations(actionId);
group.add(new DumbAwareAction("Add Keyboard Shortcut") {
@Override
@@ -983,6 +985,26 @@
}
});
+ if (Registry.is("actionSystem.enableAbbreviations")) {
+ group.add(new DumbAwareAction("Add Abbreviation") {
+ @Override
+ public void actionPerformed(AnActionEvent e) {
+ final String abbr = Messages.showInputDialog("Enter new abbreviation:", "Abbreviation", null);
+ if (abbr != null) {
+ String actionId = myActionsTree.getSelectedActionId();
+ AbbreviationManager.getInstance().register(abbr, actionId);
+ repaintLists();
+ }
+ }
+
+ @Override
+ public void update(AnActionEvent e) {
+ final boolean enabled = myActionsTree.getSelectedActionId() != null;
+ e.getPresentation().setEnabledAndVisible(enabled);
+ }
+ });
+ }
+
group.addSeparator();
for (final Shortcut shortcut : shortcuts) {
@@ -994,6 +1016,23 @@
});
}
+ if (Registry.is("actionSystem.enableAbbreviations")) {
+ for (final String abbreviation : abbreviations) {
+ group.addAction(new DumbAwareAction("Remove Abbreviation '" + abbreviation + "'") {
+ @Override
+ public void actionPerformed(AnActionEvent e) {
+ AbbreviationManager.getInstance().remove(abbreviation, actionId);
+ repaintLists();
+ }
+
+ @Override
+ public void update(AnActionEvent e) {
+ super.update(e);
+ }
+ });
+ }
+ }
+
if (e instanceof MouseEvent && ((MouseEvent)e).isPopupTrigger()) {
final ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.UNKNOWN, group);
popupMenu.getComponent().show(e.getComponent(), ((MouseEvent)e).getX(), ((MouseEvent)e).getY());
diff --git a/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectImpl.java b/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectImpl.java
index 2d62c8d..7e6a04c 100644
--- a/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectImpl.java
@@ -41,6 +41,7 @@
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.progress.ProgressIndicator;
+import com.intellij.openapi.progress.ProgressIndicatorProvider;
import com.intellij.openapi.project.DumbAwareRunnable;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectBundle;
@@ -207,9 +208,9 @@
if (!service) {
ProgressIndicator indicator = getProgressIndicator();
if (indicator != null) {
- indicator.setText2(getComponentName(component));
- // indicator.setIndeterminate(false);
- // indicator.setFraction(myComponentsRegistry.getPercentageOfComponentsLoaded());
+ // indicator.setText2(getComponentName(component));
+ indicator.setIndeterminate(false);
+ indicator.setFraction(getPercentageOfComponentsLoaded());
}
}
@@ -308,7 +309,14 @@
public void init() {
long start = System.currentTimeMillis();
// ProfilingUtil.startCPUProfiling();
+ final ProgressIndicator progressIndicator = isDefault() ? null : ProgressIndicatorProvider.getGlobalProgressIndicator();
+ if (progressIndicator != null) {
+ progressIndicator.pushState();
+ }
super.init();
+ if (progressIndicator != null) {
+ progressIndicator.popState();
+ }
// ProfilingUtil.captureCPUSnapshot();
long time = System.currentTimeMillis() - start;
LOG.info(getComponentConfigurations().length + " project components initialized in " + time + " ms");
diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemImpl.java b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemImpl.java
index 19a7fc49..6648e7c 100644
--- a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/LocalFileSystemImpl.java
@@ -82,23 +82,11 @@
return FileUtil.toSystemIndependentName(myFSRootPath);
}
- /** @deprecated implementation details (to remove in IDEA 13) */
- @Override
- public String getFileSystemRootPath() {
- return myFSRootPath;
- }
-
@Override
public boolean isToWatchRecursively() {
return myToWatchRecursively;
}
- /** @deprecated implementation details (to remove in IDEA 13) */
- @Override
- public boolean dominates(@NotNull WatchRequest other) {
- return LocalFileSystemImpl.dominates(this, (WatchRequestImpl)other);
- }
-
@Override
public String toString() {
return getRootPath();
@@ -138,19 +126,6 @@
return "LocalFileSystem";
}
- @TestOnly
- public void cleanupForNextTest() {
- ApplicationManager.getApplication().runWriteAction(new Runnable() {
- @Override
- public void run() {
- FileDocumentManager.getInstance().saveAllDocuments();
- }
- });
- PersistentFS.getInstance().clearIdCache();
-
- myRootsToWatch.clear();
- }
-
private WatchRequestImpl[] normalizeRootsForRefresh() {
final List<WatchRequestImpl> result = new ArrayList<WatchRequestImpl>();
@@ -267,14 +242,6 @@
return !request.isToWatchRecursively() && currentNode.watchRequest != null;
}
- private static boolean dominates(final WatchRequestImpl request, final WatchRequestImpl other) {
- if (request.myToWatchRecursively) {
- return other.myFSRootPath.startsWith(request.myFSRootPath);
- }
-
- return !other.myToWatchRecursively && request.myFSRootPath.equals(other.myFSRootPath);
- }
-
private void storeRefreshStatusToFiles() {
if (myWatcher.isOperational()) {
FileWatcher.DirtyPaths dirtyPaths = myWatcher.getDirtyPaths();
@@ -559,4 +526,16 @@
public String toString() {
return "LocalFileSystem";
}
+
+ @TestOnly
+ public void cleanupForNextTest() {
+ ApplicationManager.getApplication().runWriteAction(new Runnable() {
+ @Override
+ public void run() {
+ FileDocumentManager.getInstance().saveAllDocuments();
+ }
+ });
+ PersistentFS.getInstance().clearIdCache();
+ myRootsToWatch.clear();
+ }
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VirtualFileSystemEntry.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VirtualFileSystemEntry.java
index 0b32996..7da918a 100644
--- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VirtualFileSystemEntry.java
+++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/impl/VirtualFileSystemEntry.java
@@ -48,6 +48,7 @@
public abstract class VirtualFileSystemEntry extends NewVirtualFile {
public static final VirtualFileSystemEntry[] EMPTY_ARRAY = new VirtualFileSystemEntry[0];
+ @NonNls protected static final String FS_ROOT_FAKE_NAME = "";
protected static final PersistentFS ourPersistence = PersistentFS.getInstance();
private static final Key<String> SYMLINK_TARGET = Key.create("local.vfs.symlink.target");
@@ -73,7 +74,9 @@
myParent = parent;
myId = id;
- storeName(name);
+ if (name != FS_ROOT_FAKE_NAME) {
+ storeName(name);
+ }
if (parent != null && parent != VirtualDirectoryImpl.NULL_VIRTUAL_FILE) {
setFlagInt(IS_SYMLINK_FLAG, PersistentFS.isSymLink(attributes));
diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSImpl.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSImpl.java
index d980c9f..30ca7fe 100644
--- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSImpl.java
@@ -440,12 +440,11 @@
}
@Override
- public VirtualFile copyFile(final Object requestor, @NotNull final VirtualFile file, @NotNull final VirtualFile newParent, @NotNull final String copyName)
- throws IOException {
- getDelegate(file).copyFile(requestor, file, newParent, copyName);
- processEvent(new VFileCopyEvent(requestor, file, newParent, copyName));
+ public VirtualFile copyFile(Object requestor, @NotNull VirtualFile file, @NotNull VirtualFile parent, @NotNull String name) throws IOException {
+ getDelegate(file).copyFile(requestor, file, parent, name);
+ processEvent(new VFileCopyEvent(requestor, file, parent, name));
- final VirtualFile child = newParent.findChild(copyName);
+ final VirtualFile child = parent.findChild(name);
if (child == null) {
throw new IOException("Cannot create child");
}
@@ -453,7 +452,7 @@
}
@Override
- public VirtualFile createChildDirectory(final Object requestor, @NotNull final VirtualFile parent, @NotNull final String dir) throws IOException {
+ public VirtualFile createChildDirectory(Object requestor, @NotNull VirtualFile parent, @NotNull String dir) throws IOException {
getDelegate(parent).createChildDirectory(requestor, parent, dir);
processEvent(new VFileCreateEvent(requestor, parent, dir, true, false));
@@ -465,7 +464,7 @@
}
@Override
- public VirtualFile createChildFile(final Object requestor, @NotNull final VirtualFile parent, @NotNull final String file) throws IOException {
+ public VirtualFile createChildFile(Object requestor, @NotNull VirtualFile parent, @NotNull String file) throws IOException {
getDelegate(parent).createChildFile(requestor, parent, file);
processEvent(new VFileCreateEvent(requestor, parent, file, false, false));
@@ -588,8 +587,10 @@
return len;
}
- private InputStream createReplicator(@NotNull final VirtualFile file, final InputStream nativeStream, final long fileLength, final boolean readOnly)
- throws IOException {
+ private InputStream createReplicator(@NotNull final VirtualFile file,
+ final InputStream nativeStream,
+ final long fileLength,
+ final boolean readOnly) throws IOException {
if (nativeStream instanceof BufferExposingByteArrayInputStream) {
// optimization
BufferExposingByteArrayInputStream byteStream = (BufferExposingByteArrayInputStream )nativeStream;
@@ -634,20 +635,19 @@
final Object requestor,
final long modStamp,
final long timeStamp) throws IOException {
- final VFileContentChangeEvent event = new VFileContentChangeEvent(requestor, file, file.getModificationStamp(), modStamp, false);
-
- final List<VFileContentChangeEvent> events = Collections.singletonList(event);
-
- final BulkFileListener publisher = myEventsBus.syncPublisher(VirtualFileManager.VFS_CHANGES);
- publisher.before(events);
-
return new ByteArrayOutputStream() {
private boolean closed; // protection against user calling .close() twice
+
@Override
public void close() throws IOException {
if (closed) return;
super.close();
+ VFileContentChangeEvent event = new VFileContentChangeEvent(requestor, file, file.getModificationStamp(), modStamp, false);
+ List<VFileContentChangeEvent> events = Collections.singletonList(event);
+ BulkFileListener publisher = myEventsBus.syncPublisher(VirtualFileManager.VFS_CHANGES);
+ publisher.before(events);
+
NewVirtualFileSystem delegate = getDelegate(file);
OutputStream ioFileStream = delegate.getOutputStream(file, requestor, modStamp, timeStamp);
// FSRecords.ContentOutputStream already buffered, no need to wrap in BufferedStream
@@ -664,6 +664,7 @@
closed = true;
persistenceStream.close();
ioFileStream.close();
+
executeTouch(file, false, event.getModificationStamp());
publisher.after(events);
}
@@ -769,7 +770,9 @@
VirtualFile changedParent = null;
if (event instanceof VFileCreateEvent) {
changedParent = ((VFileCreateEvent)event).getParent();
- } else if (event instanceof VFileDeleteEvent) {
+ ((VFileCreateEvent)event).resetCache();
+ }
+ else if (event instanceof VFileDeleteEvent) {
changedParent = ((VFileDeleteEvent)event).getFile().getParent();
}
@@ -780,7 +783,8 @@
parentToChildrenEventsChanges.put(changedParent, parentChildrenChanges = new SmartList<VFileEvent>());
}
parentChildrenChanges.add(event);
- } else {
+ }
+ else {
applyEvent(event);
}
}
@@ -810,7 +814,7 @@
TIntHashSet parentChildrenIds = new TIntHashSet(FSRecords.list(parentId));
boolean hasRemovedChildren = false;
- for(VFileEvent event:events) {
+ for (VFileEvent event : events) {
if (event instanceof VFileCreateEvent) {
String name = ((VFileCreateEvent)event).getChildName();
final VirtualFile fake = new FakeVirtualFile(parent, name);
@@ -825,7 +829,8 @@
childrenIdsUpdated.add(childId);
parentChildrenIds.add(childId);
}
- } else if (event instanceof VFileDeleteEvent) {
+ }
+ else if (event instanceof VFileDeleteEvent) {
VirtualFile file = ((VFileDeleteEvent)event).getFile();
if (!file.exists()) {
LOG.error("Deleting a file, which does not exist: " + file.getPath());
@@ -843,16 +848,17 @@
FSRecords.updateList(parentId, parentChildrenIds.toArray());
- if (hasRemovedChildren) clearIdCache();
+ if (hasRemovedChildren) clearIdCache();
VirtualDirectoryImpl parentImpl = (VirtualDirectoryImpl)parent;
- for(int i = 0, len = childrenIdsUpdated.size(); i < len; ++i) {
+ for (int i = 0, len = childrenIdsUpdated.size(); i < len; ++i) {
final int childId = childrenIdsUpdated.get(i);
final VirtualFile childFile = childrenToBeUpdated.get(i);
if (childId > 0) {
parentImpl.addChild((VirtualFileSystemEntry)childFile);
- } else {
+ }
+ else {
FSRecords.deleteRecordRecursively(-childId);
parentImpl.removeChild(childFile);
invalidateSubtree(childFile);
@@ -864,10 +870,10 @@
@Nullable
public VirtualFileSystemEntry findRoot(@NotNull String basePath, @NotNull NewVirtualFileSystem fs) {
String rootUrl = normalizeRootUrl(basePath, fs);
-
boolean isFakeRoot = basePath.isEmpty();
- myRootsLock.readLock().lock();
VirtualFileSystemEntry root;
+
+ myRootsLock.readLock().lock();
try {
root = isFakeRoot ? mySuperRoot : myRoots.get(rootUrl);
if (root != null) return root;
@@ -887,34 +893,7 @@
if (isFakeRoot) {
// fake super-root
- root = new VirtualDirectoryImpl("", null, fs, rootId, 0) {
- @SuppressWarnings("NonSynchronizedMethodOverridesSynchronizedMethod")
- @Override
- @NotNull
- public VirtualFile[] getChildren() {
- return getRoots(getFileSystem());
- }
-
- @Override
- public VirtualFileSystemEntry findChild(@NotNull String name) {
- if (name.isEmpty()) return null;
- return findRoot(name, getFileSystem());
- }
-
- @Override
- protected char[] appendPathOnFileSystem(int pathLength, int[] position) {
- // getPath() for super-root should never be called.
- // however, when new FakeVirtualFile(superRoot, "name") is constructed,
- // return garbage to make sure they won't find anything by the name returned
- String fakeName = "@&^%$#*/\\(";
- int rootPathLength = pathLength + fakeName.length();
- char[] chars = new char[rootPathLength];
-
- position[0] = copyString(chars, position[0], fakeName);
-
- return chars;
- }
- };
+ root = new FakeRoot(fs, rootId);
}
else if (fs instanceof JarFileSystem) {
// optimization: for jar roots do not store base path in the myName field, use local FS file's getPath()
@@ -931,29 +910,7 @@
root = new JarRoot(fs, rootId, parentLocalFile);
}
else {
- root = new VirtualDirectoryImpl(basePath, null, fs, rootId, 0){
- @Override
- protected char[] appendPathOnFileSystem(int pathLength, int[] position) {
- // do not call super method since we know it's the root
- String name = getName();
- int nameLength = name.length();
- boolean appendSlash = SystemInfo.isWindows && nameLength == 2 && name.charAt(1) == ':'
- && pathLength == 0 // otherwise we called this as a part of longer file path calculation and slash will be added anyway
- ;
-
- int rootPathLength = pathLength + nameLength;
- if (appendSlash) ++rootPathLength;
- char[] chars = new char[rootPathLength];
-
- position[0] = copyString(chars, position[0], name);
-
- if (appendSlash) {
- chars[position[0]++] = '/';
- }
-
- return chars;
- }
- };
+ root = new FsRoot(fs, rootId, basePath);
}
if (isFakeRoot) {
@@ -1037,7 +994,7 @@
}
}
else {
- VirtualFileSystemEntry parentFile = findFileById(parentId, cachedOnly, visited, mask |= id);
+ VirtualFileSystemEntry parentFile = findFileById(parentId, cachedOnly, visited, mask | id);
if (parentFile instanceof VirtualDirectoryImpl) {
result = ((VirtualDirectoryImpl)parentFile).findChildById(id, cachedOnly);
}
@@ -1335,11 +1292,67 @@
}
}
- public static class JarRoot extends VirtualDirectoryImpl {
+
+ private abstract static class AbstractRoot extends VirtualDirectoryImpl {
+ protected AbstractRoot(@NotNull NewVirtualFileSystem fs, int id) {
+ super(FS_ROOT_FAKE_NAME, null, fs, id, 0);
+ }
+
+ @NotNull
+ @Override
+ public abstract String getName();
+
+ @Override
+ protected abstract char[] appendPathOnFileSystem(int accumulatedPathLength, int[] positionRef);
+
+ @Override
+ public final void setParent(@NotNull VirtualFile newParent) {
+ throw new IncorrectOperationException();
+ }
+ }
+
+ private class FakeRoot extends AbstractRoot {
+ private FakeRoot(@NotNull NewVirtualFileSystem fs, int rootId) {
+ super(fs, rootId);
+ }
+
+ @NotNull
+ @Override
+ public String getName() {
+ return FS_ROOT_FAKE_NAME;
+ }
+
+ @SuppressWarnings("NonSynchronizedMethodOverridesSynchronizedMethod")
+ @Override
+ @NotNull
+ public VirtualFile[] getChildren() {
+ return getRoots(getFileSystem());
+ }
+
+ @Override
+ public VirtualFileSystemEntry findChild(@NotNull String name) {
+ if (name.isEmpty()) return null;
+ return findRoot(name, getFileSystem());
+ }
+
+ @Override
+ protected char[] appendPathOnFileSystem(int pathLength, int[] position) {
+ // getPath() for super-root should never be called.
+ // however, when new FakeVirtualFile(superRoot, "name") is constructed,
+ // return garbage to make sure they won't find anything by the name returned
+ String fakeName = "@&^%$#*/\\(";
+ int rootPathLength = pathLength + fakeName.length();
+ char[] chars = new char[rootPathLength];
+ position[0] = copyString(chars, position[0], fakeName);
+ return chars;
+ }
+ }
+
+ private static class JarRoot extends AbstractRoot {
private final VirtualFile myParentLocalFile;
private JarRoot(@NotNull NewVirtualFileSystem fs, int rootId, @NotNull VirtualFile parentLocalFile) {
- super("", null, fs, rootId, 0);
+ super(fs, rootId);
myParentLocalFile = parentLocalFile;
}
@@ -1357,15 +1370,41 @@
positionRef[0] = copyString(chars, positionRef[0], JarFileSystem.JAR_SEPARATOR);
return chars;
}
+ }
- @Override
- public void setParent(@NotNull VirtualFile newParent) {
- throw new IncorrectOperationException();
+ private static class FsRoot extends AbstractRoot {
+ private final String myName;
+
+ private FsRoot(@NotNull NewVirtualFileSystem fs, int rootId, @NotNull String basePath) {
+ super(fs, rootId);
+ myName = FileUtil.toSystemIndependentName(basePath);
}
@NotNull
- public VirtualFile getParentLocalFile() {
- return myParentLocalFile;
+ @Override
+ public String getName() {
+ return myName;
+ }
+
+ @Override
+ protected char[] appendPathOnFileSystem(int pathLength, int[] position) {
+ String name = getName();
+ int nameLength = name.length();
+ int rootPathLength = pathLength + nameLength;
+
+ // otherwise we called this as a part of longer file path calculation and slash will be added anyway
+ boolean appendSlash = SystemInfo.isWindows && nameLength == 2 && name.charAt(1) == ':' && pathLength == 0;
+
+ if (appendSlash) ++rootPathLength;
+ char[] chars = new char[rootPathLength];
+
+ position[0] = copyString(chars, position[0], name);
+
+ if (appendSlash) {
+ chars[position[0]++] = '/';
+ }
+
+ return chars;
}
}
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeFrameImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeFrameImpl.java
index 6f20c23..96b5818 100644
--- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeFrameImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeFrameImpl.java
@@ -52,7 +52,6 @@
import com.intellij.openapi.wm.impl.welcomeScreen.WelcomeFrame;
import com.intellij.ui.*;
import com.intellij.util.ui.UIUtil;
-import org.java.ayatana.ApplicationMenu;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -75,6 +74,8 @@
private static boolean myUpdatingTitle;
+ private static String xdgCurrentDesktop = System.getenv("XDG_CURRENT_DESKTOP");
+
private String myTitle;
private String myFileTitle;
private File myCurrentFile;
@@ -97,10 +98,10 @@
setBackground(UIUtil.getPanelBackground());
AppUIUtil.updateWindowIcon(this);
final Dimension size = ScreenUtil.getMainScreenBounds().getSize();
-
+
size.width = Math.min(1400, size.width - 20);
size.height= Math.min(1000, size.height - 40);
-
+
setSize(size);
setLocationRelativeTo(null);
@@ -123,25 +124,22 @@
MouseGestureManager.getInstance().add(this);
myFrameDecorator = IdeFrameDecorator.decorate(this);
+
addWindowStateListener(new WindowAdapter() {
@Override
public void windowStateChanged(WindowEvent e) {
updateBorder();
}
});
+
Toolkit.getDefaultToolkit().addPropertyChangeListener("win.xpstyle.themeActive", new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
updateBorder();
}
});
- if (SystemInfo.isLinux && Registry.is("linux.native.menu")) {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- ApplicationMenu.tryInstall(IdeFrameImpl.this);
- }
- });
- }
+
+ IdeMenuBar.installAppMenuIfNeeded(this);
}
private void updateBorder() {
diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeMenuBar.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeMenuBar.java
index 05400de..2f02707 100644
--- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeMenuBar.java
+++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeMenuBar.java
@@ -30,6 +30,8 @@
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.util.Disposer;
+import com.intellij.openapi.util.SystemInfo;
+import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.wm.ex.IdeFrameEx;
import com.intellij.openapi.wm.impl.status.ClockPanel;
import com.intellij.ui.Gray;
@@ -37,6 +39,7 @@
import com.intellij.ui.border.CustomLineBorder;
import com.intellij.util.ui.Animator;
import com.intellij.util.ui.UIUtil;
+import org.java.ayatana.ApplicationMenu;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -126,7 +129,7 @@
return new EmptyBorder(0, 0, 1, 0);
}
- return super.getBorder();
+ return UISettings.getInstance().SHOW_MAIN_TOOLBAR || UISettings.getInstance().SHOW_NAVIGATION_BAR ? super.getBorder() : null;
}
@Override
@@ -556,4 +559,15 @@
super.mouseClicked(e);
}
}
+
+ public static void installAppMenuIfNeeded(@NotNull final JFrame frame) {
+ if (SystemInfo.isLinux && Registry.is("linux.native.menu") && "Unity".equals(System.getenv("XDG_CURRENT_DESKTOP"))) {
+ //noinspection SSBasedInspection
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ ApplicationMenu.tryInstall(frame);
+ }
+ });
+ }
+ }
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdePanePanel.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdePanePanel.java
index 5c4ced6..d953b4d 100644
--- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdePanePanel.java
+++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdePanePanel.java
@@ -15,11 +15,9 @@
*/
package com.intellij.openapi.wm.impl;
-import com.intellij.icons.AllIcons;
import com.intellij.openapi.application.ex.ApplicationInfoEx;
import com.intellij.openapi.util.IconLoader;
import com.intellij.ui.components.JBPanel;
-import com.intellij.util.PlatformUtils;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.Nullable;
@@ -50,7 +48,7 @@
@Nullable
public static Icon getIdeBackgroundImage() {
- return UIUtil.isUnderDarcula() && !PlatformUtils.isCidr() ? AllIcons.Frame_background : null;
+ return null;
}
@Nullable
@@ -64,9 +62,19 @@
return null;
}
+ @Override
+ protected void paintCenterImage(Graphics g) {
+ final Icon image = getCenterImage();
+ if (image != null) {
+ final int x = (getWidth() - image.getIconWidth()) / 2;
+ final int y = ((getHeight() - 222) / 2 - image.getIconHeight()) / 2;
+ image.paintIcon(this, g, x, y);
+ }
+ }
+
@Nullable
public static Color getIdeBackgroundColor() {
Color result = UIUtil.getSlightlyDarkerColor(UIUtil.getPanelBackground());
- return UIUtil.isUnderDarcula() ? result : UIUtil.getSlightlyDarkerColor(UIUtil.getSlightlyDarkerColor(result));
+ return UIUtil.isUnderDarcula() ? new Color(40, 40, 41) : UIUtil.getSlightlyDarkerColor(UIUtil.getSlightlyDarkerColor(result));
}
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/StripeButtonUI.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/StripeButtonUI.java
index e2302fa..ecf6af1 100644
--- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/StripeButtonUI.java
+++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/StripeButtonUI.java
@@ -17,6 +17,7 @@
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.wm.ToolWindowAnchor;
+import com.intellij.ui.ColorUtil;
import com.intellij.ui.Gray;
import com.intellij.util.ui.UIUtil;
@@ -25,7 +26,8 @@
import javax.swing.plaf.basic.BasicGraphicsUtils;
import javax.swing.plaf.metal.MetalToggleButtonUI;
import java.awt.*;
-import java.awt.geom.*;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.RoundRectangle2D;
/**
* @author Vladimir Kondratyev
@@ -189,7 +191,7 @@
Shape shape = new RoundRectangle2D.Double(gap, gap, button.getWidth() - 2 * gap, button.getHeight() - 2 * gap, r, r);
if (model.isArmed() && model.isPressed() || model.isSelected()) {
- g2.setColor(dark ? Gray._85.withAlpha(85) : new Color(0, 0, 0, 30));
+ g2.setColor(ColorUtil.mix(dark ? Gray._85.withAlpha(85) : new Color(0, 0, 0, 30), new Color(100, 150, 230, 50), .5));
g2.fill(shape);
g2.setColor(dark ? Gray._40 : new Color(0, 0, 0, 120));
g2.draw(shape);
diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/TestWindowManager.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/TestWindowManager.java
index f9de5ac..13b4b25 100644
--- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/TestWindowManager.java
+++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/TestWindowManager.java
@@ -166,6 +166,11 @@
public void updateWidget(@NotNull String id) { }
@Override
+ public StatusBarWidget getWidget(String id) {
+ return null;
+ }
+
+ @Override
public void removeWidget(@NotNull String id) { }
@Override
diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/IdeStatusBarImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/IdeStatusBarImpl.java
index 7cd1c80..e7353f0 100644
--- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/IdeStatusBarImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/IdeStatusBarImpl.java
@@ -52,6 +52,7 @@
* User: spLeaner
*/
public class IdeStatusBarImpl extends JComponent implements StatusBarEx {
+ private static final int MIN_ICON_HEIGHT = 18;
private final InfoAndProgressPanel myInfoAndProgressPanel;
private IdeFrame myFrame;
@@ -177,6 +178,16 @@
}
@Override
+ public Dimension getPreferredSize() {
+ Dimension size = super.getPreferredSize();
+ if (size == null) return null;
+
+ Insets insets = getInsets();
+ int minHeight = insets.top + insets.bottom + MIN_ICON_HEIGHT;
+ return new Dimension(size.width, Math.max(size.height, minHeight));
+ }
+
+ @Override
public void addWidget(@NotNull final StatusBarWidget widget) {
addWidget(widget, Position.RIGHT, "__AUTODETECT__");
}
@@ -839,7 +850,7 @@
@Override
public Dimension getMinimumSize() {
- return new Dimension(24, 18);
+ return new Dimension(24, MIN_ICON_HEIGHT);
}
@Override
diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/MemoryUsagePanel.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/MemoryUsagePanel.java
index 189b8b6..80aa74b1 100644
--- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/MemoryUsagePanel.java
+++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/MemoryUsagePanel.java
@@ -208,13 +208,15 @@
@Override
public Dimension getPreferredSize() {
- return new Dimension(getPreferredWidth(),
- isVisible() && getParent() != null ? getParent().getSize().height : super.getPreferredSize().height);
+ final Insets insets = getInsets();
+ int width = getFontMetrics(getWidgetFont()).stringWidth(SAMPLE_STRING) + insets.left + insets.right + 2;
+ int height = getFontMetrics(getWidgetFont()).getHeight() + insets.top + insets.bottom + 2;
+ return new Dimension(width, height);
}
- private int getPreferredWidth() {
- final Insets insets = getInsets();
- return getFontMetrics(getWidgetFont()).stringWidth(SAMPLE_STRING) + insets.left + insets.right + 2;
+ @Override
+ public Dimension getMinimumSize() {
+ return getPreferredSize();
}
@Override
diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/StatusPanel.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/StatusPanel.java
index ad42294..d2cb6e9 100644
--- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/StatusPanel.java
+++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/StatusPanel.java
@@ -27,7 +27,6 @@
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.ui.JBMenuItem;
import com.intellij.openapi.ui.JBPopupMenu;
-import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.Trinity;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.wm.IdeFrame;
@@ -51,7 +50,7 @@
*/
class StatusPanel extends JPanel {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.wm.impl.status.StatusPanel");
- private boolean myLogMode;
+ private Notification myCurrentNotification;
private int myTimeStart;
private boolean myDirty;
private boolean myAfterClick;
@@ -101,8 +100,8 @@
new ClickListener() {
@Override
public boolean onClick(MouseEvent e, int clickCount) {
- if (myLogMode || myAfterClick) {
- EventLog.toggleLog(getActiveProject());
+ if (myCurrentNotification != null || myAfterClick) {
+ EventLog.toggleLog(getActiveProject(), myCurrentNotification);
myAfterClick = true;
myTextPanel.setExplicitSize(myTextPanel.getSize());
myTextPanel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
@@ -118,7 +117,7 @@
myTextPanel.setExplicitSize(null);
myTextPanel.revalidate();
myAfterClick = false;
- if (!myLogMode) {
+ if (myCurrentNotification == null) {
myTextPanel.setCursor(Cursor.getDefaultCursor());
}
}
@@ -198,13 +197,13 @@
final Project project = getActiveProject();
final Trinity<Notification, String, Long> statusMessage = EventLog.getStatusMessage(project);
final Alarm alarm = getAlarm();
- myLogMode = StringUtil.isEmpty(nonLogText) && statusMessage != null && alarm != null;
+ myCurrentNotification = StringUtil.isEmpty(nonLogText) && statusMessage != null && alarm != null ? statusMessage.first : null;
if (alarm != null) {
alarm.cancelAllRequests();
}
- if (myLogMode) {
+ if (myCurrentNotification != null) {
myTextPanel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
new Runnable() {
@Override
@@ -229,7 +228,7 @@
setStatusText(nonLogText);
}
- return myLogMode;
+ return myCurrentNotification != null;
}
private void setStatusText(String text) {
diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/WelcomeFrame.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/WelcomeFrame.java
index c56e3b7..4764ce3 100644
--- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/WelcomeFrame.java
+++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/WelcomeFrame.java
@@ -32,17 +32,16 @@
import com.intellij.openapi.project.ProjectManagerAdapter;
import com.intellij.openapi.util.DimensionService;
import com.intellij.openapi.util.Disposer;
-import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.wm.*;
import com.intellij.openapi.wm.impl.IdeFrameImpl;
import com.intellij.openapi.wm.impl.IdeGlassPaneImpl;
+import com.intellij.openapi.wm.impl.IdeMenuBar;
import com.intellij.openapi.wm.impl.WindowManagerImpl;
import com.intellij.openapi.wm.impl.status.IdeStatusBarImpl;
import com.intellij.ui.AppUIUtil;
import com.intellij.ui.BalloonLayout;
import com.intellij.ui.BalloonLayoutImpl;
import com.intellij.util.ui.UIUtil;
-import org.java.ayatana.ApplicationMenu;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
@@ -156,11 +155,8 @@
public static void showNow() {
if (ourInstance == null) {
- IdeFrame frame = EP.getExtensions().length == 0
- ? new WelcomeFrame() : EP.getExtensions()[0].createFrame();
- if (SystemInfo.isLinux) {
- ApplicationMenu.tryInstall(((JFrame)frame));
- }
+ IdeFrame frame = EP.getExtensions().length == 0 ? new WelcomeFrame() : EP.getExtensions()[0].createFrame();
+ IdeMenuBar.installAppMenuIfNeeded((JFrame)frame);
((JFrame)frame).setVisible(true);
ourInstance = frame;
}
diff --git a/platform/platform-impl/src/com/intellij/platform/ProjectTemplateEP.java b/platform/platform-impl/src/com/intellij/platform/ProjectTemplateEP.java
new file mode 100644
index 0000000..b91a09b
--- /dev/null
+++ b/platform/platform-impl/src/com/intellij/platform/ProjectTemplateEP.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.platform;
+
+import com.intellij.openapi.extensions.AbstractExtensionPointBean;
+import com.intellij.openapi.extensions.ExtensionPointName;
+import com.intellij.util.xmlb.annotations.Attribute;
+
+/**
+ * @author Dmitry Avdeev
+ * Date: 07.11.13
+ */
+public class ProjectTemplateEP extends AbstractExtensionPointBean {
+
+ public static final ExtensionPointName<ProjectTemplateEP> EP_NAME = ExtensionPointName.create("com.intellij.projectTemplate");
+
+ @Attribute("projectType")
+ public String projectType;
+
+ @Attribute("templatePath")
+ public String templatePath;
+
+}
diff --git a/platform/platform-impl/src/com/intellij/ui/EditorTextField.java b/platform/platform-impl/src/com/intellij/ui/EditorTextField.java
index 4e18ea5..7fed54d 100644
--- a/platform/platform-impl/src/com/intellij/ui/EditorTextField.java
+++ b/platform/platform-impl/src/com/intellij/ui/EditorTextField.java
@@ -413,26 +413,14 @@
// set mode in editor
editor.setOneLineMode(isOneLineMode);
- final EditorColorsManager mgr = EditorColorsManager.getInstance();
- final EditorColorsScheme defaultScheme = UIUtil.isUnderDarcula()
- ? mgr.getScheme(mgr.getGlobalScheme().getName())
- : mgr.getScheme(EditorColorsManager.DEFAULT_SCHEME_NAME);
- final EditorColorsScheme customGlobalScheme = isOneLineMode ? defaultScheme : null;
+ EditorColorsManager colorsManager = EditorColorsManager.getInstance();
+ final EditorColorsScheme defaultScheme =
+ UIUtil.isUnderDarcula() ? colorsManager.getGlobalScheme() : colorsManager.getScheme(EditorColorsManager.DEFAULT_SCHEME_NAME);
+ EditorColorsScheme customGlobalScheme = isOneLineMode? defaultScheme : null;
- // Probably we need change scheme only for color schemas with white BG, but on the other hand
- // FindUsages dialog always uses FindUsages color scheme based on a default one and should be also fixed
- //
- //final EditorColorsScheme customGlobalScheme;
- //final EditorColorsScheme currentScheme = EditorColorsManager.getInstance().getGlobalScheme();
- //if (currentScheme.getDefaultBackground() == Color.WHITE) {
- // customGlobalScheme = currentScheme;
- //} else {
- // final EditorColorsScheme defaultScheme = EditorColorsManager.getInstance().getScheme(EditorColorsManager.DEFAULT_SCHEME_NAME);
- // customGlobalScheme = isOneLineMode ? defaultScheme : null;
- //}
editor.setColorsScheme(editor.createBoundColorSchemeDelegate(customGlobalScheme));
- final EditorColorsScheme colorsScheme = editor.getColorsScheme();
+ EditorColorsScheme colorsScheme = editor.getColorsScheme();
colorsScheme.setColor(EditorColors.CARET_ROW_COLOR, null);
editor.setColorsScheme(new DelegateColorScheme(colorsScheme) {
@Override
@@ -449,7 +437,7 @@
// color scheme settings:
setupEditorFont(editor);
updateBorder(editor);
- editor.setBackgroundColor(getBackgroundColor(!myIsViewer, colorsScheme));
+ editor.setBackgroundColor(getBackgroundColor(isEnabled(), colorsScheme));
}
diff --git a/platform/platform-impl/src/com/intellij/ui/FinderRecursivePanel.java b/platform/platform-impl/src/com/intellij/ui/FinderRecursivePanel.java
index 5781a57..a2f0648 100644
--- a/platform/platform-impl/src/com/intellij/ui/FinderRecursivePanel.java
+++ b/platform/platform-impl/src/com/intellij/ui/FinderRecursivePanel.java
@@ -9,6 +9,7 @@
import com.intellij.openapi.ide.CopyPasteManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
+import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.pom.Navigatable;
import com.intellij.psi.PsiElement;
@@ -130,6 +131,17 @@
return false;
}
+ /**
+ * To determine item list background color (if enabled).
+ *
+ * @param t Current item.
+ * @return Containing file.
+ */
+ @Nullable
+ protected VirtualFile getContainingFile(T t) {
+ return null;
+ }
+
@Nullable
protected JComponent createRightComponent(T t) {
return new JPanel();
@@ -291,6 +303,8 @@
protected ListCellRenderer createListCellRenderer() {
return new ColoredListCellRenderer() {
+ private final FileColorManager myFileColorManager = FileColorManager.getInstance(getProject());
+
public Component getListCellRendererComponent(JList list,
Object value,
int index,
@@ -311,6 +325,10 @@
doCustomizeCellRenderer(this, list, t, index, isSelected, cellHasFocus);
Color bg = isSelected ? UIUtil.getTreeSelectionBackground(cellHasFocus) : UIUtil.getTreeTextBackground();
+ if (!isSelected && myFileColorManager.isEnabled()) {
+ final Color fileBgColor = myFileColorManager.getRendererBackground(getContainingFile(t));
+ bg = fileBgColor == null ? bg : fileBgColor;
+ }
setBackground(bg);
if (hasChildren(t)) {
diff --git a/platform/platform-impl/src/com/intellij/ui/SpeedSearchBase.java b/platform/platform-impl/src/com/intellij/ui/SpeedSearchBase.java
index 2bd19a2..81c27a5 100644
--- a/platform/platform-impl/src/com/intellij/ui/SpeedSearchBase.java
+++ b/platform/platform-impl/src/com/intellij/ui/SpeedSearchBase.java
@@ -61,7 +61,7 @@
private final ToolWindowManagerListener myWindowManagerListener = new MyToolWindowManagerListener();
private final PropertyChangeSupport myChangeSupport = new PropertyChangeSupport(this);
private String myRecentEnteredPrefix;
- private SpeedSearchComparator myComparator = new SpeedSearchComparator();
+ private SpeedSearchComparator myComparator = new SpeedSearchComparator(false);
private boolean myClearSearchOnNavigateNoMatch = false;
@NonNls protected static final String ENTERED_PREFIX_PROPERTY_NAME = "enteredPrefix";
diff --git a/platform/platform-impl/src/com/intellij/ui/content/impl/ContentImpl.java b/platform/platform-impl/src/com/intellij/ui/content/impl/ContentImpl.java
index f10106a..82dd6ff 100644
--- a/platform/platform-impl/src/com/intellij/ui/content/impl/ContentImpl.java
+++ b/platform/platform-impl/src/com/intellij/ui/content/impl/ContentImpl.java
@@ -27,7 +27,9 @@
import com.intellij.ui.content.AlertIcon;
import com.intellij.ui.content.Content;
import com.intellij.ui.content.ContentManager;
+import com.intellij.util.IconUtil;
import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
@@ -36,6 +38,8 @@
import java.beans.PropertyChangeSupport;
public class ContentImpl extends UserDataHolderBase implements Content {
+ private static Icon ourEmptyPinIcon = null;
+
private String myDisplayName;
private String myDescription;
private JComponent myComponent;
@@ -113,13 +117,23 @@
@Override
public Icon getIcon() {
if (myIsLocked) {
- return myIcon == null ? AllIcons.Nodes.PinToolWindow : myLayeredIcon;
+ return myIcon == null ? getEmptyPinIcon() : myLayeredIcon;
}
else {
return myIcon;
}
}
+ @NotNull
+ private static Icon getEmptyPinIcon() {
+ if (ourEmptyPinIcon == null) {
+ Icon icon = AllIcons.Nodes.PinToolWindow;
+ int width = icon.getIconWidth();
+ ourEmptyPinIcon = IconUtil.cropIcon(icon, new Rectangle(width / 2, 0, width - width / 2, icon.getIconHeight()));
+ }
+ return ourEmptyPinIcon;
+ }
+
@Override
public void setDisplayName(String displayName) {
String oldValue = myDisplayName;
diff --git a/platform/platform-impl/src/com/intellij/ui/docking/impl/DockManagerImpl.java b/platform/platform-impl/src/com/intellij/ui/docking/impl/DockManagerImpl.java
index 0676031f..73461dd 100644
--- a/platform/platform-impl/src/com/intellij/ui/docking/impl/DockManagerImpl.java
+++ b/platform/platform-impl/src/com/intellij/ui/docking/impl/DockManagerImpl.java
@@ -346,6 +346,13 @@
}
}
+ for (DockContainer each : myContainers) {
+ RelativeRectangle rec = each.getAcceptAreaFallback();
+ if (rec.contains(point) && each.getContentResponse(content, point).canAccept()) {
+ return each;
+ }
+ }
+
return null;
}
diff --git a/platform/platform-impl/src/com/intellij/util/io/socketConnection/SocketConnectionListener.java b/platform/platform-impl/src/com/intellij/util/io/socketConnection/SocketConnectionListener.java
index 74ad0c8..ae7ae61 100644
--- a/platform/platform-impl/src/com/intellij/util/io/socketConnection/SocketConnectionListener.java
+++ b/platform/platform-impl/src/com/intellij/util/io/socketConnection/SocketConnectionListener.java
@@ -1,10 +1,12 @@
package com.intellij.util.io.socketConnection;
+import org.jetbrains.annotations.NotNull;
+
import java.util.EventListener;
/**
* @author nik
*/
public interface SocketConnectionListener extends EventListener {
- void statusChanged(ConnectionStatus status);
+ void statusChanged(@NotNull ConnectionStatus status);
}
\ No newline at end of file
diff --git a/platform/platform-impl/src/org/jetbrains/io/ChannelExceptionHandler.java b/platform/platform-impl/src/org/jetbrains/io/ChannelExceptionHandler.java
index 54ba57f..949453d 100644
--- a/platform/platform-impl/src/org/jetbrains/io/ChannelExceptionHandler.java
+++ b/platform/platform-impl/src/org/jetbrains/io/ChannelExceptionHandler.java
@@ -40,11 +40,11 @@
public void exceptionCaught(ChannelHandlerContext context, Throwable cause) throws Exception {
// don't report about errors while connecting
// WEB-7727
- if (!(cause instanceof ConnectException) && !"Connection reset".equals(cause.getMessage())) {
- NettyUtil.log(cause, LOG);
+ if (cause instanceof ConnectException || (cause.getMessage() != null && cause.getMessage().startsWith("Connection reset"))) {
+ LOG.debug(cause);
}
else {
- LOG.debug(cause);
+ NettyUtil.log(cause, LOG);
}
}
}
\ No newline at end of file
diff --git a/platform/platform-resources-en/src/messages/IdeBundle.properties b/platform/platform-resources-en/src/messages/IdeBundle.properties
index 2f0f461..e5852f2 100644
--- a/platform/platform-resources-en/src/messages/IdeBundle.properties
+++ b/platform/platform-resources-en/src/messages/IdeBundle.properties
@@ -987,7 +987,7 @@
progress.download.file.text=Downloading ''{0}'' from ''{1}''...
progress.connecting.to.download.file.text=Connecting to ''{0}''...
progress.locate.file.text=Locating ''{0}''...
-progress.downloading.0.of.1.file.text=Downloading {0} of {1} {1, choice, 1#file|2#files}...
+progress.downloading.0.files.text=Downloading {0} {0, choice, 1#file|2#files}...
dialog.directory.for.downloaded.files.title=Downloaded files will be copied to selected directory
error.file.download.failed=Failed to download ''{0}'': {1}
diff --git a/platform/platform-resources-en/src/messages/RefactoringBundle.properties b/platform/platform-resources-en/src/messages/RefactoringBundle.properties
index 4571f97..a84626e 100644
--- a/platform/platform-resources-en/src/messages/RefactoringBundle.properties
+++ b/platform/platform-resources-en/src/messages/RefactoringBundle.properties
@@ -368,6 +368,7 @@
move.classes.elements.header=Classes to be moved to {0}
move.packages.elements.header=Packages to be moved to {0}
references.found.in.code=References found in code
+references.found.in.generated.code=References found in generated code
comments.elements.header=Occurrences found in comments, strings and non-code files {0}
move.files.elements.header=Files to be moved to {0}
move.directories.elements.header=Directories to be moved to {0}
diff --git a/platform/platform-resources-en/src/messages/UsageView.properties b/platform/platform-resources-en/src/messages/UsageView.properties
index f7a1ea3..134c257 100644
--- a/platform/platform-resources-en/src/messages/UsageView.properties
+++ b/platform/platform-resources-en/src/messages/UsageView.properties
@@ -1,5 +1,6 @@
node.targets=Targets
node.non.code.usages=Non-code usages
+node.usages.in.generated.code=Usages in generated code
node.found.usages=Found usages
usage.name=usage
usages.title=Usages
diff --git a/platform/platform-resources-en/src/misc/registry.properties b/platform/platform-resources-en/src/misc/registry.properties
index 67ef53e..cd7e7d3 100644
--- a/platform/platform-resources-en/src/misc/registry.properties
+++ b/platform/platform-resources-en/src/misc/registry.properties
@@ -41,6 +41,7 @@
actionSystem.win.suppressAlt=true
actionSystem.mouseGesturesEnabled=true
actionSystem.assertFocusAccessFromEdt=true
+actionSystem.enableAbbreviations=false
ide.firstStartup=true
ide.debugMode=false
@@ -309,6 +310,7 @@
show.flex.debug.design.view=false
git.new.log=true
+svn.use.terminal=false
completion.enable.relevant.method.chain.suggestions=false
ide.mac.message.sheets.java.emulation=false
diff --git a/platform/platform-resources/src/META-INF/LangExtensionPoints.xml b/platform/platform-resources/src/META-INF/LangExtensionPoints.xml
index 97f015a..2c2d9ec 100644
--- a/platform/platform-resources/src/META-INF/LangExtensionPoints.xml
+++ b/platform/platform-resources/src/META-INF/LangExtensionPoints.xml
@@ -206,8 +206,6 @@
<with attribute="implementationClass" implements="com.intellij.lang.TokenSeparatorGenerator"/>
</extensionPoint>
- <extensionPoint name="lang.psiAugmentProvider" interface="com.intellij.psi.augment.PsiAugmentProvider"/>
-
<extensionPoint name="lang.fileViewProviderFactory" beanClass="com.intellij.lang.LanguageExtensionPoint">
<with attribute="implementationClass" implements="com.intellij.psi.FileViewProviderFactory"/>
</extensionPoint>
@@ -233,6 +231,8 @@
<extensionPoint name="resolveScopeEnlarger" interface="com.intellij.psi.ResolveScopeEnlarger"/>
<extensionPoint name="resolveScopeProvider" interface="com.intellij.psi.ResolveScopeProvider"/>
+ <extensionPoint name="generatedSourcesFilter" interface="com.intellij.openapi.roots.GeneratedSourcesFilter"/>
+
<extensionPoint name="gotoClassContributor"
interface="com.intellij.navigation.ChooseByNameContributor"/>
<extensionPoint name="gotoSymbolContributor"
diff --git a/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml b/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml
index 097168f..091006a 100644
--- a/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml
+++ b/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml
@@ -98,6 +98,8 @@
<extensionPoint name="projectTemplatesFactory"
interface="com.intellij.platform.ProjectTemplatesFactory"/>
+ <extensionPoint name="projectTemplate"
+ beanClass="com.intellij.platform.ProjectTemplateEP"/>
<extensionPoint name="ApplicationLoadListener" interface="com.intellij.ide.ApplicationLoadListener"/>
@@ -169,6 +171,8 @@
<extensionPoint name="checkinHandlerFactory" interface="com.intellij.openapi.vcs.checkin.CheckinHandlerFactory"/>
+ <extensionPoint name="eventLogCategory" interface="com.intellij.notification.EventLogCategory"/>
+
<extensionPoint name="writingAccessProvider" area="IDEA_PROJECT" interface="com.intellij.openapi.vfs.WritingAccessProvider"/>
<extensionPoint name="editorNotificationProvider" area="IDEA_PROJECT" interface="com.intellij.ui.EditorNotifications$Provider"/>
<extensionPoint name="featureStatBundle" interface="com.intellij.featureStatistics.FeatureStatisticsBundleProvider"/>
diff --git a/platform/platform-resources/src/META-INF/XmlActions.xml b/platform/platform-resources/src/META-INF/XmlActions.xml
index 06266c6..ca19e8d 100644
--- a/platform/platform-resources/src/META-INF/XmlActions.xml
+++ b/platform/platform-resources/src/META-INF/XmlActions.xml
@@ -79,5 +79,8 @@
<add-to-group group-id="RunContextPopupGroup" anchor="last"/>
<!--<add-to-group group-id="ProjectViewPopupMenu" anchor="after" relative-to-action="EditSource"/>-->
</action>
+
+ <action id="SurroundWithEmmet" class="com.intellij.codeInsight.template.emmet.SurroundWithEmmetAction"
+ text="Surround with Emmet" description="Surround selected code with Emmet abbreviation"/>
</actions>
</component>
diff --git a/platform/platform-resources/src/componentSets/UICore.xml b/platform/platform-resources/src/componentSets/UICore.xml
index 83ed0ef..f813dd2 100644
--- a/platform/platform-resources/src/componentSets/UICore.xml
+++ b/platform/platform-resources/src/componentSets/UICore.xml
@@ -14,6 +14,10 @@
<headless-implementation-class>com.intellij.idea.CommandLineApplication$MyDataManagerImpl</headless-implementation-class>
</component>
<component>
+ <interface-class>com.intellij.openapi.actionSystem.AbbreviationManager</interface-class>
+ <implementation-class>com.intellij.openapi.actionSystem.impl.AbbreviationManagerImpl</implementation-class>
+ </component>
+ <component>
<interface-class>com.intellij.openapi.actionSystem.ActionManager</interface-class>
<implementation-class>com.intellij.openapi.actionSystem.impl.ActionManagerImpl</implementation-class>
</component>
diff --git a/platform/platform-resources/src/idea/Keymap_VisualStudio.xml b/platform/platform-resources/src/idea/Keymap_VisualStudio.xml
index 8e5fbc9..5762770 100644
--- a/platform/platform-resources/src/idea/Keymap_VisualStudio.xml
+++ b/platform/platform-resources/src/idea/Keymap_VisualStudio.xml
@@ -164,7 +164,6 @@
</action>
<action id="QuickJavaDoc">
<keyboard-shortcut first-keystroke="control Q"/>
- <keyboard-shortcut first-keystroke="shift F1"/>
</action>
<action id="ShowBookmarks">
<keyboard-shortcut first-keystroke="alt F2"/>
diff --git a/platform/platform-tests/testData/newGeneralFormatter/1.xml b/platform/platform-tests/testData/newGeneralFormatter/1.xml
new file mode 100644
index 0000000..4b579a7
--- /dev/null
+++ b/platform/platform-tests/testData/newGeneralFormatter/1.xml
@@ -0,0 +1,19 @@
+<Block start="0" end="23">
+
+ <Block start="0" end="3">
+ <Indent type="NONE" count="1" spaces="0"/>
+ </Block>
+ <Block start="4" end="7">
+ <Indent type="NONE" count="1" spaces="0"/>
+ </Block>
+ <Block start="8" end="23">
+ <Indent type="NONE" count="1" spaces="0"/>
+ <Block start="8" end="11"><Indent type="NORMAL" count="1" spaces="0"/></Block>
+ <Block start="12" end="15"><Indent type="NORMAL" count="1" spaces="0"/></Block>
+ <Block start="16" end="23">
+ <Indent type="NORMAL" count="1" spaces="0"/>
+ <Block start="16" end="19"><Indent type="LABEL" count="1" spaces="0"/></Block>
+ <Block start="20" end="23"><Indent type="LABEL" count="1" spaces="0"/></Block>
+ </Block>
+ </Block>
+</Block>
\ No newline at end of file
diff --git a/platform/platform-tests/testData/newGeneralFormatter/2.xml b/platform/platform-tests/testData/newGeneralFormatter/2.xml
new file mode 100644
index 0000000..d0d3124
--- /dev/null
+++ b/platform/platform-tests/testData/newGeneralFormatter/2.xml
@@ -0,0 +1,19 @@
+<Block start="0" end="23">
+ <Block start="0" end="3"></Block>
+ <Block start="4" end="7">
+ <Alignment id="1"/>
+ </Block>
+ <Block start="8" end="23">
+ <Alignment id="1"/>
+ <Block start="8" end="11"><Indent type="LABEL" count="1" spaces="0"/></Block>
+ <Block start="12" end="15"><Indent type="LABEL" count="1" spaces="0"/></Block>
+ <Block start="16" end="23">
+ <Indent type="LABEL" count="1" spaces="0"/>
+ <Alignment id="1"/>
+ <Block start="16" end="19"></Block>
+ <Block start="20" end="23">
+ <Alignment id="1"/>
+ </Block>
+ </Block>
+ </Block>
+</Block>
\ No newline at end of file
diff --git a/platform/platform-tests/testData/newGeneralFormatter/3.xml b/platform/platform-tests/testData/newGeneralFormatter/3.xml
new file mode 100644
index 0000000..1d24df1
--- /dev/null
+++ b/platform/platform-tests/testData/newGeneralFormatter/3.xml
@@ -0,0 +1,18 @@
+<Block start="0" end="23">
+ <Block start="0" end="3"/>
+ <Space minspaces="2" maxspaces="2" minlinefeeds="0" maxlinefeeds="100"/>
+ <Block start="4" end="7"/>
+ <Space minspaces="2" maxspaces="2" minlinefeeds="0" maxlinefeeds="100" keepLineBreaks="true"/>
+ <Block start="8" end="23">
+ <Block start="8" end="11"><Indent type="NORMAL" count="1" spaces="0"/></Block>
+ <Space minspaces="2" maxspaces="2" minlinefeeds="0" maxlinefeeds="100" keepLineBreaks="true"/>
+ <Block start="12" end="15"><Indent type="NORMAL" count="1" spaces="0"/></Block>
+ <Space minspaces="2" maxspaces="2" minlinefeeds="0" maxlinefeeds="100" keepLineBreaks="true"/>
+ <Block start="16" end="23">
+ <Indent type="NORMAL" count="1" spaces="0"/>
+ <Block start="16" end="19"><Indent type="LABEL" count="1" spaces="0"/></Block>
+ <Space minspaces="2" maxspaces="2" minlinefeeds="2" maxlinefeeds="100" keepLineBreaks="true"/>
+ <Block start="20" end="23"><Indent type="LABEL" count="1" spaces="0"/></Block>
+ </Block>
+ </Block>
+</Block>
\ No newline at end of file
diff --git a/platform/platform-tests/testData/newGeneralFormatter/4.xml b/platform/platform-tests/testData/newGeneralFormatter/4.xml
new file mode 100644
index 0000000..c079be0
--- /dev/null
+++ b/platform/platform-tests/testData/newGeneralFormatter/4.xml
@@ -0,0 +1,8 @@
+<Block start="0" end="5">
+ <Block start = "0" end="1"><Indent type="NONE"/></Block>
+ <Block start="2" end="5">
+ <Indent type="NONE"/>
+ <Block start="2" end="3"><Indent type="CONTINUATION" count="1"/></Block>
+ <Block start="4" end="5"><Indent type="CONTINUATION" count="1"/></Block>
+ </Block>
+</Block>
\ No newline at end of file
diff --git a/platform/platform-tests/testData/newGeneralFormatter/5.xml b/platform/platform-tests/testData/newGeneralFormatter/5.xml
new file mode 100644
index 0000000..616ba52
--- /dev/null
+++ b/platform/platform-tests/testData/newGeneralFormatter/5.xml
@@ -0,0 +1,14 @@
+<Block start="0" end="5">
+ <Block start = "0" end="1"><Indent type="NONE"/></Block>
+ <Block start="2" end="5">
+ <Indent type="NONE"/>
+ <Block start="2" end="3">
+ <Indent type="NORMAL" count="1"/>
+ <Block start="2" end="3"></Block>
+ </Block>
+ <Block start="4" end="5">
+ <Indent type="NORMAL" count="1"/>
+ <Block start="4" end="5"></Block>
+ </Block>
+ </Block>
+</Block>
\ No newline at end of file
diff --git a/platform/platform-tests/testData/newGeneralFormatter/6.xml b/platform/platform-tests/testData/newGeneralFormatter/6.xml
new file mode 100644
index 0000000..8f9d25d
--- /dev/null
+++ b/platform/platform-tests/testData/newGeneralFormatter/6.xml
@@ -0,0 +1,12 @@
+<Block start="0" end="6">
+ <Block start="0" end="1"><Indent type="NONE"/></Block>
+ <Block start="1" end="6">
+ <Indent type="NONE"/>
+ <Block start="1" end="4">
+ <Indent type="NORMAL"/>
+ <Block start="1" end="2"><Indent type="NONE"/></Block>
+ <Block start="3" end="4"><Indent type="NONE"/></Block>
+ </Block>
+ <Block start="5" end="6"><Indent type="NORMAL"/></Block>
+ </Block>
+</Block>
\ No newline at end of file
diff --git a/platform/platform-tests/testData/newGeneralFormatter/chopDownIfLong.xml b/platform/platform-tests/testData/newGeneralFormatter/chopDownIfLong.xml
new file mode 100644
index 0000000..849352f
--- /dev/null
+++ b/platform/platform-tests/testData/newGeneralFormatter/chopDownIfLong.xml
@@ -0,0 +1,26 @@
+<Block start="0" end="23">
+ <Wrap type="CHOP" id="1"/>
+ <Block start="0" end="3"></Block>
+ <Space minspaces="2" maxspaces="2" minlinefeeds="0" maxlinefeeds="100"/>
+ <Block start="4" end="7"><Wrap type="CHOP" id="1"/></Block>
+ <Space minspaces="2" maxspaces="2" minlinefeeds="0" maxlinefeeds="100"/>
+ <Block start="8" end="23">
+ <Wrap type="CHOP" id="1"/>
+ <Block start="8" end="11"><Indent type="LABEL" count="1" spaces="0"/></Block>
+ <Space minspaces="2" maxspaces="2" minlinefeeds="0" maxlinefeeds="100"/>
+ <Block start="12" end="15">
+ <Indent type="LABEL" count="1" spaces="0"/>
+ <Wrap type="CHOP" id="1"/>
+ </Block>
+ <Space minspaces="2" maxspaces="2" minlinefeeds="0" maxlinefeeds="100"/>
+ <Block start="16" end="23">
+ <Indent type="LABEL" count="1" spaces="0"/>
+ <Wrap type="CHOP" id="1"/>
+ <Block start="16" end="19"></Block>
+ <Space minspaces="2" maxspaces="2" minlinefeeds="0" maxlinefeeds="100"/>
+ <Block start="20" end="23">
+ <Wrap type="CHOP" id="1"/>
+ </Block>
+ </Block>
+ </Block>
+</Block>
\ No newline at end of file
diff --git a/platform/platform-tests/testData/newGeneralFormatter/continuationIndent.xml b/platform/platform-tests/testData/newGeneralFormatter/continuationIndent.xml
new file mode 100644
index 0000000..a2e5397
--- /dev/null
+++ b/platform/platform-tests/testData/newGeneralFormatter/continuationIndent.xml
@@ -0,0 +1,22 @@
+<Block start="0" end="11">
+ <Block start="0" end="11">
+ <Block start="0" end="11">
+ <Block start="0" end="1"/>
+ <Block start="2" end="3"/>
+ <Block start="4" end="11">
+ <Block start="4" end="11">
+ <Block start="4" end="11">
+ <Block start="4" end="5"/>
+ <Block start="6" end="7"/>
+ <Block start="8" end="11">
+ <Block start="8" end="11">
+ <Block start="8" end="9"/>
+ <Block start="10" end="11"/>
+ </Block>
+ </Block>
+ </Block>
+ </Block>
+ </Block>
+ </Block>
+ </Block>
+</Block>
\ No newline at end of file
diff --git a/platform/platform-tests/testData/newGeneralFormatter/defaultContinuationIndent.xml b/platform/platform-tests/testData/newGeneralFormatter/defaultContinuationIndent.xml
new file mode 100644
index 0000000..74e6903
--- /dev/null
+++ b/platform/platform-tests/testData/newGeneralFormatter/defaultContinuationIndent.xml
@@ -0,0 +1,8 @@
+<Block start="0" end="23">
+ <Block start="0" end="3"/>
+ <Block start="4" end="7"/>
+ <Block start="8" end="11"/>
+ <Block start="12" end="15"/>
+ <Block start="16" end="19"/>
+ <Block start="20" end="23"/>
+</Block>
\ No newline at end of file
diff --git a/platform/platform-tests/testData/newGeneralFormatter/differentWraps.xml b/platform/platform-tests/testData/newGeneralFormatter/differentWraps.xml
new file mode 100644
index 0000000..04aa381
--- /dev/null
+++ b/platform/platform-tests/testData/newGeneralFormatter/differentWraps.xml
@@ -0,0 +1,54 @@
+<Block start="0" end="12">
+ <Block start="0" end="4">
+ <Indent type="NONE"/>
+ <Wrap type="NORMAL" id="1"/>
+ <Block start="0" end="1">
+ <Wrap type="NORMAL" id="2" parent="1"/>
+ </Block>
+ <Block start="1" end="2">
+ <Wrap type="NORMAL" id="2"/>
+ </Block>
+ <Block start="2" end="3">
+ <Wrap type="NORMAL" id="2"/>
+ </Block>
+ <Block start="3" end="4">
+ <Wrap type="NORMAL" id="2"/>
+ </Block>
+
+ </Block>
+ <Block start="4" end="8">
+ <Indent type="NONE"/>
+ <Wrap type="NORMAL" id="1"/>
+ <Block start="4" end="5">
+ <Wrap type="NORMAL" id="3" parent="1"/>
+ </Block>
+ <Block start="5" end="6">
+ <Wrap type="NORMAL" id="3"/>
+ </Block>
+ <Block start="6" end="7">
+ <Wrap type="NORMAL" id="3"/>
+ </Block>
+ <Block start="7" end="8">
+ <Wrap type="NORMAL" id="3"/>
+ </Block>
+
+ </Block>
+ <Block start="8" end="12">
+ <Indent type="NONE"/>
+ <Wrap type="NORMAL" id="1"/>
+ <Block start="8" end="9">
+ <Wrap type="NORMAL" id="4" parent="1"/>
+ </Block>
+ <Block start="9" end="10">
+ <Wrap type="NORMAL" id="4"/>
+ </Block>
+ <Block start="10" end="11">
+ <Wrap type="NORMAL" id="4"/>
+ </Block>
+ <Block start="11" end="12">
+ <Wrap type="NORMAL" id="4"/>
+ </Block>
+
+ </Block>
+
+</Block>
\ No newline at end of file
diff --git a/platform/platform-tests/testData/newGeneralFormatter/lineIndent.xml b/platform/platform-tests/testData/newGeneralFormatter/lineIndent.xml
new file mode 100644
index 0000000..83a5784
--- /dev/null
+++ b/platform/platform-tests/testData/newGeneralFormatter/lineIndent.xml
@@ -0,0 +1,3 @@
+<Block start="0" end="1" incomplete="true">
+ <Indent type="NORMAL" count="1" spaces="0"/>
+</Block>
\ No newline at end of file
diff --git a/platform/platform-tests/testData/newGeneralFormatter/multipleWrap.xml b/platform/platform-tests/testData/newGeneralFormatter/multipleWrap.xml
new file mode 100644
index 0000000..f762d87
--- /dev/null
+++ b/platform/platform-tests/testData/newGeneralFormatter/multipleWrap.xml
@@ -0,0 +1,16 @@
+<Block start="0" end="3">
+ <Block start="0" end="1">
+ <Wrap type="NORMAL" id="1"/>
+ </Block>
+ <Block start="1" end="2">
+ <Wrap type="NORMAL" id="1"/>
+ </Block>
+ <Block start="2" end="3">
+ <Wrap type="NORMAL" id="1"/>
+ <Block start="2" end="3">
+ <Wrap type="NORMAL" id="2"/>
+ </Block>
+
+ </Block>
+
+</Block>
\ No newline at end of file
diff --git a/platform/platform-tests/testData/newGeneralFormatter/nestedCalls.xml b/platform/platform-tests/testData/newGeneralFormatter/nestedCalls.xml
new file mode 100644
index 0000000..13c637b
--- /dev/null
+++ b/platform/platform-tests/testData/newGeneralFormatter/nestedCalls.xml
@@ -0,0 +1,32 @@
+<Block start="0" end="9">
+
+ <Block start="0" end="1"><Indent type="NONE"/></Block>
+ <Block start="2" end="9">
+ <Indent type="NONE"/>
+ <Block start="2" end="3"><Indent type="CONTINUATION"/></Block>
+
+ <Block start="3" end="9">
+ <Indent type="NONE"/>
+
+ <Block start="3" end="4"><Indent type="CONTINUATION"/></Block>
+ <Block start="5" end="9">
+ <Indent type="NONE"/>
+
+
+ <Block start="5" end="6"><Indent type="CONTINUATION"/></Block>
+
+ <Block start="6" end="9">
+ <Indent type="NONE"/>
+
+ <Block start="6" end="7"><Indent type="CONTINUATION"/></Block>
+ <Block start="8" end="9">
+ <Indent type="NONE"/>
+ <Block start="8" end="9"><Indent type="CONTINUATION"/></Block>
+
+ </Block>
+ </Block>
+
+ </Block>
+ </Block>
+ </Block>
+</Block>
\ No newline at end of file
diff --git a/platform/platform-tests/testData/newGeneralFormatter/removeAllSpaces.xml b/platform/platform-tests/testData/newGeneralFormatter/removeAllSpaces.xml
new file mode 100644
index 0000000..22d37e2
--- /dev/null
+++ b/platform/platform-tests/testData/newGeneralFormatter/removeAllSpaces.xml
@@ -0,0 +1,21 @@
+<Block start="0" end="20">
+ <Block start = "0" end="1"></Block>
+ <Space minspaces="0" maxspaces="0" minlinefeeds="0" maxlinefeeds="0"/>
+ <Block start = "2" end="3"></Block>
+ <Space minspaces="0" maxspaces="0" minlinefeeds="0" maxlinefeeds="0"/>
+ <Block start = "4" end="5"></Block>
+ <Space minspaces="0" maxspaces="0" minlinefeeds="0" maxlinefeeds="0"/>
+ <Block start = "6" end="7"></Block>
+ <Space minspaces="0" maxspaces="0" minlinefeeds="0" maxlinefeeds="0"/>
+ <Block start = "8" end="9"></Block>
+ <Space minspaces="0" maxspaces="0" minlinefeeds="0" maxlinefeeds="0"/>
+ <Block start = "10" end="11"></Block>
+ <Space minspaces="0" maxspaces="0" minlinefeeds="0" maxlinefeeds="0"/>
+ <Block start = "12" end="13"></Block>
+ <Space minspaces="0" maxspaces="0" minlinefeeds="0" maxlinefeeds="0"/>
+ <Block start = "14" end="15"></Block>
+ <Space minspaces="0" maxspaces="0" minlinefeeds="0" maxlinefeeds="0"/>
+ <Block start = "16" end="17"></Block>
+ <Space minspaces="0" maxspaces="0" minlinefeeds="0" maxlinefeeds="0"/>
+ <Block start = "18" end="19"></Block>
+</Block>
\ No newline at end of file
diff --git a/platform/platform-tests/testData/newGeneralFormatter/wrapAlways.xml b/platform/platform-tests/testData/newGeneralFormatter/wrapAlways.xml
new file mode 100644
index 0000000..eaa0a36
--- /dev/null
+++ b/platform/platform-tests/testData/newGeneralFormatter/wrapAlways.xml
@@ -0,0 +1,27 @@
+<Block start="0" end="23">
+ <Wrap type="ALWAYS" id="1"/>
+ <Block start="0" end="3"><Indent type="NONE" count="1" spaces="0"/></Block>
+ <Space minspaces="2" maxspaces="2" minlinefeeds="0" maxlinefeeds="100"/>
+ <Block start="4" end="7"><Wrap type="ALWAYS" id="1"/><Indent type="NONE" count="1" spaces="0"/></Block>
+ <Space minspaces="2" maxspaces="2" minlinefeeds="0" maxlinefeeds="100"/>
+ <Block start="8" end="23">
+ <Indent type="NONE" count="1" spaces="0"/>
+ <Wrap type="ALWAYS" id="1"/>
+ <Block start="8" end="11"><Indent type="LABEL" count="1" spaces="0"/></Block>
+ <Space minspaces="2" maxspaces="2" minlinefeeds="0" maxlinefeeds="100"/>
+ <Block start="12" end="15">
+ <Indent type="LABEL" count="1" spaces="0"/>
+ <Wrap type="ALWAYS" id="1"/>
+ </Block>
+ <Space minspaces="2" maxspaces="2" minlinefeeds="0" maxlinefeeds="100"/>
+ <Block start="16" end="23">
+ <Indent type="LABEL" count="1" spaces="0"/>
+ <Wrap type="ALWAYS" id="1"/>
+ <Block start="16" end="19"></Block>
+ <Space minspaces="2" maxspaces="2" minlinefeeds="0" maxlinefeeds="100"/>
+ <Block start="20" end="23">
+ <Wrap type="ALWAYS" id="1"/>
+ </Block>
+ </Block>
+ </Block>
+</Block>
\ No newline at end of file
diff --git a/platform/platform-tests/testData/newGeneralFormatter/wrapAsNeeded.xml b/platform/platform-tests/testData/newGeneralFormatter/wrapAsNeeded.xml
new file mode 100644
index 0000000..6762d13a
--- /dev/null
+++ b/platform/platform-tests/testData/newGeneralFormatter/wrapAsNeeded.xml
@@ -0,0 +1,26 @@
+<Block start="0" end="23">
+ <Wrap type="NORMAL" id="1"/>
+ <Block start="0" end="3"/>
+ <Space minspaces="2" maxspaces="2" minlinefeeds="0" maxlinefeeds="100"/>
+ <Block start="4" end="7"><Wrap type="NORMAL" id="1"/></Block>
+ <Space minspaces="2" maxspaces="2" minlinefeeds="0" maxlinefeeds="100"/>
+ <Block start="8" end="23">
+ <Wrap type="NORMAL" id="1"/>
+ <Block start="8" end="11"><Indent type="LABEL" count="1" spaces="0"/></Block>
+ <Space minspaces="2" maxspaces="2" minlinefeeds="0" maxlinefeeds="100"/>
+ <Block start="12" end="15">
+ <Indent type="LABEL" count="1" spaces="0"/>
+ <Wrap type="NORMAL" id="1"/>
+ </Block>
+ <Space minspaces="2" maxspaces="2" minlinefeeds="0" maxlinefeeds="100"/>
+ <Block start="16" end="23">
+ <Indent type="LABEL" count="1" spaces="0"/>
+ <Wrap type="NORMAL" id="1"/>
+ <Block start="16" end="19"/>
+ <Space minspaces="2" maxspaces="2" minlinefeeds="0" maxlinefeeds="100"/>
+ <Block start="20" end="23">
+ <Wrap type="NORMAL" id="1"/>
+ </Block>
+ </Block>
+ </Block>
+</Block>
\ No newline at end of file
diff --git a/platform/platform-tests/testData/newGeneralFormatter/wrapAtMiddle.xml b/platform/platform-tests/testData/newGeneralFormatter/wrapAtMiddle.xml
new file mode 100644
index 0000000..09e37d1
--- /dev/null
+++ b/platform/platform-tests/testData/newGeneralFormatter/wrapAtMiddle.xml
@@ -0,0 +1,22 @@
+<Block start="0" end="23">
+ <Block start="0" end="3"/>
+ <Space minspaces="2" maxspaces="2" minlinefeeds="0" maxlinefeeds="100"/>
+ <Block start="4" end="7"><Wrap type="NORMAL" id="1"/></Block>
+ <Space minspaces="2" maxspaces="2" minlinefeeds="0" maxlinefeeds="100"/>
+ <Block start="8" end="23">
+ <Block start="8" end="11"><Indent type="LABEL" count="1" spaces="0"/></Block>
+ <Space minspaces="2" maxspaces="2" minlinefeeds="0" maxlinefeeds="100"/>
+ <Block start="12" end="15">
+ <Indent type="LABEL" count="1" spaces="0"/>
+ <Wrap type="NORMAL" id="1"/>
+ </Block>
+ <Space minspaces="2" maxspaces="2" minlinefeeds="0" maxlinefeeds="100"/>
+ <Block start="16" end="23">
+ <Indent type="LABEL" count="1" spaces="0"/>
+ <Block start="16" end="19"/>
+ <Space minspaces="2" maxspaces="2" minlinefeeds="0" maxlinefeeds="100"/>
+ <Block start="20" end="23">
+ </Block>
+ </Block>
+ </Block>
+</Block>
\ No newline at end of file
diff --git a/platform/platform-tests/testSrc/com/intellij/formatting/FormattingModelXmlReader.java b/platform/platform-tests/testSrc/com/intellij/formatting/FormattingModelXmlReader.java
new file mode 100644
index 0000000..c206547
--- /dev/null
+++ b/platform/platform-tests/testSrc/com/intellij/formatting/FormattingModelXmlReader.java
@@ -0,0 +1,140 @@
+package com.intellij.formatting;
+
+import com.intellij.openapi.util.JDOMUtil;
+import com.intellij.openapi.util.TextRange;
+import com.intellij.testFramework.PlatformTestUtil;
+import com.intellij.util.containers.HashMap;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.JDOMException;
+import org.jetbrains.annotations.NonNls;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+@NonNls public class FormattingModelXmlReader {
+
+ private final Map<String, Alignment> myIdToAlignemt = new HashMap<String, Alignment>();
+ private final Map<String, Wrap> myIdToWrap = new HashMap<String, Wrap>();
+ private final FormattingDocumentModel myModel;
+
+ public FormattingModelXmlReader(final FormattingDocumentModel model) {
+ myModel = model;
+ }
+
+ public TestBlock readTestBlock(String dataName) throws IOException, JDOMException {
+ final File dataFile = new File( PlatformTestUtil.getCommunityPath().replace(File.separatorChar, '/') +
+ "/platform/platform-tests/testData/newGeneralFormatter", dataName + ".xml");
+ final Document document = JDOMUtil.loadDocument(dataFile);
+ return readBlock(document.getRootElement());
+ }
+
+ private TestBlock readBlock(final Element rootElement) {
+ final int startOffset = Integer.parseInt(rootElement.getAttributeValue("start"));
+ final int endOffset = Integer.parseInt(rootElement.getAttributeValue("end"));
+ final TextRange textRange = new TextRange(startOffset, endOffset);
+ final TestBlock result = new TestBlock(textRange);
+ result.setIsIncomplete(Boolean.valueOf(rootElement.getAttributeValue("incomplete")).booleanValue());
+ final CharSequence text = myModel.getText(textRange);
+ if (text != null) {
+ result.setText(text.toString());
+ }
+ final Element indentElement = rootElement.getChild("Indent");
+ if (indentElement != null) {
+ result.setIndent(readIndent(indentElement));
+ }
+ final Element alignmentElement = rootElement.getChild("Alignment");
+ if (alignmentElement != null) {
+ result.setAlignment(readAlignment(alignmentElement));
+ }
+
+ final Element wrapElement = rootElement.getChild("Wrap");
+ if (wrapElement != null) {
+ result.setWrap(readWrap(wrapElement));
+ }
+ final List children = rootElement.getChildren();
+ for (final Object aChildren : children) {
+ Element element = (Element)aChildren;
+ if (element.getName().equals("Space")) {
+ result.addSpace(readSpace(element));
+ }
+ else if (element.getName().equals("Block")) {
+ result.addBlock(readBlock(element));
+ }
+ }
+ return result;
+ }
+
+ private Wrap readWrap(final Element wrapElement) {
+ final String wrapId = wrapElement.getAttributeValue("id");
+ if (myIdToWrap.containsKey(wrapId)) return myIdToWrap.get(wrapId);
+
+ final String type = wrapElement.getAttributeValue("type");
+ String parentId = wrapElement.getAttributeValue("parent");
+ boolean wrapFirst = "true".equals(wrapElement.getAttributeValue("ignoreParents"));
+
+ if (myIdToWrap.containsKey(parentId)) {
+ final Wrap wrap = Wrap.createChildWrap(myIdToWrap.get(parentId),readWrapType(type), wrapFirst);
+ if ("true".equals(wrapElement.getAttributeValue("ignoreParents"))) {
+ wrap.ignoreParentWraps();
+ }
+ myIdToWrap.put(wrapId, wrap);
+ return wrap;
+ } else {
+ final Wrap wrap = Wrap.createWrap(readWrapType(type), wrapFirst);
+ if ("true".equals(wrapElement.getAttributeValue("ignoreParents"))) {
+ wrap.ignoreParentWraps();
+ }
+ myIdToWrap.put(wrapId, wrap);
+ return wrap;
+ }
+
+ }
+
+ private WrapType readWrapType(final String type) {
+ if ("ALWAYS".equals(type)) return WrapType.ALWAYS;
+ if ("NORMAL".equals(type)) return WrapType.NORMAL;
+ if ("CHOP".equals(type)) return WrapType.CHOP_DOWN_IF_LONG;
+ return WrapType.NONE;
+ }
+
+ private Spacing readSpace(final Element element) {
+ return Spacing.createSpacing(
+ getInt(element.getAttributeValue("minspaces")),
+ getInt(element.getAttributeValue("maxspaces")),
+ getInt(element.getAttributeValue("minlinefeeds")),
+ "true".equals(element.getAttributeValue("keepLineBreaks")), 0);
+ }
+
+ private Alignment readAlignment(final Element alignmentElement) {
+ final String alignId = alignmentElement.getAttributeValue("id");
+ if (myIdToAlignemt.containsKey(alignId)) return myIdToAlignemt.get(alignId);
+
+ final Alignment alignment = Alignment.createAlignment();
+ myIdToAlignemt.put(alignId, alignment);
+ return alignment;
+ }
+
+ private Indent readIndent(final Element indentElement) {
+ return createIndent(indentElement.getAttributeValue("type"));
+ }
+
+ private int getInt(final String count) {
+ try {
+ return Integer.parseInt(count);
+ }
+ catch (Exception e) {
+ return 0;
+ }
+ }
+
+ private Indent createIndent(final String type) {
+ if ("LABEL".equals(type)) return Indent.getLabelIndent();
+ if ("NONE".equals(type)) return Indent.getNoneIndent();
+ if ("CONTINUATION".equals(type)) return Indent.getContinuationIndent();
+ return Indent.getNormalIndent();
+ }
+
+}
diff --git a/platform/platform-tests/testSrc/com/intellij/formatting/GeneralCodeFormatterTest.java b/platform/platform-tests/testSrc/com/intellij/formatting/GeneralCodeFormatterTest.java
new file mode 100644
index 0000000..7814e6e
--- /dev/null
+++ b/platform/platform-tests/testSrc/com/intellij/formatting/GeneralCodeFormatterTest.java
@@ -0,0 +1,215 @@
+package com.intellij.formatting;
+
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.util.TextRange;
+import com.intellij.psi.codeStyle.CodeStyleSettings;
+import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
+import com.intellij.util.IncorrectOperationException;
+import com.intellij.util.ui.UIUtil;
+import junit.framework.TestCase;
+import org.jdom.JDOMException;
+import org.jetbrains.annotations.NonNls;
+
+import java.io.IOException;
+
+@NonNls public class GeneralCodeFormatterTest extends TestCase {
+ private int myRightMargin = 120;
+
+ @Override
+ public void runBare() throws Throwable {
+ if (ApplicationManager.getApplication() != null) {
+ final Throwable[] throwable = new Throwable[1];
+
+ UIUtil.invokeAndWaitIfNeeded(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ runBareImpl();
+ }
+ catch (Throwable th) {
+ throwable[0] = th;
+ }
+ }
+
+ private void runBareImpl() throws Throwable {
+ setUp();
+ try {
+ runTest();
+ }
+ finally {
+ tearDown();
+ }
+ }
+ });
+
+ if (throwable[0] != null) {
+ throw throwable[0];
+ }
+ }
+ else {
+ super.runBare();
+ }
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ FormatterImpl.getInstance();
+ }
+
+ public void testDefaultContinuationIndent() throws Exception {
+ doTest("defaultContinuationIndent", "aaa bbb ccc\nddd eee fff", "aaa bbb ccc\n" +
+ " ddd eee fff");
+ }
+
+ public void testContinuationIndent() throws Exception {
+ doTest("4", "a\nb\nc", "a\n" +
+ " b\n" +
+ " c");
+ }
+
+ public void testContinuationIndent2() throws Exception{
+ doTest("5", "a\nb\nc", "a\n" +
+ " b\n" +
+ " c");
+ }
+
+ public void testParentContinuationIndent() throws Exception {
+ doTest("continuationIndent", "a\nb\nc\nd\ne\nf",
+ "a\n" +
+ " b\n" +
+ " c\n" +
+ " d\n" +
+ " e\n" +
+ " f");
+ }
+
+ public void test1() throws Exception {
+ doTest("1", "aaa bbb\nccc ddd\neee\nfff",
+ "aaa bbb\n" +
+ " ccc ddd\n" +
+ " eee\n" +
+ " fff");
+ }
+
+ public void test2() throws Exception {
+ doTest("2", "aaa bbb\nccc ddd\neee\nfff", "aaa bbb\n" +
+ " ccc ddd\n" +
+ " eee\n" +
+ " fff");
+ }
+
+ public void testLastLineIndent() throws Exception{
+ final String initialText = "a\n";
+ final TestFormattingModel model = new TestFormattingModel(initialText);
+
+ model.setRootBlock(new FormattingModelXmlReader(model).readTestBlock("lineIndent"));
+ final CommonCodeStyleSettings.IndentOptions indentOptions = new CommonCodeStyleSettings.IndentOptions();
+ indentOptions.CONTINUATION_INDENT_SIZE = 8;
+ indentOptions.INDENT_SIZE = 4;
+ indentOptions.LABEL_INDENT_SIZE = 1;
+ final CodeStyleSettings settings = new CodeStyleSettings(false);
+ settings.RIGHT_MARGIN = myRightMargin;
+ try {
+ FormatterEx.getInstanceEx().adjustLineIndent(model, settings, indentOptions, initialText.length() - 1, new TextRange(0, initialText.length()));
+ }
+ catch (IncorrectOperationException e) {
+ fail();
+ }
+
+ assertEquals("a\n ", FormatterImpl.getText(model));
+
+ }
+
+ public void test22() throws Exception {
+ doTest("2", "aaa bbb ccc ddd eee\nfff", "aaa bbb ccc ddd eee\n" +
+ " fff");
+
+ }
+
+ public void testSpaceProperties() throws Exception {
+ doTest("3",
+ "aaa bbb ccc\n" +
+ "ddd eee fff",
+ "aaa bbb ccc\n" +
+ " ddd eee\n" +
+ "\n" +
+ " fff"
+ );
+ }
+
+ public void testSimpleWrapping() throws Exception {
+ doTest("wrapAlways", "aaa bbb ccc ddd eee fff", "aaa\n" +
+ "bbb\n" +
+ " ccc\n" +
+ " ddd\n" +
+ " eee\n" +
+ " fff");
+ myRightMargin = 16;
+ doTest("wrapAsNeeded", "aaa bbb ccc ddd eee fff", "aaa bbb ccc\n" +
+ " ddd eee fff");
+ }
+
+ public void testWrapping() throws Exception {
+ myRightMargin = 10;
+ doTest("chopDownIfLong", "aaa bbb ccc ddd eee fff", "aaa\n" +
+ " bbb\n" +
+ " ccc\n" +
+ " ddd\n" +
+ " eee\n" +
+ " fff");
+ myRightMargin = 20;
+ doTest("wrapAtMiddle", "aaa bbb ccc ddd eee fff", "aaa bbb ccc\n" +
+ " ddd eee fff");
+
+ }
+
+ public void testMultipleWrap() throws Exception {
+ myRightMargin = 2;
+ doTest("multipleWrap", "abc", "ab\n c");
+ }
+
+ public void testDifferentWraps() throws Exception {
+ myRightMargin = 10;
+ doTest("differentWraps", "(ab)(cd)(ef)", "(ab)(cd)\n" +
+ "(ef)");
+
+ }
+
+ public void testNestedCalls2() throws Exception{
+ doTest("nestedCalls",
+ "1 a2 b3\nc",
+ "1 a2 b3\n" +
+ " c");
+
+ }
+ public void testRemoveAllSpaces() throws Exception{
+ doTest("removeAllSpaces",
+ "0 1\n2\n3\t4 5\n6 7 8\t9 ",
+ "0123456789 ");
+ }
+
+ private void doTest(final String formattingModelName,
+ final String initial,
+ final String expected) throws IOException, JDOMException {
+ final TestFormattingModel model = new TestFormattingModel(initial);
+
+ model.setRootBlock(new FormattingModelXmlReader(model).readTestBlock(formattingModelName));
+ final CommonCodeStyleSettings.IndentOptions indentOptions = new CommonCodeStyleSettings.IndentOptions();
+ indentOptions.CONTINUATION_INDENT_SIZE = 8;
+ indentOptions.INDENT_SIZE = 4;
+ indentOptions.LABEL_INDENT_SIZE = 1;
+ final CodeStyleSettings settings = new CodeStyleSettings(false);
+ settings.RIGHT_MARGIN = myRightMargin;
+ try {
+ FormatterEx.getInstanceEx().format(model, settings, indentOptions, indentOptions, null);
+ }
+ catch (IncorrectOperationException e) {
+ fail();
+ }
+
+ assertEquals(expected, FormatterImpl.getText(model));
+ }
+
+
+}
diff --git a/platform/platform-tests/testSrc/com/intellij/formatting/TestBlock.java b/platform/platform-tests/testSrc/com/intellij/formatting/TestBlock.java
new file mode 100644
index 0000000..bc45734
--- /dev/null
+++ b/platform/platform-tests/testSrc/com/intellij/formatting/TestBlock.java
@@ -0,0 +1,126 @@
+package com.intellij.formatting;
+
+import com.intellij.openapi.util.TextRange;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+public class TestBlock implements Block{
+ private TextRange myTextRange;
+
+ private final List<Object> myElements = new ArrayList<Object>();
+ private Wrap myWrap;
+ private Indent myIndent;
+ private Alignment myAlignment;
+ private String myText = "";
+ private boolean myIsIncomplete = false;
+
+ public TestBlock(final TextRange textRange) {
+ myTextRange = textRange;
+ }
+
+ @Override
+ @NotNull
+ public TextRange getTextRange() {
+ return myTextRange;
+ }
+
+ @Override
+ @NotNull
+ public List<Block> getSubBlocks() {
+ return getBlockList();
+ }
+
+ public String toString() {
+ return myText;
+ }
+
+ private List<Block> getBlockList() {
+ final ArrayList<Block> blocks = new ArrayList<Block>();
+ for (Object o : myElements) {
+ if (o instanceof Block) blocks.add((Block)o);
+ }
+ return blocks;
+ }
+
+ @Override
+ public Wrap getWrap() {
+ return myWrap;
+ }
+
+ @Override
+ public Indent getIndent() {
+ return myIndent;
+ }
+
+ @Override
+ public Alignment getAlignment() {
+ return myAlignment;
+ }
+
+ public TestBlock setWrap(final Wrap wrap) {
+ myWrap = wrap;
+ return this;
+ }
+
+ public TestBlock setAlignment(final Alignment alignment) {
+ myAlignment = alignment;
+ return this;
+ }
+
+ public TestBlock setIndent(final Indent indent) {
+ myIndent = indent;
+ return this;
+ }
+
+ @Override
+ public Spacing getSpacing(@Nullable Block child1, @NotNull Block child2) {
+ if (child1 == null) {
+ return null;
+ }
+ final int index = myElements.indexOf(child2);
+ if (myElements.get(index - 1) instanceof Spacing) {
+ return (Spacing)myElements.get(index - 1);
+ }
+ return null;
+ }
+
+ public void addBlock(final Block block) {
+ myElements.add(block);
+ }
+
+ public void setTextRange(final TextRange textRange) {
+ myTextRange = textRange;
+ }
+
+ public void addSpace(final Spacing spacing) {
+ myElements.add(spacing);
+ }
+
+ public void setText(final String s) {
+ myText = s;
+ }
+
+ @Override
+ @NotNull
+ public ChildAttributes getChildAttributes(final int newChildIndex) {
+ return new ChildAttributes(getIndent(), null);
+ }
+
+ @Override
+ public boolean isIncomplete() {
+ return myIsIncomplete;
+ }
+
+ @Override
+ public boolean isLeaf() {
+ return myElements.isEmpty();
+ }
+
+ public void setIsIncomplete(final boolean value) {
+ myIsIncomplete = value;
+ }
+}
diff --git a/platform/platform-tests/testSrc/com/intellij/formatting/TestFormattingModel.java b/platform/platform-tests/testSrc/com/intellij/formatting/TestFormattingModel.java
new file mode 100644
index 0000000..afd5749
--- /dev/null
+++ b/platform/platform-tests/testSrc/com/intellij/formatting/TestFormattingModel.java
@@ -0,0 +1,121 @@
+package com.intellij.formatting;
+
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.editor.Document;
+import com.intellij.openapi.editor.impl.DocumentImpl;
+import com.intellij.openapi.util.TextRange;
+import com.intellij.psi.formatter.CompositeWhiteSpaceFormattingStrategy;
+import com.intellij.psi.formatter.StaticSymbolWhiteSpaceDefinitionStrategy;
+import com.intellij.psi.formatter.WhiteSpaceFormattingStrategy;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Arrays;
+
+public class TestFormattingModel implements FormattingModel, FormattingDocumentModel{
+
+ private final CompositeWhiteSpaceFormattingStrategy myWhiteSpaceStrategy = new CompositeWhiteSpaceFormattingStrategy(
+ Arrays.<WhiteSpaceFormattingStrategy>asList(
+ new StaticSymbolWhiteSpaceDefinitionStrategy(' ', '\t', '\n')
+ )
+ );
+ private final Document myDocument;
+ private Block myRootBlock;
+
+ public TestFormattingModel(String text) {
+ myDocument = new DocumentImpl(text);
+ }
+
+ public TestFormattingModel(final Document document) {
+ myDocument = document;
+ }
+
+ public void setRootBlock(final Block rootBlock) {
+ myRootBlock = rootBlock;
+ }
+
+ @Override
+ public int getLineNumber(int offset) {
+ return myDocument.getLineNumber(offset);
+ }
+
+ @Override
+ public int getLineStartOffset(int line) {
+ return myDocument.getLineStartOffset(line);
+ }
+
+ @Override
+ public TextRange replaceWhiteSpace(final TextRange textRange,
+ final String whiteSpace
+ ) {
+ if (ApplicationManager.getApplication() != null) {
+ ApplicationManager.getApplication().runWriteAction(new Runnable() {
+ @Override
+ public void run() {
+ myDocument.replaceString(textRange.getStartOffset(), textRange.getEndOffset(), whiteSpace);
+ }
+ });
+ } else {
+ myDocument.replaceString(textRange.getStartOffset(), textRange.getEndOffset(), whiteSpace);
+ }
+
+ return new TextRange(textRange.getStartOffset(), textRange.getStartOffset() + whiteSpace.length());
+ }
+
+ @Override
+ public CharSequence getText(final TextRange textRange) {
+ return myDocument.getCharsSequence().subSequence(textRange.getStartOffset(), textRange.getEndOffset());
+ }
+
+ @Override
+ @NotNull
+ public FormattingDocumentModel getDocumentModel() {
+ return this;
+ }
+
+ @Override
+ @NotNull
+ public Block getRootBlock() {
+ return myRootBlock;
+ }
+
+ @Override
+ public void commitChanges() {
+ }
+
+ @Override
+ public int getTextLength() {
+ return myDocument.getTextLength();
+ }
+
+ @NotNull
+ @Override
+ public Document getDocument() {
+ return myDocument;
+ }
+
+ @Override
+ public TextRange shiftIndentInsideRange(TextRange range, int indent) {
+ return range;
+ }
+
+ @Override
+ public boolean containsWhiteSpaceSymbolsOnly(int startOffset, int endOffset) {
+ return myWhiteSpaceStrategy.check(myDocument.getCharsSequence(), startOffset, endOffset) >= endOffset;
+ }
+
+ @NotNull
+ @Override
+ public CharSequence adjustWhiteSpaceIfNecessary(@NotNull CharSequence whiteSpaceText, int startOffset, int endOffset,
+ boolean changedViaPsi) {
+ return whiteSpaceText;
+ }
+
+ //@Override
+ //public boolean isWhiteSpaceSymbol(char symbol) {
+ // return containsWhiteSpaceSymbolsOnly(CharBuffer.wrap(new char[] {symbol}), 0, 1);
+ //}
+
+ //private boolean containsWhiteSpaceSymbolsOnly(CharSequence text, int startOffset, int endOffset) {
+ // return myWhiteSpaceStrategy.check(myDocument.getCharsSequence(), startOffset, endOffset) >= endOffset;
+ //}
+}
diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/LocalFileSystemTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/LocalFileSystemTest.java
index c63f685..e53f400 100644
--- a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/LocalFileSystemTest.java
+++ b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/LocalFileSystemTest.java
@@ -16,17 +16,17 @@
package com.intellij.openapi.vfs.local;
import com.intellij.ide.GeneralSettings;
+import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileAttributes;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.IoTestUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.*;
-import com.intellij.openapi.vfs.newvfs.ManagingFS;
-import com.intellij.openapi.vfs.newvfs.NewVirtualFile;
-import com.intellij.openapi.vfs.newvfs.NewVirtualFileSystem;
-import com.intellij.openapi.vfs.newvfs.RefreshQueue;
+import com.intellij.openapi.vfs.newvfs.*;
+import com.intellij.openapi.vfs.newvfs.events.VFileCreateEvent;
import com.intellij.openapi.vfs.newvfs.events.VFileDeleteEvent;
+import com.intellij.openapi.vfs.newvfs.events.VFileEvent;
import com.intellij.openapi.vfs.newvfs.impl.FakeVirtualFile;
import com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl;
import com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry;
@@ -34,13 +34,40 @@
import com.intellij.openapi.vfs.newvfs.persistent.PersistentFSImpl;
import com.intellij.testFramework.PlatformLangTestCase;
import com.intellij.testFramework.PlatformTestUtil;
+import com.intellij.util.messages.MessageBusConnection;
+import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
+import java.util.List;
import java.util.Locale;
public class LocalFileSystemTest extends PlatformLangTestCase {
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ MessageBusConnection connection = ApplicationManager.getApplication().getMessageBus().connect(myTestRootDisposable);
+ connection.subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener() {
+ @Override public void before(@NotNull List<? extends VFileEvent> events) { checkFiles(events, true); }
+
+ @Override public void after(@NotNull List<? extends VFileEvent> events) { checkFiles(events, false); }
+
+ private void checkFiles(List<? extends VFileEvent> events, boolean before) {
+ for (VFileEvent event : events) {
+ VirtualFile file = event.getFile();
+ if (file != null) {
+ boolean shouldBeInvalid =
+ event instanceof VFileCreateEvent && before && !((VFileCreateEvent)event).isReCreation() ||
+ event instanceof VFileDeleteEvent && !before;
+ assertEquals(event.toString(), !shouldBeInvalid, file.isValid());
+ }
+ }
+ }
+ });
+ }
+
public void testChildrenAccessedButNotCached() throws Exception {
File dir = createTempDirectory(false);
ManagingFS managingFS = ManagingFS.getInstance();
@@ -474,4 +501,44 @@
assertFalse(subFile.isDirty());
assertFalse(subDir.isDirty());
}
+
+ public void testSymlinkTargetBlink() throws Exception {
+ if (!SystemInfo.areSymLinksSupported) {
+ System.err.println("Ignored: symlinks not supported");
+ return;
+ }
+
+ File top = createTempDirectory(true);
+ File target = IoTestUtil.createTestDir(top, "target");
+ File link = IoTestUtil.createSymLink(target.getPath(), top.getPath() + "/link");
+
+ LocalFileSystem lfs = LocalFileSystem.getInstance();
+ VirtualFile vTop = lfs.refreshAndFindFileByIoFile(top);
+ assertNotNull(vTop);
+ assertTrue(vTop.isValid());
+ VirtualFile vTarget = lfs.refreshAndFindFileByIoFile(target);
+ assertNotNull(vTarget);
+ assertTrue(vTarget.isValid());
+ VirtualFile vLink = lfs.refreshAndFindFileByIoFile(link);
+ assertNotNull(vLink);
+ assertTrue(vLink.isValid());
+ assertTrue(vLink.isDirectory());
+
+ FileUtil.delete(target);
+ vTop.refresh(false, true);
+ assertFalse(vTarget.isValid());
+ assertFalse(vLink.isValid());
+ vLink = lfs.refreshAndFindFileByIoFile(link);
+ assertNotNull(vLink);
+ assertTrue(vLink.isValid());
+ assertFalse(vLink.isDirectory());
+
+ FileUtil.createDirectory(target);
+ vTop.refresh(false, true);
+ assertFalse(vLink.isValid());
+ vLink = lfs.refreshAndFindFileByIoFile(link);
+ assertNotNull(vLink);
+ assertTrue(vLink.isValid());
+ assertTrue(vLink.isDirectory());
+ }
}
diff --git a/platform/projectModel-api/src/com/intellij/openapi/roots/OrderEnumerator.java b/platform/projectModel-api/src/com/intellij/openapi/roots/OrderEnumerator.java
index 181c2a0..60d8b59 100644
--- a/platform/projectModel-api/src/com/intellij/openapi/roots/OrderEnumerator.java
+++ b/platform/projectModel-api/src/com/intellij/openapi/roots/OrderEnumerator.java
@@ -25,6 +25,8 @@
import com.intellij.util.Processor;
import org.jetbrains.annotations.NotNull;
+import java.util.Collection;
+
/**
* Interface for convenient processing dependencies of a module or a project. Allows to process {@link OrderEntry}s and collect classes
* and source roots.<p>
diff --git a/platform/projectModel-api/src/com/intellij/openapi/roots/SourceFolder.java b/platform/projectModel-api/src/com/intellij/openapi/roots/SourceFolder.java
index 6dd2db4..a8388a9 100644
--- a/platform/projectModel-api/src/com/intellij/openapi/roots/SourceFolder.java
+++ b/platform/projectModel-api/src/com/intellij/openapi/roots/SourceFolder.java
@@ -16,6 +16,7 @@
package com.intellij.openapi.roots;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.jps.model.module.JpsModuleSourceRoot;
import org.jetbrains.jps.model.module.JpsModuleSourceRootType;
/**
@@ -49,4 +50,7 @@
@NotNull
JpsModuleSourceRootType<?> getRootType();
+
+ @NotNull
+ JpsModuleSourceRoot getJpsElement();
}
diff --git a/platform/projectModel-impl/src/com/intellij/openapi/module/impl/ModuleManagerImpl.java b/platform/projectModel-impl/src/com/intellij/openapi/module/impl/ModuleManagerImpl.java
index c1e860c..c8ac87e 100644
--- a/platform/projectModel-impl/src/com/intellij/openapi/module/impl/ModuleManagerImpl.java
+++ b/platform/projectModel-impl/src/com/intellij/openapi/module/impl/ModuleManagerImpl.java
@@ -253,9 +253,13 @@
final List<Module> modulesWithUnknownTypes = new ArrayList<Module>();
List<ModuleLoadingErrorDescription> errors = new ArrayList<ModuleLoadingErrorDescription>();
- for (final ModulePath modulePath : myModulePaths) {
+ for (int i = 0; i < myModulePaths.size(); i++) {
+ ModulePath modulePath = myModulePaths.get(i);
+ if (progressIndicator != null) {
+ progressIndicator.setFraction((double) i / myModulePaths.size());
+ }
try {
- final Module module = moduleModel.loadModuleInternal(modulePath.getPath(), progressIndicator);
+ final Module module = moduleModel.loadModuleInternal(modulePath.getPath());
if (isUnknownModuleType(module)) {
modulesWithUnknownTypes.add(module);
}
@@ -283,6 +287,10 @@
fireErrors(errors);
showUnknownModuleTypeNotification(modulesWithUnknownTypes);
+
+ if (progressIndicator != null) {
+ progressIndicator.setIndeterminate(true);
+ }
}
protected boolean isUnknownModuleType(Module module) {
@@ -732,14 +740,14 @@
public Module loadModule(@NotNull String filePath) throws InvalidDataException, IOException, ModuleWithNameAlreadyExists {
assertWritable();
try {
- return loadModuleInternal(filePath, null);
+ return loadModuleInternal(filePath);
}
catch (StateStorageException e) {
throw new IOException(ProjectBundle.message("module.corrupted.file.error", FileUtil.toSystemDependentName(filePath), e.getMessage()));
}
}
- private Module loadModuleInternal(String filePath, @Nullable ProgressIndicator progressIndicator)
+ private Module loadModuleInternal(String filePath)
throws ModuleWithNameAlreadyExists, IOException, StateStorageException {
final VirtualFile moduleFile = StandardFileSystems.local().findFileByPath(resolveShortWindowsName(filePath));
@@ -748,9 +756,6 @@
}
final String name = moduleFile.getName();
- if (progressIndicator != null) {
- progressIndicator.setText2(FileUtil.getNameWithoutExtension(name));
- }
if (name.endsWith(IML_EXTENSION)) {
final String moduleName = name.substring(0, name.length() - 4);
diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ContentEntryImpl.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ContentEntryImpl.java
index 6d28374..26e311c 100644
--- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ContentEntryImpl.java
+++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ContentEntryImpl.java
@@ -366,7 +366,7 @@
element.setAttribute(URL_ATTRIBUTE, myRoot.getUrl());
for (final SourceFolder sourceFolder : mySourceFolders) {
if (sourceFolder instanceof SourceFolderImpl) {
- JpsModuleRootModelSerializer.saveSourceRoot(element, sourceFolder.getUrl(), ((SourceFolderImpl)sourceFolder).getJpsElement().asTyped());
+ JpsModuleRootModelSerializer.saveSourceRoot(element, sourceFolder.getUrl(), sourceFolder.getJpsElement().asTyped());
}
}
diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/PushedFilePropertiesUpdater.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/PushedFilePropertiesUpdater.java
index 29d7427..c223636 100644
--- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/PushedFilePropertiesUpdater.java
+++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/PushedFilePropertiesUpdater.java
@@ -150,6 +150,7 @@
public void pushAll(final FilePropertyPusher... pushers) {
ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
if (indicator != null) {
+ indicator.pushState();
indicator.setText("Updating file properties...");
}
Module[] modules = ModuleManager.getInstance(myProject).getModules();
@@ -175,7 +176,7 @@
}
}
if (indicator != null) {
- indicator.setText("");
+ indicator.popState();
}
}
diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/SourceFolderImpl.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/SourceFolderImpl.java
index 4f08870..4f153d3 100644
--- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/SourceFolderImpl.java
+++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/SourceFolderImpl.java
@@ -27,6 +27,7 @@
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.JpsElement;
import org.jetbrains.jps.model.JpsElementFactory;
+import org.jetbrains.jps.model.java.JavaModuleSourceRootTypes;
import org.jetbrains.jps.model.java.JavaResourceRootType;
import org.jetbrains.jps.model.java.JavaSourceRootProperties;
import org.jetbrains.jps.model.java.JavaSourceRootType;
@@ -82,13 +83,7 @@
@Nullable
private JavaSourceRootProperties getJavaProperties() {
- if (myJpsElement.getRootType() == JavaSourceRootType.SOURCE) {
- return myJpsElement.getProperties(JavaSourceRootType.SOURCE);
- }
- if (myJpsElement.getRootType() == JavaSourceRootType.TEST_SOURCE) {
- return myJpsElement.getProperties(JavaSourceRootType.TEST_SOURCE);
- }
- return null;
+ return myJpsElement.getProperties(JavaModuleSourceRootTypes.SOURCES);
}
@Override
@@ -112,6 +107,7 @@
return new SourceFolderImpl(this, (ContentEntryImpl)contentEntry);
}
+ @NotNull
public JpsModuleSourceRoot getJpsElement() {
return myJpsElement;
}
diff --git a/platform/projectModel-impl/src/com/intellij/project/model/impl/module/content/JpsSourceFolder.java b/platform/projectModel-impl/src/com/intellij/project/model/impl/module/content/JpsSourceFolder.java
index 2616121..3eb43fd 100644
--- a/platform/projectModel-impl/src/com/intellij/project/model/impl/module/content/JpsSourceFolder.java
+++ b/platform/projectModel-impl/src/com/intellij/project/model/impl/module/content/JpsSourceFolder.java
@@ -75,4 +75,10 @@
public JpsModuleSourceRootType<?> getRootType() {
return mySourceRoot.getRootType();
}
+
+ @NotNull
+ @Override
+ public JpsModuleSourceRoot getJpsElement() {
+ return mySourceRoot;
+ }
}
diff --git a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/annotation/AsyncCall.java b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/annotation/AsyncCall.java
index e310564..dd7a265 100644
--- a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/annotation/AsyncCall.java
+++ b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/annotation/AsyncCall.java
@@ -6,8 +6,7 @@
import java.lang.annotation.Target;
/**
- * Created by IntelliJ IDEA.
- * User: michael.golubev
+ * @author michael.golubev
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
diff --git a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudAgentConfigBase.java b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudAgentConfigBase.java
index dd0c2917..8cfa1e7 100644
--- a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudAgentConfigBase.java
+++ b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudAgentConfigBase.java
@@ -16,8 +16,7 @@
package com.intellij.remoteServer.agent.util;
/**
- * Created by IntelliJ IDEA.
- * User: michael.golubev
+ * @author michael.golubev
*/
public interface CloudAgentConfigBase extends CloudAgentConfig {
diff --git a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudAgentErrorHandler.java b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudAgentErrorHandler.java
index 24256bf..67d6382 100644
--- a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudAgentErrorHandler.java
+++ b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudAgentErrorHandler.java
@@ -16,8 +16,7 @@
package com.intellij.remoteServer.agent.util;
/**
- * Created by IntelliJ IDEA.
- * User: michael.golubev
+ * @author michael.golubev
*/
public interface CloudAgentErrorHandler {
diff --git a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudGitAgent.java b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudGitAgent.java
index fb07348..fae33cc 100644
--- a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudGitAgent.java
+++ b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudGitAgent.java
@@ -20,8 +20,7 @@
import com.intellij.remoteServer.agent.annotation.FinalCall;
/**
- * Created by IntelliJ IDEA.
- * User: michael.golubev
+ * @author michael.golubev
*/
public interface CloudGitAgent<C extends CloudAgentConfigBase, D extends CloudGitAgentDeployment> extends RemoteAgent {
diff --git a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudGitAgentDeployment.java b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudGitAgentDeployment.java
index c1a2610..d349b95 100644
--- a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudGitAgentDeployment.java
+++ b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudGitAgentDeployment.java
@@ -16,8 +16,7 @@
package com.intellij.remoteServer.agent.util;
/**
- * Created by IntelliJ IDEA.
- * User: michael.golubev
+ * @author michael.golubev
*/
public interface CloudGitAgentDeployment {
@@ -26,8 +25,4 @@
CloudGitApplication findApplication();
void deleteApplication();
-
- void startOrContinueListeningLog();
-
- void stopListeningLog();
}
diff --git a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudGitApplication.java b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudGitApplication.java
index 34a0dde..b9cdef5 100644
--- a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudGitApplication.java
+++ b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudGitApplication.java
@@ -16,8 +16,7 @@
package com.intellij.remoteServer.agent.util;
/**
- * Created by IntelliJ IDEA.
- * User: michael.golubev
+ * @author michael.golubev
*/
public interface CloudGitApplication {
diff --git a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudGitLoggingHandler.java b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudGitLoggingHandler.java
index d095b1a..7bf5ee1 100644
--- a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudGitLoggingHandler.java
+++ b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudGitLoggingHandler.java
@@ -18,8 +18,7 @@
import com.intellij.remoteServer.agent.util.log.LogListener;
/**
- * Created by IntelliJ IDEA.
- * User: michael.golubev
+ * @author michael.golubev
*/
public interface CloudGitLoggingHandler extends CloudAgentLoggingHandler, LogListener {
diff --git a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/DeploymentDataImpl.java b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/DeploymentDataImpl.java
index ed4077d..6b7ded3 100644
--- a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/DeploymentDataImpl.java
+++ b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/DeploymentDataImpl.java
@@ -16,8 +16,7 @@
package com.intellij.remoteServer.agent.util;
/**
- * Created by IntelliJ IDEA.
- * User: michael.golubev
+ * @author michael.golubev
*/
public class DeploymentDataImpl implements DeploymentData {
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/agent/impl/util/FinalTask.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/agent/impl/util/FinalTask.java
index 7d3ce82..bb193a4 100644
--- a/platform/remote-servers/impl/src/com/intellij/remoteServer/agent/impl/util/FinalTask.java
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/agent/impl/util/FinalTask.java
@@ -1,8 +1,7 @@
package com.intellij.remoteServer.agent.impl.util;
/**
- * Created by IntelliJ IDEA.
- * User: michael.golubev
+ * @author michael.golubev
*/
public interface FinalTask extends Runnable {
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/agent/impl/util/SequentialTaskExecutor.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/agent/impl/util/SequentialTaskExecutor.java
index fa9c320..eb96025 100644
--- a/platform/remote-servers/impl/src/com/intellij/remoteServer/agent/impl/util/SequentialTaskExecutor.java
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/agent/impl/util/SequentialTaskExecutor.java
@@ -10,8 +10,7 @@
import java.util.concurrent.LinkedBlockingQueue;
/**
- * Created by IntelliJ IDEA.
- * User: michael.golubev
+ * @author michael.golubev
*/
public class SequentialTaskExecutor {
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/agent/impl/util/UrlCollector.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/agent/impl/util/UrlCollector.java
index 21e9f8c..bf3a6e8 100644
--- a/platform/remote-servers/impl/src/com/intellij/remoteServer/agent/impl/util/UrlCollector.java
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/agent/impl/util/UrlCollector.java
@@ -10,8 +10,7 @@
import java.util.List;
/**
- * Created by IntelliJ IDEA.
- * User: michael.golubev
+ * @author michael.golubev
*/
public class UrlCollector {
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/configuration/deployment/DeployToServerConfigurationType.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/configuration/deployment/DeployToServerConfigurationType.java
index e1d78a6..27eabec 100644
--- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/configuration/deployment/DeployToServerConfigurationType.java
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/configuration/deployment/DeployToServerConfigurationType.java
@@ -65,6 +65,11 @@
}
@Override
+ public boolean isApplicable(@NotNull Project project) {
+ return !RemoteServersManager.getInstance().getServers(myServerType).isEmpty();
+ }
+
+ @Override
public void onNewConfigurationCreated(@NotNull RunConfiguration configuration) {
DeployToServerRunConfiguration<?,?> deployConfiguration = (DeployToServerRunConfiguration<?,?>)configuration;
if (deployConfiguration.getServerName() == null) {
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/clientLibrary/ClientLibraryManagerImpl.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/clientLibrary/ClientLibraryManagerImpl.java
index b9146ef..63bd558 100644
--- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/clientLibrary/ClientLibraryManagerImpl.java
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/clientLibrary/ClientLibraryManagerImpl.java
@@ -2,17 +2,13 @@
import com.intellij.execution.configurations.RuntimeConfigurationError;
import com.intellij.openapi.Disposable;
-import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.openapi.components.StoragePathMacros;
import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.progress.PerformInBackgroundOption;
-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.Pair;
import com.intellij.openapi.util.Ref;
@@ -20,11 +16,7 @@
import com.intellij.remoteServer.runtime.clientLibrary.ClientLibraryDescription;
import com.intellij.remoteServer.runtime.clientLibrary.ClientLibraryManager;
import com.intellij.util.EventDispatcher;
-import com.intellij.util.concurrency.Semaphore;
-import com.intellij.util.download.DownloadableFileDescription;
-import com.intellij.util.download.DownloadableFileService;
-import com.intellij.util.download.DownloadableFileSetDescription;
-import com.intellij.util.download.DownloadableFileSetVersions;
+import com.intellij.util.download.*;
import com.intellij.util.xmlb.annotations.AbstractCollection;
import com.intellij.util.xmlb.annotations.Attribute;
import com.intellij.util.xmlb.annotations.Property;
@@ -39,8 +31,7 @@
import java.util.*;
/**
- * Created by IntelliJ IDEA.
- * User: michael.golubev
+ * @author michael.golubev
*/
@State(
name = "RemoteServerClientLibraries",
@@ -163,71 +154,23 @@
final DownloadableFileService downloadService = DownloadableFileService.getInstance();
- final Ref<DownloadableFileSetDescription> descriptionRef = new Ref<DownloadableFileSetDescription>();
URL versionsUrl = libraryDescription.getDescriptionUrl();
final DownloadableFileSetVersions<DownloadableFileSetDescription> versions = downloadService.createFileSetVersions(null, versionsUrl);
- final Semaphore semaphore = new Semaphore();
- semaphore.down();
- versions.fetchVersions(new DownloadableFileSetVersions.FileSetVersionsCallback<DownloadableFileSetDescription>() {
- @Override
- public void onSuccess(@NotNull List<? extends DownloadableFileSetDescription> versions) {
- if (!versions.isEmpty()) {
- descriptionRef.set(versions.get(0));
- }
- semaphore.up();
- }
-
- @Override
- public void onError(@NotNull String errorMessage) {
- LOG.error(errorMessage);
- semaphore.up();
- }
- });
- semaphore.waitFor();
-
- final DownloadableFileSetDescription description = descriptionRef.get();
- if (description == null) {
+ List<DownloadableFileSetDescription> descriptions = versions.fetchVersions();
+ if (descriptions.isEmpty()) {
throw new IOException("No client library versions loaded");
}
- final Ref<List<Pair<File,DownloadableFileDescription>>> downloaded = Ref.create(null);
- final Ref<IOException> exception = Ref.create(null);
- semaphore.down();
- ApplicationManager.getApplication().invokeLater(new Runnable() {
- @Override
- public void run() {
- new Task.Backgroundable(null, "Downloading Client Libraries", true, PerformInBackgroundOption.ALWAYS_BACKGROUND) {
- @Override
- public void run(@NotNull ProgressIndicator indicator) {
- try {
- downloaded.set(downloadService.createDownloader(description).download(getStoreDirectory(libraryDescription)));
- }
- catch (IOException e) {
- exception.set(e);
- }
- finally {
- semaphore.up();
- }
- }
- }.queue();
- }
- });
- semaphore.waitFor();
-
- if (!exception.isNull()) {
- throw exception.get();
- }
- if (downloaded.isNull()) {
- throw new IOException("Downloading client libraries cancelled");
- }
+ FileDownloader downloader = downloadService.createDownloader(descriptions.get(0));
+ List<Pair<File, DownloadableFileDescription>> downloaded = downloader.download(getStoreDirectory(libraryDescription));
List<File> files = myFiles.get(libraryDescription.getId());
if (files == null) {
files = new ArrayList<File>();
myFiles.put(libraryDescription.getId(), files);
}
- for (Pair<File, DownloadableFileDescription> pair : downloaded.get()) {
+ for (Pair<File, DownloadableFileDescription> pair : downloaded) {
files.add(pair.getFirst());
}
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/ServersToolWindow.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/ServersToolWindow.java
index 1d06345..283bbf8 100644
--- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/ServersToolWindow.java
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/ServersToolWindow.java
@@ -14,8 +14,7 @@
import org.jetbrains.annotations.NotNull;
/**
- * Created by IntelliJ IDEA.
- * User: michael.golubev
+ * @author michael.golubev
*/
public class ServersToolWindow {
public static final String ID = "Application Servers";
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/ServersToolWindowContent.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/ServersToolWindowContent.java
index 8f66be1..df64945 100644
--- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/ServersToolWindowContent.java
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/ServersToolWindowContent.java
@@ -44,8 +44,7 @@
import java.util.Set;
/**
- * Created by IntelliJ IDEA.
- * User: michael.golubev
+ * @author michael.golubev
*/
public class ServersToolWindowContent extends JPanel implements Disposable {
public static final DataKey<ServersToolWindowContent> KEY = DataKey.create("serversToolWindowContent");
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/ServersToolWindowOpener.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/ServersToolWindowOpener.java
index 9603e92..8c80cc4 100644
--- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/ServersToolWindowOpener.java
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/ServersToolWindowOpener.java
@@ -7,8 +7,7 @@
import org.jetbrains.annotations.NotNull;
/**
- * Created by IntelliJ IDEA.
- * User: michael.golubev
+ * @author michael.golubev
*/
public class ServersToolWindowOpener extends AbstractProjectComponent {
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/ServersTreeStructure.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/ServersTreeStructure.java
index a1eacbf..96cd0fa 100644
--- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/ServersTreeStructure.java
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/ServersTreeStructure.java
@@ -49,8 +49,7 @@
import java.util.*;
/**
- * Created by IntelliJ IDEA.
- * User: michael.golubev
+ * @author michael.golubev
*/
public class ServersTreeStructure extends AbstractTreeStructureBase {
// 1st level: servers (RunnerAndConfigurationSettings (has CommonStrategy (extends RunConfiguration)) or RemoteServer)
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/TreeBuilderBase.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/TreeBuilderBase.java
index e3a75fa..c55ed78 100644
--- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/TreeBuilderBase.java
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/TreeBuilderBase.java
@@ -8,8 +8,7 @@
import javax.swing.tree.DefaultTreeModel;
/**
- * Created by IntelliJ IDEA.
- * User: michael.golubev
+ * @author michael.golubev
*/
public class TreeBuilderBase extends AbstractTreeBuilder {
public TreeBuilderBase(JTree tree, AbstractTreeStructureBase structure, DefaultTreeModel treeModel) {
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/DebugServerAction.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/DebugServerAction.java
index 7c7b8ea..f519478 100644
--- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/DebugServerAction.java
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/DebugServerAction.java
@@ -5,8 +5,7 @@
import com.intellij.icons.AllIcons;
/**
- * Created by IntelliJ IDEA.
- * User: michael.golubev
+ * @author michael.golubev
*/
public class DebugServerAction extends RunServerActionBase {
public DebugServerAction() {
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/DeployAction.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/DeployAction.java
index 75b697d..c6a3840 100644
--- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/DeployAction.java
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/DeployAction.java
@@ -12,8 +12,7 @@
import java.util.Set;
/**
- * Created by IntelliJ IDEA.
- * User: michael.golubev
+ * @author michael.golubev
*/
public class DeployAction extends ServersTreeActionBase {
public DeployAction() {
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/DeployAllAction.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/DeployAllAction.java
index ed3502d..818f0ad 100644
--- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/DeployAllAction.java
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/DeployAllAction.java
@@ -5,8 +5,7 @@
import org.jetbrains.annotations.NotNull;
/**
- * Created by IntelliJ IDEA.
- * User: michael.golubev
+ * @author michael.golubev
*/
public class DeployAllAction extends ServerActionBase {
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/EditConfigurationAction.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/EditConfigurationAction.java
index c488eb4..75d22a8 100644
--- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/EditConfigurationAction.java
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/EditConfigurationAction.java
@@ -10,8 +10,7 @@
import java.util.Set;
/**
- * Created by IntelliJ IDEA.
- * User: michael.golubev
+ * @author michael.golubev
*/
public class EditConfigurationAction extends ServersTreeActionBase {
public EditConfigurationAction() {
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/RunServerAction.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/RunServerAction.java
index fcb0b60..aa16c77 100644
--- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/RunServerAction.java
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/RunServerAction.java
@@ -5,8 +5,7 @@
import com.intellij.icons.AllIcons;
/**
- * Created by IntelliJ IDEA.
- * User: michael.golubev
+ * @author michael.golubev
*/
public class RunServerAction extends RunServerActionBase {
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/RunServerActionBase.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/RunServerActionBase.java
index f39e8c5..07b1e4b 100644
--- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/RunServerActionBase.java
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/RunServerActionBase.java
@@ -8,8 +8,7 @@
import javax.swing.*;
/**
- * Created by IntelliJ IDEA.
- * User: michael.golubev
+ * @author michael.golubev
*/
public abstract class RunServerActionBase extends ServerActionBase {
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/ServerActionBase.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/ServerActionBase.java
index 04d8456..1b4d4f8 100644
--- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/ServerActionBase.java
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/ServerActionBase.java
@@ -9,8 +9,7 @@
import java.util.Set;
/**
- * Created by IntelliJ IDEA.
- * User: michael.golubev
+ * @author michael.golubev
*/
public abstract class ServerActionBase extends ServersTreeActionBase {
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/ServersTreeActionBase.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/ServersTreeActionBase.java
index 8642331..7e505bd 100644
--- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/ServersTreeActionBase.java
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/ServersTreeActionBase.java
@@ -10,8 +10,7 @@
import javax.swing.*;
/**
- * Created by IntelliJ IDEA.
- * User: michael.golubev
+ * @author michael.golubev
*/
public abstract class ServersTreeActionBase extends AnAction {
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/SingleServerActionBase.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/SingleServerActionBase.java
index 16e96af..50ec636 100644
--- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/SingleServerActionBase.java
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/SingleServerActionBase.java
@@ -24,8 +24,7 @@
import java.util.Set;
/**
- * Created by IntelliJ IDEA.
- * User: michael.golubev
+ * @author michael.golubev
*/
public abstract class SingleServerActionBase extends ServersTreeActionBase {
protected SingleServerActionBase(String text, String description, Icon icon) {
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/StopServerAction.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/StopServerAction.java
index 66dcf87..7984c11 100644
--- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/StopServerAction.java
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/StopServerAction.java
@@ -5,8 +5,7 @@
import org.jetbrains.annotations.NotNull;
/**
- * Created by IntelliJ IDEA.
- * User: michael.golubev
+ * @author michael.golubev
*/
public class StopServerAction extends ServerActionBase {
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/UndeployAction.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/UndeployAction.java
index 94521be..bc11f8a 100644
--- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/UndeployAction.java
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/tree/actions/UndeployAction.java
@@ -9,8 +9,7 @@
import java.util.List;
/**
- * Created by IntelliJ IDEA.
- * User: michael.golubev
+ * @author michael.golubev
*/
public class UndeployAction extends DeploymentActionBase {
public UndeployAction() {
diff --git a/platform/remote-servers/util/src/com/intellij/remoteServer/util/AgentTaskExecutor.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/AgentTaskExecutor.java
similarity index 100%
rename from platform/remote-servers/util/src/com/intellij/remoteServer/util/AgentTaskExecutor.java
rename to platform/remote-servers/impl/src/com/intellij/remoteServer/util/AgentTaskExecutor.java
diff --git a/platform/remote-servers/util/src/com/intellij/remoteServer/util/CallbackWrapper.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CallbackWrapper.java
similarity index 100%
rename from platform/remote-servers/util/src/com/intellij/remoteServer/util/CallbackWrapper.java
rename to platform/remote-servers/impl/src/com/intellij/remoteServer/util/CallbackWrapper.java
diff --git a/platform/remote-servers/util/src/com/intellij/remoteServer/util/CloudConfigurableBase.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudConfigurableBase.java
similarity index 96%
rename from platform/remote-servers/util/src/com/intellij/remoteServer/util/CloudConfigurableBase.java
rename to platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudConfigurableBase.java
index c203769..4fb4bed0 100644
--- a/platform/remote-servers/util/src/com/intellij/remoteServer/util/CloudConfigurableBase.java
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudConfigurableBase.java
@@ -9,8 +9,7 @@
import javax.swing.*;
/**
- * Created by IntelliJ IDEA.
- * User: michael.golubev
+ * @author michael.golubev
*/
public abstract class CloudConfigurableBase<SC extends CloudConfigurationBase> implements UnnamedConfigurable {
diff --git a/platform/remote-servers/util/src/com/intellij/remoteServer/util/CloudConfigurationBase.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudConfigurationBase.java
similarity index 93%
rename from platform/remote-servers/util/src/com/intellij/remoteServer/util/CloudConfigurationBase.java
rename to platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudConfigurationBase.java
index 9088b37..4a95bf2 100644
--- a/platform/remote-servers/util/src/com/intellij/remoteServer/util/CloudConfigurationBase.java
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudConfigurationBase.java
@@ -5,8 +5,7 @@
import com.intellij.util.xmlb.annotations.Attribute;
/**
- * Created by IntelliJ IDEA.
- * User: michael.golubev
+ * @author michael.golubev
*/
public class CloudConfigurationBase<Self extends CloudConfigurationBase<Self>>
diff --git a/platform/remote-servers/util/src/com/intellij/remoteServer/util/CloudConnectionTask.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudConnectionTask.java
similarity index 100%
rename from platform/remote-servers/util/src/com/intellij/remoteServer/util/CloudConnectionTask.java
rename to platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudConnectionTask.java
diff --git a/platform/remote-servers/util/src/com/intellij/remoteServer/util/CloudDeploymentNameConfiguration.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudDeploymentNameConfiguration.java
similarity index 93%
rename from platform/remote-servers/util/src/com/intellij/remoteServer/util/CloudDeploymentNameConfiguration.java
rename to platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudDeploymentNameConfiguration.java
index e60244f..bf2e850 100644
--- a/platform/remote-servers/util/src/com/intellij/remoteServer/util/CloudDeploymentNameConfiguration.java
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudDeploymentNameConfiguration.java
@@ -3,8 +3,7 @@
import com.intellij.remoteServer.configuration.deployment.DeploymentConfigurationBase;
/**
- * Created by IntelliJ IDEA.
- * User: michael.golubev
+ * @author michael.golubev
*/
public class CloudDeploymentNameConfiguration<Self extends CloudDeploymentNameConfiguration<Self>>
diff --git a/platform/remote-servers/util/src/com/intellij/remoteServer/util/CloudDeploymentNameEditor.form b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudDeploymentNameEditor.form
similarity index 100%
rename from platform/remote-servers/util/src/com/intellij/remoteServer/util/CloudDeploymentNameEditor.form
rename to platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudDeploymentNameEditor.form
diff --git a/platform/remote-servers/util/src/com/intellij/remoteServer/util/CloudDeploymentNameEditor.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudDeploymentNameEditor.java
similarity index 97%
rename from platform/remote-servers/util/src/com/intellij/remoteServer/util/CloudDeploymentNameEditor.java
rename to platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudDeploymentNameEditor.java
index c6acd49..590e0f0 100644
--- a/platform/remote-servers/util/src/com/intellij/remoteServer/util/CloudDeploymentNameEditor.java
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudDeploymentNameEditor.java
@@ -25,8 +25,7 @@
import java.awt.event.ActionListener;
/**
- * Created by IntelliJ IDEA.
- * User: michael.golubev
+ * @author michael.golubev
*/
public class CloudDeploymentNameEditor<T extends DeploymentNameConfiguration> extends SettingsEditor<T> {
diff --git a/platform/remote-servers/util/src/com/intellij/remoteServer/util/CloudDeploymentNameProvider.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudDeploymentNameProvider.java
similarity index 100%
rename from platform/remote-servers/util/src/com/intellij/remoteServer/util/CloudDeploymentNameProvider.java
rename to platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudDeploymentNameProvider.java
diff --git a/platform/remote-servers/util/src/com/intellij/remoteServer/util/CloudServerRuntimeInstance.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudServerRuntimeInstance.java
similarity index 100%
rename from platform/remote-servers/util/src/com/intellij/remoteServer/util/CloudServerRuntimeInstance.java
rename to platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudServerRuntimeInstance.java
diff --git a/platform/remote-servers/util/src/com/intellij/remoteServer/util/DeploymentNameConfiguration.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/DeploymentNameConfiguration.java
similarity index 100%
rename from platform/remote-servers/util/src/com/intellij/remoteServer/util/DeploymentNameConfiguration.java
rename to platform/remote-servers/impl/src/com/intellij/remoteServer/util/DeploymentNameConfiguration.java
diff --git a/platform/remote-servers/util/src/com/intellij/remoteServer/util/ServerRuntimeException.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/ServerRuntimeException.java
similarity index 82%
rename from platform/remote-servers/util/src/com/intellij/remoteServer/util/ServerRuntimeException.java
rename to platform/remote-servers/impl/src/com/intellij/remoteServer/util/ServerRuntimeException.java
index 7c0e6a4..0984c49 100644
--- a/platform/remote-servers/util/src/com/intellij/remoteServer/util/ServerRuntimeException.java
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/ServerRuntimeException.java
@@ -1,8 +1,7 @@
package com.intellij.remoteServer.util;
/**
- * Created by IntelliJ IDEA.
- * User: michael.golubev
+ * @author michael.golubev
*/
public class ServerRuntimeException extends Exception {
diff --git a/platform/usageView/src/com/intellij/usages/UsageViewPresentation.java b/platform/usageView/src/com/intellij/usages/UsageViewPresentation.java
index b247e85..3467dcc 100644
--- a/platform/usageView/src/com/intellij/usages/UsageViewPresentation.java
+++ b/platform/usageView/src/com/intellij/usages/UsageViewPresentation.java
@@ -32,6 +32,7 @@
private String myTargetsNodeText = UsageViewBundle.message("node.targets"); // Default value. to be overwritten in most cases.
private String myNonCodeUsagesString = UsageViewBundle.message("node.non.code.usages");
private String myCodeUsagesString = UsageViewBundle.message("node.found.usages");
+ private String myUsagesInGeneratedCodeString = UsageViewBundle.message("node.usages.in.generated.code");
private boolean myShowReadOnlyStatusAsRed = false;
private boolean myShowCancelButton = false;
private boolean myOpenInNewTab = true;
@@ -176,6 +177,14 @@
return myDynamicCodeUsagesString;
}
+ public String getUsagesInGeneratedCodeString() {
+ return myUsagesInGeneratedCodeString;
+ }
+
+ public void setUsagesInGeneratedCodeString(String usagesInGeneratedCodeString) {
+ myUsagesInGeneratedCodeString = usagesInGeneratedCodeString;
+ }
+
public boolean isMergeDupLinesAvailable() {
return myMergeDupLinesAvailable;
}
diff --git a/platform/usageView/src/com/intellij/usages/impl/UsageGroupingRuleProviderImpl.java b/platform/usageView/src/com/intellij/usages/impl/UsageGroupingRuleProviderImpl.java
index 2cf99c1..4005567 100644
--- a/platform/usageView/src/com/intellij/usages/impl/UsageGroupingRuleProviderImpl.java
+++ b/platform/usageView/src/com/intellij/usages/impl/UsageGroupingRuleProviderImpl.java
@@ -42,7 +42,7 @@
@NotNull
public UsageGroupingRule[] getActiveRules(Project project) {
List<UsageGroupingRule> rules = new ArrayList<UsageGroupingRule>();
- rules.add(new NonCodeUsageGroupingRule());
+ rules.add(new NonCodeUsageGroupingRule(project));
if (UsageViewSettings.getInstance().GROUP_BY_SCOPE) {
rules.add(new UsageScopeGroupingRule());
}
@@ -164,7 +164,7 @@
private static class GroupByPackageAction extends RuleAction {
private GroupByPackageAction(UsageViewImpl view) {
- super(view, UsageViewBundle.message("action.group.by.package"), AllIcons.Actions.GroupByPackage);
+ super(view, DirectoryGroupingRule.getInstance(view.getProject()).getActionTitle(), AllIcons.Actions.GroupByPackage);
}
@Override
protected boolean getOptionValue() {
diff --git a/platform/usageView/src/com/intellij/usages/impl/UsagePreviewPanel.java b/platform/usageView/src/com/intellij/usages/impl/UsagePreviewPanel.java
index f2ce668..a9f4831 100644
--- a/platform/usageView/src/com/intellij/usages/impl/UsagePreviewPanel.java
+++ b/platform/usageView/src/com/intellij/usages/impl/UsagePreviewPanel.java
@@ -189,7 +189,7 @@
if (infos == null) {
releaseEditor();
removeAll();
- JComponent titleComp = new JLabel(UsageViewBundle.message("select.the.usage.to.preview"));
+ JComponent titleComp = new JLabel(UsageViewBundle.message("select.the.usage.to.preview"), SwingConstants.CENTER);
add(titleComp, BorderLayout.CENTER);
revalidate();
}
diff --git a/platform/usageView/src/com/intellij/usages/impl/rules/DirectoryGroupingRule.java b/platform/usageView/src/com/intellij/usages/impl/rules/DirectoryGroupingRule.java
index 1aba86f..38081a2 100644
--- a/platform/usageView/src/com/intellij/usages/impl/rules/DirectoryGroupingRule.java
+++ b/platform/usageView/src/com/intellij/usages/impl/rules/DirectoryGroupingRule.java
@@ -16,11 +16,15 @@
package com.intellij.usages.impl.rules;
import com.intellij.injected.editor.VirtualFileWindow;
-import com.intellij.openapi.actionSystem.*;
+import com.intellij.openapi.actionSystem.CommonDataKeys;
+import com.intellij.openapi.actionSystem.DataKey;
+import com.intellij.openapi.actionSystem.DataSink;
+import com.intellij.openapi.actionSystem.TypeSafeDataProvider;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.FileStatus;
import com.intellij.openapi.vcs.FileStatusManager;
+import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiManager;
@@ -34,6 +38,7 @@
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
+import java.io.File;
/**
* @author yole
@@ -71,6 +76,10 @@
return new DirectoryGroup(dir);
}
+ public String getActionTitle() {
+ return "Group by directory";
+ }
+
private class DirectoryGroup implements UsageGroup, TypeSafeDataProvider {
private final VirtualFile myDir;
@@ -90,7 +99,12 @@
@Override
@NotNull
public String getText(UsageView view) {
+ String relativePath = VfsUtilCore.getRelativePath(myDir, myProject.getBaseDir(), File.separatorChar);
+ if (relativePath != null) {
+ return relativePath;
+ }
String url = myDir.getPresentableUrl();
+
return url != null ? url : "<invalid>";
}
diff --git a/platform/usageView/src/com/intellij/usages/impl/rules/NonCodeUsageGroupingRule.java b/platform/usageView/src/com/intellij/usages/impl/rules/NonCodeUsageGroupingRule.java
index 08578c3..b6d6d46 100644
--- a/platform/usageView/src/com/intellij/usages/impl/rules/NonCodeUsageGroupingRule.java
+++ b/platform/usageView/src/com/intellij/usages/impl/rules/NonCodeUsageGroupingRule.java
@@ -15,7 +15,9 @@
*/
package com.intellij.usages.impl.rules;
-import com.intellij.openapi.vcs.FileStatus;
+import com.intellij.openapi.roots.GeneratedSourcesFilter;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.usageView.UsageInfo;
import com.intellij.usageView.UsageViewBundle;
import com.intellij.usages.Usage;
@@ -24,16 +26,23 @@
import com.intellij.usages.UsageView;
import com.intellij.usages.rules.PsiElementUsage;
import com.intellij.usages.rules.UsageGroupingRule;
+import com.intellij.usages.rules.UsageInFile;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
-import javax.swing.*;
-
/**
* @author max
*/
public class NonCodeUsageGroupingRule implements UsageGroupingRule {
- private static class CodeUsageGroup implements UsageGroup {
+ private final GeneratedSourcesFilter[] myGeneratedSourcesFilters;
+ private final Project myProject;
+
+ public NonCodeUsageGroupingRule(Project project) {
+ myProject = project;
+ myGeneratedSourcesFilters = GeneratedSourcesFilter.EP_NAME.getExtensions();
+ }
+
+ private static class CodeUsageGroup extends UsageGroupBase {
private static final UsageGroup INSTANCE = new CodeUsageGroup();
@Override
@@ -42,40 +51,40 @@
return view == null ? UsageViewBundle.message("node.group.code.usages") : view.getPresentation().getCodeUsagesString();
}
- @Override
- public void update() {
- }
-
public String toString() {
//noinspection HardCodedStringLiteral
return "CodeUsages";
}
@Override
- public Icon getIcon(boolean isOpen) { return null; }
- @Override
- public FileStatus getFileStatus() { return null; }
- @Override
- public boolean isValid() { return true; }
- @Override
public int compareTo(@NotNull UsageGroup usageGroup) {
if (usageGroup instanceof DynamicUsageGroup) {
return -1;
}
return usageGroup == this ? 0 : 1;
}
- @Override
- public void navigate(boolean requestFocus) { }
- @Override
- public boolean canNavigate() { return false; }
+ }
+
+ private static class UsageInGeneratedCodeGroup extends UsageGroupBase {
+ public static final UsageGroup INSTANCE = new UsageInGeneratedCodeGroup();
@Override
- public boolean canNavigateToSource() {
- return canNavigate();
+ @NotNull
+ public String getText(UsageView view) {
+ return view == null ? UsageViewBundle.message("node.usages.in.generated.code") : view.getPresentation().getUsagesInGeneratedCodeString();
+ }
+
+ public String toString() {
+ return "UsagesInGeneratedCode";
+ }
+
+ @Override
+ public int compareTo(@NotNull UsageGroup usageGroup) {
+ return usageGroup == this ? 0 : -1;
}
}
- private static class NonCodeUsageGroup implements UsageGroup {
+ private static class NonCodeUsageGroup extends UsageGroupBase {
public static final UsageGroup INSTANCE = new NonCodeUsageGroup();
@Override
@@ -92,26 +101,10 @@
//noinspection HardCodedStringLiteral
return "NonCodeUsages";
}
- @Override
- public Icon getIcon(boolean isOpen) { return null; }
- @Override
- public FileStatus getFileStatus() { return null; }
- @Override
- public boolean isValid() { return true; }
- @Override
public int compareTo(@NotNull UsageGroup usageGroup) { return usageGroup == this ? 0 : -1; }
- @Override
- public void navigate(boolean requestFocus) { }
- @Override
- public boolean canNavigate() { return false; }
-
- @Override
- public boolean canNavigateToSource() {
- return canNavigate();
- }
}
- private static class DynamicUsageGroup implements UsageGroup {
+ private static class DynamicUsageGroup extends UsageGroupBase {
public static final UsageGroup INSTANCE = new DynamicUsageGroup();
@NonNls private static final String DYNAMIC_CAPTION = "Dynamic usages";
@@ -127,35 +120,25 @@
}
}
- @Override
- public void update() {
- }
-
public String toString() {
//noinspection HardCodedStringLiteral
return "DynamicUsages";
}
- @Override
- public Icon getIcon(boolean isOpen) { return null; }
- @Override
- public FileStatus getFileStatus() { return null; }
- @Override
- public boolean isValid() { return true; }
- @Override
public int compareTo(@NotNull UsageGroup usageGroup) { return usageGroup == this ? 0 : 1; }
- @Override
- public void navigate(boolean requestFocus) { }
- @Override
- public boolean canNavigate() { return false; }
-
- @Override
- public boolean canNavigateToSource() {
- return canNavigate();
- }
}
@Override
public UsageGroup groupUsage(@NotNull Usage usage) {
+ if (usage instanceof UsageInFile) {
+ VirtualFile file = ((UsageInFile)usage).getFile();
+ if (file != null) {
+ for (GeneratedSourcesFilter filter : myGeneratedSourcesFilters) {
+ if (filter.isGeneratedSource(file, myProject)) {
+ return UsageInGeneratedCodeGroup.INSTANCE;
+ }
+ }
+ }
+ }
if (usage instanceof PsiElementUsage) {
if (usage instanceof UsageInfo2UsageAdapter) {
final UsageInfo usageInfo = ((UsageInfo2UsageAdapter)usage).getUsageInfo();
diff --git a/platform/usageView/src/com/intellij/usages/impl/rules/UsageGroupBase.java b/platform/usageView/src/com/intellij/usages/impl/rules/UsageGroupBase.java
new file mode 100644
index 0000000..dbf213b
--- /dev/null
+++ b/platform/usageView/src/com/intellij/usages/impl/rules/UsageGroupBase.java
@@ -0,0 +1,46 @@
+package com.intellij.usages.impl.rules;
+
+import com.intellij.openapi.vcs.FileStatus;
+import com.intellij.usages.UsageGroup;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+
+/**
+ * @author nik
+ */
+public abstract class UsageGroupBase implements UsageGroup {
+ @Override
+ public void update() {
+ }
+
+ @Nullable
+ @Override
+ public FileStatus getFileStatus() {
+ return null;
+ }
+
+ @Override
+ public boolean isValid() {
+ return true;
+ }
+
+ @Override
+ public Icon getIcon(boolean isOpen) {
+ return null;
+ }
+
+ @Override
+ public void navigate(boolean focus) {
+ }
+
+ @Override
+ public boolean canNavigate() {
+ return false;
+ }
+
+ @Override
+ public boolean canNavigateToSource() {
+ return false;
+ }
+}
diff --git a/platform/util/src/com/intellij/icons/AllIcons.java b/platform/util/src/com/intellij/icons/AllIcons.java
index 099bb0c4..ce668f4 100644
--- a/platform/util/src/com/intellij/icons/AllIcons.java
+++ b/platform/util/src/com/intellij/icons/AllIcons.java
@@ -972,7 +972,9 @@
public static final Icon Bea = IconLoader.getIcon("/providers/bea.png"); // 16x16
public static final Icon Cvs = IconLoader.getIcon("/providers/cvs.png"); // 16x16
public static final Icon Eclipse = IconLoader.getIcon("/providers/eclipse.png"); // 16x16
+ public static final Icon H2 = IconLoader.getIcon("/providers/h2.png"); // 16x16
public static final Icon Hibernate = IconLoader.getIcon("/providers/hibernate.png"); // 16x16
+ public static final Icon Hsqldb = IconLoader.getIcon("/providers/hsqldb.png"); // 16x16
public static final Icon Ibm = IconLoader.getIcon("/providers/ibm.png"); // 16x16
public static final Icon Microsoft = IconLoader.getIcon("/providers/microsoft.png"); // 16x16
public static final Icon Mysql = IconLoader.getIcon("/providers/mysql.png"); // 16x16
@@ -980,6 +982,7 @@
public static final Icon Postgresql = IconLoader.getIcon("/providers/postgresql.png"); // 16x16
public static final Icon Sqlite = IconLoader.getIcon("/providers/sqlite.png"); // 16x16
public static final Icon Sun = IconLoader.getIcon("/providers/sun.png"); // 16x16
+ public static final Icon Sybase = IconLoader.getIcon("/providers/sybase.png"); // 16x16
}
diff --git a/platform/util/src/com/intellij/openapi/util/Key.java b/platform/util/src/com/intellij/openapi/util/Key.java
index 7dc881b..949cb3e 100644
--- a/platform/util/src/com/intellij/openapi/util/Key.java
+++ b/platform/util/src/com/intellij/openapi/util/Key.java
@@ -34,7 +34,7 @@
public class Key<T> {
private static final AtomicInteger ourKeysCounter = new AtomicInteger();
private final int myIndex = ourKeysCounter.getAndIncrement();
- private final String myName;
+ private final String myName; // for debug purposes only
private static final ConcurrentWeakValueIntObjectHashMap<Key> allKeys = new ConcurrentWeakValueIntObjectHashMap<Key>();
public Key(@NotNull @NonNls String name) {
@@ -102,8 +102,11 @@
return (Key<T>)allKeys.get(index);
}
+ /**
+ * @deprecated access to Key via its name is a kind of hack, use Key instance directly instead
+ */
@Nullable
- public static <T> Key<T> findKeyByName(String name) {
+ public static Key<?> findKeyByName(String name) {
for (StripedLockIntObjectConcurrentHashMap.IntEntry<Key> key : allKeys.entries()) {
if (name.equals(key.getValue().myName)) {
//noinspection unchecked
diff --git a/platform/util/src/com/intellij/openapi/util/io/FileUtil.java b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java
index 662377b..bec9784 100644
--- a/platform/util/src/com/intellij/openapi/util/io/FileUtil.java
+++ b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java
@@ -1215,7 +1215,8 @@
return path;
}
- public static String expandUserHome(String path) {
+ @NotNull
+ public static String expandUserHome(@NotNull String path) {
if (path.startsWith("~/") || path.startsWith("~\\")) {
path = SystemProperties.getUserHome() + path.substring(1);
}
diff --git a/platform/util/src/com/intellij/util/containers/Interner.java b/platform/util/src/com/intellij/util/containers/Interner.java
index 690657e..cfeed0e 100644
--- a/platform/util/src/com/intellij/util/containers/Interner.java
+++ b/platform/util/src/com/intellij/util/containers/Interner.java
@@ -17,6 +17,8 @@
import org.jetbrains.annotations.NotNull;
+import java.util.Set;
+
public class Interner<T> {
private final OpenTHashSet<T> mySet = new OpenTHashSet<T>();
@@ -38,4 +40,9 @@
mySet.clear();
}
+ @NotNull
+ public Set<T> getValues() {
+ return mySet;
+ }
+
}
diff --git a/platform/util/src/com/intellij/util/containers/SLRUMap.java b/platform/util/src/com/intellij/util/containers/SLRUMap.java
index ea0eec4..3d66f95 100644
--- a/platform/util/src/com/intellij/util/containers/SLRUMap.java
+++ b/platform/util/src/com/intellij/util/containers/SLRUMap.java
@@ -48,7 +48,7 @@
myProtectedQueueSize = protectedQueueSize * FACTOR;
myProbationalQueueSize = probationalQueueSize * FACTOR;
- myProtectedQueue = new LinkedHashMap<K,V>(10, 0.6f, hashingStrategy) {
+ myProtectedQueue = new LinkedHashMap<K,V>(10, 0.6f, hashingStrategy, true) {
@Override
protected boolean removeEldestEntry(Map.Entry<K, V> eldest, K key, V value) {
if (size() > myProtectedQueueSize) {
@@ -60,7 +60,7 @@
}
};
- myProbationalQueue = new LinkedHashMap<K,V>(10, 0.6f, hashingStrategy) {
+ myProbationalQueue = new LinkedHashMap<K,V>(10, 0.6f, hashingStrategy, true) {
@Override
protected boolean removeEldestEntry(final Map.Entry<K, V> eldest, K key, V value) {
if (size() > myProbationalQueueSize) {
diff --git a/platform/util/src/com/intellij/util/containers/hash/LinkedHashMap.java b/platform/util/src/com/intellij/util/containers/hash/LinkedHashMap.java
index 1228c00..d50bc4e 100644
--- a/platform/util/src/com/intellij/util/containers/hash/LinkedHashMap.java
+++ b/platform/util/src/com/intellij/util/containers/hash/LinkedHashMap.java
@@ -29,7 +29,7 @@
private int size;
private final float loadFactor;
private final EqualityPolicy<K> hashingStrategy;
-
+ private final boolean accessOrder;
public LinkedHashMap() {
this(0);
@@ -38,19 +38,30 @@
public LinkedHashMap(int capacity) {
this(capacity, HashUtil.DEFAULT_LOAD_FACTOR);
}
+ public LinkedHashMap(int capacity, boolean accessOrder) {
+ this(capacity, HashUtil.DEFAULT_LOAD_FACTOR, accessOrder);
+ }
public LinkedHashMap(int capacity, float loadFactor) {
this(capacity, loadFactor, (EqualityPolicy)EqualityPolicy.CANONICAL);
}
+ public LinkedHashMap(int capacity, float loadFactor, boolean accessOrder) {
+ this(capacity, loadFactor, (EqualityPolicy)EqualityPolicy.CANONICAL, accessOrder);
+ }
+
public LinkedHashMap(EqualityPolicy hashingStrategy) {
this(0, HashUtil.DEFAULT_LOAD_FACTOR, hashingStrategy);
}
public LinkedHashMap(int capacity, float loadFactor, EqualityPolicy<K> hashingStrategy) {
+ this(capacity, loadFactor, hashingStrategy, false);
+ }
+ public LinkedHashMap(int capacity, float loadFactor, EqualityPolicy<K> hashingStrategy, boolean accessOrder) {
this.loadFactor = loadFactor;
this.hashingStrategy = hashingStrategy;
clear(capacity);
+ this.accessOrder = accessOrder;
}
@Override
@@ -200,7 +211,19 @@
size = 0;
}
+ public K getLastKey() {
+ return top != null ? top.key : null;
+ }
+
+ public V getLastValue() {
+ return top != null ? top.value : null;
+ }
+
private void moveToTop(final Entry<K, V> e) {
+ if (!accessOrder) {
+ return;
+ }
+
final Entry<K, V> top = this.top;
if (top != e) {
final Entry<K, V> prev = e.previous;
diff --git a/platform/util/src/com/intellij/util/io/PagePool.java b/platform/util/src/com/intellij/util/io/PagePool.java
index cb1054e..acb3a08 100644
--- a/platform/util/src/com/intellij/util/io/PagePool.java
+++ b/platform/util/src/com/intellij/util/io/PagePool.java
@@ -45,7 +45,7 @@
private PoolPageKey lastFinalizedKey = null;
public PagePool(final int protectedPagesLimit, final int probationalPagesLimit) {
- myProbationalQueue = new LinkedHashMap<PoolPageKey,Page>(probationalPagesLimit * 2, 0.6f) {
+ myProbationalQueue = new LinkedHashMap<PoolPageKey,Page>(probationalPagesLimit * 2, 0.6f, true) {
@Override
protected boolean removeEldestEntry(final Map.Entry<PoolPageKey, Page> eldest) {
if (size() > probationalPagesLimit) {
@@ -56,7 +56,7 @@
}
};
- myProtectedQueue = new LinkedHashMap<PoolPageKey, Page>(protectedPagesLimit, 0.6f) {
+ myProtectedQueue = new LinkedHashMap<PoolPageKey, Page>(protectedPagesLimit, 0.6f, true) {
@Override
protected boolean removeEldestEntry(final Map.Entry<PoolPageKey, Page> eldest) {
if (size() > protectedPagesLimit) {
diff --git a/platform/util/src/com/intellij/util/io/PagedFileStorage.java b/platform/util/src/com/intellij/util/io/PagedFileStorage.java
index 1c2f5cc..6c4c9a3 100644
--- a/platform/util/src/com/intellij/util/io/PagedFileStorage.java
+++ b/platform/util/src/com/intellij/util/io/PagedFileStorage.java
@@ -484,7 +484,7 @@
myDefaultStorageLockContext = new StorageLockContext(this, checkThreadAccess);
mySizeLimit = UPPER_LIMIT;
- mySegments = new LinkedHashMap<Integer, ByteBufferWrapper>(10, 0.75f) {
+ mySegments = new LinkedHashMap<Integer, ByteBufferWrapper>(10, 0.75f, true) {
@Override
protected boolean removeEldestEntry(Map.Entry<Integer, ByteBufferWrapper> eldest) {
return mySize > mySizeLimit;
diff --git a/platform/util/src/com/intellij/util/text/StringSearcher.java b/platform/util/src/com/intellij/util/text/StringSearcher.java
index f08c33d..22e9db2 100644
--- a/platform/util/src/com/intellij/util/text/StringSearcher.java
+++ b/platform/util/src/com/intellij/util/text/StringSearcher.java
@@ -86,9 +86,13 @@
}
public int scan(@NotNull CharSequence text, @Nullable char[] textArray, int _start, int _end) {
- LOG.assertTrue(_start <= _end, _start - _end);
+ if (_start > _end) {
+ throw new AssertionError("start > end, " + _start + ">" + _end);
+ }
final int textLength = text.length();
- LOG.assertTrue(_end <= textLength, textLength - _end);
+ if (_end > textLength) {
+ throw new AssertionError("end > length, " + _end + ">" + textLength);
+ }
if (myForwardDirection) {
if (myPatternLength == 1) {
// optimization
@@ -99,14 +103,14 @@
while (start <= end) {
int i = myPatternLength - 1;
- char lastChar = textArray != null ? textArray[start + i]:text.charAt(start + i);
+ char lastChar = textArray != null ? textArray[start + i] : text.charAt(start + i);
if (!myCaseSensitive) {
lastChar = StringUtil.toLowerCase(lastChar);
}
if (myPatternArray[i] == lastChar) {
i--;
while (i >= 0) {
- char c = textArray != null ? textArray[start + i]:text.charAt(start + i);
+ char c = textArray != null ? textArray[start + i] : text.charAt(start + i);
if (!myCaseSensitive) {
c = StringUtil.toLowerCase(c);
}
@@ -135,17 +139,17 @@
}
else {
int start = 1;
- int end = _end+1;
+ int end = _end + 1;
while (start <= end - myPatternLength + 1) {
int i = myPatternLength - 1;
- char lastChar = textArray != null ? textArray[end - (start + i)]:text.charAt(end - (start + i));
+ char lastChar = textArray != null ? textArray[end - (start + i)] : text.charAt(end - (start + i));
if (!myCaseSensitive) {
lastChar = StringUtil.toLowerCase(lastChar);
}
if (myPatternArray[myPatternLength - 1 - i] == lastChar) {
i--;
while (i >= 0) {
- char c = textArray != null ? textArray[end - (start + i)]:text.charAt(end - (start + i));
+ char c = textArray != null ? textArray[end - (start + i)] : text.charAt(end - (start + i));
if (!myCaseSensitive) {
c = StringUtil.toLowerCase(c);
}
@@ -170,7 +174,6 @@
}
return -1;
}
-
}
/**
diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java
index 6406e8f..c5c7a79 100644
--- a/platform/util/src/com/intellij/util/ui/UIUtil.java
+++ b/platform/util/src/com/intellij/util/ui/UIUtil.java
@@ -1285,6 +1285,13 @@
final Composite oldComposite = g.getComposite();
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f));
g.setPaint(getGradientPaint(startX, 2, c1, startX, height - 5, c2));
+
+ if (isRetina()) {
+ g.fillRoundRect(startX - 1, 3, endX - startX + 2, height - 5, 5, 5);
+ g.setComposite(oldComposite);
+ return;
+ }
+
g.fillRect(startX, 3, endX - startX, height - 5);
if (drawRound) {
@@ -2418,7 +2425,7 @@
final int bulletWidth = info.withBullet ? fm.stringWidth(" " + info.bulletChar) : 0;
maxBulletWidth[0] = Math.max(maxBulletWidth[0], bulletWidth);
- maxWidth[0] = Math.max(fm.stringWidth(pair.getFirst() + bulletWidth), maxWidth[0]);
+ maxWidth[0] = Math.max(fm.stringWidth(pair.getFirst().replace("<shortcut>", "").replace("</shortcut>", "") + bulletWidth), maxWidth[0]);
height[0] += (fm.getHeight() + fm.getLeading()) * myLineSpacing;
if (old != null) {
@@ -2437,6 +2444,12 @@
@Override
public boolean process(final Pair<String, LineInfo> pair) {
final LineInfo info = pair.getSecond();
+ String text = pair.first;
+ String shortcut = "";
+ if (pair.first.contains("<shortcut>")) {
+ shortcut = text.substring(text.indexOf("<shortcut>") + "<shortcut>".length(), text.indexOf("</shortcut>"));
+ text = text.substring(0, text.indexOf("<shortcut>"));
+ }
Font old = null;
if (info.smaller) {
@@ -2449,20 +2462,20 @@
final FontMetrics fm = g.getFontMetrics();
int xOffset = x;
if (info.center) {
- xOffset = x + (maxWidth[0] - fm.stringWidth(pair.getFirst())) / 2;
+ xOffset = x + (maxWidth[0] - fm.stringWidth(text)) / 2;
}
if (myDrawShadow) {
int xOff = isUnderDarcula() ? 1 : 0;
int yOff = 1;
- final Color oldColor = g.getColor();
+ Color oldColor = g.getColor();
g.setColor(myShadowColor);
if (info.withBullet) {
g.drawString(info.bulletChar + " ", x - fm.stringWidth(" " + info.bulletChar) + xOff, yOffset[0] + yOff);
}
- g.drawString(pair.getFirst(), xOffset + xOff, yOffset[0] + yOff);
+ g.drawString(text, xOffset + xOff, yOffset[0] + yOff);
g.setColor(oldColor);
}
@@ -2470,7 +2483,15 @@
g.drawString(info.bulletChar + " ", x - fm.stringWidth(" " + info.bulletChar), yOffset[0]);
}
- g.drawString(pair.getFirst(), xOffset, yOffset[0]);
+ g.drawString(text, xOffset, yOffset[0]);
+ if (!StringUtil.isEmpty(shortcut)) {
+ Color oldColor = g.getColor();
+ if (isUnderDarcula()) {
+ g.setColor(new Color(60, 118, 249));
+ }
+ g.drawString(shortcut, xOffset + fm.stringWidth(text + (isUnderDarcula() ? " " : "")), yOffset[0]);
+ g.setColor(oldColor);
+ }
if (info.underlined) {
Color c = null;
@@ -2482,6 +2503,7 @@
g.drawLine(x - maxBulletWidth[0] - 10, yOffset[0] + fm.getDescent(), x + maxWidth[0] + 10, yOffset[0] + fm.getDescent());
if (c != null) {
g.setColor(c);
+
}
if (myDrawShadow) {
diff --git a/platform/util/testSrc/com/intellij/util/containers/hash/LinkedHashMapTest.java b/platform/util/testSrc/com/intellij/util/containers/hash/LinkedHashMapTest.java
index b72d0b5..a1791cd 100644
--- a/platform/util/testSrc/com/intellij/util/containers/hash/LinkedHashMapTest.java
+++ b/platform/util/testSrc/com/intellij/util/containers/hash/LinkedHashMapTest.java
@@ -21,6 +21,10 @@
import java.util.Iterator;
import java.util.Map;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+
public class LinkedHashMapTest {
@Test
@@ -29,16 +33,16 @@
for (int i = 0; i < 1000; ++i) {
tested.put(i, Integer.toString(i));
}
- Assert.assertEquals(1000, tested.size());
+ assertEquals(1000, tested.size());
for (int i = 0; i < 1000; ++i) {
- Assert.assertEquals(Integer.toString(i), tested.get(i));
+ assertEquals(Integer.toString(i), tested.get(i));
}
for (int i = 0; i < 1000; ++i) {
- Assert.assertEquals(Integer.toString(i), tested.put(i, Integer.toString(i + 1)));
+ assertEquals(Integer.toString(i), tested.put(i, Integer.toString(i + 1)));
}
- Assert.assertEquals(1000, tested.size());
+ assertEquals(1000, tested.size());
for (int i = 0; i < 1000; ++i) {
- Assert.assertEquals(Integer.toString(i + 1), tested.get(i));
+ assertEquals(Integer.toString(i + 1), tested.get(i));
}
}
@@ -48,16 +52,16 @@
for (int i = 0; i < 1000; ++i) {
tested.put(i - 500, Integer.toString(i));
}
- Assert.assertEquals(1000, tested.size());
+ assertEquals(1000, tested.size());
for (int i = 0; i < 1000; ++i) {
- Assert.assertEquals(Integer.toString(i), tested.get(i - 500));
+ assertEquals(Integer.toString(i), tested.get(i - 500));
}
for (int i = 0; i < 1000; ++i) {
- Assert.assertEquals(Integer.toString(i), tested.put(i - 500, Integer.toString(i + 1)));
+ assertEquals(Integer.toString(i), tested.put(i - 500, Integer.toString(i + 1)));
}
- Assert.assertEquals(1000, tested.size());
+ assertEquals(1000, tested.size());
for (int i = 0; i < 1000; ++i) {
- Assert.assertEquals(Integer.toString(i + 1), tested.get(i - 500));
+ assertEquals(Integer.toString(i + 1), tested.get(i - 500));
}
}
@@ -67,13 +71,13 @@
for (int i = 0; i < 1000; ++i) {
tested.put(i, Integer.toString(i));
}
- Assert.assertEquals(1000, tested.size());
+ assertEquals(1000, tested.size());
for (int i = 0; i < 1000; i += 2) {
- Assert.assertEquals(Integer.toString(i), tested.remove(i));
+ assertEquals(Integer.toString(i), tested.remove(i));
}
- Assert.assertEquals(500, tested.size());
+ assertEquals(500, tested.size());
for (int i = 0; i < 1000; ++i) {
- Assert.assertEquals((i % 2 == 0) ? null : Integer.toString(i), tested.get(i));
+ assertEquals((i % 2 == 0) ? null : Integer.toString(i), tested.get(i));
}
}
@@ -85,7 +89,7 @@
}
int i = 10000;
for (Integer key : tested.keySet()) {
- Assert.assertEquals(--i, key.intValue());
+ assertEquals(--i, key.intValue());
}
}
@@ -103,11 +107,11 @@
}
}
- Assert.assertEquals(5000, tested.size());
+ assertEquals(5000, tested.size());
it = tested.keySet().iterator();
for (int i = 9999; i > 0; i -= 2) {
Assert.assertTrue(it.hasNext());
- Assert.assertEquals(i, it.next().intValue());
+ assertEquals(i, it.next().intValue());
}
}
@@ -122,20 +126,20 @@
for (int i = 0; i < 1000; ++i) {
tested.put(i, Integer.toString(i));
}
- Assert.assertEquals(500, tested.size());
+ assertEquals(500, tested.size());
for (int i = 0; i < 500; ++i) {
Assert.assertNull(tested.remove(i));
}
- Assert.assertEquals(500, tested.size());
+ assertEquals(500, tested.size());
for (int i = 500; i < 1000; ++i) {
- Assert.assertEquals(Integer.toString(i), tested.remove(i));
+ assertEquals(Integer.toString(i), tested.remove(i));
}
- Assert.assertEquals(0, tested.size());
+ assertEquals(0, tested.size());
}
@Test
public void lru2() {
- final LinkedHashMap<Integer, String> tested = new LinkedHashMap<Integer, String>() {
+ final LinkedHashMap<Integer, String> tested = new LinkedHashMap<Integer, String>(0, true) {
@Override
protected boolean removeEldestEntry(Map.Entry<Integer, String> eldest) {
return size() > 1000;
@@ -144,18 +148,18 @@
for (int i = 0; i < 1000; ++i) {
tested.put(i, Integer.toString(i));
}
- Assert.assertEquals(Integer.toString(0), tested.get(0));
+ assertEquals(Integer.toString(0), tested.get(0));
for (int i = 1000; i < 1999; ++i) {
tested.put(i, Integer.toString(i));
}
- Assert.assertEquals(Integer.toString(0), tested.get(0));
+ assertEquals(Integer.toString(0), tested.get(0));
tested.put(2000, Integer.toString(2000));
Assert.assertNull(tested.get(1000));
}
@Test
public void lru3() {
- final LinkedHashMap<Integer, String> tested = new LinkedHashMap<Integer, String>() {
+ final LinkedHashMap<Integer, String> tested = new LinkedHashMap<Integer, String>(0, true) {
@Override
protected boolean removeEldestEntry(Map.Entry<Integer, String> eldest) {
return size() > 1000;
@@ -164,15 +168,50 @@
for (int i = 0; i < 1000; ++i) {
tested.put(i, Integer.toString(i));
}
- Assert.assertEquals(Integer.toString(999), tested.remove(999));
- Assert.assertEquals(999, tested.size());
- Assert.assertEquals(Integer.toString(0), tested.get(0));
+ assertEquals(Integer.toString(999), tested.remove(999));
+ assertEquals(999, tested.size());
+ assertEquals(Integer.toString(0), tested.get(0));
for (int i = 1000; i < 1999; ++i) {
tested.put(i, Integer.toString(i));
}
- Assert.assertEquals(Integer.toString(0), tested.get(0));
+ assertEquals(Integer.toString(0), tested.get(0));
tested.put(2000, Integer.toString(2000));
- Assert.assertNull(tested.get(1000));
+ assertNull(tested.get(1000));
+ }
+
+ @Test
+ public void iteration() {
+ ///todo[nik] it iterates in reversed order, may be it is a bug?
+ Map<Integer, String> map = new LinkedHashMap<Integer, String>();
+ map.put(1, "a");
+ map.put(2, "b");
+ map.put(3, "c");
+ Iterator<String> iterator = map.values().iterator();
+ assertEquals("c", iterator.next());
+ assertEquals("b", iterator.next());
+ assertEquals("a", iterator.next());
+ assertFalse(iterator.hasNext());
+ }
+
+ @Test
+ public void lastAddedKey() {
+ LinkedHashMap<Integer, String> map = new LinkedHashMap<Integer, String>();
+ map.put(1, "a");
+ map.put(2, "b");
+ map.put(3, "c");
+ map.get(1);
+ map.get(2);
+ assertEquals(3, map.getLastKey().intValue());
+ assertEquals("c", map.getLastValue());
+ map.remove(2);
+ assertEquals(3, map.getLastKey().intValue());
+ assertEquals("c", map.getLastValue());
+ map.remove(3);
+ assertEquals(1, map.getLastKey().intValue());
+ assertEquals("a", map.getLastValue());
+ map.remove(1);
+ assertNull(map.getLastKey());
+ assertNull(map.getLastValue());
}
//@Test
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/issueLinks/AbstractBaseTagMouseListener.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/issueLinks/AbstractBaseTagMouseListener.java
index b8b105d..9df410d 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/issueLinks/AbstractBaseTagMouseListener.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/issueLinks/AbstractBaseTagMouseListener.java
@@ -42,7 +42,8 @@
}
@Nullable
- protected abstract Object getTagAt(final MouseEvent e);
+ public abstract Object getTagAt(final MouseEvent e);
+
public void mouseDragged(MouseEvent e) {
}
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/issueLinks/TableLinkMouseListener.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/issueLinks/TableLinkMouseListener.java
index 49ad6fb..4c88eb7 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/issueLinks/TableLinkMouseListener.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/issueLinks/TableLinkMouseListener.java
@@ -18,11 +18,9 @@
import com.intellij.ui.ColoredTableCellRenderer;
import com.intellij.ui.dualView.DualView;
import com.intellij.ui.dualView.TreeTableView;
-import com.intellij.util.containers.Convertor;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
-import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import java.awt.*;
import java.awt.event.MouseEvent;
@@ -32,7 +30,7 @@
*/
public class TableLinkMouseListener extends AbstractBaseTagMouseListener {
@Nullable
- protected Object getTagAt(final MouseEvent e) {
+ public Object getTagAt(final MouseEvent e) {
// TODO[yole]: don't update renderer on every event, like it's done in TreeLinkMouseListener
Object tag = null;
JTable table = (JTable)e.getSource();
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsDirectoryConfigurationPanel.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsDirectoryConfigurationPanel.java
index 9227682..4c5b10c 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsDirectoryConfigurationPanel.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsDirectoryConfigurationPanel.java
@@ -419,6 +419,9 @@
Collection<VcsRootError> myErrors = VcsRootErrorsFinder.getInstance(myProject).find();
for (final VcsRootError root : myErrors) {
+ if (!VcsRootError.Type.UNREGISTERED_ROOT.equals(root.getType())) {
+ continue;
+ }
final VcsKey vcsKey = root.getVcsKey();
final VcsDescriptor vcsDescriptor = myAllVcss.get(vcsKey.getName());
String displayVcsName = vcsDescriptor.getDisplayName();
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/roots/VcsRootErrorsFinder.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/roots/VcsRootErrorsFinder.java
index 8674333..0c5bcc5 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/roots/VcsRootErrorsFinder.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/roots/VcsRootErrorsFinder.java
@@ -33,7 +33,7 @@
Collection<VcsRoot> vcsRoots = new VcsRootDetector(myProject).detect().getRoots();
Collection<VcsRootError> errors = new ArrayList<VcsRootError>();
- errors.addAll(findExtraMappings(mappings, vcsRoots.isEmpty()));
+ errors.addAll(findExtraMappings(mappings));
errors.addAll(findUnregisteredRoots(mappings, vcsRoots));
return errors;
}
@@ -57,14 +57,14 @@
}
@NotNull
- private Collection<VcsRootError> findExtraMappings(@NotNull List<VcsDirectoryMapping> mappings, boolean isEmptyVcsRoots) {
+ private Collection<VcsRootError> findExtraMappings(@NotNull List<VcsDirectoryMapping> mappings) {
Collection<VcsRootError> errors = new ArrayList<VcsRootError>();
for (VcsDirectoryMapping mapping : mappings) {
if (!hasVcsChecker(mapping.getVcs())) {
continue;
}
if (mapping.isDefaultMapping()) {
- if (isEmptyVcsRoots) {
+ if (!isRoot(mapping)) {
errors.add(new VcsRootError(VcsRootError.Type.EXTRA_MAPPING, VcsDirectoryMapping.PROJECT_CONSTANT, mapping.getVcs()));
}
}
diff --git a/platform/vcs-impl/testSrc/com/intellij/openapi/vcs/roots/VcsRootDetectorTest.java b/platform/vcs-impl/testSrc/com/intellij/openapi/vcs/roots/VcsRootDetectorTest.java
index c24c9b9..75e1b30 100644
--- a/platform/vcs-impl/testSrc/com/intellij/openapi/vcs/roots/VcsRootDetectorTest.java
+++ b/platform/vcs-impl/testSrc/com/intellij/openapi/vcs/roots/VcsRootDetectorTest.java
@@ -36,25 +36,25 @@
/**
* @author Nadya Zabrodina
*/
-public class VcsRootDetectorTest extends VcsPlatformTest {
+public class VcsRootDetectorTest extends VcsRootPlatformTest {
public void testNoRootsInProject() throws IOException {
Map<String, Collection<String>> map = new HashMap<String, Collection<String>>();
- map.put("git", Collections.<String>emptyList());
+ map.put("mock", Collections.<String>emptyList());
map.put("content_roots", Collections.<String>emptyList());
doTest(map, null, Collections.<String>emptyList(), false, false);
}
- public void testProjectUnderSingleGit() throws IOException {
+ public void testProjectUnderSingleMockRoot() throws IOException {
Map<String, Collection<String>> map = new HashMap<String, Collection<String>>();
- map.put("git", Arrays.asList("."));
+ map.put("mock", Arrays.asList("."));
map.put("content_roots", Collections.<String>emptyList());
doTest(map, myProjectRoot, Arrays.asList("."), true, false);
}
- public void testProjectWithGitUnderIt() throws IOException {
+ public void testProjectWithMockRootUnderIt() throws IOException {
Map<String, Collection<String>> map = new HashMap<String, Collection<String>>();
- map.put("git", Arrays.asList("community"));
+ map.put("mock", Arrays.asList("community"));
map.put("content_roots", Collections.<String>emptyList());
cd(myProjectRoot);
mkdir("src");
@@ -62,10 +62,10 @@
doTest(map, myProjectRoot, Arrays.asList("community"), false, false);
}
- public void testProjectWithAllSubdirsUnderGitShouldStillBeNotFullyControlled() throws IOException {
+ public void testProjectWithAllSubdirsUnderMockRootShouldStillBeNotFullyControlled() throws IOException {
String[] dirNames = {".idea", "src", "community"};
Map<String, Collection<String>> map = new HashMap<String, Collection<String>>();
- map.put("git", Arrays.asList(dirNames));
+ map.put("mock", Arrays.asList(dirNames));
map.put("content_roots", Collections.<String>emptyList());
doTest(map, myProjectRoot, Arrays.asList(dirNames), false, false);
}
@@ -75,7 +75,7 @@
cd(myRepository);
mkdir(subdir);
Map<String, Collection<String>> map = new HashMap<String, Collection<String>>();
- map.put("git", Arrays.asList(myRepository.getName()));
+ map.put("mock", Arrays.asList(myRepository.getName()));
map.put("content_roots", Collections.<String>emptyList());
VirtualFile vfile = myRepository.findChild(subdir);
doTest(map, vfile, Arrays.asList(myRepository.getName()),
@@ -85,7 +85,7 @@
public void testIDEAProject() throws IOException {
String[] names = {"community", "contrib", "."};
Map<String, Collection<String>> map = new HashMap<String, Collection<String>>();
- map.put("git", Arrays.asList(names));
+ map.put("mock", Arrays.asList(names));
map.put("content_roots", Collections.<String>emptyList());
doTest(map, myProjectRoot, Arrays.asList(names), true, false);
}
@@ -93,7 +93,7 @@
public void testOneAboveAndOneUnder() throws IOException {
String[] names = {myRepository.getName() + "/community", "."};
Map<String, Collection<String>> map = new HashMap<String, Collection<String>>();
- map.put("git", Arrays.asList(names));
+ map.put("mock", Arrays.asList(names));
map.put("content_roots", Collections.<String>emptyList());
doTest(map, myRepository, Arrays.asList(names), true, true);
}
@@ -101,7 +101,7 @@
public void testOneAboveAndOneForProjectShouldShowOnlyProjectRoot() throws IOException {
String[] names = {myRepository.getName(), "."};
Map<String, Collection<String>> map = new HashMap<String, Collection<String>>();
- map.put("git", Arrays.asList(names));
+ map.put("mock", Arrays.asList(names));
map.put("content_roots", Collections.<String>emptyList());
doTest(map, myRepository, Arrays.asList(myRepository.getName()), true, false);
}
@@ -109,14 +109,14 @@
public void testOneAboveAndSeveralUnderProject() throws IOException {
String[] names = {".", myRepository.getName() + "/community", myRepository.getName() + "/contrib"};
Map<String, Collection<String>> map = new HashMap<String, Collection<String>>();
- map.put("git", Arrays.asList(names));
+ map.put("mock", Arrays.asList(names));
map.put("content_roots", Collections.<String>emptyList());
doTest(map, myRepository, Arrays.asList(names), true, true);
}
public void testMultipleAboveShouldBeDetectedAsOneAbove() throws IOException {
Map<String, Collection<String>> map = new HashMap<String, Collection<String>>();
- map.put("git", Arrays.asList(".", myRepository.getName()));
+ map.put("mock", Arrays.asList(".", myRepository.getName()));
map.put("content_roots", Collections.<String>emptyList());
String subdir = "insideRepo";
cd(myRepository);
@@ -127,7 +127,7 @@
public void testUnrelatedRootShouldNotBeDetected() throws IOException {
Map<String, Collection<String>> map = new HashMap<String, Collection<String>>();
- map.put("git", Arrays.asList("another"));
+ map.put("mock", Arrays.asList("another"));
map.put("content_roots", Collections.<String>emptyList());
doTest(map, myRepository, Collections.<String>emptyList(), false, false);
}
@@ -135,21 +135,21 @@
public void testLinkedSourceRootAloneShouldBeDetected() throws IOException {
Map<String, Collection<String>> map = new HashMap<String, Collection<String>>();
- map.put("git", Arrays.asList("linked_root"));
+ map.put("mock", Arrays.asList("linked_root"));
map.put("content_roots", Arrays.asList("linked_root"));
doTest(map, myRepository, Arrays.asList("linked_root"), false, false);
}
public void testLinkedSourceRootAndProjectRootShouldBeDetected() throws IOException {
Map<String, Collection<String>> map = new HashMap<String, Collection<String>>();
- map.put("git", Arrays.asList(".", "linked_root"));
+ map.put("mock", Arrays.asList(".", "linked_root"));
map.put("content_roots", Arrays.asList("linked_root"));
doTest(map, myProjectRoot, Arrays.asList(".", "linked_root"), true, false);
}
- public void testLinkedSourceBelowGit() throws IOException {
+ public void testLinkedSourceBelowMockRoot() throws IOException {
Map<String, Collection<String>> map = new HashMap<String, Collection<String>>();
- map.put("git", Arrays.asList(".", "linked_root"));
+ map.put("mock", Arrays.asList(".", "linked_root"));
map.put("content_roots", Arrays.asList("linked_root/src"));
doTest(map, myProjectRoot, Arrays.asList(".", "linked_root"), true, false);
}
@@ -157,7 +157,7 @@
// This is a test of performance optimization via limitation: don't scan deep though the whole VFS, i.e. don't detect deep roots
public void testDontScanDeeperThan2LevelsBelowAContentRoot() throws IOException {
Map<String, Collection<String>> map = new HashMap<String, Collection<String>>();
- map.put("git", Arrays.asList("community", "content_root/lev1/lev2", "content_root2/lev1/lev2/lev3"));
+ map.put("mock", Arrays.asList("community", "content_root/lev1/lev2", "content_root2/lev1/lev2/lev3"));
map.put("content_roots", Arrays.asList("content_root"));
doTest(map, myProjectRoot, Arrays.asList("community", "content_root/lev1/lev2"), false, false);
}
@@ -206,7 +206,7 @@
boolean expectedFull,
boolean expectedBelow)
throws IOException {
- initProject(map.get("git"), Collections.<String>emptyList(), map.get("content_roots"));
+ initProject(map.get("mock"), Collections.<String>emptyList(), map.get("content_roots"));
VcsRootDetectInfo info = detect(startDir);
assertRoots(expectedPaths, getPaths(info.getRoots()));
diff --git a/platform/vcs-impl/testSrc/com/intellij/openapi/vcs/roots/VcsRootErrorsFinderTest.java b/platform/vcs-impl/testSrc/com/intellij/openapi/vcs/roots/VcsRootErrorsFinderTest.java
index 9efe813..462186c 100644
--- a/platform/vcs-impl/testSrc/com/intellij/openapi/vcs/roots/VcsRootErrorsFinderTest.java
+++ b/platform/vcs-impl/testSrc/com/intellij/openapi/vcs/roots/VcsRootErrorsFinderTest.java
@@ -15,7 +15,6 @@
*/
package com.intellij.openapi.vcs.roots;
-import com.intellij.openapi.vcs.ProjectLevelVcsManager;
import com.intellij.openapi.vcs.VcsDirectoryMapping;
import com.intellij.openapi.vcs.VcsRootError;
import com.intellij.openapi.vcs.VcsTestUtil;
@@ -28,20 +27,18 @@
/**
* @author Nadya Zabrodina
*/
-public class VcsRootErrorsFinderTest extends VcsPlatformTest {
+public class VcsRootErrorsFinderTest extends VcsRootPlatformTest {
static final String PROJECT = VcsDirectoryMapping.PROJECT_CONSTANT;
- @NotNull private ProjectLevelVcsManager myVcsManager;
@Override
public void setUp() throws Exception {
super.setUp();
- myVcsManager = ProjectLevelVcsManager.getInstance(myProject);
}
public void testNoRootsThenNoErrors() throws IOException {
Map<String, Collection<String>> map = new HashMap<String, Collection<String>>();
- map.put("git", Collections.<String>emptyList());
+ map.put("mock", Collections.<String>emptyList());
map.put("roots", Collections.<String>emptyList());
map.put("content_roots", Collections.<String>emptyList());
doTest(map, Collections.<String, Collection<String>>emptyMap());
@@ -49,7 +46,7 @@
public void testSameOneRootInBothThenNoErrors() throws IOException {
Map<String, Collection<String>> map = new HashMap<String, Collection<String>>();
- map.put("git", Arrays.asList("."));
+ map.put("mock", Arrays.asList("."));
map.put("roots", Arrays.asList("."));
map.put("content_roots", Collections.<String>emptyList());
doTest(map, Collections.<String, Collection<String>>emptyMap());
@@ -57,15 +54,15 @@
public void testSameTwoRootsInBothThenNoErrors() throws IOException {
Map<String, Collection<String>> map = new HashMap<String, Collection<String>>();
- map.put("git", Arrays.asList(".", "community"));
+ map.put("mock", Arrays.asList(".", "community"));
map.put("roots", Arrays.asList(".", "community"));
map.put("content_roots", Collections.<String>emptyList());
doTest(map, Collections.<String, Collection<String>>emptyMap());
}
- public void testOneGitNoVCSRootsThenError() throws IOException {
+ public void testOneMockRootNoVCSRootsThenError() throws IOException {
Map<String, Collection<String>> map = new HashMap<String, Collection<String>>();
- map.put("git", Arrays.asList("."));
+ map.put("mock", Arrays.asList("."));
map.put("roots", Collections.<String>emptyList());
map.put("content_roots", Collections.<String>emptyList());
Map<String, Collection<String>> errorsMap = new HashMap<String, Collection<String>>();
@@ -73,10 +70,10 @@
doTest(map, errorsMap);
}
- public void testOneVCSRootNoGitsThenError() throws IOException {
+ public void testOneVCSRootNoMockRootsThenError() throws IOException {
Map<String, Collection<String>> map = new HashMap<String, Collection<String>>();
map.put("roots", Arrays.asList("."));
- map.put("git", Collections.<String>emptyList());
+ map.put("mock", Collections.<String>emptyList());
map.put("content_roots", Collections.<String>emptyList());
Map<String, Collection<String>> errorsMap = new HashMap<String, Collection<String>>();
errorsMap.put("extra", Arrays.asList("."));
@@ -85,7 +82,7 @@
public void testOneRootButDifferentThenTwoErrors() throws IOException {
Map<String, Collection<String>> map = new HashMap<String, Collection<String>>();
- map.put("git", Arrays.asList("."));
+ map.put("mock", Arrays.asList("."));
map.put("roots", Arrays.asList("community"));
map.put("content_roots", Collections.<String>emptyList());
Map<String, Collection<String>> errorsMap = new HashMap<String, Collection<String>>();
@@ -96,7 +93,7 @@
public void testTwoRootsOneMatchingOneDifferentThenTwoErrors() throws IOException {
Map<String, Collection<String>> map = new HashMap<String, Collection<String>>();
- map.put("git", Arrays.asList(".", "community"));
+ map.put("mock", Arrays.asList(".", "community"));
map.put("roots", Arrays.asList(".", "contrib"));
map.put("content_roots", Collections.<String>emptyList());
Map<String, Collection<String>> errorsMap = new HashMap<String, Collection<String>>();
@@ -105,9 +102,9 @@
doTest(map, errorsMap);
}
- public void testTwoRootsInGitOneMatchingInVCSThenError() throws IOException {
+ public void testTwoRootsInMockRootOneMatchingInVCSThenError() throws IOException {
Map<String, Collection<String>> map = new HashMap<String, Collection<String>>();
- map.put("git", Arrays.asList(".", "community"));
+ map.put("mock", Arrays.asList(".", "community"));
map.put("roots", Arrays.asList("."));
map.put("content_roots", Collections.<String>emptyList());
Map<String, Collection<String>> errorsMap = new HashMap<String, Collection<String>>();
@@ -117,7 +114,7 @@
public void testTwoRootsBothNotMatchingThenFourErrors() throws IOException {
Map<String, Collection<String>> map = new HashMap<String, Collection<String>>();
- map.put("git", Arrays.asList(".", "community"));
+ map.put("mock", Arrays.asList(".", "community"));
map.put("roots", Arrays.asList("another", "contrib"));
map.put("content_roots", Collections.<String>emptyList());
Map<String, Collection<String>> errorsMap = new HashMap<String, Collection<String>>();
@@ -126,9 +123,9 @@
doTest(map, errorsMap);
}
- public void testProjectRootNoGitsThenErrorAboutExtraRoot() throws IOException {
+ public void testProjectRootNoMockRootsThenErrorAboutExtraRoot() throws IOException {
Map<String, Collection<String>> map = new HashMap<String, Collection<String>>();
- map.put("git", Collections.<String>emptyList());
+ map.put("mock", Collections.<String>emptyList());
map.put("roots", Arrays.asList(PROJECT));
map.put("content_roots", Collections.<String>emptyList());
Map<String, Collection<String>> errorsMap = new HashMap<String, Collection<String>>();
@@ -136,40 +133,40 @@
doTest(map, errorsMap);
}
- public void testProjectRootFullUnderGitThenCorrect() throws IOException {
+ public void testProjectRootFullUnderMockRootThenCorrect() throws IOException {
Map<String, Collection<String>> map = new HashMap<String, Collection<String>>();
- map.put("git", Arrays.asList("."));
+ map.put("mock", Arrays.asList("."));
map.put("roots", Arrays.asList(".", PROJECT));
map.put("content_roots", Collections.<String>emptyList());
doTest(map, Collections.<String, Collection<String>>emptyMap());
}
- public void testProjectRootGitForAContentRootBelowProjectThenError() throws IOException {
+ public void testProjectRootMockRootForAContentRootBelowProjectThenError() throws IOException {
Map<String, Collection<String>> map = new HashMap<String, Collection<String>>();
- map.put("git", Arrays.asList("content_root"));
+ map.put("mock", Arrays.asList("content_root"));
map.put("roots", Arrays.asList(PROJECT));
map.put("content_roots", Arrays.asList("content_root"));
Map<String, Collection<String>> errorsMap = new HashMap<String, Collection<String>>();
errorsMap.put("unreg", Arrays.asList("content_root"));
+ errorsMap.put("extra", Arrays.asList(PROJECT));
doTest(map, errorsMap);
}
- public void testProjectRootGitBelowProjectFolderNotInAContentRootThenUnregisteredRootError() throws IOException {
- // this is to be fixed: auto-detection of Git repositories in subfolders for the <Project> mapping
+ public void testProjectRootMockRootBelowProjectFolderNotInAContentRootThenUnregisteredRootError() throws IOException {
+ // this is to be fixed: auto-detection of MockRoot repositories in subfolders for the <Project> mapping
Map<String, Collection<String>> map = new HashMap<String, Collection<String>>();
- map.put("git", Arrays.asList("community"));
+ map.put("mock", Arrays.asList("community"));
map.put("roots", Arrays.asList(PROJECT));
map.put("content_roots", Arrays.asList("."));
Map<String, Collection<String>> errorsMap = new HashMap<String, Collection<String>>();
errorsMap.put("unreg", Arrays.asList("community"));
+ errorsMap.put("extra", Arrays.asList(PROJECT));
doTest(map, errorsMap);
}
- public void testProjectRootGitForFullProjectContentRootLinkedSourceFolderBelowProjectThenErrors() throws IOException
-
- {
+ public void testProjectRootMockRootForFullProjectContentRootLinkedSourceFolderBelowProjectThenErrors() throws IOException {
Map<String, Collection<String>> map = new HashMap<String, Collection<String>>();
- map.put("git", Arrays.asList(".", "content_root", "../linked_source_root", "folder"));
+ map.put("mock", Arrays.asList(".", "content_root", "../linked_source_root", "folder"));
map.put("roots", Arrays.asList(PROJECT));
map.put("content_roots", Arrays.asList(".", "content_root", "../linked_source_root"));
Map<String, Collection<String>> errorsMap = new HashMap<String, Collection<String>>();
@@ -177,9 +174,9 @@
doTest(map, errorsMap);
}
- public void testProjectRootRootForFolderGitForFullProjectContentRootLinkedSourceFolderBelowProjectThenErrors() throws IOException {
+ public void testProjectRootForFolderMockRootForFullProjectContentRootLinkedSourceFolderBelowProjectThenErrors() throws IOException {
Map<String, Collection<String>> map = new HashMap<String, Collection<String>>();
- map.put("git", Arrays.asList(".", "content_root", "../linked_source_root", "folder"));
+ map.put("mock", Arrays.asList(".", "content_root", "../linked_source_root", "folder"));
map.put("roots", Arrays.asList(PROJECT, "folder"));
map.put("content_roots", Arrays.asList(".", "content_root", "../linked_source_root"));
Map<String, Collection<String>> errorsMap = new HashMap<String, Collection<String>>();
@@ -187,9 +184,9 @@
doTest(map, errorsMap);
}
- public void testProjectRootGitLikeInIDEAProjectThenError() throws IOException {
+ public void testProjectRootMockRootLikeInIDEAProjectThenError() throws IOException {
Map<String, Collection<String>> map = new HashMap<String, Collection<String>>();
- map.put("git", Arrays.asList(".", "community", "contrib"));
+ map.put("mock", Arrays.asList(".", "community", "contrib"));
map.put("roots", Arrays.asList(PROJECT));
map.put("content_roots", Arrays.asList(".", "community", "contrib"));
Map<String, Collection<String>> errorsMap = new HashMap<String, Collection<String>>();
@@ -197,10 +194,10 @@
doTest(map, errorsMap);
}
- public void testRealGitRootDeeperThanThreeLevelsShouldBeDetected() throws IOException {
+ public void testRealMockRootRootDeeperThanThreeLevelsShouldBeDetected() throws IOException {
Map<String, Collection<String>> map = new HashMap<String, Collection<String>>();
- map.put("git", Arrays.asList(".", "community", "contrib", "community/level1/level2/level3"));
+ map.put("mock", Arrays.asList(".", "community", "contrib", "community/level1/level2/level3"));
map.put("roots", Arrays.asList(PROJECT, "community/level1/level2/level3"));
map.put("content_roots", Arrays.asList(".", "community", "contrib"));
Map<String, Collection<String>> errorsMap = new HashMap<String, Collection<String>>();
@@ -209,7 +206,7 @@
}
private void doTest(@NotNull Map<String, Collection<String>> map, @NotNull Map<String, Collection<String>> errors) throws IOException {
- initProject(map.get("git"), Collections.<String>emptyList(), map.get("content_roots"));
+ initProject(map.get("mock"), Collections.<String>emptyList(), map.get("content_roots"));
addVcsRoots(map.get("roots"));
Collection<VcsRootError> expected = new ArrayList<VcsRootError>();
diff --git a/platform/vcs-impl/testSrc/com/intellij/openapi/vcs/roots/VcsPlatformTest.java b/platform/vcs-impl/testSrc/com/intellij/openapi/vcs/roots/VcsRootPlatformTest.java
similarity index 72%
rename from platform/vcs-impl/testSrc/com/intellij/openapi/vcs/roots/VcsPlatformTest.java
rename to platform/vcs-impl/testSrc/com/intellij/openapi/vcs/roots/VcsRootPlatformTest.java
index a12bf40..5bf8164 100644
--- a/platform/vcs-impl/testSrc/com/intellij/openapi/vcs/roots/VcsPlatformTest.java
+++ b/platform/vcs-impl/testSrc/com/intellij/openapi/vcs/roots/VcsRootPlatformTest.java
@@ -18,6 +18,8 @@
import com.intellij.ide.highlighter.ModuleFileType;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.application.WriteAction;
+import com.intellij.openapi.extensions.ExtensionPoint;
+import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.module.EmptyModuleType;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
@@ -27,6 +29,11 @@
import com.intellij.openapi.roots.impl.ModuleRootManagerImpl;
import com.intellij.openapi.roots.impl.RootModelImpl;
import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.openapi.vcs.ProjectLevelVcsManager;
+import com.intellij.openapi.vcs.VcsKey;
+import com.intellij.openapi.vcs.VcsRootChecker;
+import com.intellij.openapi.vcs.changes.committed.MockAbstractVcs;
+import com.intellij.openapi.vcs.impl.ProjectLevelVcsManagerImpl;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
@@ -35,32 +42,36 @@
import com.intellij.testFramework.fixtures.IdeaProjectTestFixture;
import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.HashSet;
-import static com.intellij.openapi.vcs.Executor.*;
+import static com.intellij.openapi.vcs.Executor.cd;
+import static com.intellij.openapi.vcs.Executor.mkdir;
/**
* @author Nadya Zabrodina
*/
-public abstract class VcsPlatformTest extends UsefulTestCase {
+public abstract class VcsRootPlatformTest extends UsefulTestCase {
+ private VcsRootChecker myExtension;
+ @NotNull protected ProjectLevelVcsManagerImpl myVcsManager;
+ @NotNull protected MockAbstractVcs myVcs;
+ @NotNull protected String myVcsName;
protected Project myProject;
protected VirtualFile myProjectRoot;
protected VirtualFile myRepository;
public static final String myRepositoryFolderName = "repository";
private RootModelImpl myRootModel;
protected static final Collection<File> myFilesToDelete = new HashSet<File>();
- protected final static String myVcsName = "Git"; //now scanner test executed only for git todo: create for all
-
protected IdeaProjectTestFixture myProjectFixture;
@SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors")
- protected VcsPlatformTest() {
+ protected VcsRootPlatformTest() {
PlatformTestCase.initPlatformLangPrefix();
}
@@ -78,10 +89,38 @@
myRootModel = ((ModuleRootManagerImpl)ModuleRootManager.getInstance(module)).getRootModel();
mkdir(myRepositoryFolderName);
myRepository = myProjectRoot.findChild(myRepositoryFolderName);
+ myVcs = new MockAbstractVcs(myProject);
+ myVcsManager = (ProjectLevelVcsManagerImpl)ProjectLevelVcsManager.getInstance(myProject);
+ ExtensionPoint<VcsRootChecker> point = getExtensionPoint();
+ myExtension = new VcsRootChecker() {
+ @Override
+ public VcsKey getSupportedVcs() {
+ return myVcs.getKeyInstanceMethod();
+ }
+
+ @Override
+ public boolean isRoot(@NotNull String path) {
+ return new File(path, ".mock").exists();
+ }
+
+ @Override
+ public boolean isVcsDir(@Nullable String path) {
+ return path != null && path.toLowerCase().endsWith(".mock");
+ }
+ };
+ point.registerExtension(myExtension);
+ myVcsManager.registerVcs(myVcs);
+ myVcsName = myVcs.getName();
+ }
+
+ private static ExtensionPoint<VcsRootChecker> getExtensionPoint() {
+ return Extensions.getRootArea().getExtensionPoint(VcsRootChecker.EXTENSION_POINT_NAME);
}
@Override
protected void tearDown() throws Exception {
+ getExtensionPoint().unregisterExtension(myExtension);
+ myVcsManager.unregisterVcs(myVcs);
for (File file : myFilesToDelete) {
delete(file);
}
@@ -97,16 +136,16 @@
}
/**
- * Creates the necessary temporary directories in the filesystem with empty ".git" directories for given roots.
+ * Creates the necessary temporary directories in the filesystem with empty ".mock" directories for given roots.
* And creates an instance of the project.
*
- * @param gitRoots path to actual .git roots, relative to the project dir.
+ * @param mockRoots path to actual .mock roots, relative to the project dir.
*/
- public void initProject(@NotNull Collection<String> gitRoots,
+ public void initProject(@NotNull Collection<String> mockRoots,
@NotNull Collection<String> projectStructure,
@NotNull Collection<String> contentRoots)
throws IOException {
- createDirs(gitRoots);
+ createDirs(mockRoots);
createProjectStructure(myProject, projectStructure);
createProjectStructure(myProject, contentRoots);
if (!contentRoots.isEmpty()) {
@@ -152,30 +191,23 @@
/**
* @return path to the project
*/
- private void createDirs(@NotNull Collection<String> gitRoots) throws IOException {
+ private void createDirs(@NotNull Collection<String> mockRoots) throws IOException {
File baseDir;
- if (gitRoots.isEmpty()) {
+ if (mockRoots.isEmpty()) {
return;
}
baseDir = VfsUtilCore.virtualToIoFile(myProject.getBaseDir());
- int maxDepth = findMaxDepthAboveProject(gitRoots);
+ int maxDepth = findMaxDepthAboveProject(mockRoots);
File projectDir = createChild(baseDir, maxDepth - 1);
cd(projectDir.getPath());
- for (String path : gitRoots) {
+ for (String path : mockRoots) {
File file = new File(projectDir, path);
file.mkdirs();
- File gitDir = new File(file, ".git");
- gitDir.mkdirs();
- myFilesToDelete.add(gitDir);
- gitDir.deleteOnExit();
- cd(gitDir.getPath());
- touch("HEAD", "ref: refs/heads/master");
- File head = new File(gitDir, "HEAD");
- myFilesToDelete.add(head);
- touch("config", "");
- File config = new File(gitDir, "config");
- myFilesToDelete.add(config);
+ File mockDir = new File(file, ".mock");
+ mockDir.mkdirs();
+ myFilesToDelete.add(mockDir);
+ mockDir.deleteOnExit();
}
}
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/VcsFullCommitDetails.java b/platform/vcs-log/api/src/com/intellij/vcs/log/VcsFullCommitDetails.java
index 8c3d87f..8382c40 100644
--- a/platform/vcs-log/api/src/com/intellij/vcs/log/VcsFullCommitDetails.java
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/VcsFullCommitDetails.java
@@ -25,13 +25,7 @@
Collection<Change> getChanges();
@NotNull
- String getAuthorEmail();
-
- @NotNull
- String getCommitterName();
-
- @NotNull
- String getCommitterEmail();
+ VcsUser getCommitter();
long getCommitTime();
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/VcsLog.java b/platform/vcs-log/api/src/com/intellij/vcs/log/VcsLog.java
index a90fad17..511854d 100644
--- a/platform/vcs-log/api/src/com/intellij/vcs/log/VcsLog.java
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/VcsLog.java
@@ -18,6 +18,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import java.awt.*;
import java.util.Collection;
import java.util.List;
@@ -54,4 +55,27 @@
@Nullable
Collection<String> getContainingBranches(@NotNull Hash commitHash);
+ /**
+ * Returns all {@link VcsRef commit references} available in the log.
+ */
+ @NotNull
+ Collection<VcsRef> getAllReferences();
+
+ /**
+ * Selects the commit node defined by the given reference (commit hash, branch or tag).
+ */
+ void jumpToReference(String reference);
+
+ /**
+ * Returns the VCS log toolbar component.
+ */
+ @NotNull
+ Component getToolbar();
+
+ /**
+ * Returns {@link VcsLogProvider VcsLogProviders} which are active in this log, i.e. which VCS roots are shown in the log.
+ */
+ @NotNull
+ Collection<VcsLogProvider> getLogProviders();
+
}
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/VcsLogObjectsFactory.java b/platform/vcs-log/api/src/com/intellij/vcs/log/VcsLogObjectsFactory.java
index debb813..89e73c1 100644
--- a/platform/vcs-log/api/src/com/intellij/vcs/log/VcsLogObjectsFactory.java
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/VcsLogObjectsFactory.java
@@ -24,7 +24,7 @@
@NotNull
VcsShortCommitDetails createShortDetails(@NotNull Hash hash, @NotNull List<Hash> parents, long timeStamp,
- VirtualFile root, @NotNull String subject, @NotNull String authorName);
+ VirtualFile root, @NotNull String subject, @NotNull String authorName, String authorEmail);
@NotNull
VcsFullCommitDetails createFullDetails(@NotNull Hash hash, @NotNull List<Hash> parents, long authorTime, VirtualFile root,
@@ -35,6 +35,9 @@
@NotNull ContentRevisionFactory contentRevisionFactory);
@NotNull
- VcsUser createUser(@NotNull String name);
+ VcsUser createUser(@NotNull String name, @NotNull String email);
+
+ @NotNull
+ VcsRef createRef(@NotNull Hash commitHash, @NotNull String name, @NotNull VcsRefType type, @NotNull VirtualFile root);
}
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/VcsLogProvider.java b/platform/vcs-log/api/src/com/intellij/vcs/log/VcsLogProvider.java
index af461a3..75460f6 100644
--- a/platform/vcs-log/api/src/com/intellij/vcs/log/VcsLogProvider.java
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/VcsLogProvider.java
@@ -3,6 +3,7 @@
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.VcsKey;
import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.util.Consumer;
import com.intellij.util.messages.MessageBus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -24,10 +25,11 @@
List<? extends VcsFullCommitDetails> readFirstBlock(@NotNull VirtualFile root, boolean ordered, int commitCount) throws VcsException;
/**
- * Reads the whole history, but only hashes & parents.
+ * <p>Reads the whole history, but only hashes & parents.</p>
+ * <p>Also reports authors/committers of this repository to the given user registry.</p>
*/
@NotNull
- List<TimedVcsCommit> readAllHashes(@NotNull VirtualFile root) throws VcsException;
+ List<TimedVcsCommit> readAllHashes(@NotNull VirtualFile root, @NotNull Consumer<VcsUser> userRegistry) throws VcsException;
/**
* Reads those details of the given commits, which are necessary to be shown in the log table.
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/VcsRef.java b/platform/vcs-log/api/src/com/intellij/vcs/log/VcsRef.java
index 95031ff..555b320 100644
--- a/platform/vcs-log/api/src/com/intellij/vcs/log/VcsRef.java
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/VcsRef.java
@@ -49,4 +49,6 @@
@NotNull
VirtualFile getRoot();
+ // TODO this is to be removed: temporary method to simplify Hash->int transition in Graph
+ int getCommitIndex();
}
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/VcsShortCommitDetails.java b/platform/vcs-log/api/src/com/intellij/vcs/log/VcsShortCommitDetails.java
index bf84291..59e33db 100644
--- a/platform/vcs-log/api/src/com/intellij/vcs/log/VcsShortCommitDetails.java
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/VcsShortCommitDetails.java
@@ -11,7 +11,7 @@
* <p>These details will be displayed in the log table.</p>
*
* <p>An instance of this object can be obtained via
- * {@link VcsLogObjectsFactory#createShortDetails(Hash, List, long, VirtualFile, String, String) VcsLogObjectsFactory#createShortDetails}
+ * {@link VcsLogObjectsFactory#createShortDetails(Hash, List, long, VirtualFile, String, String, String) VcsLogObjectsFactory#createShortDetails}
* </p>
*
* @see VcsFullCommitDetails
@@ -34,6 +34,6 @@
String getSubject();
@NotNull
- String getAuthorName();
+ VcsUser getAuthor();
}
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/VcsUser.java b/platform/vcs-log/api/src/com/intellij/vcs/log/VcsUser.java
index 33bafce..fb2ea21 100644
--- a/platform/vcs-log/api/src/com/intellij/vcs/log/VcsUser.java
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/VcsUser.java
@@ -25,4 +25,7 @@
@NotNull
String getName();
+ @NotNull
+ String getEmail();
+
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/GroovyTypeHierarchyProvider.java b/platform/vcs-log/graph/src/com/intellij/vcs/log/GraphCommit.java
similarity index 69%
copy from plugins/groovy/src/org/jetbrains/plugins/groovy/lang/GroovyTypeHierarchyProvider.java
copy to platform/vcs-log/graph/src/com/intellij/vcs/log/GraphCommit.java
index bed999e..1135964 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/GroovyTypeHierarchyProvider.java
+++ b/platform/vcs-log/graph/src/com/intellij/vcs/log/GraphCommit.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,12 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.jetbrains.plugins.groovy.lang;
-
-import com.intellij.ide.hierarchy.type.JavaTypeHierarchyProvider;
+package com.intellij.vcs.log;
/**
- * @author peter
+ *
*/
-public class GroovyTypeHierarchyProvider extends JavaTypeHierarchyProvider{
+public interface GraphCommit {
+
+ int getIndex();
+
+ int[] getParentIndices();
+
}
diff --git a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/elements/Branch.java b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/elements/Branch.java
index e9ffcba..de24961 100644
--- a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/elements/Branch.java
+++ b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/elements/Branch.java
@@ -3,7 +3,6 @@
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.containers.ContainerUtil;
-import com.intellij.vcs.log.Hash;
import com.intellij.vcs.log.VcsRef;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -14,12 +13,12 @@
* @author erokhins
*/
public final class Branch {
- private final Hash upCommitHash;
- private final Hash downCommitHash;
+ private final int upCommitHash;
+ private final int downCommitHash;
@Nullable private final VcsRef myColoredRef;
@NotNull private final VirtualFile myRepositoryRoot;
- public Branch(@NotNull Hash upCommitHash, @NotNull Hash downCommitHash, @NotNull Collection<VcsRef> refs,
+ public Branch(int upCommitHash, int downCommitHash, @NotNull Collection<VcsRef> refs,
@NotNull VirtualFile repositoryRoot) {
this.upCommitHash = upCommitHash;
this.downCommitHash = downCommitHash;
@@ -37,30 +36,28 @@
});
}
- public Branch(@NotNull Hash commit, @NotNull Collection<VcsRef> refs, @NotNull VirtualFile repositoryRoot) {
+ public Branch(int commit, @NotNull Collection<VcsRef> refs, @NotNull VirtualFile repositoryRoot) {
this(commit, commit, refs, repositoryRoot);
}
- @NotNull
- public Hash getUpCommitHash() {
+ public int getUpCommitHash() {
return upCommitHash;
}
- @NotNull
- public Hash getDownCommitHash() {
+ public int getDownCommitHash() {
return downCommitHash;
}
public int getBranchNumber() {
if (myColoredRef == null) {
- return upCommitHash.hashCode() + 73 * downCommitHash.hashCode();
+ return upCommitHash + 73 * downCommitHash;
}
return myColoredRef.getName().hashCode();
}
@Override
public int hashCode() {
- return upCommitHash.hashCode() + 73 * downCommitHash.hashCode();
+ return upCommitHash + 73 * downCommitHash;
}
@Override
@@ -75,10 +72,10 @@
@Override
public String toString() {
if (upCommitHash == downCommitHash) {
- return upCommitHash.asString();
+ return String.valueOf(upCommitHash);
}
else {
- return upCommitHash.asString() + '#' + downCommitHash.asString();
+ return String.valueOf(upCommitHash) + '#' + String.valueOf(downCommitHash);
}
}
diff --git a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/elements/Node.java b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/elements/Node.java
index dcb8050..87962f3 100644
--- a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/elements/Node.java
+++ b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/elements/Node.java
@@ -1,6 +1,5 @@
package com.intellij.vcs.log.graph.elements;
-import com.intellij.vcs.log.Hash;
import org.jetbrains.annotations.NotNull;
import java.util.List;
@@ -26,8 +25,7 @@
* if type == EDGE_NODE - common Parent
* if type == END_COMMIT_NODE - parent of This Commit
*/
- @NotNull
- Hash getCommitHash();
+ int getCommitIndex();
enum NodeType {
COMMIT_NODE,
diff --git a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/mutable/GraphAppendBuilder.java b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/mutable/GraphAppendBuilder.java
index 7a21c86..3beee18 100644
--- a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/mutable/GraphAppendBuilder.java
+++ b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/mutable/GraphAppendBuilder.java
@@ -1,7 +1,7 @@
package com.intellij.vcs.log.graph.mutable;
-import com.intellij.vcs.log.VcsCommit;
-import com.intellij.vcs.log.Hash;
+import com.intellij.util.containers.ContainerUtil;
+import com.intellij.vcs.log.GraphCommit;
import com.intellij.vcs.log.VcsRef;
import com.intellij.vcs.log.graph.mutable.elements.MutableNode;
import com.intellij.vcs.log.graph.mutable.elements.MutableNodeRow;
@@ -56,8 +56,8 @@
}
}
- private Map<Hash, MutableNode> fixUnderdoneNodes(@NotNull Hash firstHash) {
- Map<Hash, MutableNode> underdoneNodes = new HashMap<Hash, MutableNode>();
+ private Map<Integer, MutableNode> fixUnderdoneNodes(int firstHash) {
+ Map<Integer, MutableNode> underdoneNodes = ContainerUtil.newHashMap();
List<MutableNode> nodesInLaseRow = getLastRowInGraph().getInnerNodeList();
MutableNode node;
for (Iterator<MutableNode> iterator = nodesInLaseRow.iterator(); iterator.hasNext(); ) {
@@ -68,34 +68,34 @@
}
// i.e. it is EDGE_NODE
if (node.getInnerUpEdges().size() > 1) {
- if (node.getCommitHash().equals(firstHash)) {
+ if (node.getCommitIndex() == firstHash) {
iterator.remove();
underdoneNodes.put(firstHash, node);
}
else {
node.setType(EDGE_NODE);
- MutableNode newParentNode = new MutableNode(node.getBranch(), node.getCommitHash());
+ MutableNode newParentNode = new MutableNode(node.getBranch(), node.getCommitIndex());
GraphBuilder.createUsualEdge(node, newParentNode, node.getBranch());
- underdoneNodes.put(node.getCommitHash(), newParentNode);
+ underdoneNodes.put(node.getCommitIndex(), newParentNode);
}
}
else {
iterator.remove();
- underdoneNodes.put(node.getCommitHash(), node);
+ underdoneNodes.put(node.getCommitIndex(), node);
}
}
return underdoneNodes;
}
- private void simpleAppend(@NotNull List<? extends VcsCommit> commitParentses,
+ private void simpleAppend(@NotNull List<GraphCommit> commitParentses,
@NotNull MutableNodeRow nextRow,
- @NotNull Map<Hash, MutableNode> underdoneNodes) {
+ @NotNull Map<Integer, MutableNode> underdoneNodes) {
int startIndex = nextRow.getRowIndex();
- Map<Hash, Integer> commitLogIndexes = new HashMap<Hash, Integer>(commitParentses.size());
+ Map<Integer, Integer> commitLogIndexes = new HashMap<Integer, Integer>(commitParentses.size());
for (int i = 0; i < commitParentses.size(); i++) {
- commitLogIndexes.put(commitParentses.get(i).getHash(), i + startIndex);
+ commitLogIndexes.put(commitParentses.get(i).getIndex(), i + startIndex);
}
GraphBuilder builder = createGraphBuilder(commitParentses, nextRow, underdoneNodes, startIndex, commitLogIndexes);
@@ -103,21 +103,21 @@
}
@NotNull
- protected GraphBuilder createGraphBuilder(List<? extends VcsCommit> commitParentses, MutableNodeRow nextRow,
- Map<Hash, MutableNode> underdoneNodes, int startIndex, Map<Hash, Integer> commitLogIndexes) {
+ protected GraphBuilder createGraphBuilder(List<GraphCommit> commitParentses, MutableNodeRow nextRow, Map<Integer, MutableNode> underdoneNodes,
+ int startIndex, Map<Integer, Integer> commitLogIndexes) {
return new GraphBuilder(commitParentses.size() + startIndex - 1, commitLogIndexes, graph, underdoneNodes, nextRow, myRefs);
}
- public void appendToGraph(@NotNull List<? extends VcsCommit> commitParentses) {
+ public void appendToGraph(@NotNull List<GraphCommit> commitParentses) {
if (commitParentses.size() == 0) {
throw new IllegalArgumentException("Empty list commitParentses");
}
if (isSimpleEndOfGraph()) {
int startIndex = getLastRowInGraph().getRowIndex() + 1;
- simpleAppend(commitParentses, new MutableNodeRow(graph, startIndex), new HashMap<Hash, MutableNode>());
+ simpleAppend(commitParentses, new MutableNodeRow(graph, startIndex), new HashMap<Integer, MutableNode>());
}
else {
- Map<Hash, MutableNode> underdoneNodes = fixUnderdoneNodes(commitParentses.get(0).getHash());
+ Map<Integer, MutableNode> underdoneNodes = fixUnderdoneNodes(commitParentses.get(0).getIndex());
MutableNodeRow lastRow = getLastRowInGraph();
graph.getAllRows().remove(graph.getAllRows().size() - 1);
simpleAppend(commitParentses, lastRow, underdoneNodes);
diff --git a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/mutable/GraphBuilder.java b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/mutable/GraphBuilder.java
index 0e4f47e..23c60fb 100644
--- a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/mutable/GraphBuilder.java
+++ b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/mutable/GraphBuilder.java
@@ -4,8 +4,7 @@
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.newvfs.impl.NullVirtualFile;
import com.intellij.util.containers.MultiMap;
-import com.intellij.vcs.log.Hash;
-import com.intellij.vcs.log.VcsCommit;
+import com.intellij.vcs.log.GraphCommit;
import com.intellij.vcs.log.VcsRef;
import com.intellij.vcs.log.graph.elements.Branch;
import com.intellij.vcs.log.graph.mutable.elements.MutableNode;
@@ -25,16 +24,16 @@
private static final Logger LOG = Logger.getInstance(GraphBuilder.class);
@NotNull
- public static MutableGraph build(@NotNull List<? extends VcsCommit> commitParentses, Collection<VcsRef> allRefs) {
+ public static MutableGraph build(@NotNull List<? extends GraphCommit> commitParentses, Collection<VcsRef> allRefs) {
GraphBuilder builder = new GraphBuilder(commitParentses.size() - 1, calcCommitLogIndices(commitParentses), allRefs);
return builder.runBuild(commitParentses);
}
@NotNull
- public static Map<Hash, Integer> calcCommitLogIndices(@NotNull List<? extends VcsCommit> commitParentses) {
- Map<Hash, Integer> commitLogIndexes = new HashMap<Hash, Integer>(commitParentses.size());
+ public static Map<Integer, Integer> calcCommitLogIndices(@NotNull List<? extends GraphCommit> commitParentses) {
+ Map<Integer, Integer> commitLogIndexes = new HashMap<Integer, Integer>(commitParentses.size());
for (int i = 0; i < commitParentses.size(); i++) {
- commitLogIndexes.put(commitParentses.get(i).getHash(), i);
+ commitLogIndexes.put(commitParentses.get(i).getIndex(), i);
}
return commitLogIndexes;
}
@@ -48,16 +47,16 @@
private final int lastLogIndex;
private final MutableGraph graph;
- private final Map<Hash, MutableNode> underdoneNodes;
- private Map<Hash, Integer> commitHashLogIndexes;
- private MultiMap<Hash, VcsRef> myRefsOfHashes;
+ private final Map<Integer, MutableNode> underdoneNodes;
+ private Map<Integer, Integer> commitHashLogIndexes;
+ private MultiMap<Integer, VcsRef> myRefsOfHashes;
private MutableNodeRow nextRow;
public GraphBuilder(int lastLogIndex,
- Map<Hash, Integer> commitHashLogIndexes,
+ Map<Integer, Integer> commitHashLogIndexes,
MutableGraph graph,
- Map<Hash, MutableNode> underdoneNodes,
+ Map<Integer, MutableNode> underdoneNodes,
MutableNodeRow nextRow, Collection<VcsRef> refs) {
this.lastLogIndex = lastLogIndex;
this.commitHashLogIndexes = commitHashLogIndexes;
@@ -69,24 +68,24 @@
}
@NotNull
- private static MultiMap<Hash, VcsRef> prepareRefsMap(@NotNull Collection<VcsRef> refs) {
- MultiMap<Hash, VcsRef> map = MultiMap.create();
+ private static MultiMap<Integer, VcsRef> prepareRefsMap(@NotNull Collection<VcsRef> refs) {
+ MultiMap<Integer, VcsRef> map = MultiMap.create();
for (VcsRef ref : refs) {
- map.putValue(ref.getCommitHash(), ref);
+ map.putValue(ref.getCommitIndex(), ref);
}
return map;
}
- public GraphBuilder(int lastLogIndex, Map<Hash, Integer> commitHashLogIndexes, MutableGraph graph, Collection<VcsRef> refs) {
- this(lastLogIndex, commitHashLogIndexes, graph, new HashMap<Hash, MutableNode>(), new MutableNodeRow(graph, 0), refs);
+ public GraphBuilder(int lastLogIndex, Map<Integer, Integer> commitHashLogIndexes, MutableGraph graph, Collection<VcsRef> refs) {
+ this(lastLogIndex, commitHashLogIndexes, graph, new HashMap<Integer, MutableNode>(), new MutableNodeRow(graph, 0), refs);
}
- public GraphBuilder(int lastLogIndex, Map<Hash, Integer> commitHashLogIndexes, Collection<VcsRef> refs) {
+ public GraphBuilder(int lastLogIndex, Map<Integer, Integer> commitHashLogIndexes, Collection<VcsRef> refs) {
this(lastLogIndex, commitHashLogIndexes, new MutableGraph(), refs);
}
- private int getLogIndexOfCommit(@NotNull Hash commitHash) {
+ private int getLogIndexOfCommit(@NotNull Integer commitHash) {
Integer index = commitHashLogIndexes.get(commitHash);
if (index == null) {
return lastLogIndex + 1;
@@ -97,11 +96,11 @@
}
@NotNull
- private Collection<VcsRef> findRefForHash(@NotNull final Hash hash) {
+ private Collection<VcsRef> findRefForHash(int hash) {
return myRefsOfHashes.get(hash);
}
- private MutableNode addCurrentCommitAndFinishRow(@NotNull Hash commitHash) {
+ private MutableNode addCurrentCommitAndFinishRow(int commitHash) {
MutableNode node = underdoneNodes.remove(commitHash);
if (node == null) {
Collection<VcsRef> refs = findRefForHash(commitHash);
@@ -117,7 +116,7 @@
}
@NotNull
- protected Branch createBranch(@NotNull Hash commitHash, @NotNull Collection<VcsRef> refs) {
+ protected Branch createBranch(int commitHash, @NotNull Collection<VcsRef> refs) {
VirtualFile repositoryRoot;
if (refs.isEmpty()) {
// should never happen, but fallback gently.
@@ -130,7 +129,7 @@
return new Branch(commitHash, refs, repositoryRoot);
}
- private void addParent(MutableNode node, Hash parentHash, Branch branch) {
+ private void addParent(MutableNode node, int parentHash, Branch branch) {
MutableNode parentNode = underdoneNodes.remove(parentHash);
if (parentNode == null) {
parentNode = createNode(parentHash, branch);
@@ -158,30 +157,30 @@
}
}
- private MutableNode createNode(Hash hash, Branch branch) {
+ private MutableNode createNode(int hash, Branch branch) {
return new MutableNode(branch, hash);
}
- private void append(@NotNull VcsCommit vcsCommit) {
- MutableNode node = addCurrentCommitAndFinishRow(vcsCommit.getHash());
+ private void append(@NotNull GraphCommit commit) {
+ MutableNode node = addCurrentCommitAndFinishRow(commit.getIndex());
- List<Hash> parents = vcsCommit.getParents();
+ int[] parents = commit.getParentIndices();
Branch branch = node.getBranch();
- if (parents.size() == 1) {
- addParent(node, parents.get(0), branch);
+ if (parents.length == 1) {
+ addParent(node, parents[0], branch);
}
else {
- for (Hash parentHash : parents) {
- Collection<VcsRef> refs = findRefForHash(node.getCommitHash());
- addParent(node, parentHash, new Branch(node.getCommitHash(), parentHash, refs, branch.getRepositoryRoot()));
+ for (int parentHash : parents) {
+ Collection<VcsRef> refs = findRefForHash(node.getCommitIndex());
+ addParent(node, parentHash, new Branch(node.getCommitIndex(), parentHash, refs, branch.getRepositoryRoot()));
}
}
}
private void lastActions() {
- Set<Hash> notReadiedCommitHashes = underdoneNodes.keySet();
- for (Hash hash : notReadiedCommitHashes) {
+ Set<Integer> notReadiedCommitHashes = underdoneNodes.keySet();
+ for (Integer hash : notReadiedCommitHashes) {
MutableNode underdoneNode = underdoneNodes.get(hash);
underdoneNode.setNodeRow(nextRow);
underdoneNode.setType(END_COMMIT_NODE);
@@ -194,11 +193,11 @@
// local package
@NotNull
- public MutableGraph runBuild(@NotNull List<? extends VcsCommit> commitParentses) {
+ public MutableGraph runBuild(@NotNull List<? extends GraphCommit> commitParentses) {
if (commitParentses.size() == 0) {
throw new IllegalArgumentException("Empty list commitParentses");
}
- for (VcsCommit vcsCommit : commitParentses) {
+ for (GraphCommit vcsCommit : commitParentses) {
append(vcsCommit);
}
lastActions();
diff --git a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/mutable/elements/MutableNode.java b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/mutable/elements/MutableNode.java
index ba2f88a..6d321b8 100644
--- a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/mutable/elements/MutableNode.java
+++ b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/mutable/elements/MutableNode.java
@@ -1,7 +1,6 @@
package com.intellij.vcs.log.graph.mutable.elements;
import com.intellij.util.SmartList;
-import com.intellij.vcs.log.Hash;
import com.intellij.vcs.log.graph.elements.Branch;
import com.intellij.vcs.log.graph.elements.Edge;
import com.intellij.vcs.log.graph.elements.Node;
@@ -14,14 +13,14 @@
*/
public class MutableNode implements Node {
private final Branch branch;
- private final Hash hash;
+ private final int hash;
private MutableNodeRow nodeRow = null;
private NodeType type;
private final List<Edge> upEdges = new SmartList<Edge>();
private final List<Edge> downEdges = new SmartList<Edge>();
- public MutableNode(Branch branch, Hash hash) {
+ public MutableNode(Branch branch, int hash) {
this.branch = branch;
this.hash = hash;
}
@@ -100,9 +99,8 @@
*/
}
- @NotNull
@Override
- public Hash getCommitHash() {
+ public int getCommitIndex() {
return hash;
}
@@ -124,6 +122,6 @@
@Override
public String toString() {
- return getType() + " " + getCommitHash();
+ return getType() + " " + getCommitIndex();
}
}
diff --git a/platform/vcs-log/graph/src/com/intellij/vcs/log/graphmodel/GraphModel.java b/platform/vcs-log/graph/src/com/intellij/vcs/log/graphmodel/GraphModel.java
index 9c440b9..69e6754 100644
--- a/platform/vcs-log/graph/src/com/intellij/vcs/log/graphmodel/GraphModel.java
+++ b/platform/vcs-log/graph/src/com/intellij/vcs/log/graphmodel/GraphModel.java
@@ -2,13 +2,11 @@
import com.intellij.util.Consumer;
import com.intellij.util.Function;
-import com.intellij.vcs.log.Hash;
-import com.intellij.vcs.log.VcsCommit;
+import com.intellij.vcs.log.GraphCommit;
import com.intellij.vcs.log.compressedlist.UpdateRequest;
import com.intellij.vcs.log.graph.Graph;
import com.intellij.vcs.log.graph.elements.Node;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
import java.util.List;
@@ -20,15 +18,14 @@
@NotNull
public Graph getGraph();
- public void appendCommitsToGraph(@NotNull List<? extends VcsCommit> commitParentses);
+ public void appendCommitsToGraph(@NotNull List<GraphCommit> commitParentses);
public void setVisibleBranchesNodes(@NotNull Function<Node, Boolean> isStartedNode);
/**
* Checks if the node of the given hash is visible, and returns it if so; otherwise return null.
*/
- @Nullable
- boolean isNodeOfHashVisible(@NotNull Hash hash);
+ boolean isNodeOfHashVisible(int hash);
@NotNull
public FragmentManager getFragmentManager();
diff --git a/platform/vcs-log/graph/src/com/intellij/vcs/log/graphmodel/impl/BranchVisibleNodes.java b/platform/vcs-log/graph/src/com/intellij/vcs/log/graphmodel/impl/BranchVisibleNodes.java
index 9a41c57..ac59fbd 100644
--- a/platform/vcs-log/graph/src/com/intellij/vcs/log/graphmodel/impl/BranchVisibleNodes.java
+++ b/platform/vcs-log/graph/src/com/intellij/vcs/log/graphmodel/impl/BranchVisibleNodes.java
@@ -2,7 +2,6 @@
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
-import com.intellij.vcs.log.Hash;
import com.intellij.vcs.log.graph.elements.Edge;
import com.intellij.vcs.log.graph.elements.Node;
import com.intellij.vcs.log.graph.mutable.MutableGraph;
@@ -21,7 +20,7 @@
@NotNull private final MutableGraph myGraph;
@NotNull private Set<Node> myVisibleNodes = Collections.emptySet();
- @NotNull private Set<Hash> myVisibleHashes = Collections.emptySet();
+ @NotNull private Set<Integer> myVisibleHashes = Collections.emptySet();
public BranchVisibleNodes(@NotNull MutableGraph graph) {
myGraph = graph;
@@ -47,10 +46,10 @@
public void setVisibleNodes(@NotNull Set<Node> visibleNodes) {
myVisibleNodes = visibleNodes;
- myVisibleHashes = ContainerUtil.map2Set(myVisibleNodes, new Function<Node, Hash>() {
+ myVisibleHashes = ContainerUtil.map2Set(myVisibleNodes, new Function<Node, Integer>() {
@Override
- public Hash fun(Node node) {
- return node.getCommitHash();
+ public Integer fun(Node node) {
+ return node.getCommitIndex();
}
});
}
@@ -63,7 +62,7 @@
return myVisibleNodes.contains(node);
}
- public boolean isNodeVisible(@NotNull final Hash hash) {
+ public boolean isNodeVisible(final int hash) {
return myVisibleHashes.contains(hash);
}
diff --git a/platform/vcs-log/graph/src/com/intellij/vcs/log/graphmodel/impl/GraphModelImpl.java b/platform/vcs-log/graph/src/com/intellij/vcs/log/graphmodel/impl/GraphModelImpl.java
index b7dca1d..182ac76 100644
--- a/platform/vcs-log/graph/src/com/intellij/vcs/log/graphmodel/impl/GraphModelImpl.java
+++ b/platform/vcs-log/graph/src/com/intellij/vcs/log/graphmodel/impl/GraphModelImpl.java
@@ -2,8 +2,7 @@
import com.intellij.util.Consumer;
import com.intellij.util.Function;
-import com.intellij.vcs.log.Hash;
-import com.intellij.vcs.log.VcsCommit;
+import com.intellij.vcs.log.GraphCommit;
import com.intellij.vcs.log.VcsRef;
import com.intellij.vcs.log.compressedlist.UpdateRequest;
import com.intellij.vcs.log.graph.Graph;
@@ -95,7 +94,7 @@
}
@Override
- public void appendCommitsToGraph(@NotNull List<? extends VcsCommit> commitParentses) {
+ public void appendCommitsToGraph(@NotNull List<GraphCommit> commitParentses) {
int oldSize = graph.getNodeRows().size();
new GraphAppendBuilder(graph, myRefs).appendToGraph(commitParentses);
visibleNodes.setVisibleNodes(visibleNodes.generateVisibleBranchesNodes(isStartedBranchVisibilityNode));
@@ -116,7 +115,7 @@
}
@Override
- public boolean isNodeOfHashVisible(@NotNull Hash hash) {
+ public boolean isNodeOfHashVisible(int hash) {
return visibleNodes.isNodeVisible(hash);
}
diff --git a/platform/vcs-log/graph/test/com/intellij/vcs/log/SimpleCommit.java b/platform/vcs-log/graph/test/com/intellij/vcs/log/SimpleCommit.java
new file mode 100644
index 0000000..74b5cb3
--- /dev/null
+++ b/platform/vcs-log/graph/test/com/intellij/vcs/log/SimpleCommit.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.vcs.log;
+
+import org.jetbrains.annotations.NotNull;
+
+/**
+ *
+ */
+public class SimpleCommit implements GraphCommit {
+
+ private final int myIndex;
+ private final int[] myParents;
+
+ public SimpleCommit(int index, int[] parents) {
+ myIndex = index;
+ myParents = parents;
+ }
+
+ @Override
+ public int getIndex() {
+ return myIndex;
+ }
+
+ @NotNull
+ @Override
+ public int[] getParentIndices() {
+ return myParents;
+ }
+
+}
diff --git a/platform/vcs-log/graph/test/com/intellij/vcs/log/graph/GraphStrUtils.java b/platform/vcs-log/graph/test/com/intellij/vcs/log/graph/GraphStrUtils.java
index 941fbcd..ada0608 100644
--- a/platform/vcs-log/graph/test/com/intellij/vcs/log/graph/GraphStrUtils.java
+++ b/platform/vcs-log/graph/test/com/intellij/vcs/log/graph/GraphStrUtils.java
@@ -16,10 +16,10 @@
public static String toStr(Branch branch) {
if (branch.getUpCommitHash() == branch.getDownCommitHash()) {
- return branch.getUpCommitHash().asString();
+ return Integer.toHexString(branch.getUpCommitHash());
}
else {
- return branch.getUpCommitHash().asString() + '#' + branch.getDownCommitHash().asString();
+ return Integer.toHexString(branch.getUpCommitHash()) + '#' + Integer.toHexString(branch.getDownCommitHash());
}
}
@@ -30,8 +30,8 @@
*/
public static String toStr(Edge edge) {
StringBuilder s = new StringBuilder();
- s.append(edge.getUpNode().getCommitHash().asString()).append(":");
- s.append(edge.getDownNode().getCommitHash().asString()).append(":");
+ s.append(Integer.toHexString(edge.getUpNode().getCommitIndex())).append(":");
+ s.append(Integer.toHexString(edge.getDownNode().getCommitIndex())).append(":");
s.append(edge.getType()).append(":");
s.append(toStr(edge.getBranch()));
return s.toString();
@@ -65,7 +65,7 @@
public static String toStr(Node node) {
StringBuilder s = new StringBuilder();
- s.append(node.getCommitHash().asString()).append("|-");
+ s.append(Integer.toHexString(node.getCommitIndex())).append("|-");
s.append(toStr(node.getUpEdges())).append("|-");
s.append(toStr(node.getDownEdges())).append("|-");
s.append(node.getType()).append("|-");
diff --git a/platform/vcs-log/graph/test/com/intellij/vcs/log/graph/GraphTestUtils.java b/platform/vcs-log/graph/test/com/intellij/vcs/log/graph/GraphTestUtils.java
index 0f70595..b406dbf 100644
--- a/platform/vcs-log/graph/test/com/intellij/vcs/log/graph/GraphTestUtils.java
+++ b/platform/vcs-log/graph/test/com/intellij/vcs/log/graph/GraphTestUtils.java
@@ -1,8 +1,7 @@
package com.intellij.vcs.log.graph;
import com.intellij.openapi.vfs.newvfs.impl.StubVirtualFile;
-import com.intellij.vcs.log.Hash;
-import com.intellij.vcs.log.VcsCommit;
+import com.intellij.vcs.log.GraphCommit;
import com.intellij.vcs.log.VcsRef;
import com.intellij.vcs.log.graph.elements.Branch;
import com.intellij.vcs.log.graph.elements.Node;
@@ -36,7 +35,7 @@
@NotNull
public static MutableGraph getNewMutableGraph(@NotNull String inputStr) {
SimpleCommitListParser parser = new SimpleCommitListParser(new StringReader(inputStr));
- List<VcsCommit> vcsCommitParentses;
+ List<GraphCommit> vcsCommitParentses;
try {
vcsCommitParentses = parser.readAllCommits();
}
@@ -47,11 +46,11 @@
}
@NotNull
- public static MutableGraph buildGraph(@NotNull List<VcsCommit> commitParentses, @NotNull List<VcsRef> refs) {
+ public static MutableGraph buildGraph(@NotNull List<GraphCommit> commitParentses, @NotNull List<VcsRef> refs) {
GraphBuilder builder = new GraphBuilder(commitParentses.size() - 1, GraphBuilder.calcCommitLogIndices(commitParentses), refs) {
@NotNull
@Override
- protected Branch createBranch(@NotNull Hash commitHash, @NotNull Collection<VcsRef> refs) {
+ protected Branch createBranch(int commitHash, @NotNull Collection<VcsRef> refs) {
// allow no refs in tests
return createBranchWithFakeRoot(commitHash, refs);
}
@@ -60,7 +59,7 @@
}
@NotNull
- public static Branch createBranchWithFakeRoot(@NotNull Hash commitHash, @NotNull Collection<VcsRef> refs) {
+ public static Branch createBranchWithFakeRoot(int commitHash, @NotNull Collection<VcsRef> refs) {
return new Branch(commitHash, refs, new StubVirtualFile());
}
diff --git a/platform/vcs-log/graph/test/com/intellij/vcs/log/graph/mutable/GraphAppendBuildTest.java b/platform/vcs-log/graph/test/com/intellij/vcs/log/graph/mutable/GraphAppendBuildTest.java
index 8c67587..32cc83f7 100644
--- a/platform/vcs-log/graph/test/com/intellij/vcs/log/graph/mutable/GraphAppendBuildTest.java
+++ b/platform/vcs-log/graph/test/com/intellij/vcs/log/graph/mutable/GraphAppendBuildTest.java
@@ -1,7 +1,6 @@
package com.intellij.vcs.log.graph.mutable;
-import com.intellij.vcs.log.Hash;
-import com.intellij.vcs.log.VcsCommit;
+import com.intellij.vcs.log.GraphCommit;
import com.intellij.vcs.log.VcsRef;
import com.intellij.vcs.log.graph.GraphTestUtils;
import com.intellij.vcs.log.graph.elements.Branch;
@@ -24,7 +23,7 @@
*/
public class GraphAppendBuildTest {
public void runTest(String firstPart, String firstPartStr, String secondPart, String secondPartStr) {
- List<VcsCommit> vcsCommitParentses = SimpleCommitListParser.parseCommitList(firstPart);
+ List<GraphCommit> vcsCommitParentses = SimpleCommitListParser.parseCommitList(firstPart);
final MutableGraph graph = GraphTestUtils.buildGraph(vcsCommitParentses, Collections.<VcsRef>emptyList());
assertEquals(firstPartStr, toStr(graph));
@@ -32,14 +31,14 @@
new GraphAppendBuilder(graph, makeRefs(firstPart)) {
@NotNull
@Override
- protected GraphBuilder createGraphBuilder(List<? extends VcsCommit> commitParentses, MutableNodeRow nextRow,
- Map<Hash, MutableNode> underdoneNodes, int startIndex,
- Map<Hash, Integer> commitLogIndexes) {
+ protected GraphBuilder createGraphBuilder(List<GraphCommit> commitParentses, MutableNodeRow nextRow,
+ Map<Integer, MutableNode> underdoneNodes, int startIndex,
+ Map<Integer, Integer> commitLogIndexes) {
return new GraphBuilder(commitParentses.size() + startIndex - 1, commitLogIndexes, graph, underdoneNodes, nextRow,
Collections.<VcsRef>emptyList()) {
@NotNull
@Override
- protected Branch createBranch(@NotNull Hash commitHash, @NotNull Collection<VcsRef> refs) {
+ protected Branch createBranch(int commitHash, @NotNull Collection<VcsRef> refs) {
return GraphTestUtils.createBranchWithFakeRoot(commitHash, refs);
}
};
diff --git a/platform/vcs-log/graph/test/com/intellij/vcs/log/graph/mutable/GraphBuilderTest.java b/platform/vcs-log/graph/test/com/intellij/vcs/log/graph/mutable/GraphBuilderTest.java
index 745e2a1..1f6a8ee 100644
--- a/platform/vcs-log/graph/test/com/intellij/vcs/log/graph/mutable/GraphBuilderTest.java
+++ b/platform/vcs-log/graph/test/com/intellij/vcs/log/graph/mutable/GraphBuilderTest.java
@@ -1,6 +1,6 @@
package com.intellij.vcs.log.graph.mutable;
-import com.intellij.vcs.log.VcsCommit;
+import com.intellij.vcs.log.GraphCommit;
import com.intellij.vcs.log.VcsRef;
import com.intellij.vcs.log.graph.GraphTestUtils;
import com.intellij.vcs.log.parser.SimpleCommitListParser;
@@ -19,7 +19,7 @@
public void runTest(String input, String out) {
- List<VcsCommit> vcsCommitParentses = SimpleCommitListParser.parseCommitList(input);
+ List<GraphCommit> vcsCommitParentses = SimpleCommitListParser.parseCommitList(input);
MutableGraph graph = GraphTestUtils.buildGraph(vcsCommitParentses, Collections.<VcsRef>emptyList());
assertEquals(out, toStr(graph));
}
diff --git a/platform/vcs-log/graph/test/com/intellij/vcs/log/graphmodel/fragment/GraphModelTest.java b/platform/vcs-log/graph/test/com/intellij/vcs/log/graphmodel/fragment/GraphModelTest.java
index d673ecf1..515608c 100644
--- a/platform/vcs-log/graph/test/com/intellij/vcs/log/graphmodel/fragment/GraphModelTest.java
+++ b/platform/vcs-log/graph/test/com/intellij/vcs/log/graphmodel/fragment/GraphModelTest.java
@@ -18,9 +18,9 @@
import java.util.HashSet;
import java.util.Set;
-import static junit.framework.Assert.assertEquals;
import static com.intellij.vcs.log.graph.GraphStrUtils.toStr;
import static com.intellij.vcs.log.graph.GraphTestUtils.getCommitNode;
+import static junit.framework.Assert.assertEquals;
/**
* @author erokhins
@@ -191,7 +191,7 @@
@NotNull
@Override
public Boolean fun(@NotNull Node key) {
- return startedNodes.contains(key.getCommitHash().asString());
+ return startedNodes.contains(Integer.toHexString(key.getCommitIndex()));
}
});
}
diff --git a/platform/vcs-log/graph/test/com/intellij/vcs/log/graphmodel/fragment/GraphModelUtils.java b/platform/vcs-log/graph/test/com/intellij/vcs/log/graphmodel/fragment/GraphModelUtils.java
index 6eb004e..e08931b 100644
--- a/platform/vcs-log/graph/test/com/intellij/vcs/log/graphmodel/fragment/GraphModelUtils.java
+++ b/platform/vcs-log/graph/test/com/intellij/vcs/log/graphmodel/fragment/GraphModelUtils.java
@@ -17,7 +17,7 @@
*/
public class GraphModelUtils {
public static String toShortStr(@NotNull Node node) {
- return node.getCommitHash().asString() + ":" + node.getRowIndex();
+ return Integer.toHexString(node.getCommitIndex()) + ":" + node.getRowIndex();
}
diff --git a/platform/vcs-log/graph/test/com/intellij/vcs/log/parser/CommitParser.java b/platform/vcs-log/graph/test/com/intellij/vcs/log/parser/CommitParser.java
index 877befc..ee22399 100644
--- a/platform/vcs-log/graph/test/com/intellij/vcs/log/parser/CommitParser.java
+++ b/platform/vcs-log/graph/test/com/intellij/vcs/log/parser/CommitParser.java
@@ -1,14 +1,11 @@
package com.intellij.vcs.log.parser;
-import com.intellij.util.Function;
-import com.intellij.util.containers.ContainerUtil;
-import com.intellij.vcs.log.Hash;
-import com.intellij.vcs.log.TimedVcsCommit;
-import com.intellij.vcs.log.VcsCommit;
+import com.intellij.util.ArrayUtil;
+import com.intellij.vcs.log.GraphCommit;
+import com.intellij.vcs.log.SimpleCommit;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
/**
@@ -16,7 +13,7 @@
*/
public class CommitParser {
- private static int nextSeparatorIndex(@NotNull String line, int startIndex) {
+ public static int nextSeparatorIndex(@NotNull String line, int startIndex) {
int nextIndex = line.indexOf("|-", startIndex);
if (nextIndex == -1) {
throw new IllegalArgumentException("not found separator \"|-\", with startIndex=" + startIndex +
@@ -31,60 +28,24 @@
* 123|- // no parent
*/
@NotNull
- public static VcsCommit parseCommitParents(@NotNull String line) {
+ public static GraphCommit parseCommitParents(@NotNull String line) {
int separatorIndex = nextSeparatorIndex(line, 0);
String commitHashStr = line.substring(0, separatorIndex);
- Hash commitHash = createHash(commitHashStr);
+ int commitHash = createHash(commitHashStr);
String parentHashStr = line.substring(separatorIndex + 2, line.length());
String[] parentsHashes = parentHashStr.split("\\s");
- List<Hash> hashes = new ArrayList<Hash>(parentsHashes.length);
+ List<Integer> hashes = new ArrayList<Integer>(parentsHashes.length);
for (String aParentsStr : parentsHashes) {
if (aParentsStr.length() > 0) {
hashes.add(createHash(aParentsStr));
}
}
- return new SimpleCommit(commitHash, hashes, -1);
+ return new SimpleCommit(commitHash, ArrayUtil.toIntArray(hashes));
}
- /**
- * @param line 1231423|-adada|-193 adf45
- * timestamp|-hash commit|-parent hashes
- */
- @NotNull
- public static TimedVcsCommit parseTimestampParentHashes(@NotNull String line) {
- int firstSeparatorIndex = nextSeparatorIndex(line, 0);
- String timestampStr = line.substring(0, firstSeparatorIndex);
- long timestamp;
- try {
- if (timestampStr.isEmpty()) {
- timestamp = 0;
- }
- else {
- timestamp = Long.parseLong(timestampStr);
- }
- }
- catch (NumberFormatException e) {
- throw new IllegalArgumentException("bad timestamp in line: " + line);
- }
- VcsCommit vcsCommit = parseCommitParents(line.substring(firstSeparatorIndex + 2));
-
- return new SimpleCommit(vcsCommit.getHash(), vcsCommit.getParents(), timestamp);
- }
-
- @NotNull
- public static List<TimedVcsCommit> log(@NotNull String... commits) {
- return ContainerUtil.map(Arrays.asList(commits), new Function<String, TimedVcsCommit>() {
- @Override
- public TimedVcsCommit fun(String commit) {
- return parseTimestampParentHashes(commit);
- }
- });
- }
-
- @NotNull
- private static Hash createHash(@NotNull String s) {
- return new SimpleHash(s);
+ public static int createHash(@NotNull String s) {
+ return Integer.parseInt(s, 16);
}
}
diff --git a/platform/vcs-log/graph/test/com/intellij/vcs/log/parser/SimpleCommitListParser.java b/platform/vcs-log/graph/test/com/intellij/vcs/log/parser/SimpleCommitListParser.java
index 2e3b046..dec00db 100644
--- a/platform/vcs-log/graph/test/com/intellij/vcs/log/parser/SimpleCommitListParser.java
+++ b/platform/vcs-log/graph/test/com/intellij/vcs/log/parser/SimpleCommitListParser.java
@@ -1,19 +1,19 @@
package com.intellij.vcs.log.parser;
-import com.intellij.vcs.log.VcsCommit;
+import com.intellij.util.containers.ContainerUtil;
+import com.intellij.vcs.log.GraphCommit;
import org.jetbrains.annotations.NotNull;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
-import java.util.ArrayList;
import java.util.List;
/**
* @author erokhins
*/
public class SimpleCommitListParser {
- public static List<VcsCommit> parseCommitList(@NotNull String input) {
+ public static List<GraphCommit> parseCommitList(@NotNull String input) {
SimpleCommitListParser parser = new SimpleCommitListParser(new StringReader(input));
try {
return parser.readAllCommits();
@@ -29,9 +29,9 @@
this.bufferedReader = new BufferedReader(bufferedReader);
}
- public List<VcsCommit> readAllCommits() throws IOException {
+ public List<GraphCommit> readAllCommits() throws IOException {
String line;
- List<VcsCommit> vcsCommitParentses = new ArrayList<VcsCommit>();
+ List<GraphCommit> vcsCommitParentses = ContainerUtil.newArrayList();
while ((line = bufferedReader.readLine()) != null) {
vcsCommitParentses.add(CommitParser.parseCommitParents(line));
}
diff --git a/platform/vcs-log/graph/test/com/intellij/vcs/log/printmodel/LayoutTestUtils.java b/platform/vcs-log/graph/test/com/intellij/vcs/log/printmodel/LayoutTestUtils.java
index 0b3d3c4..6ddc8c3 100644
--- a/platform/vcs-log/graph/test/com/intellij/vcs/log/printmodel/LayoutTestUtils.java
+++ b/platform/vcs-log/graph/test/com/intellij/vcs/log/printmodel/LayoutTestUtils.java
@@ -13,7 +13,7 @@
*/
public class LayoutTestUtils {
public static String toShortStr(Node node) {
- return node.getCommitHash().asString();
+ return Integer.toHexString(node.getCommitIndex());
}
public static String toShortStr(GraphElement element) {
diff --git a/platform/vcs-log/graph/test/com/intellij/vcs/log/printmodel/cells/builder/LayoutModelBuilderTest.java b/platform/vcs-log/graph/test/com/intellij/vcs/log/printmodel/cells/builder/LayoutModelBuilderTest.java
index 02a56b9..c1c25c6 100644
--- a/platform/vcs-log/graph/test/com/intellij/vcs/log/printmodel/cells/builder/LayoutModelBuilderTest.java
+++ b/platform/vcs-log/graph/test/com/intellij/vcs/log/printmodel/cells/builder/LayoutModelBuilderTest.java
@@ -1,6 +1,6 @@
package com.intellij.vcs.log.printmodel.cells.builder;
-import com.intellij.vcs.log.VcsCommit;
+import com.intellij.vcs.log.GraphCommit;
import com.intellij.vcs.log.VcsRef;
import com.intellij.vcs.log.graph.GraphTestUtils;
import com.intellij.vcs.log.parser.SimpleCommitListParser;
@@ -21,7 +21,7 @@
public class LayoutModelBuilderTest {
private void runTest(String input, String out) throws IOException {
SimpleCommitListParser parser = new SimpleCommitListParser(new StringReader(input));
- List<VcsCommit> vcsCommitParentses = parser.readAllCommits();
+ List<GraphCommit> vcsCommitParentses = parser.readAllCommits();
LayoutModel layoutModel = new LayoutModel(GraphTestUtils.buildGraph(vcsCommitParentses, Collections.<VcsRef>emptyList()));
assertEquals(out, toStr(layoutModel));
}
diff --git a/platform/vcs-log/impl/src/META-INF/vcs-log.xml b/platform/vcs-log/impl/src/META-INF/vcs-log.xml
index 377cc00..3c0749b 100644
--- a/platform/vcs-log/impl/src/META-INF/vcs-log.xml
+++ b/platform/vcs-log/impl/src/META-INF/vcs-log.xml
@@ -8,7 +8,7 @@
<changesViewContent tabName="Log" className="com.intellij.vcs.log.impl.VcsLogContentProvider"
predicateClassName="com.intellij.vcs.log.impl.VcsLogContentProvider"/>
- <applicationService serviceInterface="com.intellij.vcs.log.VcsLogObjectsFactory" serviceImplementation="com.intellij.vcs.log.impl.VcsLogObjectsFactoryImpl" />
+ <projectService serviceInterface="com.intellij.vcs.log.VcsLogObjectsFactory" serviceImplementation="com.intellij.vcs.log.impl.VcsLogObjectsFactoryImpl" />
<projectService serviceInterface="com.intellij.vcs.log.impl.VcsLogManager" serviceImplementation="com.intellij.vcs.log.impl.VcsLogManager"/>
<projectService serviceInterface="com.intellij.vcs.log.VcsLogSettings" serviceImplementation="com.intellij.vcs.log.impl.VcsLogSettingsImpl"/>
<projectService serviceInterface="com.intellij.vcs.log.data.VcsLogUiProperties" serviceImplementation="com.intellij.vcs.log.data.VcsLogUiProperties"/>
@@ -18,11 +18,14 @@
<action class="com.intellij.vcs.log.ui.VcsLogCopyHashAction" id="Vcs.Log.CopyHash"
icon="AllIcons.Actions.Copy" text="Copy Hash" description="Copy hash value of the selected commit to clipboard" />
<action class="com.intellij.vcs.log.ui.VcsLogCreatePatchAction" id="Vcs.Log.CreatePatch" />
+ <action class="com.intellij.vcs.log.ui.GoToRefAction" id="Vcs.Log.GoToRef" icon="AllIcons.Actions.Menu_find" use-shortcut-of="Find"
+ text="Go To Reference" description="Specify hash or name of a branch or a tag to navigate to the commit it points"/>
<action class="com.intellij.vcs.log.ui.VcsLogQuickSettingsActions" id="Vcs.Log.QuickSettings"
icon="AllIcons.General.Gear" text="Quick Settings" description="Quick Settings" />
<group id="Vcs.Log.Toolbar">
<reference id="Vcs.Log.CopyHash"/>
+ <reference id="Vcs.Log.GoToRef" />
<reference id="Vcs.Log.QuickSettings" />
</group>
<group id="Vcs.Log.ContextMenu">
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataGetter.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataGetter.java
index dca343b..dabd64c 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataGetter.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataGetter.java
@@ -69,7 +69,7 @@
@NotNull
public T getCommitData(@NotNull final Node node) {
assert EventQueue.isDispatchThread();
- Hash hash = node.getCommitHash();
+ Hash hash = myDataHolder.getHash(node.getCommitIndex());
T details = getFromCache(hash);
if (details != null) {
return details;
@@ -140,7 +140,7 @@
Node commitNode = getCommitNodeInRow(i);
if (commitNode != null) {
nodes.add(commitNode);
- Hash hash = commitNode.getCommitHash();
+ Hash hash = myDataHolder.getHash(commitNode.getCommitIndex());
// fill the cache with temporary "Loading" values to avoid producing queries for each commit that has not been cached yet,
// even if it will be loaded within a previous query
@@ -158,7 +158,7 @@
MultiMap<VirtualFile, String> hashesByRoots = new MultiMap<VirtualFile, String>();
for (Node node : nodes) {
VirtualFile root = node.getBranch().getRepositoryRoot();
- hashesByRoots.putValue(root, node.getCommitHash().asString());
+ hashesByRoots.putValue(root, myDataHolder.getHash(node.getCommitIndex()).asString());
}
for (Map.Entry<VirtualFile, Collection<String>> entry : hashesByRoots.entrySet()) {
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java
index c40e62f..baef613 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java
@@ -3,8 +3,9 @@
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.util.Consumer;
import com.intellij.util.Function;
+import com.intellij.util.NotNullFunction;
import com.intellij.util.containers.Predicate;
-import com.intellij.vcs.log.VcsCommit;
+import com.intellij.vcs.log.GraphCommit;
import com.intellij.vcs.log.Hash;
import com.intellij.vcs.log.VcsRef;
import com.intellij.vcs.log.compressedlist.UpdateRequest;
@@ -31,10 +32,12 @@
@NotNull private final GraphModel myGraphModel;
@NotNull private final RefsModel myRefsModel;
@NotNull private final GraphPrintCellModel myPrintCellModel;
+ private final NotNullFunction<Integer, Hash> myHashGetter;
+ private final NotNullFunction<Hash, Integer> myIndexGetter;
@NotNull
- public static DataPack build(@NotNull List<? extends VcsCommit> commits, @NotNull Collection<VcsRef> allRefs,
- @NotNull ProgressIndicator indicator) {
+ public static DataPack build(@NotNull List<? extends GraphCommit> commits, @NotNull Collection<VcsRef> allRefs, @NotNull ProgressIndicator indicator,
+ NotNullFunction<Integer, Hash> hashGetter, NotNullFunction<Hash, Integer> indexGetter) {
indicator.setText("Building graph...");
MutableGraph graph = GraphBuilder.build(commits, allRefs);
@@ -49,12 +52,12 @@
}
});
- final RefsModel refsModel = new RefsModel(allRefs);
+ final RefsModel refsModel = new RefsModel(allRefs, hashGetter);
graphModel.getFragmentManager().setUnconcealedNodeFunction(new Function<Node, Boolean>() {
@NotNull
@Override
public Boolean fun(@NotNull Node key) {
- if (key.getDownEdges().isEmpty() || key.getUpEdges().isEmpty() || refsModel.isBranchRef(key.getCommitHash())) {
+ if (key.getDownEdges().isEmpty() || key.getUpEdges().isEmpty() || refsModel.isBranchRef(key.getCommitIndex())) {
return true;
}
else {
@@ -62,16 +65,19 @@
}
}
});
- return new DataPack(graphModel, refsModel, printCellModel);
+ return new DataPack(graphModel, refsModel, printCellModel, hashGetter, indexGetter);
}
- private DataPack(@NotNull GraphModel graphModel, @NotNull RefsModel refsModel, @NotNull GraphPrintCellModel printCellModel) {
+ private DataPack(@NotNull GraphModel graphModel, @NotNull RefsModel refsModel, @NotNull GraphPrintCellModel printCellModel,
+ NotNullFunction<Integer, Hash> hashGetter, NotNullFunction<Hash, Integer> indexGetter) {
myGraphModel = graphModel;
myRefsModel = refsModel;
myPrintCellModel = printCellModel;
+ myHashGetter = hashGetter;
+ myIndexGetter = indexGetter;
}
- public void appendCommits(@NotNull List<? extends VcsCommit> commitParentsList) {
+ public void appendCommits(@NotNull List<GraphCommit> commitParentsList) {
myGraphModel.appendCommitsToGraph(commitParentsList);
}
@@ -106,7 +112,7 @@
public Set<Node> getUpRefNodes(@NotNull GraphElement graphElement) {
Set<Node> nodes = new HashSet<Node>();
for (Node node : getGraphModel().getFragmentManager().getUpNodes(graphElement)) {
- if (getRefsModel().isBranchRef(node.getCommitHash())) {
+ if (getRefsModel().isBranchRef(node.getCommitIndex())) {
nodes.add(node);
}
}
@@ -125,10 +131,23 @@
@Nullable
public Node getNodeByHash(Hash hash) {
+ int index = myIndexGetter.fun(hash);
Graph graph = getGraphModel().getGraph();
for (int i = 0; i < graph.getNodeRows().size(); i++) {
Node node = graph.getCommitNodeInRow(i);
- if (node != null && node.getCommitHash().equals(hash)) {
+ if (node != null && node.getCommitIndex() == index) {
+ return node;
+ }
+ }
+ return null;
+ }
+
+ @Nullable
+ public Node getNodeByPartOfHash(@NotNull String hash) {
+ Graph graph = getGraphModel().getGraph();
+ for (int i = 0; i < graph.getNodeRows().size(); i++) {
+ Node node = graph.getCommitNodeInRow(i);
+ if (node != null && myHashGetter.fun(node.getCommitIndex()).asString().startsWith(hash.toLowerCase())) {
return node;
}
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/LoadingDetails.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/LoadingDetails.java
index 14f558c..e0fab723 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/LoadingDetails.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/LoadingDetails.java
@@ -8,6 +8,7 @@
import com.intellij.vcs.log.ContentRevisionFactory;
import com.intellij.vcs.log.Hash;
import com.intellij.vcs.log.impl.VcsFullCommitDetailsImpl;
+import com.intellij.vcs.log.impl.VcsUserImpl;
import org.jetbrains.annotations.NotNull;
import java.io.File;
@@ -21,11 +22,13 @@
*/
public class LoadingDetails extends VcsFullCommitDetailsImpl {
+ private static final VcsUserImpl STUB_USER = new VcsUserImpl("", "");
+
private final long myLoadingTaskIndex;
public LoadingDetails(@NotNull Hash hash, long loadingTaskIndex, @NotNull VirtualFile root) {
- super(hash, Collections.<Hash>emptyList(), -1, root, "Loading...", "", "", "", "", "", -1, Collections.<Change>emptyList(),
- new ContentRevisionFactory() {
+ super(hash, Collections.<Hash>emptyList(), -1, root, "Loading...", STUB_USER, "", STUB_USER, -1,
+ Collections.<Change>emptyList(), new ContentRevisionFactory() {
@NotNull
@Override
public ContentRevision createRevision(@NotNull VirtualFile file, @NotNull Hash hash) {
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/RefsModel.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/RefsModel.java
index cb82767..4078bbf 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/RefsModel.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/RefsModel.java
@@ -1,13 +1,16 @@
package com.intellij.vcs.log.data;
import com.intellij.openapi.util.Condition;
+import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.MultiMap;
import com.intellij.vcs.log.Hash;
import com.intellij.vcs.log.VcsRef;
import org.jetbrains.annotations.NotNull;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
/**
* @author erokhins
@@ -16,8 +19,10 @@
@NotNull private final Collection<VcsRef> myBranches;
@NotNull private final MultiMap<Hash, VcsRef> myRefsToHashes;
+ private final Function<Integer, Hash> myHashGetter;
- public RefsModel(@NotNull Collection<VcsRef> allRefs) {
+ public RefsModel(@NotNull Collection<VcsRef> allRefs, Function<Integer, Hash> hashGetter) {
+ myHashGetter = hashGetter;
myBranches = ContainerUtil.filter(allRefs, new Condition<VcsRef>() {
@Override
public boolean value(VcsRef ref) {
@@ -58,4 +63,14 @@
public Collection<VcsRef> getBranches() {
return myBranches;
}
+
+ @NotNull
+ public Collection<VcsRef> getAllRefs() {
+ return new ArrayList<VcsRef>(myRefsToHashes.values());
+ }
+
+ public boolean isBranchRef(int hash) {
+ return isBranchRef(myHashGetter.fun(hash));
+ }
+
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogBranchFilter.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogBranchFilter.java
index aed9fe0..f7a4a62 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogBranchFilter.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogBranchFilter.java
@@ -2,7 +2,6 @@
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
-import com.intellij.vcs.log.Hash;
import com.intellij.vcs.log.VcsRef;
import org.jetbrains.annotations.NotNull;
@@ -10,16 +9,16 @@
public class VcsLogBranchFilter implements VcsLogGraphFilter {
- @NotNull private final Collection<Hash> myMatchingHeads;
+ @NotNull private final Collection<Integer> myMatchingHeads;
@NotNull private final String myBranchName;
public VcsLogBranchFilter(@NotNull Collection<VcsRef> allRefs, @NotNull final String selectedBranchName) {
myBranchName = selectedBranchName;
- myMatchingHeads = ContainerUtil.mapNotNull(allRefs, new Function<VcsRef, Hash>() {
+ myMatchingHeads = ContainerUtil.mapNotNull(allRefs, new Function<VcsRef, Integer>() {
@Override
- public Hash fun(VcsRef ref) {
+ public Integer fun(VcsRef ref) {
if (ref.getName().equals(selectedBranchName)) {
- return ref.getCommitHash();
+ return ref.getCommitIndex();
}
return null;
}
@@ -27,7 +26,7 @@
}
@Override
- public boolean matches(@NotNull Hash hash) {
+ public boolean matches(int hash) {
return myMatchingHeads.contains(hash);
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogDataHolder.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogDataHolder.java
index e019591..8b2f075 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogDataHolder.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogDataHolder.java
@@ -16,6 +16,7 @@
package com.intellij.vcs.log.data;
import com.intellij.openapi.Disposable;
+import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.diagnostic.Attachment;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.BackgroundTaskQueue;
@@ -26,9 +27,7 @@
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.util.Consumer;
-import com.intellij.util.Function;
-import com.intellij.util.ThrowableConsumer;
+import com.intellij.util.*;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.HashSet;
import com.intellij.util.messages.Topic;
@@ -37,6 +36,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import java.io.IOException;
import java.util.*;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -153,8 +153,13 @@
* It is reinitialized on full refresh.
*/
private CountDownLatch myEntireLogLoadWaiter;
+ private final VcsUserRegistry myUserRegistry;
- public VcsLogDataHolder(@NotNull Project project, @NotNull VcsLogObjectsFactory logObjectsFactory,
+ private final VcsLogHashMap myHashMap;
+ private final NotNullFunction<Integer, Hash> myHashGetter;
+ private final NotNullFunction<Hash, Integer> myIndexGetter;
+
+ public VcsLogDataHolder(@NotNull Project project,
@NotNull Map<VirtualFile, VcsLogProvider> logProviders, @NotNull VcsLogSettings settings) {
myProject = project;
myLogProviders = logProviders;
@@ -163,29 +168,56 @@
myDetailsGetter = new CommitDetailsGetter(this, logProviders);
myLogJoiner = new VcsLogJoiner();
myMultiRepoJoiner = new VcsLogMultiRepoJoiner();
- myFactory = logObjectsFactory;
+ myFactory = ServiceManager.getService(myProject, VcsLogObjectsFactory.class);
mySettings = settings;
+ myUserRegistry = new VcsUserRegistry();
+
+ try {
+ myHashMap = new VcsLogHashMap(myProject);
+ }
+ catch (IOException e) {
+ throw new RuntimeException(e); // TODO: show a message to the user & fallback to using in-memory Hashes
+ }
+ myHashGetter = new NotNullFunction<Integer, Hash>() {
+ @NotNull
+ @Override
+ public Hash fun(Integer integer) {
+ return getHash(integer);
+ }
+ };
+ myIndexGetter = new NotNullFunction<Hash, Integer>() {
+ @NotNull
+ @Override
+ public Integer fun(Hash hash) {
+ return putHash(hash);
+ }
+ };
}
- /**
- * Initializes the VcsLogDataHolder in background in the following sequence:
- * <ul>
- * <li>Loads the first part of the log with details.</li>
- * <li>Invokes the Consumer to initialize the UI with the initial data pack.</li>
- * <li>Loads the whole log in background. When completed, substitutes the data and tells the UI to refresh itself.</li>
- * </ul>
- *
- * @param settings
- * @param onInitialized This is called when the holder is initialized with the initial data received from the VCS.
- */
- public static void init(@NotNull final Project project, @NotNull VcsLogObjectsFactory logObjectsFactory,
- @NotNull Map<VirtualFile, VcsLogProvider> logProviders,
- @NotNull VcsLogSettings settings, @NotNull final Consumer<VcsLogDataHolder> onInitialized) {
- final VcsLogDataHolder dataHolder = new VcsLogDataHolder(project, logObjectsFactory, logProviders, settings);
- dataHolder.initialize(onInitialized);
+ @NotNull
+ public Hash getHash(int commitIndex) {
+ try {
+ Hash hash = myHashMap.getHash(commitIndex);
+ if (hash == null) {
+ throw new RuntimeException("Unknown commit index: " + commitIndex); // TODO this shouldn't happen => need to recreate the map
+ }
+ return hash;
+ }
+ catch (IOException e) {
+ throw new RuntimeException(e); // TODO map is corrupted => need to recreate it
+ }
}
- private void initialize(@NotNull final Consumer<VcsLogDataHolder> onInitialized) {
+ public int putHash(@NotNull Hash hash) {
+ try {
+ return myHashMap.getOrPut(hash);
+ }
+ catch (IOException e) {
+ throw new RuntimeException(e); // TODO the map is corrupted => need to rebuild
+ }
+ }
+
+ public void initialize(@NotNull final Consumer<VcsLogDataHolder> onInitialized) {
// complete refresh => other scheduled refreshes are not interesting
// TODO: interrupt the current task as well instead of waiting for it to finish, since the result is invalid anyway
myDataLoaderQueue.clear();
@@ -248,12 +280,18 @@
@Override
public void consume(ProgressIndicator indicator) throws VcsException {
try {
- Map<VirtualFile, List<TimedVcsCommit>> logs = ContainerUtil.newHashMap();
+ Consumer<VcsUser> userRegistry = new Consumer<VcsUser>() {
+ @Override
+ public void consume(VcsUser user) {
+ myUserRegistry.addUser(user);
+ }
+ };
+ Map<VirtualFile, List<? extends TimedVcsCommit>> logs = ContainerUtil.newHashMap();
Map<VirtualFile, Collection<VcsRef>> refs = ContainerUtil.newHashMap();
for (Map.Entry<VirtualFile, VcsLogProvider> entry : myLogProviders.entrySet()) {
VirtualFile root = entry.getKey();
VcsLogProvider logProvider = entry.getValue();
- logs.put(root, logProvider.readAllHashes(root));
+ logs.put(root, compactHashes(logProvider.readAllHashes(root, userRegistry)));
refs.put(root, logProvider.readAllRefs(root));
}
DataPack existingDataPack = myLogData.getDataPack();
@@ -268,6 +306,15 @@
}, "Loading log structure...");
}
+ private List<CompactCommit> compactHashes(List<TimedVcsCommit> commits) {
+ return ContainerUtil.map(commits, new Function<TimedVcsCommit, CompactCommit>() {
+ @Override
+ public CompactCommit fun(final TimedVcsCommit commit) {
+ return commit instanceof CompactCommit ? (CompactCommit)commit : new CompactCommit(commit);
+ }
+ });
+ }
+
/**
* Show the full log tree to the user.
* Initially only the top part of the log is shown to avoid memory and performance problems.
@@ -300,7 +347,7 @@
// }
List<TimedVcsCommit> compoundLog = myMultiRepoJoiner.join(myLogData.myLogsByRoot.values());
- DataPack fullDataPack = DataPack.build(compoundLog, myLogData.getAllRefs(), indicator);
+ DataPack fullDataPack = DataPack.build(convertToGraphCommits(compoundLog), myLogData.getAllRefs(), indicator, myHashGetter, myIndexGetter);
myLogData = new LogData(myLogData.getLogs(), myLogData.getRefs(), myLogData.getTopCommits(), fullDataPack, true);
myFullLogShowing = true;
invokeAndWait(new Runnable() {
@@ -314,6 +361,14 @@
}, "Building full log...");
}
+ private List<? extends GraphCommit> convertToGraphCommits(List<TimedVcsCommit> log) {
+ return compactHashes(log);
+ }
+
+ public boolean isFullLogShowing() {
+ return myFullLogShowing;
+ }
+
/**
* Queries the VCS for the number of recent unordered commits, orders them and connects to the existing log structure.
* This is done after refresh, when the whole log skeleton has been loaded.
@@ -323,7 +378,7 @@
LOG.error("The full log is not ready!");
}
- Map<VirtualFile, List<TimedVcsCommit>> logsToBuild = ContainerUtil.newHashMap();
+ Map<VirtualFile, List<? extends TimedVcsCommit>> logsToBuild = ContainerUtil.newHashMap();
Map<VirtualFile, Collection<VcsRef>> refsByRoot = ContainerUtil.newHashMap();
int topCommitCount = myLogData.getTopCommitsCount();
@@ -347,7 +402,8 @@
List<TimedVcsCommit> topPartOfTheLog = compoundLog.subList(0, topCommitCount);
List<TimedVcsCommit> logToBuild = myFullLogShowing ? compoundLog : topPartOfTheLog; // keep looking at the full log after refresh
- DataPack dataPack = DataPack.build(logToBuild, collectAllRefs(refsByRoot), indicator);
+ DataPack dataPack = DataPack.build(convertToGraphCommits(logToBuild), collectAllRefs(refsByRoot), indicator,
+ myHashGetter, myIndexGetter);
myLogData = new LogData(logsToBuild, refsByRoot, topPartOfTheLog, dataPack, true);
@@ -365,7 +421,7 @@
* doesn't change the saved log skeleton.
*/
private void loadFromVcs(int commitCount, ProgressIndicator indicator, final Consumer<DataPack> onSuccess) throws VcsException {
- Map<VirtualFile, List<TimedVcsCommit>> logsToBuild = ContainerUtil.newHashMap();
+ Map<VirtualFile, List<? extends TimedVcsCommit>> logsToBuild = ContainerUtil.newHashMap();
Map<VirtualFile, Collection<VcsRef>> refsByRoot = ContainerUtil.newHashMap();
for (Map.Entry<VirtualFile, RecentCommitsInfo> entry : collectInfoFromVcs(true, commitCount)) {
@@ -382,7 +438,8 @@
// even if the full log was already loaded (and possibly presented to the user),
// build only the data that was retrieved from the VCS:
// if it is not one of the initial refreshes, then it is filtering, and then the DataPack will change anyway.
- DataPack dataPack = DataPack.build(compoundLog, collectAllRefs(refsByRoot), indicator);
+ DataPack dataPack = DataPack.build(convertToGraphCommits(compoundLog), collectAllRefs(refsByRoot), indicator,
+ myHashGetter, myIndexGetter);
if (myLogData != null && myLogData.isFullLogReady()) {
// reuse the skeleton, since it didn't change, because it is not a refresh
@@ -405,6 +462,7 @@
List<? extends VcsFullCommitDetails> firstBlockDetails = logProvider.readFirstBlock(root, ordered, commitsCount);
Collection<VcsRef> newRefs = logProvider.readAllRefs(root);
storeTopCommitsDetailsInCache(firstBlockDetails);
+ storeUsers(firstBlockDetails);
List<TimedVcsCommit> firstBlockCommits = getCommitsFromDetails(firstBlockDetails);
infoByRoot.put(root, new RecentCommitsInfo(firstBlockCommits, newRefs));
@@ -412,12 +470,24 @@
return infoByRoot.entrySet();
}
+ private void storeUsers(@NotNull List<? extends VcsFullCommitDetails> details) {
+ for (VcsFullCommitDetails detail : details) {
+ myUserRegistry.addUser(detail.getAuthor());
+ myUserRegistry.addUser(detail.getCommitter());
+ }
+ }
+
+ @NotNull
+ public Set<VcsUser> getAllUsers() {
+ return myUserRegistry.getUsers();
+ }
+
public void getFilteredDetailsFromTheVcs(final Collection<VcsLogFilter> filters, final Consumer<List<VcsFullCommitDetails>> success) {
runInBackground(new ThrowableConsumer<ProgressIndicator, VcsException>() {
@Override
public void consume(ProgressIndicator indicator) throws VcsException {
- Collection<List<TimedVcsCommit>> logs = ContainerUtil.newArrayList();
+ Collection<List<? extends TimedVcsCommit>> logs = ContainerUtil.newArrayList();
final Map<Hash, VcsFullCommitDetails> allDetails = ContainerUtil.newHashMap();
for (Map.Entry<VirtualFile, VcsLogProvider> entry : myLogProviders.entrySet()) {
List<? extends VcsFullCommitDetails> details = entry.getValue().getFilteredDetails(entry.getKey(), filters);
@@ -474,6 +544,20 @@
return myProject;
}
+ public VcsUserRegistry getUserRegistry() {
+ return myUserRegistry;
+ }
+
+ @NotNull
+ public Collection<VirtualFile> getRoots() {
+ return myLogProviders.keySet();
+ }
+
+ @NotNull
+ public Collection<VcsLogProvider> getLogProviders() {
+ return myLogProviders.values();
+ }
+
private static class RecentCommitsInfo {
List<TimedVcsCommit> firstBlockCommits;
Collection<VcsRef> newRefs;
@@ -513,7 +597,7 @@
return ContainerUtil.map(firstBlockDetails, new Function<VcsFullCommitDetails, TimedVcsCommit>() {
@Override
public TimedVcsCommit fun(VcsFullCommitDetails details) {
- return myFactory.createTimedCommit(details.getHash(), details.getParents(), details.getAuthorTime());
+ return new CompactCommit(details.getHash(), details.getParents(), details.getAuthorTime());
}
});
}
@@ -554,7 +638,7 @@
if (myLogData.isFullLogReady()) {
int totalSize = 0;
- for (List<TimedVcsCommit> commits : myLogData.getLogs().values()) {
+ for (List<? extends TimedVcsCommit> commits : myLogData.getLogs().values()) {
totalSize += commits.size();
}
if (topCommitsCount >= totalSize) {
@@ -588,7 +672,7 @@
LogData logData = myLogData;
if (logData.isFullLogReady()) {
int totalSize = 0;
- for (List<TimedVcsCommit> commits : logData.getLogs().values()) {
+ for (List<? extends TimedVcsCommit> commits : logData.getLogs().values()) {
totalSize += commits.size();
}
if (logData.getTopCommitsCount() >= totalSize) {
@@ -768,13 +852,13 @@
* When we load the full structure, it is substituted.
*/
private static class LogData {
- @NotNull private final Map<VirtualFile, List<TimedVcsCommit>> myLogsByRoot;
+ @NotNull private final Map<VirtualFile, List<? extends TimedVcsCommit>> myLogsByRoot;
@NotNull private final Map<VirtualFile, Collection<VcsRef>> myRefsByRoot;
@NotNull private final List<TimedVcsCommit> myCompoundTopCommits;
@NotNull private final DataPack myDataPack;
private final boolean myFullLog;
- private LogData(@NotNull Map<VirtualFile, List<TimedVcsCommit>> logsByRoot,
+ private LogData(@NotNull Map<VirtualFile, List<? extends TimedVcsCommit>> logsByRoot,
@NotNull Map<VirtualFile, Collection<VcsRef>> refsByRoot, @NotNull List<TimedVcsCommit> compoundTopCommits,
@NotNull DataPack dataPack, boolean fullLog) {
myLogsByRoot = logsByRoot;
@@ -785,7 +869,7 @@
}
@NotNull
- public List<TimedVcsCommit> getLog(@NotNull VirtualFile root) {
+ public List<? extends TimedVcsCommit> getLog(@NotNull VirtualFile root) {
return myLogsByRoot.get(root);
}
@@ -813,7 +897,7 @@
}
@NotNull
- public Map<VirtualFile,List<TimedVcsCommit>> getLogs() {
+ public Map<VirtualFile, List<? extends TimedVcsCommit>> getLogs() {
return myLogsByRoot;
}
@@ -832,4 +916,101 @@
}
}
+ private class CompactCommit implements TimedVcsCommit, GraphCommit {
+ private final int myHashIndex;
+ private final int myParent; // there is almost always one parent
+ private final int[] myOtherParents;
+ private final long myAuthorTime;
+
+ public CompactCommit(TimedVcsCommit commit) {
+ this(commit.getHash(), commit.getParents(), commit.getAuthorTime());
+ }
+
+ public CompactCommit(Hash hash, List<Hash> parents, long time) {
+ myHashIndex = putHash(hash);
+ myAuthorTime = time;
+
+ if (!parents.isEmpty()) {
+ myParent = putHash(parents.get(0));
+ if (parents.size() > 1) {
+ myOtherParents = new int[parents.size() - 1];
+ for (int i = 0; i < parents.size() - 1; i++) {
+ myOtherParents[i]= putHash(parents.get(i + 1));
+ }
+ }
+ else {
+ myOtherParents = null;
+ }
+ }
+ else {
+ myParent = -1;
+ myOtherParents = null;
+ }
+ }
+
+ @Override
+ public long getAuthorTime() {
+ return myAuthorTime;
+ }
+
+ @NotNull
+ @Override
+ public Hash getHash() {
+ return VcsLogDataHolder.this.getHash(myHashIndex);
+ }
+
+ @NotNull
+ @Override
+ public List<Hash> getParents() {
+ List<Hash> parents = new SmartList<Hash>();
+ if (myParent > -1) {
+ parents.add(VcsLogDataHolder.this.getHash(myParent));
+ }
+ if (myOtherParents != null) {
+ for (int parent : myOtherParents) {
+ parents.add(VcsLogDataHolder.this.getHash(parent));
+ }
+ }
+ return parents;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ CompactCommit commit = (CompactCommit)o;
+
+ if (myHashIndex != commit.myHashIndex) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return myHashIndex;
+ }
+
+ @Override
+ public int getIndex() {
+ return myHashIndex;
+ }
+
+ @Override
+ public int[] getParentIndices() {
+ if (myParent < 0) {
+ return ArrayUtil.EMPTY_INT_ARRAY;
+ }
+ else if (myOtherParents == null) {
+ return new int[]{myParent};
+ }
+ else {
+ int[] parents = new int[myOtherParents.length + 1];
+ parents[0] = myParent;
+ System.arraycopy(myOtherParents, 0, parents, 1, myOtherParents.length);
+ return parents;
+ }
+ }
+ }
+
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogDateFilter.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogDateFilter.java
new file mode 100644
index 0000000..fbba0d7
--- /dev/null
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogDateFilter.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.vcs.log.data;
+
+import com.intellij.vcs.log.VcsFullCommitDetails;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Date;
+
+public class VcsLogDateFilter implements VcsLogDetailsFilter {
+
+ @Nullable private final Date myAfter;
+ @Nullable private final Date myBefore;
+
+ public VcsLogDateFilter(@Nullable Date after, @Nullable Date before) {
+ myAfter = after;
+ myBefore = before;
+ }
+
+ @Override
+ public boolean matches(@NotNull VcsFullCommitDetails details) {
+ Date date = new Date(details.getCommitTime()); // behave like Git does: it filters by commit time, not author time
+ boolean matches = true;
+ if (myAfter != null) {
+ matches &= date.after(myAfter);
+ }
+ if (myBefore != null) {
+ matches &= date.before(myBefore);
+ }
+ return matches;
+ }
+
+ @Nullable
+ public Date getAfter() {
+ return myAfter;
+ }
+
+ @Nullable
+ public Date getBefore() {
+ return myBefore;
+ }
+
+}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogFilterer.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogFilterer.java
index 769b814..367c922 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogFilterer.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogFilterer.java
@@ -105,7 +105,7 @@
return !ContainerUtil.exists(onGraphFilters, new Condition<VcsLogGraphFilter>() {
@Override
public boolean value(VcsLogGraphFilter filter) {
- return !filter.matches(node.getCommitHash());
+ return !filter.matches(node.getCommitIndex());
}
});
}
@@ -124,7 +124,7 @@
return !filter.matches(details);
}
});
- return graphModel.isNodeOfHashVisible(details.getHash()) && allFilterMatch;
+ return graphModel.isNodeOfHashVisible(myLogDataHolder.putHash(details.getHash())) && allFilterMatch;
}
});
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogGraphFilter.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogGraphFilter.java
index afddd7b..5734dc0 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogGraphFilter.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogGraphFilter.java
@@ -1,14 +1,12 @@
package com.intellij.vcs.log.data;
-import com.intellij.vcs.log.Hash;
import com.intellij.vcs.log.VcsLogFilter;
-import org.jetbrains.annotations.NotNull;
/**
* Filter that is able to work on graph.
*/
public interface VcsLogGraphFilter extends VcsLogFilter {
- boolean matches(@NotNull Hash hash);
+ boolean matches(int hash);
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogHashMap.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogHashMap.java
new file mode 100644
index 0000000..940add3
--- /dev/null
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogHashMap.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.vcs.log.data;
+
+import com.intellij.openapi.application.PathManager;
+import com.intellij.openapi.project.Project;
+import com.intellij.util.io.KeyDescriptor;
+import com.intellij.util.io.Page;
+import com.intellij.util.io.PersistentEnumerator;
+import com.intellij.vcs.log.Hash;
+import com.intellij.vcs.log.impl.HashImpl;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Supports the int <-> Hash persistent mapping.
+ */
+class VcsLogHashMap {
+
+ private static final File LOG_CACHE_APP_DIR = new File(PathManager.getSystemPath(), "vcs-log");
+
+ private final PersistentEnumerator<Hash> myPersistentEnumerator;
+
+ VcsLogHashMap(@NotNull Project project) throws IOException {
+ File myMapFile = new File(LOG_CACHE_APP_DIR, project.getName() + "." + project.getLocationHash());
+ myPersistentEnumerator = new PersistentEnumerator<Hash>(myMapFile, new MyHashKeyDescriptor(), Page.PAGE_SIZE);
+ }
+
+ @Nullable
+ Hash getHash(int index) throws IOException {
+ return myPersistentEnumerator.valueOf(index);
+ }
+
+ int getOrPut(@NotNull Hash hash) throws IOException {
+ return myPersistentEnumerator.enumerate(hash);
+ }
+
+ private static class MyHashKeyDescriptor implements KeyDescriptor<Hash> {
+ @Override
+ public void save(DataOutput out, Hash value) throws IOException {
+ out.writeUTF(value.asString());
+ }
+
+ @Override
+ public Hash read(DataInput in) throws IOException {
+ return HashImpl.build(in.readUTF());
+ }
+
+ @Override
+ public int getHashCode(Hash value) {
+ return value.hashCode();
+ }
+
+ @Override
+ public boolean isEqual(Hash val1, Hash val2) {
+ return val1.equals(val2);
+ }
+ }
+}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogJoiner.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogJoiner.java
index ca3271e..912f140 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogJoiner.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogJoiner.java
@@ -44,7 +44,7 @@
* @return Total saved log with new commits properly attached to it + number of new commits attached to the log.
*/
@NotNull
- public Pair<List<TimedVcsCommit>, Integer> addCommits(@NotNull List<TimedVcsCommit> savedLog,
+ public Pair<List<TimedVcsCommit>, Integer> addCommits(@NotNull List<? extends TimedVcsCommit> savedLog,
@NotNull Collection<VcsRef> previousRefs,
@NotNull List<? extends TimedVcsCommit> firstBlock,
@NotNull Collection<VcsRef> newRefs) {
@@ -87,7 +87,7 @@
// return Pair(-1, null) if something bad :'(
@NotNull
- private static Pair<Integer, Set<TimedVcsCommit>> getNewCommitsAndSavedGreenIndex(@NotNull List<TimedVcsCommit> savedLog,
+ private static Pair<Integer, Set<TimedVcsCommit>> getNewCommitsAndSavedGreenIndex(@NotNull List<? extends TimedVcsCommit> savedLog,
@NotNull Collection<Hash> previousRefs,
@NotNull List<? extends TimedVcsCommit> firstBlock,
@NotNull Collection<Hash> newRefs) {
@@ -109,7 +109,7 @@
return new Pair<Integer, Set<TimedVcsCommit>>(saveGreenIndex, getAllNewCommits(savedLog.subList(0, saveGreenIndex), firstBlock));
}
- private static int getFirstUnTrackedIndex(@NotNull List<TimedVcsCommit> commits, @NotNull Set<Hash> searchHashes) {
+ private static int getFirstUnTrackedIndex(@NotNull List<? extends TimedVcsCommit> commits, @NotNull Set<Hash> searchHashes) {
int lastIndex = 0;
for (VcsCommit commit : commits) {
if (searchHashes.size() == 0)
@@ -122,8 +122,8 @@
return searchHashes.size() == 0 ? lastIndex : -1;
}
- private static Set<TimedVcsCommit> getAllNewCommits(@NotNull List<TimedVcsCommit> unsafeGreenPartSavedLog,
- @NotNull List<? extends TimedVcsCommit> firstBlock) {
+ private static Set<TimedVcsCommit> getAllNewCommits(@NotNull List<? extends TimedVcsCommit> unsafeGreenPartSavedLog,
+ @NotNull List<? extends TimedVcsCommit> firstBlock) {
Set<Hash> existedCommitHashes = new HashSet<Hash>();
for (VcsCommit commit : unsafeGreenPartSavedLog) {
existedCommitHashes.add(commit.getHash());
@@ -139,7 +139,7 @@
// return Pair(-1, null) if something bad :'(
@NotNull
- private static Pair<Integer, Set<Hash>> getRedCommitsAndSavedRedIndex(@NotNull List<TimedVcsCommit> savedLog,
+ private static Pair<Integer, Set<Hash>> getRedCommitsAndSavedRedIndex(@NotNull List<? extends TimedVcsCommit> savedLog,
@NotNull Collection<Hash> previousRefs,
@NotNull List<? extends TimedVcsCommit> firstBlock,
@NotNull Collection<Hash> newRefs) {
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogMultiRepoJoiner.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogMultiRepoJoiner.java
index 9a1b959..db6bb82 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogMultiRepoJoiner.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogMultiRepoJoiner.java
@@ -12,7 +12,7 @@
class VcsLogMultiRepoJoiner {
@NotNull
- public List<TimedVcsCommit> join(@NotNull Collection<List<TimedVcsCommit>> logsFromRepos) {
+ public List<TimedVcsCommit> join(@NotNull Collection<List<? extends TimedVcsCommit>> logsFromRepos) {
int size = 0;
for (List<? extends TimedVcsCommit> repo : logsFromRepos) {
size += repo.size();
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogStructureFilter.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogStructureFilter.java
new file mode 100644
index 0000000..6a0f4e3
--- /dev/null
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogStructureFilter.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.vcs.log.data;
+
+import com.intellij.openapi.util.Condition;
+import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.openapi.vcs.changes.Change;
+import com.intellij.openapi.vcs.changes.ContentRevision;
+import com.intellij.openapi.vfs.VfsUtilCore;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.util.containers.ContainerUtil;
+import com.intellij.util.containers.MultiMap;
+import com.intellij.vcs.log.VcsFullCommitDetails;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Collection;
+
+public class VcsLogStructureFilter implements VcsLogDetailsFilter {
+
+ @NotNull private final Collection<VirtualFile> myFiles;
+ @NotNull private final MultiMap<VirtualFile, VirtualFile> myFilesByRoots;
+
+ public VcsLogStructureFilter(@NotNull Collection<VirtualFile> files, Collection<VirtualFile> roots) {
+ myFiles = files;
+ myFilesByRoots = groupFilesByVcsRoots(files, roots);
+ }
+
+ private static MultiMap<VirtualFile, VirtualFile> groupFilesByVcsRoots(Collection<VirtualFile> files, Collection<VirtualFile> roots) {
+ MultiMap<VirtualFile, VirtualFile> grouped = MultiMap.create();
+ for (VirtualFile file : files) {
+ VirtualFile root = findBestRoot(file, roots);
+ if (root != null) {
+ grouped.putValue(root, file);
+ }
+ }
+ return grouped;
+ }
+
+ @Nullable
+ private static VirtualFile findBestRoot(@NotNull VirtualFile file, @NotNull Collection<VirtualFile> roots) {
+ VirtualFile candidate = null;
+ for (VirtualFile root : roots) {
+ if (VfsUtilCore.isAncestor(root, file, false)) {
+ if (candidate == null || VfsUtilCore.isAncestor(candidate, root, true)) {
+ candidate = root;
+ }
+ }
+ }
+ return candidate;
+ }
+
+ @Override
+ public boolean matches(@NotNull VcsFullCommitDetails details) {
+ for (Change change : details.getChanges()) {
+ ContentRevision before = change.getBeforeRevision();
+ if (before != null && matches(before.getFile().getPath())) {
+ return true;
+ }
+ ContentRevision after = change.getAfterRevision();
+ if (after != null && matches(after.getFile().getPath())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean matches(final String path) {
+ return ContainerUtil.find(myFiles, new Condition<VirtualFile>() {
+ @Override
+ public boolean value(VirtualFile file) {
+ return FileUtil.isAncestor(file.getPath(), path, false);
+ }
+ }) != null;
+ }
+
+ @NotNull
+ public Collection<VirtualFile> getFiles(@NotNull VirtualFile root) {
+ return myFilesByRoots.get(root);
+ }
+
+}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogUserFilter.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogUserFilter.java
index 97b9cb4..492c310 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogUserFilter.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogUserFilter.java
@@ -25,8 +25,8 @@
@Override
public boolean matches(@NotNull VcsFullCommitDetails detail) {
- return detail.getAuthorName().toLowerCase().contains(myUser.toLowerCase()) ||
- detail.getAuthorEmail().toLowerCase().contains(myUser.toLowerCase());
+ return detail.getAuthor().getName().toLowerCase().contains(myUser.toLowerCase()) ||
+ detail.getAuthor().getEmail().toLowerCase().contains(myUser.toLowerCase());
}
@NotNull
@@ -51,7 +51,7 @@
@Override
public boolean matches(@NotNull VcsFullCommitDetails details) {
VcsUser meInThisRoot = myMeData.get(details.getRoot());
- return meInThisRoot != null && meInThisRoot.getName().equalsIgnoreCase(details.getAuthorName());
+ return meInThisRoot != null && meInThisRoot.equals(details.getAuthor());
}
@NotNull
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsUserRegistry.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsUserRegistry.java
new file mode 100644
index 0000000..bd29145
--- /dev/null
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsUserRegistry.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.vcs.log.data;
+
+import com.intellij.util.containers.Interner;
+import com.intellij.vcs.log.VcsUser;
+import com.intellij.vcs.log.impl.VcsUserImpl;
+
+import java.util.Set;
+
+/**
+ *
+ */
+public class VcsUserRegistry {
+
+ private final Interner<VcsUser> myUserMap = new Interner<VcsUser>();
+
+ public VcsUser createUser(String name, String email) {
+ return myUserMap.intern(new VcsUserImpl(name, email));
+ }
+
+ public void addUser(VcsUser user) {
+ myUserMap.intern(user);
+ }
+
+ public Set<VcsUser> getUsers() {
+ return myUserMap.getValues();
+ }
+}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsFullCommitDetailsImpl.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsFullCommitDetailsImpl.java
index 30c5c37..14a0950 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsFullCommitDetailsImpl.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsFullCommitDetailsImpl.java
@@ -9,6 +9,7 @@
import com.intellij.vcs.log.ContentRevisionFactory;
import com.intellij.vcs.log.Hash;
import com.intellij.vcs.log.VcsFullCommitDetails;
+import com.intellij.vcs.log.VcsUser;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
@@ -21,21 +22,17 @@
@NotNull private final String myFullMessage;
- @NotNull private final String myAuthorEmail;
- @NotNull private final String myCommitterName;
- @NotNull private final String myCommitterEmail;
+ @NotNull private final VcsUser myCommitter;
private final long myCommitTime;
@NotNull private final Collection<LightChange> myChanges;
public VcsFullCommitDetailsImpl(@NotNull Hash hash, @NotNull List<Hash> parents, long authorTime, @NotNull VirtualFile root,
- @NotNull String subject, @NotNull String authorName, @NotNull String authorEmail, @NotNull String message,
- @NotNull String committerName, @NotNull String committerEmail, long commitTime,
+ @NotNull String subject, @NotNull VcsUser author, @NotNull String message,
+ @NotNull VcsUser committer, long commitTime,
@NotNull List<Change> changes, @NotNull final ContentRevisionFactory contentRevisionFactory) {
- super(hash, parents, authorTime, root, subject, authorName);
- myAuthorEmail = authorEmail;
- myCommitterName = committerName;
- myCommitterEmail = committerEmail;
+ super(hash, parents, authorTime, root, subject, author);
+ myCommitter = committer;
myCommitTime = commitTime;
myFullMessage = message;
myChanges = ContainerUtil.map(changes, new Function<Change, LightChange>() {
@@ -63,22 +60,10 @@
});
}
- @Override
@NotNull
- public String getAuthorEmail() {
- return myAuthorEmail;
- }
-
@Override
- @NotNull
- public String getCommitterName() {
- return myCommitterName;
- }
-
- @Override
- @NotNull
- public String getCommitterEmail() {
- return myCommitterEmail;
+ public VcsUser getCommitter() {
+ return myCommitter;
}
@Override
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogImpl.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogImpl.java
index 3489b5e..96fffeb 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogImpl.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogImpl.java
@@ -15,17 +15,17 @@
*/
package com.intellij.vcs.log.impl;
+import com.intellij.openapi.util.Condition;
import com.intellij.ui.table.JBTable;
import com.intellij.util.containers.ContainerUtil;
-import com.intellij.vcs.log.Hash;
-import com.intellij.vcs.log.VcsFullCommitDetails;
-import com.intellij.vcs.log.VcsLog;
+import com.intellij.vcs.log.*;
import com.intellij.vcs.log.data.VcsLogDataHolder;
import com.intellij.vcs.log.ui.VcsLogUI;
import com.intellij.vcs.log.ui.tables.AbstractVcsLogTableModel;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import java.awt.*;
import java.util.Collection;
import java.util.List;
@@ -84,4 +84,39 @@
return null;
}
+ @NotNull
+ @Override
+ public Collection<VcsRef> getAllReferences() {
+ return myDataHolder.getDataPack().getRefsModel().getAllRefs();
+ }
+
+ @Override
+ public void jumpToReference(final String reference) {
+ Collection<VcsRef> references = getAllReferences();
+ VcsRef ref = ContainerUtil.find(references, new Condition<VcsRef>() {
+ @Override
+ public boolean value(VcsRef ref) {
+ return ref.getName().startsWith(reference);
+ }
+ });
+ if (ref != null) {
+ myUi.jumpToCommit(ref.getCommitHash());
+ }
+ else {
+ myUi.jumpToCommitByPartOfHash(reference);
+ }
+ }
+
+ @NotNull
+ @Override
+ public Component getToolbar() {
+ return myUi.getToolbar();
+ }
+
+ @NotNull
+ @Override
+ public Collection<VcsLogProvider> getLogProviders() {
+ return myDataHolder.getLogProviders();
+ }
+
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogManager.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogManager.java
index ab2eecc..525a774 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogManager.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogManager.java
@@ -1,6 +1,9 @@
package com.intellij.vcs.log.impl;
import com.intellij.openapi.Disposable;
+import com.intellij.openapi.actionSystem.DataKey;
+import com.intellij.openapi.actionSystem.DataSink;
+import com.intellij.openapi.actionSystem.TypeSafeDataProvider;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.project.Project;
@@ -20,7 +23,6 @@
import com.intellij.util.Consumer;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.MultiMap;
-import com.intellij.vcs.log.VcsLogObjectsFactory;
import com.intellij.vcs.log.VcsLogProvider;
import com.intellij.vcs.log.VcsLogRefresher;
import com.intellij.vcs.log.VcsLogSettings;
@@ -45,7 +47,6 @@
@NotNull private final Project myProject;
@NotNull private final ProjectLevelVcsManager myVcsManager;
- @NotNull private final VcsLogObjectsFactory myLogObjectsFactory;
@NotNull private final VcsLogSettings mySettings;
@NotNull private final VcsLogUiProperties myUiProperties;
@@ -54,11 +55,10 @@
private VcsLogUI myUi;
public VcsLogManager(@NotNull Project project, @NotNull ProjectLevelVcsManager vcsManager,
- @NotNull VcsLogObjectsFactory logObjectsFactory, @NotNull VcsLogSettings settings,
+ @NotNull VcsLogSettings settings,
@NotNull VcsLogUiProperties uiProperties) {
myProject = project;
myVcsManager = vcsManager;
- myLogObjectsFactory = logObjectsFactory;
mySettings = settings;
myUiProperties = uiProperties;
Disposer.register(myProject, this);
@@ -69,7 +69,8 @@
final Map<VirtualFile, VcsLogProvider> logProviders = findLogProviders();
final VcsLogContainer mainPanel = new VcsLogContainer(myProject);
- VcsLogDataHolder.init(myProject, myLogObjectsFactory, logProviders, mySettings, new Consumer<VcsLogDataHolder>() {
+ myLogDataHolder = new VcsLogDataHolder(myProject, logProviders, mySettings);
+ myLogDataHolder.initialize(new Consumer<VcsLogDataHolder>() {
@Override
public void consume(VcsLogDataHolder vcsLogDataHolder) {
Disposer.register(VcsLogManager.this, vcsLogDataHolder);
@@ -117,6 +118,7 @@
return myLogDataHolder;
}
+ @NotNull
public VcsLogUI getLogUi() {
return myUi;
}
@@ -125,7 +127,7 @@
public void dispose() {
}
- private static class VcsLogContainer extends JPanel {
+ private class VcsLogContainer extends JPanel implements TypeSafeDataProvider {
private final JBLoadingPanel myLoadingPanel;
@@ -140,6 +142,14 @@
myLoadingPanel.add(mainComponent);
myLoadingPanel.stopLoading();
}
+
+ @Override
+ public void calcData(DataKey key, DataSink sink) {
+ if (myUi != null) {
+ myUi.getMainFrame().calcData(key, sink);
+ }
+ }
+
}
private static class PostponeableLogRefresher implements VcsLogRefresher, Disposable {
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogObjectsFactoryImpl.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogObjectsFactoryImpl.java
index 6ea9810..8023882 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogObjectsFactoryImpl.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogObjectsFactoryImpl.java
@@ -2,7 +2,9 @@
import com.intellij.openapi.vcs.changes.Change;
import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.util.NotNullFunction;
import com.intellij.vcs.log.*;
+import com.intellij.vcs.log.data.VcsLogDataHolder;
import org.jetbrains.annotations.NotNull;
import java.util.List;
@@ -12,6 +14,12 @@
*/
public class VcsLogObjectsFactoryImpl implements VcsLogObjectsFactory {
+ @NotNull private final VcsLogManager myLogManager;
+
+ public VcsLogObjectsFactoryImpl(@NotNull VcsLogManager logManager) {
+ myLogManager = logManager;
+ }
+
@NotNull
@Override
public Hash createHash(@NotNull String stringHash) {
@@ -33,8 +41,10 @@
@NotNull
@Override
public VcsShortCommitDetails createShortDetails(@NotNull Hash hash, @NotNull List<Hash> parents, long timeStamp,
- @NotNull VirtualFile root, @NotNull String subject, @NotNull String authorName) {
- return new VcsShortCommitDetailsImpl(hash, parents, timeStamp, root, subject, authorName);
+ @NotNull VirtualFile root, @NotNull String subject,
+ @NotNull String authorName, String authorEmail) {
+ VcsUser author = createUser(authorName, authorEmail);
+ return new VcsShortCommitDetailsImpl(hash, parents, timeStamp, root, subject, author);
}
@NotNull
@@ -44,14 +54,32 @@
@NotNull String message, @NotNull String committerName,
@NotNull String committerEmail, long commitTime, @NotNull List<Change> changes,
@NotNull ContentRevisionFactory contentRevisionFactory) {
- return new VcsFullCommitDetailsImpl(hash, parents, authorTime, root, subject, authorName, authorEmail, message, committerName,
- committerEmail, commitTime, changes, contentRevisionFactory);
+ VcsUser author = createUser(authorName, authorEmail);
+ VcsUser committer = createUser(committerName, committerEmail);
+ return new VcsFullCommitDetailsImpl(hash, parents, authorTime, root, subject, author, message, committer, commitTime,
+ changes, contentRevisionFactory);
}
@NotNull
@Override
- public VcsUser createUser(@NotNull String name) {
- return new VcsUserImpl(name);
+ public VcsUser createUser(@NotNull String name, @NotNull String email) {
+ VcsLogDataHolder dataHolder = myLogManager.getDataHolder();
+ if (dataHolder == null) {
+ return new VcsUserImpl(name, email);
+ }
+ return dataHolder.getUserRegistry().createUser(name, email);
+ }
+
+ @NotNull
+ @Override
+ public VcsRef createRef(@NotNull Hash commitHash, @NotNull String name, @NotNull VcsRefType type, @NotNull VirtualFile root) {
+ return new VcsRefImpl(new NotNullFunction<Hash, Integer>() {
+ @NotNull
+ @Override
+ public Integer fun(Hash hash) {
+ return myLogManager.getDataHolder().putHash(hash);
+ }
+ }, commitHash, name, type, root);
}
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsRefImpl.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsRefImpl.java
index 540caed..ae47792 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsRefImpl.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsRefImpl.java
@@ -1,6 +1,7 @@
package com.intellij.vcs.log.impl;
import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.util.NotNullFunction;
import com.intellij.vcs.log.Hash;
import com.intellij.vcs.log.VcsRef;
import com.intellij.vcs.log.VcsRefType;
@@ -15,12 +16,15 @@
@NotNull private final String myName;
@NotNull private final VcsRefType myType;
@NotNull private final VirtualFile myRoot;
+ private final int myIndex;
- public VcsRefImpl(@NotNull Hash commitHash, @NotNull String name, @NotNull VcsRefType type, @NotNull VirtualFile root) {
+ public VcsRefImpl(NotNullFunction<Hash, Integer> indexGetter, @NotNull Hash commitHash, @NotNull String name, @NotNull VcsRefType type,
+ @NotNull VirtualFile root) {
myCommitHash = commitHash;
myName = name;
myType = type;
myRoot = root;
+ myIndex = indexGetter.fun(myCommitHash);
}
@Override
@@ -48,6 +52,11 @@
}
@Override
+ public int getCommitIndex() {
+ return myIndex;
+ }
+
+ @Override
public String toString() {
return String.format("%s:%s(%s|%s)", myRoot.getName(), myName, myCommitHash, myType);
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsShortCommitDetailsImpl.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsShortCommitDetailsImpl.java
index e99e814..96a3136 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsShortCommitDetailsImpl.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsShortCommitDetailsImpl.java
@@ -4,6 +4,7 @@
import com.intellij.vcs.log.Hash;
import com.intellij.vcs.log.TimedVcsCommit;
import com.intellij.vcs.log.VcsShortCommitDetails;
+import com.intellij.vcs.log.VcsUser;
import org.jetbrains.annotations.NotNull;
import java.util.List;
@@ -15,15 +16,15 @@
@NotNull private final TimedVcsCommit myTimeCommitParents;
@NotNull private final String mySubject;
- @NotNull private final String myAuthorName;
+ @NotNull private final VcsUser myAuthor;
@NotNull private final VirtualFile myRoot;
public VcsShortCommitDetailsImpl(@NotNull Hash hash, @NotNull List<Hash> parents, long timeStamp, @NotNull VirtualFile root,
- @NotNull String subject, @NotNull String authorName) {
+ @NotNull String subject, @NotNull VcsUser author) {
myTimeCommitParents = new TimedVcsCommitImpl(hash, parents, timeStamp);
myRoot = root;
mySubject = subject;
- myAuthorName = authorName;
+ myAuthor = author;
}
@NotNull
@@ -57,8 +58,8 @@
@Override
@NotNull
- public final String getAuthorName() {
- return myAuthorName;
+ public final VcsUser getAuthor() {
+ return myAuthor;
}
@Override
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsUserImpl.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsUserImpl.java
index e5cc661..c0782f4 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsUserImpl.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsUserImpl.java
@@ -18,12 +18,17 @@
import com.intellij.vcs.log.VcsUser;
import org.jetbrains.annotations.NotNull;
+/**
+ * Note: users are considered equal if they have the same name, even if the e-mail is different.
+ */
public class VcsUserImpl implements VcsUser {
- @NotNull private String myName;
+ @NotNull private final String myName;
+ @NotNull private final String myEmail;
- public VcsUserImpl(@NotNull String name) {
+ public VcsUserImpl(@NotNull String name, @NotNull String email) {
myName = name;
+ myEmail = email;
}
@NotNull
@@ -32,6 +37,12 @@
return myName;
}
+ @NotNull
+ @Override
+ public String getEmail() {
+ return myEmail;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
@@ -51,7 +62,7 @@
@Override
public String toString() {
- return myName;
+ return myName + "<" + myEmail + ">";
}
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/GoToRefAction.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/GoToRefAction.java
new file mode 100644
index 0000000..4514217
--- /dev/null
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/GoToRefAction.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.vcs.log.ui;
+
+import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.project.DumbAwareAction;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.popup.JBPopup;
+import com.intellij.openapi.ui.popup.JBPopupListener;
+import com.intellij.openapi.ui.popup.LightweightWindowEvent;
+import com.intellij.util.Function;
+import com.intellij.util.containers.ContainerUtil;
+import com.intellij.vcs.log.VcsLog;
+import com.intellij.vcs.log.VcsLogDataKeys;
+import com.intellij.vcs.log.VcsRef;
+
+import java.util.Collection;
+
+public class GoToRefAction extends DumbAwareAction {
+
+ @Override
+ public void actionPerformed(AnActionEvent e) {
+ Project project = e.getProject();
+ final VcsLog log = e.getData(VcsLogDataKeys.VSC_LOG);
+ if (project == null || log == null) {
+ return;
+ }
+
+ Collection<String> refs = ContainerUtil.map(log.getAllReferences(), new Function<VcsRef, String>() {
+ @Override
+ public String fun(VcsRef ref) {
+ return ref.getName();
+ }
+ });
+ final PopupWithTextFieldWithAutoCompletion textField = new PopupWithTextFieldWithAutoCompletion(project, refs);
+ JBPopup popup = textField.createPopup();
+ popup.addListener(new JBPopupListener.Adapter() {
+ @Override
+ public void onClosed(LightweightWindowEvent event) {
+ if (event.isOk()) {
+ log.jumpToReference(textField.getText());
+ }
+ }
+ });
+ popup.showUnderneathOf(log.getToolbar());
+ }
+
+ @Override
+ public void update(AnActionEvent e) {
+ VcsLog log = e.getData(VcsLogDataKeys.VSC_LOG);
+ getTemplatePresentation().setEnabledAndVisible(e.getProject() != null && log != null);
+ }
+
+}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/PopupWithTextFieldWithAutoCompletion.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/PopupWithTextFieldWithAutoCompletion.java
new file mode 100644
index 0000000..f37b7b1
--- /dev/null
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/PopupWithTextFieldWithAutoCompletion.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.vcs.log.ui;
+
+import com.intellij.openapi.editor.ex.EditorEx;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.popup.JBPopup;
+import com.intellij.openapi.ui.popup.JBPopupFactory;
+import com.intellij.spellchecker.ui.SpellCheckingEditorCustomization;
+import com.intellij.ui.TextFieldWithAutoCompletion;
+import com.intellij.ui.components.JBTextField;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+import java.awt.event.KeyEvent;
+import java.util.Collection;
+
+public class PopupWithTextFieldWithAutoCompletion extends TextFieldWithAutoCompletion<String> {
+
+ @Nullable private JBPopup myPopup;
+
+ public PopupWithTextFieldWithAutoCompletion(@NotNull Project project, @NotNull Collection<String> variants) {
+ super(project, new StringsCompletionProvider(variants, null), false, null);
+
+ // this hack is needed, because the preferred size is requested before createEditor(),
+ // and EditorTextField#getPreferredSize() hardcodes unacceptable (100, 20)
+ setPreferredSize(new JBTextField(20).getPreferredSize());
+ }
+
+ public JBPopup createPopup() {
+ myPopup = JBPopupFactory.getInstance().createComponentPopupBuilder(this, this)
+ .setCancelOnClickOutside(true)
+ .setCancelOnWindowDeactivation(true)
+ .setCancelKeyEnabled(true)
+ .setRequestFocus(true)
+ .createPopup();
+ return myPopup;
+ }
+
+ @Override
+ protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) {
+ if (e.getKeyCode() == KeyEvent.VK_ENTER) {
+ if (myPopup != null) {
+ myPopup.closeOk(e);
+ }
+ return true;
+ }
+ else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
+ if (myPopup != null) {
+ myPopup.cancel(e);
+ }
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ protected EditorEx createEditor() {
+ // spell check is not needed
+ EditorEx editor = super.createEditor();
+ SpellCheckingEditorCustomization.getInstance(false).customize(editor);
+ return editor;
+ }
+}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsLogUI.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsLogUI.java
index 81ddba7..7706c2b 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsLogUI.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsLogUI.java
@@ -25,6 +25,7 @@
import org.jetbrains.annotations.Nullable;
import javax.swing.table.TableModel;
+import java.awt.*;
import java.util.Collection;
/**
@@ -205,6 +206,21 @@
}
}
+ public void jumpToCommitByPartOfHash(final String hash) {
+ Node node = myLogDataHolder.getDataPack().getNodeByPartOfHash(hash);
+ if (node != null) {
+ jumpToRow(node.getRowIndex());
+ }
+ else if (!myLogDataHolder.isFullLogShowing()) {
+ myLogDataHolder.showFullLog(new Runnable() {
+ @Override
+ public void run() {
+ jumpToCommitByPartOfHash(hash);
+ }
+ });
+ }
+ }
+
@NotNull
public VcsLogColorManager getColorManager() {
return myColorManager;
@@ -255,4 +271,7 @@
myMainFrame.setBranchesPanelVisible(visible);
}
+ public Component getToolbar() {
+ return myMainFrame.getToolbar();
+ }
}
diff --git a/plugins/git4idea/src/git4idea/history/wholeTree/VcsStructureChooser.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsStructureChooser.java
similarity index 96%
rename from plugins/git4idea/src/git4idea/history/wholeTree/VcsStructureChooser.java
rename to platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsStructureChooser.java
index ec0ae8e..787c9b2 100644
--- a/plugins/git4idea/src/git4idea/history/wholeTree/VcsStructureChooser.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsStructureChooser.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package git4idea.history.wholeTree;
+package com.intellij.vcs.log.ui;
import com.intellij.ide.util.treeView.AbstractTreeUi;
import com.intellij.ide.util.treeView.NodeDescriptor;
@@ -31,7 +31,6 @@
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.Splitter;
import com.intellij.openapi.util.Computable;
-import com.intellij.openapi.vcs.AbstractVcs;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.changes.ui.VirtualFileListCellRenderer;
import com.intellij.openapi.vfs.VirtualFile;
@@ -46,6 +45,7 @@
import com.intellij.util.containers.hash.HashSet;
import com.intellij.util.treeWithCheckedNodes.SelectionManager;
import com.intellij.util.ui.UIUtil;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
@@ -70,7 +70,7 @@
public static final Border BORDER = IdeBorderFactory.createBorder(SideBorder.TOP | SideBorder.LEFT);
public static final String DEFAULT_TEXT = "<html>Selected:</html>";
public static final String CAN_NOT_ADD_TEXT = "<html>Selected: <font color=red>(You have added " + MAX_FOLDERS + " elements. No more is allowed.)</font></html>";
- private final AbstractVcs myVcs;
+ @NotNull private final Project myProject;
private Set<VirtualFile> myRoots;
private Map<VirtualFile, String> myModulesSet;
private SelectionManager mySelectionManager;
@@ -80,14 +80,14 @@
private Tree myTree;
private final List<VirtualFile> myInitialRoots;
- public VcsStructureChooser(final AbstractVcs vcs,
+ public VcsStructureChooser(@NotNull Project project,
final String title,
final Collection<VirtualFile> initialSelection,
List<VirtualFile> initialRoots) {
- super(vcs.getProject(), true);
+ super(project, true);
myInitialRoots = initialRoots;
setTitle(title);
- myVcs = vcs;
+ myProject = project;
mySelectionManager = new SelectionManager(MAX_FOLDERS, 500, MyNodeConvertor.getInstance());
init();
mySelectionManager.setSelection(initialSelection);
@@ -95,7 +95,7 @@
}
private void calculateRoots() {
- final ModuleManager moduleManager = ModuleManager.getInstance(myVcs.getProject());
+ final ModuleManager moduleManager = ModuleManager.getInstance(myProject);
// assertion for read access inside
final Module[] modules = ApplicationManager.getApplication().runReadAction(new Computable<Module[]>() {
public Module[] compute() {
@@ -168,9 +168,9 @@
myTree.setShowsRootHandles(true);
myTree.setRootVisible(true);
myTree.getExpandableItemsHandler().setEnabled(false);
- final MyCheckboxTreeCellRenderer cellRenderer = new MyCheckboxTreeCellRenderer(mySelectionManager, myModulesSet, myVcs.getProject(),
+ final MyCheckboxTreeCellRenderer cellRenderer = new MyCheckboxTreeCellRenderer(mySelectionManager, myModulesSet, myProject,
myTree, myRoots);
- final FileSystemTreeImpl fileSystemTree = new FileSystemTreeImpl(myVcs.getProject(), descriptor, myTree, cellRenderer, null, new Convertor<TreePath, String>() {
+ final FileSystemTreeImpl fileSystemTree = new FileSystemTreeImpl(myProject, descriptor, myTree, cellRenderer, null, new Convertor<TreePath, String>() {
@Override
public String convert(TreePath o) {
final DefaultMutableTreeNode lastPathComponent = ((DefaultMutableTreeNode) o.getLastPathComponent());
@@ -244,7 +244,7 @@
mySelectedLabel.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0));
wrapper.add(mySelectedLabel, BorderLayout.NORTH);
mySelectedList = new JBList(new CollectionListModel(new ArrayList<VirtualFile>()));
- mySelectedList.setCellRenderer(new WithModulesListCellRenderer(myVcs.getProject(), myModulesSet));
+ mySelectedList.setCellRenderer(new WithModulesListCellRenderer(myProject, myModulesSet));
wrapper.add(ScrollPaneFactory.createScrollPane(mySelectedList), BorderLayout.CENTER);
splitter.setSecondComponent(wrapper);
@@ -292,7 +292,7 @@
final int[] idx = mySelectedList.getSelectedIndices();
if (idx != null && idx.length > 0) {
final int answer = Messages
- .showYesNoDialog(myVcs.getProject(), "Remove selected paths from filter?", "Remove from filter", Messages.getQuestionIcon());
+ .showYesNoDialog(myProject, "Remove selected paths from filter?", "Remove from filter", Messages.getQuestionIcon());
if (Messages.OK == answer) {
Arrays.sort(idx);
for (int i = idx.length - 1; i >= 0; --i) {
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/DateFilterPopupComponent.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/DateFilterPopupComponent.java
new file mode 100644
index 0000000..87d93a1
--- /dev/null
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/DateFilterPopupComponent.java
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.vcs.log.ui.filter;
+
+import com.intellij.openapi.actionSystem.ActionGroup;
+import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.actionSystem.DefaultActionGroup;
+import com.intellij.openapi.project.DumbAwareAction;
+import com.intellij.openapi.ui.DialogBuilder;
+import com.intellij.openapi.ui.DialogWrapper;
+import com.intellij.openapi.vcs.versionBrowser.DateFilterComponent;
+import com.intellij.util.text.DateFormatUtil;
+import com.intellij.vcs.log.VcsLogFilter;
+import com.intellij.vcs.log.data.VcsLogDateFilter;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Calendar;
+import java.util.Date;
+
+class DateFilterPopupComponent extends FilterPopupComponent {
+
+ private Date myAfter;
+ private Date myBefore;
+
+ DateFilterPopupComponent(@NotNull VcsLogClassicFilterUi filterUi) {
+ super(filterUi, "Date");
+ }
+
+ @Override
+ protected ActionGroup createActionGroup() {
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(new Date());
+ cal.add(Calendar.DAY_OF_YEAR, -1);
+ Date oneDayBefore = cal.getTime();
+ cal.add(Calendar.DAY_OF_YEAR, -6);
+ Date oneWeekBefore = cal.getTime();
+
+ DumbAwareAction allAction = new DumbAwareAction(ALL) {
+ @Override
+ public void actionPerformed(AnActionEvent e) {
+ myAfter = null;
+ myBefore = null;
+ applyFilters();
+ setValue(ALL);
+ }
+ };
+ return new DefaultActionGroup(allAction,
+ new DateAction(oneDayBefore, "Last 24 hours"),
+ new DateAction(oneWeekBefore, "Last 7 days"),
+ new SelectAction());
+ }
+
+ @Nullable
+ @Override
+ protected VcsLogFilter getFilter() {
+ return myAfter == null && myBefore == null ? null : new VcsLogDateFilter(myAfter, myBefore);
+ }
+
+ private void setOnlyAfter(Date after) {
+ myAfter = after;
+ myBefore = null;
+ }
+
+ private class DateAction extends DumbAwareAction {
+
+ private final Date mySince;
+ private final String myText;
+
+ DateAction(Date since, String text) {
+ super(text);
+ mySince = since;
+ myText = text;
+ }
+
+ @Override
+ public void actionPerformed(AnActionEvent e) {
+ setValue(myText);
+ setOnlyAfter(mySince);
+ applyFilters();
+ }
+ }
+
+ private class SelectAction extends DumbAwareAction {
+
+ SelectAction() {
+ super("Select...");
+ }
+
+ @Override
+ public void actionPerformed(AnActionEvent e) {
+ final DateFilterComponent dateComponent = new DateFilterComponent(false, DateFormatUtil.getDateFormat().getDelegate());
+ if (myBefore != null) {
+ dateComponent.setBefore(myBefore.getTime());
+ }
+ if (myAfter != null) {
+ dateComponent.setAfter(myAfter.getTime());
+ }
+
+ DialogBuilder db = new DialogBuilder(DateFilterPopupComponent.this);
+ db.addOkAction();
+ db.setCenterPanel(dateComponent.getPanel());
+ db.setPreferredFocusComponent(dateComponent.getPanel());
+ db.setTitle("Select Period");
+ if (DialogWrapper.OK_EXIT_CODE == db.show()) {
+ long after = dateComponent.getAfter();
+ long before = dateComponent.getBefore();
+ myAfter = after > 0 ? new Date(after) : null;
+ myBefore = before > 0 ? new Date(before) : null;
+
+ if (myAfter != null && myBefore != null) {
+ setValue(DateFormatUtil.formatDate(after) + "-" + DateFormatUtil.formatDate(before));
+ }
+ else if (myAfter != null) {
+ setValue("After " + DateFormatUtil.formatDate(after));
+ }
+ else {
+ setValue("Before " + DateFormatUtil.formatDate(before));
+ }
+
+ applyFilters();
+ }
+ }
+ }
+}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/StructureFilterPopupComponent.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/StructureFilterPopupComponent.java
new file mode 100644
index 0000000..c82b601
--- /dev/null
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/StructureFilterPopupComponent.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.vcs.log.ui.filter;
+
+import com.intellij.openapi.actionSystem.ActionGroup;
+import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.actionSystem.DefaultActionGroup;
+import com.intellij.openapi.project.DumbAwareAction;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.util.containers.ContainerUtil;
+import com.intellij.vcs.log.VcsLogFilter;
+import com.intellij.vcs.log.data.VcsLogStructureFilter;
+import com.intellij.vcs.log.ui.VcsStructureChooser;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+
+class StructureFilterPopupComponent extends FilterPopupComponent {
+
+ public static final int FILTER_LABEL_LENGTH = 20;
+ @NotNull private final Collection<VirtualFile> myRoots;
+ @NotNull private final Collection<VirtualFile> myFiles;
+
+ public StructureFilterPopupComponent(@NotNull VcsLogClassicFilterUi filterUi, @NotNull Collection<VirtualFile> roots) {
+ super(filterUi, "Structure");
+ myRoots = roots;
+ myFiles = ContainerUtil.newArrayList();
+ }
+
+ @Override
+ protected ActionGroup createActionGroup() {
+ return new DefaultActionGroup(createAllAction(), new SelectAction());
+ }
+
+ @Nullable
+ @Override
+ protected VcsLogFilter getFilter() {
+ return getValue() == ALL || myFiles.isEmpty() ? null : new VcsLogStructureFilter(myFiles, myRoots);
+ }
+
+ private void setValue(@NotNull Collection<VirtualFile> files) {
+ if (files.size() == 0) {
+ setValue(ALL);
+ }
+ else if (files.size() == 1) {
+ VirtualFile file = files.iterator().next();
+ setValue(StringUtil.shortenPathWithEllipsis(file.getPresentableUrl(), FILTER_LABEL_LENGTH));
+ }
+ else {
+ setValue(files.size() + " files");
+ }
+ }
+
+ @NotNull
+ private static <T> Collection<T> notNullize(@Nullable Collection<T> items) {
+ return items != null ? items : Collections.<T>emptyList();
+ }
+
+ private class SelectAction extends DumbAwareAction {
+
+ SelectAction() {
+ super("Select...");
+ }
+
+ @Override
+ public void actionPerformed(AnActionEvent e) {
+ Project project = e.getProject();
+ assert project != null;
+ VcsStructureChooser chooser = new VcsStructureChooser(project, "Select Folders to Filter", myFiles,
+ new ArrayList<VirtualFile>(myRoots));
+ if (chooser.showAndGet()) {
+ myFiles.clear();
+ myFiles.addAll(notNullize(chooser.getSelectedFiles()));
+ setValue(myFiles);
+ applyFilters();
+ }
+ }
+
+ }
+
+}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/UserFilterPopupComponent.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/UserFilterPopupComponent.java
index eb9e83e..6a5ee0a 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/UserFilterPopupComponent.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/UserFilterPopupComponent.java
@@ -21,17 +21,18 @@
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.ui.popup.JBPopup;
import com.intellij.openapi.ui.popup.JBPopupAdapter;
-import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.ui.popup.LightweightWindowEvent;
-import com.intellij.ui.components.JBTextField;
+import com.intellij.util.Function;
+import com.intellij.util.containers.ContainerUtil;
import com.intellij.vcs.log.VcsLogFilter;
+import com.intellij.vcs.log.VcsUser;
import com.intellij.vcs.log.data.VcsLogDataHolder;
import com.intellij.vcs.log.data.VcsLogUiProperties;
import com.intellij.vcs.log.data.VcsLogUserFilter;
+import com.intellij.vcs.log.ui.PopupWithTextFieldWithAutoCompletion;
import org.jetbrains.annotations.Nullable;
-import java.awt.event.KeyAdapter;
-import java.awt.event.KeyEvent;
+import java.util.Collection;
import java.util.List;
/**
@@ -89,27 +90,16 @@
@Override
public void actionPerformed(AnActionEvent e) {
- final JBTextField textField = new JBTextField(10);
-
- final JBPopup popup = JBPopupFactory.getInstance().createComponentPopupBuilder(textField, textField)
- .setCancelOnClickOutside(true)
- .setCancelOnWindowDeactivation(true)
- .setCancelKeyEnabled(true)
- .setRequestFocus(true)
- .createPopup();
-
- textField.addKeyListener(new KeyAdapter() {
+ Collection<String> users = ContainerUtil.map(myDataHolder.getAllUsers(), new Function<VcsUser, String>() {
@Override
- public void keyPressed(KeyEvent e) {
- if (e.getKeyCode() == KeyEvent.VK_ENTER) {
- popup.closeOk(e);
- }
- else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
- popup.cancel(e);
- }
+ public String fun(VcsUser user) {
+ return user.getName();
}
});
+ final PopupWithTextFieldWithAutoCompletion textField = new PopupWithTextFieldWithAutoCompletion(e.getProject(), users);
+ JBPopup popup = textField.createPopup();
+
popup.addListener(new JBPopupAdapter() {
@Override
public void onClosed(LightweightWindowEvent event) {
@@ -121,8 +111,7 @@
}
});
popup.showUnderneathOf(UserFilterPopupComponent.this);
- textField.requestFocus();
}
- }
+ }
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/VcsLogClassicFilterUi.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/VcsLogClassicFilterUi.java
index 0531b13..ec6a729 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/VcsLogClassicFilterUi.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/VcsLogClassicFilterUi.java
@@ -57,15 +57,21 @@
FilterPopupComponent branchFilter = new BranchFilterPopupComponent(this, ui);
FilterPopupComponent userFilter = new UserFilterPopupComponent(this, ui.getLogDataHolder(), ui.getUiProperties());
+ FilterPopupComponent dateFilter = new DateFilterPopupComponent(this);
+ FilterPopupComponent structureFilter = new StructureFilterPopupComponent(this, ui.getLogDataHolder().getRoots());
myFilterPopupComponents = ContainerUtil.newArrayList();
myFilterPopupComponents.add(branchFilter);
myFilterPopupComponents.add(userFilter);
+ myFilterPopupComponents.add(dateFilter);
+ myFilterPopupComponents.add(structureFilter);
myActionGroup = new DefaultActionGroup();
myActionGroup.add(new TextFilterComponent(myTextFilter));
myActionGroup.add(new FilterActionComponent(branchFilter));
myActionGroup.add(new FilterActionComponent(userFilter));
+ myActionGroup.add(new FilterActionComponent(dateFilter));
+ myActionGroup.add(new FilterActionComponent(structureFilter));
}
@Override
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/DetailsPanel.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/DetailsPanel.java
index 074cd2b..ec0a92e0 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/DetailsPanel.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/DetailsPanel.java
@@ -132,6 +132,7 @@
else {
String body = getHashText(commit) + "<br/>" + getAuthorText(commit) + "<p>" + getMessageText(commit) + "</p>";
setText("<html><head>" + UIUtil.getCssFontDeclaration(UIUtil.getLabelFont()) + "</head><body>" + body + "</body></html>");
+ setCaretPosition(0);
}
}
@@ -147,8 +148,8 @@
}
private static String getAuthorText(VcsFullCommitDetails commit) {
- String authorText = commit.getAuthorName() + " at " + DateFormatUtil.formatDateTime(commit.getAuthorTime());
- if (!commit.getAuthorName().equals(commit.getCommitterName()) || !commit.getAuthorEmail().equals(commit.getCommitterEmail())) {
+ String authorText = commit.getAuthor().getName() + " at " + DateFormatUtil.formatDateTime(commit.getAuthorTime());
+ if (!commit.getAuthor().equals(commit.getCommitter())) {
String commitTime;
if (commit.getCommitTime() != commit.getAuthorTime()) {
commitTime = " at " + DateFormatUtil.formatDateTime(commit.getCommitTime());
@@ -156,7 +157,10 @@
else {
commitTime = "";
}
- authorText += " (committed by " + commit.getCommitterName() + commitTime + ")";
+ authorText += " (committed by " + commit.getCommitter().getName() + commitTime + ")";
+ }
+ else if (commit.getCommitTime() != commit.getAuthorTime()) {
+ authorText += " (committed at " + DateFormatUtil.formatDateTime(commit.getCommitTime()) + ")";
}
return authorText;
}
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/MainFrame.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/MainFrame.java
index e63a1da..14ad6b3 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/MainFrame.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/MainFrame.java
@@ -49,6 +49,7 @@
@NotNull private final BranchesPanel myBranchesPanel;
@NotNull private final DetailsPanel myDetailsPanel;
@NotNull private final Splitter myDetailsSplitter;
+ private final JComponent myToolbar;
public MainFrame(@NotNull VcsLogDataHolder logDataHolder, @NotNull VcsLogUI vcsLogUI, @NotNull Project project,
@NotNull VcsLogSettings settings, @NotNull VcsLogUiProperties uiProperties, @NotNull VcsLog log) {
@@ -78,14 +79,14 @@
updateWhenDetailsAreLoaded(selectionChangeListener);
// layout
- JComponent toolbar = createActionsToolbar();
+ myToolbar = createActionsToolbar();
myDetailsSplitter = new Splitter(true, 0.7f);
myDetailsSplitter.setFirstComponent(ScrollPaneFactory.createScrollPane(myGraphTable));
setupDetailsSplitter(myUiProperties.isShowDetails());
JComponent toolbars = new JPanel(new BorderLayout());
- toolbars.add(toolbar, BorderLayout.NORTH);
+ toolbars.add(myToolbar, BorderLayout.NORTH);
toolbars.add(myBranchesPanel, BorderLayout.CENTER);
JComponent toolbarsAndTable = new JPanel(new BorderLayout());
toolbarsAndTable.add(toolbars, BorderLayout.NORTH);
@@ -234,6 +235,10 @@
}
}
+ public Component getToolbar() {
+ return myToolbar;
+ }
+
private class CommitSelectionListener implements ListSelectionListener {
private final ChangesBrowser myChangesBrowser;
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java
index 1e9c4df..fe9a62f 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java
@@ -85,7 +85,6 @@
addMouseListener(mouseAdapter);
PopupHandler.installPopupHandler(this, VcsLogUI.POPUP_ACTION_GROUP, VcsLogUI.VCS_LOG_TABLE_PLACE);
- new TableLinkMouseListener().installOn(this);
getColumnModel().addColumnModelListener(new TableColumnModelListener() {
@Override
@@ -226,6 +225,11 @@
private class MyMouseAdapter extends MouseAdapter {
private final Cursor DEFAULT_CURSOR = new Cursor(Cursor.DEFAULT_CURSOR);
private final Cursor HAND_CURSOR = new Cursor(Cursor.HAND_CURSOR);
+ private final TableLinkMouseListener myTableListener;
+
+ MyMouseAdapter() {
+ myTableListener = new TableLinkMouseListener();
+ }
@Nullable
private GraphPrintCell getGraphPrintCell(MouseEvent e) {
@@ -273,12 +277,13 @@
myUI.click(PositionUtil.getRowIndex(e));
}
}
+ myTableListener.onClick(e, e.getClickCount());
}
@Override
public void mouseMoved(MouseEvent e) {
Node jumpToNode = arrowToNode(e);
- if (jumpToNode != null) {
+ if (jumpToNode != null || isAboveLink(e)) {
setCursor(HAND_CURSOR);
}
else {
@@ -287,6 +292,10 @@
myUI.over(overCell(e));
}
+ private boolean isAboveLink(MouseEvent e) {
+ return myTableListener.getTagAt(e) != null;
+ }
+
@Override
public void mouseEntered(MouseEvent e) {
// Do nothing
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/AbstractVcsLogTableModel.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/AbstractVcsLogTableModel.java
index b2b803b..3799e45 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/AbstractVcsLogTableModel.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/AbstractVcsLogTableModel.java
@@ -57,7 +57,7 @@
return "";
}
else {
- return data.getAuthorName();
+ return data.getAuthor().getName();
}
case DATE_COLUMN:
if (data == null || data.getAuthorTime() < 0) {
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/GraphTableModel.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/GraphTableModel.java
index 9ddd0c5..1302553 100644
--- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/GraphTableModel.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/tables/GraphTableModel.java
@@ -135,7 +135,7 @@
@Override
public Hash getHashAtRow(int row) {
Node node = myDataPack.getGraphModel().getGraph().getCommitNodeInRow(row);
- return node == null ? null : node.getCommitHash();
+ return node == null ? null : myDataHolder.getHash(node.getCommitIndex());
}
}
diff --git a/platform/vcs-log/impl/src/icons/VcsLogIcons.java b/platform/vcs-log/impl/src/icons/VcsLogIcons.java
index 5e41d3f..a5f91b6 100644
--- a/platform/vcs-log/impl/src/icons/VcsLogIcons.java
+++ b/platform/vcs-log/impl/src/icons/VcsLogIcons.java
@@ -9,7 +9,6 @@
* DO NOT EDIT IT BY HAND, run build/scripts/icons.gant instead
*/
public class VcsLogIcons {
-
private static Icon load(String path) {
return IconLoader.getIcon(path, VcsLogIcons.class);
}
@@ -17,5 +16,4 @@
public static final Icon CollapseBranches = load("/icons/CollapseBranches.png"); // 16x16
public static final Icon ExpandBranches = load("/icons/ExpandBranches.png"); // 16x16
public static final Icon ShowHideLongEdges = load("/icons/ShowHideLongEdges.png"); // 16x16
-
}
diff --git a/platform/vcs-log/graph/test/com/intellij/vcs/log/parser/SimpleHash.java b/platform/vcs-log/impl/test/com/intellij/vcs/log/SimpleHash.java
similarity index 94%
rename from platform/vcs-log/graph/test/com/intellij/vcs/log/parser/SimpleHash.java
rename to platform/vcs-log/impl/test/com/intellij/vcs/log/SimpleHash.java
index 1265597..26b93e4 100644
--- a/platform/vcs-log/graph/test/com/intellij/vcs/log/parser/SimpleHash.java
+++ b/platform/vcs-log/impl/test/com/intellij/vcs/log/SimpleHash.java
@@ -13,9 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.intellij.vcs.log.parser;
+package com.intellij.vcs.log;
-import com.intellij.vcs.log.Hash;
import org.jetbrains.annotations.NotNull;
/**
diff --git a/platform/vcs-log/graph/test/com/intellij/vcs/log/parser/SimpleCommit.java b/platform/vcs-log/impl/test/com/intellij/vcs/log/SimpleTimedVcsCommit.java
similarity index 82%
rename from platform/vcs-log/graph/test/com/intellij/vcs/log/parser/SimpleCommit.java
rename to platform/vcs-log/impl/test/com/intellij/vcs/log/SimpleTimedVcsCommit.java
index 7b9f09f..195d0c0 100644
--- a/platform/vcs-log/graph/test/com/intellij/vcs/log/parser/SimpleCommit.java
+++ b/platform/vcs-log/impl/test/com/intellij/vcs/log/SimpleTimedVcsCommit.java
@@ -13,21 +13,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.intellij.vcs.log.parser;
+package com.intellij.vcs.log;
-import com.intellij.vcs.log.Hash;
-import com.intellij.vcs.log.TimedVcsCommit;
import org.jetbrains.annotations.NotNull;
import java.util.List;
-public class SimpleCommit implements TimedVcsCommit {
+public class SimpleTimedVcsCommit implements TimedVcsCommit {
private final Hash myHash;
private final List<Hash> myParents;
private final long myTime;
- public SimpleCommit(Hash commitHash, List<Hash> parentHashes, long time) {
+ public SimpleTimedVcsCommit(Hash commitHash, List<Hash> parentHashes, long time) {
myHash = commitHash;
myParents = parentHashes;
myTime = time;
@@ -55,7 +53,7 @@
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
- SimpleCommit commit = (SimpleCommit)o;
+ SimpleTimedVcsCommit commit = (SimpleTimedVcsCommit)o;
if (myHash != null ? !myHash.equals(commit.myHash) : commit.myHash != null) return false;
diff --git a/platform/vcs-log/impl/test/com/intellij/vcs/log/TimedCommitParser.java b/platform/vcs-log/impl/test/com/intellij/vcs/log/TimedCommitParser.java
new file mode 100644
index 0000000..2489ff5
--- /dev/null
+++ b/platform/vcs-log/impl/test/com/intellij/vcs/log/TimedCommitParser.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.vcs.log;
+
+import com.intellij.util.Function;
+import com.intellij.util.containers.ContainerUtil;
+import com.intellij.vcs.log.parser.CommitParser;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ *
+ */
+public class TimedCommitParser {
+
+ /**
+ * @param line 1231423|-adada|-193 adf45
+ * timestamp|-hash commit|-parent hashes
+ */
+ @NotNull
+ public static TimedVcsCommit parseTimestampParentHashes(@NotNull String line) {
+ int firstSeparatorIndex = CommitParser.nextSeparatorIndex(line, 0);
+ String timestampStr = line.substring(0, firstSeparatorIndex);
+ long timestamp;
+ try {
+ if (timestampStr.isEmpty()) {
+ timestamp = 0;
+ }
+ else {
+ timestamp = Long.parseLong(timestampStr);
+ }
+ }
+ catch (NumberFormatException e) {
+ throw new IllegalArgumentException("bad timestamp in line: " + line);
+ }
+ GraphCommit commit = CommitParser.parseCommitParents(line.substring(firstSeparatorIndex + 2));
+ List<Hash> parents = ContainerUtil.newArrayList();
+ for (int p : commit.getParentIndices()) {
+ parents.add(intToHash(p));
+ }
+ return new SimpleTimedVcsCommit(intToHash(commit.getIndex()), parents, timestamp);
+ }
+
+ private static Hash intToHash(int index) {
+ return new SimpleHash(Integer.toHexString(index));
+ }
+
+ @NotNull
+ public static List<TimedVcsCommit> log(@NotNull String... commits) {
+ return ContainerUtil.map(Arrays.asList(commits), new Function<String, TimedVcsCommit>() {
+ @Override
+ public TimedVcsCommit fun(String commit) {
+ return parseTimestampParentHashes(commit);
+ }
+ });
+ }
+
+}
diff --git a/platform/vcs-log/impl/test/com/intellij/vcs/log/data/VcsLogJoinerTest.java b/platform/vcs-log/impl/test/com/intellij/vcs/log/data/VcsLogJoinerTest.java
index e24ca17..1618e49 100644
--- a/platform/vcs-log/impl/test/com/intellij/vcs/log/data/VcsLogJoinerTest.java
+++ b/platform/vcs-log/impl/test/com/intellij/vcs/log/data/VcsLogJoinerTest.java
@@ -3,13 +3,11 @@
import com.intellij.openapi.vfs.newvfs.impl.StubVirtualFile;
import com.intellij.util.ArrayUtil;
import com.intellij.util.Function;
+import com.intellij.util.NotNullFunction;
import com.intellij.util.containers.ContainerUtil;
-import com.intellij.vcs.log.TimedVcsCommit;
-import com.intellij.vcs.log.VcsRef;
-import com.intellij.vcs.log.VcsRefType;
+import com.intellij.vcs.log.*;
import com.intellij.vcs.log.impl.VcsRefImpl;
-import com.intellij.vcs.log.parser.CommitParser;
-import com.intellij.vcs.log.parser.SimpleHash;
+import com.intellij.vcs.log.SimpleHash;
import org.jetbrains.annotations.NotNull;
import org.junit.Test;
@@ -26,8 +24,8 @@
public class VcsLogJoinerTest {
public void runTest(List<String> initial, List<String> updateBlock, List<String> oldRefs, List<String> newRefs, String expected) {
- List<TimedVcsCommit> savedLog = CommitParser.log(ArrayUtil.toStringArray(initial));
- List<? extends TimedVcsCommit> firstBlock = CommitParser.log(ArrayUtil.toStringArray(updateBlock));
+ List<TimedVcsCommit> savedLog = TimedCommitParser.log(ArrayUtil.toStringArray(initial));
+ List<? extends TimedVcsCommit> firstBlock = TimedCommitParser.log(ArrayUtil.toStringArray(updateBlock));
Collection<VcsRef> vcsOldRefs = ContainerUtil.map(oldRefs, new Function<String, VcsRef>() {
@Override
public VcsRef fun(String s) {
@@ -112,7 +110,13 @@
}
private static VcsRef ref(String name, String hash) {
- return new VcsRefImpl(new SimpleHash(hash), name, new VcsRefType() {
+ return new VcsRefImpl(new NotNullFunction<Hash, Integer>() {
+ @NotNull
+ @Override
+ public Integer fun(Hash hash) {
+ return Integer.parseInt(hash.asString().substring(0, Math.min(4, hash.asString().length())), 16);
+ }
+ }, new SimpleHash(hash), name, new VcsRefType() {
@Override
public boolean isBranch() {
return true;
diff --git a/platform/vcs-log/impl/test/com/intellij/vcs/log/data/VcsLogMultiRepoJoinerTest.java b/platform/vcs-log/impl/test/com/intellij/vcs/log/data/VcsLogMultiRepoJoinerTest.java
index 2f446b2..ce48e731 100644
--- a/platform/vcs-log/impl/test/com/intellij/vcs/log/data/VcsLogMultiRepoJoinerTest.java
+++ b/platform/vcs-log/impl/test/com/intellij/vcs/log/data/VcsLogMultiRepoJoinerTest.java
@@ -6,7 +6,7 @@
import java.util.Arrays;
import java.util.List;
-import static com.intellij.vcs.log.parser.CommitParser.log;
+import static com.intellij.vcs.log.TimedCommitParser.log;
import static org.junit.Assert.assertEquals;
/**
@@ -16,9 +16,9 @@
@Test
public void joinTest() {
- List<TimedVcsCommit> first = log("6|-a2|-a0", "3|-a1|-a0", "1|-a0|-");
- List<TimedVcsCommit> second = log("4|-b1|-b0", "2|-b0|-");
- List<TimedVcsCommit> third = log("7|-c1|-c0", "5|-c0|-");
+ List<? extends TimedVcsCommit> first = log("6|-a2|-a0", "3|-a1|-a0", "1|-a0|-");
+ List<? extends TimedVcsCommit> second = log("4|-b1|-b0", "2|-b0|-");
+ List<? extends TimedVcsCommit> third = log("7|-c1|-c0", "5|-c0|-");
List<TimedVcsCommit> expected = log("7|-c1|-c0", "6|-a2|-a0", "5|-c0|-", "4|-b1|-b0", "3|-a1|-a0", "2|-b0|-", "1|-a0|-");
diff --git a/platform/vcs-log/impl/vcs-log-impl.iml b/platform/vcs-log/impl/vcs-log-impl.iml
index b6bb13b..fb1cf7b 100644
--- a/platform/vcs-log/impl/vcs-log-impl.iml
+++ b/platform/vcs-log/impl/vcs-log-impl.iml
@@ -18,6 +18,8 @@
<orderEntry type="module" module-name="vcs-impl" />
<orderEntry type="library" name="Guava" level="project" />
<orderEntry type="library" name="JUnit4" level="project" />
+ <orderEntry type="module" module-name="lang-impl" />
+ <orderEntry type="module" module-name="spellchecker" />
</component>
</module>
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java
index 905e7f9..00f64af 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java
@@ -38,10 +38,14 @@
import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.markup.GutterIconRenderer;
+import com.intellij.openapi.fileEditor.FileEditorManager;
+import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.ToolWindowId;
import com.intellij.ui.AppUIUtil;
import com.intellij.util.EventDispatcher;
@@ -489,6 +493,7 @@
private void doResume() {
if (!myPaused.getAndSet(false)) return;
+ final XSourcePosition oldPosition = myCurrentPosition;
myDispatcher.getMulticaster().beforeSessionResume();
myDebuggerManager.setActiveSession(this, null, false, null);
mySuspendContext = null;
@@ -502,6 +507,9 @@
if (mySessionTab != null) {
mySessionTab.getUi().clearAttractionBy(XDebuggerUIConstants.LAYOUT_VIEW_BREAKPOINT_CONDITION);
}
+ if (oldPosition != null) {
+ adjustMouseTrackingCounter(oldPosition, -1);
+ }
}
});
myDispatcher.getMulticaster().sessionResumed();
@@ -730,11 +738,39 @@
}
mySessionTab.toFront();
mySessionTab.getUi().attractBy(XDebuggerUIConstants.LAYOUT_VIEW_BREAKPOINT_CONDITION);
+ if (myCurrentPosition != null) {
+ adjustMouseTrackingCounter(myCurrentPosition, 1);
+ }
}
});
myDispatcher.getMulticaster().sessionPaused();
}
+ private Editor getEditor(@NotNull XSourcePosition position) {
+ final VirtualFile psiFile = position.getFile();
+ if (!psiFile.isValid()) {
+ return null;
+ }
+
+ final int offset = position.getOffset();
+ if (offset < 0 || offset > psiFile.getLength()) {
+ LOG.error("Incorrect offset " + offset + " in file " + psiFile.getName());
+ return null;
+ }
+
+ return FileEditorManager.getInstance(myProject).openTextEditor(new OpenFileDescriptor(myProject, psiFile, offset), false);
+ }
+
+ private void adjustMouseTrackingCounter(@NotNull XSourcePosition position, int increment) {
+ final Editor editor = getEditor(position);
+ if (editor != null) {
+ JComponent component = editor.getComponent();
+ Object o = component.getClientProperty(Editor.IGNORE_MOUSE_TRACKING);
+ Integer value = ((o instanceof Integer) ? (Integer)o : 0) + increment;
+ component.putClientProperty(Editor.IGNORE_MOUSE_TRACKING, value > 0 ? value : null);
+ }
+ }
+
@Override
public void sessionResumed() {
doResume();
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointsDialog.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointsDialog.java
index 1925df1..1363d72 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointsDialog.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointsDialog.java
@@ -270,13 +270,19 @@
}
return enabled;
}
- });
+ }).
+ setToolbarPosition(ActionToolbarPosition.TOP).
+ setToolbarBorder(IdeBorderFactory.createEmptyBorder());
+
+ tree.setBorder(IdeBorderFactory.createBorder());
for (ToggleActionButton action : myToggleRuleActions) {
decorator.addExtraAction(action);
}
JPanel decoratedTree = decorator.createPanel();
+ decoratedTree.setBorder(IdeBorderFactory.createEmptyBorder());
+
myTreeController.setTreeView(tree);
myTreeController.buildTree(myBreakpointItems);
diff --git a/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/ShowByteCodeAction.java b/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/ShowByteCodeAction.java
index 6d455d3..9add783 100644
--- a/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/ShowByteCodeAction.java
+++ b/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/ShowByteCodeAction.java
@@ -37,6 +37,7 @@
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
import com.intellij.psi.util.PsiUtilBase;
import com.intellij.psi.util.PsiUtilCore;
+import com.intellij.ui.awt.RelativePoint;
import com.intellij.ui.popup.NotLookupOrSearchCondition;
import com.intellij.ui.popup.PopupPositionManager;
import com.intellij.util.Processor;
@@ -79,6 +80,8 @@
final VirtualFile virtualFile = PsiUtilCore.getVirtualFile(psiElement);
if (virtualFile == null) return;
+ final RelativePoint bestPopupLocation = JBPopupFactory.getInstance().guessBestPopupLocation(dataContext);
+
final SmartPsiElementPointer element = SmartPointerManager.getInstance(project).createSmartPsiElementPointer(psiElement);
ProgressManager.getInstance().run(new Task.Backgroundable(project, "Searching byte code...") {
private String myByteCode;
@@ -145,7 +148,11 @@
.createPopup();
Disposer.register(popup, component);
- PopupPositionManager.positionPopupInBestPosition(popup, editor, dataContext);
+ if (editor != null) {
+ popup.showInBestPositionFor(editor);
+ } else {
+ popup.show(bestPopupLocation);
+ }
}
}
});
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/META-INF/InspectionGadgets.xml b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/META-INF/InspectionGadgets.xml
index 1ca8290..8ebb212 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/META-INF/InspectionGadgets.xml
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/META-INF/InspectionGadgets.xml
@@ -760,6 +760,10 @@
<localInspection language="JAVA" shortName="LawOfDemeter" bundle="com.siyeh.InspectionGadgetsBundle" key="law.of.demeter.display.name"
groupBundle="messages.InspectionsBundle" groupKey="group.names.data.flow.issues" enabledByDefault="false"
level="WARNING" implementationClass="com.siyeh.ig.dataflow.LawOfDemeterInspection"/>
+ <localInspection language="JAVA" shortName="NegativelyNamedBooleanVariable" bundle="com.siyeh.InspectionGadgetsBundle"
+ key="negatively.named.boolean.variable.display.name" groupBundle="messages.InspectionsBundle"
+ groupKey="group.names.data.flow.issues" enabledByDefault="false" level="WARNING"
+ implementationClass="com.siyeh.ig.dataflow.NegativelyNamedBooleanVariableInspection"/>
<localInspection language="JAVA" shortName="OrredNotEqualExpression" bundle="com.siyeh.InspectionGadgetsBundle"
key="orred.not.equal.expression.display.name" groupBundle="messages.InspectionsBundle"
groupKey="group.names.data.flow.issues" enabledByDefault="true" level="WARNING"
@@ -1014,6 +1018,10 @@
bundle="com.siyeh.InspectionGadgetsBundle" key="non.protected.constructor.in.abstract.class.display.name"
groupBundle="messages.InspectionsBundle" groupKey="group.names.inheritance.issues" enabledByDefault="false"
level="WARNING" implementationClass="com.siyeh.ig.inheritance.NonProtectedConstructorInAbstractClassInspection"/>
+ <localInspection language="JAVA" shortName="ProblematicVarargsMethodOverride" bundle="com.siyeh.InspectionGadgetsBundle"
+ key="problematic.varargs.method.display.name" groupBundle="messages.InspectionsBundle"
+ groupKey="group.names.inheritance.issues" enabledByDefault="false" level="WARNING"
+ implementationClass="com.siyeh.ig.inheritance.ProblematicVarargsMethodOverrideInspection"/>
<localInspection language="JAVA" shortName="RedundantMethodOverride" bundle="com.siyeh.InspectionGadgetsBundle"
key="redundant.method.override.display.name" groupBundle="messages.InspectionsBundle"
groupKey="group.names.inheritance.issues" enabledByDefault="false" level="WARNING"
@@ -2388,6 +2396,10 @@
key="size.replaceable.by.isempty.display.name" groupBundle="messages.InspectionsBundle"
groupKey="group.names.code.style.issues" enabledByDefault="false" level="WARNING"
implementationClass="com.siyeh.ig.style.SizeReplaceableByIsEmptyInspection"/>
+ <localInspection language="JAVA" shortName="ProblematicWhitespace" bundle="com.siyeh.InspectionGadgetsBundle"
+ key="problematic.whitespace.display.name" groupBundle="messages.InspectionsBundle"
+ groupKey="group.names.code.style.issues" enabledByDefault="false" level="WARNING"
+ implementationClass="com.siyeh.ig.style.ProblematicWhitespaceInspection"/>
<!--group.names.threading.issues-->
<localInspection language="JAVA" suppressId="AccessToNonThreadSafeStaticField" shortName="AccessToNonThreadSafeStaticFieldFromInstance"
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties
index 1f3e7e8..36709b6 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties
@@ -910,7 +910,7 @@
final.method.problem.descriptor=Method declared <code>#ref</code> #loc
class.initializer.problem.descriptor=Non-'static' initializer #loc
class.may.be.interface.problem.descriptor=<code>#ref</code> may be interface #loc
-non.protected.constructor.in.abstract.class.problem.descriptor=Constructor <code>#ref</code> is not declared 'protected' in 'abstract' class #loc
+non.protected.constructor.in.abstract.class.problem.descriptor=Constructor <code>#ref()</code> is not declared 'protected' in 'abstract' class #loc
class.without.constructor.problem.descriptor=Class <code>#ref</code> has no constructor #loc
abstract.class.without.abstract.methods.problem.descriptor=Class <code>#ref</code> is declared 'abstract', and has no 'abstract' methods #loc
final.method.in.final.class.problem.descriptor=Method declared <code>#ref</code> in 'final' class #loc
@@ -1428,7 +1428,7 @@
replace.indexof.with.contains.quickfix=Replace 'indexOf()' with 'contains()'
overloaded.methods.with.same.number.parameters.problem.descriptor=Multiple methods named <code>#ref</code> with the same number of parameters #loc
overloaded.vararg.method.problem.descriptor=Overloaded variable argument method <code>#ref()</code> #loc
-overloaded.vararg.constructor.problem.descriptor=Overloaded variable argument constructor <code>#ref</code> #loc
+overloaded.vararg.constructor.problem.descriptor=Overloaded variable argument constructor <code>#ref()</code> #loc
cached.number.constructor.call.display.name=Number constructor call with primitive argument
cached.number.constructor.call.problem.descriptor=Number constructor call with primitive argument <code>#ref</code> #loc
cached.number.constructor.call.quickfix=Replace with ''{0}.valueOf()'' call
@@ -1731,7 +1731,8 @@
field.may.be.final.problem.descriptor=Field <code>#ref</code> may be 'final' #loc
cast.that.loses.precision.option=Ignore casts from int to char
variable.not.used.inside.if.display.name=Reference checked for 'null' is not used inside 'if'
-variable.not.used.inside.if.problem.descriptor=<code>#ref</code> is not used inside if #loc
+variable.not.used.inside.if.problem.descriptor=<code>#ref</code> checked for 'null' is not used inside 'if' #loc
+variable.not.used.inside.conditional.problem.descriptor=<code>#ref</code> checked for 'null' is not used inside conditional #loc
if.may.be.conditional.display.name='if' statement could be replaced with conditional expression
if.may.be.conditional.problem.descriptor=<code>#ref</code> could be replaced with conditional expression #loc
if.may.be.conditional.quickfix=Replace with conditional expression
@@ -1901,7 +1902,7 @@
method.can.be.variable.arity.method.display.name=Method can be variable arity method
method.can.be.variable.arity.method.problem.descriptor=<code>#ref()</code> can be converted to variable arity method #loc
method.can.be.variable.arity.method.ignore.byte.short.option=<html>Ignore methods with a last parameter of type byte[] or short[]</html>
-convert.to.variable.arity.method.quickfix=Convert to variable arity method
+convert.to.variable.arity.method.quickfix=Convert to varargs method
mismatched.string.builder.query.update.display.name=Mismatched query and update of StringBuilder
mismatched.string.builder.updated.problem.descriptor=Contents of {0} <code>#ref</code> are updated, but never queried #loc
mismatched.string.builder.queried.problem.descriptor=Contents of {0} <code>#ref</code> are queried, but never updated #loc
@@ -2026,7 +2027,7 @@
placeholder.count.matches.argument.count.more.problem.descriptor=<code>#ref()</code> call has more arguments ({0}) than placeholders ({1}) #loc
placeholder.count.matches.argument.count.fewer.problem.descriptor=<code>#ref()</code> call has fewer arguments ({0}) than placeholders ({1}) #loc
assignment.to.superclass.field.display.name=Constructor assigns value to field defined in superclass
-assignment.to.superclass.field.problem.descriptor=Assignment to field ''{0}'' defined in superclass ''{1}''
+assignment.to.superclass.field.problem.descriptor=Assignment to field ''{0}'' defined in superclass ''{1}'' #loc
junit.rule.display.name=Malformed @Rule/@ClassRule field
junit.rule.problem.descriptor=Fields annotated with @{0} should be {1}
junit.rule.type.problem.descriptor=Field type should be subtype of org.junit.rules.TestRule
@@ -2036,13 +2037,13 @@
inner.class.referenced.via.subclass.problem.descriptor=Inner class <code>#ref</code> declared in class ''{0}'' but referenced via subclass ''{1}'' #loc
inner.class.referenced.via.subclass.quickfix=Rationalize inner class access
boolean.parameter.display.name='public' method with 'boolean' parameter
-boolean.parameter.problem.descriptor='public' method <code>#ref</code> with 'boolean' parameter
-boolean.parameters.problem.descriptor='public' method <code>#ref</code> with 'boolean' parameters
-boolean.parameter.constructor.problem.descriptor='public' constructor <code>#ref</code> with 'boolean' parameter
-boolean.parameters.constructor.problem.descriptor='public' constructor <code>#ref</code> with 'boolean' parameters
+boolean.parameter.problem.descriptor='public' method <code>#ref()</code> with 'boolean' parameter #loc
+boolean.parameters.problem.descriptor='public' method <code>#ref()</code> with 'boolean' parameters #loc
+boolean.parameter.constructor.problem.descriptor='public' constructor <code>#ref()</code> with 'boolean' parameter #loc
+boolean.parameters.constructor.problem.descriptor='public' constructor <code>#ref()</code> with 'boolean' parameters #loc
boolean.parameter.only.report.multiple.option=Only report methods with multiple boolean parameters
unnecessary.unicode.escape.display.name=Unnecessary unicode escape sequence
-unnecessary.unicode.escape.problem.descriptor=Unicode escape sequence <code>#ref</code> can be replaced with ''{0}''
+unnecessary.unicode.escape.problem.descriptor=Unicode escape sequence <code>#ref</code> can be replaced with ''{0}'' #loc
missing.package.info.display.name=Missing 'package-info.java'
missing.package.info.problem.descriptor=Package ''{0}'' is missing a <code>package-info.java</code> file
missing.package.html.problem.descriptor=Package ''{0}'' is missing a <code>package.html</code> file
@@ -2051,5 +2052,16 @@
package.info.without.package.quickfix=add ''package {0};''
package.info.without.package.family.quickfix=add package statement
auto.closeable.resource.display.name=AutoCloseable used without 'try'-with-resources
-auto.closeable.resource.problem.descriptor=''{0}'' used without ''try''-with-resources statement
+auto.closeable.resource.problem.descriptor=''{0}'' used without ''try''-with-resources statement #loc
auto.closeable.resource.returned.option=Ignore AutoCloseable instances returned from method calls
+problematic.whitespace.display.name=Problematic whitespace
+problematic.whitespace.tabs.problem.descriptor=File ''{0}'' uses tabs for indentation
+problematic.whitespace.spaces.problem.descriptor=File ''{0}'' uses spaces for indentation
+problematic.whitespace.show.whitespaces.quickfix=Toggle show whitespace in the editor
+problematic.varargs.method.display.name=Non-varargs method overrides varargs method
+problematic.varargs.method.override.problem.descriptor=Non-varargs method <code>#ref()</code> overrides varargs method #loc
+negatively.named.boolean.variable.problem.descriptor=Boolean variable <code>#ref</code> is negatively named #loc
+negatively.named.boolean.variable.display.name=Negatively named boolean variable
+invert.quickfix.family.name=Invert boolean
+invert.method.quickfix=Invert method
+invert.quickfix=Invert ''{0}''
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/BaseInspectionVisitor.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/BaseInspectionVisitor.java
index 028b359..1ba34a6 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/BaseInspectionVisitor.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/BaseInspectionVisitor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2012 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2013 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -222,17 +222,10 @@
}
@Override
- public void visitReferenceExpression(
- PsiReferenceExpression expression) {
+ public void visitReferenceExpression(PsiReferenceExpression expression) {
visitExpression(expression);
}
- @Override
- public final void visitWhiteSpace(PsiWhiteSpace space) {
- // none of our inspections need to do anything with white space,
- // so this is a performance optimization
- }
-
public final void setProblemsHolder(ProblemsHolder holder) {
this.holder = holder;
}
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/VariableNotUsedInsideIfInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/VariableNotUsedInsideIfInspection.java
index f6dc0e4..bae56e9 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/VariableNotUsedInsideIfInspection.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/VariableNotUsedInsideIfInspection.java
@@ -31,15 +31,19 @@
@Nls
@NotNull
public String getDisplayName() {
- return InspectionGadgetsBundle.message(
- "variable.not.used.inside.if.display.name");
+ return InspectionGadgetsBundle.message("variable.not.used.inside.if.display.name");
}
@Override
@NotNull
protected String buildErrorString(Object... infos) {
- return InspectionGadgetsBundle.message(
- "variable.not.used.inside.if.problem.descriptor");
+ final boolean isIf = ((Boolean)infos[0]).booleanValue();
+ if (isIf) {
+ return InspectionGadgetsBundle.message("variable.not.used.inside.if.problem.descriptor");
+ }
+ else {
+ return InspectionGadgetsBundle.message("variable.not.used.inside.conditional.problem.descriptor");
+ }
}
@Override
@@ -63,10 +67,14 @@
}
final IElementType tokenType = binaryExpression.getOperationTokenType();
if (tokenType == JavaTokenType.EQEQ) {
- checkVariableUsage(referenceExpression, expression.getThenExpression(), expression.getElseExpression());
+ if (checkVariableUsage(referenceExpression, expression.getThenExpression(), expression.getElseExpression())) {
+ registerError(referenceExpression, Boolean.FALSE);
+ }
}
else if (tokenType == JavaTokenType.NE) {
- checkVariableUsage(referenceExpression, expression.getElseExpression(), expression.getThenExpression());
+ if (checkVariableUsage(referenceExpression, expression.getElseExpression(), expression.getThenExpression())) {
+ registerError(referenceExpression, Boolean.FALSE);
+ }
}
}
@@ -84,29 +92,30 @@
}
final IElementType tokenType = binaryExpression.getOperationTokenType();
if (tokenType == JavaTokenType.EQEQ) {
- checkVariableUsage(referenceExpression, statement.getThenBranch(), statement.getElseBranch());
+ if (checkVariableUsage(referenceExpression, statement.getThenBranch(), statement.getElseBranch())) {
+ registerError(referenceExpression, Boolean.TRUE);
+ }
}
else if (tokenType == JavaTokenType.NE) {
- checkVariableUsage(referenceExpression, statement.getElseBranch(), statement.getThenBranch());
+ if (checkVariableUsage(referenceExpression, statement.getElseBranch(), statement.getThenBranch())) {
+ registerError(referenceExpression, Boolean.TRUE);
+ }
}
}
- private void checkVariableUsage(PsiReferenceExpression referenceExpression, PsiElement thenContext, PsiElement elseContext) {
- if (thenContext == null) {
- return;
- }
+ private boolean checkVariableUsage(PsiReferenceExpression referenceExpression, PsiElement thenContext, PsiElement elseContext) {
final PsiElement target = referenceExpression.resolve();
if (!(target instanceof PsiVariable)) {
- return;
+ return false;
}
final PsiVariable variable = (PsiVariable)target;
- if (contextExits(thenContext) || VariableAccessUtils.variableIsAssigned(variable, thenContext)) {
- return;
+ if (thenContext != null && (contextExits(thenContext) || VariableAccessUtils.variableIsAssigned(variable, thenContext))) {
+ return false;
}
- if (elseContext != null && (contextExits(elseContext) || VariableAccessUtils.variableIsUsed(variable, elseContext))) {
- return;
+ if (elseContext == null || VariableAccessUtils.variableIsUsed(variable, elseContext)) {
+ return false;
}
- registerError(referenceExpression);
+ return true;
}
private static PsiReferenceExpression extractVariableReference(PsiBinaryExpression expression) {
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/dataflow/NegativelyNamedBooleanVariableInspectionBase.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/dataflow/NegativelyNamedBooleanVariableInspectionBase.java
new file mode 100644
index 0000000..0d3ba03
--- /dev/null
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/dataflow/NegativelyNamedBooleanVariableInspectionBase.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.siyeh.ig.dataflow;
+
+import com.intellij.psi.PsiType;
+import com.intellij.psi.PsiVariable;
+import com.siyeh.InspectionGadgetsBundle;
+import com.siyeh.ig.BaseInspection;
+import com.siyeh.ig.BaseInspectionVisitor;
+import org.jetbrains.annotations.Nls;
+import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author Bas Leijdekkers
+ */
+public class NegativelyNamedBooleanVariableInspectionBase extends BaseInspection {
+
+ @NonNls
+ private static final String[] NEGATIVE_NAMES = {"not", "isNot", "shouldNot", "shallNot", "willNot", "cannot", "cant", "hasNot",
+ "couldNot", "hidden", "isHidden", "disabled", "isDisabled"};
+
+ @Nls
+ @NotNull
+ @Override
+ public String getDisplayName() {
+ return InspectionGadgetsBundle.message("negatively.named.boolean.variable.display.name");
+ }
+
+ @NotNull
+ @Override
+ protected String buildErrorString(Object... infos) {
+ return InspectionGadgetsBundle.message("negatively.named.boolean.variable.problem.descriptor");
+ }
+
+ @Override
+ public BaseInspectionVisitor buildVisitor() {
+ return new NegativelyNamedBooleanVariableVisitor();
+ }
+
+ private static class NegativelyNamedBooleanVariableVisitor extends BaseInspectionVisitor {
+
+ @Override
+ public void visitVariable(PsiVariable variable) {
+ super.visitVariable(variable);
+ if (!PsiType.BOOLEAN.equals(variable.getType())) {
+ return;
+ }
+ final String name = variable.getName();
+ for (final String negativeName : NEGATIVE_NAMES) {
+ if (name.startsWith(negativeName) &&
+ (name.length() == negativeName.length() || Character.isUpperCase(name.charAt(negativeName.length())))) {
+ registerVariableError(variable, variable);
+ break;
+ }
+ }
+ }
+ }
+}
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/fixes/ConvertToVarargsMethodFix.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/fixes/ConvertToVarargsMethodFix.java
new file mode 100644
index 0000000..2c0212f
--- /dev/null
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/fixes/ConvertToVarargsMethodFix.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.siyeh.ig.fixes;
+
+import com.intellij.codeInsight.FileModificationService;
+import com.intellij.codeInspection.ProblemDescriptor;
+import com.intellij.openapi.project.Project;
+import com.intellij.psi.*;
+import com.intellij.psi.search.searches.ReferencesSearch;
+import com.intellij.util.IncorrectOperationException;
+import com.intellij.util.Query;
+import com.siyeh.InspectionGadgetsBundle;
+import com.siyeh.ig.InspectionGadgetsFix;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * @author Bas Leijdekkers
+ */
+public class ConvertToVarargsMethodFix extends InspectionGadgetsFix {
+
+ @Override
+ @NotNull
+ public String getFamilyName() {
+ return getName();
+ }
+
+ @NotNull
+ @Override
+ public String getName() {
+ return InspectionGadgetsBundle.message("convert.to.variable.arity.method.quickfix");
+ }
+
+ @Override
+ protected boolean prepareForWriting() {
+ return false;
+ }
+
+ @Override
+ protected void doFix(Project project, ProblemDescriptor descriptor) {
+ final PsiElement element = descriptor.getPsiElement();
+ final PsiElement parent = element.getParent();
+ if (!(parent instanceof PsiMethod)) {
+ return;
+ }
+ final PsiMethod method = (PsiMethod)parent;
+ final Collection<PsiElement> writtenElements = new ArrayList<PsiElement>();
+ final Collection<PsiReferenceExpression> methodCalls = new ArrayList<PsiReferenceExpression>();
+ writtenElements.add(method);
+ for (final PsiReference reference : ReferencesSearch.search(method, method.getUseScope(), false)) {
+ final PsiElement referenceElement = reference.getElement();
+ if (referenceElement instanceof PsiReferenceExpression) {
+ writtenElements.add(referenceElement);
+ methodCalls.add((PsiReferenceExpression)referenceElement);
+ }
+ }
+ if (!FileModificationService.getInstance().preparePsiElementsForWrite(writtenElements)) {
+ return;
+ }
+ makeMethodVarargs(method);
+ makeMethodCallsVarargs(methodCalls);
+ }
+
+ private static void makeMethodVarargs(PsiMethod method) {
+ final PsiParameterList parameterList = method.getParameterList();
+ if (parameterList.getParametersCount() == 0) {
+ return;
+ }
+ final PsiParameter[] parameters = parameterList.getParameters();
+ final PsiParameter lastParameter = parameters[parameters.length - 1];
+ final PsiType type = lastParameter.getType();
+ if (!(type instanceof PsiArrayType)) {
+ return;
+ }
+ final PsiArrayType arrayType = (PsiArrayType)type;
+ final PsiType componentType = arrayType.getComponentType();
+ final PsiElementFactory factory = JavaPsiFacade.getElementFactory(method.getProject());
+ final PsiType ellipsisType = PsiEllipsisType.createEllipsis(componentType, type.getAnnotations());
+ final PsiTypeElement newTypeElement = factory.createTypeElement(ellipsisType);
+ final PsiTypeElement typeElement = lastParameter.getTypeElement();
+ if (typeElement != null) {
+ typeElement.replace(newTypeElement);
+ }
+ }
+
+ private static void makeMethodCallsVarargs(Collection<PsiReferenceExpression> referenceExpressions) {
+ for (final PsiReferenceExpression referenceExpression : referenceExpressions) {
+ final PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression)referenceExpression.getParent();
+ final PsiExpressionList argumentList = methodCallExpression.getArgumentList();
+ final PsiExpression[] arguments = argumentList.getExpressions();
+ if (arguments.length == 0) {
+ continue;
+ }
+ final PsiExpression lastArgument = arguments[arguments.length - 1];
+ if (!(lastArgument instanceof PsiNewExpression)) {
+ continue;
+ }
+ final PsiNewExpression newExpression = (PsiNewExpression)lastArgument;
+ final PsiArrayInitializerExpression arrayInitializerExpression = newExpression.getArrayInitializer();
+ if (arrayInitializerExpression == null) {
+ continue;
+ }
+ final PsiExpression[] initializers = arrayInitializerExpression.getInitializers();
+ for (final PsiExpression initializer : initializers) {
+ argumentList.add(initializer);
+ }
+ lastArgument.delete();
+ }
+ }
+}
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/inheritance/ProblematicVarargsMethodOverrideInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/inheritance/ProblematicVarargsMethodOverrideInspection.java
new file mode 100644
index 0000000..bf121ff
--- /dev/null
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/inheritance/ProblematicVarargsMethodOverrideInspection.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.siyeh.ig.inheritance;
+
+import com.intellij.psi.*;
+import com.siyeh.InspectionGadgetsBundle;
+import com.siyeh.ig.BaseInspection;
+import com.siyeh.ig.BaseInspectionVisitor;
+import com.siyeh.ig.InspectionGadgetsFix;
+import com.siyeh.ig.fixes.ConvertToVarargsMethodFix;
+import org.jetbrains.annotations.Nls;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * @author Bas Leijdekkers
+ */
+public class ProblematicVarargsMethodOverrideInspection extends BaseInspection {
+
+ @Nls
+ @NotNull
+ @Override
+ public String getDisplayName() {
+ return InspectionGadgetsBundle.message("problematic.varargs.method.display.name");
+ }
+
+ @NotNull
+ @Override
+ protected String buildErrorString(Object... infos) {
+ return InspectionGadgetsBundle.message("problematic.varargs.method.override.problem.descriptor");
+ }
+
+ @Nullable
+ @Override
+ protected InspectionGadgetsFix buildFix(Object... infos) {
+ return new ConvertToVarargsMethodFix();
+ }
+
+ @Override
+ public BaseInspectionVisitor buildVisitor() {
+ return new NonVarargsMethodOverridesVarArgsMethodVisitor();
+ }
+
+ private static class NonVarargsMethodOverridesVarArgsMethodVisitor extends BaseInspectionVisitor {
+
+ @Override
+ public void visitMethod(PsiMethod method) {
+ super.visitMethod(method);
+ final PsiParameterList parameterList = method.getParameterList();
+ final PsiParameter[] parameters = parameterList.getParameters();
+ if (parameters.length == 0) {
+ return;
+ }
+ final PsiParameter parameter = parameters[parameters.length - 1];
+ final PsiType type = parameter.getType();
+ if (!(type instanceof PsiArrayType)) {
+ return;
+ }
+ final PsiMethod[] superMethods = method.findDeepestSuperMethods();
+ for (final PsiMethod superMethod : superMethods) {
+ if (superMethod.isVarArgs()) {
+ registerMethodError(method);
+ return;
+ }
+ }
+ }
+ }
+}
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/maturity/SuppressionAnnotationInspectionBase.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/maturity/SuppressionAnnotationInspectionBase.java
index e7bb246..2eb1cc3 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/maturity/SuppressionAnnotationInspectionBase.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/maturity/SuppressionAnnotationInspectionBase.java
@@ -62,9 +62,12 @@
&& !tokenType.equals(JavaTokenType.C_STYLE_COMMENT)) {
return;
}
- @NonNls final String strippedComment = commentText.substring(2).trim();
- if (strippedComment.startsWith(SuppressionUtilCore.SUPPRESS_INSPECTIONS_TAG_NAME)) {
- registerError(comment);
+
+ if (commentText.length() > 2) {
+ @NonNls final String strippedComment = commentText.substring(2).trim();
+ if (strippedComment.startsWith(SuppressionUtilCore.SUPPRESS_INSPECTIONS_TAG_NAME)) {
+ registerError(comment);
+ }
}
}
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/MethodCanBeVariableArityMethodInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/MethodCanBeVariableArityMethodInspection.java
index ef15918..74a0a9b 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/MethodCanBeVariableArityMethodInspection.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/MethodCanBeVariableArityMethodInspection.java
@@ -15,15 +15,14 @@
*/
package com.siyeh.ig.migration;
-import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel;
-import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiUtil;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
import com.siyeh.ig.InspectionGadgetsFix;
+import com.siyeh.ig.fixes.ConvertToVarargsMethodFix;
import com.siyeh.ig.psiutils.LibraryUtil;
import com.siyeh.ig.psiutils.MethodUtils;
import org.jetbrains.annotations.Nls;
@@ -64,49 +63,7 @@
@Override
protected InspectionGadgetsFix buildFix(Object... infos) {
- return new MethodCanBeVariableArityMethodFix();
- }
-
- private static class MethodCanBeVariableArityMethodFix extends InspectionGadgetsFix {
- @Override
- @NotNull
- public String getFamilyName() {
- return getName();
- }
-
- @NotNull
- @Override
- public String getName() {
- return InspectionGadgetsBundle.message("convert.to.variable.arity.method.quickfix");
- }
-
- @Override
- protected void doFix(Project project, ProblemDescriptor descriptor) {
- final PsiElement element = descriptor.getPsiElement();
- final PsiElement parent = element.getParent();
- if (!(parent instanceof PsiMethod)) {
- return;
- }
- final PsiMethod method = (PsiMethod)parent;
- final PsiParameterList parameterList = method.getParameterList();
- if (parameterList.getParametersCount() == 0) {
- return;
- }
- final PsiParameter[] parameters = parameterList.getParameters();
- final PsiParameter lastParameter = parameters[parameters.length - 1];
- final PsiType type = lastParameter.getType();
- if (!(type instanceof PsiArrayType)) {
- return;
- }
- final PsiArrayType arrayType = (PsiArrayType)type;
- final PsiType componentType = arrayType.getComponentType();
- final PsiElementFactory factory = JavaPsiFacade.getElementFactory(project);
- final PsiTypeElement newTypeElement = factory.createTypeElementFromText(componentType.getCanonicalText() + "...", method);
- final PsiTypeElement typeElement = lastParameter.getTypeElement();
- if (typeElement != null) {
- typeElement.replace(newTypeElement);
- }
- }
+ return new ConvertToVarargsMethodFix();
}
@Override
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/numeric/UnnecessaryExplicitNumericCastInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/numeric/UnnecessaryExplicitNumericCastInspection.java
index e8bf9a9..f7eeccf 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/numeric/UnnecessaryExplicitNumericCastInspection.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/numeric/UnnecessaryExplicitNumericCastInspection.java
@@ -140,7 +140,7 @@
}
}
- static boolean isPrimitiveNumericCastNecessary(PsiTypeCastExpression expression) {
+ public static boolean isPrimitiveNumericCastNecessary(PsiTypeCastExpression expression) {
final PsiType castType = expression.getType();
if (castType == null) {
return true;
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/DefiniteAssignment.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/DefiniteAssignment.java
index 893de08..325ddc2 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/DefiniteAssignment.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/DefiniteAssignment.java
@@ -13,11 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-/**
- * (c) 2013 Desert Island BV
- * created: 03 09 2013
- */
package com.siyeh.ig.psiutils;
import com.intellij.psi.*;
@@ -31,7 +26,7 @@
/**
* @author Bas Leijdekkers
*/
-public class DefiniteAssignment {
+class DefiniteAssignment {
@NotNull
private final PsiVariable variable;
diff --git a/plugins/InspectionGadgets/src/com/intellij/codeInspection/booleanIsAlwaysInverted/BooleanMethodIsAlwaysInvertedInspection.java b/plugins/InspectionGadgets/src/com/intellij/codeInspection/booleanIsAlwaysInverted/BooleanMethodIsAlwaysInvertedInspection.java
index 7642c92..8b847b7 100644
--- a/plugins/InspectionGadgets/src/com/intellij/codeInspection/booleanIsAlwaysInverted/BooleanMethodIsAlwaysInvertedInspection.java
+++ b/plugins/InspectionGadgets/src/com/intellij/codeInspection/booleanIsAlwaysInverted/BooleanMethodIsAlwaysInvertedInspection.java
@@ -15,60 +15,18 @@
*/
package com.intellij.codeInspection.booleanIsAlwaysInverted;
-import com.intellij.codeInspection.LocalQuickFix;
-import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.QuickFix;
-import com.intellij.ide.DataManager;
-import com.intellij.openapi.application.ApplicationManager;
-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.refactoring.JavaRefactoringActionHandlerFactory;
-import com.intellij.refactoring.RefactoringActionHandler;
-import org.jetbrains.annotations.NotNull;
+import com.siyeh.InspectionGadgetsBundle;
+import com.siyeh.ig.fixes.InvertBooleanFix;
/**
* User: anna
* Date: 06-Jan-2006
*/
public class BooleanMethodIsAlwaysInvertedInspection extends BooleanMethodIsAlwaysInvertedInspectionBase {
+
@Override
public QuickFix getQuickFix(final String hint) {
- return new InvertMethodFix();
+ return new InvertBooleanFix(InspectionGadgetsBundle.message("invert.method.quickfix"));
}
-
- private static class InvertMethodFix implements LocalQuickFix {
- @Override
- @NotNull
- public String getName() {
- return "Invert method";
- }
-
- @Override
- @NotNull
- public String getFamilyName() {
- return getName();
- }
-
- @Override
- public void applyFix(@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) {
- final PsiElement element = descriptor.getPsiElement();
- final PsiMethod psiMethod = PsiTreeUtil.getParentOfType(element, PsiMethod.class);
- assert psiMethod != null;
- final RefactoringActionHandler invertBooleanHandler = JavaRefactoringActionHandlerFactory.getInstance().createInvertBooleanHandler();
- final Runnable runnable = new Runnable() {
- @Override
- public void run() {
- invertBooleanHandler.invoke(project, new PsiElement[]{psiMethod}, DataManager.getInstance().getDataContext());
- }
- };
- if (ApplicationManager.getApplication().isUnitTestMode()) {
- runnable.run();
- }
- else {
- ApplicationManager.getApplication().invokeLater(runnable, project.getDisposed());
- }
- }
- }
-}
+}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/dataflow/BooleanVariableAlwaysNegatedInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/dataflow/BooleanVariableAlwaysNegatedInspection.java
index 1a69c90..0c9c286 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/dataflow/BooleanVariableAlwaysNegatedInspection.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/dataflow/BooleanVariableAlwaysNegatedInspection.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Bas Leijdekkers
+ * Copyright 2011-2013 Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,57 +15,16 @@
*/
package com.siyeh.ig.dataflow;
-import com.intellij.codeInspection.ProblemDescriptor;
-import com.intellij.openapi.project.Project;
-import com.intellij.psi.*;
-import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.refactoring.invertBoolean.InvertBooleanDialog;
-import com.intellij.util.IncorrectOperationException;
+import com.intellij.psi.PsiVariable;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.InspectionGadgetsFix;
-import org.jetbrains.annotations.NotNull;
+import com.siyeh.ig.fixes.InvertBooleanFix;
public class BooleanVariableAlwaysNegatedInspection extends BooleanVariableAlwaysNegatedInspectionBase {
@Override
protected InspectionGadgetsFix buildFix(Object... infos) {
final PsiVariable variable = (PsiVariable)infos[0];
- return new BooleanVariableIsAlwaysNegatedFix(variable.getName());
- }
-
- private static class BooleanVariableIsAlwaysNegatedFix
- extends InspectionGadgetsFix {
-
- private final String name;
-
- public BooleanVariableIsAlwaysNegatedFix(String name) {
- this.name = name;
- }
-
- @NotNull
- @Override
- public String getName() {
- return InspectionGadgetsBundle.message(
- "boolean.variable.always.inverted.quickfix", name);
- }
-
- @NotNull
- @Override
- public String getFamilyName() {
- return "Invert";
- }
-
- @Override
- protected void doFix(Project project, ProblemDescriptor descriptor)
- throws IncorrectOperationException {
- final PsiElement element = descriptor.getPsiElement();
- final PsiVariable variable =
- PsiTreeUtil.getParentOfType(element, PsiVariable.class);
- if (variable == null) {
- return;
- }
- final InvertBooleanDialog dialog = new InvertBooleanDialog(variable);
- dialog.show();
- }
+ return new InvertBooleanFix(InspectionGadgetsBundle.message("invert.quickfix", variable.getName()));
}
}
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/dataflow/NegativelyNamedBooleanVariableInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/dataflow/NegativelyNamedBooleanVariableInspection.java
new file mode 100644
index 0000000..06cdfff
--- /dev/null
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/dataflow/NegativelyNamedBooleanVariableInspection.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.siyeh.ig.dataflow;
+
+import com.intellij.psi.PsiVariable;
+import com.siyeh.InspectionGadgetsBundle;
+import com.siyeh.ig.InspectionGadgetsFix;
+import com.siyeh.ig.fixes.InvertBooleanFix;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * @author Bas Leijdekkers
+ */
+public class NegativelyNamedBooleanVariableInspection extends NegativelyNamedBooleanVariableInspectionBase {
+
+ @Nullable
+ @Override
+ protected InspectionGadgetsFix buildFix(Object... infos) {
+ final PsiVariable variable = (PsiVariable)infos[0];
+ return new InvertBooleanFix(InspectionGadgetsBundle.message("invert.quickfix", variable.getName()));
+ }
+}
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/fixes/InvertBooleanFix.java b/plugins/InspectionGadgets/src/com/siyeh/ig/fixes/InvertBooleanFix.java
new file mode 100644
index 0000000..68b1685
--- /dev/null
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/fixes/InvertBooleanFix.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.siyeh.ig.fixes;
+
+import com.intellij.codeInspection.ProblemDescriptor;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.project.Project;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiMethod;
+import com.intellij.psi.PsiNameIdentifierOwner;
+import com.intellij.psi.PsiVariable;
+import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.refactoring.JavaRefactoringActionHandlerFactory;
+import com.intellij.refactoring.RefactoringActionHandler;
+import com.intellij.util.IncorrectOperationException;
+import com.siyeh.InspectionGadgetsBundle;
+import com.siyeh.ig.InspectionGadgetsFix;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author Bas Leijdekkers
+ */
+public class InvertBooleanFix extends InspectionGadgetsFix {
+
+ private final String myName;
+
+ public InvertBooleanFix(String name) {
+ myName = name;
+ }
+
+ @NotNull
+ @Override
+ public String getName() {
+ return myName;
+ }
+
+ @NotNull
+ @Override
+ public String getFamilyName() {
+ return InspectionGadgetsBundle.message("invert.quickfix.family.name");
+ }
+
+ @Override
+ protected void doFix(final Project project, ProblemDescriptor descriptor) throws IncorrectOperationException {
+ final PsiNameIdentifierOwner owner = PsiTreeUtil.getParentOfType(descriptor.getPsiElement(), PsiVariable.class, PsiMethod.class);
+ if (owner == null) {
+ return;
+ }
+ final RefactoringActionHandler handler = JavaRefactoringActionHandlerFactory.getInstance().createInvertBooleanHandler();
+ final Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ handler.invoke(project, new PsiElement[]{owner}, null);
+ }
+ };
+ if (ApplicationManager.getApplication().isUnitTestMode()) {
+ runnable.run();
+ }
+ else {
+ ApplicationManager.getApplication().invokeLater(runnable, project.getDisposed());
+ }
+ }
+}
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/style/ProblematicWhitespaceInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/style/ProblematicWhitespaceInspection.java
new file mode 100644
index 0000000..8f823f0
--- /dev/null
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/style/ProblematicWhitespaceInspection.java
@@ -0,0 +1,165 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.siyeh.ig.style;
+
+import com.intellij.codeInspection.ProblemDescriptor;
+import com.intellij.ide.highlighter.JavaFileType;
+import com.intellij.openapi.editor.Document;
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.editor.EditorSettings;
+import com.intellij.openapi.fileEditor.FileEditorManager;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.TextRange;
+import com.intellij.psi.PsiDocumentManager;
+import com.intellij.psi.PsiJavaFile;
+import com.intellij.psi.codeStyle.CodeStyleSettings;
+import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
+import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
+import com.siyeh.InspectionGadgetsBundle;
+import com.siyeh.ig.BaseInspection;
+import com.siyeh.ig.BaseInspectionVisitor;
+import com.siyeh.ig.InspectionGadgetsFix;
+import org.jetbrains.annotations.Nls;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * @author Bas Leijdekkers
+ */
+public class ProblematicWhitespaceInspection extends BaseInspection {
+
+ @Nls
+ @NotNull
+ @Override
+ public String getDisplayName() {
+ return InspectionGadgetsBundle.message("problematic.whitespace.display.name");
+ }
+
+ @NotNull
+ @Override
+ protected String buildErrorString(Object... infos) {
+ final Boolean useTabs = (Boolean)infos[2];
+ return useTabs.booleanValue()
+ ? InspectionGadgetsBundle.message("problematic.whitespace.spaces.problem.descriptor", (String)infos[0])
+ : InspectionGadgetsBundle.message("problematic.whitespace.tabs.problem.descriptor", (String)infos[0]);
+ }
+
+ @Nullable
+ @Override
+ protected InspectionGadgetsFix buildFix(Object... infos) {
+ final boolean buildFix = ((Boolean)infos[1]).booleanValue();
+ if (!buildFix) {
+ return null;
+ }
+ return new ShowWhitespaceFix();
+ }
+
+
+ private static class ShowWhitespaceFix extends InspectionGadgetsFix {
+
+ @NotNull
+ @Override
+ public String getName() {
+ return InspectionGadgetsBundle.message("problematic.whitespace.show.whitespaces.quickfix");
+ }
+
+ @NotNull
+ @Override
+ public String getFamilyName() {
+ return getName();
+ }
+
+ @Override
+ protected void doFix(Project project, ProblemDescriptor descriptor) {
+ final FileEditorManager editorManager = FileEditorManager.getInstance(project);
+ final Editor editor = editorManager.getSelectedTextEditor();
+ if (editor == null) {
+ return;
+ }
+ final EditorSettings settings = editor.getSettings();
+ settings.setWhitespacesShown(!settings.isWhitespacesShown());
+ editor.getComponent().repaint();
+ }
+ }
+
+
+ @Override
+ public BaseInspectionVisitor buildVisitor() {
+ return new ProblematicWhitespaceVisitor();
+ }
+
+ private static class ProblematicWhitespaceVisitor extends BaseInspectionVisitor {
+
+ @Override
+ public void visitJavaFile(PsiJavaFile file) {
+ super.visitJavaFile(file);
+ final CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(file.getProject());
+ final CommonCodeStyleSettings.IndentOptions indentOptions = settings.getIndentOptions(JavaFileType.INSTANCE);
+ final boolean useTabs = indentOptions.USE_TAB_CHARACTER;
+ final boolean smartTabs = indentOptions.SMART_TABS;
+ final Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file);
+ if (document == null) {
+ return;
+ }
+ final int lineCount = document.getLineCount();
+ int previousLineIndent = 0;
+ for (int i = 0; i < lineCount; i++) {
+ final int startOffset = document.getLineStartOffset(i);
+ final int endOffset = document.getLineEndOffset(i);
+ final String line = document.getText(new TextRange(startOffset, endOffset));
+ boolean spaceSeen = false;
+ for (int j = 0, length = line.length(); j < length; j++) {
+ final char c = line.charAt(j);
+ if (c == '\t') {
+ if (useTabs) {
+ if (smartTabs && spaceSeen) {
+ registerError(file, file.getName(), Boolean.valueOf(isOnTheFly()), Boolean.TRUE);
+ return;
+ }
+ }
+ else {
+ registerError(file, file.getName(), Boolean.valueOf(isOnTheFly()), Boolean.FALSE);
+ return;
+ }
+ }
+ else if (c == ' ') {
+ if (useTabs) {
+ if (!smartTabs) {
+ registerError(file, file.getName(), Boolean.valueOf(isOnTheFly()), Boolean.TRUE);
+ return;
+ }
+ else {
+ final int currentIndent = Math.max(0, j);
+ if (currentIndent != previousLineIndent) {
+ registerError(file, file.getName(), Boolean.valueOf(isOnTheFly()), Boolean.TRUE);
+ return;
+ }
+ previousLineIndent = currentIndent;
+ }
+ }
+ spaceSeen = true;
+ }
+ else {
+ if (!spaceSeen) {
+ previousLineIndent = Math.max(0, j);
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NegativelyNamedBooleanVariable.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NegativelyNamedBooleanVariable.html
new file mode 100644
index 0000000..5f3ded7
--- /dev/null
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NegativelyNamedBooleanVariable.html
@@ -0,0 +1,9 @@
+<html>
+<body>
+Reports negatively named variables, for example 'disabled', 'hidden', 'isNotChanged'.
+It is usually more clear to invert the <b>boolean</b> value and remove the negation from the name.
+<!-- tooltip end -->
+<p>
+<small>New in 13</small>
+</body>
+</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/OverloadedVarargsMethod.html b/plugins/InspectionGadgets/src/inspectionDescriptions/OverloadedVarargsMethod.html
index 4961418..3df760d 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/OverloadedVarargsMethod.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/OverloadedVarargsMethod.html
@@ -1,7 +1,7 @@
<html>
<body>
-Reports vararg methods, when there are one or more other methods with the
-same name present in a class. Overloaded varargs methods can be very confusing,
+Reports varargs methods, when there are other methods with the
+same name present in a class. Overloaded variable arity methods can be very confusing,
as it is often not clear which overloading gets called.
<!-- tooltip end -->
<p>
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ProblematicVarargsMethodOverride.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ProblematicVarargsMethodOverride.html
new file mode 100644
index 0000000..769746d
--- /dev/null
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ProblematicVarargsMethodOverride.html
@@ -0,0 +1,8 @@
+<html>
+<body>
+Reports methods overriding a variable arity (varargs) method with an array parameter. While this is legal Java, it can be confusing.
+<!-- tooltip end -->
+<p>
+<small>New in 13</small>
+</body>
+</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ProblematicWhitespace.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ProblematicWhitespace.html
new file mode 100644
index 0000000..9bde0506
--- /dev/null
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ProblematicWhitespace.html
@@ -0,0 +1,10 @@
+<html>
+<body>
+Reports tabs used for indentation when the code style is configured to use only spaces. Reports spaces used for indentation when
+the code style is configured to use only tabs. Reports spaces used for indentation and tabs used for alignment when the code
+style is configured to use smart tabs.
+<!-- tooltip end -->
+<p>
+<small>New in 13</small>
+</body>
+</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryUnicodeEscape.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryUnicodeEscape.html
index 0cb8778..f768541 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryUnicodeEscape.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryUnicodeEscape.html
@@ -4,6 +4,6 @@
Unicode control characters are not reported by this inspection.
<!-- tooltip end -->
<p>
-
+<small>New in 13</small>
</body>
</html>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/inheritance/problematic_varargs_method_override/One.after.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/inheritance/problematic_varargs_method_override/One.after.java
new file mode 100644
index 0000000..79dd8da
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/inheritance/problematic_varargs_method_override/One.after.java
@@ -0,0 +1,14 @@
+package com.siyeh.igfixes.inheritance.problematic_varargs_method_override;
+
+class One {
+
+ public void m(String... ss) {}
+}
+class Two extends One {
+ public void m(String... ss) {}
+}
+class Three {
+ public static void main(String... args) {
+ new Two().m("1", "2", "3");
+ }
+}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/inheritance/problematic_varargs_method_override/One.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/inheritance/problematic_varargs_method_override/One.java
new file mode 100644
index 0000000..d74e7d0
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/inheritance/problematic_varargs_method_override/One.java
@@ -0,0 +1,14 @@
+package com.siyeh.igfixes.inheritance.problematic_varargs_method_override;
+
+class One {
+
+ public void m(String... ss) {}
+}
+class Two extends One {
+ public void m<caret>(String[] ss) {}
+}
+class Three {
+ public static void main(String... args) {
+ new Two().m(new String[]{"1", "2", "3"});
+ }
+}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/variable_not_used_inside_if/VariableNotUsedInsideIf.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/variable_not_used_inside_if/VariableNotUsedInsideIf.java
index e8dcfc5..c6d1302 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/variable_not_used_inside_if/VariableNotUsedInsideIf.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/variable_not_used_inside_if/VariableNotUsedInsideIf.java
@@ -27,10 +27,10 @@
}
void bat(String s) {
- if (s == null) {
+ if (s != null) {
System.out.println();
}
- if (s != null) {
+ if (s == null) {
} else {
@@ -38,8 +38,27 @@
}
void money(String s) {
- if ((s == null)) {
+ if (((s) != (null))) {
System.out.println();
}
}
+
+ void x(Integer x){
+ if (x != null) {
+ System.out.println();
+ }
+ }
+
+ int x(Integer x, int y){
+ if (x != null) return y;//oops, wrong one
+ return y;
+ }
+
+ int conditional(Integer x) {
+ return x == null ? 1 : someValue();
+ }
+
+ private int someValue() {
+ return 0;
+ }
}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/variable_not_used_inside_if/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/variable_not_used_inside_if/expected.xml
index a6d23f9..603a542 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/variable_not_used_inside_if/expected.xml
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/variable_not_used_inside_if/expected.xml
@@ -20,4 +20,25 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Reference checked for 'null' is not used inside 'if'</problem_class>
<description><code>s</code> is not used inside if #loc</description>
</problem>
+
+ <problem>
+ <file>VariableNotUsedInsideIf.java</file>
+ <line>47</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Reference checked for 'null' is not used inside 'if'</problem_class>
+ <description><code>x</code> checked for 'null' is not used inside 'if' #loc</description>
+ </problem>
+
+ <problem>
+ <file>VariableNotUsedInsideIf.java</file>
+ <line>53</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Reference checked for 'null' is not used inside 'if'</problem_class>
+ <description><code>x</code> checked for 'null' is not used inside 'if' #loc</description>
+ </problem>
+
+ <problem>
+ <file>VariableNotUsedInsideIf.java</file>
+ <line>58</line>
+ <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Reference checked for 'null' is not used inside 'if'</problem_class>
+ <description><code>x</code> checked for 'null' is not used inside conditional #loc</description>
+ </problem>
</problems>
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/abstraction/BooleanParameterInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/abstraction/BooleanParameterInspectionTest.java
index b0c134f..0cefd2c 100644
--- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/abstraction/BooleanParameterInspectionTest.java
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/abstraction/BooleanParameterInspectionTest.java
@@ -25,7 +25,7 @@
public void testSimple() {
doTest("class X {" +
- " public void /*'public' method 'm' with 'boolean' parameter*/m/**/(boolean b) {}" +
+ " public void /*'public' method 'm()' with 'boolean' parameter*/m/**/(boolean b) {}" +
" public void n() {}" +
" public void o(int i) {}" +
" void p(boolean b) {}" +
@@ -34,7 +34,7 @@
public void testConstructor() {
doTest("class X {" +
- " public /*'public' constructor 'X' with 'boolean' parameter*/X/**/(boolean x) {}" +
+ " public /*'public' constructor 'X()' with 'boolean' parameter*/X/**/(boolean x) {}" +
"}");
}
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/bugs/MalformedRegexInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/bugs/MalformedRegexInspectionTest.java
index 68a1a06..a12eebc 100644
--- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/bugs/MalformedRegexInspectionTest.java
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/bugs/MalformedRegexInspectionTest.java
@@ -1,7 +1,3 @@
-/**
- * (c) 2013 Desert Island BV
- * created: 20 09 2013
- */
package com.siyeh.ig.bugs;
import com.intellij.codeInspection.LocalInspectionTool;
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/dataflow/NegativelyNamedBooleanVariableInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/dataflow/NegativelyNamedBooleanVariableInspectionTest.java
new file mode 100644
index 0000000..d8ff328
--- /dev/null
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/dataflow/NegativelyNamedBooleanVariableInspectionTest.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.siyeh.ig.dataflow;
+
+import com.intellij.codeInspection.InspectionProfileEntry;
+import com.siyeh.ig.LightInspectionTestCase;
+
+/**
+ * @author Bas Leijdekkers
+ */
+public class NegativelyNamedBooleanVariableInspectionTest extends LightInspectionTestCase {
+
+ public void testTree() {
+ doTest("class X {" +
+ " boolean /*Boolean variable 'hidden' is negatively named*/hidden/**/ = false;" +
+ " boolean /*Boolean variable 'disabled' is negatively named*/disabled/**/ = false;" +
+ " boolean /*Boolean variable 'isNotChanged' is negatively named*/isNotChanged/**/ = false;" +
+ "}");
+ }
+
+ @Override
+ protected InspectionProfileEntry getInspection() {
+ return new NegativelyNamedBooleanVariableInspection();
+ }
+}
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/inheritance/ProblematicVarargsMethodOverrideFixTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/inheritance/ProblematicVarargsMethodOverrideFixTest.java
new file mode 100644
index 0000000..0e94dc6
--- /dev/null
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/inheritance/ProblematicVarargsMethodOverrideFixTest.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.siyeh.ig.fixes.inheritance;
+
+import com.siyeh.InspectionGadgetsBundle;
+import com.siyeh.ig.IGQuickFixesTestCase;
+import com.siyeh.ig.inheritance.ProblematicVarargsMethodOverrideInspection;
+
+/**
+ * @author Bas Leijdekkers
+ */
+public class ProblematicVarargsMethodOverrideFixTest extends IGQuickFixesTestCase {
+
+ public void testOne() { doTest(); }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ myFixture.enableInspections(new ProblematicVarargsMethodOverrideInspection());
+ myRelativePath = "inheritance/problematic_varargs_method_override";
+ myDefaultHint = InspectionGadgetsBundle.message("convert.to.variable.arity.method.quickfix");
+ }
+
+}
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/inheritance/ProblematicVarargsMethodOverrideInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/inheritance/ProblematicVarargsMethodOverrideInspectionTest.java
new file mode 100644
index 0000000..46ec84b
--- /dev/null
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/inheritance/ProblematicVarargsMethodOverrideInspectionTest.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.siyeh.ig.inheritance;
+
+import com.intellij.codeInspection.InspectionProfileEntry;
+import com.siyeh.ig.LightInspectionTestCase;
+
+/**
+ * @author Bas Leijdekkers
+ */
+public class ProblematicVarargsMethodOverrideInspectionTest extends LightInspectionTestCase {
+
+ public void testSimple() {
+ doTest("class One {" +
+ " void m(String... ss) {" +
+ " }" +
+ "}" +
+ "class Two extends One {" +
+ " void /*Non-varargs method 'm()' overrides varargs method*/m/**/(String[] ss) {" +
+ " }" +
+ "}");
+ }
+
+ @Override
+ protected InspectionProfileEntry getInspection() {
+ return new ProblematicVarargsMethodOverrideInspection();
+ }
+}
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/internationalization/UnnecessaryUnicodeEscapeInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/internationalization/UnnecessaryUnicodeEscapeInspectionTest.java
index 7079c5f..1ee8eab 100644
--- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/internationalization/UnnecessaryUnicodeEscapeInspectionTest.java
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/internationalization/UnnecessaryUnicodeEscapeInspectionTest.java
@@ -13,11 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-/**
- * (c) 2013 Desert Island BV
- * created: 23 09 2013
- */
package com.siyeh.ig.internationalization;
import com.intellij.codeInspection.LocalInspectionTool;
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/junit/ExpectedExceptionNeverThrownInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/junit/ExpectedExceptionNeverThrownInspectionTest.java
index e057666..d9ab5d6 100644
--- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/junit/ExpectedExceptionNeverThrownInspectionTest.java
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/junit/ExpectedExceptionNeverThrownInspectionTest.java
@@ -1,7 +1,3 @@
-/**
- * (c) 2013 Desert Island BV
- * created: 14 08 2013
- */
package com.siyeh.ig.junit;
import com.intellij.codeInspection.LocalInspectionTool;
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/ProblematicWhitespaceInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/ProblematicWhitespaceInspectionTest.java
new file mode 100644
index 0000000..c0e062c
--- /dev/null
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/ProblematicWhitespaceInspectionTest.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.siyeh.ig.style;
+
+import com.intellij.codeInspection.InspectionProfileEntry;
+import com.intellij.ide.highlighter.JavaFileType;
+import com.intellij.psi.codeStyle.CodeStyleSettings;
+import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
+import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
+import com.siyeh.ig.LightInspectionTestCase;
+
+/**
+ * @author Bas Leijdekkers
+ */
+public class ProblematicWhitespaceInspectionTest extends LightInspectionTestCase {
+
+ public void testTabsInFile() {
+ final CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
+ settings.getIndentOptions(JavaFileType.INSTANCE).USE_TAB_CHARACTER = false;
+ doTest("/*File 'X.java' uses tabs for indentation*/class X {\n" +
+ "\tString s;\n" +
+ "}\n/**/");
+ }
+
+ public void testTabsInFile2() {
+ final CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
+ settings.getIndentOptions(JavaFileType.INSTANCE).USE_TAB_CHARACTER = true;
+ doTest("class X {\n" +
+ "\tString s;\n" +
+ "}\n");
+ }
+
+ public void testSpacesInFile() {
+ final CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
+ settings.getIndentOptions(JavaFileType.INSTANCE).USE_TAB_CHARACTER = true;
+ doTest("/*File 'X.java' uses spaces for indentation*/class X {\n" +
+ " String s;\n" +
+ "}\n/**/");
+ }
+
+ public void testSpacesInFile2() {
+ final CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
+ settings.getIndentOptions(JavaFileType.INSTANCE).USE_TAB_CHARACTER = false;
+ doTest("class X {\n" +
+ " String s;\n" +
+ "}\n");
+ }
+
+ public void testSmartTabsInFile() {
+ final CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
+ final CommonCodeStyleSettings.IndentOptions options = settings.getIndentOptions(JavaFileType.INSTANCE);
+ options.USE_TAB_CHARACTER = true;
+ options.SMART_TABS = true;
+ doTest("/*File 'X.java' uses spaces for indentation*/class X {\n" +
+ " \tString s;\n" +
+ "}\n/**/");
+ }
+
+ @Override
+ protected InspectionProfileEntry getInspection() {
+ return new ProblematicWhitespaceInspection();
+ }
+}
diff --git a/plugins/IntelliLang/intellilang-jps-plugin/src/org/jetbrains/jps/intellilang/instrumentation/ErrorPostponingMethodVisitor.java b/plugins/IntelliLang/intellilang-jps-plugin/src/org/jetbrains/jps/intellilang/instrumentation/ErrorPostponingMethodVisitor.java
new file mode 100644
index 0000000..e47eab8
--- /dev/null
+++ b/plugins/IntelliLang/intellilang-jps-plugin/src/org/jetbrains/jps/intellilang/instrumentation/ErrorPostponingMethodVisitor.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.jps.intellilang.instrumentation;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.asm4.MethodVisitor;
+import org.jetbrains.asm4.Opcodes;
+
+/**
+ * @author Eugene Zhuravlev
+ * Date: 11/5/13
+ */
+public class ErrorPostponingMethodVisitor extends MethodVisitor {
+
+ private final PatternInstrumenter myInstrumenter;
+ private final String myMethodName;
+
+ public ErrorPostponingMethodVisitor(@NotNull PatternInstrumenter instrumenter, String methodName, @Nullable MethodVisitor methodvisitor) {
+ super(Opcodes.ASM4, methodvisitor);
+ myInstrumenter = instrumenter;
+ myMethodName = methodName;
+ }
+
+ public void visitMaxs(int maxStack, int maxLocals) {
+ try {
+ super.visitMaxs(maxStack, maxLocals);
+ }
+ catch (Throwable e) {
+ myInstrumenter.registerError(myMethodName, "visitMaxs", e);
+ }
+ }
+}
diff --git a/plugins/IntelliLang/intellilang-jps-plugin/src/org/jetbrains/jps/intellilang/instrumentation/PatternInstrumenter.java b/plugins/IntelliLang/intellilang-jps-plugin/src/org/jetbrains/jps/intellilang/instrumentation/PatternInstrumenter.java
index 56e979a..083252c 100644
--- a/plugins/IntelliLang/intellilang-jps-plugin/src/org/jetbrains/jps/intellilang/instrumentation/PatternInstrumenter.java
+++ b/plugins/IntelliLang/intellilang-jps-plugin/src/org/jetbrains/jps/intellilang/instrumentation/PatternInstrumenter.java
@@ -183,7 +183,7 @@
if ((access & ACC_STATIC) != 0 && name.equals("<clinit>")) {
myHasStaticInitializer = true;
- return new MethodVisitor(Opcodes.ASM4, methodvisitor) {
+ return new ErrorPostponingMethodVisitor(this, name, methodvisitor) {
public void visitCode() {
super.visitCode();
patchStaticInitializer(mv);
@@ -206,7 +206,7 @@
}
}
- return methodvisitor;
+ return new ErrorPostponingMethodVisitor(this, name, methodvisitor);
}
private static boolean isStringType(Type type) {
diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/decls/ChangeVariableTypeToRhsTypeIntention.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/decls/ChangeVariableTypeToRhsTypeIntention.java
index 729e5c2..4745c88 100644
--- a/plugins/IntentionPowerPak/src/com/siyeh/ipp/decls/ChangeVariableTypeToRhsTypeIntention.java
+++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/decls/ChangeVariableTypeToRhsTypeIntention.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,11 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-/*
- * (c) 2012 Desert Island BV
- * created: 14 08 2012
- */
package com.siyeh.ipp.decls;
import com.intellij.psi.*;
diff --git a/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/junit/FlipAssertLiteralIntentionTest.java b/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/junit/FlipAssertLiteralIntentionTest.java
index edf3905..9837187 100644
--- a/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/junit/FlipAssertLiteralIntentionTest.java
+++ b/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/junit/FlipAssertLiteralIntentionTest.java
@@ -1,7 +1,3 @@
-/**
- * (c) 2013 Desert Island BV
- * created: 08 09 2013
- */
package com.siyeh.ipp.junit;
import com.siyeh.IntentionPowerPackBundle;
diff --git a/plugins/ant/src/com/intellij/lang/ant/config/impl/AntBuildModelImpl.java b/plugins/ant/src/com/intellij/lang/ant/config/impl/AntBuildModelImpl.java
index e13e5bc..6739856 100644
--- a/plugins/ant/src/com/intellij/lang/ant/config/impl/AntBuildModelImpl.java
+++ b/plugins/ant/src/com/intellij/lang/ant/config/impl/AntBuildModelImpl.java
@@ -30,8 +30,9 @@
import com.intellij.psi.impl.PsiCachedValueImpl;
import com.intellij.psi.util.CachedValue;
import com.intellij.psi.util.CachedValueProvider;
-import com.intellij.psi.util.PsiUtilCore;
+import com.intellij.psi.util.PsiModificationTracker;
import com.intellij.psi.xml.XmlFile;
+import com.intellij.util.ArrayUtil;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.Nullable;
@@ -48,9 +49,9 @@
myTargets = new PsiCachedValueImpl<List<AntBuildTargetBase>>(PsiManager.getInstance(project), new CachedValueProvider<List<AntBuildTargetBase>>() {
public Result<List<AntBuildTargetBase>> compute() {
- final Pair<List<AntBuildTargetBase>, Collection<PsiFile>> result = getTargetListImpl(AntBuildModelImpl.this);
- final Collection<PsiFile> deps = result.getSecond();
- return Result.create(result.getFirst(), PsiUtilCore.toPsiFileArray(deps));
+ final Pair<List<AntBuildTargetBase>, Collection<Object>> result = getTargetListImpl(AntBuildModelImpl.this);
+ final Collection<Object> deps = result.getSecond();
+ return Result.create(result.getFirst(), ArrayUtil.toObjectArray(deps));
}
});
}
@@ -150,17 +151,16 @@
}
// todo: return list of dependent psi files as well
- private static Pair<List<AntBuildTargetBase>, Collection<PsiFile>> getTargetListImpl(final AntBuildModelBase model) {
+ private static Pair<List<AntBuildTargetBase>, Collection<Object>> getTargetListImpl(final AntBuildModelBase model) {
final List<AntBuildTargetBase> list = new ArrayList<AntBuildTargetBase>();
- final Set<PsiFile> dependencies = new HashSet<PsiFile>();
+ final Set<Object> dependencies = new HashSet<Object>();
final AntDomProject project = model.getAntProject();
if (project != null) {
final AntBuildFile buildFile = model.getBuildFile();
final XmlFile xmlFile = buildFile.getAntFile();
- if (xmlFile != null) {
- dependencies.add(xmlFile);
- }
+ dependencies.add(xmlFile != null? xmlFile : PsiModificationTracker.MODIFICATION_COUNT);
+
final VirtualFile sourceFile = buildFile.getVirtualFile();
new Object() {
private boolean myIsImported = false;
@@ -189,20 +189,26 @@
for (AntDomIncludingDirective incl : allIncludes) {
final PsiFileSystemItem includedFile = incl.getFile().getValue();
if (includedFile instanceof PsiFile) {
+ final PsiFile included = includedFile.getContainingFile().getOriginalFile();
+ dependencies.add(included);
final AntDomProject includedProject = AntSupport.getAntDomProject((PsiFile)includedFile);
if (includedProject != null) {
- final PsiFile included = includedFile.getContainingFile().getOriginalFile();
- dependencies.add(included);
fillTargets(list, model, includedProject, included.getVirtualFile());
}
}
-
+ else {
+ if (includedFile == null) {
+ // if not resolved yet, it's possible that the file will be created later,
+ // thus we need to recalculate the cached value
+ dependencies.add(PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT);
+ }
+ }
}
}
}.fillTargets(list, model, project, sourceFile);
}
- return new Pair<List<AntBuildTargetBase>, Collection<PsiFile>>(list, dependencies);
+ return new Pair<List<AntBuildTargetBase>, Collection<Object>>(list, dependencies);
}
}
diff --git a/plugins/ant/src/com/intellij/lang/ant/config/impl/AntConfigurationImpl.java b/plugins/ant/src/com/intellij/lang/ant/config/impl/AntConfigurationImpl.java
index 5cf28c8..7eec6e9 100644
--- a/plugins/ant/src/com/intellij/lang/ant/config/impl/AntConfigurationImpl.java
+++ b/plugins/ant/src/com/intellij/lang/ant/config/impl/AntConfigurationImpl.java
@@ -29,7 +29,6 @@
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
-import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.actionSystem.ex.ActionManagerEx;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
@@ -687,14 +686,13 @@
}
private void loadBuildFileProjectProperties(final Element parentNode) {
- final List<Pair<Element, VirtualFile>> files = new ArrayList<Pair<Element, VirtualFile>>();
+ final List<Pair<Element, String>> files = new ArrayList<Pair<Element, String>>();
final VirtualFileManager vfManager = VirtualFileManager.getInstance();
for (final Object o : parentNode.getChildren(BUILD_FILE)) {
final Element element = (Element)o;
final String url = element.getAttributeValue(URL);
- final VirtualFile file = vfManager.findFileByUrl(url);
- if (file != null) {
- files.add(new Pair<Element, VirtualFile>(element, file));
+ if (url != null) {
+ files.add(new Pair<Element, String>(element, url));
}
}
@@ -732,9 +730,12 @@
}
// then fill the configuration with the files configured in xml
List<Pair<Element, AntBuildFileBase>> buildFiles = new ArrayList<Pair<Element, AntBuildFileBase>>(files.size());
- for (Pair<Element, VirtualFile> pair : files) {
+ for (Pair<Element, String> pair : files) {
final Element element = pair.getFirst();
- final VirtualFile file = pair.getSecond();
+ final VirtualFile file = vfManager.findFileByUrl(pair.getSecond());
+ if (file == null) {
+ continue;
+ }
try {
final AntBuildFileBase buildFile = addBuildFileImpl(file);
buildFile.readProperties(element);
diff --git a/plugins/copyright/src/com/maddyhome/idea/copyright/ui/CopyrightProfilesPanel.java b/plugins/copyright/src/com/maddyhome/idea/copyright/ui/CopyrightProfilesPanel.java
index 6c349e0..20ef584 100644
--- a/plugins/copyright/src/com/maddyhome/idea/copyright/ui/CopyrightProfilesPanel.java
+++ b/plugins/copyright/src/com/maddyhome/idea/copyright/ui/CopyrightProfilesPanel.java
@@ -33,8 +33,9 @@
import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.ui.popup.PopupStep;
import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
-import com.intellij.openapi.vfs.VfsUtil;
+import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.util.Consumer;
import com.intellij.util.IconUtil;
import com.intellij.util.PlatformIcons;
import com.intellij.util.containers.HashMap;
@@ -48,6 +49,7 @@
import javax.swing.*;
import javax.swing.tree.TreePath;
+import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -80,6 +82,7 @@
return "Copyright.UI";
}
+ @Override
protected void processRemovedItems() {
Map<String, CopyrightProfile> profiles = getAllProfiles();
final List<CopyrightProfile> deleted = new ArrayList<CopyrightProfile>();
@@ -93,16 +96,19 @@
}
}
+ @Override
protected boolean wasObjectStored(Object o) {
return myManager.getCopyrights().contains((CopyrightProfile)o);
}
+ @Override
@Nls
public String getDisplayName() {
return "Copyright Profiles";
}
- @Nullable
+ @Override
+ @NotNull
@NonNls
public String getHelpTopic() {
return "copyright.profiles";
@@ -114,6 +120,7 @@
}
}
+ @Override
public void apply() throws ConfigurationException {
final Set<String> profiles = new HashSet<String>();
for (int i = 0; i < myRoot.getChildCount(); i++) {
@@ -151,6 +158,7 @@
myInitialized.set(false);
}
+ @Override
@Nullable
protected ArrayList<AnAction> createActions(boolean fromPopup) {
ArrayList<AnAction> result = new ArrayList<AnAction>();
@@ -159,6 +167,7 @@
registerCustomShortcutSet(CommonShortcuts.INSERT, myTree);
}
+ @Override
public void actionPerformed(AnActionEvent event) {
final String name = askForProfileName("Create Copyright Profile", "");
if (name == null) return;
@@ -169,9 +178,10 @@
result.add(new MyDeleteAction());
result.add(new AnAction("Copy", "Copy", PlatformIcons.COPY_ICON) {
{
- registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_D, KeyEvent.CTRL_MASK)), myTree);
+ registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_MASK)), myTree);
}
+ @Override
public void actionPerformed(AnActionEvent event) {
final String profileName = askForProfileName("Copy Copyright Profile", "");
if (profileName == null) return;
@@ -181,12 +191,14 @@
addProfileNode(clone);
}
+ @Override
public void update(AnActionEvent event) {
super.update(event);
event.getPresentation().setEnabled(getSelectedObject() != null);
}
});
result.add(new AnAction("Import", "Import", PlatformIcons.IMPORT_ICON) {
+ @Override
public void actionPerformed(AnActionEvent event) {
final OpenProjectFileChooserDescriptor descriptor = new OpenProjectFileChooserDescriptor(true) {
@Override
@@ -204,38 +216,41 @@
}
};
descriptor.setTitle("Choose file containing copyright notice");
- final VirtualFile file = FileChooser.chooseFile(descriptor, myProject, null);
- if (file == null) return;
-
- final List<CopyrightProfile> copyrightProfiles = ExternalOptionHelper.loadOptions(VfsUtil.virtualToIoFile(file));
- if (copyrightProfiles == null) return;
- if (!copyrightProfiles.isEmpty()) {
- if (copyrightProfiles.size() == 1) {
- importProfile(copyrightProfiles.get(0));
- }
- else {
- JBPopupFactory.getInstance()
- .createListPopup(new BaseListPopupStep<CopyrightProfile>("Choose profile to import", copyrightProfiles) {
- @Override
- public PopupStep onChosen(final CopyrightProfile selectedValue, boolean finalChoice) {
- return doFinalStep(new Runnable() {
- public void run() {
- importProfile(selectedValue);
+ FileChooser.chooseFile(descriptor, myProject, null, new Consumer<VirtualFile>() {
+ @Override
+ public void consume(VirtualFile file) {
+ final List<CopyrightProfile> copyrightProfiles = ExternalOptionHelper.loadOptions(VfsUtilCore.virtualToIoFile(file));
+ if (copyrightProfiles == null) return;
+ if (!copyrightProfiles.isEmpty()) {
+ if (copyrightProfiles.size() == 1) {
+ importProfile(copyrightProfiles.get(0));
+ }
+ else {
+ JBPopupFactory.getInstance()
+ .createListPopup(new BaseListPopupStep<CopyrightProfile>("Choose profile to import", copyrightProfiles) {
+ @Override
+ public PopupStep onChosen(final CopyrightProfile selectedValue, boolean finalChoice) {
+ return doFinalStep(new Runnable() {
+ @Override
+ public void run() {
+ importProfile(selectedValue);
+ }
+ });
}
- });
- }
- @NotNull
- @Override
- public String getTextFor(CopyrightProfile value) {
- return value.getName();
- }
- }).showUnderneathOf(myNorthPanel);
+ @NotNull
+ @Override
+ public String getTextFor(CopyrightProfile value) {
+ return value.getName();
+ }
+ }).showUnderneathOf(myNorthPanel);
+ }
+ }
+ else {
+ Messages.showWarningDialog(myProject, "The selected file does not contain any copyright settings.", "Import Failure");
+ }
}
- }
- else {
- Messages.showWarningDialog(myProject, "The selected file does not contain any copyright settings.", "Import Failure");
- }
+ });
}
private void importProfile(CopyrightProfile copyrightProfile) {
@@ -253,10 +268,12 @@
@Nullable
private String askForProfileName(String title, String initialName) {
return Messages.showInputDialog("New copyright profile name:", title, Messages.getQuestionIcon(), initialName, new InputValidator() {
+ @Override
public boolean checkInput(String s) {
return !getAllProfiles().containsKey(s) && s.length() > 0;
}
+ @Override
public boolean canClose(String s) {
return checkInput(s);
}
@@ -289,6 +306,7 @@
myInitialized.set(true);
}
+ @Override
public void reset() {
reloadTree();
super.reset();
@@ -301,21 +319,25 @@
public void addItemsChangeListener(final Runnable runnable) {
addItemsChangeListener(new ItemsChangeListener() {
+ @Override
public void itemChanged(@Nullable Object deletedItem) {
SwingUtilities.invokeLater(runnable);
}
+ @Override
public void itemsExternallyChanged() {
SwingUtilities.invokeLater(runnable);
}
});
}
+ @Override
@NotNull
public String getId() {
return getHelpTopic();
}
+ @Override
public Runnable enableSearch(String option) {
return null;
}
diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/dateOrRevision/CommandWrapper.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/dateOrRevision/CommandWrapper.java
deleted file mode 100644
index eb5e1a3..0000000
--- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/dateOrRevision/CommandWrapper.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2000-2009 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.cvsSupport2.cvsoperations.dateOrRevision;
-
-import org.netbeans.lib.cvsclient.command.Command;
-import org.netbeans.lib.cvsclient.command.checkout.CheckoutCommand;
-import org.netbeans.lib.cvsclient.command.checkout.ExportCommand;
-import org.netbeans.lib.cvsclient.command.update.UpdateCommand;
-
-/**
- * author: lesya
- */
-public class CommandWrapper {
- private final Command myCommand;
-
- public CommandWrapper(Command command) {
- myCommand = command;
- }
-
- @SuppressWarnings({"HardCodedStringLiteral"})
- public void setUpdateByRevisionOrDate(String revision, final String date) {
- if (isCheckoutCommand()) {
- asCheckoutCommand().setUpdateByRevisionOrTag(revision);
- asCheckoutCommand().setUpdateByDate(date);
- }
- else if (isUpdateCommand()) {
- asUpdateCommand().setUpdateByRevisionOrTag(revision);
- asUpdateCommand().setUpdateByDate(date);
- }
- else if (isExportCommand()) {
- asExportCommand().setUpdateByRevisionOrTag(revision == null && date == null ? "HEAD" : revision);
- asExportCommand().setUpdateByDate(date);
- }
- }
-
- private UpdateCommand asUpdateCommand() {
- return ((UpdateCommand)myCommand);
- }
-
- private CheckoutCommand asCheckoutCommand() {
- return ((CheckoutCommand)myCommand);
- }
-
- private ExportCommand asExportCommand() {
- return ((ExportCommand)myCommand);
- }
-
- private boolean isUpdateCommand() {
- return myCommand instanceof UpdateCommand;
- }
-
- private boolean isCheckoutCommand() {
- return myCommand instanceof CheckoutCommand;
- }
-
- private boolean isExportCommand() {
- return myCommand instanceof ExportCommand;
- }
-
-}
diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/dateOrRevision/RevisionOrDateImpl.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/dateOrRevision/RevisionOrDateImpl.java
index 3c1a461..1e8f854 100644
--- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/dateOrRevision/RevisionOrDateImpl.java
+++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/dateOrRevision/RevisionOrDateImpl.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,20 +19,28 @@
import com.intellij.cvsSupport2.application.CvsEntriesManager;
import com.intellij.cvsSupport2.config.DateOrRevisionSettings;
import com.intellij.cvsSupport2.history.CvsRevisionNumber;
+import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.vfs.VirtualFile;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import org.netbeans.lib.cvsclient.admin.Entry;
import org.netbeans.lib.cvsclient.command.Command;
-import org.jetbrains.annotations.NotNull;
+
+import java.text.ParseException;
+import java.util.Date;
/**
- * author: lesya
+ * @author lesya
*/
public class RevisionOrDateImpl implements RevisionOrDate {
- private String myStickyTag;
- private String myStickyDate;
+
+ private static final Logger LOG = Logger.getInstance(RevisionOrDateImpl.class);
+
+ @Nullable private String myStickyTag;
+ @Nullable private Date myStickyDate;
public static RevisionOrDate createOn(@NotNull VirtualFile file) {
- VirtualFile parent = file.getParent();
+ final VirtualFile parent = file.getParent();
return new RevisionOrDateImpl(parent, CvsEntriesManager.getInstance().getEntryFor(parent, file.getName()));
}
@@ -41,27 +49,25 @@
}
public static RevisionOrDate createOn(VirtualFile parent, Entry entry, DateOrRevisionSettings config) {
- RevisionOrDateImpl result = new RevisionOrDateImpl(parent, entry);
+ final RevisionOrDateImpl result = new RevisionOrDateImpl(parent, entry);
updateOn(result, config);
return result;
}
private static void updateOn(RevisionOrDateImpl result, DateOrRevisionSettings config) {
- String stickyTagFromConfig = config.USE_BRANCH ? config.BRANCH : null;
- String stickyDateFromConfig = config.USE_DATE ? config.getDate() : null;
+ final String stickyTagFromConfig = config.USE_BRANCH ? config.BRANCH : null;
+ final String stickyDateFromConfig = config.USE_DATE ? config.getDate() : null;
result.setStickyInfo(stickyTagFromConfig, stickyDateFromConfig);
}
@NotNull
public static RevisionOrDate createOn(DateOrRevisionSettings config) {
- RevisionOrDateImpl result = new RevisionOrDateImpl();
+ final RevisionOrDateImpl result = new RevisionOrDateImpl();
updateOn(result, config);
return result;
}
- private RevisionOrDateImpl() {
-
- }
+ private RevisionOrDateImpl() {}
private RevisionOrDateImpl(VirtualFile parent, Entry entry) {
if (entry == null) {
@@ -75,7 +81,7 @@
myStickyTag = entry.getStickyTag();
}
else if (entry.getStickyDateString() != null) {
- myStickyDate = entry.getStickyDateString();
+ myStickyDate = entry.getStickyDate();
}
else {
lookupDirectory(parent);
@@ -91,22 +97,34 @@
}
else {
myStickyTag = null;
- myStickyDate = stickyDate;
+ try {
+ myStickyDate = Entry.getLastModifiedDateFormatter().parse(stickyDate);
+ }
+ catch (ParseException e) {
+ LOG.error(e);
+ }
}
}
public void setForCommand(Command command) {
- CommandWrapper wrapper = new CommandWrapper(command);
- wrapper.setUpdateByRevisionOrDate(myStickyTag, myStickyDate);
+ command.setUpdateByRevisionOrDate(myStickyTag, myStickyDate == null ? null : Entry.getLastModifiedDateFormatter().format(myStickyDate));
}
private void lookupDirectory(VirtualFile directory) {
- String stickyTag = CvsUtil.getStickyTagForDirectory(directory);
+ final String stickyTag = CvsUtil.getStickyTagForDirectory(directory);
if (stickyTag != null) {
myStickyTag = stickyTag;
return;
}
- myStickyDate = CvsUtil.getStickyDateForDirectory(directory);
+ try {
+ final String stickyDateString = CvsUtil.getStickyDateForDirectory(directory);
+ if (stickyDateString != null) {
+ myStickyDate = Entry.STICKY_DATE_FORMAT.parse(stickyDateString);
+ }
+ }
+ catch (ParseException e) {
+ LOG.error(e);
+ }
}
public String getRevision() {
@@ -121,14 +139,15 @@
try {
return new CvsRevisionNumber(myStickyTag);
}
- catch (NumberFormatException ex) {
+ catch (NumberFormatException e) {
+ LOG.error(e);
return null;
}
}
public String toString() {
if (myStickyDate != null) {
- return myStickyDate;
+ return Entry.getLastModifiedDateFormatter().format(myStickyDate);
} else {
return myStickyTag;
}
diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/dateOrRevision/SimpleRevision.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/dateOrRevision/SimpleRevision.java
index 9100952..3f85ecc 100644
--- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/dateOrRevision/SimpleRevision.java
+++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/dateOrRevision/SimpleRevision.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.
@@ -47,7 +47,7 @@
}
public void setForCommand(Command command) {
- new CommandWrapper(command).setUpdateByRevisionOrDate(myRevision, null);
+ command.setUpdateByRevisionOrDate(myRevision, null);
}
public CvsRevisionNumber getCvsRevisionNumber() {
diff --git a/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/command/Command.java b/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/command/Command.java
index 829d415..9ed3bb1 100644
--- a/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/command/Command.java
+++ b/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/command/Command.java
@@ -95,4 +95,8 @@
globalOptions.reset();
}
}
+
+ public void setUpdateByRevisionOrDate(String revision, final String date) {
+ throw new UnsupportedOperationException();
+ }
}
diff --git a/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/command/checkout/CheckoutCommand.java b/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/command/checkout/CheckoutCommand.java
index 3a82568..84f0803 100644
--- a/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/command/checkout/CheckoutCommand.java
+++ b/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/command/checkout/CheckoutCommand.java
@@ -354,4 +354,10 @@
}
return cvsArguments.toString();
}
+
+ @Override
+ public void setUpdateByRevisionOrDate(String revision, String date) {
+ setUpdateByRevisionOrTag(revision);
+ setUpdateByDate(date);
+ }
}
diff --git a/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/command/checkout/ExportCommand.java b/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/command/checkout/ExportCommand.java
index aa4ce6c..712cb54 100644
--- a/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/command/checkout/ExportCommand.java
+++ b/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/command/checkout/ExportCommand.java
@@ -248,4 +248,9 @@
}
return cvsArguments.toString();
}
+
+ public void setUpdateByRevisionOrDate(String revision, final String date) {
+ setUpdateByRevisionOrTag(revision == null && date == null ? "HEAD" : revision);
+ setUpdateByDate(date);
+ }
}
diff --git a/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/command/update/UpdateCommand.java b/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/command/update/UpdateCommand.java
index 7cdd085..9f81b31 100644
--- a/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/command/update/UpdateCommand.java
+++ b/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/command/update/UpdateCommand.java
@@ -285,7 +285,7 @@
}
if (getKeywordSubst() != null) {
cvsArguments.append("-k");
- cvsArguments.append(getKeywordSubst().toString());
+ cvsArguments.append(getKeywordSubst());
cvsArguments.append(' ');
}
if (getUpdateByRevision() != null) {
@@ -311,4 +311,9 @@
}
return cvsArguments.toString();
}
+
+ public void setUpdateByRevisionOrDate(String revision, final String date) {
+ setUpdateByRevisionOrTag(revision);
+ setUpdateByDate(date);
+ }
}
diff --git a/plugins/devkit/resources/META-INF/plugin.xml b/plugins/devkit/resources/META-INF/plugin.xml
index e0a0ae7..8e26284 100644
--- a/plugins/devkit/resources/META-INF/plugin.xml
+++ b/plugins/devkit/resources/META-INF/plugin.xml
@@ -3,6 +3,10 @@
<id>DevKit</id>
<version>1.0</version>
+ <description>
+ IntelliJ Platform plugin development kit.
+ </description>
+
<category>inspection</category>
<vendor>JetBrains</vendor>
@@ -96,6 +100,9 @@
<psi.referenceContributor implementation="org.jetbrains.idea.devkit.references.IconsReferencesContributor"/>
<referencesSearch implementation="org.jetbrains.idea.devkit.references.IconsReferencesContributor"/>
<unusedDeclarationFixProvider implementation="org.jetbrains.idea.devkit.inspections.quickfix.RegisterExtensionFixProvider"/>
+
+ <stacktrace.fold substring="at com.intellij.testFramework."/>
+
</extensions>
<module-components>
@@ -136,7 +143,8 @@
</action>
<group id="Internal.DevKit" internal="true" text="DevKit" popup="true">
- <action internal="true" class="org.jetbrains.idea.devkit.actions.ToggleHighlightingMarkupAction" text="Toggle Expected Highlighting Markup"
+ <action internal="true" class="org.jetbrains.idea.devkit.actions.ToggleHighlightingMarkupAction"
+ text="Toggle Expected Highlighting Markup"
id="ToggleHighlightingMarkup"/>
<action internal="true" class="org.jetbrains.idea.devkit.actions.ShuffleNamesAction" text="Shuffle Names"
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/GroovyTypeHierarchyProvider.java b/plugins/devkit/src/dom/Abbreviation.java
similarity index 61%
copy from plugins/groovy/src/org/jetbrains/plugins/groovy/lang/GroovyTypeHierarchyProvider.java
copy to plugins/devkit/src/dom/Abbreviation.java
index bed999e..4f5be39d5 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/GroovyTypeHierarchyProvider.java
+++ b/plugins/devkit/src/dom/Abbreviation.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,12 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.jetbrains.plugins.groovy.lang;
+package org.jetbrains.idea.devkit.dom;
-import com.intellij.ide.hierarchy.type.JavaTypeHierarchyProvider;
+import com.intellij.util.xml.DomElement;
+import com.intellij.util.xml.GenericAttributeValue;
+import org.jetbrains.annotations.NotNull;
/**
- * @author peter
+ * @author Konstantin Bulenkov
*/
-public class GroovyTypeHierarchyProvider extends JavaTypeHierarchyProvider{
+public interface Abbreviation extends DomElement {
+ @NotNull
+ GenericAttributeValue<String> getValue();
}
diff --git a/plugins/devkit/src/dom/Action.java b/plugins/devkit/src/dom/Action.java
index 02ced123..be3d595 100644
--- a/plugins/devkit/src/dom/Action.java
+++ b/plugins/devkit/src/dom/Action.java
@@ -129,6 +129,18 @@
*/
Shortcut addShortcut();
+ /**
+ * Returns the list of abbreviation children.
+ * @return the list of abbreviation children.
+ */
+ @NotNull
+ List<Abbreviation> getAbbreviations();
+
+ /**
+ * Adds new child to the list of abbreviation children.
+ * @return created child
+ */
+ Abbreviation addAbbreviation();
/**
* Returns the list of add-to-group children.
diff --git a/plugins/devkit/src/module/PluginModuleType.java b/plugins/devkit/src/module/PluginModuleType.java
index 56bc22db..b97ec1b 100644
--- a/plugins/devkit/src/module/PluginModuleType.java
+++ b/plugins/devkit/src/module/PluginModuleType.java
@@ -17,7 +17,6 @@
import com.intellij.icons.AllIcons;
import com.intellij.openapi.module.*;
-import com.intellij.openapi.project.Project;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.util.IconLoader;
@@ -123,15 +122,4 @@
public boolean isValidSdk(@NotNull final Module module, final Sdk projectSdk) {
return JavaModuleType.isValidJavaSdk(module);
}
-
- public static Module[] getAllPluginModules(final Project project) {
- List<Module> modules = new ArrayList<Module>();
- Module[] allModules = ModuleManager.getInstance(project).getModules();
- for (Module module : allModules) {
- if (get(module) == getInstance()) {
- modules.add(module);
- }
- }
- return modules.toArray(new Module[modules.size()]);
- }
}
diff --git a/plugins/devkit/src/run/PluginConfigurationType.java b/plugins/devkit/src/run/PluginConfigurationType.java
index 8f7394a..cb25590 100644
--- a/plugins/devkit/src/run/PluginConfigurationType.java
+++ b/plugins/devkit/src/run/PluginConfigurationType.java
@@ -22,8 +22,10 @@
import com.intellij.icons.AllIcons;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.module.Module;
+import com.intellij.openapi.module.ModuleUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.idea.devkit.DevKitBundle;
import org.jetbrains.idea.devkit.module.PluginModuleType;
@@ -31,6 +33,7 @@
import javax.swing.*;
import java.io.File;
import java.io.IOException;
+import java.util.Collection;
public class PluginConfigurationType implements ConfigurationType {
private final ConfigurationFactory myFactory;
@@ -49,6 +52,11 @@
}
@Override
+ public boolean isApplicable(@NotNull Project project) {
+ return ModuleUtil.hasModulesOfType(project, PluginModuleType.getInstance());
+ }
+
+ @Override
public boolean isConfigurationSingletonByDefault() {
return true;
}
@@ -56,10 +64,9 @@
public RunConfiguration createConfiguration(String name, RunConfiguration template) {
final PluginRunConfiguration pluginRunConfiguration = (PluginRunConfiguration)template;
if (pluginRunConfiguration.getModule() == null) {
- final Module[] modules = PluginModuleType.getAllPluginModules(pluginRunConfiguration.getProject());
- if (modules.length > 0){
- pluginRunConfiguration.setModule(modules[0]);
- }
+ final Collection<Module> modules = ModuleUtil
+ .getModulesOfType(pluginRunConfiguration.getProject(), PluginModuleType.getInstance());
+ pluginRunConfiguration.setModule(ContainerUtil.getFirstItem(modules));
}
return super.createConfiguration(name, pluginRunConfiguration);
}
diff --git a/plugins/devkit/src/util/ActionType.java b/plugins/devkit/src/util/ActionType.java
index f703709..36b4d9db 100644
--- a/plugins/devkit/src/util/ActionType.java
+++ b/plugins/devkit/src/util/ActionType.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,8 +19,9 @@
import com.intellij.openapi.actionSystem.ActionGroup;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.keymap.KeymapManager;
-import com.intellij.psi.PsiClass;
+import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.JavaPsiFacade;
+import com.intellij.psi.PsiClass;
import com.intellij.psi.xml.XmlFile;
import com.intellij.psi.xml.XmlTag;
import com.intellij.util.IncorrectOperationException;
@@ -83,10 +84,10 @@
XmlTag actionTag = (XmlTag)actions.add(actions.createChildTag(myName, actions.getNamespace(), null, false));
actionTag.setAttribute("id", dialog.getActionId());
actionTag.setAttribute("class", klass.getQualifiedName());
- actionTag.setAttribute("text", dialog.getActionText());
+ actionTag.setAttribute("text", StringUtil.escapeXml(dialog.getActionText()));
String description = dialog.getActionDescription();
if (description != null && description.length() > 0) {
- actionTag.setAttribute("description", description);
+ actionTag.setAttribute("description", StringUtil.escapeXml(description));
}
String groupId = dialog.getSelectedGroupId();
diff --git a/plugins/generate-tostring/src/org/jetbrains/generate/tostring/element/ElementFactory.java b/plugins/generate-tostring/src/org/jetbrains/generate/tostring/element/ElementFactory.java
index 68c60c8..be60bff 100644
--- a/plugins/generate-tostring/src/org/jetbrains/generate/tostring/element/ElementFactory.java
+++ b/plugins/generate-tostring/src/org/jetbrains/generate/tostring/element/ElementFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2012 the original author or authors.
+ * Copyright 2001-2013 the original author or authors.
*
* 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,9 @@
// super
PsiClass superClass = clazz.getSuperClass();
- ce.setSuperName((superClass == null) ? null : superClass.getName());
+ if (superClass != null && !CommonClassNames.JAVA_LANG_OBJECT.equals(superClass.getQualifiedName())) {
+ ce.setSuperName(superClass.getName());
+ }
// interfaces
ce.setImplementNames(PsiAdapter.getImplementsClassnames(clazz));
diff --git a/plugins/git4idea/remote-servers-git/remote-servers-git.iml b/plugins/git4idea/remote-servers-git/remote-servers-git.iml
new file mode 100644
index 0000000..07e0637
--- /dev/null
+++ b/plugins/git4idea/remote-servers-git/remote-servers-git.iml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
+ <exclude-output />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/resources" isTestSource="false" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="module" module-name="remote-servers-agent-rt" />
+ <orderEntry type="module" module-name="core-api" />
+ <orderEntry type="module" module-name="vcs-api" />
+ <orderEntry type="module" module-name="remote-servers-api" />
+ <orderEntry type="module" module-name="git4idea" />
+ <orderEntry type="module" module-name="remote-servers-impl" />
+ <orderEntry type="module" module-name="lang-api" />
+ <orderEntry type="module" module-name="lang-impl" />
+ </component>
+</module>
+
diff --git a/platform/remote-servers/util/resources/resources/cloud.properties b/plugins/git4idea/remote-servers-git/resources/resources/cloud.properties
similarity index 100%
rename from platform/remote-servers/util/resources/resources/cloud.properties
rename to plugins/git4idea/remote-servers-git/resources/resources/cloud.properties
diff --git a/platform/remote-servers/util/src/com/intellij/remoteServer/util/CloudBundle.java b/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudBundle.java
similarity index 94%
rename from platform/remote-servers/util/src/com/intellij/remoteServer/util/CloudBundle.java
rename to plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudBundle.java
index 0427483..b2036536 100644
--- a/platform/remote-servers/util/src/com/intellij/remoteServer/util/CloudBundle.java
+++ b/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudBundle.java
@@ -9,8 +9,7 @@
import java.util.ResourceBundle;
/**
- * Created by IntelliJ IDEA.
- * User: michael.golubev
+ * @author michael.golubev
*/
public class CloudBundle {
diff --git a/platform/remote-servers/util/src/com/intellij/remoteServer/util/CloudGitDeploymentRuntime.java b/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudGitDeploymentRuntime.java
similarity index 98%
rename from platform/remote-servers/util/src/com/intellij/remoteServer/util/CloudGitDeploymentRuntime.java
rename to plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudGitDeploymentRuntime.java
index 07bac6e..ba78e40 100644
--- a/platform/remote-servers/util/src/com/intellij/remoteServer/util/CloudGitDeploymentRuntime.java
+++ b/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudGitDeploymentRuntime.java
@@ -38,8 +38,7 @@
import java.io.IOException;
/**
- * Created by IntelliJ IDEA.
- * User: michael.golubev
+ * @author michael.golubev
*/
public abstract class CloudGitDeploymentRuntime<DC extends CloudDeploymentNameConfiguration,
AD extends CloudGitAgentDeployment,
@@ -192,8 +191,6 @@
repository.update();
pushApplication(getRemoteName(), application.getGitUrl());
-
- myDeployment.startOrContinueListeningLog();
}
@Override
@@ -225,7 +222,6 @@
return null;
}
});
- myDeployment.stopListeningLog();
}
public boolean isDeployed() throws ServerRuntimeException {
diff --git a/platform/remote-servers/util/src/com/intellij/remoteServer/util/CloudGitServerRuntimeInstanceBase.java b/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudGitServerRuntimeInstanceBase.java
similarity index 98%
rename from platform/remote-servers/util/src/com/intellij/remoteServer/util/CloudGitServerRuntimeInstanceBase.java
rename to plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudGitServerRuntimeInstanceBase.java
index acc9a1c..79c2dfa 100644
--- a/platform/remote-servers/util/src/com/intellij/remoteServer/util/CloudGitServerRuntimeInstanceBase.java
+++ b/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudGitServerRuntimeInstanceBase.java
@@ -65,7 +65,7 @@
@NotNull
@Override
public String getDeploymentName(@NotNull DeploymentSource source) {
- return DEFAULT_NAME_PROVIDER.getDeploymentName(source);
+ return CloudDeploymentNameProvider.DEFAULT_NAME_PROVIDER.getDeploymentName(source);
}
public void connect(final ServerConnector.ConnectionCallback<DC> callback) {
diff --git a/platform/remote-servers/util/src/com/intellij/remoteServer/util/CloudSupportConfigurableBase.java b/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudSupportConfigurableBase.java
similarity index 99%
rename from platform/remote-servers/util/src/com/intellij/remoteServer/util/CloudSupportConfigurableBase.java
rename to plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudSupportConfigurableBase.java
index af506b0..d131adb 100644
--- a/platform/remote-servers/util/src/com/intellij/remoteServer/util/CloudSupportConfigurableBase.java
+++ b/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudSupportConfigurableBase.java
@@ -36,8 +36,7 @@
import java.util.concurrent.atomic.AtomicReference;
/**
- * Created by IntelliJ IDEA.
- * User: michael.golubev
+ * @author michael.golubev
*/
public abstract class CloudSupportConfigurableBase<
SC extends CloudConfigurationBase,
diff --git a/plugins/git4idea/src/git4idea/GitCommit.java b/plugins/git4idea/src/git4idea/GitCommit.java
index a4e1fbc..870bc01 100644
--- a/plugins/git4idea/src/git4idea/GitCommit.java
+++ b/plugins/git4idea/src/git4idea/GitCommit.java
@@ -19,6 +19,7 @@
import com.intellij.openapi.vcs.changes.Change;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.vcs.log.Hash;
+import com.intellij.vcs.log.VcsUser;
import com.intellij.vcs.log.impl.VcsFullCommitDetailsImpl;
import git4idea.log.GitContentRevisionFactory;
import org.jetbrains.annotations.NotNull;
@@ -33,11 +34,9 @@
public final class GitCommit extends VcsFullCommitDetailsImpl {
public GitCommit(final Project project, @NotNull Hash hash, @NotNull List<Hash> parents, long authorTime, @NotNull VirtualFile root,
- @NotNull String subject,
- @NotNull String authorName,
- @NotNull String authorEmail, @NotNull String message, @NotNull String committerName, @NotNull String committerEmail,
+ @NotNull String subject, @NotNull VcsUser author, @NotNull String message, @NotNull VcsUser committer,
long commitTime, @NotNull List<Change> changes) {
- super(hash, parents, authorTime, root, subject, authorName, authorEmail, message, committerName, committerEmail, commitTime, changes,
+ super(hash, parents, authorTime, root, subject, author, message, committer, commitTime, changes,
GitContentRevisionFactory.getInstance(project));
}
diff --git a/plugins/git4idea/src/git4idea/GitUtil.java b/plugins/git4idea/src/git4idea/GitUtil.java
index 42c8f103..b507e4a 100644
--- a/plugins/git4idea/src/git4idea/GitUtil.java
+++ b/plugins/git4idea/src/git4idea/GitUtil.java
@@ -23,6 +23,7 @@
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
@@ -37,7 +38,10 @@
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.Consumer;
import com.intellij.util.Function;
+import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.UIUtil;
+import com.intellij.vcs.log.VcsLog;
+import com.intellij.vcs.log.VcsLogProvider;
import com.intellij.vcsUtil.VcsFileUtil;
import com.intellij.vcsUtil.VcsUtil;
import git4idea.branch.GitBranchUtil;
@@ -951,4 +955,16 @@
repositoryManager.getRepositories()));
}
+ /**
+ * Checks if there are Git roots in the VCS log.
+ */
+ public static boolean logHasGitRoot(@NotNull VcsLog log) {
+ return ContainerUtil.find(log.getLogProviders(), new Condition<VcsLogProvider>() {
+ @Override
+ public boolean value(VcsLogProvider logProvider) {
+ return logProvider.getSupportedVcs().equals(GitVcs.getKey());
+ }
+ }) != null;
+ }
+
}
diff --git a/plugins/git4idea/src/git4idea/actions/GitInit.java b/plugins/git4idea/src/git4idea/actions/GitInit.java
index 04d3ff7..aec2fb6 100644
--- a/plugins/git4idea/src/git4idea/actions/GitInit.java
+++ b/plugins/git4idea/src/git4idea/actions/GitInit.java
@@ -18,7 +18,6 @@
import com.intellij.notification.NotificationType;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
-import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.fileChooser.FileChooser;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
@@ -33,6 +32,7 @@
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
import com.intellij.openapi.vcs.VcsDirectoryMapping;
import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.util.Consumer;
import com.intellij.vcsUtil.VcsFileUtil;
import git4idea.GitUtil;
import git4idea.GitVcs;
@@ -51,6 +51,7 @@
*/
public class GitInit extends DumbAwareAction {
+ @Override
public void actionPerformed(final AnActionEvent e) {
Project project = e.getData(CommonDataKeys.PROJECT);
if (project == null) {
@@ -65,40 +66,41 @@
if (baseDir == null) {
baseDir = project.getBaseDir();
}
- final VirtualFile root = FileChooser.chooseFile(fcd, project, baseDir);
- if (root == null) {
- return;
- }
- if (GitUtil.isUnderGit(root)) {
- final int v = Messages.showYesNoDialog(project,
- GitBundle.message("init.warning.already.under.git",
- StringUtil.escapeXml(root.getPresentableUrl())),
- GitBundle.getString("init.warning.title"),
- Messages.getWarningIcon());
- if (v != 0) {
- return;
- }
- }
+ doInit(project, fcd, baseDir, baseDir);
+ }
- Git git = ServiceManager.getService(Git.class);
- GitVcs vcs = GitVcs.getInstance(project);
- GitCommandResult result = git.init(project, root);
- if (!result.success()) {
- if (vcs != null && vcs.getExecutableValidator().checkExecutableAndNotifyIfNeeded()) {
- GitUIUtil.notify(GitVcs.IMPORTANT_ERROR_NOTIFICATION, project, "Git init failed", result.getErrorOutputAsHtmlString(),
- NotificationType.ERROR, null);
- }
- return;
- }
+ private static void doInit(final Project project, FileChooserDescriptor fcd, VirtualFile baseDir, final VirtualFile finalBaseDir) {
+ FileChooser.chooseFile(fcd, project, baseDir, new Consumer<VirtualFile>() {
+ @Override
+ public void consume(final VirtualFile root) {
+ if (GitUtil.isUnderGit(root) && Messages.showYesNoDialog(project,
+ GitBundle.message("init.warning.already.under.git",
+ StringUtil.escapeXml(root.getPresentableUrl())),
+ GitBundle.getString("init.warning.title"),
+ Messages.getWarningIcon()) != Messages.YES) {
+ return;
+ }
- if (project.isDefault()) {
- return;
- }
- final String path = root.equals(baseDir) ? "" : root.getPath();
- final Project finalProject = project;
- GitVcs.runInBackground(new Task.Backgroundable(finalProject, GitBundle.getString("common.refreshing")) {
- public void run(@NotNull ProgressIndicator indicator) {
- refreshAndConfigureVcsMappings(finalProject, root, path);
+ GitCommandResult result = ServiceManager.getService(Git.class).init(project, root);
+ if (!result.success()) {
+ GitVcs vcs = GitVcs.getInstance(project);
+ if (vcs != null && vcs.getExecutableValidator().checkExecutableAndNotifyIfNeeded()) {
+ GitUIUtil.notify(GitVcs.IMPORTANT_ERROR_NOTIFICATION, project, "Git init failed", result.getErrorOutputAsHtmlString(),
+ NotificationType.ERROR, null);
+ }
+ return;
+ }
+
+ if (project.isDefault()) {
+ return;
+ }
+ final String path = root.equals(finalBaseDir) ? "" : root.getPath();
+ GitVcs.runInBackground(new Task.Backgroundable(project, GitBundle.getString("common.refreshing")) {
+ @Override
+ public void run(@NotNull ProgressIndicator indicator) {
+ refreshAndConfigureVcsMappings(project, root, path);
+ }
+ });
}
});
}
diff --git a/plugins/git4idea/src/git4idea/actions/GitLogSingleCommitAction.java b/plugins/git4idea/src/git4idea/actions/GitLogSingleCommitAction.java
index 364b1f5..0ec2ab6 100644
--- a/plugins/git4idea/src/git4idea/actions/GitLogSingleCommitAction.java
+++ b/plugins/git4idea/src/git4idea/actions/GitLogSingleCommitAction.java
@@ -83,7 +83,7 @@
}
boolean isValid() {
- return project != null && log != null;
+ return project != null && log != null && GitUtil.logHasGitRoot(log);
}
}
diff --git a/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java b/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java
index 84ddd67..f07ef24 100644
--- a/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java
+++ b/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java
@@ -821,7 +821,7 @@
Object data = list.getData();
if (data instanceof VcsFullCommitDetails) {
VcsFullCommitDetails commit = (VcsFullCommitDetails)data;
- String author = String.format("%s <%s>", commit.getAuthorName(), commit.getAuthorEmail());
+ String author = String.format("%s <%s>", commit.getAuthor().getName(), commit.getAuthor().getEmail());
myAuthor.getEditor().setItem(author);
myAuthorDate = new Date(commit.getAuthorTime());
}
diff --git a/plugins/git4idea/src/git4idea/cherrypick/GitCherryPickAction.java b/plugins/git4idea/src/git4idea/cherrypick/GitCherryPickAction.java
index 705e861..7d24caf 100644
--- a/plugins/git4idea/src/git4idea/cherrypick/GitCherryPickAction.java
+++ b/plugins/git4idea/src/git4idea/cherrypick/GitCherryPickAction.java
@@ -29,6 +29,7 @@
import com.intellij.vcs.log.*;
import git4idea.GitLocalBranch;
import git4idea.GitPlatformFacade;
+import git4idea.GitUtil;
import git4idea.GitVcs;
import git4idea.commands.Git;
import git4idea.config.GitVcsSettings;
@@ -131,7 +132,13 @@
@Override
public void update(AnActionEvent e) {
super.update(e);
- e.getPresentation().setEnabled(enabled(e));
+ final VcsLog log = getVcsLog(e);
+ if (log != null && !GitUtil.logHasGitRoot(log)) {
+ e.getPresentation().setEnabledAndVisible(false);
+ }
+ else {
+ e.getPresentation().setEnabled(enabled(e));
+ }
}
private boolean enabled(AnActionEvent e) {
@@ -198,7 +205,7 @@
return ContainerUtil.map(commits, new Function<GitHeavyCommit, VcsFullCommitDetails>() {
@Override
public VcsFullCommitDetails fun(GitHeavyCommit commit) {
- final VcsLogObjectsFactory factory = ServiceManager.getService(VcsLogObjectsFactory.class);
+ final VcsLogObjectsFactory factory = ServiceManager.getService(project, VcsLogObjectsFactory.class);
List<Hash> parents = ContainerUtil.map(commit.getParentsHashes(), new Function<String, Hash>() {
@Override
public Hash fun(String hashValue) {
diff --git a/plugins/git4idea/src/git4idea/cherrypick/GitCherryPicker.java b/plugins/git4idea/src/git4idea/cherrypick/GitCherryPicker.java
index fb33e93..4c288c5 100644
--- a/plugins/git4idea/src/git4idea/cherrypick/GitCherryPicker.java
+++ b/plugins/git4idea/src/git4idea/cherrypick/GitCherryPicker.java
@@ -113,7 +113,7 @@
}
else if (conflictDetector.hasHappened()) {
boolean mergeCompleted = new CherryPickConflictResolver(myProject, myGit, myPlatformFacade, repository.getRoot(),
- commit.getHash().asString(), commit.getAuthorName(),
+ commit.getHash().asString(), commit.getAuthor().getName(),
commit.getSubject()).merge();
if (mergeCompleted) {
@@ -177,7 +177,7 @@
@NotNull List<GitCommitWrapper> successfulCommits) {
NotificationListener resolveLinkListener = new ResolveLinkListener(myProject, myGit, myPlatformFacade, repository.getRoot(),
commit.getCommit().getHash().toShortString(),
- commit.getCommit().getAuthorName(),
+ commit.getCommit().getAuthor().getName(),
commit.getSubject());
String description = commitDetails(commit)
+ "<br/>Unresolved conflicts remain in the working tree. <a href='resolve'>Resolve them.<a/>";
diff --git a/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java b/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java
index d51f476..13a8eeb 100644
--- a/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java
+++ b/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java
@@ -40,12 +40,8 @@
import com.intellij.util.SmartList;
import com.intellij.util.concurrency.Semaphore;
import com.intellij.util.containers.ContainerUtil;
-import com.intellij.vcs.log.Hash;
-import com.intellij.vcs.log.TimedVcsCommit;
-import com.intellij.vcs.log.VcsLogObjectsFactory;
-import com.intellij.vcs.log.VcsShortCommitDetails;
+import com.intellij.vcs.log.*;
import com.intellij.vcs.log.impl.HashImpl;
-import com.intellij.vcs.log.impl.VcsShortCommitDetailsImpl;
import git4idea.*;
import git4idea.branch.GitBranchUtil;
import git4idea.commands.*;
@@ -483,9 +479,10 @@
return null;
}
- public static List<? extends VcsShortCommitDetails> readAllMiniDetails(Project project, final VirtualFile root) throws VcsException {
+ public static List<? extends VcsShortCommitDetails> readAllMiniDetails(final Project project, final VirtualFile root) throws VcsException {
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.LOG);
- GitLogParser parser = new GitLogParser(project, GitLogParser.NameStatus.NONE, HASH, PARENTS, AUTHOR_NAME, AUTHOR_TIME, SUBJECT);
+ GitLogParser parser = new GitLogParser(project, GitLogParser.NameStatus.NONE, HASH, PARENTS, AUTHOR_NAME,
+ AUTHOR_EMAIL, AUTHOR_TIME, SUBJECT);
h.setStdoutSuppressed(true);
h.addParameters(parser.getPretty(), "--encoding=UTF-8");
h.addParameters("HEAD", "--branches", "--remotes", "--tags");
@@ -503,15 +500,17 @@
for (String parent : record.getParentsHashes()) {
parents.add(HashImpl.build(parent));
}
- return new VcsShortCommitDetailsImpl(HashImpl.build(record.getHash()), parents, record.getAuthorTimeStamp(), root,
- record.getSubject(), record.getAuthorName());
+
+ return vcsObjectsFactory(project).createShortDetails(HashImpl.build(record.getHash()), parents, record.getAuthorTimeStamp(), root,
+ record.getSubject(), record.getAuthorName(), record.getAuthorEmail());
}
});
}
- public static List<? extends VcsShortCommitDetails> readMiniDetails(Project project, final VirtualFile root, List<String> hashes) throws VcsException {
+ public static List<? extends VcsShortCommitDetails> readMiniDetails(final Project project, final VirtualFile root, List<String> hashes) throws VcsException {
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.LOG);
- GitLogParser parser = new GitLogParser(project, GitLogParser.NameStatus.NONE, HASH, PARENTS, AUTHOR_NAME, AUTHOR_TIME, SUBJECT);
+ GitLogParser parser = new GitLogParser(project, GitLogParser.NameStatus.NONE, HASH, PARENTS, AUTHOR_NAME,
+ AUTHOR_EMAIL, AUTHOR_TIME, SUBJECT);
h.setStdoutSuppressed(true);
// git show can show either -p, or --name-status, or --name-only, but we need nothing, just details => using git log --no-walk
h.addParameters("--no-walk");
@@ -528,18 +527,21 @@
for (String parent : record.getParentsHashes()) {
parents.add(HashImpl.build(parent));
}
- return new VcsShortCommitDetailsImpl(HashImpl.build(record.getHash()), parents, record.getAuthorTimeStamp(), root,
- record.getSubject(), record.getAuthorName());
+ return vcsObjectsFactory(project).createShortDetails(HashImpl.build(record.getHash()), parents, record.getAuthorTimeStamp(), root,
+ record.getSubject(), record.getAuthorName(), record.getAuthorEmail());
}
});
}
@NotNull
- public static List<TimedVcsCommit> readAllHashes(@NotNull Project project, @NotNull VirtualFile root) throws VcsException {
+ public static List<TimedVcsCommit> readAllHashes(@NotNull final Project project,
+ @NotNull VirtualFile root,
+ @NotNull final Consumer<VcsUser> userRegistry) throws VcsException {
final int COMMIT_BUFFER = 1000;
GitLineHandler h = new GitLineHandler(project, root, GitCommand.LOG);
- final GitLogParser parser = new GitLogParser(project, GitLogParser.NameStatus.NONE, HASH, PARENTS, AUTHOR_TIME);
+ final GitLogParser parser = new GitLogParser(project, GitLogParser.NameStatus.NONE, HASH, PARENTS, AUTHOR_TIME,
+ AUTHOR_NAME, AUTHOR_EMAIL);
h.setStdoutSuppressed(true);
h.addParameters(parser.getPretty(), "--encoding=UTF-8");
h.addParameters("HEAD", "--branches", "--remotes", "--tags");
@@ -571,7 +573,7 @@
afterParseRemainder = line.substring(recordEnd + 1);
}
if (afterParseRemainder != null && records.incrementAndGet() > COMMIT_BUFFER) { // null means can't parse now
- commits.addAll(parseCommit(parser, record));
+ commits.addAll(parseCommit(project, parser, record, userRegistry));
record.setLength(0);
record.append(afterParseRemainder);
}
@@ -584,7 +586,7 @@
@Override
public void processTerminated(int exitCode) {
try {
- commits.addAll(parseCommit(parser, record));
+ commits.addAll(parseCommit(project, parser, record, userRegistry));
}
catch (Exception e) {
ex.set(new VcsException(e));
@@ -603,19 +605,25 @@
return commits;
}
- private static List<TimedVcsCommit> parseCommit(GitLogParser parser, StringBuilder record) {
+ private static List<TimedVcsCommit> parseCommit(final Project project, GitLogParser parser, StringBuilder record,
+ final Consumer<VcsUser> userRegistry) {
List<GitLogRecord> rec = parser.parse(record.toString());
return ContainerUtil.mapNotNull(rec, new Function<GitLogRecord, TimedVcsCommit>() {
@Override
public TimedVcsCommit fun(GitLogRecord record) {
- return record == null ? null : convert(record);
+ if (record == null) {
+ return null;
+ }
+ TimedVcsCommit commit = convert(project, record);
+ userRegistry.consume(vcsObjectsFactory(project).createUser(record.getAuthorName(), record.getAuthorEmail()));
+ return commit;
}
});
}
@NotNull
- private static TimedVcsCommit convert(GitLogRecord rec) {
- VcsLogObjectsFactory factory = ServiceManager.getService(VcsLogObjectsFactory.class);
+ private static TimedVcsCommit convert(Project project, GitLogRecord rec) {
+ VcsLogObjectsFactory factory = vcsObjectsFactory(project);
List<Hash> parents = ContainerUtil.map(rec.getParentsHashes(), new Function<String, Hash>() {
@Override
public Hash fun(String s) {
@@ -625,6 +633,11 @@
return factory.createTimedCommit(HashImpl.build(rec.getHash()), parents, rec.getAuthorTimeStamp());
}
+ @NotNull
+ private static VcsLogObjectsFactory vcsObjectsFactory(@NotNull Project project) {
+ return ServiceManager.getService(project, VcsLogObjectsFactory.class);
+ }
+
private static class MyTokenAccumulator {
private final StringBuilder myBuffer = new StringBuilder();
@@ -775,9 +788,10 @@
return HashImpl.build(hash);
}
});
+ VcsLogObjectsFactory factory = vcsObjectsFactory(project);
return new GitCommit(project, HashImpl.build(record.getHash()), parents, record.getAuthorTimeStamp(), root, record.getSubject(),
- record.getAuthorName(), record.getAuthorEmail(), record.getFullMessage(), record.getCommitterName(),
- record.getCommitterEmail(), record.getLongTimeStamp(),
+ factory.createUser(record.getAuthorName(), record.getAuthorEmail()), record.getFullMessage(),
+ factory.createUser(record.getCommitterName(), record.getCommitterEmail()), record.getLongTimeStamp(),
record.parseChanges(project, root));
}
diff --git a/plugins/git4idea/src/git4idea/history/wholeTree/StructureFilterAction.java b/plugins/git4idea/src/git4idea/history/wholeTree/StructureFilterAction.java
index 573c5f5..b898520 100644
--- a/plugins/git4idea/src/git4idea/history/wholeTree/StructureFilterAction.java
+++ b/plugins/git4idea/src/git4idea/history/wholeTree/StructureFilterAction.java
@@ -23,7 +23,7 @@
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.Consumer;
-import git4idea.GitVcs;
+import com.intellij.vcs.log.ui.VcsStructureChooser;
import java.util.Collection;
import java.util.Map;
@@ -56,7 +56,7 @@
@Override
public void actionPerformed(AnActionEvent e) {
final VcsStructureChooser vcsStructureChooser =
- new VcsStructureChooser(GitVcs.getInstance(myProject), "Select folders to filter by", structureFilterI.getSelected(),
+ new VcsStructureChooser(myProject, "Select folders to filter by", structureFilterI.getSelected(),
structureFilterI.getRoots());
vcsStructureChooser.show();
if (vcsStructureChooser.getExitCode() == DialogWrapper.CANCEL_EXIT_CODE) return;
@@ -117,7 +117,7 @@
myPanel.setToolTipText(STRUCTURE + " " + ALL);
} else {
final VcsStructureChooser vcsStructureChooser =
- new VcsStructureChooser(GitVcs.getInstance(myProject), "Select folders to filter by", myStructureFilterI.getSelected(),
+ new VcsStructureChooser(myProject, "Select folders to filter by", myStructureFilterI.getSelected(),
myStructureFilterI.getRoots());
final Map<VirtualFile,String> modulesSet = vcsStructureChooser.getModulesSet();
final String text = getText(selected, modulesSet);
diff --git a/plugins/git4idea/src/git4idea/log/GitLogProvider.java b/plugins/git4idea/src/git4idea/log/GitLogProvider.java
index 1f3e723..c259035 100644
--- a/plugins/git4idea/src/git4idea/log/GitLogProvider.java
+++ b/plugins/git4idea/src/git4idea/log/GitLogProvider.java
@@ -23,13 +23,15 @@
import com.intellij.openapi.vcs.VcsKey;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.ArrayUtil;
+import com.intellij.util.Consumer;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.vcs.log.*;
import com.intellij.vcs.log.data.VcsLogBranchFilter;
+import com.intellij.vcs.log.data.VcsLogDateFilter;
+import com.intellij.vcs.log.data.VcsLogStructureFilter;
import com.intellij.vcs.log.data.VcsLogUserFilter;
import com.intellij.vcs.log.impl.HashImpl;
-import com.intellij.vcs.log.impl.VcsRefImpl;
import com.intellij.vcs.log.ui.filter.VcsLogTextFilter;
import git4idea.GitLocalBranch;
import git4idea.GitRemoteBranch;
@@ -66,7 +68,7 @@
myProject = project;
myRepositoryManager = repositoryManager;
myRefSorter = new GitRefManager(myRepositoryManager);
- myVcsObjectsFactory = ServiceManager.getService(VcsLogObjectsFactory.class);
+ myVcsObjectsFactory = ServiceManager.getService(myProject, VcsLogObjectsFactory.class);
}
@NotNull
@@ -83,8 +85,8 @@
@NotNull
@Override
- public List<TimedVcsCommit> readAllHashes(@NotNull VirtualFile root) throws VcsException {
- return GitHistoryUtils.readAllHashes(myProject, root);
+ public List<TimedVcsCommit> readAllHashes(@NotNull VirtualFile root, @NotNull Consumer<VcsUser> userRegistry) throws VcsException {
+ return GitHistoryUtils.readAllHashes(myProject, root, userRegistry);
}
@NotNull
@@ -114,15 +116,15 @@
Collection<GitRemoteBranch> remoteBranches = repository.getBranches().getRemoteBranches();
Collection<VcsRef> refs = new ArrayList<VcsRef>(localBranches.size() + remoteBranches.size());
for (GitLocalBranch localBranch : localBranches) {
- refs.add(new VcsRefImpl(HashImpl.build(localBranch.getHash()), localBranch.getName(), GitRefManager.LOCAL_BRANCH, root));
+ refs.add(myVcsObjectsFactory.createRef(HashImpl.build(localBranch.getHash()), localBranch.getName(), GitRefManager.LOCAL_BRANCH, root));
}
for (GitRemoteBranch remoteBranch : remoteBranches) {
- refs.add(new VcsRefImpl(HashImpl.build(remoteBranch.getHash()), remoteBranch.getNameForLocalOperations(),
+ refs.add(myVcsObjectsFactory.createRef(HashImpl.build(remoteBranch.getHash()), remoteBranch.getNameForLocalOperations(),
GitRefManager.REMOTE_BRANCH, root));
}
String currentRevision = repository.getCurrentRevision();
if (currentRevision != null) { // null => fresh repository
- refs.add(new VcsRefImpl(HashImpl.build(currentRevision), "HEAD", GitRefManager.HEAD, root));
+ refs.add(myVcsObjectsFactory.createRef(HashImpl.build(currentRevision), "HEAD", GitRefManager.HEAD, root));
}
refs.addAll(readTags(root));
@@ -138,7 +140,7 @@
Collection<VcsRef> refs = new ArrayList<VcsRef>();
for (String record : out.split(GitLogParser.RECORD_START)) {
if (!StringUtil.isEmptyOrSpaces(record)) {
- refs.addAll(RefParser.parseCommitRefs(record.trim(), root));
+ refs.addAll(new RefParser(myVcsObjectsFactory).parseCommitRefs(record.trim(), root));
}
}
return refs;
@@ -200,6 +202,18 @@
filterParameters.add(prepareParameter("author", authorFilter));
}
+ List<VcsLogDateFilter> dateFilters = ContainerUtil.findAll(filters, VcsLogDateFilter.class);
+ if (!dateFilters.isEmpty()) {
+ // assuming there is only one date filter, until filter expressions are defined
+ VcsLogDateFilter filter = dateFilters.iterator().next();
+ if (filter.getAfter() != null) {
+ filterParameters.add("--after=" + filter.getAfter().toString());
+ }
+ if (filter.getBefore() != null) {
+ filterParameters.add("--before=" + filter.getBefore().toString());
+ }
+ }
+
List<VcsLogTextFilter> textFilters = ContainerUtil.findAll(filters, VcsLogTextFilter.class);
if (textFilters.size() > 1) {
LOG.warn("Expected only one text filter: " + textFilters);
@@ -209,7 +223,19 @@
filterParameters.add(prepareParameter("grep", textFilter));
}
- filterParameters.add("--regexp-ignore-case"); // affects case sensitivity of any filter
+ filterParameters.add("--regexp-ignore-case"); // affects case sensitivity of any filter (except file filter)
+
+ // note: this filter must be the last parameter, because it uses "--" which separates parameters from paths
+ List<VcsLogStructureFilter> structureFilters = ContainerUtil.findAll(filters, VcsLogStructureFilter.class);
+ if (!structureFilters.isEmpty()) {
+ filterParameters.add("--");
+ for (VcsLogStructureFilter filter : structureFilters) {
+ for (VirtualFile file : filter.getFiles(root)) {
+ filterParameters.add(file.getPath());
+ }
+ }
+ }
+
return GitHistoryUtils.getAllDetails(myProject, root, filterParameters);
}
@@ -217,7 +243,8 @@
@Override
public VcsUser getCurrentUser(@NotNull VirtualFile root) throws VcsException {
String userName = GitConfigUtil.getValue(myProject, root, GitConfigUtil.USER_NAME);
- return userName == null ? null : myVcsObjectsFactory.createUser(userName);
+ String userEmail = StringUtil.notNullize(GitConfigUtil.getValue(myProject, root, GitConfigUtil.USER_EMAIL));
+ return userName == null ? null : myVcsObjectsFactory.createUser(userName, userEmail);
}
private static String prepareParameter(String paramName, String value) {
diff --git a/plugins/git4idea/src/git4idea/log/RefParser.java b/plugins/git4idea/src/git4idea/log/RefParser.java
index 018dab3..dfef6f3 100644
--- a/plugins/git4idea/src/git4idea/log/RefParser.java
+++ b/plugins/git4idea/src/git4idea/log/RefParser.java
@@ -2,8 +2,8 @@
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.vcs.log.Hash;
+import com.intellij.vcs.log.VcsLogObjectsFactory;
import com.intellij.vcs.log.VcsRef;
-import com.intellij.vcs.log.impl.VcsRefImpl;
import com.intellij.vcs.log.impl.HashImpl;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -19,8 +19,14 @@
*/
class RefParser {
+ private final VcsLogObjectsFactory myFactory;
+
+ public RefParser(VcsLogObjectsFactory factory) {
+ myFactory = factory;
+ }
+
// e25b7d8f (HEAD, refs/remotes/origin/master, refs/remotes/origin/HEAD, refs/heads/master)
- public static List<VcsRef> parseCommitRefs(@NotNull String input, @NotNull VirtualFile root) {
+ public List<VcsRef> parseCommitRefs(@NotNull String input, @NotNull VirtualFile root) {
int firstSpaceIndex = input.indexOf(' ');
String strHash = input.substring(0, firstSpaceIndex);
Hash hash = HashImpl.build(strHash);
@@ -52,10 +58,10 @@
// example input: fb29c80 refs/tags/92.29
@Nullable
- private static VcsRef createRef(@NotNull Hash hash, @NotNull String longRefPath, @NotNull VirtualFile root) {
+ private VcsRef createRef(@NotNull Hash hash, @NotNull String longRefPath, @NotNull VirtualFile root) {
String name = getRefName(longRefPath, "refs/tags/");
if (name != null) {
- return new VcsRefImpl(hash, name, GitRefManager.TAG, root);
+ return myFactory.createRef(hash, name, GitRefManager.TAG, root);
}
return null;
diff --git a/plugins/git4idea/src/git4idea/push/GitPushLog.java b/plugins/git4idea/src/git4idea/push/GitPushLog.java
index 335665f..b4e8f1c 100644
--- a/plugins/git4idea/src/git4idea/push/GitPushLog.java
+++ b/plugins/git4idea/src/git4idea/push/GitPushLog.java
@@ -96,7 +96,7 @@
Object userObject = ((DefaultMutableTreeNode)node).getUserObject();
if (userObject instanceof GitCommit) {
GitCommit commit = (GitCommit)userObject;
- return getHashString(commit) + " " + getDateString(commit) + " by " + commit.getAuthorName() + "\n\n" +
+ return getHashString(commit) + " " + getDateString(commit) + " by " + commit.getAuthor().getName() + "\n\n" +
IssueLinkHtmlRenderer.formatTextWithLinks(myProject, commit.getFullMessage());
}
return "";
diff --git a/plugins/git4idea/src/git4idea/repo/GitRepoInfo.java b/plugins/git4idea/src/git4idea/repo/GitRepoInfo.java
index cbeb0c4..33dc6a7 100644
--- a/plugins/git4idea/src/git4idea/repo/GitRepoInfo.java
+++ b/plugins/git4idea/src/git4idea/repo/GitRepoInfo.java
@@ -16,8 +16,11 @@
package git4idea.repo;
import com.intellij.dvcs.repo.Repository;
+import git4idea.GitBranch;
import git4idea.GitLocalBranch;
import git4idea.GitRemoteBranch;
+import gnu.trove.THashSet;
+import gnu.trove.TObjectHashingStrategy;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -97,8 +100,8 @@
if (myCurrentBranch != null ? !myCurrentBranch.equals(info.myCurrentBranch) : info.myCurrentBranch != null) return false;
if (!myRemotes.equals(info.myRemotes)) return false;
if (!myBranchTrackInfos.equals(info.myBranchTrackInfos)) return false;
- if (!myLocalBranches.equals(info.myLocalBranches)) return false;
- if (!myRemoteBranches.equals(info.myRemoteBranches)) return false;
+ if (!areEqual(myLocalBranches, info.myLocalBranches)) return false;
+ if (!areEqual(myRemoteBranches, info.myRemoteBranches)) return false;
return true;
}
@@ -120,4 +123,32 @@
return String.format("GitRepoInfo{current=%s, remotes=%s, localBranches=%s, remoteBranches=%s, trackInfos=%s}",
myCurrentBranch, myRemotes, myLocalBranches, myRemoteBranches, myBranchTrackInfos);
}
+
+ private static <T extends GitBranch> boolean areEqual(Collection<T> c1, Collection<T> c2) {
+ // GitBranch has perverted equals contract (see the comment there)
+ // until GitBranch is created only from a single place with correctly defined Hash, we can't change its equals
+ THashSet<GitBranch> set1 = new THashSet<GitBranch>(c1, new BranchesComparingStrategy());
+ THashSet<GitBranch> set2 = new THashSet<GitBranch>(c2, new BranchesComparingStrategy());
+ return set1.equals(set2);
+ }
+
+ private static class BranchesComparingStrategy implements TObjectHashingStrategy<GitBranch> {
+
+ @Override
+ public int computeHashCode(@NotNull GitBranch branch) {
+ return 31 * branch.getName().hashCode() + branch.getHash().hashCode();
+ }
+
+ @Override
+ public boolean equals(@NotNull GitBranch b1, @NotNull GitBranch b2) {
+ if (b1 == b2) {
+ return true;
+ }
+ if (b1.getClass() != b2.getClass()) {
+ return false;
+ }
+ return b1.getName().equals(b2.getName()) && b1.getHash().equals(b2.getHash());
+ }
+ }
+
}
diff --git a/plugins/git4idea/src/git4idea/ui/GitCommitListPanel.java b/plugins/git4idea/src/git4idea/ui/GitCommitListPanel.java
index c91efbd..4e774d3 100644
--- a/plugins/git4idea/src/git4idea/ui/GitCommitListPanel.java
+++ b/plugins/git4idea/src/git4idea/ui/GitCommitListPanel.java
@@ -202,7 +202,7 @@
}
private static String getAuthor(GitCommit commit) {
- return commit.getAuthorName();
+ return commit.getAuthor().getName();
}
private static String getTime(GitCommit commit) {
diff --git a/plugins/git4idea/test-stepdefs/git4idea/GitCherryPickStepdefs.java b/plugins/git4idea/test-stepdefs/git4idea/GitCherryPickStepdefs.java
index f750427..5e22069 100644
--- a/plugins/git4idea/test-stepdefs/git4idea/GitCherryPickStepdefs.java
+++ b/plugins/git4idea/test-stepdefs/git4idea/GitCherryPickStepdefs.java
@@ -262,7 +262,7 @@
private static VcsFullCommitDetails mockCommit(String hash, String message) {
List<Change> changes = new ArrayList<Change>();
changes.add(new Change(null, new MockContentRevision(new FilePathImpl(new MockVirtualFile("name")), VcsRevisionNumber.NULL)));
- return ServiceManager.getService(VcsLogObjectsFactory.class).createFullDetails(
+ return ServiceManager.getService(myProject, VcsLogObjectsFactory.class).createFullDetails(
HashImpl.build(hash), Collections.<Hash>emptyList(), 0, NullVirtualFile.INSTANCE, message, "John Smith", "john@mail.com", message,
"John Smith", "john@mail.com", 0, changes, GitContentRevisionFactory.getInstance(myProject));
}
diff --git a/plugins/git4idea/tests/git4idea/log/GitLogRefSorterTest.java b/plugins/git4idea/tests/git4idea/log/GitLogRefSorterTest.java
index 7346852..74f914c 100644
--- a/plugins/git4idea/tests/git4idea/log/GitLogRefSorterTest.java
+++ b/plugins/git4idea/tests/git4idea/log/GitLogRefSorterTest.java
@@ -6,7 +6,9 @@
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.testFramework.UsefulTestCase;
import com.intellij.util.Function;
+import com.intellij.util.NotNullFunction;
import com.intellij.util.containers.ContainerUtil;
+import com.intellij.vcs.log.Hash;
import com.intellij.vcs.log.VcsRef;
import com.intellij.vcs.log.VcsRefType;
import com.intellij.vcs.log.impl.HashImpl;
@@ -135,7 +137,13 @@
}
private static VcsRef ref(String hash, String name, VcsRefType type) {
- return new VcsRefImpl(HashImpl.build(hash), name, type, MOCK_VIRTUAL_FILE);
+ return new VcsRefImpl(new NotNullFunction<Hash, Integer>() {
+ @NotNull
+ @Override
+ public Integer fun(Hash hash) {
+ return Integer.parseInt(hash.asString().substring(0, Math.min(4, hash.asString().length())), 16);
+ }
+ }, HashImpl.build(hash), name, type, MOCK_VIRTUAL_FILE);
}
private static void check(Collection<VcsRef> unsorted, List<VcsRef> expected) {
diff --git a/plugins/git4idea/tests/git4idea/log/RefParserTest.java b/plugins/git4idea/tests/git4idea/log/RefParserTest.java
index ea393fe..c56aeb5 100644
--- a/plugins/git4idea/tests/git4idea/log/RefParserTest.java
+++ b/plugins/git4idea/tests/git4idea/log/RefParserTest.java
@@ -1,7 +1,12 @@
package git4idea.log;
+import com.intellij.openapi.vcs.changes.Change;
+import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.newvfs.impl.NullVirtualFile;
-import com.intellij.vcs.log.VcsRef;
+import com.intellij.util.NotNullFunction;
+import com.intellij.vcs.log.*;
+import com.intellij.vcs.log.impl.VcsRefImpl;
+import org.jetbrains.annotations.NotNull;
import org.junit.Test;
import java.util.List;
@@ -18,7 +23,7 @@
}
public void runTest(String inputStr, String outStr) {
- List<VcsRef> refs = RefParser.parseCommitRefs(inputStr, NullVirtualFile.INSTANCE);
+ List<VcsRef> refs = new RefParser(new TestLogObjectsFactory()).parseCommitRefs(inputStr, NullVirtualFile.INSTANCE);
StringBuilder s = new StringBuilder();
for (VcsRef ref : refs) {
if (s.length() > 0) {
@@ -61,4 +66,58 @@
}
+ private class TestLogObjectsFactory implements VcsLogObjectsFactory {
+ @NotNull
+ @Override
+ public Hash createHash(@NotNull String stringHash) {
+ throw new UnsupportedOperationException();
+ }
+
+ @NotNull
+ @Override
+ public VcsCommit createCommit(@NotNull Hash hash, @NotNull List<Hash> parents) {
+ throw new UnsupportedOperationException();
+ }
+
+ @NotNull
+ @Override
+ public TimedVcsCommit createTimedCommit(@NotNull Hash hash, @NotNull List<Hash> parents, long timeStamp) {
+ throw new UnsupportedOperationException();
+ }
+
+ @NotNull
+ @Override
+ public VcsShortCommitDetails createShortDetails(@NotNull Hash hash, @NotNull List<Hash> parents, long timeStamp, VirtualFile root,
+ @NotNull String subject, @NotNull String authorName, String authorEmail) {
+ throw new UnsupportedOperationException();
+ }
+
+ @NotNull
+ @Override
+ public VcsFullCommitDetails createFullDetails(@NotNull Hash hash, @NotNull List<Hash> parents, long authorTime, VirtualFile root,
+ @NotNull String subject, @NotNull String authorName, @NotNull String authorEmail,
+ @NotNull String message, @NotNull String committerName, @NotNull String committerEmail,
+ long commitTime, @NotNull List<Change> changes,
+ @NotNull ContentRevisionFactory contentRevisionFactory) {
+ throw new UnsupportedOperationException();
+ }
+
+ @NotNull
+ @Override
+ public VcsUser createUser(@NotNull String name, @NotNull String email) {
+ throw new UnsupportedOperationException();
+ }
+
+ @NotNull
+ @Override
+ public VcsRef createRef(@NotNull Hash commitHash, @NotNull String name, @NotNull VcsRefType type, @NotNull VirtualFile root) {
+ return new VcsRefImpl(new NotNullFunction<Hash, Integer>() {
+ @NotNull
+ @Override
+ public Integer fun(Hash dom) {
+ return Integer.parseInt(dom.asString().substring(0, Math.min(4, dom.asString().length())), 16);
+ }
+ }, commitHash, name, type, root);
+ }
+ }
}
diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubShowCommitInBrowserFromLogAction.java b/plugins/github/src/org/jetbrains/plugins/github/GithubShowCommitInBrowserFromLogAction.java
index 7b3d9a1..06392ba 100644
--- a/plugins/github/src/org/jetbrains/plugins/github/GithubShowCommitInBrowserFromLogAction.java
+++ b/plugins/github/src/org/jetbrains/plugins/github/GithubShowCommitInBrowserFromLogAction.java
@@ -70,7 +70,7 @@
private static VcsShortCommitDetails getCurrentlySelectedCommitInTheLog(AnActionEvent e) {
GitHeavyCommit heavyCommit = e.getData(GitVcs.GIT_COMMIT);
if (heavyCommit != null) {
- final VcsLogObjectsFactory factory = ServiceManager.getService(VcsLogObjectsFactory.class);
+ final VcsLogObjectsFactory factory = ServiceManager.getService(e.getProject(), VcsLogObjectsFactory.class);
List<Hash> parents = ContainerUtil.map(heavyCommit.getParentsHashes(), new Function<String, Hash>() {
@Override
public Hash fun(String s) {
@@ -78,7 +78,8 @@
}
});
return factory.createShortDetails(factory.createHash(heavyCommit.getHash().getValue()), parents, heavyCommit.getAuthorTime(),
- heavyCommit.getRoot(), heavyCommit.getSubject(), heavyCommit.getAuthor());
+ heavyCommit.getRoot(), heavyCommit.getSubject(), heavyCommit.getAuthor(),
+ heavyCommit.getAuthorEmail());
}
VcsLog log = e.getData(VcsLogDataKeys.VSC_LOG);
if (log == null) {
diff --git a/plugins/github/src/org/jetbrains/plugins/github/api/GithubApiUtil.java b/plugins/github/src/org/jetbrains/plugins/github/api/GithubApiUtil.java
index 69f6efb..885f252 100644
--- a/plugins/github/src/org/jetbrains/plugins/github/api/GithubApiUtil.java
+++ b/plugins/github/src/org/jetbrains/plugins/github/api/GithubApiUtil.java
@@ -671,7 +671,7 @@
@NotNull String repo,
@Nullable String query) throws IOException {
try {
- query = URLEncoder.encode("@" + user + "/" + repo + " " + query, "UTF-8");
+ query = URLEncoder.encode("repo:" + user + "/" + repo + " " + query, "UTF-8");
String path = "/search/issues?q=" + query;
//TODO: Use bodyHtml for issues - GitHub does not support this feature for SearchApi yet
diff --git a/plugins/gradle/gradle.iml b/plugins/gradle/gradle.iml
index fba8a60..cc1787c 100644
--- a/plugins/gradle/gradle.iml
+++ b/plugins/gradle/gradle.iml
@@ -26,100 +26,100 @@
<orderEntry type="module-library" exported="">
<library name="Gradle">
<CLASSES>
- <root url="jar://$MODULE_DIR$/lib/gradle-base-services-1.9-rc-2.jar!/" />
- <root url="jar://$MODULE_DIR$/lib/gradle-core-1.9-rc-2.jar!/" />
- <root url="jar://$MODULE_DIR$/lib/gradle-messaging-1.9-rc-2.jar!/" />
- <root url="jar://$MODULE_DIR$/lib/gradle-tooling-api-1.9-rc-2.jar!/" />
- <root url="jar://$MODULE_DIR$/lib/gradle-wrapper-1.9-rc-2.jar!/" />
- <root url="jar://$MODULE_DIR$/lib/gradle-plugins-1.9-rc-2.jar!/" />
- <root url="jar://$MODULE_DIR$/lib/gradle-build-init-1.9-rc-2.jar!/" />
- <root url="jar://$MODULE_DIR$/lib/gradle-native-1.9-rc-2.jar!/" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-base-services-1.9-rc-3.jar!/" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-core-1.9-rc-3.jar!/" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-messaging-1.9-rc-3.jar!/" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-tooling-api-1.9-rc-3.jar!/" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-wrapper-1.9-rc-3.jar!/" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-plugins-1.9-rc-3.jar!/" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-build-init-1.9-rc-3.jar!/" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-native-1.9-rc-3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/buildSrc/src/main/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/buildSrc/src/test/resources" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/ui/src/main/java" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/ui/src/test/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/ui/src/integTest/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/cli/src/main/java" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/cpp/src/main/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/cpp/src/integTest/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/ear/src/main/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/ide/src/main/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/ide/src/main/resources" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/ivy/src/main/java/org/gradle/api/publish/ivy/tasks" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/ivy/src/main/java/org/gradle/api/publish/ivy/plugins" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/ivy/src/main/java" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/core/src/main/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/core/src/test/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/core/src/integTest/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/core/src/testFixtures/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/osgi/src/main/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/osgi/src/test/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/antlr/src/main/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/jetty/src/main/java" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/maven/src/main/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/maven/src/test/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/scala/src/main/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/scala/src/test/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/jacoco/src/main/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/native/src/main/java" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/plugins/src/main/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/plugins/src/test/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/plugins/src/testFixtures/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/publish/src/main/groovy/org/gradle/api/publish/plugins" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/publish/src/main/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/wrapper/src/main/java" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/wrapper/src/test/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/announce/src/main/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/launcher/src/main/java" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/launcher/src/test/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/launcher/src/integTest/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/open-api/src/main/java" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/open-api/src/integTest/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/core-impl/src/main/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/core-impl/src/test/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/messaging/src/main/java" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/messaging/src/test/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/reporting/src/main/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/resources/src/main/java" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/javascript/src/main/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/build-init/src/main/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/build-init/src/test/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/build-init/src/integTest/resources/org/gradle/buildinit/plugins/MavenConversionIntegrationTest/testjar/src/main/java" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/build-init/src/integTest/resources/org/gradle/buildinit/plugins/MavenConversionIntegrationTest/testjar/src/test/java" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/build-init/src/integTest/resources/org/gradle/buildinit/plugins/MavenConversionIntegrationTest/multiModule/webinar-api/src/main/java" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/build-init/src/integTest/resources/org/gradle/buildinit/plugins/MavenConversionIntegrationTest/multiModule/webinar-impl/src/main/java" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/build-init/src/integTest/resources/org/gradle/buildinit/plugins/MavenConversionIntegrationTest/multiModule/webinar-impl/src/test/java" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/build-init/src/integTest/resources/org/gradle/buildinit/plugins/MavenConversionIntegrationTest/singleModule/src/main/java" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/build-init/src/integTest/resources/org/gradle/buildinit/plugins/MavenConversionIntegrationTest/singleModule/src/test/java" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/build-init/src/integTest/resources/org/gradle/buildinit/plugins/MavenConversionIntegrationTest/enforcerplugin/src/main/java" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/build-init/src/integTest/resources/org/gradle/buildinit/plugins/MavenConversionIntegrationTest/flatmultimodule/webinar-api/src/main/java" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/build-init/src/integTest/resources/org/gradle/buildinit/plugins/MavenConversionIntegrationTest/flatmultimodule/webinar-impl/src/main/java" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/build-init/src/integTest/resources/org/gradle/buildinit/plugins/MavenConversionIntegrationTest/flatmultimodule/webinar-impl/src/test/java" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/diagnostics/src/main/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/diagnostics/src/test/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/diagnostics/src/integTest/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/performance/src/configPlugin" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/performance/src/testFixtures/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/tooling-api/src/main/java" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/tooling-api/src/integTest/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/tooling-api/src/testFixtures/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/code-quality/src/main/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/language-jvm/src/main/groovy/org/gradle/language/jvm/tasks" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/language-jvm/src/main/groovy/org/gradle/language/jvm/plugins" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/language-jvm/src/main/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/base-services/src/main/java" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/base-services/src/test/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/language-base/src/main/groovy/org/gradle/language/base/plugins" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/language-base/src/main/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/build-comparison/src/main/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/build-comparison/src/integTest/resources/org/gradle/api/plugins/buildcomparison/gradle/BuildComparisonIntegrationSpec/compareArchives/source/src/main/java" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/build-comparison/src/integTest/resources/org/gradle/api/plugins/buildcomparison/gradle/BuildComparisonIntegrationSpec/compareArchives/target/src/main/java" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/internal-testing/src/main/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/base-services-groovy/src/main/groovy" />
- <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-2-src.zip!/gradle-1.9-rc-2/subprojects/base-services-groovy/src/test/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/buildSrc/src/main/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/buildSrc/src/test/resources" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/ui/src/main/java" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/ui/src/test/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/ui/src/integTest/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/cli/src/main/java" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/cpp/src/main/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/cpp/src/integTest/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/ear/src/main/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/ide/src/main/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/ide/src/main/resources" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/ivy/src/main/java/org/gradle/api/publish/ivy/tasks" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/ivy/src/main/java/org/gradle/api/publish/ivy/plugins" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/ivy/src/main/java" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/core/src/main/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/core/src/test/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/core/src/integTest/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/core/src/testFixtures/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/osgi/src/main/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/osgi/src/test/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/antlr/src/main/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/jetty/src/main/java" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/maven/src/main/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/maven/src/test/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/scala/src/main/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/scala/src/test/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/jacoco/src/main/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/native/src/main/java" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/plugins/src/main/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/plugins/src/test/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/plugins/src/testFixtures/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/publish/src/main/groovy/org/gradle/api/publish/plugins" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/publish/src/main/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/wrapper/src/main/java" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/wrapper/src/test/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/announce/src/main/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/launcher/src/main/java" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/launcher/src/test/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/launcher/src/integTest/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/open-api/src/main/java" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/open-api/src/integTest/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/core-impl/src/main/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/core-impl/src/test/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/messaging/src/main/java" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/messaging/src/test/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/reporting/src/main/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/resources/src/main/java" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/javascript/src/main/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/build-init/src/main/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/build-init/src/test/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/build-init/src/integTest/resources/org/gradle/buildinit/plugins/MavenConversionIntegrationTest/testjar/src/main/java" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/build-init/src/integTest/resources/org/gradle/buildinit/plugins/MavenConversionIntegrationTest/testjar/src/test/java" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/build-init/src/integTest/resources/org/gradle/buildinit/plugins/MavenConversionIntegrationTest/multiModule/webinar-api/src/main/java" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/build-init/src/integTest/resources/org/gradle/buildinit/plugins/MavenConversionIntegrationTest/multiModule/webinar-impl/src/main/java" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/build-init/src/integTest/resources/org/gradle/buildinit/plugins/MavenConversionIntegrationTest/multiModule/webinar-impl/src/test/java" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/build-init/src/integTest/resources/org/gradle/buildinit/plugins/MavenConversionIntegrationTest/singleModule/src/main/java" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/build-init/src/integTest/resources/org/gradle/buildinit/plugins/MavenConversionIntegrationTest/singleModule/src/test/java" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/build-init/src/integTest/resources/org/gradle/buildinit/plugins/MavenConversionIntegrationTest/enforcerplugin/src/main/java" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/build-init/src/integTest/resources/org/gradle/buildinit/plugins/MavenConversionIntegrationTest/flatmultimodule/webinar-api/src/main/java" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/build-init/src/integTest/resources/org/gradle/buildinit/plugins/MavenConversionIntegrationTest/flatmultimodule/webinar-impl/src/main/java" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/build-init/src/integTest/resources/org/gradle/buildinit/plugins/MavenConversionIntegrationTest/flatmultimodule/webinar-impl/src/test/java" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/diagnostics/src/main/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/diagnostics/src/test/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/diagnostics/src/integTest/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/performance/src/configPlugin" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/performance/src/testFixtures/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/tooling-api/src/main/java" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/tooling-api/src/integTest/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/tooling-api/src/testFixtures/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/code-quality/src/main/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/language-jvm/src/main/groovy/org/gradle/language/jvm/tasks" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/language-jvm/src/main/groovy/org/gradle/language/jvm/plugins" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/language-jvm/src/main/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/base-services/src/main/java" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/base-services/src/test/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/language-base/src/main/groovy/org/gradle/language/base/plugins" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/language-base/src/main/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/build-comparison/src/main/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/build-comparison/src/integTest/resources/org/gradle/api/plugins/buildcomparison/gradle/BuildComparisonIntegrationSpec/compareArchives/source/src/main/java" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/build-comparison/src/integTest/resources/org/gradle/api/plugins/buildcomparison/gradle/BuildComparisonIntegrationSpec/compareArchives/target/src/main/java" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/internal-testing/src/main/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/base-services-groovy/src/main/groovy" />
+ <root url="jar://$MODULE_DIR$/lib/gradle-1.9-rc-3-src.zip!/gradle-1.9-rc-3/subprojects/base-services-groovy/src/test/groovy" />
</SOURCES>
</library>
</orderEntry>
@@ -136,12 +136,10 @@
<orderEntry type="module-library" exported="">
<library name="GradleGuava">
<CLASSES>
- <root url="jar://$MODULE_DIR$/lib/guava-11.0.2.jar!/" />
+ <root url="jar://$MODULE_DIR$/lib/guava-jdk5-14.0.1.jar!/" />
</CLASSES>
<JAVADOC />
- <SOURCES>
- <root url="jar://$USER_HOME$/.ideaLibSources/guava-11.0.2-sources.jar!/" />
- </SOURCES>
+ <SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
@@ -171,9 +169,20 @@
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/jna-3.2.7.jar!/" />
<root url="jar://$MODULE_DIR$/lib/jna-posix-1.0.3.jar!/" />
+ <root url="jar://$MODULE_DIR$/lib/native-platform-0.3-rc-2.jar!/" />
+ <root url="jar://$MODULE_DIR$/lib/native-platform-linux-amd64-0.3-rc-2.jar!/" />
+ <root url="jar://$MODULE_DIR$/lib/native-platform-linux-i386-0.3-rc-2.jar!/" />
+ <root url="jar://$MODULE_DIR$/lib/native-platform-osx-universal-0.3-rc-2.jar!/" />
+ <root url="jar://$MODULE_DIR$/lib/native-platform-windows-amd64-0.3-rc-2.jar!/" />
+ <root url="jar://$MODULE_DIR$/lib/native-platform-windows-i386-0.3-rc-2.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
+ <jarDirectory url="jar://$MODULE_DIR$/lib/native-platform-linux-amd64-0.3-rc-2.jar!/" recursive="false" />
+ <jarDirectory url="jar://$MODULE_DIR$/lib/native-platform-linux-i386-0.3-rc-2.jar!/" recursive="false" />
+ <jarDirectory url="jar://$MODULE_DIR$/lib/native-platform-osx-universal-0.3-rc-2.jar!/" recursive="false" />
+ <jarDirectory url="jar://$MODULE_DIR$/lib/native-platform-windows-amd64-0.3-rc-2.jar!/" recursive="false" />
+ <jarDirectory url="jar://$MODULE_DIR$/lib/native-platform-windows-i386-0.3-rc-2.jar!/" recursive="false" />
</library>
</orderEntry>
<orderEntry type="module" module-name="testFramework-java" scope="TEST" />
diff --git a/plugins/gradle/lib/gradle-1.8-src.zip b/plugins/gradle/lib/gradle-1.8-src.zip
deleted file mode 100644
index d4857b6..0000000
--- a/plugins/gradle/lib/gradle-1.8-src.zip
+++ /dev/null
Binary files differ
diff --git a/plugins/gradle/lib/gradle-1.9-rc-2-src.zip b/plugins/gradle/lib/gradle-1.9-rc-3-src.zip
similarity index 85%
rename from plugins/gradle/lib/gradle-1.9-rc-2-src.zip
rename to plugins/gradle/lib/gradle-1.9-rc-3-src.zip
index 912d335..0401dfc 100644
--- a/plugins/gradle/lib/gradle-1.9-rc-2-src.zip
+++ b/plugins/gradle/lib/gradle-1.9-rc-3-src.zip
Binary files differ
diff --git a/plugins/gradle/lib/gradle-base-services-1.8.jar b/plugins/gradle/lib/gradle-base-services-1.8.jar
deleted file mode 100644
index 8f1c65d..0000000
--- a/plugins/gradle/lib/gradle-base-services-1.8.jar
+++ /dev/null
Binary files differ
diff --git a/plugins/gradle/lib/gradle-base-services-1.9-rc-2.jar b/plugins/gradle/lib/gradle-base-services-1.9-rc-3.jar
similarity index 84%
rename from plugins/gradle/lib/gradle-base-services-1.9-rc-2.jar
rename to plugins/gradle/lib/gradle-base-services-1.9-rc-3.jar
index 01da1fd..fbc2d9d 100644
--- a/plugins/gradle/lib/gradle-base-services-1.9-rc-2.jar
+++ b/plugins/gradle/lib/gradle-base-services-1.9-rc-3.jar
Binary files differ
diff --git a/plugins/gradle/lib/gradle-build-init-1.9-rc-2.jar b/plugins/gradle/lib/gradle-build-init-1.9-rc-3.jar
similarity index 62%
rename from plugins/gradle/lib/gradle-build-init-1.9-rc-2.jar
rename to plugins/gradle/lib/gradle-build-init-1.9-rc-3.jar
index 2cc1814..c776e9b 100644
--- a/plugins/gradle/lib/gradle-build-init-1.9-rc-2.jar
+++ b/plugins/gradle/lib/gradle-build-init-1.9-rc-3.jar
Binary files differ
diff --git a/plugins/gradle/lib/gradle-build-setup-1.8.jar b/plugins/gradle/lib/gradle-build-setup-1.8.jar
deleted file mode 100644
index 5a92990..0000000
--- a/plugins/gradle/lib/gradle-build-setup-1.8.jar
+++ /dev/null
Binary files differ
diff --git a/plugins/gradle/lib/gradle-core-1.8.jar b/plugins/gradle/lib/gradle-core-1.8.jar
deleted file mode 100644
index e0fda00..0000000
--- a/plugins/gradle/lib/gradle-core-1.8.jar
+++ /dev/null
Binary files differ
diff --git a/plugins/gradle/lib/gradle-core-1.9-rc-2.jar b/plugins/gradle/lib/gradle-core-1.9-rc-3.jar
similarity index 82%
rename from plugins/gradle/lib/gradle-core-1.9-rc-2.jar
rename to plugins/gradle/lib/gradle-core-1.9-rc-3.jar
index ac7d868..f9efe10 100644
--- a/plugins/gradle/lib/gradle-core-1.9-rc-2.jar
+++ b/plugins/gradle/lib/gradle-core-1.9-rc-3.jar
Binary files differ
diff --git a/plugins/gradle/lib/gradle-messaging-1.8.jar b/plugins/gradle/lib/gradle-messaging-1.8.jar
deleted file mode 100644
index 9cf71f5..0000000
--- a/plugins/gradle/lib/gradle-messaging-1.8.jar
+++ /dev/null
Binary files differ
diff --git a/plugins/gradle/lib/gradle-messaging-1.9-rc-2.jar b/plugins/gradle/lib/gradle-messaging-1.9-rc-3.jar
similarity index 87%
rename from plugins/gradle/lib/gradle-messaging-1.9-rc-2.jar
rename to plugins/gradle/lib/gradle-messaging-1.9-rc-3.jar
index ec97203..b255624 100644
--- a/plugins/gradle/lib/gradle-messaging-1.9-rc-2.jar
+++ b/plugins/gradle/lib/gradle-messaging-1.9-rc-3.jar
Binary files differ
diff --git a/plugins/gradle/lib/gradle-native-1.8.jar b/plugins/gradle/lib/gradle-native-1.8.jar
deleted file mode 100644
index 84b4bf7..0000000
--- a/plugins/gradle/lib/gradle-native-1.8.jar
+++ /dev/null
Binary files differ
diff --git a/plugins/gradle/lib/gradle-native-1.9-rc-2.jar b/plugins/gradle/lib/gradle-native-1.9-rc-3.jar
similarity index 84%
rename from plugins/gradle/lib/gradle-native-1.9-rc-2.jar
rename to plugins/gradle/lib/gradle-native-1.9-rc-3.jar
index 46a9b34..6909e53 100644
--- a/plugins/gradle/lib/gradle-native-1.9-rc-2.jar
+++ b/plugins/gradle/lib/gradle-native-1.9-rc-3.jar
Binary files differ
diff --git a/plugins/gradle/lib/gradle-plugins-1.8.jar b/plugins/gradle/lib/gradle-plugins-1.8.jar
deleted file mode 100644
index 071d1c1..0000000
--- a/plugins/gradle/lib/gradle-plugins-1.8.jar
+++ /dev/null
Binary files differ
diff --git a/plugins/gradle/lib/gradle-plugins-1.9-rc-2.jar b/plugins/gradle/lib/gradle-plugins-1.9-rc-3.jar
similarity index 75%
rename from plugins/gradle/lib/gradle-plugins-1.9-rc-2.jar
rename to plugins/gradle/lib/gradle-plugins-1.9-rc-3.jar
index 53c7139..2906284 100644
--- a/plugins/gradle/lib/gradle-plugins-1.9-rc-2.jar
+++ b/plugins/gradle/lib/gradle-plugins-1.9-rc-3.jar
Binary files differ
diff --git a/plugins/gradle/lib/gradle-tooling-api-1.8.jar b/plugins/gradle/lib/gradle-tooling-api-1.8.jar
deleted file mode 100644
index 7e744bb..0000000
--- a/plugins/gradle/lib/gradle-tooling-api-1.8.jar
+++ /dev/null
Binary files differ
diff --git a/plugins/gradle/lib/gradle-tooling-api-1.9-rc-2.jar b/plugins/gradle/lib/gradle-tooling-api-1.9-rc-3.jar
similarity index 82%
rename from plugins/gradle/lib/gradle-tooling-api-1.9-rc-2.jar
rename to plugins/gradle/lib/gradle-tooling-api-1.9-rc-3.jar
index 673c6f1..8902ddd 100644
--- a/plugins/gradle/lib/gradle-tooling-api-1.9-rc-2.jar
+++ b/plugins/gradle/lib/gradle-tooling-api-1.9-rc-3.jar
Binary files differ
diff --git a/plugins/gradle/lib/gradle-wrapper-1.8.jar b/plugins/gradle/lib/gradle-wrapper-1.8.jar
deleted file mode 100644
index 31e2d66..0000000
--- a/plugins/gradle/lib/gradle-wrapper-1.8.jar
+++ /dev/null
Binary files differ
diff --git a/plugins/gradle/lib/gradle-wrapper-1.9-rc-2.jar b/plugins/gradle/lib/gradle-wrapper-1.9-rc-3.jar
similarity index 90%
rename from plugins/gradle/lib/gradle-wrapper-1.9-rc-2.jar
rename to plugins/gradle/lib/gradle-wrapper-1.9-rc-3.jar
index f8ef3d6..1ada72a 100644
--- a/plugins/gradle/lib/gradle-wrapper-1.9-rc-2.jar
+++ b/plugins/gradle/lib/gradle-wrapper-1.9-rc-3.jar
Binary files differ
diff --git a/plugins/gradle/lib/guava-11.0.2.jar b/plugins/gradle/lib/guava-11.0.2.jar
deleted file mode 100644
index c8c8d5d..0000000
--- a/plugins/gradle/lib/guava-11.0.2.jar
+++ /dev/null
Binary files differ
diff --git a/plugins/gradle/lib/guava-jdk5-14.0.1.jar b/plugins/gradle/lib/guava-jdk5-14.0.1.jar
new file mode 100644
index 0000000..af66ab0
--- /dev/null
+++ b/plugins/gradle/lib/guava-jdk5-14.0.1.jar
Binary files differ
diff --git a/plugins/gradle/lib/native-platform-0.3-rc-2.jar b/plugins/gradle/lib/native-platform-0.3-rc-2.jar
new file mode 100644
index 0000000..ede1eca
--- /dev/null
+++ b/plugins/gradle/lib/native-platform-0.3-rc-2.jar
Binary files differ
diff --git a/plugins/gradle/lib/native-platform-linux-amd64-0.3-rc-2.jar b/plugins/gradle/lib/native-platform-linux-amd64-0.3-rc-2.jar
new file mode 100644
index 0000000..14508de
--- /dev/null
+++ b/plugins/gradle/lib/native-platform-linux-amd64-0.3-rc-2.jar
Binary files differ
diff --git a/plugins/gradle/lib/native-platform-linux-i386-0.3-rc-2.jar b/plugins/gradle/lib/native-platform-linux-i386-0.3-rc-2.jar
new file mode 100644
index 0000000..4e8c6db
--- /dev/null
+++ b/plugins/gradle/lib/native-platform-linux-i386-0.3-rc-2.jar
Binary files differ
diff --git a/plugins/gradle/lib/native-platform-osx-universal-0.3-rc-2.jar b/plugins/gradle/lib/native-platform-osx-universal-0.3-rc-2.jar
new file mode 100644
index 0000000..5942383
--- /dev/null
+++ b/plugins/gradle/lib/native-platform-osx-universal-0.3-rc-2.jar
Binary files differ
diff --git a/plugins/gradle/lib/native-platform-windows-amd64-0.3-rc-2.jar b/plugins/gradle/lib/native-platform-windows-amd64-0.3-rc-2.jar
new file mode 100644
index 0000000..d048493
--- /dev/null
+++ b/plugins/gradle/lib/native-platform-windows-amd64-0.3-rc-2.jar
Binary files differ
diff --git a/plugins/gradle/lib/native-platform-windows-i386-0.3-rc-2.jar b/plugins/gradle/lib/native-platform-windows-i386-0.3-rc-2.jar
new file mode 100644
index 0000000..47b6430
--- /dev/null
+++ b/plugins/gradle/lib/native-platform-windows-i386-0.3-rc-2.jar
Binary files differ
diff --git a/plugins/gradle/src/META-INF/gradle-javaee-plugin.xml b/plugins/gradle/src/META-INF/gradle-javaee-plugin.xml
new file mode 100644
index 0000000..2a8b4d5
--- /dev/null
+++ b/plugins/gradle/src/META-INF/gradle-javaee-plugin.xml
@@ -0,0 +1,8 @@
+<idea-plugin>
+ <extensions defaultExtensionNs="com.intellij">
+ <externalProjectDataService implementation="org.jetbrains.plugins.gradle.service.project.data.javaee.WebModuleGradleDataService"/>
+ </extensions>
+ <extensions defaultExtensionNs="org.jetbrains.plugins.gradle">
+ <projectResolve implementation="org.jetbrains.plugins.gradle.integrations.javaee.JavaEEGradleProjectResolverExtension"/>
+ </extensions>
+</idea-plugin>
diff --git a/plugins/gradle/src/META-INF/services/org.jetbrains.plugins.gradle.model.ModelBuilderService b/plugins/gradle/src/META-INF/services/org.jetbrains.plugins.gradle.model.ModelBuilderService
new file mode 100644
index 0000000..9d8e690
--- /dev/null
+++ b/plugins/gradle/src/META-INF/services/org.jetbrains.plugins.gradle.model.ModelBuilderService
@@ -0,0 +1,16 @@
+#
+# Copyright 2000-2013 JetBrains s.r.o.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+org.jetbrains.plugins.gradle.model.impl.WarModelBuilderImpl
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/GradleManager.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/GradleManager.java
index 4013ee3..d109ded 100644
--- a/plugins/gradle/src/org/jetbrains/plugins/gradle/GradleManager.java
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/GradleManager.java
@@ -17,8 +17,6 @@
import com.intellij.execution.ExecutionException;
import com.intellij.execution.configurations.SimpleJavaParameters;
-import com.intellij.externalSystem.JavaProjectData;
-import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.externalSystem.ExternalSystemAutoImportAware;
@@ -39,14 +37,11 @@
import com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager;
import com.intellij.openapi.externalSystem.service.ui.DefaultExternalSystemUiAware;
import com.intellij.openapi.externalSystem.task.ExternalSystemTaskManager;
+import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange;
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
import com.intellij.openapi.externalSystem.util.ExternalSystemConstants;
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
-import com.intellij.openapi.module.EmptyModuleType;
-import com.intellij.openapi.module.JavaModuleType;
-import com.intellij.openapi.module.ModuleType;
-import com.intellij.openapi.module.StdModuleTypes;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ex.ProjectRootManagerEx;
@@ -55,14 +50,10 @@
import com.intellij.openapi.util.NotNullLazyValue;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.pom.java.LanguageLevel;
import com.intellij.util.Function;
-import com.intellij.util.PathUtil;
-import com.intellij.util.PathsList;
import com.intellij.util.containers.ContainerUtilRt;
import com.intellij.util.messages.MessageBusConnection;
import icons.GradleIcons;
-import org.gradle.tooling.ProjectConnection;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.gradle.config.GradleSettingsListenerAdapter;
@@ -74,13 +65,11 @@
import org.jetbrains.plugins.gradle.service.settings.GradleConfigurable;
import org.jetbrains.plugins.gradle.service.task.GradleTaskManager;
import org.jetbrains.plugins.gradle.settings.*;
-import org.jetbrains.plugins.gradle.util.GradleBundle;
import org.jetbrains.plugins.gradle.util.GradleConstants;
import org.jetbrains.plugins.gradle.util.GradleUtil;
import javax.swing.*;
import java.io.File;
-import java.io.FilenameFilter;
import java.io.IOException;
import java.net.URL;
import java.util.Collection;
@@ -291,9 +280,9 @@
if (externalProject == null) {
return;
}
- ExternalSystemApiUtil.executeProjectChangeAction(true, new Runnable() {
+ ExternalSystemApiUtil.executeProjectChangeAction(true, new DisposeAwareProjectChange(project) {
@Override
- public void run() {
+ public void execute() {
ProjectRootManagerEx.getInstanceEx(project).mergeRootsChangesDuring(new Runnable() {
@Override
public void run() {
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/codeInsight/UseDistributionWithSourcesNotificationProvider.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/codeInsight/UseDistributionWithSourcesNotificationProvider.java
index e343850..592b668 100644
--- a/plugins/gradle/src/org/jetbrains/plugins/gradle/codeInsight/UseDistributionWithSourcesNotificationProvider.java
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/codeInsight/UseDistributionWithSourcesNotificationProvider.java
@@ -22,6 +22,7 @@
import com.intellij.openapi.externalSystem.model.project.ProjectData;
import com.intellij.openapi.externalSystem.service.project.ExternalProjectRefreshCallback;
import com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager;
+import com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange;
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
import com.intellij.openapi.externalSystem.util.ExternalSystemConstants;
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
@@ -127,9 +128,9 @@
if (externalProject == null) {
return;
}
- ExternalSystemApiUtil.executeProjectChangeAction(true, new Runnable() {
+ ExternalSystemApiUtil.executeProjectChangeAction(true, new DisposeAwareProjectChange(module.getProject()) {
@Override
- public void run() {
+ public void execute() {
ProjectRootManagerEx.getInstanceEx(module.getProject()).mergeRootsChangesDuring(new Runnable() {
@Override
public void run() {
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/integrations/javaee/JavaEEGradleProjectResolverExtension.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/integrations/javaee/JavaEEGradleProjectResolverExtension.java
new file mode 100644
index 0000000..07621c6
--- /dev/null
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/integrations/javaee/JavaEEGradleProjectResolverExtension.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.gradle.integrations.javaee;
+
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.externalSystem.model.DataNode;
+import com.intellij.openapi.externalSystem.model.project.ModuleData;
+import com.intellij.openapi.externalSystem.util.ExternalSystemConstants;
+import com.intellij.openapi.externalSystem.util.Order;
+import com.intellij.util.containers.ContainerUtil;
+import org.gradle.tooling.model.idea.IdeaModule;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.plugins.gradle.model.WarModel;
+import org.jetbrains.plugins.gradle.model.data.WarModelData;
+import org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension;
+import org.jetbrains.plugins.gradle.util.GradleConstants;
+
+import java.util.Set;
+
+/**
+ * {@link JavaEEGradleProjectResolverExtension} provides JavaEE project info based on gradle tooling API models.
+ *
+ * @author Vladislav.Soroka
+ * @since 10/14/13
+ */
+@Order(ExternalSystemConstants.UNORDERED)
+public class JavaEEGradleProjectResolverExtension extends AbstractProjectResolverExtension {
+ private static final Logger LOG = Logger.getInstance(JavaEEGradleProjectResolverExtension.class);
+
+ @Override
+ public void populateModuleExtraModels(@NotNull IdeaModule gradleModule, @NotNull DataNode<ModuleData> ideModule) {
+ WarModel warModel = resolverCtx.getExtraProject(gradleModule, WarModel.class);
+ if (warModel != null) {
+ WarModelData warModelData = new WarModelData(GradleConstants.SYSTEM_ID, warModel.getWebAppDirName(), warModel.getWebAppDir());
+ warModelData.setWebXml(warModel.getWebXml());
+ warModelData.setWebRoots(warModel.getWebRoots());
+ ideModule.createChild(WarModelData.KEY, warModelData);
+ }
+
+ nextResolver.populateModuleExtraModels(gradleModule, ideModule);
+ }
+
+ @NotNull
+ @Override
+ public Set<Class> getExtraProjectModelClasses() {
+ return ContainerUtil.<Class>set(WarModel.class);
+ }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/GroovyTypeHierarchyProvider.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/ModelBuilderService.java
similarity index 65%
copy from plugins/groovy/src/org/jetbrains/plugins/groovy/lang/GroovyTypeHierarchyProvider.java
copy to plugins/gradle/src/org/jetbrains/plugins/gradle/model/ModelBuilderService.java
index bed999e..3a76dbe 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/GroovyTypeHierarchyProvider.java
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/ModelBuilderService.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,12 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.jetbrains.plugins.groovy.lang;
+package org.jetbrains.plugins.gradle.model;
-import com.intellij.ide.hierarchy.type.JavaTypeHierarchyProvider;
+import org.gradle.api.Project;
/**
- * @author peter
+ * @author Vladislav.Soroka
+ * @since 11/5/13
*/
-public class GroovyTypeHierarchyProvider extends JavaTypeHierarchyProvider{
+public interface ModelBuilderService {
+ boolean canBuild(String modelName);
+
+ Object buildAll(String modelName, Project project);
}
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/model/WarModel.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/WarModel.java
new file mode 100644
index 0000000..2986494
--- /dev/null
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/WarModel.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.gradle.model;
+
+import java.io.File;
+import java.io.Serializable;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Vladislav.Soroka
+ * @since 11/5/13
+ */
+public interface WarModel extends Serializable {
+ String getWebAppDirName();
+
+ File getWebAppDir();
+
+ File getWebXml();
+
+ Map<String, Set<String>> getWebRoots();
+}
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/model/data/WarModelData.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/data/WarModelData.java
new file mode 100644
index 0000000..80eef6e
--- /dev/null
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/data/WarModelData.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.gradle.model.data;
+
+import com.intellij.openapi.externalSystem.model.Key;
+import com.intellij.openapi.externalSystem.model.ProjectKeys;
+import com.intellij.openapi.externalSystem.model.ProjectSystemId;
+import com.intellij.openapi.externalSystem.model.project.AbstractExternalEntityData;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.io.File;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Vladislav.Soroka
+ * @since 11/6/13
+ */
+public class WarModelData extends AbstractExternalEntityData {
+ private static final long serialVersionUID = 1L;
+
+ @NotNull
+ public static final Key<WarModelData> KEY = Key.create(WarModelData.class, ProjectKeys.MODULE.getProcessingWeight() + 1);
+ @NotNull
+ private final String myWebAppDirName;
+ @Nullable
+ private final File myWebAppDir;
+ @Nullable
+ private File myWebXml;
+ @NotNull
+ private Map<String, Set<String>> myWebRoots;
+
+
+ public WarModelData(@NotNull ProjectSystemId owner, @NotNull String webAppDirName, @Nullable File webAppDir) {
+ super(owner);
+ myWebAppDirName = webAppDirName;
+ myWebAppDir = webAppDir;
+ myWebRoots = Collections.emptyMap();
+ }
+
+ @NotNull
+ public String getWebAppDirName() {
+ return myWebAppDirName;
+ }
+
+ @Nullable
+ public File getWebAppDir() {
+ return myWebAppDir;
+ }
+
+ public void setWebXml(@Nullable File webXml) {
+ myWebXml = webXml;
+ }
+
+ @Nullable
+ public File getWebXml() {
+ return myWebXml;
+ }
+
+ public void setWebRoots(@Nullable Map<String, Set<String>> webRoots) {
+ myWebRoots = webRoots == null ? Collections.<String, Set<String>>emptyMap() : webRoots;
+ }
+
+ @NotNull
+ public Map<String, Set<String>> getWebRoots() {
+ return myWebRoots;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ if (!super.equals(o)) return false;
+
+ WarModelData that = (WarModelData)o;
+
+ if (myWebAppDir != null ? !myWebAppDir.equals(that.myWebAppDir) : that.myWebAppDir != null) return false;
+ if (!myWebAppDirName.equals(that.myWebAppDirName)) return false;
+ if (!myWebRoots.equals(that.myWebRoots)) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = super.hashCode();
+ result = 31 * result + myWebAppDirName.hashCode();
+ result = 31 * result + myWebRoots.hashCode();
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "WarModelData{" +
+ "myWebAppDirName='" + myWebAppDirName + '\'' +
+ ", myWebAppDir=" + myWebAppDir +
+ ", myWebXml=" + myWebXml +
+ ", myWebRoots=" + myWebRoots +
+ '}';
+ }
+}
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/model/impl/WarModelBuilderImpl.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/impl/WarModelBuilderImpl.java
new file mode 100644
index 0000000..0e55d6b
--- /dev/null
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/impl/WarModelBuilderImpl.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.gradle.model.impl;
+
+import org.gradle.api.Action;
+import org.gradle.api.Project;
+import org.gradle.api.Task;
+import org.gradle.api.file.FileVisitDetails;
+import org.gradle.api.file.FileVisitor;
+import org.gradle.api.internal.file.copy.CopySpecInternal;
+import org.gradle.api.plugins.WarPlugin;
+import org.gradle.api.tasks.bundling.War;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.gradle.model.ModelBuilderService;
+import org.jetbrains.plugins.gradle.model.WarModel;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Vladislav.Soroka
+ * @since 11/5/13
+ */
+public class WarModelBuilderImpl implements ModelBuilderService {
+
+ private static final String WEB_APP_DIR_PROPERTY = "webAppDir";
+ private static final String WEB_APP_DIR_NAME_PROPERTY = "webAppDirName";
+
+ @Override
+ public boolean canBuild(String modelName) {
+ return WarModel.class.getName().equals(modelName);
+ }
+
+ @Nullable
+ @Override
+ public Object buildAll(String modelName, Project project) {
+ final WarPlugin warPlugin = project.getPlugins().findPlugin(WarPlugin.class);
+ if (warPlugin == null) return null;
+
+ final String webAppDirName = !project.hasProperty(WEB_APP_DIR_NAME_PROPERTY) ?
+ "src/main/webapp" : String.valueOf(project.property(WEB_APP_DIR_NAME_PROPERTY));
+
+ final File webAppDir = !project.hasProperty(WEB_APP_DIR_PROPERTY) ? null : (File)project.property(WEB_APP_DIR_PROPERTY);
+
+ WarModelImpl warModel = new WarModelImpl(webAppDirName, webAppDir);
+
+ for (Task task : project.getTasks()) {
+ if (task instanceof War) {
+ final War warTask = (War)task;
+ warModel.setWebXml(warTask.getWebXml());
+
+ final Map<String, Set<String>> webRoots = new HashMap<String, Set<String>>();
+ warTask.getRootSpec().walk(new Action<CopySpecInternal>() {
+ @Override
+ public void execute(CopySpecInternal internal) {
+ final String relativePath = internal.getDestPath().getPathString();
+ internal.getSource().visit(new FileVisitor() {
+ @Override
+ public void visitDir(FileVisitDetails dirDetails) {
+ try {
+ addPath(webRoots, relativePath, dirDetails.getFile().getPath());
+ }
+ catch (Exception ignore) {
+ }
+ }
+
+ @Override
+ public void visitFile(FileVisitDetails fileDetails) {
+ try {
+ if (warTask.getWebXml() == null ||
+ !fileDetails.getFile().getCanonicalPath().equals(warTask.getWebXml().getCanonicalPath())) {
+ addPath(webRoots, relativePath, fileDetails.getFile().getParent());
+ }
+ }
+ catch (Exception ignore) {
+ }
+ }
+ });
+ }
+ });
+
+ warModel.setWebRoots(webRoots);
+ break;
+ }
+ }
+
+ return warModel;
+ }
+
+ private static void addPath(Map<String, Set<String>> webRoots, String relativePath, String path) {
+ relativePath = relativePath == null ? "" : relativePath;
+ Set<String> paths = webRoots.get(relativePath);
+ if (paths == null) {
+ paths = new LinkedHashSet<String>();
+ webRoots.put(relativePath, paths);
+ }
+ paths.add(path);
+ }
+}
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/model/impl/WarModelImpl.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/impl/WarModelImpl.java
new file mode 100644
index 0000000..47aa662
--- /dev/null
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/impl/WarModelImpl.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.gradle.model.impl;
+
+import org.jetbrains.plugins.gradle.model.WarModel;
+
+import java.io.File;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Vladislav.Soroka
+ * @since 11/5/13
+ */
+public class WarModelImpl implements WarModel {
+ private final String myWebAppDirName;
+ private final File myWebAppDir;
+ private File myWebXml;
+ private Map<String, Set<String>> myWebRoots;
+
+ public WarModelImpl(String webAppDirName, File webAppDir) {
+ myWebAppDirName = webAppDirName;
+ myWebAppDir = webAppDir;
+ }
+
+ @Override
+ public String getWebAppDirName() {
+ return myWebAppDirName;
+ }
+
+ @Override
+ public File getWebAppDir() {
+ return myWebAppDir;
+ }
+
+ public void setWebXml(File webXml) {
+ myWebXml = webXml;
+ }
+
+ @Override
+ public File getWebXml() {
+ return myWebXml;
+ }
+
+ @Override
+ public Map<String, Set<String>> getWebRoots() {
+ return myWebRoots;
+ }
+
+ public void setWebRoots(Map<String, Set<String>> webRoots) {
+ myWebRoots = webRoots;
+ }
+}
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/model/internal/ExtraModelBuilder.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/internal/ExtraModelBuilder.java
new file mode 100644
index 0000000..2619557
--- /dev/null
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/internal/ExtraModelBuilder.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.gradle.model.internal;
+
+import org.gradle.api.Project;
+import org.gradle.tooling.provider.model.ToolingModelBuilder;
+import org.jetbrains.plugins.gradle.model.ModelBuilderService;
+
+import java.util.ServiceLoader;
+
+/**
+ * @author Vladislav.Soroka
+ * @since 11/5/13
+ */
+@SuppressWarnings("UnusedDeclaration")
+public class ExtraModelBuilder implements ToolingModelBuilder {
+ private static ServiceLoader<ModelBuilderService> buildersLoader =
+ ServiceLoader.load(ModelBuilderService.class, ExtraModelBuilder.class.getClassLoader());
+
+ @Override
+ public boolean canBuild(String modelName) {
+ for (ModelBuilderService service : buildersLoader) {
+ if (service.canBuild(modelName)) return true;
+ }
+ return false;
+ }
+
+ @Override
+ public Object buildAll(String modelName, Project project) {
+ for (ModelBuilderService service : buildersLoader) {
+ if (service.canBuild(modelName)) {
+ return service.buildAll(modelName, project);
+ }
+ }
+ throw new IllegalArgumentException("Unsupported model: " + modelName);
+ }
+}
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/model/internal/init.gradle b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/internal/init.gradle
new file mode 100644
index 0000000..a788cb8
--- /dev/null
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/internal/init.gradle
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import org.gradle.tooling.provider.model.ToolingModelBuilderRegistry
+
+@SuppressWarnings("GrPackage")
+class JetGradlePlugin implements Plugin<Project> {
+ private final ToolingModelBuilderRegistry registry
+
+ @javax.inject.Inject
+ public JetGradlePlugin(ToolingModelBuilderRegistry registry) {
+ this.registry = registry
+ }
+
+ public void apply(Project project) {
+ registry.register(project.jetExtraModelBuilderClass.newInstance())
+ }
+}
+
+try {
+ URL[] urls = [new File("${JAR_PATH}").toURI().toURL()]
+ URLClassLoader classLoader = new URLClassLoader(urls, getClass().classLoader)
+ Class modelClass = classLoader.loadClass('org.jetbrains.plugins.gradle.model.internal.ExtraModelBuilder')
+ allprojects {
+ ext.jetExtraModelBuilderClass = modelClass
+ apply plugin: JetGradlePlugin
+ }
+}
+catch (all) {
+}
\ No newline at end of file
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/AbstractProjectResolverExtension.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/AbstractProjectResolverExtension.java
new file mode 100644
index 0000000..cde2278
--- /dev/null
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/AbstractProjectResolverExtension.java
@@ -0,0 +1,155 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.gradle.service.project;
+
+import com.intellij.execution.ExecutionException;
+import com.intellij.execution.configurations.SimpleJavaParameters;
+import com.intellij.externalSystem.JavaProjectData;
+import com.intellij.openapi.externalSystem.model.DataNode;
+import com.intellij.openapi.externalSystem.model.ExternalSystemException;
+import com.intellij.openapi.externalSystem.model.project.ModuleData;
+import com.intellij.openapi.externalSystem.model.project.ProjectData;
+import com.intellij.openapi.externalSystem.model.task.TaskData;
+import com.intellij.openapi.externalSystem.util.ExternalSystemConstants;
+import com.intellij.openapi.externalSystem.util.Order;
+import com.intellij.openapi.util.KeyValue;
+import org.gradle.tooling.model.idea.IdeaModule;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.net.URL;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * {@link org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension} provides dummy implementation of Gradle project resolver.
+ *
+ * @author Vladislav.Soroka
+ * @since 10/14/13
+ */
+@Order(ExternalSystemConstants.UNORDERED)
+public abstract class AbstractProjectResolverExtension implements GradleProjectResolverExtension {
+
+ @NotNull protected ProjectResolverContext resolverCtx;
+ @NotNull protected GradleProjectResolverExtension nextResolver;
+
+ @Override
+ public void setProjectResolverContext(@NotNull ProjectResolverContext projectResolverContext) {
+ resolverCtx = projectResolverContext;
+ }
+
+ @Override
+ public void setNext(@Nullable GradleProjectResolverExtension next) {
+ // there always should be at least gradle basic resolver further in the chain
+ //noinspection ConstantConditions
+ assert next != null;
+ nextResolver = next;
+ }
+
+ @Nullable
+ @Override
+ public GradleProjectResolverExtension getNext() {
+ return nextResolver;
+ }
+
+ @NotNull
+ @Override
+ public ProjectData createProject() {
+ return nextResolver.createProject();
+ }
+
+ @NotNull
+ @Override
+ public JavaProjectData createJavaProjectData() {
+ return nextResolver.createJavaProjectData();
+ }
+
+ @NotNull
+ @Override
+ public ModuleData createModule(@NotNull IdeaModule gradleModule, @NotNull ProjectData projectData) {
+ return nextResolver.createModule(gradleModule, projectData);
+ }
+
+ @Override
+ public void populateModuleExtraModels(@NotNull IdeaModule gradleModule, @NotNull DataNode<ModuleData> ideModule) {
+ nextResolver.populateModuleExtraModels(gradleModule, ideModule);
+ }
+
+ @Override
+ public void populateModuleContentRoots(@NotNull IdeaModule gradleModule,
+ @NotNull DataNode<ModuleData> ideModule) {
+ nextResolver.populateModuleContentRoots(gradleModule, ideModule);
+ }
+
+
+ @Override
+ public void populateModuleCompileOutputSettings(@NotNull IdeaModule gradleModule,
+ @NotNull DataNode<ModuleData> ideModule) {
+ nextResolver.populateModuleCompileOutputSettings(gradleModule, ideModule);
+ }
+
+ @Override
+ public void populateModuleDependencies(@NotNull IdeaModule gradleModule,
+ @NotNull DataNode<ModuleData> ideModule,
+ @NotNull DataNode<ProjectData> ideProject) {
+ nextResolver.populateModuleDependencies(gradleModule, ideModule, ideProject);
+ }
+
+ @NotNull
+ @Override
+ public Collection<TaskData> populateModuleTasks(@NotNull IdeaModule gradleModule,
+ @NotNull DataNode<ModuleData> ideModule,
+ @NotNull DataNode<ProjectData> ideProject)
+ throws IllegalArgumentException, IllegalStateException {
+ return nextResolver.populateModuleTasks(gradleModule, ideModule, ideProject);
+ }
+
+ @NotNull
+ @Override
+ public Collection<TaskData> filterRootProjectTasks(@NotNull List<TaskData> allTasks) {
+ return nextResolver.filterRootProjectTasks(allTasks);
+ }
+
+ @NotNull
+ @Override
+ public Set<Class> getExtraProjectModelClasses() {
+ return Collections.emptySet();
+ }
+
+ @NotNull
+ @Override
+ public List<KeyValue<String, String>> getExtraJvmArgs() {
+ return Collections.emptyList();
+ }
+
+ @NotNull
+ @Override
+ public ExternalSystemException getUserFriendlyError(@NotNull Throwable error,
+ @NotNull String projectPath,
+ @Nullable String buildFilePath) {
+ return nextResolver.getUserFriendlyError(error, projectPath, buildFilePath);
+ }
+
+ @Override
+ public void enhanceRemoteProcessing(@NotNull SimpleJavaParameters parameters) throws ExecutionException {
+ }
+
+ @Override
+ public void enhanceLocalProcessing(@NotNull List<URL> urls) {
+ }
+}
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/BaseGradleProjectResolverExtension.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/BaseGradleProjectResolverExtension.java
index 9ede224..1738364 100644
--- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/BaseGradleProjectResolverExtension.java
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/BaseGradleProjectResolverExtension.java
@@ -127,11 +127,15 @@
return new ModuleData(GradleConstants.SYSTEM_ID,
StdModuleTypes.JAVA.getId(),
moduleName,
- projectData.getIdeProjectFileDirectoryPath(),
+ moduleConfigPath,
moduleConfigPath);
}
@Override
+ public void populateModuleExtraModels(@NotNull IdeaModule gradleModule, @NotNull DataNode<ModuleData> ideModule) {
+ }
+
+ @Override
public void populateModuleContentRoots(@NotNull IdeaModule gradleModule,
@NotNull DataNode<ModuleData> ideModule) {
DomainObjectSet<? extends IdeaContentRoot> contentRoots = gradleModule.getContentRoots();
@@ -139,13 +143,11 @@
return;
}
for (IdeaContentRoot gradleContentRoot : contentRoots) {
- if (gradleContentRoot == null) {
- continue;
- }
+ if (gradleContentRoot == null) continue;
+
File rootDirectory = gradleContentRoot.getRootDirectory();
- if (rootDirectory == null) {
- continue;
- }
+ if (rootDirectory == null) continue;
+
ContentRootData ideContentRoot = new ContentRootData(GradleConstants.SYSTEM_ID, rootDirectory.getAbsolutePath());
ideModule.getData().setModuleFileDirectoryPath(ideContentRoot.getRootPath());
populateContentRoot(ideContentRoot, ExternalSystemSourceType.SOURCE, gradleContentRoot.getSourceDirectories());
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleExecutionHelper.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleExecutionHelper.java
index 8c01c62..77d2e46 100644
--- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleExecutionHelper.java
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleExecutionHelper.java
@@ -16,6 +16,7 @@
package org.jetbrains.plugins.gradle.service.project;
import com.intellij.execution.configurations.CommandLineTokenizer;
+import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.externalSystem.model.ExternalSystemException;
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId;
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationEvent;
@@ -24,6 +25,7 @@
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.ArrayUtilRt;
import com.intellij.util.Function;
+import com.intellij.util.PathUtil;
import com.intellij.util.SystemProperties;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.ContainerUtilRt;
@@ -42,6 +44,7 @@
import java.io.File;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Field;
import java.util.List;
@@ -53,6 +56,7 @@
*/
public class GradleExecutionHelper {
+ private static final Logger LOG = Logger.getInstance(GradleExecutionHelper.class);
@SuppressWarnings("MethodMayBeStatic")
@NotNull
@@ -61,8 +65,7 @@
@Nullable GradleExecutionSettings settings,
@NotNull ProjectConnection connection,
@NotNull ExternalSystemTaskNotificationListener listener,
- @NotNull List<String> extraJvmArgs)
- {
+ @NotNull List<String> extraJvmArgs) {
ModelBuilder<T> result = connection.model(modelType);
prepare(result, id, settings, listener, extraJvmArgs, connection);
return result;
@@ -74,8 +77,7 @@
@NotNull ProjectConnection connection,
@Nullable GradleExecutionSettings settings,
@NotNull ExternalSystemTaskNotificationListener listener,
- @Nullable final String vmOptions)
- {
+ @Nullable final String vmOptions) {
BuildLauncher result = connection.newBuild();
List<String> extraJvmArgs = vmOptions == null ? ContainerUtil.<String>emptyList() : ContainerUtil.newArrayList(vmOptions.trim());
prepare(result, id, settings, listener, extraJvmArgs, connection);
@@ -90,8 +92,7 @@
@NotNull ExternalSystemTaskNotificationListener listener,
@Nullable final String vmOptions,
@NotNull final OutputStream standardOutput,
- @NotNull final OutputStream standardError)
- {
+ @NotNull final OutputStream standardError) {
BuildLauncher result = connection.newBuild();
List<String> extraJvmArgs = vmOptions == null ? ContainerUtil.<String>emptyList() : ContainerUtil.newArrayList(vmOptions.trim());
prepare(result, id, settings, listener, extraJvmArgs, connection, standardOutput, standardError);
@@ -118,8 +119,7 @@
@NotNull List<String> extraJvmArgs,
@NotNull ProjectConnection connection,
@NotNull final OutputStream standardOutput,
- @NotNull final OutputStream standardError)
- {
+ @NotNull final OutputStream standardError) {
if (settings == null) {
return;
}
@@ -129,7 +129,7 @@
String vmOptions = settings.getDaemonVmOptions();
if (!StringUtil.isEmpty(vmOptions)) {
CommandLineTokenizer tokenizer = new CommandLineTokenizer(vmOptions);
- while(tokenizer.hasMoreTokens()) {
+ while (tokenizer.hasMoreTokens()) {
String vmOption = tokenizer.nextToken();
if (!StringUtil.isEmpty(vmOption)) {
jvmArgs.add(vmOption);
@@ -140,8 +140,9 @@
jvmArgs.addAll(extraJvmArgs);
if (!jvmArgs.isEmpty()) {
- List<String> args = connection.getModel(BuildEnvironment.class).getJava().getJvmArguments();
- List<String> merged = mergeJvmArgs(args, jvmArgs);
+ BuildEnvironment buildEnvironment = getBuildEnvironment(connection);
+ List<String> merged =
+ buildEnvironment != null ? mergeJvmArgs(buildEnvironment.getJava().getJvmArguments(), jvmArgs) : jvmArgs;
operation.setJvmArguments(ArrayUtilRt.toStringArray(merged));
}
@@ -167,14 +168,15 @@
if (projectPathFile.isFile() && projectPath.endsWith(GradleConstants.EXTENSION)
&& projectPathFile.getParent() != null) {
projectDir = projectPathFile.getParent();
- } else {
+ }
+ else {
projectDir = projectPath;
}
// This is a workaround to get right base dir in case of 'PROJECT' setting used in case custom wrapper property file location
// see org.gradle.wrapper.PathAssembler#getBaseDir for details
String userDir = null;
- if(settings != null && settings.getDistributionType() == DistributionType.WRAPPED) {
+ if (settings != null && settings.getDistributionType() == DistributionType.WRAPPED) {
try {
userDir = System.getProperty("user.dir");
System.setProperty("user.dir", projectDir);
@@ -227,7 +229,9 @@
"gradle.taskGraph.afterTask { Task task ->",
" if (task instanceof Wrapper) {",
" def wrapperPropertyFileLocation = task.jarFile.getCanonicalPath() - '.jar' + '.properties'",
- " new File('" + StringUtil.escapeBackSlashes(wrapperPropertyFileLocation.getCanonicalPath()) + "').write wrapperPropertyFileLocation",
+ " new File('" +
+ StringUtil.escapeBackSlashes(wrapperPropertyFileLocation.getCanonicalPath()) +
+ "').write wrapperPropertyFileLocation",
"}}",
};
FileUtil.writeToFile(tempFile, StringUtil.join(lines, SystemProperties.getLineSeparator()));
@@ -263,21 +267,20 @@
/**
* Allows to retrieve gradle api connection to use for the given project.
*
- * @param projectPath target project path
- * @param settings execution settings to use
+ * @param projectPath target project path
+ * @param settings execution settings to use
* @return connection to use
* @throws IllegalStateException if it's not possible to create the connection
*/
@NotNull
private static ProjectConnection getConnection(@NotNull String projectPath,
@Nullable GradleExecutionSettings settings)
- throws IllegalStateException
- {
+ throws IllegalStateException {
File projectDir = new File(projectPath);
GradleConnector connector = GradleConnector.newConnector();
int ttl = -1;
- if(settings != null) {
+ if (settings != null) {
//noinspection EnumSwitchStatementWhichMissesCases
switch (settings.getDistributionType()) {
case LOCAL:
@@ -357,4 +360,35 @@
field.set(obj, fieldValue);
field.setAccessible(isAccessible);
}
+
+ @SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
+ public static void setInitScript(LongRunningOperation longRunningOperation) {
+ try {
+ InputStream stream = GradleProjectResolver.class.getResourceAsStream("/org/jetbrains/plugins/gradle/model/internal/init.gradle");
+ if (stream == null) return;
+
+ String jarPath = PathUtil.getCanonicalPath(PathUtil.getJarPathForClass(GradleProjectResolver.class));
+ String s = FileUtil.loadTextAndClose(stream).replace("${JAR_PATH}", jarPath);
+
+ final File tempFile = FileUtil.createTempFile("ijinit", '.' + GradleConstants.EXTENSION, true);
+ FileUtil.writeToFile(tempFile, s);
+
+ String[] buildExecutorArgs = new String[]{"--init-script", tempFile.getAbsolutePath()};
+ longRunningOperation.withArguments(buildExecutorArgs);
+ }
+ catch (Exception e) {
+ LOG.warn("Can't use IJ gradle init script", e);
+ }
+ }
+
+ @Nullable
+ private static BuildEnvironment getBuildEnvironment(@NotNull ProjectConnection connection) {
+ try {
+ return connection.getModel(BuildEnvironment.class);
+ }
+ catch (Exception e) {
+ LOG.warn("can not get BuildEnvironment model", e);
+ return null;
+ }
+ }
}
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleProjectResolver.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleProjectResolver.java
index 34f044c..4da7f14 100644
--- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleProjectResolver.java
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleProjectResolver.java
@@ -49,6 +49,7 @@
import org.jetbrains.plugins.gradle.settings.ClassHolder;
import org.jetbrains.plugins.gradle.settings.GradleExecutionSettings;
import org.jetbrains.plugins.gradle.util.GradleConstants;
+import org.jetbrains.plugins.gradle.util.GradleEnvironment;
import java.util.*;
@@ -152,6 +153,11 @@
resolverCtx.getSettings(), resolverCtx.getListener(),
parametersList.getParameters(), resolverCtx.getConnection());
+ // TODO [vlad] remove the check
+ if (GradleEnvironment.USE_ENHANCED_TOOLING_API) {
+ GradleExecutionHelper.setInitScript(buildActionExecutor);
+ }
+
ProjectImportAction.AllModels allModels;
try {
allModels = buildActionExecutor.run();
@@ -220,6 +226,7 @@
for (final Pair<DataNode<ModuleData>, IdeaModule> pair : moduleMap.values()) {
final DataNode<ModuleData> moduleDataNode = pair.first;
final IdeaModule ideaModule = pair.second;
+ projectResolverChain.populateModuleExtraModels(ideaModule, moduleDataNode);
projectResolverChain.populateModuleContentRoots(ideaModule, moduleDataNode);
projectResolverChain.populateModuleCompileOutputSettings(ideaModule, moduleDataNode);
projectResolverChain.populateModuleDependencies(ideaModule, moduleDataNode, projectDataNode);
@@ -251,7 +258,8 @@
private static BuildEnvironment getBuildEnvironment(@NotNull ProjectResolverContext resolverCtx) {
try {
return resolverCtx.getConnection().getModel(BuildEnvironment.class);
- } catch (Exception e) {
+ }
+ catch (Exception e) {
return null;
}
}
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleProjectResolverExtension.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleProjectResolverExtension.java
index 377a128..b663dbc 100644
--- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleProjectResolverExtension.java
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleProjectResolverExtension.java
@@ -67,6 +67,13 @@
ModuleData createModule(@NotNull IdeaModule gradleModule, @NotNull ProjectData projectData);
/**
+ * Populates extra models of the given ide module on the basis of the information provided by {@link org.jetbrains.plugins.gradle.model.ModelBuilderService}
+ *
+ * @param ideModule corresponding module from intellij gradle plugin domain
+ */
+ void populateModuleExtraModels(@NotNull IdeaModule gradleModule, @NotNull DataNode<ModuleData> ideModule);
+
+ /**
* Populates {@link com.intellij.openapi.externalSystem.model.ProjectKeys#CONTENT_ROOT) content roots} of the given ide module on the basis of the information
* contained at the given gradle module.
*
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleCommonClassNames.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleCommonClassNames.java
index 1279557..ef446f1 100644
--- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleCommonClassNames.java
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleCommonClassNames.java
@@ -40,6 +40,7 @@
@NonNls public static final String GRADLE_API_DEFAULT_TASK = "org.gradle.api.DefaultTask";
@NonNls public static final String GRADLE_API_TASKS_DELETE = "org.gradle.api.tasks.Delete";
@NonNls public static final String GRADLE_API_TASKS_BUNDLING_JAR = "org.gradle.api.tasks.bundling.Jar";
+ @NonNls public static final String GRADLE_API_TASKS_BUNDLING_WAR = "org.gradle.api.tasks.bundling.War";
@NonNls public static final String GRADLE_API_TASKS_COMPILE_JAVA_COMPILE = "org.gradle.api.tasks.compile.JavaCompile";
@NonNls public static final String GRADLE_API_TASKS_WRAPPER_WRAPPER = "org.gradle.api.tasks.wrapper.Wrapper";
@NonNls public static final String GRADLE_API_TASKS_JAVADOC_JAVADOC = "org.gradle.api.tasks.javadoc.Javadoc";
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleImplicitContributor.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleImplicitContributor.java
index c64b19e..84ab010 100644
--- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleImplicitContributor.java
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleImplicitContributor.java
@@ -56,6 +56,7 @@
new Pair<String, String>("buildNeeded", GRADLE_API_DEFAULT_TASK),
new Pair<String, String>("clean", GRADLE_API_TASKS_DELETE),
new Pair<String, String>("jar", GRADLE_API_TASKS_BUNDLING_JAR),
+ new Pair<String, String>("war", GRADLE_API_TASKS_BUNDLING_WAR),
new Pair<String, String>("classes", GRADLE_API_DEFAULT_TASK),
new Pair<String, String>("compileJava", GRADLE_API_TASKS_COMPILE_JAVA_COMPILE),
new Pair<String, String>("compileTestJava", GRADLE_API_DEFAULT_TASK),
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleEnvironment.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleEnvironment.java
index e511485..0a91825 100644
--- a/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleEnvironment.java
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/util/GradleEnvironment.java
@@ -10,6 +10,7 @@
public class GradleEnvironment {
@NonNls public static final boolean DEBUG_GRADLE_HOME_PROCESSING = Boolean.getBoolean("gradle.debug.home.processing");
+ @NonNls public static final boolean USE_ENHANCED_TOOLING_API = Boolean.getBoolean("gradle.use.enhanced.tooling.api");
private GradleEnvironment() {
}
diff --git a/plugins/groovy/src/META-INF/plugin.xml b/plugins/groovy/src/META-INF/plugin.xml
index d835e45..d9f86bf 100644
--- a/plugins/groovy/src/META-INF/plugin.xml
+++ b/plugins/groovy/src/META-INF/plugin.xml
@@ -413,7 +413,8 @@
<langCodeStyleSettingsProvider implementation="org.jetbrains.plugins.groovy.codeStyle.GroovyLanguageCodeStyleSettingsProvider"/>
<codeStyleSettingsProvider implementation="org.jetbrains.plugins.groovy.codeStyle.GroovyCodeStyleSettingsProvider"/>
- <typeHierarchyProvider language="Groovy" implementationClass="org.jetbrains.plugins.groovy.lang.GroovyTypeHierarchyProvider"/>
+ <typeHierarchyProvider language="Groovy" implementationClass="org.jetbrains.plugins.groovy.hierarchy.type.GroovyTypeHierarchyProvider"/>
+ <callHierarchyProvider language="Groovy" implementationClass="org.jetbrains.plugins.groovy.hierarchy.call.GrCallHierarchyProvider"/>
<lang.unwrapDescriptor language="Groovy" implementationClass="org.jetbrains.plugins.groovy.unwrap.GroovyUnwrapDescriptor"/>
@@ -985,14 +986,6 @@
displayName="Method parameter naming convention"
groupName="Naming Conventions" enabledByDefault="false" level="WARNING"
implementationClass="org.jetbrains.plugins.groovy.codeInspection.naming.GroovyParameterNamingConventionInspection"/>
- <localInspection language="Groovy" groupPath="Groovy" shortName="GroovyGetterCallCanBePropertyAccess"
- displayName="Getter call can be property access"
- groupName="GPath inspections" enabledByDefault="false" level="WARNING"
- implementationClass="org.jetbrains.plugins.groovy.codeInspection.gpath.GroovyGetterCallCanBePropertyAccessInspection"/>
- <localInspection language="Groovy" groupPath="Groovy" shortName="GroovySetterCallCanBePropertyAccess"
- displayName="Setter call can be property access"
- groupName="GPath inspections" enabledByDefault="false" level="WARNING"
- implementationClass="org.jetbrains.plugins.groovy.codeInspection.gpath.GroovySetterCallCanBePropertyAccessInspection"/>
<localInspection language="Groovy" groupPath="Groovy" shortName="GroovyMapGetCanBeKeyedAccess"
displayName="Call to Map.get can be keyed access"
groupName="GPath inspections" enabledByDefault="false" level="WARNING"
@@ -1458,6 +1451,7 @@
<refactoring.pullUpHelperFactory language="Groovy"
implementationClass="org.jetbrains.plugins.groovy.refactoring.memberPullUp.GrPullUpHelperFactory"/>
<classTypePointerFactory implementation="org.jetbrains.plugins.groovy.lang.psi.impl.smartPointers.GrClassReferenceTypePointerFactory"/>
+ <hierarchy.referenceProcessor implementation="org.jetbrains.plugins.groovy.hierarchy.call.GrCallReferenceProcessor"/>
</extensions>
<extensions defaultExtensionNs="com.intellij.debugger">
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/gpath/GroovyGetterCallCanBePropertyAccessInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/gpath/GroovyGetterCallCanBePropertyAccessInspection.java
deleted file mode 100644
index 2345790..0000000
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/gpath/GroovyGetterCallCanBePropertyAccessInspection.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright 2007-2008 Dave Griffith
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jetbrains.plugins.groovy.codeInspection.gpath;
-
-import com.intellij.codeInspection.ProblemDescriptor;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.psi.PsiElement;
-import com.intellij.util.IncorrectOperationException;
-import org.jetbrains.annotations.Nls;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.jetbrains.plugins.groovy.codeInspection.BaseInspection;
-import org.jetbrains.plugins.groovy.codeInspection.BaseInspectionVisitor;
-import org.jetbrains.plugins.groovy.codeInspection.GroovyFix;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrMethodCallExpression;
-import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
-import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
-
-public class GroovyGetterCallCanBePropertyAccessInspection extends BaseInspection {
-
- @Nls
- @NotNull
- public String getGroupDisplayName() {
- return GPATH;
- }
-
- @Nls
- @NotNull
- public String getDisplayName() {
- return "Getter call can be property access";
- }
-
- @Nullable
- protected String buildErrorString(Object... args) {
- return "Call to '#ref' can be property access #loc";
- }
-
- public BaseInspectionVisitor buildVisitor() {
- return new Visitor();
- }
-
- public GroovyFix buildFix(PsiElement location) {
- return new ReplaceWithPropertyAccessFix();
- }
-
- private static class ReplaceWithPropertyAccessFix extends GroovyFix {
-
- @NotNull
- public String getName() {
- return "Replace with property access";
- }
-
- public void doFix(Project project, ProblemDescriptor descriptor)
- throws IncorrectOperationException {
- final PsiElement referenceName = descriptor.getPsiElement();
- final String getterName = referenceName.getText();
- final String propertyName = Character.toLowerCase(getterName.charAt(3)) + getterName.substring(4);
- final GrReferenceExpression invokedExpression = (GrReferenceExpression) referenceName.getParent();
- final GrMethodCallExpression callExpression = (GrMethodCallExpression) invokedExpression.getParent();
- replaceExpression(callExpression, invokedExpression.getQualifierExpression().getText() + '.' + propertyName);
- }
- }
-
- private static class Visitor extends BaseInspectionVisitor {
- @NonNls private static final String GET_PREFIX = "get";
-
- public void visitMethodCallExpression(GrMethodCallExpression grMethodCallExpression) {
- super.visitMethodCallExpression(grMethodCallExpression);
- final GrArgumentList args = grMethodCallExpression.getArgumentList();
- if (args == null) {
- return;
- }
- if (PsiImplUtil.hasExpressionArguments(args)) {
- return;
- }
- if (PsiImplUtil.hasNamedArguments(args)) {
- return;
- }
- final GrExpression methodExpression = grMethodCallExpression.getInvokedExpression();
- if (!(methodExpression instanceof GrReferenceExpression)) {
- return;
- }
- final GrReferenceExpression referenceExpression = (GrReferenceExpression)methodExpression;
- final String name = referenceExpression.getReferenceName();
- if (name == null || !name.startsWith(GET_PREFIX)) {
- return;
- }
- if (name.equals(GET_PREFIX)) {
- return;
- }
- String tail = StringUtil.trimStart(name, GET_PREFIX);
- // If doesn't conform to getter's convention
- if (!tail.equals(StringUtil.capitalize(tail))) {
- return;
- }
- final GrExpression qualifier = referenceExpression.getQualifierExpression();
- if (qualifier == null) return;
- if (PsiUtil.isThisOrSuperRef(qualifier)) return;
- registerMethodCallError(grMethodCallExpression);
- }
- }
-}
\ No newline at end of file
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/gpath/GroovySetterCallCanBePropertyAccessInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/gpath/GroovySetterCallCanBePropertyAccessInspection.java
deleted file mode 100644
index c8ffcde..0000000
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/gpath/GroovySetterCallCanBePropertyAccessInspection.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright 2007-2008 Dave Griffith
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jetbrains.plugins.groovy.codeInspection.gpath;
-
-import com.intellij.codeInspection.ProblemDescriptor;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.psi.PsiElement;
-import com.intellij.util.IncorrectOperationException;
-import org.jetbrains.annotations.Nls;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.jetbrains.plugins.groovy.codeInspection.BaseInspection;
-import org.jetbrains.plugins.groovy.codeInspection.BaseInspectionVisitor;
-import org.jetbrains.plugins.groovy.codeInspection.GroovyFix;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrMethodCallExpression;
-import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
-import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
-
-public class GroovySetterCallCanBePropertyAccessInspection extends BaseInspection {
- private final ReplaceWithPropertyAccessFix fix = new ReplaceWithPropertyAccessFix();
-
- @Nls
- @NotNull
- public String getGroupDisplayName() {
- return GPATH;
- }
-
- @Nls
- @NotNull
- public String getDisplayName() {
- return "Setter call can be property access";
- }
-
- @Nullable
- protected String buildErrorString(Object... args) {
- return "Call to '#ref' can be property access #loc";
- }
-
- public BaseInspectionVisitor buildVisitor() {
- return new Visitor();
- }
-
- public GroovyFix buildFix(PsiElement location) {
- return fix;
- }
-
- private static class
- ReplaceWithPropertyAccessFix extends GroovyFix {
- @NotNull
- public String getName() {
- return "Replace with property access";
- }
-
- public void doFix(Project project, ProblemDescriptor descriptor)
- throws IncorrectOperationException {
- final PsiElement referenceName = descriptor.getPsiElement();
- final String setter = referenceName.getText();
- final String propertyName = Character.toLowerCase(setter.charAt(3)) + setter.substring(4);
- final GrReferenceExpression invokedExpression = (GrReferenceExpression) referenceName.getParent();
- final GrMethodCallExpression callExpression = (GrMethodCallExpression) invokedExpression.getParent();
- final GrArgumentList args = callExpression.getArgumentList();
- assert args != null;
- final GrExpression arg = args.getExpressionArguments()[0];
- replaceExpression(callExpression, invokedExpression.getQualifierExpression().getText() + '.' + propertyName + " = " + arg.getText());
- }
- }
-
- private static class Visitor extends BaseInspectionVisitor {
- @NonNls private static final String SET_PREFIX = "set";
-
- public void visitMethodCallExpression(GrMethodCallExpression grMethodCallExpression) {
- super.visitMethodCallExpression(grMethodCallExpression);
- final GrArgumentList args = grMethodCallExpression.getArgumentList();
- if (args == null) {
- return;
- }
- if (args.getExpressionArguments().length != 1) {
- return;
- }
- if (PsiImplUtil.hasNamedArguments(args)) {
- return;
- }
- final GrExpression methodExpression = grMethodCallExpression.getInvokedExpression();
- if (!(methodExpression instanceof GrReferenceExpression)) {
- return;
- }
- final GrReferenceExpression referenceExpression = (GrReferenceExpression) methodExpression;
- final String name = referenceExpression.getReferenceName();
- if (name == null || !name.startsWith(SET_PREFIX)) {
- return;
- }
- if (SET_PREFIX.equals(name)) {
- return;
- }
- String tail = StringUtil.trimStart(name, SET_PREFIX);
- // If doesn't conform to getter's convention
- if (!tail.equals(StringUtil.capitalize(tail))) {
- return;
- }
- final GrExpression qualifier = referenceExpression.getQualifierExpression();
- if (qualifier == null || PsiUtil.isThisOrSuperRef(qualifier)) {
- return;
- }
- registerMethodCallError(grMethodCallExpression);
- }
- }
-}
\ No newline at end of file
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/style/JavaStylePropertiesInvocationInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/style/JavaStylePropertiesInvocationInspection.java
index f0152ec..48c98b1 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/style/JavaStylePropertiesInvocationInspection.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/style/JavaStylePropertiesInvocationInspection.java
@@ -1,8 +1,24 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.jetbrains.plugins.groovy.codeInspection.style;
import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.ProblemHighlightType;
import com.intellij.psi.PsiElement;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.codeInspection.BaseInspection;
import org.jetbrains.plugins.groovy.codeInspection.BaseInspectionVisitor;
import org.jetbrains.plugins.groovy.codeInspection.GroovyInspectionBundle;
@@ -14,6 +30,7 @@
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrMethodCallExpression;
public class JavaStylePropertiesInvocationInspection extends BaseInspection {
+ @NotNull
@Override
protected BaseInspectionVisitor buildVisitor() {
return new BaseInspectionVisitor() {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/utils/JavaStylePropertiesUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/utils/JavaStylePropertiesUtil.java
index 8715a5c..0e54ffd 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/utils/JavaStylePropertiesUtil.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/utils/JavaStylePropertiesUtil.java
@@ -20,6 +20,7 @@
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiManager;
import com.intellij.psi.PsiMethod;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
@@ -132,7 +133,7 @@
return false;
}
- private static boolean isGetterInvocation(GrMethodCall call) {
+ private static boolean isGetterInvocation(@NotNull GrMethodCall call) {
GrExpression expr = call.getInvokedExpression();
if (!(expr instanceof GrReferenceExpression)) return false;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyAwareModuleBuilder.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyAwareModuleBuilder.java
index 8cece08..978d7c7 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyAwareModuleBuilder.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyAwareModuleBuilder.java
@@ -18,8 +18,6 @@
import com.intellij.ide.util.projectWizard.JavaModuleBuilder;
import com.intellij.ide.util.projectWizard.ModuleWizardStep;
import com.intellij.ide.util.projectWizard.SettingsStep;
-import com.intellij.ide.util.projectWizard.WizardContext;
-import com.intellij.openapi.roots.ui.configuration.ModulesProvider;
import icons.JetgroovyIcons;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -49,11 +47,6 @@
myBigIcon = bigIcon;
}
- @Override
- public ModuleWizardStep[] createWizardSteps(@NotNull WizardContext wizardContext, @NotNull ModulesProvider modulesProvider) {
- return new ModuleWizardStep[]{new GroovySdkForNewModuleWizardStep(this, wizardContext, getFramework(), null)};
- }
-
@Nullable
@Override
public ModuleWizardStep modifySettingsStep(@NotNull SettingsStep settingsStep) {
@@ -90,6 +83,7 @@
return "Groovy";
}
+ @Nullable
protected MvcFramework getFramework() {
return null;
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryDescription.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryDescription.java
index f375045..76205a8 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryDescription.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyLibraryDescription.java
@@ -126,7 +126,7 @@
final String sdkVersion = provider.getSDKVersion(path);
if (AbstractConfigUtils.UNDEFINED_VERSION.equals(sdkVersion)) {
Messages.showErrorDialog(parentComponent,
- "Looks like " + myFrameworkName + " distribution in specified path is broken. Cannot determinate version.",
+ "Looks like " + myFrameworkName + " distribution in specified path is broken. Cannot determine version.",
"Failed to Create Library");
return null;
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/GroovyTypeHierarchyProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/hierarchy/call/GrCallHierarchyProvider.java
similarity index 68%
copy from plugins/groovy/src/org/jetbrains/plugins/groovy/lang/GroovyTypeHierarchyProvider.java
copy to plugins/groovy/src/org/jetbrains/plugins/groovy/hierarchy/call/GrCallHierarchyProvider.java
index bed999e..f4caaee 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/GroovyTypeHierarchyProvider.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/hierarchy/call/GrCallHierarchyProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,12 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.jetbrains.plugins.groovy.lang;
+package org.jetbrains.plugins.groovy.hierarchy.call;
-import com.intellij.ide.hierarchy.type.JavaTypeHierarchyProvider;
+import com.intellij.ide.hierarchy.call.JavaCallHierarchyProvider;
/**
- * @author peter
+ * Created by Max Medvedev on 10/5/13
*/
-public class GroovyTypeHierarchyProvider extends JavaTypeHierarchyProvider{
+public class GrCallHierarchyProvider extends JavaCallHierarchyProvider {
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/hierarchy/call/GrCallReferenceProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/hierarchy/call/GrCallReferenceProcessor.java
new file mode 100644
index 0000000..2b60ae7
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/hierarchy/call/GrCallReferenceProcessor.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.hierarchy.call;
+
+import com.intellij.ide.hierarchy.call.CallHierarchyNodeDescriptor;
+import com.intellij.ide.hierarchy.call.CallReferenceProcessor;
+import com.intellij.ide.hierarchy.call.JavaCallHierarchyData;
+import com.intellij.ide.util.treeView.NodeDescriptor;
+import com.intellij.openapi.project.Project;
+import com.intellij.psi.*;
+import com.intellij.psi.util.PsiUtil;
+import com.intellij.psi.util.TypeConversionUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrAnonymousClassDefinition;
+
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Created by Max Medvedev on 10/5/13
+ */
+public class GrCallReferenceProcessor implements CallReferenceProcessor {
+ @Override
+ public boolean process(@NotNull PsiReference reference, @NotNull JavaCallHierarchyData data) {
+ PsiClass originalClass = data.getOriginalClass();
+ PsiMethod method = data.getMethod();
+ Set<PsiMethod> methodsToFind = data.getMethodsToFind();
+ PsiMethod methodToFind = data.getMethodToFind();
+ PsiClassType originalType = data.getOriginalType();
+ Map<PsiMember, NodeDescriptor> methodToDescriptorMap = data.getResultMap();
+ Project project = data.getProject();
+
+ if (reference instanceof GrReferenceExpression) {
+ final GrExpression qualifier = ((GrReferenceExpression)reference).getQualifierExpression();
+ if (org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil.isSuperReference(qualifier)) { // filter super.foo() call inside foo() and similar cases (bug 8411)
+ assert qualifier != null;
+ final PsiClass superClass = PsiUtil.resolveClassInType(qualifier.getType());
+ if (originalClass == null || originalClass.isInheritor(superClass, true)) {
+ return true;
+ }
+ }
+ if (qualifier != null && !methodToFind.hasModifierProperty(PsiModifier.STATIC)) {
+ final PsiType qualifierType = qualifier.getType();
+ if (qualifierType instanceof PsiClassType && !TypeConversionUtil.isAssignable(qualifierType, originalType) && methodToFind != method) {
+ final PsiClass psiClass = ((PsiClassType)qualifierType).resolve();
+ if (psiClass != null) {
+ final PsiMethod callee = psiClass.findMethodBySignature(methodToFind, true);
+ if (callee != null && !methodsToFind.contains(callee)) {
+ // skip sibling methods
+ return true;
+ }
+ }
+ }
+ }
+ }
+ else {
+ if (!(reference instanceof PsiElement)) {
+ return true;
+ }
+
+ final PsiElement parent = ((PsiElement)reference).getParent();
+ if (parent instanceof PsiNewExpression) {
+ if (((PsiNewExpression)parent).getClassReference() != reference) {
+ return true;
+ }
+ }
+ else if (parent instanceof GrAnonymousClassDefinition) {
+ if (((GrAnonymousClassDefinition)parent).getBaseClassReferenceGroovy() != reference) {
+ return true;
+ }
+ }
+ else {
+ return true;
+ }
+ }
+
+ final PsiElement element = reference.getElement();
+ final PsiMember key = CallHierarchyNodeDescriptor.getEnclosingElement(element);
+
+ synchronized (methodToDescriptorMap) {
+ CallHierarchyNodeDescriptor d = (CallHierarchyNodeDescriptor)methodToDescriptorMap.get(key);
+ if (d == null) {
+ d = new CallHierarchyNodeDescriptor(project, (CallHierarchyNodeDescriptor)data.getNodeDescriptor(), element, false, true);
+ methodToDescriptorMap.put(key, d);
+ }
+ else if (!d.hasReference(reference)) {
+ d.incrementUsageCount();
+ }
+ d.addReference(reference);
+ }
+ return true;
+ }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/GroovyTypeHierarchyProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/hierarchy/type/GroovyTypeHierarchyProvider.java
similarity index 88%
rename from plugins/groovy/src/org/jetbrains/plugins/groovy/lang/GroovyTypeHierarchyProvider.java
rename to plugins/groovy/src/org/jetbrains/plugins/groovy/hierarchy/type/GroovyTypeHierarchyProvider.java
index bed999e..da42de7 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/GroovyTypeHierarchyProvider.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/hierarchy/type/GroovyTypeHierarchyProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.jetbrains.plugins.groovy.lang;
+package org.jetbrains.plugins.groovy.hierarchy.type;
import com.intellij.ide.hierarchy.type.JavaTypeHierarchyProvider;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/GroovySdkForNewModuleWizardStep.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/GroovySdkForNewModuleWizardStep.java
index 3551692..6ed51ed 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/GroovySdkForNewModuleWizardStep.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/GroovySdkForNewModuleWizardStep.java
@@ -33,13 +33,13 @@
public GroovySdkForNewModuleWizardStep(ModuleBuilder moduleBuilder,
WizardContext wizardContext,
- final MvcFramework framework,
+ @Nullable MvcFramework framework,
SettingsStep settingsStep) {
super(framework, wizardContext, moduleBuilder.getContentEntryPath());
moduleBuilder.addModuleConfigurationUpdater(createModuleConfigurationUpdater());
if (settingsStep != null) {
myJavaStep = JavaModuleType.getModuleType().modifySettingsStep(settingsStep, moduleBuilder);
- settingsStep.addSettingsField("\u001BGroovy library:", getPanel().getSimplePanel());
+ settingsStep.addSettingsField("\u001B" + (framework == null ? "Groovy" : framework.getDisplayName()) + " library:", getPanel().getSimplePanel());
}
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcModuleBuilder.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcModuleBuilder.java
index ea0dae6..399a99d 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcModuleBuilder.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcModuleBuilder.java
@@ -15,13 +15,6 @@
*/
package org.jetbrains.plugins.groovy.mvc;
-import com.intellij.ide.util.projectWizard.ModuleWizardStep;
-import com.intellij.ide.util.projectWizard.SdkSettingsStep;
-import com.intellij.ide.util.projectWizard.SettingsStep;
-import com.intellij.openapi.projectRoots.SdkTypeId;
-import com.intellij.openapi.util.Condition;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.config.GroovyAwareModuleBuilder;
import javax.swing.*;
@@ -42,15 +35,4 @@
protected MvcFramework getFramework() {
return myFramework;
}
-
- @Nullable
- @Override
- public ModuleWizardStep modifySettingsStep(@NotNull SettingsStep settingsStep) {
- return new SdkSettingsStep(settingsStep, this, new Condition<SdkTypeId>() {
- @Override
- public boolean value(SdkTypeId sdkType) {
- return isSuitableSdkType(sdkType);
- }
- });
- }
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcProjectWithoutLibraryNotificator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcProjectWithoutLibraryNotificator.java
index f5ba037..7445188 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcProjectWithoutLibraryNotificator.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcProjectWithoutLibraryNotificator.java
@@ -27,38 +27,43 @@
@Override
public void runActivity(@NotNull final Project project) {
- AccessToken accessToken = ApplicationManager.getApplication().acquireReadActionLock();
+ ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
+ @Override
+ public void run() {
+ AccessToken accessToken = ApplicationManager.getApplication().acquireReadActionLock();
- try {
- if (JavaPsiFacade.getInstance(project).findClass(CommonClassNames.JAVA_LANG_OBJECT, GlobalSearchScope.allScope(project)) == null) {
- return; // If indexes is corrupted JavaPsiFacade.findClass() can't find classes during StartupActivity (may be it's a bug).
- // So we can't determine whether exists Grails library or not.
+ try {
+ if (JavaPsiFacade.getInstance(project).findClass(CommonClassNames.JAVA_LANG_OBJECT, GlobalSearchScope.allScope(project)) == null) {
+ return; // If indexes is corrupted JavaPsiFacade.findClass() can't find classes during StartupActivity (may be it's a bug).
+ // So we can't determine whether exists Grails library or not.
+ }
+
+ Pair<Module, MvcFramework> pair = findModuleWithoutLibrary(project);
+
+ if (pair != null) {
+ final MvcFramework framework = pair.second;
+ final Module module = pair.first;
+
+ new Notification(framework.getFrameworkName() + ".Configure",
+ framework.getFrameworkName() + " SDK not found.",
+ "<html><body>Module '" +
+ module.getName() +
+ "' has no " +
+ framework.getFrameworkName() +
+ " SDK. <a href='create'>Configure SDK</a></body></html>", NotificationType.INFORMATION,
+ new NotificationListener.Adapter() {
+ @Override
+ protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) {
+ MvcConfigureNotification.configure(framework, module);
+ }
+ }).notify(project);
+ }
+ }
+ finally {
+ accessToken.finish();
+ }
}
-
- Pair<Module, MvcFramework> pair = findModuleWithoutLibrary(project);
-
- if (pair != null) {
- final MvcFramework framework = pair.second;
- final Module module = pair.first;
-
- new Notification(framework.getFrameworkName() + ".Configure",
- framework.getFrameworkName() + " SDK not found.",
- "<html><body>Module '" +
- module.getName() +
- "' has no " +
- framework.getFrameworkName() +
- " SDK. <a href='create'>Configure SDK</a></body></html>", NotificationType.INFORMATION,
- new NotificationListener.Adapter() {
- @Override
- protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) {
- MvcConfigureNotification.configure(framework, module);
- }
- }).notify(project);
- }
- }
- finally {
- accessToken.finish();
- }
+ });
}
@Nullable
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyScriptRunConfigurationType.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyScriptRunConfigurationType.java
index da97279..fef7af5 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyScriptRunConfigurationType.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyScriptRunConfigurationType.java
@@ -21,9 +21,12 @@
import com.intellij.execution.configurations.ConfigurationTypeUtil;
import com.intellij.execution.configurations.RunConfiguration;
import com.intellij.openapi.project.Project;
+import com.intellij.psi.search.FileTypeIndex;
+import com.intellij.psi.search.GlobalSearchScope;
import icons.JetgroovyIcons;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.plugins.groovy.GroovyFileType;
import javax.swing.*;
@@ -65,6 +68,11 @@
super(type);
}
+ @Override
+ public boolean isApplicable(@NotNull Project project) {
+ return FileTypeIndex.containsFileOfType(GroovyFileType.GROOVY_FILE_TYPE, GlobalSearchScope.allScope(project));
+ }
+
public RunConfiguration createTemplateConfiguration(Project project) {
return new GroovyScriptRunConfiguration("Groovy Script", project, this);
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/spock/SpockTestFramework.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/spock/SpockTestFramework.java
index ec53534..b7872dcc 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/spock/SpockTestFramework.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/spock/SpockTestFramework.java
@@ -24,6 +24,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.GroovyFileType;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiManager;
import org.jetbrains.plugins.groovy.testIntegration.GroovyTestFramework;
@@ -65,9 +66,9 @@
@Override
public boolean isTestMethod(PsiElement element) {
- if (!(element instanceof PsiMethod)) return false;
+ if (!(element instanceof GrMethod)) return false;
- return GroovyPsiManager.isInheritorCached(((PsiMethod)element).getContainingClass(), SpockUtils.SPEC_CLASS_NAME)
+ return GroovyPsiManager.isInheritorCached(((GrMethod)element).getContainingClass(), SpockUtils.SPEC_CLASS_NAME)
&& JUnitUtil.getTestMethod(element) != null;
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/util/SdkHomeSettings.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/util/SdkHomeSettings.java
index 2230270..e357762 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/util/SdkHomeSettings.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/util/SdkHomeSettings.java
@@ -36,19 +36,22 @@
*/
public abstract class SdkHomeSettings implements PersistentStateComponent<SdkHomeConfigurable.SdkHomeBean> {
private final PsiModificationTrackerImpl myTracker;
- private SdkHomeConfigurable.SdkHomeBean mySdkPath;
+ private SdkHomeConfigurable.SdkHomeBean mySdkHome;
protected SdkHomeSettings(Project project) {
myTracker = (PsiModificationTrackerImpl)PsiManager.getInstance(project).getModificationTracker();
}
public SdkHomeConfigurable.SdkHomeBean getState() {
- return mySdkPath;
+ return mySdkHome;
}
public void loadState(SdkHomeConfigurable.SdkHomeBean state) {
- mySdkPath = state;
- myTracker.incCounter();
+ SdkHomeConfigurable.SdkHomeBean oldState = mySdkHome;
+ mySdkHome = state;
+ if (oldState != null) {
+ myTracker.incCounter();
+ }
}
@Nullable
@@ -67,7 +70,7 @@
@Nullable
public VirtualFile getSdkHome() {
- return calcHome(mySdkPath);
+ return calcHome(mySdkHome);
}
public List<VirtualFile> getClassRoots() {
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/GrFindManagerTest.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/GrFindManagerTest.java
new file mode 100644
index 0000000..6112a21
--- /dev/null
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/GrFindManagerTest.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy;
+
+import com.intellij.codeInsight.daemon.DaemonAnalyzerTestCase;
+import com.intellij.find.FindManager;
+import com.intellij.find.FindManagerTestUtils;
+import com.intellij.find.FindModel;
+
+public class GrFindManagerTest extends DaemonAnalyzerTestCase {
+ private FindManager myFindManager;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ myFindManager = FindManager.getInstance(myProject);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ myFindManager = null;
+ super.tearDown();
+ }
+
+ public void testFindInJavaDocs() {
+ FindModel findModel = FindManagerTestUtils.configureFindModel("done");
+ String text = "/** done done done */";
+ FindManagerTestUtils.runFindForwardAndBackward(myFindManager, findModel, text, "groovy");
+ }
+
+ public void testFindInLiteralToSkipQuotes() {
+ FindModel findModel = FindManagerTestUtils.configureFindModel("^done$");
+ findModel.setRegularExpressions(true);
+ findModel.setInStringLiteralsOnly(true);
+ findModel.setInCommentsOnly(false);
+ String text = "def n = \"\"\"done\"\"\"\n def n = /done/\n def n = \"done\"\n def n = \"done2\"";
+ FindManagerTestUtils.runFindForwardAndBackward(myFindManager, findModel, text, "groovy");
+ }
+
+ public void testFindInShellCommentsOfGroovy() {
+ FindModel findModel = FindManagerTestUtils.configureFindModel("done");
+ findModel.setWholeWordsOnly(true);
+ findModel.setInCommentsOnly(true);
+ String text = "#! done done done\n";
+ FindManagerTestUtils.runFindForwardAndBackward(myFindManager, findModel, text, "groovy");
+ }
+}
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyFixesTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyFixesTest.groovy
index 4d61175..b5fa168 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyFixesTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyFixesTest.groovy
@@ -1,12 +1,23 @@
/*
- * Copyright (c) 2000-2005 by JetBrains s.r.o. All Rights Reserved.
- * Use is subject to license terms.
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.jetbrains.plugins.groovy.lang
import com.intellij.openapi.application.ApplicationManager
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
import org.jetbrains.plugins.groovy.codeInspection.control.GroovyConstantIfStatementInspection
-import org.jetbrains.plugins.groovy.codeInspection.gpath.GroovySetterCallCanBePropertyAccessInspection
+import org.jetbrains.plugins.groovy.codeInspection.style.JavaStylePropertiesInvocationInspection
import org.jetbrains.plugins.groovy.codeInspection.untypedUnresolvedAccess.GrUnresolvedAccessInspection
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile
/**
@@ -28,7 +39,7 @@
}
public void testShallowChangeToGroovyStylePropertyAccess() throws Throwable {
- myFixture.enableInspections new GroovySetterCallCanBePropertyAccessInspection()
+ myFixture.enableInspections new JavaStylePropertiesInvocationInspection()
myFixture.configureByText "a.groovy", """class GroovyClasss {
def initializer
def foo() {
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandExecutor.java b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandExecutor.java
index ca3020f..a076635 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandExecutor.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandExecutor.java
@@ -125,6 +125,10 @@
public HgCommandResult executeInCurrentThread(@Nullable final VirtualFile repo, @NotNull final String operation,
@Nullable final List<String> arguments, @Nullable HgPromptHandler handler) {
HgCommandResult result = executeInCurrentThread(repo, operation, arguments, handler, false);
+ if (HgErrorUtil.isUnknownEncodingError(result)) {
+ setCharset(Charset.forName("utf8"));
+ result = executeInCurrentThread(repo, operation, arguments, handler, false);
+ }
if (HgErrorUtil.isAuthorizationError(result)) {
if (HgErrorUtil.hasAuthorizationInDestinationPath(myDestination)) {
new HgCommandResultNotifier(myProject)
@@ -195,7 +199,7 @@
}
if (HgVcs.HGENCODING == null) {
cmdLine.add("--encoding");
- cmdLine.add(myCharset.name());
+ cmdLine.add(HgEncodingUtil.getNameFor(myCharset));
}
HgCommandResult result;
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/log/HgLogProvider.java b/plugins/hg4idea/src/org/zmlx/hg4idea/log/HgLogProvider.java
index e8f170b..61e08e1 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/log/HgLogProvider.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/log/HgLogProvider.java
@@ -24,12 +24,12 @@
import com.intellij.openapi.vcs.VcsKey;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.ArrayUtil;
+import com.intellij.util.Consumer;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.vcs.log.*;
import com.intellij.vcs.log.data.VcsLogBranchFilter;
import com.intellij.vcs.log.data.VcsLogUserFilter;
-import com.intellij.vcs.log.impl.VcsRefImpl;
import com.intellij.vcs.log.ui.filter.VcsLogTextFilter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -62,25 +62,21 @@
myProject = project;
myRepositoryManager = repositoryManager;
myRefSorter = new HgRefManager();
- myVcsObjectsFactory = ServiceManager.getService(VcsLogObjectsFactory.class);
+ myVcsObjectsFactory = ServiceManager.getService(project, VcsLogObjectsFactory.class);
}
@NotNull
@Override
public List<? extends VcsFullCommitDetails> readFirstBlock(@NotNull VirtualFile root,
boolean ordered, int commitCount) throws VcsException {
- String[] params = {"--encoding=UTF-8"};
- if (!ordered) {
- params = ArrayUtil.append(params, "-r");
- params = ArrayUtil.append(params, "0:tip");
- }
+ String[] params = ordered ? ArrayUtil.EMPTY_STRING_ARRAY : new String[]{"-r", "0:tip"};
return HgHistoryUtil.history(myProject, root, commitCount, params);
}
@NotNull
@Override
- public List<TimedVcsCommit> readAllHashes(@NotNull VirtualFile root) throws VcsException {
- return HgHistoryUtil.readAllHashes(myProject, root);
+ public List<TimedVcsCommit> readAllHashes(@NotNull VirtualFile root, @NotNull Consumer<VcsUser> userRegistry) throws VcsException {
+ return HgHistoryUtil.readAllHashes(myProject, root, userRegistry);
}
@NotNull
@@ -115,21 +111,21 @@
Collection<VcsRef> refs = new ArrayList<VcsRef>(branches.size() + bookmarks.size());
for (HgNameWithHashInfo branchInfo : branches) {
- refs.add(new VcsRefImpl(myVcsObjectsFactory.createHash(branchInfo.getHash()), branchInfo.getName(), HgRefManager.BRANCH, root));
+ refs.add(myVcsObjectsFactory.createRef(myVcsObjectsFactory.createHash(branchInfo.getHash()), branchInfo.getName(), HgRefManager.BRANCH, root));
}
for (HgNameWithHashInfo bookmarkInfo : bookmarks) {
- refs.add(new VcsRefImpl(myVcsObjectsFactory.createHash(bookmarkInfo.getHash()), bookmarkInfo.getName(),
+ refs.add(myVcsObjectsFactory.createRef(myVcsObjectsFactory.createHash(bookmarkInfo.getHash()), bookmarkInfo.getName(),
HgRefManager.BOOKMARK, root));
}
String currentRevision = repository.getCurrentRevision();
if (currentRevision != null) { // null => fresh repository
- refs.add(new VcsRefImpl(myVcsObjectsFactory.createHash(currentRevision), "HEAD", HgRefManager.HEAD, root));
+ refs.add(myVcsObjectsFactory.createRef(myVcsObjectsFactory.createHash(currentRevision), "HEAD", HgRefManager.HEAD, root));
}
for (HgNameWithHashInfo tagInfo : tags) {
- refs.add(new VcsRefImpl(myVcsObjectsFactory.createHash(tagInfo.getHash()), tagInfo.getName(), HgRefManager.TAG, root));
+ refs.add(myVcsObjectsFactory.createRef(myVcsObjectsFactory.createHash(tagInfo.getHash()), tagInfo.getName(), HgRefManager.TAG, root));
}
for (HgNameWithHashInfo localTagInfo : localTags) {
- refs.add(new VcsRefImpl(myVcsObjectsFactory.createHash(localTagInfo.getHash()), localTagInfo.getName(),
+ refs.add(myVcsObjectsFactory.createRef(myVcsObjectsFactory.createHash(localTagInfo.getHash()), localTagInfo.getName(),
HgRefManager.LOCAL_TAG, root));
}
return refs;
@@ -206,7 +202,7 @@
if (userName == null) {
userName = System.getenv("HGUSER");
}
- return userName == null ? null : myVcsObjectsFactory.createUser(userName);
+ return userName == null ? null : myVcsObjectsFactory.createUser(userName, "");
}
private static String prepareParameter(String paramName, String value) {
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgRepositoryImpl.java b/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgRepositoryImpl.java
index 740df7d..7b99bda 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgRepositoryImpl.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgRepositoryImpl.java
@@ -51,7 +51,7 @@
super(project, rootDir, parentDisposable);
myHgDir = rootDir.findChild(HgUtil.DOT_HG);
assert myHgDir != null : ".hg directory wasn't found under " + rootDir.getPresentableUrl();
- myReader = new HgRepositoryReader(VfsUtilCore.virtualToIoFile(myHgDir));
+ myReader = new HgRepositoryReader(project, VfsUtilCore.virtualToIoFile(myHgDir));
myConfig = HgConfig.getInstance(project, rootDir);
update();
}
@@ -137,7 +137,7 @@
@Override
public void update() {
- HgRepoInfo currentInfo = readRepoInfo(myInfo);
+ HgRepoInfo currentInfo = readRepoInfo();
// update only if something changed!!! if update every time - new log will be refreshed every time, too.
// Then blinking and do not work properly;
if (!Disposer.isDisposed(getProject()) && currentInfo != null && !currentInfo.equals(myInfo)) {
@@ -153,11 +153,8 @@
}
@Nullable
- private HgRepoInfo readRepoInfo(@Nullable HgRepoInfo previousInfo) {
+ private HgRepoInfo readRepoInfo() {
myIsFresh = myIsFresh && myReader.checkIsFresh();
- if (isFresh()) {
- return previousInfo;
- }
//in GitRepositoryImpl there are temporary state object for reader fields storing! Todo Check;
return
new HgRepoInfo(myReader.readCurrentBranch(), myReader.readCurrentRevision(), myReader.readState(), myReader.readBranches(),
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgRepositoryReader.java b/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgRepositoryReader.java
index 39524ad..aaf7fb5 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgRepositoryReader.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgRepositoryReader.java
@@ -19,6 +19,7 @@
import com.intellij.dvcs.repo.Repository;
import com.intellij.dvcs.repo.RepositoryUtil;
import com.intellij.openapi.components.ServiceManager;
+import com.intellij.openapi.project.Project;
import com.intellij.vcs.log.VcsLogObjectsFactory;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -49,7 +50,7 @@
@NotNull private final File myLocalTagsFile; // .hg/localtags
@NotNull private final VcsLogObjectsFactory myVcsObjectsFactory;
- public HgRepositoryReader(@NotNull File hgDir) {
+ public HgRepositoryReader(@NotNull Project project, @NotNull File hgDir) {
myHgDir = hgDir;
RepositoryUtil.assertFileExists(myHgDir, ".hg directory not found in " + myHgDir);
File branchesFile = new File(new File(myHgDir, "cache"), "branchheads-served"); //branchheads-served exist after mercurial 2.5,
@@ -60,7 +61,7 @@
myCurrentBookmark = new File(myHgDir, "bookmarks.current");
myLocalTagsFile = new File(myHgDir, "localtags");
myTagsFile = new File(myHgDir.getParentFile(), ".hgtags");
- myVcsObjectsFactory = ServiceManager.getService(VcsLogObjectsFactory.class);
+ myVcsObjectsFactory = ServiceManager.getService(project, VcsLogObjectsFactory.class);
}
/**
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgInitDialog.java b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgInitDialog.java
index d936cb1..0a66ab7 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgInitDialog.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgInitDialog.java
@@ -24,8 +24,8 @@
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.vcsUtil.VcsUtil;
import org.jetbrains.annotations.Nullable;
-import org.zmlx.hg4idea.util.HgUtil;
import org.zmlx.hg4idea.HgVcsMessages;
+import org.zmlx.hg4idea.util.HgUtil;
import javax.swing.*;
import javax.swing.event.CaretEvent;
@@ -111,7 +111,8 @@
public void show() {
if (myShowDialog) {
super.show();
- } else {
+ }
+ else {
mySelectedDir = FileChooser.chooseFile(myFileDescriptor, myProject, null);
}
}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgEncodingUtil.java b/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgEncodingUtil.java
index c5ad072..af7d0c2 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgEncodingUtil.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgEncodingUtil.java
@@ -26,4 +26,14 @@
}
return Charset.defaultCharset();
}
+
+ @NotNull
+ public static String getNameFor(@NotNull Charset charset) {
+ //workaround for x_MacRoman encoding etc; todo: create map with encoding aliases because some encodings name are not supported by hg
+ String name = charset.name();
+ if (name.startsWith("x-M")) {
+ return name.substring(2); // without "x-" prefix;
+ }
+ return name;
+ }
}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgErrorUtil.java b/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgErrorUtil.java
index 8558e81..ab2dba7 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgErrorUtil.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgErrorUtil.java
@@ -93,4 +93,16 @@
}
};
}
+
+ public static boolean isUnknownEncodingError(@Nullable HgCommandResult result) {
+ if (result == null) {
+ return false;
+ }
+ List<String> errorLines = result.getErrorLines();
+ if (errorLines.isEmpty()) {
+ return false;
+ }
+ String line = errorLines.get(0);
+ return !StringUtil.isEmptyOrSpaces(line) && (line.contains("abort") && line.contains("unknown encoding"));
+ }
}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgHistoryUtil.java b/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgHistoryUtil.java
index 4873558..65d5d2f 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgHistoryUtil.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgHistoryUtil.java
@@ -22,6 +22,7 @@
import com.intellij.openapi.vcs.changes.Change;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.ArrayUtil;
+import com.intellij.util.Consumer;
import com.intellij.util.Function;
import com.intellij.util.SmartList;
import com.intellij.util.containers.ContainerUtil;
@@ -120,7 +121,7 @@
@NotNull
public static List<? extends VcsShortCommitDetails> readMiniDetails(Project project, final VirtualFile root, List<String> hashes)
throws VcsException {
- final VcsLogObjectsFactory factory = ServiceManager.getService(VcsLogObjectsFactory.class);
+ final VcsLogObjectsFactory factory = ServiceManager.getService(project, VcsLogObjectsFactory.class);
return ContainerUtil.map(getCommittedChangeList(project, root, -1, false, prepareHashes(hashes)),
new Function<HgCommittedChangeList, VcsShortCommitDetails>() {
@Override
@@ -132,15 +133,16 @@
}
return factory.createShortDetails(factory.createHash(revNumber.getChangeset()), parents,
record.getCommitDate().getTime(), root,
- revNumber.getSubject(), revNumber.getAuthor());
+ revNumber.getSubject(), revNumber.getAuthor(), "");
}
});
}
@NotNull
- public static List<TimedVcsCommit> readAllHashes(@NotNull Project project, @NotNull VirtualFile root) throws VcsException {
+ public static List<TimedVcsCommit> readAllHashes(@NotNull Project project, @NotNull VirtualFile root,
+ @NotNull final Consumer<VcsUser> userRegistry) throws VcsException {
- final VcsLogObjectsFactory factory = ServiceManager.getService(VcsLogObjectsFactory.class);
+ final VcsLogObjectsFactory factory = ServiceManager.getService(project, VcsLogObjectsFactory.class);
return ContainerUtil.map(getCommittedChangeList(project, root, -1, false, ""), new Function<HgCommittedChangeList, TimedVcsCommit>() {
@Override
public TimedVcsCommit fun(HgCommittedChangeList record) {
@@ -149,6 +151,7 @@
for (HgRevisionNumber parent : revNumber.getParents()) {
parents.add(factory.createHash(parent.getChangeset()));
}
+ userRegistry.consume(factory.createUser(record.getRevision().getAuthor(), ""));
return factory.createTimedCommit(factory.createHash(revNumber.getChangeset()),
parents, record.getCommitDate().getTime());
}
@@ -174,7 +177,7 @@
private static VcsFullCommitDetails createCommit(@NotNull Project project, @NotNull VirtualFile root,
@NotNull HgCommittedChangeList record) {
- final VcsLogObjectsFactory factory = ServiceManager.getService(VcsLogObjectsFactory.class);
+ final VcsLogObjectsFactory factory = ServiceManager.getService(project, VcsLogObjectsFactory.class);
HgRevisionNumber revNumber = (HgRevisionNumber)record.getRevisionNumber();
List<Hash> parents = ContainerUtil.map(revNumber.getParents(), new Function<HgRevisionNumber, Hash>() {
diff --git a/plugins/hg4idea/testSrc/hg4idea/test/repo/HgRealRepositoryReaderTest.java b/plugins/hg4idea/testSrc/hg4idea/test/repo/HgRealRepositoryReaderTest.java
index 73a1a58..079a6d2 100644
--- a/plugins/hg4idea/testSrc/hg4idea/test/repo/HgRealRepositoryReaderTest.java
+++ b/plugins/hg4idea/testSrc/hg4idea/test/repo/HgRealRepositoryReaderTest.java
@@ -41,7 +41,7 @@
File hgDir = new File(myRepository.getPath(), ".hg");
assertTrue(hgDir.exists());
createBranchesAndTags();
- myRepositoryReader = new HgRepositoryReader(hgDir);
+ myRepositoryReader = new HgRepositoryReader(myProject, hgDir);
}
public void testMergeState() {
diff --git a/plugins/hg4idea/testSrc/hg4idea/test/repo/HgRepositoryReaderTest.java b/plugins/hg4idea/testSrc/hg4idea/test/repo/HgRepositoryReaderTest.java
index c7bc0f5..bb94270 100644
--- a/plugins/hg4idea/testSrc/hg4idea/test/repo/HgRepositoryReaderTest.java
+++ b/plugins/hg4idea/testSrc/hg4idea/test/repo/HgRepositoryReaderTest.java
@@ -63,7 +63,7 @@
FileUtil.copy(testTagFile, new File(myHgDir.getParentFile(), ".hgtags"));
FileUtil.copy(testLocalTagFile, new File(myHgDir, "localtags"));
- myRepositoryReader = new HgRepositoryReader(myHgDir);
+ myRepositoryReader = new HgRepositoryReader(myProject, myHgDir);
myBranches = readBranches();
myBookmarks = readRefs(testBookmarkFile);
myTags = readRefs(testTagFile);
diff --git a/plugins/maven/jps-plugin/src/org/jetbrains/jps/maven/model/impl/MavenArtifactResourceConfiguration.java b/plugins/maven/jps-plugin/src/org/jetbrains/jps/maven/model/impl/MavenArtifactResourceConfiguration.java
new file mode 100644
index 0000000..d0988e3
--- /dev/null
+++ b/plugins/maven/jps-plugin/src/org/jetbrains/jps/maven/model/impl/MavenArtifactResourceConfiguration.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.jps.maven.model.impl;
+
+import com.intellij.util.xmlb.annotations.AbstractCollection;
+import com.intellij.util.xmlb.annotations.Tag;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Sergey Evdokimov
+ */
+public class MavenArtifactResourceConfiguration {
+
+ public String webArtifactName;
+
+ @Tag("web-resources")
+ @AbstractCollection(surroundWithTag = false, elementTag = "resource")
+ public List<ResourceRootConfiguration> webResources = new ArrayList<ResourceRootConfiguration>();
+
+}
diff --git a/plugins/maven/jps-plugin/src/org/jetbrains/jps/maven/model/impl/MavenModuleResourceConfiguration.java b/plugins/maven/jps-plugin/src/org/jetbrains/jps/maven/model/impl/MavenModuleResourceConfiguration.java
index a2f1bf9e..3c4c47c 100644
--- a/plugins/maven/jps-plugin/src/org/jetbrains/jps/maven/model/impl/MavenModuleResourceConfiguration.java
+++ b/plugins/maven/jps-plugin/src/org/jetbrains/jps/maven/model/impl/MavenModuleResourceConfiguration.java
@@ -71,7 +71,6 @@
@AbstractCollection(surroundWithTag = false, elementTag = "resource")
public List<ResourceRootConfiguration> testResources = new ArrayList<ResourceRootConfiguration>();
-
public Set<String> getFilteringExcludedExtensions() {
if (filteringExclusions.isEmpty()) {
return MavenProjectConfiguration.DEFAULT_FILTERING_EXCLUDED_EXTENSIONS;
diff --git a/plugins/maven/jps-plugin/src/org/jetbrains/jps/maven/model/impl/MavenProjectConfiguration.java b/plugins/maven/jps-plugin/src/org/jetbrains/jps/maven/model/impl/MavenProjectConfiguration.java
index adbc48e..91ff552 100644
--- a/plugins/maven/jps-plugin/src/org/jetbrains/jps/maven/model/impl/MavenProjectConfiguration.java
+++ b/plugins/maven/jps-plugin/src/org/jetbrains/jps/maven/model/impl/MavenProjectConfiguration.java
@@ -49,6 +49,10 @@
@MapAnnotation(surroundWithTag = false, surroundKeyWithTag = false, surroundValueWithTag = false, entryTagName = "maven-module", keyAttributeName = "name")
public Map<String, MavenModuleResourceConfiguration> moduleConfigurations = new THashMap<String, MavenModuleResourceConfiguration>();
+ @Tag("web-resources")
+ @MapAnnotation(surroundWithTag = false, surroundKeyWithTag = false, surroundValueWithTag = false, entryTagName = "artifact", keyAttributeName = "name")
+ public Map<String, MavenArtifactResourceConfiguration> artifactsResources = new THashMap<String, MavenArtifactResourceConfiguration>();
+
@Nullable
public MavenModuleResourceConfiguration findProject(MavenIdBean id) {
return getModuleConfigurationMap().get(id);
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesArtifactIdConverter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesArtifactIdConverter.java
index 6245613..24fbf3b 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesArtifactIdConverter.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesArtifactIdConverter.java
@@ -20,6 +20,7 @@
import com.intellij.codeInsight.completion.InsertionContext;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupElementBuilder;
+import com.intellij.codeInsight.template.TemplateManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiElement;
@@ -81,6 +82,10 @@
@Override
public void handleInsert(final InsertionContext context, LookupElement item) {
+ if (TemplateManager.getInstance(context.getProject()).getActiveTemplate(context.getEditor()) != null) {
+ return; // Don't brake the template.
+ }
+
context.commitDocument();
XmlFile xmlFile = (XmlFile)context.getFile();
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesGroupIdConverter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesGroupIdConverter.java
index 15b1b2f..3b89a83 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesGroupIdConverter.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesGroupIdConverter.java
@@ -4,6 +4,7 @@
import com.intellij.codeInsight.completion.InsertionContext;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupElementBuilder;
+import com.intellij.codeInsight.template.TemplateManager;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiElement;
import com.intellij.psi.util.PsiTreeUtil;
@@ -77,6 +78,10 @@
@Override
public void handleInsert(final InsertionContext context, LookupElement item) {
+ if (TemplateManager.getInstance(context.getProject()).getActiveTemplate(context.getEditor()) != null) {
+ return; // Don't brake the template.
+ }
+
context.commitDocument();
XmlFile xmlFile = (XmlFile)context.getFile();
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenFoldersImporter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenFoldersImporter.java
index 0558a36..d61b12b 100755
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenFoldersImporter.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenFoldersImporter.java
@@ -25,7 +25,6 @@
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.roots.SourceFolder;
import com.intellij.openapi.roots.impl.ModifiableModelCommitter;
-import com.intellij.openapi.roots.impl.SourceFolderImpl;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.util.ArrayUtil;
@@ -38,7 +37,7 @@
import org.jetbrains.idea.maven.project.MavenImportingSettings;
import org.jetbrains.idea.maven.project.MavenProject;
import org.jetbrains.idea.maven.project.MavenProjectsManager;
-import org.jetbrains.jps.model.JpsElement;
+import org.jetbrains.jps.model.java.JavaModuleSourceRootTypes;
import org.jetbrains.jps.model.java.JavaResourceRootType;
import org.jetbrains.jps.model.java.JavaSourceRootProperties;
import org.jetbrains.jps.model.java.JavaSourceRootType;
@@ -269,8 +268,8 @@
}
private static boolean isGenerated(@NotNull SourceFolder folder) {
- JpsElement properties = ((SourceFolderImpl)folder).getJpsElement().getProperties();
- return properties instanceof JavaSourceRootProperties && ((JavaSourceRootProperties)properties).isForGeneratedSources();
+ JavaSourceRootProperties properties = folder.getJpsElement().getProperties(JavaModuleSourceRootTypes.SOURCES);
+ return properties != null && properties.isForGeneratedSources();
}
private void addAllSubDirsAsGeneratedSources(@NotNull File dir, final JavaSourceRootType rootType) {
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenIndices.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenIndices.java
index b13e2de..68a4539 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenIndices.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenIndices.java
@@ -112,8 +112,9 @@
File f = new File(parent, name);
if (!f.exists()) {
boolean createSuccessFull = f.mkdirs();
- assert createSuccessFull || f.exists();
- return f;
+ if (createSuccessFull) {
+ return f;
+ }
}
}
throw new RuntimeException("No available dir found");
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsTree.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsTree.java
index 621af26c..4089981 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsTree.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsTree.java
@@ -17,6 +17,7 @@
import com.intellij.openapi.application.AccessToken;
import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ProjectFileIndex;
@@ -32,6 +33,8 @@
import gnu.trove.THashSet;
import gnu.trove.TObjectHashingStrategy;
import org.jdom.Element;
+import org.jdom.output.Format;
+import org.jdom.output.XMLOutputter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
@@ -49,6 +52,9 @@
import java.util.zip.CRC32;
public class MavenProjectsTree {
+
+ private static final Logger LOG = Logger.getInstance(MavenProjectsTree.class);
+
private static final String STORAGE_VERSION = MavenProjectsTree.class.getSimpleName() + ".6";
private final Object myStateLock = new Object();
@@ -884,7 +890,7 @@
readLock();
try {
- CRC32 crc = new CRC32();
+ final CRC32 crc = new CRC32();
Set<String> profiles = myExplicitProfiles;
if (profiles != null) {
@@ -919,7 +925,7 @@
updateCrc(crc, mavenProject.getDirectory());
updateCrc(crc, MavenFilteredPropertyPsiReferenceProvider.getDelimitersPattern(mavenProject).pattern());
updateCrc(crc, mavenProject.getModelMap().hashCode());
- updateCrc(crc, mavenProject.getResources().hashCode() + 1); // @todo remove '+1' after 01.05.2013 (when 12.0.1 become out of date)
+ updateCrc(crc, mavenProject.getResources().hashCode());
updateCrc(crc, mavenProject.getTestResources().hashCode());
updateCrc(crc, getFilterExclusions(mavenProject).hashCode());
updateCrc(crc, mavenProject.getProperties().hashCode());
@@ -929,9 +935,41 @@
updateCrc(crc, file.lastModified());
}
- Element pluginConfiguration = mavenProject.getPluginConfiguration("org.apache.maven.plugins", "maven-resources-plugin");
- updateCrc(crc, MavenJDOMUtil.findChildValueByPath(pluginConfiguration, "escapeString"));
- updateCrc(crc, MavenJDOMUtil.findChildValueByPath(pluginConfiguration, "escapeWindowsPaths"));
+ XMLOutputter outputter = new XMLOutputter(Format.getCompactFormat());
+
+ Writer crcWriter = new Writer() {
+ @Override
+ public void write(char[] cbuf, int off, int len) throws IOException {
+ for (int i = off, end = off + len; i < end; i++) {
+ crc.update(cbuf[i]);
+ }
+ }
+
+ @Override
+ public void flush() throws IOException {
+
+ }
+
+ @Override
+ public void close() throws IOException {
+
+ }
+ };
+
+ try {
+ Element resourcePluginCfg = mavenProject.getPluginConfiguration("org.apache.maven.plugins", "maven-resources-plugin");
+ if (resourcePluginCfg != null) {
+ outputter.output(resourcePluginCfg, crcWriter);
+ }
+
+ Element warPluginCfg = mavenProject.getPluginConfiguration("org.apache.maven.plugins", "maven-war-plugin");
+ if (warPluginCfg != null) {
+ outputter.output(warPluginCfg, crcWriter);
+ }
+ }
+ catch (IOException e) {
+ LOG.error(e);
+ }
}
return (int)crc.getValue();
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenResourceCompilerConfigurationGenerator.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenResourceCompilerConfigurationGenerator.java
index 12fb1d3..523d5cb 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenResourceCompilerConfigurationGenerator.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenResourceCompilerConfigurationGenerator.java
@@ -3,12 +3,14 @@
import com.intellij.compiler.CompilerConfiguration;
import com.intellij.compiler.CompilerConfigurationImpl;
import com.intellij.compiler.server.BuildManager;
+import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.*;
import com.intellij.openapi.util.JDOMUtil;
import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
@@ -16,15 +18,13 @@
import com.intellij.util.xmlb.XmlSerializer;
import org.jdom.Document;
import org.jdom.Element;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.idea.maven.dom.references.MavenFilteredPropertyPsiReferenceProvider;
import org.jetbrains.idea.maven.model.MavenId;
import org.jetbrains.idea.maven.model.MavenResource;
import org.jetbrains.idea.maven.utils.MavenJDOMUtil;
import org.jetbrains.idea.maven.utils.MavenUtil;
-import org.jetbrains.jps.maven.model.impl.MavenIdBean;
-import org.jetbrains.jps.maven.model.impl.MavenModuleResourceConfiguration;
-import org.jetbrains.jps.maven.model.impl.MavenProjectConfiguration;
-import org.jetbrains.jps.maven.model.impl.ResourceRootConfiguration;
+import org.jetbrains.jps.maven.model.impl.*;
import java.io.*;
import java.util.*;
@@ -36,6 +36,8 @@
*/
public class MavenResourceCompilerConfigurationGenerator {
+ private static Logger LOG = Logger.getInstance(MavenResourceCompilerConfigurationGenerator.class);
+
private static final Pattern SIMPLE_NEGATIVE_PATTERN = Pattern.compile("!\\?(\\*\\.\\w+)");
private final Project myProject;
@@ -116,6 +118,9 @@
}
addResources(resourceConfig.resources, mavenProject.getResources());
addResources(resourceConfig.testResources, mavenProject.getTestResources());
+
+ addWebResources(module, projectConfig, mavenProject);
+
resourceConfig.filteringExclusions.addAll(MavenProjectsTree.getFilterExclusions(mavenProject));
final Properties properties = getFilteringProperties(mavenProject);
@@ -220,6 +225,63 @@
}
}
+ private static void addWebResources(@NotNull Module module, MavenProjectConfiguration projectCfg, MavenProject mavenProject) {
+ Element warCfg = mavenProject.getPluginConfiguration("org.apache.maven.plugins", "maven-war-plugin");
+ if (warCfg == null) return;
+
+ Element webResources = warCfg.getChild("webResources");
+ if (webResources == null) return;
+
+ String webArtifactName = MavenUtil.getArtifactName("war", module, true);
+
+ MavenArtifactResourceConfiguration artifactResourceCfg = projectCfg.artifactsResources.get(webArtifactName);
+ if (artifactResourceCfg == null) {
+ artifactResourceCfg = new MavenArtifactResourceConfiguration();
+ artifactResourceCfg.webArtifactName = webArtifactName;
+ projectCfg.artifactsResources.put(webArtifactName, artifactResourceCfg);
+ }
+ else {
+ LOG.error("MavenArtifactResourceConfiguration already exists.");
+ }
+
+ for (Element resource : webResources.getChildren("resource")) {
+ ResourceRootConfiguration r = new ResourceRootConfiguration();
+ String directory = resource.getChildTextTrim("directory");
+ if (StringUtil.isEmptyOrSpaces(directory)) continue;
+
+ if (!FileUtil.isAbsolute(directory)) {
+ directory = mavenProject.getDirectory() + '/' + directory;
+ }
+
+ r.directory = directory;
+ r.isFiltered = Boolean.parseBoolean(resource.getChildTextTrim("filtering"));
+
+ r.targetPath = resource.getChildTextTrim("targetPath");
+
+ Element includes = resource.getChild("includes");
+ if (includes != null) {
+ for (Element include : includes.getChildren("include")) {
+ String includeText = include.getTextTrim();
+ if (!includeText.isEmpty()) {
+ r.includes.add(includeText);
+ }
+ }
+ }
+
+ Element excludes = resource.getChild("excludes");
+ if (excludes != null) {
+ for (Element exclude : excludes.getChildren("exclude")) {
+ String excludeText = exclude.getTextTrim();
+ if (!excludeText.isEmpty()) {
+ r.excludes.add(excludeText);
+ }
+ }
+ }
+
+ artifactResourceCfg.webResources.add(r);
+ }
+ }
+
private void addNonMavenResources(MavenProjectConfiguration projectCfg) {
Set<VirtualFile> processedRoots = new HashSet<VirtualFile>();
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/server/MavenServerManager.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/server/MavenServerManager.java
index 774bc83..b4c440b 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/server/MavenServerManager.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/server/MavenServerManager.java
@@ -25,6 +25,7 @@
import com.intellij.execution.rmi.RemoteProcessSupport;
import com.intellij.execution.runners.ProgramRunner;
import com.intellij.openapi.actionSystem.AnAction;
+import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.components.*;
import com.intellij.openapi.project.Project;
@@ -79,7 +80,7 @@
private final Alarm myShutdownAlarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD);
- private boolean useMaven2 = true;
+ private boolean useMaven2 = false;
private String mavenEmbedderVMOptions = DEFAULT_VM_OPTIONS;
private String embedderJdk = MavenRunnerSettings.USE_INTERNAL_JAVA;
@@ -294,19 +295,24 @@
return new File(pluginFileOrDir.getParentFile(), "maven3");
}
- public static List<File> collectClassPathAndLibsFolder() {
+ public List<File> collectClassPathAndLibsFolder() {
File pluginFileOrDir = new File(PathUtil.getJarPathForClass(MavenServerManager.class));
List<File> classpath = new ArrayList<File>();
String root = pluginFileOrDir.getParent();
+ boolean useMaven2 = this.useMaven2;
+ if (ApplicationManager.getApplication().isUnitTestMode()) {
+ useMaven2 = true;
+ }
+
if (pluginFileOrDir.isDirectory()) {
classpath.add(new File(root, "maven-server-api"));
File luceneLib = new File(PathUtil.getJarPathForClass(Query.class));
- if (getInstance().isUseMaven2()) {
+ if (useMaven2) {
classpath.add(new File(root, "maven2-server-impl"));
addDir(classpath, new File(luceneLib.getParentFile().getParentFile().getParentFile(), "maven2-server-impl/lib"));
}
@@ -326,7 +332,7 @@
else {
classpath.add(new File(root, "maven-server-api.jar"));
- if (getInstance().isUseMaven2()) {
+ if (useMaven2) {
classpath.add(new File(root, "maven2-server-impl.jar"));
addDir(classpath, new File(root, "maven2"));
@@ -499,7 +505,7 @@
@Override
public Element getState() {
final Element element = new Element("maven-version");
- element.setAttribute("version", useMaven2 ? "2" : "3");
+ element.setAttribute("version", useMaven2 ? "2.x" : "3.x");
element.setAttribute("vmOptions", mavenEmbedderVMOptions);
return element;
}
@@ -507,7 +513,7 @@
@Override
public void loadState(Element state) {
String version = state.getAttributeValue("version");
- useMaven2 = !"3".equals(version);
+ useMaven2 = "2.x".equals(version);
String vmOptions = state.getAttributeValue("vmOptions");
mavenEmbedderVMOptions = vmOptions == null ? DEFAULT_VM_OPTIONS : vmOptions;
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java
index fba889c..71f22ec 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java
@@ -711,6 +711,7 @@
}
if (result == null) {
result = doResolveSuperPomFile(MavenServerManager.getMavenLibDirectory());
+ assert result != null : "Super pom not found in: " + MavenServerManager.getMavenLibDirectory();
}
return result;
}
@@ -926,4 +927,9 @@
return (V)res;
}
+ public static String getArtifactName(String packaging, Module module, boolean exploded) {
+ final String baseName = module.getName() + ":" + packaging;
+ return exploded ? baseName + " exploded" : baseName;
+ }
+
}
diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenImportingTestCase.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenImportingTestCase.java
index 1da55a1..1f7a404 100644
--- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenImportingTestCase.java
+++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenImportingTestCase.java
@@ -34,7 +34,6 @@
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.projectRoots.impl.JavaAwareProjectJdkTableImpl;
import com.intellij.openapi.roots.*;
-import com.intellij.openapi.roots.impl.SourceFolderImpl;
import com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable;
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.ui.Messages;
@@ -130,7 +129,9 @@
ContentEntry contentRoot = getContentRoot(moduleName);
List<ContentFolder> folders = new ArrayList<ContentFolder>();
for (SourceFolder folder : contentRoot.getSourceFolders(JavaSourceRootType.SOURCE)) {
- if (((JavaSourceRootProperties)((SourceFolderImpl)folder).getJpsElement().getProperties()).isForGeneratedSources()) {
+ JavaSourceRootProperties properties = folder.getJpsElement().getProperties(JavaSourceRootType.SOURCE);
+ assertNotNull(properties);
+ if (properties.isForGeneratedSources()) {
folders.add(folder);
}
}
diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenFoldersImporterTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenFoldersImporterTest.java
index 2138756..e6e946e 100644
--- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenFoldersImporterTest.java
+++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenFoldersImporterTest.java
@@ -18,13 +18,13 @@
import com.intellij.ProjectTopics;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.roots.*;
-import com.intellij.openapi.roots.impl.SourceFolderImpl;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.Consumer;
import org.jetbrains.idea.maven.MavenImportingTestCase;
import org.jetbrains.idea.maven.importing.MavenDefaultModifiableModelsProvider;
import org.jetbrains.idea.maven.importing.MavenFoldersImporter;
import org.jetbrains.idea.maven.importing.MavenRootModelAdapter;
+import org.jetbrains.jps.model.java.JavaModuleSourceRootTypes;
import org.jetbrains.jps.model.java.JavaSourceRootProperties;
import org.jetbrains.jps.model.java.JavaSourceRootType;
@@ -239,7 +239,9 @@
@Override
public void consume(ModifiableRootModel model) {
for (SourceFolder folder : model.getContentEntries()[0].getSourceFolders()) {
- ((JavaSourceRootProperties)((SourceFolderImpl)folder).getJpsElement().getProperties()).setForGeneratedSources(false);
+ JavaSourceRootProperties properties = folder.getJpsElement().getProperties(JavaModuleSourceRootTypes.SOURCES);
+ assertNotNull(properties);
+ properties.setForGeneratedSources(false);
}
}
});
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnUtil.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnUtil.java
index 073bf57..ce734fd 100644
--- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnUtil.java
+++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnUtil.java
@@ -15,6 +15,7 @@
*/
package org.jetbrains.idea.svn;
+import com.intellij.notification.NotificationType;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProcessCanceledException;
@@ -25,11 +26,13 @@
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.AbstractVcsHelper;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.changes.Change;
import com.intellij.openapi.vcs.changes.ChangesUtil;
+import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
@@ -57,6 +60,7 @@
import org.tmatesoft.svn.core.wc2.SvnTarget;
import java.io.File;
+import java.nio.channels.NonWritableChannelException;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -369,30 +373,34 @@
*/
@NotNull
public static WorkingCopyFormat getFormat(final File path) {
- int format = 0;
+ WorkingCopyFormat result = null;
File dbFile = resolveDatabase(path);
if (dbFile != null) {
- SqlJetDb db = null;
- try {
- db = SqlJetDb.open(dbFile, false);
- format = db.getOptions().getUserVersion();
- }
- catch (SqlJetException e) {
- LOG.error(e);
- } finally {
- if (db != null) {
- try {
- db.close();
- }
- catch (SqlJetException e) {
- LOG.error(e);
- }
- }
+ result = FileUtilRt.doIOOperation(new WorkingCopyFormatOperation(dbFile));
+
+ if (result == null) {
+ notifyDatabaseError();
}
}
- return WorkingCopyFormat.getInstance(format);
+ return result != null ? result : WorkingCopyFormat.UNKNOWN;
+ }
+
+ private static void close(@Nullable SqlJetDb db) {
+ if (db != null) {
+ try {
+ db.close();
+ }
+ catch (SqlJetException e) {
+ notifyDatabaseError();
+ }
+ }
+ }
+
+ private static void notifyDatabaseError() {
+ VcsBalloonProblemNotifier.NOTIFICATION_GROUP
+ .createNotification("Some errors occurred while accessing svn working copy database.", NotificationType.ERROR).notify(null);
}
private static File resolveDatabase(final File path) {
@@ -803,4 +811,40 @@
// thrown when getting info from repository for non-existent item - like HEAD revision for deleted file
SVNErrorCode.ILLEGAL_TARGET.equals(code);
}
+
+ private static class WorkingCopyFormatOperation implements FileUtilRt.RepeatableIOOperation<WorkingCopyFormat, RuntimeException> {
+ @NotNull private final File myDbFile;
+
+ public WorkingCopyFormatOperation(@NotNull File dbFile) {
+ myDbFile = dbFile;
+ }
+
+ @Nullable
+ @Override
+ public WorkingCopyFormat execute(boolean lastAttempt) {
+ // TODO: rewrite it using sqlite jdbc driver
+ SqlJetDb db = null;
+ WorkingCopyFormat result = null;
+ try {
+ // "write" access is requested here for now as workaround - see some details
+ // in https://code.google.com/p/sqljet/issues/detail?id=25 and http://issues.tmatesoft.com/issue/SVNKIT-418.
+ // BUSY error is currently handled same way as others.
+ db = SqlJetDb.open(myDbFile, true);
+ result = WorkingCopyFormat.getInstance(db.getOptions().getUserVersion());
+ }
+ catch (NonWritableChannelException e) {
+ // Such exceptions could be thrown when db is opened in "read" mode, but the db file is readonly (for instance, locked
+ // by other process). See links above for some details.
+ // handle this exception type separately - not to break execution flow
+ LOG.info(e);
+ }
+ catch (SqlJetException e) {
+ LOG.info(e);
+ }
+ finally {
+ close(db);
+ }
+ return result;
+ }
+ }
}
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/Command.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/Command.java
index e5d7dd6..ea623f4 100644
--- a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/Command.java
+++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/Command.java
@@ -41,6 +41,12 @@
myParameters.addAll(parameters);
}
+ public void putIfNotPresent(@NotNull String parameter) {
+ if (!myParameters.contains(parameter)) {
+ myParameters.add(parameter);
+ }
+ }
+
@Nullable
public File getConfigDir() {
return myConfigDir;
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/CommandExecutor.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/CommandExecutor.java
index c015d025..5779ee4 100644
--- a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/CommandExecutor.java
+++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/CommandExecutor.java
@@ -15,6 +15,7 @@
*/
package org.jetbrains.idea.svn.commandLine;
+import com.intellij.execution.ExecutionException;
import com.intellij.execution.configurations.GeneralCommandLine;
import com.intellij.execution.process.*;
import com.intellij.openapi.diagnostic.Logger;
@@ -25,6 +26,8 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
@@ -40,9 +43,11 @@
private boolean myIsDestroyed;
private boolean myNeedsDestroy;
+ private volatile String myDestroyReason;
protected final GeneralCommandLine myCommandLine;
- private Process myProcess;
- private OSProcessHandler myHandler;
+ protected Process myProcess;
+ protected OSProcessHandler myHandler;
+ private OutputStreamWriter myProcessWriter;
// TODO: Try to implement commands in a way that they manually indicate if they need full output - to prevent situations
// TODO: when large amount of data needs to be stored instead of just sequential processing.
private CapturingProcessAdapter outputAdapter;
@@ -86,16 +91,21 @@
return myIsDestroyed;
}
+ public String getDestroyReason() {
+ return myDestroyReason;
+ }
+
public void start() {
synchronized (myLock) {
checkNotStarted();
try {
- myProcess = myCommandLine.createProcess();
+ myProcess = createProcess();
if (LOG.isDebugEnabled()) {
LOG.debug(myCommandLine.toString());
}
- myHandler = new OSProcessHandler(myProcess, myCommandLine.getCommandLineString());
+ myHandler = createProcessHandler();
+ myProcessWriter = new OutputStreamWriter(myHandler.getProcessInput());
startHandlingStreams();
} catch (Throwable t) {
listeners().startFailed(t);
@@ -104,7 +114,17 @@
}
}
- private void startHandlingStreams() {
+ @NotNull
+ protected OSProcessHandler createProcessHandler() {
+ return new OSProcessHandler(myProcess, myCommandLine.getCommandLineString());
+ }
+
+ @NotNull
+ protected Process createProcess() throws ExecutionException {
+ return myCommandLine.createProcess();
+ }
+
+ protected void startHandlingStreams() {
outputAdapter = new CapturingProcessAdapter();
myHandler.addProcessListener(outputAdapter);
myHandler.addProcessListener(new ProcessTracker());
@@ -121,6 +141,12 @@
return outputAdapter.getOutput().getStderr();
}
+ // TODO: Carefully here - do not modify command from threads other than the one started command execution
+ @NotNull
+ public Command getCommand() {
+ return myCommand;
+ }
+
/**
* Wait for process termination
* @param timeout
@@ -183,6 +209,13 @@
}
}
+ public void destroyProcess(@Nullable String destroyReason) {
+ synchronized (myLock) {
+ myDestroyReason = destroyReason;
+ myNeedsDestroy = true;
+ }
+ }
+
/**
* ProcessHandler.destroyProcess() implementations could acquire read lock in its implementation - like OSProcessManager.getInstance().
* Some commands are called under write lock - which is generally bad idea, but such logic is not refactored yet.
@@ -265,6 +298,23 @@
}
}
+ public void write(String value) throws SvnBindException {
+ try {
+ synchronized (myLock) {
+ myProcessWriter.write(value);
+ myProcessWriter.flush();
+ }
+ }
+ catch (IOException e) {
+ throw new SvnBindException(e);
+ }
+ }
+
+ public void logCommand() {
+ LOG.info("Command text " + getCommandText());
+ LOG.info("Command output " + getOutput());
+ }
+
private class CommandCancelTracker extends LineCommandAdapter {
@Override
public void onLineAvailable(String line, Key outputType) {
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/CommandParametersResolutionModule.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/CommandParametersResolutionModule.java
index a76f0ec..2e9e420 100644
--- a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/CommandParametersResolutionModule.java
+++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/CommandParametersResolutionModule.java
@@ -44,7 +44,6 @@
command.setWorkingDirectory(resolveWorkingDirectory(command));
}
command.setConfigDir(myAuthCallback.getSpecialConfigDir());
- command.put("--non-interactive");
command.saveOriginalParameters();
}
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/CommandRuntime.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/CommandRuntime.java
index be097b6..67867ea 100644
--- a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/CommandRuntime.java
+++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/CommandRuntime.java
@@ -17,6 +17,8 @@
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Condition;
+import com.intellij.openapi.util.registry.Registry;
+import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -85,12 +87,20 @@
if (exitCode == null || exitCode != 0) {
logNullExitCode(executor, exitCode);
+ if (executor.isManuallyDestroyed()) {
+ cleanup(executor, command.getWorkingDirectory());
+
+ String destroyReason = executor.getDestroyReason();
+ if (!StringUtil.isEmpty(destroyReason)) {
+ throw new SvnBindException(destroyReason);
+ }
+ }
+
if (executor.getErrorOutput().length() > 0) {
// handle authentication
final String errText = executor.getErrorOutput().trim();
- final AuthCallbackCase callback = createCallback(errText, command.getRepositoryUrl());
+ final AuthCallbackCase callback = executor instanceof TerminalExecutor ? null : createCallback(errText, command.getRepositoryUrl());
if (callback != null) {
- cleanup(executor, command.getWorkingDirectory());
if (callback.getCredentials(errText)) {
if (myAuthCallback.getSpecialConfigDir() != null) {
command.setConfigDir(myAuthCallback.getSpecialConfigDir());
@@ -107,6 +117,9 @@
// no errors found in error stream => we treat null exitCode as successful, otherwise exception is thrown
if (exitCode != null) {
// here exitCode != null && exitCode != 0
+ LOG.info("Command - " + executor.getCommandText());
+ LOG.info("Command output - " + executor.getOutput());
+
throw new SvnBindException("Svn process exited with error code: " + exitCode);
}
}
@@ -148,7 +161,7 @@
}
private void cleanup(@NotNull CommandExecutor executor, @NotNull File workingDirectory) throws SvnBindException {
- if (executor.isManuallyDestroyed() && executor.getCommandName().isWriteable()) {
+ if (executor.getCommandName().isWriteable()) {
File wcRoot = SvnUtil.getWorkingCopyRootNew(workingDirectory);
// not all commands require cleanup - for instance, some commands operate only with repository - like "svn info <url>"
@@ -167,7 +180,19 @@
@NotNull
private CommandExecutor newExecutor(@NotNull Command command) {
- return new CommandExecutor(exePath, command);
+ final CommandExecutor executor;
+
+ if (!Registry.is("svn.use.terminal")) {
+ command.putIfNotPresent("--non-interactive");
+ executor = new CommandExecutor(exePath, command);
+ }
+ else {
+ command.put("--force-interactive");
+ executor = new TerminalExecutor(exePath, command);
+ ((TerminalExecutor)executor).addInteractiveListener(new TerminalSshModule(this, executor));
+ }
+
+ return executor;
}
@NotNull
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/GroovyTypeHierarchyProvider.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/InteractiveCommandListener.java
similarity index 68%
copy from plugins/groovy/src/org/jetbrains/plugins/groovy/lang/GroovyTypeHierarchyProvider.java
copy to plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/InteractiveCommandListener.java
index bed999e..a9dc33a 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/GroovyTypeHierarchyProvider.java
+++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/InteractiveCommandListener.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,12 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.jetbrains.plugins.groovy.lang;
+package org.jetbrains.idea.svn.commandLine;
-import com.intellij.ide.hierarchy.type.JavaTypeHierarchyProvider;
+import com.intellij.openapi.util.Key;
/**
- * @author peter
+ * @author Konstantin Kolosovsky.
*/
-public class GroovyTypeHierarchyProvider extends JavaTypeHierarchyProvider{
+public interface InteractiveCommandListener {
+
+ boolean handlePrompt(String line, Key outputType);
}
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/SvnCommandLineStatusClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/SvnCommandLineStatusClient.java
index 48dcfa5..860e858 100644
--- a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/SvnCommandLineStatusClient.java
+++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/SvnCommandLineStatusClient.java
@@ -171,6 +171,11 @@
throw new SVNException(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e), e);
}
catch (SAXException e) {
+ // status parsing errors are logged separately as sometimes there are parsing errors connected to terminal output handling.
+ // these errors primarily occur when status output is rather large.
+ // and status output could be large, for instance, when working copy is locked (seems that each file is listed in status output).
+ command.logCommand();
+
throw new SVNException(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e), e);
}
}
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/TerminalExecutor.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/TerminalExecutor.java
new file mode 100644
index 0000000..203b25c
--- /dev/null
+++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/TerminalExecutor.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.idea.svn.commandLine;
+
+import com.intellij.execution.CommandLineUtil;
+import com.intellij.execution.ExecutionException;
+import com.intellij.execution.process.OSProcessHandler;
+import com.intellij.openapi.util.SystemInfo;
+import com.intellij.util.ArrayUtil;
+import com.intellij.util.Function;
+import com.intellij.util.containers.ContainerUtil;
+import com.pty4j.PtyProcess;
+import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
+
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * @author Konstantin Kolosovsky.
+ */
+public class TerminalExecutor extends CommandExecutor {
+
+ // max available value is 480
+ // if greater value is provided than the default value of 80 will be assumed
+ // this could provide unnecessary line breaks and thus could break parsing logic
+ private static final int TERMINAL_WINDOW_MAX_COLUMNS = 480;
+
+ static {
+ if (SystemInfo.isWindows) {
+ System.setProperty("win.pty.cols", String.valueOf(TERMINAL_WINDOW_MAX_COLUMNS));
+ }
+ }
+
+ private final List<InteractiveCommandListener> myInteractiveListeners = ContainerUtil.createLockFreeCopyOnWriteList();
+
+ public TerminalExecutor(@NotNull @NonNls String exePath, @NotNull Command command) {
+ super(exePath, command);
+ }
+
+ public void addInteractiveListener(@NotNull InteractiveCommandListener listener) {
+ myInteractiveListeners.add(listener);
+ }
+
+ @Override
+ protected void startHandlingStreams() {
+ for (InteractiveCommandListener listener : myInteractiveListeners) {
+ ((TerminalProcessHandler)myHandler).addInteractiveListener(listener);
+ }
+
+ super.startHandlingStreams();
+ }
+
+ @NotNull
+ @Override
+ protected OSProcessHandler createProcessHandler() {
+ return new TerminalProcessHandler(myProcess);
+ }
+
+ @NotNull
+ @Override
+ protected Process createProcess() throws ExecutionException {
+ List<String> parameters =
+ escapeArguments(CommandLineUtil.toCommandLine(myCommandLine.getExePath(), myCommandLine.getParametersList().getList()));
+
+ try {
+ return PtyProcess
+ .exec(ArrayUtil.toStringArray(parameters), myCommandLine.getEnvironment(), myCommandLine.getWorkDirectory().getAbsolutePath());
+ }
+ catch (IOException e) {
+ throw new ExecutionException(e);
+ }
+ }
+
+ @Override
+ public void logCommand() {
+ super.logCommand();
+
+ LOG.info("Terminal output " + ((TerminalProcessHandler) myHandler).getTerminalOutput());
+ }
+
+ private static List<String> escapeArguments(List<String> collection) {
+ // TODO: Add additional checks like in java.lang.ProcessImpl constructor
+ return ContainerUtil.map(collection, new Function<String, String>() {
+ @Override
+ public String fun(String s) {
+ return s.contains(" ") ? "\"" + s + "\"" : s;
+ }
+ });
+ }
+}
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/TerminalProcessHandler.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/TerminalProcessHandler.java
new file mode 100644
index 0000000..86fd039
--- /dev/null
+++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/TerminalProcessHandler.java
@@ -0,0 +1,153 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.idea.svn.commandLine;
+
+import com.intellij.execution.process.CapturingProcessAdapter;
+import com.intellij.execution.process.OSProcessHandler;
+import com.intellij.execution.process.ProcessEvent;
+import com.intellij.execution.process.ProcessOutputTypes;
+import com.intellij.openapi.util.Key;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.util.containers.ContainerUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.idea.svn.SvnUtil;
+
+import java.util.List;
+import java.util.regex.Matcher;
+
+/**
+ * @author Konstantin Kolosovsky.
+ */
+public class TerminalProcessHandler extends OSProcessHandler {
+
+ // see http://en.wikipedia.org/wiki/ANSI_escape_code
+ private static final String NON_CSI_ESCAPE_CODE = "\u001B.[@-_]";
+ private static final String CSI_ESCAPE_CODE = "\u001B\\[(.*?)[@-~]";
+
+ private final List<InteractiveCommandListener> myInteractiveListeners = ContainerUtil.createLockFreeCopyOnWriteList();
+ private final CapturingProcessAdapter terminalOutputCapturer = new CapturingProcessAdapter();
+
+ private final StringBuilder outputLine = new StringBuilder();
+ private final StringBuilder errorLine = new StringBuilder();
+
+ public TerminalProcessHandler(@NotNull Process process) {
+ super(process);
+ }
+
+ public void addInteractiveListener(@NotNull InteractiveCommandListener listener) {
+ myInteractiveListeners.add(listener);
+ }
+
+ @Override
+ protected boolean processHasSeparateErrorStream() {
+ return false;
+ }
+
+ @Override
+ protected void destroyProcessImpl() {
+ final Process process = getProcess();
+ process.destroy();
+ }
+
+ @Override
+ public void notifyTextAvailable(String text, Key outputType) {
+ terminalOutputCapturer.onTextAvailable(new ProcessEvent(this, text), outputType);
+
+ // filter terminal escape codes - they are presented in the output for windows platform
+ String filteredText = text.replaceAll(CSI_ESCAPE_CODE, "").replaceAll(NON_CSI_ESCAPE_CODE, "");
+ // trim leading '\r' symbols - as they break xml parsing logic
+ filteredText = StringUtil.trimLeading(filteredText);
+
+ if (!StringUtil.isEmpty(filteredText)) {
+ StringBuilder lastLine = getLastLineFor(outputType);
+ String currentLine = lastLine.append(filteredText).toString();
+ lastLine.setLength(0);
+
+ // check if current line presents some interactive output
+ boolean handled = false;
+ for (InteractiveCommandListener listener : myInteractiveListeners) {
+ handled |= listener.handlePrompt(currentLine, outputType);
+ }
+
+ if (!handled) {
+ notify(currentLine, outputType, lastLine);
+ }
+ }
+ }
+
+ private void notify(@NotNull String text, @NotNull Key outputType, @NotNull StringBuilder lastLine) {
+ // for windows platform output is assumed in format suitable for terminal emulator
+ // for instance, same text could be returned twice with '\r' symbol in between (so in emulator output we'll still see correct
+ // text without duplication)
+ // because of this we manually process '\r' occurrences to get correct output
+ text = removeAllBeforeCaretReturn(text);
+
+ // text is not more than one line - either one line or part of the line
+ if (StringUtil.endsWith(text, "\n")) {
+ // we have full line - notify listeners
+ super.notifyTextAvailable(text, resolveOutputType(text, outputType));
+ }
+ else {
+ // save line part to lastLine
+ lastLine.append(text);
+ }
+ }
+
+ private static String removeAllBeforeCaretReturn(@NotNull String line) {
+ int caretReturn = line.lastIndexOf("\r");
+
+ while (caretReturn >= 0) {
+ if (caretReturn + 1 < line.length() && line.charAt(caretReturn + 1) != '\n') {
+ // next symbol is not '\n' - we should not treat text before found caret return symbol
+ line = line.substring(caretReturn + 1);
+ break;
+ }
+ caretReturn = line.lastIndexOf("\r", caretReturn - 1);
+ }
+
+ return line;
+ }
+
+ private static Key resolveOutputType(@NotNull String line, @NotNull Key outputType) {
+ Key result = outputType;
+
+ if (!ProcessOutputTypes.SYSTEM.equals(outputType)) {
+ Matcher errorMatcher = SvnUtil.ERROR_PATTERN.matcher(line);
+ Matcher warningMatcher = SvnUtil.WARNING_PATTERN.matcher(line);
+
+ result = errorMatcher.find() || warningMatcher.find() ? ProcessOutputTypes.STDERR : ProcessOutputTypes.STDOUT;
+ }
+
+ return result;
+ }
+
+ @NotNull
+ private StringBuilder getLastLineFor(Key outputType) {
+ if (ProcessOutputTypes.STDERR.equals(outputType)) {
+ return errorLine;
+ }
+ else if (ProcessOutputTypes.STDOUT.equals(outputType)) {
+ return outputLine;
+ }
+ else {
+ throw new IllegalArgumentException("Unknown process output type " + outputType);
+ }
+ }
+
+ public String getTerminalOutput() {
+ return terminalOutputCapturer.getOutput().getStdout();
+ }
+}
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/TerminalSshModule.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/TerminalSshModule.java
new file mode 100644
index 0000000..b957b9a
--- /dev/null
+++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/TerminalSshModule.java
@@ -0,0 +1,164 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.idea.svn.commandLine;
+
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Key;
+import com.intellij.openapi.util.Ref;
+import com.intellij.util.WaitForProgressToShow;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.idea.svn.SvnBundle;
+import org.jetbrains.idea.svn.dialogs.ServerSSHDialog;
+import org.jetbrains.idea.svn.dialogs.SimpleCredentialsDialog;
+import org.tmatesoft.svn.core.SVNURL;
+import org.tmatesoft.svn.core.auth.ISVNAuthenticationProvider;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author Konstantin Kolosovsky.
+ */
+public class TerminalSshModule extends LineCommandAdapter implements CommandRuntimeModule, InteractiveCommandListener {
+
+ private static final Logger LOG = Logger.getInstance(TerminalSshModule.class);
+
+ private static final Pattern PASSPHRASE_PROMPT = Pattern.compile("Enter passphrase for key \\'(.*)\\':\\s?");
+ private static final Pattern PASSWORD_PROMPT = Pattern.compile("(.*)\\'s password:\\s?");
+
+ private static final Pattern UNKNOWN_HOST_MESSAGE =
+ Pattern.compile("The authenticity of host \\'((.*) \\((.*)\\))\\' can\\'t be established\\.\\s?");
+ private static final Pattern HOST_FINGERPRINT_MESSAGE = Pattern.compile("(\\w+) key fingerprint is (.*)\\.\\s?");
+ private static final Pattern ACCEPT_HOST_PROMPT = Pattern.compile("Are you sure you want to continue connecting \\(yes/no\\)\\?\\s?");
+
+ @NotNull private final CommandRuntime myRuntime;
+ @NotNull private final CommandExecutor myExecutor;
+
+ private String unknownHost;
+ private String fingerprintAlgorithm;
+ private String hostFingerprint;
+
+ // TODO: Do not accept executor here and make it as command runtime module
+ public TerminalSshModule(@NotNull CommandRuntime runtime, @NotNull CommandExecutor executor) {
+ myExecutor = executor;
+ myRuntime = runtime;
+ }
+
+ @Override
+ public void onStart(@NotNull Command command) throws SvnBindException {
+ }
+
+ @Override
+ public boolean handlePrompt(String line, Key outputType) {
+ return checkPassphrase(line) || checkPassword(line) || checkUnknownHost(line);
+ }
+
+ private boolean checkPassphrase(@NotNull String line) {
+ Matcher matcher = PASSPHRASE_PROMPT.matcher(line);
+
+ return matcher.matches() && handleAuthPrompt(SimpleCredentialsDialog.Mode.SSH_PASSPHRASE, matcher.group(1));
+ }
+
+ private boolean checkPassword(@NotNull String line) {
+ Matcher matcher = PASSWORD_PROMPT.matcher(line);
+
+ return matcher.matches() && handleAuthPrompt(SimpleCredentialsDialog.Mode.SSH_PASSWORD, matcher.group(1));
+ }
+
+ private boolean checkUnknownHost(@NotNull String line) {
+ Matcher unknownHostMatcher = UNKNOWN_HOST_MESSAGE.matcher(line);
+ Matcher hostFingerPrintMatcher = HOST_FINGERPRINT_MESSAGE.matcher(line);
+ Matcher acceptHostMatcher = ACCEPT_HOST_PROMPT.matcher(line);
+
+ if (unknownHostMatcher.matches()) {
+ unknownHost = unknownHostMatcher.group(1);
+ }
+ else if (hostFingerPrintMatcher.matches()) {
+ fingerprintAlgorithm = hostFingerPrintMatcher.group(1);
+ hostFingerprint = hostFingerPrintMatcher.group(2);
+ }
+ else if (acceptHostMatcher.matches()) {
+ handleUnknownHost();
+ }
+
+ return unknownHostMatcher.matches() || hostFingerPrintMatcher.matches() || acceptHostMatcher.matches();
+ }
+
+ private void handleUnknownHost() {
+ final Project project = myRuntime.getVcs().getProject();
+ final Ref<Integer> answer = new Ref<Integer>();
+
+ Runnable command = new Runnable() {
+ @Override
+ public void run() {
+ final ServerSSHDialog dialog = new ServerSSHDialog(project, true, unknownHost, fingerprintAlgorithm, hostFingerprint);
+ dialog.show();
+ answer.set(dialog.getResult());
+ }
+ };
+
+ WaitForProgressToShow.runOrInvokeAndWaitAboveProgress(command);
+
+ unknownHost = null;
+ fingerprintAlgorithm = null;
+ hostFingerprint = null;
+
+ sendAnswer(answer.get() == ISVNAuthenticationProvider.REJECTED ? "no" : "yes");
+ }
+
+ private boolean handleAuthPrompt(@NotNull final SimpleCredentialsDialog.Mode mode, @NotNull final String key) {
+ @NotNull final SVNURL repositoryUrl = myExecutor.getCommand().getRepositoryUrl();
+ final Project project = myRuntime.getVcs().getProject();
+ final Ref<String> answer = new Ref<String>();
+
+ Runnable command = new Runnable() {
+ public void run() {
+ SimpleCredentialsDialog dialog = new SimpleCredentialsDialog(project);
+ dialog.setup(mode, repositoryUrl.toDecodedString(), key, true);
+ dialog.setTitle(SvnBundle.message("dialog.title.authentication.required"));
+ dialog.show();
+ if (dialog.isOK()) {
+ answer.set(dialog.getPassword());
+ }
+ // TODO: Correctly handle "cancel" - kill the process
+ // TODO: and perform "cleanup" on working copy
+ }
+ };
+
+ WaitForProgressToShow.runOrInvokeAndWaitAboveProgress(command);
+
+ if (!answer.isNull()) {
+ sendAnswer(answer.get());
+ } else {
+ myExecutor.destroyProcess("Authentication canceled for repository: " + repositoryUrl);
+ }
+
+ return !answer.isNull();
+ }
+
+ private boolean sendAnswer(@NotNull String answer) {
+ try {
+ myExecutor.write(answer + "\n");
+ return true;
+ }
+ catch (SvnBindException e) {
+ // TODO: handle this more carefully
+ LOG.info(e);
+ }
+ return false;
+ }
+}
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/ServerSSHDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/ServerSSHDialog.java
index 30ef521..54e0265 100644
--- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/ServerSSHDialog.java
+++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/ServerSSHDialog.java
@@ -17,6 +17,7 @@
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
+import com.intellij.openapi.util.text.StringUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.svn.SvnBundle;
@@ -41,12 +42,20 @@
public ServerSSHDialog(Project project, boolean store, @NotNull final String host, @Nullable final String algorithm,
@NotNull final byte[] fingerprints) {
+ this(project, store, host, algorithm, SVNSSLUtil.getFingerprint(fingerprints, "SHA1"));
+ }
+
+ public ServerSSHDialog(Project project,
+ boolean store,
+ @NotNull final String host,
+ @Nullable final String algorithm,
+ @NotNull String fingerprints) {
super(project, true);
myStore = store;
myHost = host;
- myAlgorithm = algorithm == null ? "" : algorithm;
+ myAlgorithm = StringUtil.notNullize(algorithm);
// todo ?
- myFingerprints = SVNSSLUtil.getFingerprint(fingerprints, "SHA1");
+ myFingerprints = fingerprints;
myResult = ISVNAuthenticationProvider.REJECTED;
setOKButtonText(SvnBundle.message("button.text.ssh.accept"));
setCancelButtonText(SvnBundle.message("button.text.ssh.reject"));
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SimpleCredentialsDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SimpleCredentialsDialog.java
index 3c11acb..f779c0c 100644
--- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SimpleCredentialsDialog.java
+++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SimpleCredentialsDialog.java
@@ -34,6 +34,7 @@
public class SimpleCredentialsDialog extends DialogWrapper implements DocumentListener {
private boolean myAllowSave;
private String myUserName;
+ private Mode myMode;
private String myRealm;
private JTextField myUserNameText;
@@ -42,18 +43,24 @@
@NonNls private static final String HELP_ID = "vcs.subversion.authentication";
- protected SimpleCredentialsDialog(Project project) {
+ public SimpleCredentialsDialog(Project project) {
super(project, true);
setResizable(false);
}
public void setup(String realm, String userName, boolean allowSave) {
+ setup(Mode.DEFAULT, realm, userName, allowSave);
+ }
+
+ public void setup(Mode mode, String realm, String userName, boolean allowSave) {
+ myMode = mode;
myRealm = realm;
myUserName = userName;
myAllowSave = allowSave;
getHelpAction().setEnabled(true);
init();
}
+
protected void doHelpAction() {
HelpManager.getInstance().invokeHelp(HELP_ID);
}
@@ -89,7 +96,7 @@
gb.weightx = 0;
gb.fill = GridBagConstraints.NONE;
- label = new JLabel(SvnBundle.message("label.auth.user.name"));
+ label = new JLabel(SvnBundle.message(myMode.equals(Mode.SSH_PASSPHRASE) ? "label.ssh.key.file" : "label.auth.user.name"));
panel.add(label, gb);
// user name field
@@ -106,6 +113,7 @@
}
myUserNameText.selectAll();
myUserNameText.getDocument().addDocumentListener(this);
+ myUserNameText.setEnabled(myMode.equals(Mode.DEFAULT));
gb.gridy += 1;
gb.weightx = 0;
@@ -113,7 +121,7 @@
gb.fill = GridBagConstraints.NONE;
gb.gridwidth = 1;
- label = new JLabel(SvnBundle.message("label.auth.password"));
+ label = new JLabel(SvnBundle.message(myMode.equals(Mode.SSH_PASSPHRASE) ? "label.ssh.passphrase" : "label.auth.password"));
panel.add(label, gb);
// passworde field
@@ -152,7 +160,7 @@
}
public JComponent getPreferredFocusedComponent() {
- return myUserNameText;
+ return myUserNameText.isEnabled() ? myUserNameText : myPasswordText;
}
public boolean shouldCloseOnCross() {
@@ -197,4 +205,10 @@
private void updateOKButton() {
getOKAction().setEnabled(isOKActionEnabled());
}
+
+ public enum Mode {
+ SSH_PASSPHRASE,
+ SSH_PASSWORD,
+ DEFAULT
+ }
}
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/ToBeMergedDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/ToBeMergedDialog.java
index 620bc38..19a8832 100644
--- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/ToBeMergedDialog.java
+++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/ToBeMergedDialog.java
@@ -296,7 +296,7 @@
myRevisionsList.setShowGrid(false);
final AbstractBaseTagMouseListener mouseListener = new AbstractBaseTagMouseListener() {
@Override
- protected Object getTagAt(MouseEvent e) {
+ public Object getTagAt(MouseEvent e) {
Object tag = null;
JTable table = (JTable)e.getSource();
int row = table.rowAtPoint(e.getPoint());
diff --git a/plugins/svn4idea/svn4idea.iml b/plugins/svn4idea/svn4idea.iml
index 53dd661..1765d1a 100644
--- a/plugins/svn4idea/svn4idea.iml
+++ b/plugins/svn4idea/svn4idea.iml
@@ -76,6 +76,9 @@
</SOURCES>
</library>
</orderEntry>
+ <orderEntry type="library" name="jna" level="project" />
+ <orderEntry type="library" name="pty4j" level="project" />
+ <orderEntry type="library" name="purejavacomm" level="project" />
</component>
</module>
diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/youtrack/YouTrackIntellisense.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/youtrack/YouTrackIntellisense.java
index 3b2eaf0..609a8d7 100644
--- a/plugins/tasks/tasks-core/src/com/intellij/tasks/youtrack/YouTrackIntellisense.java
+++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/youtrack/YouTrackIntellisense.java
@@ -56,7 +56,7 @@
private final int myMaxSize;
private SizeLimitedCache(int max) {
- super((int)(max / 0.75) + 1);
+ super((int)(max / 0.75) + 1, true);
myMaxSize = max;
}
diff --git a/plugins/terminal/lib/jediterm-pty-0.08.jar b/plugins/terminal/lib/jediterm-pty-0.08.jar
deleted file mode 100644
index a801f88..0000000
--- a/plugins/terminal/lib/jediterm-pty-0.08.jar
+++ /dev/null
Binary files differ
diff --git a/plugins/terminal/lib/jediterm-pty-1.0.jar b/plugins/terminal/lib/jediterm-pty-1.0.jar
new file mode 100644
index 0000000..bb04f22
--- /dev/null
+++ b/plugins/terminal/lib/jediterm-pty-1.0.jar
Binary files differ
diff --git a/plugins/terminal/lib/readme.txt b/plugins/terminal/lib/jediterm.txt
similarity index 100%
rename from plugins/terminal/lib/readme.txt
rename to plugins/terminal/lib/jediterm.txt
diff --git a/plugins/terminal/resources/META-INF/terminal.xml b/plugins/terminal/resources/META-INF/terminal.xml
index 36500b8..ed2a2b5 100644
--- a/plugins/terminal/resources/META-INF/terminal.xml
+++ b/plugins/terminal/resources/META-INF/terminal.xml
@@ -12,6 +12,8 @@
factoryClass="org.jetbrains.plugins.terminal.TerminalToolWindowFactory" secondary="false"/>
<projectConfigurable instance="org.jetbrains.plugins.terminal.TerminalOptionsConfigurable"/>
+
+ <fileEditorProvider implementation="org.jetbrains.plugins.terminal.vfs.TerminalSessionEditorProvider"/>
</extensions>
<project-components>
diff --git a/plugins/terminal/src/org/jetbrains/plugins/terminal/AbstractTerminalRunner.java b/plugins/terminal/src/org/jetbrains/plugins/terminal/AbstractTerminalRunner.java
index 5a3b607..121958b 100644
--- a/plugins/terminal/src/org/jetbrains/plugins/terminal/AbstractTerminalRunner.java
+++ b/plugins/terminal/src/org/jetbrains/plugins/terminal/AbstractTerminalRunner.java
@@ -7,6 +7,7 @@
import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.execution.ui.actions.CloseAction;
+import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProgressIndicator;
@@ -82,15 +83,16 @@
protected abstract ProcessHandler createProcessHandler(T process);
- public JBTabbedTerminalWidget createTerminalWidget() {
+ @NotNull
+ public JBTabbedTerminalWidget createTerminalWidget(@NotNull Disposable parent) {
final JBTerminalSystemSettingsProvider provider = new JBTerminalSystemSettingsProvider();
- JBTabbedTerminalWidget terminalWidget = new JBTabbedTerminalWidget(provider, new Predicate<TerminalWidget>() {
+ JBTabbedTerminalWidget terminalWidget = new JBTabbedTerminalWidget(myProject, provider, new Predicate<TerminalWidget>() {
@Override
public boolean apply(TerminalWidget widget) {
openSession(widget);
return true;
}
- });
+ }, parent);
openSession(terminalWidget);
return terminalWidget;
}
@@ -100,21 +102,12 @@
final DefaultActionGroup toolbarActions = new DefaultActionGroup();
final ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, toolbarActions, false);
- final JBTerminalSystemSettingsProvider provider = new JBTerminalSystemSettingsProvider();
- TerminalWidget widget = new JBTabbedTerminalWidget(provider, new Predicate<TerminalWidget>() {
- @Override
- public boolean apply(TerminalWidget widget) {
- openSession(widget);
- return true;
- }
- });
-
- openSession(widget, createTtyConnector(process));
+
final JPanel panel = new JPanel(new BorderLayout());
panel.add(actionToolbar.getComponent(), BorderLayout.WEST);
- panel.add(widget.getComponent(), BorderLayout.CENTER);
+
actionToolbar.setTargetComponent(panel);
@@ -127,6 +120,19 @@
toolbarActions.add(createCloseAction(defaultExecutor, contentDescriptor));
+ final JBTerminalSystemSettingsProvider provider = new JBTerminalSystemSettingsProvider();
+ TerminalWidget widget = new JBTabbedTerminalWidget(myProject, provider, new Predicate<TerminalWidget>() {
+ @Override
+ public boolean apply(TerminalWidget widget) {
+ openSession(widget);
+ return true;
+ }
+ }, contentDescriptor);
+
+ openSession(widget, createTtyConnector(process));
+
+ panel.add(widget.getComponent(), BorderLayout.CENTER);
+
showConsole(defaultExecutor, contentDescriptor, widget.getComponent());
processHandler.startNotify();
diff --git a/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTabbedTerminalWidget.java b/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTabbedTerminalWidget.java
index d46e858..f714c38 100644
--- a/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTabbedTerminalWidget.java
+++ b/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTabbedTerminalWidget.java
@@ -1,34 +1,60 @@
package org.jetbrains.plugins.terminal;
import com.google.common.base.Predicate;
+import com.intellij.openapi.Disposable;
+import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.actionSystem.Presentation;
+import com.intellij.openapi.fileEditor.impl.EditorTabbedContainer;
+import com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl;
import com.intellij.openapi.project.DumbAwareAction;
-import com.jediterm.terminal.ui.JediTermWidget;
-import com.jediterm.terminal.ui.TabbedTerminalWidget;
-import com.jediterm.terminal.ui.TerminalAction;
-import com.jediterm.terminal.ui.TerminalWidget;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Disposer;
+import com.intellij.openapi.wm.IdeFocusManager;
+import com.intellij.ui.SimpleColoredComponent;
+import com.intellij.ui.components.JBTextField;
+import com.intellij.ui.docking.DockManager;
+import com.intellij.ui.docking.DragSession;
+import com.intellij.ui.tabs.TabInfo;
+import com.intellij.ui.tabs.TabsListener;
+import com.intellij.ui.tabs.impl.JBEditorTabs;
+import com.intellij.ui.tabs.impl.JBTabsImpl;
+import com.intellij.ui.tabs.impl.TabLabel;
+import com.jediterm.terminal.ui.*;
import com.jediterm.terminal.ui.settings.SettingsProvider;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.terminal.vfs.TerminalSessionVirtualFileImpl;
import javax.swing.*;
-import java.awt.event.KeyEvent;
+import java.awt.*;
+import java.awt.event.*;
import java.util.List;
+import java.util.concurrent.CopyOnWriteArraySet;
/**
* @author traff
*/
-public class JBTabbedTerminalWidget extends TabbedTerminalWidget {
+public class JBTabbedTerminalWidget extends TabbedTerminalWidget implements Disposable{
+ private Project myProject;
private final JBTerminalSystemSettingsProvider mySettingsProvider;
+ private Disposable myParent;
- public JBTabbedTerminalWidget(@NotNull JBTerminalSystemSettingsProvider settingsProvider, @NotNull Predicate<TerminalWidget> createNewSessionAction) {
+ public JBTabbedTerminalWidget(@NotNull Project project,
+ @NotNull JBTerminalSystemSettingsProvider settingsProvider,
+ @NotNull Predicate<TerminalWidget> createNewSessionAction, @NotNull Disposable parent) {
super(settingsProvider, createNewSessionAction);
-
+ myProject = project;
+
mySettingsProvider = settingsProvider;
+ myParent = parent;
convertActions(this, getActions());
+
+ Disposer.register(parent, this);
+ Disposer.register(this, settingsProvider);
}
public static void convertActions(@NotNull JComponent component,
@@ -57,6 +83,300 @@
@Override
protected JediTermWidget createInnerTerminalWidget(SettingsProvider settingsProvider) {
- return new JBTerminalWidget(mySettingsProvider);
+ return new JBTerminalWidget(mySettingsProvider, myParent);
+ }
+
+ @Override
+ protected TerminalTabs createTabbedPane() {
+ return new JBTerminalTabs(myProject, myParent);
+ }
+
+ public class JBTerminalTabs implements TerminalTabs {
+ private final JBEditorTabs myTabs;
+
+ private TabInfo.DragOutDelegate myDragDelegate = new MyDragOutDelegate();
+
+ private final CopyOnWriteArraySet<TabChangeListener> myListeners = new CopyOnWriteArraySet<TabChangeListener>();
+
+ public JBTerminalTabs(@NotNull Project project, @NotNull Disposable parent) {
+ final ActionManager actionManager = ActionManager.getInstance();
+ myTabs = new JBEditorTabs(project, actionManager, IdeFocusManager.getInstance(project), parent) {
+ @Override
+ protected TabLabel createTabLabel(TabInfo info) {
+ return new TerminalTabLabel(this, info);
+ }
+ };
+
+ myTabs.addListener(new TabsListener.Adapter() {
+ @Override
+ public void selectionChanged(TabInfo oldSelection, TabInfo newSelection) {
+ for (TabChangeListener each : myListeners) {
+ each.selectionChanged();
+ }
+ }
+
+ @Override
+ public void tabRemoved(TabInfo tabInfo) {
+ for (TabChangeListener each : myListeners) {
+ each.tabRemoved();
+ }
+ }
+ });
+
+ myTabs.setTabDraggingEnabled(true);
+ }
+
+ @Override
+ public int getSelectedIndex() {
+ return myTabs.getIndexOf(myTabs.getSelectedInfo());
+ }
+
+ @Override
+ public void setSelectedIndex(int index) {
+ myTabs.select(myTabs.getTabAt(index), true);
+ }
+
+ @Override
+ public void setTabComponentAt(int index, Component component) {
+ //nop
+ }
+
+ @Override
+ public int indexOfTabComponent(Component component) {
+ return 0; //nop
+ }
+
+
+ private TabInfo getTabAt(int index) {
+ checkIndex(index);
+ return myTabs.getTabAt(index);
+ }
+
+ private void checkIndex(int index) {
+ if (index < 0 || index >= getTabCount()) {
+ throw new ArrayIndexOutOfBoundsException("tabCount=" + getTabCount() + " index=" + index);
+ }
+ }
+
+
+ @Override
+ public JediTermWidget getComponentAt(int i) {
+ return (JediTermWidget)getTabAt(i).getComponent();
+ }
+
+ @Override
+ public void addChangeListener(TabChangeListener listener) {
+ myListeners.add(listener);
+ }
+
+ @Override
+ public void setTitleAt(int index, String title) {
+ getTabAt(index).setText(title);
+ }
+
+ @Override
+ public void setSelectedComponent(JediTermWidget terminal) {
+ TabInfo info = myTabs.findInfo(terminal);
+ if (info != null) {
+ myTabs.select(info, true);
+ }
+ }
+
+ @Override
+ public JComponent getComponent() {
+ return myTabs.getComponent();
+ }
+
+ @Override
+ public int getTabCount() {
+ return myTabs.getTabCount();
+ }
+
+ @Override
+ public void addTab(String name, JediTermWidget terminal) {
+ myTabs.addTab(createTabInfo(name, terminal));
+ }
+
+ private TabInfo createTabInfo(String name, JediTermWidget terminal) {
+ TabInfo tabInfo = new TabInfo(terminal).setText(name).setDragOutDelegate(myDragDelegate);
+ return tabInfo
+ .setObject(new TerminalSessionVirtualFileImpl(tabInfo, terminal, mySettingsProvider));
+ }
+
+ public String getTitleAt(int i) {
+ return getTabAt(i).getText();
+ }
+
+ public void removeAll() {
+ myTabs.removeAllTabs();
+ }
+
+ @Override
+ public void remove(JediTermWidget terminal) {
+ TabInfo info = myTabs.findInfo(terminal);
+ if (info != null) {
+ myTabs.removeTab(info);
+ }
+ }
+
+ private class TerminalTabLabel extends TabLabel {
+ public TerminalTabLabel(final JBTabsImpl tabs, TabInfo info) {
+ super(tabs, info);
+
+ setOpaque(false);
+
+ setFocusable(false);
+
+ SimpleColoredComponent label = myLabel;
+
+ //add more space between the label and the button
+ label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
+
+ label.addMouseListener(new MouseAdapter() {
+
+ @Override
+ public void mouseReleased(MouseEvent event) {
+ handleMouse(event);
+ }
+
+ @Override
+ public void mousePressed(MouseEvent event) {
+ handleMouse(event);
+ }
+
+ private void handleMouse(MouseEvent event) {
+ if (event.isPopupTrigger()) {
+ JPopupMenu menu = createPopup();
+ menu.show(event.getComponent(), event.getX(), event.getY());
+ }
+ else {
+ myTabs.select(getInfo(), true);
+
+ if (event.getClickCount() == 2 && !event.isConsumed()) {
+ event.consume();
+ renameTab();
+ }
+ }
+ }
+ });
+ }
+
+ protected JPopupMenu createPopup() {
+ JPopupMenu popupMenu = new JPopupMenu();
+
+ TerminalAction.addToMenu(popupMenu, JBTabbedTerminalWidget.this);
+
+ JMenuItem rename = new JMenuItem("Rename Tab");
+
+ rename.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent actionEvent) {
+ renameTab();
+ }
+ });
+
+ popupMenu.add(rename);
+
+ return popupMenu;
+ }
+
+ private void renameTab() {
+ new TabRenamer() {
+ @Override
+ protected JTextField createTextField() {
+ JBTextField textField = new JBTextField() {
+ private int myMinimalWidth;
+
+ @Override
+ public Dimension getPreferredSize() {
+ Dimension size = super.getPreferredSize();
+ if (size.width > myMinimalWidth) {
+ myMinimalWidth = size.width;
+ }
+
+ return wider(size, myMinimalWidth);
+ }
+
+ private Dimension wider(Dimension size, int minimalWidth) {
+ return new Dimension(minimalWidth + 10, size.height);
+ }
+ };
+ textField.setOpaque(true);
+ return textField;
+ }
+ }.install(getSelectedIndex(), getInfo().getText(), myLabel, new TabRenamer.RenameCallBack() {
+ @Override
+ public void setComponent(Component c) {
+ myTabs.setTabDraggingEnabled(!(c instanceof JBTextField));
+
+ setPlaceholderContent(true, (JComponent)c);
+ }
+
+ @Override
+ public void setNewName(int index, String name) {
+ setTitleAt(index, name);
+ }
+ });
+ }
+ }
+
+ class MyDragOutDelegate implements TabInfo.DragOutDelegate {
+
+ private TerminalSessionVirtualFileImpl myFile;
+ private DragSession mySession;
+
+ @Override
+ public void dragOutStarted(MouseEvent mouseEvent, TabInfo info) {
+ final TabInfo previousSelection = info.getPreviousSelection();
+ final Image img = JBTabsImpl.getComponentImage(info);
+ info.setHidden(true);
+ if (previousSelection != null) {
+ myTabs.select(previousSelection, true);
+ }
+
+ myFile = (TerminalSessionVirtualFileImpl)info.getObject();
+ Presentation presentation = new Presentation(info.getText());
+ presentation.setIcon(info.getIcon());
+ mySession = getDockManager()
+ .createDragSession(mouseEvent, new EditorTabbedContainer.DockableEditor(myProject, img, myFile, presentation,
+ info.getComponent().getPreferredSize(), false));
+ }
+
+ private DockManager getDockManager() {
+ return DockManager.getInstance(myProject);
+ }
+
+ @Override
+ public void processDragOut(MouseEvent event, TabInfo source) {
+ mySession.process(event);
+ }
+
+ @Override
+ public void dragOutFinished(MouseEvent event, TabInfo source) {
+ myFile.putUserData(FileEditorManagerImpl.CLOSING_TO_REOPEN, Boolean.TRUE);
+
+
+ myTabs.removeTab(source);
+
+ mySession.process(event);
+
+ myFile.putUserData(FileEditorManagerImpl.CLOSING_TO_REOPEN, null);
+
+
+ myFile = null;
+ mySession = null;
+ }
+
+ @Override
+ public void dragOutCancelled(TabInfo source) {
+ source.setHidden(false);
+ if (mySession != null) {
+ mySession.cancel();
+ }
+
+ myFile = null;
+ mySession = null;
+ }
+ }
}
}
diff --git a/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalPanel.java b/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalPanel.java
index 1ae988d..767df1e 100644
--- a/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalPanel.java
+++ b/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalPanel.java
@@ -22,6 +22,7 @@
import com.google.common.base.Predicate;
import com.intellij.ide.GeneralSettings;
import com.intellij.ide.ui.UISettings;
+import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.editor.impl.ComplementaryFontsRegistry;
import com.intellij.openapi.editor.impl.FontInfo;
@@ -52,7 +53,7 @@
import java.awt.image.ImageObserver;
import java.io.IOException;
-public class JBTerminalPanel extends TerminalPanel implements FocusListener {
+public class JBTerminalPanel extends TerminalPanel implements FocusListener, TerminalSettingsListener, Disposable {
private final JBTerminalSystemSettingsProvider mySettingsProvider;
public JBTerminalPanel(@NotNull JBTerminalSystemSettingsProvider settingsProvider,
@@ -73,6 +74,8 @@
registerKeymapActions(this);
addFocusListener(this);
+
+ mySettingsProvider.addListener(this);
}
private static void registerKeymapActions(final TerminalPanel terminalPanel) {
@@ -200,5 +203,15 @@
public FontInfo fontForChar(final char c, @JdkConstants.FontStyle int style) {
return ComplementaryFontsRegistry.getFontAbleToDisplay(c, style, mySettingsProvider.getColorScheme().getConsoleFontPreferences());
}
+
+ @Override
+ public void fontChanged() {
+ reinitFontAndResize();
+ }
+
+ @Override
+ public void dispose() {
+ mySettingsProvider.removeListener(this);
+ }
}
diff --git a/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalSystemSettingsProvider.java b/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalSystemSettingsProvider.java
index f2fe5dd..4adeb3c 100644
--- a/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalSystemSettingsProvider.java
+++ b/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalSystemSettingsProvider.java
@@ -1,8 +1,10 @@
package org.jetbrains.plugins.terminal;
-import com.intellij.application.options.OptionsConstants;
+import com.google.common.collect.Sets;
import com.intellij.execution.ui.ConsoleViewContentType;
import com.intellij.ide.ui.UISettings;
+import com.intellij.ide.ui.UISettingsListener;
+import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.KeyboardShortcut;
import com.intellij.openapi.actionSystem.Shortcut;
import com.intellij.openapi.editor.colors.*;
@@ -25,20 +27,37 @@
import javax.swing.*;
import java.awt.*;
-import java.util.ArrayList;
-import java.util.EnumMap;
+import java.util.*;
import java.util.List;
-import java.util.Map;
/**
* @author traff
*/
-class JBTerminalSystemSettingsProvider extends DefaultTabbedSettingsProvider {
-
- private final EditorColorsScheme myColorScheme;
+class JBTerminalSystemSettingsProvider extends DefaultTabbedSettingsProvider implements Disposable {
+ private Set<TerminalSettingsListener> myListeners = Sets.newHashSet();
+
+ private final MyColorSchemeDelegate myColorScheme;
JBTerminalSystemSettingsProvider() {
myColorScheme = createBoundColorSchemeDelegate(null);
+
+ UISettings.getInstance().addUISettingsListener(new UISettingsListener() {
+ @Override
+ public void uiSettingsChanged(UISettings source) {
+ int size;
+ if (UISettings.getInstance().PRESENTATION_MODE) {
+ size = UISettings.getInstance().PRESENTATION_MODE_FONT_SIZE;
+ }
+ else {
+ size = myColorScheme.getGlobal().getConsoleFontSize();
+ }
+
+ if (myColorScheme.getConsoleFontSize() != size) {
+ myColorScheme.setConsoleFontSize(size);
+ fireFontChanged();
+ }
+ }
+ }, this);
}
@Override
@@ -52,6 +71,16 @@
}
@Override
+ public KeyStroke[] getNextTabKeyStrokes() {
+ return getKeyStrokesByActionId("NextTab");
+ }
+
+ @Override
+ public KeyStroke[] getPreviousTabKeyStrokes() {
+ return getKeyStrokesByActionId("PreviousTab");
+ }
+
+ @Override
public ColorPalette getTerminalColorPalette() {
return new JBTerminalSchemeColorPalette(myColorScheme);
}
@@ -181,10 +210,15 @@
}
@NotNull
- public EditorColorsScheme createBoundColorSchemeDelegate(@Nullable final EditorColorsScheme customGlobalScheme) {
+ private static MyColorSchemeDelegate createBoundColorSchemeDelegate(@Nullable final EditorColorsScheme customGlobalScheme) {
return new MyColorSchemeDelegate(customGlobalScheme);
}
+ @Override
+ public void dispose() {
+
+ }
+
private static class MyColorSchemeDelegate implements EditorColorsScheme {
private final FontPreferences myFontPreferences = new FontPreferences();
@@ -192,14 +226,15 @@
private final HashMap<ColorKey, Color> myOwnColors = new HashMap<ColorKey, Color>();
private final EditorColorsScheme myCustomGlobalScheme;
private Map<EditorFontType, Font> myFontsMap = null;
- private int myMaxFontSize = OptionsConstants.MAX_EDITOR_FONT_SIZE;
- private int myFontSize = -1;
private String myFaceName = null;
private EditorColorsScheme myGlobalScheme;
+ private int myConsoleFontSize = -1;
+
private MyColorSchemeDelegate(@Nullable final EditorColorsScheme globalScheme) {
myCustomGlobalScheme = globalScheme;
updateGlobalScheme();
+ initFonts();
}
private EditorColorsScheme getGlobal() {
@@ -213,17 +248,17 @@
protected void initFonts() {
- String editorFontName = getEditorFontName();
- int editorFontSize = getEditorFontSize();
+ String consoleFontName = getConsoleFontName();
+ int consoleFontSize = getConsoleFontSize();
myFontPreferences.clear();
- myFontPreferences.register(editorFontName, editorFontSize);
+ myFontPreferences.register(consoleFontName, consoleFontSize);
myFontsMap = new EnumMap<EditorFontType, Font>(EditorFontType.class);
- Font plainFont = new Font(editorFontName, Font.PLAIN, editorFontSize);
- Font boldFont = new Font(editorFontName, Font.BOLD, editorFontSize);
- Font italicFont = new Font(editorFontName, Font.ITALIC, editorFontSize);
- Font boldItalicFont = new Font(editorFontName, Font.BOLD | Font.ITALIC, editorFontSize);
+ Font plainFont = new Font(consoleFontName, Font.PLAIN, consoleFontSize);
+ Font boldFont = new Font(consoleFontName, Font.BOLD, consoleFontSize);
+ Font italicFont = new Font(consoleFontName, Font.ITALIC, consoleFontSize);
+ Font boldItalicFont = new Font(consoleFontName, Font.BOLD | Font.ITALIC, consoleFontSize);
myFontsMap.put(EditorFontType.PLAIN, plainFont);
myFontsMap.put(EditorFontType.BOLD, boldFont);
@@ -274,29 +309,22 @@
@NotNull
@Override
public FontPreferences getFontPreferences() {
- return myFontPreferences;
+ return myGlobalScheme.getFontPreferences();
}
@Override
public void setFontPreferences(@NotNull FontPreferences preferences) {
- preferences.copyTo(myFontPreferences);
- initFonts();
+ throw new IllegalStateException();
}
@Override
public int getEditorFontSize() {
- if (myFontSize == -1) {
- return getGlobal().getEditorFontSize();
- }
- return myFontSize;
+ return getGlobal().getEditorFontSize();
}
@Override
public void setEditorFontSize(int fontSize) {
- if (fontSize < 8) fontSize = 8;
- if (fontSize > myMaxFontSize) fontSize = myMaxFontSize;
- myFontSize = fontSize;
- initFonts();
+
}
@Override
@@ -311,16 +339,12 @@
@Override
public String getEditorFontName() {
- if (myFaceName == null) {
- return getGlobal().getEditorFontName();
- }
- return myFaceName;
+ return getGlobal().getEditorFontName();
}
@Override
public void setEditorFontName(String fontName) {
- myFaceName = fontName;
- initFonts();
+ throw new IllegalStateException();
}
@Override
@@ -366,39 +390,50 @@
public void updateGlobalScheme() {
myGlobalScheme = myCustomGlobalScheme == null ? EditorColorsManager.getInstance().getGlobalScheme() : myCustomGlobalScheme;
- int globalFontSize = getGlobal().getEditorFontSize();
- myMaxFontSize = Math.max(OptionsConstants.MAX_EDITOR_FONT_SIZE, globalFontSize);
}
@NotNull
@Override
public FontPreferences getConsoleFontPreferences() {
- return getGlobal().getConsoleFontPreferences();
+ return myFontPreferences;
}
@Override
public void setConsoleFontPreferences(@NotNull FontPreferences preferences) {
- getGlobal().setConsoleFontPreferences(preferences);
+ preferences.copyTo(myFontPreferences);
+ initFonts();
}
@Override
public String getConsoleFontName() {
- return getGlobal().getConsoleFontName();
+ if (myFaceName == null) {
+ return getGlobal().getConsoleFontName();
+ }
+ else {
+ return myFaceName;
+ }
}
@Override
public void setConsoleFontName(String fontName) {
- getGlobal().setConsoleFontName(fontName);
+ myFaceName = fontName;
+ initFonts();
}
@Override
public int getConsoleFontSize() {
- return getGlobal().getConsoleFontSize();
+ if (myConsoleFontSize == -1) {
+ return getGlobal().getConsoleFontSize();
+ }
+ else {
+ return myConsoleFontSize;
+ }
}
@Override
public void setConsoleFontSize(int fontSize) {
- getGlobal().setConsoleFontSize(fontSize);
+ myConsoleFontSize = fontSize;
+ initFonts();
}
@Override
@@ -411,4 +446,18 @@
getGlobal().setConsoleLineSpacing(lineSpacing);
}
}
+
+ public void addListener(TerminalSettingsListener listener) {
+ myListeners.add(listener);
+ }
+
+ public void removeListener(TerminalSettingsListener listener) {
+ myListeners.remove(listener);
+ }
+
+ public void fireFontChanged() {
+ for (TerminalSettingsListener l : myListeners) {
+ l.fontChanged();
+ }
+ }
}
diff --git a/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalWidget.java b/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalWidget.java
index 3150cc9..79d8bfe 100644
--- a/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalWidget.java
+++ b/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalWidget.java
@@ -1,5 +1,7 @@
package org.jetbrains.plugins.terminal;
+import com.intellij.openapi.Disposable;
+import com.intellij.openapi.util.Disposer;
import com.intellij.ui.components.JBScrollBar;
import com.jediterm.terminal.TerminalStarter;
import com.jediterm.terminal.TtyConnector;
@@ -12,19 +14,23 @@
import javax.swing.*;
-public class JBTerminalWidget extends JediTermWidget {
+public class JBTerminalWidget extends JediTermWidget implements Disposable{
- public JBTerminalWidget(JBTerminalSystemSettingsProvider settingsProvider) {
+ public JBTerminalWidget(JBTerminalSystemSettingsProvider settingsProvider, Disposable parent) {
super(settingsProvider);
JBTabbedTerminalWidget.convertActions(this, getActions());
+
+ Disposer.register(parent, this);
}
@Override
protected JBTerminalPanel createTerminalPanel(@NotNull SettingsProvider settingsProvider,
@NotNull StyleState styleState,
@NotNull BackBuffer backBuffer) {
- return new JBTerminalPanel((JBTerminalSystemSettingsProvider)settingsProvider, backBuffer, styleState);
+ JBTerminalPanel panel = new JBTerminalPanel((JBTerminalSystemSettingsProvider)settingsProvider, backBuffer, styleState);
+ Disposer.register(this, panel);
+ return panel;
}
@Override
@@ -36,4 +42,8 @@
protected JScrollBar createScrollBar() {
return new JBScrollBar();
}
+
+ @Override
+ public void dispose() {
+ }
}
diff --git a/plugins/terminal/src/org/jetbrains/plugins/terminal/OpenLocalTerminalAction.java b/plugins/terminal/src/org/jetbrains/plugins/terminal/OpenLocalTerminalAction.java
index 3659634..4d93dd9 100644
--- a/plugins/terminal/src/org/jetbrains/plugins/terminal/OpenLocalTerminalAction.java
+++ b/plugins/terminal/src/org/jetbrains/plugins/terminal/OpenLocalTerminalAction.java
@@ -3,14 +3,12 @@
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
-import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowManager;
import icons.TerminalIcons;
-import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.NotNull;
/**
* @author traff
@@ -48,16 +46,8 @@
}, true);
}
- @Nullable
+ @NotNull
public static LocalTerminalDirectRunner createTerminalRunner(Project project) {
- String[] terminalCommand;
- if (SystemInfo.isWindows) {
- terminalCommand = new String[]{"cmd.exe"};
- }
- else {
- terminalCommand = new String[]{"/bin/bash", "--login"};
- }
-
return new LocalTerminalDirectRunner(project);
}
}
diff --git a/plugins/terminal/src/org/jetbrains/plugins/terminal/TerminalSettingsListener.java b/plugins/terminal/src/org/jetbrains/plugins/terminal/TerminalSettingsListener.java
new file mode 100644
index 0000000..7569880
--- /dev/null
+++ b/plugins/terminal/src/org/jetbrains/plugins/terminal/TerminalSettingsListener.java
@@ -0,0 +1,8 @@
+package org.jetbrains.plugins.terminal;
+
+/**
+ * @author traff
+ */
+public interface TerminalSettingsListener {
+ void fontChanged();
+}
diff --git a/plugins/terminal/src/org/jetbrains/plugins/terminal/TerminalView.java b/plugins/terminal/src/org/jetbrains/plugins/terminal/TerminalView.java
index c3f49f9..14b992a 100644
--- a/plugins/terminal/src/org/jetbrains/plugins/terminal/TerminalView.java
+++ b/plugins/terminal/src/org/jetbrains/plugins/terminal/TerminalView.java
@@ -4,7 +4,6 @@
import com.intellij.notification.EventLog;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
-import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.SimpleToolWindowPanel;
@@ -13,8 +12,13 @@
import com.intellij.openapi.wm.ToolWindowManager;
import com.intellij.openapi.wm.ex.ToolWindowManagerEx;
import com.intellij.openapi.wm.ex.ToolWindowManagerListener;
+import com.intellij.ui.awt.RelativePoint;
+import com.intellij.ui.awt.RelativeRectangle;
import com.intellij.ui.content.Content;
import com.intellij.ui.content.ContentFactory;
+import com.intellij.ui.docking.DockContainer;
+import com.intellij.ui.docking.DockManager;
+import com.intellij.ui.docking.DockableContent;
import com.intellij.util.ui.UIUtil;
import com.jediterm.terminal.ui.JediTermWidget;
import com.jediterm.terminal.ui.TabbedTerminalWidget;
@@ -22,6 +26,7 @@
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.terminal.vfs.TerminalSessionVirtualFileImpl;
import javax.swing.*;
import java.awt.*;
@@ -37,6 +42,8 @@
private final Project myProject;
+ private TerminalDockContainer myDockContainer;
+
public TerminalView(Project project) {
myProject = project;
}
@@ -52,22 +59,7 @@
toolWindow.setToHideOnEmptyContent(true);
if (terminalRunner != null) {
- myTerminalWidget = terminalRunner.createTerminalWidget();
- myTerminalWidget.addTabListener(new TabbedTerminalWidget.TabListener() {
- @Override
- public void tabClosed(JediTermWidget terminal) {
- UIUtil.invokeLaterIfNeeded(new Runnable() {
- @Override
- public void run() {
- hideIfNoActiveSessions(toolWindow, myTerminalWidget);
- }
- });
- }
- });
- }
-
- if (myTerminalWidget != null) {
- Content content = createToolWindowContentPanel(terminalRunner, myTerminalWidget, toolWindow);
+ Content content = createTerminalInContentPanel(terminalRunner, toolWindow);
toolWindow.getContentManager().addContent(content);
@@ -98,11 +90,17 @@
}
});
}
+
+ if (myDockContainer == null) {
+ myDockContainer = new TerminalDockContainer(toolWindow);
+
+ Disposer.register(myProject, myDockContainer);
+ DockManager.getInstance(myProject).register(myDockContainer);
+ }
}
- private Content createToolWindowContentPanel(@Nullable LocalTerminalDirectRunner terminalRunner,
- @NotNull JBTabbedTerminalWidget terminalWidget,
- @NotNull ToolWindow toolWindow) {
+ private Content createTerminalInContentPanel(@Nullable LocalTerminalDirectRunner terminalRunner,
+ final @NotNull ToolWindow toolWindow) {
SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true) {
@Override
public Object getData(@NonNls String dataId) {
@@ -110,18 +108,34 @@
}
};
- panel.setContent(terminalWidget.getComponent());
+ final Content content = ContentFactory.SERVICE.getInstance().createContent(panel, "", false);
+ content.setCloseable(true);
+
+ myTerminalWidget = terminalRunner.createTerminalWidget(content);
+ myTerminalWidget.addTabListener(new TabbedTerminalWidget.TabListener() {
+ @Override
+ public void tabClosed(JediTermWidget terminal) {
+ UIUtil.invokeLaterIfNeeded(new Runnable() {
+ @Override
+ public void run() {
+ if (myTerminalWidget != null) {
+ hideIfNoActiveSessions(toolWindow, myTerminalWidget);
+ }
+ }
+ });
+ }
+ });
+
+ panel.setContent(myTerminalWidget.getComponent());
panel.addFocusListener(createFocusListener());
- ActionToolbar toolbar = createToolbar(terminalRunner, terminalWidget, toolWindow);
+ ActionToolbar toolbar = createToolbar(terminalRunner, myTerminalWidget, toolWindow);
toolbar.getComponent().addFocusListener(createFocusListener());
toolbar.setTargetComponent(panel);
panel.setToolbar(toolbar.getComponent());
- final Content content = ContentFactory.SERVICE.getInstance().createContent(panel, "", false);
- content.setCloseable(true);
- content.setPreferredFocusableComponent(terminalWidget.getComponent());
+ content.setPreferredFocusableComponent(myTerminalWidget.getComponent());
return content;
}
@@ -152,11 +166,10 @@
openSession(terminal, terminalRunner);
}
- private void openSession(ToolWindow toolWindow, AbstractTerminalRunner terminalRunner) {
+ private void openSession(@NotNull ToolWindow toolWindow, @NotNull AbstractTerminalRunner terminalRunner) {
if (myTerminalWidget == null) {
- myTerminalWidget = terminalRunner.createTerminalWidget();
toolWindow.getContentManager().removeAllContents(true);
- final Content content = createToolWindowContentPanel(null, myTerminalWidget, toolWindow);
+ final Content content = createTerminalInContentPanel(null, toolWindow);
toolWindow.getContentManager().addContent(content);
}
else {
@@ -194,7 +207,7 @@
}, true);
}
- private static void hideIfNoActiveSessions(final ToolWindow toolWindow, JBTabbedTerminalWidget terminal) {
+ private static void hideIfNoActiveSessions(@NotNull final ToolWindow toolWindow, @NotNull JBTabbedTerminalWidget terminal) {
if (terminal.isNoActiveSessions()) {
toolWindow.getContentManager().removeAllContents(true);
}
@@ -234,4 +247,101 @@
hideIfNoActiveSessions(myToolWindow, myTerminal);
}
}
+
+ /**
+ * @author traff
+ */
+ public class TerminalDockContainer implements DockContainer {
+ private ToolWindow myTerminalToolWindow;
+
+ public TerminalDockContainer(ToolWindow toolWindow) {
+ myTerminalToolWindow = toolWindow;
+ }
+
+ @Override
+ public RelativeRectangle getAcceptArea() {
+ return new RelativeRectangle(myTerminalToolWindow.getComponent());
+ }
+
+ @Override
+ public RelativeRectangle getAcceptAreaFallback() {
+ return getAcceptArea();
+ }
+
+ @NotNull
+ @Override
+ public ContentResponse getContentResponse(@NotNull DockableContent content, RelativePoint point) {
+ return isTerminalSessionContent(content) ? ContentResponse.ACCEPT_MOVE : ContentResponse.DENY;
+ }
+
+ @Override
+ public JComponent getContainerComponent() {
+ return myTerminalToolWindow.getComponent();
+ }
+
+ @Override
+ public void add(@NotNull DockableContent content, RelativePoint dropTarget) {
+ if (isTerminalSessionContent(content)) {
+ TerminalSessionVirtualFileImpl terminalFile = (TerminalSessionVirtualFileImpl)content.getKey();
+ myTerminalWidget.addTab(terminalFile.getName(), terminalFile.getTerminal());
+ terminalFile.getTerminal().setNextProvider(myTerminalWidget);
+ }
+ }
+
+ private boolean isTerminalSessionContent(DockableContent content) {
+ return content.getKey() instanceof TerminalSessionVirtualFileImpl;
+ }
+
+ @Override
+ public void closeAll() {
+
+ }
+
+ @Override
+ public void addListener(Listener listener, Disposable parent) {
+
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return false;
+ }
+
+ @Nullable
+ @Override
+ public Image startDropOver(@NotNull DockableContent content, RelativePoint point) {
+ return null;
+ }
+
+ @Nullable
+ @Override
+ public Image processDropOver(@NotNull DockableContent content, RelativePoint point) {
+ return null;
+ }
+
+ @Override
+ public void resetDropOver(@NotNull DockableContent content) {
+
+ }
+
+ @Override
+ public boolean isDisposeWhenEmpty() {
+ return false;
+ }
+
+ @Override
+ public void showNotify() {
+
+ }
+
+ @Override
+ public void hideNotify() {
+
+ }
+
+ @Override
+ public void dispose() {
+
+ }
+ }
}
diff --git a/plugins/terminal/src/org/jetbrains/plugins/terminal/vfs/TerminalSessionEditor.java b/plugins/terminal/src/org/jetbrains/plugins/terminal/vfs/TerminalSessionEditor.java
new file mode 100644
index 0000000..5dc7b62
--- /dev/null
+++ b/plugins/terminal/src/org/jetbrains/plugins/terminal/vfs/TerminalSessionEditor.java
@@ -0,0 +1,181 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.terminal.vfs;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Lists;
+import com.intellij.codeHighlighting.BackgroundEditorHighlighter;
+import com.intellij.ide.structureView.StructureViewBuilder;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.fileEditor.FileEditor;
+import com.intellij.openapi.fileEditor.FileEditorLocation;
+import com.intellij.openapi.fileEditor.FileEditorState;
+import com.intellij.openapi.fileEditor.FileEditorStateLevel;
+import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx;
+import com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.UserDataHolderBase;
+import com.jediterm.terminal.TtyConnectorWaitFor;
+import com.jediterm.terminal.ui.TerminalAction;
+import com.jediterm.terminal.ui.TerminalActionProviderBase;
+import com.jediterm.terminal.ui.settings.TabbedSettingsProvider;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+import java.awt.event.KeyEvent;
+import java.beans.PropertyChangeListener;
+import java.util.List;
+import java.util.concurrent.Executors;
+
+/**
+ * @author traff
+ */
+public class TerminalSessionEditor extends UserDataHolderBase implements FileEditor {
+
+ private Project myProject;
+ private final TerminalSessionVirtualFileImpl myFile;
+ private final TtyConnectorWaitFor myWaitFor;
+
+ public TerminalSessionEditor(Project project, @NotNull TerminalSessionVirtualFileImpl terminalFile) {
+ myProject = project;
+ myFile = terminalFile;
+
+ final TabbedSettingsProvider settings = myFile.getSettingsProvider();
+
+ myFile.getTerminal().setNextProvider(new TerminalActionProviderBase() {
+ @Override
+ public List<TerminalAction> getActions() {
+ return Lists.newArrayList(
+ new TerminalAction("Close Session", settings.getCloseSessionKeyStrokes(), new Predicate<KeyEvent>() {
+ @Override
+ public boolean apply(KeyEvent input) {
+ handleCloseSession();
+ return true;
+ }
+ }).withMnemonicKey(KeyEvent.VK_S)
+ );
+ }
+ });
+
+ myWaitFor = new TtyConnectorWaitFor(myFile.getTerminal().getTtyConnector(), Executors.newSingleThreadExecutor());
+
+ myWaitFor
+ .setTerminationCallback(new Predicate<Integer>() {
+ @Override
+ public boolean apply(Integer integer) {
+ ApplicationManager.getApplication().invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ FileEditorManagerEx.getInstanceEx(myProject).closeFile(myFile);
+ }
+ });
+
+ return true;
+ }
+ });
+ }
+
+ private void handleCloseSession() {
+ myFile.getTerminal().close();
+ }
+
+ @NotNull
+ @Override
+ public JComponent getComponent() {
+ return myFile.getTerminal();
+ }
+
+ @Nullable
+ @Override
+ public JComponent getPreferredFocusedComponent() {
+ return myFile.getTerminal();
+ }
+
+ @NotNull
+ @Override
+ public String getName() {
+ return myFile.getName();
+ }
+
+ @NotNull
+ @Override
+ public FileEditorState getState(@NotNull FileEditorStateLevel level) {
+ return FileEditorState.INSTANCE;
+ }
+
+ @Override
+ public void setState(@NotNull FileEditorState state) {
+
+ }
+
+ @Override
+ public boolean isModified() {
+ return false;
+ }
+
+ @Override
+ public boolean isValid() {
+ return true;
+ }
+
+ @Override
+ public void selectNotify() {
+
+ }
+
+ @Override
+ public void deselectNotify() {
+
+ }
+
+ @Override
+ public void addPropertyChangeListener(@NotNull PropertyChangeListener listener) {
+
+ }
+
+ @Override
+ public void removePropertyChangeListener(@NotNull PropertyChangeListener listener) {
+
+ }
+
+ @Nullable
+ @Override
+ public BackgroundEditorHighlighter getBackgroundHighlighter() {
+ return null;
+ }
+
+ @Nullable
+ @Override
+ public FileEditorLocation getCurrentLocation() {
+ return null;
+ }
+
+ @Nullable
+ @Override
+ public StructureViewBuilder getStructureViewBuilder() {
+ return null;
+ }
+
+ @Override
+ public void dispose() {
+ Boolean closingToReopen = myFile.getUserData(FileEditorManagerImpl.CLOSING_TO_REOPEN);
+ myWaitFor.detach();
+ if (closingToReopen == null || !closingToReopen) {
+ myFile.getTerminal().close();
+ }
+ }
+}
diff --git a/plugins/terminal/src/org/jetbrains/plugins/terminal/vfs/TerminalSessionEditorProvider.java b/plugins/terminal/src/org/jetbrains/plugins/terminal/vfs/TerminalSessionEditorProvider.java
new file mode 100644
index 0000000..cf1fd59
--- /dev/null
+++ b/plugins/terminal/src/org/jetbrains/plugins/terminal/vfs/TerminalSessionEditorProvider.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.terminal.vfs;
+
+import com.intellij.openapi.fileEditor.FileEditor;
+import com.intellij.openapi.fileEditor.FileEditorPolicy;
+import com.intellij.openapi.fileEditor.FileEditorProvider;
+import com.intellij.openapi.fileEditor.FileEditorState;
+import com.intellij.openapi.project.DumbAware;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Disposer;
+import com.intellij.openapi.vfs.VirtualFile;
+import org.jdom.Element;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author traff
+ */
+public class TerminalSessionEditorProvider implements FileEditorProvider, DumbAware {
+ @Override
+ public boolean accept(@NotNull Project project, @NotNull VirtualFile file) {
+ return file instanceof TerminalSessionVirtualFileImpl;
+ }
+
+ @NotNull
+ @Override
+ public FileEditor createEditor(@NotNull Project project, @NotNull VirtualFile file) {
+ return new TerminalSessionEditor(project, (TerminalSessionVirtualFileImpl)file);
+ }
+
+ @Override
+ public void disposeEditor(@NotNull FileEditor editor) {
+ Disposer.dispose(editor);
+ }
+
+ @NotNull
+ @Override
+ public FileEditorState readState(@NotNull Element sourceElement, @NotNull Project project, @NotNull VirtualFile file) {
+ return FileEditorState.INSTANCE;
+ }
+
+ @Override
+ public void writeState(@NotNull FileEditorState state, @NotNull Project project, @NotNull Element targetElement) {
+
+ }
+
+ @NotNull
+ @Override
+ public String getEditorTypeId() {
+ return "terminal-session-editor";
+ }
+
+ @NotNull
+ @Override
+ public FileEditorPolicy getPolicy() {
+ return FileEditorPolicy.HIDE_DEFAULT_EDITOR;
+ }
+}
diff --git a/plugins/terminal/src/org/jetbrains/plugins/terminal/vfs/TerminalSessionFileType.java b/plugins/terminal/src/org/jetbrains/plugins/terminal/vfs/TerminalSessionFileType.java
new file mode 100644
index 0000000..bb545a1
--- /dev/null
+++ b/plugins/terminal/src/org/jetbrains/plugins/terminal/vfs/TerminalSessionFileType.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.terminal.vfs;
+
+import com.intellij.openapi.fileTypes.ex.FakeFileType;
+import com.intellij.openapi.vfs.VirtualFile;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author traff
+ */
+public class TerminalSessionFileType extends FakeFileType {
+
+ public final static TerminalSessionFileType INSTANCE = new TerminalSessionFileType();
+
+ @NotNull
+ public String getName() {
+ return "Terminal Session";
+ }
+
+ @NotNull
+ public String getDescription() {
+ return getName() + " Fake File Type";
+ }
+
+ public boolean isMyFileType(VirtualFile file) {
+ return file instanceof TerminalSessionVirtualFileImpl;
+ }
+}
diff --git a/plugins/terminal/src/org/jetbrains/plugins/terminal/vfs/TerminalSessionVirtualFileImpl.java b/plugins/terminal/src/org/jetbrains/plugins/terminal/vfs/TerminalSessionVirtualFileImpl.java
new file mode 100644
index 0000000..b642f7f
--- /dev/null
+++ b/plugins/terminal/src/org/jetbrains/plugins/terminal/vfs/TerminalSessionVirtualFileImpl.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author cdr
+ */
+package org.jetbrains.plugins.terminal.vfs;
+
+import com.intellij.testFramework.LightVirtualFile;
+import com.intellij.ui.tabs.TabInfo;
+import com.jediterm.terminal.ui.JediTermWidget;
+import com.jediterm.terminal.ui.settings.TabbedSettingsProvider;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author traff
+ */
+public class TerminalSessionVirtualFileImpl extends LightVirtualFile {
+ private final JediTermWidget myTerminal;
+ private TabbedSettingsProvider mySettingsProvider;
+
+ private final TabInfo myTabInfo;
+
+ public TerminalSessionVirtualFileImpl(@NotNull TabInfo tabInfo,
+ @NotNull JediTermWidget terminal,
+ @NotNull TabbedSettingsProvider settingsProvider) {
+ myTabInfo = tabInfo;
+ myTerminal = terminal;
+ mySettingsProvider = settingsProvider;
+ setFileType(TerminalSessionFileType.INSTANCE);
+ setWritable(true);
+ }
+
+ public JediTermWidget getTerminal() {
+ return myTerminal;
+ }
+
+ @NotNull
+ public String getName() {
+ return myTabInfo.getText();
+ }
+
+ public TabbedSettingsProvider getSettingsProvider() {
+ return mySettingsProvider;
+ }
+}
diff --git a/plugins/terminal/src/org/jetbrains/plugins/terminal/vfs/TerminalSessionsVFS.java b/plugins/terminal/src/org/jetbrains/plugins/terminal/vfs/TerminalSessionsVFS.java
new file mode 100644
index 0000000..b1439cc
--- /dev/null
+++ b/plugins/terminal/src/org/jetbrains/plugins/terminal/vfs/TerminalSessionsVFS.java
@@ -0,0 +1,128 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.terminal.vfs;
+
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.project.ProjectManager;
+import com.intellij.openapi.project.ProjectManagerAdapter;
+import com.intellij.openapi.startup.StartupManager;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.openapi.vfs.VirtualFileManager;
+import com.intellij.openapi.vfs.ex.dummy.DummyFileSystem;
+import com.intellij.util.containers.BidirectionalMap;
+import com.intellij.util.containers.HashMap;
+import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * @author traff
+ */
+public class TerminalSessionsVFS extends DummyFileSystem {
+ @NonNls private static final String PROTOCOL = "terminalDummy";
+ @NonNls private static final String PATH_PREFIX = "terminal";
+ @NonNls private static final String PROTOCOL_SEPARATOR = ":/";
+
+ private final BidirectionalMap<Project, String> myProject2Id = new BidirectionalMap<Project, String>();
+ private final Map<String, VirtualFile> myCachedFiles = new HashMap<String, VirtualFile>();
+
+ private ProjectManagerAdapter myProjectManagerListener;
+
+ public static TerminalSessionsVFS getTerminalSessionVFS() {
+ return (TerminalSessionsVFS)VirtualFileManager.getInstance().getFileSystem(PROTOCOL);
+ }
+
+ @Override
+ @Nullable
+ public VirtualFile createRoot(String name) {
+ return null;
+ }
+
+ public void initListener() {
+ if (myProjectManagerListener == null || ApplicationManager.getApplication().isUnitTestMode()) {
+ myCachedFiles.clear();
+ myProject2Id.clear();
+ for (Project project : ProjectManager.getInstance().getOpenProjects()) {
+ onProjectOpened(project);
+ }
+ }
+ if (myProjectManagerListener == null) {
+ myProjectManagerListener = new ProjectManagerAdapter() {
+ @Override
+ public void projectOpened(final Project project) {
+ onProjectOpened(project);
+ }
+
+ @Override
+ public void projectClosed(final Project project) {
+ onProjectClosed(project);
+ }
+ };
+ ProjectManager.getInstance().addProjectManagerListener(myProjectManagerListener);
+ }
+ }
+
+ public void onProjectClosed(final Project project) {
+ myCachedFiles.clear();
+ myProject2Id.remove(project);
+ }
+
+ public void onProjectOpened(final Project project) {
+ myProject2Id.put(project, project.getLocationHash());
+ StartupManager.getInstance(project).runWhenProjectIsInitialized(new Runnable() {
+ @Override
+ public void run() {
+// DatabaseEditorHelper.installEditorFactoryListener(project); TODO:?
+ }
+ });
+ }
+
+ @Override
+ public VirtualFile findFileByPath(@NotNull String path) {
+ throw new UnsupportedOperationException("not implemented yet"); //TODO: implement TerminalSessionManager and store there terminal sessions by handle ID
+ }
+
+ public static String getPath(Project project, final String dataSourceId, final String tableName, String typeName) {
+ return PATH_PREFIX + typeName + PROTOCOL_SEPARATOR + project.getLocationHash() + "/" + dataSourceId + "/" + tableName;
+ }
+
+ @Override
+ @NotNull
+ public String getProtocol() {
+ return PROTOCOL;
+ }
+
+ @Override
+ public boolean isReadOnly() {
+ return false;
+ }
+
+ @Override
+ public void renameFile(Object requestor, @NotNull VirtualFile vFile, @NotNull String newName) throws IOException {
+ throw new UnsupportedOperationException("renameFile not supported");
+ }
+
+ @Override
+ @NotNull
+ public String extractPresentableUrl(@NotNull String path) {
+ VirtualFile file = findFileByPath(path);
+ return file != null ? file.getPresentableName() : super.extractPresentableUrl(path);
+ }
+}
diff --git a/plugins/terminal/terminal.iml b/plugins/terminal/terminal.iml
index ce9ede1..f2d64268 100644
--- a/plugins/terminal/terminal.iml
+++ b/plugins/terminal/terminal.iml
@@ -13,7 +13,7 @@
<orderEntry type="module-library">
<library name="jediterm-pty">
<CLASSES>
- <root url="jar://$MODULE_DIR$/lib/jediterm-pty-0.08.jar!/" />
+ <root url="jar://$MODULE_DIR$/lib/jediterm-pty-1.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
diff --git a/plugins/ui-designer-core/src/com/intellij/designer/DesignerToolWindow.java b/plugins/ui-designer-core/src/com/intellij/designer/DesignerToolWindow.java
index 3c8b155..6cafce8 100644
--- a/plugins/ui-designer-core/src/com/intellij/designer/DesignerToolWindow.java
+++ b/plugins/ui-designer-core/src/com/intellij/designer/DesignerToolWindow.java
@@ -39,7 +39,7 @@
/**
* @author Alexander Lobas
*/
-public final class DesignerToolWindow implements LightToolWindowContent {
+public final class DesignerToolWindow implements DesignerToolWindowContent {
private final Splitter myToolWindowPanel;
private ComponentTree myComponentTree;
private ComponentTreeBuilder myTreeBuilder;
@@ -138,12 +138,14 @@
return myPropertyTablePanel.getPropertyTable();
}
+ @Override
public void expandFromState() {
if (myTreeBuilder != null) {
myTreeBuilder.expandFromState();
}
}
+ @Override
public void refresh(boolean updateProperties) {
if (myTreeBuilder != null) {
if (updateProperties) {
@@ -155,6 +157,7 @@
}
}
+ @Override
public void updateInspections() {
if (myComponentTree != null) {
myComponentTree.updateInspections();
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/GroovyTypeHierarchyProvider.java b/plugins/ui-designer-core/src/com/intellij/designer/DesignerToolWindowContent.java
similarity index 68%
copy from plugins/groovy/src/org/jetbrains/plugins/groovy/lang/GroovyTypeHierarchyProvider.java
copy to plugins/ui-designer-core/src/com/intellij/designer/DesignerToolWindowContent.java
index bed999e..4ef588d 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/GroovyTypeHierarchyProvider.java
+++ b/plugins/ui-designer-core/src/com/intellij/designer/DesignerToolWindowContent.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,12 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.jetbrains.plugins.groovy.lang;
+package com.intellij.designer;
-import com.intellij.ide.hierarchy.type.JavaTypeHierarchyProvider;
+public interface DesignerToolWindowContent extends LightToolWindowContent {
+ void refresh(boolean updateProperties);
-/**
- * @author peter
- */
-public class GroovyTypeHierarchyProvider extends JavaTypeHierarchyProvider{
-}
+ void expandFromState();
+
+ void updateInspections();
+}
\ No newline at end of file
diff --git a/plugins/ui-designer-core/src/com/intellij/designer/PaletteToolWindowContent.java b/plugins/ui-designer-core/src/com/intellij/designer/PaletteToolWindowContent.java
new file mode 100644
index 0000000..5e77e7c
--- /dev/null
+++ b/plugins/ui-designer-core/src/com/intellij/designer/PaletteToolWindowContent.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.designer;
+
+import com.intellij.designer.designSurface.DesignerEditorPanel;
+import com.intellij.designer.palette.PaletteItem;
+import org.jetbrains.annotations.Nullable;
+
+public interface PaletteToolWindowContent extends LightToolWindowContent {
+ @Nullable
+ PaletteItem getActiveItem();
+
+ void clearActiveItem();
+
+ void refresh();
+
+ boolean isEmpty();
+
+ void loadPalette(@Nullable DesignerEditorPanel designer);
+}
\ No newline at end of file
diff --git a/plugins/ui-designer-core/src/com/intellij/designer/designSurface/DesignerEditorPanel.java b/plugins/ui-designer-core/src/com/intellij/designer/designSurface/DesignerEditorPanel.java
index 9405e8b..dc12a18 100644
--- a/plugins/ui-designer-core/src/com/intellij/designer/designSurface/DesignerEditorPanel.java
+++ b/plugins/ui-designer-core/src/com/intellij/designer/designSurface/DesignerEditorPanel.java
@@ -164,8 +164,8 @@
@Override
public void run() {
DesignerEditorPanel designer = DesignerEditorPanel.this;
- DesignerToolWindowManager.getInstance(myProject).bind(designer);
- PaletteToolWindowManager.getInstance(myProject).bind(designer);
+ getDesignerWindowManager().bind(designer);
+ getPaletteWindowManager().bind(designer);
}
});
}
@@ -376,7 +376,7 @@
myErrorPanel.revalidate();
myLayout.show(myPanel, ERROR_CARD);
- DesignerToolWindowManager.getInstance(this).refresh(true);
+ getDesignerToolWindow().refresh(true);
repaint();
}
@@ -603,7 +603,7 @@
}
protected void restoreState() {
- DesignerToolWindow toolManager = DesignerToolWindowManager.getInstance(this);
+ DesignerToolWindowContent toolManager = getDesignerToolWindow();
if (myExpandedState != null) {
List<RadComponent> expanded = new ArrayList<RadComponent>();
@@ -733,11 +733,27 @@
public void dispose() {
Disposer.dispose(myProgressIcon);
- DesignerToolWindowManager.getInstance(myProject).dispose(this);
- PaletteToolWindowManager.getInstance(myProject).dispose(this);
+ getDesignerWindowManager().dispose(this);
+ getPaletteWindowManager().dispose(this);
Disposer.dispose(myContentSplitter);
}
+ protected AbstractToolWindowManager getDesignerWindowManager() {
+ return DesignerToolWindowManager.getInstance(myProject);
+ }
+
+ protected AbstractToolWindowManager getPaletteWindowManager() {
+ return PaletteToolWindowManager.getInstance(myProject);
+ }
+
+ public DesignerToolWindowContent getDesignerToolWindow() {
+ return DesignerToolWindowManager.getInstance(this);
+ }
+
+ protected PaletteToolWindowContent getPaletteToolWindow() {
+ return PaletteToolWindowManager.getInstance(this);
+ }
+
@Nullable
public WrapInProvider getWrapInProvider() {
return null;
@@ -1012,7 +1028,7 @@
@Override
public void setActiveTool(InputTool tool) {
if (getActiveTool() instanceof CreationTool && !(tool instanceof CreationTool)) {
- PaletteToolWindowManager.getInstance(DesignerEditorPanel.this).clearActiveItem();
+ getPaletteToolWindow().clearActiveItem();
}
if (!(tool instanceof SelectionTool)) {
hideInspections();
diff --git a/plugins/ui-designer-core/src/com/intellij/designer/inspection/DesignerHighlightingPass.java b/plugins/ui-designer-core/src/com/intellij/designer/inspection/DesignerHighlightingPass.java
index fc3fe23..0fe7241 100644
--- a/plugins/ui-designer-core/src/com/intellij/designer/inspection/DesignerHighlightingPass.java
+++ b/plugins/ui-designer-core/src/com/intellij/designer/inspection/DesignerHighlightingPass.java
@@ -16,7 +16,6 @@
package com.intellij.designer.inspection;
import com.intellij.codeHighlighting.HighlightingPass;
-import com.intellij.designer.DesignerToolWindowManager;
import com.intellij.designer.designSurface.DesignerEditorPanel;
import com.intellij.openapi.progress.ProgressIndicator;
import org.jetbrains.annotations.NotNull;
@@ -38,7 +37,7 @@
@Override
public void applyInformationToEditor() {
- DesignerToolWindowManager.getInstance(myDesigner).updateInspections();
+ myDesigner.getDesignerToolWindow().updateInspections();
myDesigner.updateInspections();
}
}
\ No newline at end of file
diff --git a/plugins/ui-designer-core/src/com/intellij/designer/model/MetaManager.java b/plugins/ui-designer-core/src/com/intellij/designer/model/MetaManager.java
index 453751d..0727b48 100644
--- a/plugins/ui-designer-core/src/com/intellij/designer/model/MetaManager.java
+++ b/plugins/ui-designer-core/src/com/intellij/designer/model/MetaManager.java
@@ -22,6 +22,7 @@
import com.intellij.openapi.util.text.StringUtil;
import org.jdom.Attribute;
import org.jdom.Element;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
@@ -92,8 +93,9 @@
}
}
+ @NotNull
@SuppressWarnings("unchecked")
- private void loadModel(ClassLoader classLoader, Element element, Map<MetaModel, List<String>> modelToMorphing) throws Exception {
+ protected MetaModel loadModel(ClassLoader classLoader, Element element, Map<MetaModel, List<String>> modelToMorphing) throws Exception {
String modelValue = element.getAttributeValue("model");
Class<RadComponent> model = modelValue == null ? null : (Class<RadComponent>)classLoader.loadClass(modelValue);
String target = element.getAttributeValue("class");
@@ -145,16 +147,30 @@
if (target != null) {
myTarget2Model.put(target, meta);
}
+
+ return meta;
}
+ @NotNull
protected MetaModel createModel(Class<RadComponent> model, String target, String tag) throws Exception {
return new MetaModel(model, target, tag);
}
+ @NotNull
protected DefaultPaletteItem createPaletteItem(Element palette) {
return new DefaultPaletteItem(palette);
}
+ @NotNull
+ protected VariationPaletteItem createVariationPaletteItem(PaletteItem paletteItem, MetaModel model, Element itemElement) {
+ return new VariationPaletteItem(paletteItem, model, itemElement);
+ }
+
+ @NotNull
+ protected PaletteGroup createPaletteGroup(String name) {
+ return new PaletteGroup(name);
+ }
+
protected void loadProperties(MetaModel meta, Element properties) throws Exception {
Attribute inplace = properties.getAttribute("inplace");
if (inplace != null) {
@@ -190,8 +206,9 @@
protected void loadOther(MetaModel meta, Element element) throws Exception {
}
- private void loadGroup(Element element) throws Exception {
- PaletteGroup group = new PaletteGroup(element.getAttributeValue(NAME));
+ @NotNull
+ protected PaletteGroup loadGroup(Element element) throws Exception {
+ PaletteGroup group = createPaletteGroup(element.getAttributeValue(NAME));
for (Object child : element.getChildren(ITEM)) {
Element itemElement = (Element)child;
@@ -209,12 +226,12 @@
// this such that the {@link MetaModel} can hold multiple {@link PaletteItem}
// instances, and perform attribute matching.
if (itemElement.getAttribute("title") != null) {
- paletteItem = new VariationPaletteItem(paletteItem, model, itemElement);
+ paletteItem = createVariationPaletteItem(paletteItem, model, itemElement);
}
group.addItem(paletteItem);
for (Object grandChild : itemElement.getChildren(ITEM)) {
- group.addItem(new VariationPaletteItem(paletteItem, model, (Element)grandChild));
+ group.addItem(createVariationPaletteItem(paletteItem, model, (Element)grandChild));
}
}
else {
@@ -223,6 +240,8 @@
}
myPaletteGroups.add(group);
+
+ return group;
}
@SuppressWarnings("unchecked")
diff --git a/plugins/ui-designer-core/src/com/intellij/designer/model/MetaModel.java b/plugins/ui-designer-core/src/com/intellij/designer/model/MetaModel.java
index 8f4bbb9..442adf2 100644
--- a/plugins/ui-designer-core/src/com/intellij/designer/model/MetaModel.java
+++ b/plugins/ui-designer-core/src/com/intellij/designer/model/MetaModel.java
@@ -16,6 +16,7 @@
package com.intellij.designer.model;
import com.intellij.designer.palette.DefaultPaletteItem;
+import com.intellij.designer.palette.PaletteItem;
import com.intellij.designer.propertyTable.IPropertyDecorator;
import com.intellij.openapi.util.IconLoader;
import com.intellij.util.ArrayUtil;
@@ -33,7 +34,7 @@
private Class<RadLayout> myLayout;
private final String myTarget;
private final String myTag;
- private DefaultPaletteItem myPaletteItem;
+ private PaletteItem myPaletteItem;
private String myTitle;
private String myIconPath;
private Icon myIcon;
@@ -117,7 +118,7 @@
myIcon = null;
}
- public DefaultPaletteItem getPaletteItem() {
+ public PaletteItem getPaletteItem() {
return myPaletteItem;
}
diff --git a/plugins/ui-designer-core/src/com/intellij/designer/model/VariationPaletteItem.java b/plugins/ui-designer-core/src/com/intellij/designer/model/VariationPaletteItem.java
index 81c761f..782fd85 100644
--- a/plugins/ui-designer-core/src/com/intellij/designer/model/VariationPaletteItem.java
+++ b/plugins/ui-designer-core/src/com/intellij/designer/model/VariationPaletteItem.java
@@ -12,16 +12,16 @@
* Implementation of a {@link PaletteItem} which delegates to another {@linkplain PaletteItem}
* but which possibly overrides the title, icon and or creation properties.
*/
-final class VariationPaletteItem implements PaletteItem {
+public class VariationPaletteItem implements PaletteItem {
private final PaletteItem myDefaultItem;
- private final MetaModel myModel;
private final String myTitle;
private final String myIconPath;
private final String myTooltip;
private final String myCreation;
private Icon myIcon;
+ private MetaModel myModel;
- VariationPaletteItem(PaletteItem defaultItem, MetaModel model, Element element) {
+ protected VariationPaletteItem(PaletteItem defaultItem, MetaModel model, Element element) {
myDefaultItem = defaultItem;
myModel = model;
@@ -91,6 +91,11 @@
return myModel;
}
+ @Override
+ public void setMetaModel(MetaModel metaModel) {
+ myModel = metaModel;
+ }
+
@Nullable
@Override
public String getDeprecatedIn() {
diff --git a/plugins/ui-designer-core/src/com/intellij/designer/palette/DefaultPaletteItem.java b/plugins/ui-designer-core/src/com/intellij/designer/palette/DefaultPaletteItem.java
index 4ae4ae9..0824f5a 100644
--- a/plugins/ui-designer-core/src/com/intellij/designer/palette/DefaultPaletteItem.java
+++ b/plugins/ui-designer-core/src/com/intellij/designer/palette/DefaultPaletteItem.java
@@ -114,6 +114,7 @@
return myMetaModel;
}
+ @Override
public void setMetaModel(MetaModel metaModel) {
myMetaModel = metaModel;
}
diff --git a/plugins/ui-designer-core/src/com/intellij/designer/palette/PaletteItem.java b/plugins/ui-designer-core/src/com/intellij/designer/palette/PaletteItem.java
index 8cf9578..54347f5 100644
--- a/plugins/ui-designer-core/src/com/intellij/designer/palette/PaletteItem.java
+++ b/plugins/ui-designer-core/src/com/intellij/designer/palette/PaletteItem.java
@@ -60,4 +60,9 @@
* Returns the associated {@link com.intellij.designer.model.MetaModel}, if known
*/
MetaModel getMetaModel();
+
+ /**
+ * Sets the associated {@link com.intellij.designer.model.MetaModel}, if known
+ */
+ void setMetaModel(MetaModel metaModel);
}
\ No newline at end of file
diff --git a/plugins/ui-designer-core/src/com/intellij/designer/palette/PalettePanel.java b/plugins/ui-designer-core/src/com/intellij/designer/palette/PalettePanel.java
index 67bfd77..a7dfef3 100644
--- a/plugins/ui-designer-core/src/com/intellij/designer/palette/PalettePanel.java
+++ b/plugins/ui-designer-core/src/com/intellij/designer/palette/PalettePanel.java
@@ -15,7 +15,7 @@
*/
package com.intellij.designer.palette;
-import com.intellij.designer.LightToolWindowContent;
+import com.intellij.designer.PaletteToolWindowContent;
import com.intellij.designer.designSurface.DesignerEditorPanel;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.ApplicationManager;
@@ -42,7 +42,7 @@
/**
* @author Alexander Lobas
*/
-public class PalettePanel extends JPanel implements DataProvider, LightToolWindowContent {
+public class PalettePanel extends JPanel implements DataProvider, PaletteToolWindowContent {
private final JPanel myPaletteContainer = new PaletteContainer();
private List<PaletteGroupComponent> myGroupComponents = Collections.emptyList();
private List<PaletteItemsComponent> myItemsComponents = Collections.emptyList();
@@ -116,6 +116,7 @@
return null;
}
+ @Override
public void clearActiveItem() {
if (getActiveItem() != null) {
for (PaletteItemsComponent itemsComponent : myItemsComponents) {
@@ -125,14 +126,17 @@
}
}
+ @Override
public void refresh() {
repaint();
}
+ @Override
public boolean isEmpty() {
return myGroups.isEmpty();
}
+ @Override
public void loadPalette(@Nullable DesignerEditorPanel designer) {
if (myDesigner == null && designer == null) {
return;
diff --git a/python/build/pycharm_community_build.gant b/python/build/pycharm_community_build.gant
index 071e31b..4701545 100644
--- a/python/build/pycharm_community_build.gant
+++ b/python/build/pycharm_community_build.gant
@@ -216,6 +216,12 @@
module("util-rt")
}
+ dir("libpty") {
+ fileset(dir: "$home/community/lib/libpty") {
+ exclude(name: "*.txt")
+ }
+ }
+
jar("openapi.jar") {
openapiModules.each { module it }
}
diff --git a/python/ide/src/com/jetbrains/python/PlatformPythonModuleType.java b/python/ide/src/com/jetbrains/python/PlatformPythonModuleType.java
index b1fe9e9..ae4e18c 100644
--- a/python/ide/src/com/jetbrains/python/PlatformPythonModuleType.java
+++ b/python/ide/src/com/jetbrains/python/PlatformPythonModuleType.java
@@ -18,6 +18,8 @@
import com.intellij.ide.util.projectWizard.EmptyModuleBuilder;
import com.intellij.openapi.module.ModuleType;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.jps.model.java.JavaSourceRootType;
+import org.jetbrains.jps.model.module.JpsModuleSourceRootType;
/**
* @author yole
@@ -33,4 +35,9 @@
}
};
}
+
+ @Override
+ public boolean isSupportedRootType(JpsModuleSourceRootType type) {
+ return type == JavaSourceRootType.SOURCE;
+ }
}
diff --git a/python/python-plugin-tests.iml b/python/python-plugin-tests.iml
index 9d3a505..3269555 100644
--- a/python/python-plugin-tests.iml
+++ b/python/python-plugin-tests.iml
@@ -2,7 +2,23 @@
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
+ <content url="file://$MODULE_DIR$/pluginResources">
+ <sourceFolder url="file://$MODULE_DIR$/pluginResources" type="java-resource" />
+ </content>
+ <content url="file://$MODULE_DIR$/pluginTestSrc">
+ <sourceFolder url="file://$MODULE_DIR$/pluginTestSrc" isTestSource="true" />
+ </content>
+ <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="module" module-name="testFramework-java" />
+ <orderEntry type="library" scope="TEST" name="JUnit3" level="project" />
+ <orderEntry type="module" module-name="java-impl" />
+ <orderEntry type="module" module-name="jam-support-impl" scope="RUNTIME" />
+ <orderEntry type="module" module-name="IntelliLang-java" scope="RUNTIME" />
+ <orderEntry type="module" module-name="python-community-tests" />
+ <orderEntry type="module" module-name="python-community-plugin" />
+ <orderEntry type="module" module-name="python-community" />
+ <orderEntry type="module" module-name="IntelliLang-xml" scope="RUNTIME" />
</component>
</module>
diff --git a/python/python-rest/src/com/jetbrains/rest/run/RestRunConfigurationType.java b/python/python-rest/src/com/jetbrains/rest/run/RestRunConfigurationType.java
index 0045004..79929d2 100644
--- a/python/python-rest/src/com/jetbrains/rest/run/RestRunConfigurationType.java
+++ b/python/python-rest/src/com/jetbrains/rest/run/RestRunConfigurationType.java
@@ -15,8 +15,12 @@
*/
package com.jetbrains.rest.run;
-import com.intellij.execution.configurations.*;
+import com.intellij.execution.configurations.ConfigurationFactory;
+import com.intellij.execution.configurations.ConfigurationType;
+import com.intellij.execution.configurations.ConfigurationTypeUtil;
+import com.intellij.execution.configurations.RunConfiguration;
import com.intellij.openapi.project.Project;
+import com.jetbrains.python.run.PythonConfigurationFactoryBase;
import com.jetbrains.rest.RestBundle;
import com.jetbrains.rest.RestFileType;
import com.jetbrains.rest.run.docutils.DocutilsRunConfiguration;
@@ -59,7 +63,7 @@
return new ConfigurationFactory[] {DOCUTILS_FACTORY, SPHINX_FACTORY};
}
- private static abstract class RestConfigurationFactory extends ConfigurationFactory {
+ private static abstract class RestConfigurationFactory extends PythonConfigurationFactoryBase {
private final String myName;
public RestConfigurationFactory(@NotNull final ConfigurationType type, @NotNull String name) {
diff --git a/python/src/META-INF/python-core.xml b/python/src/META-INF/python-core.xml
index 6ec62ec..6c02c7a 100644
--- a/python/src/META-INF/python-core.xml
+++ b/python/src/META-INF/python-core.xml
@@ -550,6 +550,7 @@
<dumbAnnotator implementation="com.jetbrains.python.validation.PyDefinitionsAnnotator"/>
<dumbAnnotator implementation="com.jetbrains.python.validation.GeneratorInArgumentListAnnotator"/>
<dumbAnnotator implementation="com.jetbrains.python.validation.StarAnnotator"/>
+ <dumbAnnotator implementation="com.jetbrains.python.validation.StringLiteralQuotesAnnotator"/>
<customTargetExpressionStubType implementation="com.jetbrains.python.psi.impl.stubs.PropertyStubType"/>
<dialectsTokenSetContributor implementation="com.jetbrains.python.PythonTokenSetContributor"/>
diff --git a/python/src/com/jetbrains/python/codeInsight/completion/OverwriteEqualsInsertHandler.java b/python/src/com/jetbrains/python/codeInsight/completion/OverwriteEqualsInsertHandler.java
new file mode 100644
index 0000000..1fb1070
--- /dev/null
+++ b/python/src/com/jetbrains/python/codeInsight/completion/OverwriteEqualsInsertHandler.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jetbrains.python.codeInsight.completion;
+
+import com.intellij.codeInsight.completion.InsertHandler;
+import com.intellij.codeInsight.completion.InsertionContext;
+import com.intellij.codeInsight.lookup.Lookup;
+import com.intellij.codeInsight.lookup.LookupElement;
+import com.intellij.openapi.editor.Document;
+
+/**
+ * @author yole
+ */
+public class OverwriteEqualsInsertHandler implements InsertHandler<LookupElement> {
+ public static OverwriteEqualsInsertHandler INSTANCE = new OverwriteEqualsInsertHandler();
+
+ @Override
+ public void handleInsert(InsertionContext context, LookupElement item) {
+ if (context.getCompletionChar() != Lookup.REPLACE_SELECT_CHAR) {
+ return;
+ }
+ Document doc = context.getDocument();
+ int tailOffset = context.getTailOffset();
+ if (doc.getCharsSequence().charAt(tailOffset) == '=') {
+ doc.deleteString(tailOffset, tailOffset+1);
+ }
+ }
+}
diff --git a/python/src/com/jetbrains/python/codeInsight/imports/AutoImportQuickFix.java b/python/src/com/jetbrains/python/codeInsight/imports/AutoImportQuickFix.java
index 5484ce7..4b46413 100644
--- a/python/src/com/jetbrains/python/codeInsight/imports/AutoImportQuickFix.java
+++ b/python/src/com/jetbrains/python/codeInsight/imports/AutoImportQuickFix.java
@@ -98,7 +98,12 @@
@NotNull
public String getText() {
if (myUseQualifiedImport) return PyBundle.message("ACT.qualify.with.module");
- else return PyBundle.message("ACT.NAME.use.import");
+ else if (myImports.size() == 1) {
+ return "Import '" + myImports.get(0).getPresentableText(getNameToImport()) + "'";
+ }
+ else {
+ return PyBundle.message("ACT.NAME.use.import");
+ }
}
@NotNull
diff --git a/python/src/com/jetbrains/python/console/PythonConsoleView.java b/python/src/com/jetbrains/python/console/PythonConsoleView.java
index 198a4d3..ddf62ed 100644
--- a/python/src/com/jetbrains/python/console/PythonConsoleView.java
+++ b/python/src/com/jetbrains/python/console/PythonConsoleView.java
@@ -29,10 +29,8 @@
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
-import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
@@ -77,18 +75,17 @@
private EditorColorsScheme myScheme;
private boolean myHyperlink;
- private final MyLanguageConsoleViewImpl myLanguageConsoleView;
+ private final LanguageConsoleViewImpl myLanguageConsoleView;
private Disposable mySplittedDisposable;
public PythonConsoleView(final Project project, final String title, Sdk sdk) {
super(new BorderLayout());
- myLanguageConsoleView = new MyLanguageConsoleViewImpl(project, title, sdk);
+ myLanguageConsoleView = new LanguageConsoleViewImpl(new PythonLanguageConsole(project, title, sdk));
add(myLanguageConsoleView.getComponent(), BorderLayout.CENTER);
- getPythonLanguageConsole().setPythonConsoleView(this);
getPythonLanguageConsole().setPrompt(PyConsoleUtil.ORDINARY_PROMPT);
myLanguageConsoleView.setUpdateFoldingsEnabled(false);
myProject = project;
@@ -421,12 +418,7 @@
}
}
- public void beforeExternalAddContentToDocument(int length, ConsoleViewContentType contentType) {
- myLanguageConsoleView.beforeExternalAddContentToDocument(length, contentType);
- }
-
private static class PythonLanguageConsole extends LanguageConsoleImpl {
- private PythonConsoleView myPythonConsoleView;
public PythonLanguageConsole(final Project project, final String title, final Sdk sdk) {
super(project, title, PythonLanguage.getInstance(), false);
@@ -446,39 +438,12 @@
}
}
- public void setPythonConsoleView(PythonConsoleView pythonConsoleView) {
- myPythonConsoleView = pythonConsoleView;
- }
-
public void setConsoleCommunication(final ConsoleCommunication communication) {
myFile.putCopyableUserData(PydevConsoleRunner.CONSOLE_KEY, communication);
}
- @Override
- protected void appendToHistoryDocument(@NotNull Document history, @NotNull CharSequence text) {
- myPythonConsoleView.beforeExternalAddContentToDocument(text.length(), ConsoleViewContentType.NORMAL_OUTPUT);
- super.appendToHistoryDocument(history, text);
- }
-
public void setSdk(Sdk sdk) {
myFile.putCopyableUserData(PydevConsoleRunner.CONSOLE_SDK, sdk);
}
}
-
- private static class MyLanguageConsoleViewImpl extends LanguageConsoleViewImpl {
- public MyLanguageConsoleViewImpl(Project project, String title, Sdk sdk) {
- super(new PythonLanguageConsole(project, title, sdk));
- }
-
- @Override
- protected EditorEx createRealEditor() {
- EditorEx editor = myConsole.getHistoryViewer();
- editor.setHighlighter(createHighlighter());
- return editor;
- }
-
- public void beforeExternalAddContentToDocument(int length, ConsoleViewContentType contentType) {
- super.beforeExternalAddContentToDocument(length, contentType);
- }
- }
}
diff --git a/python/src/com/jetbrains/python/formatter/PyBlock.java b/python/src/com/jetbrains/python/formatter/PyBlock.java
index ab03c46..6d343e2 100644
--- a/python/src/com/jetbrains/python/formatter/PyBlock.java
+++ b/python/src/com/jetbrains/python/formatter/PyBlock.java
@@ -152,7 +152,7 @@
if (ourListElementTypes.contains(parentType)) {
// wrapping in non-parenthesized tuple expression is not allowed (PY-1792)
if ((parentType != PyElementTypes.TUPLE_EXPRESSION || grandparentType == PyElementTypes.PARENTHESIZED_EXPRESSION) &&
- !ourBrackets.contains(childType) && childType != PyTokenTypes.COMMA && !isSliceOperand(child)) {
+ !ourBrackets.contains(childType) && childType != PyTokenTypes.COMMA && !isSliceOperand(child) /*&& !isSubscriptionOperand(child)*/) {
wrap = Wrap.createWrap(WrapType.NORMAL, true);
}
if (needListAlignment(child) && !isEmptyList(_node.getPsi())) {
@@ -257,6 +257,11 @@
return new PyBlock(this, child, childAlignment, childIndent, wrap, myContext);
}
+ private static boolean isSubscriptionOperand(ASTNode child) {
+ return child.getTreeParent().getElementType() == PyElementTypes.SUBSCRIPTION_EXPRESSION &&
+ child.getPsi() == ((PySubscriptionExpression) child.getTreeParent().getPsi()).getOperand();
+ }
+
private boolean isInControlStatement() {
return PsiTreeUtil.getParentOfType(_node.getPsi(), PyStatementPart.class, false, PyStatementList.class) != null ||
PsiTreeUtil.getParentOfType(_node.getPsi(), PyWithItem.class) != null;
diff --git a/python/src/com/jetbrains/python/formatter/PythonFormattingModelBuilder.java b/python/src/com/jetbrains/python/formatter/PythonFormattingModelBuilder.java
index 0bfe359..aee9e53 100644
--- a/python/src/com/jetbrains/python/formatter/PythonFormattingModelBuilder.java
+++ b/python/src/com/jetbrains/python/formatter/PythonFormattingModelBuilder.java
@@ -112,6 +112,7 @@
.before(SEMICOLON).spaceIf(commonSettings.SPACE_BEFORE_SEMICOLON)
.withinPairInside(LPAR, RPAR, ARGUMENT_LIST).spaceIf(commonSettings.SPACE_WITHIN_METHOD_CALL_PARENTHESES)
.withinPairInside(LPAR, RPAR, PARAMETER_LIST).spaceIf(commonSettings.SPACE_WITHIN_METHOD_PARENTHESES)
+ .withinPairInside(LPAR, RPAR, FROM_IMPORT_STATEMENT).spaces(0)
.before(LBRACKET).spaceIf(pySettings.SPACE_BEFORE_LBRACKET)
.withinPair(LBRACE, RBRACE).spaceIf(pySettings.SPACE_WITHIN_BRACES)
diff --git a/python/src/com/jetbrains/python/inspections/PyUnresolvedReferencesInspection.java b/python/src/com/jetbrains/python/inspections/PyUnresolvedReferencesInspection.java
index 514bc9d..0739893 100644
--- a/python/src/com/jetbrains/python/inspections/PyUnresolvedReferencesInspection.java
+++ b/python/src/com/jetbrains/python/inspections/PyUnresolvedReferencesInspection.java
@@ -561,13 +561,13 @@
final PsiElement point;
final TextRange range;
- if (reference instanceof PyOperatorReference) {
+ final PsiElement lastChild = node.getLastChild();
+ if (reference instanceof PyOperatorReference || lastChild == null) {
point = node;
range = rangeInElement;
}
else {
- final PsiElement lastChild = node.getLastChild();
- point = lastChild != null ? lastChild : node; // usually the identifier at the end of qual ref
+ point = lastChild; // usually the identifier at the end of qual ref
range = rangeInElement.shiftRight(-point.getStartOffsetInParent());
}
if (reference instanceof PyImportReference && refname != null) {
diff --git a/python/src/com/jetbrains/python/parsing/FunctionParsing.java b/python/src/com/jetbrains/python/parsing/FunctionParsing.java
index f9fe799..768fa0a 100644
--- a/python/src/com/jetbrains/python/parsing/FunctionParsing.java
+++ b/python/src/com/jetbrains/python/parsing/FunctionParsing.java
@@ -44,12 +44,7 @@
protected void parseFunctionInnards(PsiBuilder.Marker functionMarker) {
myBuilder.advanceLexer();
- if (myBuilder.getTokenType() == PyTokenTypes.IDENTIFIER) {
- myBuilder.advanceLexer();
- }
- else {
- myBuilder.error(message("PARSE.expected.func.name"));
- }
+ checkMatchesOrSkip(PyTokenTypes.IDENTIFIER, message("PARSE.expected.func.name"));
parseParameterList();
parseReturnTypeAnnotation();
checkMatches(PyTokenTypes.COLON, message("PARSE.expected.colon"));
@@ -85,10 +80,18 @@
getExpressionParser().parseArgumentList();
}
else { // empty arglist node, so we always have it
- myBuilder.mark().done(PyElementTypes.ARGUMENT_LIST);
+ PsiBuilder.Marker argListMarker = myBuilder.mark();
+ argListMarker.setCustomEdgeTokenBinders(LeftBiasedWhitespaceBinder.INSTANCE, null);
+ argListMarker.done(PyElementTypes.ARGUMENT_LIST);
}
- checkMatches(PyTokenTypes.STATEMENT_BREAK, message("PARSE.expected.statement.break"));
- decoratorMarker.done(PyElementTypes.DECORATOR_CALL);
+ if (atToken(PyTokenTypes.STATEMENT_BREAK)) {
+ decoratorMarker.done(PyElementTypes.DECORATOR_CALL);
+ nextToken();
+ }
+ else {
+ myBuilder.error(message("PARSE.expected.statement.break"));
+ decoratorMarker.done(PyElementTypes.DECORATOR_CALL);
+ }
decorated = true;
}
if (decorated) decoListMarker.done(PyElementTypes.DECORATOR_LIST);
@@ -217,7 +220,7 @@
nextToken();
}
invalidElements.error(message("PARSE.expected.formal.param.name"));
- return false;
+ return atToken(endToken) || atToken(PyTokenTypes.COMMA);
}
return true;
}
diff --git a/python/src/com/jetbrains/python/parsing/LeftBiasedWhitespaceBinder.java b/python/src/com/jetbrains/python/parsing/LeftBiasedWhitespaceBinder.java
new file mode 100644
index 0000000..38bd079
--- /dev/null
+++ b/python/src/com/jetbrains/python/parsing/LeftBiasedWhitespaceBinder.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jetbrains.python.parsing;
+
+import com.intellij.lang.WhitespacesAndCommentsBinder;
+import com.intellij.psi.tree.IElementType;
+
+import java.util.List;
+
+/**
+ * @author yole
+ */
+public class LeftBiasedWhitespaceBinder implements WhitespacesAndCommentsBinder {
+ public static LeftBiasedWhitespaceBinder INSTANCE = new LeftBiasedWhitespaceBinder();
+
+ @Override
+ public int getEdgePosition(List<IElementType> tokens, boolean atStreamEdge, TokenTextGetter getter) {
+ return 0;
+ }
+}
diff --git a/python/src/com/jetbrains/python/parsing/Parsing.java b/python/src/com/jetbrains/python/parsing/Parsing.java
index 0edce7a..99eab6f 100644
--- a/python/src/com/jetbrains/python/parsing/Parsing.java
+++ b/python/src/com/jetbrains/python/parsing/Parsing.java
@@ -61,6 +61,17 @@
return false;
}
+ protected boolean checkMatchesOrSkip(final IElementType token, final String message) {
+ if (myBuilder.getTokenType() == token) {
+ myBuilder.advanceLexer();
+ return true;
+ }
+ PsiBuilder.Marker mark = myBuilder.mark();
+ myBuilder.advanceLexer();
+ mark.error(message);
+ return false;
+ }
+
protected void assertCurrentToken(final PyElementType tokenType) {
LOG.assertTrue(myBuilder.getTokenType() == tokenType);
}
diff --git a/python/src/com/jetbrains/python/parsing/StatementParsing.java b/python/src/com/jetbrains/python/parsing/StatementParsing.java
index b247e29..518caa7 100644
--- a/python/src/com/jetbrains/python/parsing/StatementParsing.java
+++ b/python/src/com/jetbrains/python/parsing/StatementParsing.java
@@ -598,13 +598,17 @@
final PsiBuilder.Marker ifStatement = myBuilder.mark();
final PsiBuilder.Marker ifPart = myBuilder.mark();
myBuilder.advanceLexer();
- getExpressionParser().parseExpression();
+ if (!getExpressionParser().parseSingleExpression(false)) {
+ myBuilder.error("expression expected");
+ }
parseColonAndSuite(scope);
ifPart.done(PyElementTypes.IF_PART_IF);
PsiBuilder.Marker elifPart = myBuilder.mark();
while (myBuilder.getTokenType() == elifKeyword) {
myBuilder.advanceLexer();
- getExpressionParser().parseExpression();
+ if (!getExpressionParser().parseSingleExpression(false)) {
+ myBuilder.error("expression expected");
+ }
parseColonAndSuite(scope);
elifPart.done(PyElementTypes.IF_PART_ELIF);
elifPart = myBuilder.mark();
@@ -628,11 +632,15 @@
return true;
}
final PsiBuilder.Marker marker = myBuilder.mark();
- if (myBuilder.getTokenType() == PyTokenTypes.STATEMENT_BREAK) {
+ while (!atAnyOfTokens(null, PyTokenTypes.DEDENT, PyTokenTypes.STATEMENT_BREAK, PyTokenTypes.COLON)) {
+ myBuilder.advanceLexer();
+ }
+ boolean result = matchToken(PyTokenTypes.COLON);
+ if (!result && atToken(PyTokenTypes.STATEMENT_BREAK)) {
myBuilder.advanceLexer();
}
marker.error("Colon expected");
- return false;
+ return result;
}
private void parseForStatement(ParsingScope scope) {
@@ -758,7 +766,10 @@
setExpectAsKeyword(true);
if (myBuilder.getTokenType() == PyTokenTypes.AS_KEYWORD) {
myBuilder.advanceLexer();
- getExpressionParser().parseSingleExpression(true); // 'as' is followed by a target
+ if (!getExpressionParser().parseSingleExpression(true)) {
+ myBuilder.error("identifier expected");
+ // 'as' is followed by a target
+ }
}
withItem.done(PyElementTypes.WITH_ITEM);
if (!matchToken(PyTokenTypes.COMMA)) {
@@ -777,7 +788,7 @@
public void parseClassDeclaration(PsiBuilder.Marker classMarker, ParsingScope scope) {
assertCurrentToken(PyTokenTypes.CLASS_KEYWORD);
myBuilder.advanceLexer();
- checkMatches(PyTokenTypes.IDENTIFIER, IDENTIFIER_EXPECTED);
+ checkMatchesOrSkip(PyTokenTypes.IDENTIFIER, IDENTIFIER_EXPECTED);
if (myBuilder.getTokenType() == PyTokenTypes.LPAR) {
getExpressionParser().parseArgumentList();
}
diff --git a/python/src/com/jetbrains/python/psi/PyUtil.java b/python/src/com/jetbrains/python/psi/PyUtil.java
index 1baf3c4..e939857 100644
--- a/python/src/com/jetbrains/python/psi/PyUtil.java
+++ b/python/src/com/jetbrains/python/psi/PyUtil.java
@@ -54,6 +54,7 @@
import com.jetbrains.python.PyBundle;
import com.jetbrains.python.PyNames;
import com.jetbrains.python.PyTokenTypes;
+import com.jetbrains.python.codeInsight.completion.OverwriteEqualsInsertHandler;
import com.jetbrains.python.codeInsight.controlflow.ScopeOwner;
import com.jetbrains.python.codeInsight.dataflow.scope.ScopeUtil;
import com.jetbrains.python.codeInsight.stdlib.PyNamedTupleType;
@@ -888,6 +889,7 @@
public static LookupElement createNamedParameterLookup(String name) {
LookupElementBuilder lookupElementBuilder = LookupElementBuilder.create(name + "=").withIcon(PlatformIcons.PARAMETER_ICON);
+ lookupElementBuilder = lookupElementBuilder.withInsertHandler(OverwriteEqualsInsertHandler.INSTANCE);
return PrioritizedLookupElement.withGrouping(lookupElementBuilder, 1);
}
diff --git a/python/src/com/jetbrains/python/psi/impl/PyFunctionImpl.java b/python/src/com/jetbrains/python/psi/impl/PyFunctionImpl.java
index d108c09..93469c6 100644
--- a/python/src/com/jetbrains/python/psi/impl/PyFunctionImpl.java
+++ b/python/src/com/jetbrains/python/psi/impl/PyFunctionImpl.java
@@ -23,6 +23,7 @@
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
+import com.intellij.psi.StubBasedPsiElement;
import com.intellij.psi.search.LocalSearchScope;
import com.intellij.psi.search.SearchScope;
import com.intellij.psi.stubs.IStubElementType;
@@ -158,12 +159,9 @@
return null;
}
- final PsiElement parent = getParent();
- if (parent instanceof PyStatementList) {
- PsiElement pparent = parent.getParent();
- if (pparent instanceof PyClass) {
- return (PyClass)pparent;
- }
+ final PsiElement parent = PsiTreeUtil.getParentOfType(this, StubBasedPsiElement.class);
+ if (parent instanceof PyClass) {
+ return (PyClass)parent;
}
return null;
}
diff --git a/python/src/com/jetbrains/python/refactoring/rename/PyContainingFileRenamerFactory.java b/python/src/com/jetbrains/python/refactoring/rename/PyContainingFileRenamerFactory.java
index e51c51b..1c2c372 100644
--- a/python/src/com/jetbrains/python/refactoring/rename/PyContainingFileRenamerFactory.java
+++ b/python/src/com/jetbrains/python/refactoring/rename/PyContainingFileRenamerFactory.java
@@ -22,6 +22,7 @@
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.refactoring.rename.naming.AutomaticRenamer;
import com.intellij.refactoring.rename.naming.AutomaticRenamerFactory;
+import com.intellij.refactoring.rename.naming.NameSuggester;
import com.intellij.usageView.UsageInfo;
import com.jetbrains.python.codeInsight.PyCodeInsightSettings;
import com.jetbrains.python.codeInsight.controlflow.ScopeOwner;
@@ -107,5 +108,13 @@
public boolean isSelectedByDefault() {
return true;
}
+
+ @Override
+ protected String suggestNameForElement(PsiNamedElement element, NameSuggester suggester, String newClassName, String oldClassName) {
+ if (element instanceof PyFile && element.getName().equals(oldClassName.toLowerCase() + ".py")) {
+ return newClassName.toLowerCase() + ".py";
+ }
+ return super.suggestNameForElement(element, suggester, newClassName, oldClassName);
+ }
}
}
diff --git a/python/src/com/jetbrains/python/run/PythonConfigurationFactoryBase.java b/python/src/com/jetbrains/python/run/PythonConfigurationFactoryBase.java
new file mode 100644
index 0000000..1d0a082
--- /dev/null
+++ b/python/src/com/jetbrains/python/run/PythonConfigurationFactoryBase.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.jetbrains.python.run;
+
+import com.intellij.execution.configurations.ConfigurationFactory;
+import com.intellij.execution.configurations.ConfigurationType;
+import com.intellij.openapi.project.Project;
+import com.intellij.util.PlatformUtils;
+import com.jetbrains.python.sdk.PythonSdkType;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author nik
+ */
+public abstract class PythonConfigurationFactoryBase extends ConfigurationFactory {
+ protected PythonConfigurationFactoryBase(@NotNull ConfigurationType type) {
+ super(type);
+ }
+
+ @Override
+ public boolean isApplicable(@NotNull Project project) {
+ return PlatformUtils.isPyCharm() || PythonSdkType.hasValidSdk();
+ }
+}
diff --git a/python/src/com/jetbrains/python/run/PythonConfigurationType.java b/python/src/com/jetbrains/python/run/PythonConfigurationType.java
index 5f4cd95..6d2e26a 100644
--- a/python/src/com/jetbrains/python/run/PythonConfigurationType.java
+++ b/python/src/com/jetbrains/python/run/PythonConfigurationType.java
@@ -43,7 +43,7 @@
return null;
}
- private static class PythonConfigurationFactory extends ConfigurationFactory {
+ private static class PythonConfigurationFactory extends PythonConfigurationFactoryBase {
protected PythonConfigurationFactory(ConfigurationType configurationType) {
super(configurationType);
}
diff --git a/python/src/com/jetbrains/python/sdk/PythonSdkType.java b/python/src/com/jetbrains/python/sdk/PythonSdkType.java
index 0e64b29..65d80821 100644
--- a/python/src/com/jetbrains/python/sdk/PythonSdkType.java
+++ b/python/src/com/jetbrains/python/sdk/PythonSdkType.java
@@ -190,6 +190,15 @@
return s;
}
+ public static boolean hasValidSdk() {
+ for (Sdk sdk : ProjectJdkTable.getInstance().getAllJdks()) {
+ if (sdk.getSdkType() instanceof PythonSdkType) {
+ return true;
+ }
+ }
+ return false;
+ }
+
public boolean isValidSdkHome(@Nullable final String path) {
return PythonSdkFlavor.getFlavor(path) != null;
}
diff --git a/python/src/com/jetbrains/python/testing/PythonTestConfigurationType.java b/python/src/com/jetbrains/python/testing/PythonTestConfigurationType.java
index 9d9a396..059509a 100644
--- a/python/src/com/jetbrains/python/testing/PythonTestConfigurationType.java
+++ b/python/src/com/jetbrains/python/testing/PythonTestConfigurationType.java
@@ -15,9 +15,13 @@
*/
package com.jetbrains.python.testing;
-import com.intellij.execution.configurations.*;
+import com.intellij.execution.configurations.ConfigurationFactory;
+import com.intellij.execution.configurations.ConfigurationType;
+import com.intellij.execution.configurations.ConfigurationTypeUtil;
+import com.intellij.execution.configurations.RunConfiguration;
import com.intellij.openapi.project.Project;
import com.jetbrains.python.PyBundle;
+import com.jetbrains.python.run.PythonConfigurationFactoryBase;
import com.jetbrains.python.testing.attest.PythonAtTestRunConfiguration;
import com.jetbrains.python.testing.doctest.PythonDocTestRunConfiguration;
import com.jetbrains.python.testing.nosetest.PythonNoseTestRunConfiguration;
@@ -44,7 +48,7 @@
return ConfigurationTypeUtil.findConfigurationType(PythonTestConfigurationType.class);
}
- private static class PythonUnitTestConfigurationFactory extends ConfigurationFactory {
+ private static class PythonUnitTestConfigurationFactory extends PythonConfigurationFactoryBase {
protected PythonUnitTestConfigurationFactory(ConfigurationType configurationType) {
super(configurationType);
}
@@ -60,7 +64,7 @@
}
}
- private static class PythonDocTestConfigurationFactory extends ConfigurationFactory {
+ private static class PythonDocTestConfigurationFactory extends PythonConfigurationFactoryBase {
protected PythonDocTestConfigurationFactory(ConfigurationType configurationType) {
super(configurationType);
}
@@ -76,7 +80,7 @@
}
}
- private static class PythonPyTestConfigurationFactory extends ConfigurationFactory {
+ private static class PythonPyTestConfigurationFactory extends PythonConfigurationFactoryBase {
protected PythonPyTestConfigurationFactory(ConfigurationType configurationType) {
super(configurationType);
}
@@ -92,7 +96,7 @@
}
}
- private static class PythonNoseTestConfigurationFactory extends ConfigurationFactory {
+ private static class PythonNoseTestConfigurationFactory extends PythonConfigurationFactoryBase {
protected PythonNoseTestConfigurationFactory(ConfigurationType configurationType) {
super(configurationType);
}
@@ -108,7 +112,7 @@
}
}
- private static class PythonAtTestConfigurationFactory extends ConfigurationFactory {
+ private static class PythonAtTestConfigurationFactory extends PythonConfigurationFactoryBase {
protected PythonAtTestConfigurationFactory(ConfigurationType configurationType) {
super(configurationType);
}
diff --git a/python/src/com/jetbrains/python/validation/PyAnnotatingVisitor.java b/python/src/com/jetbrains/python/validation/PyAnnotatingVisitor.java
index e75fa04..39ab363 100644
--- a/python/src/com/jetbrains/python/validation/PyAnnotatingVisitor.java
+++ b/python/src/com/jetbrains/python/validation/PyAnnotatingVisitor.java
@@ -43,7 +43,6 @@
BreakContinueAnnotator.class,
GlobalAnnotator.class,
ImportAnnotator.class,
- StringLiteralQuotesAnnotator.class,
PyBuiltinAnnotator.class,
UnsupportedFeatures.class
};
diff --git a/python/src/com/jetbrains/python/validation/StringLiteralQuotesAnnotator.java b/python/src/com/jetbrains/python/validation/StringLiteralQuotesAnnotator.java
index abea262..0666e83 100644
--- a/python/src/com/jetbrains/python/validation/StringLiteralQuotesAnnotator.java
+++ b/python/src/com/jetbrains/python/validation/StringLiteralQuotesAnnotator.java
@@ -16,6 +16,7 @@
package com.jetbrains.python.validation;
import com.intellij.lang.ASTNode;
+import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.text.StringUtil;
import com.jetbrains.python.psi.PyStringLiteralExpression;
import com.jetbrains.python.psi.impl.PyStringLiteralExpressionImpl;
@@ -65,7 +66,15 @@
private boolean checkTripleQuotedString(ASTNode stringNode, String text, final String quotes) {
if (text.length() < 6 || !text.endsWith(quotes)) {
- getHolder().createErrorAnnotation(stringNode, "Missing closing triple quotes");
+ int startOffset = StringUtil.trimTrailing(stringNode.getText()).lastIndexOf('\n');
+ if (startOffset < 0) {
+ startOffset = stringNode.getTextRange().getStartOffset();
+ }
+ else {
+ startOffset = stringNode.getTextRange().getStartOffset() + startOffset + 1;
+ }
+ TextRange highlightRange = new TextRange(startOffset, stringNode.getTextRange().getEndOffset());
+ getHolder().createErrorAnnotation(highlightRange, "Missing closing triple quotes");
return true;
}
return false;
diff --git a/python/testData/findUsages/ConditionalFunctions.py b/python/testData/findUsages/ConditionalFunctions.py
new file mode 100644
index 0000000..39f63a8
--- /dev/null
+++ b/python/testData/findUsages/ConditionalFunctions.py
@@ -0,0 +1,14 @@
+import sys
+
+var = (sys.platform == 'win32')
+
+class A():
+ def __init__(self):
+ self.<caret>a = None
+
+ if var:
+ def func(self):
+ self.a = ""
+ else:
+ def func(self):
+ self.a = ()
\ No newline at end of file
diff --git a/python/testData/formatter/spacesInImportParentheses.py b/python/testData/formatter/spacesInImportParentheses.py
new file mode 100644
index 0000000..923e38d
--- /dev/null
+++ b/python/testData/formatter/spacesInImportParentheses.py
@@ -0,0 +1,5 @@
+from os import ( environ, getcwd )
+
+
+def foo():
+ print(environ, getcwd)
\ No newline at end of file
diff --git a/python/testData/formatter/spacesInImportParentheses_after.py b/python/testData/formatter/spacesInImportParentheses_after.py
new file mode 100644
index 0000000..4119a94
--- /dev/null
+++ b/python/testData/formatter/spacesInImportParentheses_after.py
@@ -0,0 +1,5 @@
+from os import (environ, getcwd)
+
+
+def foo():
+ print(environ, getcwd)
\ No newline at end of file
diff --git a/python/testData/formatter/wrapBeforeElse.py b/python/testData/formatter/wrapBeforeElse.py
new file mode 100644
index 0000000..6e3f8c9
--- /dev/null
+++ b/python/testData/formatter/wrapBeforeElse.py
@@ -0,0 +1 @@
+id = 1 if looooooooooooooooooooooooong_vaaaaaaaaaaaaaaaar == 'loooooooooooooooong_vaaaaaaaaaaaaaaaaaaaaaaaaaalue' else list('foo')[0]
\ No newline at end of file
diff --git a/python/testData/formatter/wrapBeforeElse_after.py b/python/testData/formatter/wrapBeforeElse_after.py
new file mode 100644
index 0000000..216c191
--- /dev/null
+++ b/python/testData/formatter/wrapBeforeElse_after.py
@@ -0,0 +1,2 @@
+id = 1 if looooooooooooooooooooooooong_vaaaaaaaaaaaaaaaar == 'loooooooooooooooong_vaaaaaaaaaaaaaaaaaaaaaaaaaalue' else list(
+ 'foo')[0]
\ No newline at end of file
diff --git a/python/testData/inspections/PyArgumentListInspection/decorators.py b/python/testData/inspections/PyArgumentListInspection/decorators.py
index 83b0955..9377b5e 100644
--- a/python/testData/inspections/PyArgumentListInspection/decorators.py
+++ b/python/testData/inspections/PyArgumentListInspection/decorators.py
@@ -19,7 +19,7 @@
def deco2(p1, p2): pass
-<warning descr="Parameter 'p2' unfilled">@deco2 # fail: missing p2</warning>
+<warning descr="Parameter 'p2' unfilled">@deco2</warning> # fail: missing p2
def f10():
pass
@@ -61,7 +61,7 @@
def f17():
pass
-<warning descr="Parameter 'p2' unfilled">@Dec2 # fail: no p2</warning>
+<warning descr="Parameter 'p2' unfilled">@Dec2</warning> # fail: no p2
def f18():
pass
diff --git a/python/testData/psi/CommentAfterDecorator.py b/python/testData/psi/CommentAfterDecorator.py
new file mode 100644
index 0000000..bd2fefc
--- /dev/null
+++ b/python/testData/psi/CommentAfterDecorator.py
@@ -0,0 +1,3 @@
+@uncallable_deco # some comment
+def f():
+ pass
diff --git a/python/testData/psi/CommentAfterDecorator.txt b/python/testData/psi/CommentAfterDecorator.txt
new file mode 100644
index 0000000..6e8214f
--- /dev/null
+++ b/python/testData/psi/CommentAfterDecorator.txt
@@ -0,0 +1,23 @@
+PyFile:CommentAfterDecorator.py
+ PyFunction('f')
+ PyDecoratorList
+ PyDecorator: @uncallable_deco
+ PsiElement(Py:AT)('@')
+ PyReferenceExpression: uncallable_deco
+ PsiElement(Py:IDENTIFIER)('uncallable_deco')
+ PyArgumentList
+ <empty list>
+ PsiWhiteSpace(' ')
+ PsiComment(Py:END_OF_LINE_COMMENT)('# some comment')
+ PsiWhiteSpace('\n')
+ PsiElement(Py:DEF_KEYWORD)('def')
+ PsiWhiteSpace(' ')
+ PsiElement(Py:IDENTIFIER)('f')
+ PyParameterList
+ PsiElement(Py:LPAR)('(')
+ PsiElement(Py:RPAR)(')')
+ PsiElement(Py:COLON)(':')
+ PsiWhiteSpace('\n ')
+ PyStatementList
+ PyPassStatement
+ PsiElement(Py:PASS_KEYWORD)('pass')
\ No newline at end of file
diff --git a/python/testData/psi/IfInList.py b/python/testData/psi/IfInList.py
new file mode 100644
index 0000000..ddf663c
--- /dev/null
+++ b/python/testData/psi/IfInList.py
@@ -0,0 +1,2 @@
+if "string" in "string", "string2":
+ pass
\ No newline at end of file
diff --git a/python/testData/psi/IfInList.txt b/python/testData/psi/IfInList.txt
new file mode 100644
index 0000000..a1c3cf5
--- /dev/null
+++ b/python/testData/psi/IfInList.txt
@@ -0,0 +1,22 @@
+PyFile:IfInList.py
+ PyIfStatement
+ PyIfPartIf
+ PsiElement(Py:IF_KEYWORD)('if')
+ PsiWhiteSpace(' ')
+ PyBinaryExpression
+ PyStringLiteralExpression: string
+ PsiElement(Py:SINGLE_QUOTED_STRING)('"string"')
+ PsiWhiteSpace(' ')
+ PsiElement(Py:IN_KEYWORD)('in')
+ PsiWhiteSpace(' ')
+ PyStringLiteralExpression: string
+ PsiElement(Py:SINGLE_QUOTED_STRING)('"string"')
+ PsiErrorElement:Colon expected
+ PsiElement(Py:COMMA)(',')
+ PsiWhiteSpace(' ')
+ PsiElement(Py:SINGLE_QUOTED_STRING)('"string2"')
+ PsiElement(Py:COLON)(':')
+ PsiWhiteSpace('\n ')
+ PyStatementList
+ PyPassStatement
+ PsiElement(Py:PASS_KEYWORD)('pass')
\ No newline at end of file
diff --git a/python/testData/psi/KeywordAsClassName.py b/python/testData/psi/KeywordAsClassName.py
new file mode 100644
index 0000000..41ee23a
--- /dev/null
+++ b/python/testData/psi/KeywordAsClassName.py
@@ -0,0 +1,2 @@
+class from:
+ pass
\ No newline at end of file
diff --git a/python/testData/psi/KeywordAsClassName.txt b/python/testData/psi/KeywordAsClassName.txt
new file mode 100644
index 0000000..d9d7aaf
--- /dev/null
+++ b/python/testData/psi/KeywordAsClassName.txt
@@ -0,0 +1,13 @@
+PyFile:KeywordAsClassName.py
+ PyClass: null
+ PsiElement(Py:CLASS_KEYWORD)('class')
+ PsiWhiteSpace(' ')
+ PsiErrorElement:Identifier expected
+ PsiElement(Py:FROM_KEYWORD)('from')
+ PyArgumentList
+ <empty list>
+ PsiElement(Py:COLON)(':')
+ PsiWhiteSpace('\n ')
+ PyStatementList
+ PyPassStatement
+ PsiElement(Py:PASS_KEYWORD)('pass')
\ No newline at end of file
diff --git a/python/testData/psi/KeywordAsFunctionName.py b/python/testData/psi/KeywordAsFunctionName.py
new file mode 100644
index 0000000..052077a
--- /dev/null
+++ b/python/testData/psi/KeywordAsFunctionName.py
@@ -0,0 +1,2 @@
+def from():
+ pass
\ No newline at end of file
diff --git a/python/testData/psi/KeywordAsFunctionName.txt b/python/testData/psi/KeywordAsFunctionName.txt
new file mode 100644
index 0000000..473ba30c
--- /dev/null
+++ b/python/testData/psi/KeywordAsFunctionName.txt
@@ -0,0 +1,14 @@
+PyFile:KeywordAsFunctionName.py
+ PyFunction('null')
+ PsiElement(Py:DEF_KEYWORD)('def')
+ PsiWhiteSpace(' ')
+ PsiErrorElement:function name expected
+ PsiElement(Py:FROM_KEYWORD)('from')
+ PyParameterList
+ PsiElement(Py:LPAR)('(')
+ PsiElement(Py:RPAR)(')')
+ PsiElement(Py:COLON)(':')
+ PsiWhiteSpace('\n ')
+ PyStatementList
+ PyPassStatement
+ PsiElement(Py:PASS_KEYWORD)('pass')
\ No newline at end of file
diff --git a/python/testData/psi/KeywordAsNamedParameter.py b/python/testData/psi/KeywordAsNamedParameter.py
new file mode 100644
index 0000000..6694d8e
--- /dev/null
+++ b/python/testData/psi/KeywordAsNamedParameter.py
@@ -0,0 +1,2 @@
+def f(from=1, another_one=2):
+ pass
\ No newline at end of file
diff --git a/python/testData/psi/KeywordAsNamedParameter.txt b/python/testData/psi/KeywordAsNamedParameter.txt
new file mode 100644
index 0000000..51d4413
--- /dev/null
+++ b/python/testData/psi/KeywordAsNamedParameter.txt
@@ -0,0 +1,24 @@
+PyFile:KeywordAsNamedParameter.py
+ PyFunction('f')
+ PsiElement(Py:DEF_KEYWORD)('def')
+ PsiWhiteSpace(' ')
+ PsiElement(Py:IDENTIFIER)('f')
+ PyParameterList
+ PsiElement(Py:LPAR)('(')
+ PsiErrorElement:formal parameter name expected
+ PsiElement(Py:FROM_KEYWORD)('from')
+ PsiElement(Py:EQ)('=')
+ PsiElement(Py:INTEGER_LITERAL)('1')
+ PsiElement(Py:COMMA)(',')
+ PsiWhiteSpace(' ')
+ PyNamedParameter('another_one')
+ PsiElement(Py:IDENTIFIER)('another_one')
+ PsiElement(Py:EQ)('=')
+ PyNumericLiteralExpression
+ PsiElement(Py:INTEGER_LITERAL)('2')
+ PsiElement(Py:RPAR)(')')
+ PsiElement(Py:COLON)(':')
+ PsiWhiteSpace('\n ')
+ PyStatementList
+ PyPassStatement
+ PsiElement(Py:PASS_KEYWORD)('pass')
\ No newline at end of file
diff --git a/python/testData/psi/WithMissingID.py b/python/testData/psi/WithMissingID.py
new file mode 100644
index 0000000..2cee86f
--- /dev/null
+++ b/python/testData/psi/WithMissingID.py
@@ -0,0 +1,2 @@
+with open("") as :
+ pass
\ No newline at end of file
diff --git a/python/testData/psi/WithMissingID.txt b/python/testData/psi/WithMissingID.txt
new file mode 100644
index 0000000..fa8caab
--- /dev/null
+++ b/python/testData/psi/WithMissingID.txt
@@ -0,0 +1,23 @@
+PyFile:WithMissingID.py
+ PyWithStatement
+ PsiElement(Py:WITH_KEYWORD)('with')
+ PsiWhiteSpace(' ')
+ PyWithItem
+ PyCallExpression: open
+ PyReferenceExpression: open
+ PsiElement(Py:IDENTIFIER)('open')
+ PyArgumentList
+ PsiElement(Py:LPAR)('(')
+ PyStringLiteralExpression:
+ PsiElement(Py:SINGLE_QUOTED_STRING)('""')
+ PsiElement(Py:RPAR)(')')
+ PsiWhiteSpace(' ')
+ PsiElement(Py:AS_KEYWORD)('as')
+ PsiErrorElement:identifier expected
+ <empty list>
+ PsiWhiteSpace(' ')
+ PsiElement(Py:COLON)(':')
+ PsiWhiteSpace('\n ')
+ PyStatementList
+ PyPassStatement
+ PsiElement(Py:PASS_KEYWORD)('pass')
\ No newline at end of file
diff --git a/python/testData/psi/WithStatement2.txt b/python/testData/psi/WithStatement2.txt
index b5a8e62..eb9c941 100644
--- a/python/testData/psi/WithStatement2.txt
+++ b/python/testData/psi/WithStatement2.txt
@@ -73,13 +73,8 @@
PsiErrorElement:expression expected
<empty list>
PsiErrorElement:Colon expected
- <empty list>
+ PsiElement(Py:EQ)('=')
+ PsiWhiteSpace(' ')
+ PsiElement(Py:INTEGER_LITERAL)('1')
PyStatementList
- <empty list>
- PsiElement(Py:EQ)('=')
- PsiErrorElement:Statement expected, found Py:EQ
- <empty list>
- PsiWhiteSpace(' ')
- PyExpressionStatement
- PyNumericLiteralExpression
- PsiElement(Py:INTEGER_LITERAL)('1')
\ No newline at end of file
+ <empty list>
\ No newline at end of file
diff --git a/python/testSrc/com/jetbrains/python/PyEditingTest.java b/python/testSrc/com/jetbrains/python/PyEditingTest.java
index a10fb71..6619bf8 100644
--- a/python/testSrc/com/jetbrains/python/PyEditingTest.java
+++ b/python/testSrc/com/jetbrains/python/PyEditingTest.java
@@ -127,7 +127,7 @@
}
public void testEnterInLineComment() { // PY-1739
- doTestEnter("# foo <caret>bar", "# foo \n# bar");
+ doTestEnter("# foo <caret>bar", "# foo \n# <caret>bar");
}
public void testEnterInPrefixString() { // PY-5058
@@ -318,7 +318,8 @@
private void doTestEnter(String before, final String after) {
int pos = before.indexOf("<caret>");
before = before.replace("<caret>", "");
- assertEquals(after, doTestTyping(before, pos, '\n'));
+ doTestTyping(before, pos, '\n');
+ myFixture.checkResult(after);
}
private String doTestTyping(final String text, final int offset, final char character) {
diff --git a/python/testSrc/com/jetbrains/python/PyFindUsagesTest.java b/python/testSrc/com/jetbrains/python/PyFindUsagesTest.java
index 2e22393..e906386 100644
--- a/python/testSrc/com/jetbrains/python/PyFindUsagesTest.java
+++ b/python/testSrc/com/jetbrains/python/PyFindUsagesTest.java
@@ -147,6 +147,11 @@
assertEquals(2, usages.size());
}
+ public void testConditionalFunctions() { // PY-1448
+ final Collection<UsageInfo> usages = myFixture.testFindUsages("findUsages/ConditionalFunctions.py");
+ assertEquals(3, usages.size());
+ }
+
private Collection<UsageInfo> findMultiFileUsages(String filename) {
final String testName = getTestName(false);
myFixture.copyDirectoryToProject("findUsages/" + testName, "");
diff --git a/python/testSrc/com/jetbrains/python/PyFormatterTest.java b/python/testSrc/com/jetbrains/python/PyFormatterTest.java
index d0275d5..bf6c1fe 100644
--- a/python/testSrc/com/jetbrains/python/PyFormatterTest.java
+++ b/python/testSrc/com/jetbrains/python/PyFormatterTest.java
@@ -337,12 +337,31 @@
doTest();
}
+ public void _testWrapBeforeElse() { // PY-10319
+ doTest(true);
+ }
+
+ public void testSpacesInImportParentheses() { // PY-11359
+ doTest();
+ }
+
private void doTest() {
+ doTest(false);
+ }
+
+ private void doTest(final boolean reformatText) {
myFixture.configureByFile("formatter/" + getTestName(true) + ".py");
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
- CodeStyleManager.getInstance(myFixture.getProject()).reformat(myFixture.getFile());
+ CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(myFixture.getProject());
+ PsiFile file = myFixture.getFile();
+ if (reformatText) {
+ codeStyleManager.reformatText(file, 0, file.getTextLength());
+ }
+ else {
+ codeStyleManager.reformat(file);
+ }
}
});
myFixture.checkResultByFile("formatter/" + getTestName(true) + "_after.py");
diff --git a/python/testSrc/com/jetbrains/python/PyQuickFixTest.java b/python/testSrc/com/jetbrains/python/PyQuickFixTest.java
index 9f5dccc..e0f82b0 100644
--- a/python/testSrc/com/jetbrains/python/PyQuickFixTest.java
+++ b/python/testSrc/com/jetbrains/python/PyQuickFixTest.java
@@ -33,20 +33,20 @@
public class PyQuickFixTest extends PyTestCase {
public void testAddImport() {
- doInspectionTest(new String[] { "AddImport.py", "ImportTarget.py" }, PyUnresolvedReferencesInspection.class, PyBundle.message("ACT.NAME.use.import"), true, true);
+ doInspectionTest(new String[] { "AddImport.py", "ImportTarget.py" }, PyUnresolvedReferencesInspection.class, "Import 'ImportTarget'", true, true);
}
public void testAddImportDoc() {
- doInspectionTest(new String[] { "AddImportDoc.py", "ImportTarget.py" }, PyUnresolvedReferencesInspection.class, PyBundle.message("ACT.NAME.use.import"), true, true);
+ doInspectionTest(new String[] { "AddImportDoc.py", "ImportTarget.py" }, PyUnresolvedReferencesInspection.class, "Import 'ImportTarget'", true, true);
}
public void testAddImportDocComment() { // PY-728
- doInspectionTest(new String[] { "AddImportDocComment.py", "ImportTarget.py" }, PyUnresolvedReferencesInspection.class, PyBundle.message("ACT.NAME.use.import"), true, true);
+ doInspectionTest(new String[] { "AddImportDocComment.py", "ImportTarget.py" }, PyUnresolvedReferencesInspection.class, "Import 'ImportTarget'", true, true);
}
public void testImportFromModule() {
doInspectionTest(new String[] { "importFromModule/foo/bar.py", "importFromModule/foo/baz.py", "importFromModule/foo/__init__.py" },
- PyUnresolvedReferencesInspection.class, PyBundle.message("ACT.NAME.use.import"), true, true);
+ PyUnresolvedReferencesInspection.class, "Import 'importFromModule.foo.baz'", true, true);
}
public void testImportFromModuleStar() { // PY-6302
@@ -54,7 +54,7 @@
myFixture.copyDirectoryToProject("importFromModuleStar", "");
myFixture.configureFromTempProjectFile("source.py");
myFixture.checkHighlighting(true, false, false);
- final IntentionAction intentionAction = myFixture.findSingleIntention(PyBundle.message("ACT.NAME.use.import"));
+ final IntentionAction intentionAction = myFixture.findSingleIntention("Import 'target.xyzzy()'");
assertNotNull(intentionAction);
myFixture.launchAction(intentionAction);
myFixture.checkResultByFile("importFromModuleStar/source_after.py");
@@ -80,7 +80,7 @@
boolean oldHighlightUnused = settings.HIGHLIGHT_UNUSED_IMPORTS;
settings.HIGHLIGHT_UNUSED_IMPORTS = false;
try {
- doInspectionTest(new String[]{"AddToImportFromList.py", "AddToImportFromFoo.py"}, PyUnresolvedReferencesInspection.class, PyBundle.message("ACT.NAME.use.import"), true, true);
+ doInspectionTest(new String[]{"AddToImportFromList.py", "AddToImportFromFoo.py"}, PyUnresolvedReferencesInspection.class, "Import 'foo(a) from AddToImportFromFoo'", true, true);
}
finally {
settings.HIGHLIGHT_UNUSED_IMPORTS = oldHighlightUnused;
diff --git a/python/testSrc/com/jetbrains/python/PythonCompletionTest.java b/python/testSrc/com/jetbrains/python/PythonCompletionTest.java
index c00e632..4f93cca 100644
--- a/python/testSrc/com/jetbrains/python/PythonCompletionTest.java
+++ b/python/testSrc/com/jetbrains/python/PythonCompletionTest.java
@@ -16,6 +16,7 @@
package com.jetbrains.python;
import com.intellij.codeInsight.completion.impl.CamelHumpMatcher;
+import com.intellij.codeInsight.lookup.Lookup;
import com.intellij.codeInsight.lookup.LookupElement;
import com.jetbrains.python.documentation.DocStringFormat;
import com.jetbrains.python.documentation.PyDocumentationSettings;
@@ -583,4 +584,21 @@
"f('foo').<caret>\n");
assertTrue(results.contains("lower"));
}
+
+ public void testOverwriteEqualsSign() { // PY-1337
+ doTestByText("def foo(school=None, kiga=None): pass\n" +
+ "foo(<caret>school=None)");
+ myFixture.type("sch");
+ myFixture.finishLookup(Lookup.REPLACE_SELECT_CHAR);
+ myFixture.checkResult("def foo(school=None, kiga=None): pass\n" +
+ "foo(school=None)");
+ }
+
+ public void testOverwriteBracket() { // PY-6095
+ doTestByText("bar = {'a': '1'}\n" +
+ "print ba<caret>['a']");
+ myFixture.finishLookup(Lookup.REPLACE_SELECT_CHAR);
+ myFixture.checkResult("bar = {'a': '1'}\n" +
+ "print bar<caret>['a']");
+ }
}
diff --git a/python/testSrc/com/jetbrains/python/PythonParsingTest.java b/python/testSrc/com/jetbrains/python/PythonParsingTest.java
index 87f9e53..fbbabda 100644
--- a/python/testSrc/com/jetbrains/python/PythonParsingTest.java
+++ b/python/testSrc/com/jetbrains/python/PythonParsingTest.java
@@ -402,6 +402,30 @@
doTest();
}
+ public void testCommentAfterDecorator() { // PY-5912
+ doTest();
+ }
+
+ public void testKeywordAsNamedParameter() { // PY-8318
+ doTest();
+ }
+
+ public void testKeywordAsClassName() { // PY-8319
+ doTest();
+ }
+
+ public void testKeywordAsFunctionName() { // PY-8319
+ doTest();
+ }
+
+ public void testIfInList() { // PY-9561
+ doTest();
+ }
+
+ public void testWithMissingID() { // PY-9853
+ doTest(LanguageLevel.PYTHON27);
+ }
+
public void doTest(LanguageLevel languageLevel) {
LanguageLevel prev = myLanguageLevel;
myLanguageLevel = languageLevel;
diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml
index 09bf0b3..05517c4 100644
--- a/resources/src/META-INF/IdeaPlugin.xml
+++ b/resources/src/META-INF/IdeaPlugin.xml
@@ -235,8 +235,14 @@
<extensionPoint name="java.compilerOutputIndex" area="IDEA_PROJECT"
interface="com.intellij.compilerOutputIndex.api.indexer.CompilerOutputBaseIndex"/>
+
<extensionPoint name="vetoSPICondition" interface="com.intellij.openapi.util.Condition"/>
+
<extensionPoint name="testStatusListener" interface="com.intellij.execution.testframework.TestStatusListener"/>
+
+ <extensionPoint name="hierarchy.referenceProcessor" interface="com.intellij.ide.hierarchy.call.CallReferenceProcessor"/>
+
+ <extensionPoint name="lang.psiAugmentProvider" interface="com.intellij.psi.augment.PsiAugmentProvider"/>
</extensionPoints>
<extensions defaultExtensionNs="com.intellij">
@@ -977,16 +983,14 @@
<langCodeStyleSettingsProvider implementation="com.intellij.ide.JavaLanguageCodeStyleSettingsProvider"/>
- <stacktrace.fold substring="at java.awt.EventDispatchThread.pumpEventsForFilter("/>
- <stacktrace.fold substring="at java.awt.EventDispatchThread.pumpEventsForHierarchy("/>
- <stacktrace.fold substring="at java.awt.EventDispatchThread.pumpEvents("/>
+ <stacktrace.fold substring="at java.awt.EventDispatchThread"/>
<stacktrace.fold substring="at java.awt.Window.dispatchEventImpl("/>
<stacktrace.fold substring="at java.awt.Container.dispatchEventImpl("/>
<stacktrace.fold substring="at java.awt.LightweightDispatcher."/>
<stacktrace.fold substring="at java.awt.Component.dispatchEvent("/>
- <stacktrace.fold substring="at java.awt.EventQueue.dispatchEvent("/>
+ <stacktrace.fold substring="at java.awt.event.InvocationEvent.dispatch("/>
+ <stacktrace.fold substring="at java.awt.EventQueue"/>
<stacktrace.fold substring="at java.awt.Component.dispatchEventImpl("/>
- <stacktrace.fold substring="at java.awt.EventDispatchThread.pumpOneEventForFilters("/>
<stacktrace.fold substring="at java.awt.Container.processEvent("/>
<stacktrace.fold substring="at javax.swing.JComponent.processMouseEvent("/>
<stacktrace.fold substring="at javax.swing.plaf.basic.BasicMenuItemUI"/>
@@ -998,12 +1002,10 @@
<stacktrace.fold substring="at javax.swing.DefaultButtonModel.setPressed("/>
<stacktrace.fold substring="at javax.swing.AbstractButton.fireActionPerformed("/>
<stacktrace.fold substring="at javax.swing.AbstractButton$Handler.actionPerformed("/>
- <stacktrace.fold substring="at java.awt.EventQueue$1.run("/>
<stacktrace.fold substring="at java.security.AccessControlContext$1.doIntersectionPrivilege("/>
<stacktrace.fold substring="at java.awt.EventQueue.dispatchEventImpl("/>
<stacktrace.fold substring="at java.security.AccessController.doPrivileged(Native Method)"/>
- <stacktrace.fold substring="at java.awt.EventQueue$2.run("/>
- <stacktrace.fold substring="at java.awt.EventQueue.access$000("/>
+ <stacktrace.fold substring="at java.security.ProtectionDomain$1.doIntersectionPrivilege("/>
<stacktrace.fold substring="at com.jgoodies.binding.beans.ExtendedPropertyChangeSupport.firePropertyChange0("/>
<stacktrace.fold substring="at javax.swing.plaf.basic.BasicComboPopup$Handler.mouseReleased("/>
@@ -1483,6 +1485,9 @@
<xdebugger.breakpointType implementation="org.jetbrains.java.debugger.breakpoints.JavaBreakpointType"/>
<refactoring.pullUpHelperFactory language="JAVA" implementationClass="com.intellij.refactoring.memberPullUp.JavaPullUpHelperFactory"/>
+ <hierarchy.referenceProcessor implementation="com.intellij.ide.hierarchy.call.JavaCallReferenceProcessor"/>
+ <projectTemplate projectType="Java" templatePath="resources/projectTemplates/Java/Command_Line_App.zip"/>
+ <generatedSourcesFilter implementation="com.intellij.openapi.roots.JavaGeneratedSourcesFilter"/>
</extensions>
<actions>
diff --git a/resources/src/idea/JavaActions.xml b/resources/src/idea/JavaActions.xml
index 7f0ae1c..c0a7d4a 100644
--- a/resources/src/idea/JavaActions.xml
+++ b/resources/src/idea/JavaActions.xml
@@ -315,6 +315,12 @@
<reference ref="Debugger.CustomizeContextView"/>
</group>
+ <group id="MarkGeneratedSourceRootGroup">
+ <action id="MarkGeneratedSourceRoot" class="com.intellij.ide.projectView.actions.MarkGeneratedSourceRootAction"/>
+ <action id="UnmarkGeneratedSourceRoot" class="com.intellij.ide.projectView.actions.UnmarkGeneratedSourceRootAction"/>
+ <add-to-group group-id="MarkRootGroup" anchor="after" relative-to-action="MarkSourceRootGroup"/>
+ </group>
+
<action id="ShowPackageDeps" class="com.intellij.packageDependencies.actions.AnalyzeDependenciesAction">
<add-to-group group-id="ShowPackageDepsGroup" anchor="first"/>
<add-to-group group-id="AnalyzeActions" anchor="first"/>
diff --git a/resources/src/idea/RichPlatformPlugin.xml b/resources/src/idea/RichPlatformPlugin.xml
index 7f388cc..11b2997 100644
--- a/resources/src/idea/RichPlatformPlugin.xml
+++ b/resources/src/idea/RichPlatformPlugin.xml
@@ -1,4 +1,5 @@
<idea-plugin version="2" xmlns:xi="http://www.w3.org/2001/XInclude">
+ <!-- former Flex IDE foundation, todo: integrate into IdeaPlugin.xml -->
<module value="com.intellij.modules.platform"/>
<module value="com.intellij.modules.lang"/>
diff --git a/spellchecker/src/com/intellij/spellchecker/engine/BaseSpellChecker.java b/spellchecker/src/com/intellij/spellchecker/engine/BaseSpellChecker.java
index dc4e2ff..d5a0674 100644
--- a/spellchecker/src/com/intellij/spellchecker/engine/BaseSpellChecker.java
+++ b/spellchecker/src/com/intellij/spellchecker/engine/BaseSpellChecker.java
@@ -18,10 +18,6 @@
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.progress.PerformInBackgroundOption;
-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.project.ProjectManager;
import com.intellij.openapi.startup.StartupManager;
@@ -103,70 +99,48 @@
final Runnable runnable = new Runnable() {
@Override
public void run() {
- if (myProject.isDisposed()) return;
LOG.debug("Loading " + loader.getName());
- ProgressManager.getInstance()
- .run(new Task.Backgroundable(myProject, "Loading spellchecker dictionaries...", false,
- new PerformInBackgroundOption() {
- @Override
- public boolean shouldStartInBackground() {
- return true;
- }
+ ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
+ @Override
+ public void run() {
+ if (ApplicationManager.getApplication().isDisposed()) return;
+
+ final CompressedDictionary dictionary = CompressedDictionary.create(loader, transform);
+ LOG.debug(loader.getName() + " loaded!");
+ consumer.consume(dictionary);
- @Override
- public void processSentToBackground() {
- }
- }) {
- @Override
- public void run(@NotNull ProgressIndicator indicator) {
- indicator.setText(String.format("Loading %s...", loader.getName()));
- final CompressedDictionary dictionary = CompressedDictionary.create(loader, transform);
- LOG.debug(loader.getName() + " loaded!");
- consumer.consume(dictionary);
+ while (!myDictionariesToLoad.isEmpty()) {
+ if (ApplicationManager.getApplication().isDisposed()) return;
+
+ final Pair<Loader, Consumer<Dictionary>> nextDictionary = myDictionariesToLoad.remove(0);
+ Loader nextDictionaryLoader = nextDictionary.getFirst();
+ CompressedDictionary dictionary1 = CompressedDictionary.create(nextDictionaryLoader, transform);
+ LOG.debug(nextDictionaryLoader.getName() + " loaded!");
+ nextDictionary.getSecond().consume(dictionary1);
+ }
- while (!myDictionariesToLoad.isEmpty()) {
- final Pair<Loader, Consumer<Dictionary>> nextDictionary = myDictionariesToLoad.remove(0);
- Loader nextDictionaryLoader = nextDictionary.getFirst();
- indicator.setText(String.format("Loading %s...", nextDictionaryLoader.getName()));
- CompressedDictionary dictionary1 = CompressedDictionary.create(nextDictionaryLoader, transform);
- LOG.debug(nextDictionaryLoader.getName() + " loaded!");
- nextDictionary.getSecond().consume(dictionary1);
- }
-
- LOG.debug("Loading finished, restarting daemon...");
- myLoadingDictionaries.set(false);
- final Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
- for (final Project project : openProjects) {
- if (project.isInitialized() && project.isOpen() && !project.isDefault()) {
- UIUtil.invokeLaterIfNeeded(new Runnable() {
- @Override
- public void run() {
- if (project.isDisposed()) return;
- final DaemonCodeAnalyzer instance = DaemonCodeAnalyzer.getInstance(project);
- if (instance != null) instance.restart();
- }
- });
+ LOG.debug("Loading finished, restarting daemon...");
+ myLoadingDictionaries.set(false);
+ UIUtil.invokeLaterIfNeeded(new Runnable() {
+ @Override
+ public void run() {
+ if (ApplicationManager.getApplication().isDisposed()) return;
+
+ for (final Project project : ProjectManager.getInstance().getOpenProjects()) {
+ if (project.isInitialized() && project.isOpen() && !project.isDefault()) {
+ final DaemonCodeAnalyzer instance = DaemonCodeAnalyzer.getInstance(project);
+ if (instance != null) instance.restart();
+ }
}
}
- }
- });
+ });
+ }
+ });
}
};
- if (!myProject.isInitialized()) {
- StartupManager.getInstance(myProject).runWhenProjectIsInitialized(
- new Runnable() {
- @Override
- public void run() {
- UIUtil.invokeLaterIfNeeded(runnable);
- }
- }
- );
- }
- else {
- UIUtil.invokeLaterIfNeeded(runnable);
- }
+ StartupManager.getInstance(myProject).runWhenProjectIsInitialized(runnable);
}
private void queueDictionaryLoad(final Loader loader, final Consumer<Dictionary> consumer) {
diff --git a/xml/dom-impl/src/META-INF/DomPlugin.xml b/xml/dom-impl/src/META-INF/DomPlugin.xml
index 9fdaaed..00b15cb 100644
--- a/xml/dom-impl/src/META-INF/DomPlugin.xml
+++ b/xml/dom-impl/src/META-INF/DomPlugin.xml
@@ -32,6 +32,7 @@
<filetype.stubBuilder filetype="XML" implementationClass="com.intellij.util.xml.stubs.builder.DomStubBuilder"/>
<stubElementTypeHolder class="com.intellij.util.xml.stubs.DomElementTypeHolder"/>
+ <stubIndex implementation="com.intellij.util.xml.stubs.index.DomNamespaceKeyIndex"/>
<applicationService serviceInterface="com.intellij.util.xml.impl.DomApplicationComponent"
serviceImplementation="com.intellij.util.xml.impl.DomApplicationComponent"/>
diff --git a/xml/dom-impl/src/com/intellij/util/xml/stubs/ElementStubSerializer.java b/xml/dom-impl/src/com/intellij/util/xml/stubs/ElementStubSerializer.java
index 5247af3..d1522f5 100644
--- a/xml/dom-impl/src/com/intellij/util/xml/stubs/ElementStubSerializer.java
+++ b/xml/dom-impl/src/com/intellij/util/xml/stubs/ElementStubSerializer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,10 +15,12 @@
*/
package com.intellij.util.xml.stubs;
+import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.stubs.IndexSink;
import com.intellij.psi.stubs.ObjectStubSerializer;
import com.intellij.psi.stubs.StubInputStream;
import com.intellij.psi.stubs.StubOutputStream;
+import com.intellij.util.xml.stubs.index.DomNamespaceKeyIndex;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
@@ -46,6 +48,10 @@
@Override
public void indexStub(@NotNull ElementStub stub, @NotNull IndexSink sink) {
+ final String namespaceKey = stub.getNamespaceKey();
+ if (StringUtil.isNotEmpty(namespaceKey)) {
+ sink.occurrence(DomNamespaceKeyIndex.KEY, namespaceKey);
+ }
}
@NotNull
diff --git a/xml/dom-impl/src/com/intellij/util/xml/stubs/index/DomNamespaceKeyIndex.java b/xml/dom-impl/src/com/intellij/util/xml/stubs/index/DomNamespaceKeyIndex.java
new file mode 100644
index 0000000..b3528ba
--- /dev/null
+++ b/xml/dom-impl/src/com/intellij/util/xml/stubs/index/DomNamespaceKeyIndex.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.util.xml.stubs.index;
+
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.openapi.vfs.VirtualFileWithId;
+import com.intellij.psi.PsiFile;
+import com.intellij.psi.search.GlobalSearchScope;
+import com.intellij.psi.stubs.StringStubIndexExtension;
+import com.intellij.psi.stubs.StubIndex;
+import com.intellij.psi.stubs.StubIndexKey;
+import com.intellij.util.CommonProcessors;
+import com.intellij.util.indexing.IdFilter;
+import com.intellij.util.xml.DomFileElement;
+import org.jetbrains.annotations.NotNull;
+
+public class DomNamespaceKeyIndex extends StringStubIndexExtension<PsiFile> {
+
+ public static final StubIndexKey<String, PsiFile> KEY = StubIndexKey.createIndexKey("dom.namespaceKey");
+
+ private static final DomNamespaceKeyIndex ourInstance = new DomNamespaceKeyIndex();
+
+ public static DomNamespaceKeyIndex getInstance() {
+ return ourInstance;
+ }
+
+ public boolean hasStubElementsWithNamespaceKey(final DomFileElement domFileElement, final String namespaceKey) {
+ final VirtualFile file = domFileElement.getFile().getVirtualFile();
+ assert file instanceof VirtualFileWithId : file;
+
+ final int virtualFileId = ((VirtualFileWithId)file).getId();
+ CommonProcessors.FindFirstProcessor<String> processor =
+ new CommonProcessors.FindFirstProcessor<String>() {
+ @Override
+ protected boolean accept(String s) {
+ return namespaceKey.equals(s);
+ }
+ };
+ StubIndex.getInstance().processAllKeys(KEY, processor,
+ GlobalSearchScope.fileScope(domFileElement.getFile()),
+ new IdFilter() {
+ @Override
+ public boolean containsFileId(int id) {
+ return id == virtualFileId;
+ }
+ });
+ return processor.isFound();
+ }
+
+ @Override
+ public boolean traceKeyHashToVirtualFileMapping() {
+ return true;
+ }
+
+ @NotNull
+ @Override
+ public StubIndexKey<String, PsiFile> getKey() {
+ return KEY;
+ }
+
+ @Override
+ public int getVersion() {
+ return 0;
+ }
+}
diff --git a/xml/dom-openapi/src/com/intellij/util/xml/AbstractConvertContext.java b/xml/dom-openapi/src/com/intellij/util/xml/AbstractConvertContext.java
index f8f8e69..fc7cbef 100644
--- a/xml/dom-openapi/src/com/intellij/util/xml/AbstractConvertContext.java
+++ b/xml/dom-openapi/src/com/intellij/util/xml/AbstractConvertContext.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,7 +16,7 @@
package com.intellij.util.xml;
import com.intellij.openapi.module.Module;
-import com.intellij.openapi.module.ModuleUtil;
+import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.openapi.roots.ProjectFileIndex;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.vfs.VirtualFile;
@@ -52,7 +52,7 @@
final DomFileElement<DomElement> fileElement = DomUtil.getFileElement(getInvocationElement());
if (fileElement == null) {
final XmlElement xmlElement = getInvocationElement().getXmlElement();
- return xmlElement == null ? null : ModuleUtil.findModuleForPsiElement(xmlElement);
+ return xmlElement == null ? null : ModuleUtilCore.findModuleForPsiElement(xmlElement);
}
return fileElement.getRootElement().getModule();
}
@@ -65,7 +65,7 @@
public GlobalSearchScope getSearchScope() {
GlobalSearchScope scope = null;
- Module[] modules = getConvertContextModules(this);
+ Module[] modules = getConvertContextModules();
if (modules.length != 0) {
PsiFile file = getFile();
@@ -88,39 +88,14 @@
return scope; // ??? scope == null ? GlobalSearchScope.allScope(getProject()) : scope; ???
}
- public static GlobalSearchScope getSearchScope(@NotNull ConvertContext context) {
- Module[] modules = getConvertContextModules(context);
- if (modules.length == 0) return null;
-
- PsiFile file = context.getFile();
- file = file.getOriginalFile();
- VirtualFile virtualFile = file.getVirtualFile();
- if (virtualFile == null) return null;
- ProjectFileIndex fileIndex = ProjectRootManager.getInstance(file.getProject()).getFileIndex();
- boolean tests = fileIndex.isInTestSourceContent(virtualFile);
-
-
- GlobalSearchScope scope = null;
- for (Module module : modules) {
- if (scope == null) {
- scope = module.getModuleRuntimeScope(tests);
- }
- else {
- scope.union(module.getModuleRuntimeScope(tests));
- }
- }
- return scope;
- }
-
-
@NotNull
- private static Module[] getConvertContextModules(@NotNull ConvertContext context) {
- Module[] modules = ModuleContextProvider.getModules(context.getFile());
+ private Module[] getConvertContextModules() {
+ Module[] modules = ModuleContextProvider.getModules(getFile());
if (modules.length > 0) return modules;
- final Module module = context.getModule();
+ final Module module = getModule();
if (module != null) return new Module[]{module};
- return new Module[0];
+ return Module.EMPTY_ARRAY;
}
}
diff --git a/xml/impl/src/com/intellij/codeInsight/completion/XmlCompletionData.java b/xml/impl/src/com/intellij/codeInsight/completion/XmlCompletionData.java
index bf87f35..4249986 100644
--- a/xml/impl/src/com/intellij/codeInsight/completion/XmlCompletionData.java
+++ b/xml/impl/src/com/intellij/codeInsight/completion/XmlCompletionData.java
@@ -32,6 +32,7 @@
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.xml.*;
import com.intellij.util.ArrayUtil;
+import com.intellij.xml.Html5SchemaProvider;
import com.intellij.xml.XmlElementDescriptor;
import com.intellij.xml.XmlNSDescriptor;
import com.intellij.xml.util.HtmlUtil;
@@ -186,7 +187,7 @@
try {
final int unicodeChar = Integer.valueOf(s).intValue();
- return LookupValueFactory.createLookupValueWithHint(name, null, new String(Character.toChars(unicodeChar)));
+ return LookupValueFactory.createLookupValueWithHint(name, null, String.valueOf((char)unicodeChar));
}
catch (NumberFormatException e) {
return null;
@@ -208,8 +209,9 @@
descriptorFile = findDescriptorFile(tag, containingFile);
}
- boolean isHtml5 = false;
- if (tag == null || (isHtml5 = HtmlUtil.isHtml5Context(tag))) { // Html5 RNG does not have entities
+ if (HtmlUtil.isHtml5Context(tag)) {
+ descriptorFile = XmlUtil.findXmlFile(containingFile, Html5SchemaProvider.getCharsDtdLocation());
+ } else if (tag == null) {
final XmlDocument document = PsiTreeUtil.getParentOfType(context, XmlDocument.class);
if (document != null) {
@@ -218,7 +220,7 @@
final FileType ft = containingFile.getFileType();
if(ft != StdFileTypes.XML) {
- final String namespace = ft == StdFileTypes.XHTML || ft == StdFileTypes.JSPX || isHtml5? XmlUtil.XHTML_URI:XmlUtil.HTML_URI;
+ final String namespace = ft == StdFileTypes.XHTML || ft == StdFileTypes.JSPX ? XmlUtil.XHTML_URI : XmlUtil.HTML_URI;
final XmlNSDescriptor nsDescriptor = document.getDefaultNSDescriptor(namespace, true);
if (nsDescriptor != null) {
diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/SurroundWithEmmetAction.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/SurroundWithEmmetAction.java
new file mode 100644
index 0000000..4ba8816
--- /dev/null
+++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/SurroundWithEmmetAction.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.codeInsight.template.emmet;
+
+import com.intellij.application.options.emmet.EmmetOptions;
+import com.intellij.codeInsight.CodeInsightActionHandler;
+import com.intellij.codeInsight.actions.BaseCodeInsightAction;
+import com.intellij.codeInsight.hint.HintManager;
+import com.intellij.codeInsight.template.CustomTemplateCallback;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.editor.Document;
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.editor.SelectionModel;
+import com.intellij.openapi.fileEditor.FileDocumentManager;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.vfs.ReadonlyStatusHandler;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.psi.PsiDocumentManager;
+import com.intellij.psi.PsiFile;
+import org.jetbrains.annotations.NotNull;
+
+public class SurroundWithEmmetAction extends BaseCodeInsightAction {
+ public SurroundWithEmmetAction() {
+ setEnabledInModalContext(true);
+ }
+
+ @Override
+ protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
+ return EmmetOptions.getInstance().isEmmetEnabled() && new ZenCodingTemplate().isApplicable(file, editor.getCaretModel().getOffset(), true);
+ }
+
+ @NotNull
+ @Override
+ protected CodeInsightActionHandler getHandler() {
+ return new SurroundWithEmmetHandler();
+ }
+
+ private static class SurroundWithEmmetHandler implements CodeInsightActionHandler {
+ @Override
+ public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
+ SelectionModel selectionModel = editor.getSelectionModel();
+ if (!selectionModel.hasSelection() && !selectionModel.hasBlockSelection()) {
+ selectionModel.selectLineAtCaret();
+ }
+
+ final Document document = editor.getDocument();
+ final VirtualFile virtualFile = FileDocumentManager.getInstance().getFile(document);
+ if (virtualFile != null) {
+ ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(virtualFile);
+ }
+
+ String selection = editor.getSelectionModel().getSelectedText();
+
+ final ZenCodingTemplate template = new ZenCodingTemplate();
+ if (selection != null && template.isApplicable(file, editor.getCaretModel().getOffset(), true)) {
+ selection = selection.trim();
+ PsiDocumentManager.getInstance(project).commitAllDocuments();
+ template.wrap(selection, new CustomTemplateCallback(editor, file, true));
+ }
+ else if (!ApplicationManager.getApplication().isUnitTestMode()) {
+ HintManager.getInstance().showErrorHint(editor, "Cannot invoke Surround with Emmet in the current context");
+ }
+ }
+
+ @Override
+ public boolean startInWriteAction() {
+ return true;
+ }
+ }
+}
diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java
index 236743c..a80b08d 100644
--- a/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java
+++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java
@@ -381,6 +381,13 @@
return applicableGenerator != null && applicableGenerator.isEnabled();
}
+ @Override
+ public boolean hasCompletionItem(@NotNull PsiFile file, int offset) {
+ PsiElement element = CustomTemplateCallback.getContext(file, offset);
+ final ZenCodingGenerator applicableGenerator = findApplicableDefaultGenerator(element, false);
+ return applicableGenerator != null && applicableGenerator.isEnabled() && applicableGenerator.hasCompletionItem();
+ }
+
public static void doWrap(final String selection, final String abbreviation, final CustomTemplateCallback callback) {
final ZenCodingGenerator defaultGenerator = findApplicableDefaultGenerator(callback.getContext(), true);
assert defaultGenerator != null;
diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/generators/ZenCodingGenerator.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/generators/ZenCodingGenerator.java
index 5c23ba9..1965bf1 100644
--- a/xml/impl/src/com/intellij/codeInsight/template/emmet/generators/ZenCodingGenerator.java
+++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/generators/ZenCodingGenerator.java
@@ -179,4 +179,8 @@
public UnnamedConfigurable createConfigurable() {
return null;
}
+
+ public boolean hasCompletionItem() {
+ return false;
+ }
}
diff --git a/xml/impl/src/com/intellij/ide/browsers/OpenFileInDefaultBrowserAction.java b/xml/impl/src/com/intellij/ide/browsers/OpenFileInDefaultBrowserAction.java
index 7e82281..92f5abf 100644
--- a/xml/impl/src/com/intellij/ide/browsers/OpenFileInDefaultBrowserAction.java
+++ b/xml/impl/src/com/intellij/ide/browsers/OpenFileInDefaultBrowserAction.java
@@ -15,7 +15,7 @@
*/
package com.intellij.ide.browsers;
-import com.intellij.ide.BrowserUtil;
+import com.intellij.icons.AllIcons;
import com.intellij.ide.GeneralSettings;
import com.intellij.ide.browsers.impl.WebBrowserServiceImpl;
import com.intellij.openapi.actionSystem.*;
@@ -23,13 +23,23 @@
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.ui.Messages;
+import com.intellij.openapi.ui.popup.JBPopupFactory;
+import com.intellij.openapi.util.AsyncResult;
import com.intellij.openapi.util.Pair;
+import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.testFramework.LightVirtualFile;
+import com.intellij.ui.ColoredListCellRenderer;
+import com.intellij.ui.components.JBList;
+import com.intellij.util.Consumer;
+import com.intellij.util.containers.ContainerUtil;
import com.intellij.xml.XmlBundle;
import com.intellij.xml.util.HtmlUtil;
+import org.jetbrains.annotations.NotNull;
+import javax.swing.*;
import java.awt.event.InputEvent;
+import java.util.Set;
public class OpenFileInDefaultBrowserAction extends DumbAwareAction {
private static final Logger LOG = Logger.getInstance(OpenFileInDefaultBrowserAction.class);
@@ -46,7 +56,7 @@
return;
}
- Pair<WebBrowserUrlProvider, Url> browserUrlProvider = WebBrowserServiceImpl.getProvider(file);
+ Pair<WebBrowserUrlProvider, Set<Url>> browserUrlProvider = WebBrowserServiceImpl.getProvider(file);
final boolean isHtmlFile = HtmlUtil.isHtmlFile(file);
if (browserUrlProvider == null) {
if (file.getVirtualFile() instanceof LightVirtualFile) {
@@ -102,15 +112,20 @@
PsiFile psiFile = CommonDataKeys.PSI_FILE.getData(dataContext);
LOG.assertTrue(psiFile != null);
InputEvent event = e.getInputEvent();
- doOpen(psiFile, event != null && event.isShiftDown());
+ doOpen(psiFile, event != null && event.isShiftDown(), null);
}
- static void doOpen(PsiFile psiFile, boolean preferLocalUrl) {
+ public static void doOpen(PsiElement psiFile, boolean preferLocalUrl, final WebBrowser browser) {
try {
- Url url = WebBrowserService.getInstance().getUrlToOpen(psiFile, preferLocalUrl);
- if (url != null) {
- ApplicationManager.getApplication().saveAll();
- BrowserUtil.launchBrowser(url.toExternalForm());
+ Set<Url> urls = WebBrowserService.getInstance().getUrlToOpen(psiFile, preferLocalUrl);
+ if (!urls.isEmpty()) {
+ chooseUrl(urls).doWhenDone(new Consumer<Url>() {
+ @Override
+ public void consume(Url url) {
+ ApplicationManager.getApplication().saveAll();
+ UrlOpener.launchBrowser(url.toExternalForm(), browser);
+ }
+ });
}
}
catch (WebBrowserUrlProvider.BrowserException e1) {
@@ -120,4 +135,40 @@
LOG.error(e1);
}
}
+
+ @NotNull
+ private static AsyncResult<Url> chooseUrl(Set<Url> urls) {
+ if (urls.size() == 1) {
+ return new AsyncResult.Done<Url>(ContainerUtil.getFirstItem(urls));
+ }
+
+ final JBList list = new JBList(urls);
+ list.setCellRenderer(new ColoredListCellRenderer() {
+ @Override
+ protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
+ // todo icons looks good, but is it really suitable for all URLs providers?
+ setIcon(AllIcons.Nodes.Servlet);
+ append(((Url)value).getPath());
+ }
+ });
+
+ final AsyncResult<Url> result = new AsyncResult<Url>();
+ JBPopupFactory.getInstance().
+ createListPopupBuilder(list).
+ setTitle("Choose Url").
+ setItemChoosenCallback(new Runnable() {
+ @Override
+ public void run() {
+ Url value = (Url)list.getSelectedValue();
+ if (value != null) {
+ result.setDone(value);
+ }
+ else {
+ result.setRejected();
+ }
+ }
+ }).
+ createPopup().showInFocusCenter();
+ return result;
+ }
}
diff --git a/xml/impl/src/com/intellij/ide/browsers/SelectInDefaultBrowserTarget.java b/xml/impl/src/com/intellij/ide/browsers/SelectInDefaultBrowserTarget.java
index 3114bb8..55ceeeb 100644
--- a/xml/impl/src/com/intellij/ide/browsers/SelectInDefaultBrowserTarget.java
+++ b/xml/impl/src/com/intellij/ide/browsers/SelectInDefaultBrowserTarget.java
@@ -27,6 +27,8 @@
import com.intellij.xml.XmlBundle;
import com.intellij.xml.util.HtmlUtil;
+import java.util.Set;
+
class SelectInDefaultBrowserTarget extends SelectInTargetBase {
private static final Logger LOG = Logger.getInstance(SelectInDefaultBrowserTarget.class);
@@ -44,7 +46,7 @@
return false;
}
- Pair<WebBrowserUrlProvider, Url> browserUrlProvider = WebBrowserServiceImpl.getProvider(file);
+ Pair<WebBrowserUrlProvider, Set<Url>> browserUrlProvider = WebBrowserServiceImpl.getProvider(file);
currentName = XmlBundle.message("browser.select.in.default.name");
if (browserUrlProvider == null) {
return HtmlUtil.isHtmlFile(file) && !(file.getVirtualFile() instanceof LightVirtualFile);
@@ -69,7 +71,7 @@
LOG.assertTrue(psiElement != null);
PsiFile psiFile = psiElement.getContainingFile();
LOG.assertTrue(psiFile != null);
- OpenFileInDefaultBrowserAction.doOpen(psiFile, false);
+ OpenFileInDefaultBrowserAction.doOpen(psiFile, false, null);
}
@Override
diff --git a/xml/impl/src/com/intellij/ide/browsers/UrlImpl.java b/xml/impl/src/com/intellij/ide/browsers/UrlImpl.java
index 936cda3..3523ad9b 100644
--- a/xml/impl/src/com/intellij/ide/browsers/UrlImpl.java
+++ b/xml/impl/src/com/intellij/ide/browsers/UrlImpl.java
@@ -169,6 +169,9 @@
return true;
}
if (!(o instanceof UrlImpl)) {
+ if (o instanceof LocalFileUrl && isInLocalFileSystem()) {
+ return o.getPath().equals(path);
+ }
return false;
}
diff --git a/xml/impl/src/com/intellij/ide/browsers/Urls.java b/xml/impl/src/com/intellij/ide/browsers/Urls.java
index 763204d..cd40599 100644
--- a/xml/impl/src/com/intellij/ide/browsers/Urls.java
+++ b/xml/impl/src/com/intellij/ide/browsers/Urls.java
@@ -120,12 +120,23 @@
// must not be used in NodeJS
public static Url newFromVirtualFile(@NotNull VirtualFile file) {
- String path = file.getPath();
if (file.isInLocalFileSystem()) {
- return new UrlImpl(file.getFileSystem().getProtocol(), null, path);
+ return new UrlImpl(file.getFileSystem().getProtocol(), null, file.getPath());
}
else {
return parseUrl(file.getUrl(), false);
}
}
+
+ public static boolean equalsIgnoreParameters(@NotNull Url url, @NotNull VirtualFile file) {
+ if (file.isInLocalFileSystem()) {
+ return url.isInLocalFileSystem() && url.getPath().equals(file.getPath());
+ }
+ else if (url.isInLocalFileSystem()) {
+ return false;
+ }
+
+ Url fileUrl = parseUrl(file.getUrl(), false);
+ return fileUrl != null && fileUrl.equalsIgnoreParameters(url);
+ }
}
\ No newline at end of file
diff --git a/xml/impl/src/com/intellij/ide/browsers/impl/WebBrowserServiceImpl.java b/xml/impl/src/com/intellij/ide/browsers/impl/WebBrowserServiceImpl.java
index 4541caf..af7eb2e 100644
--- a/xml/impl/src/com/intellij/ide/browsers/impl/WebBrowserServiceImpl.java
+++ b/xml/impl/src/com/intellij/ide/browsers/impl/WebBrowserServiceImpl.java
@@ -27,10 +27,14 @@
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.testFramework.LightVirtualFile;
+import com.intellij.util.containers.ContainerUtil;
import com.intellij.xml.util.HtmlUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import java.util.Collections;
+import java.util.Set;
+
public class WebBrowserServiceImpl extends WebBrowserService {
@Override
public boolean canOpenInBrowser(@NotNull PsiElement psiElement) {
@@ -40,32 +44,32 @@
((HtmlUtil.isHtmlFile(psiFile) && !(virtualFile instanceof LightVirtualFile)) || getProvider(psiElement, psiFile) != null);
}
+ @NotNull
@Override
- @Nullable
- public Url getUrlToOpen(@NotNull PsiElement psiElement, boolean preferLocalUrl) throws WebBrowserUrlProvider.BrowserException {
+ public Set<Url> getUrlToOpen(@NotNull PsiElement psiElement, boolean preferLocalUrl) throws WebBrowserUrlProvider.BrowserException {
final PsiFile psiFile = psiElement instanceof PsiFile ? (PsiFile)psiElement : psiElement.getContainingFile();
if (psiFile == null) {
- return null;
+ return Collections.emptySet();
}
VirtualFile virtualFile = psiFile.getVirtualFile();
if (virtualFile == null) {
- return null;
+ return Collections.emptySet();
}
if (virtualFile instanceof HttpVirtualFile) {
- return Urls.newFromVirtualFile(virtualFile);
+ return Collections.singleton(Urls.newFromVirtualFile(virtualFile));
}
if (!(preferLocalUrl && HtmlUtil.isHtmlFile(psiFile))) {
- Pair<WebBrowserUrlProvider, Url> provider = getProvider(psiElement);
+ Pair<WebBrowserUrlProvider, Set<Url>> provider = getProvider(psiElement);
if (provider != null) {
if (provider.second != null) {
return provider.second;
}
try {
- Url url = provider.first.getUrl(psiElement, psiFile, virtualFile);
- if (url != null) {
- return url;
+ Set<Url> urls = provider.first.getUrls(psiElement, psiFile, virtualFile);
+ if (!urls.isEmpty()) {
+ return urls;
}
}
catch (WebBrowserUrlProvider.BrowserException e) {
@@ -75,28 +79,17 @@
}
}
}
- return virtualFile instanceof LightVirtualFile ? null : Urls.newFromVirtualFile(virtualFile);
- }
-
- @Override
- @Nullable
- public Url getUrlToOpen(@NotNull PsiElement psiElement) {
- try {
- return getUrlToOpen(psiElement, false);
- }
- catch (WebBrowserUrlProvider.BrowserException ignored) {
- return null;
- }
+ return virtualFile instanceof LightVirtualFile ? Collections.<Url>emptySet() : Collections.singleton(Urls.newFromVirtualFile(virtualFile));
}
@Nullable
- public static Pair<WebBrowserUrlProvider, Url> getProvider(@Nullable PsiElement element) {
+ public static Pair<WebBrowserUrlProvider, Set<Url>> getProvider(@Nullable PsiElement element) {
PsiFile psiFile = element == null ? null : element.getContainingFile();
return psiFile == null ? null : getProvider(element, psiFile);
}
- private static Pair<WebBrowserUrlProvider, Url> getProvider(PsiElement element, PsiFile psiFile) {
- Ref<Url> result = Ref.create();
+ private static Pair<WebBrowserUrlProvider, Set<Url>> getProvider(PsiElement element, PsiFile psiFile) {
+ Ref<Set<Url>> result = Ref.create();
DumbService dumbService = DumbService.getInstance(element.getProject());
for (WebBrowserUrlProvider urlProvider : WebBrowserUrlProvider.EP_NAME.getExtensions()) {
if ((!dumbService.isDumb() || DumbService.isDumbAware(urlProvider)) && urlProvider.canHandleElement(element, psiFile, result)) {
@@ -113,8 +106,15 @@
return null;
}
- Url url = WebBrowserService.getInstance().getUrlToOpen(sourceElement);
- if (url == null) {
+ Url url;
+ try {
+ Set<Url> urls = WebBrowserService.getInstance().getUrlToOpen(sourceElement, false);
+ url = ContainerUtil.getFirstItem(urls);
+ if (url == null) {
+ return null;
+ }
+ }
+ catch (WebBrowserUrlProvider.BrowserException ignored) {
return null;
}
@@ -123,7 +123,6 @@
return null;
}
- boolean isRemote = !url.isInLocalFileSystem();
- return isRemote || HtmlUtil.isHtmlFile(virtualFile) ? url : null;
+ return !url.isInLocalFileSystem() || HtmlUtil.isHtmlFile(virtualFile) ? url : null;
}
}
diff --git a/xml/impl/src/com/intellij/javaee/EditLocationDialog.java b/xml/impl/src/com/intellij/javaee/EditLocationDialog.java
index 443e0d6..a07d232 100644
--- a/xml/impl/src/com/intellij/javaee/EditLocationDialog.java
+++ b/xml/impl/src/com/intellij/javaee/EditLocationDialog.java
@@ -22,6 +22,7 @@
import com.intellij.openapi.ui.FixedSizeButton;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.util.Consumer;
import com.intellij.xml.XmlBundle;
import javax.swing.*;
@@ -63,54 +64,53 @@
init();
}
+ @Override
protected JComponent createCenterPanel() {
JPanel panel = new JPanel(new GridBagLayout());
panel.add(
- new JLabel(myName),
- new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 3, 5), 0, 0)
+ new JLabel(myName),
+ new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 3, 5), 0, 0)
);
panel.add(
- myTfUrl,
- new GridBagConstraints(0, 1, 2, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 5), 0, 0)
+ myTfUrl,
+ new GridBagConstraints(0, 1, 2, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 5), 0, 0)
);
myTfUrl.setPreferredSize(new Dimension(350, myTfUrl.getPreferredSize().height));
- if (myShowPath) {
+ if (myShowPath) {
panel.add(
- new JLabel(myLocation),
- new GridBagConstraints(0, 2, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 3, 5), 0, 0)
+ new JLabel(myLocation),
+ new GridBagConstraints(0, 2, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 3, 5), 0, 0)
);
panel.add(
- myTfPath,
- new GridBagConstraints(0, 3, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 10, 0), 0, 0)
+ myTfPath,
+ new GridBagConstraints(0, 3, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 10, 0), 0, 0)
);
panel.add(
- myBtnBrowseLocalPath,
- new GridBagConstraints(1, 3, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 10, 5), 0, 0)
+ myBtnBrowseLocalPath,
+ new GridBagConstraints(1, 3, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 10, 5), 0, 0)
);
- //
- TextFieldWithBrowseButton.MyDoClickAction.addTo(myBtnBrowseLocalPath, myTfPath);
- myBtnBrowseLocalPath.addActionListener(
- new ActionListener() {
- public void actionPerformed(ActionEvent ignored) {
- FileChooserDescriptor descriptor = getChooserDescriptor();
- VirtualFile file = FileChooser.chooseFile(descriptor, myProject, null);
- if (file != null) {
- myTfPath.setText(file.getPath().replace('/', File.separatorChar));
- }
+ TextFieldWithBrowseButton.MyDoClickAction.addTo(myBtnBrowseLocalPath, myTfPath);
+ myBtnBrowseLocalPath.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent ignored) {
+ FileChooserDescriptor descriptor = getChooserDescriptor();
+ FileChooser.chooseFile(descriptor, myProject, null, new Consumer<VirtualFile>() {
+ @Override
+ public void consume(VirtualFile file) {
+ myTfPath.setText(file.getPath().replace('/', File.separatorChar));
}
- }
- );
+ });
+ }
+ });
}
-
- //
-
return panel;
}
+ @Override
public JComponent getPreferredFocusedComponent() {
return myTfUrl;
}
@@ -125,6 +125,7 @@
return new FileChooserDescriptor(true, false, false, false, true, false);
}
+ @Override
protected void init() {
setTitle(myTitle);
myTfUrl = new JTextField();
diff --git a/xml/impl/src/com/intellij/psi/impl/source/xml/DefaultXmlTagNameProvider.java b/xml/impl/src/com/intellij/psi/impl/source/xml/DefaultXmlTagNameProvider.java
index 1c6ddd4..714d305 100644
--- a/xml/impl/src/com/intellij/psi/impl/source/xml/DefaultXmlTagNameProvider.java
+++ b/xml/impl/src/com/intellij/psi/impl/source/xml/DefaultXmlTagNameProvider.java
@@ -15,6 +15,7 @@
*/
package com.intellij.psi.impl.source.xml;
+import com.intellij.codeInsight.completion.PrioritizedLookupElement;
import com.intellij.codeInsight.completion.XmlTagInsertHandler;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupElementBuilder;
@@ -69,11 +70,10 @@
lookupElement = lookupElement.withIcon(((PsiPresentableMetaData)descriptor).getIcon());
}
if (xmlExtension.useXmlTagInsertHandler()) {
- elements.add(lookupElement.withInsertHandler(XmlTagInsertHandler.INSTANCE));
+ lookupElement = lookupElement.withInsertHandler(XmlTagInsertHandler.INSTANCE);
}
- else {
- elements.add(lookupElement);
- }
+
+ elements.add(PrioritizedLookupElement.withPriority(lookupElement, separator > 0 ? 0 : 1));
}
}
diff --git a/xml/openapi/src/com/intellij/ide/browsers/WebBrowserService.java b/xml/openapi/src/com/intellij/ide/browsers/WebBrowserService.java
index a6acf58..267cfd0 100644
--- a/xml/openapi/src/com/intellij/ide/browsers/WebBrowserService.java
+++ b/xml/openapi/src/com/intellij/ide/browsers/WebBrowserService.java
@@ -18,7 +18,8 @@
import com.intellij.openapi.components.ServiceManager;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
+
+import java.util.Set;
public abstract class WebBrowserService {
public static WebBrowserService getInstance() {
@@ -27,9 +28,6 @@
public abstract boolean canOpenInBrowser(@NotNull PsiElement psiElement);
- @Nullable
- public abstract Url getUrlToOpen(@NotNull PsiElement psiElement);
-
- @Nullable
- public abstract Url getUrlToOpen(@NotNull PsiElement psiElement, boolean preferLocalUrl) throws WebBrowserUrlProvider.BrowserException;
+ @NotNull
+ public abstract Set<Url> getUrlToOpen(@NotNull PsiElement psiElement, boolean preferLocalUrl) throws WebBrowserUrlProvider.BrowserException;
}
\ No newline at end of file
diff --git a/xml/openapi/src/com/intellij/ide/browsers/WebBrowserUrlProvider.java b/xml/openapi/src/com/intellij/ide/browsers/WebBrowserUrlProvider.java
index 2bdf78c..e0d0c85 100644
--- a/xml/openapi/src/com/intellij/ide/browsers/WebBrowserUrlProvider.java
+++ b/xml/openapi/src/com/intellij/ide/browsers/WebBrowserUrlProvider.java
@@ -23,11 +23,14 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import java.util.Collections;
+import java.util.Set;
+
public abstract class WebBrowserUrlProvider {
public static ExtensionPointName<WebBrowserUrlProvider> EP_NAME = ExtensionPointName.create("com.intellij.webBrowserUrlProvider");
/**
- * Browser exceptions are printed in Error Dialog when user presses any browser button.
+ * Browser exceptions are printed in Error Dialog when user presses any browser button
*/
public static class BrowserException extends Exception {
public BrowserException(final String message) {
@@ -35,16 +38,16 @@
}
}
- public boolean canHandleElement(@NotNull PsiElement element, @NotNull PsiFile psiFile, @NotNull Ref<Url> result) {
+ public boolean canHandleElement(@NotNull PsiElement element, @NotNull PsiFile psiFile, @NotNull Ref<Set<Url>> result) {
VirtualFile file = psiFile.getVirtualFile();
if (file == null) {
return false;
}
try {
- Url url = getUrl(element, psiFile, file);
- if (url != null) {
- result.set(url);
+ Set<Url> urls = getUrls(element, psiFile, file);
+ if (!urls.isEmpty()) {
+ result.set(urls);
return true;
}
}
@@ -55,7 +58,14 @@
}
@Nullable
- public abstract Url getUrl(@NotNull PsiElement element, @NotNull PsiFile psiFile, @NotNull VirtualFile virtualFile) throws BrowserException;
+ protected Url getUrl(@NotNull PsiElement element, @NotNull PsiFile psiFile, @NotNull VirtualFile virtualFile) throws BrowserException {
+ return null;
+ }
+
+ public Set<Url> getUrls(@NotNull PsiElement element, @NotNull PsiFile psiFile, @NotNull VirtualFile virtualFile) throws BrowserException {
+ Url url = getUrl(element, psiFile, virtualFile);
+ return url == null ? Collections.<Url>emptySet() : Collections.singleton(url);
+ }
@Nullable
public String getOpenInBrowserActionText(@NotNull PsiFile file) {
diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/RngHtml5SchemaProvider.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/RngHtml5SchemaProvider.java
index e86e532..d59cd90 100644
--- a/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/RngHtml5SchemaProvider.java
+++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/xml/RngHtml5SchemaProvider.java
@@ -20,4 +20,10 @@
public URL getXhtmlSchemaLocation() {
return RngHtml5SchemaProvider.class.getResource("/resources/html5-schema/xhtml5.rnc");
}
+
+ @NotNull
+ @Override
+ public URL getCharsLocation() {
+ return RngHtml5SchemaProvider.class.getResource("/resources/html5-schema/html5chars.ent");
+ }
}
diff --git a/xml/relaxng/src/resources/html5-schema/html5charref.rb b/xml/relaxng/src/resources/html5-schema/html5charref.rb
new file mode 100755
index 0000000..b5850d6
--- /dev/null
+++ b/xml/relaxng/src/resources/html5-schema/html5charref.rb
@@ -0,0 +1,38 @@
+#! /usr/bin/env ruby
+CHAR_REFS_URL = 'http://dev.w3.org/html5/html-author/charref'
+refs = `curl #{CHAR_REFS_URL}`
+
+header = <<header
+<!--
+ * Copyright 2000-#{Time.now.year} JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ -->
+
+<!-- It's an automatically generated code. Do not modify it. -->
+<!-- Please see #{CHAR_REFS_URL} and #{$0} -->
+
+header
+
+body = ""
+refs.scan(/<td class="named"><code>&((\w|; &)+);\<\/code><td class="hex"><code>&(#([^;])*);<\/code><td class="dec"><code>&(#([^;])*);<\/code>/) do | match |
+ $1.split("; &").each do | name |
+ body = body + " <!ENTITY #{name} \"&#{$5};\" >\n"
+ end
+end
+
+
+footer = <<footer
+footer
+
+puts header + body + footer
\ No newline at end of file
diff --git a/xml/relaxng/src/resources/html5-schema/html5chars.ent b/xml/relaxng/src/resources/html5-schema/html5chars.ent
new file mode 100644
index 0000000..419a0e6
--- /dev/null
+++ b/xml/relaxng/src/resources/html5-schema/html5chars.ent
@@ -0,0 +1,2050 @@
+<!--
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ -->
+
+<!-- It's an automatically generated code. Do not modify it. -->
+<!-- Please see http://dev.w3.org/html5/html-author/charref and ./html5charref.rb -->
+
+ <!ENTITY Tab "	" >
+ <!ENTITY NewLine " " >
+ <!ENTITY excl "!" >
+ <!ENTITY quot """ >
+ <!ENTITY QUOT """ >
+ <!ENTITY num "#" >
+ <!ENTITY dollar "$" >
+ <!ENTITY percnt "%" >
+ <!ENTITY amp "&" >
+ <!ENTITY AMP "&" >
+ <!ENTITY apos "'" >
+ <!ENTITY lpar "(" >
+ <!ENTITY rpar ")" >
+ <!ENTITY ast "*" >
+ <!ENTITY midast "*" >
+ <!ENTITY plus "+" >
+ <!ENTITY comma "," >
+ <!ENTITY period "." >
+ <!ENTITY sol "/" >
+ <!ENTITY colon ":" >
+ <!ENTITY semi ";" >
+ <!ENTITY lt "<" >
+ <!ENTITY LT "<" >
+ <!ENTITY equals "=" >
+ <!ENTITY gt ">" >
+ <!ENTITY GT ">" >
+ <!ENTITY quest "?" >
+ <!ENTITY commat "@" >
+ <!ENTITY lsqb "[" >
+ <!ENTITY lbrack "[" >
+ <!ENTITY bsol "\" >
+ <!ENTITY rsqb "]" >
+ <!ENTITY rbrack "]" >
+ <!ENTITY Hat "^" >
+ <!ENTITY lowbar "_" >
+ <!ENTITY grave "`" >
+ <!ENTITY DiacriticalGrave "`" >
+ <!ENTITY lcub "{" >
+ <!ENTITY lbrace "{" >
+ <!ENTITY verbar "|" >
+ <!ENTITY vert "|" >
+ <!ENTITY VerticalLine "|" >
+ <!ENTITY rcub "}" >
+ <!ENTITY rbrace "}" >
+ <!ENTITY nbsp " " >
+ <!ENTITY NonBreakingSpace " " >
+ <!ENTITY iexcl "¡" >
+ <!ENTITY cent "¢" >
+ <!ENTITY pound "£" >
+ <!ENTITY curren "¤" >
+ <!ENTITY yen "¥" >
+ <!ENTITY brvbar "¦" >
+ <!ENTITY sect "§" >
+ <!ENTITY Dot "¨" >
+ <!ENTITY die "¨" >
+ <!ENTITY DoubleDot "¨" >
+ <!ENTITY uml "¨" >
+ <!ENTITY copy "©" >
+ <!ENTITY COPY "©" >
+ <!ENTITY ordf "ª" >
+ <!ENTITY laquo "«" >
+ <!ENTITY not "¬" >
+ <!ENTITY shy "­" >
+ <!ENTITY reg "®" >
+ <!ENTITY circledR "®" >
+ <!ENTITY REG "®" >
+ <!ENTITY macr "¯" >
+ <!ENTITY OverBar "¯" >
+ <!ENTITY strns "¯" >
+ <!ENTITY deg "°" >
+ <!ENTITY plusmn "±" >
+ <!ENTITY pm "±" >
+ <!ENTITY PlusMinus "±" >
+ <!ENTITY sup2 "²" >
+ <!ENTITY sup3 "³" >
+ <!ENTITY acute "´" >
+ <!ENTITY DiacriticalAcute "´" >
+ <!ENTITY micro "µ" >
+ <!ENTITY para "¶" >
+ <!ENTITY middot "·" >
+ <!ENTITY centerdot "·" >
+ <!ENTITY CenterDot "·" >
+ <!ENTITY cedil "¸" >
+ <!ENTITY Cedilla "¸" >
+ <!ENTITY sup1 "¹" >
+ <!ENTITY ordm "º" >
+ <!ENTITY raquo "»" >
+ <!ENTITY frac14 "¼" >
+ <!ENTITY frac12 "½" >
+ <!ENTITY half "½" >
+ <!ENTITY frac34 "¾" >
+ <!ENTITY iquest "¿" >
+ <!ENTITY Agrave "À" >
+ <!ENTITY Aacute "Á" >
+ <!ENTITY Acirc "Â" >
+ <!ENTITY Atilde "Ã" >
+ <!ENTITY Auml "Ä" >
+ <!ENTITY Aring "Å" >
+ <!ENTITY AElig "Æ" >
+ <!ENTITY Ccedil "Ç" >
+ <!ENTITY Egrave "È" >
+ <!ENTITY Eacute "É" >
+ <!ENTITY Ecirc "Ê" >
+ <!ENTITY Euml "Ë" >
+ <!ENTITY Igrave "Ì" >
+ <!ENTITY Iacute "Í" >
+ <!ENTITY Icirc "Î" >
+ <!ENTITY Iuml "Ï" >
+ <!ENTITY ETH "Ð" >
+ <!ENTITY Ntilde "Ñ" >
+ <!ENTITY Ograve "Ò" >
+ <!ENTITY Oacute "Ó" >
+ <!ENTITY Ocirc "Ô" >
+ <!ENTITY Otilde "Õ" >
+ <!ENTITY Ouml "Ö" >
+ <!ENTITY times "×" >
+ <!ENTITY Oslash "Ø" >
+ <!ENTITY Ugrave "Ù" >
+ <!ENTITY Uacute "Ú" >
+ <!ENTITY Ucirc "Û" >
+ <!ENTITY Uuml "Ü" >
+ <!ENTITY Yacute "Ý" >
+ <!ENTITY THORN "Þ" >
+ <!ENTITY szlig "ß" >
+ <!ENTITY agrave "à" >
+ <!ENTITY aacute "á" >
+ <!ENTITY acirc "â" >
+ <!ENTITY atilde "ã" >
+ <!ENTITY auml "ä" >
+ <!ENTITY aring "å" >
+ <!ENTITY aelig "æ" >
+ <!ENTITY ccedil "ç" >
+ <!ENTITY egrave "è" >
+ <!ENTITY eacute "é" >
+ <!ENTITY ecirc "ê" >
+ <!ENTITY euml "ë" >
+ <!ENTITY igrave "ì" >
+ <!ENTITY iacute "í" >
+ <!ENTITY icirc "î" >
+ <!ENTITY iuml "ï" >
+ <!ENTITY eth "ð" >
+ <!ENTITY ntilde "ñ" >
+ <!ENTITY ograve "ò" >
+ <!ENTITY oacute "ó" >
+ <!ENTITY ocirc "ô" >
+ <!ENTITY otilde "õ" >
+ <!ENTITY ouml "ö" >
+ <!ENTITY divide "÷" >
+ <!ENTITY div "÷" >
+ <!ENTITY oslash "ø" >
+ <!ENTITY ugrave "ù" >
+ <!ENTITY uacute "ú" >
+ <!ENTITY ucirc "û" >
+ <!ENTITY uuml "ü" >
+ <!ENTITY yacute "ý" >
+ <!ENTITY thorn "þ" >
+ <!ENTITY yuml "ÿ" >
+ <!ENTITY Amacr "Ā" >
+ <!ENTITY amacr "ā" >
+ <!ENTITY Abreve "Ă" >
+ <!ENTITY abreve "ă" >
+ <!ENTITY Aogon "Ą" >
+ <!ENTITY aogon "ą" >
+ <!ENTITY Cacute "Ć" >
+ <!ENTITY cacute "ć" >
+ <!ENTITY Ccirc "Ĉ" >
+ <!ENTITY ccirc "ĉ" >
+ <!ENTITY Cdot "Ċ" >
+ <!ENTITY cdot "ċ" >
+ <!ENTITY Ccaron "Č" >
+ <!ENTITY ccaron "č" >
+ <!ENTITY Dcaron "Ď" >
+ <!ENTITY dcaron "ď" >
+ <!ENTITY Dstrok "Đ" >
+ <!ENTITY dstrok "đ" >
+ <!ENTITY Emacr "Ē" >
+ <!ENTITY emacr "ē" >
+ <!ENTITY Edot "Ė" >
+ <!ENTITY edot "ė" >
+ <!ENTITY Eogon "Ę" >
+ <!ENTITY eogon "ę" >
+ <!ENTITY Ecaron "Ě" >
+ <!ENTITY ecaron "ě" >
+ <!ENTITY Gcirc "Ĝ" >
+ <!ENTITY gcirc "ĝ" >
+ <!ENTITY Gbreve "Ğ" >
+ <!ENTITY gbreve "ğ" >
+ <!ENTITY Gdot "Ġ" >
+ <!ENTITY gdot "ġ" >
+ <!ENTITY Gcedil "Ģ" >
+ <!ENTITY Hcirc "Ĥ" >
+ <!ENTITY hcirc "ĥ" >
+ <!ENTITY Hstrok "Ħ" >
+ <!ENTITY hstrok "ħ" >
+ <!ENTITY Itilde "Ĩ" >
+ <!ENTITY itilde "ĩ" >
+ <!ENTITY Imacr "Ī" >
+ <!ENTITY imacr "ī" >
+ <!ENTITY Iogon "Į" >
+ <!ENTITY iogon "į" >
+ <!ENTITY Idot "İ" >
+ <!ENTITY imath "ı" >
+ <!ENTITY inodot "ı" >
+ <!ENTITY IJlig "IJ" >
+ <!ENTITY ijlig "ij" >
+ <!ENTITY Jcirc "Ĵ" >
+ <!ENTITY jcirc "ĵ" >
+ <!ENTITY Kcedil "Ķ" >
+ <!ENTITY kcedil "ķ" >
+ <!ENTITY kgreen "ĸ" >
+ <!ENTITY Lacute "Ĺ" >
+ <!ENTITY lacute "ĺ" >
+ <!ENTITY Lcedil "Ļ" >
+ <!ENTITY lcedil "ļ" >
+ <!ENTITY Lcaron "Ľ" >
+ <!ENTITY lcaron "ľ" >
+ <!ENTITY Lmidot "Ŀ" >
+ <!ENTITY lmidot "ŀ" >
+ <!ENTITY Lstrok "Ł" >
+ <!ENTITY lstrok "ł" >
+ <!ENTITY Nacute "Ń" >
+ <!ENTITY nacute "ń" >
+ <!ENTITY Ncedil "Ņ" >
+ <!ENTITY ncedil "ņ" >
+ <!ENTITY Ncaron "Ň" >
+ <!ENTITY ncaron "ň" >
+ <!ENTITY napos "ʼn" >
+ <!ENTITY ENG "Ŋ" >
+ <!ENTITY eng "ŋ" >
+ <!ENTITY Omacr "Ō" >
+ <!ENTITY omacr "ō" >
+ <!ENTITY Odblac "Ő" >
+ <!ENTITY odblac "ő" >
+ <!ENTITY OElig "Œ" >
+ <!ENTITY oelig "œ" >
+ <!ENTITY Racute "Ŕ" >
+ <!ENTITY racute "ŕ" >
+ <!ENTITY Rcedil "Ŗ" >
+ <!ENTITY rcedil "ŗ" >
+ <!ENTITY Rcaron "Ř" >
+ <!ENTITY rcaron "ř" >
+ <!ENTITY Sacute "Ś" >
+ <!ENTITY sacute "ś" >
+ <!ENTITY Scirc "Ŝ" >
+ <!ENTITY scirc "ŝ" >
+ <!ENTITY Scedil "Ş" >
+ <!ENTITY scedil "ş" >
+ <!ENTITY Scaron "Š" >
+ <!ENTITY scaron "š" >
+ <!ENTITY Tcedil "Ţ" >
+ <!ENTITY tcedil "ţ" >
+ <!ENTITY Tcaron "Ť" >
+ <!ENTITY tcaron "ť" >
+ <!ENTITY Tstrok "Ŧ" >
+ <!ENTITY tstrok "ŧ" >
+ <!ENTITY Utilde "Ũ" >
+ <!ENTITY utilde "ũ" >
+ <!ENTITY Umacr "Ū" >
+ <!ENTITY umacr "ū" >
+ <!ENTITY Ubreve "Ŭ" >
+ <!ENTITY ubreve "ŭ" >
+ <!ENTITY Uring "Ů" >
+ <!ENTITY uring "ů" >
+ <!ENTITY Udblac "Ű" >
+ <!ENTITY udblac "ű" >
+ <!ENTITY Uogon "Ų" >
+ <!ENTITY uogon "ų" >
+ <!ENTITY Wcirc "Ŵ" >
+ <!ENTITY wcirc "ŵ" >
+ <!ENTITY Ycirc "Ŷ" >
+ <!ENTITY ycirc "ŷ" >
+ <!ENTITY Yuml "Ÿ" >
+ <!ENTITY Zacute "Ź" >
+ <!ENTITY zacute "ź" >
+ <!ENTITY Zdot "Ż" >
+ <!ENTITY zdot "ż" >
+ <!ENTITY Zcaron "Ž" >
+ <!ENTITY zcaron "ž" >
+ <!ENTITY fnof "ƒ" >
+ <!ENTITY imped "Ƶ" >
+ <!ENTITY gacute "ǵ" >
+ <!ENTITY jmath "ȷ" >
+ <!ENTITY circ "ˆ" >
+ <!ENTITY caron "ˇ" >
+ <!ENTITY Hacek "ˇ" >
+ <!ENTITY breve "˘" >
+ <!ENTITY Breve "˘" >
+ <!ENTITY dot "˙" >
+ <!ENTITY DiacriticalDot "˙" >
+ <!ENTITY ring "˚" >
+ <!ENTITY ogon "˛" >
+ <!ENTITY tilde "˜" >
+ <!ENTITY DiacriticalTilde "˜" >
+ <!ENTITY dblac "˝" >
+ <!ENTITY DiacriticalDoubleAcute "˝" >
+ <!ENTITY DownBreve "̑" >
+ <!ENTITY UnderBar "̲" >
+ <!ENTITY Alpha "Α" >
+ <!ENTITY Beta "Β" >
+ <!ENTITY Gamma "Γ" >
+ <!ENTITY Delta "Δ" >
+ <!ENTITY Epsilon "Ε" >
+ <!ENTITY Zeta "Ζ" >
+ <!ENTITY Eta "Η" >
+ <!ENTITY Theta "Θ" >
+ <!ENTITY Iota "Ι" >
+ <!ENTITY Kappa "Κ" >
+ <!ENTITY Lambda "Λ" >
+ <!ENTITY Mu "Μ" >
+ <!ENTITY Nu "Ν" >
+ <!ENTITY Xi "Ξ" >
+ <!ENTITY Omicron "Ο" >
+ <!ENTITY Pi "Π" >
+ <!ENTITY Rho "Ρ" >
+ <!ENTITY Sigma "Σ" >
+ <!ENTITY Tau "Τ" >
+ <!ENTITY Upsilon "Υ" >
+ <!ENTITY Phi "Φ" >
+ <!ENTITY Chi "Χ" >
+ <!ENTITY Psi "Ψ" >
+ <!ENTITY Omega "Ω" >
+ <!ENTITY alpha "α" >
+ <!ENTITY beta "β" >
+ <!ENTITY gamma "γ" >
+ <!ENTITY delta "δ" >
+ <!ENTITY epsiv "ε" >
+ <!ENTITY varepsilon "ε" >
+ <!ENTITY epsilon "ε" >
+ <!ENTITY zeta "ζ" >
+ <!ENTITY eta "η" >
+ <!ENTITY theta "θ" >
+ <!ENTITY iota "ι" >
+ <!ENTITY kappa "κ" >
+ <!ENTITY lambda "λ" >
+ <!ENTITY mu "μ" >
+ <!ENTITY nu "ν" >
+ <!ENTITY xi "ξ" >
+ <!ENTITY omicron "ο" >
+ <!ENTITY pi "π" >
+ <!ENTITY rho "ρ" >
+ <!ENTITY sigmav "ς" >
+ <!ENTITY varsigma "ς" >
+ <!ENTITY sigmaf "ς" >
+ <!ENTITY sigma "σ" >
+ <!ENTITY tau "τ" >
+ <!ENTITY upsi "υ" >
+ <!ENTITY upsilon "υ" >
+ <!ENTITY phi "φ" >
+ <!ENTITY phiv "φ" >
+ <!ENTITY varphi "φ" >
+ <!ENTITY chi "χ" >
+ <!ENTITY psi "ψ" >
+ <!ENTITY omega "ω" >
+ <!ENTITY thetav "ϑ" >
+ <!ENTITY vartheta "ϑ" >
+ <!ENTITY thetasym "ϑ" >
+ <!ENTITY Upsi "ϒ" >
+ <!ENTITY upsih "ϒ" >
+ <!ENTITY straightphi "ϕ" >
+ <!ENTITY piv "ϖ" >
+ <!ENTITY varpi "ϖ" >
+ <!ENTITY Gammad "Ϝ" >
+ <!ENTITY gammad "ϝ" >
+ <!ENTITY digamma "ϝ" >
+ <!ENTITY kappav "ϰ" >
+ <!ENTITY varkappa "ϰ" >
+ <!ENTITY rhov "ϱ" >
+ <!ENTITY varrho "ϱ" >
+ <!ENTITY epsi "ϵ" >
+ <!ENTITY straightepsilon "ϵ" >
+ <!ENTITY bepsi "϶" >
+ <!ENTITY backepsilon "϶" >
+ <!ENTITY IOcy "Ё" >
+ <!ENTITY DJcy "Ђ" >
+ <!ENTITY GJcy "Ѓ" >
+ <!ENTITY Jukcy "Є" >
+ <!ENTITY DScy "Ѕ" >
+ <!ENTITY Iukcy "І" >
+ <!ENTITY YIcy "Ї" >
+ <!ENTITY Jsercy "Ј" >
+ <!ENTITY LJcy "Љ" >
+ <!ENTITY NJcy "Њ" >
+ <!ENTITY TSHcy "Ћ" >
+ <!ENTITY KJcy "Ќ" >
+ <!ENTITY Ubrcy "Ў" >
+ <!ENTITY DZcy "Џ" >
+ <!ENTITY Acy "А" >
+ <!ENTITY Bcy "Б" >
+ <!ENTITY Vcy "В" >
+ <!ENTITY Gcy "Г" >
+ <!ENTITY Dcy "Д" >
+ <!ENTITY IEcy "Е" >
+ <!ENTITY ZHcy "Ж" >
+ <!ENTITY Zcy "З" >
+ <!ENTITY Icy "И" >
+ <!ENTITY Jcy "Й" >
+ <!ENTITY Kcy "К" >
+ <!ENTITY Lcy "Л" >
+ <!ENTITY Mcy "М" >
+ <!ENTITY Ncy "Н" >
+ <!ENTITY Ocy "О" >
+ <!ENTITY Pcy "П" >
+ <!ENTITY Rcy "Р" >
+ <!ENTITY Scy "С" >
+ <!ENTITY Tcy "Т" >
+ <!ENTITY Ucy "У" >
+ <!ENTITY Fcy "Ф" >
+ <!ENTITY KHcy "Х" >
+ <!ENTITY TScy "Ц" >
+ <!ENTITY CHcy "Ч" >
+ <!ENTITY SHcy "Ш" >
+ <!ENTITY SHCHcy "Щ" >
+ <!ENTITY HARDcy "Ъ" >
+ <!ENTITY Ycy "Ы" >
+ <!ENTITY SOFTcy "Ь" >
+ <!ENTITY Ecy "Э" >
+ <!ENTITY YUcy "Ю" >
+ <!ENTITY YAcy "Я" >
+ <!ENTITY acy "а" >
+ <!ENTITY bcy "б" >
+ <!ENTITY vcy "в" >
+ <!ENTITY gcy "г" >
+ <!ENTITY dcy "д" >
+ <!ENTITY iecy "е" >
+ <!ENTITY zhcy "ж" >
+ <!ENTITY zcy "з" >
+ <!ENTITY icy "и" >
+ <!ENTITY jcy "й" >
+ <!ENTITY kcy "к" >
+ <!ENTITY lcy "л" >
+ <!ENTITY mcy "м" >
+ <!ENTITY ncy "н" >
+ <!ENTITY ocy "о" >
+ <!ENTITY pcy "п" >
+ <!ENTITY rcy "р" >
+ <!ENTITY scy "с" >
+ <!ENTITY tcy "т" >
+ <!ENTITY ucy "у" >
+ <!ENTITY fcy "ф" >
+ <!ENTITY khcy "х" >
+ <!ENTITY tscy "ц" >
+ <!ENTITY chcy "ч" >
+ <!ENTITY shcy "ш" >
+ <!ENTITY shchcy "щ" >
+ <!ENTITY hardcy "ъ" >
+ <!ENTITY ycy "ы" >
+ <!ENTITY softcy "ь" >
+ <!ENTITY ecy "э" >
+ <!ENTITY yucy "ю" >
+ <!ENTITY yacy "я" >
+ <!ENTITY iocy "ё" >
+ <!ENTITY djcy "ђ" >
+ <!ENTITY gjcy "ѓ" >
+ <!ENTITY jukcy "є" >
+ <!ENTITY dscy "ѕ" >
+ <!ENTITY iukcy "і" >
+ <!ENTITY yicy "ї" >
+ <!ENTITY jsercy "ј" >
+ <!ENTITY ljcy "љ" >
+ <!ENTITY njcy "њ" >
+ <!ENTITY tshcy "ћ" >
+ <!ENTITY kjcy "ќ" >
+ <!ENTITY ubrcy "ў" >
+ <!ENTITY dzcy "џ" >
+ <!ENTITY ensp " " >
+ <!ENTITY emsp " " >
+ <!ENTITY emsp13 " " >
+ <!ENTITY emsp14 " " >
+ <!ENTITY numsp " " >
+ <!ENTITY puncsp " " >
+ <!ENTITY thinsp " " >
+ <!ENTITY ThinSpace " " >
+ <!ENTITY hairsp " " >
+ <!ENTITY VeryThinSpace " " >
+ <!ENTITY ZeroWidthSpace "​" >
+ <!ENTITY NegativeVeryThinSpace "​" >
+ <!ENTITY NegativeThinSpace "​" >
+ <!ENTITY NegativeMediumSpace "​" >
+ <!ENTITY NegativeThickSpace "​" >
+ <!ENTITY zwnj "‌" >
+ <!ENTITY zwj "‍" >
+ <!ENTITY lrm "‎" >
+ <!ENTITY rlm "‏" >
+ <!ENTITY hyphen "‐" >
+ <!ENTITY dash "‐" >
+ <!ENTITY ndash "–" >
+ <!ENTITY mdash "—" >
+ <!ENTITY horbar "―" >
+ <!ENTITY Verbar "‖" >
+ <!ENTITY Vert "‖" >
+ <!ENTITY lsquo "‘" >
+ <!ENTITY OpenCurlyQuote "‘" >
+ <!ENTITY rsquo "’" >
+ <!ENTITY rsquor "’" >
+ <!ENTITY CloseCurlyQuote "’" >
+ <!ENTITY lsquor "‚" >
+ <!ENTITY sbquo "‚" >
+ <!ENTITY ldquo "“" >
+ <!ENTITY OpenCurlyDoubleQuote "“" >
+ <!ENTITY rdquo "”" >
+ <!ENTITY rdquor "”" >
+ <!ENTITY CloseCurlyDoubleQuote "”" >
+ <!ENTITY ldquor "„" >
+ <!ENTITY bdquo "„" >
+ <!ENTITY dagger "†" >
+ <!ENTITY Dagger "‡" >
+ <!ENTITY ddagger "‡" >
+ <!ENTITY bull "•" >
+ <!ENTITY bullet "•" >
+ <!ENTITY nldr "‥" >
+ <!ENTITY hellip "…" >
+ <!ENTITY mldr "…" >
+ <!ENTITY permil "‰" >
+ <!ENTITY pertenk "‱" >
+ <!ENTITY prime "′" >
+ <!ENTITY Prime "″" >
+ <!ENTITY tprime "‴" >
+ <!ENTITY bprime "‵" >
+ <!ENTITY backprime "‵" >
+ <!ENTITY lsaquo "‹" >
+ <!ENTITY rsaquo "›" >
+ <!ENTITY oline "‾" >
+ <!ENTITY caret "⁁" >
+ <!ENTITY hybull "⁃" >
+ <!ENTITY frasl "⁄" >
+ <!ENTITY bsemi "⁏" >
+ <!ENTITY qprime "⁗" >
+ <!ENTITY MediumSpace " " >
+ <!ENTITY NoBreak "⁠" >
+ <!ENTITY ApplyFunction "⁡" >
+ <!ENTITY af "⁡" >
+ <!ENTITY InvisibleTimes "⁢" >
+ <!ENTITY it "⁢" >
+ <!ENTITY InvisibleComma "⁣" >
+ <!ENTITY ic "⁣" >
+ <!ENTITY euro "€" >
+ <!ENTITY tdot "⃛" >
+ <!ENTITY TripleDot "⃛" >
+ <!ENTITY DotDot "⃜" >
+ <!ENTITY Copf "ℂ" >
+ <!ENTITY complexes "ℂ" >
+ <!ENTITY incare "℅" >
+ <!ENTITY gscr "ℊ" >
+ <!ENTITY hamilt "ℋ" >
+ <!ENTITY HilbertSpace "ℋ" >
+ <!ENTITY Hscr "ℋ" >
+ <!ENTITY Hfr "ℌ" >
+ <!ENTITY Poincareplane "ℌ" >
+ <!ENTITY quaternions "ℍ" >
+ <!ENTITY Hopf "ℍ" >
+ <!ENTITY planckh "ℎ" >
+ <!ENTITY planck "ℏ" >
+ <!ENTITY hbar "ℏ" >
+ <!ENTITY plankv "ℏ" >
+ <!ENTITY hslash "ℏ" >
+ <!ENTITY Iscr "ℐ" >
+ <!ENTITY imagline "ℐ" >
+ <!ENTITY image "ℑ" >
+ <!ENTITY Im "ℑ" >
+ <!ENTITY imagpart "ℑ" >
+ <!ENTITY Ifr "ℑ" >
+ <!ENTITY Lscr "ℒ" >
+ <!ENTITY lagran "ℒ" >
+ <!ENTITY Laplacetrf "ℒ" >
+ <!ENTITY ell "ℓ" >
+ <!ENTITY Nopf "ℕ" >
+ <!ENTITY naturals "ℕ" >
+ <!ENTITY numero "№" >
+ <!ENTITY copysr "℗" >
+ <!ENTITY weierp "℘" >
+ <!ENTITY wp "℘" >
+ <!ENTITY Popf "ℙ" >
+ <!ENTITY primes "ℙ" >
+ <!ENTITY rationals "ℚ" >
+ <!ENTITY Qopf "ℚ" >
+ <!ENTITY Rscr "ℛ" >
+ <!ENTITY realine "ℛ" >
+ <!ENTITY real "ℜ" >
+ <!ENTITY Re "ℜ" >
+ <!ENTITY realpart "ℜ" >
+ <!ENTITY Rfr "ℜ" >
+ <!ENTITY reals "ℝ" >
+ <!ENTITY Ropf "ℝ" >
+ <!ENTITY rx "℞" >
+ <!ENTITY trade "™" >
+ <!ENTITY TRADE "™" >
+ <!ENTITY integers "ℤ" >
+ <!ENTITY Zopf "ℤ" >
+ <!ENTITY ohm "Ω" >
+ <!ENTITY mho "℧" >
+ <!ENTITY Zfr "ℨ" >
+ <!ENTITY zeetrf "ℨ" >
+ <!ENTITY iiota "℩" >
+ <!ENTITY angst "Å" >
+ <!ENTITY bernou "ℬ" >
+ <!ENTITY Bernoullis "ℬ" >
+ <!ENTITY Bscr "ℬ" >
+ <!ENTITY Cfr "ℭ" >
+ <!ENTITY Cayleys "ℭ" >
+ <!ENTITY escr "ℯ" >
+ <!ENTITY Escr "ℰ" >
+ <!ENTITY expectation "ℰ" >
+ <!ENTITY Fscr "ℱ" >
+ <!ENTITY Fouriertrf "ℱ" >
+ <!ENTITY phmmat "ℳ" >
+ <!ENTITY Mellintrf "ℳ" >
+ <!ENTITY Mscr "ℳ" >
+ <!ENTITY order "ℴ" >
+ <!ENTITY orderof "ℴ" >
+ <!ENTITY oscr "ℴ" >
+ <!ENTITY alefsym "ℵ" >
+ <!ENTITY aleph "ℵ" >
+ <!ENTITY beth "ℶ" >
+ <!ENTITY gimel "ℷ" >
+ <!ENTITY daleth "ℸ" >
+ <!ENTITY CapitalDifferentialD "ⅅ" >
+ <!ENTITY DD "ⅅ" >
+ <!ENTITY DifferentialD "ⅆ" >
+ <!ENTITY dd "ⅆ" >
+ <!ENTITY ExponentialE "ⅇ" >
+ <!ENTITY exponentiale "ⅇ" >
+ <!ENTITY ee "ⅇ" >
+ <!ENTITY ImaginaryI "ⅈ" >
+ <!ENTITY ii "ⅈ" >
+ <!ENTITY frac13 "⅓" >
+ <!ENTITY frac23 "⅔" >
+ <!ENTITY frac15 "⅕" >
+ <!ENTITY frac25 "⅖" >
+ <!ENTITY frac35 "⅗" >
+ <!ENTITY frac45 "⅘" >
+ <!ENTITY frac16 "⅙" >
+ <!ENTITY frac56 "⅚" >
+ <!ENTITY frac18 "⅛" >
+ <!ENTITY frac38 "⅜" >
+ <!ENTITY frac58 "⅝" >
+ <!ENTITY frac78 "⅞" >
+ <!ENTITY larr "←" >
+ <!ENTITY leftarrow "←" >
+ <!ENTITY LeftArrow "←" >
+ <!ENTITY slarr "←" >
+ <!ENTITY ShortLeftArrow "←" >
+ <!ENTITY uarr "↑" >
+ <!ENTITY uparrow "↑" >
+ <!ENTITY UpArrow "↑" >
+ <!ENTITY ShortUpArrow "↑" >
+ <!ENTITY rarr "→" >
+ <!ENTITY rightarrow "→" >
+ <!ENTITY RightArrow "→" >
+ <!ENTITY srarr "→" >
+ <!ENTITY ShortRightArrow "→" >
+ <!ENTITY darr "↓" >
+ <!ENTITY downarrow "↓" >
+ <!ENTITY DownArrow "↓" >
+ <!ENTITY ShortDownArrow "↓" >
+ <!ENTITY harr "↔" >
+ <!ENTITY leftrightarrow "↔" >
+ <!ENTITY LeftRightArrow "↔" >
+ <!ENTITY varr "↕" >
+ <!ENTITY updownarrow "↕" >
+ <!ENTITY UpDownArrow "↕" >
+ <!ENTITY nwarr "↖" >
+ <!ENTITY UpperLeftArrow "↖" >
+ <!ENTITY nwarrow "↖" >
+ <!ENTITY nearr "↗" >
+ <!ENTITY UpperRightArrow "↗" >
+ <!ENTITY nearrow "↗" >
+ <!ENTITY searr "↘" >
+ <!ENTITY searrow "↘" >
+ <!ENTITY LowerRightArrow "↘" >
+ <!ENTITY swarr "↙" >
+ <!ENTITY swarrow "↙" >
+ <!ENTITY LowerLeftArrow "↙" >
+ <!ENTITY nlarr "↚" >
+ <!ENTITY nleftarrow "↚" >
+ <!ENTITY nrarr "↛" >
+ <!ENTITY nrightarrow "↛" >
+ <!ENTITY rarrw "↝" >
+ <!ENTITY rightsquigarrow "↝" >
+ <!ENTITY Larr "↞" >
+ <!ENTITY twoheadleftarrow "↞" >
+ <!ENTITY Uarr "↟" >
+ <!ENTITY Rarr "↠" >
+ <!ENTITY twoheadrightarrow "↠" >
+ <!ENTITY Darr "↡" >
+ <!ENTITY larrtl "↢" >
+ <!ENTITY leftarrowtail "↢" >
+ <!ENTITY rarrtl "↣" >
+ <!ENTITY rightarrowtail "↣" >
+ <!ENTITY LeftTeeArrow "↤" >
+ <!ENTITY mapstoleft "↤" >
+ <!ENTITY UpTeeArrow "↥" >
+ <!ENTITY mapstoup "↥" >
+ <!ENTITY map "↦" >
+ <!ENTITY RightTeeArrow "↦" >
+ <!ENTITY mapsto "↦" >
+ <!ENTITY DownTeeArrow "↧" >
+ <!ENTITY mapstodown "↧" >
+ <!ENTITY larrhk "↩" >
+ <!ENTITY hookleftarrow "↩" >
+ <!ENTITY rarrhk "↪" >
+ <!ENTITY hookrightarrow "↪" >
+ <!ENTITY larrlp "↫" >
+ <!ENTITY looparrowleft "↫" >
+ <!ENTITY rarrlp "↬" >
+ <!ENTITY looparrowright "↬" >
+ <!ENTITY harrw "↭" >
+ <!ENTITY leftrightsquigarrow "↭" >
+ <!ENTITY nharr "↮" >
+ <!ENTITY nleftrightarrow "↮" >
+ <!ENTITY lsh "↰" >
+ <!ENTITY Lsh "↰" >
+ <!ENTITY rsh "↱" >
+ <!ENTITY Rsh "↱" >
+ <!ENTITY ldsh "↲" >
+ <!ENTITY rdsh "↳" >
+ <!ENTITY crarr "↵" >
+ <!ENTITY cularr "↶" >
+ <!ENTITY curvearrowleft "↶" >
+ <!ENTITY curarr "↷" >
+ <!ENTITY curvearrowright "↷" >
+ <!ENTITY olarr "↺" >
+ <!ENTITY circlearrowleft "↺" >
+ <!ENTITY orarr "↻" >
+ <!ENTITY circlearrowright "↻" >
+ <!ENTITY lharu "↼" >
+ <!ENTITY LeftVector "↼" >
+ <!ENTITY leftharpoonup "↼" >
+ <!ENTITY lhard "↽" >
+ <!ENTITY leftharpoondown "↽" >
+ <!ENTITY DownLeftVector "↽" >
+ <!ENTITY uharr "↾" >
+ <!ENTITY upharpoonright "↾" >
+ <!ENTITY RightUpVector "↾" >
+ <!ENTITY uharl "↿" >
+ <!ENTITY upharpoonleft "↿" >
+ <!ENTITY LeftUpVector "↿" >
+ <!ENTITY rharu "⇀" >
+ <!ENTITY RightVector "⇀" >
+ <!ENTITY rightharpoonup "⇀" >
+ <!ENTITY rhard "⇁" >
+ <!ENTITY rightharpoondown "⇁" >
+ <!ENTITY DownRightVector "⇁" >
+ <!ENTITY dharr "⇂" >
+ <!ENTITY RightDownVector "⇂" >
+ <!ENTITY downharpoonright "⇂" >
+ <!ENTITY dharl "⇃" >
+ <!ENTITY LeftDownVector "⇃" >
+ <!ENTITY downharpoonleft "⇃" >
+ <!ENTITY rlarr "⇄" >
+ <!ENTITY rightleftarrows "⇄" >
+ <!ENTITY RightArrowLeftArrow "⇄" >
+ <!ENTITY udarr "⇅" >
+ <!ENTITY UpArrowDownArrow "⇅" >
+ <!ENTITY lrarr "⇆" >
+ <!ENTITY leftrightarrows "⇆" >
+ <!ENTITY LeftArrowRightArrow "⇆" >
+ <!ENTITY llarr "⇇" >
+ <!ENTITY leftleftarrows "⇇" >
+ <!ENTITY uuarr "⇈" >
+ <!ENTITY upuparrows "⇈" >
+ <!ENTITY rrarr "⇉" >
+ <!ENTITY rightrightarrows "⇉" >
+ <!ENTITY ddarr "⇊" >
+ <!ENTITY downdownarrows "⇊" >
+ <!ENTITY lrhar "⇋" >
+ <!ENTITY ReverseEquilibrium "⇋" >
+ <!ENTITY leftrightharpoons "⇋" >
+ <!ENTITY rlhar "⇌" >
+ <!ENTITY rightleftharpoons "⇌" >
+ <!ENTITY Equilibrium "⇌" >
+ <!ENTITY nlArr "⇍" >
+ <!ENTITY nLeftarrow "⇍" >
+ <!ENTITY nhArr "⇎" >
+ <!ENTITY nLeftrightarrow "⇎" >
+ <!ENTITY nrArr "⇏" >
+ <!ENTITY nRightarrow "⇏" >
+ <!ENTITY lArr "⇐" >
+ <!ENTITY Leftarrow "⇐" >
+ <!ENTITY DoubleLeftArrow "⇐" >
+ <!ENTITY uArr "⇑" >
+ <!ENTITY Uparrow "⇑" >
+ <!ENTITY DoubleUpArrow "⇑" >
+ <!ENTITY rArr "⇒" >
+ <!ENTITY Rightarrow "⇒" >
+ <!ENTITY Implies "⇒" >
+ <!ENTITY DoubleRightArrow "⇒" >
+ <!ENTITY dArr "⇓" >
+ <!ENTITY Downarrow "⇓" >
+ <!ENTITY DoubleDownArrow "⇓" >
+ <!ENTITY hArr "⇔" >
+ <!ENTITY Leftrightarrow "⇔" >
+ <!ENTITY DoubleLeftRightArrow "⇔" >
+ <!ENTITY iff "⇔" >
+ <!ENTITY vArr "⇕" >
+ <!ENTITY Updownarrow "⇕" >
+ <!ENTITY DoubleUpDownArrow "⇕" >
+ <!ENTITY nwArr "⇖" >
+ <!ENTITY neArr "⇗" >
+ <!ENTITY seArr "⇘" >
+ <!ENTITY swArr "⇙" >
+ <!ENTITY lAarr "⇚" >
+ <!ENTITY Lleftarrow "⇚" >
+ <!ENTITY rAarr "⇛" >
+ <!ENTITY Rrightarrow "⇛" >
+ <!ENTITY zigrarr "⇝" >
+ <!ENTITY larrb "⇤" >
+ <!ENTITY LeftArrowBar "⇤" >
+ <!ENTITY rarrb "⇥" >
+ <!ENTITY RightArrowBar "⇥" >
+ <!ENTITY duarr "⇵" >
+ <!ENTITY DownArrowUpArrow "⇵" >
+ <!ENTITY loarr "⇽" >
+ <!ENTITY roarr "⇾" >
+ <!ENTITY hoarr "⇿" >
+ <!ENTITY forall "∀" >
+ <!ENTITY ForAll "∀" >
+ <!ENTITY comp "∁" >
+ <!ENTITY complement "∁" >
+ <!ENTITY part "∂" >
+ <!ENTITY PartialD "∂" >
+ <!ENTITY exist "∃" >
+ <!ENTITY Exists "∃" >
+ <!ENTITY nexist "∄" >
+ <!ENTITY NotExists "∄" >
+ <!ENTITY nexists "∄" >
+ <!ENTITY empty "∅" >
+ <!ENTITY emptyset "∅" >
+ <!ENTITY emptyv "∅" >
+ <!ENTITY varnothing "∅" >
+ <!ENTITY nabla "∇" >
+ <!ENTITY Del "∇" >
+ <!ENTITY isin "∈" >
+ <!ENTITY isinv "∈" >
+ <!ENTITY Element "∈" >
+ <!ENTITY in "∈" >
+ <!ENTITY notin "∉" >
+ <!ENTITY NotElement "∉" >
+ <!ENTITY notinva "∉" >
+ <!ENTITY niv "∋" >
+ <!ENTITY ReverseElement "∋" >
+ <!ENTITY ni "∋" >
+ <!ENTITY SuchThat "∋" >
+ <!ENTITY notni "∌" >
+ <!ENTITY notniva "∌" >
+ <!ENTITY NotReverseElement "∌" >
+ <!ENTITY prod "∏" >
+ <!ENTITY Product "∏" >
+ <!ENTITY coprod "∐" >
+ <!ENTITY Coproduct "∐" >
+ <!ENTITY sum "∑" >
+ <!ENTITY Sum "∑" >
+ <!ENTITY minus "−" >
+ <!ENTITY mnplus "∓" >
+ <!ENTITY mp "∓" >
+ <!ENTITY MinusPlus "∓" >
+ <!ENTITY plusdo "∔" >
+ <!ENTITY dotplus "∔" >
+ <!ENTITY setmn "∖" >
+ <!ENTITY setminus "∖" >
+ <!ENTITY Backslash "∖" >
+ <!ENTITY ssetmn "∖" >
+ <!ENTITY smallsetminus "∖" >
+ <!ENTITY lowast "∗" >
+ <!ENTITY compfn "∘" >
+ <!ENTITY SmallCircle "∘" >
+ <!ENTITY radic "√" >
+ <!ENTITY Sqrt "√" >
+ <!ENTITY prop "∝" >
+ <!ENTITY propto "∝" >
+ <!ENTITY Proportional "∝" >
+ <!ENTITY vprop "∝" >
+ <!ENTITY varpropto "∝" >
+ <!ENTITY infin "∞" >
+ <!ENTITY angrt "∟" >
+ <!ENTITY ang "∠" >
+ <!ENTITY angle "∠" >
+ <!ENTITY angmsd "∡" >
+ <!ENTITY measuredangle "∡" >
+ <!ENTITY angsph "∢" >
+ <!ENTITY mid "∣" >
+ <!ENTITY VerticalBar "∣" >
+ <!ENTITY smid "∣" >
+ <!ENTITY shortmid "∣" >
+ <!ENTITY nmid "∤" >
+ <!ENTITY NotVerticalBar "∤" >
+ <!ENTITY nsmid "∤" >
+ <!ENTITY nshortmid "∤" >
+ <!ENTITY par "∥" >
+ <!ENTITY parallel "∥" >
+ <!ENTITY DoubleVerticalBar "∥" >
+ <!ENTITY spar "∥" >
+ <!ENTITY shortparallel "∥" >
+ <!ENTITY npar "∦" >
+ <!ENTITY nparallel "∦" >
+ <!ENTITY NotDoubleVerticalBar "∦" >
+ <!ENTITY nspar "∦" >
+ <!ENTITY nshortparallel "∦" >
+ <!ENTITY and "∧" >
+ <!ENTITY wedge "∧" >
+ <!ENTITY or "∨" >
+ <!ENTITY vee "∨" >
+ <!ENTITY cap "∩" >
+ <!ENTITY cup "∪" >
+ <!ENTITY int "∫" >
+ <!ENTITY Integral "∫" >
+ <!ENTITY Int "∬" >
+ <!ENTITY tint "∭" >
+ <!ENTITY iiint "∭" >
+ <!ENTITY conint "∮" >
+ <!ENTITY oint "∮" >
+ <!ENTITY ContourIntegral "∮" >
+ <!ENTITY Conint "∯" >
+ <!ENTITY DoubleContourIntegral "∯" >
+ <!ENTITY Cconint "∰" >
+ <!ENTITY cwint "∱" >
+ <!ENTITY cwconint "∲" >
+ <!ENTITY ClockwiseContourIntegral "∲" >
+ <!ENTITY awconint "∳" >
+ <!ENTITY CounterClockwiseContourIntegral "∳" >
+ <!ENTITY there4 "∴" >
+ <!ENTITY therefore "∴" >
+ <!ENTITY Therefore "∴" >
+ <!ENTITY becaus "∵" >
+ <!ENTITY because "∵" >
+ <!ENTITY Because "∵" >
+ <!ENTITY ratio "∶" >
+ <!ENTITY Colon "∷" >
+ <!ENTITY Proportion "∷" >
+ <!ENTITY minusd "∸" >
+ <!ENTITY dotminus "∸" >
+ <!ENTITY mDDot "∺" >
+ <!ENTITY homtht "∻" >
+ <!ENTITY sim "∼" >
+ <!ENTITY Tilde "∼" >
+ <!ENTITY thksim "∼" >
+ <!ENTITY thicksim "∼" >
+ <!ENTITY bsim "∽" >
+ <!ENTITY backsim "∽" >
+ <!ENTITY ac "∾" >
+ <!ENTITY mstpos "∾" >
+ <!ENTITY acd "∿" >
+ <!ENTITY wreath "≀" >
+ <!ENTITY VerticalTilde "≀" >
+ <!ENTITY wr "≀" >
+ <!ENTITY nsim "≁" >
+ <!ENTITY NotTilde "≁" >
+ <!ENTITY esim "≂" >
+ <!ENTITY EqualTilde "≂" >
+ <!ENTITY eqsim "≂" >
+ <!ENTITY sime "≃" >
+ <!ENTITY TildeEqual "≃" >
+ <!ENTITY simeq "≃" >
+ <!ENTITY nsime "≄" >
+ <!ENTITY nsimeq "≄" >
+ <!ENTITY NotTildeEqual "≄" >
+ <!ENTITY cong "≅" >
+ <!ENTITY TildeFullEqual "≅" >
+ <!ENTITY simne "≆" >
+ <!ENTITY ncong "≇" >
+ <!ENTITY NotTildeFullEqual "≇" >
+ <!ENTITY asymp "≈" >
+ <!ENTITY ap "≈" >
+ <!ENTITY TildeTilde "≈" >
+ <!ENTITY approx "≈" >
+ <!ENTITY thkap "≈" >
+ <!ENTITY thickapprox "≈" >
+ <!ENTITY nap "≉" >
+ <!ENTITY NotTildeTilde "≉" >
+ <!ENTITY napprox "≉" >
+ <!ENTITY ape "≊" >
+ <!ENTITY approxeq "≊" >
+ <!ENTITY apid "≋" >
+ <!ENTITY bcong "≌" >
+ <!ENTITY backcong "≌" >
+ <!ENTITY asympeq "≍" >
+ <!ENTITY CupCap "≍" >
+ <!ENTITY bump "≎" >
+ <!ENTITY HumpDownHump "≎" >
+ <!ENTITY Bumpeq "≎" >
+ <!ENTITY bumpe "≏" >
+ <!ENTITY HumpEqual "≏" >
+ <!ENTITY bumpeq "≏" >
+ <!ENTITY esdot "≐" >
+ <!ENTITY DotEqual "≐" >
+ <!ENTITY doteq "≐" >
+ <!ENTITY eDot "≑" >
+ <!ENTITY doteqdot "≑" >
+ <!ENTITY efDot "≒" >
+ <!ENTITY fallingdotseq "≒" >
+ <!ENTITY erDot "≓" >
+ <!ENTITY risingdotseq "≓" >
+ <!ENTITY colone "≔" >
+ <!ENTITY coloneq "≔" >
+ <!ENTITY Assign "≔" >
+ <!ENTITY ecolon "≕" >
+ <!ENTITY eqcolon "≕" >
+ <!ENTITY ecir "≖" >
+ <!ENTITY eqcirc "≖" >
+ <!ENTITY cire "≗" >
+ <!ENTITY circeq "≗" >
+ <!ENTITY wedgeq "≙" >
+ <!ENTITY veeeq "≚" >
+ <!ENTITY trie "≜" >
+ <!ENTITY triangleq "≜" >
+ <!ENTITY equest "≟" >
+ <!ENTITY questeq "≟" >
+ <!ENTITY ne "≠" >
+ <!ENTITY NotEqual "≠" >
+ <!ENTITY equiv "≡" >
+ <!ENTITY Congruent "≡" >
+ <!ENTITY nequiv "≢" >
+ <!ENTITY NotCongruent "≢" >
+ <!ENTITY le "≤" >
+ <!ENTITY leq "≤" >
+ <!ENTITY ge "≥" >
+ <!ENTITY GreaterEqual "≥" >
+ <!ENTITY geq "≥" >
+ <!ENTITY lE "≦" >
+ <!ENTITY LessFullEqual "≦" >
+ <!ENTITY leqq "≦" >
+ <!ENTITY gE "≧" >
+ <!ENTITY GreaterFullEqual "≧" >
+ <!ENTITY geqq "≧" >
+ <!ENTITY lnE "≨" >
+ <!ENTITY lneqq "≨" >
+ <!ENTITY gnE "≩" >
+ <!ENTITY gneqq "≩" >
+ <!ENTITY Lt "≪" >
+ <!ENTITY NestedLessLess "≪" >
+ <!ENTITY ll "≪" >
+ <!ENTITY Gt "≫" >
+ <!ENTITY NestedGreaterGreater "≫" >
+ <!ENTITY gg "≫" >
+ <!ENTITY twixt "≬" >
+ <!ENTITY between "≬" >
+ <!ENTITY NotCupCap "≭" >
+ <!ENTITY nlt "≮" >
+ <!ENTITY NotLess "≮" >
+ <!ENTITY nless "≮" >
+ <!ENTITY ngt "≯" >
+ <!ENTITY NotGreater "≯" >
+ <!ENTITY ngtr "≯" >
+ <!ENTITY nle "≰" >
+ <!ENTITY NotLessEqual "≰" >
+ <!ENTITY nleq "≰" >
+ <!ENTITY nge "≱" >
+ <!ENTITY NotGreaterEqual "≱" >
+ <!ENTITY ngeq "≱" >
+ <!ENTITY lsim "≲" >
+ <!ENTITY LessTilde "≲" >
+ <!ENTITY lesssim "≲" >
+ <!ENTITY gsim "≳" >
+ <!ENTITY gtrsim "≳" >
+ <!ENTITY GreaterTilde "≳" >
+ <!ENTITY nlsim "≴" >
+ <!ENTITY NotLessTilde "≴" >
+ <!ENTITY ngsim "≵" >
+ <!ENTITY NotGreaterTilde "≵" >
+ <!ENTITY lg "≶" >
+ <!ENTITY lessgtr "≶" >
+ <!ENTITY LessGreater "≶" >
+ <!ENTITY gl "≷" >
+ <!ENTITY gtrless "≷" >
+ <!ENTITY GreaterLess "≷" >
+ <!ENTITY ntlg "≸" >
+ <!ENTITY NotLessGreater "≸" >
+ <!ENTITY ntgl "≹" >
+ <!ENTITY NotGreaterLess "≹" >
+ <!ENTITY pr "≺" >
+ <!ENTITY Precedes "≺" >
+ <!ENTITY prec "≺" >
+ <!ENTITY sc "≻" >
+ <!ENTITY Succeeds "≻" >
+ <!ENTITY succ "≻" >
+ <!ENTITY prcue "≼" >
+ <!ENTITY PrecedesSlantEqual "≼" >
+ <!ENTITY preccurlyeq "≼" >
+ <!ENTITY sccue "≽" >
+ <!ENTITY SucceedsSlantEqual "≽" >
+ <!ENTITY succcurlyeq "≽" >
+ <!ENTITY prsim "≾" >
+ <!ENTITY precsim "≾" >
+ <!ENTITY PrecedesTilde "≾" >
+ <!ENTITY scsim "≿" >
+ <!ENTITY succsim "≿" >
+ <!ENTITY SucceedsTilde "≿" >
+ <!ENTITY npr "⊀" >
+ <!ENTITY nprec "⊀" >
+ <!ENTITY NotPrecedes "⊀" >
+ <!ENTITY nsc "⊁" >
+ <!ENTITY nsucc "⊁" >
+ <!ENTITY NotSucceeds "⊁" >
+ <!ENTITY sub "⊂" >
+ <!ENTITY subset "⊂" >
+ <!ENTITY sup "⊃" >
+ <!ENTITY supset "⊃" >
+ <!ENTITY Superset "⊃" >
+ <!ENTITY nsub "⊄" >
+ <!ENTITY nsup "⊅" >
+ <!ENTITY sube "⊆" >
+ <!ENTITY SubsetEqual "⊆" >
+ <!ENTITY subseteq "⊆" >
+ <!ENTITY supe "⊇" >
+ <!ENTITY supseteq "⊇" >
+ <!ENTITY SupersetEqual "⊇" >
+ <!ENTITY nsube "⊈" >
+ <!ENTITY nsubseteq "⊈" >
+ <!ENTITY NotSubsetEqual "⊈" >
+ <!ENTITY nsupe "⊉" >
+ <!ENTITY nsupseteq "⊉" >
+ <!ENTITY NotSupersetEqual "⊉" >
+ <!ENTITY subne "⊊" >
+ <!ENTITY subsetneq "⊊" >
+ <!ENTITY supne "⊋" >
+ <!ENTITY supsetneq "⊋" >
+ <!ENTITY cupdot "⊍" >
+ <!ENTITY uplus "⊎" >
+ <!ENTITY UnionPlus "⊎" >
+ <!ENTITY sqsub "⊏" >
+ <!ENTITY SquareSubset "⊏" >
+ <!ENTITY sqsubset "⊏" >
+ <!ENTITY sqsup "⊐" >
+ <!ENTITY SquareSuperset "⊐" >
+ <!ENTITY sqsupset "⊐" >
+ <!ENTITY sqsube "⊑" >
+ <!ENTITY SquareSubsetEqual "⊑" >
+ <!ENTITY sqsubseteq "⊑" >
+ <!ENTITY sqsupe "⊒" >
+ <!ENTITY SquareSupersetEqual "⊒" >
+ <!ENTITY sqsupseteq "⊒" >
+ <!ENTITY sqcap "⊓" >
+ <!ENTITY SquareIntersection "⊓" >
+ <!ENTITY sqcup "⊔" >
+ <!ENTITY SquareUnion "⊔" >
+ <!ENTITY oplus "⊕" >
+ <!ENTITY CirclePlus "⊕" >
+ <!ENTITY ominus "⊖" >
+ <!ENTITY CircleMinus "⊖" >
+ <!ENTITY otimes "⊗" >
+ <!ENTITY CircleTimes "⊗" >
+ <!ENTITY osol "⊘" >
+ <!ENTITY odot "⊙" >
+ <!ENTITY CircleDot "⊙" >
+ <!ENTITY ocir "⊚" >
+ <!ENTITY circledcirc "⊚" >
+ <!ENTITY oast "⊛" >
+ <!ENTITY circledast "⊛" >
+ <!ENTITY odash "⊝" >
+ <!ENTITY circleddash "⊝" >
+ <!ENTITY plusb "⊞" >
+ <!ENTITY boxplus "⊞" >
+ <!ENTITY minusb "⊟" >
+ <!ENTITY boxminus "⊟" >
+ <!ENTITY timesb "⊠" >
+ <!ENTITY boxtimes "⊠" >
+ <!ENTITY sdotb "⊡" >
+ <!ENTITY dotsquare "⊡" >
+ <!ENTITY vdash "⊢" >
+ <!ENTITY RightTee "⊢" >
+ <!ENTITY dashv "⊣" >
+ <!ENTITY LeftTee "⊣" >
+ <!ENTITY top "⊤" >
+ <!ENTITY DownTee "⊤" >
+ <!ENTITY bottom "⊥" >
+ <!ENTITY bot "⊥" >
+ <!ENTITY perp "⊥" >
+ <!ENTITY UpTee "⊥" >
+ <!ENTITY models "⊧" >
+ <!ENTITY vDash "⊨" >
+ <!ENTITY DoubleRightTee "⊨" >
+ <!ENTITY Vdash "⊩" >
+ <!ENTITY Vvdash "⊪" >
+ <!ENTITY VDash "⊫" >
+ <!ENTITY nvdash "⊬" >
+ <!ENTITY nvDash "⊭" >
+ <!ENTITY nVdash "⊮" >
+ <!ENTITY nVDash "⊯" >
+ <!ENTITY prurel "⊰" >
+ <!ENTITY vltri "⊲" >
+ <!ENTITY vartriangleleft "⊲" >
+ <!ENTITY LeftTriangle "⊲" >
+ <!ENTITY vrtri "⊳" >
+ <!ENTITY vartriangleright "⊳" >
+ <!ENTITY RightTriangle "⊳" >
+ <!ENTITY ltrie "⊴" >
+ <!ENTITY trianglelefteq "⊴" >
+ <!ENTITY LeftTriangleEqual "⊴" >
+ <!ENTITY rtrie "⊵" >
+ <!ENTITY trianglerighteq "⊵" >
+ <!ENTITY RightTriangleEqual "⊵" >
+ <!ENTITY origof "⊶" >
+ <!ENTITY imof "⊷" >
+ <!ENTITY mumap "⊸" >
+ <!ENTITY multimap "⊸" >
+ <!ENTITY hercon "⊹" >
+ <!ENTITY intcal "⊺" >
+ <!ENTITY intercal "⊺" >
+ <!ENTITY veebar "⊻" >
+ <!ENTITY barvee "⊽" >
+ <!ENTITY angrtvb "⊾" >
+ <!ENTITY lrtri "⊿" >
+ <!ENTITY xwedge "⋀" >
+ <!ENTITY Wedge "⋀" >
+ <!ENTITY bigwedge "⋀" >
+ <!ENTITY xvee "⋁" >
+ <!ENTITY Vee "⋁" >
+ <!ENTITY bigvee "⋁" >
+ <!ENTITY xcap "⋂" >
+ <!ENTITY Intersection "⋂" >
+ <!ENTITY bigcap "⋂" >
+ <!ENTITY xcup "⋃" >
+ <!ENTITY Union "⋃" >
+ <!ENTITY bigcup "⋃" >
+ <!ENTITY diam "⋄" >
+ <!ENTITY diamond "⋄" >
+ <!ENTITY Diamond "⋄" >
+ <!ENTITY sdot "⋅" >
+ <!ENTITY sstarf "⋆" >
+ <!ENTITY Star "⋆" >
+ <!ENTITY divonx "⋇" >
+ <!ENTITY divideontimes "⋇" >
+ <!ENTITY bowtie "⋈" >
+ <!ENTITY ltimes "⋉" >
+ <!ENTITY rtimes "⋊" >
+ <!ENTITY lthree "⋋" >
+ <!ENTITY leftthreetimes "⋋" >
+ <!ENTITY rthree "⋌" >
+ <!ENTITY rightthreetimes "⋌" >
+ <!ENTITY bsime "⋍" >
+ <!ENTITY backsimeq "⋍" >
+ <!ENTITY cuvee "⋎" >
+ <!ENTITY curlyvee "⋎" >
+ <!ENTITY cuwed "⋏" >
+ <!ENTITY curlywedge "⋏" >
+ <!ENTITY Sub "⋐" >
+ <!ENTITY Subset "⋐" >
+ <!ENTITY Sup "⋑" >
+ <!ENTITY Supset "⋑" >
+ <!ENTITY Cap "⋒" >
+ <!ENTITY Cup "⋓" >
+ <!ENTITY fork "⋔" >
+ <!ENTITY pitchfork "⋔" >
+ <!ENTITY epar "⋕" >
+ <!ENTITY ltdot "⋖" >
+ <!ENTITY lessdot "⋖" >
+ <!ENTITY gtdot "⋗" >
+ <!ENTITY gtrdot "⋗" >
+ <!ENTITY Ll "⋘" >
+ <!ENTITY Gg "⋙" >
+ <!ENTITY ggg "⋙" >
+ <!ENTITY leg "⋚" >
+ <!ENTITY LessEqualGreater "⋚" >
+ <!ENTITY lesseqgtr "⋚" >
+ <!ENTITY gel "⋛" >
+ <!ENTITY gtreqless "⋛" >
+ <!ENTITY GreaterEqualLess "⋛" >
+ <!ENTITY cuepr "⋞" >
+ <!ENTITY curlyeqprec "⋞" >
+ <!ENTITY cuesc "⋟" >
+ <!ENTITY curlyeqsucc "⋟" >
+ <!ENTITY nprcue "⋠" >
+ <!ENTITY NotPrecedesSlantEqual "⋠" >
+ <!ENTITY nsccue "⋡" >
+ <!ENTITY NotSucceedsSlantEqual "⋡" >
+ <!ENTITY nsqsube "⋢" >
+ <!ENTITY NotSquareSubsetEqual "⋢" >
+ <!ENTITY nsqsupe "⋣" >
+ <!ENTITY NotSquareSupersetEqual "⋣" >
+ <!ENTITY lnsim "⋦" >
+ <!ENTITY gnsim "⋧" >
+ <!ENTITY prnsim "⋨" >
+ <!ENTITY precnsim "⋨" >
+ <!ENTITY scnsim "⋩" >
+ <!ENTITY succnsim "⋩" >
+ <!ENTITY nltri "⋪" >
+ <!ENTITY ntriangleleft "⋪" >
+ <!ENTITY NotLeftTriangle "⋪" >
+ <!ENTITY nrtri "⋫" >
+ <!ENTITY ntriangleright "⋫" >
+ <!ENTITY NotRightTriangle "⋫" >
+ <!ENTITY nltrie "⋬" >
+ <!ENTITY ntrianglelefteq "⋬" >
+ <!ENTITY NotLeftTriangleEqual "⋬" >
+ <!ENTITY nrtrie "⋭" >
+ <!ENTITY ntrianglerighteq "⋭" >
+ <!ENTITY NotRightTriangleEqual "⋭" >
+ <!ENTITY vellip "⋮" >
+ <!ENTITY ctdot "⋯" >
+ <!ENTITY utdot "⋰" >
+ <!ENTITY dtdot "⋱" >
+ <!ENTITY disin "⋲" >
+ <!ENTITY isinsv "⋳" >
+ <!ENTITY isins "⋴" >
+ <!ENTITY isindot "⋵" >
+ <!ENTITY notinvc "⋶" >
+ <!ENTITY notinvb "⋷" >
+ <!ENTITY isinE "⋹" >
+ <!ENTITY nisd "⋺" >
+ <!ENTITY xnis "⋻" >
+ <!ENTITY nis "⋼" >
+ <!ENTITY notnivc "⋽" >
+ <!ENTITY notnivb "⋾" >
+ <!ENTITY barwed "⌅" >
+ <!ENTITY barwedge "⌅" >
+ <!ENTITY Barwed "⌆" >
+ <!ENTITY doublebarwedge "⌆" >
+ <!ENTITY lceil "⌈" >
+ <!ENTITY LeftCeiling "⌈" >
+ <!ENTITY rceil "⌉" >
+ <!ENTITY RightCeiling "⌉" >
+ <!ENTITY lfloor "⌊" >
+ <!ENTITY LeftFloor "⌊" >
+ <!ENTITY rfloor "⌋" >
+ <!ENTITY RightFloor "⌋" >
+ <!ENTITY drcrop "⌌" >
+ <!ENTITY dlcrop "⌍" >
+ <!ENTITY urcrop "⌎" >
+ <!ENTITY ulcrop "⌏" >
+ <!ENTITY bnot "⌐" >
+ <!ENTITY profline "⌒" >
+ <!ENTITY profsurf "⌓" >
+ <!ENTITY telrec "⌕" >
+ <!ENTITY target "⌖" >
+ <!ENTITY ulcorn "⌜" >
+ <!ENTITY ulcorner "⌜" >
+ <!ENTITY urcorn "⌝" >
+ <!ENTITY urcorner "⌝" >
+ <!ENTITY dlcorn "⌞" >
+ <!ENTITY llcorner "⌞" >
+ <!ENTITY drcorn "⌟" >
+ <!ENTITY lrcorner "⌟" >
+ <!ENTITY frown "⌢" >
+ <!ENTITY sfrown "⌢" >
+ <!ENTITY smile "⌣" >
+ <!ENTITY ssmile "⌣" >
+ <!ENTITY cylcty "⌭" >
+ <!ENTITY profalar "⌮" >
+ <!ENTITY topbot "⌶" >
+ <!ENTITY ovbar "⌽" >
+ <!ENTITY solbar "⌿" >
+ <!ENTITY angzarr "⍼" >
+ <!ENTITY lmoust "⎰" >
+ <!ENTITY lmoustache "⎰" >
+ <!ENTITY rmoust "⎱" >
+ <!ENTITY rmoustache "⎱" >
+ <!ENTITY tbrk "⎴" >
+ <!ENTITY OverBracket "⎴" >
+ <!ENTITY bbrk "⎵" >
+ <!ENTITY UnderBracket "⎵" >
+ <!ENTITY bbrktbrk "⎶" >
+ <!ENTITY OverParenthesis "⏜" >
+ <!ENTITY UnderParenthesis "⏝" >
+ <!ENTITY OverBrace "⏞" >
+ <!ENTITY UnderBrace "⏟" >
+ <!ENTITY trpezium "⏢" >
+ <!ENTITY elinters "⏧" >
+ <!ENTITY blank "␣" >
+ <!ENTITY oS "Ⓢ" >
+ <!ENTITY circledS "Ⓢ" >
+ <!ENTITY boxh "─" >
+ <!ENTITY HorizontalLine "─" >
+ <!ENTITY boxv "│" >
+ <!ENTITY boxdr "┌" >
+ <!ENTITY boxdl "┐" >
+ <!ENTITY boxur "└" >
+ <!ENTITY boxul "┘" >
+ <!ENTITY boxvr "├" >
+ <!ENTITY boxvl "┤" >
+ <!ENTITY boxhd "┬" >
+ <!ENTITY boxhu "┴" >
+ <!ENTITY boxvh "┼" >
+ <!ENTITY boxH "═" >
+ <!ENTITY boxV "║" >
+ <!ENTITY boxdR "╒" >
+ <!ENTITY boxDr "╓" >
+ <!ENTITY boxDR "╔" >
+ <!ENTITY boxdL "╕" >
+ <!ENTITY boxDl "╖" >
+ <!ENTITY boxDL "╗" >
+ <!ENTITY boxuR "╘" >
+ <!ENTITY boxUr "╙" >
+ <!ENTITY boxUR "╚" >
+ <!ENTITY boxuL "╛" >
+ <!ENTITY boxUl "╜" >
+ <!ENTITY boxUL "╝" >
+ <!ENTITY boxvR "╞" >
+ <!ENTITY boxVr "╟" >
+ <!ENTITY boxVR "╠" >
+ <!ENTITY boxvL "╡" >
+ <!ENTITY boxVl "╢" >
+ <!ENTITY boxVL "╣" >
+ <!ENTITY boxHd "╤" >
+ <!ENTITY boxhD "╥" >
+ <!ENTITY boxHD "╦" >
+ <!ENTITY boxHu "╧" >
+ <!ENTITY boxhU "╨" >
+ <!ENTITY boxHU "╩" >
+ <!ENTITY boxvH "╪" >
+ <!ENTITY boxVh "╫" >
+ <!ENTITY boxVH "╬" >
+ <!ENTITY uhblk "▀" >
+ <!ENTITY lhblk "▄" >
+ <!ENTITY block "█" >
+ <!ENTITY blk14 "░" >
+ <!ENTITY blk12 "▒" >
+ <!ENTITY blk34 "▓" >
+ <!ENTITY squ "□" >
+ <!ENTITY square "□" >
+ <!ENTITY Square "□" >
+ <!ENTITY squf "▪" >
+ <!ENTITY squarf "▪" >
+ <!ENTITY blacksquare "▪" >
+ <!ENTITY FilledVerySmallSquare "▪" >
+ <!ENTITY EmptyVerySmallSquare "▫" >
+ <!ENTITY rect "▭" >
+ <!ENTITY marker "▮" >
+ <!ENTITY fltns "▱" >
+ <!ENTITY xutri "△" >
+ <!ENTITY bigtriangleup "△" >
+ <!ENTITY utrif "▴" >
+ <!ENTITY blacktriangle "▴" >
+ <!ENTITY utri "▵" >
+ <!ENTITY triangle "▵" >
+ <!ENTITY rtrif "▸" >
+ <!ENTITY blacktriangleright "▸" >
+ <!ENTITY rtri "▹" >
+ <!ENTITY triangleright "▹" >
+ <!ENTITY xdtri "▽" >
+ <!ENTITY bigtriangledown "▽" >
+ <!ENTITY dtrif "▾" >
+ <!ENTITY blacktriangledown "▾" >
+ <!ENTITY dtri "▿" >
+ <!ENTITY triangledown "▿" >
+ <!ENTITY ltrif "◂" >
+ <!ENTITY blacktriangleleft "◂" >
+ <!ENTITY ltri "◃" >
+ <!ENTITY triangleleft "◃" >
+ <!ENTITY loz "◊" >
+ <!ENTITY lozenge "◊" >
+ <!ENTITY cir "○" >
+ <!ENTITY tridot "◬" >
+ <!ENTITY xcirc "◯" >
+ <!ENTITY bigcirc "◯" >
+ <!ENTITY ultri "◸" >
+ <!ENTITY urtri "◹" >
+ <!ENTITY lltri "◺" >
+ <!ENTITY EmptySmallSquare "◻" >
+ <!ENTITY FilledSmallSquare "◼" >
+ <!ENTITY starf "★" >
+ <!ENTITY bigstar "★" >
+ <!ENTITY star "☆" >
+ <!ENTITY phone "☎" >
+ <!ENTITY female "♀" >
+ <!ENTITY male "♂" >
+ <!ENTITY spades "♠" >
+ <!ENTITY spadesuit "♠" >
+ <!ENTITY clubs "♣" >
+ <!ENTITY clubsuit "♣" >
+ <!ENTITY hearts "♥" >
+ <!ENTITY heartsuit "♥" >
+ <!ENTITY diams "♦" >
+ <!ENTITY diamondsuit "♦" >
+ <!ENTITY sung "♪" >
+ <!ENTITY flat "♭" >
+ <!ENTITY natur "♮" >
+ <!ENTITY natural "♮" >
+ <!ENTITY sharp "♯" >
+ <!ENTITY check "✓" >
+ <!ENTITY checkmark "✓" >
+ <!ENTITY cross "✗" >
+ <!ENTITY malt "✠" >
+ <!ENTITY maltese "✠" >
+ <!ENTITY sext "✶" >
+ <!ENTITY VerticalSeparator "❘" >
+ <!ENTITY lbbrk "❲" >
+ <!ENTITY rbbrk "❳" >
+ <!ENTITY lobrk "⟦" >
+ <!ENTITY LeftDoubleBracket "⟦" >
+ <!ENTITY robrk "⟧" >
+ <!ENTITY RightDoubleBracket "⟧" >
+ <!ENTITY lang "⟨" >
+ <!ENTITY LeftAngleBracket "⟨" >
+ <!ENTITY langle "⟨" >
+ <!ENTITY rang "⟩" >
+ <!ENTITY RightAngleBracket "⟩" >
+ <!ENTITY rangle "⟩" >
+ <!ENTITY Lang "⟪" >
+ <!ENTITY Rang "⟫" >
+ <!ENTITY loang "⟬" >
+ <!ENTITY roang "⟭" >
+ <!ENTITY xlarr "⟵" >
+ <!ENTITY longleftarrow "⟵" >
+ <!ENTITY LongLeftArrow "⟵" >
+ <!ENTITY xrarr "⟶" >
+ <!ENTITY longrightarrow "⟶" >
+ <!ENTITY LongRightArrow "⟶" >
+ <!ENTITY xharr "⟷" >
+ <!ENTITY longleftrightarrow "⟷" >
+ <!ENTITY LongLeftRightArrow "⟷" >
+ <!ENTITY xlArr "⟸" >
+ <!ENTITY Longleftarrow "⟸" >
+ <!ENTITY DoubleLongLeftArrow "⟸" >
+ <!ENTITY xrArr "⟹" >
+ <!ENTITY Longrightarrow "⟹" >
+ <!ENTITY DoubleLongRightArrow "⟹" >
+ <!ENTITY xhArr "⟺" >
+ <!ENTITY Longleftrightarrow "⟺" >
+ <!ENTITY DoubleLongLeftRightArrow "⟺" >
+ <!ENTITY xmap "⟼" >
+ <!ENTITY longmapsto "⟼" >
+ <!ENTITY dzigrarr "⟿" >
+ <!ENTITY nvlArr "⤂" >
+ <!ENTITY nvrArr "⤃" >
+ <!ENTITY nvHarr "⤄" >
+ <!ENTITY Map "⤅" >
+ <!ENTITY lbarr "⤌" >
+ <!ENTITY rbarr "⤍" >
+ <!ENTITY bkarow "⤍" >
+ <!ENTITY lBarr "⤎" >
+ <!ENTITY rBarr "⤏" >
+ <!ENTITY dbkarow "⤏" >
+ <!ENTITY RBarr "⤐" >
+ <!ENTITY drbkarow "⤐" >
+ <!ENTITY DDotrahd "⤑" >
+ <!ENTITY UpArrowBar "⤒" >
+ <!ENTITY DownArrowBar "⤓" >
+ <!ENTITY Rarrtl "⤖" >
+ <!ENTITY latail "⤙" >
+ <!ENTITY ratail "⤚" >
+ <!ENTITY lAtail "⤛" >
+ <!ENTITY rAtail "⤜" >
+ <!ENTITY larrfs "⤝" >
+ <!ENTITY rarrfs "⤞" >
+ <!ENTITY larrbfs "⤟" >
+ <!ENTITY rarrbfs "⤠" >
+ <!ENTITY nwarhk "⤣" >
+ <!ENTITY nearhk "⤤" >
+ <!ENTITY searhk "⤥" >
+ <!ENTITY hksearow "⤥" >
+ <!ENTITY swarhk "⤦" >
+ <!ENTITY hkswarow "⤦" >
+ <!ENTITY nwnear "⤧" >
+ <!ENTITY nesear "⤨" >
+ <!ENTITY toea "⤨" >
+ <!ENTITY seswar "⤩" >
+ <!ENTITY tosa "⤩" >
+ <!ENTITY swnwar "⤪" >
+ <!ENTITY rarrc "⤳" >
+ <!ENTITY cudarrr "⤵" >
+ <!ENTITY ldca "⤶" >
+ <!ENTITY rdca "⤷" >
+ <!ENTITY cudarrl "⤸" >
+ <!ENTITY larrpl "⤹" >
+ <!ENTITY curarrm "⤼" >
+ <!ENTITY cularrp "⤽" >
+ <!ENTITY rarrpl "⥅" >
+ <!ENTITY harrcir "⥈" >
+ <!ENTITY Uarrocir "⥉" >
+ <!ENTITY lurdshar "⥊" >
+ <!ENTITY ldrushar "⥋" >
+ <!ENTITY LeftRightVector "⥎" >
+ <!ENTITY RightUpDownVector "⥏" >
+ <!ENTITY DownLeftRightVector "⥐" >
+ <!ENTITY LeftUpDownVector "⥑" >
+ <!ENTITY LeftVectorBar "⥒" >
+ <!ENTITY RightVectorBar "⥓" >
+ <!ENTITY RightUpVectorBar "⥔" >
+ <!ENTITY RightDownVectorBar "⥕" >
+ <!ENTITY DownLeftVectorBar "⥖" >
+ <!ENTITY DownRightVectorBar "⥗" >
+ <!ENTITY LeftUpVectorBar "⥘" >
+ <!ENTITY LeftDownVectorBar "⥙" >
+ <!ENTITY LeftTeeVector "⥚" >
+ <!ENTITY RightTeeVector "⥛" >
+ <!ENTITY RightUpTeeVector "⥜" >
+ <!ENTITY RightDownTeeVector "⥝" >
+ <!ENTITY DownLeftTeeVector "⥞" >
+ <!ENTITY DownRightTeeVector "⥟" >
+ <!ENTITY LeftUpTeeVector "⥠" >
+ <!ENTITY LeftDownTeeVector "⥡" >
+ <!ENTITY lHar "⥢" >
+ <!ENTITY uHar "⥣" >
+ <!ENTITY rHar "⥤" >
+ <!ENTITY dHar "⥥" >
+ <!ENTITY luruhar "⥦" >
+ <!ENTITY ldrdhar "⥧" >
+ <!ENTITY ruluhar "⥨" >
+ <!ENTITY rdldhar "⥩" >
+ <!ENTITY lharul "⥪" >
+ <!ENTITY llhard "⥫" >
+ <!ENTITY rharul "⥬" >
+ <!ENTITY lrhard "⥭" >
+ <!ENTITY udhar "⥮" >
+ <!ENTITY UpEquilibrium "⥮" >
+ <!ENTITY duhar "⥯" >
+ <!ENTITY ReverseUpEquilibrium "⥯" >
+ <!ENTITY RoundImplies "⥰" >
+ <!ENTITY erarr "⥱" >
+ <!ENTITY simrarr "⥲" >
+ <!ENTITY larrsim "⥳" >
+ <!ENTITY rarrsim "⥴" >
+ <!ENTITY rarrap "⥵" >
+ <!ENTITY ltlarr "⥶" >
+ <!ENTITY gtrarr "⥸" >
+ <!ENTITY subrarr "⥹" >
+ <!ENTITY suplarr "⥻" >
+ <!ENTITY lfisht "⥼" >
+ <!ENTITY rfisht "⥽" >
+ <!ENTITY ufisht "⥾" >
+ <!ENTITY dfisht "⥿" >
+ <!ENTITY lopar "⦅" >
+ <!ENTITY ropar "⦆" >
+ <!ENTITY lbrke "⦋" >
+ <!ENTITY rbrke "⦌" >
+ <!ENTITY lbrkslu "⦍" >
+ <!ENTITY rbrksld "⦎" >
+ <!ENTITY lbrksld "⦏" >
+ <!ENTITY rbrkslu "⦐" >
+ <!ENTITY langd "⦑" >
+ <!ENTITY rangd "⦒" >
+ <!ENTITY lparlt "⦓" >
+ <!ENTITY rpargt "⦔" >
+ <!ENTITY gtlPar "⦕" >
+ <!ENTITY ltrPar "⦖" >
+ <!ENTITY vzigzag "⦚" >
+ <!ENTITY vangrt "⦜" >
+ <!ENTITY angrtvbd "⦝" >
+ <!ENTITY ange "⦤" >
+ <!ENTITY range "⦥" >
+ <!ENTITY dwangle "⦦" >
+ <!ENTITY uwangle "⦧" >
+ <!ENTITY angmsdaa "⦨" >
+ <!ENTITY angmsdab "⦩" >
+ <!ENTITY angmsdac "⦪" >
+ <!ENTITY angmsdad "⦫" >
+ <!ENTITY angmsdae "⦬" >
+ <!ENTITY angmsdaf "⦭" >
+ <!ENTITY angmsdag "⦮" >
+ <!ENTITY angmsdah "⦯" >
+ <!ENTITY bemptyv "⦰" >
+ <!ENTITY demptyv "⦱" >
+ <!ENTITY cemptyv "⦲" >
+ <!ENTITY raemptyv "⦳" >
+ <!ENTITY laemptyv "⦴" >
+ <!ENTITY ohbar "⦵" >
+ <!ENTITY omid "⦶" >
+ <!ENTITY opar "⦷" >
+ <!ENTITY operp "⦹" >
+ <!ENTITY olcross "⦻" >
+ <!ENTITY odsold "⦼" >
+ <!ENTITY olcir "⦾" >
+ <!ENTITY ofcir "⦿" >
+ <!ENTITY olt "⧀" >
+ <!ENTITY ogt "⧁" >
+ <!ENTITY cirscir "⧂" >
+ <!ENTITY cirE "⧃" >
+ <!ENTITY solb "⧄" >
+ <!ENTITY bsolb "⧅" >
+ <!ENTITY boxbox "⧉" >
+ <!ENTITY trisb "⧍" >
+ <!ENTITY rtriltri "⧎" >
+ <!ENTITY LeftTriangleBar "⧏" >
+ <!ENTITY RightTriangleBar "⧐" >
+ <!ENTITY race "⧚" >
+ <!ENTITY iinfin "⧜" >
+ <!ENTITY infintie "⧝" >
+ <!ENTITY nvinfin "⧞" >
+ <!ENTITY eparsl "⧣" >
+ <!ENTITY smeparsl "⧤" >
+ <!ENTITY eqvparsl "⧥" >
+ <!ENTITY lozf "⧫" >
+ <!ENTITY blacklozenge "⧫" >
+ <!ENTITY RuleDelayed "⧴" >
+ <!ENTITY dsol "⧶" >
+ <!ENTITY xodot "⨀" >
+ <!ENTITY bigodot "⨀" >
+ <!ENTITY xoplus "⨁" >
+ <!ENTITY bigoplus "⨁" >
+ <!ENTITY xotime "⨂" >
+ <!ENTITY bigotimes "⨂" >
+ <!ENTITY xuplus "⨄" >
+ <!ENTITY biguplus "⨄" >
+ <!ENTITY xsqcup "⨆" >
+ <!ENTITY bigsqcup "⨆" >
+ <!ENTITY qint "⨌" >
+ <!ENTITY iiiint "⨌" >
+ <!ENTITY fpartint "⨍" >
+ <!ENTITY cirfnint "⨐" >
+ <!ENTITY awint "⨑" >
+ <!ENTITY rppolint "⨒" >
+ <!ENTITY scpolint "⨓" >
+ <!ENTITY npolint "⨔" >
+ <!ENTITY pointint "⨕" >
+ <!ENTITY quatint "⨖" >
+ <!ENTITY intlarhk "⨗" >
+ <!ENTITY pluscir "⨢" >
+ <!ENTITY plusacir "⨣" >
+ <!ENTITY simplus "⨤" >
+ <!ENTITY plusdu "⨥" >
+ <!ENTITY plussim "⨦" >
+ <!ENTITY plustwo "⨧" >
+ <!ENTITY mcomma "⨩" >
+ <!ENTITY minusdu "⨪" >
+ <!ENTITY loplus "⨭" >
+ <!ENTITY roplus "⨮" >
+ <!ENTITY Cross "⨯" >
+ <!ENTITY timesd "⨰" >
+ <!ENTITY timesbar "⨱" >
+ <!ENTITY smashp "⨳" >
+ <!ENTITY lotimes "⨴" >
+ <!ENTITY rotimes "⨵" >
+ <!ENTITY otimesas "⨶" >
+ <!ENTITY Otimes "⨷" >
+ <!ENTITY odiv "⨸" >
+ <!ENTITY triplus "⨹" >
+ <!ENTITY triminus "⨺" >
+ <!ENTITY tritime "⨻" >
+ <!ENTITY iprod "⨼" >
+ <!ENTITY intprod "⨼" >
+ <!ENTITY amalg "⨿" >
+ <!ENTITY capdot "⩀" >
+ <!ENTITY ncup "⩂" >
+ <!ENTITY ncap "⩃" >
+ <!ENTITY capand "⩄" >
+ <!ENTITY cupor "⩅" >
+ <!ENTITY cupcap "⩆" >
+ <!ENTITY capcup "⩇" >
+ <!ENTITY cupbrcap "⩈" >
+ <!ENTITY capbrcup "⩉" >
+ <!ENTITY cupcup "⩊" >
+ <!ENTITY capcap "⩋" >
+ <!ENTITY ccups "⩌" >
+ <!ENTITY ccaps "⩍" >
+ <!ENTITY ccupssm "⩐" >
+ <!ENTITY And "⩓" >
+ <!ENTITY Or "⩔" >
+ <!ENTITY andand "⩕" >
+ <!ENTITY oror "⩖" >
+ <!ENTITY orslope "⩗" >
+ <!ENTITY andslope "⩘" >
+ <!ENTITY andv "⩚" >
+ <!ENTITY orv "⩛" >
+ <!ENTITY andd "⩜" >
+ <!ENTITY ord "⩝" >
+ <!ENTITY wedbar "⩟" >
+ <!ENTITY sdote "⩦" >
+ <!ENTITY simdot "⩪" >
+ <!ENTITY congdot "⩭" >
+ <!ENTITY easter "⩮" >
+ <!ENTITY apacir "⩯" >
+ <!ENTITY apE "⩰" >
+ <!ENTITY eplus "⩱" >
+ <!ENTITY pluse "⩲" >
+ <!ENTITY Esim "⩳" >
+ <!ENTITY Colone "⩴" >
+ <!ENTITY Equal "⩵" >
+ <!ENTITY eDDot "⩷" >
+ <!ENTITY ddotseq "⩷" >
+ <!ENTITY equivDD "⩸" >
+ <!ENTITY ltcir "⩹" >
+ <!ENTITY gtcir "⩺" >
+ <!ENTITY ltquest "⩻" >
+ <!ENTITY gtquest "⩼" >
+ <!ENTITY les "⩽" >
+ <!ENTITY LessSlantEqual "⩽" >
+ <!ENTITY leqslant "⩽" >
+ <!ENTITY ges "⩾" >
+ <!ENTITY GreaterSlantEqual "⩾" >
+ <!ENTITY geqslant "⩾" >
+ <!ENTITY lesdot "⩿" >
+ <!ENTITY gesdot "⪀" >
+ <!ENTITY lesdoto "⪁" >
+ <!ENTITY gesdoto "⪂" >
+ <!ENTITY lesdotor "⪃" >
+ <!ENTITY gesdotol "⪄" >
+ <!ENTITY lap "⪅" >
+ <!ENTITY lessapprox "⪅" >
+ <!ENTITY gap "⪆" >
+ <!ENTITY gtrapprox "⪆" >
+ <!ENTITY lne "⪇" >
+ <!ENTITY lneq "⪇" >
+ <!ENTITY gne "⪈" >
+ <!ENTITY gneq "⪈" >
+ <!ENTITY lnap "⪉" >
+ <!ENTITY lnapprox "⪉" >
+ <!ENTITY gnap "⪊" >
+ <!ENTITY gnapprox "⪊" >
+ <!ENTITY lEg "⪋" >
+ <!ENTITY lesseqqgtr "⪋" >
+ <!ENTITY gEl "⪌" >
+ <!ENTITY gtreqqless "⪌" >
+ <!ENTITY lsime "⪍" >
+ <!ENTITY gsime "⪎" >
+ <!ENTITY lsimg "⪏" >
+ <!ENTITY gsiml "⪐" >
+ <!ENTITY lgE "⪑" >
+ <!ENTITY glE "⪒" >
+ <!ENTITY lesges "⪓" >
+ <!ENTITY gesles "⪔" >
+ <!ENTITY els "⪕" >
+ <!ENTITY eqslantless "⪕" >
+ <!ENTITY egs "⪖" >
+ <!ENTITY eqslantgtr "⪖" >
+ <!ENTITY elsdot "⪗" >
+ <!ENTITY egsdot "⪘" >
+ <!ENTITY el "⪙" >
+ <!ENTITY eg "⪚" >
+ <!ENTITY siml "⪝" >
+ <!ENTITY simg "⪞" >
+ <!ENTITY simlE "⪟" >
+ <!ENTITY simgE "⪠" >
+ <!ENTITY LessLess "⪡" >
+ <!ENTITY GreaterGreater "⪢" >
+ <!ENTITY glj "⪤" >
+ <!ENTITY gla "⪥" >
+ <!ENTITY ltcc "⪦" >
+ <!ENTITY gtcc "⪧" >
+ <!ENTITY lescc "⪨" >
+ <!ENTITY gescc "⪩" >
+ <!ENTITY smt "⪪" >
+ <!ENTITY lat "⪫" >
+ <!ENTITY smte "⪬" >
+ <!ENTITY late "⪭" >
+ <!ENTITY bumpE "⪮" >
+ <!ENTITY pre "⪯" >
+ <!ENTITY preceq "⪯" >
+ <!ENTITY PrecedesEqual "⪯" >
+ <!ENTITY sce "⪰" >
+ <!ENTITY succeq "⪰" >
+ <!ENTITY SucceedsEqual "⪰" >
+ <!ENTITY prE "⪳" >
+ <!ENTITY scE "⪴" >
+ <!ENTITY prnE "⪵" >
+ <!ENTITY precneqq "⪵" >
+ <!ENTITY scnE "⪶" >
+ <!ENTITY succneqq "⪶" >
+ <!ENTITY prap "⪷" >
+ <!ENTITY precapprox "⪷" >
+ <!ENTITY scap "⪸" >
+ <!ENTITY succapprox "⪸" >
+ <!ENTITY prnap "⪹" >
+ <!ENTITY precnapprox "⪹" >
+ <!ENTITY scnap "⪺" >
+ <!ENTITY succnapprox "⪺" >
+ <!ENTITY Pr "⪻" >
+ <!ENTITY Sc "⪼" >
+ <!ENTITY subdot "⪽" >
+ <!ENTITY supdot "⪾" >
+ <!ENTITY subplus "⪿" >
+ <!ENTITY supplus "⫀" >
+ <!ENTITY submult "⫁" >
+ <!ENTITY supmult "⫂" >
+ <!ENTITY subedot "⫃" >
+ <!ENTITY supedot "⫄" >
+ <!ENTITY subE "⫅" >
+ <!ENTITY subseteqq "⫅" >
+ <!ENTITY supE "⫆" >
+ <!ENTITY supseteqq "⫆" >
+ <!ENTITY subsim "⫇" >
+ <!ENTITY supsim "⫈" >
+ <!ENTITY subnE "⫋" >
+ <!ENTITY subsetneqq "⫋" >
+ <!ENTITY supnE "⫌" >
+ <!ENTITY supsetneqq "⫌" >
+ <!ENTITY csub "⫏" >
+ <!ENTITY csup "⫐" >
+ <!ENTITY csube "⫑" >
+ <!ENTITY csupe "⫒" >
+ <!ENTITY subsup "⫓" >
+ <!ENTITY supsub "⫔" >
+ <!ENTITY subsub "⫕" >
+ <!ENTITY supsup "⫖" >
+ <!ENTITY suphsub "⫗" >
+ <!ENTITY supdsub "⫘" >
+ <!ENTITY forkv "⫙" >
+ <!ENTITY topfork "⫚" >
+ <!ENTITY mlcp "⫛" >
+ <!ENTITY Dashv "⫤" >
+ <!ENTITY DoubleLeftTee "⫤" >
+ <!ENTITY Vdashl "⫦" >
+ <!ENTITY Barv "⫧" >
+ <!ENTITY vBar "⫨" >
+ <!ENTITY vBarv "⫩" >
+ <!ENTITY Vbar "⫫" >
+ <!ENTITY Not "⫬" >
+ <!ENTITY bNot "⫭" >
+ <!ENTITY rnmid "⫮" >
+ <!ENTITY cirmid "⫯" >
+ <!ENTITY midcir "⫰" >
+ <!ENTITY topcir "⫱" >
+ <!ENTITY nhpar "⫲" >
+ <!ENTITY parsim "⫳" >
+ <!ENTITY parsl "⫽" >
+ <!ENTITY fflig "ff" >
+ <!ENTITY filig "fi" >
+ <!ENTITY fllig "fl" >
+ <!ENTITY ffilig "ffi" >
+ <!ENTITY ffllig "ffl" >
+ <!ENTITY Ascr "𝒜" >
+ <!ENTITY Cscr "𝒞" >
+ <!ENTITY Dscr "𝒟" >
+ <!ENTITY Gscr "𝒢" >
+ <!ENTITY Jscr "𝒥" >
+ <!ENTITY Kscr "𝒦" >
+ <!ENTITY Nscr "𝒩" >
+ <!ENTITY Oscr "𝒪" >
+ <!ENTITY Pscr "𝒫" >
+ <!ENTITY Qscr "𝒬" >
+ <!ENTITY Sscr "𝒮" >
+ <!ENTITY Tscr "𝒯" >
+ <!ENTITY Uscr "𝒰" >
+ <!ENTITY Vscr "𝒱" >
+ <!ENTITY Wscr "𝒲" >
+ <!ENTITY Xscr "𝒳" >
+ <!ENTITY Yscr "𝒴" >
+ <!ENTITY Zscr "𝒵" >
+ <!ENTITY ascr "𝒶" >
+ <!ENTITY bscr "𝒷" >
+ <!ENTITY cscr "𝒸" >
+ <!ENTITY dscr "𝒹" >
+ <!ENTITY fscr "𝒻" >
+ <!ENTITY hscr "𝒽" >
+ <!ENTITY iscr "𝒾" >
+ <!ENTITY jscr "𝒿" >
+ <!ENTITY kscr "𝓀" >
+ <!ENTITY lscr "𝓁" >
+ <!ENTITY mscr "𝓂" >
+ <!ENTITY nscr "𝓃" >
+ <!ENTITY pscr "𝓅" >
+ <!ENTITY qscr "𝓆" >
+ <!ENTITY rscr "𝓇" >
+ <!ENTITY sscr "𝓈" >
+ <!ENTITY tscr "𝓉" >
+ <!ENTITY uscr "𝓊" >
+ <!ENTITY vscr "𝓋" >
+ <!ENTITY wscr "𝓌" >
+ <!ENTITY xscr "𝓍" >
+ <!ENTITY yscr "𝓎" >
+ <!ENTITY zscr "𝓏" >
+ <!ENTITY Afr "𝔄" >
+ <!ENTITY Bfr "𝔅" >
+ <!ENTITY Dfr "𝔇" >
+ <!ENTITY Efr "𝔈" >
+ <!ENTITY Ffr "𝔉" >
+ <!ENTITY Gfr "𝔊" >
+ <!ENTITY Jfr "𝔍" >
+ <!ENTITY Kfr "𝔎" >
+ <!ENTITY Lfr "𝔏" >
+ <!ENTITY Mfr "𝔐" >
+ <!ENTITY Nfr "𝔑" >
+ <!ENTITY Ofr "𝔒" >
+ <!ENTITY Pfr "𝔓" >
+ <!ENTITY Qfr "𝔔" >
+ <!ENTITY Sfr "𝔖" >
+ <!ENTITY Tfr "𝔗" >
+ <!ENTITY Ufr "𝔘" >
+ <!ENTITY Vfr "𝔙" >
+ <!ENTITY Wfr "𝔚" >
+ <!ENTITY Xfr "𝔛" >
+ <!ENTITY Yfr "𝔜" >
+ <!ENTITY afr "𝔞" >
+ <!ENTITY bfr "𝔟" >
+ <!ENTITY cfr "𝔠" >
+ <!ENTITY dfr "𝔡" >
+ <!ENTITY efr "𝔢" >
+ <!ENTITY ffr "𝔣" >
+ <!ENTITY gfr "𝔤" >
+ <!ENTITY hfr "𝔥" >
+ <!ENTITY ifr "𝔦" >
+ <!ENTITY jfr "𝔧" >
+ <!ENTITY kfr "𝔨" >
+ <!ENTITY lfr "𝔩" >
+ <!ENTITY mfr "𝔪" >
+ <!ENTITY nfr "𝔫" >
+ <!ENTITY ofr "𝔬" >
+ <!ENTITY pfr "𝔭" >
+ <!ENTITY qfr "𝔮" >
+ <!ENTITY rfr "𝔯" >
+ <!ENTITY sfr "𝔰" >
+ <!ENTITY tfr "𝔱" >
+ <!ENTITY ufr "𝔲" >
+ <!ENTITY vfr "𝔳" >
+ <!ENTITY wfr "𝔴" >
+ <!ENTITY xfr "𝔵" >
+ <!ENTITY yfr "𝔶" >
+ <!ENTITY zfr "𝔷" >
+ <!ENTITY Aopf "𝔸" >
+ <!ENTITY Bopf "𝔹" >
+ <!ENTITY Dopf "𝔻" >
+ <!ENTITY Eopf "𝔼" >
+ <!ENTITY Fopf "𝔽" >
+ <!ENTITY Gopf "𝔾" >
+ <!ENTITY Iopf "𝕀" >
+ <!ENTITY Jopf "𝕁" >
+ <!ENTITY Kopf "𝕂" >
+ <!ENTITY Lopf "𝕃" >
+ <!ENTITY Mopf "𝕄" >
+ <!ENTITY Oopf "𝕆" >
+ <!ENTITY Sopf "𝕊" >
+ <!ENTITY Topf "𝕋" >
+ <!ENTITY Uopf "𝕌" >
+ <!ENTITY Vopf "𝕍" >
+ <!ENTITY Wopf "𝕎" >
+ <!ENTITY Xopf "𝕏" >
+ <!ENTITY Yopf "𝕐" >
+ <!ENTITY aopf "𝕒" >
+ <!ENTITY bopf "𝕓" >
+ <!ENTITY copf "𝕔" >
+ <!ENTITY dopf "𝕕" >
+ <!ENTITY eopf "𝕖" >
+ <!ENTITY fopf "𝕗" >
+ <!ENTITY gopf "𝕘" >
+ <!ENTITY hopf "𝕙" >
+ <!ENTITY iopf "𝕚" >
+ <!ENTITY jopf "𝕛" >
+ <!ENTITY kopf "𝕜" >
+ <!ENTITY lopf "𝕝" >
+ <!ENTITY mopf "𝕞" >
+ <!ENTITY nopf "𝕟" >
+ <!ENTITY oopf "𝕠" >
+ <!ENTITY popf "𝕡" >
+ <!ENTITY qopf "𝕢" >
+ <!ENTITY ropf "𝕣" >
+ <!ENTITY sopf "𝕤" >
+ <!ENTITY topf "𝕥" >
+ <!ENTITY uopf "𝕦" >
+ <!ENTITY vopf "𝕧" >
+ <!ENTITY wopf "𝕨" >
+ <!ENTITY xopf "𝕩" >
+ <!ENTITY yopf "𝕪" >
+ <!ENTITY zopf "𝕫" >
diff --git a/xml/xml-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java b/xml/xml-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java
index 69a63ba..6164e7a 100644
--- a/xml/xml-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java
+++ b/xml/xml-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java
@@ -721,7 +721,14 @@
@Override
public boolean suitableForFile(@NotNull final PsiFile file) {
- return file instanceof XmlFile;
+ if (file instanceof XmlFile) return true;
+
+ for (PsiFile psiFile : file.getViewProvider().getAllFiles()) {
+ if (psiFile instanceof XmlFile) {
+ return true;
+ }
+ }
+ return false;
}
@Override
diff --git a/xml/xml-analysis-impl/src/com/intellij/xml/util/CheckDtdReferencesInspection.java b/xml/xml-analysis-impl/src/com/intellij/xml/util/CheckDtdReferencesInspection.java
index e266aef..9768dd6 100644
--- a/xml/xml-analysis-impl/src/com/intellij/xml/util/CheckDtdReferencesInspection.java
+++ b/xml/xml-analysis-impl/src/com/intellij/xml/util/CheckDtdReferencesInspection.java
@@ -23,17 +23,14 @@
import com.intellij.codeInspection.XmlSuppressableInspectionTool;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.psi.PsiElementVisitor;
-import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiReference;
import com.intellij.psi.XmlElementVisitor;
-import com.intellij.psi.xml.*;
-import com.intellij.util.containers.HashMap;
+import com.intellij.psi.xml.XmlElement;
+import com.intellij.psi.xml.XmlElementContentSpec;
+import com.intellij.psi.xml.XmlEntityRef;
import com.intellij.xml.XmlBundle;
-import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
-import java.util.Map;
-
/**
* @author Maxim Mossienko
*/
@@ -47,49 +44,14 @@
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
return new XmlElementVisitor() {
-
- private final Map<PsiFile, Boolean> myDoctypeMap = new HashMap<PsiFile, Boolean>();
-
@Override
public void visitXmlElement(final XmlElement element) {
- if (isHtml5Doctype(element)) {
- return;
- }
-
if (element instanceof XmlElementContentSpec ||
element instanceof XmlEntityRef
) {
doCheckRefs(element, holder);
}
}
-
- private boolean isHtml5Doctype(XmlElement element) {
- if (HtmlUtil.isHtml5Context(element)) {
- return true;
- }
-
- PsiFile file = element.getContainingFile();
- if (file instanceof XmlFile) {
- if (!myDoctypeMap.containsKey(file)) {
- myDoctypeMap.put(file, computeHtml5Doctype((XmlFile)file));
- }
- return myDoctypeMap.get(file);
- }
- return false;
- }
-
- private boolean computeHtml5Doctype(XmlFile file) {
- XmlDoctype doctype = null;
- //Search for doctypes from providers
- for (HtmlDoctypeProvider provider : HtmlDoctypeProvider.EP_NAME.getExtensions()) {
- doctype = provider.getDoctype(file);
- if (doctype != null) {
- break;
- }
- }
-
- return doctype != null && HtmlUtil.isHtml5Doctype(doctype);
- }
};
}
@@ -123,11 +85,4 @@
public String getDisplayName() {
return XmlBundle.message("xml.inspections.check.dtd.references");
}
-
- @Override
- @NotNull
- @NonNls
- public String getShortName() {
- return "CheckDtdRefs";
- }
}
diff --git a/xml/xml-psi-impl/resources/standardSchemas/plugin.dtd b/xml/xml-psi-impl/resources/standardSchemas/plugin.dtd
index c1cb334..bb094298 100644
--- a/xml/xml-psi-impl/resources/standardSchemas/plugin.dtd
+++ b/xml/xml-psi-impl/resources/standardSchemas/plugin.dtd
@@ -149,6 +149,8 @@
relative-to-action CDATA #IMPLIED>
<!ELEMENT separator EMPTY>
+<!ELEMENT abbreviation EMPTY>
+
<!-- helpset is a name of file from PLUGIN/help/ folder
Example: <helpset file="myhelp.jar" path="/Help.hs"/>
-->
diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/dtd/HtmlElementDescriptorImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/dtd/HtmlElementDescriptorImpl.java
index 12b2468..2dd7767 100644
--- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/dtd/HtmlElementDescriptorImpl.java
+++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/dtd/HtmlElementDescriptorImpl.java
@@ -95,8 +95,8 @@
}
public XmlAttributeDescriptor getAttributeDescriptor(String attributeName, final XmlTag context) {
- if (!myCaseSensitive) attributeName = attributeName.toLowerCase();
- XmlAttributeDescriptor descriptor = super.getAttributeDescriptor(attributeName, context);
+ String caseSensitiveAttributeName = !myCaseSensitive ? attributeName.toLowerCase() : attributeName;
+ XmlAttributeDescriptor descriptor = super.getAttributeDescriptor(caseSensitiveAttributeName, context);
if (descriptor == null) descriptor = RelaxedHtmlFromSchemaElementDescriptor.getAttributeDescriptorFromFacelets(attributeName, context);
if (descriptor == null) {
@@ -106,7 +106,7 @@
XmlNSDescriptor nsdescriptor = context.getNSDescriptor(XmlUtil.XML_NAMESPACE_URI, true);
if (nsdescriptor instanceof XmlNSDescriptorImpl) {
descriptor = ((XmlNSDescriptorImpl)nsdescriptor).getAttribute(
- XmlUtil.findLocalNameByQualifiedName(attributeName), XmlUtil.XML_NAMESPACE_URI, context);
+ XmlUtil.findLocalNameByQualifiedName(caseSensitiveAttributeName), XmlUtil.XML_NAMESPACE_URI, context);
}
}
}
diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlEntityRefImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlEntityRefImpl.java
index 310f5a2..e666cdc 100644
--- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlEntityRefImpl.java
+++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlEntityRefImpl.java
@@ -26,8 +26,10 @@
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.xml.*;
import com.intellij.util.ArrayUtil;
+import com.intellij.xml.Html5SchemaProvider;
import com.intellij.xml.XmlElementDescriptor;
import com.intellij.xml.impl.schema.AnyXmlElementDescriptor;
+import com.intellij.xml.util.HtmlUtil;
import com.intellij.xml.util.XmlUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -104,7 +106,7 @@
public boolean execute(@NotNull PsiElement element) {
if (element instanceof XmlDoctype) {
XmlDoctype xmlDoctype = (XmlDoctype)element;
- final String dtdUri = XmlUtil.getDtdUri(xmlDoctype);
+ final String dtdUri = getDtdForEntity(xmlDoctype);
if (dtdUri != null) {
XmlFile file = XmlUtil.getContainingFile(element);
if (file == null) return true;
@@ -155,7 +157,8 @@
final XmlElementDescriptor descriptor = rootTag.getDescriptor();
if (descriptor != null && !(descriptor instanceof AnyXmlElementDescriptor)) {
- PsiElement element = descriptor.getDeclaration();
+ PsiElement element = !HtmlUtil.isHtml5Context(rootTag) ? descriptor.getDeclaration() :
+ XmlUtil.findXmlFile((XmlFile)targetElement, Html5SchemaProvider.getCharsDtdLocation());
final PsiFile containingFile = element != null ? element.getContainingFile():null;
final XmlFile descriptorFile = containingFile instanceof XmlFile ? (XmlFile)containingFile:null;
@@ -179,6 +182,10 @@
}
}
+ private static String getDtdForEntity(XmlDoctype xmlDoctype) {
+ return HtmlUtil.isHtml5Doctype(xmlDoctype) ? Html5SchemaProvider.getCharsDtdLocation() : XmlUtil.getDtdUri(xmlDoctype);
+ }
+
public XmlTag getParentTag() {
final XmlElement parent = (XmlElement)getParent();
if(parent instanceof XmlTag) return (XmlTag)parent;
diff --git a/xml/xml-psi-impl/src/com/intellij/xml/Html5SchemaProvider.java b/xml/xml-psi-impl/src/com/intellij/xml/Html5SchemaProvider.java
index bfb1ef6..b9072c3 100644
--- a/xml/xml-psi-impl/src/com/intellij/xml/Html5SchemaProvider.java
+++ b/xml/xml-psi-impl/src/com/intellij/xml/Html5SchemaProvider.java
@@ -19,6 +19,7 @@
private static String HTML5_SCHEMA_LOCATION;
private static String XHTML5_SCHEMA_LOCATION;
+ private static String CHARS_DTD_LOCATION;
private static boolean ourInitialized;
@@ -32,6 +33,12 @@
return XHTML5_SCHEMA_LOCATION;
}
+ public static String getCharsDtdLocation() {
+ ensureInitialized();
+ return CHARS_DTD_LOCATION;
+ }
+
+
private synchronized static void ensureInitialized() {
if (ourInitialized) return;
ourInitialized = true;
@@ -39,6 +46,7 @@
final Html5SchemaProvider[] providers = EP_NAME.getExtensions();
final URL htmlSchemaLocationURL;
final URL xhtmlSchemaLocationURL;
+ final URL dtdCharsLocationURL;
if (providers.length > 1) {
LOG.error("More than one HTML5 schema providers found: " + getClassesListString(providers));
@@ -47,11 +55,13 @@
if (providers.length > 0) {
htmlSchemaLocationURL = providers[0].getHtmlSchemaLocation();
xhtmlSchemaLocationURL = providers[0].getXhtmlSchemaLocation();
+ dtdCharsLocationURL = providers[0].getCharsLocation();
}
else {
LOG.info("RelaxNG based schema for HTML5 is not supported. Old XSD schema will be used");
htmlSchemaLocationURL = Html5SchemaProvider.class.getResource(ExternalResourceManagerEx.STANDARD_SCHEMAS + "html5/xhtml5.xsd");
xhtmlSchemaLocationURL = htmlSchemaLocationURL;
+ dtdCharsLocationURL = htmlSchemaLocationURL;
}
HTML5_SCHEMA_LOCATION = VfsUtilCore.urlToPath(VfsUtilCore.fixURLforIDEA(
@@ -61,6 +71,10 @@
XHTML5_SCHEMA_LOCATION = VfsUtilCore.urlToPath(VfsUtilCore.fixURLforIDEA(
URLUtil.unescapePercentSequences(xhtmlSchemaLocationURL.toExternalForm())));
LOG.info("XHTML5_SCHEMA_LOCATION = " + getXhtml5SchemaLocation());
+
+ CHARS_DTD_LOCATION = VfsUtilCore.urlToPath(VfsUtilCore.fixURLforIDEA(
+ URLUtil.unescapePercentSequences(dtdCharsLocationURL.toExternalForm())));
+ LOG.info("CHARS_DTD_LOCATION = " + getCharsDtdLocation());
}
@NotNull
@@ -69,6 +83,9 @@
@NotNull
public abstract URL getXhtmlSchemaLocation();
+ @NotNull
+ public abstract URL getCharsLocation();
+
static {
}