summaryrefslogtreecommitdiff
path: root/plugins/groovy/src/org
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2013-09-19 12:39:22 -0700
committerTor Norbye <tnorbye@google.com>2013-09-19 12:40:05 -0700
commitbeca9839b2866f90da9dc517c29df2ec25a6f6a8 (patch)
tree747d1f98670ee652ac6637ad488124760b2ac489 /plugins/groovy/src/org
parenta28de544d7f6bae0c637a1f8175ea613a976c52e (diff)
downloadidea-beca9839b2866f90da9dc517c29df2ec25a6f6a8.tar.gz
Snapshot 09776de1457414bbc7dc8a09e242de80e282d7dc from idea/132.325 of git://git.jetbrains.org/idea/community.git
09776de: IDEA-97132 "Building Gradle project info" dialog is modal and non-cancelable 8013ffd: Merge remote-tracking branch 'origin/master' 870d88c: IDEA-113775 External System: new 'Refresh external project' action for single module refresh; shortcut changed to "use-shortcut-of='Refresh'" 8c31855: JediTerm jars updated. 6e01d2c: remove unused dependency of dvcs on groovy 206b35f: allow to filter out inspection highlight infos (IDEA-113738) 0b123a7: pass PsiElement to be able to filter out specific highlight infos based on location (IDEA-113738) 85ca653: do we have java.applet in mockjdk now? 7c0ff90: more diagnostics in buildModulesAndCollectUsedJars() a99e7af: NSIS build scripts moved to community 3f2c72f: robust removeAllBreakpoints catch error while open new tab (attach debugger) Chrome still crashed on speed search in Variable View. bedb5d8: move NsiFiles helper task to community 26e1d16: new inference: do not imply constraints for proper types e273976: new inference: null upper bounds 278120e: move DefaultColorScheme* stuff to editor-ui-ex module e0ed326: Add reference for dependenciesToScan parameter of maven-surefire-plugin 79f4809: IDEA-112202 Ability to open surefire-reports in tests view like Eclipse does Add reference to open test result folder a0d65ce: IDEA-113766 Incorrect font width calculation in text area 44e095e: fix Terminal issues 34b1575: new project wizard: fixing layout problems 077e89f: IDEA-98656 Java doc not generated when an other Java doc has been commented after. 1554b75: IDEA-113604 Error suppression does not stop freemarker validator 5c0d022: IDEA-113596 Can't copy "About" details while indexing a645075: use optimized changes calculation always and only report different values in case of EAP mode c37d75d: IDEA-113581 Gradle: New Project Wizard: it could be possible to enable "Use default gradle wrapper" option 3b277d2: new project wizard: fixing layout problems 6e39762: new project wizard: hiding the "select desired technologies" label 5c1c1b0: new inference: infer from condition 052290e: NPE c1137ac: new inference: promote extends bounds to lower level 6950859: new inference: accept bounds with recursive dependency 92f6ae2: new inference: open top level captured wildcards 1622968: new inference: use dependant variables instantiations when resolve bounds e980a77: IDEA-113581 Gradle: New Project Wizard: it could be possible to enable "Use default gradle wrapper" option b3d49a4: IDEA-113775 External System: new 'Refresh external project' action for single module refresh c0afc26: fix stringWidth on non Retina devices e5781d7: IDEA-110452 Darcula theme causes font size increase 92b5fac: Don't add actions without icons to the file history toolbar 95df681: new project wizard: AddSupportForFrameworksPanel reused bcd0639: EA-49794 - NPE fix fcde853: Gradle: vmOptions provisioning fix 83ef088: IDEA-113199 Grails Plugins manager uses application.properties instead of BuildConfig.groovy Disable Grails plugin dialog for Grails 2.3.0 cae8718: platform: detect case-only name changes e19b820: Cleanup (minor refactoring and optimization) 620b9a1: common super-class extracted for library-based frameworks 60b4a4c: unnecessary intermediate class removed fdec7af: deprecate RoamingTypeExtensionPoint 09faeb9: deprecate RoamingTypeDisabled 2bdc447: [Serega Vasiliev] don't share statistics.application.usages.xml d8c1328: new StreamProvider API: client must not worry about supplementary files (version files for example) cd5f5bf: we don't need to manage list of stream providers, one is enough 3e0ccdd: unused import removed a49963f: Gradle: vmOptions provisioning fix e39cc01: IDEA-113448 Ability to create tests for inner classes 8f64aec: IDEA-113581 Gradle: New Project Wizard: it could be possible to enable "Use default gradle wrapper" option 2ff3757: xdebugger: implemented standalone variables view 93a2c9e: xdebugger: debugger trees decoupled from XDebugSession 7469f4b: notnullification 58c7e6e: hide flex modules from 'available elements' tree in artifact editor c6e955e: ability to cancel write to local file 6999b95: icon classes regenerated: copyright added to generated files, more instructive comment added 4583d6d: action component should be transparent b966b4e: IDEA-96724 Unable to clear Recent Projects list anymore 36c939f: do not handle SelectAll 9007f1e: Merge remote-tracking branch 'origin/master' 0c020d5: JediTerm jars updated. bdd7827: IDEA-98275 (Inspection "Unused assignment" does not work with the += operator) 2366f48: reduce flashes in lens mode da1f984: Lense mode patches&fixes (still internal mode only) 2926b90: unescape unicode escape sequences with a selection 33917b2: Merge remote-tracking branch 'origin/master' db74d04: cleanup aa8b725: keep apple.awt dependencies to util module f5b050d: dfa: boxed/unboxed values are also unknown 68499e9: re: tina 7db91db: For 'normal indices' schedule the file for update and reset stamps for all affected indices (there can be client that used indices between before and after events, in such case indices are up to date due to force update with old content) cee92af: WEB-1212 Add actions "expand children" and "expand descendants" in object variable context menu in JS debug Actually, we don't add such actions, but now speed search can expand nodes. 491868c: Tests updated for system dependent problems. b32093e: Fix 'compare with' on windows for file history. b4e6e2e: IDEA-113622 IDEA-101040 Throw assertion error + add a javadoc 02f8059: groovy for groovy shell 34464a1: cleanup a5c6842: Platform: more precise string version comparison +review CR-OC-818 c5daac1: Merge remote-tracking branch 'origin/master' c9e64f9: Merge branch 'svn1_8_new' 88df6b0: fix dfa false positive in JSTypeofTypeImpl 0a8c128: DfaMemoryStateImpl: use only non-trivial equality classes for comparison fb5e43a: IDEA-94942 Do not add '@' to the path end if no peg revision specified and path does not contain '@' 6eec3b3: IDEA-113725 Remove adding '@' to the checkout destination folder path end 88a8cc6: Enable action for generic fileEditors (non-text) & cleanup 9f1e568: fix NPE on startup with empty configs 57ec7ae: IDEA-108294 every time I open project — it is collapsed to (0.0) fda2edf: IDEA-103303 "BeforeLaunch" tools in run/debug configurations do not do macro substitution (After review http://crucible.labs.intellij.net/cru/CR-IC-2352) 1b52604: new titled renderer 01db28a: rollback 6e2e668: fix stringWidth on Windows 016affd: setup AA as well as fractional metrics b60b5ae: + custom foreground as a parameter e07e365: remove useless warning "Client-side debugging is available in Chrome and Firefox only" 5a773cb: IDEA-113719 Ide frame collapses if a project has been saved with maximised frame on Mac OS X and jdk7 2c7c801: WEB-9277 Exception when startup page in config doesn't start with http:// bad42ce: resource roots: added button to mark directory as a resource root to the toolbar of 'Sources' tab in module editor 82869db: simplification 92ba709: StartBrowserPanel UI fixed after kb review — "Start Browser" checkbox renamed to "After launch", don't disable all panel controls on unselect this checkbox remove label for URL field fix combobox text baseline (only Mac&Acua LAF, other LAFs are not checked) c495a55: cleanup e810a1d: new StreamProvider API: saveContent accept byte[] instead of InputStream 48c3963: hash as primitive int, saveForProviders - avoid document copy e4e62de: IDEA-113678 NPE in external Make with Eclipse compiler 1e0f096: IDEA-95943 Mac OS X, application menu disappears for project sometimes daad75e: Minor code change: optimization 9872570: EA-37570 - IAE: MavenRootModelAdapter.addModuleDependency c110f6a: added icons for resource roots 87a043e: temporary exclude darcula icons from generation 092a4c0: icons classes generation: 'external-system' module migrated to use generated class 2c4952d: Merge remote-tracking branch 'origin/master' dc39410: IDEA-71176 Encapsulate Java fields should update Groovy usages 5de8769: EA-48031 - assert: PsiJavaCodeReferenceElementImpl.diagnoseUnknownParent d2f8238: EA-47448 - SOE: remove GPP traits which cause SOE 3e1a9aa: encode only known references d15350e: batch highlighter dispose requests 2c2111f: avoid deprecated methods ed104a4: refresh todo configuration on color scheme change 02bfaee: cleanup ee5cc85: NPE 17ec6e7: cleanup 2c44b32: visibility 7a12666: AllIcons class regenerated: copyright removed b724720: delete outputs corresponding to changed files for each target before running builders on it f2cb5f3: new inference: initial lambda 0959d41: new inference: delayed constraints 74364db: new inference: accept all new expressions when diamond is checked to support collapse checks 7a06e5d: platform: less Win32 FS cache misses 2fe6eea: EA-47867 (keep order of path macros) 24caf16: Cleanup (unneeded qualifier) cae47e4: model: meaningful macro name assertion cdc9cc1: Cleanup (typos) cf7580c: tests framework: project descriptor creation eased 2d83d16: tests: nothing to present for the public 24f5418: IDEA-113686 Unable to debug gradle tests when -Dtest.single is used c42bb71: correctly handle case changes in resource files for case-insensitive file systems: ensure case of the output file is exactly the same as the case of the source file 6375979: new inference: typo b6d38c0: new inference with diamonds: find in map by context arguments 46e8363: diamonds: unify substitutor calculation 4c9117d: class moved to proper source root d831db7: icons classes generation: fixed regex processing in icon-robots.txt files, android finally excluded from generation 0a73b24: icon classes regenerated; please don't modify icons classes by hand, use icons.gant instead 2920a3e: EA-50043 - UOE: BaseGenerateTestSupportMethodAction$MyHandler.invoke addc304: inspection profile: allow to change inspection settings from quick fix - profileChanged would force diff to default recalculation (IDEA-113650) 39e0079: NPE c20b88c: new inference: fix subtyping direction 005a409: new inference: incomplete exprs 7b431f4: new inference: wildcard bounds could mention type vars aa8f107: StorageUtil.documentToBytes - we should use standard line-separator (\n) - stream provider can share file content on any OS Only stream provider — in case of local file we use system line separator as before 592744f: cleanup 63d4c9b: component version as TObjectLongHashMap fe5954c: cleanup a109761: IDEA-103303 "BeforeLaunch" tools in run/debug configurations do not do macro substitution 6656c26: remove white stripe under Aqua 4cba712: IDEA-113617 (Inspection "Comparator class not declared serializable" proposes wrong modification for extending interface.) 2253395: new StreamProvider API: saveContent accept size as int, listSubFiles returns Collection<String> instead of String[], default impl listSubFiles moved to interface class use new StreamProvider API in ICS plugin fd10033: building searchable options should also be available in community build scripts c142fea: extract a useful function from ultimate build script 7e43f9c: make peter less worried b3ac677: dfa: closure states have empty stack initially c8e66db: flush code block variables when leaving it via exception route d046951: dfa: don't create negated value just to flush it 36a4b9b: DfaVariableValue: not-null psi, store qualified references in the value itself 2401bcc: DfaVariableValue: cheaper creation, cache negated var 67ecf76: a more explicit CommandLog category 3aa48b4: Use JBColor. c33135a: VCS: improve ChangesTreeList selection in Tree mode ec73fec: StartBrowserPanel & JS Debug RC editor — unified url text field 450ff3c: Merge remote-tracking branch 'origin/master' c9064eb: Merge branch 'svn1_8_new' d89ff92: new inference: find method by arg list fixed dcdaebd: new inference: process all vararg args to gather constraints 903f47b: new inference: stop when bound set is fully inferred 2198276: new inference: subtyping with anonymous fixes b36107d: new inference: exclude return type constraint from applicability check e2ee888: new inference: reuse getTargetType initial e6d1b14: new inference: do not infer non-generics calls 48e206d: new inference: equals & hashCode 314333d: IDEA-94942 Make svn command line implementation always use "interactive authentication" (fixes error when "passive authentication" was applied on some threads where thread local storage was not correctly cleared) f3ba5c7: cleanup, apply on name change fix & NPE fix 1b15d56: assertion fix d12f8f3: bigger font size in Project View d78422c: IDEA-94942 Use move destination as working directory for "svn move" command (not to lock source directory by running process) 3d8cdeb: should be undo/redo in TextFieldWithBrowseButton 7b3500d: move StartBrowserSettings to xml module, use our robust Url instead of java URI 8f9926f: IDEA-102165 android xml: show icons and quickdoc for views in code completion 5eea60f: IDEA-113664 Do not use '@' (for peg revision) at the end of move destination a17d4b6: new "Replace Octal Escape with Unicode Escape" intention ff1983d: IDEA-84569 Gradle - IntelliJ warning about 'main' in sourceSet 8f155fa: EfficientChooseByNameModel -> ChooseByNameModelEx EfficientChooseByNameContributor ->ChooseByNameContributorEx 7401dc6: two inner classes instead of anonymous ones for clarity 8076c8c: Merge remote-tracking branch 'origin/master' d7679bb: XmlElementStorage must pass any files to stream providers, project files too: step 1 — adapter for old StreamProvider interface (such old implementations will not get project files as before, only new new implementations). According to reviewer's suggestion, new interface is not part of platform-api, it is our impl interface 8d65d2e: don't expose getStartupPageField afaaeb4: StartBrowserPanel should not require usage SwingHelper.wrapWithHorizontalStretch, add clearBorder 53f4029: simplify saveForProviders 7c3e74c: Merge branch 'svn1_8_new' 24a4e13: Cleanup ExpressionUtils duplication 0bcf6a3: IDEA-112854 Save credentials to memory cache (for command line implementation) 851c574: IDEA-113555 void in right side of assignment de35189: EA-49916 diagnostics 5083a96: IDEA-113117 Groovy: NPE at GrIntroduceConstantDialog.initializeTargetClassEditor() on attempt to introduce a constant to an anonymous class 91f27f1: process only groovy files 5b636c4: IDEA-94942 Refactored utility cleanup command to use SvnLineCommand (instead of SvnSimpleCommand) 1f2c85e: fix testdata d92bbf1: IDEA-94942 Refactored info client to use SvnLineCommand (instead of SvnSimpleCommand) 780efca: allow to use framework-specific libraries from application servers installations 49312c3: IDEA-112821 IDEA falls in endless loop during editing run configurations f24a45e: Workaround for stringWidth in 7u40 03e8f77: IDEA-94942 Refactored update logic - use common behavior for command line svn commands fa37b7b: Platform: JavaDoc for ExecutionTargets +review CR-IC @yole a0c19e2: Platform: compare versions with different number of parts + Version class constructor's arguments order fixed 8b4064a: fix cat walking over keyboard 0fbc2ec: relax dfa time limit for global inspections c5fbb2e: dfa: fix wrong instanceof detection when using several incarnations of the same generic field with different substitutors 8049090: forget old splitter proportions, etc for the sake of less default values (IDEA-113644) 8c2cee3: unnecessary fqn: check for conflict parameterized references 4f24b07: IDEA-94942 Refactored commit logic - use common behavior for command line svn commands b38de05: IDEA-94942 Resolve repository url and command working directory based on command target (file or url) element (for each command line command) 2015083: java: highlighting for statics in anonymous classes 2c8eb0d: Cleanup (formatting) af9ffb8: fix SIOOBE dcfd5ea: Gradle: cosmetic change 6e3c972: platform: commit/dispose allocated model a7b887e: Gradle: changed settings of gradleHomeCache c6c74fa: Gradle: fix external project path option usage 0a138db: IDEA-94942 Refactored LineCommandListener - removed baseDirectory method 99eba34: restore "Fix StringBuilder append" quickfix a5d17029: Merge remote-tracking branch 'origin/master' 7a56ffa: dfa: cleanup block local variables when exiting it 852aaa1: more concise DfaVariableState.toString 0f1494e: dfa: don't multiply eq classes until really needed c2f28d8: VCS: improve ChangesTreeList selection in Tree mode 7cc9d99: Github: add util function a00623d: IDEA-113634 ("Confusing octal escape sequence" inspection misses some cases) e8d6955: before and after template text must be longer for IntentionDescriptionTest e16694e: IDEA-63698 (Inconvertible type (assign double to Integer) not highlighted as error) 0200bab: DfaMemoryState is unfortunately mutable; use defensive copying a808b08: "Replace Unicode Escape with Unescaped Character" intention (IDEA-60661) 11e73a4: allow to use element to the left if element to the right is not available (at the end of the file) ab2c4af: cleanup 91543ed: dfa: treat every getter-like invocation like a field access, don't look inside and don't parse other classes for that 3b8ee6f: global inspections: preallocate less memory for children 7afff0e: global inspections: store parameter references only once 368e989: revert: honor shouldBuildStubFor() for substituted languages 7436173: honor shouldBuildStubFor() for substituted languages 94c7d9b: separate template name for groovy e508172: EA-49855 - assert: TextRange.<init> select start offset for empty statement 353f4b8: EA-49924 - NPE: JavaMethodsConflictResolver.checkSameSignatures 7fa275b: spellchecker: dictionary extended f389b3f: use java LinkedHashMap (why order is not stable?) 7e13241: restore resolve() method with an old signature for old plugins support, mark it as deprecated 42141f3: IDEA-113538 Insert Managed Dependency: does not find artifact based on artifact id 93af907: Gradle: update bundled gradle version to '1.8-rc-1' 6a9eb29: Gradle: update bundled gradle version to '1.8-rc-1' 6bed505: Merge remote-tracking branch 'origin/master' 995ac2b: @InjectMocks also ignored (IDEA-113579) 4d869d9: IDEA-113532 Gradle: use gradle javadocs for script dsl 'quick documentation' enrichment 5769bd9: Merge remote-tracking branch 'origin/master' 9408a08: fix file case 09fbdf3: prefer java paste provider 88c43fb: new inference: fix dependencies b26f1f0: simplify API — TextBrowseFolderListener JSDebug settings editor — file chooser must use the same logic as RC producer 8429da0: Delete unused file with a lot of bugs. 1b6eba8: Update workaround for '--follow' log argument with largefiles extension. b8f0412: Merge remote-tracking branch 'origin/master' e0c2f16: IDEA-94942 Refactored AuthenticationCallback - accept repository url instead of file 269a0de: WEB-9250 Add "Start browser"/"with JavaScript debugger" options to Node.js run/debug configuration b78367f: Fix OC-8214: [',' on the next line] formatting option +review CR-OC @Anton.Makeev 2911086: minor optimization: do not wait for vfs refresh to complete in case build was cancelled cf9c4ae: remove unused import from test data 4c56a28: more assertions 614a73e: IDEA-94942 Require authentication callback for svn command be not null cb122ba: store language level in CoreLanguageLevelProjectExtension fa81fe4: Merge branch 'fix' of git://github.com/bashor/intellij-community into pull102 c51a79a: Fixed TypeConversionUtil#getAllBoxedTypeSupers (after f4a27e8). ProjectRootModificationTracker#getInstance returns NEVER_CHANGED when ProjectRootModificationTracker service not registered. 8c6247d: avoid empty commits, specify author based on system settings b358947: PropertiesComponentImpl must save settings in predictable stable order cf053bf: cleanup c5c0662: WebBrowsersConfiguration must save list of browsers in predictable stable order 1141959: ignore "ver" as well 63ccfea: cleanup f79f498: cleanup: unused code removed da234c7: cleanup: use less specific interface 33ca91f: unused code removed 3e598ed: IDEA-113519 Groovy Shell fails to open with exceptions 8cc385d: A minimal interface sufficient for XVariablesView usage extracted from XDebugSession. 0ab182e: drop obsolete bkwrd-compatibility 2dc69e5: cleanup e70fcab: not every field with non-annotated constructor initializer is notnull 6af48bb: dfa: fix & treatment 1af2b84: typos fbc3d18: IDEA-111450 false positive for "Redundant type cast" inspection b816d27: mission: new inference (initial) ff775ca: external annos: spare some findFileByUrl aea6b5b: IDEA-94942 Make "svn info <url>" work correctly - do not require File instance in parse logic 9304e4b: IDEA-94942 Make path to svn command line client be obtained only once 6e1d4ee: IDEA-98756 IDEA is unable to resolve AspectJ compiler JAR if Maven 3 importing is on 4262c63: ...create a file :) f6fc373: dfa: use more efficient references to common exception classes 9f6948f: IDEA-94942 Refactored commit logic - removed SvnBindClient ea61355: Do you want to create a file named xxx instead? 4e10a46: ExternalAnnotator: compatibility with older clients is restored; typo fixed in collectInformation name +review CR-IC-2315 cfd6567: IDEA-59783 Properties files: code completion list does not open after dot character e3335f6: ExternalAnnotator documentation is improved +review CR-IC-2315 89087c5: IDEA-113375 "Cyclic expand word" should expand words-separated-by-dashes too d10236b: revert "add possibility to setup lookup element for XML attribute values; IDEA-102167 layout_* attributes should go first" 7b2249b: Add ResolveContext object shared between all scheduled resolve tasks; IDEA-113446 Do not clear data in AndroidExternalApklibDependenciesManager. Instead, store cache in ResolveContext to avoid several resolves of one apklib artifact 7e1bcf2: support conversion of artifact settings d1cfd20: IntelliLang: error filter configuration fix & rename e4d31ad: IDEA-94942 Refactored method CommandUtil.putChangeLists (use concrete type instead of Object) 1c11e83: IDEA-113488 Show commit in git log from file history context menu 8415851: IDEA-94942 Changed log level from "warn" to "info" (in svn command execution logic) 24effbd: Merge branch 'master' of git://github.com/asedunov/intellij-community into pull101 c2ea835: 'prepare plugin for deployment' action creates separate jars for modules included into classpath of external build 88a2716: external annotator is allowed to decide if it should handle file with error +review CR-IC d2de078: IDEA-90511 Slow version comparison made faster. d9224ad: assertion fixed f2bf952: IDEA-113312 Do not fail svn command if could not determine working copy root to execute cleanup (after authentication failure) 315ec89: EA-49525 - assert: TextRange.<init> c052ec4: new project wizard: no checkboxes in header 22a8608: simplify JavaScriptDebugStarter — don't implement — consider to implement com.jetbrains.javascript.debugger.FileUrlMapper instead of providing mappings directly 9c8f60b: Merge remote-tracking branch 'origin/master' c6635f0: IDEA-112456 Show "Cleanup" link on "working copies information panel" for svn 1.8 working copies ace9afb: continue extract "Start Browser" functionality from J2EE to platform xml — JavaEEJavaScriptDebugStarter unified 3639fb1: extract "Start Browser" functionality from J2EE to platform xml, remove outdated BrowserLauncher IDEA-23782 tomcat run configuration: list all known browsers 97f8c64: remove deprecated method escapeUrl 59c7b63: IDEA-112794 Explicitly check that current logic could return "null" as svn command exit code 3af18cf: WEB-8397 Incorrect "element is not allowed here" inspection 840d7aa: cleanup 754959a: moved to psi b15f4f0: IDEA-113432 Groovy script classpath should include module dependencies d2030a5: provide default sensible implementation 4f6aadc: EA-49793 - NPE: FilePointerPartNode.update e87e071: customize GeneralHighlightingPass with - HighlightInfoProcessor which reacts to various highlight info lifecycle events - HighlightVisitorProducer which allows to change highlight visitor set to run in this pass (needed in DefaultHighlightVisitorBasedInspection) All this allows to get rid of MessageBus-propagated daemon events which turned out to be too expensive and to untangle GHP from UpdateHighlightingUtil. df5526b: moved to indexing 6581043: cleanup e68c984: moved to project-model 48c7973: suggest to create a file when user creates a directory named "foo.xt" (IDEA-113072) 85fd323: IDEA-112499 Static imports in live templates fail the second time they're used 95693da: WEB-9248 Emmet fails when having HTML entities 27c1f03: un-inject language 167b44d: un-inject language 22e526c: fix documentation prvovider 897e8ea6: resource roots: suggest only java roots for java-specific actions 64055b1: resource roots: show 'out of source' icon for java files under resource roots 5c9daf7: unused method removed 0f17e3d: file chooser: convert jar file from local FS to jar FS in all cases (IDEA-113159) 0b8e31f: <with> for changesViewContent 7349329: suppress warning for xmlRpcHandler 3dd899a: <with> for psi.referenceProvider, quoteHandler 4b0a964: revert 01d5b0e aa2399b: Merge branch 'svn1_8_new' 05ab0c6: DevKit: fix type name for plugin references f7c6cdb: DevKit: no do spellcheck <vendor> 5dc41cb: IDEA-94942 Implemented "Relocate" action 835d71e: java: utility method extracted 79f9b398: remove LoggerFactory.getInstance() because it can silently override static Log4j properties even when TestLoggerFactory is used e6cfd25: IDEA-112456 Implemented "Cleanup" action 2e9d443: Refresh $APP_ROOT/plugins manually on Grails application synchronization. +review CR-IU-291 7c2343c: Nullness cannot be null, therefore mark nullness as @NotNull 8d7f95a: IDEA-26350 (Bad Java code is green: variable might not have been initialized) 7ec8c9e: cleanup 0f63921: EA-49491 - NPE: RenameFileFix.isAvailable b0fb4e9: EA-49640 - IAE: ActionManagerImpl.getId a48e1e6: more diagnostics ed10a0e: more diagnostics c6190a8: cleanup de46935: IDEA-113147 Fixed "typo" so that url field contains url value (but not depth value) 7bf4b24: compact ui mode 842c947: IDEA-113180 Force '@' at the end of paths without peg revision passed to svn command line client ab23b28: don't generate java doc for synthetic elements 26ae6ba: Lense mode "internal" preview e1bb3a2: EA-48054 - CCE: MethodResolverProcessor.execute af608e8: EA-49203 - ISE: GrAnonymousClassType.getJavaClassName a62b14d: EA-48178 - IAE: GrLightClassReferenceElement.<init> b93e88c: EA-49152 - diagnostics ec324a7: Add synchronization on initialization of GroovyMethodInfo +review CR-IC @gromopert f98f472: AppCode: canceling simulator launch, if there are pending sessions to start b54680b: IDEA-94942 Refactored command line commit logic to use common way of parameters creation 8b0c612: remove GroovyDeclarationSearcher as it's only needed for dead Groovy++ (EA-49626) c608b03: dfa: use human numeration, not programmers' one 0c2794b: remove alphanumbering from Reopen Recent Project action 857fb3d: enable "scroll to the end" console action when the last line is not visible (IDEA-113322) 43a124a: correct implementation of ReverseCharSequence.subSequence 1337e5f: WEB-9232 Debugger: support inline base64-encoded source maps: nodejs support 4a0d7d9: AppServerSupportConfigurable reworked afe88ea: reworked IO exception dialog (IDEA-103128) 641595d: artifact editor: keep output file name and artifact name in sync even if output directory name was changed (IDEA-113412) 2a99cd3: IDEA-103015: Project Structure / module / Paths / output paths: Module action in disabled in file choosers ab8aa4e: EA-49739 added null checks in JDParser#formatJDTagDescription [CR-IC-2248] 668cf2c: IDEA-113465 Groovy: UOE at GrConcatenationAwareInjector.getLanguagesToInject() on adding @Language annotation to a string 9a8589c: EA-49261 - assert: PsiElementBase.notNullChild 5a99120: don't generate javadoc for light elements c8d30b0: EA-49487 - diagnostics ccf2ac3: Groovy introduce refactorings: show error hint 878ec43: EA-49641 - IAE: MissingReturnInspection.methodMissesSomeReturns 9574118: EA-47298 - IOE: PsiJavaParserFacadeImpl.createTypeElementFromText 4fceec4: use xml injections in Groovy 1775e6f: Fix maven test 9c4df88: IDEA-94942 Removed fake "empty" svn command 3c76855: IDEA-94942 Refactored status command not to use fake "empty" svn command e0556d8: IDEA-112811 Create client factory for merge based on target working copy format 1b27b17: IDEA-112811 Refactored merge options creation 243ba78: Allow inheritance from HierarchyBrowser implementations (Type/Method hierarchy) 91ef206: IDEA-112803 Implemented tree conflict resolution in "change details" panel 8abd924: IDEA-94942 Add ability to specify depth for "resolve conflict" command 967205e: IDEA-112803 Fixed committed data parsing for "svn status" command 12854d7: IDEA-94942 Update logic refactored to ClientFactory model 4a16e4b: IDEA-94942 Code cleanup - removed unused imports Change-Id: I6acefa9563b98b26db1f88e21354a0de20c27770
Diffstat (limited to 'plugins/groovy/src/org')
-rw-r--r--plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/GrConcatenationAwareInjector.java329
-rw-r--r--plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/GrConcatenationInjector.java38
-rw-r--r--plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/GrInjectionUtil.java112
-rw-r--r--plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/GroovyLanguageInjectionSupport.java90
-rw-r--r--plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/PatternEditorContextMembersProvider.java5
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/actions/GroovyTemplates.java2
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/constructors/GroovyGenerateConstructorHandler.java4
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/ConfigureGroovyLibraryNotificationProvider.java4
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovyAssignabilityCheckInspection.java6
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/utils/JavaStylePropertiesUtil.java1
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/console/DefaultGroovyShellRunner.java21
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyShellAction.java12
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/dsl/GroovyDslScript.java4
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/extensions/GroovyMethodInfo.java46
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/gpp/GppClassSubstitutor.java36
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/gpp/GppPositionManager.java57
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/grape/GrabDependencies.java24
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/lang/documentation/GroovyDocumentationProvider.java2
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/GrClassSubstitutor.java48
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/GroovyDeclarationSearcher.java23
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrAnonymousClassType.java3
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyDirectInheritorsSearcher.java5
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyResolveResultImpl.java10
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/GrThrowsClauseImpl.java26
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrFinallyClauseImpl.java7
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrLightClassReferenceElement.java4
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/PsiUtil.java6
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/MethodResolverProcessor.java10
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcActionBase.java8
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcFramework.java2
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyChangeContextUtil.java17
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/CodeBlockGenerator.java2
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/GenerationUtil.java3
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/GroovyToJavaGenerator.java5
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/encapsulateFields/GroovyEncapsulateFieldHelper.java57
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/GrIntroduceHandlerBase.java71
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrIntroduceConstantProcessor.java5
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/field/GrIntroduceFieldProcessor.java8
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/variable/GrIntroduceLocalVariableProcessor.java14
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/runner/DefaultGroovyScriptRunner.java14
-rw-r--r--plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyScriptRunner.java19
41 files changed, 777 insertions, 383 deletions
diff --git a/plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/GrConcatenationAwareInjector.java b/plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/GrConcatenationAwareInjector.java
index 4bec74ce7528..5f3a421a4a5e 100644
--- a/plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/GrConcatenationAwareInjector.java
+++ b/plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/GrConcatenationAwareInjector.java
@@ -19,21 +19,42 @@ import com.intellij.lang.Language;
import com.intellij.lang.injection.ConcatenationAwareInjector;
import com.intellij.lang.injection.MultiHostRegistrar;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.Trinity;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
+import com.intellij.psi.injection.ReferenceInjector;
+import com.intellij.psi.search.LocalSearchScope;
+import com.intellij.psi.search.searches.ReferencesSearch;
+import com.intellij.psi.tree.IElementType;
import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.util.Processor;
import com.intellij.util.containers.ContainerUtil;
+import gnu.trove.THashSet;
import org.intellij.plugins.intelliLang.Configuration;
import org.intellij.plugins.intelliLang.inject.InjectedLanguage;
import org.intellij.plugins.intelliLang.inject.InjectorUtils;
import org.intellij.plugins.intelliLang.inject.LanguageInjectionSupport;
import org.intellij.plugins.intelliLang.inject.TemporaryPlacesRegistry;
+import org.intellij.plugins.intelliLang.inject.config.BaseInjection;
+import org.intellij.plugins.intelliLang.inject.java.JavaLanguageInjectionSupport;
+import org.intellij.plugins.intelliLang.util.AnnotationUtilEx;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.groovy.codeInspection.utils.ControlFlowUtils;
+import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
+import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase;
+import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
+import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationNameValuePair;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrReturnStatement;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.*;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrStringInjection;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrMethodCallExpression;
+import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
+import java.util.LinkedList;
import java.util.List;
/**
@@ -41,33 +62,301 @@ import java.util.List;
*/
public class GrConcatenationAwareInjector implements ConcatenationAwareInjector {
private final LanguageInjectionSupport mySupport;
+ private final Configuration myConfiguration;
@SuppressWarnings("UnusedParameters")
public GrConcatenationAwareInjector(Configuration configuration, Project project, TemporaryPlacesRegistry temporaryPlacesRegistry) {
+ myConfiguration = configuration;
mySupport = InjectorUtils.findNotNullInjectionSupport(GroovyLanguageInjectionSupport.GROOVY_SUPPORT_ID);
}
@Override
- public void getLanguagesToInject(@NotNull MultiHostRegistrar registrar, @NotNull PsiElement... operands) {
+ public void getLanguagesToInject(@NotNull final MultiHostRegistrar registrar, @NotNull final PsiElement... operands) {
if (operands.length == 0) return;
- Language language = findLanguage(operands);
- if (language != null) {
- PsiFile file = operands[0].getContainingFile();
+ final PsiFile file = operands[0].getContainingFile();
+ if (!(file instanceof GroovyFileBase)) return;
+
+ new InjectionProcessor(myConfiguration, mySupport, operands) {
+ @Override
+ protected void processInjection(Language language,
+ List<Trinity<PsiLanguageInjectionHost, InjectedLanguage, TextRange>> list,
+ boolean settingsAvailable,
+ boolean unparsable) {
+ InjectorUtils.registerInjection(language, list, file, registrar);
+ InjectorUtils.registerSupport(mySupport, settingsAvailable, registrar);
+ InjectorUtils.putInjectedFileUserData(registrar, InjectedLanguageUtil.FRANKENSTEIN_INJECTION, unparsable);
+ }
+ }.processInjections();
+ }
+
+ private static String getStringPresentation(PsiElement operand) {
+ if (operand instanceof GrStringInjection) {
+ return operand.getText();
+ }
+ return "missingValue";
+ }
+
+ @Nullable
+ private String findLanguage(PsiElement[] operands) {
+ PsiElement parent = PsiTreeUtil.findCommonParent(operands);
+ BaseInjection params = GrConcatenationInjector.findLanguageParams(parent, myConfiguration);
+ if (params != null) {
+ return params.getInjectedLanguageId();
+ }
+ return null;
+ }
+
+ static class InjectionProcessor {
+ private final Configuration myConfiguration;
+ private final LanguageInjectionSupport mySupport;
+ private final PsiElement[] myOperands;
+ private boolean myShouldStop;
+ private boolean myUnparsable;
+
+ public InjectionProcessor(Configuration configuration, LanguageInjectionSupport support, PsiElement... operands) {
+ myConfiguration = configuration;
+ mySupport = support;
+ myOperands = operands;
+ }
+
+ void processInjections() {
+ final PsiElement firstOperand = myOperands[0];
+ final PsiElement topBlock = ControlFlowUtils.findControlFlowOwner(firstOperand);
+ final LocalSearchScope searchScope = new LocalSearchScope(new PsiElement[]{topBlock instanceof PsiCodeBlock
+ ? topBlock : firstOperand.getContainingFile()}, "", true);
+ final THashSet<PsiModifierListOwner> visitedVars = new THashSet<PsiModifierListOwner>();
+ final LinkedList<PsiElement> places = new LinkedList<PsiElement>();
+ places.add(firstOperand);
+ final GrInjectionUtil.AnnotatedElementVisitor visitor = new GrInjectionUtil.AnnotatedElementVisitor() {
+ public boolean visitMethodParameter(GrExpression expression, GrCall methodCall) {
+ final GrArgumentList list = methodCall.getArgumentList();
+ assert list != null;
+
+ final String methodName;
+ if (methodCall instanceof GrMethodCallExpression) {
+ GrExpression invoked = ((GrMethodCallExpression)methodCall).getInvokedExpression();
+ final String referenceName = invoked instanceof GrReferenceExpression? ((GrReferenceExpression)invoked).getReferenceName() : null;
+ if ("super".equals(referenceName) || "this".equals(referenceName)) { // constructor call
+ final PsiClass psiClass = PsiTreeUtil.getParentOfType(methodCall, PsiClass.class, true);
+ final PsiClass psiTargetClass = "super".equals(referenceName)? psiClass == null ? null : psiClass.getSuperClass() : psiClass;
+ methodName = psiTargetClass == null? null : psiTargetClass.getName();
+ }
+ else {
+ methodName = referenceName;
+ }
+ }
+ else if (methodCall instanceof GrNewExpression) {
+ final GrCodeReferenceElement classRef = ((GrNewExpression)methodCall).getReferenceElement();
+ methodName = classRef == null ? null : classRef.getReferenceName();
+ }
+ else {
+ methodName = null;
+ }
+ if (methodName != null && areThereInjectionsWithName(methodName, false)) {
+ final GroovyResolveResult result = methodCall.advancedResolve();
+ PsiElement element = result.getElement();
+ if (element instanceof PsiMethod) {
+ PsiMethod method = (PsiMethod)element;
+ final PsiParameter[] parameters = method.getParameterList().getParameters();
+ int index = GrInjectionUtil.findParameterIndex(expression, methodCall);
+ if (index >= 0) {
+ process(parameters[index], method, index);
+ }
+ }
+ }
+ return false;
+ }
+
+ public boolean visitMethodReturnStatement(GrReturnStatement parent, PsiMethod method) {
+ if (areThereInjectionsWithName(method.getName(), false)) {
+ process(method, method, -1);
+ }
+ return false;
+ }
+
+ public boolean visitVariable(PsiVariable variable) {
+ if (myConfiguration.getAdvancedConfiguration().getDfaOption() != Configuration.DfaOption.OFF && visitedVars.add(variable)) {
+ ReferencesSearch.search(variable, searchScope).forEach(new Processor<PsiReference>() {
+ @Override
+ public boolean process(PsiReference psiReference) {
+ final PsiElement element = psiReference.getElement();
+ if (element instanceof GrExpression) {
+ final GrExpression refExpression = (GrExpression)element;
+ places.add(refExpression);
+ if (!myUnparsable) {
+ myUnparsable = checkUnparsableReference(refExpression);
+ }
+ }
+ return true;
+ }
+ });
+ }
+ if (!processCommentInjections(variable)) {
+ myShouldStop = true;
+ }
+ else if (areThereInjectionsWithName(variable.getName(), false)) {
+ process(variable, null, -1);
+ }
+ return false;
+ }
+
+ public boolean visitAnnotationParameter(GrAnnotationNameValuePair nameValuePair, PsiAnnotation psiAnnotation) {
+ final String paramName = nameValuePair.getName();
+ final String methodName = paramName != null ? paramName : PsiAnnotation.DEFAULT_REFERENCED_METHOD_NAME;
+ if (areThereInjectionsWithName(methodName, false)) {
+ final PsiReference reference = nameValuePair.getReference();
+ final PsiElement element = reference == null ? null : reference.resolve();
+ if (element instanceof PsiMethod) {
+ process((PsiMethod)element, (PsiMethod)element, -1);
+ }
+ }
+ return false;
+ }
+
+ public boolean visitReference(GrReferenceExpression expression) {
+ if (myConfiguration.getAdvancedConfiguration().getDfaOption() == Configuration.DfaOption.OFF) return true;
+ final PsiElement e = expression.resolve();
+ if (e instanceof PsiVariable) {
+ if (e instanceof PsiParameter) {
+ final PsiParameter p = (PsiParameter)e;
+ final PsiElement declarationScope = p.getDeclarationScope();
+ final PsiMethod method = declarationScope instanceof PsiMethod ? (PsiMethod)declarationScope : null;
+ final PsiParameterList parameterList = method == null ? null : method.getParameterList();
+ // don't check catchblock parameters & etc.
+ if (!(parameterList == null || parameterList != e.getParent()) &&
+ areThereInjectionsWithName(method.getName(), false)) {
+ final int parameterIndex = parameterList.getParameterIndex((PsiParameter)e);
+ process((PsiModifierListOwner)e, method, parameterIndex);
+ }
+ }
+ visitVariable((PsiVariable)e);
+ }
+ return !myShouldStop;
+ }
+ };
+
+ while (!places.isEmpty() && !myShouldStop) {
+ final PsiElement curPlace = places.removeFirst();
+ GrInjectionUtil.visitAnnotatedElements(curPlace, visitor);
+ }
+
+ }
+
+ private void process(final PsiModifierListOwner owner, PsiMethod method, int paramIndex) {
+ if (!processAnnotationInjections(owner)) {
+ myShouldStop = true;
+ }
+ for (BaseInjection injection : myConfiguration.getInjections(JavaLanguageInjectionSupport.JAVA_SUPPORT_ID)) {
+ if (injection.acceptsPsiElement(owner)) {
+ if (!processXmlInjections(injection, owner, method, paramIndex)) {
+ myShouldStop = true;
+ break;
+ }
+ }
+ }
+ }
+
+ private boolean processAnnotationInjections(final PsiModifierListOwner annoElement) {
+ final String checkName;
+ if (annoElement instanceof PsiParameter) {
+ final PsiElement scope = ((PsiParameter)annoElement).getDeclarationScope();
+ checkName = scope instanceof PsiMethod ? ((PsiNamedElement)scope).getName() : ((PsiNamedElement)annoElement).getName();
+ }
+ else if (annoElement instanceof PsiNamedElement) {
+ checkName = ((PsiNamedElement)annoElement).getName();
+ }
+ else checkName = null;
+ if (checkName == null || !areThereInjectionsWithName(checkName, true)) return true;
+ final PsiAnnotation[] annotations =
+ GrConcatenationInjector.getAnnotationFrom(annoElement, myConfiguration.getAdvancedConfiguration().getLanguageAnnotationPair(), true, true);
+ if (annotations.length > 0) {
+ return processAnnotationInjectionInner(annoElement, annotations);
+ }
+ return true;
+ }
+
+
+ private boolean checkUnparsableReference(GrExpression expression) {
+ final PsiElement parent = expression.getParent();
+ if (parent instanceof GrAssignmentExpression) {
+ final GrAssignmentExpression assignmentExpression = (GrAssignmentExpression)parent;
+ final IElementType operation = assignmentExpression.getOperationTokenType();
+ if (assignmentExpression.getLValue() == expression && operation == GroovyTokenTypes.mPLUS_ASSIGN ) {
+ return true;
+ }
+ }
+ else if (parent instanceof GrBinaryExpression) {
+ return true;
+ }
+ return false;
+
+ }
+
+ protected boolean areThereInjectionsWithName(String methodName, boolean annoOnly) {
+ return true;
+ }
+
+ protected boolean processCommentInjectionInner(PsiVariable owner, PsiElement comment, BaseInjection injection) {
+ processInjectionWithContext(injection, false);
+ return false;
+ }
+
+ protected boolean processAnnotationInjectionInner(PsiModifierListOwner owner, PsiAnnotation[] annotations) {
+ final String id = AnnotationUtilEx.calcAnnotationValue(annotations, "value");
+ final String prefix = AnnotationUtilEx.calcAnnotationValue(annotations, "prefix");
+ final String suffix = AnnotationUtilEx.calcAnnotationValue(annotations, "suffix");
+ final BaseInjection injection = new BaseInjection(JavaLanguageInjectionSupport.JAVA_SUPPORT_ID);
+ if (prefix != null) injection.setPrefix(prefix);
+ if (suffix != null) injection.setSuffix(suffix);
+ if (id != null) injection.setInjectedLanguageId(id);
+ processInjectionWithContext(injection, false);
+ return false;
+ }
+
+ protected boolean processXmlInjections(BaseInjection injection, PsiModifierListOwner owner, PsiMethod method, int paramIndex) {
+ processInjectionWithContext(injection, true);
+ if (injection.isTerminal()) {
+ return false;
+ }
+ return true;
+ }
+
+ private boolean processCommentInjections(PsiVariable owner) {
+ Ref<PsiElement> causeRef = Ref.create();
+ PsiElement anchor = owner.getFirstChild() instanceof PsiComment?
+ (owner.getModifierList() != null? owner.getModifierList() : owner.getTypeElement()) : owner;
+ if (anchor == null) return true;
+ BaseInjection injection = mySupport.findCommentInjection(anchor, causeRef);
+ return injection == null || processCommentInjectionInner(owner, causeRef.get(), injection);
+ }
+
+
+ private void processInjectionWithContext(BaseInjection injection, boolean settingsAvailable) {
+ Language language = InjectedLanguage.findLanguageById(injection.getInjectedLanguageId());
+ if (language == null) {
+ ReferenceInjector injector = ReferenceInjector.findById(injection.getInjectedLanguageId());
+ if (injector != null) {
+ language = injector.toLanguage();
+ }
+ else return;
+ }
+
+ String languageID = language.getID();
List<Trinity<PsiLanguageInjectionHost, InjectedLanguage, TextRange>> list = ContainerUtil.newArrayList();
boolean unparsable = false;
String prefix = "";
//String suffix = "";
- for (int i = 0; i < operands.length; i++) {
- PsiElement operand = operands[i];
+ for (int i = 0; i < myOperands.length; i++) {
+ PsiElement operand = myOperands[i];
final ElementManipulator<PsiElement> manipulator = ElementManipulators.getManipulator(operand);
if (manipulator == null) {
unparsable = true;
prefix += getStringPresentation(operand);
- if (i == operands.length - 1) {
+ if (i == myOperands.length - 1) {
Trinity<PsiLanguageInjectionHost, InjectedLanguage, TextRange> last = ContainerUtil.getLastItem(list);
assert last != null;
InjectedLanguage injected = last.second;
@@ -75,7 +364,7 @@ public class GrConcatenationAwareInjector implements ConcatenationAwareInjector
}
}
else {
- InjectedLanguage injectedLanguage = InjectedLanguage.create(language.getID(), prefix, "", false);
+ InjectedLanguage injectedLanguage = InjectedLanguage.create(languageID, prefix, "", false);
TextRange range = manipulator.getRangeInElement(operand);
PsiLanguageInjectionHost host = (PsiLanguageInjectionHost)operand;
list.add(Trinity.create(host, injectedLanguage, range));
@@ -83,27 +372,15 @@ public class GrConcatenationAwareInjector implements ConcatenationAwareInjector
}
}
- InjectorUtils.registerInjection(language, list, file, registrar);
- InjectorUtils.registerSupport(mySupport, false/*todo*/, registrar);
- InjectorUtils.putInjectedFileUserData(registrar, InjectedLanguageUtil.FRANKENSTEIN_INJECTION, unparsable);
- }
- }
-
- private static String getStringPresentation(PsiElement operand) {
- if (operand instanceof GrStringInjection) {
- return operand.getText();
+ if (!list.isEmpty()) {
+ processInjection(language, list, settingsAvailable, unparsable);
+ }
}
- return "missingValue";
- }
- @Nullable
- private static Language findLanguage(PsiElement[] operands) {
- PsiElement parent = PsiTreeUtil.findCommonParent(operands);
- Trinity<String, String, String> params = GrConcatenationInjector.findLanguageParams(parent);
- if (params != null) {
- return Language.findLanguageByID(params.first);
+ protected void processInjection(Language language,
+ List<Trinity<PsiLanguageInjectionHost, InjectedLanguage, TextRange>> list,
+ boolean settingsAvailable, boolean unparsable) {
}
- return null;
}
}
diff --git a/plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/GrConcatenationInjector.java b/plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/GrConcatenationInjector.java
index a16480ea97fc..ae2c6e6307c3 100644
--- a/plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/GrConcatenationInjector.java
+++ b/plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/GrConcatenationInjector.java
@@ -18,13 +18,13 @@ package org.intellij.plugins.intelliLang.inject.groovy;
import com.intellij.lang.injection.MultiHostInjector;
import com.intellij.lang.injection.MultiHostRegistrar;
import com.intellij.openapi.util.Pair;
-import com.intellij.openapi.util.Trinity;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
import org.intellij.plugins.intelliLang.Configuration;
import org.intellij.plugins.intelliLang.inject.InjectorUtils;
import org.intellij.plugins.intelliLang.inject.LanguageInjectionSupport;
import org.intellij.plugins.intelliLang.inject.config.BaseInjection;
+import org.intellij.plugins.intelliLang.inject.java.JavaLanguageInjectionSupport;
import org.intellij.plugins.intelliLang.util.AnnotationUtilEx;
import org.intellij.plugins.intelliLang.util.PsiUtilEx;
import org.jetbrains.annotations.NotNull;
@@ -59,32 +59,27 @@ public class GrConcatenationInjector implements MultiHostInjector {
}
public static void processInPlace(MultiHostRegistrar registrar, GrLiteral literal) {
- Trinity<String, String, String> params = findLanguageParams(literal);
-
- if (params != null) {
- BaseInjection injection = new BaseInjection(GroovyLanguageInjectionSupport.GROOVY_SUPPORT_ID);
- injection.setInjectedLanguageId(params.first);
- injection.setPrefix(params.second);
- injection.setSuffix(params.third);
+ BaseInjection injection = findLanguageParams(literal, Configuration.getInstance());
+ if (injection != null) {
LanguageInjectionSupport support = InjectorUtils.findInjectionSupport(GroovyLanguageInjectionSupport.GROOVY_SUPPORT_ID);
InjectorUtils.registerInjectionSimple(literal, injection, support, registrar);
}
}
- public static Trinity<String, String, String> findLanguageParams(PsiElement place) {
+ public static BaseInjection findLanguageParams(PsiElement place, Configuration configuration) {
PsiElement parent = place.getParent();
if (parent instanceof GrAssignmentExpression && ((GrAssignmentExpression)parent).getRValue() == place) {
final GrExpression lvalue = ((GrAssignmentExpression)parent).getLValue();
if (lvalue instanceof GrReferenceExpression) {
final PsiElement resolved = ((GrReferenceExpression)lvalue).resolve();
if (resolved instanceof PsiModifierListOwner) {
- return getLanguageParams((PsiModifierListOwner)resolved);
+ return getLanguageParams((PsiModifierListOwner)resolved, configuration);
}
}
}
else if (parent instanceof GrVariable) {
- return getLanguageParams((PsiModifierListOwner)parent);
+ return getLanguageParams((PsiModifierListOwner)parent, configuration);
}
else if (parent instanceof GrArgumentList) {
final PsiElement pparent = parent.getParent();
@@ -98,7 +93,7 @@ public class GrConcatenationInjector implements MultiHostInjector {
if (map != null) {
final Pair<PsiParameter, PsiType> pair = map.get(place);
- return getLanguageParams(pair.first);
+ return getLanguageParams(pair.first, configuration);
}
}
}
@@ -107,14 +102,29 @@ public class GrConcatenationInjector implements MultiHostInjector {
}
@Nullable
- public static Trinity<String, String, String> getLanguageParams(PsiModifierListOwner annotationOwner) {
+ private static BaseInjection getLanguageParams(PsiModifierListOwner annotationOwner, Configuration configuration) {
final Pair<String, ? extends Set<String>> pair = Configuration.getInstance().getAdvancedConfiguration().getLanguageAnnotationPair();
final PsiAnnotation[] annotations = getAnnotationFrom(annotationOwner, pair, true, true);
if (annotations.length > 0) {
String prefix = StringUtil.notNullize(AnnotationUtilEx.calcAnnotationValue(annotations, "prefix"));
String suffix = StringUtil.notNullize(AnnotationUtilEx.calcAnnotationValue(annotations, "suffix"));
String id = StringUtil.notNullize(AnnotationUtilEx.calcAnnotationValue(annotations, "value"));
- return Trinity.create(id, prefix, suffix);
+ if (!StringUtil.isEmpty(id)) {
+ BaseInjection injection = new BaseInjection(GroovyLanguageInjectionSupport.GROOVY_SUPPORT_ID);
+ injection.setPrefix(prefix);
+ injection.setSuffix(suffix);
+ injection.setInjectedLanguageId(id);
+ return injection;
+ }
+ }
+
+ if (annotationOwner instanceof PsiParameter && annotationOwner.getParent() instanceof PsiParameterList &&annotationOwner.getParent().getParent() instanceof PsiMethod) {
+ List<BaseInjection> injections = configuration.getInjections(JavaLanguageInjectionSupport.JAVA_SUPPORT_ID);
+ for (BaseInjection injection : injections) {
+ if (injection.acceptsPsiElement(annotationOwner)) {
+ return injection;
+ }
+ }
}
return null;
diff --git a/plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/GrInjectionUtil.java b/plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/GrInjectionUtil.java
new file mode 100644
index 000000000000..612af211bb62
--- /dev/null
+++ b/plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/GrInjectionUtil.java
@@ -0,0 +1,112 @@
+/*
+ * 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.intellij.plugins.intelliLang.inject.groovy;
+
+import com.intellij.openapi.util.Pair;
+import com.intellij.psi.*;
+import com.intellij.psi.util.PsiTreeUtil;
+import org.intellij.plugins.intelliLang.util.ContextComputationProcessor;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
+import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
+import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
+import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationArrayInitializer;
+import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationNameValuePair;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrReturnStatement;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.*;
+import org.jetbrains.plugins.groovy.lang.psi.impl.signatures.GrClosureSignatureUtil;
+
+import java.util.Map;
+
+/**
+ * Created by Max Medvedev on 9/12/13
+ */
+public class GrInjectionUtil {
+ static int findParameterIndex(PsiElement arg, GrCall call) {
+ final GroovyResolveResult result = call.advancedResolve();
+ if (!(result.getElement() instanceof PsiMethod)) return -1;
+
+ final Map<GrExpression, Pair<PsiParameter, PsiType>> map = GrClosureSignatureUtil
+ .mapArgumentsToParameters(result, call, false, false, call.getNamedArguments(), call.getExpressionArguments(), call.getClosureArguments());
+ if (map == null) return -1;
+
+ final PsiMethod method = (PsiMethod)result.getElement();
+ final PsiParameter parameter = map.get(arg).first;
+ if (parameter == null) return -1;
+
+ return method.getParameterList().getParameterIndex(parameter);
+ }
+
+ public interface AnnotatedElementVisitor {
+ boolean visitMethodParameter(GrExpression expression, GrCall psiCallExpression);
+ boolean visitMethodReturnStatement(GrReturnStatement parent, PsiMethod method);
+ boolean visitVariable(PsiVariable variable);
+ boolean visitAnnotationParameter(GrAnnotationNameValuePair nameValuePair, PsiAnnotation psiAnnotation);
+ boolean visitReference(GrReferenceExpression expression);
+ }
+
+ public static void visitAnnotatedElements(@Nullable PsiElement element, AnnotatedElementVisitor visitor) {
+ if (element == null) return;
+ for (PsiElement cur = ContextComputationProcessor.getTopLevelInjectionTarget(element); cur != null; cur = cur.getParent()) {
+ if (!visitAnnotatedElementInner(cur, visitor)) return;
+ }
+ }
+
+ private static boolean visitAnnotatedElementInner(PsiElement element, AnnotatedElementVisitor visitor) {
+ final PsiElement parent = element.getParent();
+
+ if (element instanceof GrReferenceExpression) {
+ if (!visitor.visitReference((GrReferenceExpression)element)) return false;
+ }
+ else if (element instanceof GrAnnotationNameValuePair && parent != null && parent.getParent() instanceof PsiAnnotation) {
+ return visitor.visitAnnotationParameter((GrAnnotationNameValuePair)element, (PsiAnnotation)parent.getParent());
+ }
+
+ if (parent instanceof GrAssignmentExpression) {
+ final GrAssignmentExpression p = (GrAssignmentExpression)parent;
+ if (p.getRValue() == element || p.getOperationTokenType() == GroovyTokenTypes.mPLUS_ASSIGN) {
+ final GrExpression left = p.getLValue();
+ if (left instanceof GrReferenceExpression) {
+ if (!visitor.visitReference((GrReferenceExpression)left)) return false;
+ }
+ }
+ }
+ else if (parent instanceof GrConditionalExpression && ((GrConditionalExpression)parent).getCondition() == element) {
+ return false;
+ }
+ else if (parent instanceof GrReturnStatement) {
+ final PsiElement m = PsiTreeUtil.getParentOfType(parent, PsiMethod.class, GrClosableBlock.class, GroovyFile.class);
+ if (m instanceof PsiMethod) {
+ if (!visitor.visitMethodReturnStatement((GrReturnStatement)parent, (PsiMethod)m)) return false;
+ }
+ }
+ else if (parent instanceof PsiVariable) {
+ return visitor.visitVariable((PsiVariable)parent);
+ }
+ else if (parent instanceof PsiModifierListOwner) {
+ return false; // PsiClass/PsiClassInitializer/PsiCodeBlock
+ }
+ else if (parent instanceof GrAnnotationArrayInitializer || parent instanceof GrAnnotationNameValuePair) {
+ return true;
+ }
+ else if (parent instanceof GrArgumentList && parent.getParent() instanceof GrCall && element instanceof GrExpression) {
+ return visitor.visitMethodParameter((GrExpression)element, (GrCall)parent.getParent());
+ }
+ return true;
+ }
+}
diff --git a/plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/GroovyLanguageInjectionSupport.java b/plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/GroovyLanguageInjectionSupport.java
index bd0122fbf2e6..d8be45115765 100644
--- a/plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/GroovyLanguageInjectionSupport.java
+++ b/plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/GroovyLanguageInjectionSupport.java
@@ -22,7 +22,13 @@ import com.intellij.openapi.util.Pair;
import com.intellij.psi.*;
import com.intellij.psi.impl.light.LightElement;
import com.intellij.psi.tree.IElementType;
+import com.intellij.util.NullableFunction;
+import com.intellij.util.containers.ContainerUtil;
+import org.intellij.plugins.intelliLang.Configuration;
import org.intellij.plugins.intelliLang.inject.AbstractLanguageInjectionSupport;
+import org.intellij.plugins.intelliLang.inject.InjectorUtils;
+import org.intellij.plugins.intelliLang.inject.LanguageInjectionSupport;
+import org.intellij.plugins.intelliLang.inject.config.BaseInjection;
import org.intellij.plugins.intelliLang.inject.java.JavaLanguageInjectionSupport;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -30,7 +36,6 @@ import org.jetbrains.plugins.groovy.codeInspection.utils.ControlFlowUtils;
import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
import org.jetbrains.plugins.groovy.lang.psi.GrControlFlowOwner;
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
-import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrListOrMap;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationArrayInitializer;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationNameValuePair;
@@ -39,12 +44,16 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrReturnStatement;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.*;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteralContainer;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrString;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrStringContent;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
-import org.jetbrains.plugins.groovy.lang.psi.impl.signatures.GrClosureSignatureUtil;
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.literals.GrLiteralImpl;
import org.jetbrains.plugins.groovy.lang.psi.patterns.GroovyPatterns;
-import java.util.Map;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
/**
* @author Gregory.Shrago
@@ -84,6 +93,58 @@ public class GroovyLanguageInjectionSupport extends AbstractLanguageInjectionSup
return doInject(language.getID(), psiElement, psiElement);
}
+ @Override
+ public boolean removeInjectionInPlace(final PsiLanguageInjectionHost psiElement) {
+ if (!isStringLiteral(psiElement)) return false;
+
+ GrLiteralContainer host = (GrLiteralContainer)psiElement;
+ final HashMap<BaseInjection, Pair<PsiMethod, Integer>> injectionsMap = ContainerUtil.newHashMap();
+ final ArrayList<PsiElement> annotations = new ArrayList<PsiElement>();
+ final Project project = host.getProject();
+ final Configuration configuration = Configuration.getProjectInstance(project);
+ collectInjections(host, configuration, this, injectionsMap, annotations);
+
+ if (injectionsMap.isEmpty() && annotations.isEmpty()) return false;
+ final ArrayList<BaseInjection> originalInjections = new ArrayList<BaseInjection>(injectionsMap.keySet());
+ final List<BaseInjection> newInjections = ContainerUtil.mapNotNull(originalInjections, new NullableFunction<BaseInjection, BaseInjection>() {
+ public BaseInjection fun(final BaseInjection injection) {
+ final Pair<PsiMethod, Integer> pair = injectionsMap.get(injection);
+ final String placeText = JavaLanguageInjectionSupport.getPatternStringForJavaPlace(pair.first, pair.second);
+ final BaseInjection newInjection = injection.copy();
+ newInjection.setPlaceEnabled(placeText, false);
+ return InjectorUtils.canBeRemoved(newInjection) ? null : newInjection;
+ }
+ });
+ configuration.replaceInjectionsWithUndo(project, newInjections, originalInjections, annotations);
+ return true;
+ }
+
+ private static void collectInjections(GrLiteralContainer host,
+ Configuration configuration,
+ LanguageInjectionSupport support,
+ final HashMap<BaseInjection, Pair<PsiMethod, Integer>> injectionsMap,
+ final ArrayList<PsiElement> annotations) {
+ new GrConcatenationAwareInjector.InjectionProcessor(configuration, support, host) {
+ @Override
+ protected boolean processCommentInjectionInner(PsiVariable owner, PsiElement comment, BaseInjection injection) {
+ ContainerUtil.addAll(annotations, comment);
+ return true;
+ }
+
+ @Override
+ protected boolean processAnnotationInjectionInner(PsiModifierListOwner owner, PsiAnnotation[] annos) {
+ ContainerUtil.addAll(annotations, annos);
+ return true;
+ }
+
+ @Override
+ protected boolean processXmlInjections(BaseInjection injection, PsiModifierListOwner owner, PsiMethod method, int paramIndex) {
+ injectionsMap.put(injection, Pair.create(method, paramIndex));
+ return true;
+ }
+ }.processInjections();
+ }
+
private static boolean doInject(String languageId, PsiElement psiElement, PsiLanguageInjectionHost host) {
final PsiElement target = getTopLevelInjectionTarget(psiElement);
final PsiElement parent = target.getParent();
@@ -110,7 +171,7 @@ public class GroovyLanguageInjectionSupport extends AbstractLanguageInjectionSup
else if (parent instanceof GrArgumentList && parent.getParent() instanceof GrMethodCall) {
final PsiMethod method = ((GrMethodCall)parent.getParent()).resolveMethod();
if (method != null) {
- final int index = findParameterIndex(target, ((GrMethodCall)parent.getParent()));
+ final int index = GrInjectionUtil.findParameterIndex(target, ((GrMethodCall)parent.getParent()));
if (index >= 0) {
return JavaLanguageInjectionSupport.doInjectInJavaMethod(project, method, index, host, languageId);
}
@@ -136,23 +197,11 @@ public class GroovyLanguageInjectionSupport extends AbstractLanguageInjectionSup
return false;
}
- private static int findParameterIndex(PsiElement arg, GrMethodCall call) {
- final GroovyResolveResult result = call.advancedResolve();
- assert result.getElement() instanceof PsiMethod;
- final Map<GrExpression, Pair<PsiParameter, PsiType>> map = GrClosureSignatureUtil
- .mapArgumentsToParameters(result, call, false, false, call.getNamedArguments(), call.getExpressionArguments(),
- call.getClosureArguments());
- if (map == null) return -1;
-
- final PsiMethod method = (PsiMethod)result.getElement();
- final PsiParameter parameter = map.get(arg).first;
- if (parameter == null) return -1;
-
- return method.getParameterList().getParameterIndex(parameter);
- }
-
private static boolean isStringLiteral(PsiLanguageInjectionHost element) {
- if (element instanceof GrLiteral) {
+ if (element instanceof GrStringContent) {
+ return true;
+ }
+ else if (element instanceof GrLiteral) {
final IElementType type = GrLiteralImpl.getLiteralType((GrLiteral)element);
return TokenSets.STRING_LITERALS.contains(type);
}
@@ -165,6 +214,7 @@ public class GroovyLanguageInjectionSupport extends AbstractLanguageInjectionSup
PsiElement parent = target.getParent();
for (; parent != null; target = parent, parent = target.getParent()) {
if (parent instanceof GrBinaryExpression) continue;
+ if (parent instanceof GrString) continue;
if (parent instanceof GrParenthesizedExpression) continue;
if (parent instanceof GrConditionalExpression && ((GrConditionalExpression)parent).getCondition() != target) continue;
if (parent instanceof GrAnnotationArrayInitializer) continue;
diff --git a/plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/PatternEditorContextMembersProvider.java b/plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/PatternEditorContextMembersProvider.java
index bca271ea6d42..0afd46f4069d 100644
--- a/plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/PatternEditorContextMembersProvider.java
+++ b/plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/PatternEditorContextMembersProvider.java
@@ -19,6 +19,7 @@ import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.progress.EmptyProgressIndicator;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
+import com.intellij.openapi.util.ModificationTracker;
import com.intellij.patterns.compiler.PatternClassBean;
import com.intellij.patterns.compiler.PatternCompilerFactory;
import com.intellij.psi.*;
@@ -35,7 +36,6 @@ import com.intellij.psi.util.CachedValuesManager;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.xml.XmlTag;
import com.intellij.psi.xml.XmlText;
-import com.intellij.util.ArrayUtil;
import com.intellij.util.Processor;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.text.StringSearcher;
@@ -87,7 +87,8 @@ public class PatternEditorContextMembersProvider extends NonCodeMembersContribut
@Override
public Result<List<PsiElement>> compute() {
return new Result<List<PsiElement>>(Collections.<PsiElement>singletonList(
- getRootByClasses(InjectorUtils.getPatternClasses(injection.getSupportId()), file.getProject())), ArrayUtil.EMPTY_OBJECT_ARRAY);
+ getRootByClasses(InjectorUtils.getPatternClasses(injection.getSupportId()), file.getProject())),
+ ModificationTracker.NEVER_CHANGED);
}
};
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/GroovyTemplates.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/GroovyTemplates.java
index 49875ced64b9..8a443b219923 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/GroovyTemplates.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/GroovyTemplates.java
@@ -29,7 +29,7 @@ public interface GroovyTemplates {
@NonNls String GROOVY_DSL_SCRIPT = "GroovyDslScript.gdsl";
@NonNls String GANT_SCRIPT = "GantScript.gant";
@NonNls String GROOVY_SERVER_PAGE = "GroovyServerPage.gsp";
- @NonNls String GROOVY_FROM_USAGE_METHOD_BODY = "New Method Body.groovy";
+ @NonNls String GROOVY_FROM_USAGE_METHOD_BODY = "Groovy New Method Body.groovy";
@NonNls String GROOVY_JUNIT_TEST_METHOD_GROOVY = "Groovy JUnit Test Method.groovy";
@NonNls String GROOVY_JUNIT_SET_UP_METHOD_GROOVY = "Groovy JUnit SetUp Method.groovy";
@NonNls String GROOVY_JUNIT_TEAR_DOWN_METHOD_GROOVY = "Groovy JUnit TearDown Method.groovy";
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/constructors/GroovyGenerateConstructorHandler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/constructors/GroovyGenerateConstructorHandler.java
index b815bd68edf7..ebec4689bd3a 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/constructors/GroovyGenerateConstructorHandler.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/constructors/GroovyGenerateConstructorHandler.java
@@ -120,6 +120,10 @@ public class GroovyGenerateConstructorHandler extends GenerateConstructorHandler
final String[] paramTypes = ArrayUtil.toStringArray(parametersTypes);
assert constructorName != null;
GrMethod grConstructor = factory.createConstructorFromText(constructorName, paramTypes, paramNames, body);
+ PsiReferenceList throwsList = grConstructor.getThrowsList();
+ for (PsiJavaCodeReferenceElement element : constructor.getThrowsList().getReferenceElements()) {
+ throwsList.add(element);
+ }
codeStyleManager.shortenClassReferences(grConstructor);
grConstructors.add(new GroovyGenerationInfo<GrMethod>(grConstructor));
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/ConfigureGroovyLibraryNotificationProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/ConfigureGroovyLibraryNotificationProvider.java
index 711d6598cffb..dd4308b4bdfd 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/ConfigureGroovyLibraryNotificationProvider.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/ConfigureGroovyLibraryNotificationProvider.java
@@ -28,6 +28,7 @@ import com.intellij.openapi.roots.ModuleRootAdapter;
import com.intellij.openapi.roots.ModuleRootEvent;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.util.Key;
+import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.EditorNotificationPanel;
import com.intellij.ui.EditorNotifications;
@@ -74,6 +75,9 @@ public class ConfigureGroovyLibraryNotificationProvider extends EditorNotificati
public EditorNotificationPanel createNotificationPanel(VirtualFile file, FileEditor fileEditor) {
try {
if (!supportedFileTypes.contains(file.getFileType())) return null;
+ // do not show the panel for Gradle build scripts
+ // expecting groovy library to always be available at the gradle distribution
+ if (StringUtil.endsWith(file.getName(), ".gradle")) return null;
if (CompilerManager.getInstance(myProject).isExcludedFromCompilation(file)) return null;
final Module module = ModuleUtil.findModuleForFile(file, myProject);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovyAssignabilityCheckInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovyAssignabilityCheckInspection.java
index 8f9629ba80a2..fff85386e35c 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovyAssignabilityCheckInspection.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovyAssignabilityCheckInspection.java
@@ -125,7 +125,7 @@ public class GroovyAssignabilityCheckInspection extends BaseInspection {
if (PsiUtil.isRawClassMemberAccess(expression)) return;
if (checkForImplicitEnumAssigning(expectedType, expression, expression)) return;
final PsiType rType = expression.getType();
- if (rType == null || rType == PsiType.VOID) return;
+ if (rType == null) return;
if (!TypesUtil.isAssignable(expectedType, rType, expression)) {
final List<LocalQuickFix> fixes = ContainerUtil.newArrayList();
@@ -219,7 +219,9 @@ public class GroovyAssignabilityCheckInspection extends BaseInspection {
final PsiType returnType = PsiImplUtil.inferReturnType(expression);
final GrControlFlowOwner flowOwner = ControlFlowUtils.findControlFlowOwner(expression);
if (flowOwner != null && returnType != null && returnType != PsiType.VOID) {
- if (ControlFlowUtils.isReturnValue(expression, flowOwner) && !isNewInstanceInitialingByTuple(expression)) {
+ if (ControlFlowUtils.isReturnValue(expression, flowOwner) &&
+ !isNewInstanceInitialingByTuple(expression) &&
+ expression.getType() != PsiType.VOID) {
checkAssignability(returnType, expression, getExpressionPartToHighlight(expression));
}
}
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 0328abe2a217..c5fcdbbf12f1 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
@@ -57,6 +57,7 @@ public class JavaStylePropertiesUtil {
private static GrAssignmentExpression genRefForSetter(GrMethodCall call, String accessorName) {
String name = getPropertyNameBySetterName(accessorName);
+ assert name != null : accessorName;
GrExpression value = call.getExpressionArguments()[0];
GrReferenceExpression refExpr = (GrReferenceExpression)call.getInvokedExpression();
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/console/DefaultGroovyShellRunner.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/console/DefaultGroovyShellRunner.java
index cf4ba7d61433..58b672d1e153 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/console/DefaultGroovyShellRunner.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/console/DefaultGroovyShellRunner.java
@@ -22,7 +22,6 @@ import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.search.GlobalSearchScope;
-import com.intellij.util.PathsList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.config.AbstractConfigUtils;
import org.jetbrains.plugins.groovy.config.GroovyConfigUtils;
@@ -32,6 +31,8 @@ import org.jetbrains.plugins.groovy.runner.GroovyScriptRunner;
import org.jetbrains.plugins.groovy.util.GroovyUtils;
import org.jetbrains.plugins.groovy.util.LibrariesUtil;
+import java.io.File;
+
/**
* @author Sergey Evdokimov
*/
@@ -47,13 +48,19 @@ public class DefaultGroovyShellRunner extends GroovyShellRunner {
@Override
public JavaParameters createJavaParameters(@NotNull Module module) throws ExecutionException {
JavaParameters res = GroovyScriptRunConfiguration.createJavaParametersWithSdk(module);
- DefaultGroovyScriptRunner.configureGenericGroovyRunner(res, module, "org.codehaus.groovy.tools.shell.Main", !hasGroovyAll(module));
- PathsList list = GroovyScriptRunner.getClassPathFromRootModel(module, true, res, true);
- if (list != null) {
- res.getClassPath().addAll(list.getPathList());
+ boolean useBundled = !hasGroovyAll(module);
+ DefaultGroovyScriptRunner.configureGenericGroovyRunner(res, module, "org.codehaus.groovy.tools.shell.Main", false, true);
+ if (useBundled) {
+ String parent = GroovyUtils.getBundledGroovyJar().getParent();
+ String groovyHome = parent + File.separator + "groovy";
+ File libDir = new File(groovyHome + File.separator + "lib");
+ assert libDir.isDirectory();
+ for (File file : libDir.listFiles()) {
+ res.getClassPath().add(file);
+ }
+
+ GroovyScriptRunner.setGroovyHome(res, groovyHome);
}
- //res.getProgramParametersList().addAll("-p", GroovyScriptRunner.getPathInConf("console.txt"));
- //res.getVMParametersList().add("-Xdebug"); res.getVMParametersList().add("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5239");
res.setWorkingDirectory(getWorkingDirectory(module));
return res;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyShellAction.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyShellAction.java
index f27aaf9cb769..289977c21a89 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyShellAction.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyShellAction.java
@@ -24,7 +24,7 @@ import com.intellij.execution.runners.AbstractConsoleRunnerWithHistory;
import com.intellij.execution.runners.ConsoleExecuteActionHandler;
import com.intellij.ide.util.PropertiesComponent;
import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.openapi.actionSystem.PlatformDataKeys;
+import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.compiler.CompileContext;
import com.intellij.openapi.compiler.CompileStatusNotification;
import com.intellij.openapi.compiler.CompilerManager;
@@ -76,7 +76,7 @@ public class GroovyShellAction extends DumbAwareAction {
@Override
public void update(AnActionEvent e) {
- final Project project = e.getData(PlatformDataKeys.PROJECT);
+ final Project project = e.getData(CommonDataKeys.PROJECT);
boolean enabled = project != null && !getGroovyCompatibleModules(project).isEmpty();
@@ -86,7 +86,7 @@ public class GroovyShellAction extends DumbAwareAction {
@Override
public void actionPerformed(AnActionEvent e) {
- final Project project = e.getData(PlatformDataKeys.PROJECT);
+ final Project project = e.getData(CommonDataKeys.PROJECT);
assert project != null;
CompilerManager.getInstance(project).make(new CompileStatusNotification() {
@@ -105,7 +105,7 @@ public class GroovyShellAction extends DumbAwareAction {
});
}
- private void runGroovyShell(Project project) {
+ private static void runGroovyShell(Project project) {
List<Module> modules = new ArrayList<Module>();
final Map<Module, String> versions = new HashMap<Module, String>();
@@ -159,7 +159,7 @@ public class GroovyShellAction extends DumbAwareAction {
JBPopupFactory.getInstance().createListPopup(step).showCenteredInCurrentWindow(project);
}
- private void doRun(final Module module) {
+ private static void doRun(final Module module) {
final GroovyShellRunner shellRunner = GroovyShellRunner.getAppropriateRunner(module);
if (shellRunner == null) return;
@@ -220,7 +220,7 @@ public class GroovyShellAction extends DumbAwareAction {
}
catch (ExecutionException e1) {
LOG.info(e1);
- Messages.showErrorDialog(module.getProject(), e1.getMessage(), "Cannot run Groovy Shell");
+ Messages.showErrorDialog(module.getProject(), e1.getMessage(), "Cannot Run Groovy Shell");
}
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/dsl/GroovyDslScript.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/dsl/GroovyDslScript.java
index 1cf5661c2418..2ae6f07786b8 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/dsl/GroovyDslScript.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/dsl/GroovyDslScript.java
@@ -78,8 +78,8 @@ public class GroovyDslScript {
return holder.processMembers(descriptor, processor, state);
}
catch (IncorrectOperationException e) {
- LOG.error("Error while processing dsl script '" + myPath + "'", e);
- return false;
+ handleDslError(e);
+ return true;
}
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/extensions/GroovyMethodInfo.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/extensions/GroovyMethodInfo.java
index 3d3f6e416837..7730c6feb110 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/extensions/GroovyMethodInfo.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/extensions/GroovyMethodInfo.java
@@ -43,32 +43,34 @@ public class GroovyMethodInfo {
private static void ensureInit() {
if (METHOD_INFOS != null) return;
- Map<String, Map<String, List<GroovyMethodInfo>>> methodInfos = new HashMap<String, Map<String, List<GroovyMethodInfo>>>();
- Map<String, Map<String, List<GroovyMethodInfo>>> lightMethodInfos = new HashMap<String, Map<String, List<GroovyMethodInfo>>>();
-
- for (GroovyClassDescriptor classDescriptor : GroovyClassDescriptor.EP_NAME.getExtensions()) {
- ClassLoader classLoader = classDescriptor.getLoaderForClass();
- for (GroovyMethodDescriptor method : classDescriptor.methods) {
- addMethodDescriptor(methodInfos, method, classLoader, classDescriptor.className);
+ synchronized (GroovyMethodInfo.class) {
+ Map<String, Map<String, List<GroovyMethodInfo>>> methodInfos = new HashMap<String, Map<String, List<GroovyMethodInfo>>>();
+ Map<String, Map<String, List<GroovyMethodInfo>>> lightMethodInfos = new HashMap<String, Map<String, List<GroovyMethodInfo>>>();
+
+ for (GroovyClassDescriptor classDescriptor : GroovyClassDescriptor.EP_NAME.getExtensions()) {
+ ClassLoader classLoader = classDescriptor.getLoaderForClass();
+ for (GroovyMethodDescriptor method : classDescriptor.methods) {
+ addMethodDescriptor(methodInfos, method, classLoader, classDescriptor.className);
+ }
}
- }
- for (GroovyMethodDescriptorExtension methodDescriptor : GroovyMethodDescriptorExtension.EP_NAME.getExtensions()) {
- if (methodDescriptor.className != null) {
- assert methodDescriptor.lightMethodKey == null;
- addMethodDescriptor(methodInfos, methodDescriptor, methodDescriptor.getLoaderForClass(), methodDescriptor.className);
- }
- else {
- assert methodDescriptor.className == null;
- addMethodDescriptor(lightMethodInfos, methodDescriptor, methodDescriptor.getLoaderForClass(), methodDescriptor.lightMethodKey);
+ for (GroovyMethodDescriptorExtension methodDescriptor : GroovyMethodDescriptorExtension.EP_NAME.getExtensions()) {
+ if (methodDescriptor.className != null) {
+ assert methodDescriptor.lightMethodKey == null;
+ addMethodDescriptor(methodInfos, methodDescriptor, methodDescriptor.getLoaderForClass(), methodDescriptor.className);
+ }
+ else {
+ assert methodDescriptor.className == null;
+ addMethodDescriptor(lightMethodInfos, methodDescriptor, methodDescriptor.getLoaderForClass(), methodDescriptor.lightMethodKey);
+ }
}
- }
- processUnnamedDescriptors(lightMethodInfos);
- processUnnamedDescriptors(methodInfos);
+ processUnnamedDescriptors(lightMethodInfos);
+ processUnnamedDescriptors(methodInfos);
- LIGHT_METHOD_INFOS = lightMethodInfos;
- METHOD_INFOS = methodInfos;
+ LIGHT_METHOD_INFOS = lightMethodInfos;
+ METHOD_INFOS = methodInfos;
+ }
}
private static void processUnnamedDescriptors(Map<String, Map<String, List<GroovyMethodInfo>>> map) {
@@ -127,7 +129,7 @@ public class GroovyMethodInfo {
}
}
- public GroovyMethodInfo(GroovyMethodDescriptor method, @NotNull ClassLoader classLoader) {
+ private GroovyMethodInfo(GroovyMethodDescriptor method, @NotNull ClassLoader classLoader) {
myClassLoader = classLoader;
myParams = method.getParams();
myReturnType = method.returnType;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/gpp/GppClassSubstitutor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/gpp/GppClassSubstitutor.java
deleted file mode 100644
index 80a2376de47d..000000000000
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/gpp/GppClassSubstitutor.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package org.jetbrains.plugins.groovy.gpp;
-
-import com.intellij.psi.PsiClass;
-import com.intellij.psi.PsiModifierList;
-import com.intellij.psi.impl.light.LightClass;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.plugins.groovy.GroovyFileType;
-import org.jetbrains.plugins.groovy.lang.psi.GrClassSubstitution;
-import org.jetbrains.plugins.groovy.lang.psi.GrClassSubstitutor;
-
-/**
- * @author peter
- */
-public class GppClassSubstitutor extends GrClassSubstitutor {
-
- @Override
- public GrClassSubstitution substituteClass(@NotNull PsiClass base) {
- final PsiModifierList modifierList = base.getModifierList();
- if (modifierList != null && modifierList.findAnnotation("groovy.lang.Trait") != null) {
- return new TraitClass(base);
- }
- return null;
- }
-
- public static class TraitClass extends LightClass implements GrClassSubstitution {
- public TraitClass(PsiClass base) {
- super(base, GroovyFileType.GROOVY_LANGUAGE);
- }
-
- @Override
- public boolean isInterface() {
- return true;
- }
-
- }
-}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/gpp/GppPositionManager.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/gpp/GppPositionManager.java
deleted file mode 100644
index 5a8d72725975..000000000000
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/gpp/GppPositionManager.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package org.jetbrains.plugins.groovy.gpp;
-
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.psi.JavaPsiFacade;
-import com.intellij.psi.PsiClass;
-import com.intellij.psi.PsiFile;
-import com.intellij.psi.search.GlobalSearchScope;
-import com.sun.jdi.ReferenceType;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.plugins.groovy.extensions.debugger.ScriptPositionManagerHelper;
-import org.jetbrains.plugins.groovy.lang.psi.GrClassSubstitutor;
-import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
-
-/**
- * @author peter
- */
-public class GppPositionManager extends ScriptPositionManagerHelper {
- private static final String TRAIT_IMPL = "$TraitImpl";
-
- @Override
- public boolean isAppropriateRuntimeName(@NotNull String runtimeName) {
- return runtimeName.endsWith(TRAIT_IMPL);
- }
-
- @Override
- public boolean isAppropriateScriptFile(@NotNull PsiFile scriptFile) {
- return false;
- }
-
- @NotNull
- @Override
- public String getRuntimeScriptName(@NotNull String originalName, GroovyFile groovyFile) {
- return originalName;
- }
-
- @Override
- public PsiFile getExtraScriptIfNotFound(ReferenceType refType, @NotNull String runtimeName, Project project, GlobalSearchScope scope) {
- final PsiClass trait =
- JavaPsiFacade.getInstance(project).findClass(StringUtil.trimEnd(runtimeName, TRAIT_IMPL), GlobalSearchScope.allScope(project));
- if (trait != null) {
- return trait.getContainingFile();
- }
- return null;
- }
-
- public String customizeClassName(PsiClass psiClass) {
- if (GrClassSubstitutor.getSubstitutedClass(psiClass) instanceof GppClassSubstitutor.TraitClass) {
- final String qname = psiClass.getQualifiedName();
- if (qname != null) {
- return qname + TRAIT_IMPL;
- }
- }
- return null;
- }
-
-}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/grape/GrabDependencies.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/grape/GrabDependencies.java
index 74c90d84d39e..5512ded5eb86 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/grape/GrabDependencies.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/grape/GrabDependencies.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.
@@ -30,7 +30,6 @@ import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.module.Module;
-import com.intellij.openapi.module.ModuleUtil;
import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
@@ -43,7 +42,6 @@ import com.intellij.openapi.projectRoots.SdkTypeId;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.roots.OrderRootType;
-import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.roots.libraries.LibraryTable;
import com.intellij.openapi.ui.Messages;
@@ -57,14 +55,16 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiRecursiveElementWalkingVisitor;
import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.util.*;
+import com.intellij.util.ExceptionUtil;
+import com.intellij.util.Function;
+import com.intellij.util.IncorrectOperationException;
+import com.intellij.util.PathUtil;
import com.intellij.util.containers.ContainerUtil;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation;
import org.jetbrains.plugins.groovy.runner.DefaultGroovyScriptRunner;
import org.jetbrains.plugins.groovy.runner.GroovyScriptRunConfiguration;
-import org.jetbrains.plugins.groovy.runner.GroovyScriptRunner;
import java.io.File;
import java.net.MalformedURLException;
@@ -119,7 +119,7 @@ public class GrabDependencies implements IntentionAction {
}
public void invoke(@NotNull final Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
- final Module module = ModuleUtil.findModuleForPsiElement(file);
+ final Module module = ModuleUtilCore.findModuleForPsiElement(file);
assert module != null;
final VirtualFile vfile = file.getOriginalFile().getVirtualFile();
@@ -145,23 +145,15 @@ public class GrabDependencies implements IntentionAction {
//debug
//javaParameters.getVMParametersList().add("-Xdebug"); javaParameters.getVMParametersList().add("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5239");
- DefaultGroovyScriptRunner
- .configureGenericGroovyRunner(javaParameters, module, "org.jetbrains.plugins.groovy.grape.GrapeRunner", false);
- PathsList list;
try {
- list = GroovyScriptRunner.getClassPathFromRootModel(module, ProjectRootManager.getInstance(project).getFileIndex().isInTestSourceContent(vfile), javaParameters, true);
+ DefaultGroovyScriptRunner.configureGenericGroovyRunner(javaParameters, module, "org.jetbrains.plugins.groovy.grape.GrapeRunner", false, true);
}
catch (CantRunException e) {
NOTIFICATION_GROUP.createNotification("Can't run @Grab: " + ExceptionUtil.getMessage(e), ExceptionUtil.getThrowableText(e), NotificationType.ERROR, null).notify(project);
return;
}
- if (list == null) {
- list = new PathsList();
- }
- list.add(PathUtil.getJarPathForClass(GrapeRunner.class));
+ javaParameters.getClassPath().add(PathUtil.getJarPathForClass(GrapeRunner.class));
- javaParameters.getProgramParametersList().add("--classpath");
- javaParameters.getProgramParametersList().add(list.getPathsString());
javaParameters.getProgramParametersList().add(queries.get(grabText));
lines.put(grabText, JdkUtil.setupJVMCommandLine(exePath, javaParameters, true));
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/documentation/GroovyDocumentationProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/documentation/GroovyDocumentationProvider.java
index b7bf71027300..d56722d3d56f 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/documentation/GroovyDocumentationProvider.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/documentation/GroovyDocumentationProvider.java
@@ -348,7 +348,7 @@ public class GroovyDocumentationProvider implements CodeDocumentationProvider, E
if (element == null) return null;
- String standard = JavaDocumentationProvider.generateExternalJavadoc(element);
+ String standard = element.getNavigationElement() instanceof PsiDocCommentOwner ? JavaDocumentationProvider.generateExternalJavadoc(element) : null;
if (element instanceof GrVariable &&
((GrVariable)element).getTypeElementGroovy() == null &&
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/GrClassSubstitutor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/GrClassSubstitutor.java
deleted file mode 100644
index c8196595ff3b..000000000000
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/GrClassSubstitutor.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.jetbrains.plugins.groovy.lang.psi;
-
-import com.intellij.openapi.extensions.ExtensionPointName;
-import com.intellij.openapi.extensions.Extensions;
-import com.intellij.openapi.util.Key;
-import com.intellij.psi.PsiClass;
-import com.intellij.psi.util.CachedValue;
-import com.intellij.psi.util.CachedValueProvider;
-import com.intellij.psi.util.CachedValuesManager;
-import com.intellij.psi.util.PsiModificationTracker;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * @author peter
- */
-public abstract class GrClassSubstitutor {
- public static final ExtensionPointName<GrClassSubstitutor> EP_NAME = ExtensionPointName.create("org.intellij.groovy.classSubstitutor");
- private static final Key<CachedValue<PsiClass>> SUBSTITUTED_CLASS_KEY = Key.create("GroovySubstitutedType");
-
- @Nullable
- public abstract GrClassSubstitution substituteClass(@NotNull PsiClass base);
-
- @NotNull
- public static PsiClass getSubstitutedClass(@NotNull final PsiClass base) {
- if (!Extensions.getRootArea().getExtensionPoint(EP_NAME).hasAnyExtensions()) {
- return base;
- }
-
- if (base instanceof GrClassSubstitution) {
- return base;
- }
-
- return CachedValuesManager.getManager(base.getProject())
- .getCachedValue(base, SUBSTITUTED_CLASS_KEY, new CachedValueProvider<PsiClass>() {
- public Result<PsiClass> compute() {
- for (GrClassSubstitutor enhancer : GrClassSubstitutor.EP_NAME.getExtensions()) {
- final PsiClass type = enhancer.substituteClass(base);
- if (type != null) {
- return Result.create(type, PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT);
- }
- }
- return Result.create(base, PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT);
- }
- }, false);
- }
-
-}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/GroovyDeclarationSearcher.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/GroovyDeclarationSearcher.java
deleted file mode 100644
index d3e77699f03b..000000000000
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/GroovyDeclarationSearcher.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.jetbrains.plugins.groovy.lang.psi;
-
-import com.intellij.pom.PomDeclarationSearcher;
-import com.intellij.pom.PomTarget;
-import com.intellij.psi.PsiElement;
-import com.intellij.util.Consumer;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
-
-/**
- * @author peter
- */
-public class GroovyDeclarationSearcher extends PomDeclarationSearcher {
- @Override
- public void findDeclarationsAt(@NotNull PsiElement element, int offsetInElement, Consumer<PomTarget> consumer) {
- if (element instanceof GrTypeDefinition) {
- final PsiElement name = ((GrTypeDefinition)element).getNameIdentifierGroovy();
- if (name.getTextRange().shiftRight(-element.getTextRange().getStartOffset()).contains(offsetInElement)) {
- consumer.consume(GrClassSubstitutor.getSubstitutedClass((GrTypeDefinition)element));
- }
- }
- }
-}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrAnonymousClassType.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrAnonymousClassType.java
index e7db58c891cd..fd6ee28c7e32 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrAnonymousClassType.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrAnonymousClassType.java
@@ -43,7 +43,8 @@ public class GrAnonymousClassType extends GrLiteralClassType {
final GrCodeReferenceElement ref = myAnonymous.getBaseClassReferenceGroovy();
final PsiElement resolved = ref.resolve();
if (resolved instanceof PsiClass) {
- return ((PsiClass)resolved).getQualifiedName();
+ String qname = ((PsiClass)resolved).getQualifiedName();
+ return qname != null ? qname : ((PsiClass)resolved).getName();
}
else {
return ref.getClassNameText();
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyDirectInheritorsSearcher.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyDirectInheritorsSearcher.java
index 36f239b74975..aa31f55c1cee 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyDirectInheritorsSearcher.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyDirectInheritorsSearcher.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.
@@ -27,7 +27,6 @@ import com.intellij.psi.stubs.StubIndex;
import com.intellij.util.Processor;
import com.intellij.util.QueryExecutor;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.plugins.groovy.lang.psi.GrClassSubstitutor;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrAnonymousClassDefinition;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrReferenceList;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
@@ -54,7 +53,7 @@ class GroovyDirectInheritorsSearcher implements QueryExecutor<PsiClass, DirectCl
GrReferenceList.class)) {
final PsiElement parent = list.getParent();
if (parent instanceof GrTypeDefinition) {
- inheritors.add(GrClassSubstitutor.getSubstitutedClass(((GrTypeDefinition)parent)));
+ inheritors.add((PsiClass)parent);
}
}
final Collection<GrAnonymousClassDefinition> classes =
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyResolveResultImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyResolveResultImpl.java
index 59c4bd50b3a1..ee45530f4c18 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyResolveResultImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyResolveResultImpl.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 org.jetbrains.plugins.groovy.lang.psi.impl;
-import com.intellij.psi.*;
+import com.intellij.psi.PsiClassType;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiNamedElement;
+import com.intellij.psi.PsiSubstitutor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import org.jetbrains.plugins.groovy.lang.psi.GrClassSubstitutor;
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
import org.jetbrains.plugins.groovy.lang.psi.api.SpreadState;
@@ -60,7 +62,7 @@ public class GroovyResolveResultImpl implements GroovyResolveResult {
boolean staticsOK,
boolean isInvokedOnProperty) {
myCurrentFileResolveContext = resolveContext;
- myElement = element instanceof PsiClass? GrClassSubstitutor.getSubstitutedClass((PsiClass)element) : element;
+ myElement = element;
myIsAccessible = isAccessible;
mySubstitutor = substitutor;
myIsStaticsOK = staticsOK;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/GrThrowsClauseImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/GrThrowsClauseImpl.java
index 0f85339d3adf..4818023f6f97 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/GrThrowsClauseImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/GrThrowsClauseImpl.java
@@ -17,13 +17,18 @@
package org.jetbrains.plugins.groovy.lang.psi.impl.auxiliary;
import com.intellij.lang.ASTNode;
+import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiClassType;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiJavaCodeReferenceElement;
+import com.intellij.psi.impl.PsiManagerEx;
+import com.intellij.psi.impl.light.LightClassReference;
import com.intellij.util.IncorrectOperationException;
+import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
+import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrThrowsClause;
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
import org.jetbrains.plugins.groovy.lang.psi.impl.GrClassReferenceType;
@@ -52,7 +57,20 @@ public class GrThrowsClauseImpl extends GroovyPsiElementImpl implements GrThrows
@NotNull
public PsiJavaCodeReferenceElement[] getReferenceElements() {
- return PsiJavaCodeReferenceElement.EMPTY_ARRAY;
+ PsiClassType[] types = getReferencedTypes();
+ if (types.length == 0) return PsiJavaCodeReferenceElement.EMPTY_ARRAY;
+
+ PsiManagerEx manager = getManager();
+
+ List<PsiJavaCodeReferenceElement> result = ContainerUtil.newArrayList();
+ for (PsiClassType type : types) {
+ PsiClassType.ClassResolveResult resolveResult = type.resolveGenerics();
+ PsiClass resolved = resolveResult.getElement();
+ if (resolved != null) {
+ result.add(new LightClassReference(manager, type.getCanonicalText(), resolved, resolveResult.getSubstitutor()));
+ }
+ }
+ return result.toArray(new PsiJavaCodeReferenceElement[result.size()]);
}
@NotNull
@@ -77,7 +95,7 @@ public class GrThrowsClauseImpl extends GroovyPsiElementImpl implements GrThrows
@Override
public PsiElement add(@NotNull PsiElement element) throws IncorrectOperationException {
- if (element instanceof GrCodeReferenceElement) {
+ if (element instanceof GrCodeReferenceElement || element instanceof PsiJavaCodeReferenceElement) {
if (findChildByClass(GrCodeReferenceElement.class) == null) {
getNode().addLeaf(GroovyTokenTypes.kTHROWS, "throws", null);
}
@@ -88,6 +106,10 @@ public class GrThrowsClauseImpl extends GroovyPsiElementImpl implements GrThrows
getNode().addLeaf(GroovyTokenTypes.mCOMMA, ",", null);
}
}
+
+ if (element instanceof PsiJavaCodeReferenceElement) {
+ element = GroovyPsiElementFactory.getInstance(getProject()).createCodeReferenceElementFromText(element.getText());
+ }
}
return super.add(element);
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrFinallyClauseImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrFinallyClauseImpl.java
index 3c7ee88fb9ed..c757a80f3aa3 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrFinallyClauseImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrFinallyClauseImpl.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.
@@ -17,6 +17,7 @@ package org.jetbrains.plugins.groovy.lang.psi.impl.statements;
import com.intellij.lang.ASTNode;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrFinallyClause;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock;
@@ -38,9 +39,9 @@ public class GrFinallyClauseImpl extends GroovyPsiElementImpl implements GrFinal
return "Finally clause";
}
- @NotNull
+ @Nullable
public GrOpenBlock getBody() {
- return findNotNullChildByClass(GrOpenBlock.class);
+ return findChildByClass(GrOpenBlock.class);
}
} \ No newline at end of file
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrLightClassReferenceElement.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrLightClassReferenceElement.java
index 021c08d6e8fd..3fa5a2153155 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrLightClassReferenceElement.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrLightClassReferenceElement.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.
@@ -53,7 +53,7 @@ public class GrLightClassReferenceElement extends LightElement implements GrCode
}
public GrLightClassReferenceElement(PsiClass aClass, PsiElement context) {
- this(aClass.getQualifiedName(), aClass.getName(), context);
+ this(aClass.getQualifiedName() != null ? aClass.getQualifiedName() : aClass.getName(), aClass.getName(), context);
}
@Override
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/PsiUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/PsiUtil.java
index 6b3db56de380..05776812df78 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/PsiUtil.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/PsiUtil.java
@@ -157,7 +157,7 @@ public class PsiUtil {
public static boolean isApplicable(@Nullable PsiType[] argumentTypes,
PsiMethod method,
PsiSubstitutor substitutor,
- GroovyPsiElement place,
+ PsiElement place,
final boolean eraseParameterTypes) {
return isApplicableConcrete(argumentTypes, method, substitutor, place, eraseParameterTypes) !=
GrClosureSignatureUtil.ApplicabilityResult.inapplicable;
@@ -166,7 +166,7 @@ public class PsiUtil {
public static GrClosureSignatureUtil.ApplicabilityResult isApplicableConcrete(@Nullable PsiType[] argumentTypes,
PsiMethod method,
PsiSubstitutor substitutor,
- GroovyPsiElement place,
+ PsiElement place,
final boolean eraseParameterTypes) {
if (argumentTypes == null) return GrClosureSignatureUtil.ApplicabilityResult.canBeApplicable;
@@ -348,7 +348,7 @@ public class PsiUtil {
return JavaPsiFacade.getInstance(resolved.getProject()).findClass(CommonClassNames.JAVA_LANG_CLASS, scope);
}
- public static boolean isValidReferenceName(String text) {
+ public static boolean isValidReferenceName(@NotNull String text) {
final GroovyLexer lexer = new GroovyLexer();
lexer.start(text);
return TokenSets.REFERENCE_NAMES_WITHOUT_NUMBERS.contains(lexer.getTokenType()) && lexer.getTokenEnd() == text.length();
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/MethodResolverProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/MethodResolverProcessor.java
index 5e760771d1a0..2a7856527bd9 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/MethodResolverProcessor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/MethodResolverProcessor.java
@@ -106,15 +106,17 @@ public class MethodResolverProcessor extends ResolverProcessor implements GrMeth
if (!myByShape) {
substitutor = mySubstitutorComputer.obtainSubstitutor(substitutor, method, state);
}
- boolean isAccessible = isAccessible(method);
+
PsiElement resolveContext = state.get(RESOLVE_CONTEXT);
final SpreadState spreadState = state.get(SpreadState.SPREAD_STATE);
+ boolean isAccessible = isAccessible(method);
boolean isStaticsOK = isStaticsOK(method, resolveContext, true);
- if (!myAllVariants && isStaticsOK && isAccessible &&
- PsiUtil.isApplicable(myArgumentTypes, method, substitutor, (GroovyPsiElement)myPlace, myByShape)) {
+
+ if (!myAllVariants && isStaticsOK && isAccessible && PsiUtil.isApplicable(myArgumentTypes, method, substitutor, myPlace, myByShape)) {
addCandidate(new GroovyResolveResultImpl(method, resolveContext, spreadState, substitutor, isAccessible, isStaticsOK));
- } else {
+ }
+ else {
myInapplicableCandidates.add(new GroovyResolveResultImpl(method, resolveContext, spreadState, substitutor, isAccessible, isStaticsOK));
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcActionBase.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcActionBase.java
index ef1aa37a8db0..b952f25d5107 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcActionBase.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcActionBase.java
@@ -19,7 +19,7 @@ public abstract class MvcActionBase extends DumbAwareAction {
@Override
public final void actionPerformed(AnActionEvent e) {
Pair<MvcFramework, Module> pair = guessFramework(e);
- if (pair != null && isFrameworkSupported(pair.getFirst())) {
+ if (pair != null && isSupported(pair.getFirst(), pair.getSecond())) {
actionPerformed(e, pair.getSecond(), pair.getFirst());
}
}
@@ -28,6 +28,10 @@ public abstract class MvcActionBase extends DumbAwareAction {
return true;
}
+ protected boolean isSupported(@NotNull MvcFramework framework, @NotNull Module module) {
+ return isFrameworkSupported(framework);
+ }
+
@Nullable
public static Pair<MvcFramework, Module> guessFramework(AnActionEvent event) {
final Module module = event.getData(event.getPlace().equals(ActionPlaces.MAIN_MENU) ? LangDataKeys.MODULE : LangDataKeys.MODULE_CONTEXT);
@@ -74,7 +78,7 @@ public abstract class MvcActionBase extends DumbAwareAction {
public final void update(AnActionEvent event) {
Pair<MvcFramework, Module> pair = guessFramework(event);
- if (pair != null && isFrameworkSupported(pair.getFirst())) {
+ if (pair != null && isSupported(pair.getFirst(), pair.getSecond())) {
event.getPresentation().setVisible(true);
updateView(event, pair.getFirst(), pair.getSecond());
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcFramework.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcFramework.java
index a3ccb230688e..aa0eb3eaca08 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcFramework.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcFramework.java
@@ -468,7 +468,7 @@ public abstract class MvcFramework {
VirtualFile root = findAppRoot(module);
if (root == null) return;
- extractPlugins(module.getProject(), root.findChild(MvcModuleStructureUtil.PLUGINS_DIRECTORY), false, result);
+ extractPlugins(module.getProject(), root.findChild(MvcModuleStructureUtil.PLUGINS_DIRECTORY), refresh, result);
extractPlugins(module.getProject(), MvcModuleStructureUtil.findFile(getCommonPluginsDir(module), refresh), refresh, result);
extractPlugins(module.getProject(), MvcModuleStructureUtil.findFile(getGlobalPluginsDir(module), refresh), refresh, result);
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyChangeContextUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyChangeContextUtil.java
index 83aeabdf0ea6..422b5573c00c 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyChangeContextUtil.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyChangeContextUtil.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.
@@ -25,6 +25,7 @@ import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
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.members.GrAccessorMethod;
+import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
/**
@@ -68,15 +69,11 @@ public class GroovyChangeContextUtil {
}
}
}
- else {
-// final GrClassTypeElement typeElement = (GrClassTypeElement)element;
- final PsiReference ref = element.getReference();
- if (ref != null) {
- final PsiElement resolvedElement = ref.resolve();
- element.putCopyableUserData(KEY_ENCODED, KEY_ENCODED);
- if (resolvedElement instanceof PsiClass && !PsiTreeUtil.isContextAncestor(scope, resolvedElement, false)) {
- element.putCopyableUserData(REF_TO_CLASS, (PsiClass)resolvedElement);
- }
+ else if (element instanceof GrCodeReferenceElement) {
+ final PsiElement resolvedElement = ((GrCodeReferenceElement)element).resolve();
+ element.putCopyableUserData(KEY_ENCODED, KEY_ENCODED);
+ if (resolvedElement instanceof PsiClass && !PsiTreeUtil.isContextAncestor(scope, resolvedElement, false)) {
+ element.putCopyableUserData(REF_TO_CLASS, (PsiClass)resolvedElement);
}
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/CodeBlockGenerator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/CodeBlockGenerator.java
index 0f4ba98e93c6..739c6a9818af 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/CodeBlockGenerator.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/CodeBlockGenerator.java
@@ -106,7 +106,7 @@ public class CodeBlockGenerator extends Generator {
PsiType returnType = context.typeProvider.getReturnType(method);
if (!method.isConstructor() && returnType != PsiType.VOID) {
myExitPoints.addAll(ControlFlowUtils.collectReturns(block));
- shouldInsertReturnNull = !(returnType instanceof PsiPrimitiveType) &&
+ shouldInsertReturnNull = block != null && !(returnType instanceof PsiPrimitiveType) &&
MissingReturnInspection.methodMissesSomeReturns(block,
MissingReturnInspection.ReturnStatus.getReturnStatus(method));
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/GenerationUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/GenerationUtil.java
index 0c38554a6fae..8179b12faa1a 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/GenerationUtil.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/GenerationUtil.java
@@ -28,7 +28,6 @@ import com.intellij.util.containers.HashMap;
import com.intellij.util.containers.hash.HashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import org.jetbrains.plugins.groovy.lang.psi.GrClassSubstitutor;
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
@@ -276,7 +275,7 @@ public class GenerationUtil {
}
final PsiClass psiClass = method.getContainingClass();
- return psiClass != null && GrClassSubstitutor.getSubstitutedClass(psiClass).isInterface();
+ return psiClass != null && psiClass.isInterface();
}
static void writeTypeParameters(StringBuilder text,
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/GroovyToJavaGenerator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/GroovyToJavaGenerator.java
index 4efa71f719ed..d52c64e856c8 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/GroovyToJavaGenerator.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/GroovyToJavaGenerator.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.
@@ -26,7 +26,6 @@ import com.intellij.psi.PsiMethod;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import org.jetbrains.plugins.groovy.lang.psi.GrClassSubstitutor;
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
@@ -85,7 +84,7 @@ public class GroovyToJavaGenerator {
}
for (final GrTypeDefinition typeDefinition : file.getTypeDefinitions()) {
- generateClassStub(GrClassSubstitutor.getSubstitutedClass(typeDefinition), output);
+ generateClassStub(typeDefinition, output);
}
return output;
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/encapsulateFields/GroovyEncapsulateFieldHelper.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/encapsulateFields/GroovyEncapsulateFieldHelper.java
index a2624da97abb..d7be9bf39c54 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/encapsulateFields/GroovyEncapsulateFieldHelper.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/encapsulateFields/GroovyEncapsulateFieldHelper.java
@@ -20,6 +20,7 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.util.PropertyUtil;
+import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.refactoring.encapsulateFields.*;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.VisibilityUtil;
@@ -28,10 +29,12 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.codeInspection.utils.JavaStylePropertiesUtil;
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
+import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.*;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrMethodCallExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
+import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GroovyScriptClass;
import org.jetbrains.plugins.groovy.lang.psi.util.GroovyPropertyUtils;
import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
@@ -92,7 +95,6 @@ public class GroovyEncapsulateFieldHelper extends EncapsulateFieldHelper {
boolean findSet = descriptor.isToEncapsulateSet();
boolean findGet = descriptor.isToEncapsulateGet();
GrReferenceExpression ref = (GrReferenceExpression)reference;
- // [Jeka] to avoid recursion in the field's accessors
if (findGet &&
JavaEncapsulateFieldHelper.isUsedInExistingAccessor(descriptor.getTargetClass(), fieldDescriptor.getGetterPrototype(), ref)) {
return null;
@@ -107,14 +109,14 @@ public class GroovyEncapsulateFieldHelper extends EncapsulateFieldHelper {
if (!findSet || fieldDescriptor.getField().hasModifierProperty(PsiModifier.FINAL)) {
if (!PsiUtil.isAccessedForReading(ref)) return null;
}
- if (!descriptor.isToUseAccessorsWhenAccessible()) {
+ /*if (!descriptor.isToUseAccessorsWhenAccessible()) {
PsiModifierList newModifierList = JavaEncapsulateFieldHelper.createNewModifierList(descriptor);
PsiClass accessObjectClass = getAccessObject(ref);
final PsiResolveHelper helper = JavaPsiFacade.getInstance(((GrReferenceExpression)reference).getProject()).getResolveHelper();
if (helper.isAccessible(fieldDescriptor.getField(), newModifierList, ref, accessObjectClass, null)) {
return null;
}
- }
+ }*/
return new EncapsulateFieldUsageInfo(ref, fieldDescriptor);
}
@@ -134,8 +136,6 @@ public class GroovyEncapsulateFieldHelper extends EncapsulateFieldHelper {
final PsiElement element = usage.getElement();
if (!(element instanceof GrReferenceExpression)) return false;
-
-
final FieldDescriptor fieldDescriptor = usage.getFieldDescriptor();
PsiField field = fieldDescriptor.getField();
boolean processGet = descriptor.isToEncapsulateGet();
@@ -147,6 +147,18 @@ public class GroovyEncapsulateFieldHelper extends EncapsulateFieldHelper {
final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(descriptor.getTargetClass().getProject());
try {
+ if (!descriptor.isToUseAccessorsWhenAccessible()) {
+ PsiModifierList newModifierList = JavaEncapsulateFieldHelper.createNewModifierList(descriptor);
+ PsiClass accessObjectClass = getAccessObject(expr);
+ final PsiResolveHelper helper = JavaPsiFacade.getInstance((expr).getProject()).getResolveHelper();
+ if (helper.isAccessible(fieldDescriptor.getField(), newModifierList, expr, accessObjectClass, null)) {
+ if (expr.resolve() instanceof PsiMethod) {
+ addMemberOperator(expr, field);
+ }
+ return true;
+ }
+ }
+
final PsiElement parent = expr.getParent();
if (parent instanceof GrAssignmentExpression && expr.equals(((GrAssignmentExpression)parent).getLValue())) {
GrAssignmentExpression assignment = (GrAssignmentExpression)parent;
@@ -255,6 +267,41 @@ public class GroovyEncapsulateFieldHelper extends EncapsulateFieldHelper {
return true;
}
+ private static void addMemberOperator(@NotNull GrReferenceExpression ref, @NotNull PsiField field) {
+ GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(ref.getProject());
+
+ GrExpression qualifier = ref.getQualifier();
+ if (qualifier == null) {
+ PsiClass parentClass = PsiTreeUtil.getParentOfType(ref, PsiClass.class);
+ PsiClass containingClass = findContainingClass(ref, field);
+ GrReferenceExpression thisRef = !ref.getManager().areElementsEquivalent(parentClass, containingClass)
+ ? factory.createThisExpression(containingClass)
+ : factory.createThisExpression(null);
+ ref.setQualifier(thisRef);
+ }
+
+ ref.getNode().addLeaf(GroovyTokenTypes.mAT, "@", ref.getDotToken().getNode().getTreeNext());
+ }
+
+ private static PsiClass findContainingClass(@NotNull GrReferenceExpression ref, @NotNull PsiField field) {
+ PsiElement context = ref;
+ while (true) {
+ PsiClass aClass = PsiUtil.getContextClass(context);
+ if (aClass == null) return null;
+
+ PsiManager manager = context.getManager();
+ PsiField found = aClass.findFieldByName(field.getName(), true);
+ if (manager.areElementsEquivalent(found, field)) {
+ return aClass;
+ }
+
+ if (context instanceof GroovyScriptClass) return null;
+ if (context.getParent() instanceof GroovyFile) return null;
+
+ context = aClass.getParent();
+ }
+ }
+
private static boolean checkAccessorsAreSimpleAndFieldIsInaccessible(@NotNull PsiField field,
@Nullable PsiMethod setter,
@Nullable PsiMethod getter,
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/GrIntroduceHandlerBase.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/GrIntroduceHandlerBase.java
index 3411ccfeccf1..fb2a4b2338b9 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/GrIntroduceHandlerBase.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/GrIntroduceHandlerBase.java
@@ -16,11 +16,13 @@
package org.jetbrains.plugins.groovy.refactoring.introduce;
import com.intellij.codeInsight.highlighting.HighlightManager;
+import com.intellij.diagnostic.LogMessageEx;
import com.intellij.lang.LanguageRefactoringSupport;
import com.intellij.lang.refactoring.RefactoringSupportProvider;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.CommandProcessor;
+import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.RangeMarker;
@@ -78,6 +80,8 @@ import static org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil.skipParentheses
* @author Maxim.Medvedev
*/
public abstract class GrIntroduceHandlerBase<Settings extends GrIntroduceSettings, Scope extends PsiElement> implements RefactoringActionHandler {
+ private static final Logger LOG = Logger.getInstance(GrIntroduceHandlerBase.class);
+
public static final Function<GrExpression, String> GR_EXPRESSION_RENDERER = new Function<GrExpression, String>() {
@Override
public String fun(@NotNull GrExpression expr) {
@@ -429,32 +433,37 @@ public abstract class GrIntroduceHandlerBase<Settings extends GrIntroduceSetting
@NotNull final Editor editor,
@NotNull PsiFile file,
int startOffset,
- int endOffset) {
- PsiDocumentManager.getInstance(project).commitAllDocuments();
- if (!(file instanceof GroovyFileBase)) {
- throw new GrRefactoringError(GroovyRefactoringBundle.message("only.in.groovy.files"));
- }
- if (!CommonRefactoringUtil.checkReadOnlyStatus(project, file)) {
- throw new GrRefactoringError(RefactoringBundle.message("readonly.occurences.found"));
- }
+ int endOffset) throws GrRefactoringError {
+ try {
+ PsiDocumentManager.getInstance(project).commitAllDocuments();
+ if (!(file instanceof GroovyFileBase)) {
+ throw new GrRefactoringError(GroovyRefactoringBundle.message("only.in.groovy.files"));
+ }
+ if (!CommonRefactoringUtil.checkReadOnlyStatus(project, file)) {
+ throw new GrRefactoringError(RefactoringBundle.message("readonly.occurences.found"));
+ }
- GrExpression selectedExpr = findExpression(file, startOffset, endOffset);
- final GrVariable variable = findVariable(file, startOffset, endOffset);
- final StringPartInfo stringPart = StringPartInfo.findStringPart(file, startOffset, endOffset);
- if (variable != null) {
- checkVariable(variable);
- }
- else if (selectedExpr != null) {
- checkExpression(selectedExpr);
- }
- else if (stringPart != null) {
- checkStringLiteral(stringPart);
+ GrExpression selectedExpr = findExpression(file, startOffset, endOffset);
+ final GrVariable variable = findVariable(file, startOffset, endOffset);
+ final StringPartInfo stringPart = StringPartInfo.findStringPart(file, startOffset, endOffset);
+ if (variable != null) {
+ checkVariable(variable);
+ }
+ else if (selectedExpr != null) {
+ checkExpression(selectedExpr);
+ }
+ else if (stringPart != null) {
+ checkStringLiteral(stringPart);
+ }
+ else {
+ throw new GrRefactoringError(null);
+ }
+
+ getContextAndInvoke(project, editor, selectedExpr, variable, stringPart);
}
- else {
- throw new GrRefactoringError(null);
+ catch (GrRefactoringError e) {
+ CommonRefactoringUtil.showErrorHint(project, editor, RefactoringBundle.getCannotRefactorMessage(e.getMessage()), getRefactoringName(), getHelpID());
}
-
- getContextAndInvoke(project, editor, selectedExpr, variable, stringPart);
}
public static RangeMarker createRange(Document document, StringPartInfo part) {
@@ -622,6 +631,22 @@ public abstract class GrIntroduceHandlerBase<Settings extends GrIntroduceSetting
return candidate;
}
+ public static void assertStatement(PsiElement anchor, PsiElement[] occurrences, PsiElement scope) {
+ if (!(anchor instanceof GrStatement)) {
+ StringBuilder error = new StringBuilder("scope:");
+ error.append(scope.getText());
+ error.append("\n---------------------------------------\n\n");
+ error.append("occurrences: ");
+ for (PsiElement occurrence : occurrences) {
+ error.append(occurrence.getText());
+ error.append("\n------------------\n");
+ }
+
+ LogMessageEx.error(LOG, "cannot find anchor for variable", error.toString());
+ }
+ }
+
+
@Nullable
private static PsiElement findContainingStatement(@Nullable PsiElement candidate) {
while (candidate != null && !PsiUtil.isExpressionStatement(candidate)) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrIntroduceConstantProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrIntroduceConstantProcessor.java
index 9c90668b544d..2e2f0007350f 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrIntroduceConstantProcessor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrIntroduceConstantProcessor.java
@@ -27,6 +27,7 @@ import com.intellij.util.VisibilityUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.GroovyFileType;
+import org.jetbrains.plugins.groovy.codeStyle.GrReferenceAdjuster;
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariableDeclaration;
@@ -172,7 +173,7 @@ public class GrIntroduceConstantProcessor {
PsiUtil.escalateVisibility(field, replaced);
}
if (replaced instanceof GrReferenceExpression) {
- org.jetbrains.plugins.groovy.codeStyle.GrReferenceAdjuster.shortenReference((GrReferenceExpression)replaced);
+ GrReferenceAdjuster.shortenReference((GrReferenceExpression)replaced);
}
if (isOriginal) {
updateCaretPosition(replaced);
@@ -184,7 +185,7 @@ public class GrIntroduceConstantProcessor {
private static GrReferenceExpression createRefExpression(@NotNull GrField field, @NotNull PsiElement place) {
final PsiClass containingClass = field.getContainingClass();
assert containingClass != null;
- final String refText = containingClass.getQualifiedName() + "." + field.getName();
+ final String refText = containingClass.getQualifiedName() != null ? containingClass.getQualifiedName() + "." + field.getName() : field.getName();
return GroovyPsiElementFactory.getInstance(place.getProject()).createReferenceExpressionFromText(refText, place);
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/field/GrIntroduceFieldProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/field/GrIntroduceFieldProcessor.java
index 3efe8f62e0b6..81da87ba01c7 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/field/GrIntroduceFieldProcessor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/field/GrIntroduceFieldProcessor.java
@@ -191,18 +191,20 @@ public class GrIntroduceFieldProcessor {
null;
assert container != null;
- final GrStatement anchor;
+ final PsiElement anchor;
if (settings.removeLocalVar()) {
GrVariable variable = GrIntroduceHandlerBase.resolveLocalVar(context);
anchor = PsiTreeUtil.getParentOfType(variable, GrStatement.class);
}
else {
- anchor = (GrStatement)GrIntroduceHandlerBase.findAnchor(context.getOccurrences(), container);
+ anchor = GrIntroduceHandlerBase.findAnchor(context.getOccurrences(), container);
+ GrIntroduceHandlerBase.assertStatement(anchor, context.getOccurrences(), context.getScope());
}
- generateAssignment(field, anchor, container);
+ generateAssignment(field, (GrStatement)anchor, container);
}
+
void initializeInConstructor(@NotNull GrVariable field) {
final PsiClass scope = (PsiClass)context.getScope();
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/variable/GrIntroduceLocalVariableProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/variable/GrIntroduceLocalVariableProcessor.java
index 3e3f6888d339..a43356d5dd18 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/variable/GrIntroduceLocalVariableProcessor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/variable/GrIntroduceLocalVariableProcessor.java
@@ -15,7 +15,6 @@
*/
package org.jetbrains.plugins.groovy.refactoring.introduce.variable;
-import com.intellij.diagnostic.LogMessageEx;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiReference;
@@ -209,18 +208,7 @@ public class GrIntroduceLocalVariableProcessor {
@NotNull
private GrStatement getAnchor(PsiElement[] replaced, PsiElement replacedExpression) {
PsiElement anchor = GrIntroduceHandlerBase.findAnchor(replaced, GroovyRefactoringUtil.getEnclosingContainer(replacedExpression));
- if (!(anchor instanceof GrStatement)) {
- StringBuilder error = new StringBuilder("scope:");
- error.append(myContext.getScope());
- error.append("\n---------------------------------------\n\n");
- error.append("occurrences: ");
- for (PsiElement occurrence : myOccurrences) {
- error.append(occurrence);
- error.append("\n------------------\n");
- }
-
- LogMessageEx.error(LOG, "cannot find anchor for variable", error.toString());
- }
+ GrIntroduceHandlerBase.assertStatement(anchor, myOccurrences, myContext.getScope());
return (GrStatement)anchor;
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/DefaultGroovyScriptRunner.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/DefaultGroovyScriptRunner.java
index abf532318f13..dff59a8df2a7 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/DefaultGroovyScriptRunner.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/DefaultGroovyScriptRunner.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.
@@ -66,9 +66,9 @@ public class DefaultGroovyScriptRunner extends GroovyScriptRunner {
@Override
public void configureCommandLine(JavaParameters params, @Nullable Module module, boolean tests, VirtualFile script, GroovyScriptRunConfiguration configuration) throws CantRunException {
- configureGenericGroovyRunner(params, module, "groovy.ui.GroovyMain", false);
+ configureGenericGroovyRunner(params, module, "groovy.ui.GroovyMain", false, tests);
- addClasspathFromRootModel(module, tests, params, true);
+ //addClasspathFromRootModel(module, tests, params, true);
params.getVMParametersList().addParametersString(configuration.getVMParameters());
@@ -82,7 +82,11 @@ public class DefaultGroovyScriptRunner extends GroovyScriptRunner {
params.getProgramParametersList().addParametersString(configuration.getScriptParameters());
}
- public static void configureGenericGroovyRunner(@NotNull JavaParameters params, @NotNull Module module, @NotNull String mainClass, boolean useBundled) {
+ public static void configureGenericGroovyRunner(@NotNull JavaParameters params,
+ @NotNull Module module,
+ @NotNull String mainClass,
+ boolean useBundled,
+ boolean tests) throws CantRunException {
final VirtualFile groovyJar = findGroovyJar(module);
if (useBundled) {
params.getClassPath().add(GroovyUtils.getBundledGroovyJar());
@@ -91,6 +95,8 @@ public class DefaultGroovyScriptRunner extends GroovyScriptRunner {
params.getClassPath().add(groovyJar);
}
+ getClassPathFromRootModel(module, tests, params, true, params.getClassPath());
+
setToolsJar(params);
String groovyHome = useBundled ? FileUtil.toCanonicalPath(GroovyUtils.getBundledGroovyJar().getParentFile().getParent()) : LibrariesUtil.getGroovyHomePath(module);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyScriptRunner.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyScriptRunner.java
index 40f4f8d19838..5c724c2632f0 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyScriptRunner.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyScriptRunner.java
@@ -79,7 +79,7 @@ public abstract class GroovyScriptRunner {
}
}
- protected static void setGroovyHome(JavaParameters params, @NotNull String groovyHome) {
+ public static void setGroovyHome(JavaParameters params, @NotNull String groovyHome) {
params.getVMParametersList().add("-Dgroovy.home=" + groovyHome);
if (groovyHome.contains("grails")) { //a bit of a hack
params.getVMParametersList().add("-Dgrails.home=" + groovyHome);
@@ -118,10 +118,8 @@ public abstract class GroovyScriptRunner {
}
protected static void addClasspathFromRootModel(@Nullable Module module, boolean isTests, JavaParameters params, boolean allowDuplication) throws CantRunException {
- PathsList nonCore = getClassPathFromRootModel(module, isTests, params, allowDuplication);
- if (nonCore == null) {
- nonCore = new PathsList();
- }
+ PathsList nonCore = new PathsList();
+ getClassPathFromRootModel(module, isTests, params, allowDuplication, nonCore);
nonCore.add(".");
final String cp = nonCore.getPathsString();
@@ -132,7 +130,11 @@ public abstract class GroovyScriptRunner {
}
@Nullable
- public static PathsList getClassPathFromRootModel(Module module, boolean isTests, JavaParameters params, boolean allowDuplication)
+ public static PathsList getClassPathFromRootModel(Module module,
+ boolean isTests,
+ JavaParameters params,
+ boolean allowDuplication,
+ PathsList pathList)
throws CantRunException {
if (module == null) {
return null;
@@ -146,12 +148,11 @@ public abstract class GroovyScriptRunner {
Set<VirtualFile> core = new HashSet<VirtualFile>(params.getClassPath().getVirtualFiles());
- PathsList nonCore = new PathsList();
for (VirtualFile virtualFile : tmp.getClassPath().getVirtualFiles()) {
if (allowDuplication || !core.contains(virtualFile)) {
- nonCore.add(virtualFile);
+ pathList.add(virtualFile);
}
}
- return nonCore;
+ return pathList;
}
}